From 15cd1ba0f46e90998a6254232f72683a4bd8ef4e Mon Sep 17 00:00:00 2001 From: budnix <571316+budnix@users.noreply.github.com> Date: Fri, 19 Apr 2019 14:09:25 +0200 Subject: [PATCH] 3.0.1 --- dist/formula-parser.js | 797 ++++++++++++++++++++----------------- dist/formula-parser.min.js | 2 +- package.json | 2 +- 3 files changed, 428 insertions(+), 373 deletions(-) diff --git a/dist/formula-parser.js b/dist/formula-parser.js index 6436aea1..a3ebb468 100644 --- a/dist/formula-parser.js +++ b/dist/formula-parser.js @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 14); +/******/ return __webpack_require__(__webpack_require__.s = 15); /******/ }) /************************************************************************/ /******/ ([ @@ -351,12 +351,12 @@ exports.arrayEach = function(array, iteratee) { }; exports.transpose = function(matrix) { - if(!matrix) { + if(!matrix) { return error.value; } - return matrix[0].map(function(col, i) { - return matrix.map(function(row) { + return matrix[0].map(function(col, i) { + return matrix.map(function(row) { return row[i]; }); }); @@ -469,7 +469,8 @@ function invertNumber(number) { var utils = __webpack_require__(1); var error = __webpack_require__(0); var statistical = __webpack_require__(5); -var information = __webpack_require__(7); +var information = __webpack_require__(8); +var evalExpression = __webpack_require__(7); exports.ABS = function(number) { number = utils.parseNumber(number); @@ -1456,41 +1457,73 @@ exports.SUM = function() { exports.SUMIF = function(range, criteria) { range = utils.parseNumberArray(utils.flatten(range)); + if (range instanceof Error) { return range; } var result = 0; + var isWildcard = criteria === void 0 || criteria === '*'; + var tokenizedCriteria = isWildcard ? null : evalExpression.parse(criteria + ''); + for (var i = 0; i < range.length; i++) { - result += (eval(range[i] + criteria)) ? range[i] : 0; // jshint ignore:line + var value = range[i]; + + if (isWildcard) { + result += value; + } else { + var tokens = [evalExpression.createToken(value, evalExpression.TOKEN_TYPE_LITERAL)].concat(tokenizedCriteria); + + result += (evalExpression.compute(tokens) ? value : 0); + } } + return result; }; exports.SUMIFS = function() { var args = utils.argsToArray(arguments); var range = utils.parseNumberArray(utils.flatten(args.shift())); + if (range instanceof Error) { return range; } - var criteria = args; - + var criterias = args; var n_range_elements = range.length; - var n_criterias = criteria.length; - + var criteriaLength = criterias.length; var result = 0; + for (var i = 0; i < n_range_elements; i++) { - var el = range[i]; - var condition = ''; - for (var c = 0; c < n_criterias; c++) { - condition += el + criteria[c]; - if (c !== n_criterias - 1) { - condition += '&&'; + var value = range[i]; + var isMeetCondition = false; + + for (var j = 0; j < criteriaLength; j++) { + var criteria = criterias[j]; + var isWildcard = criteria === void 0 || criteria === '*'; + var computedResult = false; + + if (isWildcard) { + computedResult = true; + } else { + var tokenizedCriteria = evalExpression.parse(criteria + ''); + var tokens = [evalExpression.createToken(value, evalExpression.TOKEN_TYPE_LITERAL)].concat(tokenizedCriteria); + + computedResult = evalExpression.compute(tokens); + } + + // Criterias are calculated as AND so any `false` breakes the loop as unmeet condition + if (!computedResult) { + isMeetCondition = false; + break; } + + isMeetCondition = true; } - if (eval(condition)) { // jshint ignore:line - result += el; + + if (isMeetCondition) { + result += value; } } + return result; }; @@ -1623,10 +1656,11 @@ exports.TRUNC = function(number, digits) { var mathTrig = __webpack_require__(4); var text = __webpack_require__(6); -var jStat = __webpack_require__(9).jStat; +var jStat = __webpack_require__(10); var utils = __webpack_require__(1); +var evalExpression = __webpack_require__(7); var error = __webpack_require__(0); -var misc = __webpack_require__(10); +var misc = __webpack_require__(11); var SQRT2PI = 2.5066282746310002; @@ -1692,17 +1726,31 @@ exports.AVERAGEIF = function(range, criteria, average_range) { average_range = average_range || range; range = utils.flatten(range); average_range = utils.parseNumberArray(utils.flatten(average_range)); + if (average_range instanceof Error) { return average_range; } var average_count = 0; var result = 0; + var isWildcard = criteria === void 0 || criteria === '*'; + var tokenizedCriteria = isWildcard ? null : evalExpression.parse(criteria + ''); + for (var i = 0; i < range.length; i++) { - if (eval(range[i] + criteria)) { // jshint ignore:line + var value = range[i]; + + if (isWildcard) { result += average_range[i]; average_count++; + } else { + var tokens = [evalExpression.createToken(value, evalExpression.TOKEN_TYPE_LITERAL)].concat(tokenizedCriteria); + + if (evalExpression.compute(tokens)) { + result += average_range[i]; + average_count++; + } } } + return result / average_count; }; @@ -1710,25 +1758,46 @@ exports.AVERAGEIFS = function() { // Does not work with multi dimensional ranges yet! //http://office.microsoft.com/en-001/excel-help/averageifs-function-HA010047493.aspx var args = utils.argsToArray(arguments); - var criteria = (args.length - 1) / 2; + var criteriaLength = (args.length - 1) / 2; var range = utils.flatten(args[0]); var count = 0; var result = 0; + for (var i = 0; i < range.length; i++) { - var condition = ''; - for (var j = 0; j < criteria; j++) { - condition += args[2 * j + 1][i] + args[2 * j + 2]; - if (j !== criteria - 1) { - condition += '&&'; + var isMeetCondition = false; + + for (var j = 0; j < criteriaLength; j++) { + var value = args[2 * j + 1][i]; + var criteria = args[2 * j + 2]; + var isWildcard = criteria === void 0 || criteria === '*'; + var computedResult = false; + + if (isWildcard) { + computedResult = true; + } else { + var tokenizedCriteria = evalExpression.parse(criteria + ''); + var tokens = [evalExpression.createToken(value, evalExpression.TOKEN_TYPE_LITERAL)].concat(tokenizedCriteria); + + computedResult = evalExpression.compute(tokens); } + + // Criterias are calculated as AND so any `false` breakes the loop as unmeet condition + if (!computedResult) { + isMeetCondition = false; + break; + } + + isMeetCondition = true; } - if (eval(condition)) { // jshint ignore:line + + if (isMeetCondition) { result += range[i]; count++; } } var average = result / count; + if (isNaN(average)) { return 0; } else { @@ -2051,41 +2120,48 @@ exports.COUNTBLANK = function() { exports.COUNTIF = function(range, criteria) { range = utils.flatten(range); - if (!/[<>=!]/.test(criteria)) { - criteria = '=="' + criteria + '"'; + + var isWildcard = criteria === void 0 || criteria === '*'; + + if (isWildcard) { + return range.length; } + var matches = 0; + var tokenizedCriteria = evalExpression.parse(criteria + ''); + for (var i = 0; i < range.length; i++) { - if (typeof range[i] !== 'string') { - if (eval(range[i] + criteria)) { // jshint ignore:line - matches++; - } - } else { - if (eval('"' + range[i] + '"' + criteria)) { // jshint ignore:line - matches++; - } + var value = range[i]; + var tokens = [evalExpression.createToken(value, evalExpression.TOKEN_TYPE_LITERAL)].concat(tokenizedCriteria); + + if (evalExpression.compute(tokens)) { + matches++; } } + return matches; }; exports.COUNTIFS = function() { var args = utils.argsToArray(arguments); var results = new Array(utils.flatten(args[0]).length); + for (var i = 0; i < results.length; i++) { results[i] = true; } for (i = 0; i < args.length; i += 2) { var range = utils.flatten(args[i]); var criteria = args[i + 1]; - if (!/[<>=!]/.test(criteria)) { - criteria = '=="' + criteria + '"'; - } - for (var j = 0; j < range.length; j++) { - if (typeof range[j] !== 'string') { - results[j] = results[j] && eval(range[j] + criteria); // jshint ignore:line - } else { - results[j] = results[j] && eval('"' + range[j] + '"' + criteria); // jshint ignore:line + var isWildcard = criteria === void 0 || criteria === '*'; + + if (!isWildcard) { + var tokenizedCriteria = evalExpression.parse(criteria + ''); + + for (var j = 0; j < range.length; j++) { + var value = range[j]; + var tokens = [evalExpression.createToken(value, evalExpression.TOKEN_TYPE_LITERAL)].concat(tokenizedCriteria); + + results[j] = results[j] && evalExpression.compute(tokens); } } } @@ -2095,6 +2171,7 @@ exports.COUNTIFS = function() { result++; } } + return result; }; @@ -3730,6 +3807,202 @@ exports.VALUE = function() { /***/ }), /* 7 */ +/***/ (function(module, exports) { + +var defaultOperator = '='; +var validSymbols = ['>', '>=', '<', '<=', '=', '<>']; +var TOKEN_TYPE_OPERATOR = 'operator'; +var TOKEN_TYPE_LITERAL = 'literal'; +var SUPPORTED_TOKENS = [TOKEN_TYPE_OPERATOR, TOKEN_TYPE_LITERAL]; + +exports.TOKEN_TYPE_OPERATOR = TOKEN_TYPE_OPERATOR; +exports.TOKEN_TYPE_LITERAL = TOKEN_TYPE_LITERAL; + +/** + * Create token which describe passed symbol/value. + * + * @param {String} value Value/Symbol to describe. + * @param {String} type Type of the token 'operator' or 'literal'. + * @return {Object} + */ +function createToken(value, type) { + if (SUPPORTED_TOKENS.indexOf(type) === -1) { + throw new Error('Unsupported token type: ' + type); + } + + return { + value: value, + type: type, + }; +} + +/** + * Tries to cast numeric values to their type passed as a string. + * + * @param {*} value + * @return {*} + */ +function castValueToCorrectType(value) { + if (typeof value !== 'string') { + return value; + } + + if (/^\d+(\.\d+)?$/.test(value)) { + value = value.indexOf('.') === -1 ? parseInt(value, 10) : parseFloat(value); + } + + return value; +} + +/** + * Generate stream of tokens from passed expression. + * + * @param {String} expression + * @return {String[]} + */ +function tokenizeExpression(expression) { + var expressionLength = expression.length; + var tokens = []; + var cursorIndex = 0; + var processedValue = ''; + var processedSymbol = ''; + + while (cursorIndex < expressionLength) { + var char = expression.charAt(cursorIndex); + + switch (char) { + case '>': + case '<': + case '=': + processedSymbol = processedSymbol + char; + + if (processedValue.length > 0) { + tokens.push(processedValue); + processedValue = ''; + } + break; + default: + if (processedSymbol.length > 0) { + tokens.push(processedSymbol); + processedSymbol = ''; + } + + processedValue = processedValue + char; + break; + } + cursorIndex++; + } + + if (processedValue.length > 0) { + tokens.push(processedValue); + } + if (processedSymbol.length > 0) { + tokens.push(processedSymbol); + } + + return tokens; +}; + +/** + * Analyze and convert tokens to an object which describes their meaning. + * + * @param {String[]} tokens + * @return {Object[]} + */ +function analyzeTokens(tokens) { + var literalValue = ''; + var analyzedTokens = []; + + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + + if (i === 0 && validSymbols.indexOf(token) >= 0) { + analyzedTokens.push(createToken(token, TOKEN_TYPE_OPERATOR)); + } else { + literalValue += token; + } + } + + if (literalValue.length > 0) { + analyzedTokens.push(createToken(castValueToCorrectType(literalValue), TOKEN_TYPE_LITERAL)); + } + + if (analyzedTokens.length > 0 && analyzedTokens[0].type !== TOKEN_TYPE_OPERATOR) { + analyzedTokens.unshift(createToken(defaultOperator, TOKEN_TYPE_OPERATOR)); + } + + return analyzedTokens; +}; + +/** + * Compute/Evaluate an expression passed as an array of tokens. + * + * @param {Object[]} tokens + * @return {Boolean} + */ +function computeExpression(tokens) { + var values = []; + var operator; + + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + + switch (token.type) { + case TOKEN_TYPE_OPERATOR: + operator = token.value; + break; + case TOKEN_TYPE_LITERAL: + values.push(token.value); + break; + } + } + + return evaluate(values, operator); +}; + +/** + * Evaluate values based on passed math operator. + * + * @param {*} values + * @param {String} operator + * @return {Boolean} + */ +function evaluate(values, operator) { + var result = false; + + switch (operator) { + case '>': + result = values[0] > values[1]; + break; + case '>=': + result = values[0] >= values[1]; + break; + case '<': + result = values[0] < values[1]; + break; + case '<=': + result = values[0] <= values[1]; + break; + case '=': + result = values[0] == values[1]; + break; + case '<>': + result = values[0] != values[1]; + break; + } + + return result; +} + +exports.parse = function(expression) { + return analyzeTokens(tokenizeExpression(expression)); +}; +exports.createToken = createToken; +exports.compute = computeExpression; + + +/***/ }), +/* 8 */ /***/ (function(module, exports, __webpack_require__) { var error = __webpack_require__(0); @@ -3868,7 +4141,7 @@ exports.TYPE = function(value) { /***/ }), -/* 8 */ +/* 9 */ /***/ (function(module, exports, __webpack_require__) { var error = __webpack_require__(0); @@ -4432,18 +4705,20 @@ function serial(date) { /***/ }), -/* 9 */ +/* 10 */ /***/ (function(module, exports, __webpack_require__) { (function (window, factory) { if (true) { module.exports = factory(); } else if (typeof define === 'function' && define.amd) { - define(factory); + define('jstat', factory); + } else if(typeof exports === 'object') { + exports['jstat'] = factory(); } else { - window.jStat = factory(); + window['jstat'] = factory(); } -})(this, function () { +})(typeof self !== 'undefined' ? self : this, function () { var jStat = (function(Math, undefined) { // For quick reference. @@ -5110,8 +5385,9 @@ jProto.alter = function alter(func) { // Extend prototype with simple shortcut methods. (function(funcs) { for (var i = 0; i < funcs.length; i++) (function(passfunc) { - jProto[passfunc] = new Function( - 'return jStat(jStat.' + passfunc + '.apply(null, arguments));'); + jProto[passfunc] = function() { + return jStat(jStat[passfunc].apply(null, arguments)); + }; })(funcs[i]); })('create zeros ones rand identity'.split(' ')); @@ -9127,15 +9403,12 @@ jStat.models = (function(){ return { ols: ols_wrap }; })(); - // Make it compatible with previous version. - jStat.jStat = jStat; - return jStat; }); /***/ }), -/* 10 */ +/* 11 */ /***/ (function(module, exports, __webpack_require__) { var utils = __webpack_require__(1); @@ -9199,15 +9472,16 @@ exports.NUMBERS = function () { }); }; + /***/ }), -/* 11 */ +/* 12 */ /***/ (function(module, exports, __webpack_require__) { var error = __webpack_require__(0); -var jStat = __webpack_require__(9).jStat; +var jStat = __webpack_require__(10); var text = __webpack_require__(6); var utils = __webpack_require__(1); -var bessel = __webpack_require__(25); +var bessel = __webpack_require__(26); function isValidBinaryNumber(number) { return (/^[01]{1,10}$/).test(number); @@ -10768,7 +11042,7 @@ exports.OCT2HEX = function(number, places) { /***/ }), -/* 12 */ +/* 13 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10780,7 +11054,7 @@ var SUPPORTED_FORMULAS = ['ABS', 'ACCRINT', 'ACOS', 'ACOSH', 'ACOT', 'ACOTH', 'A exports['default'] = SUPPORTED_FORMULAS; /***/ }), -/* 13 */ +/* 14 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10913,7 +11187,7 @@ function toLabel(row, column) { } /***/ }), -/* 14 */ +/* 15 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10922,11 +11196,11 @@ function toLabel(row, column) { exports.__esModule = true; exports.rowLabelToIndex = exports.rowIndexToLabel = exports.columnLabelToIndex = exports.columnIndexToLabel = exports.toLabel = exports.extractLabel = exports.error = exports.Parser = exports.ERROR_VALUE = exports.ERROR_REF = exports.ERROR_NUM = exports.ERROR_NULL = exports.ERROR_NOT_AVAILABLE = exports.ERROR_NAME = exports.ERROR_DIV_ZERO = exports.ERROR = exports.SUPPORTED_FORMULAS = undefined; -var _parser = __webpack_require__(15); +var _parser = __webpack_require__(16); var _parser2 = _interopRequireDefault(_parser); -var _supportedFormulas = __webpack_require__(12); +var _supportedFormulas = __webpack_require__(13); var _supportedFormulas2 = _interopRequireDefault(_supportedFormulas); @@ -10934,7 +11208,7 @@ var _error = __webpack_require__(2); var _error2 = _interopRequireDefault(_error); -var _cell = __webpack_require__(13); +var _cell = __webpack_require__(14); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -10957,7 +11231,7 @@ exports.rowIndexToLabel = _cell.rowIndexToLabel; exports.rowLabelToIndex = _cell.rowLabelToIndex; /***/ }), -/* 15 */ +/* 16 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10965,17 +11239,17 @@ exports.rowLabelToIndex = _cell.rowLabelToIndex; exports.__esModule = true; -var _tinyEmitter = __webpack_require__(16); +var _tinyEmitter = __webpack_require__(17); var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter); -var _evaluateByOperator = __webpack_require__(17); +var _evaluateByOperator = __webpack_require__(18); var _evaluateByOperator2 = _interopRequireDefault(_evaluateByOperator); -var _grammarParser = __webpack_require__(38); +var _grammarParser = __webpack_require__(39); -var _string = __webpack_require__(41); +var _string = __webpack_require__(40); var _number = __webpack_require__(3); @@ -10983,7 +11257,7 @@ var _error = __webpack_require__(2); var _error2 = _interopRequireDefault(_error); -var _cell = __webpack_require__(13); +var _cell = __webpack_require__(14); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -11283,7 +11557,7 @@ var Parser = function (_Emitter) { exports['default'] = Parser; /***/ }), -/* 16 */ +/* 17 */ /***/ (function(module, exports) { function E () { @@ -11355,7 +11629,7 @@ module.exports = E; /***/ }), -/* 17 */ +/* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11365,55 +11639,55 @@ exports.__esModule = true; exports['default'] = evaluateByOperator; exports.registerOperation = registerOperation; -var _add = __webpack_require__(18); +var _add = __webpack_require__(19); var _add2 = _interopRequireDefault(_add); -var _ampersand = __webpack_require__(19); +var _ampersand = __webpack_require__(20); var _ampersand2 = _interopRequireDefault(_ampersand); -var _divide = __webpack_require__(20); +var _divide = __webpack_require__(21); var _divide2 = _interopRequireDefault(_divide); -var _equal = __webpack_require__(21); +var _equal = __webpack_require__(22); var _equal2 = _interopRequireDefault(_equal); -var _formulaFunction = __webpack_require__(22); +var _formulaFunction = __webpack_require__(23); var _formulaFunction2 = _interopRequireDefault(_formulaFunction); -var _greaterThan = __webpack_require__(30); +var _greaterThan = __webpack_require__(31); var _greaterThan2 = _interopRequireDefault(_greaterThan); -var _greaterThanOrEqual = __webpack_require__(31); +var _greaterThanOrEqual = __webpack_require__(32); var _greaterThanOrEqual2 = _interopRequireDefault(_greaterThanOrEqual); -var _lessThan = __webpack_require__(32); +var _lessThan = __webpack_require__(33); var _lessThan2 = _interopRequireDefault(_lessThan); -var _lessThanOrEqual = __webpack_require__(33); +var _lessThanOrEqual = __webpack_require__(34); var _lessThanOrEqual2 = _interopRequireDefault(_lessThanOrEqual); -var _minus = __webpack_require__(34); +var _minus = __webpack_require__(35); var _minus2 = _interopRequireDefault(_minus); -var _multiply = __webpack_require__(35); +var _multiply = __webpack_require__(36); var _multiply2 = _interopRequireDefault(_multiply); -var _notEqual = __webpack_require__(36); +var _notEqual = __webpack_require__(37); var _notEqual2 = _interopRequireDefault(_notEqual); -var _power = __webpack_require__(37); +var _power = __webpack_require__(38); var _power2 = _interopRequireDefault(_power); @@ -11477,7 +11751,7 @@ registerOperation(_notEqual2['default'].SYMBOL, _notEqual2['default']); registerOperation(_minus2['default'].SYMBOL, _minus2['default']); /***/ }), -/* 18 */ +/* 19 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11512,7 +11786,7 @@ function func(first) { func.SYMBOL = SYMBOL; /***/ }), -/* 19 */ +/* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11535,7 +11809,7 @@ function func() { func.SYMBOL = SYMBOL; /***/ }), -/* 20 */ +/* 21 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11573,7 +11847,7 @@ function func(first) { func.SYMBOL = SYMBOL; /***/ }), -/* 21 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11590,7 +11864,7 @@ function func(exp1, exp2) { func.SYMBOL = SYMBOL; /***/ }), -/* 22 */ +/* 23 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11600,11 +11874,11 @@ exports.__esModule = true; exports.SYMBOL = undefined; exports['default'] = func; -var _formulajs = __webpack_require__(23); +var _formulajs = __webpack_require__(24); var formulajs = _interopRequireWildcard(_formulajs); -var _supportedFormulas = __webpack_require__(12); +var _supportedFormulas = __webpack_require__(13); var _supportedFormulas2 = _interopRequireDefault(_supportedFormulas); @@ -11661,22 +11935,22 @@ func.isFactory = true; func.SYMBOL = SYMBOL; /***/ }), -/* 23 */ +/* 24 */ /***/ (function(module, exports, __webpack_require__) { var categories = [ - __webpack_require__(24), - __webpack_require__(26), - __webpack_require__(11), + __webpack_require__(25), __webpack_require__(27), + __webpack_require__(12), + __webpack_require__(28), __webpack_require__(4), __webpack_require__(6), - __webpack_require__(8), - __webpack_require__(28), - __webpack_require__(7), + __webpack_require__(9), __webpack_require__(29), + __webpack_require__(8), + __webpack_require__(30), __webpack_require__(5), - __webpack_require__(10) + __webpack_require__(11) ]; for (var c in categories) { @@ -11688,13 +11962,13 @@ for (var c in categories) { /***/ }), -/* 24 */ +/* 25 */ /***/ (function(module, exports, __webpack_require__) { var mathTrig = __webpack_require__(4); var statistical = __webpack_require__(5); -var engineering = __webpack_require__(11); -var dateTime = __webpack_require__(8); +var engineering = __webpack_require__(12); +var dateTime = __webpack_require__(9); function set(fn, root) { if (root) { @@ -11781,7 +12055,7 @@ exports.ZTEST = statistical.Z.TEST; /***/ }), -/* 25 */ +/* 26 */ /***/ (function(module, exports, __webpack_require__) { var M = Math; @@ -11996,13 +12270,14 @@ if(true) { /***/ }), -/* 26 */ +/* 27 */ /***/ (function(module, exports, __webpack_require__) { var error = __webpack_require__(0); var stats = __webpack_require__(5); var maths = __webpack_require__(4); var utils = __webpack_require__(1); +var evalExpression = __webpack_require__(7); function compact(array) { var result = []; @@ -12062,7 +12337,18 @@ function findResultIndex(database, criterias) { } hasMatchingCriteria = true; for (var p = 1; p < criteria.length; ++p) { - currentCriteriaResult = currentCriteriaResult || eval(database[k][l] + criteria[p]); // jshint ignore:line + if (!currentCriteriaResult) { + var isWildcard = criteria[p] === void 0 || criteria[p] === '*'; + + if (isWildcard) { + currentCriteriaResult = true; + } else { + var tokenizedCriteria = evalExpression.parse(criteria[p] + ''); + var tokens = [evalExpression.createToken(database[k][l], evalExpression.TOKEN_TYPE_LITERAL)].concat(tokenizedCriteria); + + currentCriteriaResult = evalExpression.compute(tokens); + } + } } } if (hasMatchingCriteria) { @@ -12389,12 +12675,12 @@ exports.DVARP = function(database, field, criteria) { /***/ }), -/* 27 */ +/* 28 */ /***/ (function(module, exports, __webpack_require__) { var error = __webpack_require__(0); var utils = __webpack_require__(1); -var information = __webpack_require__(7); +var information = __webpack_require__(8); exports.AND = function() { var args = utils.flatten(arguments); @@ -12506,11 +12792,11 @@ exports.SWITCH = function () { /***/ }), -/* 28 */ +/* 29 */ /***/ (function(module, exports, __webpack_require__) { var error = __webpack_require__(0); -var dateTime = __webpack_require__(8); +var dateTime = __webpack_require__(9); var utils = __webpack_require__(1); function validDate(d) { @@ -13602,7 +13888,7 @@ exports.YIELDMAT = function() { /***/ }), -/* 29 */ +/* 30 */ /***/ (function(module, exports, __webpack_require__) { var error = __webpack_require__(0); @@ -13683,7 +13969,7 @@ exports.VLOOKUP = function (needle, table, index, rangeLookup) { } return error.na; -}; +}; exports.HLOOKUP = function (needle, table, index, rangeLookup) { if (!needle || !table || !index) { @@ -13708,7 +13994,7 @@ exports.HLOOKUP = function (needle, table, index, rangeLookup) { /***/ }), -/* 30 */ +/* 31 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -13725,7 +14011,7 @@ function func(exp1, exp2) { func.SYMBOL = SYMBOL; /***/ }), -/* 31 */ +/* 32 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -13742,7 +14028,7 @@ function func(exp1, exp2) { func.SYMBOL = SYMBOL; /***/ }), -/* 32 */ +/* 33 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -13759,7 +14045,7 @@ function func(exp1, exp2) { func.SYMBOL = SYMBOL; /***/ }), -/* 33 */ +/* 34 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -13776,7 +14062,7 @@ function func(exp1, exp2) { func.SYMBOL = SYMBOL; /***/ }), -/* 34 */ +/* 35 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -13811,7 +14097,7 @@ function func(first) { func.SYMBOL = SYMBOL; /***/ }), -/* 35 */ +/* 36 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -13846,7 +14132,7 @@ function func(first) { func.SYMBOL = SYMBOL; /***/ }), -/* 36 */ +/* 37 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -13863,7 +14149,7 @@ function func(exp1, exp2) { func.SYMBOL = SYMBOL; /***/ }), -/* 37 */ +/* 38 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -13892,10 +14178,10 @@ function func(exp1, exp2) { func.SYMBOL = SYMBOL; /***/ }), -/* 38 */ +/* 39 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(module, process) {/* parser generated by jison 0.4.17 */ +/* parser generated by jison 0.4.18 */ /* Returns a Parser object of the following structure: @@ -13970,7 +14256,7 @@ func.SYMBOL = SYMBOL; */ var grammarParser = (function(){ var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,5],$V1=[1,8],$V2=[1,6],$V3=[1,7],$V4=[1,9],$V5=[1,14],$V6=[1,15],$V7=[1,16],$V8=[1,12],$V9=[1,13],$Va=[1,17],$Vb=[1,19],$Vc=[1,20],$Vd=[1,21],$Ve=[1,22],$Vf=[1,23],$Vg=[1,24],$Vh=[1,25],$Vi=[1,26],$Vj=[1,27],$Vk=[1,28],$Vl=[5,9,10,11,13,14,15,16,17,18,19,20,29,30],$Vm=[5,9,10,11,13,14,15,16,17,18,19,20,29,30,32],$Vn=[5,9,10,11,13,14,15,16,17,18,19,20,29,30,34],$Vo=[5,10,11,13,14,15,16,17,29,30],$Vp=[5,10,13,14,15,16,29,30],$Vq=[5,10,11,13,14,15,16,17,18,19,29,30],$Vr=[13,29,30]; -var parser = {trace: function trace() { }, +var parser = {trace: function trace () { }, yy: {}, symbols_: {"error":2,"expressions":3,"expression":4,"EOF":5,"variableSequence":6,"number":7,"STRING":8,"&":9,"=":10,"+":11,"(":12,")":13,"<":14,">":15,"NOT":16,"-":17,"*":18,"/":19,"^":20,"FUNCTION":21,"expseq":22,"cell":23,"ABSOLUTE_CELL":24,"RELATIVE_CELL":25,"MIXED_CELL":26,":":27,"ARRAY":28,";":29,",":30,"VARIABLE":31,"DECIMAL":32,"NUMBER":33,"%":34,"ERROR":35,"$accept":0,"$end":1}, terminals_: {5:"EOF",8:"STRING",9:"&",10:"=",11:"+",12:"(",13:")",14:"<",15:">",16:"NOT",17:"-",18:"*",19:"/",20:"^",21:"FUNCTION",24:"ABSOLUTE_CELL",25:"RELATIVE_CELL",26:"MIXED_CELL",27:":",28:"ARRAY",29:";",30:",",31:"VARIABLE",32:"DECIMAL",33:"NUMBER",34:"%",35:"ERROR"}, @@ -14119,14 +14405,7 @@ case 38: case 42: break; case 39: - var result = []; - var arr = eval("[" + yytext + "]"); - - arr.forEach(function(item) { - result.push(item); - }); - - this.$ = result; + this.$ = yy.trimEdges(yytext).split(','); break; case 40: case 41: @@ -14165,20 +14444,16 @@ break; }, table: [{2:11,3:1,4:2,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{1:[3]},{5:[1,18],9:$Vb,10:$Vc,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk},o($Vl,[2,2],{32:[1,29]}),o($Vl,[2,3],{34:[1,30]}),o($Vl,[2,4]),{2:11,4:31,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:32,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:33,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{12:[1,34]},o($Vl,[2,23]),o($Vl,[2,24],{2:35,35:$Va}),o($Vm,[2,42]),o($Vn,[2,44],{32:[1,36]}),o($Vl,[2,26],{27:[1,37]}),o($Vl,[2,27],{27:[1,38]}),o($Vl,[2,28],{27:[1,39]}),o([5,9,10,11,13,14,15,16,17,18,19,20,29,30,35],[2,47]),{1:[2,1]},{2:11,4:40,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:41,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:42,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:45,6:3,7:4,8:$V0,10:[1,43],11:$V1,12:$V2,15:[1,44],17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:47,6:3,7:4,8:$V0,10:[1,46],11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:48,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:49,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:50,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:51,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:52,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{31:[1,53]},o($Vn,[2,46]),{9:$Vb,10:$Vc,11:$Vd,13:[1,54],14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk},o($Vo,[2,19],{9:$Vb,18:$Vi,19:$Vj,20:$Vk}),o($Vo,[2,20],{9:$Vb,18:$Vi,19:$Vj,20:$Vk}),{2:11,4:57,6:3,7:4,8:$V0,11:$V1,12:$V2,13:[1,55],17:$V3,21:$V4,22:56,23:10,24:$V5,25:$V6,26:$V7,28:[1,58],31:$V8,33:$V9,35:$Va},o($Vl,[2,25]),{33:[1,59]},{24:[1,60],25:[1,61],26:[1,62]},{24:[1,63],25:[1,64],26:[1,65]},{24:[1,66],25:[1,67],26:[1,68]},o($Vl,[2,5]),o([5,10,13,29,30],[2,6],{9:$Vb,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vo,[2,7],{9:$Vb,18:$Vi,19:$Vj,20:$Vk}),{2:11,4:69,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:70,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},o($Vp,[2,14],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),{2:11,4:71,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},o($Vp,[2,13],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o([5,10,13,16,29,30],[2,12],{9:$Vb,11:$Vd,14:$Ve,15:$Vf,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vo,[2,15],{9:$Vb,18:$Vi,19:$Vj,20:$Vk}),o($Vq,[2,16],{9:$Vb,20:$Vk}),o($Vq,[2,17],{9:$Vb,20:$Vk}),o([5,10,11,13,14,15,16,17,18,19,20,29,30],[2,18],{9:$Vb}),o($Vm,[2,43]),o($Vl,[2,8]),o($Vl,[2,21]),{13:[1,72],29:[1,73],30:[1,74]},o($Vr,[2,38],{9:$Vb,10:$Vc,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vr,[2,39]),o($Vn,[2,45]),o($Vl,[2,29]),o($Vl,[2,30]),o($Vl,[2,31]),o($Vl,[2,32]),o($Vl,[2,33]),o($Vl,[2,34]),o($Vl,[2,35]),o($Vl,[2,36]),o($Vl,[2,37]),o($Vp,[2,9],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vp,[2,11],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vp,[2,10],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vl,[2,22]),{2:11,4:75,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:76,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},o($Vr,[2,40],{9:$Vb,10:$Vc,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vr,[2,41],{9:$Vb,10:$Vc,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk})], defaultActions: {18:[2,1]}, -parseError: function parseError(str, hash) { +parseError: function parseError (str, hash) { if (hash.recoverable) { this.trace(str); } else { - function _parseError (msg, hash) { - this.message = msg; - this.hash = hash; - } - _parseError.prototype = Error; - - throw new _parseError(str, hash); + var error = new Error(str); + error.hash = hash; + throw error; } }, -parse: function parse(input) { +parse: function parse (input) { var self = this, stack = [0], tstack = [], // token stack @@ -14228,6 +14503,7 @@ parse: function parse(input) { lstack.length = lstack.length - n; } +_token_stack: var lex = function () { var token; token = lexer.lex() || EOF; @@ -14254,6 +14530,7 @@ parse: function parse(input) { action = table[state] && table[state][symbol]; } +_handle_error: // handle parse error if (typeof action === 'undefined' || !action.length || !action[0]) { var error_rule_depth; @@ -14557,7 +14834,7 @@ showPosition:function () { }, // test the lexed token: return FALSE when not a match, otherwise return token -test_match:function (match, indexed_rule) { +test_match:function(match, indexed_rule) { var token, lines, backup; @@ -14687,7 +14964,7 @@ next:function () { }, // return next match that has a token -lex:function lex() { +lex:function lex () { var r = this.next(); if (r) { return r; @@ -14697,12 +14974,12 @@ lex:function lex() { }, // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) -begin:function begin(condition) { +begin:function begin (condition) { this.conditionStack.push(condition); }, // pop the previously active lexer condition state off the condition stack -popState:function popState() { +popState:function popState () { var n = this.conditionStack.length - 1; if (n > 0) { return this.conditionStack.pop(); @@ -14712,7 +14989,7 @@ popState:function popState() { }, // produce the lexer rule set which is active for the currently active lexer condition state -_currentRules:function _currentRules() { +_currentRules:function _currentRules () { if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; } else { @@ -14721,7 +14998,7 @@ _currentRules:function _currentRules() { }, // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available -topState:function topState(n) { +topState:function topState (n) { n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; @@ -14731,7 +15008,7 @@ topState:function topState(n) { }, // alias for begin(condition) -pushState:function pushState(condition) { +pushState:function pushState (condition) { this.begin(condition); }, @@ -14837,233 +15114,11 @@ if (true) { exports.parser = grammarParser; exports.Parser = grammarParser.Parser; exports.parse = function () { return grammarParser.parse.apply(grammarParser, arguments); }; -if (typeof module !== 'undefined' && __webpack_require__.c[__webpack_require__.s] === module) { - exports.main(process.argv.slice(1)); -} } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(39)(module), __webpack_require__(40))) - -/***/ }), -/* 39 */ -/***/ (function(module, exports) { - -module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if(!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - get: function() { - return module.l; - } - }); - Object.defineProperty(module, "id", { - enumerable: true, - get: function() { - return module.i; - } - }); - module.webpackPolyfill = 1; - } - return module; -}; - /***/ }), /* 40 */ -/***/ (function(module, exports) { - -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - - -/***/ }), -/* 41 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; diff --git a/dist/formula-parser.min.js b/dist/formula-parser.min.js index 593b63b2..f3cdd5d4 100644 --- a/dist/formula-parser.min.js +++ b/dist/formula-parser.min.js @@ -1 +1 @@ -!function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.formulaParser=t():r.formulaParser=t()}("undefined"!=typeof self?self:this,function(){return function(r){function t(n){if(e[n])return e[n].exports;var a=e[n]={i:n,l:!1,exports:{}};return r[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var e={};return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{configurable:!1,enumerable:!0,get:n})},t.n=function(r){var e=r&&r.__esModule?function(){return r["default"]}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},t.p="",t(t.s=14)}([function(r,t){t.nil=Error("#NULL!"),t.div0=Error("#DIV/0!"),t.value=Error("#VALUE!"),t.ref=Error("#REF!"),t.name=Error("#NAME?"),t.num=Error("#NUM!"),t.na=Error("#N/A"),t.error=Error("#ERROR!"),t.data=Error("#GETTING_DATA")},function(r,t,e){var n=e(0);t.flattenShallow=function(r){return r&&r.reduce?r.reduce(function(r,t){var e=Array.isArray(r),n=Array.isArray(t);return e&&n?r.concat(t):e?(r.push(t),r):n?[r].concat(t):[r,t]}):r},t.isFlat=function(r){if(!r)return!1;for(var t=0;r.length>t;++t)if(Array.isArray(r[t]))return!1;return!0},t.flatten=function(){for(var r=t.argsToArray.apply(null,arguments);!t.isFlat(r);)r=t.flattenShallow(r);return r},t.argsToArray=function(r){var e=[];return t.arrayEach(r,function(r){e.push(r)}),e},t.numbers=function(){return this.flatten.apply(null,arguments).filter(function(r){return"number"==typeof r})},t.cleanFloat=function(r){return Math.round(1e14*r)/1e14},t.parseBool=function(r){if("boolean"==typeof r)return r;if(r instanceof Error)return r;if("number"==typeof r)return 0!==r;if("string"==typeof r){var t=r.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1}return r instanceof Date&&!isNaN(r)||n.value},t.parseNumber=function(r){return r===undefined||""===r?n.value:isNaN(r)?n.value:parseFloat(r)},t.parseNumberArray=function(r){var e;if(!r||0===(e=r.length))return n.value;for(var a;e--;){if((a=t.parseNumber(r[e]))===n.value)return a;r[e]=a}return r},t.parseMatrix=function(r){if(!r||0===r.length)return n.value;for(var e,a=0;r.length>a;a++)if(e=t.parseNumberArray(r[a]),r[a]=e,e instanceof Error)return e;return r};var a=new Date(Date.UTC(1900,0,1));t.parseDate=function(r){if(!isNaN(r)){if(r instanceof Date)return new Date(r);var t=parseInt(r,10);return 0>t?n.num:t>60?new Date(a.getTime()+864e5*(t-2)):new Date(a.getTime()+864e5*(t-1))}return"string"!=typeof r||(r=new Date(r),isNaN(r))?n.value:r},t.parseDateArray=function(r){for(var t,e=r.length;e--;){if((t=this.parseDate(r[e]))===n.value)return t;r[e]=t}return r},t.anyIsError=function(){for(var r=arguments.length;r--;)if(arguments[r]instanceof Error)return!0;return!1},t.arrayValuesToNumbers=function(r){for(var t,e=r.length;e--;)if("number"!=typeof(t=r[e]))if(!0!==t)if(!1!==t){if("string"==typeof t){var n=this.parseNumber(t);r[e]=n instanceof Error?0:n}}else r[e]=0;else r[e]=1;return r},t.rest=function(r,t){return t=t||1,r&&"function"==typeof r.slice?r.slice(t):r},t.initial=function(r,t){return t=t||1,r&&"function"==typeof r.slice?r.slice(0,r.length-t):r},t.arrayEach=function(r,t){for(var e=-1,n=r.length;++e-1?parseFloat(r):parseInt(r,10)),t}function a(r){return-1*n(r)}t.__esModule=!0,t.toNumber=n,t.invertNumber=a},function(module,exports,__webpack_require__){var utils=__webpack_require__(1),error=__webpack_require__(0),statistical=__webpack_require__(5),information=__webpack_require__(7);exports.ABS=function(r){return(r=utils.parseNumber(r))instanceof Error?r:Math.abs(r)},exports.ACOS=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.acos(r);return isNaN(t)&&(t=error.num),t},exports.ACOSH=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.log(r+Math.sqrt(r*r-1));return isNaN(t)&&(t=error.num),t},exports.ACOT=function(r){return(r=utils.parseNumber(r))instanceof Error?r:Math.atan(1/r)},exports.ACOTH=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=.5*Math.log((r+1)/(r-1));return isNaN(t)&&(t=error.num),t},exports.AGGREGATE=function(r,t,e,n){if(r=utils.parseNumber(r),t=utils.parseNumber(r),utils.anyIsError(r,t))return error.value;switch(r){case 1:return statistical.AVERAGE(e);case 2:return statistical.COUNT(e);case 3:return statistical.COUNTA(e);case 4:return statistical.MAX(e);case 5:return statistical.MIN(e);case 6:return exports.PRODUCT(e);case 7:return statistical.STDEV.S(e);case 8:return statistical.STDEV.P(e);case 9:return exports.SUM(e);case 10:return statistical.VAR.S(e);case 11:return statistical.VAR.P(e);case 12:return statistical.MEDIAN(e);case 13:return statistical.MODE.SNGL(e);case 14:return statistical.LARGE(e,n);case 15:return statistical.SMALL(e,n);case 16:return statistical.PERCENTILE.INC(e,n);case 17:return statistical.QUARTILE.INC(e,n);case 18:return statistical.PERCENTILE.EXC(e,n);case 19:return statistical.QUARTILE.EXC(e,n)}},exports.ARABIC=function(r){if(!/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/.test(r))return error.value;var t=0;return r.replace(/[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,function(r){t+={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}[r]}),t},exports.ASIN=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.asin(r);return isNaN(t)&&(t=error.num),t},exports.ASINH=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.log(r+Math.sqrt(r*r+1))},exports.ATAN=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.atan(r)},exports.ATAN2=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:Math.atan2(r,t)},exports.ATANH=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.log((1+r)/(1-r))/2;return isNaN(t)&&(t=error.num),t},exports.BASE=function(r,t,e){if(e=e||0,r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e))return error.value;e=e===undefined?0:e;var n=r.toString(t);return Array(Math.max(e+1-n.length,0)).join("0")+n},exports.CEILING=function(r,t,e){if(t=t===undefined?1:Math.abs(t),e=e||0,r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e))return error.value;if(0===t)return 0;var n=-Math.floor(Math.log(t)/Math.log(10));return 0>r?0===e?-exports.ROUND(Math.floor(Math.abs(r)/t)*t,n):-exports.ROUND(Math.ceil(Math.abs(r)/t)*t,n):exports.ROUND(Math.ceil(r/t)*t,n)},exports.CEILING.MATH=exports.CEILING,exports.CEILING.PRECISE=exports.CEILING,exports.COMBIN=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:exports.FACT(r)/(exports.FACT(t)*exports.FACT(r-t))},exports.COMBINA=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:0===r&&0===t?1:exports.COMBIN(r+t-1,r-1)},exports.COS=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.cos(r)},exports.COSH=function(r){return r=utils.parseNumber(r),r instanceof Error?r:(Math.exp(r)+Math.exp(-r))/2},exports.COT=function(r){return r=utils.parseNumber(r),r instanceof Error?r:1/Math.tan(r)},exports.COTH=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.exp(2*r);return(t+1)/(t-1)},exports.CSC=function(r){return r=utils.parseNumber(r),r instanceof Error?r:1/Math.sin(r)},exports.CSCH=function(r){return r=utils.parseNumber(r),r instanceof Error?r:2/(Math.exp(r)-Math.exp(-r))},exports.DECIMAL=function(r,t){return 1>arguments.length?error.value:parseInt(r,t)},exports.DEGREES=function(r){return r=utils.parseNumber(r),r instanceof Error?r:180*r/Math.PI},exports.EVEN=function(r){return r=utils.parseNumber(r),r instanceof Error?r:exports.CEILING(r,-2,-1)},exports.EXP=function(r){return 1>arguments.length?error.na:"number"!=typeof r||arguments.length>1?error.error:r=Math.exp(r)};var MEMOIZED_FACT=[];exports.FACT=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.floor(r);return 0===t||1===t?1:MEMOIZED_FACT[t]>0?MEMOIZED_FACT[t]:MEMOIZED_FACT[t]=exports.FACT(t-1)*t},exports.FACTDOUBLE=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.floor(r);return t>0?t*exports.FACTDOUBLE(t-2):1},exports.FLOOR=function(r,t){if(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;if(0===t)return 0;if(!(r>0&&t>0||0>r&&0>t))return error.num;t=Math.abs(t);var e=-Math.floor(Math.log(t)/Math.log(10));return 0>r?-exports.ROUND(Math.ceil(Math.abs(r)/t),e):exports.ROUND(Math.floor(r/t)*t,e)},exports.FLOOR.MATH=function(r,t,e){if(t=t===undefined?1:t,e=e===undefined?0:e,r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e))return error.value;if(0===t)return 0;t=t?Math.abs(t):1;var n=-Math.floor(Math.log(t)/Math.log(10));return 0>r?0===e||e===undefined?-exports.ROUND(Math.ceil(Math.abs(r)/t)*t,n):-exports.ROUND(Math.floor(Math.abs(r)/t)*t,n):exports.ROUND(Math.floor(r/t)*t,n)},exports.FLOOR.PRECISE=exports.FLOOR.MATH,exports.GCD=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=r.length,e=r[0],n=0>e?-e:e,a=1;t>a;a++){for(var u=r[a],i=0>u?-u:u;n&&i;)n>i?n%=i:i%=n;n+=i}return n},exports.INT=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.floor(r)},exports.ISO={CEILING:exports.CEILING},exports.LCM=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t,e,n,a,u=1;(n=r.pop())!==undefined;)for(;n>1;){if(n%2){for(t=3,e=Math.floor(Math.sqrt(n));e>=t&&n%t;t+=2);a=t>e?n:t}else a=2;for(n/=a,u*=a,t=r.length;t;r[--t]%a==0&&1==(r[t]/=a)&&r.splice(t,1));}return u},exports.LN=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.log(r)},exports.LN10=function(){return Math.log(10)},exports.LN2=function(){return Math.log(2)},exports.LOG10E=function(){return Math.LOG10E},exports.LOG2E=function(){return Math.LOG2E},exports.LOG=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:(t=t===undefined?10:t,Math.log(r)/Math.log(t))},exports.LOG10=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.log(r)/Math.log(10)},exports.MOD=function(r,t){if(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;if(0===t)return error.div0;var e=Math.abs(r%t);return t>0?e:-e},exports.MROUND=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:0>r*t?error.num:Math.round(r/t)*t},exports.MULTINOMIAL=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=0,e=1,n=0;r.length>n;n++)t+=r[n],e*=exports.FACT(r[n]);return exports.FACT(t)/e},exports.ODD=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.ceil(Math.abs(r));return t=1&t?t:t+1,r>0?t:-t},exports.PI=function(){return Math.PI},exports.E=function(){return Math.E},exports.POWER=function(r,t){if(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;var e=Math.pow(r,t);return isNaN(e)?error.num:e},exports.PRODUCT=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=1,e=0;r.length>e;e++)t*=r[e];return t},exports.QUOTIENT=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:parseInt(r/t,10)},exports.RADIANS=function(r){return r=utils.parseNumber(r),r instanceof Error?r:r*Math.PI/180},exports.RAND=function(){return Math.random()},exports.RANDBETWEEN=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:r+Math.ceil((t-r+1)*Math.random())-1},exports.ROMAN=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;for(var t=(r+"").split(""),e=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],n="",a=3;a--;)n=(e[+t.pop()+10*a]||"")+n;return Array(+t.join("")+1).join("M")+n},exports.ROUND=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:Math.round(r*Math.pow(10,t))/Math.pow(10,t)},exports.ROUNDDOWN=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:(r>0?1:-1)*Math.floor(Math.abs(r)*Math.pow(10,t))/Math.pow(10,t)},exports.ROUNDUP=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:(r>0?1:-1)*Math.ceil(Math.abs(r)*Math.pow(10,t))/Math.pow(10,t)},exports.SEC=function(r){return r=utils.parseNumber(r),r instanceof Error?r:1/Math.cos(r)},exports.SECH=function(r){return r=utils.parseNumber(r),r instanceof Error?r:2/(Math.exp(r)+Math.exp(-r))},exports.SERIESSUM=function(r,t,e,n){if(r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),n=utils.parseNumberArray(n),utils.anyIsError(r,t,e,n))return error.value;for(var a=n[0]*Math.pow(r,t),u=1;n.length>u;u++)a+=n[u]*Math.pow(r,t+u*e);return a},exports.SIGN=function(r){return r=utils.parseNumber(r),r instanceof Error?r:0>r?-1:0===r?0:1},exports.SIN=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.sin(r)},exports.SINH=function(r){return r=utils.parseNumber(r),r instanceof Error?r:(Math.exp(r)-Math.exp(-r))/2},exports.SQRT=function(r){return r=utils.parseNumber(r),r instanceof Error?r:0>r?error.num:Math.sqrt(r)},exports.SQRTPI=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.sqrt(r*Math.PI)},exports.SQRT1_2=function(){return 1/Math.sqrt(2)},exports.SQRT2=function(){return Math.sqrt(2)},exports.SUBTOTAL=function(r,t){if((r=utils.parseNumber(r))instanceof Error)return r;switch(r){case 1:return statistical.AVERAGE(t);case 2:return statistical.COUNT(t);case 3:return statistical.COUNTA(t);case 4:return statistical.MAX(t);case 5:return statistical.MIN(t);case 6:return exports.PRODUCT(t);case 7:return statistical.STDEV.S(t);case 8:return statistical.STDEV.P(t);case 9:return exports.SUM(t);case 10:return statistical.VAR.S(t);case 11:return statistical.VAR.P(t);case 101:return statistical.AVERAGE(t);case 102:return statistical.COUNT(t);case 103:return statistical.COUNTA(t);case 104:return statistical.MAX(t);case 105:return statistical.MIN(t);case 106:return exports.PRODUCT(t);case 107:return statistical.STDEV.S(t);case 108:return statistical.STDEV.P(t);case 109:return exports.SUM(t);case 110:return statistical.VAR.S(t);case 111:return statistical.VAR.P(t)}},exports.ADD=function(r,t){return 2!==arguments.length?error.na:(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:r+t)},exports.MINUS=function(r,t){return 2!==arguments.length?error.na:(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:r-t)},exports.DIVIDE=function(r,t){return 2!==arguments.length?error.na:(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:0===t?error.div0:r/t)},exports.MULTIPLY=function(r,t){return 2!==arguments.length?error.na:(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:r*t)},exports.GTE=function(r,t){return 2!==arguments.length?error.na:(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.error:r>=t)},exports.LT=function(r,t){return 2!==arguments.length?error.na:(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.error:t>r)},exports.LTE=function(r,t){return 2!==arguments.length?error.na:(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.error:t>=r)},exports.EQ=function(r,t){return 2!==arguments.length?error.na:r===t},exports.NE=function(r,t){return 2!==arguments.length?error.na:r!==t},exports.POW=function(r,t){return 2!==arguments.length?error.na:(r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.error:exports.POWER(r,t))},exports.SUM=function(){var r=0;return utils.arrayEach(utils.argsToArray(arguments),function(t){if("number"==typeof t)r+=t;else if("string"==typeof t){var e=parseFloat(t);!isNaN(e)&&(r+=e)}else Array.isArray(t)&&(r+=exports.SUM.apply(null,t))}),r},exports.SUMIF=function(range,criteria){if((range=utils.parseNumberArray(utils.flatten(range)))instanceof Error)return range;for(var result=0,i=0;range.length>i;i++)result+=eval(range[i]+criteria)?range[i]:0;return result},exports.SUMIFS=function(){var args=utils.argsToArray(arguments),range=utils.parseNumberArray(utils.flatten(args.shift()));if(range instanceof Error)return range;for(var criteria=args,n_range_elements=range.length,n_criterias=criteria.length,result=0,i=0;n_range_elements>i;i++){for(var el=range[i],condition="",c=0;n_criterias>c;c++)condition+=el+criteria[c],c!==n_criterias-1&&(condition+="&&");eval(condition)&&(result+=el)}return result},exports.SUMPRODUCT=function(){if(!arguments||0===arguments.length)return error.value;for(var r,t,e,n,a=arguments.length+1,u=0,i=0;arguments[0].length>i;i++)if(arguments[0][i]instanceof Array)for(var o=0;arguments[0][i].length>o;o++){for(r=1,t=1;a>t;t++){if((n=utils.parseNumber(arguments[t-1][i][o]))instanceof Error)return n;r*=n}u+=r}else{for(r=1,t=1;a>t;t++){if((e=utils.parseNumber(arguments[t-1][i]))instanceof Error)return e;r*=e}u+=r}return u},exports.SUMSQ=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=0,e=r.length,n=0;e>n;n++)t+=information.ISNUMBER(r[n])?r[n]*r[n]:0;return t},exports.SUMX2MY2=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;for(var e=0,n=0;r.length>n;n++)e+=r[n]*r[n]-t[n]*t[n];return e},exports.SUMX2PY2=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;var e=0;r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t));for(var n=0;r.length>n;n++)e+=r[n]*r[n]+t[n]*t[n];return e},exports.SUMXMY2=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;var e=0;r=utils.flatten(r),t=utils.flatten(t);for(var n=0;r.length>n;n++)e+=Math.pow(r[n]-t[n],2);return e},exports.TAN=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.tan(r)},exports.TANH=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.exp(2*r);return(t-1)/(t+1)},exports.TRUNC=function(r,t){return t=t===undefined?0:t,r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:(r>0?1:-1)*Math.floor(Math.abs(r)*Math.pow(10,t))/Math.pow(10,t)}},function(module,exports,__webpack_require__){var mathTrig=__webpack_require__(4),text=__webpack_require__(6),jStat=__webpack_require__(9).jStat,utils=__webpack_require__(1),error=__webpack_require__(0),misc=__webpack_require__(10);exports.AVEDEV=function(){var r=utils.parseNumberArray(utils.flatten(arguments));return r instanceof Error?r:jStat.sum(jStat(r).subtract(jStat.mean(r)).abs()[0])/r.length},exports.AVERAGE=function(){for(var r,t=utils.numbers(utils.flatten(arguments)),e=t.length,n=0,a=0,u=0;e>u;u++)n+=t[u],a+=1;return r=n/a,isNaN(r)&&(r=error.num),r},exports.AVERAGEA=function(){for(var r,t=utils.flatten(arguments),e=t.length,n=0,a=0,u=0;e>u;u++){var i=t[u];"number"==typeof i&&(n+=i),!0===i&&n++,null!==i&&a++}return r=n/a,isNaN(r)&&(r=error.num),r},exports.AVERAGEIF=function(range,criteria,average_range){if(1>=arguments.length)return error.na;if(average_range=average_range||range,range=utils.flatten(range),(average_range=utils.parseNumberArray(utils.flatten(average_range)))instanceof Error)return average_range;for(var average_count=0,result=0,i=0;range.length>i;i++)eval(range[i]+criteria)&&(result+=average_range[i],average_count++);return result/average_count},exports.AVERAGEIFS=function(){for(var args=utils.argsToArray(arguments),criteria=(args.length-1)/2,range=utils.flatten(args[0]),count=0,result=0,i=0;range.length>i;i++){for(var condition="",j=0;criteria>j;j++)condition+=args[2*j+1][i]+args[2*j+2],j!==criteria-1&&(condition+="&&");eval(condition)&&(result+=range[i],count++)}var average=result/count;return isNaN(average)?0:average},exports.BETA={},exports.BETA.DIST=function(r,t,e,n,a,u){return 4>arguments.length?error.value:(a=a===undefined?0:a,u=u===undefined?1:u,r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),a=utils.parseNumber(a),u=utils.parseNumber(u),utils.anyIsError(r,t,e,a,u)?error.value:(r=(r-a)/(u-a),n?jStat.beta.cdf(r,t,e):jStat.beta.pdf(r,t,e)))},exports.BETA.INV=function(r,t,e,n,a){return n=n===undefined?0:n,a=a===undefined?1:a,r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),n=utils.parseNumber(n),a=utils.parseNumber(a),utils.anyIsError(r,t,e,n,a)?error.value:jStat.beta.inv(r,t,e)*(a-n)+n},exports.BINOM={},exports.BINOM.DIST=function(r,t,e,n){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),n=utils.parseNumber(n),utils.anyIsError(r,t,e,n)?error.value:n?jStat.binomial.cdf(r,t,e):jStat.binomial.pdf(r,t,e)},exports.BINOM.DIST.RANGE=function(r,t,e,n){if(n=n===undefined?e:n,r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),n=utils.parseNumber(n),utils.anyIsError(r,t,e,n))return error.value;for(var a=0,u=e;n>=u;u++)a+=mathTrig.COMBIN(r,u)*Math.pow(t,u)*Math.pow(1-t,r-u);return a},exports.BINOM.INV=function(r,t,e){if(r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e))return error.value;for(var n=0;r>=n;){if(jStat.binomial.cdf(n,r,t)>=e)return n;n++}},exports.CHISQ={},exports.CHISQ.DIST=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:e?jStat.chisquare.cdf(r,t):jStat.chisquare.pdf(r,t)},exports.CHISQ.DIST.RT=function(r,t){return!r|!t?error.na:1>r||t>Math.pow(10,10)?error.num:"number"!=typeof r||"number"!=typeof t?error.value:1-jStat.chisquare.cdf(r,t)},exports.CHISQ.INV=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:jStat.chisquare.inv(r,t)},exports.CHISQ.INV.RT=function(r,t){return!r|!t?error.na:0>r||r>1||1>t||t>Math.pow(10,10)?error.num:"number"!=typeof r||"number"!=typeof t?error.value:jStat.chisquare.inv(1-r,t)},exports.CHISQ.TEST=function(r,t){if(2!==arguments.length)return error.na;if(!(r instanceof Array&&t instanceof Array))return error.value;if(r.length!==t.length)return error.value;if(r[0]&&t[0]&&r[0].length!==t[0].length)return error.value;var e,n,a,u=r.length;for(n=0;u>n;n++)r[n]instanceof Array||(e=r[n],r[n]=[],r[n].push(e)),t[n]instanceof Array||(e=t[n],t[n]=[],t[n].push(e));var i=r[0].length,o=1===i?u-1:(u-1)*(i-1),s=0,l=Math.PI;for(n=0;u>n;n++)for(a=0;i>a;a++)s+=Math.pow(r[n][a]-t[n][a],2)/t[n][a];return Math.round(1e6*function(r,t){var e=Math.exp(-.5*r);t%2==1&&(e*=Math.sqrt(2*r/l));for(var n=t;n>=2;)e=e*r/n,n-=2;for(var a=e,u=t;a>1e-10*e;)u+=2,a=a*r/u,e+=a;return 1-e}(s,o))/1e6},exports.COLUMN=function(r,t){return 2!==arguments.length?error.na:0>t?error.num:r instanceof Array&&"number"==typeof t?0===r.length?undefined:jStat.col(r,t):error.value},exports.COLUMNS=function(r){return 1!==arguments.length?error.na:r instanceof Array?0===r.length?0:jStat.cols(r):error.value},exports.CONFIDENCE={},exports.CONFIDENCE.NORM=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:jStat.normalci(1,r,t,e)[1]-1},exports.CONFIDENCE.T=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:jStat.tci(1,r,t,e)[1]-1},exports.CORREL=function(r,t){return r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t)?error.value:jStat.corrcoeff(r,t)},exports.COUNT=function(){return utils.numbers(utils.flatten(arguments)).length},exports.COUNTA=function(){var r=utils.flatten(arguments);return r.length-exports.COUNTBLANK(r)},exports.COUNTIN=function(r,t){var e=0;r=utils.flatten(r);for(var n=0;r.length>n;n++)r[n]===t&&e++;return e},exports.COUNTBLANK=function(){for(var r,t=utils.flatten(arguments),e=0,n=0;t.length>n;n++)null!==(r=t[n])&&""!==r||e++;return e},exports.COUNTIF=function(range,criteria){range=utils.flatten(range),/[<>=!]/.test(criteria)||(criteria='=="'+criteria+'"');for(var matches=0,i=0;range.length>i;i++)"string"!=typeof range[i]?eval(range[i]+criteria)&&matches++:eval('"'+range[i]+'"'+criteria)&&matches++;return matches},exports.COUNTIFS=function(){for(var args=utils.argsToArray(arguments),results=Array(utils.flatten(args[0]).length),i=0;results.length>i;i++)results[i]=!0;for(i=0;args.length>i;i+=2){var range=utils.flatten(args[i]),criteria=args[i+1];/[<>=!]/.test(criteria)||(criteria='=="'+criteria+'"');for(var j=0;range.length>j;j++)results[j]="string"!=typeof range[j]?results[j]&&eval(range[j]+criteria):results[j]&&eval('"'+range[j]+'"'+criteria)}var result=0;for(i=0;results.length>i;i++)results[i]&&result++;return result},exports.COUNTUNIQUE=function(){return misc.UNIQUE.apply(null,utils.flatten(arguments)).length},exports.COVARIANCE={},exports.COVARIANCE.P=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;for(var e=jStat.mean(r),n=jStat.mean(t),a=0,u=r.length,i=0;u>i;i++)a+=(r[i]-e)*(t[i]-n);return a/u},exports.COVARIANCE.S=function(r,t){return r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t)?error.value:jStat.covariance(r,t)},exports.DEVSQ=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=jStat.mean(r),e=0,n=0;r.length>n;n++)e+=Math.pow(r[n]-t,2);return e},exports.EXPON={},exports.EXPON.DIST=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:e?jStat.exponential.cdf(r,t):jStat.exponential.pdf(r,t)},exports.F={},exports.F.DIST=function(r,t,e,n){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:n?jStat.centralF.cdf(r,t,e):jStat.centralF.pdf(r,t,e)},exports.F.DIST.RT=function(r,t,e){return 3!==arguments.length?error.na:0>r||1>t||1>e?error.num:"number"!=typeof r||"number"!=typeof t||"number"!=typeof e?error.value:1-jStat.centralF.cdf(r,t,e)},exports.F.INV=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:0>=r||r>1?error.num:jStat.centralF.inv(r,t,e)},exports.F.INV.RT=function(r,t,e){return 3!==arguments.length?error.na:0>r||r>1||1>t||t>Math.pow(10,10)||1>e||e>Math.pow(10,10)?error.num:"number"!=typeof r||"number"!=typeof t||"number"!=typeof e?error.value:jStat.centralF.inv(1-r,t,e)},exports.F.TEST=function(r,t){if(!r||!t)return error.na;if(!(r instanceof Array&&t instanceof Array))return error.na;if(2>r.length||2>t.length)return error.div0;var e=function(r,t){for(var e=0,n=0;r.length>n;n++)e+=Math.pow(r[n]-t,2);return e},n=mathTrig.SUM(r)/r.length,a=mathTrig.SUM(t)/t.length;return e(r,n)/(r.length-1)/(e(t,a)/(t.length-1))},exports.FISHER=function(r){return r=utils.parseNumber(r),r instanceof Error?r:Math.log((1+r)/(1-r))/2},exports.FISHERINV=function(r){if((r=utils.parseNumber(r))instanceof Error)return r;var t=Math.exp(2*r);return(t-1)/(t+1)},exports.FORECAST=function(r,t,e){if(r=utils.parseNumber(r),t=utils.parseNumberArray(utils.flatten(t)),e=utils.parseNumberArray(utils.flatten(e)),utils.anyIsError(r,t,e))return error.value;for(var n=jStat.mean(e),a=jStat.mean(t),u=e.length,i=0,o=0,s=0;u>s;s++)i+=(e[s]-n)*(t[s]-a),o+=Math.pow(e[s]-n,2);var l=i/o;return a-l*n+l*r},exports.FREQUENCY=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;for(var e=r.length,n=t.length,a=[],u=0;n>=u;u++){a[u]=0;for(var i=0;e>i;i++)0===u?r[i]>t[0]||(a[0]+=1):n>u?r[i]>t[u-1]&&t[u]>=r[i]&&(a[u]+=1):u===n&&r[i]>t[n-1]&&(a[n]+=1)}return a},exports.GAMMA=function(r){return r=utils.parseNumber(r),r instanceof Error?r:0===r?error.num:parseInt(r,10)===r&&0>r?error.num:jStat.gammafn(r)},exports.GAMMA.DIST=function(r,t,e,n){return 4!==arguments.length?error.na:r>=0&&t>0&&e>0?"number"!=typeof r||"number"!=typeof t||"number"!=typeof e?error.value:n?jStat.gamma.cdf(r,t,e,!0):jStat.gamma.pdf(r,t,e,!1):error.value},exports.GAMMA.INV=function(r,t,e){return 3!==arguments.length?error.na:0>r||r>1||0>=t||0>=e?error.num:"number"!=typeof r||"number"!=typeof t||"number"!=typeof e?error.value:jStat.gamma.inv(r,t,e)},exports.GAMMALN=function(r){return r=utils.parseNumber(r),r instanceof Error?r:jStat.gammaln(r)},exports.GAMMALN.PRECISE=function(r){return 1!==arguments.length?error.na:r>0?"number"!=typeof r?error.value:jStat.gammaln(r):error.num},exports.GAUSS=function(r){return r=utils.parseNumber(r),r instanceof Error?r:jStat.normal.cdf(r,0,1)-.5},exports.GEOMEAN=function(){var r=utils.parseNumberArray(utils.flatten(arguments));return r instanceof Error?r:jStat.geomean(r)},exports.GROWTH=function(r,t,e,n){if((r=utils.parseNumberArray(r))instanceof Error)return r;var a;if(t===undefined)for(t=[],a=1;r.length>=a;a++)t.push(a);if(e===undefined)for(e=[],a=1;r.length>=a;a++)e.push(a);if(t=utils.parseNumberArray(t),e=utils.parseNumberArray(e),utils.anyIsError(t,e))return error.value;n===undefined&&(n=!0);var u=r.length,i=0,o=0,s=0,l=0;for(a=0;u>a;a++){var f=t[a],c=Math.log(r[a]);i+=f,o+=c,s+=f*c,l+=f*f}i/=u,o/=u,s/=u,l/=u;var p,h;n?(p=(s-i*o)/(l-i*i),h=o-p*i):(p=s/l,h=0);var m=[];for(a=0;e.length>a;a++)m.push(Math.exp(h+p*e[a]));return m},exports.HARMEAN=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=r.length,e=0,n=0;t>n;n++)e+=1/r[n];return t/e},exports.HYPGEOM={},exports.HYPGEOM.DIST=function(r,t,e,n,a){function u(r,t,e,n){return mathTrig.COMBIN(e,r)*mathTrig.COMBIN(n-e,t-r)/mathTrig.COMBIN(n,t)}return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),n=utils.parseNumber(n),utils.anyIsError(r,t,e,n)?error.value:a?function(r,t,e,n){for(var a=0,i=0;r>=i;i++)a+=u(i,t,e,n);return a}(r,t,e,n):u(r,t,e,n)},exports.INTERCEPT=function(r,t){return r=utils.parseNumberArray(r),t=utils.parseNumberArray(t),utils.anyIsError(r,t)?error.value:r.length!==t.length?error.na:exports.FORECAST(0,r,t)},exports.KURT=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=jStat.mean(r),e=r.length,n=0,a=0;e>a;a++)n+=Math.pow(r[a]-t,4);return n/=Math.pow(jStat.stdev(r,!0),4),e*(e+1)/((e-1)*(e-2)*(e-3))*n-3*(e-1)*(e-1)/((e-2)*(e-3))},exports.LARGE=function(r,t){return r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),utils.anyIsError(r,t)?r:r.sort(function(r,t){return t-r})[t-1]},exports.LINEST=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;for(var e=jStat.mean(r),n=jStat.mean(t),a=t.length,u=0,i=0,o=0;a>o;o++)u+=(t[o]-n)*(r[o]-e),i+=Math.pow(t[o]-n,2);var s=u/i;return[s,e-s*n]},exports.LOGEST=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;for(var e=0;r.length>e;e++)r[e]=Math.log(r[e]);var n=exports.LINEST(r,t);return n[0]=Math.round(1e6*Math.exp(n[0]))/1e6,n[1]=Math.round(1e6*Math.exp(n[1]))/1e6,n},exports.LOGNORM={},exports.LOGNORM.DIST=function(r,t,e,n){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:n?jStat.lognormal.cdf(r,t,e):jStat.lognormal.pdf(r,t,e)},exports.LOGNORM.INV=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:jStat.lognormal.inv(r,t,e)},exports.MAX=function(){var r=utils.numbers(utils.flatten(arguments));return 0===r.length?0:Math.max.apply(Math,r)},exports.MAXA=function(){var r=utils.arrayValuesToNumbers(utils.flatten(arguments));return 0===r.length?0:Math.max.apply(Math,r)},exports.MEDIAN=function(){var r=utils.arrayValuesToNumbers(utils.flatten(arguments)),t=jStat.median(r);return isNaN(t)&&(t=error.num),t},exports.MIN=function(){var r=utils.numbers(utils.flatten(arguments));return 0===r.length?0:Math.min.apply(Math,r)},exports.MINA=function(){var r=utils.arrayValuesToNumbers(utils.flatten(arguments));return 0===r.length?0:Math.min.apply(Math,r)},exports.MODE={},exports.MODE.MULT=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t,e=r.length,n={},a=[],u=0,i=0;e>i;i++)t=r[i],n[t]=n[t]?n[t]+1:1,n[t]>u&&(u=n[t],a=[]),n[t]===u&&(a[a.length]=t);return a},exports.MODE.SNGL=function(){var r=utils.parseNumberArray(utils.flatten(arguments));return r instanceof Error?r:exports.MODE.MULT(r).sort(function(r,t){return r-t})[0]},exports.NEGBINOM={},exports.NEGBINOM.DIST=function(r,t,e,n){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:n?jStat.negbin.cdf(r,t,e):jStat.negbin.pdf(r,t,e)},exports.NORM={},exports.NORM.DIST=function(r,t,e,n){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:e>0?n?jStat.normal.cdf(r,t,e):jStat.normal.pdf(r,t,e):error.num},exports.NORM.INV=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:jStat.normal.inv(r,t,e)},exports.NORM.S={},exports.NORM.S.DIST=function(r,t){return r=utils.parseNumber(r),r instanceof Error?error.value:t?jStat.normal.cdf(r,0,1):jStat.normal.pdf(r,0,1)},exports.NORM.S.INV=function(r){return r=utils.parseNumber(r),r instanceof Error?error.value:jStat.normal.inv(r,0,1)},exports.PEARSON=function(r,t){if(t=utils.parseNumberArray(utils.flatten(t)),r=utils.parseNumberArray(utils.flatten(r)),utils.anyIsError(t,r))return error.value;for(var e=jStat.mean(r),n=jStat.mean(t),a=r.length,u=0,i=0,o=0,s=0;a>s;s++)u+=(r[s]-e)*(t[s]-n),i+=Math.pow(r[s]-e,2),o+=Math.pow(t[s]-n,2);return u/Math.sqrt(i*o)},exports.PERCENTILE={},exports.PERCENTILE.EXC=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;r=r.sort(function(r,t){return r-t});var e=r.length;if(1/(e+1)>t||t>1-1/(e+1))return error.num;var n=t*(e+1)-1,a=Math.floor(n);return utils.cleanFloat(n===a?r[n]:r[a]+(n-a)*(r[a+1]-r[a]))},exports.PERCENTILE.INC=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;r=r.sort(function(r,t){return r-t});var e=r.length,n=t*(e-1),a=Math.floor(n);return utils.cleanFloat(n===a?r[n]:r[a]+(n-a)*(r[a+1]-r[a]))},exports.PERCENTRANK={},exports.PERCENTRANK.EXC=function(r,t,e){if(e=e===undefined?3:e,r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e))return error.value;r=r.sort(function(r,t){return r-t});for(var n=misc.UNIQUE.apply(null,r),a=r.length,u=n.length,i=Math.pow(10,e),o=0,s=!1,l=0;!s&&u>l;)t===n[l]?(o=(r.indexOf(n[l])+1)/(a+1),s=!0):n[l]>t||t>=n[l+1]&&l!==u-1||(o=(r.indexOf(n[l])+1+(t-n[l])/(n[l+1]-n[l]))/(a+1),s=!0),l++;return Math.floor(o*i)/i},exports.PERCENTRANK.INC=function(r,t,e){if(e=e===undefined?3:e,r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e))return error.value;r=r.sort(function(r,t){return r-t});for(var n=misc.UNIQUE.apply(null,r),a=r.length,u=n.length,i=Math.pow(10,e),o=0,s=!1,l=0;!s&&u>l;)t===n[l]?(o=r.indexOf(n[l])/(a-1),s=!0):n[l]>t||t>=n[l+1]&&l!==u-1||(o=(r.indexOf(n[l])+(t-n[l])/(n[l+1]-n[l]))/(a-1),s=!0),l++;return Math.floor(o*i)/i},exports.PERMUT=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:mathTrig.FACT(r)/mathTrig.FACT(r-t)},exports.PERMUTATIONA=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:Math.pow(r,t)},exports.PHI=function(r){return r=utils.parseNumber(r),r instanceof Error?error.value:Math.exp(-.5*r*r)/2.5066282746310002},exports.POISSON={},exports.POISSON.DIST=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:e?jStat.poisson.cdf(r,t):jStat.poisson.pdf(r,t)},exports.PROB=function(r,t,e,n){if(e===undefined)return 0;if(n=n===undefined?e:n,r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),e=utils.parseNumber(e),n=utils.parseNumber(n),utils.anyIsError(r,t,e,n))return error.value;if(e===n)return 0>r.indexOf(e)?0:t[r.indexOf(e)];for(var a=r.sort(function(r,t){return r-t}),u=a.length,i=0,o=0;u>o;o++)e>a[o]||a[o]>n||(i+=t[r.indexOf(a[o])]);return i},exports.QUARTILE={},exports.QUARTILE.EXC=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;switch(t){case 1:return exports.PERCENTILE.EXC(r,.25);case 2:return exports.PERCENTILE.EXC(r,.5);case 3:return exports.PERCENTILE.EXC(r,.75);default:return error.num}},exports.QUARTILE.INC=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;switch(t){case 1:return exports.PERCENTILE.INC(r,.25);case 2:return exports.PERCENTILE.INC(r,.5);case 3:return exports.PERCENTILE.INC(r,.75);default:return error.num}},exports.RANK={},exports.RANK.AVG=function(r,t,e){if(r=utils.parseNumber(r),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;t=utils.flatten(t),e=e||!1,t=t.sort(e?function(r,t){return r-t}:function(r,t){return t-r});for(var n=t.length,a=0,u=0;n>u;u++)t[u]===r&&a++;return a>1?(2*t.indexOf(r)+a+1)/2:t.indexOf(r)+1},exports.RANK.EQ=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t)?error.value:(e=e||!1,t=t.sort(e?function(r,t){return r-t}:function(r,t){return t-r}),t.indexOf(r)+1)},exports.ROW=function(r,t){return 2!==arguments.length?error.na:0>t?error.num:r instanceof Array&&"number"==typeof t?0===r.length?undefined:jStat.row(r,t):error.value},exports.ROWS=function(r){return 1!==arguments.length?error.na:r instanceof Array?0===r.length?0:jStat.rows(r):error.value},exports.RSQ=function(r,t){return r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t)?error.value:Math.pow(exports.PEARSON(r,t),2)},exports.SKEW=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=jStat.mean(r),e=r.length,n=0,a=0;e>a;a++)n+=Math.pow(r[a]-t,3);return e*n/((e-1)*(e-2)*Math.pow(jStat.stdev(r,!0),3))},exports.SKEW.P=function(){var r=utils.parseNumberArray(utils.flatten(arguments));if(r instanceof Error)return r;for(var t=jStat.mean(r),e=r.length,n=0,a=0,u=0;e>u;u++)a+=Math.pow(r[u]-t,3),n+=Math.pow(r[u]-t,2);return a/=e,n/=e,a/Math.pow(n,1.5)},exports.SLOPE=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;for(var e=jStat.mean(t),n=jStat.mean(r),a=t.length,u=0,i=0,o=0;a>o;o++)u+=(t[o]-e)*(r[o]-n),i+=Math.pow(t[o]-e,2);return u/i},exports.SMALL=function(r,t){return r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),utils.anyIsError(r,t)?r:r.sort(function(r,t){return r-t})[t-1]},exports.STANDARDIZE=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:(r-t)/e},exports.STDEV={},exports.STDEV.P=function(){var r=exports.VAR.P.apply(this,arguments),t=Math.sqrt(r);return isNaN(t)&&(t=error.num),t},exports.STDEV.S=function(){var r=exports.VAR.S.apply(this,arguments);return Math.sqrt(r)},exports.STDEVA=function(){var r=exports.VARA.apply(this,arguments);return Math.sqrt(r)},exports.STDEVPA=function(){var r=exports.VARPA.apply(this,arguments),t=Math.sqrt(r);return isNaN(t)&&(t=error.num),t},exports.STEYX=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;for(var e=jStat.mean(t),n=jStat.mean(r),a=t.length,u=0,i=0,o=0,s=0;a>s;s++)u+=Math.pow(r[s]-n,2),i+=(t[s]-e)*(r[s]-n),o+=Math.pow(t[s]-e,2);return Math.sqrt((u-i*i/o)/(a-2))},exports.TRANSPOSE=function(r){return r?jStat.transpose(r):error.na},exports.T=text.T,exports.T.DIST=function(r,t,e){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:e?jStat.studentt.cdf(r,t):jStat.studentt.pdf(r,t)},exports.T.DIST["2T"]=function(r,t){return 2!==arguments.length?error.na:0>r||1>t?error.num:"number"!=typeof r||"number"!=typeof t?error.value:2*(1-jStat.studentt.cdf(r,t))},exports.T.DIST.RT=function(r,t){return 2!==arguments.length?error.na:0>r||1>t?error.num:"number"!=typeof r||"number"!=typeof t?error.value:1-jStat.studentt.cdf(r,t)},exports.T.INV=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),utils.anyIsError(r,t)?error.value:jStat.studentt.inv(r,t)},exports.T.INV["2T"]=function(r,t){return r=utils.parseNumber(r),t=utils.parseNumber(t),0>=r||r>1||1>t?error.num:utils.anyIsError(r,t)?error.value:Math.abs(jStat.studentt.inv(r/2,t))},exports.T.TEST=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),utils.anyIsError(r,t))return error.value;var e,n=jStat.mean(r),a=jStat.mean(t),u=0,i=0;for(e=0;r.length>e;e++)u+=Math.pow(r[e]-n,2);for(e=0;t.length>e;e++)i+=Math.pow(t[e]-a,2);u/=r.length-1,i/=t.length-1;var o=Math.abs(n-a)/Math.sqrt(u/r.length+i/t.length);return exports.T.DIST["2T"](o,r.length+t.length-2)},exports.TREND=function(r,t,e){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumberArray(utils.flatten(t)),e=utils.parseNumberArray(utils.flatten(e)),utils.anyIsError(r,t,e))return error.value;var n=exports.LINEST(r,t),a=n[0],u=n[1],i=[];return e.forEach(function(r){i.push(a*r+u)}),i},exports.TRIMMEAN=function(r,t){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;var e=mathTrig.FLOOR(r.length*t,2)/2;return jStat.mean(utils.initial(utils.rest(r.sort(function(r,t){return r-t}),e),e))},exports.VAR={},exports.VAR.P=function(){for(var r,t=utils.numbers(utils.flatten(arguments)),e=t.length,n=0,a=exports.AVERAGE(t),u=0;e>u;u++)n+=Math.pow(t[u]-a,2);return r=n/e,isNaN(r)&&(r=error.num),r},exports.VAR.S=function(){for(var r=utils.numbers(utils.flatten(arguments)),t=r.length,e=0,n=exports.AVERAGE(r),a=0;t>a;a++)e+=Math.pow(r[a]-n,2);return e/(t-1)},exports.VARA=function(){for(var r=utils.flatten(arguments),t=r.length,e=0,n=0,a=exports.AVERAGEA(r),u=0;t>u;u++){var i=r[u];e+="number"==typeof i?Math.pow(i-a,2):!0===i?Math.pow(1-a,2):Math.pow(0-a,2),null!==i&&n++}return e/(n-1)},exports.VARPA=function(){for(var r,t=utils.flatten(arguments),e=t.length,n=0,a=0,u=exports.AVERAGEA(t),i=0;e>i;i++){var o=t[i];n+="number"==typeof o?Math.pow(o-u,2):!0===o?Math.pow(1-u,2):Math.pow(0-u,2),null!==o&&a++}return r=n/a,isNaN(r)&&(r=error.num),r},exports.WEIBULL={},exports.WEIBULL.DIST=function(r,t,e,n){return r=utils.parseNumber(r),t=utils.parseNumber(t),e=utils.parseNumber(e),utils.anyIsError(r,t,e)?error.value:n?1-Math.exp(-Math.pow(r/e,t)):Math.pow(r,t-1)*Math.exp(-Math.pow(r/e,t))*t/Math.pow(e,t)},exports.Z={},exports.Z.TEST=function(r,t,e){if(r=utils.parseNumberArray(utils.flatten(r)),t=utils.parseNumber(t),utils.anyIsError(r,t))return error.value;e=e||exports.STDEV.S(r);var n=r.length;return 1-exports.NORM.S.DIST((exports.AVERAGE(r)-t)/(e/Math.sqrt(n)),!0)}},function(r,t,e){var n=e(1),a=e(0);t.ASC=function(){throw Error("ASC is not implemented")},t.BAHTTEXT=function(){throw Error("BAHTTEXT is not implemented")},t.CHAR=function(r){return r=n.parseNumber(r),r instanceof Error?r:String.fromCharCode(r)},t.CLEAN=function(r){return r=r||"",r.replace(/[\0-\x1F]/g,"")},t.CODE=function(r){r=r||"";var t=r.charCodeAt(0);return isNaN(t)&&(t=a.na),t},t.CONCATENATE=function(){for(var r=n.flatten(arguments),t=0;(t=r.indexOf(!0))>-1;)r[t]="TRUE";for(var e=0;(e=r.indexOf(!1))>-1;)r[e]="FALSE";return r.join("")},t.DBCS=function(){throw Error("DBCS is not implemented")},t.DOLLAR=function(){throw Error("DOLLAR is not implemented")},t.EXACT=function(r,t){return 2!==arguments.length?a.na:r===t},t.FIND=function(r,t,e){return 2>arguments.length?a.na:(e=e===undefined?0:e,t?t.indexOf(r,e-1)+1:null)},t.FIXED=function(){throw Error("FIXED is not implemented")},t.HTML2TEXT=function(r){var t="";return r&&(r instanceof Array?r.forEach(function(r){""!==t&&(t+="\n"),t+=r.replace(/<(?:.|\n)*?>/gm,"")}):t=r.replace(/<(?:.|\n)*?>/gm,"")),t},t.LEFT=function(r,t){return t=t===undefined?1:t,t=n.parseNumber(t),t instanceof Error||"string"!=typeof r?a.value:r?r.substring(0,t):null},t.LEN=function(r){return 0===arguments.length?a.error:"string"==typeof r?r?r.length:0:r.length?r.length:a.value},t.LOWER=function(r){return"string"!=typeof r?a.value:r?r.toLowerCase():r},t.MID=function(r,t,e){if(t=n.parseNumber(t),e=n.parseNumber(e),n.anyIsError(t,e)||"string"!=typeof r)return e;var a=t-1;return r.substring(a,a+e)},t.NUMBERVALUE=function(r,t,e){return t=void 0===t?".":t,e=void 0===e?",":e,+r.replace(t,".").replace(e,"")},t.PRONETIC=function(){throw Error("PRONETIC is not implemented")},t.PROPER=function(r){return r===undefined||0===r.length?a.value:(!0===r&&(r="TRUE"),!1===r&&(r="FALSE"),isNaN(r)&&"number"==typeof r?a.value:("number"==typeof r&&(r=""+r),r.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+r.substr(1).toLowerCase()})))},t.REGEXEXTRACT=function(r,t){if(2>arguments.length)return a.na;var e=r.match(RegExp(t));return e?e[e.length>1?e.length-1:0]:null},t.REGEXMATCH=function(r,t,e){if(2>arguments.length)return a.na;var n=r.match(RegExp(t));return e?n:!!n},t.REGEXREPLACE=function(r,t,e){return 3>arguments.length?a.na:r.replace(RegExp(t),e)},t.REPLACE=function(r,t,e,u){return t=n.parseNumber(t),e=n.parseNumber(e),n.anyIsError(t,e)||"string"!=typeof r||"string"!=typeof u?a.value:r.substr(0,t-1)+u+r.substr(t-1+e)},t.REPT=function(r,t){return t=n.parseNumber(t),t instanceof Error?t:Array(t+1).join(r)},t.RIGHT=function(r,t){return t=t===undefined?1:t,t=n.parseNumber(t),t instanceof Error?t:r?r.substring(r.length-t):a.na},t.SEARCH=function(r,t,e){var n;return"string"!=typeof r||"string"!=typeof t?a.value:(e=e===undefined?0:e,n=t.toLowerCase().indexOf(r.toLowerCase(),e-1)+1,0===n?a.value:n)},t.SPLIT=function(r,t){return r.split(t)},t.SUBSTITUTE=function(r,t,e,n){if(2>arguments.length)return a.na;if(!(r&&t&&e))return r;if(n===undefined)return r.replace(RegExp(t,"g"),e);for(var u=0,i=0;r.indexOf(t,u)>0;)if(u=r.indexOf(t,u+1),++i===n)return r.substring(0,u)+e+r.substring(u+t.length)},t.T=function(r){return"string"==typeof r?r:""},t.TEXT=function(){throw Error("TEXT is not implemented")},t.TRIM=function(r){return"string"!=typeof r?a.value:r.replace(/ +/g," ").trim()},t.UNICHAR=t.CHAR,t.UNICODE=t.CODE,t.UPPER=function(r){return"string"!=typeof r?a.value:r.toUpperCase()},t.VALUE=function(){throw Error("VALUE is not implemented")}},function(r,t,e){var n=e(0);t.CELL=function(){throw Error("CELL is not implemented")},t.ERROR={},t.ERROR.TYPE=function(r){switch(r){case n.nil:return 1;case n.div0:return 2;case n.value:return 3;case n.ref:return 4;case n.name:return 5;case n.num:return 6;case n.na:return 7;case n.data:return 8}return n.na},t.INFO=function(){throw Error("INFO is not implemented")},t.ISBLANK=function(r){return null===r},t.ISBINARY=function(r){return/^[01]{1,10}$/.test(r)},t.ISERR=function(r){return[n.value,n.ref,n.div0,n.num,n.name,n.nil].indexOf(r)>=0||"number"==typeof r&&(isNaN(r)||!isFinite(r))},t.ISERROR=function(r){return t.ISERR(r)||r===n.na},t.ISEVEN=function(r){return!(1&Math.floor(Math.abs(r)))},t.ISFORMULA=function(){throw Error("ISFORMULA is not implemented")},t.ISLOGICAL=function(r){return!0===r||!1===r},t.ISNA=function(r){return r===n.na},t.ISNONTEXT=function(r){return"string"!=typeof r},t.ISNUMBER=function(r){return"number"==typeof r&&!isNaN(r)&&isFinite(r)},t.ISODD=function(r){return!!(1&Math.floor(Math.abs(r)))},t.ISREF=function(){throw Error("ISREF is not implemented")},t.ISTEXT=function(r){return"string"==typeof r},t.N=function(r){return this.ISNUMBER(r)?r:r instanceof Date?r.getTime():!0===r?1:!1===r?0:this.ISERROR(r)?r:0},t.NA=function(){return n.na},t.SHEET=function(){throw Error("SHEET is not implemented")},t.SHEETS=function(){throw Error("SHEETS is not implemented")},t.TYPE=function(r){return this.ISNUMBER(r)?1:this.ISTEXT(r)?2:this.ISLOGICAL(r)?4:this.ISERROR(r)?16:Array.isArray(r)?64:void 0}},function(r,t,e){function n(r){return 1===new Date(r,1,29).getMonth()}function a(r,t){return Math.ceil((t-r)/1e3/60/60/24)}function u(r){var t=r>-22038912e5?2:1;return Math.ceil((r-s)/864e5)+t}var i=e(0),o=e(1),s=new Date(Date.UTC(1900,0,1)),l=[undefined,0,1,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,1,2,3,4,5,6,0],f=[[],[1,2,3,4,5,6,7],[7,1,2,3,4,5,6],[6,0,1,2,3,4,5],[],[],[],[],[],[],[],[7,1,2,3,4,5,6],[6,7,1,2,3,4,5],[5,6,7,1,2,3,4],[4,5,6,7,1,2,3],[3,4,5,6,7,1,2],[2,3,4,5,6,7,1],[1,2,3,4,5,6,7]],c=[[],[6,0],[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],undefined,undefined,undefined,[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]];t.DATE=function(r,t,e){return r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),o.anyIsError(r,t,e)?i.value:0>r||0>t||0>e?i.num:new Date(r,t-1,e)},t.DATEVALUE=function(r){var t,e=2;return"string"!=typeof r?i.value:(t=Date.parse(r),isNaN(t)?i.value:(t>-22038912e5||(e=1),Math.ceil((t-s)/864e5)+e))},t.DAY=function(r){var t=o.parseDate(r);return t instanceof Error?t:t.getDate()},t.DAYS=function(r,t){return r=o.parseDate(r),t=o.parseDate(t),r instanceof Error?r:t instanceof Error?t:u(r)-u(t)},t.DAYS360=function(r,t,e){if(e=o.parseBool(e),r=o.parseDate(r),t=o.parseDate(t),r instanceof Error)return r;if(t instanceof Error)return t;if(e instanceof Error)return e;var n,a,u=r.getMonth(),i=t.getMonth();if(e)n=31===r.getDate()?30:r.getDate(),a=31===t.getDate()?30:t.getDate();else{var s=new Date(r.getFullYear(),u+1,0).getDate(),l=new Date(t.getFullYear(),i+1,0).getDate();n=r.getDate()===s?30:r.getDate(),t.getDate()===l?30>n?(i++,a=1):a=30:a=t.getDate()}return 360*(t.getFullYear()-r.getFullYear())+30*(i-u)+(a-n)},t.EDATE=function(r,t){return(r=o.parseDate(r))instanceof Error?r:isNaN(t)?i.value:(t=parseInt(t,10),r.setMonth(r.getMonth()+t),u(r))},t.EOMONTH=function(r,t){return(r=o.parseDate(r))instanceof Error?r:isNaN(t)?i.value:(t=parseInt(t,10),u(new Date(r.getFullYear(),r.getMonth()+t+1,0)))},t.HOUR=function(r){return r=o.parseDate(r),r instanceof Error?r:r.getHours()},t.INTERVAL=function(r){if("number"!=typeof r&&"string"!=typeof r)return i.value;r=parseInt(r,10);var t=Math.floor(r/94608e4);r%=94608e4;var e=Math.floor(r/2592e3);r%=2592e3;var n=Math.floor(r/86400);r%=86400;var a=Math.floor(r/3600);r%=3600;var u=Math.floor(r/60);r%=60;var o=r;return t=t>0?t+"Y":"",e=e>0?e+"M":"",n=n>0?n+"D":"",a=a>0?a+"H":"",u=u>0?u+"M":"",o=o>0?o+"S":"","P"+t+e+n+"T"+a+u+o},t.ISOWEEKNUM=function(r){if((r=o.parseDate(r))instanceof Error)return r;r.setHours(0,0,0),r.setDate(r.getDate()+4-(r.getDay()||7));var t=new Date(r.getFullYear(),0,1);return Math.ceil(((r-t)/864e5+1)/7)},t.MINUTE=function(r){return r=o.parseDate(r),r instanceof Error?r:r.getMinutes()},t.MONTH=function(r){return r=o.parseDate(r),r instanceof Error?r:r.getMonth()+1},t.NETWORKDAYS=function(r,t,e){return this.NETWORKDAYS.INTL(r,t,1,e)},t.NETWORKDAYS.INTL=function(r,t,e,n){if((r=o.parseDate(r))instanceof Error)return r;if((t=o.parseDate(t))instanceof Error)return t;if(!((e=e===undefined?c[1]:c[e])instanceof Array))return i.value;n===undefined?n=[]:n instanceof Array||(n=[n]);for(var a=0;n.length>a;a++){var u=o.parseDate(n[a]);if(u instanceof Error)return u;n[a]=u}var s=(t-r)/864e5+1,l=s,f=r;for(a=0;s>a;a++){var p=(new Date).getTimezoneOffset()>0?f.getUTCDay():f.getDay(),h=!1;p!==e[0]&&p!==e[1]||(h=!0);for(var m=0;n.length>m;m++){var E=n[m];if(E.getDate()===f.getDate()&&E.getMonth()===f.getMonth()&&E.getFullYear()===f.getFullYear()){h=!0;break}}h&&l--,f.setDate(f.getDate()+1)}return l},t.NOW=function(){return new Date},t.SECOND=function(r){return r=o.parseDate(r),r instanceof Error?r:r.getSeconds()},t.TIME=function(r,t,e){return r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),o.anyIsError(r,t,e)?i.value:0>r||0>t||0>e?i.num:(3600*r+60*t+e)/86400},t.TIMEVALUE=function(r){return r=o.parseDate(r),r instanceof Error?r:(3600*r.getHours()+60*r.getMinutes()+r.getSeconds())/86400},t.TODAY=function(){return new Date},t.WEEKDAY=function(r,t){if((r=o.parseDate(r))instanceof Error)return r;t===undefined&&(t=1);var e=r.getDay();return f[t][e]},t.WEEKNUM=function(r,t){if((r=o.parseDate(r))instanceof Error)return r;if(t===undefined&&(t=1),21===t)return this.ISOWEEKNUM(r);var e=l[t],n=new Date(r.getFullYear(),0,1),a=n.getDay()t)return i.num;if(!((e=e===undefined?c[1]:c[e])instanceof Array))return i.value;n===undefined?n=[]:n instanceof Array||(n=[n]);for(var a=0;n.length>a;a++){var u=o.parseDate(n[a]);if(u instanceof Error)return u;n[a]=u}for(var s=0;t>s;){r.setDate(r.getDate()+1);var l=r.getDay();if(l!==e[0]&&l!==e[1]){for(var f=0;n.length>f;f++){var p=n[f];if(p.getDate()===r.getDate()&&p.getMonth()===r.getMonth()&&p.getFullYear()===r.getFullYear()){s--;break}}s++}}return r},t.YEAR=function(r){return r=o.parseDate(r),r instanceof Error?r:r.getFullYear()},t.YEARFRAC=function(r,t,e){if((r=o.parseDate(r))instanceof Error)return r;if((t=o.parseDate(t))instanceof Error)return t;e=e||0;var u=r.getDate(),i=r.getMonth()+1,s=r.getFullYear(),l=t.getDate(),f=t.getMonth()+1,c=t.getFullYear();switch(e){case 0:return 31===u&&31===l?(u=30,l=30):31===u?u=30:30===u&&31===l&&(l=30),(l+30*f+360*c-(u+30*i+360*s))/360;case 1:var p=365;if(s===c||s+1===c&&(i>f||i===f&&u>=l))return(s===c&&n(s)||function(r,t){var e=r.getFullYear(),a=new Date(e,2,1);if(n(e)&&a>r&&t>=a)return!0;var u=t.getFullYear(),i=new Date(u,2,1);return n(u)&&t>=i&&i>r}(r,t)||1===f&&29===l)&&(p=366),a(r,t)/p;var h=c-s+1,m=(new Date(c+1,0,1)-new Date(s,0,1))/1e3/60/60/24,E=m/h;return a(r,t)/E;case 2:return a(r,t)/360;case 3:return a(r,t)/365;case 4:return(l+30*f+360*c-(u+30*i+360*s))/360}}},function(t,e,n){!function(r,e){t.exports=e()}(0,function(){var t=function(r,t){function e(t,e){var n=t>e?t:e;return r.pow(10,17-~~(r.log(n>0?n:-n)*r.LOG10E))}function n(r){return"[object Function]"===h.call(r)}function a(r){return"number"==typeof r&&r===r}function u(r){return c.apply([],r)}function o(){return new o._init(arguments)}function s(){return 0}function l(){return 1}function f(r,t){return r===t?1:0}var c=Array.prototype.concat,p=Array.prototype.slice,h=Object.prototype.toString,m=Array.isArray||function(r){return"[object Array]"===h.call(r)};o.fn=o.prototype,o._init=function(r){var t;if(m(r[0]))if(m(r[0][0])){n(r[1])&&(r[0]=o.map(r[0],r[1]));for(var t=0;r[0].length>t;t++)this[t]=r[0][t];this.length=r[0].length}else this[0]=n(r[1])?o.map(r[0],r[1]):r[0],this.length=1;else if(a(r[0]))this[0]=o.seq.apply(null,r),this.length=1;else{if(r[0]instanceof o)return o(r[0].toArray());this[0]=[],this.length=1}return this},o._init.prototype=o.prototype,o._init.constructor=o,o.utils={calcRdx:e,isArray:m,isFunction:n,isNumber:a,toVector:u},o.extend=function(r){var t,e;if(1===arguments.length){for(e in r)o[e]=r[e];return this}for(var t=1;arguments.length>t;t++)for(e in arguments[t])r[e]=arguments[t][e];return r},o.rows=function(r){return r.length||1},o.cols=function(r){return r[0].length||1},o.dimensions=function(r){return{rows:o.rows(r),cols:o.cols(r)}},o.row=function(r,t){return m(t)?t.map(function(t){return o.row(r,t)}):r[t]},o.rowa=function(r,t){return o.row(r,t)},o.col=function(r,t){if(m(t)){var e=o.arange(r.length).map(function(r){return Array(t.length)});return t.forEach(function(t,n){o.arange(r.length).forEach(function(a){e[a][n]=r[a][t]})}),e}for(var n=Array(r.length),a=0;r.length>a;a++)n[a]=[r[a][t]];return n},o.cola=function(r,t){return o.col(r,t).map(function(r){return r[0]})},o.diag=function(r){for(var t=o.rows(r),e=Array(t),n=0;t>n;n++)e[n]=[r[n][n]];return e},o.antidiag=function(r){for(var t=o.rows(r)-1,e=Array(t),n=0;t>=0;t--,n++)e[n]=[r[n][t]];return e},o.transpose=function(r){var t,e,n,a,u,i=[];m(r[0])||(r=[r]),e=r.length,n=r[0].length;for(var u=0;n>u;u++){for(t=Array(e),a=0;e>a;a++)t[a]=r[a][u];i.push(t)}return 1===i.length?i[0]:i},o.map=function(r,t,e){var n,a,u,i,o;for(m(r[0])||(r=[r]),a=r.length,u=r[0].length,i=e?r:Array(a),n=0;a>n;n++)for(i[n]||(i[n]=Array(u)),o=0;u>o;o++)i[n][o]=t(r[n][o],n,o);return 1===i.length?i[0]:i},o.cumreduce=function(r,t,e){var n,a,u,i,o;for(m(r[0])||(r=[r]),a=r.length,u=r[0].length,i=e?r:Array(a),n=0;a>n;n++)for(i[n]||(i[n]=Array(u)),u>0&&(i[n][0]=r[n][0]),o=1;u>o;o++)i[n][o]=t(i[n][o-1],r[n][o]);return 1===i.length?i[0]:i},o.alter=function(r,t){return o.map(r,t,!0)},o.create=function(r,t,e){var a,u,i=Array(r);n(t)&&(e=t,t=r);for(var a=0;r>a;a++)for(i[a]=Array(t),u=0;t>u;u++)i[a][u]=e(a,u);return i},o.zeros=function(r,t){return a(t)||(t=r),o.create(r,t,s)},o.ones=function(r,t){return a(t)||(t=r),o.create(r,t,l)},o.rand=function(t,e){return a(e)||(e=t),o.create(t,e,r.random)},o.identity=function(r,t){return a(t)||(t=r),o.create(r,t,f)},o.symmetric=function(r){var t,e,n=r.length;if(r.length!==r[0].length)return!1;for(t=0;n>t;t++)for(e=0;n>e;e++)if(r[e][t]!==r[t][e])return!1;return!0},o.clear=function(r){return o.alter(r,s)},o.seq=function(r,t,a,u){n(u)||(u=!1);var i,o=[],s=e(r,t),l=(t*s-r*s)/((a-1)*s),f=r;for(i=0;t>=f&&a>i;i++,f=(r*s+l*s*i)/s)o.push(u?u(f,i):f);return o},o.arange=function(r,e,n){var a=[];if(n=n||1,e===t&&(e=r,r=0),r===e||0===n)return[];if(e>r&&0>n)return[];if(r>e&&n>0)return[];if(n>0)for(i=r;ie;i+=n)a.push(i);return a},o.slice=function(){function r(r,e,n,a){var u,i=[],s=r.length;if(e===t&&n===t&&a===t)return o.copy(r);if(e=e||0,n=n||r.length,e=0>e?s+e:e,n=0>n?s+n:n,a=a||1,e===n||0===a)return[];if(n>e&&0>a)return[];if(e>n&&a>0)return[];if(a>0)for(u=e;n>u;u+=a)i.push(r[u]);else for(u=e;u>n;u+=a)i.push(r[u]);return i}function e(t,e){if(e=e||{},a(e.row)){if(a(e.col))return t[e.row][e.col];var n=o.rowa(t,e.row),u=e.col||{};return r(n,u.start,u.end,u.step)}if(a(e.col)){var i=o.cola(t,e.col),s=e.row||{};return r(i,s.start,s.end,s.step)}var s=e.row||{},u=e.col||{};return r(t,s.start,s.end,s.step).map(function(t){return r(t,u.start,u.end,u.step)})}return e}(),o.sliceAssign=function(e,n,u){if(a(n.row)){if(a(n.col))return e[n.row][n.col]=u;n.col=n.col||{},n.col.start=n.col.start||0,n.col.end=n.col.end||e[0].length,n.col.step=n.col.step||1;var i=o.arange(n.col.start,r.min(e.length,n.col.end),n.col.step),s=n.row;return i.forEach(function(r,t){e[s][r]=u[t]}),e}if(a(n.col)){n.row=n.row||{},n.row.start=n.row.start||0,n.row.end=n.row.end||e.length,n.row.step=n.row.step||1;var l=o.arange(n.row.start,r.min(e[0].length,n.row.end),n.row.step),f=n.col;return l.forEach(function(r,t){e[r][f]=u[t]}),e}u[0].length===t&&(u=[u]),n.row.start=n.row.start||0,n.row.end=n.row.end||e.length,n.row.step=n.row.step||1,n.col.start=n.col.start||0,n.col.end=n.col.end||e[0].length,n.col.step=n.col.step||1;var l=o.arange(n.row.start,r.min(e.length,n.row.end),n.row.step),i=o.arange(n.col.start,r.min(e[0].length,n.col.end),n.col.step);return l.forEach(function(r,t){i.forEach(function(n,a){e[r][n]=u[t][a]})}),e},o.diagonal=function(r){var t=o.zeros(r.length,r.length);return r.forEach(function(r,e){t[e][e]=r}),t},o.copy=function(r){return r.map(function(r){return a(r)?r:r.map(function(r){return r})})};var E=o.prototype;return E.length=0,E.push=Array.prototype.push,E.sort=Array.prototype.sort,E.splice=Array.prototype.splice,E.slice=Array.prototype.slice,E.toArray=function(){return this.length>1?p.call(this):p.call(this)[0]},E.map=function(r,t){return o(o.map(this,r,t))},E.cumreduce=function(r,t){return o(o.cumreduce(this,r,t))},E.alter=function(r){return o.alter(this,r),this},function(r){for(var t=0;r.length>t;t++)!function(r){E[r]=function(t){var e,n=this;return t?(setTimeout(function(){t.call(n,E[r].call(n))}),this):(e=o[r](this),m(e)?o(e):e)}}(r[t])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(r){for(var t=0;r.length>t;t++)!function(r){E[r]=function(t,e){var n=this;return e?(setTimeout(function(){e.call(n,E[r].call(n,t))}),this):o(o[r](this,t))}}(r[t])}("row col".split(" ")),function(r){for(var t=0;r.length>t;t++)!function(r){E[r]=Function("return jStat(jStat."+r+".apply(null, arguments));")}(r[t])}("create zeros ones rand identity".split(" ")),o}(Math);return function(r,t){function e(r,t){return r-t}function n(r,e,n){return t.max(e,t.min(r,n))}var a=r.utils.isFunction;r.sum=function(r){for(var t=0,e=r.length;--e>=0;)t+=r[e];return t},r.sumsqrd=function(r){for(var t=0,e=r.length;--e>=0;)t+=r[e]*r[e];return t},r.sumsqerr=function(t){for(var e,n=r.mean(t),a=0,u=t.length;--u>=0;)e=t[u]-n,a+=e*e;return a},r.sumrow=function(r){for(var t=0,e=r.length;--e>=0;)t+=r[e];return t},r.product=function(r){for(var t=1,e=r.length;--e>=0;)t*=r[e];return t},r.min=function(r){for(var t=r[0],e=0;++er[e]&&(t=r[e]);return t},r.max=function(r){for(var t=r[0],e=0;++et&&(t=r[e]);return t},r.unique=function(r){for(var t={},e=[],n=0;r.length>n;n++)t[r[n]]||(t[r[n]]=!0,e.push(r[n]));return e},r.mean=function(t){return r.sum(t)/t.length},r.meansqerr=function(t){return r.sumsqerr(t)/t.length},r.geomean=function(e){return t.pow(r.product(e),1/e.length)},r.median=function(r){var t=r.length,n=r.slice().sort(e);return 1&t?n[t/2|0]:(n[t/2-1]+n[t/2])/2},r.cumsum=function(t){return r.cumreduce(t,function(r,t){return r+t})},r.cumprod=function(t){return r.cumreduce(t,function(r,t){return r*t})},r.diff=function(r){for(var t,e=[],n=r.length,t=1;n>t;t++)e.push(r[t]-r[t-1]);return e},r.rank=function(r){for(var t=r.length,n=r.slice().sort(e),a=Array(t),u=0;t>u;u++){var i=n.indexOf(r[u]),o=n.lastIndexOf(r[u]);if(i===o)var s=i;else var s=(i+o)/2;a[u]=s+1}return a},r.mode=function(r){for(var t,n=r.length,a=r.slice().sort(e),u=1,i=0,o=0,s=[],t=0;n>t;t++)a[t]===a[t+1]?u++:(u>i?(s=[a[t]],i=u,o=0):u===i&&(s.push(a[t]),o++),u=1);return 0===o?s[0]:s},r.range=function(t){return r.max(t)-r.min(t)},r.variance=function(t,e){return r.sumsqerr(t)/(t.length-(e?1:0))},r.pooledvariance=function(t){return t.reduce(function(t,e){return t+r.sumsqerr(e)},0)/(t.reduce(function(r,t){return r+t.length},0)-t.length)},r.deviation=function(t){for(var e=r.mean(t),n=t.length,a=Array(n),u=0;n>u;u++)a[u]=t[u]-e;return a},r.stdev=function(e,n){return t.sqrt(r.variance(e,n))},r.pooledstdev=function(e){return t.sqrt(r.pooledvariance(e))},r.meandev=function(e){for(var n=r.mean(e),a=[],u=e.length-1;u>=0;u--)a.push(t.abs(e[u]-n));return r.mean(a)},r.meddev=function(e){for(var n=r.median(e),a=[],u=e.length-1;u>=0;u--)a.push(t.abs(e[u]-n));return r.median(a)},r.coeffvar=function(t){return r.stdev(t)/r.mean(t)},r.quartiles=function(r){var n=r.length,a=r.slice().sort(e);return[a[t.round(n/4)-1],a[t.round(n/2)-1],a[t.round(3*n/4)-1]]},r.quantiles=function(r,a,u,i){var o,s,l,f,c,p,h=r.slice().sort(e),m=[a.length],E=r.length;void 0===u&&(u=3/8),void 0===i&&(i=3/8);for(var o=0;a.length>o;o++)s=a[o],l=u+s*(1-u-i),f=E*s+l,c=t.floor(n(f,1,E-1)),p=n(f-c,0,1),m[o]=(1-p)*h[c-1]+p*h[c];return m},r.percentile=function(r,t){var n=r.slice().sort(e),a=t*(n.length-1),u=parseInt(a),i=a-u;return n.length>u+1?n[u]*(1-i)+n[u+1]*i:n[u]},r.percentileOfScore=function(r,t,e){var n,a,u=0,i=r.length,o=!1;"strict"===e&&(o=!0);for(var a=0;i>a;a++)n=r[a],(o&&t>n||!o&&t>=n)&&u++;return u/i},r.histogram=function(e,n){for(var a,u=r.min(e),i=n||4,o=(r.max(e)-u)/i,s=e.length,n=[],a=0;i>a;a++)n[a]=0;for(var a=0;s>a;a++)n[t.min(t.floor((e[a]-u)/o),i-1)]+=1;return n},r.covariance=function(t,e){for(var n,a=r.mean(t),u=r.mean(e),i=t.length,o=Array(i),n=0;i>n;n++)o[n]=(t[n]-a)*(e[n]-u);return r.sum(o)/(i-1)},r.corrcoeff=function(t,e){return r.covariance(t,e)/r.stdev(t,1)/r.stdev(e,1)},r.spearmancoeff=function(t,e){return t=r.rank(t),e=r.rank(e),r.corrcoeff(t,e)},r.stanMoment=function(e,n){for(var a=r.mean(e),u=r.stdev(e),i=e.length,o=0,s=0;i>s;s++)o+=t.pow((e[s]-a)/u,n);return o/e.length},r.skewness=function(t){return r.stanMoment(t,3)},r.kurtosis=function(t){return r.stanMoment(t,4)-3};var u=r.prototype;!function(t){for(var e=0;t.length>e;e++)!function(t){u[t]=function(e,n){var i=[],o=0,s=this;if(a(e)&&(n=e,e=!1),n)return setTimeout(function(){n.call(s,u[t].call(s,e))}),this;if(this.length>1){for(s=!0===e?this:this.transpose();s.length>o;o++)i[o]=r[t](s[o]);return i}return r[t](this[0],e)}}(t[e])}("cumsum cumprod".split(" ")),function(t){for(var e=0;t.length>e;e++)!function(t){u[t]=function(e,n){var i=[],o=0,s=this;if(a(e)&&(n=e,e=!1),n)return setTimeout(function(){n.call(s,u[t].call(s,e))}),this;if(this.length>1){for("sumrow"!==t&&(s=!0===e?this:this.transpose());s.length>o;o++)i[o]=r[t](s[o]);return!0===e?r[t](r.utils.toVector(i)):i}return r[t](this[0],e)}}(t[e])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(t){for(var e=0;t.length>e;e++)!function(t){u[t]=function(){var e=[],n=0,i=this,o=Array.prototype.slice.call(arguments);if(a(o[o.length-1])){var s=o[o.length-1],l=o.slice(0,o.length-1);return setTimeout(function(){s.call(i,u[t].apply(i,l))}),this}var s=undefined,f=function(e){return r[t].apply(i,[e].concat(o))};if(this.length>1){for(i=i.transpose();i.length>n;n++)e[n]=f(i[n]);return e}return f(this[0])}}(t[e])}("quantiles percentileOfScore".split(" "))}(t,Math),function(r,t){r.gammaln=function(r){var e,n,a,u=0,i=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],o=1.000000000190015;for(a=(n=e=r)+5.5,a-=(e+.5)*t.log(a);6>u;u++)o+=i[u]/++n;return t.log(2.5066282746310007*o/e)-a},r.gammafn=function(r){var e,n,a,u,i=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],o=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],s=!1,l=0,f=0,c=0,p=r;if(0>=p){if(!(u=p%1+3.6e-16))return Infinity;s=(1&p?-1:1)*t.PI/t.sin(t.PI*u),p=1-p}a=p,n=1>p?p++:(p-=l=(0|p)-1)-1;for(var e=0;8>e;++e)c=(c+i[e])*n,f=f*n+o[e];if(u=c/f+1,p>a)u/=a;else if(a>p)for(var e=0;l>e;++e)u*=p,p++;return s&&(u=s/u),u},r.gammap=function(t,e){return r.lowRegGamma(t,e)*r.gammafn(t)},r.lowRegGamma=function(e,n){var a,u=r.gammaln(e),i=e,o=1/e,s=o,l=n+1-e,f=1/1e-30,c=1/l,p=c,h=1,m=-~(8.5*t.log(1>e?1/e:e)+.4*e+17);if(0>n||0>=e)return NaN;if(e+1>n){for(;m>=h;h++)o+=s*=n/++i;return o*t.exp(-n+e*t.log(n)-u)}for(;m>=h;h++)a=-h*(h-e),l+=2,c=a*c+l,f=l+a/f,c=1/c,p*=c*f;return 1-p*t.exp(-n+e*t.log(n)-u)},r.factorialln=function(t){return 0>t?NaN:r.gammaln(t+1)},r.factorial=function(t){return 0>t?NaN:r.gammafn(t+1)},r.combination=function(e,n){return e>170||n>170?t.exp(r.combinationln(e,n)):r.factorial(e)/r.factorial(n)/r.factorial(e-n)},r.combinationln=function(t,e){return r.factorialln(t)-r.factorialln(e)-r.factorialln(t-e)},r.permutation=function(t,e){return r.factorial(t)/r.factorial(t-e)},r.betafn=function(e,n){return e>0&&n>0?e+n>170?t.exp(r.betaln(e,n)):r.gammafn(e)*r.gammafn(n)/r.gammafn(e+n):undefined},r.betaln=function(t,e){return r.gammaln(t)+r.gammaln(e)-r.gammaln(t+e)},r.betacf=function(r,e,n){var a,u,i,o,s=1,l=e+n,f=e+1,c=e-1,p=1,h=1-l*r/f;for(1e-30>t.abs(h)&&(h=1e-30),h=1/h,o=h;100>=s&&(a=2*s,u=s*(n-s)*r/((c+a)*(e+a)),h=1+u*h,1e-30>t.abs(h)&&(h=1e-30),p=1+u/p,1e-30>t.abs(p)&&(p=1e-30),h=1/h,o*=h*p,u=-(e+s)*(l+s)*r/((e+a)*(f+a)),h=1+u*h,1e-30>t.abs(h)&&(h=1e-30),p=1+u/p,1e-30>t.abs(p)&&(p=1e-30),h=1/h,i=h*p,o*=i,3e-7<=t.abs(i-1));s++);return o},r.gammapinv=function(e,n){var a,u,i,o,s,l,f,c=0,p=n-1,h=r.gammaln(n);if(e>=1)return t.max(100,n+100*t.sqrt(n));if(0>=e)return 0;for(n>1?(l=t.log(p),f=t.exp(p*(l-1)-h),s=.5>e?e:1-e,i=t.sqrt(-2*t.log(s)),a=(2.30753+.27061*i)/(1+i*(.99229+.04481*i))-i,.5>e&&(a=-a),a=t.max(.001,n*t.pow(1-1/(9*n)-a/(3*t.sqrt(n)),3))):(i=1-n*(.253+.12*n),a=i>e?t.pow(e/i,1/n):1-t.log(1-(e-i)/(1-i)));12>c;c++){if(0>=a)return 0;if(u=r.lowRegGamma(n,a)-e,i=n>1?f*t.exp(-(a-p)+p*(t.log(a)-l)):t.exp(-a+p*t.log(a)-h),o=u/i,a-=i=o/(1-.5*t.min(1,o*((n-1)/a-1))),a>0||(a=.5*(a+i)),t.abs(i)<1e-8*a)break}return a},r.erf=function(r){var e,n,a,u,i=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,9.6467911e-11,2.394038e-12,-6.886027e-12,8.94487e-13,3.13092e-13,-1.12708e-13,3.81e-16,7.106e-15,-1.523e-15,-9.4e-17,1.21e-16,-2.8e-17],o=27,s=!1,l=0,f=0;for(0>r&&(r=-r,s=!0),e=2/(2+r),n=4*e-2;o>0;o--)a=l,l=n*l-f+i[o],f=a;return u=e*t.exp(-r*r+.5*(i[0]+n*l)-f),s?u-1:1-u},r.erfc=function(t){return 1-r.erf(t)},r.erfcinv=function(e){var n,a,u,i,o=0;if(e>=2)return-100;if(0>=e)return 100;for(i=1>e?e:2-e,u=t.sqrt(-2*t.log(i/2)),n=-.70711*((2.30753+.27061*u)/(1+u*(.99229+.04481*u))-u);2>o;o++)a=r.erfc(n)-i,n+=a/(1.1283791670955126*t.exp(-n*n)-n*a);return 1>e?n:-n},r.ibetainv=function(e,n,a){var u,i,o,s,l,f,c,p,h,m,E,g=n-1,N=a-1,v=0;if(0>=e)return 0;if(e>=1)return 1;for(1>n||1>a?(u=t.log(n/(n+a)),i=t.log(a/(n+a)),s=t.exp(n*u)/n,l=t.exp(a*i)/a,m=s+l,c=s/m>e?t.pow(n*m*e,1/n):1-t.pow(a*m*(1-e),1/a)):(o=.5>e?e:1-e,s=t.sqrt(-2*t.log(o)),c=(2.30753+.27061*s)/(1+s*(.99229+.04481*s))-s,.5>e&&(c=-c),p=(c*c-3)/6,h=2/(1/(2*n-1)+1/(2*a-1)),m=c*t.sqrt(p+h)/h-(1/(2*a-1)-1/(2*n-1))*(p+5/6-2/(3*h)),c=n/(n+a*t.exp(2*m))),E=-r.gammaln(n)-r.gammaln(a)+r.gammaln(n+a);10>v;v++){if(0===c||1===c)return c;if(f=r.ibeta(c,n,a)-e,s=t.exp(g*t.log(c)+N*t.log(1-c)+E),l=f/s,c-=s=l/(1-.5*t.min(1,l*(g/c-N/(1-c)))),c>0||(c=.5*(c+s)),1>c||(c=.5*(c+s+1)),t.abs(s)<1e-8*c&&v>0)break}return c},r.ibeta=function(e,n,a){var u=0===e||1===e?0:t.exp(r.gammaln(n+a)-r.gammaln(n)-r.gammaln(a)+n*t.log(e)+a*t.log(1-e));return e>=0&&1>=e&&((n+1)/(n+a+2)>e?u*r.betacf(e,n,a)/n:1-u*r.betacf(1-e,a,n)/a)},r.randn=function(e,n){var a,u,i,o,s;if(n||(n=e),e)return r.create(e,n,function(){return r.randn()});do{a=t.random(),u=1.7156*(t.random()-.5),i=a-.449871,o=t.abs(u)+.386595,s=i*i+o*(.196*o-.25472*i)}while(s>.27597&&(s>.27846||u*u>-4*t.log(a)*a*a));return u/a},r.randg=function(e,n,a){var u,i,o,s,l,f,c=e;if(a||(a=n),e||(e=1),n)return f=r.zeros(n,a),f.alter(function(){return r.randg(e)}),f;1>e&&(e+=1),u=e-1/3,i=1/t.sqrt(9*u);do{do{l=r.randn(),s=1+i*l}while(0>=s);s*=s*s,o=t.random()}while(o>1-.331*t.pow(l,4)&&t.log(o)>.5*l*l+u*(1-s+t.log(s)));if(e==c)return u*s;do{o=t.random()}while(0===o);return t.pow(o,1/c)*u*s},function(t){for(var e=0;t.length>e;e++)!function(t){r.fn[t]=function(){return r(r.map(this,function(e){return r[t](e)}))}}(t[e])}("gammaln gammafn factorial factorialln".split(" ")),function(t){for(var e=0;t.length>e;e++)!function(t){r.fn[t]=function(){return r(r[t].apply(null,arguments))}}(t[e])}("randn".split(" "))}(t,Math),function(r,t){function e(r){return r/t.abs(r)}function n(e,n,a){var u=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],i=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],o=.5*e;if(o>=8)return 1;var s=2*r.normal.cdf(o,0,1,1,0)-1;s=s3?2:3;for(var f=o,c=(8-o)/l,p=f+c,h=0,m=a-1,E=1;l>=E;E++){for(var g=0,N=.5*(p+f),v=.5*(p-f),d=1;12>=d;d++){var I,b;d>6?(I=12-d+1,b=u[I-1]):(I=d,b=-u[I-1]);var y=v*b,M=N+y,A=M*M;if(A>60)break;var R=2*r.normal.cdf(M,0,1,1,0),S=2*r.normal.cdf(M,e,1,1,0),T=.5*R-.5*S;Tt.exp(-30/n)?(s=t.pow(s,n),1>s?s:1):0}function a(r,e,n){var a=.5-.5*r,u=t.sqrt(t.log(1/(a*a))),i=u+((((-453642210148e-16*u-.204231210125)*u-.342242088547)*u-1)*u+.322232421088)/((((.0038560700634*u+.10353775285)*u+.531103462366)*u+.588581570495)*u+.099348462606);120>n&&(i+=(i*i*i+i)/n/4);var o=.8832-.2368*i;return 120>n&&(o+=-1.214/n+1.208*i/n),i*(o*t.log(e-1)+1.4142)}!function(t){for(var e=0;t.length>e;e++)!function(t){r[t]=function(r,t,e){return this instanceof arguments.callee?(this._a=r,this._b=t,this._c=e,this):new arguments.callee(r,t,e)},r.fn[t]=function(e,n,a){var u=r[t](e,n,a);return u.data=this,u},r[t].prototype.sample=function(e){var n=this._a,a=this._b,u=this._c;return e?r.alter(e,function(){return r[t].sample(n,a,u)}):r[t].sample(n,a,u)},function(e){for(var n=0;e.length>n;n++)!function(e){r[t].prototype[e]=function(n){var a=this._a,u=this._b,i=this._c;return n||0===n||(n=this.data),"number"!=typeof n?r.fn.map.call(n,function(n){return r[t][e](n,a,u,i)}):r[t][e](n,a,u,i)}}(e[n])}("pdf cdf inv".split(" ")),function(e){for(var n=0;e.length>n;n++)!function(e){r[t].prototype[e]=function(){return r[t][e](this._a,this._b,this._c)}}(e[n])}("mean median mode variance".split(" "))}(t[e])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),r.extend(r.beta,{pdf:function(e,n,a){return e>1||0>e?0:1==n&&1==a?1:512>n&&512>a?t.pow(e,n-1)*t.pow(1-e,a-1)/r.betafn(n,a):t.exp((n-1)*t.log(e)+(a-1)*t.log(1-e)-r.betaln(n,a))},cdf:function(t,e,n){return t>1||0>t?1*(t>1):r.ibeta(t,e,n)},inv:function(t,e,n){return r.ibetainv(t,e,n)},mean:function(r,t){return r/(r+t)},median:function(t,e){return r.ibetainv(.5,t,e)},mode:function(r,t){return(r-1)/(r+t-2)},sample:function(t,e){var n=r.randg(t);return n/(n+r.randg(e))},variance:function(r,e){return r*e/(t.pow(r+e,2)*(r+e+1))}}),r.extend(r.centralF,{pdf:function(e,n,a){var u,i;return 0>e?0:n>2?(u=n*e/(a+e*n),i=a/(a+e*n),n*i/2*r.binomial.pdf((n-2)/2,(n+a-2)/2,u)):0===e&&2>n?Infinity:0===e&&2===n?1:1/r.betafn(n/2,a/2)*t.pow(n/a,n/2)*t.pow(e,n/2-1)*t.pow(1+n/a*e,-(n+a)/2)},cdf:function(t,e,n){return 0>t?0:r.ibeta(e*t/(e*t+n),e/2,n/2)},inv:function(t,e,n){return n/(e*(1/r.ibetainv(t,e/2,n/2)-1))},mean:function(r,t){return t>2?t/(t-2):undefined},mode:function(r,t){return r>2?t*(r-2)/(r*(t+2)):undefined},sample:function(t,e){return 2*r.randg(t/2)/t/(2*r.randg(e/2)/e)},variance:function(r,t){return t>4?2*t*t*(r+t-2)/(r*(t-2)*(t-2)*(t-4)):undefined}}),r.extend(r.cauchy,{pdf:function(r,e,n){return 0>n?0:n/(t.pow(r-e,2)+t.pow(n,2))/t.PI},cdf:function(r,e,n){return t.atan((r-e)/n)/t.PI+.5},inv:function(r,e,n){return e+n*t.tan(t.PI*(r-.5))},median:function(r,t){return r},mode:function(r,t){return r},sample:function(e,n){return r.randn()*t.sqrt(1/(2*r.randg(.5)))*n+e}}),r.extend(r.chisquare,{pdf:function(e,n){return 0>e?0:0===e&&2===n?.5:t.exp((n/2-1)*t.log(e)-e/2-n/2*t.log(2)-r.gammaln(n/2))},cdf:function(t,e){return 0>t?0:r.lowRegGamma(e/2,t/2)},inv:function(t,e){return 2*r.gammapinv(t,.5*e)},mean:function(r){return r},median:function(r){return r*t.pow(1-2/(9*r),3)},mode:function(r){return r-2>0?r-2:0},sample:function(t){return 2*r.randg(t/2)},variance:function(r){return 2*r}}),r.extend(r.exponential,{pdf:function(r,e){return 0>r?0:e*t.exp(-e*r)},cdf:function(r,e){return 0>r?0:1-t.exp(-e*r)},inv:function(r,e){return-t.log(1-r)/e},mean:function(r){return 1/r},median:function(r){return 1/r*t.log(2)},mode:function(r){return 0},sample:function(r){return-1/r*t.log(t.random())},variance:function(r){return t.pow(r,-2)}}),r.extend(r.gamma,{pdf:function(e,n,a){return 0>e?0:0===e&&1===n?1/a:t.exp((n-1)*t.log(e)-e/a-r.gammaln(n)-n*t.log(a))},cdf:function(t,e,n){return 0>t?0:r.lowRegGamma(e,t/n)},inv:function(t,e,n){return r.gammapinv(t,e)*n},mean:function(r,t){return r*t},mode:function(r,t){return r>1?(r-1)*t:undefined},sample:function(t,e){return r.randg(t)*e},variance:function(r,t){return r*t*t}}),r.extend(r.invgamma,{pdf:function(e,n,a){return e>0?t.exp(-(n+1)*t.log(e)-a/e-r.gammaln(n)+n*t.log(a)):0},cdf:function(t,e,n){return t>0?1-r.lowRegGamma(e,n/t):0},inv:function(t,e,n){return n/r.gammapinv(1-t,e)},mean:function(r,t){return r>1?t/(r-1):undefined},mode:function(r,t){return t/(r+1)},sample:function(t,e){return e/r.randg(t)},variance:function(r,t){return r>2?t*t/((r-1)*(r-1)*(r-2)):undefined}}),r.extend(r.kumaraswamy,{pdf:function(r,e,n){return 0===r&&1===e?n:1===r&&1===n?e:t.exp(t.log(e)+t.log(n)+(e-1)*t.log(r)+(n-1)*t.log(1-t.pow(r,e)))},cdf:function(r,e,n){return 0>r?0:r>1?1:1-t.pow(1-t.pow(r,e),n)},inv:function(r,e,n){return t.pow(1-t.pow(1-r,1/n),1/e)},mean:function(t,e){return e*r.gammafn(1+1/t)*r.gammafn(e)/r.gammafn(1+1/t+e)},median:function(r,e){return t.pow(1-t.pow(2,-1/e),1/r)},mode:function(r,e){return 1>r||1>e||1===r||1===e?undefined:t.pow((r-1)/(r*e-1),1/r)},variance:function(r,t){throw Error("variance not yet implemented")}}),r.extend(r.lognormal,{pdf:function(r,e,n){return r>0?t.exp(-t.log(r)-.5*t.log(2*t.PI)-t.log(n)-t.pow(t.log(r)-e,2)/(2*n*n)):0},cdf:function(e,n,a){return 0>e?0:.5+.5*r.erf((t.log(e)-n)/t.sqrt(2*a*a))},inv:function(e,n,a){return t.exp(-1.4142135623730951*a*r.erfcinv(2*e)+n)},mean:function(r,e){return t.exp(r+e*e/2)},median:function(r,e){return t.exp(r)},mode:function(r,e){return t.exp(r-e*e)},sample:function(e,n){return t.exp(r.randn()*n+e)},variance:function(r,e){return(t.exp(e*e)-1)*t.exp(2*r+e*e)}}),r.extend(r.noncentralt,{pdf:function(e,n,a){return 1e-14>t.abs(a)?r.studentt.pdf(e,n):1e-14>t.abs(e)?t.exp(r.gammaln((n+1)/2)-a*a/2-.5*t.log(t.PI*n)-r.gammaln(n/2)):n/e*(r.noncentralt.cdf(e*t.sqrt(1+2/n),n+2,a)-r.noncentralt.cdf(e,n,a))},cdf:function(e,n,a){if(1e-14>t.abs(a))return r.studentt.cdf(e,n);var u=!1;0>e&&(u=!0,a=-a);for(var i=r.normal.cdf(-a,0,1),o=1e-14+1,s=o,l=e*e/(e*e+n),f=0,c=t.exp(-a*a/2),p=t.exp(-a*a/2-.5*t.log(2)-r.gammaln(1.5))*a;200>f||s>1e-14||o>1e-14;)s=o,f>0&&(c*=a*a/(2*f),p*=a*a/(2*(f+.5))),o=c*r.beta.cdf(l,f+.5,n/2)+p*r.beta.cdf(l,f+1,n/2),i+=.5*o,f++;return u?1-i:i}}),r.extend(r.normal,{pdf:function(r,e,n){return t.exp(-.5*t.log(2*t.PI)-t.log(n)-t.pow(r-e,2)/(2*n*n))},cdf:function(e,n,a){return.5*(1+r.erf((e-n)/t.sqrt(2*a*a)))},inv:function(t,e,n){return-1.4142135623730951*n*r.erfcinv(2*t)+e},mean:function(r,t){return r},median:function(r,t){return r},mode:function(r,t){return r},sample:function(t,e){return r.randn()*e+t},variance:function(r,t){return t*t}}),r.extend(r.pareto,{pdf:function(r,e,n){return e>r?0:n*t.pow(e,n)/t.pow(r,n+1)},cdf:function(r,e,n){return e>r?0:1-t.pow(e/r,n)},inv:function(r,e,n){return e/t.pow(1-r,1/n)},mean:function(r,e){return e>1?e*t.pow(r,e)/(e-1):undefined},median:function(r,e){return r*(e*t.SQRT2)},mode:function(r,t){return r},variance:function(r,e){return e>2?r*r*e/(t.pow(e-1,2)*(e-2)):undefined}}),r.extend(r.studentt,{pdf:function(e,n){return n=n>1e100?1e100:n,1/(t.sqrt(n)*r.betafn(.5,n/2))*t.pow(1+e*e/n,-(n+1)/2)},cdf:function(e,n){var a=n/2;return r.ibeta((e+t.sqrt(e*e+n))/(2*t.sqrt(e*e+n)),a,a)},inv:function(e,n){var a=r.ibetainv(2*t.min(e,1-e),.5*n,.5);return a=t.sqrt(n*(1-a)/a),e>.5?a:-a},mean:function(r){return r>1?0:undefined},median:function(r){return 0},mode:function(r){return 0},sample:function(e){return r.randn()*t.sqrt(e/(2*r.randg(e/2)))},variance:function(r){return r>2?r/(r-2):r>1?Infinity:undefined}}),r.extend(r.weibull,{pdf:function(r,e,n){return 0>r||0>e||0>n?0:n/e*t.pow(r/e,n-1)*t.exp(-t.pow(r/e,n))},cdf:function(r,e,n){return 0>r?0:1-t.exp(-t.pow(r/e,n))},inv:function(r,e,n){return e*t.pow(-t.log(1-r),1/n)},mean:function(t,e){return t*r.gammafn(1+1/e)},median:function(r,e){return r*t.pow(t.log(2),1/e)},mode:function(r,e){return e>1?r*t.pow((e-1)/e,1/e):0},sample:function(r,e){return r*t.pow(-t.log(t.random()),1/e)},variance:function(e,n){return e*e*r.gammafn(1+2/n)-t.pow(r.weibull.mean(e,n),2)}}),r.extend(r.uniform,{pdf:function(r,t,e){return t>r||r>e?0:1/(e-t)},cdf:function(r,t,e){return t>r?0:e>r?(r-t)/(e-t):1},inv:function(r,t,e){return t+r*(e-t)},mean:function(r,t){return.5*(r+t)},median:function(t,e){return r.mean(t,e)},mode:function(r,t){throw Error("mode is not yet implemented")},sample:function(r,e){return r/2+e/2+(e/2-r/2)*(2*t.random()-1)},variance:function(r,e){return t.pow(e-r,2)/12}}),r.extend(r.binomial,{pdf:function(e,n,a){return 0===a||1===a?n*a===e?1:0:r.combination(n,e)*t.pow(a,e)*t.pow(1-a,n-e)},cdf:function(t,e,n){var a=[],u=0;if(0>t)return 0;if(e>t){for(;t>=u;u++)a[u]=r.binomial.pdf(u,e,n);return r.sum(a)}return 1}}),r.extend(r.negbin,{pdf:function(e,n,a){return e===e>>>0&&(0>e?0:r.combination(e+n-1,n-1)*t.pow(1-a,e)*t.pow(a,n))},cdf:function(t,e,n){var a=0,u=0;if(0>t)return 0;for(;t>=u;u++)a+=r.negbin.pdf(u,e,n);return a}}),r.extend(r.hypgeom,{pdf:function(e,n,a,u){if(e!==e|0)return!1;if(0>e||a-(n-u)>e)return 0;if(e>u||e>a)return 0;if(2*a>n)return 2*u>n?r.hypgeom.pdf(n-a-u+e,n,n-a,n-u):r.hypgeom.pdf(u-e,n,n-a,u);if(2*u>n)return r.hypgeom.pdf(a-e,n,a,n-u);if(u>a)return r.hypgeom.pdf(e,n,u,a);for(var i=1,o=0,s=0;e>s;s++){for(;i>1&&u>o;)i*=1-a/(n-o),o++;i*=(u-s)*(a-s)/((s+1)*(n-a-u+s+1))}for(;u>o;o++)i*=1-a/(n-o);return t.min(1,t.max(0,i))},cdf:function(e,n,a,u){if(0>e||a-(n-u)>e)return 0;if(u>e&&a>e){if(2*a>n)return 2*u>n?r.hypgeom.cdf(n-a-u+e,n,n-a,n-u):1-r.hypgeom.cdf(u-e-1,n,n-a,u);if(2*u>n)return 1-r.hypgeom.cdf(a-e-1,n,a,n-u);if(u>a)return r.hypgeom.cdf(e,n,u,a);for(var i=1,o=1,s=0,l=0;e>l;l++){for(;i>1&&u>s;){var f=1-a/(n-s);o*=f,i*=f,s++}o*=(u-l)*(a-l)/((l+1)*(n-a-u+l+1)),i+=o}for(;u>s;s++)i*=1-a/(n-s);return t.min(1,t.max(0,i))}return 1}}),r.extend(r.poisson,{pdf:function(e,n){return 0>n||e%1!=0||0>e?0:t.pow(n,e)*t.exp(-n)/r.factorial(e)},cdf:function(t,e){var n=[],a=0;if(0>t)return 0;for(;t>=a;a++)n.push(r.poisson.pdf(a,e));return r.sum(n)},mean:function(r){return r},variance:function(r){return r},sample:function(r){var e=1,n=0,a=t.exp(-r);do{n++,e*=t.random()}while(e>a);return n-1}}),r.extend(r.triangular,{pdf:function(r,t,e,n){return t>=e||t>n||n>e?NaN:t>r||r>e?0:n>r?2*(r-t)/((e-t)*(n-t)):r===n?2/(e-t):2*(e-r)/((e-t)*(e-n))},cdf:function(r,e,n,a){return e>=n||e>a||a>n?NaN:r>e?n>r?r>a?1-t.pow(n-r,2)/((n-e)*(n-a)):t.pow(r-e,2)/((n-e)*(a-e)):1:0},inv:function(r,e,n,a){return e>=n||e>a||a>n?NaN:r>(a-e)/(n-e)?e+(n-e)*(1-t.sqrt((1-r)*(1-(a-e)/(n-e)))):e+(n-e)*t.sqrt(r*((a-e)/(n-e)))},mean:function(r,t,e){return(r+t+e)/3},median:function(r,e,n){return n>(r+e)/2?n>(r+e)/2?r+t.sqrt((e-r)*(n-r))/t.sqrt(2):void 0:e-t.sqrt((e-r)*(e-n))/t.sqrt(2)},mode:function(r,t,e){return e},sample:function(r,e,n){var a=t.random();return(n-r)/(e-r)>a?r+t.sqrt(a*(e-r)*(n-r)):e-t.sqrt((1-a)*(e-r)*(e-n))},variance:function(r,t,e){return(r*r+t*t+e*e-r*t-r*e-t*e)/18}}),r.extend(r.arcsine,{pdf:function(r,e,n){return n>e?r>e&&n>r?2/t.PI*t.pow(t.pow(n-e,2)-t.pow(2*r-e-n,2),-.5):0:NaN},cdf:function(r,e,n){return e>r?0:n>r?2/t.PI*t.asin(t.sqrt((r-e)/(n-e))):1},inv:function(r,e,n){return e+(.5-.5*t.cos(t.PI*r))*(n-e)},mean:function(r,t){return t>r?(r+t)/2:NaN},median:function(r,t){return t>r?(r+t)/2:NaN},mode:function(r,t){throw Error("mode is not yet implemented")},sample:function(e,n){return(e+n)/2+(n-e)/2*t.sin(2*t.PI*r.uniform.sample(0,1))},variance:function(r,e){return e>r?t.pow(e-r,2)/8:NaN}}),r.extend(r.laplace,{pdf:function(r,e,n){return n>0?t.exp(-t.abs(r-e)/n)/(2*n):0},cdf:function(r,e,n){return n>0?e>r?.5*t.exp((r-e)/n):1-.5*t.exp(-(r-e)/n):0},mean:function(r,t){return r},median:function(r,t){return r},mode:function(r,t){return r},variance:function(r,t){return 2*t*t},sample:function(r,n){var a=t.random()-.5;return r-n*e(a)*t.log(1-2*t.abs(a))}}),r.extend(r.tukey,{cdf:function(e,a,u){var i=a,o=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],s=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(0>=e)return 0;if(2>u||2>i)return NaN;if(!Number.isFinite(e))return 1;if(u>25e3)return n(e,1,i);var l,f=.5*u,c=f*t.log(u)-u*t.log(2)-r.gammaln(f),p=f-1,h=.25*u;l=u>100?u>800?u>5e3?.125:.25:.5:1,c+=t.log(l);for(var m=0,E=1;50>=E;E++){for(var g=0,N=(2*E-1)*l,v=1;16>=v;v++){var d,I;v>8?(d=v-8-1,I=c+p*t.log(N+o[d]*l)-(o[d]*l+N)*h):(d=v-1,I=c+p*t.log(N-o[d]*l)+(o[d]*l-N)*h);var b;if(I>=-30){b=v>8?e*t.sqrt(.5*(o[d]*l+N)):e*t.sqrt(.5*(-o[d]*l+N));g+=n(b,1,i)*s[d]*t.exp(I)}}if(E*l>=1&&1e-14>=g)break;m+=g}if(g>1e-14)throw Error("tukey.cdf failed to converge");return m>1&&(m=1),m},inv:function(e,n,u){var i=n;if(2>u||2>i)return NaN;if(0>e||e>1)return NaN;if(0===e)return 0;if(1===e)return Infinity;var o,s=a(e,i,u),l=r.tukey.cdf(s,n,u)-e;o=l>0?t.max(0,s-1):s+1;for(var f,c=r.tukey.cdf(o,n,u)-e,p=1;50>p;p++){f=o-c*(o-s)/(c-l),l=c,s=o,0>f&&(f=0,c=-e),c=r.tukey.cdf(f,n,u)-e,o=f;if(1e-4>t.abs(o-s))return f}throw Error("tukey.inv failed to converge")}})}(t,Math),function(t,e){function n(r){return u(r)||r instanceof t}var a=Array.prototype.push,u=t.utils.isArray;t.extend({add:function(r,e){return n(e)?(n(e[0])||(e=[e]),t.map(r,function(r,t,n){return r+e[t][n]})):t.map(r,function(r){return r+e})},subtract:function(r,e){return n(e)?(n(e[0])||(e=[e]),t.map(r,function(r,t,n){return r-e[t][n]||0})):t.map(r,function(r){return r-e})},divide:function(r,e){return n(e)?(n(e[0])||(e=[e]),t.multiply(r,t.inv(e))):t.map(r,function(r){return r/e})},multiply:function(r,e){var a,u,i,o,s,l,f,c;if(r.length===undefined&&e.length===undefined)return r*e;if(s=r.length,l=r[0].length,f=t.zeros(s,i=n(e)?e[0].length:l),c=0,n(e)){for(;i>c;c++)for(a=0;s>a;a++){for(o=0,u=0;l>u;u++)o+=r[a][u]*e[u][c];f[a][c]=o}return 1===s&&1===c?f[0][0]:f}return t.map(r,function(r){return r*e})},outer:function(r,e){return t.multiply(r.map(function(r){return[r]}),[e])},dot:function(r,e){n(r[0])||(r=[r]),n(e[0])||(e=[e]);for(var a,u,i=1===r[0].length&&1!==r.length?t.transpose(r):r,o=1===e[0].length&&1!==e.length?t.transpose(e):e,s=[],l=0,f=i.length,c=i[0].length;f>l;l++){for(s[l]=[],a=0,u=0;c>u;u++)a+=i[l][u]*o[l][u];s[l]=a}return 1===s.length?s[0]:s},pow:function(r,n){return t.map(r,function(r){return e.pow(r,n)})},exp:function(r){return t.map(r,function(r){return e.exp(r)})},log:function(r){return t.map(r,function(r){return e.log(r)})},abs:function(r){return t.map(r,function(r){return e.abs(r)})},norm:function(r,t){var a=0,u=0;for(isNaN(t)&&(t=2),n(r[0])&&(r=r[0]);r.length>u;u++)a+=e.pow(e.abs(r[u]),t);return e.pow(a,1/t)},angle:function(r,n){return e.acos(t.dot(r,n)/(t.norm(r)*t.norm(n)))},aug:function(r,t){for(var e=[],n=0;r.length>n;n++)e.push(r[n].slice());for(var n=0;e.length>n;n++)a.apply(e[n],t[n]);return e},inv:function(r){for(var e,n=r.length,a=r[0].length,u=t.identity(n,a),i=t.gauss_jordan(r,u),o=[],s=0;n>s;s++)for(o[s]=[],e=a;i[0].length>e;e++)o[s][e-a]=i[s][e];return o},det:function(r){var t,e=r.length,n=2*e,a=Array(n),u=e-1,i=n-1,o=u-e+1,s=i,l=0,f=0;if(2===e)return r[0][0]*r[1][1]-r[0][1]*r[1][0];for(;n>l;l++)a[l]=1;for(var l=0;e>l;l++){for(t=0;e>t;t++)a[0>o?o+e:o]*=r[l][t],a[e>s?s+e:s]*=r[l][t],o++,s--;o=--u-e+1,s=--i}for(var l=0;e>l;l++)f+=a[l];for(;n>l;l++)f-=a[l];return f},gauss_elimination:function(r,n){var a,u,i,o,s=0,l=0,f=r.length,c=r[0].length,p=1,h=0,m=[];r=t.aug(r,n),a=r[0].length;for(var s=0;f>s;s++){for(u=r[s][s],l=s,o=s+1;c>o;o++)uo;o++)i=r[s][o],r[s][o]=r[l][o],r[l][o]=i;for(l=s+1;f>l;l++)for(p=r[l][s]/r[s][s],o=s;a>o;o++)r[l][o]=r[l][o]-p*r[s][o]}for(var s=f-1;s>=0;s--){for(h=0,l=s+1;f-1>=l;l++)h+=m[l]*r[s][l];m[s]=(r[s][a-1]-h)/r[s][s]}return m},gauss_jordan:function(r,n){for(var a=t.aug(r,n),u=a.length,i=a[0].length,o=0,s=0;u>s;s++){for(var l=s,f=s+1;u>f;f++)e.abs(a[f][s])>e.abs(a[l][s])&&(l=f);var c=a[s];a[s]=a[l],a[l]=c;for(var f=s+1;u>f;f++){o=a[f][s]/a[s][s];for(var p=s;i>p;p++)a[f][p]-=a[s][p]*o}}for(var s=u-1;s>=0;s--){o=a[s][s];for(var f=0;s>f;f++)for(var p=i-1;p>s-1;p--)a[f][p]-=a[s][p]*a[f][s]/o;a[s][s]/=o;for(var p=u;i>p;p++)a[s][p]/=o}return a},triaUpSolve:function(r,e){var n,a=r[0].length,u=t.zeros(1,a)[0],i=!1;return e[0].length!=undefined&&(e=e.map(function(r){return r[0]}),i=!0),t.arange(a-1,-1,-1).forEach(function(i){n=t.arange(i+1,a).map(function(t){return u[t]*r[i][t]}),u[i]=(e[i]-t.sum(n))/r[i][i]}),i?u.map(function(r){return[r]}):u},triaLowSolve:function(r,e){var n,a=r[0].length,u=t.zeros(1,a)[0],i=!1;return e[0].length!=undefined&&(e=e.map(function(r){return r[0]}),i=!0),t.arange(a).forEach(function(a){n=t.arange(a).map(function(t){return r[a][t]*u[t]}),u[a]=(e[a]-t.sum(n))/r[a][a]}),i?u.map(function(r){return[r]}):u},lu:function(r){var e,n=r.length,a=t.identity(n),u=t.zeros(r.length,r[0].length);return t.arange(n).forEach(function(t){u[0][t]=r[0][t]}),t.arange(1,n).forEach(function(o){t.arange(o).forEach(function(n){e=t.arange(n).map(function(r){return a[o][r]*u[r][n]}),a[o][n]=(r[o][n]-t.sum(e))/u[n][n]}),t.arange(o,n).forEach(function(n){e=t.arange(o).map(function(r){return a[o][r]*u[r][n]}),u[o][n]=r[i][n]-t.sum(e)})}),[a,u]},cholesky:function(r){var n,a=r.length,u=t.zeros(r.length,r[0].length);return t.arange(a).forEach(function(i){n=t.arange(i).map(function(r){return e.pow(u[i][r],2)}),u[i][i]=e.sqrt(r[i][i]-t.sum(n)),t.arange(i+1,a).forEach(function(e){n=t.arange(i).map(function(r){return u[i][r]*u[e][r]}),u[e][i]=(r[i][e]-t.sum(n))/u[i][i]})}),u},gauss_jacobi:function(r,n,a,u){for(var i,o,s,l,f=0,c=0,p=r.length,h=[],m=[],E=[];p>f;f++)for(h[f]=[],m[f]=[],E[f]=[],c=0;p>c;c++)f>c?(h[f][c]=r[f][c],m[f][c]=E[f][c]=0):c>f?(m[f][c]=r[f][c],h[f][c]=E[f][c]=0):(E[f][c]=r[f][c],h[f][c]=m[f][c]=0);for(s=t.multiply(t.multiply(t.inv(E),t.add(h,m)),-1),o=t.multiply(t.inv(E),n),i=a,l=t.add(t.multiply(s,a),o),f=2;e.abs(t.norm(t.subtract(l,i)))>u;)i=l,l=t.add(t.multiply(s,i),o),f++;return l},gauss_seidel:function(r,n,a,u){for(var i,o,s,l,f,c=0,p=r.length,h=[],m=[],E=[];p>c;c++)for(h[c]=[],m[c]=[],E[c]=[],i=0;p>i;i++)c>i?(h[c][i]=r[c][i],m[c][i]=E[c][i]=0):i>c?(m[c][i]=r[c][i],h[c][i]=E[c][i]=0):(E[c][i]=r[c][i],h[c][i]=m[c][i]=0);for(l=t.multiply(t.multiply(t.inv(t.add(E,h)),m),-1),s=t.multiply(t.inv(t.add(E,h)),n),o=a,f=t.add(t.multiply(l,a),s),c=2;e.abs(t.norm(t.subtract(f,o)))>u;)o=f,f=t.add(t.multiply(l,o),s),c+=1;return f},SOR:function(r,n,a,u,i){for(var o,s,l,f,c,p=0,h=r.length,m=[],E=[],g=[];h>p;p++)for(m[p]=[],E[p]=[],g[p]=[],o=0;h>o;o++)p>o?(m[p][o]=r[p][o],E[p][o]=g[p][o]=0):o>p?(E[p][o]=r[p][o],m[p][o]=g[p][o]=0):(g[p][o]=r[p][o],m[p][o]=E[p][o]=0);for(f=t.multiply(t.inv(t.add(g,t.multiply(m,i))),t.subtract(t.multiply(g,1-i),t.multiply(E,i))),l=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(m,i))),n),i),s=a,c=t.add(t.multiply(f,a),l),p=2;e.abs(t.norm(t.subtract(c,s)))>u;)s=c,c=t.add(t.multiply(f,s),l),p++;return c},householder:function(r){for(var n,a,u,i,o,s=r.length,l=r[0].length,f=0,c=[],p=[];s-1>f;f++){for(n=0,i=f+1;l>i;i++)n+=r[i][f]*r[i][f];for(o=r[f+1][f]>0?-1:1,n=o*e.sqrt(n),a=e.sqrt((n*n-r[f+1][f]*n)/2),c=t.zeros(s,1),c[f+1][0]=(r[f+1][f]-n)/(2*a),u=f+2;s>u;u++)c[u][0]=r[u][f]/(2*a);p=t.subtract(t.identity(s,l),t.multiply(t.multiply(c,t.transpose(c)),2)),r=t.multiply(p,t.multiply(r,p))}return r},QR:function(){function n(n){var i=n.length,o=n[0].length;n=t.copy(n),r=t.zeros(o,o);var s,l,f;for(l=0;o>l;l++){for(r[l][l]=e.sqrt(a(u(i).map(function(r){return n[r][l]*n[r][l]}))),s=0;i>s;s++)n[s][l]=n[s][l]/r[l][l];for(f=l+1;o>f;f++)for(r[l][f]=a(u(i).map(function(r){return n[r][l]*n[r][f]})),s=0;i>s;s++)n[s][f]=n[s][f]-n[s][l]*r[l][f]}return[n,r]}var a=t.sum,u=t.arange;return n}(),lstsq:function(r,e){function n(r){r=t.copy(r);var e=r.length,n=t.identity(e);return t.arange(e-1,-1,-1).forEach(function(e){t.sliceAssign(n,{row:e},t.divide(t.slice(n,{row:e}),r[e][e])),t.sliceAssign(r,{row:e},t.divide(t.slice(r,{row:e}),r[e][e])),t.arange(e).forEach(function(a){var u=t.multiply(r[a][e],-1),i=t.slice(r,{row:a}),o=t.multiply(t.slice(r,{row:e}),u);t.sliceAssign(r,{row:a},t.add(i,o));var s=t.slice(n,{row:a}),l=t.multiply(t.slice(n,{row:e}),u);t.sliceAssign(n,{row:a},t.add(s,l))})}),n}function a(r,e){var a=!1;e[0].length===undefined&&(e=e.map(function(r){return[r]}),a=!0);var u=t.QR(r),i=u[0],o=u[1],s=r[0].length,l=t.slice(i,{col:{end:s}}),f=t.slice(o,{row:{end:s}}),c=n(f),p=t.transpose(l);p[0].length===undefined&&(p=[p]);var h=t.multiply(t.multiply(c,p),e);return h.length===undefined&&(h=[[h]]),a?h.map(function(r){return r[0]}):h}return a}(),jacobi:function(r){for(var n,a,u,i,o,s,l,f,c=1,p=0,h=r.length,m=t.identity(h,h),E=[];1===c;){p++,s=r[0][1],i=0,o=1;for(var a=0;h>a;a++)for(u=0;h>u;u++)a!=u&&s0?e.PI/4:-e.PI/4:e.atan(2*r[i][o]/(r[i][i]-r[o][o]))/2,f=t.identity(h,h),f[i][i]=e.cos(l),f[i][o]=-e.sin(l),f[o][i]=e.sin(l),f[o][o]=e.cos(l),m=t.multiply(m,f),n=t.multiply(t.multiply(t.inv(f),r),f),r=n,c=0;for(var a=1;h>a;a++)for(u=1;h>u;u++)a!=u&&e.abs(r[a][u])>.001&&(c=1)}for(var a=0;h>a;a++)E.push(r[a][a]);return[m,E]},rungekutta:function(r,t,e,n,a,u){var i,o,s,l,f;if(2===u)for(;e>=n;)i=t*r(n,a),o=t*r(n+t,a+i),s=a+(i+o)/2,a=s,n+=t;if(4===u)for(;e>=n;)i=t*r(n,a),o=t*r(n+t/2,a+i/2),l=t*r(n+t/2,a+o/2),f=t*r(n+t,a+l),s=a+(i+2*o+2*l+f)/6,a=s,n+=t;return a},romberg:function(r,t,n,a){for(var u,i,o,s,l,f=0,c=(n-t)/2,p=[],h=[],m=[];a/2>f;){for(l=r(t),o=t,s=0;n>=o;o+=c,s++)p[s]=o;for(u=p.length,o=1;u-1>o;o++)l+=(o%2!=0?4:2)*r(p[o]);l=c/3*(l+r(n)),m[f]=l,c/=2,f++}for(i=m.length,u=1;1!==i;){for(o=0;i-1>o;o++)h[o]=(e.pow(4,u)*m[o+1]-m[o])/(e.pow(4,u)-1);i=h.length,m=h,h=[],u++}return m},richardson:function(r,t,n,a){function u(r,t){for(var e,n=0,a=r.length;a>n;n++)r[n]===t&&(e=n);return e}for(var i,o,s,l,f,c=e.abs(n-r[u(r,n)+1]),p=0,h=[],m=[];a>=c;)i=u(r,n+a),o=u(r,n),h[p]=(t[i]-2*t[o]+t[2*o-i])/(a*a),a/=2,p++;for(l=h.length,s=1;1!=l;){for(f=0;l-1>f;f++)m[f]=(e.pow(4,s)*h[f+1]-h[f])/(e.pow(4,s)-1);l=m.length,h=m,m=[],s++}return h},simpson:function(r,t,e,n){for(var a,u=(e-t)/n,i=r(t),o=[],s=t,l=0,f=1;e>=s;s+=u,l++)o[l]=s;for(a=o.length;a-1>f;f++)i+=(f%2!=0?4:2)*r(o[f]);return u/3*(i+r(e))},hermite:function(r,t,e,n){for(var a,u=r.length,i=0,o=0,s=[],l=[],f=[],c=[];u>o;o++){for(s[o]=1,a=0;u>a;a++)o!=a&&(s[o]*=(n-r[a])/(r[o]-r[a]));for(l[o]=0,a=0;u>a;a++)o!=a&&(l[o]+=1/(r[o]-r[a]));f[o]=s[o]*s[o]*(1-2*(n-r[o])*l[o]),c[o]=s[o]*s[o]*(n-r[o]),i+=f[o]*t[o]+c[o]*e[o]}return i},lagrange:function(r,t,e){for(var n,a,u=0,i=0,o=r.length;o>i;i++){for(a=t[i],n=0;o>n;n++)i!=n&&(a*=(e-r[n])/(r[i]-r[n]));u+=a}return u},cubic_spline:function(r,e,n){for(var a,u=r.length,i=0,o=[],s=[],l=[],f=[],c=[],p=[],h=[];u-1>i;i++)c[i]=r[i+1]-r[i];l[0]=0;for(var i=1;u-1>i;i++)l[i]=3/c[i]*(e[i+1]-e[i])-3/c[i-1]*(e[i]-e[i-1]);for(var i=1;u-1>i;i++)o[i]=[],s[i]=[],o[i][i-1]=c[i-1],o[i][i]=2*(c[i-1]+c[i]),o[i][i+1]=c[i],s[i][0]=l[i];for(f=t.multiply(t.inv(o),s),a=0;u-1>a;a++)p[a]=(e[a+1]-e[a])/c[a]-c[a]*(f[a+1][0]+2*f[a][0])/3,h[a]=(f[a+1][0]-f[a][0])/(3*c[a]);for(a=0;u>a&&r[a]<=n;a++);return a-=1,e[a]+(n-r[a])*p[a]+t.sq(n-r[a])*f[a]+(n-r[a])*t.sq(n-r[a])*h[a]},gauss_quadrature:function(){throw Error("gauss_quadrature not yet implemented")},PCA:function(r){for(var e,n,a=r.length,u=r[0].length,i=0,o=[],s=[],l=[],f=[],c=[],p=[],h=[],m=[],E=[],g=[],i=0;a>i;i++)o[i]=t.sum(r[i])/u;for(var i=0;u>i;i++)for(h[i]=[],e=0;a>e;e++)h[i][e]=r[e][i]-o[e];h=t.transpose(h);for(var i=0;a>i;i++)for(m[i]=[],e=0;a>e;e++)m[i][e]=t.dot([h[i]],[h[e]])/(u-1);l=t.jacobi(m),E=l[0],s=l[1],g=t.transpose(E);for(var i=0;s.length>i;i++)for(e=i;s.length>e;e++)s[e]>s[i]&&(n=s[i],s[i]=s[e],s[e]=n,f=g[i],g[i]=g[e],g[e]=f);p=t.transpose(h);for(var i=0;a>i;i++)for(c[i]=[],e=0;p.length>e;e++)c[i][e]=t.dot([g[i]],[p[e]]);return[r,s,g,c]}}),function(r){for(var e=0;r.length>e;e++)!function(r){t.fn[r]=function(e,n){var a=this;return n?(setTimeout(function(){n.call(a,t.fn[r].call(a,e))},15),this):"number"==typeof t[r](this,e)?t[r](this,e):t(t[r](this,e))}}(r[e])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(t,Math),function(r,t){function e(r,e,n,a){if(r>1||n>1||0>=r||0>=n)throw Error("Proportions should be greater than 0 and less than 1");var u=(r*e+n*a)/(e+a);return(r-n)/t.sqrt(u*(1-u)*(1/e+1/a))}var n=[].slice,a=r.utils.isNumber,u=r.utils.isArray;r.extend({zscore:function(){var t=n.call(arguments);return a(t[1])?(t[0]-t[1])/t[2]:(t[0]-r.mean(t[1]))/r.stdev(t[1],t[2])},ztest:function(){var e,a=n.call(arguments);return u(a[1])?(e=r.zscore(a[0],a[1],a[3]),1===a[2]?r.normal.cdf(-t.abs(e),0,1):2*r.normal.cdf(-t.abs(e),0,1)):a.length>2?(e=r.zscore(a[0],a[1],a[2]),1===a[3]?r.normal.cdf(-t.abs(e),0,1):2*r.normal.cdf(-t.abs(e),0,1)):(e=a[0],1===a[1]?r.normal.cdf(-t.abs(e),0,1):2*r.normal.cdf(-t.abs(e),0,1))}}),r.extend(r.fn,{zscore:function(r,t){return(r-this.mean())/this.stdev(t)},ztest:function(e,n,a){var u=t.abs(this.zscore(e,a));return 1===n?r.normal.cdf(-u,0,1):2*r.normal.cdf(-u,0,1)}}),r.extend({tscore:function(){var e=n.call(arguments);return 4===e.length?(e[0]-e[1])/(e[2]/t.sqrt(e[3])):(e[0]-r.mean(e[1]))/(r.stdev(e[1],!0)/t.sqrt(e[1].length))},ttest:function(){var e,u=n.call(arguments);return 5===u.length?(e=t.abs(r.tscore(u[0],u[1],u[2],u[3])),1===u[4]?r.studentt.cdf(-e,u[3]-1):2*r.studentt.cdf(-e,u[3]-1)):a(u[1])?(e=t.abs(u[0]),1==u[2]?r.studentt.cdf(-e,u[1]-1):2*r.studentt.cdf(-e,u[1]-1)):(e=t.abs(r.tscore(u[0],u[1])),1==u[2]?r.studentt.cdf(-e,u[1].length-1):2*r.studentt.cdf(-e,u[1].length-1))}}),r.extend(r.fn,{tscore:function(r){return(r-this.mean())/(this.stdev(!0)/t.sqrt(this.cols()))},ttest:function(e,n){return 1===n?1-r.studentt.cdf(t.abs(this.tscore(e)),this.cols()-1):2*r.studentt.cdf(-t.abs(this.tscore(e)),this.cols()-1)}}),r.extend({anovafscore:function(){var e,a,u,i,o,s,l,f,c=n.call(arguments);if(1===c.length){o=Array(c[0].length);for(var l=0;c[0].length>l;l++)o[l]=c[0][l];c=o}if(2===c.length)return r.variance(c[0])/r.variance(c[1]);a=[];for(var l=0;c.length>l;l++)a=a.concat(c[l]);u=r.mean(a),e=0;for(var l=0;c.length>l;l++)e+=c[l].length*t.pow(r.mean(c[l])-u,2);e/=c.length-1,s=0;for(var l=0;c.length>l;l++)for(i=r.mean(c[l]),f=0;c[l].length>f;f++)s+=t.pow(c[l][f]-i,2);return s/=a.length-c.length,e/s},anovaftest:function(){var t,e,u,i,o=n.call(arguments);if(a(o[0]))return 1-r.centralF.cdf(o[0],o[1],o[2]);anovafscore=r.anovafscore(o),t=o.length-1,u=0;for(var i=0;o.length>i;i++)u+=o[i].length;return e=u-t-1,1-r.centralF.cdf(anovafscore,t,e)},ftest:function(t,e,n){return 1-r.centralF.cdf(t,e,n)}}),r.extend(r.fn,{anovafscore:function(){return r.anovafscore(this.toArray())},anovaftes:function(){for(var t,e=0,t=0;this.length>t;t++)e+=this[t].length;return r.ftest(this.anovafscore(),this.length-1,e-this.length)}}),r.extend({qscore:function(){var e,u,i,o,s,l=n.call(arguments);return a(l[0])?(e=l[0],u=l[1],i=l[2],o=l[3],s=l[4]):(e=r.mean(l[0]),u=r.mean(l[1]),i=l[0].length,o=l[1].length,s=l[2]),t.abs(e-u)/(s*t.sqrt((1/i+1/o)/2))},qtest:function(){var t,e=n.call(arguments);3===e.length?(t=e[0],e=e.slice(1)):7===e.length?(t=r.qscore(e[0],e[1],e[2],e[3],e[4]),e=e.slice(5)):(t=r.qscore(e[0],e[1],e[2]),e=e.slice(3));var a=e[0],u=e[1];return 1-r.tukey.cdf(t,u,a-u)},tukeyhsd:function(t){for(var e=r.pooledstdev(t),n=t.map(function(t){return r.mean(t)}),a=t.reduce(function(r,t){return r+t.length},0),u=[],i=0;t.length>i;++i)for(var o=i+1;t.length>o;++o){var s=r.qtest(n[i],n[o],t[i].length,t[o].length,e,a,t.length);u.push([[i,o],s])}return u}}),r.extend({normalci:function(){var e,a=n.call(arguments),u=Array(2);return e=t.abs(4===a.length?r.normal.inv(a[1]/2,0,1)*a[2]/t.sqrt(a[3]):r.normal.inv(a[1]/2,0,1)*r.stdev(a[2])/t.sqrt(a[2].length)),u[0]=a[0]-e,u[1]=a[0]+e,u},tci:function(){var e,a=n.call(arguments),u=Array(2);return e=t.abs(4===a.length?r.studentt.inv(a[1]/2,a[3]-1)*a[2]/t.sqrt(a[3]):r.studentt.inv(a[1]/2,a[2].length-1)*r.stdev(a[2],!0)/t.sqrt(a[2].length)),u[0]=a[0]-e,u[1]=a[0]+e,u},significant:function(r,t){return t>r}}),r.extend(r.fn,{normalci:function(t,e){return r.normalci(t,e,this.toArray())},tci:function(t,e){return r.tci(t,e,this.toArray())}}),r.extend(r.fn,{oneSidedDifferenceOfProportions:function(t,n,a,u){var i=e(t,n,a,u);return r.ztest(i,1)},twoSidedDifferenceOfProportions:function(t,n,a,u){var i=e(t,n,a,u);return r.ztest(i,2)}})}(t,Math),t.models=function(){function r(r,t){return e(r,t)}function r(r){var n=r[0].length;return t.arange(n).map(function(a){var u=t.arange(n).filter(function(r){return r!==a});return e(t.col(r,a).map(function(r){return r[0]}),t.col(r,u))})}function e(r,e){var n=r.length,a=e[0].length-1,u=n-a-1,i=t.lstsq(e,r),o=t.multiply(e,i.map(function(r){return[r]})).map(function(r){return r[0]}),s=t.subtract(r,o),l=t.mean(r),f=t.sum(o.map(function(r){return Math.pow(r-l,2)})),c=t.sum(r.map(function(r,t){return Math.pow(r-o[t],2)})),p=f+c;return{exog:e,endog:r,nobs:n,df_model:a,df_resid:u,coef:i,predict:o,resid:s,ybar:l,SST:p,SSE:f,SSR:c,R2:f/p}}function n(e){var n=r(e.exog),a=Math.sqrt(e.SSR/e.df_resid),u=n.map(function(r){var t=r.SST,e=r.R2;return a/Math.sqrt(t*(1-e))}),i=e.coef.map(function(r,t){return(r-0)/u[t]}),o=i.map(function(r){var n=t.studentt.cdf(r,e.df_resid);return 2*(n>.5?1-n:n)}),s=t.studentt.inv(.975,e.df_resid),l=e.coef.map(function(r,t){var e=s*u[t];return[r-e,r+e]});return{se:u,t:i,p:o,sigmaHat:a,interval95:l}}function a(r){var e=r.R2/r.df_model/((1-r.R2)/r.df_resid);return{F_statistic:e,pvalue:1-function(r,e,n){return t.beta.cdf(r/(n/e+r),e/2,n/2)}(e,r.df_model,r.df_resid)}}function u(r,t){var u=e(r,t),i=n(u),o=a(u),s=1-(u.nobs-1)/u.df_resid*(1-u.R2);return u.t=i,u.f=o,u.adjust_R2=s,u}return{ols:u}}(),t.jStat=t,t})},function(r,t,e){var n=e(1),a=e(0);t.UNIQUE=function(){for(var r=[],t=0;arguments.length>t;++t){for(var e=!1,n=arguments[t],a=0;r.length>a&&!(e=r[a]===n);++a);e||r.push(n)}return r},t.FLATTEN=n.flatten,t.ARGS2ARRAY=function(){return Array.prototype.slice.call(arguments,0)},t.REFERENCE=function(r,t){if(!arguments.length)return a.error;try{for(var e=t.split("."),n=r,u=0;e.length>u;++u){var i=e[u];if("]"===i[i.length-1]){var o=i.indexOf("["),s=i.substring(o+1,i.length-1);n=n[i.substring(0,o)][s]}else n=n[i]}return n}catch(a){}},t.JOIN=function(r,t){return r.join(t)},t.NUMBERS=function(){return n.flatten(arguments).filter(function(r){return"number"==typeof r})}},function(r,t,e){function n(r){return/^[01]{1,10}$/.test(r)}var a=e(0),u=e(9).jStat,i=e(6),o=e(1),s=e(25);t.BESSELI=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:s.besseli(r,t)},t.BESSELJ=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:s.besselj(r,t)},t.BESSELK=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:s.besselk(r,t)},t.BESSELY=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:s.bessely(r,t)},t.BIN2DEC=function(r){if(!n(r))return a.num;var t=parseInt(r,2),e=""+r;return 10===e.length&&"1"===e.substring(0,1)?parseInt(e.substring(1),2)-512:t},t.BIN2HEX=function(r,t){if(!n(r))return a.num;var e=""+r;if(10===e.length&&"1"===e.substring(0,1))return(0xfffffffe00+parseInt(e.substring(1),2)).toString(16);var u=parseInt(r,2).toString(16);return t===undefined?u:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),u.length>t?a.num:i.REPT("0",t-u.length)+u)},t.BIN2OCT=function(r,t){if(!n(r))return a.num;var e=""+r;if(10===e.length&&"1"===e.substring(0,1))return(1073741312+parseInt(e.substring(1),2)).toString(8);var u=parseInt(r,2).toString(8);return t===undefined?u:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),u.length>t?a.num:i.REPT("0",t-u.length)+u)},t.BITAND=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:0>r||0>t?a.num:Math.floor(r)!==r||Math.floor(t)!==t?a.num:r>0xffffffffffff||t>0xffffffffffff?a.num:r&t},t.BITLSHIFT=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:0>r?a.num:Math.floor(r)!==r?a.num:r>0xffffffffffff?a.num:Math.abs(t)>53?a.num:0>t?r>>-t:r<r||0>t?a.num:Math.floor(r)!==r||Math.floor(t)!==t?a.num:r>0xffffffffffff||t>0xffffffffffff?a.num:r|t},t.BITRSHIFT=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:0>r?a.num:Math.floor(r)!==r?a.num:r>0xffffffffffff?a.num:Math.abs(t)>53?a.num:0>t?r<<-t:r>>t},t.BITXOR=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:0>r||0>t?a.num:Math.floor(r)!==r||Math.floor(t)!==t?a.num:r>0xffffffffffff||t>0xffffffffffff?a.num:r^t},t.COMPLEX=function(r,t,e){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?r:"i"!==(e=e===undefined?"i":e)&&"j"!==e?a.value:0===r&&0===t?0:0===r?1===t?e:""+t+e:0===t?""+r:r+(t>0?"+":"")+(1===t?e:""+t+e)},t.CONVERT=function(r,t,e){if((r=o.parseNumber(r))instanceof Error)return r;for(var n,u=[["a.u. of action","?",null,"action",!1,!1,1.05457168181818e-34],["a.u. of charge","e",null,"electric_charge",!1,!1,1.60217653141414e-19],["a.u. of energy","Eh",null,"energy",!1,!1,4.35974417757576e-18],["a.u. of length","a?",null,"length",!1,!1,5.29177210818182e-11],["a.u. of mass","m?",null,"mass",!1,!1,9.10938261616162e-31],["a.u. of time","?/Eh",null,"time",!1,!1,2.41888432650516e-17],["admiralty knot","admkn",null,"speed",!1,!0,.514773333],["ampere","A",null,"electric_current",!0,!1,1],["ampere per meter","A/m",null,"magnetic_field_intensity",!0,!1,1],["ångström","Å",["ang"],"length",!1,!0,1e-10],["are","ar",null,"area",!1,!0,100],["astronomical unit","ua",null,"length",!1,!1,1.49597870691667e-11],["bar","bar",null,"pressure",!1,!1,1e5],["barn","b",null,"area",!1,!1,1e-28],["becquerel","Bq",null,"radioactivity",!0,!1,1],["bit","bit",["b"],"information",!1,!0,1],["btu","BTU",["btu"],"energy",!1,!0,1055.05585262],["byte","byte",null,"information",!1,!0,8],["candela","cd",null,"luminous_intensity",!0,!1,1],["candela per square metre","cd/m?",null,"luminance",!0,!1,1],["coulomb","C",null,"electric_charge",!0,!1,1],["cubic ångström","ang3",["ang^3"],"volume",!1,!0,1e-30],["cubic foot","ft3",["ft^3"],"volume",!1,!0,.028316846592],["cubic inch","in3",["in^3"],"volume",!1,!0,16387064e-12],["cubic light-year","ly3",["ly^3"],"volume",!1,!0,8.46786664623715e-47],["cubic metre","m?",null,"volume",!0,!0,1],["cubic mile","mi3",["mi^3"],"volume",!1,!0,4168181825.44058],["cubic nautical mile","Nmi3",["Nmi^3"],"volume",!1,!0,6352182208],["cubic Pica","Pica3",["Picapt3","Pica^3","Picapt^3"],"volume",!1,!0,7.58660370370369e-8],["cubic yard","yd3",["yd^3"],"volume",!1,!0,.764554857984],["cup","cup",null,"volume",!1,!0,.0002365882365],["dalton","Da",["u"],"mass",!1,!1,1.66053886282828e-27],["day","d",["day"],"time",!1,!0,86400],["degree","°",null,"angle",!1,!1,.0174532925199433],["degrees Rankine","Rank",null,"temperature",!1,!0,.555555555555556],["dyne","dyn",["dy"],"force",!1,!0,1e-5],["electronvolt","eV",["ev"],"energy",!1,!0,1.60217656514141],["ell","ell",null,"length",!1,!0,1.143],["erg","erg",["e"],"energy",!1,!0,1e-7],["farad","F",null,"electric_capacitance",!0,!1,1],["fluid ounce","oz",null,"volume",!1,!0,295735295625e-16],["foot","ft",null,"length",!1,!0,.3048],["foot-pound","flb",null,"energy",!1,!0,1.3558179483314],["gal","Gal",null,"acceleration",!1,!1,.01],["gallon","gal",null,"volume",!1,!0,.003785411784],["gauss","G",["ga"],"magnetic_flux_density",!1,!0,1],["grain","grain",null,"mass",!1,!0,647989e-10],["gram","g",null,"mass",!1,!0,.001],["gray","Gy",null,"absorbed_dose",!0,!1,1],["gross registered ton","GRT",["regton"],"volume",!1,!0,2.8316846592],["hectare","ha",null,"area",!1,!0,1e4],["henry","H",null,"inductance",!0,!1,1],["hertz","Hz",null,"frequency",!0,!1,1],["horsepower","HP",["h"],"power",!1,!0,745.69987158227],["horsepower-hour","HPh",["hh","hph"],"energy",!1,!0,2684519.538],["hour","h",["hr"],"time",!1,!0,3600],["imperial gallon (U.K.)","uk_gal",null,"volume",!1,!0,.00454609],["imperial hundredweight","lcwt",["uk_cwt","hweight"],"mass",!1,!0,50.802345],["imperial quart (U.K)","uk_qt",null,"volume",!1,!0,.0011365225],["imperial ton","brton",["uk_ton","LTON"],"mass",!1,!0,1016.046909],["inch","in",null,"length",!1,!0,.0254],["international acre","uk_acre",null,"area",!1,!0,4046.8564224],["IT calorie","cal",null,"energy",!1,!0,4.1868],["joule","J",null,"energy",!0,!0,1],["katal","kat",null,"catalytic_activity",!0,!1,1],["kelvin","K",["kel"],"temperature",!0,!0,1],["kilogram","kg",null,"mass",!0,!0,1],["knot","kn",null,"speed",!1,!0,.514444444444444],["light-year","ly",null,"length",!1,!0,9460730472580800],["litre","L",["l","lt"],"volume",!1,!0,.001],["lumen","lm",null,"luminous_flux",!0,!1,1],["lux","lx",null,"illuminance",!0,!1,1],["maxwell","Mx",null,"magnetic_flux",!1,!1,1e-18],["measurement ton","MTON",null,"volume",!1,!0,1.13267386368],["meter per hour","m/h",["m/hr"],"speed",!1,!0,.00027777777777778],["meter per second","m/s",["m/sec"],"speed",!0,!0,1],["meter per second squared","m?s??",null,"acceleration",!0,!1,1],["parsec","pc",["parsec"],"length",!1,!0,0x6da012f958ee1c],["meter squared per second","m?/s",null,"kinematic_viscosity",!0,!1,1],["metre","m",null,"length",!0,!0,1],["miles per hour","mph",null,"speed",!1,!0,.44704],["millimetre of mercury","mmHg",null,"pressure",!1,!1,133.322],["minute","?",null,"angle",!1,!1,.000290888208665722],["minute","min",["mn"],"time",!1,!0,60],["modern teaspoon","tspm",null,"volume",!1,!0,5e-6],["mole","mol",null,"amount_of_substance",!0,!1,1],["morgen","Morgen",null,"area",!1,!0,2500],["n.u. of action","?",null,"action",!1,!1,1.05457168181818e-34],["n.u. of mass","m?",null,"mass",!1,!1,9.10938261616162e-31],["n.u. of speed","c?",null,"speed",!1,!1,299792458],["n.u. of time","?/(me?c??)",null,"time",!1,!1,1.28808866778687e-21],["nautical mile","M",["Nmi"],"length",!1,!0,1852],["newton","N",null,"force",!0,!0,1],["œrsted","Oe ",null,"magnetic_field_intensity",!1,!1,79.5774715459477],["ohm","Ω",null,"electric_resistance",!0,!1,1],["ounce mass","ozm",null,"mass",!1,!0,.028349523125],["pascal","Pa",null,"pressure",!0,!1,1],["pascal second","Pa?s",null,"dynamic_viscosity",!0,!1,1],["pferdestärke","PS",null,"power",!1,!0,735.49875],["phot","ph",null,"illuminance",!1,!1,1e-4],["pica (1/6 inch)","pica",null,"length",!1,!0,.00035277777777778],["pica (1/72 inch)","Pica",["Picapt"],"length",!1,!0,.00423333333333333],["poise","P",null,"dynamic_viscosity",!1,!1,.1],["pond","pond",null,"force",!1,!0,.00980665],["pound force","lbf",null,"force",!1,!0,4.4482216152605],["pound mass","lbm",null,"mass",!1,!0,.45359237],["quart","qt",null,"volume",!1,!0,.000946352946],["radian","rad",null,"angle",!0,!1,1],["second","?",null,"angle",!1,!1,484813681109536e-20],["second","s",["sec"],"time",!0,!0,1],["short hundredweight","cwt",["shweight"],"mass",!1,!0,45.359237],["siemens","S",null,"electrical_conductance",!0,!1,1],["sievert","Sv",null,"equivalent_dose",!0,!1,1],["slug","sg",null,"mass",!1,!0,14.59390294],["square ångström","ang2",["ang^2"],"area",!1,!0,1e-20],["square foot","ft2",["ft^2"],"area",!1,!0,.09290304],["square inch","in2",["in^2"],"area",!1,!0,64516e-8],["square light-year","ly2",["ly^2"],"area",!1,!0,8.95054210748189e31],["square meter","m?",null,"area",!0,!0,1],["square mile","mi2",["mi^2"],"area",!1,!0,2589988.110336],["square nautical mile","Nmi2",["Nmi^2"],"area",!1,!0,3429904],["square Pica","Pica2",["Picapt2","Pica^2","Picapt^2"],"area",!1,!0,1792111111111e-17],["square yard","yd2",["yd^2"],"area",!1,!0,.83612736],["statute mile","mi",null,"length",!1,!0,1609.344],["steradian","sr",null,"solid_angle",!0,!1,1],["stilb","sb",null,"luminance",!1,!1,1e-4],["stokes","St",null,"kinematic_viscosity",!1,!1,1e-4],["stone","stone",null,"mass",!1,!0,6.35029318],["tablespoon","tbs",null,"volume",!1,!0,147868e-10],["teaspoon","tsp",null,"volume",!1,!0,492892e-11],["tesla","T",null,"magnetic_flux_density",!0,!0,1],["thermodynamic calorie","c",null,"energy",!1,!0,4.184],["ton","ton",null,"mass",!1,!0,907.18474],["tonne","t",null,"mass",!1,!1,1e3],["U.K. pint","uk_pt",null,"volume",!1,!0,.00056826125],["U.S. bushel","bushel",null,"volume",!1,!0,.03523907],["U.S. oil barrel","barrel",null,"volume",!1,!0,.158987295],["U.S. pint","pt",["us_pt"],"volume",!1,!0,.000473176473],["U.S. survey mile","survey_mi",null,"length",!1,!0,1609.347219],["U.S. survey/statute acre","us_acre",null,"area",!1,!0,4046.87261],["volt","V",null,"voltage",!0,!1,1],["watt","W",null,"power",!0,!0,1],["watt-hour","Wh",["wh"],"energy",!1,!0,3600],["weber","Wb",null,"magnetic_flux",!0,!1,1],["yard","yd",null,"length",!1,!0,.9144],["year","yr",null,"time",!1,!0,31557600]],i={Yi:["yobi",80,1.2089258196146292e24,"Yi","yotta"],Zi:["zebi",70,0x400000000000000000,"Zi","zetta"],Ei:["exbi",60,0x1000000000000000,"Ei","exa"],Pi:["pebi",50,0x4000000000000,"Pi","peta"],Ti:["tebi",40,1099511627776,"Ti","tera"],Gi:["gibi",30,1073741824,"Gi","giga"],Mi:["mebi",20,1048576,"Mi","mega"],ki:["kibi",10,1024,"ki","kilo"]},s={Y:["yotta",1e24,"Y"],Z:["zetta",1e21,"Z"],E:["exa",1e18,"E"],P:["peta",1e15,"P"],T:["tera",1e12,"T"],G:["giga",1e9,"G"],M:["mega",1e6,"M"],k:["kilo",1e3,"k"],h:["hecto",100,"h"],e:["dekao",10,"e"],d:["deci",.1,"d"],c:["centi",.01,"c"],m:["milli",.001,"m"],u:["micro",1e-6,"u"],n:["nano",1e-9,"n"],p:["pico",1e-12,"p"],f:["femto",1e-15,"f"],a:["atto",1e-18,"a"],z:["zepto",1e-21,"z"],y:["yocto",1e-24,"y"]},l=null,f=null,c=t,p=e,h=1,m=1,E=0;146>E;E++)n=null===u[E][2]?[]:u[E][2],u[E][1]!==c&&0>n.indexOf(c)||(l=u[E]),u[E][1]!==p&&0>n.indexOf(p)||(f=u[E]);if(null===l){var g=i[t.substring(0,2)],N=s[t.substring(0,1)];"da"===t.substring(0,2)&&(N=["dekao",10,"da"]),g?(h=g[2],c=t.substring(2)):N&&(h=N[1],c=t.substring(N[2].length));for(var v=0;146>v;v++)n=null===u[v][2]?[]:u[v][2],u[v][1]!==c&&0>n.indexOf(c)||(l=u[v])}if(null===f){var d=i[e.substring(0,2)],I=s[e.substring(0,1)];"da"===e.substring(0,2)&&(I=["dekao",10,"da"]),d?(m=d[2],p=e.substring(2)):I&&(m=I[1],p=e.substring(I[2].length));for(var b=0;146>b;b++)n=null===u[b][2]?[]:u[b][2],u[b][1]!==p&&0>n.indexOf(p)||(f=u[b])}return null===l||null===f?a.na:l[3]!==f[3]?a.na:r*l[6]*h/(f[6]*m)},t.DEC2BIN=function(r,t){if((r=o.parseNumber(r))instanceof Error)return r;if(!/^-?[0-9]{1,3}$/.test(r)||-512>r||r>511)return a.num;if(0>r)return"1"+i.REPT("0",9-(512+r).toString(2).length)+(512+r).toString(2);var e=parseInt(r,10).toString(2);return void 0===t?e:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),e.length>t?a.num:i.REPT("0",t-e.length)+e)},t.DEC2HEX=function(r,t){if((r=o.parseNumber(r))instanceof Error)return r;if(!/^-?[0-9]{1,12}$/.test(r)||-549755813888>r||r>549755813887)return a.num;if(0>r)return(1099511627776+r).toString(16);var e=parseInt(r,10).toString(16);return void 0===t?e:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),e.length>t?a.num:i.REPT("0",t-e.length)+e)},t.DEC2OCT=function(r,t){if((r=o.parseNumber(r))instanceof Error)return r;if(!/^-?[0-9]{1,9}$/.test(r)||-536870912>r||r>536870911)return a.num;if(0>r)return(1073741824+r).toString(8);var e=parseInt(r,10).toString(8);return void 0===t?e:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),e.length>t?a.num:i.REPT("0",t-e.length)+e)},t.DELTA=function(r,t){return t=t===undefined?0:t,r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:r===t?1:0},t.ERF=function(r,t){return t=t===undefined?0:t,r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?a.value:u.erf(r)},t.ERF.PRECISE=function(){throw Error("ERF.PRECISE is not implemented")},t.ERFC=function(r){return isNaN(r)?a.value:u.erfc(r)},t.ERFC.PRECISE=function(){throw Error("ERFC.PRECISE is not implemented")},t.GESTEP=function(r,t){return t=t||0,r=o.parseNumber(r),o.anyIsError(t,r)?r:t>r?0:1},t.HEX2BIN=function(r,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(r))return a.num;var e=10===r.length&&"f"===r.substring(0,1).toLowerCase(),n=e?parseInt(r,16)-1099511627776:parseInt(r,16);if(-512>n||n>511)return a.num;if(e)return"1"+i.REPT("0",9-(512+n).toString(2).length)+(512+n).toString(2);var u=n.toString(2);return t===undefined?u:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),u.length>t?a.num:i.REPT("0",t-u.length)+u)},t.HEX2DEC=function(r){if(!/^[0-9A-Fa-f]{1,10}$/.test(r))return a.num;var t=parseInt(r,16);return 549755813888>t?t:t-1099511627776},t.HEX2OCT=function(r,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(r))return a.num;var e=parseInt(r,16);if(e>536870911&&0xffe0000000>e)return a.num;if(e>=0xffe0000000)return(e-0xffc0000000).toString(8);var n=e.toString(8);return t===undefined?n:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),n.length>t?a.num:i.REPT("0",t-n.length)+n)},t.IMABS=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);return o.anyIsError(e,n)?a.value:Math.sqrt(Math.pow(e,2)+Math.pow(n,2))},t.IMAGINARY=function(r){if(r===undefined||!0===r||!1===r)return a.value;if(0===r||"0"===r)return 0;if(["i","j"].indexOf(r)>=0)return 1;r=r.replace("+i","+1i").replace("-i","-1i").replace("+j","+1j").replace("-j","-1j");var t=r.indexOf("+"),e=r.indexOf("-");0===t&&(t=r.indexOf("+",1)),0===e&&(e=r.indexOf("-",1));var n=r.substring(r.length-1,r.length),u="i"===n||"j"===n;return 0>t&&0>e?u?isNaN(r.substring(0,r.length-1))?a.num:r.substring(0,r.length-1):isNaN(r)?a.num:0:u?0>t?isNaN(r.substring(0,e))||isNaN(r.substring(e+1,r.length-1))?a.num:-+r.substring(e+1,r.length-1):isNaN(r.substring(0,t))||isNaN(r.substring(t+1,r.length-1))?a.num:+r.substring(t+1,r.length-1):a.num},t.IMARGUMENT=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);return o.anyIsError(e,n)?a.value:0===e&&0===n?a.div0:0===e&&n>0?Math.PI/2:0===e&&0>n?-Math.PI/2:0===n&&e>0?0:0===n&&0>e?-Math.PI:e>0?Math.atan(n/e):0>e&&n>=0?Math.atan(n/e)+Math.PI:Math.atan(n/e)-Math.PI},t.IMCONJUGATE=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",0!==n?t.COMPLEX(e,-n,u):r},t.IMCOS=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",t.COMPLEX(Math.cos(e)*(Math.exp(n)+Math.exp(-n))/2,-Math.sin(e)*(Math.exp(n)-Math.exp(-n))/2,u)},t.IMCOSH=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",t.COMPLEX(Math.cos(n)*(Math.exp(e)+Math.exp(-e))/2,Math.sin(n)*(Math.exp(e)-Math.exp(-e))/2,u)},t.IMCOT=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);return o.anyIsError(e,n)?a.value:t.IMDIV(t.IMCOS(r),t.IMSIN(r))},t.IMDIV=function(r,e){var n=t.IMREAL(r),u=t.IMAGINARY(r),i=t.IMREAL(e),s=t.IMAGINARY(e);if(o.anyIsError(n,u,i,s))return a.value;var l=r.substring(r.length-1),f=e.substring(e.length-1),c="i";if("j"===l?c="j":"j"===f&&(c="j"),0===i&&0===s)return a.num;var p=i*i+s*s;return t.COMPLEX((n*i+u*s)/p,(u*i-n*s)/p,c)},t.IMEXP=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);u="i"===u||"j"===u?u:"i";var i=Math.exp(e);return t.COMPLEX(i*Math.cos(n),i*Math.sin(n),u)},t.IMLN=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",t.COMPLEX(Math.log(Math.sqrt(e*e+n*n)),Math.atan(n/e),u)},t.IMLOG10=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",t.COMPLEX(Math.log(Math.sqrt(e*e+n*n))/Math.log(10),Math.atan(n/e)/Math.log(10),u)},t.IMLOG2=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",t.COMPLEX(Math.log(Math.sqrt(e*e+n*n))/Math.log(2),Math.atan(n/e)/Math.log(2),u)},t.IMPOWER=function(r,e){e=o.parseNumber(e);var n=t.IMREAL(r),u=t.IMAGINARY(r);if(o.anyIsError(e,n,u))return a.value;var i=r.substring(r.length-1);i="i"===i||"j"===i?i:"i";var s=Math.pow(t.IMABS(r),e),l=t.IMARGUMENT(r);return t.COMPLEX(s*Math.cos(e*l),s*Math.sin(e*l),i)},t.IMPRODUCT=function(){var r=arguments[0];if(!arguments.length)return a.value;for(var e=1;arguments.length>e;e++){var n=t.IMREAL(r),u=t.IMAGINARY(r),i=t.IMREAL(arguments[e]),s=t.IMAGINARY(arguments[e]);if(o.anyIsError(n,u,i,s))return a.value;r=t.COMPLEX(n*i-u*s,n*s+u*i)}return r},t.IMREAL=function(r){if(r===undefined||!0===r||!1===r)return a.value;if(0===r||"0"===r)return 0;if(["i","+i","1i","+1i","-i","-1i","j","+j","1j","+1j","-j","-1j"].indexOf(r)>=0)return 0;var t=r.indexOf("+"),e=r.indexOf("-");0===t&&(t=r.indexOf("+",1)),0===e&&(e=r.indexOf("-",1));var n=r.substring(r.length-1,r.length),u="i"===n||"j"===n;return 0>t&&0>e?u?isNaN(r.substring(0,r.length-1))?a.num:0:isNaN(r)?a.num:r:u?0>t?isNaN(r.substring(0,e))||isNaN(r.substring(e+1,r.length-1))?a.num:+r.substring(0,e):isNaN(r.substring(0,t))||isNaN(r.substring(t+1,r.length-1))?a.num:+r.substring(0,t):a.num},t.IMSEC=function(r){if(!0===r||!1===r)return a.value;var e=t.IMREAL(r),n=t.IMAGINARY(r);return o.anyIsError(e,n)?a.value:t.IMDIV("1",t.IMCOS(r))},t.IMSECH=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);return o.anyIsError(e,n)?a.value:t.IMDIV("1",t.IMCOSH(r))},t.IMSIN=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",t.COMPLEX(Math.sin(e)*(Math.exp(n)+Math.exp(-n))/2,Math.cos(e)*(Math.exp(n)-Math.exp(-n))/2,u)},t.IMSINH=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",t.COMPLEX(Math.cos(n)*(Math.exp(e)-Math.exp(-e))/2,Math.sin(n)*(Math.exp(e)+Math.exp(-e))/2,u)},t.IMSQRT=function(r){var e=t.IMREAL(r),n=t.IMAGINARY(r);if(o.anyIsError(e,n))return a.value;var u=r.substring(r.length-1);u="i"===u||"j"===u?u:"i";var i=Math.sqrt(t.IMABS(r)),s=t.IMARGUMENT(r);return t.COMPLEX(i*Math.cos(s/2),i*Math.sin(s/2),u)},t.IMCSC=function(r){if(!0===r||!1===r)return a.value;var e=t.IMREAL(r),n=t.IMAGINARY(r);return o.anyIsError(e,n)?a.num:t.IMDIV("1",t.IMSIN(r))},t.IMCSCH=function(r){if(!0===r||!1===r)return a.value;var e=t.IMREAL(r),n=t.IMAGINARY(r);return o.anyIsError(e,n)?a.num:t.IMDIV("1",t.IMSINH(r))},t.IMSUB=function(r,t){var e=this.IMREAL(r),n=this.IMAGINARY(r),u=this.IMREAL(t),i=this.IMAGINARY(t);if(o.anyIsError(e,n,u,i))return a.value;var s=r.substring(r.length-1),l=t.substring(t.length-1),f="i";return"j"===s?f="j":"j"===l&&(f="j"),this.COMPLEX(e-u,n-i,f)},t.IMSUM=function(){if(!arguments.length)return a.value;for(var r=o.flatten(arguments),t=r[0],e=1;r.length>e;e++){var n=this.IMREAL(t),u=this.IMAGINARY(t),i=this.IMREAL(r[e]),s=this.IMAGINARY(r[e]);if(o.anyIsError(n,u,i,s))return a.value;t=this.COMPLEX(n+i,u+s)}return t},t.IMTAN=function(r){if(!0===r||!1===r)return a.value;var e=t.IMREAL(r),n=t.IMAGINARY(r);return o.anyIsError(e,n)?a.value:this.IMDIV(this.IMSIN(r),this.IMCOS(r))},t.OCT2BIN=function(r,t){if(!/^[0-7]{1,10}$/.test(r))return a.num;var e=10===r.length&&"7"===r.substring(0,1),n=e?parseInt(r,8)-1073741824:parseInt(r,8);if(-512>n||n>511)return a.num;if(e)return"1"+i.REPT("0",9-(512+n).toString(2).length)+(512+n).toString(2);var u=n.toString(2);return void 0===t?u:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),u.length>t?a.num:i.REPT("0",t-u.length)+u)},t.OCT2DEC=function(r){if(!/^[0-7]{1,10}$/.test(r))return a.num;var t=parseInt(r,8);return 536870912>t?t:t-1073741824},t.OCT2HEX=function(r,t){if(!/^[0-7]{1,10}$/.test(r))return a.num;var e=parseInt(r,8);if(e>=536870912)return"ff"+(e+3221225472).toString(16);var n=e.toString(16);return t===undefined?n:isNaN(t)?a.value:0>t?a.num:(t=Math.floor(t),n.length>t?a.num:i.REPT("0",t-n.length)+n)}},function(r,t,e){"use strict";t.__esModule=!0,t["default"]=["ABS","ACCRINT","ACOS","ACOSH","ACOT","ACOTH","ADD","AGGREGATE","AND","ARABIC","ARGS2ARRAY","ASIN","ASINH","ATAN","ATAN2","ATANH","AVEDEV","AVERAGE","AVERAGEA","AVERAGEIF","AVERAGEIFS","BASE","BESSELI","BESSELJ","BESSELK","BESSELY","BETA.DIST","BETA.INV","BETADIST","BETAINV","BIN2DEC","BIN2HEX","BIN2OCT","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BINOMDIST","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING","CEILINGMATH","CEILINGPRECISE","CHAR","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHOOSE","CHOOSE","CLEAN","CODE","COLUMN","COLUMNS","COMBIN","COMBINA","COMPLEX","CONCATENATE","CONFIDENCE","CONFIDENCE.NORM","CONFIDENCE.T","CONVERT","CORREL","COS","COSH","COT","COTH","COUNT","COUNTA","COUNTBLANK","COUNTIF","COUNTIFS","COUNTIN","COUNTUNIQUE","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","CUMIPMT","CUMPRINC","DATE","DATEVALUE","DAY","DAYS","DAYS360","DB","DDB","DEC2BIN","DEC2HEX","DEC2OCT","DECIMAL","DEGREES","DELTA","DEVSQ","DIVIDE","DOLLARDE","DOLLARFR","E","EDATE","EFFECT","EOMONTH","EQ","ERF","ERFC","EVEN","EXACT","EXP","EXPON.DIST","EXPONDIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","FACT","FACTDOUBLE","FALSE","FDIST","FDISTRT","FIND","FINV","FINVRT","FISHER","FISHERINV","FLATTEN","FLOOR","FORECAST","FREQUENCY","FV","FVSCHEDULE","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMADIST","GAMMAINV","GAMMALN","GAMMALN.PRECISE","GAUSS","GCD","GEOMEAN","GESTEP","GROWTH","GTE","HARMEAN","HEX2BIN","HEX2DEC","HEX2OCT","HOUR","HTML2TEXT","HYPGEOM.DIST","HYPGEOMDIST","IF","IMABS","IMAGINARY","IMARGUMENT","IMCONJUGATE","IMCOS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMDIV","IMEXP","IMLN","IMLOG10","IMLOG2","IMPOWER","IMPRODUCT","IMREAL","IMSEC","IMSECH","IMSIN","IMSINH","IMSQRT","IMSUB","IMSUM","IMTAN","INT","INTERCEPT","INTERVAL","IPMT","IRR","ISBINARY","ISBLANK","ISEVEN","ISLOGICAL","ISNONTEXT","ISNUMBER","ISODD","ISODD","ISOWEEKNUM","ISPMT","ISTEXT","JOIN","KURT","LARGE","LCM","LEFT","LEN","LINEST","LN","LOG","LOG10","LOGEST","LOGNORM.DIST","LOGNORM.INV","LOGNORMDIST","LOGNORMINV","LOWER","LT","LTE","MATCH","MAX","MAXA","MEDIAN","MID","MIN","MINA","MINUS","MINUTE","MIRR","MOD","MODE.MULT","MODE.SNGL","MODEMULT","MODESNGL","MONTH","MROUND","MULTINOMIAL","MULTIPLY","NE","NEGBINOM.DIST","NEGBINOMDIST","NETWORKDAYS","NOMINAL","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NORMDIST","NORMINV","NORMSDIST","NORMSINV","NOT","NOW","NPER","NPV","NUMBERS","OCT2BIN","OCT2DEC","OCT2HEX","ODD","OR","PDURATION","PEARSON","PERCENTILEEXC","PERCENTILEINC","PERCENTRANKEXC","PERCENTRANKINC","PERMUT","PERMUTATIONA","PHI","PI","PMT","POISSON.DIST","POISSONDIST","POW","POWER","PPMT","PROB","PRODUCT","PROPER","PV","QUARTILE.EXC","QUARTILE.INC","QUARTILEEXC","QUARTILEINC","QUOTIENT","RADIANS","RAND","RANDBETWEEN","RANK.AVG","RANK.EQ","RANKAVG","RANKEQ","RATE","REFERENCE","REGEXEXTRACT","REGEXMATCH","REGEXREPLACE","REPLACE","REPT","RIGHT","ROMAN","ROUND","ROUNDDOWN","ROUNDUP","ROW","ROWS","RRI","RSQ","SEARCH","SEC","SECH","SECOND","SERIESSUM","SIGN","SIN","SINH","SKEW","SKEW.P","SKEWP","SLN","SLOPE","SMALL","SPLIT","SPLIT","SQRT","SQRTPI","STANDARDIZE","STDEV.P","STDEV.S","STDEVA","STDEVP","STDEVPA","STDEVS","STEYX","SUBSTITUTE","SUBTOTAL","SUM","SUMIF","SUMIFS","SUMPRODUCT","SUMSQ","SUMX2MY2","SUMX2PY2","SUMXMY2","SWITCH","SYD","T","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","TAN","TANH","TBILLEQ","TBILLPRICE","TBILLYIELD","TDIST","TDIST2T","TDISTRT","TIME","TIMEVALUE","TINV","TINV2T","TODAY","TRANSPOSE","TREND","TRIM","TRIMMEAN","TRUE","TRUNC","UNICHAR","UNICODE","UNIQUE","UPPER","VAR.P","VAR.S","VARA","VARP","VARPA","VARS","WEEKDAY","WEEKNUM","WEIBULL.DIST","WEIBULLDIST","WORKDAY","XIRR","XNPV","XOR","YEAR","YEARFRAC"]},function(r,t,e){"use strict";function n(r){var t=parseInt(r,10);return t=isNaN(t)?-1:Math.max(t-1,-1)}function a(r){var t="";return 0>r||(t=""+(r+1)),t}function u(r){var t=0;if("string"==typeof r){r=r.toUpperCase();for(var e=0,n=r.length-1;r.length>e;e+=1,n-=1)t+=Math.pow(f,n)*(l.indexOf(r[e])+1)}return--t}function i(r){for(var t="";r>=0;)t=String.fromCharCode(r%f+97)+t,r=Math.floor(r/f)-1;return t.toUpperCase()}function o(r){if("string"!=typeof r||!c.test(r))return[];var t=r.toUpperCase().match(c),e=t[1],a=t[2],i=t[3],o=t[4];return[{index:n(o),label:o,isAbsolute:"$"===i},{index:u(a),label:a,isAbsolute:"$"===e}]}function s(r,t){var e=(r.isAbsolute?"$":"")+a(r.index);return(t.isAbsolute?"$":"")+i(t.index)+e}t.__esModule=!0,t.rowLabelToIndex=n,t.rowIndexToLabel=a,t.columnLabelToIndex=u,t.columnIndexToLabel=i,t.extractLabel=o,t.toLabel=s;var l="ABCDEFGHIJKLMNOPQRSTUVWXYZ",f=l.length,c=/^([$])?([A-Za-z]+)([$])?([0-9]+)$/},function(r,t,e){"use strict";function n(r){return r&&r.__esModule?r:{"default":r}}t.__esModule=!0,t.rowLabelToIndex=t.rowIndexToLabel=t.columnLabelToIndex=t.columnIndexToLabel=t.toLabel=t.extractLabel=t.error=t.Parser=t.ERROR_VALUE=t.ERROR_REF=t.ERROR_NUM=t.ERROR_NULL=t.ERROR_NOT_AVAILABLE=t.ERROR_NAME=t.ERROR_DIV_ZERO=t.ERROR=t.SUPPORTED_FORMULAS=undefined;var a=e(15),u=n(a),i=e(12),o=n(i),s=e(2),l=n(s),f=e(13);t.SUPPORTED_FORMULAS=o["default"],t.ERROR=s.ERROR,t.ERROR_DIV_ZERO=s.ERROR_DIV_ZERO,t.ERROR_NAME=s.ERROR_NAME,t.ERROR_NOT_AVAILABLE=s.ERROR_NOT_AVAILABLE,t.ERROR_NULL=s.ERROR_NULL,t.ERROR_NUM=s.ERROR_NUM,t.ERROR_REF=s.ERROR_REF,t.ERROR_VALUE=s.ERROR_VALUE,t.Parser=u["default"],t.error=l["default"],t.extractLabel=f.extractLabel,t.toLabel=f.toLabel,t.columnIndexToLabel=f.columnIndexToLabel,t.columnLabelToIndex=f.columnLabelToIndex,t.rowIndexToLabel=f.rowIndexToLabel,t.rowLabelToIndex=f.rowLabelToIndex},function(r,t,e){"use strict";function n(r){return r&&r.__esModule?r:{"default":r}}function a(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function u(r,t){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?r:t}function i(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(r,t):r.__proto__=t)}t.__esModule=!0;var o=e(16),s=n(o),l=e(17),f=n(l),c=e(38),p=e(41),h=e(3),m=e(2),E=n(m),g=e(13);t["default"]=function(r){function t(){a(this,t);var e=u(this,r.call(this));return e.parser=new c.Parser,e.parser.yy={toNumber:h.toNumber,trimEdges:p.trimEdges,invertNumber:h.invertNumber,throwError:function(r){return e._throwError(r)},callVariable:function(r){return e._callVariable(r)},evaluateByOperator:f["default"],callFunction:function(r,t){return e._callFunction(r,t)},cellValue:function(r){return e._callCellValue(r)},rangeValue:function(r,t){return e._callRangeValue(r,t)}},e.variables=Object.create(null),e.functions=Object.create(null),e.setVariable("TRUE",!0).setVariable("FALSE",!1).setVariable("NULL",null),e}return i(t,r),t.prototype.parse=function(r){var t=null,e=null;try{t=""===r?"":this.parser.parse(r)}catch(a){var n=(0,E["default"])(a.message);e=n||(0,E["default"])(m.ERROR)}return t instanceof Error&&(e=(0,E["default"])(t.message)||(0,E["default"])(m.ERROR),t=null),{error:e,result:t}},t.prototype.setVariable=function(r,t){return this.variables[r]=t,this},t.prototype.getVariable=function(r){return this.variables[r]},t.prototype._callVariable=function(r){var t=this.getVariable(r);if(this.emit("callVariable",r,function(r){void 0!==r&&(t=r)}),void 0===t)throw Error(m.ERROR_NAME);return t},t.prototype.setFunction=function(r,t){return this.functions[r]=t,this},t.prototype.getFunction=function(r){return this.functions[r]},t.prototype._callFunction=function(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[],e=this.getFunction(r),n=void 0;return e&&(n=e(t)),this.emit("callFunction",r,t,function(r){void 0!==r&&(n=r)}),void 0===n?(0,f["default"])(r,t):n},t.prototype._callCellValue=function(r){r=r.toUpperCase();var t=(0,g.extractLabel)(r),e=t[0],n=t[1],a=void 0;return this.emit("callCellValue",{label:r,row:e,column:n},function(r){a=r}),a},t.prototype._callRangeValue=function(r,t){r=r.toUpperCase(),t=t.toUpperCase();var e=(0,g.extractLabel)(r),n=e[0],a=e[1],u=(0,g.extractLabel)(t),i=u[0],o=u[1],s={},l={};n.index>i.index?(s.row=i,l.row=n):(s.row=n,l.row=i),a.index>o.index?(s.column=o,l.column=a):(s.column=a,l.column=o),s.label=(0,g.toLabel)(s.row,s.column),l.label=(0,g.toLabel)(l.row,l.column);var f=[];return this.emit("callRangeValue",s,l,function(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];f=r}),f},t.prototype._throwError=function(r){if((0,m.isValidStrict)(r))throw Error(r);throw Error(m.ERROR)},t}(s["default"])},function(r,t){function e(){}e.prototype={on:function(r,t,e){var n=this.e||(this.e={});return(n[r]||(n[r]=[])).push({fn:t,ctx:e}),this},once:function(r,t,e){function n(){a.off(r,n),t.apply(e,arguments)}var a=this;return n._=t,this.on(r,n,e)},emit:function(r){var t=[].slice.call(arguments,1),e=((this.e||(this.e={}))[r]||[]).slice(),n=0,a=e.length;for(n;a>n;n++)e[n].fn.apply(e[n].ctx,t);return this},off:function(r,t){var e=this.e||(this.e={}),n=e[r],a=[];if(n&&t)for(var u=0,i=n.length;i>u;u++)n[u].fn!==t&&n[u].fn._!==t&&a.push(n[u]);return a.length?e[r]=a:delete e[r],this}},r.exports=e},function(r,t,e){"use strict";function n(r){return r&&r.__esModule?r:{"default":r}}function a(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];if(r=r.toUpperCase(),!L[r])throw Error(C.ERROR_NAME);return L[r].apply(L,t)}function u(r,t){Array.isArray(r)||(r=[r.toUpperCase()]),r.forEach(function(r){L[r]=t.isFactory?t(r):t})}t.__esModule=!0,t["default"]=a,t.registerOperation=u;var i=e(18),o=n(i),s=e(19),l=n(s),f=e(20),c=n(f),p=e(21),h=n(p),m=e(22),E=n(m),g=e(30),N=n(g),v=e(31),d=n(v),I=e(32),b=n(I),y=e(33),M=n(y),A=e(34),R=n(A),S=e(35),T=n(S),O=e(36),V=n(O),x=e(37),$=n(x),C=e(2),L=Object.create(null);u(o["default"].SYMBOL,o["default"]),u(l["default"].SYMBOL,l["default"]),u(c["default"].SYMBOL,c["default"]),u(h["default"].SYMBOL,h["default"]),u($["default"].SYMBOL,$["default"]),u(E["default"].SYMBOL,E["default"]),u(N["default"].SYMBOL,N["default"]),u(d["default"].SYMBOL,d["default"]),u(b["default"].SYMBOL,b["default"]),u(M["default"].SYMBOL,M["default"]),u(T["default"].SYMBOL,T["default"]),u(V["default"].SYMBOL,V["default"]),u(R["default"].SYMBOL,R["default"])},function(r,t,e){"use strict";function n(r){for(var t=arguments.length,e=Array(t>1?t-1:0),n=1;t>n;n++)e[n-1]=arguments[n];var i=e.reduce(function(r,t){return r+(0,a.toNumber)(t)},(0,a.toNumber)(r));if(isNaN(i))throw Error(u.ERROR_VALUE);return i}t.__esModule=!0,t.SYMBOL=undefined,t["default"]=n;var a=e(3),u=e(2);n.SYMBOL=t.SYMBOL="+"},function(r,t,e){"use strict";function n(){for(var r=arguments.length,t=Array(r),e=0;r>e;e++)t[e]=arguments[e];return t.reduce(function(r,t){return r+""+t},"")}t.__esModule=!0,t["default"]=n,n.SYMBOL=t.SYMBOL="&"},function(r,t,e){"use strict";function n(r){for(var t=arguments.length,e=Array(t>1?t-1:0),n=1;t>n;n++)e[n-1]=arguments[n];var i=e.reduce(function(r,t){return r/(0,a.toNumber)(t)},(0,a.toNumber)(r));if(i===Infinity)throw Error(u.ERROR_DIV_ZERO);if(isNaN(i))throw Error(u.ERROR_VALUE);return i}t.__esModule=!0,t.SYMBOL=undefined,t["default"]=n;var a=e(3),u=e(2);n.SYMBOL=t.SYMBOL="/"},function(r,t,e){"use strict";function n(r,t){return r===t}t.__esModule=!0,t["default"]=n,n.SYMBOL=t.SYMBOL="="},function(r,t,e){"use strict";function n(r){return function(){r=r.toUpperCase();var t=r.split("."),e=!1,n=void 0;if(1===t.length)u[t[0]]&&(e=!0,n=u[t[0]].apply(u,arguments));else{for(var a=t.length,i=0,o=u;a>i;)if(o=o[t[i]],i++,!o){o=null;break}o&&(e=!0,n=o.apply(undefined,arguments))}if(!e)throw Error(s.ERROR_NAME);return n}}t.__esModule=!0,t.SYMBOL=undefined,t["default"]=n;var a=e(23),u=function(r){if(r&&r.__esModule)return r;var t={};if(null!=r)for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t["default"]=r,t}(a),i=e(12),o=function(r){return r&&r.__esModule?r:{"default":r}}(i),s=e(2),l=t.SYMBOL=o["default"];n.isFactory=!0,n.SYMBOL=l},function(r,t,e){var n=[e(24),e(26),e(11),e(27),e(4),e(6),e(8),e(28),e(7),e(29),e(5),e(10)];for(var a in n){var u=n[a];for(var i in u)t[i]=t[i]||u[i]}},function(r,t,e){function n(r,t){if(t)for(var e in t)r[e]=t[e];return r}var a=e(4),u=e(5),i=e(11),o=e(8);t.BETADIST=u.BETA.DIST,t.BETAINV=u.BETA.INV,t.BINOMDIST=u.BINOM.DIST,t.CEILING=t.ISOCEILING=n(a.CEILING.MATH,a.CEILING),t.CEILINGMATH=a.CEILING.MATH,t.CEILINGPRECISE=a.CEILING.PRECISE,t.CHIDIST=u.CHISQ.DIST,t.CHIDISTRT=u.CHISQ.DIST.RT,t.CHIINV=u.CHISQ.INV,t.CHIINVRT=u.CHISQ.INV.RT,t.CHITEST=u.CHISQ.TEST,t.CONFIDENCE=n(u.CONFIDENCE.NORM,u.CONFIDENCE),t.COVAR=u.COVARIANCE.P,t.COVARIANCEP=u.COVARIANCE.P,t.COVARIANCES=u.COVARIANCE.S,t.CRITBINOM=u.BINOM.INV,t.EXPONDIST=u.EXPON.DIST,t.ERFCPRECISE=i.ERFC.PRECISE,t.ERFPRECISE=i.ERF.PRECISE,t.FDIST=u.F.DIST,t.FDISTRT=u.F.DIST.RT,t.FINVRT=u.F.INV.RT,t.FINV=u.F.INV,t.FLOOR=n(a.FLOOR.MATH,a.FLOOR),t.FLOORMATH=a.FLOOR.MATH,t.FLOORPRECISE=a.FLOOR.PRECISE,t.FTEST=u.F.TEST,t.GAMMADIST=u.GAMMA.DIST,t.GAMMAINV=u.GAMMA.INV,t.GAMMALNPRECISE=u.GAMMALN.PRECISE,t.HYPGEOMDIST=u.HYPGEOM.DIST,t.LOGINV=u.LOGNORM.INV,t.LOGNORMINV=u.LOGNORM.INV,t.LOGNORMDIST=u.LOGNORM.DIST,t.MODE=n(u.MODE.SNGL,u.MODE),t.MODEMULT=u.MODE.MULT,t.MODESNGL=u.MODE.SNGL,t.NEGBINOMDIST=u.NEGBINOM.DIST,t.NETWORKDAYSINTL=o.NETWORKDAYS.INTL,t.NORMDIST=u.NORM.DIST,t.NORMINV=u.NORM.INV,t.NORMSDIST=u.NORM.S.DIST,t.NORMSINV=u.NORM.S.INV,t.PERCENTILE=n(u.PERCENTILE.EXC,u.PERCENTILE),t.PERCENTILEEXC=u.PERCENTILE.EXC,t.PERCENTILEINC=u.PERCENTILE.INC,t.PERCENTRANK=n(u.PERCENTRANK.INC,u.PERCENTRANK),t.PERCENTRANKEXC=u.PERCENTRANK.EXC,t.PERCENTRANKINC=u.PERCENTRANK.INC,t.POISSON=n(u.POISSON.DIST,u.POISSON),t.POISSONDIST=u.POISSON.DIST,t.QUARTILE=n(u.QUARTILE.INC,u.QUARTILE),t.QUARTILEEXC=u.QUARTILE.EXC,t.QUARTILEINC=u.QUARTILE.INC,t.RANK=n(u.RANK.EQ,u.RANK),t.RANKAVG=u.RANK.AVG,t.RANKEQ=u.RANK.EQ,t.SKEWP=u.SKEW.P,t.STDEV=n(u.STDEV.S,u.STDEV),t.STDEVP=u.STDEV.P,t.STDEVS=u.STDEV.S,t.TDIST=u.T.DIST,t.TDISTRT=u.T.DIST.RT,t.TINV=u.T.INV,t.TTEST=u.T.TEST,t.VAR=n(u.VAR.S,u.VAR),t.VARP=u.VAR.P,t.VARS=u.VAR.S,t.WEIBULL=n(u.WEIBULL.DIST,u.WEIBULL),t.WEIBULLDIST=u.WEIBULL.DIST,t.WORKDAYINTL=o.WORKDAY.INTL,t.ZTEST=u.Z.TEST},function(r,t,e){function n(r,t){return r.reduce(function(r,e){return t*r+e},0)}function a(r,t,e,n,a){a||(a=-1);var u,i=2/r;if(0===t)return e;if(1===t)return n;for(var o=1;o!=t;++o)u=n*o*i+a*e,e=n,n=u;return n}function u(r,t,e,n,u){return function(i,o){if(0===o)return r(i);if(1===o)return t(i);if(0>o)throw e+": Order ("+o+") must be nonnegative";if(1==n&&0===i)throw e+": Undefined when x == 0";if(2==n&&0>=i)throw e+": Undefined when x <= 0";return a(i,o,r(i),t(i),u)}}var i=Math,o=function(){function r(r){var t,a,f,c=r*r,p=i.abs(r)-.785398164;return 8>i.abs(r)?(a=n(e,c),f=n(u,c),t=a/f):(c=64/c,a=n(o,c),f=n(s,c),t=i.sqrt(l/i.abs(r))*(i.cos(p)*a-i.sin(p)*f*8/i.abs(r))),t}function t(r){var t,e,a,u=r*r,o=i.abs(r)-2.356194491;return 8>Math.abs(r)?(e=r*n(f,u),a=n(c,u),t=e/a):(u=64/u,e=n(p,u),a=n(h,u),t=i.sqrt(l/i.abs(r))*(i.cos(o)*e-i.sin(o)*a*8/i.abs(r)),0>r&&(t=-t)),t}var e=[57568490574,-13362590354,651619640.7,-11214424.18,77392.33017,-184.9052456].reverse(),u=[57568490411,1029532985,9494680.718,59272.64853,267.8532712,1].reverse(),o=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),s=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34935152e-8].reverse(),l=.636619772,f=[72362614232,-7895059235,242396853.1,-2972611.439,15704.4826,-30.16036606].reverse(),c=[144725228442,2300535178,18583304.74,99447.43394,376.9991397,1].reverse(),p=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),h=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();return function(e,n){if(0===(n=Math.round(n)))return r(i.abs(e));if(1===n)return t(i.abs(e));if(0>n)throw"BESSELJ: Order ("+n+") must be nonnegative";if(0===i.abs(e))return 0;var u,o,s,l,f,c,p,h,m=2/i.abs(e);if(i.abs(e)>n)u=a(e,n,r(i.abs(e)),t(i.abs(e)),-1);else{for(s=2*i.floor((n+i.floor(i.sqrt(40*n)))/2),l=0,c=u=f=0,p=1,o=s;o>0;o--)h=o*m*p-c,c=p,p=h,i.abs(p)>1e10&&(p*=1e-10,c*=1e-10,u*=1e-10,f*=1e-10),l&&(f+=p),l=!l,o==n&&(u=c);f=2*f-p,u/=f}return 0>e&&n%2?-u:u}}(),s=function(){function r(r){var t,u,c,p=r*r,h=r-.785398164;return 8>r?(u=n(e,p),c=n(a,p),t=u/c+f*o(r,0)*i.log(r)):(p=64/p,u=n(s,p),c=n(l,p),t=i.sqrt(f/r)*(i.sin(h)*u+i.cos(h)*c*8/r)),t}function t(r){var t,e,a,u=r*r,s=r-2.356194491;return 8>r?(e=r*n(c,u),a=n(p,u),t=e/a+f*(o(r,1)*i.log(r)-1/r)):(u=64/u,e=n(h,u),a=n(m,u),t=i.sqrt(f/r)*(i.sin(s)*e+i.cos(s)*a*8/r)),t}var e=[-2957821389,7062834065,-512359803.6,10879881.29,-86327.92757,228.4622733].reverse(),a=[40076544269,745249964.8,7189466.438,47447.2647,226.1030244,1].reverse(),s=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),l=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34945152e-8].reverse(),f=.636619772,c=[-4900604943e3,127527439e4,-51534381390,734926455.1,-4237922.726,8511.937935].reverse(),p=[249958057e5,424441966400,3733650367,22459040.02,102042.605,354.9632885,1].reverse(),h=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),m=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();return u(r,t,"BESSELY",1,-1)}(),l=function(){function r(r){return r>3.75?i.exp(i.abs(r))/i.sqrt(i.abs(r))*n(a,3.75/i.abs(r)):n(e,r*r/14.0625)}function t(r){return 3.75>r?r*n(u,r*r/14.0625):(0>r?-1:1)*i.exp(i.abs(r))/i.sqrt(i.abs(r))*n(o,3.75/i.abs(r))}var e=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),a=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse(),u=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),o=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse();return function s(e,n){if(0===(n=Math.round(n)))return r(e);if(1==n)return t(e);if(0>n)throw"BESSELI Order ("+n+") must be nonnegative";if(0===i.abs(e))return 0;var a,u,o,l,f,c,p=2/i.abs(e);for(o=2*i.round((n+i.round(i.sqrt(40*n)))/2),l=a=0,f=1,u=o;u>0;u--)c=u*p*f+l,l=f,f=c,i.abs(f)>1e10&&(f*=1e-10,l*=1e-10,a*=1e-10),u==n&&(a=l);return a*=s(e,0)/f,0>e&&n%2?-a:a}}(),f=function(){function r(r){return r>2?i.exp(-r)/i.sqrt(r)*n(a,2/r):-i.log(r/2)*l(r,0)+n(e,r*r/4)}function t(r){return r>2?i.exp(-r)/i.sqrt(r)*n(s,2/r):i.log(r/2)*l(r,1)+1/r*n(o,r*r/4)}var e=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),a=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse(),o=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),s=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();return u(r,t,"BESSELK",2,1)}();t.besselj=o,t.bessely=s,t.besseli=l,t.besselk=f},function(module,exports,__webpack_require__){function compact(r){var t=[];return utils.arrayEach(r,function(r){r&&t.push(r)}),t}function findResultIndex(database,criterias){for(var matches={},i=1;database[0].length>i;++i)matches[i]=!0;var maxCriteriaLength=criterias[0].length;for(i=1;criterias.length>i;++i)criterias[i].length>maxCriteriaLength&&(maxCriteriaLength=criterias[i].length);for(var k=1;database.length>k;++k)for(var l=1;database[k].length>l;++l){for(var currentCriteriaResult=!1,hasMatchingCriteria=!1,j=0;criterias.length>j;++j){var criteria=criterias[j];if(criteria.length>=maxCriteriaLength){var criteriaField=criteria[0];if(database[k][0]===criteriaField){hasMatchingCriteria=!0;for(var p=1;criteria.length>p;++p)currentCriteriaResult=currentCriteriaResult||eval(database[k][l]+criteria[p])}}}hasMatchingCriteria&&(matches[l]=matches[l]&¤tCriteriaResult)}for(var result=[],n=0;database[0].length>n;++n)matches[n]&&result.push(n-1);return result}var error=__webpack_require__(0),stats=__webpack_require__(5),maths=__webpack_require__(4),utils=__webpack_require__(1);exports.FINDFIELD=function(r,t){var e=null;return utils.arrayEach(r,function(r,n){if(r[0]===t)return e=n,!1}),null==e?error.value:e},exports.DAVERAGE=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=0;return utils.arrayEach(n,function(r){i+=a[r]}),0===n.length?error.div0:i/n.length},exports.DCOUNT=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=[];return utils.arrayEach(n,function(r){i.push(a[r])}),stats.COUNT(i)},exports.DCOUNTA=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=[];return utils.arrayEach(n,function(r){i.push(a[r])}),stats.COUNTA(i)},exports.DGET=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);return 0===n.length?error.value:n.length>1?error.num:a[n[0]]},exports.DMAX=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=a[n[0]];return utils.arrayEach(n,function(r){a[r]>i&&(i=a[r])}),i},exports.DMIN=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=a[n[0]];return utils.arrayEach(n,function(r){i>a[r]&&(i=a[r])}),i},exports.DPRODUCT=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=[];utils.arrayEach(n,function(r){i.push(a[r])}),i=compact(i);var o=1;return utils.arrayEach(i,function(r){o*=r}),o},exports.DSTDEV=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=[];return utils.arrayEach(n,function(r){i.push(a[r])}),i=compact(i),stats.STDEV.S(i)},exports.DSTDEVP=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=[];return utils.arrayEach(n,function(r){i.push(a[r])}),i=compact(i),stats.STDEV.P(i)},exports.DSUM=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=[];return utils.arrayEach(n,function(r){i.push(a[r])}),maths.SUM(i)},exports.DVAR=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=[];return utils.arrayEach(n,function(r){i.push(a[r])}),stats.VAR.S(i)},exports.DVARP=function(r,t,e){if(isNaN(t)&&"string"!=typeof t)return error.value;var n=findResultIndex(r,e),a=[];if("string"==typeof t){var u=exports.FINDFIELD(r,t);a=utils.rest(r[u])}else a=utils.rest(r[t]);var i=[];return utils.arrayEach(n,function(r){i.push(a[r])}),stats.VAR.P(i)}},function(r,t,e){var n=e(0),a=e(1),u=e(7);t.AND=function(){for(var r=a.flatten(arguments),t=!0,e=0;r.length>e;e++)r[e]||(t=!1);return t},t.CHOOSE=function(){if(2>arguments.length)return n.na;var r=arguments[0];return 1>r||r>254?n.value:r+1>arguments.length?n.value:arguments[r]},t.FALSE=function(){return!1},t.IF=function(r,t,e){return r?t:e},t.IFERROR=function(r,t){return u.ISERROR(r)?t:r},t.IFNA=function(r,t){return r===n.na?t:r},t.NOT=function(r){return!r},t.OR=function(){for(var r=a.flatten(arguments),t=!1,e=0;r.length>e;e++)r[e]&&(t=!0);return t},t.TRUE=function(){return!0},t.XOR=function(){for(var r=a.flatten(arguments),t=0,e=0;r.length>e;e++)r[e]&&t++;return!!(1&Math.floor(Math.abs(t)))},t.SWITCH=function(){var r;if(arguments.length>0){var t=arguments[0],e=arguments.length-1,a=Math.floor(e/2),u=!1,i=e%2!=0,o=e%2==0?null:arguments[arguments.length-1];if(a)for(var s=0;a>s;s++)if(t===arguments[2*s+1]){r=arguments[2*s+2],u=!0;break}u||(r=i?o:n.na)}else r=n.value;return r}},function(r,t,e){function n(r){return r&&r.getTime&&!isNaN(r.getTime())}function a(r){return r instanceof Date?r:new Date(r)}var u=e(0),i=e(8),o=e(1);t.ACCRINT=function(r,t,e,o,s,l,f){return r=a(r),t=a(t),e=a(e),n(r)&&n(t)&&n(e)?o>0&&s>0?-1===[1,2,4].indexOf(l)?u.num:-1===[0,1,2,3,4].indexOf(f)?u.num:e>r?(s=s||0,f=f||0,s*o*i.YEARFRAC(r,e,f)):u.num:u.num:u.value},t.ACCRINTM=function(){throw Error("ACCRINTM is not implemented")},t.AMORDEGRC=function(){throw Error("AMORDEGRC is not implemented")},t.AMORLINC=function(){throw Error("AMORLINC is not implemented")},t.COUPDAYBS=function(){throw Error("COUPDAYBS is not implemented")},t.COUPDAYS=function(){throw Error("COUPDAYS is not implemented")},t.COUPDAYSNC=function(){throw Error("COUPDAYSNC is not implemented")},t.COUPNCD=function(){throw Error("COUPNCD is not implemented")},t.COUPNUM=function(){throw Error("COUPNUM is not implemented")},t.COUPPCD=function(){throw Error("COUPPCD is not implemented")},t.CUMIPMT=function(r,e,n,a,i,s){if(r=o.parseNumber(r),e=o.parseNumber(e),n=o.parseNumber(n),o.anyIsError(r,e,n))return u.value;if(0>=r||0>=e||0>=n)return u.num;if(1>a||1>i||a>i)return u.num;if(0!==s&&1!==s)return u.num;var l=t.PMT(r,e,n,0,s),f=0;1===a&&0===s&&(f=-n,a++);for(var c=a;i>=c;c++)f+=1===s?t.FV(r,c-2,l,n,1)-l:t.FV(r,c-1,l,n,0);return f*=r},t.CUMPRINC=function(r,e,n,a,i,s){if(r=o.parseNumber(r),e=o.parseNumber(e),n=o.parseNumber(n),o.anyIsError(r,e,n))return u.value;if(0>=r||0>=e||0>=n)return u.num;if(1>a||1>i||a>i)return u.num;if(0!==s&&1!==s)return u.num;var l=t.PMT(r,e,n,0,s),f=0;1===a&&(f=0===s?l+n*r:l,a++);for(var c=a;i>=c;c++)f+=s>0?l-(t.FV(r,c-2,l,n,1)-l)*r:l-t.FV(r,c-1,l,n,0)*r;return f},t.DB=function(r,t,e,n,a){if(a=a===undefined?12:a,r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),a=o.parseNumber(a),o.anyIsError(r,t,e,n,a))return u.value;if(0>r||0>t||0>e||0>n)return u.num;if(-1===[1,2,3,4,5,6,7,8,9,10,11,12].indexOf(a))return u.num;if(n>e)return u.num;if(t>=r)return 0;for(var i=(1-Math.pow(t/r,1/e)).toFixed(3),s=r*i*a/12,l=s,f=0,c=n===e?e-1:n,p=2;c>=p;p++)f=(r-l)*i,l+=f;return 1===n?s:n===e?(r-l)*i:f},t.DDB=function(r,t,e,n,a){if(a=a===undefined?2:a,r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),a=o.parseNumber(a),o.anyIsError(r,t,e,n,a))return u.value;if(0>r||0>t||0>e||0>n||0>=a)return u.num;if(n>e)return u.num;if(t>=r)return 0;for(var i=0,s=0,l=1;n>=l;l++)s=Math.min(a/e*(r-i),r-t-i),i+=s;return s},t.DISC=function(){throw Error("DISC is not implemented")},t.DOLLARDE=function(r,t){if(r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t))return u.value;if(0>t)return u.num;if(t>=0&&1>t)return u.div0;t=parseInt(t,10);var e=parseInt(r,10);e+=r%1*Math.pow(10,Math.ceil(Math.log(t)/Math.LN10))/t;var n=Math.pow(10,Math.ceil(Math.log(t)/Math.LN2)+1);return e=Math.round(e*n)/n},t.DOLLARFR=function(r,t){if(r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t))return u.value;if(0>t)return u.num;if(t>=0&&1>t)return u.div0;t=parseInt(t,10);var e=parseInt(r,10);return e+=r%1*Math.pow(10,-Math.ceil(Math.log(t)/Math.LN10))*t},t.DURATION=function(){throw Error("DURATION is not implemented")},t.EFFECT=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?u.value:0>=r||1>t?u.num:(t=parseInt(t,10),Math.pow(1+r/t,t)-1)},t.FV=function(r,t,e,n,a){if(n=n||0,a=a||0,r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),a=o.parseNumber(a),o.anyIsError(r,t,e,n,a))return u.value;var i;if(0===r)i=n+e*t;else{var s=Math.pow(1+r,t);i=1===a?n*s+e*(1+r)*(s-1)/r:n*s+e*(s-1)/r}return-i},t.FVSCHEDULE=function(r,t){if(r=o.parseNumber(r),t=o.parseNumberArray(o.flatten(t)),o.anyIsError(r,t))return u.value;for(var e=t.length,n=r,a=0;e>a;a++)n*=1+t[a];return n},t.INTRATE=function(){throw Error("INTRATE is not implemented")},t.IPMT=function(r,e,n,a,i,s){if(i=i||0,s=s||0,r=o.parseNumber(r),e=o.parseNumber(e),n=o.parseNumber(n),a=o.parseNumber(a),i=o.parseNumber(i),s=o.parseNumber(s),o.anyIsError(r,e,n,a,i,s))return u.value;var l=t.PMT(r,n,a,i,s);return(1===e?1===s?0:-a:1===s?t.FV(r,e-2,l,a,1)-l:t.FV(r,e-1,l,a,0))*r},t.IRR=function(r,t){if(t=t||0,r=o.parseNumberArray(o.flatten(r)),t=o.parseNumber(t),o.anyIsError(r,t))return u.value;for(var e=[],n=!1,a=!1,i=0;r.length>i;i++)e[i]=0===i?0:e[i-1]+365,r[i]>0&&(n=!0),0>r[i]&&(a=!0);if(!n||!a)return u.num;t=t===undefined?.1:t;var s,l,f,c=t,p=!0;do{f=function(r,t,e){for(var n=e+1,a=r[0],u=1;r.length>u;u++)a+=r[u]/Math.pow(n,(t[u]-t[0])/365);return a}(r,e,c),s=c-f/function(r,t,e){for(var n=e+1,a=0,u=1;r.length>u;u++){var i=(t[u]-t[0])/365;a-=i*r[u]/Math.pow(n,i+1)}return a}(r,e,c),l=Math.abs(s-c),c=s,p=l>1e-10&&Math.abs(f)>1e-10}while(p);return c},t.ISPMT=function(r,t,e,n){return r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),o.anyIsError(r,t,e,n)?u.value:n*r*(t/e-1)},t.MDURATION=function(){throw Error("MDURATION is not implemented")},t.MIRR=function(r,e,n){if(r=o.parseNumberArray(o.flatten(r)),e=o.parseNumber(e),n=o.parseNumber(n),o.anyIsError(r,e,n))return u.value;for(var a=r.length,i=[],s=[],l=0;a>l;l++)0>r[l]?i.push(r[l]):s.push(r[l]);var f=-t.NPV(n,s)*Math.pow(1+n,a-1),c=t.NPV(e,i)*(1+e);return Math.pow(f/c,1/(a-1))-1},t.NOMINAL=function(r,t){return r=o.parseNumber(r),t=o.parseNumber(t),o.anyIsError(r,t)?u.value:0>=r||1>t?u.num:(t=parseInt(t,10),(Math.pow(r+1,1/t)-1)*t)},t.NPER=function(r,t,e,n,a){if(a=a===undefined?0:a,n=n===undefined?0:n,r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),a=o.parseNumber(a),o.anyIsError(r,t,e,n,a))return u.value;var i=t*(1+r*a)-n*r,s=e*r+t*(1+r*a);return Math.log(i/s)/Math.log(1+r)},t.NPV=function(){var r=o.parseNumberArray(o.flatten(arguments));if(r instanceof Error)return r;for(var t=r[0],e=0,n=1;r.length>n;n++)e+=r[n]/Math.pow(1+t,n);return e},t.ODDFPRICE=function(){throw Error("ODDFPRICE is not implemented")},t.ODDFYIELD=function(){throw Error("ODDFYIELD is not implemented")},t.ODDLPRICE=function(){throw Error("ODDLPRICE is not implemented")},t.ODDLYIELD=function(){throw Error("ODDLYIELD is not implemented")},t.PDURATION=function(r,t,e){return r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),o.anyIsError(r,t,e)?u.value:r>0?(Math.log(e)-Math.log(t))/Math.log(1+r):u.num},t.PMT=function(r,t,e,n,a){if(n=n||0,a=a||0,r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),a=o.parseNumber(a),o.anyIsError(r,t,e,n,a))return u.value;var i;if(0===r)i=(e+n)/t;else{var s=Math.pow(1+r,t);i=1===a?(n*r/(s-1)+e*r/(1-1/s))/(1+r):n*r/(s-1)+e*r/(1-1/s)}return-i},t.PPMT=function(r,e,n,a,i,s){return i=i||0,s=s||0,r=o.parseNumber(r),n=o.parseNumber(n),a=o.parseNumber(a),i=o.parseNumber(i),s=o.parseNumber(s),o.anyIsError(r,n,a,i,s)?u.value:t.PMT(r,n,a,i,s)-t.IPMT(r,e,n,a,i,s)},t.PRICE=function(){throw Error("PRICE is not implemented")},t.PRICEDISC=function(){throw Error("PRICEDISC is not implemented")},t.PRICEMAT=function(){throw Error("PRICEMAT is not implemented")},t.PV=function(r,t,e,n,a){return n=n||0,a=a||0,r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),a=o.parseNumber(a),o.anyIsError(r,t,e,n,a)?u.value:0===r?-e*t-n:((1-Math.pow(1+r,t))/r*e*(1+r*a)-n)/Math.pow(1+r,t)},t.RATE=function(r,t,e,n,a,i){if(i=i===undefined?.01:i,n=n===undefined?0:n,a=a===undefined?0:a,r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),a=o.parseNumber(a),i=o.parseNumber(i),o.anyIsError(r,t,e,n,a,i))return u.value;var s,l,f,c,p=0,h=0,m=0,E=i;for(1e-10>Math.abs(E)?s=e*(1+r*E)+t*(1+E*a)*r+n:(h=Math.exp(r*Math.log(1+E)),s=e*h+t*(1/E+a)*(h-1)+n),l=e+t*r+n,f=e*h+t*(1/E+a)*(h-1)+n,m=c=0,p=E;Math.abs(l-f)>1e-10&&50>m;)E=(f*c-l*p)/(f-l),c=p,p=E,1e-10>Math.abs(E)?s=e*(1+r*E)+t*(1+E*a)*r+n:(h=Math.exp(r*Math.log(1+E)),s=e*h+t*(1/E+a)*(h-1)+n),l=f,f=s,++m;return E},t.RECEIVED=function(){throw Error("RECEIVED is not implemented")},t.RRI=function(r,t,e){return r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),o.anyIsError(r,t,e)?u.value:0===r||0===t?u.num:Math.pow(e/t,1/r)-1},t.SLN=function(r,t,e){return r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),o.anyIsError(r,t,e)?u.value:0===e?u.num:(r-t)/e},t.SYD=function(r,t,e,n){return r=o.parseNumber(r),t=o.parseNumber(t),e=o.parseNumber(e),n=o.parseNumber(n),o.anyIsError(r,t,e,n)?u.value:0===e?u.num:1>n||n>e?u.num:(n=parseInt(n,10),(r-t)*(e-n+1)*2/(e*(e+1)))},t.TBILLEQ=function(r,t,e){return r=o.parseDate(r),t=o.parseDate(t),e=o.parseNumber(e),o.anyIsError(r,t,e)?u.value:e>0?r>t?u.num:t-r>31536e6?u.num:365*e/(360-e*i.DAYS360(r,t,!1)):u.num},t.TBILLPRICE=function(r,t,e){return r=o.parseDate(r),t=o.parseDate(t),e=o.parseNumber(e),o.anyIsError(r,t,e)?u.value:e>0?r>t?u.num:t-r>31536e6?u.num:100*(1-e*i.DAYS360(r,t,!1)/360):u.num},t.TBILLYIELD=function(r,t,e){return r=o.parseDate(r),t=o.parseDate(t),e=o.parseNumber(e),o.anyIsError(r,t,e)?u.value:e>0?r>t?u.num:t-r>31536e6?u.num:360*(100-e)/(e*i.DAYS360(r,t,!1)):u.num},t.VDB=function(){throw Error("VDB is not implemented")},t.XNPV=function(r,t,e){if(r=o.parseNumber(r),t=o.parseNumberArray(o.flatten(t)),e=o.parseDateArray(o.flatten(e)),o.anyIsError(r,t,e))return u.value;for(var n=0,a=0;t.length>a;a++)n+=t[a]/Math.pow(1+r,i.DAYS(e[a],e[0])/365);return n},t.YIELD=function(){throw Error("YIELD is not implemented")},t.YIELDDISC=function(){throw Error("YIELDDISC is not implemented")},t.YIELDMAT=function(){throw Error("YIELDMAT is not implemented")}},function(r,t,e){var n=e(0),a=e(1);t.MATCH=function(r,t,e){if(!r&&!t)return n.na;if(2===arguments.length&&(e=1),!(t instanceof Array))return n.na;if(-1!==e&&0!==e&&1!==e)return n.na;for(var a,u,i=0;t.length>i;i++)if(1===e){if(t[i]===r)return i+1;r>t[i]&&(u?t[i]>u&&(a=i+1,u=t[i]):(a=i+1,u=t[i]))}else if(0===e){if("string"==typeof r){if(r=r.replace(/\?/g,"."),t[i].toLowerCase().match(r.toLowerCase()))return i+1}else if(t[i]===r)return i+1}else if(-1===e){if(t[i]===r)return i+1;t[i]>r&&(u?u>t[i]&&(a=i+1,u=t[i]):(a=i+1,u=t[i]))}return a||n.na},t.VLOOKUP=function(r,t,e,a){if(!r||!t||!e)return n.na;a=a||!1;for(var u=0;t.length>u;u++){var i=t[u];if(!a&&i[0]===r||i[0]===r||a&&"string"==typeof i[0]&&-1!==i[0].toLowerCase().indexOf(r.toLowerCase()))return i.length+1>e?i[e-1]:n.ref}return n.na},t.HLOOKUP=function(r,t,e,u){if(!r||!t||!e)return n.na;u=u||!1;for(var i=a.transpose(t),o=0;i.length>o;o++){var s=i[o];if(!u&&s[0]===r||s[0]===r||u&&"string"==typeof s[0]&&-1!==s[0].toLowerCase().indexOf(r.toLowerCase()))return s.length+1>e?s[e-1]:n.ref}return n.na}},function(r,t,e){"use strict";function n(r,t){return r>t}t.__esModule=!0,t["default"]=n,n.SYMBOL=t.SYMBOL=">"},function(r,t,e){"use strict";function n(r,t){return r>=t}t.__esModule=!0,t["default"]=n,n.SYMBOL=t.SYMBOL=">="},function(r,t,e){"use strict";function n(r,t){return t>r}t.__esModule=!0,t["default"]=n,n.SYMBOL=t.SYMBOL="<"},function(r,t,e){"use strict";function n(r,t){return t>=r}t.__esModule=!0,t["default"]=n,n.SYMBOL=t.SYMBOL="<="},function(r,t,e){"use strict";function n(r){for(var t=arguments.length,e=Array(t>1?t-1:0),n=1;t>n;n++)e[n-1]=arguments[n];var i=e.reduce(function(r,t){return r-(0,a.toNumber)(t)},(0,a.toNumber)(r));if(isNaN(i))throw Error(u.ERROR_VALUE);return i}t.__esModule=!0,t.SYMBOL=undefined,t["default"]=n;var a=e(3),u=e(2);n.SYMBOL=t.SYMBOL="-"},function(r,t,e){"use strict";function n(r){for(var t=arguments.length,e=Array(t>1?t-1:0),n=1;t>n;n++)e[n-1]=arguments[n];var i=e.reduce(function(r,t){return r*(0,a.toNumber)(t)},(0,a.toNumber)(r));if(isNaN(i))throw Error(u.ERROR_VALUE);return i}t.__esModule=!0,t.SYMBOL=undefined,t["default"]=n;var a=e(3),u=e(2);n.SYMBOL=t.SYMBOL="*"},function(r,t,e){"use strict";function n(r,t){return r!==t}t.__esModule=!0,t["default"]=n,n.SYMBOL=t.SYMBOL="<>"},function(r,t,e){"use strict";function n(r,t){var e=Math.pow((0,a.toNumber)(r),(0,a.toNumber)(t));if(isNaN(e))throw Error(u.ERROR_VALUE);return e}t.__esModule=!0,t.SYMBOL=undefined,t["default"]=n;var a=e(3),u=e(2);n.SYMBOL=t.SYMBOL="^"},function(module,exports,__webpack_require__){(function(module,process){var grammarParser=function(){function Parser(){this.yy={}}var o=function(r,t,e,n){for(e=e||{},n=r.length;n--;e[r[n]]=t);return e},$V0=[1,5],$V1=[1,8],$V2=[1,6],$V3=[1,7],$V4=[1,9],$V5=[1,14],$V6=[1,15],$V7=[1,16],$V8=[1,12],$V9=[1,13],$Va=[1,17],$Vb=[1,19],$Vc=[1,20],$Vd=[1,21],$Ve=[1,22],$Vf=[1,23],$Vg=[1,24],$Vh=[1,25],$Vi=[1,26],$Vj=[1,27],$Vk=[1,28],$Vl=[5,9,10,11,13,14,15,16,17,18,19,20,29,30],$Vm=[5,9,10,11,13,14,15,16,17,18,19,20,29,30,32],$Vn=[5,9,10,11,13,14,15,16,17,18,19,20,29,30,34],$Vo=[5,10,11,13,14,15,16,17,29,30],$Vp=[5,10,13,14,15,16,29,30],$Vq=[5,10,11,13,14,15,16,17,18,19,29,30],$Vr=[13,29,30],parser={trace:function(){},yy:{},symbols_:{error:2,expressions:3,expression:4,EOF:5,variableSequence:6,number:7,STRING:8,"&":9,"=":10,"+":11,"(":12,")":13,"<":14,">":15,NOT:16,"-":17,"*":18,"/":19,"^":20,FUNCTION:21,expseq:22,cell:23,ABSOLUTE_CELL:24,RELATIVE_CELL:25,MIXED_CELL:26,":":27,ARRAY:28,";":29,",":30,VARIABLE:31,DECIMAL:32,NUMBER:33,"%":34,ERROR:35,$accept:0,$end:1},terminals_:{5:"EOF",8:"STRING",9:"&",10:"=",11:"+",12:"(",13:")",14:"<",15:">",16:"NOT",17:"-",18:"*",19:"/",20:"^",21:"FUNCTION",24:"ABSOLUTE_CELL",25:"RELATIVE_CELL",26:"MIXED_CELL",27:":",28:"ARRAY",29:";",30:",",31:"VARIABLE",32:"DECIMAL",33:"NUMBER",34:"%",35:"ERROR"},productions_:[0,[3,2],[4,1],[4,1],[4,1],[4,3],[4,3],[4,3],[4,3],[4,4],[4,4],[4,4],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,2],[4,2],[4,3],[4,4],[4,1],[4,1],[4,2],[23,1],[23,1],[23,1],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[22,1],[22,1],[22,3],[22,3],[6,1],[6,3],[7,1],[7,3],[7,2],[2,1]],performAction:function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 1:return $$[$0-1];case 2:this.$=yy.callVariable($$[$0][0]);break;case 3:this.$=yy.toNumber($$[$0]);break;case 4:this.$=yy.trimEdges($$[$0]);break;case 5:this.$=yy.evaluateByOperator("&",[$$[$0-2],$$[$0]]);break;case 6:this.$=yy.evaluateByOperator("=",[$$[$0-2],$$[$0]]);break;case 7:this.$=yy.evaluateByOperator("+",[$$[$0-2],$$[$0]]);break;case 8:this.$=$$[$0-1];break;case 9:this.$=yy.evaluateByOperator("<=",[$$[$0-3],$$[$0]]);break;case 10:this.$=yy.evaluateByOperator(">=",[$$[$0-3],$$[$0]]);break;case 11:this.$=yy.evaluateByOperator("<>",[$$[$0-3],$$[$0]]);break;case 12:this.$=yy.evaluateByOperator("NOT",[$$[$0-2],$$[$0]]);break;case 13:this.$=yy.evaluateByOperator(">",[$$[$0-2],$$[$0]]);break;case 14:this.$=yy.evaluateByOperator("<",[$$[$0-2],$$[$0]]);break;case 15:this.$=yy.evaluateByOperator("-",[$$[$0-2],$$[$0]]);break;case 16:this.$=yy.evaluateByOperator("*",[$$[$0-2],$$[$0]]);break;case 17:this.$=yy.evaluateByOperator("/",[$$[$0-2],$$[$0]]);break;case 18:this.$=yy.evaluateByOperator("^",[$$[$0-2],$$[$0]]);break;case 19:var n1=yy.invertNumber($$[$0]);this.$=n1,isNaN(this.$)&&(this.$=0);break;case 20:var n1=yy.toNumber($$[$0]);this.$=n1,isNaN(this.$)&&(this.$=0);break;case 21:this.$=yy.callFunction($$[$0-2]);break;case 22:this.$=yy.callFunction($$[$0-3],$$[$0-1]);break;case 26:case 27:case 28:this.$=yy.cellValue($$[$0]);break;case 29:case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:this.$=yy.rangeValue($$[$0-2],$$[$0]);break;case 38:case 42:this.$=[$$[$0]];break;case 39:var result=[],arr=eval("["+yytext+"]");arr.forEach(function(r){result.push(r)}),this.$=result;break;case 40:case 41:$$[$0-2].push($$[$0]),this.$=$$[$0-2];break;case 43:this.$=Array.isArray($$[$0-2])?$$[$0-2]:[$$[$0-2]],this.$.push($$[$0]);break;case 44:this.$=$$[$0];break;case 45:this.$=1*($$[$0-2]+"."+$$[$0]);break;case 46:this.$=.01*$$[$0-1];break;case 47:this.$=yy.throwError($$[$0])}},table:[{2:11,3:1,4:2,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{1:[3]},{5:[1,18],9:$Vb,10:$Vc,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk},o($Vl,[2,2],{32:[1,29]}),o($Vl,[2,3],{34:[1,30]}),o($Vl,[2,4]),{2:11,4:31,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:32,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:33,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{12:[1,34]},o($Vl,[2,23]),o($Vl,[2,24],{2:35,35:$Va}),o($Vm,[2,42]),o($Vn,[2,44],{32:[1,36]}),o($Vl,[2,26],{27:[1,37]}),o($Vl,[2,27],{27:[1,38]}),o($Vl,[2,28],{27:[1,39]}),o([5,9,10,11,13,14,15,16,17,18,19,20,29,30,35],[2,47]),{1:[2,1]},{2:11,4:40,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:41,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:42,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:45,6:3,7:4,8:$V0,10:[1,43],11:$V1,12:$V2,15:[1,44],17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:47,6:3,7:4,8:$V0,10:[1,46],11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:48,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:49,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:50,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:51,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:52,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{31:[1,53]},o($Vn,[2,46]),{9:$Vb,10:$Vc,11:$Vd,13:[1,54],14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk},o($Vo,[2,19],{9:$Vb,18:$Vi,19:$Vj,20:$Vk}),o($Vo,[2,20],{9:$Vb,18:$Vi,19:$Vj,20:$Vk}),{2:11,4:57,6:3,7:4,8:$V0,11:$V1,12:$V2,13:[1,55],17:$V3,21:$V4,22:56,23:10,24:$V5,25:$V6,26:$V7,28:[1,58],31:$V8,33:$V9,35:$Va},o($Vl,[2,25]),{33:[1,59]},{24:[1,60],25:[1,61],26:[1,62]},{24:[1,63],25:[1,64],26:[1,65]},{24:[1,66],25:[1,67],26:[1,68]},o($Vl,[2,5]),o([5,10,13,29,30],[2,6],{9:$Vb,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vo,[2,7],{9:$Vb,18:$Vi,19:$Vj,20:$Vk}),{2:11,4:69,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:70,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},o($Vp,[2,14],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),{2:11,4:71,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},o($Vp,[2,13],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o([5,10,13,16,29,30],[2,12],{9:$Vb,11:$Vd,14:$Ve,15:$Vf,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vo,[2,15],{9:$Vb,18:$Vi,19:$Vj,20:$Vk}),o($Vq,[2,16],{9:$Vb,20:$Vk}),o($Vq,[2,17],{9:$Vb,20:$Vk}),o([5,10,11,13,14,15,16,17,18,19,20,29,30],[2,18],{9:$Vb}),o($Vm,[2,43]),o($Vl,[2,8]),o($Vl,[2,21]),{13:[1,72],29:[1,73],30:[1,74]},o($Vr,[2,38],{9:$Vb,10:$Vc,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vr,[2,39]),o($Vn,[2,45]),o($Vl,[2,29]),o($Vl,[2,30]),o($Vl,[2,31]),o($Vl,[2,32]),o($Vl,[2,33]),o($Vl,[2,34]),o($Vl,[2,35]),o($Vl,[2,36]),o($Vl,[2,37]),o($Vp,[2,9],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vp,[2,11],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vp,[2,10],{9:$Vb,11:$Vd,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vl,[2,22]),{2:11,4:75,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},{2:11,4:76,6:3,7:4,8:$V0,11:$V1,12:$V2,17:$V3,21:$V4,23:10,24:$V5,25:$V6,26:$V7,31:$V8,33:$V9,35:$Va},o($Vr,[2,40],{9:$Vb,10:$Vc,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk}),o($Vr,[2,41],{9:$Vb,10:$Vc,11:$Vd,14:$Ve,15:$Vf,16:$Vg,17:$Vh,18:$Vi,19:$Vj,20:$Vk})],defaultActions:{18:[2,1]},parseError:function(r,t){function e(r,t){this.message=r,this.hash=t}if(!t.recoverable)throw e.prototype=Error,new e(r,t);this.trace(r)},parse:function(r){function t(r){for(var t=n.length-1,e=0;;){if(""+c in i[r])return e;if(0===r||2>t)return!1;t-=2,r=n[t],++e}}var e=this,n=[0],a=[null],u=[],i=this.table,o="",s=0,l=0,f=0,c=2,p=u.slice.call(arguments,1),h=Object.create(this.lexer),m={yy:{}};for(var E in this.yy)Object.prototype.hasOwnProperty.call(this.yy,E)&&(m.yy[E]=this.yy[E]);h.setInput(r,m.yy),m.yy.lexer=h,m.yy.parser=this,"undefined"==typeof h.yylloc&&(h.yylloc={});var g=h.yylloc;u.push(g);var N=h.options&&h.options.ranges;this.parseError="function"==typeof m.yy.parseError?m.yy.parseError:Object.getPrototypeOf(this).parseError;for(var v,d,I,b,y,M,A,R,S,T=function(){var r;return r=h.lex()||1,"number"!=typeof r&&(r=e.symbols_[r]||r),r},O={};;){if(I=n[n.length-1],this.defaultActions[I]?b=this.defaultActions[I]:(null!==v&&void 0!==v||(v=T()),b=i[I]&&i[I][v]),void 0===b||!b.length||!b[0]){var V,x="";if(f)1!==d&&(V=t(I));else{V=t(I),S=[];for(M in i[I])this.terminals_[M]&&M>c&&S.push("'"+this.terminals_[M]+"'");x=h.showPosition?"Parse error on line "+(s+1)+":\n"+h.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(s+1)+": Unexpected "+(1==v?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(x,{text:h.match,token:this.terminals_[v]||v,line:h.yylineno,loc:g,expected:S,recoverable:!1!==V})}if(3==f){if(1===v||1===d)throw Error(x||"Parsing halted while starting to recover from another error.");l=h.yyleng,o=h.yytext,s=h.yylineno,g=h.yylloc,v=T()}if(!1===V)throw Error(x||"Parsing halted. No suitable error recovery rule available.");!function(r){n.length=n.length-2*r,a.length=a.length-r,u.length=u.length-r}(V),d=v==c?null:v,v=c,I=n[n.length-1],b=i[I]&&i[I][c],f=3}if(b[0]instanceof Array&&b.length>1)throw Error("Parse Error: multiple actions possible at state: "+I+", token: "+v);switch(b[0]){case 1:n.push(v),a.push(h.yytext),u.push(h.yylloc),n.push(b[1]),v=null,d?(v=d,d=null):(l=h.yyleng,o=h.yytext,s=h.yylineno,g=h.yylloc,f>0&&f--);break;case 2:if(A=this.productions_[b[1]][1],O.$=a[a.length-A],O._$={first_line:u[u.length-(A||1)].first_line,last_line:u[u.length-1].last_line,first_column:u[u.length-(A||1)].first_column,last_column:u[u.length-1].last_column},N&&(O._$.range=[u[u.length-(A||1)].range[0],u[u.length-1].range[1]]),void 0!==(y=this.performAction.apply(O,[o,l,s,m.yy,b[1],a,u].concat(p))))return y;A&&(n=n.slice(0,-1*A*2),a=a.slice(0,-1*A),u=u.slice(0,-1*A)),n.push(this.productions_[b[1]][0]),a.push(O.$),u.push(O._$),R=i[n[n.length-2]][n[n.length-1]],n.push(R);break;case 3:return!0}}return!0}},lexer=function(){return{EOF:1,parseError:function(r,t){if(!this.yy.parser)throw Error(r);this.yy.parser.parseError(r,t)},setInput:function(r,t){return this.yy=t||this.yy||{},this._input=r,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var r=this._input[0];return this.yytext+=r,this.yyleng++,this.offset++,this.match+=r,this.matched+=r,r.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),r},unput:function(r){var t=r.length,e=r.split(/(?:\r\n?|\n)/g);this._input=r+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),e.length-1&&(this.yylineno-=e.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:e?(e.length===n.length?this.yylloc.first_column:0)+n[n.length-e.length].length-e[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(r){this.unput(this.match.slice(r))},pastInput:function(){var r=this.matched.substr(0,this.matched.length-this.match.length);return(r.length>20?"...":"")+r.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var r=this.match;return 20>r.length&&(r+=this._input.substr(0,20-r.length)),(r.substr(0,20)+(r.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var r=this.pastInput(),t=Array(r.length+1).join("-");return r+this.upcomingInput()+"\n"+t+"^"},test_match:function(r,t){var e,n,a;if(this.options.backtrack_lexer&&(a={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(a.yylloc.range=this.yylloc.range.slice(0))),n=r[0].match(/(?:\r\n?|\n).*/g),n&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+r[0].length},this.yytext+=r[0],this.match+=r[0],this.matches=r,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(r[0].length),this.matched+=r[0],e=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),e)return e;if(this._backtrack){for(var u in a)this[u]=a[u];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var r,t,e,n;this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),u=0;a.length>u;u++)if((e=this._input.match(this.rules[a[u]]))&&(!t||e[0].length>t[0].length)){if(t=e,n=u,this.options.backtrack_lexer){if(!1!==(r=this.test_match(e,a[u])))return r;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(r=this.test_match(t,a[n]))&&r:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var r=this.next();return r||this.lex()},begin:function(r){this.conditionStack.push(r)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(r){return r=this.conditionStack.length-1-Math.abs(r||0),0>r?"INITIAL":this.conditionStack[r]},pushState:function(r){this.begin(r)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(r,t,e,n){switch(e){case 0:break;case 1:case 2:return 8;case 3:return 21;case 4:return 35;case 5:return 24;case 6:case 7:return 26;case 8:return 25;case 9:return 21;case 10:case 11:return 31;case 12:return 33;case 13:return 28;case 14:return 9;case 15:return" ";case 16:return 32;case 17:return 27;case 18:return 29;case 19:return 30;case 20:return 18;case 21:return 19;case 22:return 17;case 23:return 11;case 24:return 20;case 25:return 12;case 26:return 13;case 27:return 15;case 28:return 14;case 29:return 16;case 30:return'"';case 31:return"'";case 32:return"!";case 33:return 10;case 34:return 34;case 35:return"#";case 36:return 5}},rules:[/^(?:\s+)/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9\.]+(?=[(]))/,/^(?:#[A-Z0-9\/]+(!|\?)?)/,/^(?:\$[A-Za-z]+\$[0-9]+)/,/^(?:\$[A-Za-z]+[0-9]+)/,/^(?:[A-Za-z]+\$[0-9]+)/,/^(?:[A-Za-z]+[0-9]+)/,/^(?:[A-Za-z\.]+(?=[(]))/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)/,/^(?:[A-Za-z_]+)/,/^(?:[0-9]+)/,/^(?:\[(.*)?\])/,/^(?:&)/,/^(?: )/,/^(?:[.])/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:\*)/,/^(?:\/)/,/^(?:-)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\))/,/^(?:>)/,/^(?:<)/,/^(?:NOT\b)/,/^(?:")/,/^(?:')/,/^(?:!)/,/^(?:=)/,/^(?:%)/,/^(?:[#])/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],inclusive:!0}}}}();return parser.lexer=lexer,Parser.prototype=parser,parser.Parser=Parser,new Parser}();exports.parser=grammarParser,exports.Parser=grammarParser.Parser,exports.parse=function(){return grammarParser.parse.apply(grammarParser,arguments)},void 0!==module&&__webpack_require__.c[__webpack_require__.s]===module&&exports.main(process.argv.slice(1))}).call(exports,__webpack_require__(39)(module),__webpack_require__(40))},function(r,t){r.exports=function(r){return r.webpackPolyfill||(r.deprecate=function(){},r.paths=[],r.children||(r.children=[]),Object.defineProperty(r,"loaded",{enumerable:!0,get:function(){return r.l}}),Object.defineProperty(r,"id",{enumerable:!0,get:function(){return r.i}}),r.webpackPolyfill=1),r}},function(r,t){function e(){throw Error("setTimeout has not been defined")}function n(){throw Error("clearTimeout has not been defined")}function a(r){if(f===setTimeout)return setTimeout(r,0);if((f===e||!f)&&setTimeout)return f=setTimeout,setTimeout(r,0);try{return f(r,0)}catch(t){try{return f.call(null,r,0)}catch(t){return f.call(this,r,0)}}}function u(r){if(c===clearTimeout)return clearTimeout(r);if((c===n||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(r);try{return c(r)}catch(t){try{return c.call(null,r)}catch(t){return c.call(this,r)}}}function i(){E&&h&&(E=!1,h.length?m=h.concat(m):g=-1,m.length&&o())}function o(){if(!E){var r=a(i);E=!0;for(var t=m.length;t;){for(h=m,m=[];++g1)for(var e=1;arguments.length>e;e++)t[e-1]=arguments[e];m.push(new s(r,t)),1!==m.length||E||a(o)},s.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=l,p.addListener=l,p.once=l,p.off=l,p.removeListener=l,p.removeAllListeners=l,p.emit=l,p.prependListener=l,p.prependOnceListener=l,p.listeners=function(r){return[]},p.binding=function(r){throw Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(r){throw Error("process.chdir is not supported")},p.umask=function(){return 0}},function(r,t,e){"use strict";function n(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;return r=r.substring(t,r.length-t)}t.__esModule=!0,t.trimEdges=n}])}); \ No newline at end of file +!function(r,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.formulaParser=n():r.formulaParser=n()}("undefined"!=typeof self?self:this,function(){return function(r){function n(t){if(e[t])return e[t].exports;var a=e[t]={i:t,l:!1,exports:{}};return r[t].call(a.exports,a,a.exports,n),a.l=!0,a.exports}var e={};return n.m=r,n.c=e,n.d=function(r,e,t){n.o(r,e)||Object.defineProperty(r,e,{configurable:!1,enumerable:!0,get:t})},n.n=function(r){var e=r&&r.__esModule?function(){return r["default"]}:function(){return r};return n.d(e,"a",e),e},n.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},n.p="",n(n.s=15)}([function(r,n){n.nil=Error("#NULL!"),n.div0=Error("#DIV/0!"),n.value=Error("#VALUE!"),n.ref=Error("#REF!"),n.name=Error("#NAME?"),n.num=Error("#NUM!"),n.na=Error("#N/A"),n.error=Error("#ERROR!"),n.data=Error("#GETTING_DATA")},function(r,n,e){var t=e(0);n.flattenShallow=function(r){return r&&r.reduce?r.reduce(function(r,n){var e=Array.isArray(r),t=Array.isArray(n);return e&&t?r.concat(n):e?(r.push(n),r):t?[r].concat(n):[r,n]}):r},n.isFlat=function(r){if(!r)return!1;for(var n=0;r.length>n;++n)if(Array.isArray(r[n]))return!1;return!0},n.flatten=function(){for(var r=n.argsToArray.apply(null,arguments);!n.isFlat(r);)r=n.flattenShallow(r);return r},n.argsToArray=function(r){var e=[];return n.arrayEach(r,function(r){e.push(r)}),e},n.numbers=function(){return this.flatten.apply(null,arguments).filter(function(r){return"number"==typeof r})},n.cleanFloat=function(r){return Math.round(1e14*r)/1e14},n.parseBool=function(r){if("boolean"==typeof r)return r;if(r instanceof Error)return r;if("number"==typeof r)return 0!==r;if("string"==typeof r){var n=r.toUpperCase();if("TRUE"===n)return!0;if("FALSE"===n)return!1}return r instanceof Date&&!isNaN(r)||t.value},n.parseNumber=function(r){return r===undefined||""===r?t.value:isNaN(r)?t.value:parseFloat(r)},n.parseNumberArray=function(r){var e;if(!r||0===(e=r.length))return t.value;for(var a;e--;){if((a=n.parseNumber(r[e]))===t.value)return a;r[e]=a}return r},n.parseMatrix=function(r){if(!r||0===r.length)return t.value;for(var e,a=0;r.length>a;a++)if(e=n.parseNumberArray(r[a]),r[a]=e,e instanceof Error)return e;return r};var a=new Date(Date.UTC(1900,0,1));n.parseDate=function(r){if(!isNaN(r)){if(r instanceof Date)return new Date(r);var n=parseInt(r,10);return 0>n?t.num:n>60?new Date(a.getTime()+864e5*(n-2)):new Date(a.getTime()+864e5*(n-1))}return"string"!=typeof r||(r=new Date(r),isNaN(r))?t.value:r},n.parseDateArray=function(r){for(var n,e=r.length;e--;){if((n=this.parseDate(r[e]))===t.value)return n;r[e]=n}return r},n.anyIsError=function(){for(var r=arguments.length;r--;)if(arguments[r]instanceof Error)return!0;return!1},n.arrayValuesToNumbers=function(r){for(var n,e=r.length;e--;)if("number"!=typeof(n=r[e]))if(!0!==n)if(!1!==n){if("string"==typeof n){var t=this.parseNumber(n);r[e]=t instanceof Error?0:t}}else r[e]=0;else r[e]=1;return r},n.rest=function(r,n){return n=n||1,r&&"function"==typeof r.slice?r.slice(n):r},n.initial=function(r,n){return n=n||1,r&&"function"==typeof r.slice?r.slice(0,r.length-n):r},n.arrayEach=function(r,n){for(var e=-1,t=r.length;++e-1?parseFloat(r):parseInt(r,10)),n}function a(r){return-1*t(r)}n.__esModule=!0,n.toNumber=t,n.invertNumber=a},function(r,n,e){var t=e(1),a=e(0),u=e(5),o=e(8),i=e(7);n.ABS=function(r){return(r=t.parseNumber(r))instanceof Error?r:Math.abs(r)},n.ACOS=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var n=Math.acos(r);return isNaN(n)&&(n=a.num),n},n.ACOSH=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var n=Math.log(r+Math.sqrt(r*r-1));return isNaN(n)&&(n=a.num),n},n.ACOT=function(r){return(r=t.parseNumber(r))instanceof Error?r:Math.atan(1/r)},n.ACOTH=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var n=.5*Math.log((r+1)/(r-1));return isNaN(n)&&(n=a.num),n},n.AGGREGATE=function(r,e,o,i){if(r=t.parseNumber(r),e=t.parseNumber(r),t.anyIsError(r,e))return a.value;switch(r){case 1:return u.AVERAGE(o);case 2:return u.COUNT(o);case 3:return u.COUNTA(o);case 4:return u.MAX(o);case 5:return u.MIN(o);case 6:return n.PRODUCT(o);case 7:return u.STDEV.S(o);case 8:return u.STDEV.P(o);case 9:return n.SUM(o);case 10:return u.VAR.S(o);case 11:return u.VAR.P(o);case 12:return u.MEDIAN(o);case 13:return u.MODE.SNGL(o);case 14:return u.LARGE(o,i);case 15:return u.SMALL(o,i);case 16:return u.PERCENTILE.INC(o,i);case 17:return u.QUARTILE.INC(o,i);case 18:return u.PERCENTILE.EXC(o,i);case 19:return u.QUARTILE.EXC(o,i)}},n.ARABIC=function(r){if(!/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/.test(r))return a.value;var n=0;return r.replace(/[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,function(r){n+={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}[r]}),n},n.ASIN=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var n=Math.asin(r);return isNaN(n)&&(n=a.num),n},n.ASINH=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.log(r+Math.sqrt(r*r+1))},n.ATAN=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.atan(r)},n.ATAN2=function(r,n){return r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:Math.atan2(r,n)},n.ATANH=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var n=Math.log((1+r)/(1-r))/2;return isNaN(n)&&(n=a.num),n},n.BASE=function(r,n,e){if(e=e||0,r=t.parseNumber(r),n=t.parseNumber(n),e=t.parseNumber(e),t.anyIsError(r,n,e))return a.value;e=e===undefined?0:e;var u=r.toString(n);return Array(Math.max(e+1-u.length,0)).join("0")+u},n.CEILING=function(r,e,u){if(e=e===undefined?1:Math.abs(e),u=u||0,r=t.parseNumber(r),e=t.parseNumber(e),u=t.parseNumber(u),t.anyIsError(r,e,u))return a.value;if(0===e)return 0;var o=-Math.floor(Math.log(e)/Math.log(10));return 0>r?0===u?-n.ROUND(Math.floor(Math.abs(r)/e)*e,o):-n.ROUND(Math.ceil(Math.abs(r)/e)*e,o):n.ROUND(Math.ceil(r/e)*e,o)},n.CEILING.MATH=n.CEILING,n.CEILING.PRECISE=n.CEILING,n.COMBIN=function(r,e){return r=t.parseNumber(r),e=t.parseNumber(e),t.anyIsError(r,e)?a.value:n.FACT(r)/(n.FACT(e)*n.FACT(r-e))},n.COMBINA=function(r,e){return r=t.parseNumber(r),e=t.parseNumber(e),t.anyIsError(r,e)?a.value:0===r&&0===e?1:n.COMBIN(r+e-1,r-1)},n.COS=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.cos(r)},n.COSH=function(r){return r=t.parseNumber(r),r instanceof Error?r:(Math.exp(r)+Math.exp(-r))/2},n.COT=function(r){return r=t.parseNumber(r),r instanceof Error?r:1/Math.tan(r)},n.COTH=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var n=Math.exp(2*r);return(n+1)/(n-1)},n.CSC=function(r){return r=t.parseNumber(r),r instanceof Error?r:1/Math.sin(r)},n.CSCH=function(r){return r=t.parseNumber(r),r instanceof Error?r:2/(Math.exp(r)-Math.exp(-r))},n.DECIMAL=function(r,n){return 1>arguments.length?a.value:parseInt(r,n)},n.DEGREES=function(r){return r=t.parseNumber(r),r instanceof Error?r:180*r/Math.PI},n.EVEN=function(r){return r=t.parseNumber(r),r instanceof Error?r:n.CEILING(r,-2,-1)},n.EXP=function(r){return 1>arguments.length?a.na:"number"!=typeof r||arguments.length>1?a.error:r=Math.exp(r)};var f=[];n.FACT=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var e=Math.floor(r);return 0===e||1===e?1:f[e]>0?f[e]:f[e]=n.FACT(e-1)*e},n.FACTDOUBLE=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var e=Math.floor(r);return e>0?e*n.FACTDOUBLE(e-2):1},n.FLOOR=function(r,e){if(r=t.parseNumber(r),e=t.parseNumber(e),t.anyIsError(r,e))return a.value;if(0===e)return 0;if(!(r>0&&e>0||0>r&&0>e))return a.num;e=Math.abs(e);var u=-Math.floor(Math.log(e)/Math.log(10));return 0>r?-n.ROUND(Math.ceil(Math.abs(r)/e),u):n.ROUND(Math.floor(r/e)*e,u)},n.FLOOR.MATH=function(r,e,u){if(e=e===undefined?1:e,u=u===undefined?0:u,r=t.parseNumber(r),e=t.parseNumber(e),u=t.parseNumber(u),t.anyIsError(r,e,u))return a.value;if(0===e)return 0;e=e?Math.abs(e):1;var o=-Math.floor(Math.log(e)/Math.log(10));return 0>r?0===u||u===undefined?-n.ROUND(Math.ceil(Math.abs(r)/e)*e,o):-n.ROUND(Math.floor(Math.abs(r)/e)*e,o):n.ROUND(Math.floor(r/e)*e,o)},n.FLOOR.PRECISE=n.FLOOR.MATH,n.GCD=function(){var r=t.parseNumberArray(t.flatten(arguments));if(r instanceof Error)return r;for(var n=r.length,e=r[0],a=0>e?-e:e,u=1;n>u;u++){for(var o=r[u],i=0>o?-o:o;a&&i;)a>i?a%=i:i%=a;a+=i}return a},n.INT=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.floor(r)},n.ISO={CEILING:n.CEILING},n.LCM=function(){var r=t.parseNumberArray(t.flatten(arguments));if(r instanceof Error)return r;for(var n,e,a,u,o=1;(a=r.pop())!==undefined;)for(;a>1;){if(a%2){for(n=3,e=Math.floor(Math.sqrt(a));e>=n&&a%n;n+=2);u=n>e?a:n}else u=2;for(a/=u,o*=u,n=r.length;n;r[--n]%u==0&&1==(r[n]/=u)&&r.splice(n,1));}return o},n.LN=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.log(r)},n.LN10=function(){return Math.log(10)},n.LN2=function(){return Math.log(2)},n.LOG10E=function(){return Math.LOG10E},n.LOG2E=function(){return Math.LOG2E},n.LOG=function(r,n){return r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:(n=n===undefined?10:n,Math.log(r)/Math.log(n))},n.LOG10=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.log(r)/Math.log(10)},n.MOD=function(r,n){if(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n))return a.value;if(0===n)return a.div0;var e=Math.abs(r%n);return n>0?e:-e},n.MROUND=function(r,n){return r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:0>r*n?a.num:Math.round(r/n)*n},n.MULTINOMIAL=function(){var r=t.parseNumberArray(t.flatten(arguments));if(r instanceof Error)return r;for(var e=0,a=1,u=0;r.length>u;u++)e+=r[u],a*=n.FACT(r[u]);return n.FACT(e)/a},n.ODD=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var n=Math.ceil(Math.abs(r));return n=1&n?n:n+1,r>0?n:-n},n.PI=function(){return Math.PI},n.E=function(){return Math.E},n.POWER=function(r,n){if(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n))return a.value;var e=Math.pow(r,n);return isNaN(e)?a.num:e},n.PRODUCT=function(){var r=t.parseNumberArray(t.flatten(arguments));if(r instanceof Error)return r;for(var n=1,e=0;r.length>e;e++)n*=r[e];return n},n.QUOTIENT=function(r,n){return r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:parseInt(r/n,10)},n.RADIANS=function(r){return r=t.parseNumber(r),r instanceof Error?r:r*Math.PI/180},n.RAND=function(){return Math.random()},n.RANDBETWEEN=function(r,n){return r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:r+Math.ceil((n-r+1)*Math.random())-1},n.ROMAN=function(r){if((r=t.parseNumber(r))instanceof Error)return r;for(var n=(r+"").split(""),e=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],a="",u=3;u--;)a=(e[+n.pop()+10*u]||"")+a;return Array(+n.join("")+1).join("M")+a},n.ROUND=function(r,n){return r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:Math.round(r*Math.pow(10,n))/Math.pow(10,n)},n.ROUNDDOWN=function(r,n){return r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:(r>0?1:-1)*Math.floor(Math.abs(r)*Math.pow(10,n))/Math.pow(10,n)},n.ROUNDUP=function(r,n){return r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:(r>0?1:-1)*Math.ceil(Math.abs(r)*Math.pow(10,n))/Math.pow(10,n)},n.SEC=function(r){return r=t.parseNumber(r),r instanceof Error?r:1/Math.cos(r)},n.SECH=function(r){return r=t.parseNumber(r),r instanceof Error?r:2/(Math.exp(r)+Math.exp(-r))},n.SERIESSUM=function(r,n,e,u){if(r=t.parseNumber(r),n=t.parseNumber(n),e=t.parseNumber(e),u=t.parseNumberArray(u),t.anyIsError(r,n,e,u))return a.value;for(var o=u[0]*Math.pow(r,n),i=1;u.length>i;i++)o+=u[i]*Math.pow(r,n+i*e);return o},n.SIGN=function(r){return r=t.parseNumber(r),r instanceof Error?r:0>r?-1:0===r?0:1},n.SIN=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.sin(r)},n.SINH=function(r){return r=t.parseNumber(r),r instanceof Error?r:(Math.exp(r)-Math.exp(-r))/2},n.SQRT=function(r){return r=t.parseNumber(r),r instanceof Error?r:0>r?a.num:Math.sqrt(r)},n.SQRTPI=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.sqrt(r*Math.PI)},n.SQRT1_2=function(){return 1/Math.sqrt(2)},n.SQRT2=function(){return Math.sqrt(2)},n.SUBTOTAL=function(r,e){if((r=t.parseNumber(r))instanceof Error)return r;switch(r){case 1:return u.AVERAGE(e);case 2:return u.COUNT(e);case 3:return u.COUNTA(e);case 4:return u.MAX(e);case 5:return u.MIN(e);case 6:return n.PRODUCT(e);case 7:return u.STDEV.S(e);case 8:return u.STDEV.P(e);case 9:return n.SUM(e);case 10:return u.VAR.S(e);case 11:return u.VAR.P(e);case 101:return u.AVERAGE(e);case 102:return u.COUNT(e);case 103:return u.COUNTA(e);case 104:return u.MAX(e);case 105:return u.MIN(e);case 106:return n.PRODUCT(e);case 107:return u.STDEV.S(e);case 108:return u.STDEV.P(e);case 109:return n.SUM(e);case 110:return u.VAR.S(e);case 111:return u.VAR.P(e)}},n.ADD=function(r,n){return 2!==arguments.length?a.na:(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:r+n)},n.MINUS=function(r,n){return 2!==arguments.length?a.na:(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:r-n)},n.DIVIDE=function(r,n){return 2!==arguments.length?a.na:(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:0===n?a.div0:r/n)},n.MULTIPLY=function(r,n){return 2!==arguments.length?a.na:(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:r*n)},n.GTE=function(r,n){return 2!==arguments.length?a.na:(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.error:r>=n)},n.LT=function(r,n){return 2!==arguments.length?a.na:(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.error:n>r)},n.LTE=function(r,n){return 2!==arguments.length?a.na:(r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.error:n>=r)},n.EQ=function(r,n){return 2!==arguments.length?a.na:r===n},n.NE=function(r,n){return 2!==arguments.length?a.na:r!==n},n.POW=function(r,e){return 2!==arguments.length?a.na:(r=t.parseNumber(r),e=t.parseNumber(e),t.anyIsError(r,e)?a.error:n.POWER(r,e))},n.SUM=function(){var r=0;return t.arrayEach(t.argsToArray(arguments),function(e){if("number"==typeof e)r+=e;else if("string"==typeof e){var t=parseFloat(e);!isNaN(t)&&(r+=t)}else Array.isArray(e)&&(r+=n.SUM.apply(null,e))}),r},n.SUMIF=function(r,n){if((r=t.parseNumberArray(t.flatten(r)))instanceof Error)return r;for(var e=0,a=void 0===n||"*"===n,u=a?null:i.parse(n+""),o=0;r.length>o;o++){var f=r[o];if(a)e+=f;else{var s=[i.createToken(f,i.TOKEN_TYPE_LITERAL)].concat(u);e+=i.compute(s)?f:0}}return e},n.SUMIFS=function(){var r=t.argsToArray(arguments),n=t.parseNumberArray(t.flatten(r.shift()));if(n instanceof Error)return n;for(var e=r,a=n.length,u=e.length,o=0,f=0;a>f;f++){for(var s=n[f],l=!1,c=0;u>c;c++){var h=e[c],p=void 0===h||"*"===h,m=!1;if(p)m=!0;else{var E=i.parse(h+""),N=[i.createToken(s,i.TOKEN_TYPE_LITERAL)].concat(E);m=i.compute(N)}if(!m){l=!1;break}l=!0}l&&(o+=s)}return o},n.SUMPRODUCT=function(){if(!arguments||0===arguments.length)return a.value;for(var r,n,e,u,o=arguments.length+1,i=0,f=0;arguments[0].length>f;f++)if(arguments[0][f]instanceof Array)for(var s=0;arguments[0][f].length>s;s++){for(r=1,n=1;o>n;n++){if((u=t.parseNumber(arguments[n-1][f][s]))instanceof Error)return u;r*=u}i+=r}else{for(r=1,n=1;o>n;n++){if((e=t.parseNumber(arguments[n-1][f]))instanceof Error)return e;r*=e}i+=r}return i},n.SUMSQ=function(){var r=t.parseNumberArray(t.flatten(arguments));if(r instanceof Error)return r;for(var n=0,e=r.length,a=0;e>a;a++)n+=o.ISNUMBER(r[a])?r[a]*r[a]:0;return n},n.SUMX2MY2=function(r,n){if(r=t.parseNumberArray(t.flatten(r)),n=t.parseNumberArray(t.flatten(n)),t.anyIsError(r,n))return a.value;for(var e=0,u=0;r.length>u;u++)e+=r[u]*r[u]-n[u]*n[u];return e},n.SUMX2PY2=function(r,n){if(r=t.parseNumberArray(t.flatten(r)),n=t.parseNumberArray(t.flatten(n)),t.anyIsError(r,n))return a.value;var e=0;r=t.parseNumberArray(t.flatten(r)),n=t.parseNumberArray(t.flatten(n));for(var u=0;r.length>u;u++)e+=r[u]*r[u]+n[u]*n[u];return e},n.SUMXMY2=function(r,n){if(r=t.parseNumberArray(t.flatten(r)),n=t.parseNumberArray(t.flatten(n)),t.anyIsError(r,n))return a.value;var e=0;r=t.flatten(r),n=t.flatten(n);for(var u=0;r.length>u;u++)e+=Math.pow(r[u]-n[u],2);return e},n.TAN=function(r){return r=t.parseNumber(r),r instanceof Error?r:Math.tan(r)},n.TANH=function(r){if((r=t.parseNumber(r))instanceof Error)return r;var n=Math.exp(2*r);return(n-1)/(n+1)},n.TRUNC=function(r,n){return n=n===undefined?0:n,r=t.parseNumber(r),n=t.parseNumber(n),t.anyIsError(r,n)?a.value:(r>0?1:-1)*Math.floor(Math.abs(r)*Math.pow(10,n))/Math.pow(10,n)}},function(r,n,e){var t=e(4),a=e(6),u=e(10),o=e(1),i=e(7),f=e(0),s=e(11);n.AVEDEV=function(){var r=o.parseNumberArray(o.flatten(arguments));return r instanceof Error?r:u.sum(u(r).subtract(u.mean(r)).abs()[0])/r.length},n.AVERAGE=function(){for(var r,n=o.numbers(o.flatten(arguments)),e=n.length,t=0,a=0,u=0;e>u;u++)t+=n[u],a+=1;return r=t/a,isNaN(r)&&(r=f.num),r},n.AVERAGEA=function(){for(var r,n=o.flatten(arguments),e=n.length,t=0,a=0,u=0;e>u;u++){var i=n[u];"number"==typeof i&&(t+=i),!0===i&&t++,null!==i&&a++}return r=t/a,isNaN(r)&&(r=f.num),r},n.AVERAGEIF=function(r,n,e){if(1>=arguments.length)return f.na;if(e=e||r,r=o.flatten(r),(e=o.parseNumberArray(o.flatten(e)))instanceof Error)return e;for(var t=0,a=0,u=void 0===n||"*"===n,s=u?null:i.parse(n+""),l=0;r.length>l;l++){var c=r[l];if(u)a+=e[l],t++;else{var h=[i.createToken(c,i.TOKEN_TYPE_LITERAL)].concat(s);i.compute(h)&&(a+=e[l],t++)}}return a/t},n.AVERAGEIFS=function(){for(var r=o.argsToArray(arguments),n=(r.length-1)/2,e=o.flatten(r[0]),t=0,a=0,u=0;e.length>u;u++){for(var f=!1,s=0;n>s;s++){var l=r[2*s+1][u],c=r[2*s+2],h=void 0===c||"*"===c,p=!1;if(h)p=!0;else{var m=i.parse(c+""),E=[i.createToken(l,i.TOKEN_TYPE_LITERAL)].concat(m);p=i.compute(E)}if(!p){f=!1;break}f=!0}f&&(a+=e[u],t++)}var N=a/t;return isNaN(N)?0:N},n.BETA={},n.BETA.DIST=function(r,n,e,t,a,i){return 4>arguments.length?f.value:(a=a===undefined?0:a,i=i===undefined?1:i,r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),a=o.parseNumber(a),i=o.parseNumber(i),o.anyIsError(r,n,e,a,i)?f.value:(r=(r-a)/(i-a),t?u.beta.cdf(r,n,e):u.beta.pdf(r,n,e)))},n.BETA.INV=function(r,n,e,t,a){return t=t===undefined?0:t,a=a===undefined?1:a,r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),t=o.parseNumber(t),a=o.parseNumber(a),o.anyIsError(r,n,e,t,a)?f.value:u.beta.inv(r,n,e)*(a-t)+t},n.BINOM={},n.BINOM.DIST=function(r,n,e,t){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),t=o.parseNumber(t),o.anyIsError(r,n,e,t)?f.value:t?u.binomial.cdf(r,n,e):u.binomial.pdf(r,n,e)},n.BINOM.DIST.RANGE=function(r,n,e,a){if(a=a===undefined?e:a,r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),a=o.parseNumber(a),o.anyIsError(r,n,e,a))return f.value;for(var u=0,i=e;a>=i;i++)u+=t.COMBIN(r,i)*Math.pow(n,i)*Math.pow(1-n,r-i);return u},n.BINOM.INV=function(r,n,e){if(r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e))return f.value;for(var t=0;r>=t;){if(u.binomial.cdf(t,r,n)>=e)return t;t++}},n.CHISQ={},n.CHISQ.DIST=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),o.anyIsError(r,n)?f.value:e?u.chisquare.cdf(r,n):u.chisquare.pdf(r,n)},n.CHISQ.DIST.RT=function(r,n){return!r|!n?f.na:1>r||n>Math.pow(10,10)?f.num:"number"!=typeof r||"number"!=typeof n?f.value:1-u.chisquare.cdf(r,n)},n.CHISQ.INV=function(r,n){return r=o.parseNumber(r),n=o.parseNumber(n),o.anyIsError(r,n)?f.value:u.chisquare.inv(r,n)},n.CHISQ.INV.RT=function(r,n){return!r|!n?f.na:0>r||r>1||1>n||n>Math.pow(10,10)?f.num:"number"!=typeof r||"number"!=typeof n?f.value:u.chisquare.inv(1-r,n)},n.CHISQ.TEST=function(r,n){if(2!==arguments.length)return f.na;if(!(r instanceof Array&&n instanceof Array))return f.value;if(r.length!==n.length)return f.value;if(r[0]&&n[0]&&r[0].length!==n[0].length)return f.value;var e,t,a,u=r.length;for(t=0;u>t;t++)r[t]instanceof Array||(e=r[t],r[t]=[],r[t].push(e)),n[t]instanceof Array||(e=n[t],n[t]=[],n[t].push(e));var o=r[0].length,i=1===o?u-1:(u-1)*(o-1),s=0,l=Math.PI;for(t=0;u>t;t++)for(a=0;o>a;a++)s+=Math.pow(r[t][a]-n[t][a],2)/n[t][a];return Math.round(1e6*function(r,n){var e=Math.exp(-.5*r);n%2==1&&(e*=Math.sqrt(2*r/l));for(var t=n;t>=2;)e=e*r/t,t-=2;for(var a=e,u=n;a>1e-10*e;)u+=2,a=a*r/u,e+=a;return 1-e}(s,i))/1e6},n.COLUMN=function(r,n){return 2!==arguments.length?f.na:0>n?f.num:r instanceof Array&&"number"==typeof n?0===r.length?undefined:u.col(r,n):f.value},n.COLUMNS=function(r){return 1!==arguments.length?f.na:r instanceof Array?0===r.length?0:u.cols(r):f.value},n.CONFIDENCE={},n.CONFIDENCE.NORM=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:u.normalci(1,r,n,e)[1]-1},n.CONFIDENCE.T=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:u.tci(1,r,n,e)[1]-1},n.CORREL=function(r,n){return r=o.parseNumberArray(o.flatten(r)),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n)?f.value:u.corrcoeff(r,n)},n.COUNT=function(){return o.numbers(o.flatten(arguments)).length},n.COUNTA=function(){var r=o.flatten(arguments);return r.length-n.COUNTBLANK(r)},n.COUNTIN=function(r,n){var e=0;r=o.flatten(r);for(var t=0;r.length>t;t++)r[t]===n&&e++;return e},n.COUNTBLANK=function(){for(var r,n=o.flatten(arguments),e=0,t=0;n.length>t;t++)null!==(r=n[t])&&""!==r||e++;return e},n.COUNTIF=function(r,n){if(r=o.flatten(r),void 0===n||"*"===n)return r.length;for(var e=0,t=i.parse(n+""),a=0;r.length>a;a++){var u=r[a],f=[i.createToken(u,i.TOKEN_TYPE_LITERAL)].concat(t);i.compute(f)&&e++}return e},n.COUNTIFS=function(){for(var r=o.argsToArray(arguments),n=Array(o.flatten(r[0]).length),e=0;n.length>e;e++)n[e]=!0;for(e=0;r.length>e;e+=2){var t=o.flatten(r[e]),a=r[e+1];if(!(void 0===a||"*"===a))for(var u=i.parse(a+""),f=0;t.length>f;f++){var s=t[f],l=[i.createToken(s,i.TOKEN_TYPE_LITERAL)].concat(u);n[f]=n[f]&&i.compute(l)}}var c=0;for(e=0;n.length>e;e++)n[e]&&c++;return c},n.COUNTUNIQUE=function(){return s.UNIQUE.apply(null,o.flatten(arguments)).length},n.COVARIANCE={},n.COVARIANCE.P=function(r,n){if(r=o.parseNumberArray(o.flatten(r)),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n))return f.value;for(var e=u.mean(r),t=u.mean(n),a=0,i=r.length,s=0;i>s;s++)a+=(r[s]-e)*(n[s]-t);return a/i},n.COVARIANCE.S=function(r,n){return r=o.parseNumberArray(o.flatten(r)),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n)?f.value:u.covariance(r,n)},n.DEVSQ=function(){var r=o.parseNumberArray(o.flatten(arguments));if(r instanceof Error)return r;for(var n=u.mean(r),e=0,t=0;r.length>t;t++)e+=Math.pow(r[t]-n,2);return e},n.EXPON={},n.EXPON.DIST=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),o.anyIsError(r,n)?f.value:e?u.exponential.cdf(r,n):u.exponential.pdf(r,n)},n.F={},n.F.DIST=function(r,n,e,t){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:t?u.centralF.cdf(r,n,e):u.centralF.pdf(r,n,e)},n.F.DIST.RT=function(r,n,e){return 3!==arguments.length?f.na:0>r||1>n||1>e?f.num:"number"!=typeof r||"number"!=typeof n||"number"!=typeof e?f.value:1-u.centralF.cdf(r,n,e)},n.F.INV=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:0>=r||r>1?f.num:u.centralF.inv(r,n,e)},n.F.INV.RT=function(r,n,e){return 3!==arguments.length?f.na:0>r||r>1||1>n||n>Math.pow(10,10)||1>e||e>Math.pow(10,10)?f.num:"number"!=typeof r||"number"!=typeof n||"number"!=typeof e?f.value:u.centralF.inv(1-r,n,e)},n.F.TEST=function(r,n){if(!r||!n)return f.na;if(!(r instanceof Array&&n instanceof Array))return f.na;if(2>r.length||2>n.length)return f.div0;var e=function(r,n){for(var e=0,t=0;r.length>t;t++)e+=Math.pow(r[t]-n,2);return e},a=t.SUM(r)/r.length,u=t.SUM(n)/n.length;return e(r,a)/(r.length-1)/(e(n,u)/(n.length-1))},n.FISHER=function(r){return r=o.parseNumber(r),r instanceof Error?r:Math.log((1+r)/(1-r))/2},n.FISHERINV=function(r){if((r=o.parseNumber(r))instanceof Error)return r;var n=Math.exp(2*r);return(n-1)/(n+1)},n.FORECAST=function(r,n,e){if(r=o.parseNumber(r),n=o.parseNumberArray(o.flatten(n)),e=o.parseNumberArray(o.flatten(e)),o.anyIsError(r,n,e))return f.value;for(var t=u.mean(e),a=u.mean(n),i=e.length,s=0,l=0,c=0;i>c;c++)s+=(e[c]-t)*(n[c]-a),l+=Math.pow(e[c]-t,2);var h=s/l;return a-h*t+h*r},n.FREQUENCY=function(r,n){if(r=o.parseNumberArray(o.flatten(r)),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n))return f.value;for(var e=r.length,t=n.length,a=[],u=0;t>=u;u++){a[u]=0;for(var i=0;e>i;i++)0===u?r[i]>n[0]||(a[0]+=1):t>u?r[i]>n[u-1]&&n[u]>=r[i]&&(a[u]+=1):u===t&&r[i]>n[t-1]&&(a[t]+=1)}return a},n.GAMMA=function(r){return r=o.parseNumber(r),r instanceof Error?r:0===r?f.num:parseInt(r,10)===r&&0>r?f.num:u.gammafn(r)},n.GAMMA.DIST=function(r,n,e,t){return 4!==arguments.length?f.na:r>=0&&n>0&&e>0?"number"!=typeof r||"number"!=typeof n||"number"!=typeof e?f.value:t?u.gamma.cdf(r,n,e,!0):u.gamma.pdf(r,n,e,!1):f.value},n.GAMMA.INV=function(r,n,e){return 3!==arguments.length?f.na:0>r||r>1||0>=n||0>=e?f.num:"number"!=typeof r||"number"!=typeof n||"number"!=typeof e?f.value:u.gamma.inv(r,n,e)},n.GAMMALN=function(r){return r=o.parseNumber(r),r instanceof Error?r:u.gammaln(r)},n.GAMMALN.PRECISE=function(r){return 1!==arguments.length?f.na:r>0?"number"!=typeof r?f.value:u.gammaln(r):f.num},n.GAUSS=function(r){return r=o.parseNumber(r),r instanceof Error?r:u.normal.cdf(r,0,1)-.5},n.GEOMEAN=function(){var r=o.parseNumberArray(o.flatten(arguments));return r instanceof Error?r:u.geomean(r)},n.GROWTH=function(r,n,e,t){if((r=o.parseNumberArray(r))instanceof Error)return r;var a;if(n===undefined)for(n=[],a=1;r.length>=a;a++)n.push(a);if(e===undefined)for(e=[],a=1;r.length>=a;a++)e.push(a);if(n=o.parseNumberArray(n),e=o.parseNumberArray(e),o.anyIsError(n,e))return f.value;t===undefined&&(t=!0);var u=r.length,i=0,s=0,l=0,c=0;for(a=0;u>a;a++){var h=n[a],p=Math.log(r[a]);i+=h,s+=p,l+=h*p,c+=h*h}i/=u,s/=u,l/=u,c/=u;var m,E;t?(m=(l-i*s)/(c-i*i),E=s-m*i):(m=l/c,E=0);var N=[];for(a=0;e.length>a;a++)N.push(Math.exp(E+m*e[a]));return N},n.HARMEAN=function(){var r=o.parseNumberArray(o.flatten(arguments));if(r instanceof Error)return r;for(var n=r.length,e=0,t=0;n>t;t++)e+=1/r[t];return n/e},n.HYPGEOM={},n.HYPGEOM.DIST=function(r,n,e,a,u){function i(r,n,e,a){return t.COMBIN(e,r)*t.COMBIN(a-e,n-r)/t.COMBIN(a,n)}return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),a=o.parseNumber(a),o.anyIsError(r,n,e,a)?f.value:u?function(r,n,e,t){for(var a=0,u=0;r>=u;u++)a+=i(u,n,e,t);return a}(r,n,e,a):i(r,n,e,a)},n.INTERCEPT=function(r,e){return r=o.parseNumberArray(r),e=o.parseNumberArray(e),o.anyIsError(r,e)?f.value:r.length!==e.length?f.na:n.FORECAST(0,r,e)},n.KURT=function(){var r=o.parseNumberArray(o.flatten(arguments));if(r instanceof Error)return r;for(var n=u.mean(r),e=r.length,t=0,a=0;e>a;a++)t+=Math.pow(r[a]-n,4);return t/=Math.pow(u.stdev(r,!0),4),e*(e+1)/((e-1)*(e-2)*(e-3))*t-3*(e-1)*(e-1)/((e-2)*(e-3))},n.LARGE=function(r,n){return r=o.parseNumberArray(o.flatten(r)),n=o.parseNumber(n),o.anyIsError(r,n)?r:r.sort(function(r,n){return n-r})[n-1]},n.LINEST=function(r,n){if(r=o.parseNumberArray(o.flatten(r)),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n))return f.value;for(var e=u.mean(r),t=u.mean(n),a=n.length,i=0,s=0,l=0;a>l;l++)i+=(n[l]-t)*(r[l]-e),s+=Math.pow(n[l]-t,2);var c=i/s;return[c,e-c*t]},n.LOGEST=function(r,e){if(r=o.parseNumberArray(o.flatten(r)),e=o.parseNumberArray(o.flatten(e)),o.anyIsError(r,e))return f.value;for(var t=0;r.length>t;t++)r[t]=Math.log(r[t]);var a=n.LINEST(r,e);return a[0]=Math.round(1e6*Math.exp(a[0]))/1e6,a[1]=Math.round(1e6*Math.exp(a[1]))/1e6,a},n.LOGNORM={},n.LOGNORM.DIST=function(r,n,e,t){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:t?u.lognormal.cdf(r,n,e):u.lognormal.pdf(r,n,e)},n.LOGNORM.INV=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:u.lognormal.inv(r,n,e)},n.MAX=function(){var r=o.numbers(o.flatten(arguments));return 0===r.length?0:Math.max.apply(Math,r)},n.MAXA=function(){var r=o.arrayValuesToNumbers(o.flatten(arguments));return 0===r.length?0:Math.max.apply(Math,r)},n.MEDIAN=function(){var r=o.arrayValuesToNumbers(o.flatten(arguments)),n=u.median(r);return isNaN(n)&&(n=f.num),n},n.MIN=function(){var r=o.numbers(o.flatten(arguments));return 0===r.length?0:Math.min.apply(Math,r)},n.MINA=function(){var r=o.arrayValuesToNumbers(o.flatten(arguments));return 0===r.length?0:Math.min.apply(Math,r)},n.MODE={},n.MODE.MULT=function(){var r=o.parseNumberArray(o.flatten(arguments));if(r instanceof Error)return r;for(var n,e=r.length,t={},a=[],u=0,i=0;e>i;i++)n=r[i],t[n]=t[n]?t[n]+1:1,t[n]>u&&(u=t[n],a=[]),t[n]===u&&(a[a.length]=n);return a},n.MODE.SNGL=function(){var r=o.parseNumberArray(o.flatten(arguments));return r instanceof Error?r:n.MODE.MULT(r).sort(function(r,n){return r-n})[0]},n.NEGBINOM={},n.NEGBINOM.DIST=function(r,n,e,t){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:t?u.negbin.cdf(r,n,e):u.negbin.pdf(r,n,e)},n.NORM={},n.NORM.DIST=function(r,n,e,t){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:e>0?t?u.normal.cdf(r,n,e):u.normal.pdf(r,n,e):f.num},n.NORM.INV=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:u.normal.inv(r,n,e)},n.NORM.S={},n.NORM.S.DIST=function(r,n){return r=o.parseNumber(r),r instanceof Error?f.value:n?u.normal.cdf(r,0,1):u.normal.pdf(r,0,1)},n.NORM.S.INV=function(r){return r=o.parseNumber(r),r instanceof Error?f.value:u.normal.inv(r,0,1)},n.PEARSON=function(r,n){if(n=o.parseNumberArray(o.flatten(n)),r=o.parseNumberArray(o.flatten(r)),o.anyIsError(n,r))return f.value;for(var e=u.mean(r),t=u.mean(n),a=r.length,i=0,s=0,l=0,c=0;a>c;c++)i+=(r[c]-e)*(n[c]-t),s+=Math.pow(r[c]-e,2),l+=Math.pow(n[c]-t,2);return i/Math.sqrt(s*l)},n.PERCENTILE={},n.PERCENTILE.EXC=function(r,n){if(r=o.parseNumberArray(o.flatten(r)),n=o.parseNumber(n),o.anyIsError(r,n))return f.value;r=r.sort(function(r,n){return r-n});var e=r.length;if(1/(e+1)>n||n>1-1/(e+1))return f.num;var t=n*(e+1)-1,a=Math.floor(t);return o.cleanFloat(t===a?r[t]:r[a]+(t-a)*(r[a+1]-r[a]))},n.PERCENTILE.INC=function(r,n){if(r=o.parseNumberArray(o.flatten(r)),n=o.parseNumber(n),o.anyIsError(r,n))return f.value;r=r.sort(function(r,n){return r-n});var e=r.length,t=n*(e-1),a=Math.floor(t);return o.cleanFloat(t===a?r[t]:r[a]+(t-a)*(r[a+1]-r[a]))},n.PERCENTRANK={},n.PERCENTRANK.EXC=function(r,n,e){if(e=e===undefined?3:e,r=o.parseNumberArray(o.flatten(r)),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e))return f.value;r=r.sort(function(r,n){return r-n});for(var t=s.UNIQUE.apply(null,r),a=r.length,u=t.length,i=Math.pow(10,e),l=0,c=!1,h=0;!c&&u>h;)n===t[h]?(l=(r.indexOf(t[h])+1)/(a+1),c=!0):t[h]>n||n>=t[h+1]&&h!==u-1||(l=(r.indexOf(t[h])+1+(n-t[h])/(t[h+1]-t[h]))/(a+1),c=!0),h++;return Math.floor(l*i)/i},n.PERCENTRANK.INC=function(r,n,e){if(e=e===undefined?3:e,r=o.parseNumberArray(o.flatten(r)),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e))return f.value;r=r.sort(function(r,n){return r-n});for(var t=s.UNIQUE.apply(null,r),a=r.length,u=t.length,i=Math.pow(10,e),l=0,c=!1,h=0;!c&&u>h;)n===t[h]?(l=r.indexOf(t[h])/(a-1),c=!0):t[h]>n||n>=t[h+1]&&h!==u-1||(l=(r.indexOf(t[h])+(n-t[h])/(t[h+1]-t[h]))/(a-1),c=!0),h++;return Math.floor(l*i)/i},n.PERMUT=function(r,n){return r=o.parseNumber(r),n=o.parseNumber(n),o.anyIsError(r,n)?f.value:t.FACT(r)/t.FACT(r-n)},n.PERMUTATIONA=function(r,n){return r=o.parseNumber(r),n=o.parseNumber(n),o.anyIsError(r,n)?f.value:Math.pow(r,n)},n.PHI=function(r){return r=o.parseNumber(r),r instanceof Error?f.value:Math.exp(-.5*r*r)/2.5066282746310002},n.POISSON={},n.POISSON.DIST=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),o.anyIsError(r,n)?f.value:e?u.poisson.cdf(r,n):u.poisson.pdf(r,n)},n.PROB=function(r,n,e,t){if(e===undefined)return 0;if(t=t===undefined?e:t,r=o.parseNumberArray(o.flatten(r)),n=o.parseNumberArray(o.flatten(n)),e=o.parseNumber(e),t=o.parseNumber(t),o.anyIsError(r,n,e,t))return f.value;if(e===t)return 0>r.indexOf(e)?0:n[r.indexOf(e)];for(var a=r.sort(function(r,n){return r-n}),u=a.length,i=0,s=0;u>s;s++)e>a[s]||a[s]>t||(i+=n[r.indexOf(a[s])]);return i},n.QUARTILE={},n.QUARTILE.EXC=function(r,e){if(r=o.parseNumberArray(o.flatten(r)),e=o.parseNumber(e),o.anyIsError(r,e))return f.value;switch(e){case 1:return n.PERCENTILE.EXC(r,.25);case 2:return n.PERCENTILE.EXC(r,.5);case 3:return n.PERCENTILE.EXC(r,.75);default:return f.num}},n.QUARTILE.INC=function(r,e){if(r=o.parseNumberArray(o.flatten(r)),e=o.parseNumber(e),o.anyIsError(r,e))return f.value;switch(e){case 1:return n.PERCENTILE.INC(r,.25);case 2:return n.PERCENTILE.INC(r,.5);case 3:return n.PERCENTILE.INC(r,.75);default:return f.num}},n.RANK={},n.RANK.AVG=function(r,n,e){if(r=o.parseNumber(r),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n))return f.value;n=o.flatten(n),e=e||!1,n=n.sort(e?function(r,n){return r-n}:function(r,n){return n-r});for(var t=n.length,a=0,u=0;t>u;u++)n[u]===r&&a++;return a>1?(2*n.indexOf(r)+a+1)/2:n.indexOf(r)+1},n.RANK.EQ=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n)?f.value:(e=e||!1,n=n.sort(e?function(r,n){return r-n}:function(r,n){return n-r}),n.indexOf(r)+1)},n.ROW=function(r,n){return 2!==arguments.length?f.na:0>n?f.num:r instanceof Array&&"number"==typeof n?0===r.length?undefined:u.row(r,n):f.value},n.ROWS=function(r){return 1!==arguments.length?f.na:r instanceof Array?0===r.length?0:u.rows(r):f.value},n.RSQ=function(r,e){return r=o.parseNumberArray(o.flatten(r)),e=o.parseNumberArray(o.flatten(e)),o.anyIsError(r,e)?f.value:Math.pow(n.PEARSON(r,e),2)},n.SKEW=function(){var r=o.parseNumberArray(o.flatten(arguments));if(r instanceof Error)return r;for(var n=u.mean(r),e=r.length,t=0,a=0;e>a;a++)t+=Math.pow(r[a]-n,3);return e*t/((e-1)*(e-2)*Math.pow(u.stdev(r,!0),3))},n.SKEW.P=function(){var r=o.parseNumberArray(o.flatten(arguments));if(r instanceof Error)return r;for(var n=u.mean(r),e=r.length,t=0,a=0,i=0;e>i;i++)a+=Math.pow(r[i]-n,3),t+=Math.pow(r[i]-n,2);return a/=e,t/=e,a/Math.pow(t,1.5)},n.SLOPE=function(r,n){if(r=o.parseNumberArray(o.flatten(r)),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n))return f.value;for(var e=u.mean(n),t=u.mean(r),a=n.length,i=0,s=0,l=0;a>l;l++)i+=(n[l]-e)*(r[l]-t),s+=Math.pow(n[l]-e,2);return i/s},n.SMALL=function(r,n){return r=o.parseNumberArray(o.flatten(r)),n=o.parseNumber(n),o.anyIsError(r,n)?r:r.sort(function(r,n){return r-n})[n-1]},n.STANDARDIZE=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:(r-n)/e},n.STDEV={},n.STDEV.P=function(){var r=n.VAR.P.apply(this,arguments),e=Math.sqrt(r);return isNaN(e)&&(e=f.num),e},n.STDEV.S=function(){var r=n.VAR.S.apply(this,arguments);return Math.sqrt(r)},n.STDEVA=function(){var r=n.VARA.apply(this,arguments);return Math.sqrt(r)},n.STDEVPA=function(){var r=n.VARPA.apply(this,arguments),e=Math.sqrt(r);return isNaN(e)&&(e=f.num),e},n.STEYX=function(r,n){if(r=o.parseNumberArray(o.flatten(r)),n=o.parseNumberArray(o.flatten(n)),o.anyIsError(r,n))return f.value;for(var e=u.mean(n),t=u.mean(r),a=n.length,i=0,s=0,l=0,c=0;a>c;c++)i+=Math.pow(r[c]-t,2),s+=(n[c]-e)*(r[c]-t),l+=Math.pow(n[c]-e,2);return Math.sqrt((i-s*s/l)/(a-2))},n.TRANSPOSE=function(r){return r?u.transpose(r):f.na},n.T=a.T,n.T.DIST=function(r,n,e){return r=o.parseNumber(r),n=o.parseNumber(n),o.anyIsError(r,n)?f.value:e?u.studentt.cdf(r,n):u.studentt.pdf(r,n)},n.T.DIST["2T"]=function(r,n){return 2!==arguments.length?f.na:0>r||1>n?f.num:"number"!=typeof r||"number"!=typeof n?f.value:2*(1-u.studentt.cdf(r,n))},n.T.DIST.RT=function(r,n){return 2!==arguments.length?f.na:0>r||1>n?f.num:"number"!=typeof r||"number"!=typeof n?f.value:1-u.studentt.cdf(r,n)},n.T.INV=function(r,n){return r=o.parseNumber(r),n=o.parseNumber(n),o.anyIsError(r,n)?f.value:u.studentt.inv(r,n)},n.T.INV["2T"]=function(r,n){return r=o.parseNumber(r),n=o.parseNumber(n),0>=r||r>1||1>n?f.num:o.anyIsError(r,n)?f.value:Math.abs(u.studentt.inv(r/2,n))},n.T.TEST=function(r,e){if(r=o.parseNumberArray(o.flatten(r)),e=o.parseNumberArray(o.flatten(e)),o.anyIsError(r,e))return f.value;var t,a=u.mean(r),i=u.mean(e),s=0,l=0;for(t=0;r.length>t;t++)s+=Math.pow(r[t]-a,2);for(t=0;e.length>t;t++)l+=Math.pow(e[t]-i,2);s/=r.length-1,l/=e.length-1;var c=Math.abs(a-i)/Math.sqrt(s/r.length+l/e.length);return n.T.DIST["2T"](c,r.length+e.length-2)},n.TREND=function(r,e,t){if(r=o.parseNumberArray(o.flatten(r)),e=o.parseNumberArray(o.flatten(e)),t=o.parseNumberArray(o.flatten(t)),o.anyIsError(r,e,t))return f.value;var a=n.LINEST(r,e),u=a[0],i=a[1],s=[];return t.forEach(function(r){s.push(u*r+i)}),s},n.TRIMMEAN=function(r,n){if(r=o.parseNumberArray(o.flatten(r)),n=o.parseNumber(n),o.anyIsError(r,n))return f.value;var e=t.FLOOR(r.length*n,2)/2;return u.mean(o.initial(o.rest(r.sort(function(r,n){return r-n}),e),e))},n.VAR={},n.VAR.P=function(){for(var r,e=o.numbers(o.flatten(arguments)),t=e.length,a=0,u=n.AVERAGE(e),i=0;t>i;i++)a+=Math.pow(e[i]-u,2);return r=a/t,isNaN(r)&&(r=f.num),r},n.VAR.S=function(){for(var r=o.numbers(o.flatten(arguments)),e=r.length,t=0,a=n.AVERAGE(r),u=0;e>u;u++)t+=Math.pow(r[u]-a,2);return t/(e-1)},n.VARA=function(){for(var r=o.flatten(arguments),e=r.length,t=0,a=0,u=n.AVERAGEA(r),i=0;e>i;i++){var f=r[i];t+="number"==typeof f?Math.pow(f-u,2):!0===f?Math.pow(1-u,2):Math.pow(0-u,2),null!==f&&a++}return t/(a-1)},n.VARPA=function(){for(var r,e=o.flatten(arguments),t=e.length,a=0,u=0,i=n.AVERAGEA(e),s=0;t>s;s++){var l=e[s];a+="number"==typeof l?Math.pow(l-i,2):!0===l?Math.pow(1-i,2):Math.pow(0-i,2),null!==l&&u++}return r=a/u,isNaN(r)&&(r=f.num),r},n.WEIBULL={},n.WEIBULL.DIST=function(r,n,e,t){return r=o.parseNumber(r),n=o.parseNumber(n),e=o.parseNumber(e),o.anyIsError(r,n,e)?f.value:t?1-Math.exp(-Math.pow(r/e,n)):Math.pow(r,n-1)*Math.exp(-Math.pow(r/e,n))*n/Math.pow(e,n)},n.Z={},n.Z.TEST=function(r,e,t){if(r=o.parseNumberArray(o.flatten(r)),e=o.parseNumber(e),o.anyIsError(r,e))return f.value;t=t||n.STDEV.S(r);var a=r.length;return 1-n.NORM.S.DIST((n.AVERAGE(r)-e)/(t/Math.sqrt(a)),!0)}},function(r,n,e){var t=e(1),a=e(0);n.ASC=function(){throw Error("ASC is not implemented")},n.BAHTTEXT=function(){throw Error("BAHTTEXT is not implemented")},n.CHAR=function(r){return r=t.parseNumber(r),r instanceof Error?r:String.fromCharCode(r)},n.CLEAN=function(r){return r=r||"",r.replace(/[\0-\x1F]/g,"")},n.CODE=function(r){r=r||"";var n=r.charCodeAt(0);return isNaN(n)&&(n=a.na),n},n.CONCATENATE=function(){for(var r=t.flatten(arguments),n=0;(n=r.indexOf(!0))>-1;)r[n]="TRUE";for(var e=0;(e=r.indexOf(!1))>-1;)r[e]="FALSE";return r.join("")},n.DBCS=function(){throw Error("DBCS is not implemented")},n.DOLLAR=function(){throw Error("DOLLAR is not implemented")},n.EXACT=function(r,n){return 2!==arguments.length?a.na:r===n},n.FIND=function(r,n,e){return 2>arguments.length?a.na:(e=e===undefined?0:e,n?n.indexOf(r,e-1)+1:null)},n.FIXED=function(){throw Error("FIXED is not implemented")},n.HTML2TEXT=function(r){var n="";return r&&(r instanceof Array?r.forEach(function(r){""!==n&&(n+="\n"),n+=r.replace(/<(?:.|\n)*?>/gm,"")}):n=r.replace(/<(?:.|\n)*?>/gm,"")),n},n.LEFT=function(r,n){return n=n===undefined?1:n,n=t.parseNumber(n),n instanceof Error||"string"!=typeof r?a.value:r?r.substring(0,n):null},n.LEN=function(r){return 0===arguments.length?a.error:"string"==typeof r?r?r.length:0:r.length?r.length:a.value},n.LOWER=function(r){return"string"!=typeof r?a.value:r?r.toLowerCase():r},n.MID=function(r,n,e){if(n=t.parseNumber(n),e=t.parseNumber(e),t.anyIsError(n,e)||"string"!=typeof r)return e;var a=n-1;return r.substring(a,a+e)},n.NUMBERVALUE=function(r,n,e){return n=void 0===n?".":n,e=void 0===e?",":e,+r.replace(n,".").replace(e,"")},n.PRONETIC=function(){throw Error("PRONETIC is not implemented")},n.PROPER=function(r){return r===undefined||0===r.length?a.value:(!0===r&&(r="TRUE"),!1===r&&(r="FALSE"),isNaN(r)&&"number"==typeof r?a.value:("number"==typeof r&&(r=""+r),r.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+r.substr(1).toLowerCase()})))},n.REGEXEXTRACT=function(r,n){if(2>arguments.length)return a.na;var e=r.match(RegExp(n));return e?e[e.length>1?e.length-1:0]:null},n.REGEXMATCH=function(r,n,e){if(2>arguments.length)return a.na;var t=r.match(RegExp(n));return e?t:!!t},n.REGEXREPLACE=function(r,n,e){return 3>arguments.length?a.na:r.replace(RegExp(n),e)},n.REPLACE=function(r,n,e,u){return n=t.parseNumber(n),e=t.parseNumber(e),t.anyIsError(n,e)||"string"!=typeof r||"string"!=typeof u?a.value:r.substr(0,n-1)+u+r.substr(n-1+e)},n.REPT=function(r,n){return n=t.parseNumber(n),n instanceof Error?n:Array(n+1).join(r)},n.RIGHT=function(r,n){return n=n===undefined?1:n,n=t.parseNumber(n),n instanceof Error?n:r?r.substring(r.length-n):a.na},n.SEARCH=function(r,n,e){var t;return"string"!=typeof r||"string"!=typeof n?a.value:(e=e===undefined?0:e,t=n.toLowerCase().indexOf(r.toLowerCase(),e-1)+1,0===t?a.value:t)},n.SPLIT=function(r,n){return r.split(n)},n.SUBSTITUTE=function(r,n,e,t){if(2>arguments.length)return a.na;if(!(r&&n&&e))return r;if(t===undefined)return r.replace(RegExp(n,"g"),e);for(var u=0,o=0;r.indexOf(n,u)>0;)if(u=r.indexOf(n,u+1),++o===t)return r.substring(0,u)+e+r.substring(u+n.length)},n.T=function(r){return"string"==typeof r?r:""},n.TEXT=function(){throw Error("TEXT is not implemented")},n.TRIM=function(r){return"string"!=typeof r?a.value:r.replace(/ +/g," ").trim()},n.UNICHAR=n.CHAR,n.UNICODE=n.CODE,n.UPPER=function(r){return"string"!=typeof r?a.value:r.toUpperCase()},n.VALUE=function(){throw Error("VALUE is not implemented")}},function(r,n){function e(r,n){if(-1===h.indexOf(n))throw Error("Unsupported token type: "+n);return{value:r,type:n}}function t(r){return"string"!=typeof r?r:(/^\d+(\.\d+)?$/.test(r)&&(r=-1===r.indexOf(".")?parseInt(r,10):parseFloat(r)),r)}function a(r){for(var n=r.length,e=[],t=0,a="",u="";n>t;){var o=r.charAt(t);switch(o){case">":case"<":case"=":u+=o,a.length>0&&(e.push(a),a="");break;default:u.length>0&&(e.push(u),u=""),a+=o}t++}return a.length>0&&e.push(a),u.length>0&&e.push(u),e}function u(r){for(var n="",a=[],u=0;r.length>u;u++){var o=r[u];0!==u||0>s.indexOf(o)?n+=o:a.push(e(o,l))}return n.length>0&&a.push(e(t(n),c)),a.length>0&&a[0].type!==l&&a.unshift(e(f,l)),a}function o(r){for(var n,e=[],t=0;r.length>t;t++){var a=r[t];switch(a.type){case l:n=a.value;break;case c:e.push(a.value)}}return i(e,n)}function i(r,n){var e=!1;switch(n){case">":e=r[0]>r[1];break;case">=":e=r[0]>=r[1];break;case"<":e=r[1]>r[0];break;case"<=":e=r[1]>=r[0];break;case"=":e=r[0]==r[1];break;case"<>":e=r[0]!=r[1]}return e}var f="=",s=[">",">=","<","<=","=","<>"],l="operator",c="literal",h=[l,c];n.TOKEN_TYPE_OPERATOR=l,n.TOKEN_TYPE_LITERAL=c,n.parse=function(r){return u(a(r))},n.createToken=e,n.compute=o},function(r,n,e){var t=e(0);n.CELL=function(){throw Error("CELL is not implemented")},n.ERROR={},n.ERROR.TYPE=function(r){switch(r){case t.nil:return 1;case t.div0:return 2;case t.value:return 3;case t.ref:return 4;case t.name:return 5;case t.num:return 6;case t.na:return 7;case t.data:return 8}return t.na},n.INFO=function(){throw Error("INFO is not implemented")},n.ISBLANK=function(r){return null===r},n.ISBINARY=function(r){return/^[01]{1,10}$/.test(r)},n.ISERR=function(r){return[t.value,t.ref,t.div0,t.num,t.name,t.nil].indexOf(r)>=0||"number"==typeof r&&(isNaN(r)||!isFinite(r))},n.ISERROR=function(r){return n.ISERR(r)||r===t.na},n.ISEVEN=function(r){return!(1&Math.floor(Math.abs(r)))},n.ISFORMULA=function(){throw Error("ISFORMULA is not implemented")},n.ISLOGICAL=function(r){return!0===r||!1===r},n.ISNA=function(r){return r===t.na},n.ISNONTEXT=function(r){return"string"!=typeof r},n.ISNUMBER=function(r){return"number"==typeof r&&!isNaN(r)&&isFinite(r)},n.ISODD=function(r){return!!(1&Math.floor(Math.abs(r)))},n.ISREF=function(){throw Error("ISREF is not implemented")},n.ISTEXT=function(r){return"string"==typeof r},n.N=function(r){return this.ISNUMBER(r)?r:r instanceof Date?r.getTime():!0===r?1:!1===r?0:this.ISERROR(r)?r:0},n.NA=function(){return t.na},n.SHEET=function(){throw Error("SHEET is not implemented")},n.SHEETS=function(){throw Error("SHEETS is not implemented")},n.TYPE=function(r){return this.ISNUMBER(r)?1:this.ISTEXT(r)?2:this.ISLOGICAL(r)?4:this.ISERROR(r)?16:Array.isArray(r)?64:void 0}},function(r,n,e){function t(r){return 1===new Date(r,1,29).getMonth()}function a(r,n){return Math.ceil((n-r)/1e3/60/60/24)}function u(r){var n=r>-22038912e5?2:1;return Math.ceil((r-f)/864e5)+n}var o=e(0),i=e(1),f=new Date(Date.UTC(1900,0,1)),s=[undefined,0,1,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,1,2,3,4,5,6,0],l=[[],[1,2,3,4,5,6,7],[7,1,2,3,4,5,6],[6,0,1,2,3,4,5],[],[],[],[],[],[],[],[7,1,2,3,4,5,6],[6,7,1,2,3,4,5],[5,6,7,1,2,3,4],[4,5,6,7,1,2,3],[3,4,5,6,7,1,2],[2,3,4,5,6,7,1],[1,2,3,4,5,6,7]],c=[[],[6,0],[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],undefined,undefined,undefined,[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]];n.DATE=function(r,n,e){return r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),i.anyIsError(r,n,e)?o.value:0>r||0>n||0>e?o.num:new Date(r,n-1,e)},n.DATEVALUE=function(r){var n,e=2;return"string"!=typeof r?o.value:(n=Date.parse(r),isNaN(n)?o.value:(n>-22038912e5||(e=1),Math.ceil((n-f)/864e5)+e))},n.DAY=function(r){var n=i.parseDate(r);return n instanceof Error?n:n.getDate()},n.DAYS=function(r,n){return r=i.parseDate(r),n=i.parseDate(n),r instanceof Error?r:n instanceof Error?n:u(r)-u(n)},n.DAYS360=function(r,n,e){if(e=i.parseBool(e),r=i.parseDate(r),n=i.parseDate(n),r instanceof Error)return r;if(n instanceof Error)return n;if(e instanceof Error)return e;var t,a,u=r.getMonth(),o=n.getMonth();if(e)t=31===r.getDate()?30:r.getDate(),a=31===n.getDate()?30:n.getDate();else{var f=new Date(r.getFullYear(),u+1,0).getDate(),s=new Date(n.getFullYear(),o+1,0).getDate();t=r.getDate()===f?30:r.getDate(),n.getDate()===s?30>t?(o++,a=1):a=30:a=n.getDate()}return 360*(n.getFullYear()-r.getFullYear())+30*(o-u)+(a-t)},n.EDATE=function(r,n){return(r=i.parseDate(r))instanceof Error?r:isNaN(n)?o.value:(n=parseInt(n,10),r.setMonth(r.getMonth()+n),u(r))},n.EOMONTH=function(r,n){return(r=i.parseDate(r))instanceof Error?r:isNaN(n)?o.value:(n=parseInt(n,10),u(new Date(r.getFullYear(),r.getMonth()+n+1,0)))},n.HOUR=function(r){return r=i.parseDate(r),r instanceof Error?r:r.getHours()},n.INTERVAL=function(r){if("number"!=typeof r&&"string"!=typeof r)return o.value;r=parseInt(r,10);var n=Math.floor(r/94608e4);r%=94608e4;var e=Math.floor(r/2592e3);r%=2592e3;var t=Math.floor(r/86400);r%=86400;var a=Math.floor(r/3600);r%=3600;var u=Math.floor(r/60);r%=60;var i=r;return n=n>0?n+"Y":"",e=e>0?e+"M":"",t=t>0?t+"D":"",a=a>0?a+"H":"",u=u>0?u+"M":"",i=i>0?i+"S":"","P"+n+e+t+"T"+a+u+i},n.ISOWEEKNUM=function(r){if((r=i.parseDate(r))instanceof Error)return r;r.setHours(0,0,0),r.setDate(r.getDate()+4-(r.getDay()||7));var n=new Date(r.getFullYear(),0,1);return Math.ceil(((r-n)/864e5+1)/7)},n.MINUTE=function(r){return r=i.parseDate(r),r instanceof Error?r:r.getMinutes()},n.MONTH=function(r){return r=i.parseDate(r),r instanceof Error?r:r.getMonth()+1},n.NETWORKDAYS=function(r,n,e){return this.NETWORKDAYS.INTL(r,n,1,e)},n.NETWORKDAYS.INTL=function(r,n,e,t){if((r=i.parseDate(r))instanceof Error)return r;if((n=i.parseDate(n))instanceof Error)return n;if(!((e=e===undefined?c[1]:c[e])instanceof Array))return o.value;t===undefined?t=[]:t instanceof Array||(t=[t]);for(var a=0;t.length>a;a++){var u=i.parseDate(t[a]);if(u instanceof Error)return u;t[a]=u}var f=(n-r)/864e5+1,s=f,l=r;for(a=0;f>a;a++){var h=(new Date).getTimezoneOffset()>0?l.getUTCDay():l.getDay(),p=!1;h!==e[0]&&h!==e[1]||(p=!0);for(var m=0;t.length>m;m++){var E=t[m];if(E.getDate()===l.getDate()&&E.getMonth()===l.getMonth()&&E.getFullYear()===l.getFullYear()){p=!0;break}}p&&s--,l.setDate(l.getDate()+1)}return s},n.NOW=function(){return new Date},n.SECOND=function(r){return r=i.parseDate(r),r instanceof Error?r:r.getSeconds()},n.TIME=function(r,n,e){return r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),i.anyIsError(r,n,e)?o.value:0>r||0>n||0>e?o.num:(3600*r+60*n+e)/86400},n.TIMEVALUE=function(r){return r=i.parseDate(r),r instanceof Error?r:(3600*r.getHours()+60*r.getMinutes()+r.getSeconds())/86400},n.TODAY=function(){return new Date},n.WEEKDAY=function(r,n){if((r=i.parseDate(r))instanceof Error)return r;n===undefined&&(n=1);var e=r.getDay();return l[n][e]},n.WEEKNUM=function(r,n){if((r=i.parseDate(r))instanceof Error)return r;if(n===undefined&&(n=1),21===n)return this.ISOWEEKNUM(r);var e=s[n],t=new Date(r.getFullYear(),0,1),a=t.getDay()n)return o.num;if(!((e=e===undefined?c[1]:c[e])instanceof Array))return o.value;t===undefined?t=[]:t instanceof Array||(t=[t]);for(var a=0;t.length>a;a++){var u=i.parseDate(t[a]);if(u instanceof Error)return u;t[a]=u}for(var f=0;n>f;){r.setDate(r.getDate()+1);var s=r.getDay();if(s!==e[0]&&s!==e[1]){for(var l=0;t.length>l;l++){var h=t[l];if(h.getDate()===r.getDate()&&h.getMonth()===r.getMonth()&&h.getFullYear()===r.getFullYear()){f--;break}}f++}}return r},n.YEAR=function(r){return r=i.parseDate(r),r instanceof Error?r:r.getFullYear()},n.YEARFRAC=function(r,n,e){if((r=i.parseDate(r))instanceof Error)return r;if((n=i.parseDate(n))instanceof Error)return n;e=e||0;var u=r.getDate(),o=r.getMonth()+1,f=r.getFullYear(),s=n.getDate(),l=n.getMonth()+1,c=n.getFullYear();switch(e){case 0:return 31===u&&31===s?(u=30,s=30):31===u?u=30:30===u&&31===s&&(s=30),(s+30*l+360*c-(u+30*o+360*f))/360;case 1:var h=365;if(f===c||f+1===c&&(o>l||o===l&&u>=s))return(f===c&&t(f)||function(r,n){var e=r.getFullYear(),a=new Date(e,2,1);if(t(e)&&a>r&&n>=a)return!0;var u=n.getFullYear(),o=new Date(u,2,1);return t(u)&&n>=o&&o>r}(r,n)||1===l&&29===s)&&(h=366),a(r,n)/h;var p=c-f+1,m=(new Date(c+1,0,1)-new Date(f,0,1))/1e3/60/60/24,E=m/p;return a(r,n)/E;case 2:return a(r,n)/360;case 3:return a(r,n)/365;case 4:return(s+30*l+360*c-(u+30*o+360*f))/360}}},function(n,e,t){!function(r,e){n.exports=e()}("undefined"!=typeof self&&self,function(){var n=function(r,n){function e(n,e){var t=n>e?n:e;return r.pow(10,17-~~(r.log(t>0?t:-t)*r.LOG10E))}function t(r){return"[object Function]"===p.call(r)}function a(r){return"number"==typeof r&&r===r}function u(r){return c.apply([],r)}function o(){return new o._init(arguments)}function f(){return 0}function s(){return 1}function l(r,n){return r===n?1:0}var c=Array.prototype.concat,h=Array.prototype.slice,p=Object.prototype.toString,m=Array.isArray||function(r){return"[object Array]"===p.call(r)};o.fn=o.prototype,o._init=function(r){var n;if(m(r[0]))if(m(r[0][0])){t(r[1])&&(r[0]=o.map(r[0],r[1]));for(var n=0;r[0].length>n;n++)this[n]=r[0][n];this.length=r[0].length}else this[0]=t(r[1])?o.map(r[0],r[1]):r[0],this.length=1;else if(a(r[0]))this[0]=o.seq.apply(null,r),this.length=1;else{if(r[0]instanceof o)return o(r[0].toArray());this[0]=[],this.length=1}return this},o._init.prototype=o.prototype,o._init.constructor=o,o.utils={calcRdx:e,isArray:m,isFunction:t,isNumber:a,toVector:u},o.extend=function(r){var n,e;if(1===arguments.length){for(e in r)o[e]=r[e];return this}for(var n=1;arguments.length>n;n++)for(e in arguments[n])r[e]=arguments[n][e];return r},o.rows=function(r){return r.length||1},o.cols=function(r){return r[0].length||1},o.dimensions=function(r){return{rows:o.rows(r),cols:o.cols(r)}},o.row=function(r,n){return m(n)?n.map(function(n){return o.row(r,n)}):r[n]},o.rowa=function(r,n){return o.row(r,n)},o.col=function(r,n){if(m(n)){var e=o.arange(r.length).map(function(r){return Array(n.length)});return n.forEach(function(n,t){o.arange(r.length).forEach(function(a){e[a][t]=r[a][n]})}),e}for(var t=Array(r.length),a=0;r.length>a;a++)t[a]=[r[a][n]];return t},o.cola=function(r,n){return o.col(r,n).map(function(r){return r[0]})},o.diag=function(r){for(var n=o.rows(r),e=Array(n),t=0;n>t;t++)e[t]=[r[t][t]];return e},o.antidiag=function(r){for(var n=o.rows(r)-1,e=Array(n),t=0;n>=0;n--,t++)e[t]=[r[t][n]];return e},o.transpose=function(r){var n,e,t,a,u,o=[];m(r[0])||(r=[r]),e=r.length,t=r[0].length;for(var u=0;t>u;u++){for(n=Array(e),a=0;e>a;a++)n[a]=r[a][u];o.push(n)}return 1===o.length?o[0]:o},o.map=function(r,n,e){var t,a,u,o,i;for(m(r[0])||(r=[r]),a=r.length,u=r[0].length,o=e?r:Array(a),t=0;a>t;t++)for(o[t]||(o[t]=Array(u)),i=0;u>i;i++)o[t][i]=n(r[t][i],t,i);return 1===o.length?o[0]:o},o.cumreduce=function(r,n,e){var t,a,u,o,i;for(m(r[0])||(r=[r]),a=r.length,u=r[0].length,o=e?r:Array(a),t=0;a>t;t++)for(o[t]||(o[t]=Array(u)),u>0&&(o[t][0]=r[t][0]),i=1;u>i;i++)o[t][i]=n(o[t][i-1],r[t][i]);return 1===o.length?o[0]:o},o.alter=function(r,n){return o.map(r,n,!0)},o.create=function(r,n,e){var a,u,o=Array(r);t(n)&&(e=n,n=r);for(var a=0;r>a;a++)for(o[a]=Array(n),u=0;n>u;u++)o[a][u]=e(a,u);return o},o.zeros=function(r,n){return a(n)||(n=r),o.create(r,n,f)},o.ones=function(r,n){return a(n)||(n=r),o.create(r,n,s)},o.rand=function(n,e){return a(e)||(e=n),o.create(n,e,r.random)},o.identity=function(r,n){return a(n)||(n=r),o.create(r,n,l)},o.symmetric=function(r){var n,e,t=r.length;if(r.length!==r[0].length)return!1;for(n=0;t>n;n++)for(e=0;t>e;e++)if(r[e][n]!==r[n][e])return!1;return!0},o.clear=function(r){return o.alter(r,f)},o.seq=function(r,n,a,u){t(u)||(u=!1);var o,i=[],f=e(r,n),s=(n*f-r*f)/((a-1)*f),l=r;for(o=0;n>=l&&a>o;o++,l=(r*f+s*f*o)/f)i.push(u?u(l,o):l);return i},o.arange=function(r,e,t){var a=[];if(t=t||1,e===n&&(e=r,r=0),r===e||0===t)return[];if(e>r&&0>t)return[];if(r>e&&t>0)return[];if(t>0)for(i=r;ie;i+=t)a.push(i);return a},o.slice=function(){function r(r,e,t,a){var u,i=[],f=r.length;if(e===n&&t===n&&a===n)return o.copy(r);if(e=e||0,t=t||r.length,e=0>e?f+e:e,t=0>t?f+t:t,a=a||1,e===t||0===a)return[];if(t>e&&0>a)return[];if(e>t&&a>0)return[];if(a>0)for(u=e;t>u;u+=a)i.push(r[u]);else for(u=e;u>t;u+=a)i.push(r[u]);return i}function e(n,e){if(e=e||{},a(e.row)){if(a(e.col))return n[e.row][e.col];var t=o.rowa(n,e.row),u=e.col||{};return r(t,u.start,u.end,u.step)}if(a(e.col)){var i=o.cola(n,e.col),f=e.row||{};return r(i,f.start,f.end,f.step)}var f=e.row||{},u=e.col||{};return r(n,f.start,f.end,f.step).map(function(n){return r(n,u.start,u.end,u.step)})}return e}(),o.sliceAssign=function(e,t,u){if(a(t.row)){if(a(t.col))return e[t.row][t.col]=u;t.col=t.col||{},t.col.start=t.col.start||0,t.col.end=t.col.end||e[0].length,t.col.step=t.col.step||1;var i=o.arange(t.col.start,r.min(e.length,t.col.end),t.col.step),f=t.row;return i.forEach(function(r,n){e[f][r]=u[n]}),e}if(a(t.col)){t.row=t.row||{},t.row.start=t.row.start||0,t.row.end=t.row.end||e.length,t.row.step=t.row.step||1;var s=o.arange(t.row.start,r.min(e[0].length,t.row.end),t.row.step),l=t.col;return s.forEach(function(r,n){e[r][l]=u[n]}),e}u[0].length===n&&(u=[u]),t.row.start=t.row.start||0,t.row.end=t.row.end||e.length,t.row.step=t.row.step||1,t.col.start=t.col.start||0,t.col.end=t.col.end||e[0].length,t.col.step=t.col.step||1;var s=o.arange(t.row.start,r.min(e.length,t.row.end),t.row.step),i=o.arange(t.col.start,r.min(e[0].length,t.col.end),t.col.step);return s.forEach(function(r,n){i.forEach(function(t,a){e[r][t]=u[n][a]})}),e},o.diagonal=function(r){var n=o.zeros(r.length,r.length);return r.forEach(function(r,e){n[e][e]=r}),n},o.copy=function(r){return r.map(function(r){return a(r)?r:r.map(function(r){return r})})};var E=o.prototype;return E.length=0,E.push=Array.prototype.push,E.sort=Array.prototype.sort,E.splice=Array.prototype.splice,E.slice=Array.prototype.slice,E.toArray=function(){return this.length>1?h.call(this):h.call(this)[0]},E.map=function(r,n){return o(o.map(this,r,n))},E.cumreduce=function(r,n){return o(o.cumreduce(this,r,n))},E.alter=function(r){return o.alter(this,r),this},function(r){for(var n=0;r.length>n;n++)!function(r){E[r]=function(n){var e,t=this;return n?(setTimeout(function(){n.call(t,E[r].call(t))}),this):(e=o[r](this),m(e)?o(e):e)}}(r[n])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(r){for(var n=0;r.length>n;n++)!function(r){E[r]=function(n,e){var t=this;return e?(setTimeout(function(){e.call(t,E[r].call(t,n))}),this):o(o[r](this,n))}}(r[n])}("row col".split(" ")),function(r){for(var n=0;r.length>n;n++)!function(r){E[r]=function(){return o(o[r].apply(null,arguments))}}(r[n])}("create zeros ones rand identity".split(" ")),o}(Math);return function(r,n){function e(r,n){return r-n}function t(r,e,t){return n.max(e,n.min(r,t))}var a=r.utils.isFunction;r.sum=function(r){for(var n=0,e=r.length;--e>=0;)n+=r[e];return n},r.sumsqrd=function(r){for(var n=0,e=r.length;--e>=0;)n+=r[e]*r[e];return n},r.sumsqerr=function(n){for(var e,t=r.mean(n),a=0,u=n.length;--u>=0;)e=n[u]-t,a+=e*e;return a},r.sumrow=function(r){for(var n=0,e=r.length;--e>=0;)n+=r[e];return n},r.product=function(r){for(var n=1,e=r.length;--e>=0;)n*=r[e];return n},r.min=function(r){for(var n=r[0],e=0;++er[e]&&(n=r[e]);return n},r.max=function(r){for(var n=r[0],e=0;++en&&(n=r[e]);return n},r.unique=function(r){for(var n={},e=[],t=0;r.length>t;t++)n[r[t]]||(n[r[t]]=!0,e.push(r[t]));return e},r.mean=function(n){return r.sum(n)/n.length},r.meansqerr=function(n){return r.sumsqerr(n)/n.length},r.geomean=function(e){return n.pow(r.product(e),1/e.length)},r.median=function(r){var n=r.length,t=r.slice().sort(e);return 1&n?t[n/2|0]:(t[n/2-1]+t[n/2])/2},r.cumsum=function(n){return r.cumreduce(n,function(r,n){return r+n})},r.cumprod=function(n){return r.cumreduce(n,function(r,n){return r*n})},r.diff=function(r){for(var n,e=[],t=r.length,n=1;t>n;n++)e.push(r[n]-r[n-1]);return e},r.rank=function(r){for(var n=r.length,t=r.slice().sort(e),a=Array(n),u=0;n>u;u++){var o=t.indexOf(r[u]),i=t.lastIndexOf(r[u]);if(o===i)var f=o;else var f=(o+i)/2;a[u]=f+1}return a},r.mode=function(r){for(var n,t=r.length,a=r.slice().sort(e),u=1,o=0,i=0,f=[],n=0;t>n;n++)a[n]===a[n+1]?u++:(u>o?(f=[a[n]],o=u,i=0):u===o&&(f.push(a[n]),i++),u=1);return 0===i?f[0]:f},r.range=function(n){return r.max(n)-r.min(n)},r.variance=function(n,e){return r.sumsqerr(n)/(n.length-(e?1:0))},r.pooledvariance=function(n){return n.reduce(function(n,e){return n+r.sumsqerr(e)},0)/(n.reduce(function(r,n){return r+n.length},0)-n.length)},r.deviation=function(n){for(var e=r.mean(n),t=n.length,a=Array(t),u=0;t>u;u++)a[u]=n[u]-e;return a},r.stdev=function(e,t){return n.sqrt(r.variance(e,t))},r.pooledstdev=function(e){return n.sqrt(r.pooledvariance(e))},r.meandev=function(e){for(var t=r.mean(e),a=[],u=e.length-1;u>=0;u--)a.push(n.abs(e[u]-t));return r.mean(a)},r.meddev=function(e){for(var t=r.median(e),a=[],u=e.length-1;u>=0;u--)a.push(n.abs(e[u]-t));return r.median(a)},r.coeffvar=function(n){return r.stdev(n)/r.mean(n)},r.quartiles=function(r){var t=r.length,a=r.slice().sort(e);return[a[n.round(t/4)-1],a[n.round(t/2)-1],a[n.round(3*t/4)-1]]},r.quantiles=function(r,a,u,o){var i,f,s,l,c,h,p=r.slice().sort(e),m=[a.length],E=r.length;void 0===u&&(u=3/8),void 0===o&&(o=3/8);for(var i=0;a.length>i;i++)f=a[i],s=u+f*(1-u-o),l=E*f+s,c=n.floor(t(l,1,E-1)),h=t(l-c,0,1),m[i]=(1-h)*p[c-1]+h*p[c];return m},r.percentile=function(r,n){var t=r.slice().sort(e),a=n*(t.length-1),u=parseInt(a),o=a-u;return t.length>u+1?t[u]*(1-o)+t[u+1]*o:t[u]},r.percentileOfScore=function(r,n,e){var t,a,u=0,o=r.length,i=!1;"strict"===e&&(i=!0);for(var a=0;o>a;a++)t=r[a],(i&&n>t||!i&&n>=t)&&u++;return u/o},r.histogram=function(e,t){for(var a,u=r.min(e),o=t||4,i=(r.max(e)-u)/o,f=e.length,t=[],a=0;o>a;a++)t[a]=0;for(var a=0;f>a;a++)t[n.min(n.floor((e[a]-u)/i),o-1)]+=1;return t},r.covariance=function(n,e){for(var t,a=r.mean(n),u=r.mean(e),o=n.length,i=Array(o),t=0;o>t;t++)i[t]=(n[t]-a)*(e[t]-u);return r.sum(i)/(o-1)},r.corrcoeff=function(n,e){return r.covariance(n,e)/r.stdev(n,1)/r.stdev(e,1)},r.spearmancoeff=function(n,e){return n=r.rank(n),e=r.rank(e),r.corrcoeff(n,e)},r.stanMoment=function(e,t){for(var a=r.mean(e),u=r.stdev(e),o=e.length,i=0,f=0;o>f;f++)i+=n.pow((e[f]-a)/u,t);return i/e.length},r.skewness=function(n){return r.stanMoment(n,3)},r.kurtosis=function(n){return r.stanMoment(n,4)-3};var u=r.prototype;!function(n){for(var e=0;n.length>e;e++)!function(n){u[n]=function(e,t){var o=[],i=0,f=this;if(a(e)&&(t=e,e=!1),t)return setTimeout(function(){t.call(f,u[n].call(f,e))}),this;if(this.length>1){for(f=!0===e?this:this.transpose();f.length>i;i++)o[i]=r[n](f[i]);return o}return r[n](this[0],e)}}(n[e])}("cumsum cumprod".split(" ")),function(n){for(var e=0;n.length>e;e++)!function(n){u[n]=function(e,t){var o=[],i=0,f=this;if(a(e)&&(t=e,e=!1),t)return setTimeout(function(){t.call(f,u[n].call(f,e))}),this;if(this.length>1){for("sumrow"!==n&&(f=!0===e?this:this.transpose());f.length>i;i++)o[i]=r[n](f[i]);return!0===e?r[n](r.utils.toVector(o)):o}return r[n](this[0],e)}}(n[e])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(n){for(var e=0;n.length>e;e++)!function(n){u[n]=function(){var e=[],t=0,o=this,i=Array.prototype.slice.call(arguments);if(a(i[i.length-1])){var f=i[i.length-1],s=i.slice(0,i.length-1);return setTimeout(function(){f.call(o,u[n].apply(o,s))}),this}var f=undefined,l=function(e){return r[n].apply(o,[e].concat(i))};if(this.length>1){for(o=o.transpose();o.length>t;t++)e[t]=l(o[t]);return e}return l(this[0])}}(n[e])}("quantiles percentileOfScore".split(" "))}(n,Math),function(r,n){r.gammaln=function(r){var e,t,a,u=0,o=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],i=1.000000000190015;for(a=(t=e=r)+5.5,a-=(e+.5)*n.log(a);6>u;u++)i+=o[u]/++t;return n.log(2.5066282746310007*i/e)-a},r.gammafn=function(r){var e,t,a,u,o=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],i=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],f=!1,s=0,l=0,c=0,h=r;if(0>=h){if(!(u=h%1+3.6e-16))return Infinity;f=(1&h?-1:1)*n.PI/n.sin(n.PI*u),h=1-h}a=h,t=1>h?h++:(h-=s=(0|h)-1)-1;for(var e=0;8>e;++e)c=(c+o[e])*t,l=l*t+i[e];if(u=c/l+1,h>a)u/=a;else if(a>h)for(var e=0;s>e;++e)u*=h,h++;return f&&(u=f/u),u},r.gammap=function(n,e){return r.lowRegGamma(n,e)*r.gammafn(n)},r.lowRegGamma=function(e,t){var a,u=r.gammaln(e),o=e,i=1/e,f=i,s=t+1-e,l=1/1e-30,c=1/s,h=c,p=1,m=-~(8.5*n.log(1>e?1/e:e)+.4*e+17);if(0>t||0>=e)return NaN;if(e+1>t){for(;m>=p;p++)i+=f*=t/++o;return i*n.exp(-t+e*n.log(t)-u)}for(;m>=p;p++)a=-p*(p-e),s+=2,c=a*c+s,l=s+a/l,c=1/c,h*=c*l;return 1-h*n.exp(-t+e*n.log(t)-u)},r.factorialln=function(n){return 0>n?NaN:r.gammaln(n+1)},r.factorial=function(n){return 0>n?NaN:r.gammafn(n+1)},r.combination=function(e,t){return e>170||t>170?n.exp(r.combinationln(e,t)):r.factorial(e)/r.factorial(t)/r.factorial(e-t)},r.combinationln=function(n,e){return r.factorialln(n)-r.factorialln(e)-r.factorialln(n-e)},r.permutation=function(n,e){return r.factorial(n)/r.factorial(n-e)},r.betafn=function(e,t){return e>0&&t>0?e+t>170?n.exp(r.betaln(e,t)):r.gammafn(e)*r.gammafn(t)/r.gammafn(e+t):undefined},r.betaln=function(n,e){return r.gammaln(n)+r.gammaln(e)-r.gammaln(n+e)},r.betacf=function(r,e,t){var a,u,o,i,f=1,s=e+t,l=e+1,c=e-1,h=1,p=1-s*r/l;for(1e-30>n.abs(p)&&(p=1e-30),p=1/p,i=p;100>=f&&(a=2*f,u=f*(t-f)*r/((c+a)*(e+a)),p=1+u*p,1e-30>n.abs(p)&&(p=1e-30),h=1+u/h,1e-30>n.abs(h)&&(h=1e-30),p=1/p,i*=p*h,u=-(e+f)*(s+f)*r/((e+a)*(l+a)),p=1+u*p,1e-30>n.abs(p)&&(p=1e-30),h=1+u/h,1e-30>n.abs(h)&&(h=1e-30),p=1/p,o=p*h,i*=o,3e-7<=n.abs(o-1));f++);return i},r.gammapinv=function(e,t){var a,u,o,i,f,s,l,c=0,h=t-1,p=r.gammaln(t);if(e>=1)return n.max(100,t+100*n.sqrt(t));if(0>=e)return 0;for(t>1?(s=n.log(h),l=n.exp(h*(s-1)-p),f=.5>e?e:1-e,o=n.sqrt(-2*n.log(f)),a=(2.30753+.27061*o)/(1+o*(.99229+.04481*o))-o,.5>e&&(a=-a),a=n.max(.001,t*n.pow(1-1/(9*t)-a/(3*n.sqrt(t)),3))):(o=1-t*(.253+.12*t),a=o>e?n.pow(e/o,1/t):1-n.log(1-(e-o)/(1-o)));12>c;c++){if(0>=a)return 0;if(u=r.lowRegGamma(t,a)-e,o=t>1?l*n.exp(-(a-h)+h*(n.log(a)-s)):n.exp(-a+h*n.log(a)-p),i=u/o,a-=o=i/(1-.5*n.min(1,i*((t-1)/a-1))),a>0||(a=.5*(a+o)),n.abs(o)<1e-8*a)break}return a},r.erf=function(r){var e,t,a,u,o=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,9.6467911e-11,2.394038e-12,-6.886027e-12,8.94487e-13,3.13092e-13,-1.12708e-13,3.81e-16,7.106e-15,-1.523e-15,-9.4e-17,1.21e-16,-2.8e-17],i=27,f=!1,s=0,l=0;for(0>r&&(r=-r,f=!0),e=2/(2+r),t=4*e-2;i>0;i--)a=s,s=t*s-l+o[i],l=a;return u=e*n.exp(-r*r+.5*(o[0]+t*s)-l),f?u-1:1-u},r.erfc=function(n){return 1-r.erf(n)},r.erfcinv=function(e){var t,a,u,o,i=0;if(e>=2)return-100;if(0>=e)return 100;for(o=1>e?e:2-e,u=n.sqrt(-2*n.log(o/2)),t=-.70711*((2.30753+.27061*u)/(1+u*(.99229+.04481*u))-u);2>i;i++)a=r.erfc(t)-o,t+=a/(1.1283791670955126*n.exp(-t*t)-t*a);return 1>e?t:-t},r.ibetainv=function(e,t,a){var u,o,i,f,s,l,c,h,p,m,E,N=t-1,v=a-1,g=0;if(0>=e)return 0;if(e>=1)return 1;for(1>t||1>a?(u=n.log(t/(t+a)),o=n.log(a/(t+a)),f=n.exp(t*u)/t,s=n.exp(a*o)/a,m=f+s,c=f/m>e?n.pow(t*m*e,1/t):1-n.pow(a*m*(1-e),1/a)):(i=.5>e?e:1-e,f=n.sqrt(-2*n.log(i)),c=(2.30753+.27061*f)/(1+f*(.99229+.04481*f))-f,.5>e&&(c=-c),h=(c*c-3)/6,p=2/(1/(2*t-1)+1/(2*a-1)),m=c*n.sqrt(h+p)/p-(1/(2*a-1)-1/(2*t-1))*(h+5/6-2/(3*p)),c=t/(t+a*n.exp(2*m))),E=-r.gammaln(t)-r.gammaln(a)+r.gammaln(t+a);10>g;g++){if(0===c||1===c)return c;if(l=r.ibeta(c,t,a)-e,f=n.exp(N*n.log(c)+v*n.log(1-c)+E),s=l/f,c-=f=s/(1-.5*n.min(1,s*(N/c-v/(1-c)))),c>0||(c=.5*(c+f)),1>c||(c=.5*(c+f+1)),n.abs(f)<1e-8*c&&g>0)break}return c},r.ibeta=function(e,t,a){var u=0===e||1===e?0:n.exp(r.gammaln(t+a)-r.gammaln(t)-r.gammaln(a)+t*n.log(e)+a*n.log(1-e));return e>=0&&1>=e&&((t+1)/(t+a+2)>e?u*r.betacf(e,t,a)/t:1-u*r.betacf(1-e,a,t)/a)},r.randn=function(e,t){var a,u,o,i,f;if(t||(t=e),e)return r.create(e,t,function(){return r.randn()});do{a=n.random(),u=1.7156*(n.random()-.5),o=a-.449871,i=n.abs(u)+.386595,f=o*o+i*(.196*i-.25472*o)}while(f>.27597&&(f>.27846||u*u>-4*n.log(a)*a*a));return u/a},r.randg=function(e,t,a){var u,o,i,f,s,l,c=e;if(a||(a=t),e||(e=1),t)return l=r.zeros(t,a),l.alter(function(){return r.randg(e)}),l;1>e&&(e+=1),u=e-1/3,o=1/n.sqrt(9*u);do{do{s=r.randn(),f=1+o*s}while(0>=f);f*=f*f,i=n.random()}while(i>1-.331*n.pow(s,4)&&n.log(i)>.5*s*s+u*(1-f+n.log(f)));if(e==c)return u*f;do{i=n.random()}while(0===i);return n.pow(i,1/c)*u*f},function(n){for(var e=0;n.length>e;e++)!function(n){r.fn[n]=function(){return r(r.map(this,function(e){return r[n](e)}))}}(n[e])}("gammaln gammafn factorial factorialln".split(" ")),function(n){for(var e=0;n.length>e;e++)!function(n){r.fn[n]=function(){return r(r[n].apply(null,arguments))}}(n[e])}("randn".split(" "))}(n,Math),function(r,n){function e(r){return r/n.abs(r)}function t(e,t,a){var u=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],o=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],i=.5*e;if(i>=8)return 1;var f=2*r.normal.cdf(i,0,1,1,0)-1;f=f3?2:3;for(var l=i,c=(8-i)/s,h=l+c,p=0,m=a-1,E=1;s>=E;E++){for(var N=0,v=.5*(h+l),g=.5*(h-l),I=1;12>=I;I++){var d,b;I>6?(d=12-I+1,b=u[d-1]):(d=I,b=-u[d-1]);var M=g*b,y=v+M,A=y*y;if(A>60)break;var R=2*r.normal.cdf(y,0,1,1,0),T=2*r.normal.cdf(y,e,1,1,0),O=.5*R-.5*T;On.exp(-30/t)?(f=n.pow(f,t),1>f?f:1):0}function a(r,e,t){var a=.5-.5*r,u=n.sqrt(n.log(1/(a*a))),o=u+((((-453642210148e-16*u-.204231210125)*u-.342242088547)*u-1)*u+.322232421088)/((((.0038560700634*u+.10353775285)*u+.531103462366)*u+.588581570495)*u+.099348462606);120>t&&(o+=(o*o*o+o)/t/4);var i=.8832-.2368*o;return 120>t&&(i+=-1.214/t+1.208*o/t),o*(i*n.log(e-1)+1.4142)}!function(n){for(var e=0;n.length>e;e++)!function(n){r[n]=function(r,n,e){return this instanceof arguments.callee?(this._a=r,this._b=n,this._c=e,this):new arguments.callee(r,n,e)},r.fn[n]=function(e,t,a){var u=r[n](e,t,a);return u.data=this,u},r[n].prototype.sample=function(e){var t=this._a,a=this._b,u=this._c;return e?r.alter(e,function(){return r[n].sample(t,a,u)}):r[n].sample(t,a,u)},function(e){for(var t=0;e.length>t;t++)!function(e){r[n].prototype[e]=function(t){var a=this._a,u=this._b,o=this._c;return t||0===t||(t=this.data),"number"!=typeof t?r.fn.map.call(t,function(t){return r[n][e](t,a,u,o)}):r[n][e](t,a,u,o)}}(e[t])}("pdf cdf inv".split(" ")),function(e){for(var t=0;e.length>t;t++)!function(e){r[n].prototype[e]=function(){return r[n][e](this._a,this._b,this._c)}}(e[t])}("mean median mode variance".split(" "))}(n[e])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),r.extend(r.beta,{pdf:function(e,t,a){return e>1||0>e?0:1==t&&1==a?1:512>t&&512>a?n.pow(e,t-1)*n.pow(1-e,a-1)/r.betafn(t,a):n.exp((t-1)*n.log(e)+(a-1)*n.log(1-e)-r.betaln(t,a))},cdf:function(n,e,t){return n>1||0>n?1*(n>1):r.ibeta(n,e,t)},inv:function(n,e,t){return r.ibetainv(n,e,t)},mean:function(r,n){return r/(r+n)},median:function(n,e){return r.ibetainv(.5,n,e)},mode:function(r,n){return(r-1)/(r+n-2)},sample:function(n,e){var t=r.randg(n);return t/(t+r.randg(e))},variance:function(r,e){return r*e/(n.pow(r+e,2)*(r+e+1))}}),r.extend(r.centralF,{pdf:function(e,t,a){var u,o;return 0>e?0:t>2?(u=t*e/(a+e*t),o=a/(a+e*t),t*o/2*r.binomial.pdf((t-2)/2,(t+a-2)/2,u)):0===e&&2>t?Infinity:0===e&&2===t?1:1/r.betafn(t/2,a/2)*n.pow(t/a,t/2)*n.pow(e,t/2-1)*n.pow(1+t/a*e,-(t+a)/2)},cdf:function(n,e,t){return 0>n?0:r.ibeta(e*n/(e*n+t),e/2,t/2)},inv:function(n,e,t){return t/(e*(1/r.ibetainv(n,e/2,t/2)-1))},mean:function(r,n){return n>2?n/(n-2):undefined},mode:function(r,n){return r>2?n*(r-2)/(r*(n+2)):undefined},sample:function(n,e){return 2*r.randg(n/2)/n/(2*r.randg(e/2)/e)},variance:function(r,n){return n>4?2*n*n*(r+n-2)/(r*(n-2)*(n-2)*(n-4)):undefined}}),r.extend(r.cauchy,{pdf:function(r,e,t){return 0>t?0:t/(n.pow(r-e,2)+n.pow(t,2))/n.PI},cdf:function(r,e,t){return n.atan((r-e)/t)/n.PI+.5},inv:function(r,e,t){return e+t*n.tan(n.PI*(r-.5))},median:function(r,n){return r},mode:function(r,n){return r},sample:function(e,t){return r.randn()*n.sqrt(1/(2*r.randg(.5)))*t+e}}),r.extend(r.chisquare,{pdf:function(e,t){return 0>e?0:0===e&&2===t?.5:n.exp((t/2-1)*n.log(e)-e/2-t/2*n.log(2)-r.gammaln(t/2))},cdf:function(n,e){return 0>n?0:r.lowRegGamma(e/2,n/2)},inv:function(n,e){return 2*r.gammapinv(n,.5*e)},mean:function(r){return r},median:function(r){return r*n.pow(1-2/(9*r),3)},mode:function(r){return r-2>0?r-2:0},sample:function(n){return 2*r.randg(n/2)},variance:function(r){return 2*r}}),r.extend(r.exponential,{pdf:function(r,e){return 0>r?0:e*n.exp(-e*r)},cdf:function(r,e){return 0>r?0:1-n.exp(-e*r)},inv:function(r,e){return-n.log(1-r)/e},mean:function(r){return 1/r},median:function(r){return 1/r*n.log(2)},mode:function(r){return 0},sample:function(r){return-1/r*n.log(n.random())},variance:function(r){return n.pow(r,-2)}}),r.extend(r.gamma,{pdf:function(e,t,a){return 0>e?0:0===e&&1===t?1/a:n.exp((t-1)*n.log(e)-e/a-r.gammaln(t)-t*n.log(a))},cdf:function(n,e,t){return 0>n?0:r.lowRegGamma(e,n/t)},inv:function(n,e,t){return r.gammapinv(n,e)*t},mean:function(r,n){return r*n},mode:function(r,n){return r>1?(r-1)*n:undefined},sample:function(n,e){return r.randg(n)*e},variance:function(r,n){return r*n*n}}),r.extend(r.invgamma,{pdf:function(e,t,a){return e>0?n.exp(-(t+1)*n.log(e)-a/e-r.gammaln(t)+t*n.log(a)):0},cdf:function(n,e,t){return n>0?1-r.lowRegGamma(e,t/n):0},inv:function(n,e,t){return t/r.gammapinv(1-n,e)},mean:function(r,n){return r>1?n/(r-1):undefined},mode:function(r,n){return n/(r+1)},sample:function(n,e){return e/r.randg(n)},variance:function(r,n){return r>2?n*n/((r-1)*(r-1)*(r-2)):undefined}}),r.extend(r.kumaraswamy,{pdf:function(r,e,t){return 0===r&&1===e?t:1===r&&1===t?e:n.exp(n.log(e)+n.log(t)+(e-1)*n.log(r)+(t-1)*n.log(1-n.pow(r,e)))},cdf:function(r,e,t){return 0>r?0:r>1?1:1-n.pow(1-n.pow(r,e),t)},inv:function(r,e,t){return n.pow(1-n.pow(1-r,1/t),1/e)},mean:function(n,e){return e*r.gammafn(1+1/n)*r.gammafn(e)/r.gammafn(1+1/n+e)},median:function(r,e){return n.pow(1-n.pow(2,-1/e),1/r)},mode:function(r,e){return 1>r||1>e||1===r||1===e?undefined:n.pow((r-1)/(r*e-1),1/r)},variance:function(r,n){throw Error("variance not yet implemented")}}),r.extend(r.lognormal,{pdf:function(r,e,t){return r>0?n.exp(-n.log(r)-.5*n.log(2*n.PI)-n.log(t)-n.pow(n.log(r)-e,2)/(2*t*t)):0},cdf:function(e,t,a){return 0>e?0:.5+.5*r.erf((n.log(e)-t)/n.sqrt(2*a*a))},inv:function(e,t,a){return n.exp(-1.4142135623730951*a*r.erfcinv(2*e)+t)},mean:function(r,e){return n.exp(r+e*e/2)},median:function(r,e){return n.exp(r)},mode:function(r,e){return n.exp(r-e*e)},sample:function(e,t){return n.exp(r.randn()*t+e)},variance:function(r,e){return(n.exp(e*e)-1)*n.exp(2*r+e*e)}}),r.extend(r.noncentralt,{pdf:function(e,t,a){return 1e-14>n.abs(a)?r.studentt.pdf(e,t):1e-14>n.abs(e)?n.exp(r.gammaln((t+1)/2)-a*a/2-.5*n.log(n.PI*t)-r.gammaln(t/2)):t/e*(r.noncentralt.cdf(e*n.sqrt(1+2/t),t+2,a)-r.noncentralt.cdf(e,t,a))},cdf:function(e,t,a){if(1e-14>n.abs(a))return r.studentt.cdf(e,t);var u=!1;0>e&&(u=!0,a=-a);for(var o=r.normal.cdf(-a,0,1),i=1e-14+1,f=i,s=e*e/(e*e+t),l=0,c=n.exp(-a*a/2),h=n.exp(-a*a/2-.5*n.log(2)-r.gammaln(1.5))*a;200>l||f>1e-14||i>1e-14;)f=i,l>0&&(c*=a*a/(2*l),h*=a*a/(2*(l+.5))),i=c*r.beta.cdf(s,l+.5,t/2)+h*r.beta.cdf(s,l+1,t/2),o+=.5*i,l++;return u?1-o:o}}),r.extend(r.normal,{pdf:function(r,e,t){return n.exp(-.5*n.log(2*n.PI)-n.log(t)-n.pow(r-e,2)/(2*t*t))},cdf:function(e,t,a){return.5*(1+r.erf((e-t)/n.sqrt(2*a*a)))},inv:function(n,e,t){return-1.4142135623730951*t*r.erfcinv(2*n)+e},mean:function(r,n){return r},median:function(r,n){return r},mode:function(r,n){return r},sample:function(n,e){return r.randn()*e+n},variance:function(r,n){return n*n}}),r.extend(r.pareto,{pdf:function(r,e,t){return e>r?0:t*n.pow(e,t)/n.pow(r,t+1)},cdf:function(r,e,t){return e>r?0:1-n.pow(e/r,t)},inv:function(r,e,t){return e/n.pow(1-r,1/t)},mean:function(r,e){return e>1?e*n.pow(r,e)/(e-1):undefined},median:function(r,e){return r*(e*n.SQRT2)},mode:function(r,n){return r},variance:function(r,e){return e>2?r*r*e/(n.pow(e-1,2)*(e-2)):undefined}}),r.extend(r.studentt,{pdf:function(e,t){return t=t>1e100?1e100:t,1/(n.sqrt(t)*r.betafn(.5,t/2))*n.pow(1+e*e/t,-(t+1)/2)},cdf:function(e,t){var a=t/2;return r.ibeta((e+n.sqrt(e*e+t))/(2*n.sqrt(e*e+t)),a,a)},inv:function(e,t){var a=r.ibetainv(2*n.min(e,1-e),.5*t,.5);return a=n.sqrt(t*(1-a)/a),e>.5?a:-a},mean:function(r){return r>1?0:undefined},median:function(r){return 0},mode:function(r){return 0},sample:function(e){return r.randn()*n.sqrt(e/(2*r.randg(e/2)))},variance:function(r){return r>2?r/(r-2):r>1?Infinity:undefined}}),r.extend(r.weibull,{pdf:function(r,e,t){return 0>r||0>e||0>t?0:t/e*n.pow(r/e,t-1)*n.exp(-n.pow(r/e,t))},cdf:function(r,e,t){return 0>r?0:1-n.exp(-n.pow(r/e,t))},inv:function(r,e,t){return e*n.pow(-n.log(1-r),1/t)},mean:function(n,e){return n*r.gammafn(1+1/e)},median:function(r,e){return r*n.pow(n.log(2),1/e)},mode:function(r,e){return e>1?r*n.pow((e-1)/e,1/e):0},sample:function(r,e){return r*n.pow(-n.log(n.random()),1/e)},variance:function(e,t){return e*e*r.gammafn(1+2/t)-n.pow(r.weibull.mean(e,t),2)}}),r.extend(r.uniform,{pdf:function(r,n,e){return n>r||r>e?0:1/(e-n)},cdf:function(r,n,e){return n>r?0:e>r?(r-n)/(e-n):1},inv:function(r,n,e){return n+r*(e-n)},mean:function(r,n){return.5*(r+n)},median:function(n,e){return r.mean(n,e)},mode:function(r,n){throw Error("mode is not yet implemented")},sample:function(r,e){return r/2+e/2+(e/2-r/2)*(2*n.random()-1)},variance:function(r,e){return n.pow(e-r,2)/12}}),r.extend(r.binomial,{pdf:function(e,t,a){return 0===a||1===a?t*a===e?1:0:r.combination(t,e)*n.pow(a,e)*n.pow(1-a,t-e)},cdf:function(n,e,t){var a=[],u=0;if(0>n)return 0;if(e>n){for(;n>=u;u++)a[u]=r.binomial.pdf(u,e,t);return r.sum(a)}return 1}}),r.extend(r.negbin,{pdf:function(e,t,a){return e===e>>>0&&(0>e?0:r.combination(e+t-1,t-1)*n.pow(1-a,e)*n.pow(a,t))},cdf:function(n,e,t){var a=0,u=0;if(0>n)return 0;for(;n>=u;u++)a+=r.negbin.pdf(u,e,t);return a}}),r.extend(r.hypgeom,{pdf:function(e,t,a,u){if(e!==e|0)return!1;if(0>e||a-(t-u)>e)return 0;if(e>u||e>a)return 0;if(2*a>t)return 2*u>t?r.hypgeom.pdf(t-a-u+e,t,t-a,t-u):r.hypgeom.pdf(u-e,t,t-a,u);if(2*u>t)return r.hypgeom.pdf(a-e,t,a,t-u);if(u>a)return r.hypgeom.pdf(e,t,u,a);for(var o=1,i=0,f=0;e>f;f++){for(;o>1&&u>i;)o*=1-a/(t-i),i++;o*=(u-f)*(a-f)/((f+1)*(t-a-u+f+1))}for(;u>i;i++)o*=1-a/(t-i);return n.min(1,n.max(0,o))},cdf:function(e,t,a,u){if(0>e||a-(t-u)>e)return 0;if(u>e&&a>e){if(2*a>t)return 2*u>t?r.hypgeom.cdf(t-a-u+e,t,t-a,t-u):1-r.hypgeom.cdf(u-e-1,t,t-a,u);if(2*u>t)return 1-r.hypgeom.cdf(a-e-1,t,a,t-u);if(u>a)return r.hypgeom.cdf(e,t,u,a);for(var o=1,i=1,f=0,s=0;e>s;s++){for(;o>1&&u>f;){var l=1-a/(t-f);i*=l,o*=l,f++}i*=(u-s)*(a-s)/((s+1)*(t-a-u+s+1)),o+=i}for(;u>f;f++)o*=1-a/(t-f);return n.min(1,n.max(0,o))}return 1}}),r.extend(r.poisson,{pdf:function(e,t){return 0>t||e%1!=0||0>e?0:n.pow(t,e)*n.exp(-t)/r.factorial(e)},cdf:function(n,e){var t=[],a=0;if(0>n)return 0;for(;n>=a;a++)t.push(r.poisson.pdf(a,e));return r.sum(t)},mean:function(r){return r},variance:function(r){return r},sample:function(r){var e=1,t=0,a=n.exp(-r);do{t++,e*=n.random()}while(e>a);return t-1}}),r.extend(r.triangular,{pdf:function(r,n,e,t){return n>=e||n>t||t>e?NaN:n>r||r>e?0:t>r?2*(r-n)/((e-n)*(t-n)):r===t?2/(e-n):2*(e-r)/((e-n)*(e-t))},cdf:function(r,e,t,a){return e>=t||e>a||a>t?NaN:r>e?t>r?r>a?1-n.pow(t-r,2)/((t-e)*(t-a)):n.pow(r-e,2)/((t-e)*(a-e)):1:0},inv:function(r,e,t,a){return e>=t||e>a||a>t?NaN:r>(a-e)/(t-e)?e+(t-e)*(1-n.sqrt((1-r)*(1-(a-e)/(t-e)))):e+(t-e)*n.sqrt(r*((a-e)/(t-e)))},mean:function(r,n,e){return(r+n+e)/3},median:function(r,e,t){return t>(r+e)/2?t>(r+e)/2?r+n.sqrt((e-r)*(t-r))/n.sqrt(2):void 0:e-n.sqrt((e-r)*(e-t))/n.sqrt(2)},mode:function(r,n,e){return e},sample:function(r,e,t){var a=n.random();return(t-r)/(e-r)>a?r+n.sqrt(a*(e-r)*(t-r)):e-n.sqrt((1-a)*(e-r)*(e-t))},variance:function(r,n,e){return(r*r+n*n+e*e-r*n-r*e-n*e)/18}}),r.extend(r.arcsine,{pdf:function(r,e,t){return t>e?r>e&&t>r?2/n.PI*n.pow(n.pow(t-e,2)-n.pow(2*r-e-t,2),-.5):0:NaN},cdf:function(r,e,t){return e>r?0:t>r?2/n.PI*n.asin(n.sqrt((r-e)/(t-e))):1},inv:function(r,e,t){return e+(.5-.5*n.cos(n.PI*r))*(t-e)},mean:function(r,n){return n>r?(r+n)/2:NaN},median:function(r,n){return n>r?(r+n)/2:NaN},mode:function(r,n){throw Error("mode is not yet implemented")},sample:function(e,t){return(e+t)/2+(t-e)/2*n.sin(2*n.PI*r.uniform.sample(0,1))},variance:function(r,e){return e>r?n.pow(e-r,2)/8:NaN}}),r.extend(r.laplace,{pdf:function(r,e,t){return t>0?n.exp(-n.abs(r-e)/t)/(2*t):0},cdf:function(r,e,t){return t>0?e>r?.5*n.exp((r-e)/t):1-.5*n.exp(-(r-e)/t):0},mean:function(r,n){return r},median:function(r,n){return r},mode:function(r,n){return r},variance:function(r,n){return 2*n*n},sample:function(r,t){var a=n.random()-.5;return r-t*e(a)*n.log(1-2*n.abs(a))}}),r.extend(r.tukey,{cdf:function(e,a,u){var o=a,i=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],f=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(0>=e)return 0;if(2>u||2>o)return NaN;if(!Number.isFinite(e))return 1;if(u>25e3)return t(e,1,o);var s,l=.5*u,c=l*n.log(u)-u*n.log(2)-r.gammaln(l),h=l-1,p=.25*u;s=u>100?u>800?u>5e3?.125:.25:.5:1,c+=n.log(s);for(var m=0,E=1;50>=E;E++){for(var N=0,v=(2*E-1)*s,g=1;16>=g;g++){var I,d;g>8?(I=g-8-1,d=c+h*n.log(v+i[I]*s)-(i[I]*s+v)*p):(I=g-1,d=c+h*n.log(v-i[I]*s)+(i[I]*s-v)*p);var b;if(d>=-30){b=g>8?e*n.sqrt(.5*(i[I]*s+v)):e*n.sqrt(.5*(-i[I]*s+v));N+=t(b,1,o)*f[I]*n.exp(d)}}if(E*s>=1&&1e-14>=N)break;m+=N}if(N>1e-14)throw Error("tukey.cdf failed to converge");return m>1&&(m=1),m},inv:function(e,t,u){var o=t;if(2>u||2>o)return NaN;if(0>e||e>1)return NaN;if(0===e)return 0;if(1===e)return Infinity;var i,f=a(e,o,u),s=r.tukey.cdf(f,t,u)-e;i=s>0?n.max(0,f-1):f+1;for(var l,c=r.tukey.cdf(i,t,u)-e,h=1;50>h;h++){l=i-c*(i-f)/(c-s),s=c,f=i,0>l&&(l=0,c=-e),c=r.tukey.cdf(l,t,u)-e,i=l;if(1e-4>n.abs(i-f))return l}throw Error("tukey.inv failed to converge")}})}(n,Math),function(n,e){function t(r){return u(r)||r instanceof n}var a=Array.prototype.push,u=n.utils.isArray;n.extend({add:function(r,e){return t(e)?(t(e[0])||(e=[e]),n.map(r,function(r,n,t){return r+e[n][t]})):n.map(r,function(r){return r+e})},subtract:function(r,e){return t(e)?(t(e[0])||(e=[e]),n.map(r,function(r,n,t){return r-e[n][t]||0})):n.map(r,function(r){return r-e})},divide:function(r,e){return t(e)?(t(e[0])||(e=[e]),n.multiply(r,n.inv(e))):n.map(r,function(r){return r/e})},multiply:function(r,e){var a,u,o,i,f,s,l,c;if(r.length===undefined&&e.length===undefined)return r*e;if(f=r.length,s=r[0].length,l=n.zeros(f,o=t(e)?e[0].length:s),c=0,t(e)){for(;o>c;c++)for(a=0;f>a;a++){for(i=0,u=0;s>u;u++)i+=r[a][u]*e[u][c];l[a][c]=i}return 1===f&&1===c?l[0][0]:l}return n.map(r,function(r){return r*e})},outer:function(r,e){return n.multiply(r.map(function(r){return[r]}),[e])},dot:function(r,e){t(r[0])||(r=[r]),t(e[0])||(e=[e]);for(var a,u,o=1===r[0].length&&1!==r.length?n.transpose(r):r,i=1===e[0].length&&1!==e.length?n.transpose(e):e,f=[],s=0,l=o.length,c=o[0].length;l>s;s++){for(f[s]=[],a=0,u=0;c>u;u++)a+=o[s][u]*i[s][u];f[s]=a}return 1===f.length?f[0]:f},pow:function(r,t){return n.map(r,function(r){return e.pow(r,t)})},exp:function(r){return n.map(r,function(r){return e.exp(r)})},log:function(r){return n.map(r,function(r){return e.log(r)})},abs:function(r){return n.map(r,function(r){return e.abs(r)})},norm:function(r,n){var a=0,u=0;for(isNaN(n)&&(n=2),t(r[0])&&(r=r[0]);r.length>u;u++)a+=e.pow(e.abs(r[u]),n);return e.pow(a,1/n)},angle:function(r,t){return e.acos(n.dot(r,t)/(n.norm(r)*n.norm(t)))},aug:function(r,n){for(var e=[],t=0;r.length>t;t++)e.push(r[t].slice());for(var t=0;e.length>t;t++)a.apply(e[t],n[t]);return e},inv:function(r){for(var e,t=r.length,a=r[0].length,u=n.identity(t,a),o=n.gauss_jordan(r,u),i=[],f=0;t>f;f++)for(i[f]=[],e=a;o[0].length>e;e++)i[f][e-a]=o[f][e];return i},det:function(r){var n,e=r.length,t=2*e,a=Array(t),u=e-1,o=t-1,i=u-e+1,f=o,s=0,l=0;if(2===e)return r[0][0]*r[1][1]-r[0][1]*r[1][0];for(;t>s;s++)a[s]=1;for(var s=0;e>s;s++){for(n=0;e>n;n++)a[0>i?i+e:i]*=r[s][n],a[e>f?f+e:f]*=r[s][n],i++,f--;i=--u-e+1,f=--o}for(var s=0;e>s;s++)l+=a[s];for(;t>s;s++)l-=a[s];return l},gauss_elimination:function(r,t){var a,u,o,i,f=0,s=0,l=r.length,c=r[0].length,h=1,p=0,m=[];r=n.aug(r,t),a=r[0].length;for(var f=0;l>f;f++){for(u=r[f][f],s=f,i=f+1;c>i;i++)ui;i++)o=r[f][i],r[f][i]=r[s][i],r[s][i]=o;for(s=f+1;l>s;s++)for(h=r[s][f]/r[f][f],i=f;a>i;i++)r[s][i]=r[s][i]-h*r[f][i]}for(var f=l-1;f>=0;f--){for(p=0,s=f+1;l-1>=s;s++)p+=m[s]*r[f][s];m[f]=(r[f][a-1]-p)/r[f][f]}return m},gauss_jordan:function(r,t){for(var a=n.aug(r,t),u=a.length,o=a[0].length,i=0,f=0;u>f;f++){for(var s=f,l=f+1;u>l;l++)e.abs(a[l][f])>e.abs(a[s][f])&&(s=l);var c=a[f];a[f]=a[s],a[s]=c;for(var l=f+1;u>l;l++){i=a[l][f]/a[f][f];for(var h=f;o>h;h++)a[l][h]-=a[f][h]*i}}for(var f=u-1;f>=0;f--){i=a[f][f];for(var l=0;f>l;l++)for(var h=o-1;h>f-1;h--)a[l][h]-=a[f][h]*a[l][f]/i;a[f][f]/=i;for(var h=u;o>h;h++)a[f][h]/=i}return a},triaUpSolve:function(r,e){var t,a=r[0].length,u=n.zeros(1,a)[0],o=!1;return e[0].length!=undefined&&(e=e.map(function(r){return r[0]}),o=!0),n.arange(a-1,-1,-1).forEach(function(o){t=n.arange(o+1,a).map(function(n){return u[n]*r[o][n]}),u[o]=(e[o]-n.sum(t))/r[o][o]}),o?u.map(function(r){return[r]}):u},triaLowSolve:function(r,e){var t,a=r[0].length,u=n.zeros(1,a)[0],o=!1;return e[0].length!=undefined&&(e=e.map(function(r){return r[0]}),o=!0),n.arange(a).forEach(function(a){t=n.arange(a).map(function(n){return r[a][n]*u[n]}),u[a]=(e[a]-n.sum(t))/r[a][a]}),o?u.map(function(r){return[r]}):u},lu:function(r){var e,t=r.length,a=n.identity(t),u=n.zeros(r.length,r[0].length);return n.arange(t).forEach(function(n){u[0][n]=r[0][n]}),n.arange(1,t).forEach(function(o){n.arange(o).forEach(function(t){e=n.arange(t).map(function(r){return a[o][r]*u[r][t]}),a[o][t]=(r[o][t]-n.sum(e))/u[t][t]}),n.arange(o,t).forEach(function(t){e=n.arange(o).map(function(r){return a[o][r]*u[r][t]}),u[o][t]=r[i][t]-n.sum(e)})}),[a,u]},cholesky:function(r){var t,a=r.length,u=n.zeros(r.length,r[0].length);return n.arange(a).forEach(function(o){t=n.arange(o).map(function(r){return e.pow(u[o][r],2)}),u[o][o]=e.sqrt(r[o][o]-n.sum(t)),n.arange(o+1,a).forEach(function(e){t=n.arange(o).map(function(r){return u[o][r]*u[e][r]}),u[e][o]=(r[o][e]-n.sum(t))/u[o][o]})}),u},gauss_jacobi:function(r,t,a,u){for(var o,i,f,s,l=0,c=0,h=r.length,p=[],m=[],E=[];h>l;l++)for(p[l]=[],m[l]=[],E[l]=[],c=0;h>c;c++)l>c?(p[l][c]=r[l][c],m[l][c]=E[l][c]=0):c>l?(m[l][c]=r[l][c],p[l][c]=E[l][c]=0):(E[l][c]=r[l][c],p[l][c]=m[l][c]=0);for(f=n.multiply(n.multiply(n.inv(E),n.add(p,m)),-1),i=n.multiply(n.inv(E),t),o=a,s=n.add(n.multiply(f,a),i),l=2;e.abs(n.norm(n.subtract(s,o)))>u;)o=s,s=n.add(n.multiply(f,o),i),l++;return s},gauss_seidel:function(r,t,a,u){for(var o,i,f,s,l,c=0,h=r.length,p=[],m=[],E=[];h>c;c++)for(p[c]=[],m[c]=[],E[c]=[],o=0;h>o;o++)c>o?(p[c][o]=r[c][o],m[c][o]=E[c][o]=0):o>c?(m[c][o]=r[c][o],p[c][o]=E[c][o]=0):(E[c][o]=r[c][o],p[c][o]=m[c][o]=0);for(s=n.multiply(n.multiply(n.inv(n.add(E,p)),m),-1),f=n.multiply(n.inv(n.add(E,p)),t),i=a,l=n.add(n.multiply(s,a),f),c=2;e.abs(n.norm(n.subtract(l,i)))>u;)i=l,l=n.add(n.multiply(s,i),f),c+=1;return l},SOR:function(r,t,a,u,o){for(var i,f,s,l,c,h=0,p=r.length,m=[],E=[],N=[];p>h;h++)for(m[h]=[],E[h]=[],N[h]=[],i=0;p>i;i++)h>i?(m[h][i]=r[h][i],E[h][i]=N[h][i]=0):i>h?(E[h][i]=r[h][i],m[h][i]=N[h][i]=0):(N[h][i]=r[h][i],m[h][i]=E[h][i]=0);for(l=n.multiply(n.inv(n.add(N,n.multiply(m,o))),n.subtract(n.multiply(N,1-o),n.multiply(E,o))),s=n.multiply(n.multiply(n.inv(n.add(N,n.multiply(m,o))),t),o),f=a,c=n.add(n.multiply(l,a),s),h=2;e.abs(n.norm(n.subtract(c,f)))>u;)f=c,c=n.add(n.multiply(l,f),s),h++;return c},householder:function(r){for(var t,a,u,o,i,f=r.length,s=r[0].length,l=0,c=[],h=[];f-1>l;l++){for(t=0,o=l+1;s>o;o++)t+=r[o][l]*r[o][l];for(i=r[l+1][l]>0?-1:1,t=i*e.sqrt(t),a=e.sqrt((t*t-r[l+1][l]*t)/2),c=n.zeros(f,1),c[l+1][0]=(r[l+1][l]-t)/(2*a),u=l+2;f>u;u++)c[u][0]=r[u][l]/(2*a);h=n.subtract(n.identity(f,s),n.multiply(n.multiply(c,n.transpose(c)),2)),r=n.multiply(h,n.multiply(r,h))}return r},QR:function(){function t(t){var o=t.length,i=t[0].length;t=n.copy(t),r=n.zeros(i,i);var f,s,l;for(s=0;i>s;s++){for(r[s][s]=e.sqrt(a(u(o).map(function(r){return t[r][s]*t[r][s]}))),f=0;o>f;f++)t[f][s]=t[f][s]/r[s][s];for(l=s+1;i>l;l++)for(r[s][l]=a(u(o).map(function(r){return t[r][s]*t[r][l]})),f=0;o>f;f++)t[f][l]=t[f][l]-t[f][s]*r[s][l]}return[t,r]}var a=n.sum,u=n.arange;return t}(),lstsq:function(r,e){function t(r){r=n.copy(r);var e=r.length,t=n.identity(e);return n.arange(e-1,-1,-1).forEach(function(e){n.sliceAssign(t,{row:e},n.divide(n.slice(t,{row:e}),r[e][e])),n.sliceAssign(r,{row:e},n.divide(n.slice(r,{row:e}),r[e][e])),n.arange(e).forEach(function(a){var u=n.multiply(r[a][e],-1),o=n.slice(r,{row:a}),i=n.multiply(n.slice(r,{row:e}),u);n.sliceAssign(r,{row:a},n.add(o,i));var f=n.slice(t,{row:a}),s=n.multiply(n.slice(t,{row:e}),u);n.sliceAssign(t,{row:a},n.add(f,s))})}),t}function a(r,e){var a=!1;e[0].length===undefined&&(e=e.map(function(r){return[r]}),a=!0);var u=n.QR(r),o=u[0],i=u[1],f=r[0].length,s=n.slice(o,{col:{end:f}}),l=n.slice(i,{row:{end:f}}),c=t(l),h=n.transpose(s);h[0].length===undefined&&(h=[h]);var p=n.multiply(n.multiply(c,h),e);return p.length===undefined&&(p=[[p]]),a?p.map(function(r){return r[0]}):p}return a}(),jacobi:function(r){for(var t,a,u,o,i,f,s,l,c=1,h=0,p=r.length,m=n.identity(p,p),E=[];1===c;){h++,f=r[0][1],o=0,i=1;for(var a=0;p>a;a++)for(u=0;p>u;u++)a!=u&&f0?e.PI/4:-e.PI/4:e.atan(2*r[o][i]/(r[o][o]-r[i][i]))/2,l=n.identity(p,p),l[o][o]=e.cos(s),l[o][i]=-e.sin(s),l[i][o]=e.sin(s),l[i][i]=e.cos(s),m=n.multiply(m,l),t=n.multiply(n.multiply(n.inv(l),r),l),r=t,c=0;for(var a=1;p>a;a++)for(u=1;p>u;u++)a!=u&&e.abs(r[a][u])>.001&&(c=1)}for(var a=0;p>a;a++)E.push(r[a][a]);return[m,E]},rungekutta:function(r,n,e,t,a,u){var o,i,f,s,l;if(2===u)for(;e>=t;)o=n*r(t,a),i=n*r(t+n,a+o),f=a+(o+i)/2,a=f,t+=n;if(4===u)for(;e>=t;)o=n*r(t,a),i=n*r(t+n/2,a+o/2),s=n*r(t+n/2,a+i/2),l=n*r(t+n,a+s),f=a+(o+2*i+2*s+l)/6,a=f,t+=n;return a},romberg:function(r,n,t,a){for(var u,o,i,f,s,l=0,c=(t-n)/2,h=[],p=[],m=[];a/2>l;){for(s=r(n),i=n,f=0;t>=i;i+=c,f++)h[f]=i;for(u=h.length,i=1;u-1>i;i++)s+=(i%2!=0?4:2)*r(h[i]);s=c/3*(s+r(t)),m[l]=s,c/=2,l++}for(o=m.length,u=1;1!==o;){for(i=0;o-1>i;i++)p[i]=(e.pow(4,u)*m[i+1]-m[i])/(e.pow(4,u)-1);o=p.length,m=p,p=[],u++}return m},richardson:function(r,n,t,a){function u(r,n){for(var e,t=0,a=r.length;a>t;t++)r[t]===n&&(e=t);return e}for(var o,i,f,s,l,c=e.abs(t-r[u(r,t)+1]),h=0,p=[],m=[];a>=c;)o=u(r,t+a),i=u(r,t),p[h]=(n[o]-2*n[i]+n[2*i-o])/(a*a),a/=2,h++;for(s=p.length,f=1;1!=s;){for(l=0;s-1>l;l++)m[l]=(e.pow(4,f)*p[l+1]-p[l])/(e.pow(4,f)-1);s=m.length,p=m,m=[],f++}return p},simpson:function(r,n,e,t){for(var a,u=(e-n)/t,o=r(n),i=[],f=n,s=0,l=1;e>=f;f+=u,s++)i[s]=f;for(a=i.length;a-1>l;l++)o+=(l%2!=0?4:2)*r(i[l]);return u/3*(o+r(e))},hermite:function(r,n,e,t){for(var a,u=r.length,o=0,i=0,f=[],s=[],l=[],c=[];u>i;i++){for(f[i]=1,a=0;u>a;a++)i!=a&&(f[i]*=(t-r[a])/(r[i]-r[a]));for(s[i]=0,a=0;u>a;a++)i!=a&&(s[i]+=1/(r[i]-r[a]));l[i]=f[i]*f[i]*(1-2*(t-r[i])*s[i]),c[i]=f[i]*f[i]*(t-r[i]),o+=l[i]*n[i]+c[i]*e[i]}return o},lagrange:function(r,n,e){for(var t,a,u=0,o=0,i=r.length;i>o;o++){for(a=n[o],t=0;i>t;t++)o!=t&&(a*=(e-r[t])/(r[o]-r[t]));u+=a}return u},cubic_spline:function(r,e,t){for(var a,u=r.length,o=0,i=[],f=[],s=[],l=[],c=[],h=[],p=[];u-1>o;o++)c[o]=r[o+1]-r[o];s[0]=0;for(var o=1;u-1>o;o++)s[o]=3/c[o]*(e[o+1]-e[o])-3/c[o-1]*(e[o]-e[o-1]);for(var o=1;u-1>o;o++)i[o]=[],f[o]=[],i[o][o-1]=c[o-1],i[o][o]=2*(c[o-1]+c[o]),i[o][o+1]=c[o],f[o][0]=s[o];for(l=n.multiply(n.inv(i),f),a=0;u-1>a;a++)h[a]=(e[a+1]-e[a])/c[a]-c[a]*(l[a+1][0]+2*l[a][0])/3,p[a]=(l[a+1][0]-l[a][0])/(3*c[a]);for(a=0;u>a&&r[a]<=t;a++);return a-=1,e[a]+(t-r[a])*h[a]+n.sq(t-r[a])*l[a]+(t-r[a])*n.sq(t-r[a])*p[a]},gauss_quadrature:function(){throw Error("gauss_quadrature not yet implemented")},PCA:function(r){for(var e,t,a=r.length,u=r[0].length,o=0,i=[],f=[],s=[],l=[],c=[],h=[],p=[],m=[],E=[],N=[],o=0;a>o;o++)i[o]=n.sum(r[o])/u;for(var o=0;u>o;o++)for(p[o]=[],e=0;a>e;e++)p[o][e]=r[e][o]-i[e];p=n.transpose(p);for(var o=0;a>o;o++)for(m[o]=[],e=0;a>e;e++)m[o][e]=n.dot([p[o]],[p[e]])/(u-1);s=n.jacobi(m),E=s[0],f=s[1],N=n.transpose(E);for(var o=0;f.length>o;o++)for(e=o;f.length>e;e++)f[e]>f[o]&&(t=f[o],f[o]=f[e],f[e]=t,l=N[o],N[o]=N[e],N[e]=l);h=n.transpose(p);for(var o=0;a>o;o++)for(c[o]=[],e=0;h.length>e;e++)c[o][e]=n.dot([N[o]],[h[e]]);return[r,f,N,c]}}),function(r){for(var e=0;r.length>e;e++)!function(r){n.fn[r]=function(e,t){var a=this;return t?(setTimeout(function(){t.call(a,n.fn[r].call(a,e))},15),this):"number"==typeof n[r](this,e)?n[r](this,e):n(n[r](this,e))}}(r[e])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(n,Math),function(r,n){function e(r,e,t,a){if(r>1||t>1||0>=r||0>=t)throw Error("Proportions should be greater than 0 and less than 1");var u=(r*e+t*a)/(e+a);return(r-t)/n.sqrt(u*(1-u)*(1/e+1/a))}var t=[].slice,a=r.utils.isNumber,u=r.utils.isArray;r.extend({zscore:function(){var n=t.call(arguments);return a(n[1])?(n[0]-n[1])/n[2]:(n[0]-r.mean(n[1]))/r.stdev(n[1],n[2])},ztest:function(){var e,a=t.call(arguments);return u(a[1])?(e=r.zscore(a[0],a[1],a[3]),1===a[2]?r.normal.cdf(-n.abs(e),0,1):2*r.normal.cdf(-n.abs(e),0,1)):a.length>2?(e=r.zscore(a[0],a[1],a[2]),1===a[3]?r.normal.cdf(-n.abs(e),0,1):2*r.normal.cdf(-n.abs(e),0,1)):(e=a[0],1===a[1]?r.normal.cdf(-n.abs(e),0,1):2*r.normal.cdf(-n.abs(e),0,1))}}),r.extend(r.fn,{zscore:function(r,n){return(r-this.mean())/this.stdev(n)},ztest:function(e,t,a){var u=n.abs(this.zscore(e,a));return 1===t?r.normal.cdf(-u,0,1):2*r.normal.cdf(-u,0,1)}}),r.extend({tscore:function(){var e=t.call(arguments);return 4===e.length?(e[0]-e[1])/(e[2]/n.sqrt(e[3])):(e[0]-r.mean(e[1]))/(r.stdev(e[1],!0)/n.sqrt(e[1].length))},ttest:function(){var e,u=t.call(arguments);return 5===u.length?(e=n.abs(r.tscore(u[0],u[1],u[2],u[3])),1===u[4]?r.studentt.cdf(-e,u[3]-1):2*r.studentt.cdf(-e,u[3]-1)):a(u[1])?(e=n.abs(u[0]),1==u[2]?r.studentt.cdf(-e,u[1]-1):2*r.studentt.cdf(-e,u[1]-1)):(e=n.abs(r.tscore(u[0],u[1])),1==u[2]?r.studentt.cdf(-e,u[1].length-1):2*r.studentt.cdf(-e,u[1].length-1))}}),r.extend(r.fn,{tscore:function(r){return(r-this.mean())/(this.stdev(!0)/n.sqrt(this.cols()))},ttest:function(e,t){return 1===t?1-r.studentt.cdf(n.abs(this.tscore(e)),this.cols()-1):2*r.studentt.cdf(-n.abs(this.tscore(e)),this.cols()-1)}}),r.extend({anovafscore:function(){var e,a,u,o,i,f,s,l,c=t.call(arguments);if(1===c.length){i=Array(c[0].length);for(var s=0;c[0].length>s;s++)i[s]=c[0][s];c=i}if(2===c.length)return r.variance(c[0])/r.variance(c[1]);a=[];for(var s=0;c.length>s;s++)a=a.concat(c[s]);u=r.mean(a),e=0;for(var s=0;c.length>s;s++)e+=c[s].length*n.pow(r.mean(c[s])-u,2);e/=c.length-1,f=0;for(var s=0;c.length>s;s++)for(o=r.mean(c[s]),l=0;c[s].length>l;l++)f+=n.pow(c[s][l]-o,2);return f/=a.length-c.length,e/f},anovaftest:function(){var n,e,u,o,i=t.call(arguments);if(a(i[0]))return 1-r.centralF.cdf(i[0],i[1],i[2]);anovafscore=r.anovafscore(i),n=i.length-1,u=0;for(var o=0;i.length>o;o++)u+=i[o].length;return e=u-n-1,1-r.centralF.cdf(anovafscore,n,e)},ftest:function(n,e,t){return 1-r.centralF.cdf(n,e,t)}}),r.extend(r.fn,{anovafscore:function(){return r.anovafscore(this.toArray())},anovaftes:function(){for(var n,e=0,n=0;this.length>n;n++)e+=this[n].length;return r.ftest(this.anovafscore(),this.length-1,e-this.length)}}),r.extend({qscore:function(){var e,u,o,i,f,s=t.call(arguments);return a(s[0])?(e=s[0],u=s[1],o=s[2],i=s[3],f=s[4]):(e=r.mean(s[0]),u=r.mean(s[1]),o=s[0].length,i=s[1].length,f=s[2]),n.abs(e-u)/(f*n.sqrt((1/o+1/i)/2))},qtest:function(){var n,e=t.call(arguments);3===e.length?(n=e[0],e=e.slice(1)):7===e.length?(n=r.qscore(e[0],e[1],e[2],e[3],e[4]),e=e.slice(5)):(n=r.qscore(e[0],e[1],e[2]),e=e.slice(3));var a=e[0],u=e[1];return 1-r.tukey.cdf(n,u,a-u)},tukeyhsd:function(n){for(var e=r.pooledstdev(n),t=n.map(function(n){return r.mean(n)}),a=n.reduce(function(r,n){return r+n.length},0),u=[],o=0;n.length>o;++o)for(var i=o+1;n.length>i;++i){var f=r.qtest(t[o],t[i],n[o].length,n[i].length,e,a,n.length);u.push([[o,i],f])}return u}}),r.extend({normalci:function(){var e,a=t.call(arguments),u=Array(2);return e=n.abs(4===a.length?r.normal.inv(a[1]/2,0,1)*a[2]/n.sqrt(a[3]):r.normal.inv(a[1]/2,0,1)*r.stdev(a[2])/n.sqrt(a[2].length)),u[0]=a[0]-e,u[1]=a[0]+e,u},tci:function(){var e,a=t.call(arguments),u=Array(2);return e=n.abs(4===a.length?r.studentt.inv(a[1]/2,a[3]-1)*a[2]/n.sqrt(a[3]):r.studentt.inv(a[1]/2,a[2].length-1)*r.stdev(a[2],!0)/n.sqrt(a[2].length)),u[0]=a[0]-e,u[1]=a[0]+e,u},significant:function(r,n){return n>r}}),r.extend(r.fn,{normalci:function(n,e){return r.normalci(n,e,this.toArray())},tci:function(n,e){return r.tci(n,e,this.toArray())}}),r.extend(r.fn,{oneSidedDifferenceOfProportions:function(n,t,a,u){var o=e(n,t,a,u);return r.ztest(o,1)},twoSidedDifferenceOfProportions:function(n,t,a,u){var o=e(n,t,a,u);return r.ztest(o,2)}})}(n,Math),n.models=function(){function r(r,n){return e(r,n)}function r(r){var t=r[0].length;return n.arange(t).map(function(a){var u=n.arange(t).filter(function(r){return r!==a});return e(n.col(r,a).map(function(r){return r[0]}),n.col(r,u))})}function e(r,e){var t=r.length,a=e[0].length-1,u=t-a-1,o=n.lstsq(e,r),i=n.multiply(e,o.map(function(r){return[r]})).map(function(r){return r[0]}),f=n.subtract(r,i),s=n.mean(r),l=n.sum(i.map(function(r){return Math.pow(r-s,2)})),c=n.sum(r.map(function(r,n){return Math.pow(r-i[n],2)})),h=l+c;return{exog:e,endog:r,nobs:t,df_model:a,df_resid:u,coef:o,predict:i,resid:f,ybar:s,SST:h,SSE:l,SSR:c,R2:l/h}}function t(e){var t=r(e.exog),a=Math.sqrt(e.SSR/e.df_resid),u=t.map(function(r){var n=r.SST,e=r.R2;return a/Math.sqrt(n*(1-e))}),o=e.coef.map(function(r,n){return(r-0)/u[n]}),i=o.map(function(r){var t=n.studentt.cdf(r,e.df_resid);return 2*(t>.5?1-t:t)}),f=n.studentt.inv(.975,e.df_resid),s=e.coef.map(function(r,n){var e=f*u[n];return[r-e,r+e]});return{se:u,t:o,p:i,sigmaHat:a,interval95:s}}function a(r){var e=r.R2/r.df_model/((1-r.R2)/r.df_resid);return{F_statistic:e,pvalue:1-function(r,e,t){return n.beta.cdf(r/(t/e+r),e/2,t/2)}(e,r.df_model,r.df_resid)}}function u(r,n){var u=e(r,n),o=t(u),i=a(u),f=1-(u.nobs-1)/u.df_resid*(1-u.R2);return u.t=o,u.f=i,u.adjust_R2=f,u}return{ols:u}}(),n})},function(r,n,e){var t=e(1),a=e(0);n.UNIQUE=function(){for(var r=[],n=0;arguments.length>n;++n){for(var e=!1,t=arguments[n],a=0;r.length>a&&!(e=r[a]===t);++a);e||r.push(t)}return r},n.FLATTEN=t.flatten,n.ARGS2ARRAY=function(){return Array.prototype.slice.call(arguments,0)},n.REFERENCE=function(r,n){if(!arguments.length)return a.error;try{for(var e=n.split("."),t=r,u=0;e.length>u;++u){var o=e[u];if("]"===o[o.length-1]){var i=o.indexOf("["),f=o.substring(i+1,o.length-1);t=t[o.substring(0,i)][f]}else t=t[o]}return t}catch(a){}},n.JOIN=function(r,n){return r.join(n)},n.NUMBERS=function(){return t.flatten(arguments).filter(function(r){return"number"==typeof r})}},function(r,n,e){function t(r){return/^[01]{1,10}$/.test(r)}var a=e(0),u=e(10),o=e(6),i=e(1),f=e(26);n.BESSELI=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:f.besseli(r,n)},n.BESSELJ=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:f.besselj(r,n)},n.BESSELK=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:f.besselk(r,n)},n.BESSELY=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:f.bessely(r,n)},n.BIN2DEC=function(r){if(!t(r))return a.num;var n=parseInt(r,2),e=""+r;return 10===e.length&&"1"===e.substring(0,1)?parseInt(e.substring(1),2)-512:n},n.BIN2HEX=function(r,n){if(!t(r))return a.num;var e=""+r;if(10===e.length&&"1"===e.substring(0,1))return(0xfffffffe00+parseInt(e.substring(1),2)).toString(16);var u=parseInt(r,2).toString(16);return n===undefined?u:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),u.length>n?a.num:o.REPT("0",n-u.length)+u)},n.BIN2OCT=function(r,n){if(!t(r))return a.num;var e=""+r;if(10===e.length&&"1"===e.substring(0,1))return(1073741312+parseInt(e.substring(1),2)).toString(8);var u=parseInt(r,2).toString(8);return n===undefined?u:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),u.length>n?a.num:o.REPT("0",n-u.length)+u)},n.BITAND=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:0>r||0>n?a.num:Math.floor(r)!==r||Math.floor(n)!==n?a.num:r>0xffffffffffff||n>0xffffffffffff?a.num:r&n},n.BITLSHIFT=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:0>r?a.num:Math.floor(r)!==r?a.num:r>0xffffffffffff?a.num:Math.abs(n)>53?a.num:0>n?r>>-n:r<r||0>n?a.num:Math.floor(r)!==r||Math.floor(n)!==n?a.num:r>0xffffffffffff||n>0xffffffffffff?a.num:r|n},n.BITRSHIFT=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:0>r?a.num:Math.floor(r)!==r?a.num:r>0xffffffffffff?a.num:Math.abs(n)>53?a.num:0>n?r<<-n:r>>n},n.BITXOR=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:0>r||0>n?a.num:Math.floor(r)!==r||Math.floor(n)!==n?a.num:r>0xffffffffffff||n>0xffffffffffff?a.num:r^n},n.COMPLEX=function(r,n,e){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?r:"i"!==(e=e===undefined?"i":e)&&"j"!==e?a.value:0===r&&0===n?0:0===r?1===n?e:""+n+e:0===n?""+r:r+(n>0?"+":"")+(1===n?e:""+n+e)},n.CONVERT=function(r,n,e){if((r=i.parseNumber(r))instanceof Error)return r;for(var t,u=[["a.u. of action","?",null,"action",!1,!1,1.05457168181818e-34],["a.u. of charge","e",null,"electric_charge",!1,!1,1.60217653141414e-19],["a.u. of energy","Eh",null,"energy",!1,!1,4.35974417757576e-18],["a.u. of length","a?",null,"length",!1,!1,5.29177210818182e-11],["a.u. of mass","m?",null,"mass",!1,!1,9.10938261616162e-31],["a.u. of time","?/Eh",null,"time",!1,!1,2.41888432650516e-17],["admiralty knot","admkn",null,"speed",!1,!0,.514773333],["ampere","A",null,"electric_current",!0,!1,1],["ampere per meter","A/m",null,"magnetic_field_intensity",!0,!1,1],["ångström","Å",["ang"],"length",!1,!0,1e-10],["are","ar",null,"area",!1,!0,100],["astronomical unit","ua",null,"length",!1,!1,1.49597870691667e-11],["bar","bar",null,"pressure",!1,!1,1e5],["barn","b",null,"area",!1,!1,1e-28],["becquerel","Bq",null,"radioactivity",!0,!1,1],["bit","bit",["b"],"information",!1,!0,1],["btu","BTU",["btu"],"energy",!1,!0,1055.05585262],["byte","byte",null,"information",!1,!0,8],["candela","cd",null,"luminous_intensity",!0,!1,1],["candela per square metre","cd/m?",null,"luminance",!0,!1,1],["coulomb","C",null,"electric_charge",!0,!1,1],["cubic ångström","ang3",["ang^3"],"volume",!1,!0,1e-30],["cubic foot","ft3",["ft^3"],"volume",!1,!0,.028316846592],["cubic inch","in3",["in^3"],"volume",!1,!0,16387064e-12],["cubic light-year","ly3",["ly^3"],"volume",!1,!0,8.46786664623715e-47],["cubic metre","m?",null,"volume",!0,!0,1],["cubic mile","mi3",["mi^3"],"volume",!1,!0,4168181825.44058],["cubic nautical mile","Nmi3",["Nmi^3"],"volume",!1,!0,6352182208],["cubic Pica","Pica3",["Picapt3","Pica^3","Picapt^3"],"volume",!1,!0,7.58660370370369e-8],["cubic yard","yd3",["yd^3"],"volume",!1,!0,.764554857984],["cup","cup",null,"volume",!1,!0,.0002365882365],["dalton","Da",["u"],"mass",!1,!1,1.66053886282828e-27],["day","d",["day"],"time",!1,!0,86400],["degree","°",null,"angle",!1,!1,.0174532925199433],["degrees Rankine","Rank",null,"temperature",!1,!0,.555555555555556],["dyne","dyn",["dy"],"force",!1,!0,1e-5],["electronvolt","eV",["ev"],"energy",!1,!0,1.60217656514141],["ell","ell",null,"length",!1,!0,1.143],["erg","erg",["e"],"energy",!1,!0,1e-7],["farad","F",null,"electric_capacitance",!0,!1,1],["fluid ounce","oz",null,"volume",!1,!0,295735295625e-16],["foot","ft",null,"length",!1,!0,.3048],["foot-pound","flb",null,"energy",!1,!0,1.3558179483314],["gal","Gal",null,"acceleration",!1,!1,.01],["gallon","gal",null,"volume",!1,!0,.003785411784],["gauss","G",["ga"],"magnetic_flux_density",!1,!0,1],["grain","grain",null,"mass",!1,!0,647989e-10],["gram","g",null,"mass",!1,!0,.001],["gray","Gy",null,"absorbed_dose",!0,!1,1],["gross registered ton","GRT",["regton"],"volume",!1,!0,2.8316846592],["hectare","ha",null,"area",!1,!0,1e4],["henry","H",null,"inductance",!0,!1,1],["hertz","Hz",null,"frequency",!0,!1,1],["horsepower","HP",["h"],"power",!1,!0,745.69987158227],["horsepower-hour","HPh",["hh","hph"],"energy",!1,!0,2684519.538],["hour","h",["hr"],"time",!1,!0,3600],["imperial gallon (U.K.)","uk_gal",null,"volume",!1,!0,.00454609],["imperial hundredweight","lcwt",["uk_cwt","hweight"],"mass",!1,!0,50.802345],["imperial quart (U.K)","uk_qt",null,"volume",!1,!0,.0011365225],["imperial ton","brton",["uk_ton","LTON"],"mass",!1,!0,1016.046909],["inch","in",null,"length",!1,!0,.0254],["international acre","uk_acre",null,"area",!1,!0,4046.8564224],["IT calorie","cal",null,"energy",!1,!0,4.1868],["joule","J",null,"energy",!0,!0,1],["katal","kat",null,"catalytic_activity",!0,!1,1],["kelvin","K",["kel"],"temperature",!0,!0,1],["kilogram","kg",null,"mass",!0,!0,1],["knot","kn",null,"speed",!1,!0,.514444444444444],["light-year","ly",null,"length",!1,!0,9460730472580800],["litre","L",["l","lt"],"volume",!1,!0,.001],["lumen","lm",null,"luminous_flux",!0,!1,1],["lux","lx",null,"illuminance",!0,!1,1],["maxwell","Mx",null,"magnetic_flux",!1,!1,1e-18],["measurement ton","MTON",null,"volume",!1,!0,1.13267386368],["meter per hour","m/h",["m/hr"],"speed",!1,!0,.00027777777777778],["meter per second","m/s",["m/sec"],"speed",!0,!0,1],["meter per second squared","m?s??",null,"acceleration",!0,!1,1],["parsec","pc",["parsec"],"length",!1,!0,0x6da012f958ee1c],["meter squared per second","m?/s",null,"kinematic_viscosity",!0,!1,1],["metre","m",null,"length",!0,!0,1],["miles per hour","mph",null,"speed",!1,!0,.44704],["millimetre of mercury","mmHg",null,"pressure",!1,!1,133.322],["minute","?",null,"angle",!1,!1,.000290888208665722],["minute","min",["mn"],"time",!1,!0,60],["modern teaspoon","tspm",null,"volume",!1,!0,5e-6],["mole","mol",null,"amount_of_substance",!0,!1,1],["morgen","Morgen",null,"area",!1,!0,2500],["n.u. of action","?",null,"action",!1,!1,1.05457168181818e-34],["n.u. of mass","m?",null,"mass",!1,!1,9.10938261616162e-31],["n.u. of speed","c?",null,"speed",!1,!1,299792458],["n.u. of time","?/(me?c??)",null,"time",!1,!1,1.28808866778687e-21],["nautical mile","M",["Nmi"],"length",!1,!0,1852],["newton","N",null,"force",!0,!0,1],["œrsted","Oe ",null,"magnetic_field_intensity",!1,!1,79.5774715459477],["ohm","Ω",null,"electric_resistance",!0,!1,1],["ounce mass","ozm",null,"mass",!1,!0,.028349523125],["pascal","Pa",null,"pressure",!0,!1,1],["pascal second","Pa?s",null,"dynamic_viscosity",!0,!1,1],["pferdestärke","PS",null,"power",!1,!0,735.49875],["phot","ph",null,"illuminance",!1,!1,1e-4],["pica (1/6 inch)","pica",null,"length",!1,!0,.00035277777777778],["pica (1/72 inch)","Pica",["Picapt"],"length",!1,!0,.00423333333333333],["poise","P",null,"dynamic_viscosity",!1,!1,.1],["pond","pond",null,"force",!1,!0,.00980665],["pound force","lbf",null,"force",!1,!0,4.4482216152605],["pound mass","lbm",null,"mass",!1,!0,.45359237],["quart","qt",null,"volume",!1,!0,.000946352946],["radian","rad",null,"angle",!0,!1,1],["second","?",null,"angle",!1,!1,484813681109536e-20],["second","s",["sec"],"time",!0,!0,1],["short hundredweight","cwt",["shweight"],"mass",!1,!0,45.359237],["siemens","S",null,"electrical_conductance",!0,!1,1],["sievert","Sv",null,"equivalent_dose",!0,!1,1],["slug","sg",null,"mass",!1,!0,14.59390294],["square ångström","ang2",["ang^2"],"area",!1,!0,1e-20],["square foot","ft2",["ft^2"],"area",!1,!0,.09290304],["square inch","in2",["in^2"],"area",!1,!0,64516e-8],["square light-year","ly2",["ly^2"],"area",!1,!0,8.95054210748189e31],["square meter","m?",null,"area",!0,!0,1],["square mile","mi2",["mi^2"],"area",!1,!0,2589988.110336],["square nautical mile","Nmi2",["Nmi^2"],"area",!1,!0,3429904],["square Pica","Pica2",["Picapt2","Pica^2","Picapt^2"],"area",!1,!0,1792111111111e-17],["square yard","yd2",["yd^2"],"area",!1,!0,.83612736],["statute mile","mi",null,"length",!1,!0,1609.344],["steradian","sr",null,"solid_angle",!0,!1,1],["stilb","sb",null,"luminance",!1,!1,1e-4],["stokes","St",null,"kinematic_viscosity",!1,!1,1e-4],["stone","stone",null,"mass",!1,!0,6.35029318],["tablespoon","tbs",null,"volume",!1,!0,147868e-10],["teaspoon","tsp",null,"volume",!1,!0,492892e-11],["tesla","T",null,"magnetic_flux_density",!0,!0,1],["thermodynamic calorie","c",null,"energy",!1,!0,4.184],["ton","ton",null,"mass",!1,!0,907.18474],["tonne","t",null,"mass",!1,!1,1e3],["U.K. pint","uk_pt",null,"volume",!1,!0,.00056826125],["U.S. bushel","bushel",null,"volume",!1,!0,.03523907],["U.S. oil barrel","barrel",null,"volume",!1,!0,.158987295],["U.S. pint","pt",["us_pt"],"volume",!1,!0,.000473176473],["U.S. survey mile","survey_mi",null,"length",!1,!0,1609.347219],["U.S. survey/statute acre","us_acre",null,"area",!1,!0,4046.87261],["volt","V",null,"voltage",!0,!1,1],["watt","W",null,"power",!0,!0,1],["watt-hour","Wh",["wh"],"energy",!1,!0,3600],["weber","Wb",null,"magnetic_flux",!0,!1,1],["yard","yd",null,"length",!1,!0,.9144],["year","yr",null,"time",!1,!0,31557600]],o={Yi:["yobi",80,1.2089258196146292e24,"Yi","yotta"],Zi:["zebi",70,0x400000000000000000,"Zi","zetta"],Ei:["exbi",60,0x1000000000000000,"Ei","exa"],Pi:["pebi",50,0x4000000000000,"Pi","peta"],Ti:["tebi",40,1099511627776,"Ti","tera"],Gi:["gibi",30,1073741824,"Gi","giga"],Mi:["mebi",20,1048576,"Mi","mega"],ki:["kibi",10,1024,"ki","kilo"]},f={Y:["yotta",1e24,"Y"],Z:["zetta",1e21,"Z"],E:["exa",1e18,"E"],P:["peta",1e15,"P"],T:["tera",1e12,"T"],G:["giga",1e9,"G"],M:["mega",1e6,"M"],k:["kilo",1e3,"k"],h:["hecto",100,"h"],e:["dekao",10,"e"],d:["deci",.1,"d"],c:["centi",.01,"c"],m:["milli",.001,"m"],u:["micro",1e-6,"u"],n:["nano",1e-9,"n"],p:["pico",1e-12,"p"],f:["femto",1e-15,"f"],a:["atto",1e-18,"a"],z:["zepto",1e-21,"z"],y:["yocto",1e-24,"y"]},s=null,l=null,c=n,h=e,p=1,m=1,E=0;146>E;E++)t=null===u[E][2]?[]:u[E][2],u[E][1]!==c&&0>t.indexOf(c)||(s=u[E]),u[E][1]!==h&&0>t.indexOf(h)||(l=u[E]);if(null===s){var N=o[n.substring(0,2)],v=f[n.substring(0,1)];"da"===n.substring(0,2)&&(v=["dekao",10,"da"]),N?(p=N[2],c=n.substring(2)):v&&(p=v[1],c=n.substring(v[2].length));for(var g=0;146>g;g++)t=null===u[g][2]?[]:u[g][2],u[g][1]!==c&&0>t.indexOf(c)||(s=u[g])}if(null===l){var I=o[e.substring(0,2)],d=f[e.substring(0,1)];"da"===e.substring(0,2)&&(d=["dekao",10,"da"]),I?(m=I[2],h=e.substring(2)):d&&(m=d[1],h=e.substring(d[2].length));for(var b=0;146>b;b++)t=null===u[b][2]?[]:u[b][2],u[b][1]!==h&&0>t.indexOf(h)||(l=u[b])}return null===s||null===l?a.na:s[3]!==l[3]?a.na:r*s[6]*p/(l[6]*m)},n.DEC2BIN=function(r,n){if((r=i.parseNumber(r))instanceof Error)return r;if(!/^-?[0-9]{1,3}$/.test(r)||-512>r||r>511)return a.num;if(0>r)return"1"+o.REPT("0",9-(512+r).toString(2).length)+(512+r).toString(2);var e=parseInt(r,10).toString(2);return void 0===n?e:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),e.length>n?a.num:o.REPT("0",n-e.length)+e)},n.DEC2HEX=function(r,n){if((r=i.parseNumber(r))instanceof Error)return r;if(!/^-?[0-9]{1,12}$/.test(r)||-549755813888>r||r>549755813887)return a.num;if(0>r)return(1099511627776+r).toString(16);var e=parseInt(r,10).toString(16);return void 0===n?e:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),e.length>n?a.num:o.REPT("0",n-e.length)+e)},n.DEC2OCT=function(r,n){if((r=i.parseNumber(r))instanceof Error)return r;if(!/^-?[0-9]{1,9}$/.test(r)||-536870912>r||r>536870911)return a.num;if(0>r)return(1073741824+r).toString(8);var e=parseInt(r,10).toString(8);return void 0===n?e:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),e.length>n?a.num:o.REPT("0",n-e.length)+e)},n.DELTA=function(r,n){return n=n===undefined?0:n,r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:r===n?1:0},n.ERF=function(r,n){return n=n===undefined?0:n,r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?a.value:u.erf(r)},n.ERF.PRECISE=function(){throw Error("ERF.PRECISE is not implemented")},n.ERFC=function(r){return isNaN(r)?a.value:u.erfc(r)},n.ERFC.PRECISE=function(){throw Error("ERFC.PRECISE is not implemented")},n.GESTEP=function(r,n){return n=n||0,r=i.parseNumber(r),i.anyIsError(n,r)?r:n>r?0:1},n.HEX2BIN=function(r,n){if(!/^[0-9A-Fa-f]{1,10}$/.test(r))return a.num;var e=10===r.length&&"f"===r.substring(0,1).toLowerCase(),t=e?parseInt(r,16)-1099511627776:parseInt(r,16);if(-512>t||t>511)return a.num;if(e)return"1"+o.REPT("0",9-(512+t).toString(2).length)+(512+t).toString(2);var u=t.toString(2);return n===undefined?u:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),u.length>n?a.num:o.REPT("0",n-u.length)+u)},n.HEX2DEC=function(r){if(!/^[0-9A-Fa-f]{1,10}$/.test(r))return a.num;var n=parseInt(r,16);return 549755813888>n?n:n-1099511627776},n.HEX2OCT=function(r,n){if(!/^[0-9A-Fa-f]{1,10}$/.test(r))return a.num;var e=parseInt(r,16);if(e>536870911&&0xffe0000000>e)return a.num;if(e>=0xffe0000000)return(e-0xffc0000000).toString(8);var t=e.toString(8);return n===undefined?t:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),t.length>n?a.num:o.REPT("0",n-t.length)+t)},n.IMABS=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);return i.anyIsError(e,t)?a.value:Math.sqrt(Math.pow(e,2)+Math.pow(t,2))},n.IMAGINARY=function(r){if(r===undefined||!0===r||!1===r)return a.value;if(0===r||"0"===r)return 0;if(["i","j"].indexOf(r)>=0)return 1;r=r.replace("+i","+1i").replace("-i","-1i").replace("+j","+1j").replace("-j","-1j");var n=r.indexOf("+"),e=r.indexOf("-");0===n&&(n=r.indexOf("+",1)),0===e&&(e=r.indexOf("-",1));var t=r.substring(r.length-1,r.length),u="i"===t||"j"===t;return 0>n&&0>e?u?isNaN(r.substring(0,r.length-1))?a.num:r.substring(0,r.length-1):isNaN(r)?a.num:0:u?0>n?isNaN(r.substring(0,e))||isNaN(r.substring(e+1,r.length-1))?a.num:-+r.substring(e+1,r.length-1):isNaN(r.substring(0,n))||isNaN(r.substring(n+1,r.length-1))?a.num:+r.substring(n+1,r.length-1):a.num},n.IMARGUMENT=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);return i.anyIsError(e,t)?a.value:0===e&&0===t?a.div0:0===e&&t>0?Math.PI/2:0===e&&0>t?-Math.PI/2:0===t&&e>0?0:0===t&&0>e?-Math.PI:e>0?Math.atan(t/e):0>e&&t>=0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI},n.IMCONJUGATE=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",0!==t?n.COMPLEX(e,-t,u):r},n.IMCOS=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",n.COMPLEX(Math.cos(e)*(Math.exp(t)+Math.exp(-t))/2,-Math.sin(e)*(Math.exp(t)-Math.exp(-t))/2,u)},n.IMCOSH=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",n.COMPLEX(Math.cos(t)*(Math.exp(e)+Math.exp(-e))/2,Math.sin(t)*(Math.exp(e)-Math.exp(-e))/2,u)},n.IMCOT=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);return i.anyIsError(e,t)?a.value:n.IMDIV(n.IMCOS(r),n.IMSIN(r))},n.IMDIV=function(r,e){var t=n.IMREAL(r),u=n.IMAGINARY(r),o=n.IMREAL(e),f=n.IMAGINARY(e);if(i.anyIsError(t,u,o,f))return a.value;var s=r.substring(r.length-1),l=e.substring(e.length-1),c="i";if("j"===s?c="j":"j"===l&&(c="j"),0===o&&0===f)return a.num;var h=o*o+f*f;return n.COMPLEX((t*o+u*f)/h,(u*o-t*f)/h,c)},n.IMEXP=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);u="i"===u||"j"===u?u:"i";var o=Math.exp(e);return n.COMPLEX(o*Math.cos(t),o*Math.sin(t),u)},n.IMLN=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",n.COMPLEX(Math.log(Math.sqrt(e*e+t*t)),Math.atan(t/e),u)},n.IMLOG10=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",n.COMPLEX(Math.log(Math.sqrt(e*e+t*t))/Math.log(10),Math.atan(t/e)/Math.log(10),u)},n.IMLOG2=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",n.COMPLEX(Math.log(Math.sqrt(e*e+t*t))/Math.log(2),Math.atan(t/e)/Math.log(2),u)},n.IMPOWER=function(r,e){e=i.parseNumber(e);var t=n.IMREAL(r),u=n.IMAGINARY(r);if(i.anyIsError(e,t,u))return a.value;var o=r.substring(r.length-1);o="i"===o||"j"===o?o:"i";var f=Math.pow(n.IMABS(r),e),s=n.IMARGUMENT(r);return n.COMPLEX(f*Math.cos(e*s),f*Math.sin(e*s),o)},n.IMPRODUCT=function(){var r=arguments[0];if(!arguments.length)return a.value;for(var e=1;arguments.length>e;e++){var t=n.IMREAL(r),u=n.IMAGINARY(r),o=n.IMREAL(arguments[e]),f=n.IMAGINARY(arguments[e]);if(i.anyIsError(t,u,o,f))return a.value;r=n.COMPLEX(t*o-u*f,t*f+u*o)}return r},n.IMREAL=function(r){if(r===undefined||!0===r||!1===r)return a.value;if(0===r||"0"===r)return 0;if(["i","+i","1i","+1i","-i","-1i","j","+j","1j","+1j","-j","-1j"].indexOf(r)>=0)return 0;var n=r.indexOf("+"),e=r.indexOf("-");0===n&&(n=r.indexOf("+",1)),0===e&&(e=r.indexOf("-",1));var t=r.substring(r.length-1,r.length),u="i"===t||"j"===t;return 0>n&&0>e?u?isNaN(r.substring(0,r.length-1))?a.num:0:isNaN(r)?a.num:r:u?0>n?isNaN(r.substring(0,e))||isNaN(r.substring(e+1,r.length-1))?a.num:+r.substring(0,e):isNaN(r.substring(0,n))||isNaN(r.substring(n+1,r.length-1))?a.num:+r.substring(0,n):a.num},n.IMSEC=function(r){if(!0===r||!1===r)return a.value;var e=n.IMREAL(r),t=n.IMAGINARY(r);return i.anyIsError(e,t)?a.value:n.IMDIV("1",n.IMCOS(r))},n.IMSECH=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);return i.anyIsError(e,t)?a.value:n.IMDIV("1",n.IMCOSH(r))},n.IMSIN=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",n.COMPLEX(Math.sin(e)*(Math.exp(t)+Math.exp(-t))/2,Math.cos(e)*(Math.exp(t)-Math.exp(-t))/2,u)},n.IMSINH=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);return u="i"===u||"j"===u?u:"i",n.COMPLEX(Math.cos(t)*(Math.exp(e)-Math.exp(-e))/2,Math.sin(t)*(Math.exp(e)+Math.exp(-e))/2,u)},n.IMSQRT=function(r){var e=n.IMREAL(r),t=n.IMAGINARY(r);if(i.anyIsError(e,t))return a.value;var u=r.substring(r.length-1);u="i"===u||"j"===u?u:"i";var o=Math.sqrt(n.IMABS(r)),f=n.IMARGUMENT(r);return n.COMPLEX(o*Math.cos(f/2),o*Math.sin(f/2),u)},n.IMCSC=function(r){if(!0===r||!1===r)return a.value;var e=n.IMREAL(r),t=n.IMAGINARY(r);return i.anyIsError(e,t)?a.num:n.IMDIV("1",n.IMSIN(r))},n.IMCSCH=function(r){if(!0===r||!1===r)return a.value;var e=n.IMREAL(r),t=n.IMAGINARY(r);return i.anyIsError(e,t)?a.num:n.IMDIV("1",n.IMSINH(r))},n.IMSUB=function(r,n){var e=this.IMREAL(r),t=this.IMAGINARY(r),u=this.IMREAL(n),o=this.IMAGINARY(n);if(i.anyIsError(e,t,u,o))return a.value;var f=r.substring(r.length-1),s=n.substring(n.length-1),l="i";return"j"===f?l="j":"j"===s&&(l="j"),this.COMPLEX(e-u,t-o,l)},n.IMSUM=function(){if(!arguments.length)return a.value;for(var r=i.flatten(arguments),n=r[0],e=1;r.length>e;e++){var t=this.IMREAL(n),u=this.IMAGINARY(n),o=this.IMREAL(r[e]),f=this.IMAGINARY(r[e]);if(i.anyIsError(t,u,o,f))return a.value;n=this.COMPLEX(t+o,u+f)}return n},n.IMTAN=function(r){if(!0===r||!1===r)return a.value;var e=n.IMREAL(r),t=n.IMAGINARY(r);return i.anyIsError(e,t)?a.value:this.IMDIV(this.IMSIN(r),this.IMCOS(r))},n.OCT2BIN=function(r,n){if(!/^[0-7]{1,10}$/.test(r))return a.num;var e=10===r.length&&"7"===r.substring(0,1),t=e?parseInt(r,8)-1073741824:parseInt(r,8);if(-512>t||t>511)return a.num;if(e)return"1"+o.REPT("0",9-(512+t).toString(2).length)+(512+t).toString(2);var u=t.toString(2);return void 0===n?u:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),u.length>n?a.num:o.REPT("0",n-u.length)+u)},n.OCT2DEC=function(r){if(!/^[0-7]{1,10}$/.test(r))return a.num;var n=parseInt(r,8);return 536870912>n?n:n-1073741824},n.OCT2HEX=function(r,n){if(!/^[0-7]{1,10}$/.test(r))return a.num;var e=parseInt(r,8);if(e>=536870912)return"ff"+(e+3221225472).toString(16);var t=e.toString(16);return n===undefined?t:isNaN(n)?a.value:0>n?a.num:(n=Math.floor(n),t.length>n?a.num:o.REPT("0",n-t.length)+t)}},function(r,n,e){"use strict";n.__esModule=!0,n["default"]=["ABS","ACCRINT","ACOS","ACOSH","ACOT","ACOTH","ADD","AGGREGATE","AND","ARABIC","ARGS2ARRAY","ASIN","ASINH","ATAN","ATAN2","ATANH","AVEDEV","AVERAGE","AVERAGEA","AVERAGEIF","AVERAGEIFS","BASE","BESSELI","BESSELJ","BESSELK","BESSELY","BETA.DIST","BETA.INV","BETADIST","BETAINV","BIN2DEC","BIN2HEX","BIN2OCT","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BINOMDIST","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING","CEILINGMATH","CEILINGPRECISE","CHAR","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHOOSE","CHOOSE","CLEAN","CODE","COLUMN","COLUMNS","COMBIN","COMBINA","COMPLEX","CONCATENATE","CONFIDENCE","CONFIDENCE.NORM","CONFIDENCE.T","CONVERT","CORREL","COS","COSH","COT","COTH","COUNT","COUNTA","COUNTBLANK","COUNTIF","COUNTIFS","COUNTIN","COUNTUNIQUE","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","CUMIPMT","CUMPRINC","DATE","DATEVALUE","DAY","DAYS","DAYS360","DB","DDB","DEC2BIN","DEC2HEX","DEC2OCT","DECIMAL","DEGREES","DELTA","DEVSQ","DIVIDE","DOLLARDE","DOLLARFR","E","EDATE","EFFECT","EOMONTH","EQ","ERF","ERFC","EVEN","EXACT","EXP","EXPON.DIST","EXPONDIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","FACT","FACTDOUBLE","FALSE","FDIST","FDISTRT","FIND","FINV","FINVRT","FISHER","FISHERINV","FLATTEN","FLOOR","FORECAST","FREQUENCY","FV","FVSCHEDULE","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMADIST","GAMMAINV","GAMMALN","GAMMALN.PRECISE","GAUSS","GCD","GEOMEAN","GESTEP","GROWTH","GTE","HARMEAN","HEX2BIN","HEX2DEC","HEX2OCT","HOUR","HTML2TEXT","HYPGEOM.DIST","HYPGEOMDIST","IF","IMABS","IMAGINARY","IMARGUMENT","IMCONJUGATE","IMCOS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMDIV","IMEXP","IMLN","IMLOG10","IMLOG2","IMPOWER","IMPRODUCT","IMREAL","IMSEC","IMSECH","IMSIN","IMSINH","IMSQRT","IMSUB","IMSUM","IMTAN","INT","INTERCEPT","INTERVAL","IPMT","IRR","ISBINARY","ISBLANK","ISEVEN","ISLOGICAL","ISNONTEXT","ISNUMBER","ISODD","ISODD","ISOWEEKNUM","ISPMT","ISTEXT","JOIN","KURT","LARGE","LCM","LEFT","LEN","LINEST","LN","LOG","LOG10","LOGEST","LOGNORM.DIST","LOGNORM.INV","LOGNORMDIST","LOGNORMINV","LOWER","LT","LTE","MATCH","MAX","MAXA","MEDIAN","MID","MIN","MINA","MINUS","MINUTE","MIRR","MOD","MODE.MULT","MODE.SNGL","MODEMULT","MODESNGL","MONTH","MROUND","MULTINOMIAL","MULTIPLY","NE","NEGBINOM.DIST","NEGBINOMDIST","NETWORKDAYS","NOMINAL","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NORMDIST","NORMINV","NORMSDIST","NORMSINV","NOT","NOW","NPER","NPV","NUMBERS","OCT2BIN","OCT2DEC","OCT2HEX","ODD","OR","PDURATION","PEARSON","PERCENTILEEXC","PERCENTILEINC","PERCENTRANKEXC","PERCENTRANKINC","PERMUT","PERMUTATIONA","PHI","PI","PMT","POISSON.DIST","POISSONDIST","POW","POWER","PPMT","PROB","PRODUCT","PROPER","PV","QUARTILE.EXC","QUARTILE.INC","QUARTILEEXC","QUARTILEINC","QUOTIENT","RADIANS","RAND","RANDBETWEEN","RANK.AVG","RANK.EQ","RANKAVG","RANKEQ","RATE","REFERENCE","REGEXEXTRACT","REGEXMATCH","REGEXREPLACE","REPLACE","REPT","RIGHT","ROMAN","ROUND","ROUNDDOWN","ROUNDUP","ROW","ROWS","RRI","RSQ","SEARCH","SEC","SECH","SECOND","SERIESSUM","SIGN","SIN","SINH","SKEW","SKEW.P","SKEWP","SLN","SLOPE","SMALL","SPLIT","SPLIT","SQRT","SQRTPI","STANDARDIZE","STDEV.P","STDEV.S","STDEVA","STDEVP","STDEVPA","STDEVS","STEYX","SUBSTITUTE","SUBTOTAL","SUM","SUMIF","SUMIFS","SUMPRODUCT","SUMSQ","SUMX2MY2","SUMX2PY2","SUMXMY2","SWITCH","SYD","T","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","TAN","TANH","TBILLEQ","TBILLPRICE","TBILLYIELD","TDIST","TDIST2T","TDISTRT","TIME","TIMEVALUE","TINV","TINV2T","TODAY","TRANSPOSE","TREND","TRIM","TRIMMEAN","TRUE","TRUNC","UNICHAR","UNICODE","UNIQUE","UPPER","VAR.P","VAR.S","VARA","VARP","VARPA","VARS","WEEKDAY","WEEKNUM","WEIBULL.DIST","WEIBULLDIST","WORKDAY","XIRR","XNPV","XOR","YEAR","YEARFRAC"]},function(r,n,e){"use strict";function t(r){var n=parseInt(r,10);return n=isNaN(n)?-1:Math.max(n-1,-1)}function a(r){var n="";return 0>r||(n=""+(r+1)),n}function u(r){var n=0;if("string"==typeof r){r=r.toUpperCase();for(var e=0,t=r.length-1;r.length>e;e+=1,t-=1)n+=Math.pow(l,t)*(s.indexOf(r[e])+1)}return--n}function o(r){for(var n="";r>=0;)n=String.fromCharCode(r%l+97)+n,r=Math.floor(r/l)-1;return n.toUpperCase()}function i(r){if("string"!=typeof r||!c.test(r))return[];var n=r.toUpperCase().match(c),e=n[1],a=n[2],o=n[3],i=n[4];return[{index:t(i),label:i,isAbsolute:"$"===o},{index:u(a),label:a,isAbsolute:"$"===e}]}function f(r,n){var e=(r.isAbsolute?"$":"")+a(r.index);return(n.isAbsolute?"$":"")+o(n.index)+e}n.__esModule=!0,n.rowLabelToIndex=t,n.rowIndexToLabel=a,n.columnLabelToIndex=u,n.columnIndexToLabel=o,n.extractLabel=i,n.toLabel=f;var s="ABCDEFGHIJKLMNOPQRSTUVWXYZ",l=s.length,c=/^([$])?([A-Za-z]+)([$])?([0-9]+)$/},function(r,n,e){"use strict";function t(r){return r&&r.__esModule?r:{"default":r}}n.__esModule=!0,n.rowLabelToIndex=n.rowIndexToLabel=n.columnLabelToIndex=n.columnIndexToLabel=n.toLabel=n.extractLabel=n.error=n.Parser=n.ERROR_VALUE=n.ERROR_REF=n.ERROR_NUM=n.ERROR_NULL=n.ERROR_NOT_AVAILABLE=n.ERROR_NAME=n.ERROR_DIV_ZERO=n.ERROR=n.SUPPORTED_FORMULAS=undefined;var a=e(16),u=t(a),o=e(13),i=t(o),f=e(2),s=t(f),l=e(14);n.SUPPORTED_FORMULAS=i["default"],n.ERROR=f.ERROR,n.ERROR_DIV_ZERO=f.ERROR_DIV_ZERO,n.ERROR_NAME=f.ERROR_NAME,n.ERROR_NOT_AVAILABLE=f.ERROR_NOT_AVAILABLE,n.ERROR_NULL=f.ERROR_NULL,n.ERROR_NUM=f.ERROR_NUM,n.ERROR_REF=f.ERROR_REF,n.ERROR_VALUE=f.ERROR_VALUE,n.Parser=u["default"],n.error=s["default"],n.extractLabel=l.extractLabel,n.toLabel=l.toLabel,n.columnIndexToLabel=l.columnIndexToLabel,n.columnLabelToIndex=l.columnLabelToIndex,n.rowIndexToLabel=l.rowIndexToLabel,n.rowLabelToIndex=l.rowLabelToIndex},function(r,n,e){"use strict";function t(r){return r&&r.__esModule?r:{"default":r}}function a(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function u(r,n){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?r:n}function o(r,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(r,n):r.__proto__=n)}n.__esModule=!0;var i=e(17),f=t(i),s=e(18),l=t(s),c=e(39),h=e(40),p=e(3),m=e(2),E=t(m),N=e(14);n["default"]=function(r){function n(){a(this,n);var e=u(this,r.call(this));return e.parser=new c.Parser,e.parser.yy={toNumber:p.toNumber,trimEdges:h.trimEdges,invertNumber:p.invertNumber,throwError:function(r){return e._throwError(r)},callVariable:function(r){return e._callVariable(r)},evaluateByOperator:l["default"],callFunction:function(r,n){return e._callFunction(r,n)},cellValue:function(r){return e._callCellValue(r)},rangeValue:function(r,n){return e._callRangeValue(r,n)}},e.variables=Object.create(null),e.functions=Object.create(null),e.setVariable("TRUE",!0).setVariable("FALSE",!1).setVariable("NULL",null),e}return o(n,r),n.prototype.parse=function(r){var n=null,e=null;try{n=""===r?"":this.parser.parse(r)}catch(a){var t=(0,E["default"])(a.message);e=t||(0,E["default"])(m.ERROR)}return n instanceof Error&&(e=(0,E["default"])(n.message)||(0,E["default"])(m.ERROR),n=null),{error:e,result:n}},n.prototype.setVariable=function(r,n){return this.variables[r]=n,this},n.prototype.getVariable=function(r){return this.variables[r]},n.prototype._callVariable=function(r){var n=this.getVariable(r);if(this.emit("callVariable",r,function(r){void 0!==r&&(n=r)}),void 0===n)throw Error(m.ERROR_NAME);return n},n.prototype.setFunction=function(r,n){return this.functions[r]=n,this},n.prototype.getFunction=function(r){return this.functions[r]},n.prototype._callFunction=function(r){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[],e=this.getFunction(r),t=void 0;return e&&(t=e(n)),this.emit("callFunction",r,n,function(r){void 0!==r&&(t=r)}),void 0===t?(0,l["default"])(r,n):t},n.prototype._callCellValue=function(r){r=r.toUpperCase();var n=(0,N.extractLabel)(r),e=n[0],t=n[1],a=void 0;return this.emit("callCellValue",{label:r,row:e,column:t},function(r){a=r}),a},n.prototype._callRangeValue=function(r,n){r=r.toUpperCase(),n=n.toUpperCase();var e=(0,N.extractLabel)(r),t=e[0],a=e[1],u=(0,N.extractLabel)(n),o=u[0],i=u[1],f={},s={};t.index>o.index?(f.row=o,s.row=t):(f.row=t,s.row=o),a.index>i.index?(f.column=i,s.column=a):(f.column=a,s.column=i),f.label=(0,N.toLabel)(f.row,f.column),s.label=(0,N.toLabel)(s.row,s.column);var l=[];return this.emit("callRangeValue",f,s,function(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];l=r}),l},n.prototype._throwError=function(r){if((0,m.isValidStrict)(r))throw Error(r);throw Error(m.ERROR)},n}(f["default"])},function(r,n){function e(){}e.prototype={on:function(r,n,e){var t=this.e||(this.e={});return(t[r]||(t[r]=[])).push({fn:n,ctx:e}),this},once:function(r,n,e){function t(){a.off(r,t),n.apply(e,arguments)}var a=this;return t._=n,this.on(r,t,e)},emit:function(r){var n=[].slice.call(arguments,1),e=((this.e||(this.e={}))[r]||[]).slice(),t=0,a=e.length;for(t;a>t;t++)e[t].fn.apply(e[t].ctx,n);return this},off:function(r,n){var e=this.e||(this.e={}),t=e[r],a=[];if(t&&n)for(var u=0,o=t.length;o>u;u++)t[u].fn!==n&&t[u].fn._!==n&&a.push(t[u]);return a.length?e[r]=a:delete e[r],this}},r.exports=e},function(r,n,e){"use strict";function t(r){return r&&r.__esModule?r:{"default":r}}function a(r){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];if(r=r.toUpperCase(),!P[r])throw Error(w.ERROR_NAME);return P[r].apply(P,n)}function u(r,n){Array.isArray(r)||(r=[r.toUpperCase()]),r.forEach(function(r){P[r]=n.isFactory?n(r):n})}n.__esModule=!0,n["default"]=a,n.registerOperation=u;var o=e(19),i=t(o),f=e(20),s=t(f),l=e(21),c=t(l),h=e(22),p=t(h),m=e(23),E=t(m),N=e(31),v=t(N),g=e(32),I=t(g),d=e(33),b=t(d),M=e(34),y=t(M),A=e(35),R=t(A),T=e(36),O=t(T),S=e(37),L=t(S),C=e(38),D=t(C),w=e(2),P=Object.create(null);u(i["default"].SYMBOL,i["default"]),u(s["default"].SYMBOL,s["default"]),u(c["default"].SYMBOL,c["default"]),u(p["default"].SYMBOL,p["default"]),u(D["default"].SYMBOL,D["default"]),u(E["default"].SYMBOL,E["default"]),u(v["default"].SYMBOL,v["default"]),u(I["default"].SYMBOL,I["default"]),u(b["default"].SYMBOL,b["default"]),u(y["default"].SYMBOL,y["default"]),u(O["default"].SYMBOL,O["default"]),u(L["default"].SYMBOL,L["default"]),u(R["default"].SYMBOL,R["default"])},function(r,n,e){"use strict";function t(r){for(var n=arguments.length,e=Array(n>1?n-1:0),t=1;n>t;t++)e[t-1]=arguments[t];var o=e.reduce(function(r,n){return r+(0,a.toNumber)(n)},(0,a.toNumber)(r));if(isNaN(o))throw Error(u.ERROR_VALUE);return o}n.__esModule=!0,n.SYMBOL=undefined,n["default"]=t;var a=e(3),u=e(2);t.SYMBOL=n.SYMBOL="+"},function(r,n,e){"use strict";function t(){for(var r=arguments.length,n=Array(r),e=0;r>e;e++)n[e]=arguments[e];return n.reduce(function(r,n){return r+""+n},"")}n.__esModule=!0,n["default"]=t,t.SYMBOL=n.SYMBOL="&"},function(r,n,e){"use strict";function t(r){for(var n=arguments.length,e=Array(n>1?n-1:0),t=1;n>t;t++)e[t-1]=arguments[t];var o=e.reduce(function(r,n){return r/(0,a.toNumber)(n)},(0,a.toNumber)(r));if(o===Infinity)throw Error(u.ERROR_DIV_ZERO);if(isNaN(o))throw Error(u.ERROR_VALUE);return o}n.__esModule=!0,n.SYMBOL=undefined,n["default"]=t;var a=e(3),u=e(2);t.SYMBOL=n.SYMBOL="/"},function(r,n,e){"use strict";function t(r,n){return r===n}n.__esModule=!0,n["default"]=t,t.SYMBOL=n.SYMBOL="="},function(r,n,e){"use strict";function t(r){return function(){r=r.toUpperCase();var n=r.split("."),e=!1,t=void 0;if(1===n.length)u[n[0]]&&(e=!0,t=u[n[0]].apply(u,arguments));else{for(var a=n.length,o=0,i=u;a>o;)if(i=i[n[o]],o++,!i){i=null;break}i&&(e=!0,t=i.apply(undefined,arguments))}if(!e)throw Error(f.ERROR_NAME);return t}}n.__esModule=!0,n.SYMBOL=undefined,n["default"]=t;var a=e(24),u=function(r){if(r&&r.__esModule)return r;var n={};if(null!=r)for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=r[e]);return n["default"]=r,n}(a),o=e(13),i=function(r){return r&&r.__esModule?r:{"default":r}}(o),f=e(2),s=n.SYMBOL=i["default"];t.isFactory=!0,t.SYMBOL=s},function(r,n,e){var t=[e(25),e(27),e(12),e(28),e(4),e(6),e(9),e(29),e(8),e(30),e(5),e(11)];for(var a in t){var u=t[a];for(var o in u)n[o]=n[o]||u[o]}},function(r,n,e){function t(r,n){if(n)for(var e in n)r[e]=n[e];return r}var a=e(4),u=e(5),o=e(12),i=e(9);n.BETADIST=u.BETA.DIST,n.BETAINV=u.BETA.INV,n.BINOMDIST=u.BINOM.DIST,n.CEILING=n.ISOCEILING=t(a.CEILING.MATH,a.CEILING),n.CEILINGMATH=a.CEILING.MATH,n.CEILINGPRECISE=a.CEILING.PRECISE,n.CHIDIST=u.CHISQ.DIST,n.CHIDISTRT=u.CHISQ.DIST.RT,n.CHIINV=u.CHISQ.INV,n.CHIINVRT=u.CHISQ.INV.RT,n.CHITEST=u.CHISQ.TEST,n.CONFIDENCE=t(u.CONFIDENCE.NORM,u.CONFIDENCE),n.COVAR=u.COVARIANCE.P,n.COVARIANCEP=u.COVARIANCE.P,n.COVARIANCES=u.COVARIANCE.S,n.CRITBINOM=u.BINOM.INV,n.EXPONDIST=u.EXPON.DIST,n.ERFCPRECISE=o.ERFC.PRECISE,n.ERFPRECISE=o.ERF.PRECISE,n.FDIST=u.F.DIST,n.FDISTRT=u.F.DIST.RT,n.FINVRT=u.F.INV.RT,n.FINV=u.F.INV,n.FLOOR=t(a.FLOOR.MATH,a.FLOOR),n.FLOORMATH=a.FLOOR.MATH,n.FLOORPRECISE=a.FLOOR.PRECISE,n.FTEST=u.F.TEST,n.GAMMADIST=u.GAMMA.DIST,n.GAMMAINV=u.GAMMA.INV,n.GAMMALNPRECISE=u.GAMMALN.PRECISE,n.HYPGEOMDIST=u.HYPGEOM.DIST,n.LOGINV=u.LOGNORM.INV,n.LOGNORMINV=u.LOGNORM.INV,n.LOGNORMDIST=u.LOGNORM.DIST,n.MODE=t(u.MODE.SNGL,u.MODE),n.MODEMULT=u.MODE.MULT,n.MODESNGL=u.MODE.SNGL,n.NEGBINOMDIST=u.NEGBINOM.DIST,n.NETWORKDAYSINTL=i.NETWORKDAYS.INTL,n.NORMDIST=u.NORM.DIST,n.NORMINV=u.NORM.INV,n.NORMSDIST=u.NORM.S.DIST,n.NORMSINV=u.NORM.S.INV,n.PERCENTILE=t(u.PERCENTILE.EXC,u.PERCENTILE),n.PERCENTILEEXC=u.PERCENTILE.EXC,n.PERCENTILEINC=u.PERCENTILE.INC,n.PERCENTRANK=t(u.PERCENTRANK.INC,u.PERCENTRANK),n.PERCENTRANKEXC=u.PERCENTRANK.EXC,n.PERCENTRANKINC=u.PERCENTRANK.INC,n.POISSON=t(u.POISSON.DIST,u.POISSON),n.POISSONDIST=u.POISSON.DIST,n.QUARTILE=t(u.QUARTILE.INC,u.QUARTILE),n.QUARTILEEXC=u.QUARTILE.EXC,n.QUARTILEINC=u.QUARTILE.INC,n.RANK=t(u.RANK.EQ,u.RANK),n.RANKAVG=u.RANK.AVG,n.RANKEQ=u.RANK.EQ,n.SKEWP=u.SKEW.P,n.STDEV=t(u.STDEV.S,u.STDEV),n.STDEVP=u.STDEV.P,n.STDEVS=u.STDEV.S,n.TDIST=u.T.DIST,n.TDISTRT=u.T.DIST.RT,n.TINV=u.T.INV,n.TTEST=u.T.TEST,n.VAR=t(u.VAR.S,u.VAR),n.VARP=u.VAR.P,n.VARS=u.VAR.S,n.WEIBULL=t(u.WEIBULL.DIST,u.WEIBULL),n.WEIBULLDIST=u.WEIBULL.DIST,n.WORKDAYINTL=i.WORKDAY.INTL,n.ZTEST=u.Z.TEST},function(r,n,e){function t(r,n){return r.reduce(function(r,e){return n*r+e},0)}function a(r,n,e,t,a){a||(a=-1);var u,o=2/r;if(0===n)return e;if(1===n)return t;for(var i=1;i!=n;++i)u=t*i*o+a*e,e=t,t=u;return t}function u(r,n,e,t,u){return function(o,i){if(0===i)return r(o);if(1===i)return n(o);if(0>i)throw e+": Order ("+i+") must be nonnegative";if(1==t&&0===o)throw e+": Undefined when x == 0";if(2==t&&0>=o)throw e+": Undefined when x <= 0";return a(o,i,r(o),n(o),u)}}var o=Math,i=function(){function r(r){var n,a,l,c=r*r,h=o.abs(r)-.785398164;return 8>o.abs(r)?(a=t(e,c),l=t(u,c),n=a/l):(c=64/c,a=t(i,c),l=t(f,c),n=o.sqrt(s/o.abs(r))*(o.cos(h)*a-o.sin(h)*l*8/o.abs(r))),n}function n(r){var n,e,a,u=r*r,i=o.abs(r)-2.356194491;return 8>Math.abs(r)?(e=r*t(l,u),a=t(c,u),n=e/a):(u=64/u,e=t(h,u),a=t(p,u),n=o.sqrt(s/o.abs(r))*(o.cos(i)*e-o.sin(i)*a*8/o.abs(r)),0>r&&(n=-n)),n}var e=[57568490574,-13362590354,651619640.7,-11214424.18,77392.33017,-184.9052456].reverse(),u=[57568490411,1029532985,9494680.718,59272.64853,267.8532712,1].reverse(),i=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),f=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34935152e-8].reverse(),s=.636619772,l=[72362614232,-7895059235,242396853.1,-2972611.439,15704.4826,-30.16036606].reverse(),c=[144725228442,2300535178,18583304.74,99447.43394,376.9991397,1].reverse(),h=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),p=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();return function(e,t){if(0===(t=Math.round(t)))return r(o.abs(e));if(1===t)return n(o.abs(e));if(0>t)throw"BESSELJ: Order ("+t+") must be nonnegative";if(0===o.abs(e))return 0;var u,i,f,s,l,c,h,p,m=2/o.abs(e);if(o.abs(e)>t)u=a(e,t,r(o.abs(e)),n(o.abs(e)),-1);else{for(f=2*o.floor((t+o.floor(o.sqrt(40*t)))/2),s=0,c=u=l=0,h=1,i=f;i>0;i--)p=i*m*h-c,c=h,h=p,o.abs(h)>1e10&&(h*=1e-10,c*=1e-10,u*=1e-10,l*=1e-10),s&&(l+=h),s=!s,i==t&&(u=c);l=2*l-h,u/=l}return 0>e&&t%2?-u:u}}(),f=function(){function r(r){var n,u,c,h=r*r,p=r-.785398164;return 8>r?(u=t(e,h),c=t(a,h),n=u/c+l*i(r,0)*o.log(r)):(h=64/h,u=t(f,h),c=t(s,h),n=o.sqrt(l/r)*(o.sin(p)*u+o.cos(p)*c*8/r)),n}function n(r){var n,e,a,u=r*r,f=r-2.356194491;return 8>r?(e=r*t(c,u),a=t(h,u),n=e/a+l*(i(r,1)*o.log(r)-1/r)):(u=64/u,e=t(p,u),a=t(m,u),n=o.sqrt(l/r)*(o.sin(f)*e+o.cos(f)*a*8/r)),n}var e=[-2957821389,7062834065,-512359803.6,10879881.29,-86327.92757,228.4622733].reverse(),a=[40076544269,745249964.8,7189466.438,47447.2647,226.1030244,1].reverse(),f=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),s=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34945152e-8].reverse(),l=.636619772,c=[-4900604943e3,127527439e4,-51534381390,734926455.1,-4237922.726,8511.937935].reverse(),h=[249958057e5,424441966400,3733650367,22459040.02,102042.605,354.9632885,1].reverse(),p=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),m=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();return u(r,n,"BESSELY",1,-1)}(),s=function(){function r(r){return r>3.75?o.exp(o.abs(r))/o.sqrt(o.abs(r))*t(a,3.75/o.abs(r)):t(e,r*r/14.0625)}function n(r){return 3.75>r?r*t(u,r*r/14.0625):(0>r?-1:1)*o.exp(o.abs(r))/o.sqrt(o.abs(r))*t(i,3.75/o.abs(r))}var e=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),a=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse(),u=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),i=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse();return function f(e,t){if(0===(t=Math.round(t)))return r(e);if(1==t)return n(e);if(0>t)throw"BESSELI Order ("+t+") must be nonnegative";if(0===o.abs(e))return 0;var a,u,i,s,l,c,h=2/o.abs(e);for(i=2*o.round((t+o.round(o.sqrt(40*t)))/2),s=a=0,l=1,u=i;u>0;u--)c=u*h*l+s,s=l,l=c,o.abs(l)>1e10&&(l*=1e-10,s*=1e-10,a*=1e-10),u==t&&(a=s);return a*=f(e,0)/l,0>e&&t%2?-a:a}}(),l=function(){function r(r){return r>2?o.exp(-r)/o.sqrt(r)*t(a,2/r):-o.log(r/2)*s(r,0)+t(e,r*r/4)}function n(r){return r>2?o.exp(-r)/o.sqrt(r)*t(f,2/r):o.log(r/2)*s(r,1)+1/r*t(i,r*r/4)}var e=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),a=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse(),i=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),f=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();return u(r,n,"BESSELK",2,1)}();n.besselj=i,n.bessely=f,n.besseli=s,n.besselk=l},function(r,n,e){function t(r){var n=[];return f.arrayEach(r,function(r){r&&n.push(r)}),n}function a(r,n){for(var e={},t=1;r[0].length>t;++t)e[t]=!0;var a=n[0].length;for(t=1;n.length>t;++t)n[t].length>a&&(a=n[t].length);for(var u=1;r.length>u;++u)for(var o=1;r[u].length>o;++o){for(var i=!1,f=!1,l=0;n.length>l;++l){var c=n[l];if(c.length>=a){var h=c[0];if(r[u][0]===h){f=!0;for(var p=1;c.length>p;++p)if(!i){var m=void 0===c[p]||"*"===c[p];if(m)i=!0;else{var E=s.parse(c[p]+""),N=[s.createToken(r[u][o],s.TOKEN_TYPE_LITERAL)].concat(E);i=s.compute(N)}}}}}f&&(e[o]=e[o]&&i)}for(var v=[],g=0;r[0].length>g;++g)e[g]&&v.push(g-1);return v}var u=e(0),o=e(5),i=e(4),f=e(1),s=e(7);n.FINDFIELD=function(r,n){var e=null;return f.arrayEach(r,function(r,t){if(r[0]===n)return e=t,!1}),null==e?u.value:e},n.DAVERAGE=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var o=a(r,t),i=[];if("string"==typeof e){var s=n.FINDFIELD(r,e);i=f.rest(r[s])}else i=f.rest(r[e]);var l=0;return f.arrayEach(o,function(r){l+=i[r]}),0===o.length?u.div0:l/o.length},n.DCOUNT=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var i=a(r,t),s=[];if("string"==typeof e){var l=n.FINDFIELD(r,e);s=f.rest(r[l])}else s=f.rest(r[e]);var c=[];return f.arrayEach(i,function(r){c.push(s[r])}),o.COUNT(c)},n.DCOUNTA=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var i=a(r,t),s=[];if("string"==typeof e){var l=n.FINDFIELD(r,e);s=f.rest(r[l])}else s=f.rest(r[e]);var c=[];return f.arrayEach(i,function(r){c.push(s[r])}),o.COUNTA(c)},n.DGET=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var o=a(r,t),i=[];if("string"==typeof e){var s=n.FINDFIELD(r,e);i=f.rest(r[s])}else i=f.rest(r[e]);return 0===o.length?u.value:o.length>1?u.num:i[o[0]]},n.DMAX=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var o=a(r,t),i=[];if("string"==typeof e){var s=n.FINDFIELD(r,e);i=f.rest(r[s])}else i=f.rest(r[e]);var l=i[o[0]];return f.arrayEach(o,function(r){i[r]>l&&(l=i[r])}),l},n.DMIN=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var o=a(r,t),i=[];if("string"==typeof e){var s=n.FINDFIELD(r,e);i=f.rest(r[s])}else i=f.rest(r[e]);var l=i[o[0]];return f.arrayEach(o,function(r){l>i[r]&&(l=i[r])}),l},n.DPRODUCT=function(r,e,o){if(isNaN(e)&&"string"!=typeof e)return u.value;var i=a(r,o),s=[];if("string"==typeof e){var l=n.FINDFIELD(r,e);s=f.rest(r[l])}else s=f.rest(r[e]);var c=[];f.arrayEach(i,function(r){c.push(s[r])}),c=t(c);var h=1;return f.arrayEach(c,function(r){h*=r}),h},n.DSTDEV=function(r,e,i){if(isNaN(e)&&"string"!=typeof e)return u.value;var s=a(r,i),l=[];if("string"==typeof e){var c=n.FINDFIELD(r,e);l=f.rest(r[c])}else l=f.rest(r[e]);var h=[];return f.arrayEach(s,function(r){h.push(l[r])}),h=t(h),o.STDEV.S(h)},n.DSTDEVP=function(r,e,i){if(isNaN(e)&&"string"!=typeof e)return u.value;var s=a(r,i),l=[];if("string"==typeof e){var c=n.FINDFIELD(r,e);l=f.rest(r[c])}else l=f.rest(r[e]);var h=[];return f.arrayEach(s,function(r){h.push(l[r])}),h=t(h),o.STDEV.P(h)},n.DSUM=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var o=a(r,t),s=[];if("string"==typeof e){var l=n.FINDFIELD(r,e);s=f.rest(r[l])}else s=f.rest(r[e]);var c=[];return f.arrayEach(o,function(r){c.push(s[r])}),i.SUM(c)},n.DVAR=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var i=a(r,t),s=[];if("string"==typeof e){var l=n.FINDFIELD(r,e);s=f.rest(r[l])}else s=f.rest(r[e]);var c=[];return f.arrayEach(i,function(r){c.push(s[r])}),o.VAR.S(c)},n.DVARP=function(r,e,t){if(isNaN(e)&&"string"!=typeof e)return u.value;var i=a(r,t),s=[];if("string"==typeof e){var l=n.FINDFIELD(r,e);s=f.rest(r[l])}else s=f.rest(r[e]);var c=[];return f.arrayEach(i,function(r){c.push(s[r])}),o.VAR.P(c)}},function(r,n,e){var t=e(0),a=e(1),u=e(8);n.AND=function(){for(var r=a.flatten(arguments),n=!0,e=0;r.length>e;e++)r[e]||(n=!1);return n},n.CHOOSE=function(){if(2>arguments.length)return t.na;var r=arguments[0];return 1>r||r>254?t.value:r+1>arguments.length?t.value:arguments[r]},n.FALSE=function(){return!1},n.IF=function(r,n,e){return r?n:e},n.IFERROR=function(r,n){return u.ISERROR(r)?n:r},n.IFNA=function(r,n){return r===t.na?n:r},n.NOT=function(r){return!r},n.OR=function(){for(var r=a.flatten(arguments),n=!1,e=0;r.length>e;e++)r[e]&&(n=!0);return n},n.TRUE=function(){return!0},n.XOR=function(){for(var r=a.flatten(arguments),n=0,e=0;r.length>e;e++)r[e]&&n++;return!!(1&Math.floor(Math.abs(n)))},n.SWITCH=function(){var r;if(arguments.length>0){var n=arguments[0],e=arguments.length-1,a=Math.floor(e/2),u=!1,o=e%2!=0,i=e%2==0?null:arguments[arguments.length-1];if(a)for(var f=0;a>f;f++)if(n===arguments[2*f+1]){r=arguments[2*f+2],u=!0;break}u||(r=o?i:t.na)}else r=t.value;return r}},function(r,n,e){function t(r){return r&&r.getTime&&!isNaN(r.getTime())}function a(r){return r instanceof Date?r:new Date(r)}var u=e(0),o=e(9),i=e(1);n.ACCRINT=function(r,n,e,i,f,s,l){return r=a(r),n=a(n),e=a(e),t(r)&&t(n)&&t(e)?i>0&&f>0?-1===[1,2,4].indexOf(s)?u.num:-1===[0,1,2,3,4].indexOf(l)?u.num:e>r?(f=f||0,l=l||0,f*i*o.YEARFRAC(r,e,l)):u.num:u.num:u.value},n.ACCRINTM=function(){throw Error("ACCRINTM is not implemented")},n.AMORDEGRC=function(){throw Error("AMORDEGRC is not implemented")},n.AMORLINC=function(){throw Error("AMORLINC is not implemented")},n.COUPDAYBS=function(){throw Error("COUPDAYBS is not implemented")},n.COUPDAYS=function(){throw Error("COUPDAYS is not implemented")},n.COUPDAYSNC=function(){throw Error("COUPDAYSNC is not implemented")},n.COUPNCD=function(){throw Error("COUPNCD is not implemented")},n.COUPNUM=function(){throw Error("COUPNUM is not implemented")},n.COUPPCD=function(){throw Error("COUPPCD is not implemented")},n.CUMIPMT=function(r,e,t,a,o,f){if(r=i.parseNumber(r),e=i.parseNumber(e),t=i.parseNumber(t),i.anyIsError(r,e,t))return u.value;if(0>=r||0>=e||0>=t)return u.num;if(1>a||1>o||a>o)return u.num;if(0!==f&&1!==f)return u.num;var s=n.PMT(r,e,t,0,f),l=0;1===a&&0===f&&(l=-t,a++);for(var c=a;o>=c;c++)l+=1===f?n.FV(r,c-2,s,t,1)-s:n.FV(r,c-1,s,t,0);return l*=r},n.CUMPRINC=function(r,e,t,a,o,f){if(r=i.parseNumber(r),e=i.parseNumber(e),t=i.parseNumber(t),i.anyIsError(r,e,t))return u.value;if(0>=r||0>=e||0>=t)return u.num;if(1>a||1>o||a>o)return u.num;if(0!==f&&1!==f)return u.num;var s=n.PMT(r,e,t,0,f),l=0;1===a&&(l=0===f?s+t*r:s,a++);for(var c=a;o>=c;c++)l+=f>0?s-(n.FV(r,c-2,s,t,1)-s)*r:s-n.FV(r,c-1,s,t,0)*r;return l},n.DB=function(r,n,e,t,a){if(a=a===undefined?12:a,r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),a=i.parseNumber(a),i.anyIsError(r,n,e,t,a))return u.value;if(0>r||0>n||0>e||0>t)return u.num;if(-1===[1,2,3,4,5,6,7,8,9,10,11,12].indexOf(a))return u.num;if(t>e)return u.num;if(n>=r)return 0;for(var o=(1-Math.pow(n/r,1/e)).toFixed(3),f=r*o*a/12,s=f,l=0,c=t===e?e-1:t,h=2;c>=h;h++)l=(r-s)*o,s+=l;return 1===t?f:t===e?(r-s)*o:l},n.DDB=function(r,n,e,t,a){if(a=a===undefined?2:a,r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),a=i.parseNumber(a),i.anyIsError(r,n,e,t,a))return u.value;if(0>r||0>n||0>e||0>t||0>=a)return u.num;if(t>e)return u.num;if(n>=r)return 0;for(var o=0,f=0,s=1;t>=s;s++)f=Math.min(a/e*(r-o),r-n-o),o+=f;return f},n.DISC=function(){throw Error("DISC is not implemented")},n.DOLLARDE=function(r,n){if(r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n))return u.value;if(0>n)return u.num;if(n>=0&&1>n)return u.div0;n=parseInt(n,10);var e=parseInt(r,10);e+=r%1*Math.pow(10,Math.ceil(Math.log(n)/Math.LN10))/n;var t=Math.pow(10,Math.ceil(Math.log(n)/Math.LN2)+1);return e=Math.round(e*t)/t},n.DOLLARFR=function(r,n){if(r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n))return u.value;if(0>n)return u.num;if(n>=0&&1>n)return u.div0;n=parseInt(n,10);var e=parseInt(r,10);return e+=r%1*Math.pow(10,-Math.ceil(Math.log(n)/Math.LN10))*n},n.DURATION=function(){throw Error("DURATION is not implemented")},n.EFFECT=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?u.value:0>=r||1>n?u.num:(n=parseInt(n,10),Math.pow(1+r/n,n)-1)},n.FV=function(r,n,e,t,a){if(t=t||0,a=a||0,r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),a=i.parseNumber(a),i.anyIsError(r,n,e,t,a))return u.value;var o;if(0===r)o=t+e*n;else{var f=Math.pow(1+r,n);o=1===a?t*f+e*(1+r)*(f-1)/r:t*f+e*(f-1)/r}return-o},n.FVSCHEDULE=function(r,n){if(r=i.parseNumber(r),n=i.parseNumberArray(i.flatten(n)),i.anyIsError(r,n))return u.value;for(var e=n.length,t=r,a=0;e>a;a++)t*=1+n[a];return t},n.INTRATE=function(){throw Error("INTRATE is not implemented")},n.IPMT=function(r,e,t,a,o,f){if(o=o||0,f=f||0,r=i.parseNumber(r),e=i.parseNumber(e),t=i.parseNumber(t),a=i.parseNumber(a),o=i.parseNumber(o),f=i.parseNumber(f),i.anyIsError(r,e,t,a,o,f))return u.value;var s=n.PMT(r,t,a,o,f);return(1===e?1===f?0:-a:1===f?n.FV(r,e-2,s,a,1)-s:n.FV(r,e-1,s,a,0))*r},n.IRR=function(r,n){if(n=n||0,r=i.parseNumberArray(i.flatten(r)),n=i.parseNumber(n),i.anyIsError(r,n))return u.value;for(var e=[],t=!1,a=!1,o=0;r.length>o;o++)e[o]=0===o?0:e[o-1]+365,r[o]>0&&(t=!0),0>r[o]&&(a=!0);if(!t||!a)return u.num;n=n===undefined?.1:n;var f,s,l,c=n,h=!0;do{l=function(r,n,e){for(var t=e+1,a=r[0],u=1;r.length>u;u++)a+=r[u]/Math.pow(t,(n[u]-n[0])/365);return a}(r,e,c),f=c-l/function(r,n,e){for(var t=e+1,a=0,u=1;r.length>u;u++){var o=(n[u]-n[0])/365;a-=o*r[u]/Math.pow(t,o+1)}return a}(r,e,c),s=Math.abs(f-c),c=f,h=s>1e-10&&Math.abs(l)>1e-10}while(h);return c},n.ISPMT=function(r,n,e,t){return r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),i.anyIsError(r,n,e,t)?u.value:t*r*(n/e-1)},n.MDURATION=function(){throw Error("MDURATION is not implemented")},n.MIRR=function(r,e,t){if(r=i.parseNumberArray(i.flatten(r)),e=i.parseNumber(e),t=i.parseNumber(t),i.anyIsError(r,e,t))return u.value;for(var a=r.length,o=[],f=[],s=0;a>s;s++)0>r[s]?o.push(r[s]):f.push(r[s]);var l=-n.NPV(t,f)*Math.pow(1+t,a-1),c=n.NPV(e,o)*(1+e);return Math.pow(l/c,1/(a-1))-1},n.NOMINAL=function(r,n){return r=i.parseNumber(r),n=i.parseNumber(n),i.anyIsError(r,n)?u.value:0>=r||1>n?u.num:(n=parseInt(n,10),(Math.pow(r+1,1/n)-1)*n)},n.NPER=function(r,n,e,t,a){if(a=a===undefined?0:a,t=t===undefined?0:t,r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),a=i.parseNumber(a),i.anyIsError(r,n,e,t,a))return u.value;var o=n*(1+r*a)-t*r,f=e*r+n*(1+r*a);return Math.log(o/f)/Math.log(1+r)},n.NPV=function(){var r=i.parseNumberArray(i.flatten(arguments));if(r instanceof Error)return r;for(var n=r[0],e=0,t=1;r.length>t;t++)e+=r[t]/Math.pow(1+n,t);return e},n.ODDFPRICE=function(){throw Error("ODDFPRICE is not implemented")},n.ODDFYIELD=function(){throw Error("ODDFYIELD is not implemented")},n.ODDLPRICE=function(){throw Error("ODDLPRICE is not implemented")},n.ODDLYIELD=function(){throw Error("ODDLYIELD is not implemented")},n.PDURATION=function(r,n,e){return r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),i.anyIsError(r,n,e)?u.value:r>0?(Math.log(e)-Math.log(n))/Math.log(1+r):u.num},n.PMT=function(r,n,e,t,a){if(t=t||0,a=a||0,r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),a=i.parseNumber(a),i.anyIsError(r,n,e,t,a))return u.value;var o;if(0===r)o=(e+t)/n;else{var f=Math.pow(1+r,n);o=1===a?(t*r/(f-1)+e*r/(1-1/f))/(1+r):t*r/(f-1)+e*r/(1-1/f)}return-o},n.PPMT=function(r,e,t,a,o,f){return o=o||0,f=f||0,r=i.parseNumber(r),t=i.parseNumber(t),a=i.parseNumber(a),o=i.parseNumber(o),f=i.parseNumber(f),i.anyIsError(r,t,a,o,f)?u.value:n.PMT(r,t,a,o,f)-n.IPMT(r,e,t,a,o,f)},n.PRICE=function(){throw Error("PRICE is not implemented")},n.PRICEDISC=function(){throw Error("PRICEDISC is not implemented")},n.PRICEMAT=function(){throw Error("PRICEMAT is not implemented")},n.PV=function(r,n,e,t,a){return t=t||0,a=a||0,r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),a=i.parseNumber(a),i.anyIsError(r,n,e,t,a)?u.value:0===r?-e*n-t:((1-Math.pow(1+r,n))/r*e*(1+r*a)-t)/Math.pow(1+r,n)},n.RATE=function(r,n,e,t,a,o){if(o=o===undefined?.01:o,t=t===undefined?0:t,a=a===undefined?0:a,r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),a=i.parseNumber(a),o=i.parseNumber(o),i.anyIsError(r,n,e,t,a,o))return u.value;var f,s,l,c,h=0,p=0,m=0,E=o;for(1e-10>Math.abs(E)?f=e*(1+r*E)+n*(1+E*a)*r+t:(p=Math.exp(r*Math.log(1+E)),f=e*p+n*(1/E+a)*(p-1)+t),s=e+n*r+t,l=e*p+n*(1/E+a)*(p-1)+t,m=c=0,h=E;Math.abs(s-l)>1e-10&&50>m;)E=(l*c-s*h)/(l-s),c=h,h=E,1e-10>Math.abs(E)?f=e*(1+r*E)+n*(1+E*a)*r+t:(p=Math.exp(r*Math.log(1+E)),f=e*p+n*(1/E+a)*(p-1)+t),s=l,l=f,++m;return E},n.RECEIVED=function(){throw Error("RECEIVED is not implemented")},n.RRI=function(r,n,e){return r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),i.anyIsError(r,n,e)?u.value:0===r||0===n?u.num:Math.pow(e/n,1/r)-1},n.SLN=function(r,n,e){return r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),i.anyIsError(r,n,e)?u.value:0===e?u.num:(r-n)/e},n.SYD=function(r,n,e,t){return r=i.parseNumber(r),n=i.parseNumber(n),e=i.parseNumber(e),t=i.parseNumber(t),i.anyIsError(r,n,e,t)?u.value:0===e?u.num:1>t||t>e?u.num:(t=parseInt(t,10),(r-n)*(e-t+1)*2/(e*(e+1)))},n.TBILLEQ=function(r,n,e){return r=i.parseDate(r),n=i.parseDate(n),e=i.parseNumber(e),i.anyIsError(r,n,e)?u.value:e>0?r>n?u.num:n-r>31536e6?u.num:365*e/(360-e*o.DAYS360(r,n,!1)):u.num},n.TBILLPRICE=function(r,n,e){return r=i.parseDate(r),n=i.parseDate(n),e=i.parseNumber(e),i.anyIsError(r,n,e)?u.value:e>0?r>n?u.num:n-r>31536e6?u.num:100*(1-e*o.DAYS360(r,n,!1)/360):u.num},n.TBILLYIELD=function(r,n,e){return r=i.parseDate(r),n=i.parseDate(n),e=i.parseNumber(e),i.anyIsError(r,n,e)?u.value:e>0?r>n?u.num:n-r>31536e6?u.num:360*(100-e)/(e*o.DAYS360(r,n,!1)):u.num},n.VDB=function(){throw Error("VDB is not implemented")},n.XNPV=function(r,n,e){if(r=i.parseNumber(r),n=i.parseNumberArray(i.flatten(n)),e=i.parseDateArray(i.flatten(e)),i.anyIsError(r,n,e))return u.value;for(var t=0,a=0;n.length>a;a++)t+=n[a]/Math.pow(1+r,o.DAYS(e[a],e[0])/365);return t},n.YIELD=function(){throw Error("YIELD is not implemented")},n.YIELDDISC=function(){throw Error("YIELDDISC is not implemented")},n.YIELDMAT=function(){throw Error("YIELDMAT is not implemented")}},function(r,n,e){var t=e(0),a=e(1);n.MATCH=function(r,n,e){if(!r&&!n)return t.na;if(2===arguments.length&&(e=1),!(n instanceof Array))return t.na;if(-1!==e&&0!==e&&1!==e)return t.na;for(var a,u,o=0;n.length>o;o++)if(1===e){if(n[o]===r)return o+1;r>n[o]&&(u?n[o]>u&&(a=o+1,u=n[o]):(a=o+1,u=n[o]))}else if(0===e){if("string"==typeof r){if(r=r.replace(/\?/g,"."),n[o].toLowerCase().match(r.toLowerCase()))return o+1}else if(n[o]===r)return o+1}else if(-1===e){if(n[o]===r)return o+1;n[o]>r&&(u?u>n[o]&&(a=o+1,u=n[o]):(a=o+1,u=n[o]))}return a||t.na},n.VLOOKUP=function(r,n,e,a){if(!r||!n||!e)return t.na;a=a||!1;for(var u=0;n.length>u;u++){var o=n[u];if(!a&&o[0]===r||o[0]===r||a&&"string"==typeof o[0]&&-1!==o[0].toLowerCase().indexOf(r.toLowerCase()))return o.length+1>e?o[e-1]:t.ref}return t.na},n.HLOOKUP=function(r,n,e,u){if(!r||!n||!e)return t.na;u=u||!1;for(var o=a.transpose(n),i=0;o.length>i;i++){var f=o[i];if(!u&&f[0]===r||f[0]===r||u&&"string"==typeof f[0]&&-1!==f[0].toLowerCase().indexOf(r.toLowerCase()))return f.length+1>e?f[e-1]:t.ref}return t.na}},function(r,n,e){"use strict";function t(r,n){return r>n}n.__esModule=!0,n["default"]=t,t.SYMBOL=n.SYMBOL=">"},function(r,n,e){"use strict";function t(r,n){return r>=n}n.__esModule=!0,n["default"]=t,t.SYMBOL=n.SYMBOL=">="},function(r,n,e){"use strict";function t(r,n){return n>r}n.__esModule=!0,n["default"]=t,t.SYMBOL=n.SYMBOL="<"},function(r,n,e){"use strict";function t(r,n){return n>=r}n.__esModule=!0,n["default"]=t,t.SYMBOL=n.SYMBOL="<="},function(r,n,e){"use strict";function t(r){for(var n=arguments.length,e=Array(n>1?n-1:0),t=1;n>t;t++)e[t-1]=arguments[t];var o=e.reduce(function(r,n){return r-(0,a.toNumber)(n)},(0,a.toNumber)(r));if(isNaN(o))throw Error(u.ERROR_VALUE);return o}n.__esModule=!0,n.SYMBOL=undefined,n["default"]=t;var a=e(3),u=e(2);t.SYMBOL=n.SYMBOL="-"},function(r,n,e){"use strict";function t(r){for(var n=arguments.length,e=Array(n>1?n-1:0),t=1;n>t;t++)e[t-1]=arguments[t];var o=e.reduce(function(r,n){return r*(0,a.toNumber)(n)},(0,a.toNumber)(r));if(isNaN(o))throw Error(u.ERROR_VALUE);return o}n.__esModule=!0,n.SYMBOL=undefined,n["default"]=t;var a=e(3),u=e(2);t.SYMBOL=n.SYMBOL="*"},function(r,n,e){"use strict";function t(r,n){return r!==n}n.__esModule=!0,n["default"]=t,t.SYMBOL=n.SYMBOL="<>"},function(r,n,e){"use strict";function t(r,n){var e=Math.pow((0,a.toNumber)(r),(0,a.toNumber)(n));if(isNaN(e))throw Error(u.ERROR_VALUE);return e}n.__esModule=!0,n.SYMBOL=undefined,n["default"]=t;var a=e(3),u=e(2);t.SYMBOL=n.SYMBOL="^"},function(r,n,e){var t=function(){function r(){this.yy={}}var n=function(r,n,e,t){for(e=e||{},t=r.length;t--;e[r[t]]=n);return e},e=[1,5],t=[1,8],a=[1,6],u=[1,7],o=[1,9],i=[1,14],f=[1,15],s=[1,16],l=[1,12],c=[1,13],h=[1,17],p=[1,19],m=[1,20],E=[1,21],N=[1,22],v=[1,23],g=[1,24],I=[1,25],d=[1,26],b=[1,27],M=[1,28],y=[5,9,10,11,13,14,15,16,17,18,19,20,29,30],A=[5,9,10,11,13,14,15,16,17,18,19,20,29,30,32],R=[5,9,10,11,13,14,15,16,17,18,19,20,29,30,34],T=[5,10,11,13,14,15,16,17,29,30],O=[5,10,13,14,15,16,29,30],S=[5,10,11,13,14,15,16,17,18,19,29,30],L=[13,29,30],C={trace:function(){},yy:{},symbols_:{error:2,expressions:3,expression:4,EOF:5,variableSequence:6,number:7,STRING:8,"&":9,"=":10,"+":11,"(":12,")":13,"<":14,">":15,NOT:16,"-":17,"*":18,"/":19,"^":20,FUNCTION:21,expseq:22,cell:23,ABSOLUTE_CELL:24,RELATIVE_CELL:25,MIXED_CELL:26,":":27,ARRAY:28,";":29,",":30,VARIABLE:31,DECIMAL:32,NUMBER:33,"%":34,ERROR:35,$accept:0,$end:1},terminals_:{5:"EOF",8:"STRING",9:"&",10:"=",11:"+",12:"(",13:")",14:"<",15:">",16:"NOT",17:"-",18:"*",19:"/",20:"^",21:"FUNCTION",24:"ABSOLUTE_CELL",25:"RELATIVE_CELL",26:"MIXED_CELL",27:":",28:"ARRAY",29:";",30:",",31:"VARIABLE",32:"DECIMAL",33:"NUMBER",34:"%",35:"ERROR"},productions_:[0,[3,2],[4,1],[4,1],[4,1],[4,3],[4,3],[4,3],[4,3],[4,4],[4,4],[4,4],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,2],[4,2],[4,3],[4,4],[4,1],[4,1],[4,2],[23,1],[23,1],[23,1],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[23,3],[22,1],[22,1],[22,3],[22,3],[6,1],[6,3],[7,1],[7,3],[7,2],[2,1]],performAction:function(r,n,e,t,a,u,o){var i=u.length-1;switch(a){case 1:return u[i-1];case 2:this.$=t.callVariable(u[i][0]);break;case 3:this.$=t.toNumber(u[i]);break;case 4:this.$=t.trimEdges(u[i]);break;case 5:this.$=t.evaluateByOperator("&",[u[i-2],u[i]]);break;case 6:this.$=t.evaluateByOperator("=",[u[i-2],u[i]]);break;case 7:this.$=t.evaluateByOperator("+",[u[i-2],u[i]]);break;case 8:this.$=u[i-1];break;case 9:this.$=t.evaluateByOperator("<=",[u[i-3],u[i]]);break;case 10:this.$=t.evaluateByOperator(">=",[u[i-3],u[i]]);break;case 11:this.$=t.evaluateByOperator("<>",[u[i-3],u[i]]);break;case 12:this.$=t.evaluateByOperator("NOT",[u[i-2],u[i]]);break;case 13:this.$=t.evaluateByOperator(">",[u[i-2],u[i]]);break;case 14:this.$=t.evaluateByOperator("<",[u[i-2],u[i]]);break;case 15:this.$=t.evaluateByOperator("-",[u[i-2],u[i]]);break;case 16:this.$=t.evaluateByOperator("*",[u[i-2],u[i]]);break;case 17:this.$=t.evaluateByOperator("/",[u[i-2],u[i]]);break;case 18:this.$=t.evaluateByOperator("^",[u[i-2],u[i]]);break;case 19:var f=t.invertNumber(u[i]);this.$=f,isNaN(this.$)&&(this.$=0);break;case 20:var f=t.toNumber(u[i]);this.$=f,isNaN(this.$)&&(this.$=0);break;case 21:this.$=t.callFunction(u[i-2]);break;case 22:this.$=t.callFunction(u[i-3],u[i-1]);break;case 26:case 27:case 28:this.$=t.cellValue(u[i]);break;case 29:case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:this.$=t.rangeValue(u[i-2],u[i]);break;case 38:case 42:this.$=[u[i]];break;case 39:this.$=t.trimEdges(r).split(",");break;case 40:case 41:u[i-2].push(u[i]),this.$=u[i-2];break;case 43:this.$=Array.isArray(u[i-2])?u[i-2]:[u[i-2]],this.$.push(u[i]);break;case 44:this.$=u[i];break;case 45:this.$=1*(u[i-2]+"."+u[i]);break;case 46:this.$=.01*u[i-1];break;case 47:this.$=t.throwError(u[i])}},table:[{2:11,3:1,4:2,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{1:[3]},{5:[1,18],9:p,10:m,11:E,14:N,15:v,16:g,17:I,18:d,19:b,20:M},n(y,[2,2],{32:[1,29]}),n(y,[2,3],{34:[1,30]}),n(y,[2,4]),{2:11,4:31,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:32,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:33,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{12:[1,34]},n(y,[2,23]),n(y,[2,24],{2:35,35:h}),n(A,[2,42]),n(R,[2,44],{32:[1,36]}),n(y,[2,26],{27:[1,37]}),n(y,[2,27],{27:[1,38]}),n(y,[2,28],{27:[1,39]}),n([5,9,10,11,13,14,15,16,17,18,19,20,29,30,35],[2,47]),{1:[2,1]},{2:11,4:40,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:41,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:42,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:45,6:3,7:4,8:e,10:[1,43],11:t,12:a,15:[1,44],17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:47,6:3,7:4,8:e,10:[1,46],11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:48,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:49,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:50,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:51,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:52,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{31:[1,53]},n(R,[2,46]),{9:p,10:m,11:E,13:[1,54],14:N,15:v,16:g,17:I,18:d,19:b,20:M},n(T,[2,19],{9:p,18:d,19:b,20:M}),n(T,[2,20],{9:p,18:d,19:b,20:M}),{2:11,4:57,6:3,7:4,8:e,11:t,12:a,13:[1,55],17:u,21:o,22:56,23:10,24:i,25:f,26:s,28:[1,58],31:l,33:c,35:h},n(y,[2,25]),{33:[1,59]},{24:[1,60],25:[1,61],26:[1,62]},{24:[1,63],25:[1,64],26:[1,65]},{24:[1,66],25:[1,67],26:[1,68]},n(y,[2,5]),n([5,10,13,29,30],[2,6],{9:p,11:E,14:N,15:v,16:g,17:I,18:d,19:b,20:M}),n(T,[2,7],{9:p,18:d,19:b,20:M}),{2:11,4:69,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:70,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},n(O,[2,14],{9:p,11:E,17:I,18:d,19:b,20:M}),{2:11,4:71,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},n(O,[2,13],{9:p,11:E,17:I,18:d,19:b,20:M}),n([5,10,13,16,29,30],[2,12],{9:p,11:E,14:N,15:v,17:I,18:d,19:b,20:M}),n(T,[2,15],{9:p,18:d,19:b,20:M}),n(S,[2,16],{9:p,20:M}),n(S,[2,17],{9:p,20:M}),n([5,10,11,13,14,15,16,17,18,19,20,29,30],[2,18],{9:p}),n(A,[2,43]),n(y,[2,8]),n(y,[2,21]),{13:[1,72],29:[1,73],30:[1,74]},n(L,[2,38],{9:p,10:m,11:E,14:N,15:v,16:g,17:I,18:d,19:b,20:M}),n(L,[2,39]),n(R,[2,45]),n(y,[2,29]),n(y,[2,30]),n(y,[2,31]),n(y,[2,32]),n(y,[2,33]),n(y,[2,34]),n(y,[2,35]),n(y,[2,36]),n(y,[2,37]),n(O,[2,9],{9:p,11:E,17:I,18:d,19:b,20:M}),n(O,[2,11],{9:p,11:E,17:I,18:d,19:b,20:M}),n(O,[2,10],{9:p,11:E,17:I,18:d,19:b,20:M}),n(y,[2,22]),{2:11,4:75,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},{2:11,4:76,6:3,7:4,8:e,11:t,12:a,17:u,21:o,23:10,24:i,25:f,26:s,31:l,33:c,35:h},n(L,[2,40],{9:p,10:m,11:E,14:N,15:v,16:g,17:I,18:d,19:b,20:M}),n(L,[2,41],{9:p,10:m,11:E,14:N,15:v,16:g,17:I,18:d,19:b,20:M})],defaultActions:{18:[2,1]},parseError:function(r,n){if(!n.recoverable){var e=Error(r);throw e.hash=n,e}this.trace(r)},parse:function(r){function n(r){for(var n=t.length-1,e=0;;){if(""+c in o[r])return e;if(0===r||2>n)return!1;n-=2,r=t[n],++e}}var e=this,t=[0],a=[null],u=[],o=this.table,i="",f=0,s=0,l=0,c=2,h=u.slice.call(arguments,1),p=Object.create(this.lexer),m={yy:{}};for(var E in this.yy)Object.prototype.hasOwnProperty.call(this.yy,E)&&(m.yy[E]=this.yy[E]);p.setInput(r,m.yy),m.yy.lexer=p,m.yy.parser=this,"undefined"==typeof p.yylloc&&(p.yylloc={});var N=p.yylloc;u.push(N);var v=p.options&&p.options.ranges;this.parseError="function"==typeof m.yy.parseError?m.yy.parseError:Object.getPrototypeOf(this).parseError;for(var g,I,d,b,M,y,A,R,T,O=function(){var r;return r=p.lex()||1,"number"!=typeof r&&(r=e.symbols_[r]||r),r},S={};;){if(d=t[t.length-1],this.defaultActions[d]?b=this.defaultActions[d]:(null!==g&&void 0!==g||(g=O()),b=o[d]&&o[d][g]),void 0===b||!b.length||!b[0]){var L,C="";if(l)1!==I&&(L=n(d));else{L=n(d),T=[];for(y in o[d])this.terminals_[y]&&y>c&&T.push("'"+this.terminals_[y]+"'");C=p.showPosition?"Parse error on line "+(f+1)+":\n"+p.showPosition()+"\nExpecting "+T.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(f+1)+": Unexpected "+(1==g?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(C,{text:p.match,token:this.terminals_[g]||g,line:p.yylineno,loc:N,expected:T,recoverable:!1!==L})}if(3==l){if(1===g||1===I)throw Error(C||"Parsing halted while starting to recover from another error.");s=p.yyleng,i=p.yytext,f=p.yylineno,N=p.yylloc,g=O()}if(!1===L)throw Error(C||"Parsing halted. No suitable error recovery rule available.");!function(r){t.length=t.length-2*r,a.length=a.length-r,u.length=u.length-r}(L),I=g==c?null:g,g=c,d=t[t.length-1],b=o[d]&&o[d][c],l=3}if(b[0]instanceof Array&&b.length>1)throw Error("Parse Error: multiple actions possible at state: "+d+", token: "+g);switch(b[0]){case 1:t.push(g),a.push(p.yytext),u.push(p.yylloc),t.push(b[1]),g=null,I?(g=I,I=null):(s=p.yyleng,i=p.yytext,f=p.yylineno,N=p.yylloc,l>0&&l--);break;case 2:if(A=this.productions_[b[1]][1],S.$=a[a.length-A],S._$={first_line:u[u.length-(A||1)].first_line,last_line:u[u.length-1].last_line,first_column:u[u.length-(A||1)].first_column,last_column:u[u.length-1].last_column},v&&(S._$.range=[u[u.length-(A||1)].range[0],u[u.length-1].range[1]]),void 0!==(M=this.performAction.apply(S,[i,s,f,m.yy,b[1],a,u].concat(h))))return M;A&&(t=t.slice(0,-1*A*2),a=a.slice(0,-1*A),u=u.slice(0,-1*A)),t.push(this.productions_[b[1]][0]),a.push(S.$),u.push(S._$),R=o[t[t.length-2]][t[t.length-1]],t.push(R);break;case 3:return!0}}return!0}};return C.lexer=function(){return{EOF:1,parseError:function(r,n){if(!this.yy.parser)throw Error(r);this.yy.parser.parseError(r,n)},setInput:function(r,n){return this.yy=n||this.yy||{},this._input=r,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var r=this._input[0];return this.yytext+=r,this.yyleng++,this.offset++,this.match+=r,this.matched+=r,r.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),r},unput:function(r){var n=r.length,e=r.split(/(?:\r\n?|\n)/g);this._input=r+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var t=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),e.length-1&&(this.yylineno-=e.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:e?(e.length===t.length?this.yylloc.first_column:0)+t[t.length-e.length].length-e[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(r){this.unput(this.match.slice(r))},pastInput:function(){var r=this.matched.substr(0,this.matched.length-this.match.length);return(r.length>20?"...":"")+r.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var r=this.match;return 20>r.length&&(r+=this._input.substr(0,20-r.length)),(r.substr(0,20)+(r.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var r=this.pastInput(),n=Array(r.length+1).join("-");return r+this.upcomingInput()+"\n"+n+"^"},test_match:function(r,n){var e,t,a;if(this.options.backtrack_lexer&&(a={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(a.yylloc.range=this.yylloc.range.slice(0))),t=r[0].match(/(?:\r\n?|\n).*/g),t&&(this.yylineno+=t.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:t?t[t.length-1].length-t[t.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+r[0].length},this.yytext+=r[0],this.match+=r[0],this.matches=r,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(r[0].length),this.matched+=r[0],e=this.performAction.call(this,this.yy,this,n,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),e)return e;if(this._backtrack){for(var u in a)this[u]=a[u];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var r,n,e,t;this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),u=0;a.length>u;u++)if((e=this._input.match(this.rules[a[u]]))&&(!n||e[0].length>n[0].length)){if(n=e,t=u,this.options.backtrack_lexer){if(!1!==(r=this.test_match(e,a[u])))return r;if(this._backtrack){n=!1;continue}return!1}if(!this.options.flex)break}return n?!1!==(r=this.test_match(n,a[t]))&&r:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var r=this.next();return r||this.lex()},begin:function(r){this.conditionStack.push(r)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(r){return r=this.conditionStack.length-1-Math.abs(r||0),0>r?"INITIAL":this.conditionStack[r]},pushState:function(r){this.begin(r)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(r,n,e,t){switch(e){case 0:break;case 1:case 2:return 8;case 3:return 21;case 4:return 35;case 5:return 24;case 6:case 7:return 26;case 8:return 25;case 9:return 21;case 10:case 11:return 31;case 12:return 33;case 13:return 28;case 14:return 9;case 15:return" ";case 16:return 32;case 17:return 27;case 18:return 29;case 19:return 30;case 20:return 18;case 21:return 19;case 22:return 17;case 23:return 11;case 24:return 20;case 25:return 12;case 26:return 13;case 27:return 15;case 28:return 14;case 29:return 16;case 30:return'"';case 31:return"'";case 32:return"!";case 33:return 10;case 34:return 34;case 35:return"#";case 36:return 5}},rules:[/^(?:\s+)/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9\.]+(?=[(]))/,/^(?:#[A-Z0-9\/]+(!|\?)?)/,/^(?:\$[A-Za-z]+\$[0-9]+)/,/^(?:\$[A-Za-z]+[0-9]+)/,/^(?:[A-Za-z]+\$[0-9]+)/,/^(?:[A-Za-z]+[0-9]+)/,/^(?:[A-Za-z\.]+(?=[(]))/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)/,/^(?:[A-Za-z_]+)/,/^(?:[0-9]+)/,/^(?:\[(.*)?\])/,/^(?:&)/,/^(?: )/,/^(?:[.])/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:\*)/,/^(?:\/)/,/^(?:-)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\))/,/^(?:>)/,/^(?:<)/,/^(?:NOT\b)/,/^(?:")/,/^(?:')/,/^(?:!)/,/^(?:=)/,/^(?:%)/,/^(?:[#])/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],inclusive:!0}}}}(),r.prototype=C,C.Parser=r,new r}();n.parser=t,n.Parser=t.Parser,n.parse=function(){return t.parse.apply(t,arguments)}},function(r,n,e){"use strict";function t(r){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;return r=r.substring(n,r.length-n)}n.__esModule=!0,n.trimEdges=t}])}); \ No newline at end of file diff --git a/package.json b/package.json index 40fe4ded..f831588a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hot-formula-parser", - "version": "3.0.0", + "version": "3.0.1", "description": "Formula parser", "browser": "dist/formula-parser.js", "main": "lib/index.js",