Created
January 25, 2017 18:59
-
-
Save mynameisfiber/2afe53e0738d56ca5916c21bcc9726b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[nltk_data] Downloading package brown to /home/micha/nltk_data...\n", | |
"[nltk_data] Package brown is already up-to-date!\n" | |
] | |
} | |
], | |
"source": [ | |
"from tqdm import tqdm_notebook as tqdm\n", | |
"import nltk\n", | |
"nltk.download('brown')\n", | |
"\n", | |
"from nltk.corpus import brown" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Widget Javascript not detected. It may not be installed properly. Did you enable the widgetsnbextension? If not, then run \"jupyter nbextension enable --py --sys-prefix widgetsnbextension\"\n" | |
] | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"with open(\"brown_ft_data.txt\", \"w+\") as fd:\n", | |
" for category in tqdm(brown.categories()):\n", | |
" for sentence in brown.sents(categories=[category]):\n", | |
" fd.write(\"__label__{} , {}\\n\".format(category, \" \".join(sentence)))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"models/brown_ft_data_ft\n", | |
"Training fasttext on brown_ft_data.txt corpus..\n", | |
"Read 1M words\n", | |
"Number of words: 56058\n", | |
"Number of labels: 15\n", | |
"Progress: 100.0% words/sec/thread: 923471 lr: 0.000000 loss: 0.530122 eta: 0h0m 171 loss: 0.593661 eta: 0h0m \n", | |
"CPU times: user 1.28 s, sys: 96 ms, total: 1.38 s\n", | |
"Wall time: 14 s\n", | |
"P@1: 0.965\n", | |
"R@1: 0.965\n", | |
"Number of examples: 57340\n", | |
"CPU times: user 60 ms, sys: 16 ms, total: 76 ms\n", | |
"Wall time: 2.69 s\n" | |
] | |
} | |
], | |
"source": [ | |
"import os\n", | |
"\n", | |
"FT_HOME = '/home/micha/work/fastText/'\n", | |
"MODELS_DIR = 'models/'\n", | |
"!mkdir -p {MODELS_DIR}\n", | |
"\n", | |
"lr = 0.1\n", | |
"dim = 100\n", | |
"ws = 10\n", | |
"epoch = 25\n", | |
"minCount = 1\n", | |
"neg = 5\n", | |
"loss = 'ns'\n", | |
"t = 1e-4\n", | |
"wordNgrams = 2\n", | |
"\n", | |
"def train_model(corpus_file, output_name):\n", | |
" output_file = '{:s}_ft'.format(output_name)\n", | |
" print(MODELS_DIR + output_file)\n", | |
" if not os.path.isfile(os.path.join(MODELS_DIR, '{:s}.vec'.format(output_file))):\n", | |
" print('Training fasttext on {:s} corpus..'.format(corpus_file))\n", | |
" %time !{FT_HOME}fasttext supervised -input {corpus_file} -output {MODELS_DIR+output_file} -lr {lr} -dim {dim} -ws {ws} -epoch {epoch} -minCount {minCount} -neg {neg} -loss {loss} -t {t} -wordNgrams {wordNgrams} -pretrainedVectors models/text9_ft.vec\n", | |
" else:\n", | |
" print('\\nUsing existing model file {:s}.vec'.format(output_file))\n", | |
" %time !{FT_HOME}fasttext test {MODELS_DIR+output_file}.bin {corpus_file}\n", | |
" \n", | |
"train_model(\"brown_ft_data.txt\", \"brown_ft_data\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 81, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"import tempfile\n", | |
"import subprocess\n", | |
"import numpy as np\n", | |
"\n", | |
"def predict_proba(sentences):\n", | |
" _, fname = tempfile.mkstemp()\n", | |
" with open(fname, 'w+') as fd:\n", | |
" for sent in sentences:\n", | |
" fd.write(\"{}\\n\".format(sent))\n", | |
" output = subprocess.check_output(\"{}fasttext predict-prob models/brown_ft_data_ft.bin {} {}\".format(FT_HOME, fname, len(brown.categories())).split(' '))\n", | |
" results = []\n", | |
" for result in output.decode('utf8').split('\\n'):\n", | |
" cur_result = {}\n", | |
" if not result:\n", | |
" continue\n", | |
" for line in result.strip(\"__label__\").split(\" __label__\"):\n", | |
" label, proba = line.split(\" \")\n", | |
" cur_result[label] = float(proba)\n", | |
" results.append([cur_result.get(c, 0) for c in brown.categories()])\n", | |
" return np.asarray(results)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 82, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"['adventure', 'belles_lettres', 'editorial', 'fiction', 'government', 'hobbies', 'humor', 'learned', 'lore', 'mystery', 'news', 'religion', 'reviews', 'romance', 'science_fiction']\n" | |
] | |
} | |
], | |
"source": [ | |
"from lime import lime_text\n", | |
"from lime.lime_text import LimeTextExplainer\n", | |
"class_names = brown.categories()\n", | |
"print(class_names)\n", | |
"explainer = LimeTextExplainer(class_names=class_names)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 100, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"even to clean men and boys .\n" | |
] | |
}, | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/home/micha/ssd/work/gensim/docs/notebooks/venv/lib/python3.5/re.py:203: FutureWarning: split() requires a non-empty pattern match.\n", | |
" return _compile(pattern, flags).split(string, maxsplit)\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<html>\n", | |
" <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF8\">\n", | |
" <head><script>var lime =\n", | |
"/******/ (function(modules) { // webpackBootstrap\n", | |
"/******/ \t// The module cache\n", | |
"/******/ \tvar installedModules = {};\n", | |
"/******/\n", | |
"/******/ \t// The require function\n", | |
"/******/ \tfunction __webpack_require__(moduleId) {\n", | |
"/******/\n", | |
"/******/ \t\t// Check if module is in cache\n", | |
"/******/ \t\tif(installedModules[moduleId])\n", | |
"/******/ \t\t\treturn installedModules[moduleId].exports;\n", | |
"/******/\n", | |
"/******/ \t\t// Create a new module (and put it into the cache)\n", | |
"/******/ \t\tvar module = installedModules[moduleId] = {\n", | |
"/******/ \t\t\texports: {},\n", | |
"/******/ \t\t\tid: moduleId,\n", | |
"/******/ \t\t\tloaded: false\n", | |
"/******/ \t\t};\n", | |
"/******/\n", | |
"/******/ \t\t// Execute the module function\n", | |
"/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n", | |
"/******/\n", | |
"/******/ \t\t// Flag the module as loaded\n", | |
"/******/ \t\tmodule.loaded = true;\n", | |
"/******/\n", | |
"/******/ \t\t// Return the exports of the module\n", | |
"/******/ \t\treturn module.exports;\n", | |
"/******/ \t}\n", | |
"/******/\n", | |
"/******/\n", | |
"/******/ \t// expose the modules object (__webpack_modules__)\n", | |
"/******/ \t__webpack_require__.m = modules;\n", | |
"/******/\n", | |
"/******/ \t// expose the module cache\n", | |
"/******/ \t__webpack_require__.c = installedModules;\n", | |
"/******/\n", | |
"/******/ \t// __webpack_public_path__\n", | |
"/******/ \t__webpack_require__.p = \"\";\n", | |
"/******/\n", | |
"/******/ \t// Load entry module and return exports\n", | |
"/******/ \treturn __webpack_require__(0);\n", | |
"/******/ })\n", | |
"/************************************************************************/\n", | |
"/******/ ([\n", | |
"/* 0 */\n", | |
"/***/ function(module, exports, __webpack_require__) {\n", | |
"\n", | |
"\t'use strict';\n", | |
"\t\n", | |
"\tObject.defineProperty(exports, \"__esModule\", {\n", | |
"\t value: true\n", | |
"\t});\n", | |
"\texports.PredictProba = exports.Barchart = exports.Explanation = undefined;\n", | |
"\t\n", | |
"\tvar _explanation = __webpack_require__(1);\n", | |
"\t\n", | |
"\tvar _explanation2 = _interopRequireDefault(_explanation);\n", | |
"\t\n", | |
"\tvar _bar_chart = __webpack_require__(3);\n", | |
"\t\n", | |
"\tvar _bar_chart2 = _interopRequireDefault(_bar_chart);\n", | |
"\t\n", | |
"\tvar _predict_proba = __webpack_require__(6);\n", | |
"\t\n", | |
"\tvar _predict_proba2 = _interopRequireDefault(_predict_proba);\n", | |
"\t\n", | |
"\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n", | |
"\t\n", | |
"\t__webpack_require__(7);\n", | |
"\texports.Explanation = _explanation2.default;\n", | |
"\texports.Barchart = _bar_chart2.default;\n", | |
"\texports.PredictProba = _predict_proba2.default;\n", | |
"\n", | |
"/***/ },\n", | |
"/* 1 */\n", | |
"/***/ function(module, exports, __webpack_require__) {\n", | |
"\n", | |
"\t'use strict';\n", | |
"\t\n", | |
"\tObject.defineProperty(exports, \"__esModule\", {\n", | |
"\t value: true\n", | |
"\t});\n", | |
"\t\n", | |
"\tvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n", | |
"\t\n", | |
"\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n", | |
"\t\n", | |
"\tvar _d2 = __webpack_require__(2);\n", | |
"\t\n", | |
"\tvar _d3 = _interopRequireDefault(_d2);\n", | |
"\t\n", | |
"\tvar _bar_chart = __webpack_require__(3);\n", | |
"\t\n", | |
"\tvar _bar_chart2 = _interopRequireDefault(_bar_chart);\n", | |
"\t\n", | |
"\tvar _lodash = __webpack_require__(4);\n", | |
"\t\n", | |
"\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n", | |
"\t\n", | |
"\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n", | |
"\t\n", | |
"\tvar Explanation = function () {\n", | |
"\t function Explanation(class_names) {\n", | |
"\t _classCallCheck(this, Explanation);\n", | |
"\t\n", | |
"\t this.names = class_names;\n", | |
"\t if (class_names.length < 10) {\n", | |
"\t this.colors = _d3.default.scale.category10().domain(this.names);\n", | |
"\t this.colors_i = _d3.default.scale.category10().domain((0, _lodash.range)(this.names.length));\n", | |
"\t } else {\n", | |
"\t this.colors = _d3.default.scale.category20().domain(this.names);\n", | |
"\t this.colors_i = _d3.default.scale.category20().domain((0, _lodash.range)(this.names.length));\n", | |
"\t }\n", | |
"\t }\n", | |
"\t // exp: [(feature-name, weight), ...]\n", | |
"\t // label: int\n", | |
"\t // div: d3 selection\n", | |
"\t\n", | |
"\t\n", | |
"\t _createClass(Explanation, [{\n", | |
"\t key: 'show',\n", | |
"\t value: function show(exp, label, div) {\n", | |
"\t var svg = div.append('svg').style('width', '100%');\n", | |
"\t var colors = ['#5F9EA0', this.colors_i(label)];\n", | |
"\t var names = ['NOT ' + this.names[label], this.names[label]];\n", | |
"\t if (this.names.length == 2) {\n", | |
"\t colors = [this.colors_i(0), this.colors_i(1)];\n", | |
"\t names = this.names;\n", | |
"\t }\n", | |
"\t var plot = new _bar_chart2.default(svg, exp, true, names, colors, true, 10);\n", | |
"\t svg.style('height', plot.svg_height);\n", | |
"\t }\n", | |
"\t // exp has all ocurrences of words, with start index and weight:\n", | |
"\t // exp = [('word', 132, -0.13), ('word3', 111, 1.3)\n", | |
"\t\n", | |
"\t }, {\n", | |
"\t key: 'show_raw_text',\n", | |
"\t value: function show_raw_text(exp, label, raw, div) {\n", | |
"\t var opacity = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;\n", | |
"\t\n", | |
"\t //let colors=['#5F9EA0', this.colors(this.exp['class'])];\n", | |
"\t var colors = ['#5F9EA0', this.colors_i(label)];\n", | |
"\t if (this.names.length == 2) {\n", | |
"\t colors = [this.colors_i(0), this.colors_i(1)];\n", | |
"\t }\n", | |
"\t var word_lists = [[], []];\n", | |
"\t var max_weight = -1;\n", | |
"\t var _iteratorNormalCompletion = true;\n", | |
"\t var _didIteratorError = false;\n", | |
"\t var _iteratorError = undefined;\n", | |
"\t\n", | |
"\t try {\n", | |
"\t for (var _iterator = exp[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n", | |
"\t var _step$value = _slicedToArray(_step.value, 3),\n", | |
"\t word = _step$value[0],\n", | |
"\t start = _step$value[1],\n", | |
"\t weight = _step$value[2];\n", | |
"\t\n", | |
"\t if (weight > 0) {\n", | |
"\t word_lists[1].push([start, start + word.length, weight]);\n", | |
"\t } else {\n", | |
"\t word_lists[0].push([start, start + word.length, -weight]);\n", | |
"\t }\n", | |
"\t max_weight = Math.max(max_weight, Math.abs(weight));\n", | |
"\t }\n", | |
"\t } catch (err) {\n", | |
"\t _didIteratorError = true;\n", | |
"\t _iteratorError = err;\n", | |
"\t } finally {\n", | |
"\t try {\n", | |
"\t if (!_iteratorNormalCompletion && _iterator.return) {\n", | |
"\t _iterator.return();\n", | |
"\t }\n", | |
"\t } finally {\n", | |
"\t if (_didIteratorError) {\n", | |
"\t throw _iteratorError;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t if (!opacity) {\n", | |
"\t max_weight = 0;\n", | |
"\t }\n", | |
"\t this.display_raw_text(div, raw, word_lists, colors, max_weight, true);\n", | |
"\t }\n", | |
"\t // exp is list of (feature_name, value, weight)\n", | |
"\t\n", | |
"\t }, {\n", | |
"\t key: 'show_raw_tabular',\n", | |
"\t value: function show_raw_tabular(exp, label, div) {\n", | |
"\t div.classed('lime', true).classed('table_div', true);\n", | |
"\t var colors = ['#5F9EA0', this.colors_i(label)];\n", | |
"\t if (this.names.length == 2) {\n", | |
"\t colors = [this.colors_i(0), this.colors_i(1)];\n", | |
"\t }\n", | |
"\t var table = div.append('table');\n", | |
"\t var thead = table.append('tr');\n", | |
"\t thead.append('td').text('Feature');\n", | |
"\t thead.append('td').text('Value');\n", | |
"\t thead.style('color', 'black').style('font-size', '20px');\n", | |
"\t var _iteratorNormalCompletion2 = true;\n", | |
"\t var _didIteratorError2 = false;\n", | |
"\t var _iteratorError2 = undefined;\n", | |
"\t\n", | |
"\t try {\n", | |
"\t for (var _iterator2 = exp[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n", | |
"\t var _step2$value = _slicedToArray(_step2.value, 3),\n", | |
"\t fname = _step2$value[0],\n", | |
"\t value = _step2$value[1],\n", | |
"\t weight = _step2$value[2];\n", | |
"\t\n", | |
"\t var tr = table.append('tr');\n", | |
"\t tr.style('border-style', 'hidden');\n", | |
"\t tr.append('td').text(fname);\n", | |
"\t tr.append('td').text(value);\n", | |
"\t if (weight > 0) {\n", | |
"\t tr.style('background-color', colors[1]);\n", | |
"\t } else if (weight < 0) {\n", | |
"\t tr.style('background-color', colors[0]);\n", | |
"\t } else {\n", | |
"\t tr.style('color', 'black');\n", | |
"\t }\n", | |
"\t }\n", | |
"\t } catch (err) {\n", | |
"\t _didIteratorError2 = true;\n", | |
"\t _iteratorError2 = err;\n", | |
"\t } finally {\n", | |
"\t try {\n", | |
"\t if (!_iteratorNormalCompletion2 && _iterator2.return) {\n", | |
"\t _iterator2.return();\n", | |
"\t }\n", | |
"\t } finally {\n", | |
"\t if (_didIteratorError2) {\n", | |
"\t throw _iteratorError2;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }, {\n", | |
"\t key: 'hexToRgb',\n", | |
"\t value: function hexToRgb(hex) {\n", | |
"\t var result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n", | |
"\t return result ? {\n", | |
"\t r: parseInt(result[1], 16),\n", | |
"\t g: parseInt(result[2], 16),\n", | |
"\t b: parseInt(result[3], 16)\n", | |
"\t } : null;\n", | |
"\t }\n", | |
"\t }, {\n", | |
"\t key: 'applyAlpha',\n", | |
"\t value: function applyAlpha(hex, alpha) {\n", | |
"\t var components = this.hexToRgb(hex);\n", | |
"\t return 'rgba(' + components.r + \",\" + components.g + \",\" + components.b + \",\" + alpha.toFixed(3) + \")\";\n", | |
"\t }\n", | |
"\t // sord_lists is an array of arrays, of length (colors). if with_positions is true,\n", | |
"\t // word_lists is an array of [start,end] positions instead\n", | |
"\t\n", | |
"\t }, {\n", | |
"\t key: 'display_raw_text',\n", | |
"\t value: function display_raw_text(div, raw_text) {\n", | |
"\t var word_lists = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n", | |
"\t var colors = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];\n", | |
"\t var max_weight = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;\n", | |
"\t var positions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;\n", | |
"\t\n", | |
"\t div.classed('lime', true).classed('text_div', true);\n", | |
"\t div.append('h3').text('Text with highlighted words');\n", | |
"\t var highlight_tag = 'span';\n", | |
"\t var text_span = div.append('span').style('white-space', 'pre-wrap').text(raw_text);\n", | |
"\t var position_lists = word_lists;\n", | |
"\t if (!positions) {\n", | |
"\t position_lists = this.wordlists_to_positions(word_lists, raw_text);\n", | |
"\t }\n", | |
"\t var objects = [];\n", | |
"\t var _iteratorNormalCompletion3 = true;\n", | |
"\t var _didIteratorError3 = false;\n", | |
"\t var _iteratorError3 = undefined;\n", | |
"\t\n", | |
"\t try {\n", | |
"\t var _loop = function _loop() {\n", | |
"\t var i = _step3.value;\n", | |
"\t\n", | |
"\t position_lists[i].map(function (x) {\n", | |
"\t return objects.push({ 'label': i, 'start': x[0], 'end': x[1], 'alpha': max_weight === 0 ? 1 : x[2] / max_weight });\n", | |
"\t });\n", | |
"\t };\n", | |
"\t\n", | |
"\t for (var _iterator3 = (0, _lodash.range)(position_lists.length)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n", | |
"\t _loop();\n", | |
"\t }\n", | |
"\t } catch (err) {\n", | |
"\t _didIteratorError3 = true;\n", | |
"\t _iteratorError3 = err;\n", | |
"\t } finally {\n", | |
"\t try {\n", | |
"\t if (!_iteratorNormalCompletion3 && _iterator3.return) {\n", | |
"\t _iterator3.return();\n", | |
"\t }\n", | |
"\t } finally {\n", | |
"\t if (_didIteratorError3) {\n", | |
"\t throw _iteratorError3;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t objects = (0, _lodash.sortBy)(objects, function (x) {\n", | |
"\t return x['start'];\n", | |
"\t });\n", | |
"\t var node = text_span.node().childNodes[0];\n", | |
"\t var subtract = 0;\n", | |
"\t var _iteratorNormalCompletion4 = true;\n", | |
"\t var _didIteratorError4 = false;\n", | |
"\t var _iteratorError4 = undefined;\n", | |
"\t\n", | |
"\t try {\n", | |
"\t for (var _iterator4 = objects[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n", | |
"\t var obj = _step4.value;\n", | |
"\t\n", | |
"\t var word = raw_text.slice(obj.start, obj.end);\n", | |
"\t var start = obj.start - subtract;\n", | |
"\t var end = obj.end - subtract;\n", | |
"\t var match = document.createElement(highlight_tag);\n", | |
"\t match.appendChild(document.createTextNode(word));\n", | |
"\t match.style.backgroundColor = this.applyAlpha(colors[obj.label], obj.alpha);\n", | |
"\t var after = node.splitText(start);\n", | |
"\t after.nodeValue = after.nodeValue.substring(word.length);\n", | |
"\t node.parentNode.insertBefore(match, after);\n", | |
"\t subtract += end;\n", | |
"\t node = after;\n", | |
"\t }\n", | |
"\t } catch (err) {\n", | |
"\t _didIteratorError4 = true;\n", | |
"\t _iteratorError4 = err;\n", | |
"\t } finally {\n", | |
"\t try {\n", | |
"\t if (!_iteratorNormalCompletion4 && _iterator4.return) {\n", | |
"\t _iterator4.return();\n", | |
"\t }\n", | |
"\t } finally {\n", | |
"\t if (_didIteratorError4) {\n", | |
"\t throw _iteratorError4;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }, {\n", | |
"\t key: 'wordlists_to_positions',\n", | |
"\t value: function wordlists_to_positions(word_lists, raw_text) {\n", | |
"\t var ret = [];\n", | |
"\t var _iteratorNormalCompletion5 = true;\n", | |
"\t var _didIteratorError5 = false;\n", | |
"\t var _iteratorError5 = undefined;\n", | |
"\t\n", | |
"\t try {\n", | |
"\t for (var _iterator5 = word_lists[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n", | |
"\t var words = _step5.value;\n", | |
"\t\n", | |
"\t if (words.length === 0) {\n", | |
"\t ret.push([]);\n", | |
"\t continue;\n", | |
"\t }\n", | |
"\t var re = new RegExp(\"\\\\b(\" + words.join('|') + \")\\\\b\", 'gm');\n", | |
"\t var temp = void 0;\n", | |
"\t var list = [];\n", | |
"\t while ((temp = re.exec(raw_text)) !== null) {\n", | |
"\t list.push([temp.index, temp.index + temp[0].length]);\n", | |
"\t }\n", | |
"\t ret.push(list);\n", | |
"\t }\n", | |
"\t } catch (err) {\n", | |
"\t _didIteratorError5 = true;\n", | |
"\t _iteratorError5 = err;\n", | |
"\t } finally {\n", | |
"\t try {\n", | |
"\t if (!_iteratorNormalCompletion5 && _iterator5.return) {\n", | |
"\t _iterator5.return();\n", | |
"\t }\n", | |
"\t } finally {\n", | |
"\t if (_didIteratorError5) {\n", | |
"\t throw _iteratorError5;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t return ret;\n", | |
"\t }\n", | |
"\t }]);\n", | |
"\t\n", | |
"\t return Explanation;\n", | |
"\t}();\n", | |
"\t\n", | |
"\texports.default = Explanation;\n", | |
"\n", | |
"/***/ },\n", | |
"/* 2 */\n", | |
"/***/ function(module, exports, __webpack_require__) {\n", | |
"\n", | |
"\tvar __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;!function() {\n", | |
"\t var d3 = {\n", | |
"\t version: \"3.5.17\"\n", | |
"\t };\n", | |
"\t var d3_arraySlice = [].slice, d3_array = function(list) {\n", | |
"\t return d3_arraySlice.call(list);\n", | |
"\t };\n", | |
"\t var d3_document = this.document;\n", | |
"\t function d3_documentElement(node) {\n", | |
"\t return node && (node.ownerDocument || node.document || node).documentElement;\n", | |
"\t }\n", | |
"\t function d3_window(node) {\n", | |
"\t return node && (node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView);\n", | |
"\t }\n", | |
"\t if (d3_document) {\n", | |
"\t try {\n", | |
"\t d3_array(d3_document.documentElement.childNodes)[0].nodeType;\n", | |
"\t } catch (e) {\n", | |
"\t d3_array = function(list) {\n", | |
"\t var i = list.length, array = new Array(i);\n", | |
"\t while (i--) array[i] = list[i];\n", | |
"\t return array;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (!Date.now) Date.now = function() {\n", | |
"\t return +new Date();\n", | |
"\t };\n", | |
"\t if (d3_document) {\n", | |
"\t try {\n", | |
"\t d3_document.createElement(\"DIV\").style.setProperty(\"opacity\", 0, \"\");\n", | |
"\t } catch (error) {\n", | |
"\t var d3_element_prototype = this.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, d3_style_prototype = this.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;\n", | |
"\t d3_element_prototype.setAttribute = function(name, value) {\n", | |
"\t d3_element_setAttribute.call(this, name, value + \"\");\n", | |
"\t };\n", | |
"\t d3_element_prototype.setAttributeNS = function(space, local, value) {\n", | |
"\t d3_element_setAttributeNS.call(this, space, local, value + \"\");\n", | |
"\t };\n", | |
"\t d3_style_prototype.setProperty = function(name, value, priority) {\n", | |
"\t d3_style_setProperty.call(this, name, value + \"\", priority);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3.ascending = d3_ascending;\n", | |
"\t function d3_ascending(a, b) {\n", | |
"\t return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;\n", | |
"\t }\n", | |
"\t d3.descending = function(a, b) {\n", | |
"\t return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;\n", | |
"\t };\n", | |
"\t d3.min = function(array, f) {\n", | |
"\t var i = -1, n = array.length, a, b;\n", | |
"\t if (arguments.length === 1) {\n", | |
"\t while (++i < n) if ((b = array[i]) != null && b >= b) {\n", | |
"\t a = b;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t while (++i < n) if ((b = array[i]) != null && a > b) a = b;\n", | |
"\t } else {\n", | |
"\t while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n", | |
"\t a = b;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;\n", | |
"\t }\n", | |
"\t return a;\n", | |
"\t };\n", | |
"\t d3.max = function(array, f) {\n", | |
"\t var i = -1, n = array.length, a, b;\n", | |
"\t if (arguments.length === 1) {\n", | |
"\t while (++i < n) if ((b = array[i]) != null && b >= b) {\n", | |
"\t a = b;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t while (++i < n) if ((b = array[i]) != null && b > a) a = b;\n", | |
"\t } else {\n", | |
"\t while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n", | |
"\t a = b;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;\n", | |
"\t }\n", | |
"\t return a;\n", | |
"\t };\n", | |
"\t d3.extent = function(array, f) {\n", | |
"\t var i = -1, n = array.length, a, b, c;\n", | |
"\t if (arguments.length === 1) {\n", | |
"\t while (++i < n) if ((b = array[i]) != null && b >= b) {\n", | |
"\t a = c = b;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t while (++i < n) if ((b = array[i]) != null) {\n", | |
"\t if (a > b) a = b;\n", | |
"\t if (c < b) c = b;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n", | |
"\t a = c = b;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t while (++i < n) if ((b = f.call(array, array[i], i)) != null) {\n", | |
"\t if (a > b) a = b;\n", | |
"\t if (c < b) c = b;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return [ a, c ];\n", | |
"\t };\n", | |
"\t function d3_number(x) {\n", | |
"\t return x === null ? NaN : +x;\n", | |
"\t }\n", | |
"\t function d3_numeric(x) {\n", | |
"\t return !isNaN(x);\n", | |
"\t }\n", | |
"\t d3.sum = function(array, f) {\n", | |
"\t var s = 0, n = array.length, a, i = -1;\n", | |
"\t if (arguments.length === 1) {\n", | |
"\t while (++i < n) if (d3_numeric(a = +array[i])) s += a;\n", | |
"\t } else {\n", | |
"\t while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a;\n", | |
"\t }\n", | |
"\t return s;\n", | |
"\t };\n", | |
"\t d3.mean = function(array, f) {\n", | |
"\t var s = 0, n = array.length, a, i = -1, j = n;\n", | |
"\t if (arguments.length === 1) {\n", | |
"\t while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j;\n", | |
"\t } else {\n", | |
"\t while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j;\n", | |
"\t }\n", | |
"\t if (j) return s / j;\n", | |
"\t };\n", | |
"\t d3.quantile = function(values, p) {\n", | |
"\t var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;\n", | |
"\t return e ? v + e * (values[h] - v) : v;\n", | |
"\t };\n", | |
"\t d3.median = function(array, f) {\n", | |
"\t var numbers = [], n = array.length, a, i = -1;\n", | |
"\t if (arguments.length === 1) {\n", | |
"\t while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a);\n", | |
"\t } else {\n", | |
"\t while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a);\n", | |
"\t }\n", | |
"\t if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5);\n", | |
"\t };\n", | |
"\t d3.variance = function(array, f) {\n", | |
"\t var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0;\n", | |
"\t if (arguments.length === 1) {\n", | |
"\t while (++i < n) {\n", | |
"\t if (d3_numeric(a = d3_number(array[i]))) {\n", | |
"\t d = a - m;\n", | |
"\t m += d / ++j;\n", | |
"\t s += d * (a - m);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t while (++i < n) {\n", | |
"\t if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) {\n", | |
"\t d = a - m;\n", | |
"\t m += d / ++j;\n", | |
"\t s += d * (a - m);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (j > 1) return s / (j - 1);\n", | |
"\t };\n", | |
"\t d3.deviation = function() {\n", | |
"\t var v = d3.variance.apply(this, arguments);\n", | |
"\t return v ? Math.sqrt(v) : v;\n", | |
"\t };\n", | |
"\t function d3_bisector(compare) {\n", | |
"\t return {\n", | |
"\t left: function(a, x, lo, hi) {\n", | |
"\t if (arguments.length < 3) lo = 0;\n", | |
"\t if (arguments.length < 4) hi = a.length;\n", | |
"\t while (lo < hi) {\n", | |
"\t var mid = lo + hi >>> 1;\n", | |
"\t if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid;\n", | |
"\t }\n", | |
"\t return lo;\n", | |
"\t },\n", | |
"\t right: function(a, x, lo, hi) {\n", | |
"\t if (arguments.length < 3) lo = 0;\n", | |
"\t if (arguments.length < 4) hi = a.length;\n", | |
"\t while (lo < hi) {\n", | |
"\t var mid = lo + hi >>> 1;\n", | |
"\t if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1;\n", | |
"\t }\n", | |
"\t return lo;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t var d3_bisect = d3_bisector(d3_ascending);\n", | |
"\t d3.bisectLeft = d3_bisect.left;\n", | |
"\t d3.bisect = d3.bisectRight = d3_bisect.right;\n", | |
"\t d3.bisector = function(f) {\n", | |
"\t return d3_bisector(f.length === 1 ? function(d, x) {\n", | |
"\t return d3_ascending(f(d), x);\n", | |
"\t } : f);\n", | |
"\t };\n", | |
"\t d3.shuffle = function(array, i0, i1) {\n", | |
"\t if ((m = arguments.length) < 3) {\n", | |
"\t i1 = array.length;\n", | |
"\t if (m < 2) i0 = 0;\n", | |
"\t }\n", | |
"\t var m = i1 - i0, t, i;\n", | |
"\t while (m) {\n", | |
"\t i = Math.random() * m-- | 0;\n", | |
"\t t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t;\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t };\n", | |
"\t d3.permute = function(array, indexes) {\n", | |
"\t var i = indexes.length, permutes = new Array(i);\n", | |
"\t while (i--) permutes[i] = array[indexes[i]];\n", | |
"\t return permutes;\n", | |
"\t };\n", | |
"\t d3.pairs = function(array) {\n", | |
"\t var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n);\n", | |
"\t while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ];\n", | |
"\t return pairs;\n", | |
"\t };\n", | |
"\t d3.transpose = function(matrix) {\n", | |
"\t if (!(n = matrix.length)) return [];\n", | |
"\t for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) {\n", | |
"\t for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n; ) {\n", | |
"\t row[j] = matrix[j][i];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return transpose;\n", | |
"\t };\n", | |
"\t function d3_transposeLength(d) {\n", | |
"\t return d.length;\n", | |
"\t }\n", | |
"\t d3.zip = function() {\n", | |
"\t return d3.transpose(arguments);\n", | |
"\t };\n", | |
"\t d3.keys = function(map) {\n", | |
"\t var keys = [];\n", | |
"\t for (var key in map) keys.push(key);\n", | |
"\t return keys;\n", | |
"\t };\n", | |
"\t d3.values = function(map) {\n", | |
"\t var values = [];\n", | |
"\t for (var key in map) values.push(map[key]);\n", | |
"\t return values;\n", | |
"\t };\n", | |
"\t d3.entries = function(map) {\n", | |
"\t var entries = [];\n", | |
"\t for (var key in map) entries.push({\n", | |
"\t key: key,\n", | |
"\t value: map[key]\n", | |
"\t });\n", | |
"\t return entries;\n", | |
"\t };\n", | |
"\t d3.merge = function(arrays) {\n", | |
"\t var n = arrays.length, m, i = -1, j = 0, merged, array;\n", | |
"\t while (++i < n) j += arrays[i].length;\n", | |
"\t merged = new Array(j);\n", | |
"\t while (--n >= 0) {\n", | |
"\t array = arrays[n];\n", | |
"\t m = array.length;\n", | |
"\t while (--m >= 0) {\n", | |
"\t merged[--j] = array[m];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return merged;\n", | |
"\t };\n", | |
"\t var abs = Math.abs;\n", | |
"\t d3.range = function(start, stop, step) {\n", | |
"\t if (arguments.length < 3) {\n", | |
"\t step = 1;\n", | |
"\t if (arguments.length < 2) {\n", | |
"\t stop = start;\n", | |
"\t start = 0;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if ((stop - start) / step === Infinity) throw new Error(\"infinite range\");\n", | |
"\t var range = [], k = d3_range_integerScale(abs(step)), i = -1, j;\n", | |
"\t start *= k, stop *= k, step *= k;\n", | |
"\t if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k);\n", | |
"\t return range;\n", | |
"\t };\n", | |
"\t function d3_range_integerScale(x) {\n", | |
"\t var k = 1;\n", | |
"\t while (x * k % 1) k *= 10;\n", | |
"\t return k;\n", | |
"\t }\n", | |
"\t function d3_class(ctor, properties) {\n", | |
"\t for (var key in properties) {\n", | |
"\t Object.defineProperty(ctor.prototype, key, {\n", | |
"\t value: properties[key],\n", | |
"\t enumerable: false\n", | |
"\t });\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3.map = function(object, f) {\n", | |
"\t var map = new d3_Map();\n", | |
"\t if (object instanceof d3_Map) {\n", | |
"\t object.forEach(function(key, value) {\n", | |
"\t map.set(key, value);\n", | |
"\t });\n", | |
"\t } else if (Array.isArray(object)) {\n", | |
"\t var i = -1, n = object.length, o;\n", | |
"\t if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o);\n", | |
"\t } else {\n", | |
"\t for (var key in object) map.set(key, object[key]);\n", | |
"\t }\n", | |
"\t return map;\n", | |
"\t };\n", | |
"\t function d3_Map() {\n", | |
"\t this._ = Object.create(null);\n", | |
"\t }\n", | |
"\t var d3_map_proto = \"__proto__\", d3_map_zero = \"\\x00\";\n", | |
"\t d3_class(d3_Map, {\n", | |
"\t has: d3_map_has,\n", | |
"\t get: function(key) {\n", | |
"\t return this._[d3_map_escape(key)];\n", | |
"\t },\n", | |
"\t set: function(key, value) {\n", | |
"\t return this._[d3_map_escape(key)] = value;\n", | |
"\t },\n", | |
"\t remove: d3_map_remove,\n", | |
"\t keys: d3_map_keys,\n", | |
"\t values: function() {\n", | |
"\t var values = [];\n", | |
"\t for (var key in this._) values.push(this._[key]);\n", | |
"\t return values;\n", | |
"\t },\n", | |
"\t entries: function() {\n", | |
"\t var entries = [];\n", | |
"\t for (var key in this._) entries.push({\n", | |
"\t key: d3_map_unescape(key),\n", | |
"\t value: this._[key]\n", | |
"\t });\n", | |
"\t return entries;\n", | |
"\t },\n", | |
"\t size: d3_map_size,\n", | |
"\t empty: d3_map_empty,\n", | |
"\t forEach: function(f) {\n", | |
"\t for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]);\n", | |
"\t }\n", | |
"\t });\n", | |
"\t function d3_map_escape(key) {\n", | |
"\t return (key += \"\") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key;\n", | |
"\t }\n", | |
"\t function d3_map_unescape(key) {\n", | |
"\t return (key += \"\")[0] === d3_map_zero ? key.slice(1) : key;\n", | |
"\t }\n", | |
"\t function d3_map_has(key) {\n", | |
"\t return d3_map_escape(key) in this._;\n", | |
"\t }\n", | |
"\t function d3_map_remove(key) {\n", | |
"\t return (key = d3_map_escape(key)) in this._ && delete this._[key];\n", | |
"\t }\n", | |
"\t function d3_map_keys() {\n", | |
"\t var keys = [];\n", | |
"\t for (var key in this._) keys.push(d3_map_unescape(key));\n", | |
"\t return keys;\n", | |
"\t }\n", | |
"\t function d3_map_size() {\n", | |
"\t var size = 0;\n", | |
"\t for (var key in this._) ++size;\n", | |
"\t return size;\n", | |
"\t }\n", | |
"\t function d3_map_empty() {\n", | |
"\t for (var key in this._) return false;\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t d3.nest = function() {\n", | |
"\t var nest = {}, keys = [], sortKeys = [], sortValues, rollup;\n", | |
"\t function map(mapType, array, depth) {\n", | |
"\t if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;\n", | |
"\t var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values;\n", | |
"\t while (++i < n) {\n", | |
"\t if (values = valuesByKey.get(keyValue = key(object = array[i]))) {\n", | |
"\t values.push(object);\n", | |
"\t } else {\n", | |
"\t valuesByKey.set(keyValue, [ object ]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (mapType) {\n", | |
"\t object = mapType();\n", | |
"\t setter = function(keyValue, values) {\n", | |
"\t object.set(keyValue, map(mapType, values, depth));\n", | |
"\t };\n", | |
"\t } else {\n", | |
"\t object = {};\n", | |
"\t setter = function(keyValue, values) {\n", | |
"\t object[keyValue] = map(mapType, values, depth);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t valuesByKey.forEach(setter);\n", | |
"\t return object;\n", | |
"\t }\n", | |
"\t function entries(map, depth) {\n", | |
"\t if (depth >= keys.length) return map;\n", | |
"\t var array = [], sortKey = sortKeys[depth++];\n", | |
"\t map.forEach(function(key, keyMap) {\n", | |
"\t array.push({\n", | |
"\t key: key,\n", | |
"\t values: entries(keyMap, depth)\n", | |
"\t });\n", | |
"\t });\n", | |
"\t return sortKey ? array.sort(function(a, b) {\n", | |
"\t return sortKey(a.key, b.key);\n", | |
"\t }) : array;\n", | |
"\t }\n", | |
"\t nest.map = function(array, mapType) {\n", | |
"\t return map(mapType, array, 0);\n", | |
"\t };\n", | |
"\t nest.entries = function(array) {\n", | |
"\t return entries(map(d3.map, array, 0), 0);\n", | |
"\t };\n", | |
"\t nest.key = function(d) {\n", | |
"\t keys.push(d);\n", | |
"\t return nest;\n", | |
"\t };\n", | |
"\t nest.sortKeys = function(order) {\n", | |
"\t sortKeys[keys.length - 1] = order;\n", | |
"\t return nest;\n", | |
"\t };\n", | |
"\t nest.sortValues = function(order) {\n", | |
"\t sortValues = order;\n", | |
"\t return nest;\n", | |
"\t };\n", | |
"\t nest.rollup = function(f) {\n", | |
"\t rollup = f;\n", | |
"\t return nest;\n", | |
"\t };\n", | |
"\t return nest;\n", | |
"\t };\n", | |
"\t d3.set = function(array) {\n", | |
"\t var set = new d3_Set();\n", | |
"\t if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);\n", | |
"\t return set;\n", | |
"\t };\n", | |
"\t function d3_Set() {\n", | |
"\t this._ = Object.create(null);\n", | |
"\t }\n", | |
"\t d3_class(d3_Set, {\n", | |
"\t has: d3_map_has,\n", | |
"\t add: function(key) {\n", | |
"\t this._[d3_map_escape(key += \"\")] = true;\n", | |
"\t return key;\n", | |
"\t },\n", | |
"\t remove: d3_map_remove,\n", | |
"\t values: d3_map_keys,\n", | |
"\t size: d3_map_size,\n", | |
"\t empty: d3_map_empty,\n", | |
"\t forEach: function(f) {\n", | |
"\t for (var key in this._) f.call(this, d3_map_unescape(key));\n", | |
"\t }\n", | |
"\t });\n", | |
"\t d3.behavior = {};\n", | |
"\t function d3_identity(d) {\n", | |
"\t return d;\n", | |
"\t }\n", | |
"\t d3.rebind = function(target, source) {\n", | |
"\t var i = 1, n = arguments.length, method;\n", | |
"\t while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);\n", | |
"\t return target;\n", | |
"\t };\n", | |
"\t function d3_rebind(target, source, method) {\n", | |
"\t return function() {\n", | |
"\t var value = method.apply(source, arguments);\n", | |
"\t return value === source ? target : value;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_vendorSymbol(object, name) {\n", | |
"\t if (name in object) return name;\n", | |
"\t name = name.charAt(0).toUpperCase() + name.slice(1);\n", | |
"\t for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) {\n", | |
"\t var prefixName = d3_vendorPrefixes[i] + name;\n", | |
"\t if (prefixName in object) return prefixName;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var d3_vendorPrefixes = [ \"webkit\", \"ms\", \"moz\", \"Moz\", \"o\", \"O\" ];\n", | |
"\t function d3_noop() {}\n", | |
"\t d3.dispatch = function() {\n", | |
"\t var dispatch = new d3_dispatch(), i = -1, n = arguments.length;\n", | |
"\t while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);\n", | |
"\t return dispatch;\n", | |
"\t };\n", | |
"\t function d3_dispatch() {}\n", | |
"\t d3_dispatch.prototype.on = function(type, listener) {\n", | |
"\t var i = type.indexOf(\".\"), name = \"\";\n", | |
"\t if (i >= 0) {\n", | |
"\t name = type.slice(i + 1);\n", | |
"\t type = type.slice(0, i);\n", | |
"\t }\n", | |
"\t if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);\n", | |
"\t if (arguments.length === 2) {\n", | |
"\t if (listener == null) for (type in this) {\n", | |
"\t if (this.hasOwnProperty(type)) this[type].on(name, null);\n", | |
"\t }\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_dispatch_event(dispatch) {\n", | |
"\t var listeners = [], listenerByName = new d3_Map();\n", | |
"\t function event() {\n", | |
"\t var z = listeners, i = -1, n = z.length, l;\n", | |
"\t while (++i < n) if (l = z[i].on) l.apply(this, arguments);\n", | |
"\t return dispatch;\n", | |
"\t }\n", | |
"\t event.on = function(name, listener) {\n", | |
"\t var l = listenerByName.get(name), i;\n", | |
"\t if (arguments.length < 2) return l && l.on;\n", | |
"\t if (l) {\n", | |
"\t l.on = null;\n", | |
"\t listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));\n", | |
"\t listenerByName.remove(name);\n", | |
"\t }\n", | |
"\t if (listener) listeners.push(listenerByName.set(name, {\n", | |
"\t on: listener\n", | |
"\t }));\n", | |
"\t return dispatch;\n", | |
"\t };\n", | |
"\t return event;\n", | |
"\t }\n", | |
"\t d3.event = null;\n", | |
"\t function d3_eventPreventDefault() {\n", | |
"\t d3.event.preventDefault();\n", | |
"\t }\n", | |
"\t function d3_eventSource() {\n", | |
"\t var e = d3.event, s;\n", | |
"\t while (s = e.sourceEvent) e = s;\n", | |
"\t return e;\n", | |
"\t }\n", | |
"\t function d3_eventDispatch(target) {\n", | |
"\t var dispatch = new d3_dispatch(), i = 0, n = arguments.length;\n", | |
"\t while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);\n", | |
"\t dispatch.of = function(thiz, argumentz) {\n", | |
"\t return function(e1) {\n", | |
"\t try {\n", | |
"\t var e0 = e1.sourceEvent = d3.event;\n", | |
"\t e1.target = target;\n", | |
"\t d3.event = e1;\n", | |
"\t dispatch[e1.type].apply(thiz, argumentz);\n", | |
"\t } finally {\n", | |
"\t d3.event = e0;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t };\n", | |
"\t return dispatch;\n", | |
"\t }\n", | |
"\t d3.requote = function(s) {\n", | |
"\t return s.replace(d3_requote_re, \"\\\\$&\");\n", | |
"\t };\n", | |
"\t var d3_requote_re = /[\\\\\\^\\$\\*\\+\\?\\|\\[\\]\\(\\)\\.\\{\\}]/g;\n", | |
"\t var d3_subclass = {}.__proto__ ? function(object, prototype) {\n", | |
"\t object.__proto__ = prototype;\n", | |
"\t } : function(object, prototype) {\n", | |
"\t for (var property in prototype) object[property] = prototype[property];\n", | |
"\t };\n", | |
"\t function d3_selection(groups) {\n", | |
"\t d3_subclass(groups, d3_selectionPrototype);\n", | |
"\t return groups;\n", | |
"\t }\n", | |
"\t var d3_select = function(s, n) {\n", | |
"\t return n.querySelector(s);\n", | |
"\t }, d3_selectAll = function(s, n) {\n", | |
"\t return n.querySelectorAll(s);\n", | |
"\t }, d3_selectMatches = function(n, s) {\n", | |
"\t var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, \"matchesSelector\")];\n", | |
"\t d3_selectMatches = function(n, s) {\n", | |
"\t return d3_selectMatcher.call(n, s);\n", | |
"\t };\n", | |
"\t return d3_selectMatches(n, s);\n", | |
"\t };\n", | |
"\t if (typeof Sizzle === \"function\") {\n", | |
"\t d3_select = function(s, n) {\n", | |
"\t return Sizzle(s, n)[0] || null;\n", | |
"\t };\n", | |
"\t d3_selectAll = Sizzle;\n", | |
"\t d3_selectMatches = Sizzle.matchesSelector;\n", | |
"\t }\n", | |
"\t d3.selection = function() {\n", | |
"\t return d3.select(d3_document.documentElement);\n", | |
"\t };\n", | |
"\t var d3_selectionPrototype = d3.selection.prototype = [];\n", | |
"\t d3_selectionPrototype.select = function(selector) {\n", | |
"\t var subgroups = [], subgroup, subnode, group, node;\n", | |
"\t selector = d3_selection_selector(selector);\n", | |
"\t for (var j = -1, m = this.length; ++j < m; ) {\n", | |
"\t subgroups.push(subgroup = []);\n", | |
"\t subgroup.parentNode = (group = this[j]).parentNode;\n", | |
"\t for (var i = -1, n = group.length; ++i < n; ) {\n", | |
"\t if (node = group[i]) {\n", | |
"\t subgroup.push(subnode = selector.call(node, node.__data__, i, j));\n", | |
"\t if (subnode && \"__data__\" in node) subnode.__data__ = node.__data__;\n", | |
"\t } else {\n", | |
"\t subgroup.push(null);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_selection(subgroups);\n", | |
"\t };\n", | |
"\t function d3_selection_selector(selector) {\n", | |
"\t return typeof selector === \"function\" ? selector : function() {\n", | |
"\t return d3_select(selector, this);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.selectAll = function(selector) {\n", | |
"\t var subgroups = [], subgroup, node;\n", | |
"\t selector = d3_selection_selectorAll(selector);\n", | |
"\t for (var j = -1, m = this.length; ++j < m; ) {\n", | |
"\t for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n", | |
"\t if (node = group[i]) {\n", | |
"\t subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j)));\n", | |
"\t subgroup.parentNode = node;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_selection(subgroups);\n", | |
"\t };\n", | |
"\t function d3_selection_selectorAll(selector) {\n", | |
"\t return typeof selector === \"function\" ? selector : function() {\n", | |
"\t return d3_selectAll(selector, this);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t var d3_nsXhtml = \"http://www.w3.org/1999/xhtml\";\n", | |
"\t var d3_nsPrefix = {\n", | |
"\t svg: \"http://www.w3.org/2000/svg\",\n", | |
"\t xhtml: d3_nsXhtml,\n", | |
"\t xlink: \"http://www.w3.org/1999/xlink\",\n", | |
"\t xml: \"http://www.w3.org/XML/1998/namespace\",\n", | |
"\t xmlns: \"http://www.w3.org/2000/xmlns/\"\n", | |
"\t };\n", | |
"\t d3.ns = {\n", | |
"\t prefix: d3_nsPrefix,\n", | |
"\t qualify: function(name) {\n", | |
"\t var i = name.indexOf(\":\"), prefix = name;\n", | |
"\t if (i >= 0 && (prefix = name.slice(0, i)) !== \"xmlns\") name = name.slice(i + 1);\n", | |
"\t return d3_nsPrefix.hasOwnProperty(prefix) ? {\n", | |
"\t space: d3_nsPrefix[prefix],\n", | |
"\t local: name\n", | |
"\t } : name;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.attr = function(name, value) {\n", | |
"\t if (arguments.length < 2) {\n", | |
"\t if (typeof name === \"string\") {\n", | |
"\t var node = this.node();\n", | |
"\t name = d3.ns.qualify(name);\n", | |
"\t return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name);\n", | |
"\t }\n", | |
"\t for (value in name) this.each(d3_selection_attr(value, name[value]));\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t return this.each(d3_selection_attr(name, value));\n", | |
"\t };\n", | |
"\t function d3_selection_attr(name, value) {\n", | |
"\t name = d3.ns.qualify(name);\n", | |
"\t function attrNull() {\n", | |
"\t this.removeAttribute(name);\n", | |
"\t }\n", | |
"\t function attrNullNS() {\n", | |
"\t this.removeAttributeNS(name.space, name.local);\n", | |
"\t }\n", | |
"\t function attrConstant() {\n", | |
"\t this.setAttribute(name, value);\n", | |
"\t }\n", | |
"\t function attrConstantNS() {\n", | |
"\t this.setAttributeNS(name.space, name.local, value);\n", | |
"\t }\n", | |
"\t function attrFunction() {\n", | |
"\t var x = value.apply(this, arguments);\n", | |
"\t if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);\n", | |
"\t }\n", | |
"\t function attrFunctionNS() {\n", | |
"\t var x = value.apply(this, arguments);\n", | |
"\t if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);\n", | |
"\t }\n", | |
"\t return value == null ? name.local ? attrNullNS : attrNull : typeof value === \"function\" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;\n", | |
"\t }\n", | |
"\t function d3_collapse(s) {\n", | |
"\t return s.trim().replace(/\\s+/g, \" \");\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.classed = function(name, value) {\n", | |
"\t if (arguments.length < 2) {\n", | |
"\t if (typeof name === \"string\") {\n", | |
"\t var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1;\n", | |
"\t if (value = node.classList) {\n", | |
"\t while (++i < n) if (!value.contains(name[i])) return false;\n", | |
"\t } else {\n", | |
"\t value = node.getAttribute(\"class\");\n", | |
"\t while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false;\n", | |
"\t }\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t for (value in name) this.each(d3_selection_classed(value, name[value]));\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t return this.each(d3_selection_classed(name, value));\n", | |
"\t };\n", | |
"\t function d3_selection_classedRe(name) {\n", | |
"\t return new RegExp(\"(?:^|\\\\s+)\" + d3.requote(name) + \"(?:\\\\s+|$)\", \"g\");\n", | |
"\t }\n", | |
"\t function d3_selection_classes(name) {\n", | |
"\t return (name + \"\").trim().split(/^|\\s+/);\n", | |
"\t }\n", | |
"\t function d3_selection_classed(name, value) {\n", | |
"\t name = d3_selection_classes(name).map(d3_selection_classedName);\n", | |
"\t var n = name.length;\n", | |
"\t function classedConstant() {\n", | |
"\t var i = -1;\n", | |
"\t while (++i < n) name[i](this, value);\n", | |
"\t }\n", | |
"\t function classedFunction() {\n", | |
"\t var i = -1, x = value.apply(this, arguments);\n", | |
"\t while (++i < n) name[i](this, x);\n", | |
"\t }\n", | |
"\t return typeof value === \"function\" ? classedFunction : classedConstant;\n", | |
"\t }\n", | |
"\t function d3_selection_classedName(name) {\n", | |
"\t var re = d3_selection_classedRe(name);\n", | |
"\t return function(node, value) {\n", | |
"\t if (c = node.classList) return value ? c.add(name) : c.remove(name);\n", | |
"\t var c = node.getAttribute(\"class\") || \"\";\n", | |
"\t if (value) {\n", | |
"\t re.lastIndex = 0;\n", | |
"\t if (!re.test(c)) node.setAttribute(\"class\", d3_collapse(c + \" \" + name));\n", | |
"\t } else {\n", | |
"\t node.setAttribute(\"class\", d3_collapse(c.replace(re, \" \")));\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.style = function(name, value, priority) {\n", | |
"\t var n = arguments.length;\n", | |
"\t if (n < 3) {\n", | |
"\t if (typeof name !== \"string\") {\n", | |
"\t if (n < 2) value = \"\";\n", | |
"\t for (priority in name) this.each(d3_selection_style(priority, name[priority], value));\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t if (n < 2) {\n", | |
"\t var node = this.node();\n", | |
"\t return d3_window(node).getComputedStyle(node, null).getPropertyValue(name);\n", | |
"\t }\n", | |
"\t priority = \"\";\n", | |
"\t }\n", | |
"\t return this.each(d3_selection_style(name, value, priority));\n", | |
"\t };\n", | |
"\t function d3_selection_style(name, value, priority) {\n", | |
"\t function styleNull() {\n", | |
"\t this.style.removeProperty(name);\n", | |
"\t }\n", | |
"\t function styleConstant() {\n", | |
"\t this.style.setProperty(name, value, priority);\n", | |
"\t }\n", | |
"\t function styleFunction() {\n", | |
"\t var x = value.apply(this, arguments);\n", | |
"\t if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);\n", | |
"\t }\n", | |
"\t return value == null ? styleNull : typeof value === \"function\" ? styleFunction : styleConstant;\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.property = function(name, value) {\n", | |
"\t if (arguments.length < 2) {\n", | |
"\t if (typeof name === \"string\") return this.node()[name];\n", | |
"\t for (value in name) this.each(d3_selection_property(value, name[value]));\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t return this.each(d3_selection_property(name, value));\n", | |
"\t };\n", | |
"\t function d3_selection_property(name, value) {\n", | |
"\t function propertyNull() {\n", | |
"\t delete this[name];\n", | |
"\t }\n", | |
"\t function propertyConstant() {\n", | |
"\t this[name] = value;\n", | |
"\t }\n", | |
"\t function propertyFunction() {\n", | |
"\t var x = value.apply(this, arguments);\n", | |
"\t if (x == null) delete this[name]; else this[name] = x;\n", | |
"\t }\n", | |
"\t return value == null ? propertyNull : typeof value === \"function\" ? propertyFunction : propertyConstant;\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.text = function(value) {\n", | |
"\t return arguments.length ? this.each(typeof value === \"function\" ? function() {\n", | |
"\t var v = value.apply(this, arguments);\n", | |
"\t this.textContent = v == null ? \"\" : v;\n", | |
"\t } : value == null ? function() {\n", | |
"\t this.textContent = \"\";\n", | |
"\t } : function() {\n", | |
"\t this.textContent = value;\n", | |
"\t }) : this.node().textContent;\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.html = function(value) {\n", | |
"\t return arguments.length ? this.each(typeof value === \"function\" ? function() {\n", | |
"\t var v = value.apply(this, arguments);\n", | |
"\t this.innerHTML = v == null ? \"\" : v;\n", | |
"\t } : value == null ? function() {\n", | |
"\t this.innerHTML = \"\";\n", | |
"\t } : function() {\n", | |
"\t this.innerHTML = value;\n", | |
"\t }) : this.node().innerHTML;\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.append = function(name) {\n", | |
"\t name = d3_selection_creator(name);\n", | |
"\t return this.select(function() {\n", | |
"\t return this.appendChild(name.apply(this, arguments));\n", | |
"\t });\n", | |
"\t };\n", | |
"\t function d3_selection_creator(name) {\n", | |
"\t function create() {\n", | |
"\t var document = this.ownerDocument, namespace = this.namespaceURI;\n", | |
"\t return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name);\n", | |
"\t }\n", | |
"\t function createNS() {\n", | |
"\t return this.ownerDocument.createElementNS(name.space, name.local);\n", | |
"\t }\n", | |
"\t return typeof name === \"function\" ? name : (name = d3.ns.qualify(name)).local ? createNS : create;\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.insert = function(name, before) {\n", | |
"\t name = d3_selection_creator(name);\n", | |
"\t before = d3_selection_selector(before);\n", | |
"\t return this.select(function() {\n", | |
"\t return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null);\n", | |
"\t });\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.remove = function() {\n", | |
"\t return this.each(d3_selectionRemove);\n", | |
"\t };\n", | |
"\t function d3_selectionRemove() {\n", | |
"\t var parent = this.parentNode;\n", | |
"\t if (parent) parent.removeChild(this);\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.data = function(value, key) {\n", | |
"\t var i = -1, n = this.length, group, node;\n", | |
"\t if (!arguments.length) {\n", | |
"\t value = new Array(n = (group = this[0]).length);\n", | |
"\t while (++i < n) {\n", | |
"\t if (node = group[i]) {\n", | |
"\t value[i] = node.__data__;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return value;\n", | |
"\t }\n", | |
"\t function bind(group, groupData) {\n", | |
"\t var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData;\n", | |
"\t if (key) {\n", | |
"\t var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue;\n", | |
"\t for (i = -1; ++i < n; ) {\n", | |
"\t if (node = group[i]) {\n", | |
"\t if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) {\n", | |
"\t exitNodes[i] = node;\n", | |
"\t } else {\n", | |
"\t nodeByKeyValue.set(keyValue, node);\n", | |
"\t }\n", | |
"\t keyValues[i] = keyValue;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t for (i = -1; ++i < m; ) {\n", | |
"\t if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) {\n", | |
"\t enterNodes[i] = d3_selection_dataNode(nodeData);\n", | |
"\t } else if (node !== true) {\n", | |
"\t updateNodes[i] = node;\n", | |
"\t node.__data__ = nodeData;\n", | |
"\t }\n", | |
"\t nodeByKeyValue.set(keyValue, true);\n", | |
"\t }\n", | |
"\t for (i = -1; ++i < n; ) {\n", | |
"\t if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) {\n", | |
"\t exitNodes[i] = group[i];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t for (i = -1; ++i < n0; ) {\n", | |
"\t node = group[i];\n", | |
"\t nodeData = groupData[i];\n", | |
"\t if (node) {\n", | |
"\t node.__data__ = nodeData;\n", | |
"\t updateNodes[i] = node;\n", | |
"\t } else {\n", | |
"\t enterNodes[i] = d3_selection_dataNode(nodeData);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t for (;i < m; ++i) {\n", | |
"\t enterNodes[i] = d3_selection_dataNode(groupData[i]);\n", | |
"\t }\n", | |
"\t for (;i < n; ++i) {\n", | |
"\t exitNodes[i] = group[i];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t enterNodes.update = updateNodes;\n", | |
"\t enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;\n", | |
"\t enter.push(enterNodes);\n", | |
"\t update.push(updateNodes);\n", | |
"\t exit.push(exitNodes);\n", | |
"\t }\n", | |
"\t var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);\n", | |
"\t if (typeof value === \"function\") {\n", | |
"\t while (++i < n) {\n", | |
"\t bind(group = this[i], value.call(group, group.parentNode.__data__, i));\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t while (++i < n) {\n", | |
"\t bind(group = this[i], value);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t update.enter = function() {\n", | |
"\t return enter;\n", | |
"\t };\n", | |
"\t update.exit = function() {\n", | |
"\t return exit;\n", | |
"\t };\n", | |
"\t return update;\n", | |
"\t };\n", | |
"\t function d3_selection_dataNode(data) {\n", | |
"\t return {\n", | |
"\t __data__: data\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.datum = function(value) {\n", | |
"\t return arguments.length ? this.property(\"__data__\", value) : this.property(\"__data__\");\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.filter = function(filter) {\n", | |
"\t var subgroups = [], subgroup, group, node;\n", | |
"\t if (typeof filter !== \"function\") filter = d3_selection_filter(filter);\n", | |
"\t for (var j = 0, m = this.length; j < m; j++) {\n", | |
"\t subgroups.push(subgroup = []);\n", | |
"\t subgroup.parentNode = (group = this[j]).parentNode;\n", | |
"\t for (var i = 0, n = group.length; i < n; i++) {\n", | |
"\t if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {\n", | |
"\t subgroup.push(node);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_selection(subgroups);\n", | |
"\t };\n", | |
"\t function d3_selection_filter(selector) {\n", | |
"\t return function() {\n", | |
"\t return d3_selectMatches(this, selector);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.order = function() {\n", | |
"\t for (var j = -1, m = this.length; ++j < m; ) {\n", | |
"\t for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {\n", | |
"\t if (node = group[i]) {\n", | |
"\t if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);\n", | |
"\t next = node;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return this;\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.sort = function(comparator) {\n", | |
"\t comparator = d3_selection_sortComparator.apply(this, arguments);\n", | |
"\t for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator);\n", | |
"\t return this.order();\n", | |
"\t };\n", | |
"\t function d3_selection_sortComparator(comparator) {\n", | |
"\t if (!arguments.length) comparator = d3_ascending;\n", | |
"\t return function(a, b) {\n", | |
"\t return a && b ? comparator(a.__data__, b.__data__) : !a - !b;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.each = function(callback) {\n", | |
"\t return d3_selection_each(this, function(node, i, j) {\n", | |
"\t callback.call(node, node.__data__, i, j);\n", | |
"\t });\n", | |
"\t };\n", | |
"\t function d3_selection_each(groups, callback) {\n", | |
"\t for (var j = 0, m = groups.length; j < m; j++) {\n", | |
"\t for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {\n", | |
"\t if (node = group[i]) callback(node, i, j);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return groups;\n", | |
"\t }\n", | |
"\t d3_selectionPrototype.call = function(callback) {\n", | |
"\t var args = d3_array(arguments);\n", | |
"\t callback.apply(args[0] = this, args);\n", | |
"\t return this;\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.empty = function() {\n", | |
"\t return !this.node();\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.node = function() {\n", | |
"\t for (var j = 0, m = this.length; j < m; j++) {\n", | |
"\t for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n", | |
"\t var node = group[i];\n", | |
"\t if (node) return node;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return null;\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.size = function() {\n", | |
"\t var n = 0;\n", | |
"\t d3_selection_each(this, function() {\n", | |
"\t ++n;\n", | |
"\t });\n", | |
"\t return n;\n", | |
"\t };\n", | |
"\t function d3_selection_enter(selection) {\n", | |
"\t d3_subclass(selection, d3_selection_enterPrototype);\n", | |
"\t return selection;\n", | |
"\t }\n", | |
"\t var d3_selection_enterPrototype = [];\n", | |
"\t d3.selection.enter = d3_selection_enter;\n", | |
"\t d3.selection.enter.prototype = d3_selection_enterPrototype;\n", | |
"\t d3_selection_enterPrototype.append = d3_selectionPrototype.append;\n", | |
"\t d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;\n", | |
"\t d3_selection_enterPrototype.node = d3_selectionPrototype.node;\n", | |
"\t d3_selection_enterPrototype.call = d3_selectionPrototype.call;\n", | |
"\t d3_selection_enterPrototype.size = d3_selectionPrototype.size;\n", | |
"\t d3_selection_enterPrototype.select = function(selector) {\n", | |
"\t var subgroups = [], subgroup, subnode, upgroup, group, node;\n", | |
"\t for (var j = -1, m = this.length; ++j < m; ) {\n", | |
"\t upgroup = (group = this[j]).update;\n", | |
"\t subgroups.push(subgroup = []);\n", | |
"\t subgroup.parentNode = group.parentNode;\n", | |
"\t for (var i = -1, n = group.length; ++i < n; ) {\n", | |
"\t if (node = group[i]) {\n", | |
"\t subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j));\n", | |
"\t subnode.__data__ = node.__data__;\n", | |
"\t } else {\n", | |
"\t subgroup.push(null);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_selection(subgroups);\n", | |
"\t };\n", | |
"\t d3_selection_enterPrototype.insert = function(name, before) {\n", | |
"\t if (arguments.length < 2) before = d3_selection_enterInsertBefore(this);\n", | |
"\t return d3_selectionPrototype.insert.call(this, name, before);\n", | |
"\t };\n", | |
"\t function d3_selection_enterInsertBefore(enter) {\n", | |
"\t var i0, j0;\n", | |
"\t return function(d, i, j) {\n", | |
"\t var group = enter[j].update, n = group.length, node;\n", | |
"\t if (j != j0) j0 = j, i0 = 0;\n", | |
"\t if (i >= i0) i0 = i + 1;\n", | |
"\t while (!(node = group[i0]) && ++i0 < n) ;\n", | |
"\t return node;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.select = function(node) {\n", | |
"\t var group;\n", | |
"\t if (typeof node === \"string\") {\n", | |
"\t group = [ d3_select(node, d3_document) ];\n", | |
"\t group.parentNode = d3_document.documentElement;\n", | |
"\t } else {\n", | |
"\t group = [ node ];\n", | |
"\t group.parentNode = d3_documentElement(node);\n", | |
"\t }\n", | |
"\t return d3_selection([ group ]);\n", | |
"\t };\n", | |
"\t d3.selectAll = function(nodes) {\n", | |
"\t var group;\n", | |
"\t if (typeof nodes === \"string\") {\n", | |
"\t group = d3_array(d3_selectAll(nodes, d3_document));\n", | |
"\t group.parentNode = d3_document.documentElement;\n", | |
"\t } else {\n", | |
"\t group = d3_array(nodes);\n", | |
"\t group.parentNode = null;\n", | |
"\t }\n", | |
"\t return d3_selection([ group ]);\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.on = function(type, listener, capture) {\n", | |
"\t var n = arguments.length;\n", | |
"\t if (n < 3) {\n", | |
"\t if (typeof type !== \"string\") {\n", | |
"\t if (n < 2) listener = false;\n", | |
"\t for (capture in type) this.each(d3_selection_on(capture, type[capture], listener));\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t if (n < 2) return (n = this.node()[\"__on\" + type]) && n._;\n", | |
"\t capture = false;\n", | |
"\t }\n", | |
"\t return this.each(d3_selection_on(type, listener, capture));\n", | |
"\t };\n", | |
"\t function d3_selection_on(type, listener, capture) {\n", | |
"\t var name = \"__on\" + type, i = type.indexOf(\".\"), wrap = d3_selection_onListener;\n", | |
"\t if (i > 0) type = type.slice(0, i);\n", | |
"\t var filter = d3_selection_onFilters.get(type);\n", | |
"\t if (filter) type = filter, wrap = d3_selection_onFilter;\n", | |
"\t function onRemove() {\n", | |
"\t var l = this[name];\n", | |
"\t if (l) {\n", | |
"\t this.removeEventListener(type, l, l.$);\n", | |
"\t delete this[name];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function onAdd() {\n", | |
"\t var l = wrap(listener, d3_array(arguments));\n", | |
"\t onRemove.call(this);\n", | |
"\t this.addEventListener(type, this[name] = l, l.$ = capture);\n", | |
"\t l._ = listener;\n", | |
"\t }\n", | |
"\t function removeAll() {\n", | |
"\t var re = new RegExp(\"^__on([^.]+)\" + d3.requote(type) + \"$\"), match;\n", | |
"\t for (var name in this) {\n", | |
"\t if (match = name.match(re)) {\n", | |
"\t var l = this[name];\n", | |
"\t this.removeEventListener(match[1], l, l.$);\n", | |
"\t delete this[name];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll;\n", | |
"\t }\n", | |
"\t var d3_selection_onFilters = d3.map({\n", | |
"\t mouseenter: \"mouseover\",\n", | |
"\t mouseleave: \"mouseout\"\n", | |
"\t });\n", | |
"\t if (d3_document) {\n", | |
"\t d3_selection_onFilters.forEach(function(k) {\n", | |
"\t if (\"on\" + k in d3_document) d3_selection_onFilters.remove(k);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function d3_selection_onListener(listener, argumentz) {\n", | |
"\t return function(e) {\n", | |
"\t var o = d3.event;\n", | |
"\t d3.event = e;\n", | |
"\t argumentz[0] = this.__data__;\n", | |
"\t try {\n", | |
"\t listener.apply(this, argumentz);\n", | |
"\t } finally {\n", | |
"\t d3.event = o;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_selection_onFilter(listener, argumentz) {\n", | |
"\t var l = d3_selection_onListener(listener, argumentz);\n", | |
"\t return function(e) {\n", | |
"\t var target = this, related = e.relatedTarget;\n", | |
"\t if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) {\n", | |
"\t l.call(target, e);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t var d3_event_dragSelect, d3_event_dragId = 0;\n", | |
"\t function d3_event_dragSuppress(node) {\n", | |
"\t var name = \".dragsuppress-\" + ++d3_event_dragId, click = \"click\" + name, w = d3.select(d3_window(node)).on(\"touchmove\" + name, d3_eventPreventDefault).on(\"dragstart\" + name, d3_eventPreventDefault).on(\"selectstart\" + name, d3_eventPreventDefault);\n", | |
"\t if (d3_event_dragSelect == null) {\n", | |
"\t d3_event_dragSelect = \"onselectstart\" in node ? false : d3_vendorSymbol(node.style, \"userSelect\");\n", | |
"\t }\n", | |
"\t if (d3_event_dragSelect) {\n", | |
"\t var style = d3_documentElement(node).style, select = style[d3_event_dragSelect];\n", | |
"\t style[d3_event_dragSelect] = \"none\";\n", | |
"\t }\n", | |
"\t return function(suppressClick) {\n", | |
"\t w.on(name, null);\n", | |
"\t if (d3_event_dragSelect) style[d3_event_dragSelect] = select;\n", | |
"\t if (suppressClick) {\n", | |
"\t var off = function() {\n", | |
"\t w.on(click, null);\n", | |
"\t };\n", | |
"\t w.on(click, function() {\n", | |
"\t d3_eventPreventDefault();\n", | |
"\t off();\n", | |
"\t }, true);\n", | |
"\t setTimeout(off, 0);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.mouse = function(container) {\n", | |
"\t return d3_mousePoint(container, d3_eventSource());\n", | |
"\t };\n", | |
"\t var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0;\n", | |
"\t function d3_mousePoint(container, e) {\n", | |
"\t if (e.changedTouches) e = e.changedTouches[0];\n", | |
"\t var svg = container.ownerSVGElement || container;\n", | |
"\t if (svg.createSVGPoint) {\n", | |
"\t var point = svg.createSVGPoint();\n", | |
"\t if (d3_mouse_bug44083 < 0) {\n", | |
"\t var window = d3_window(container);\n", | |
"\t if (window.scrollX || window.scrollY) {\n", | |
"\t svg = d3.select(\"body\").append(\"svg\").style({\n", | |
"\t position: \"absolute\",\n", | |
"\t top: 0,\n", | |
"\t left: 0,\n", | |
"\t margin: 0,\n", | |
"\t padding: 0,\n", | |
"\t border: \"none\"\n", | |
"\t }, \"important\");\n", | |
"\t var ctm = svg[0][0].getScreenCTM();\n", | |
"\t d3_mouse_bug44083 = !(ctm.f || ctm.e);\n", | |
"\t svg.remove();\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, \n", | |
"\t point.y = e.clientY;\n", | |
"\t point = point.matrixTransform(container.getScreenCTM().inverse());\n", | |
"\t return [ point.x, point.y ];\n", | |
"\t }\n", | |
"\t var rect = container.getBoundingClientRect();\n", | |
"\t return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];\n", | |
"\t }\n", | |
"\t d3.touch = function(container, touches, identifier) {\n", | |
"\t if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;\n", | |
"\t if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {\n", | |
"\t if ((touch = touches[i]).identifier === identifier) {\n", | |
"\t return d3_mousePoint(container, touch);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t };\n", | |
"\t d3.behavior.drag = function() {\n", | |
"\t var event = d3_eventDispatch(drag, \"drag\", \"dragstart\", \"dragend\"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_window, \"mousemove\", \"mouseup\"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_identity, \"touchmove\", \"touchend\");\n", | |
"\t function drag() {\n", | |
"\t this.on(\"mousedown.drag\", mousedown).on(\"touchstart.drag\", touchstart);\n", | |
"\t }\n", | |
"\t function dragstart(id, position, subject, move, end) {\n", | |
"\t return function() {\n", | |
"\t var that = this, target = d3.event.target.correspondingElement || d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = \".drag\" + (dragId == null ? \"\" : \"-\" + dragId), dragOffset, dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId);\n", | |
"\t if (origin) {\n", | |
"\t dragOffset = origin.apply(that, arguments);\n", | |
"\t dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ];\n", | |
"\t } else {\n", | |
"\t dragOffset = [ 0, 0 ];\n", | |
"\t }\n", | |
"\t dispatch({\n", | |
"\t type: \"dragstart\"\n", | |
"\t });\n", | |
"\t function moved() {\n", | |
"\t var position1 = position(parent, dragId), dx, dy;\n", | |
"\t if (!position1) return;\n", | |
"\t dx = position1[0] - position0[0];\n", | |
"\t dy = position1[1] - position0[1];\n", | |
"\t dragged |= dx | dy;\n", | |
"\t position0 = position1;\n", | |
"\t dispatch({\n", | |
"\t type: \"drag\",\n", | |
"\t x: position1[0] + dragOffset[0],\n", | |
"\t y: position1[1] + dragOffset[1],\n", | |
"\t dx: dx,\n", | |
"\t dy: dy\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function ended() {\n", | |
"\t if (!position(parent, dragId)) return;\n", | |
"\t dragSubject.on(move + dragName, null).on(end + dragName, null);\n", | |
"\t dragRestore(dragged);\n", | |
"\t dispatch({\n", | |
"\t type: \"dragend\"\n", | |
"\t });\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t drag.origin = function(x) {\n", | |
"\t if (!arguments.length) return origin;\n", | |
"\t origin = x;\n", | |
"\t return drag;\n", | |
"\t };\n", | |
"\t return d3.rebind(drag, event, \"on\");\n", | |
"\t };\n", | |
"\t function d3_behavior_dragTouchId() {\n", | |
"\t return d3.event.changedTouches[0].identifier;\n", | |
"\t }\n", | |
"\t d3.touches = function(container, touches) {\n", | |
"\t if (arguments.length < 2) touches = d3_eventSource().touches;\n", | |
"\t return touches ? d3_array(touches).map(function(touch) {\n", | |
"\t var point = d3_mousePoint(container, touch);\n", | |
"\t point.identifier = touch.identifier;\n", | |
"\t return point;\n", | |
"\t }) : [];\n", | |
"\t };\n", | |
"\t var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;\n", | |
"\t function d3_sgn(x) {\n", | |
"\t return x > 0 ? 1 : x < 0 ? -1 : 0;\n", | |
"\t }\n", | |
"\t function d3_cross2d(a, b, c) {\n", | |
"\t return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);\n", | |
"\t }\n", | |
"\t function d3_acos(x) {\n", | |
"\t return x > 1 ? 0 : x < -1 ? π : Math.acos(x);\n", | |
"\t }\n", | |
"\t function d3_asin(x) {\n", | |
"\t return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x);\n", | |
"\t }\n", | |
"\t function d3_sinh(x) {\n", | |
"\t return ((x = Math.exp(x)) - 1 / x) / 2;\n", | |
"\t }\n", | |
"\t function d3_cosh(x) {\n", | |
"\t return ((x = Math.exp(x)) + 1 / x) / 2;\n", | |
"\t }\n", | |
"\t function d3_tanh(x) {\n", | |
"\t return ((x = Math.exp(2 * x)) - 1) / (x + 1);\n", | |
"\t }\n", | |
"\t function d3_haversin(x) {\n", | |
"\t return (x = Math.sin(x / 2)) * x;\n", | |
"\t }\n", | |
"\t var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4;\n", | |
"\t d3.interpolateZoom = function(p0, p1) {\n", | |
"\t var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S;\n", | |
"\t if (d2 < ε2) {\n", | |
"\t S = Math.log(w1 / w0) / ρ;\n", | |
"\t i = function(t) {\n", | |
"\t return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * t * S) ];\n", | |
"\t };\n", | |
"\t } else {\n", | |
"\t var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);\n", | |
"\t S = (r1 - r0) / ρ;\n", | |
"\t i = function(t) {\n", | |
"\t var s = t * S, coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0));\n", | |
"\t return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ];\n", | |
"\t };\n", | |
"\t }\n", | |
"\t i.duration = S * 1e3;\n", | |
"\t return i;\n", | |
"\t };\n", | |
"\t d3.behavior.zoom = function() {\n", | |
"\t var view = {\n", | |
"\t x: 0,\n", | |
"\t y: 0,\n", | |
"\t k: 1\n", | |
"\t }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, mousedown = \"mousedown.zoom\", mousemove = \"mousemove.zoom\", mouseup = \"mouseup.zoom\", mousewheelTimer, touchstart = \"touchstart.zoom\", touchtime, event = d3_eventDispatch(zoom, \"zoomstart\", \"zoom\", \"zoomend\"), x0, x1, y0, y1;\n", | |
"\t if (!d3_behavior_zoomWheel) {\n", | |
"\t d3_behavior_zoomWheel = \"onwheel\" in d3_document ? (d3_behavior_zoomDelta = function() {\n", | |
"\t return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1);\n", | |
"\t }, \"wheel\") : \"onmousewheel\" in d3_document ? (d3_behavior_zoomDelta = function() {\n", | |
"\t return d3.event.wheelDelta;\n", | |
"\t }, \"mousewheel\") : (d3_behavior_zoomDelta = function() {\n", | |
"\t return -d3.event.detail;\n", | |
"\t }, \"MozMousePixelScroll\");\n", | |
"\t }\n", | |
"\t function zoom(g) {\n", | |
"\t g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + \".zoom\", mousewheeled).on(\"dblclick.zoom\", dblclicked).on(touchstart, touchstarted);\n", | |
"\t }\n", | |
"\t zoom.event = function(g) {\n", | |
"\t g.each(function() {\n", | |
"\t var dispatch = event.of(this, arguments), view1 = view;\n", | |
"\t if (d3_transitionInheritId) {\n", | |
"\t d3.select(this).transition().each(\"start.zoom\", function() {\n", | |
"\t view = this.__chart__ || {\n", | |
"\t x: 0,\n", | |
"\t y: 0,\n", | |
"\t k: 1\n", | |
"\t };\n", | |
"\t zoomstarted(dispatch);\n", | |
"\t }).tween(\"zoom:zoom\", function() {\n", | |
"\t var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]);\n", | |
"\t return function(t) {\n", | |
"\t var l = i(t), k = dx / l[2];\n", | |
"\t this.__chart__ = view = {\n", | |
"\t x: cx - l[0] * k,\n", | |
"\t y: cy - l[1] * k,\n", | |
"\t k: k\n", | |
"\t };\n", | |
"\t zoomed(dispatch);\n", | |
"\t };\n", | |
"\t }).each(\"interrupt.zoom\", function() {\n", | |
"\t zoomended(dispatch);\n", | |
"\t }).each(\"end.zoom\", function() {\n", | |
"\t zoomended(dispatch);\n", | |
"\t });\n", | |
"\t } else {\n", | |
"\t this.__chart__ = view;\n", | |
"\t zoomstarted(dispatch);\n", | |
"\t zoomed(dispatch);\n", | |
"\t zoomended(dispatch);\n", | |
"\t }\n", | |
"\t });\n", | |
"\t };\n", | |
"\t zoom.translate = function(_) {\n", | |
"\t if (!arguments.length) return [ view.x, view.y ];\n", | |
"\t view = {\n", | |
"\t x: +_[0],\n", | |
"\t y: +_[1],\n", | |
"\t k: view.k\n", | |
"\t };\n", | |
"\t rescale();\n", | |
"\t return zoom;\n", | |
"\t };\n", | |
"\t zoom.scale = function(_) {\n", | |
"\t if (!arguments.length) return view.k;\n", | |
"\t view = {\n", | |
"\t x: view.x,\n", | |
"\t y: view.y,\n", | |
"\t k: null\n", | |
"\t };\n", | |
"\t scaleTo(+_);\n", | |
"\t rescale();\n", | |
"\t return zoom;\n", | |
"\t };\n", | |
"\t zoom.scaleExtent = function(_) {\n", | |
"\t if (!arguments.length) return scaleExtent;\n", | |
"\t scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ];\n", | |
"\t return zoom;\n", | |
"\t };\n", | |
"\t zoom.center = function(_) {\n", | |
"\t if (!arguments.length) return center;\n", | |
"\t center = _ && [ +_[0], +_[1] ];\n", | |
"\t return zoom;\n", | |
"\t };\n", | |
"\t zoom.size = function(_) {\n", | |
"\t if (!arguments.length) return size;\n", | |
"\t size = _ && [ +_[0], +_[1] ];\n", | |
"\t return zoom;\n", | |
"\t };\n", | |
"\t zoom.duration = function(_) {\n", | |
"\t if (!arguments.length) return duration;\n", | |
"\t duration = +_;\n", | |
"\t return zoom;\n", | |
"\t };\n", | |
"\t zoom.x = function(z) {\n", | |
"\t if (!arguments.length) return x1;\n", | |
"\t x1 = z;\n", | |
"\t x0 = z.copy();\n", | |
"\t view = {\n", | |
"\t x: 0,\n", | |
"\t y: 0,\n", | |
"\t k: 1\n", | |
"\t };\n", | |
"\t return zoom;\n", | |
"\t };\n", | |
"\t zoom.y = function(z) {\n", | |
"\t if (!arguments.length) return y1;\n", | |
"\t y1 = z;\n", | |
"\t y0 = z.copy();\n", | |
"\t view = {\n", | |
"\t x: 0,\n", | |
"\t y: 0,\n", | |
"\t k: 1\n", | |
"\t };\n", | |
"\t return zoom;\n", | |
"\t };\n", | |
"\t function location(p) {\n", | |
"\t return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ];\n", | |
"\t }\n", | |
"\t function point(l) {\n", | |
"\t return [ l[0] * view.k + view.x, l[1] * view.k + view.y ];\n", | |
"\t }\n", | |
"\t function scaleTo(s) {\n", | |
"\t view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));\n", | |
"\t }\n", | |
"\t function translateTo(p, l) {\n", | |
"\t l = point(l);\n", | |
"\t view.x += p[0] - l[0];\n", | |
"\t view.y += p[1] - l[1];\n", | |
"\t }\n", | |
"\t function zoomTo(that, p, l, k) {\n", | |
"\t that.__chart__ = {\n", | |
"\t x: view.x,\n", | |
"\t y: view.y,\n", | |
"\t k: view.k\n", | |
"\t };\n", | |
"\t scaleTo(Math.pow(2, k));\n", | |
"\t translateTo(center0 = p, l);\n", | |
"\t that = d3.select(that);\n", | |
"\t if (duration > 0) that = that.transition().duration(duration);\n", | |
"\t that.call(zoom.event);\n", | |
"\t }\n", | |
"\t function rescale() {\n", | |
"\t if (x1) x1.domain(x0.range().map(function(x) {\n", | |
"\t return (x - view.x) / view.k;\n", | |
"\t }).map(x0.invert));\n", | |
"\t if (y1) y1.domain(y0.range().map(function(y) {\n", | |
"\t return (y - view.y) / view.k;\n", | |
"\t }).map(y0.invert));\n", | |
"\t }\n", | |
"\t function zoomstarted(dispatch) {\n", | |
"\t if (!zooming++) dispatch({\n", | |
"\t type: \"zoomstart\"\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function zoomed(dispatch) {\n", | |
"\t rescale();\n", | |
"\t dispatch({\n", | |
"\t type: \"zoom\",\n", | |
"\t scale: view.k,\n", | |
"\t translate: [ view.x, view.y ]\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function zoomended(dispatch) {\n", | |
"\t if (!--zooming) dispatch({\n", | |
"\t type: \"zoomend\"\n", | |
"\t }), center0 = null;\n", | |
"\t }\n", | |
"\t function mousedowned() {\n", | |
"\t var that = this, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that);\n", | |
"\t d3_selection_interrupt.call(that);\n", | |
"\t zoomstarted(dispatch);\n", | |
"\t function moved() {\n", | |
"\t dragged = 1;\n", | |
"\t translateTo(d3.mouse(that), location0);\n", | |
"\t zoomed(dispatch);\n", | |
"\t }\n", | |
"\t function ended() {\n", | |
"\t subject.on(mousemove, null).on(mouseup, null);\n", | |
"\t dragRestore(dragged);\n", | |
"\t zoomended(dispatch);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function touchstarted() {\n", | |
"\t var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = \".zoom-\" + d3.event.changedTouches[0].identifier, touchmove = \"touchmove\" + zoomName, touchend = \"touchend\" + zoomName, targets = [], subject = d3.select(that), dragRestore = d3_event_dragSuppress(that);\n", | |
"\t started();\n", | |
"\t zoomstarted(dispatch);\n", | |
"\t subject.on(mousedown, null).on(touchstart, started);\n", | |
"\t function relocate() {\n", | |
"\t var touches = d3.touches(that);\n", | |
"\t scale0 = view.k;\n", | |
"\t touches.forEach(function(t) {\n", | |
"\t if (t.identifier in locations0) locations0[t.identifier] = location(t);\n", | |
"\t });\n", | |
"\t return touches;\n", | |
"\t }\n", | |
"\t function started() {\n", | |
"\t var target = d3.event.target;\n", | |
"\t d3.select(target).on(touchmove, moved).on(touchend, ended);\n", | |
"\t targets.push(target);\n", | |
"\t var changed = d3.event.changedTouches;\n", | |
"\t for (var i = 0, n = changed.length; i < n; ++i) {\n", | |
"\t locations0[changed[i].identifier] = null;\n", | |
"\t }\n", | |
"\t var touches = relocate(), now = Date.now();\n", | |
"\t if (touches.length === 1) {\n", | |
"\t if (now - touchtime < 500) {\n", | |
"\t var p = touches[0];\n", | |
"\t zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);\n", | |
"\t d3_eventPreventDefault();\n", | |
"\t }\n", | |
"\t touchtime = now;\n", | |
"\t } else if (touches.length > 1) {\n", | |
"\t var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];\n", | |
"\t distance0 = dx * dx + dy * dy;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function moved() {\n", | |
"\t var touches = d3.touches(that), p0, l0, p1, l1;\n", | |
"\t d3_selection_interrupt.call(that);\n", | |
"\t for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {\n", | |
"\t p1 = touches[i];\n", | |
"\t if (l1 = locations0[p1.identifier]) {\n", | |
"\t if (l0) break;\n", | |
"\t p0 = p1, l0 = l1;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (l1) {\n", | |
"\t var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0);\n", | |
"\t p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];\n", | |
"\t l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];\n", | |
"\t scaleTo(scale1 * scale0);\n", | |
"\t }\n", | |
"\t touchtime = null;\n", | |
"\t translateTo(p0, l0);\n", | |
"\t zoomed(dispatch);\n", | |
"\t }\n", | |
"\t function ended() {\n", | |
"\t if (d3.event.touches.length) {\n", | |
"\t var changed = d3.event.changedTouches;\n", | |
"\t for (var i = 0, n = changed.length; i < n; ++i) {\n", | |
"\t delete locations0[changed[i].identifier];\n", | |
"\t }\n", | |
"\t for (var identifier in locations0) {\n", | |
"\t return void relocate();\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3.selectAll(targets).on(zoomName, null);\n", | |
"\t subject.on(mousedown, mousedowned).on(touchstart, touchstarted);\n", | |
"\t dragRestore();\n", | |
"\t zoomended(dispatch);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function mousewheeled() {\n", | |
"\t var dispatch = event.of(this, arguments);\n", | |
"\t if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), \n", | |
"\t translate0 = location(center0 = center || d3.mouse(this)), zoomstarted(dispatch);\n", | |
"\t mousewheelTimer = setTimeout(function() {\n", | |
"\t mousewheelTimer = null;\n", | |
"\t zoomended(dispatch);\n", | |
"\t }, 50);\n", | |
"\t d3_eventPreventDefault();\n", | |
"\t scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);\n", | |
"\t translateTo(center0, translate0);\n", | |
"\t zoomed(dispatch);\n", | |
"\t }\n", | |
"\t function dblclicked() {\n", | |
"\t var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2;\n", | |
"\t zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1);\n", | |
"\t }\n", | |
"\t return d3.rebind(zoom, event, \"on\");\n", | |
"\t };\n", | |
"\t var d3_behavior_zoomInfinity = [ 0, Infinity ], d3_behavior_zoomDelta, d3_behavior_zoomWheel;\n", | |
"\t d3.color = d3_color;\n", | |
"\t function d3_color() {}\n", | |
"\t d3_color.prototype.toString = function() {\n", | |
"\t return this.rgb() + \"\";\n", | |
"\t };\n", | |
"\t d3.hsl = d3_hsl;\n", | |
"\t function d3_hsl(h, s, l) {\n", | |
"\t return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse(\"\" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l);\n", | |
"\t }\n", | |
"\t var d3_hslPrototype = d3_hsl.prototype = new d3_color();\n", | |
"\t d3_hslPrototype.brighter = function(k) {\n", | |
"\t k = Math.pow(.7, arguments.length ? k : 1);\n", | |
"\t return new d3_hsl(this.h, this.s, this.l / k);\n", | |
"\t };\n", | |
"\t d3_hslPrototype.darker = function(k) {\n", | |
"\t k = Math.pow(.7, arguments.length ? k : 1);\n", | |
"\t return new d3_hsl(this.h, this.s, k * this.l);\n", | |
"\t };\n", | |
"\t d3_hslPrototype.rgb = function() {\n", | |
"\t return d3_hsl_rgb(this.h, this.s, this.l);\n", | |
"\t };\n", | |
"\t function d3_hsl_rgb(h, s, l) {\n", | |
"\t var m1, m2;\n", | |
"\t h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;\n", | |
"\t s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;\n", | |
"\t l = l < 0 ? 0 : l > 1 ? 1 : l;\n", | |
"\t m2 = l <= .5 ? l * (1 + s) : l + s - l * s;\n", | |
"\t m1 = 2 * l - m2;\n", | |
"\t function v(h) {\n", | |
"\t if (h > 360) h -= 360; else if (h < 0) h += 360;\n", | |
"\t if (h < 60) return m1 + (m2 - m1) * h / 60;\n", | |
"\t if (h < 180) return m2;\n", | |
"\t if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;\n", | |
"\t return m1;\n", | |
"\t }\n", | |
"\t function vv(h) {\n", | |
"\t return Math.round(v(h) * 255);\n", | |
"\t }\n", | |
"\t return new d3_rgb(vv(h + 120), vv(h), vv(h - 120));\n", | |
"\t }\n", | |
"\t d3.hcl = d3_hcl;\n", | |
"\t function d3_hcl(h, c, l) {\n", | |
"\t return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l);\n", | |
"\t }\n", | |
"\t var d3_hclPrototype = d3_hcl.prototype = new d3_color();\n", | |
"\t d3_hclPrototype.brighter = function(k) {\n", | |
"\t return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));\n", | |
"\t };\n", | |
"\t d3_hclPrototype.darker = function(k) {\n", | |
"\t return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));\n", | |
"\t };\n", | |
"\t d3_hclPrototype.rgb = function() {\n", | |
"\t return d3_hcl_lab(this.h, this.c, this.l).rgb();\n", | |
"\t };\n", | |
"\t function d3_hcl_lab(h, c, l) {\n", | |
"\t if (isNaN(h)) h = 0;\n", | |
"\t if (isNaN(c)) c = 0;\n", | |
"\t return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);\n", | |
"\t }\n", | |
"\t d3.lab = d3_lab;\n", | |
"\t function d3_lab(l, a, b) {\n", | |
"\t return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b);\n", | |
"\t }\n", | |
"\t var d3_lab_K = 18;\n", | |
"\t var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;\n", | |
"\t var d3_labPrototype = d3_lab.prototype = new d3_color();\n", | |
"\t d3_labPrototype.brighter = function(k) {\n", | |
"\t return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);\n", | |
"\t };\n", | |
"\t d3_labPrototype.darker = function(k) {\n", | |
"\t return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);\n", | |
"\t };\n", | |
"\t d3_labPrototype.rgb = function() {\n", | |
"\t return d3_lab_rgb(this.l, this.a, this.b);\n", | |
"\t };\n", | |
"\t function d3_lab_rgb(l, a, b) {\n", | |
"\t var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;\n", | |
"\t x = d3_lab_xyz(x) * d3_lab_X;\n", | |
"\t y = d3_lab_xyz(y) * d3_lab_Y;\n", | |
"\t z = d3_lab_xyz(z) * d3_lab_Z;\n", | |
"\t return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z));\n", | |
"\t }\n", | |
"\t function d3_lab_hcl(l, a, b) {\n", | |
"\t return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l);\n", | |
"\t }\n", | |
"\t function d3_lab_xyz(x) {\n", | |
"\t return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;\n", | |
"\t }\n", | |
"\t function d3_xyz_lab(x) {\n", | |
"\t return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;\n", | |
"\t }\n", | |
"\t function d3_xyz_rgb(r) {\n", | |
"\t return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));\n", | |
"\t }\n", | |
"\t d3.rgb = d3_rgb;\n", | |
"\t function d3_rgb(r, g, b) {\n", | |
"\t return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse(\"\" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, b);\n", | |
"\t }\n", | |
"\t function d3_rgbNumber(value) {\n", | |
"\t return new d3_rgb(value >> 16, value >> 8 & 255, value & 255);\n", | |
"\t }\n", | |
"\t function d3_rgbString(value) {\n", | |
"\t return d3_rgbNumber(value) + \"\";\n", | |
"\t }\n", | |
"\t var d3_rgbPrototype = d3_rgb.prototype = new d3_color();\n", | |
"\t d3_rgbPrototype.brighter = function(k) {\n", | |
"\t k = Math.pow(.7, arguments.length ? k : 1);\n", | |
"\t var r = this.r, g = this.g, b = this.b, i = 30;\n", | |
"\t if (!r && !g && !b) return new d3_rgb(i, i, i);\n", | |
"\t if (r && r < i) r = i;\n", | |
"\t if (g && g < i) g = i;\n", | |
"\t if (b && b < i) b = i;\n", | |
"\t return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k));\n", | |
"\t };\n", | |
"\t d3_rgbPrototype.darker = function(k) {\n", | |
"\t k = Math.pow(.7, arguments.length ? k : 1);\n", | |
"\t return new d3_rgb(k * this.r, k * this.g, k * this.b);\n", | |
"\t };\n", | |
"\t d3_rgbPrototype.hsl = function() {\n", | |
"\t return d3_rgb_hsl(this.r, this.g, this.b);\n", | |
"\t };\n", | |
"\t d3_rgbPrototype.toString = function() {\n", | |
"\t return \"#\" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);\n", | |
"\t };\n", | |
"\t function d3_rgb_hex(v) {\n", | |
"\t return v < 16 ? \"0\" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);\n", | |
"\t }\n", | |
"\t function d3_rgb_parse(format, rgb, hsl) {\n", | |
"\t var r = 0, g = 0, b = 0, m1, m2, color;\n", | |
"\t m1 = /([a-z]+)\\((.*)\\)/.exec(format = format.toLowerCase());\n", | |
"\t if (m1) {\n", | |
"\t m2 = m1[2].split(\",\");\n", | |
"\t switch (m1[1]) {\n", | |
"\t case \"hsl\":\n", | |
"\t {\n", | |
"\t return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);\n", | |
"\t }\n", | |
"\t\n", | |
"\t case \"rgb\":\n", | |
"\t {\n", | |
"\t return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (color = d3_rgb_names.get(format)) {\n", | |
"\t return rgb(color.r, color.g, color.b);\n", | |
"\t }\n", | |
"\t if (format != null && format.charAt(0) === \"#\" && !isNaN(color = parseInt(format.slice(1), 16))) {\n", | |
"\t if (format.length === 4) {\n", | |
"\t r = (color & 3840) >> 4;\n", | |
"\t r = r >> 4 | r;\n", | |
"\t g = color & 240;\n", | |
"\t g = g >> 4 | g;\n", | |
"\t b = color & 15;\n", | |
"\t b = b << 4 | b;\n", | |
"\t } else if (format.length === 7) {\n", | |
"\t r = (color & 16711680) >> 16;\n", | |
"\t g = (color & 65280) >> 8;\n", | |
"\t b = color & 255;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return rgb(r, g, b);\n", | |
"\t }\n", | |
"\t function d3_rgb_hsl(r, g, b) {\n", | |
"\t var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2;\n", | |
"\t if (d) {\n", | |
"\t s = l < .5 ? d / (max + min) : d / (2 - max - min);\n", | |
"\t if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4;\n", | |
"\t h *= 60;\n", | |
"\t } else {\n", | |
"\t h = NaN;\n", | |
"\t s = l > 0 && l < 1 ? 0 : h;\n", | |
"\t }\n", | |
"\t return new d3_hsl(h, s, l);\n", | |
"\t }\n", | |
"\t function d3_rgb_lab(r, g, b) {\n", | |
"\t r = d3_rgb_xyz(r);\n", | |
"\t g = d3_rgb_xyz(g);\n", | |
"\t b = d3_rgb_xyz(b);\n", | |
"\t var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z);\n", | |
"\t return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z));\n", | |
"\t }\n", | |
"\t function d3_rgb_xyz(r) {\n", | |
"\t return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4);\n", | |
"\t }\n", | |
"\t function d3_rgb_parseNumber(c) {\n", | |
"\t var f = parseFloat(c);\n", | |
"\t return c.charAt(c.length - 1) === \"%\" ? Math.round(f * 2.55) : f;\n", | |
"\t }\n", | |
"\t var d3_rgb_names = d3.map({\n", | |
"\t aliceblue: 15792383,\n", | |
"\t antiquewhite: 16444375,\n", | |
"\t aqua: 65535,\n", | |
"\t aquamarine: 8388564,\n", | |
"\t azure: 15794175,\n", | |
"\t beige: 16119260,\n", | |
"\t bisque: 16770244,\n", | |
"\t black: 0,\n", | |
"\t blanchedalmond: 16772045,\n", | |
"\t blue: 255,\n", | |
"\t blueviolet: 9055202,\n", | |
"\t brown: 10824234,\n", | |
"\t burlywood: 14596231,\n", | |
"\t cadetblue: 6266528,\n", | |
"\t chartreuse: 8388352,\n", | |
"\t chocolate: 13789470,\n", | |
"\t coral: 16744272,\n", | |
"\t cornflowerblue: 6591981,\n", | |
"\t cornsilk: 16775388,\n", | |
"\t crimson: 14423100,\n", | |
"\t cyan: 65535,\n", | |
"\t darkblue: 139,\n", | |
"\t darkcyan: 35723,\n", | |
"\t darkgoldenrod: 12092939,\n", | |
"\t darkgray: 11119017,\n", | |
"\t darkgreen: 25600,\n", | |
"\t darkgrey: 11119017,\n", | |
"\t darkkhaki: 12433259,\n", | |
"\t darkmagenta: 9109643,\n", | |
"\t darkolivegreen: 5597999,\n", | |
"\t darkorange: 16747520,\n", | |
"\t darkorchid: 10040012,\n", | |
"\t darkred: 9109504,\n", | |
"\t darksalmon: 15308410,\n", | |
"\t darkseagreen: 9419919,\n", | |
"\t darkslateblue: 4734347,\n", | |
"\t darkslategray: 3100495,\n", | |
"\t darkslategrey: 3100495,\n", | |
"\t darkturquoise: 52945,\n", | |
"\t darkviolet: 9699539,\n", | |
"\t deeppink: 16716947,\n", | |
"\t deepskyblue: 49151,\n", | |
"\t dimgray: 6908265,\n", | |
"\t dimgrey: 6908265,\n", | |
"\t dodgerblue: 2003199,\n", | |
"\t firebrick: 11674146,\n", | |
"\t floralwhite: 16775920,\n", | |
"\t forestgreen: 2263842,\n", | |
"\t fuchsia: 16711935,\n", | |
"\t gainsboro: 14474460,\n", | |
"\t ghostwhite: 16316671,\n", | |
"\t gold: 16766720,\n", | |
"\t goldenrod: 14329120,\n", | |
"\t gray: 8421504,\n", | |
"\t green: 32768,\n", | |
"\t greenyellow: 11403055,\n", | |
"\t grey: 8421504,\n", | |
"\t honeydew: 15794160,\n", | |
"\t hotpink: 16738740,\n", | |
"\t indianred: 13458524,\n", | |
"\t indigo: 4915330,\n", | |
"\t ivory: 16777200,\n", | |
"\t khaki: 15787660,\n", | |
"\t lavender: 15132410,\n", | |
"\t lavenderblush: 16773365,\n", | |
"\t lawngreen: 8190976,\n", | |
"\t lemonchiffon: 16775885,\n", | |
"\t lightblue: 11393254,\n", | |
"\t lightcoral: 15761536,\n", | |
"\t lightcyan: 14745599,\n", | |
"\t lightgoldenrodyellow: 16448210,\n", | |
"\t lightgray: 13882323,\n", | |
"\t lightgreen: 9498256,\n", | |
"\t lightgrey: 13882323,\n", | |
"\t lightpink: 16758465,\n", | |
"\t lightsalmon: 16752762,\n", | |
"\t lightseagreen: 2142890,\n", | |
"\t lightskyblue: 8900346,\n", | |
"\t lightslategray: 7833753,\n", | |
"\t lightslategrey: 7833753,\n", | |
"\t lightsteelblue: 11584734,\n", | |
"\t lightyellow: 16777184,\n", | |
"\t lime: 65280,\n", | |
"\t limegreen: 3329330,\n", | |
"\t linen: 16445670,\n", | |
"\t magenta: 16711935,\n", | |
"\t maroon: 8388608,\n", | |
"\t mediumaquamarine: 6737322,\n", | |
"\t mediumblue: 205,\n", | |
"\t mediumorchid: 12211667,\n", | |
"\t mediumpurple: 9662683,\n", | |
"\t mediumseagreen: 3978097,\n", | |
"\t mediumslateblue: 8087790,\n", | |
"\t mediumspringgreen: 64154,\n", | |
"\t mediumturquoise: 4772300,\n", | |
"\t mediumvioletred: 13047173,\n", | |
"\t midnightblue: 1644912,\n", | |
"\t mintcream: 16121850,\n", | |
"\t mistyrose: 16770273,\n", | |
"\t moccasin: 16770229,\n", | |
"\t navajowhite: 16768685,\n", | |
"\t navy: 128,\n", | |
"\t oldlace: 16643558,\n", | |
"\t olive: 8421376,\n", | |
"\t olivedrab: 7048739,\n", | |
"\t orange: 16753920,\n", | |
"\t orangered: 16729344,\n", | |
"\t orchid: 14315734,\n", | |
"\t palegoldenrod: 15657130,\n", | |
"\t palegreen: 10025880,\n", | |
"\t paleturquoise: 11529966,\n", | |
"\t palevioletred: 14381203,\n", | |
"\t papayawhip: 16773077,\n", | |
"\t peachpuff: 16767673,\n", | |
"\t peru: 13468991,\n", | |
"\t pink: 16761035,\n", | |
"\t plum: 14524637,\n", | |
"\t powderblue: 11591910,\n", | |
"\t purple: 8388736,\n", | |
"\t rebeccapurple: 6697881,\n", | |
"\t red: 16711680,\n", | |
"\t rosybrown: 12357519,\n", | |
"\t royalblue: 4286945,\n", | |
"\t saddlebrown: 9127187,\n", | |
"\t salmon: 16416882,\n", | |
"\t sandybrown: 16032864,\n", | |
"\t seagreen: 3050327,\n", | |
"\t seashell: 16774638,\n", | |
"\t sienna: 10506797,\n", | |
"\t silver: 12632256,\n", | |
"\t skyblue: 8900331,\n", | |
"\t slateblue: 6970061,\n", | |
"\t slategray: 7372944,\n", | |
"\t slategrey: 7372944,\n", | |
"\t snow: 16775930,\n", | |
"\t springgreen: 65407,\n", | |
"\t steelblue: 4620980,\n", | |
"\t tan: 13808780,\n", | |
"\t teal: 32896,\n", | |
"\t thistle: 14204888,\n", | |
"\t tomato: 16737095,\n", | |
"\t turquoise: 4251856,\n", | |
"\t violet: 15631086,\n", | |
"\t wheat: 16113331,\n", | |
"\t white: 16777215,\n", | |
"\t whitesmoke: 16119285,\n", | |
"\t yellow: 16776960,\n", | |
"\t yellowgreen: 10145074\n", | |
"\t });\n", | |
"\t d3_rgb_names.forEach(function(key, value) {\n", | |
"\t d3_rgb_names.set(key, d3_rgbNumber(value));\n", | |
"\t });\n", | |
"\t function d3_functor(v) {\n", | |
"\t return typeof v === \"function\" ? v : function() {\n", | |
"\t return v;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.functor = d3_functor;\n", | |
"\t d3.xhr = d3_xhrType(d3_identity);\n", | |
"\t function d3_xhrType(response) {\n", | |
"\t return function(url, mimeType, callback) {\n", | |
"\t if (arguments.length === 2 && typeof mimeType === \"function\") callback = mimeType, \n", | |
"\t mimeType = null;\n", | |
"\t return d3_xhr(url, mimeType, response, callback);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_xhr(url, mimeType, response, callback) {\n", | |
"\t var xhr = {}, dispatch = d3.dispatch(\"beforesend\", \"progress\", \"load\", \"error\"), headers = {}, request = new XMLHttpRequest(), responseType = null;\n", | |
"\t if (this.XDomainRequest && !(\"withCredentials\" in request) && /^(http(s)?:)?\\/\\//.test(url)) request = new XDomainRequest();\n", | |
"\t \"onload\" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {\n", | |
"\t request.readyState > 3 && respond();\n", | |
"\t };\n", | |
"\t function respond() {\n", | |
"\t var status = request.status, result;\n", | |
"\t if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) {\n", | |
"\t try {\n", | |
"\t result = response.call(xhr, request);\n", | |
"\t } catch (e) {\n", | |
"\t dispatch.error.call(xhr, e);\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t dispatch.load.call(xhr, result);\n", | |
"\t } else {\n", | |
"\t dispatch.error.call(xhr, request);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t request.onprogress = function(event) {\n", | |
"\t var o = d3.event;\n", | |
"\t d3.event = event;\n", | |
"\t try {\n", | |
"\t dispatch.progress.call(xhr, request);\n", | |
"\t } finally {\n", | |
"\t d3.event = o;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t xhr.header = function(name, value) {\n", | |
"\t name = (name + \"\").toLowerCase();\n", | |
"\t if (arguments.length < 2) return headers[name];\n", | |
"\t if (value == null) delete headers[name]; else headers[name] = value + \"\";\n", | |
"\t return xhr;\n", | |
"\t };\n", | |
"\t xhr.mimeType = function(value) {\n", | |
"\t if (!arguments.length) return mimeType;\n", | |
"\t mimeType = value == null ? null : value + \"\";\n", | |
"\t return xhr;\n", | |
"\t };\n", | |
"\t xhr.responseType = function(value) {\n", | |
"\t if (!arguments.length) return responseType;\n", | |
"\t responseType = value;\n", | |
"\t return xhr;\n", | |
"\t };\n", | |
"\t xhr.response = function(value) {\n", | |
"\t response = value;\n", | |
"\t return xhr;\n", | |
"\t };\n", | |
"\t [ \"get\", \"post\" ].forEach(function(method) {\n", | |
"\t xhr[method] = function() {\n", | |
"\t return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments)));\n", | |
"\t };\n", | |
"\t });\n", | |
"\t xhr.send = function(method, data, callback) {\n", | |
"\t if (arguments.length === 2 && typeof data === \"function\") callback = data, data = null;\n", | |
"\t request.open(method, url, true);\n", | |
"\t if (mimeType != null && !(\"accept\" in headers)) headers[\"accept\"] = mimeType + \",*/*\";\n", | |
"\t if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]);\n", | |
"\t if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType);\n", | |
"\t if (responseType != null) request.responseType = responseType;\n", | |
"\t if (callback != null) xhr.on(\"error\", callback).on(\"load\", function(request) {\n", | |
"\t callback(null, request);\n", | |
"\t });\n", | |
"\t dispatch.beforesend.call(xhr, request);\n", | |
"\t request.send(data == null ? null : data);\n", | |
"\t return xhr;\n", | |
"\t };\n", | |
"\t xhr.abort = function() {\n", | |
"\t request.abort();\n", | |
"\t return xhr;\n", | |
"\t };\n", | |
"\t d3.rebind(xhr, dispatch, \"on\");\n", | |
"\t return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));\n", | |
"\t }\n", | |
"\t function d3_xhr_fixCallback(callback) {\n", | |
"\t return callback.length === 1 ? function(error, request) {\n", | |
"\t callback(error == null ? request : null);\n", | |
"\t } : callback;\n", | |
"\t }\n", | |
"\t function d3_xhrHasResponse(request) {\n", | |
"\t var type = request.responseType;\n", | |
"\t return type && type !== \"text\" ? request.response : request.responseText;\n", | |
"\t }\n", | |
"\t d3.dsv = function(delimiter, mimeType) {\n", | |
"\t var reFormat = new RegExp('[\"' + delimiter + \"\\n]\"), delimiterCode = delimiter.charCodeAt(0);\n", | |
"\t function dsv(url, row, callback) {\n", | |
"\t if (arguments.length < 3) callback = row, row = null;\n", | |
"\t var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback);\n", | |
"\t xhr.row = function(_) {\n", | |
"\t return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row;\n", | |
"\t };\n", | |
"\t return xhr;\n", | |
"\t }\n", | |
"\t function response(request) {\n", | |
"\t return dsv.parse(request.responseText);\n", | |
"\t }\n", | |
"\t function typedResponse(f) {\n", | |
"\t return function(request) {\n", | |
"\t return dsv.parse(request.responseText, f);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t dsv.parse = function(text, f) {\n", | |
"\t var o;\n", | |
"\t return dsv.parseRows(text, function(row, i) {\n", | |
"\t if (o) return o(row, i - 1);\n", | |
"\t var a = new Function(\"d\", \"return {\" + row.map(function(name, i) {\n", | |
"\t return JSON.stringify(name) + \": d[\" + i + \"]\";\n", | |
"\t }).join(\",\") + \"}\");\n", | |
"\t o = f ? function(row, i) {\n", | |
"\t return f(a(row), i);\n", | |
"\t } : a;\n", | |
"\t });\n", | |
"\t };\n", | |
"\t dsv.parseRows = function(text, f) {\n", | |
"\t var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol;\n", | |
"\t function token() {\n", | |
"\t if (I >= N) return EOF;\n", | |
"\t if (eol) return eol = false, EOL;\n", | |
"\t var j = I;\n", | |
"\t if (text.charCodeAt(j) === 34) {\n", | |
"\t var i = j;\n", | |
"\t while (i++ < N) {\n", | |
"\t if (text.charCodeAt(i) === 34) {\n", | |
"\t if (text.charCodeAt(i + 1) !== 34) break;\n", | |
"\t ++i;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t I = i + 2;\n", | |
"\t var c = text.charCodeAt(i + 1);\n", | |
"\t if (c === 13) {\n", | |
"\t eol = true;\n", | |
"\t if (text.charCodeAt(i + 2) === 10) ++I;\n", | |
"\t } else if (c === 10) {\n", | |
"\t eol = true;\n", | |
"\t }\n", | |
"\t return text.slice(j + 1, i).replace(/\"\"/g, '\"');\n", | |
"\t }\n", | |
"\t while (I < N) {\n", | |
"\t var c = text.charCodeAt(I++), k = 1;\n", | |
"\t if (c === 10) eol = true; else if (c === 13) {\n", | |
"\t eol = true;\n", | |
"\t if (text.charCodeAt(I) === 10) ++I, ++k;\n", | |
"\t } else if (c !== delimiterCode) continue;\n", | |
"\t return text.slice(j, I - k);\n", | |
"\t }\n", | |
"\t return text.slice(j);\n", | |
"\t }\n", | |
"\t while ((t = token()) !== EOF) {\n", | |
"\t var a = [];\n", | |
"\t while (t !== EOL && t !== EOF) {\n", | |
"\t a.push(t);\n", | |
"\t t = token();\n", | |
"\t }\n", | |
"\t if (f && (a = f(a, n++)) == null) continue;\n", | |
"\t rows.push(a);\n", | |
"\t }\n", | |
"\t return rows;\n", | |
"\t };\n", | |
"\t dsv.format = function(rows) {\n", | |
"\t if (Array.isArray(rows[0])) return dsv.formatRows(rows);\n", | |
"\t var fieldSet = new d3_Set(), fields = [];\n", | |
"\t rows.forEach(function(row) {\n", | |
"\t for (var field in row) {\n", | |
"\t if (!fieldSet.has(field)) {\n", | |
"\t fields.push(fieldSet.add(field));\n", | |
"\t }\n", | |
"\t }\n", | |
"\t });\n", | |
"\t return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) {\n", | |
"\t return fields.map(function(field) {\n", | |
"\t return formatValue(row[field]);\n", | |
"\t }).join(delimiter);\n", | |
"\t })).join(\"\\n\");\n", | |
"\t };\n", | |
"\t dsv.formatRows = function(rows) {\n", | |
"\t return rows.map(formatRow).join(\"\\n\");\n", | |
"\t };\n", | |
"\t function formatRow(row) {\n", | |
"\t return row.map(formatValue).join(delimiter);\n", | |
"\t }\n", | |
"\t function formatValue(text) {\n", | |
"\t return reFormat.test(text) ? '\"' + text.replace(/\\\"/g, '\"\"') + '\"' : text;\n", | |
"\t }\n", | |
"\t return dsv;\n", | |
"\t };\n", | |
"\t d3.csv = d3.dsv(\",\", \"text/csv\");\n", | |
"\t d3.tsv = d3.dsv(\"\t\", \"text/tab-separated-values\");\n", | |
"\t var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_frame = this[d3_vendorSymbol(this, \"requestAnimationFrame\")] || function(callback) {\n", | |
"\t setTimeout(callback, 17);\n", | |
"\t };\n", | |
"\t d3.timer = function() {\n", | |
"\t d3_timer.apply(this, arguments);\n", | |
"\t };\n", | |
"\t function d3_timer(callback, delay, then) {\n", | |
"\t var n = arguments.length;\n", | |
"\t if (n < 2) delay = 0;\n", | |
"\t if (n < 3) then = Date.now();\n", | |
"\t var time = then + delay, timer = {\n", | |
"\t c: callback,\n", | |
"\t t: time,\n", | |
"\t n: null\n", | |
"\t };\n", | |
"\t if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer;\n", | |
"\t d3_timer_queueTail = timer;\n", | |
"\t if (!d3_timer_interval) {\n", | |
"\t d3_timer_timeout = clearTimeout(d3_timer_timeout);\n", | |
"\t d3_timer_interval = 1;\n", | |
"\t d3_timer_frame(d3_timer_step);\n", | |
"\t }\n", | |
"\t return timer;\n", | |
"\t }\n", | |
"\t function d3_timer_step() {\n", | |
"\t var now = d3_timer_mark(), delay = d3_timer_sweep() - now;\n", | |
"\t if (delay > 24) {\n", | |
"\t if (isFinite(delay)) {\n", | |
"\t clearTimeout(d3_timer_timeout);\n", | |
"\t d3_timer_timeout = setTimeout(d3_timer_step, delay);\n", | |
"\t }\n", | |
"\t d3_timer_interval = 0;\n", | |
"\t } else {\n", | |
"\t d3_timer_interval = 1;\n", | |
"\t d3_timer_frame(d3_timer_step);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3.timer.flush = function() {\n", | |
"\t d3_timer_mark();\n", | |
"\t d3_timer_sweep();\n", | |
"\t };\n", | |
"\t function d3_timer_mark() {\n", | |
"\t var now = Date.now(), timer = d3_timer_queueHead;\n", | |
"\t while (timer) {\n", | |
"\t if (now >= timer.t && timer.c(now - timer.t)) timer.c = null;\n", | |
"\t timer = timer.n;\n", | |
"\t }\n", | |
"\t return now;\n", | |
"\t }\n", | |
"\t function d3_timer_sweep() {\n", | |
"\t var t0, t1 = d3_timer_queueHead, time = Infinity;\n", | |
"\t while (t1) {\n", | |
"\t if (t1.c) {\n", | |
"\t if (t1.t < time) time = t1.t;\n", | |
"\t t1 = (t0 = t1).n;\n", | |
"\t } else {\n", | |
"\t t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3_timer_queueTail = t0;\n", | |
"\t return time;\n", | |
"\t }\n", | |
"\t function d3_format_precision(x, p) {\n", | |
"\t return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1);\n", | |
"\t }\n", | |
"\t d3.round = function(x, n) {\n", | |
"\t return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);\n", | |
"\t };\n", | |
"\t var d3_formatPrefixes = [ \"y\", \"z\", \"a\", \"f\", \"p\", \"n\", \"µ\", \"m\", \"\", \"k\", \"M\", \"G\", \"T\", \"P\", \"E\", \"Z\", \"Y\" ].map(d3_formatPrefix);\n", | |
"\t d3.formatPrefix = function(value, precision) {\n", | |
"\t var i = 0;\n", | |
"\t if (value = +value) {\n", | |
"\t if (value < 0) value *= -1;\n", | |
"\t if (precision) value = d3.round(value, d3_format_precision(value, precision));\n", | |
"\t i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);\n", | |
"\t i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3));\n", | |
"\t }\n", | |
"\t return d3_formatPrefixes[8 + i / 3];\n", | |
"\t };\n", | |
"\t function d3_formatPrefix(d, i) {\n", | |
"\t var k = Math.pow(10, abs(8 - i) * 3);\n", | |
"\t return {\n", | |
"\t scale: i > 8 ? function(d) {\n", | |
"\t return d / k;\n", | |
"\t } : function(d) {\n", | |
"\t return d * k;\n", | |
"\t },\n", | |
"\t symbol: d\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_locale_numberFormat(locale) {\n", | |
"\t var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping && locale_thousands ? function(value, width) {\n", | |
"\t var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0;\n", | |
"\t while (i > 0 && g > 0) {\n", | |
"\t if (length + g + 1 > width) g = Math.max(1, width - length);\n", | |
"\t t.push(value.substring(i -= g, i + g));\n", | |
"\t if ((length += g + 1) > width) break;\n", | |
"\t g = locale_grouping[j = (j + 1) % locale_grouping.length];\n", | |
"\t }\n", | |
"\t return t.reverse().join(locale_thousands);\n", | |
"\t } : d3_identity;\n", | |
"\t return function(specifier) {\n", | |
"\t var match = d3_format_re.exec(specifier), fill = match[1] || \" \", align = match[2] || \">\", sign = match[3] || \"-\", symbol = match[4] || \"\", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = \"\", suffix = \"\", integer = false, exponent = true;\n", | |
"\t if (precision) precision = +precision.substring(1);\n", | |
"\t if (zfill || fill === \"0\" && align === \"=\") {\n", | |
"\t zfill = fill = \"0\";\n", | |
"\t align = \"=\";\n", | |
"\t }\n", | |
"\t switch (type) {\n", | |
"\t case \"n\":\n", | |
"\t comma = true;\n", | |
"\t type = \"g\";\n", | |
"\t break;\n", | |
"\t\n", | |
"\t case \"%\":\n", | |
"\t scale = 100;\n", | |
"\t suffix = \"%\";\n", | |
"\t type = \"f\";\n", | |
"\t break;\n", | |
"\t\n", | |
"\t case \"p\":\n", | |
"\t scale = 100;\n", | |
"\t suffix = \"%\";\n", | |
"\t type = \"r\";\n", | |
"\t break;\n", | |
"\t\n", | |
"\t case \"b\":\n", | |
"\t case \"o\":\n", | |
"\t case \"x\":\n", | |
"\t case \"X\":\n", | |
"\t if (symbol === \"#\") prefix = \"0\" + type.toLowerCase();\n", | |
"\t\n", | |
"\t case \"c\":\n", | |
"\t exponent = false;\n", | |
"\t\n", | |
"\t case \"d\":\n", | |
"\t integer = true;\n", | |
"\t precision = 0;\n", | |
"\t break;\n", | |
"\t\n", | |
"\t case \"s\":\n", | |
"\t scale = -1;\n", | |
"\t type = \"r\";\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t if (symbol === \"$\") prefix = locale_currency[0], suffix = locale_currency[1];\n", | |
"\t if (type == \"r\" && !precision) type = \"g\";\n", | |
"\t if (precision != null) {\n", | |
"\t if (type == \"g\") precision = Math.max(1, Math.min(21, precision)); else if (type == \"e\" || type == \"f\") precision = Math.max(0, Math.min(20, precision));\n", | |
"\t }\n", | |
"\t type = d3_format_types.get(type) || d3_format_typeDefault;\n", | |
"\t var zcomma = zfill && comma;\n", | |
"\t return function(value) {\n", | |
"\t var fullSuffix = suffix;\n", | |
"\t if (integer && value % 1) return \"\";\n", | |
"\t var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, \"-\") : sign === \"-\" ? \"\" : sign;\n", | |
"\t if (scale < 0) {\n", | |
"\t var unit = d3.formatPrefix(value, precision);\n", | |
"\t value = unit.scale(value);\n", | |
"\t fullSuffix = unit.symbol + suffix;\n", | |
"\t } else {\n", | |
"\t value *= scale;\n", | |
"\t }\n", | |
"\t value = type(value, precision);\n", | |
"\t var i = value.lastIndexOf(\".\"), before, after;\n", | |
"\t if (i < 0) {\n", | |
"\t var j = exponent ? value.lastIndexOf(\"e\") : -1;\n", | |
"\t if (j < 0) before = value, after = \"\"; else before = value.substring(0, j), after = value.substring(j);\n", | |
"\t } else {\n", | |
"\t before = value.substring(0, i);\n", | |
"\t after = locale_decimal + value.substring(i + 1);\n", | |
"\t }\n", | |
"\t if (!zfill && comma) before = formatGroup(before, Infinity);\n", | |
"\t var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : \"\";\n", | |
"\t if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity);\n", | |
"\t negative += prefix;\n", | |
"\t value = before + after;\n", | |
"\t return (align === \"<\" ? negative + value + padding : align === \">\" ? padding + negative + value : align === \"^\" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + fullSuffix;\n", | |
"\t };\n", | |
"\t };\n", | |
"\t }\n", | |
"\t var d3_format_re = /(?:([^{])?([<>=^]))?([+\\- ])?([$#])?(0)?(\\d+)?(,)?(\\.-?\\d+)?([a-z%])?/i;\n", | |
"\t var d3_format_types = d3.map({\n", | |
"\t b: function(x) {\n", | |
"\t return x.toString(2);\n", | |
"\t },\n", | |
"\t c: function(x) {\n", | |
"\t return String.fromCharCode(x);\n", | |
"\t },\n", | |
"\t o: function(x) {\n", | |
"\t return x.toString(8);\n", | |
"\t },\n", | |
"\t x: function(x) {\n", | |
"\t return x.toString(16);\n", | |
"\t },\n", | |
"\t X: function(x) {\n", | |
"\t return x.toString(16).toUpperCase();\n", | |
"\t },\n", | |
"\t g: function(x, p) {\n", | |
"\t return x.toPrecision(p);\n", | |
"\t },\n", | |
"\t e: function(x, p) {\n", | |
"\t return x.toExponential(p);\n", | |
"\t },\n", | |
"\t f: function(x, p) {\n", | |
"\t return x.toFixed(p);\n", | |
"\t },\n", | |
"\t r: function(x, p) {\n", | |
"\t return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p))));\n", | |
"\t }\n", | |
"\t });\n", | |
"\t function d3_format_typeDefault(x) {\n", | |
"\t return x + \"\";\n", | |
"\t }\n", | |
"\t var d3_time = d3.time = {}, d3_date = Date;\n", | |
"\t function d3_date_utc() {\n", | |
"\t this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);\n", | |
"\t }\n", | |
"\t d3_date_utc.prototype = {\n", | |
"\t getDate: function() {\n", | |
"\t return this._.getUTCDate();\n", | |
"\t },\n", | |
"\t getDay: function() {\n", | |
"\t return this._.getUTCDay();\n", | |
"\t },\n", | |
"\t getFullYear: function() {\n", | |
"\t return this._.getUTCFullYear();\n", | |
"\t },\n", | |
"\t getHours: function() {\n", | |
"\t return this._.getUTCHours();\n", | |
"\t },\n", | |
"\t getMilliseconds: function() {\n", | |
"\t return this._.getUTCMilliseconds();\n", | |
"\t },\n", | |
"\t getMinutes: function() {\n", | |
"\t return this._.getUTCMinutes();\n", | |
"\t },\n", | |
"\t getMonth: function() {\n", | |
"\t return this._.getUTCMonth();\n", | |
"\t },\n", | |
"\t getSeconds: function() {\n", | |
"\t return this._.getUTCSeconds();\n", | |
"\t },\n", | |
"\t getTime: function() {\n", | |
"\t return this._.getTime();\n", | |
"\t },\n", | |
"\t getTimezoneOffset: function() {\n", | |
"\t return 0;\n", | |
"\t },\n", | |
"\t valueOf: function() {\n", | |
"\t return this._.valueOf();\n", | |
"\t },\n", | |
"\t setDate: function() {\n", | |
"\t d3_time_prototype.setUTCDate.apply(this._, arguments);\n", | |
"\t },\n", | |
"\t setDay: function() {\n", | |
"\t d3_time_prototype.setUTCDay.apply(this._, arguments);\n", | |
"\t },\n", | |
"\t setFullYear: function() {\n", | |
"\t d3_time_prototype.setUTCFullYear.apply(this._, arguments);\n", | |
"\t },\n", | |
"\t setHours: function() {\n", | |
"\t d3_time_prototype.setUTCHours.apply(this._, arguments);\n", | |
"\t },\n", | |
"\t setMilliseconds: function() {\n", | |
"\t d3_time_prototype.setUTCMilliseconds.apply(this._, arguments);\n", | |
"\t },\n", | |
"\t setMinutes: function() {\n", | |
"\t d3_time_prototype.setUTCMinutes.apply(this._, arguments);\n", | |
"\t },\n", | |
"\t setMonth: function() {\n", | |
"\t d3_time_prototype.setUTCMonth.apply(this._, arguments);\n", | |
"\t },\n", | |
"\t setSeconds: function() {\n", | |
"\t d3_time_prototype.setUTCSeconds.apply(this._, arguments);\n", | |
"\t },\n", | |
"\t setTime: function() {\n", | |
"\t d3_time_prototype.setTime.apply(this._, arguments);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t var d3_time_prototype = Date.prototype;\n", | |
"\t function d3_time_interval(local, step, number) {\n", | |
"\t function round(date) {\n", | |
"\t var d0 = local(date), d1 = offset(d0, 1);\n", | |
"\t return date - d0 < d1 - date ? d0 : d1;\n", | |
"\t }\n", | |
"\t function ceil(date) {\n", | |
"\t step(date = local(new d3_date(date - 1)), 1);\n", | |
"\t return date;\n", | |
"\t }\n", | |
"\t function offset(date, k) {\n", | |
"\t step(date = new d3_date(+date), k);\n", | |
"\t return date;\n", | |
"\t }\n", | |
"\t function range(t0, t1, dt) {\n", | |
"\t var time = ceil(t0), times = [];\n", | |
"\t if (dt > 1) {\n", | |
"\t while (time < t1) {\n", | |
"\t if (!(number(time) % dt)) times.push(new Date(+time));\n", | |
"\t step(time, 1);\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t while (time < t1) times.push(new Date(+time)), step(time, 1);\n", | |
"\t }\n", | |
"\t return times;\n", | |
"\t }\n", | |
"\t function range_utc(t0, t1, dt) {\n", | |
"\t try {\n", | |
"\t d3_date = d3_date_utc;\n", | |
"\t var utc = new d3_date_utc();\n", | |
"\t utc._ = t0;\n", | |
"\t return range(utc, t1, dt);\n", | |
"\t } finally {\n", | |
"\t d3_date = Date;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t local.floor = local;\n", | |
"\t local.round = round;\n", | |
"\t local.ceil = ceil;\n", | |
"\t local.offset = offset;\n", | |
"\t local.range = range;\n", | |
"\t var utc = local.utc = d3_time_interval_utc(local);\n", | |
"\t utc.floor = utc;\n", | |
"\t utc.round = d3_time_interval_utc(round);\n", | |
"\t utc.ceil = d3_time_interval_utc(ceil);\n", | |
"\t utc.offset = d3_time_interval_utc(offset);\n", | |
"\t utc.range = range_utc;\n", | |
"\t return local;\n", | |
"\t }\n", | |
"\t function d3_time_interval_utc(method) {\n", | |
"\t return function(date, k) {\n", | |
"\t try {\n", | |
"\t d3_date = d3_date_utc;\n", | |
"\t var utc = new d3_date_utc();\n", | |
"\t utc._ = date;\n", | |
"\t return method(utc, k)._;\n", | |
"\t } finally {\n", | |
"\t d3_date = Date;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3_time.year = d3_time_interval(function(date) {\n", | |
"\t date = d3_time.day(date);\n", | |
"\t date.setMonth(0, 1);\n", | |
"\t return date;\n", | |
"\t }, function(date, offset) {\n", | |
"\t date.setFullYear(date.getFullYear() + offset);\n", | |
"\t }, function(date) {\n", | |
"\t return date.getFullYear();\n", | |
"\t });\n", | |
"\t d3_time.years = d3_time.year.range;\n", | |
"\t d3_time.years.utc = d3_time.year.utc.range;\n", | |
"\t d3_time.day = d3_time_interval(function(date) {\n", | |
"\t var day = new d3_date(2e3, 0);\n", | |
"\t day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());\n", | |
"\t return day;\n", | |
"\t }, function(date, offset) {\n", | |
"\t date.setDate(date.getDate() + offset);\n", | |
"\t }, function(date) {\n", | |
"\t return date.getDate() - 1;\n", | |
"\t });\n", | |
"\t d3_time.days = d3_time.day.range;\n", | |
"\t d3_time.days.utc = d3_time.day.utc.range;\n", | |
"\t d3_time.dayOfYear = function(date) {\n", | |
"\t var year = d3_time.year(date);\n", | |
"\t return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);\n", | |
"\t };\n", | |
"\t [ \"sunday\", \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\" ].forEach(function(day, i) {\n", | |
"\t i = 7 - i;\n", | |
"\t var interval = d3_time[day] = d3_time_interval(function(date) {\n", | |
"\t (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);\n", | |
"\t return date;\n", | |
"\t }, function(date, offset) {\n", | |
"\t date.setDate(date.getDate() + Math.floor(offset) * 7);\n", | |
"\t }, function(date) {\n", | |
"\t var day = d3_time.year(date).getDay();\n", | |
"\t return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);\n", | |
"\t });\n", | |
"\t d3_time[day + \"s\"] = interval.range;\n", | |
"\t d3_time[day + \"s\"].utc = interval.utc.range;\n", | |
"\t d3_time[day + \"OfYear\"] = function(date) {\n", | |
"\t var day = d3_time.year(date).getDay();\n", | |
"\t return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7);\n", | |
"\t };\n", | |
"\t });\n", | |
"\t d3_time.week = d3_time.sunday;\n", | |
"\t d3_time.weeks = d3_time.sunday.range;\n", | |
"\t d3_time.weeks.utc = d3_time.sunday.utc.range;\n", | |
"\t d3_time.weekOfYear = d3_time.sundayOfYear;\n", | |
"\t function d3_locale_timeFormat(locale) {\n", | |
"\t var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_days = locale.days, locale_shortDays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths;\n", | |
"\t function d3_time_format(template) {\n", | |
"\t var n = template.length;\n", | |
"\t function format(date) {\n", | |
"\t var string = [], i = -1, j = 0, c, p, f;\n", | |
"\t while (++i < n) {\n", | |
"\t if (template.charCodeAt(i) === 37) {\n", | |
"\t string.push(template.slice(j, i));\n", | |
"\t if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i);\n", | |
"\t if (f = d3_time_formats[c]) c = f(date, p == null ? c === \"e\" ? \" \" : \"0\" : p);\n", | |
"\t string.push(c);\n", | |
"\t j = i + 1;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t string.push(template.slice(j, i));\n", | |
"\t return string.join(\"\");\n", | |
"\t }\n", | |
"\t format.parse = function(string) {\n", | |
"\t var d = {\n", | |
"\t y: 1900,\n", | |
"\t m: 0,\n", | |
"\t d: 1,\n", | |
"\t H: 0,\n", | |
"\t M: 0,\n", | |
"\t S: 0,\n", | |
"\t L: 0,\n", | |
"\t Z: null\n", | |
"\t }, i = d3_time_parse(d, template, string, 0);\n", | |
"\t if (i != string.length) return null;\n", | |
"\t if (\"p\" in d) d.H = d.H % 12 + d.p * 12;\n", | |
"\t var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)();\n", | |
"\t if (\"j\" in d) date.setFullYear(d.y, 0, d.j); else if (\"W\" in d || \"U\" in d) {\n", | |
"\t if (!(\"w\" in d)) d.w = \"W\" in d ? 1 : 0;\n", | |
"\t date.setFullYear(d.y, 0, 1);\n", | |
"\t date.setFullYear(d.y, 0, \"W\" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7);\n", | |
"\t } else date.setFullYear(d.y, d.m, d.d);\n", | |
"\t date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L);\n", | |
"\t return localZ ? date._ : date;\n", | |
"\t };\n", | |
"\t format.toString = function() {\n", | |
"\t return template;\n", | |
"\t };\n", | |
"\t return format;\n", | |
"\t }\n", | |
"\t function d3_time_parse(date, template, string, j) {\n", | |
"\t var c, p, t, i = 0, n = template.length, m = string.length;\n", | |
"\t while (i < n) {\n", | |
"\t if (j >= m) return -1;\n", | |
"\t c = template.charCodeAt(i++);\n", | |
"\t if (c === 37) {\n", | |
"\t t = template.charAt(i++);\n", | |
"\t p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t];\n", | |
"\t if (!p || (j = p(date, string, j)) < 0) return -1;\n", | |
"\t } else if (c != string.charCodeAt(j++)) {\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return j;\n", | |
"\t }\n", | |
"\t d3_time_format.utc = function(template) {\n", | |
"\t var local = d3_time_format(template);\n", | |
"\t function format(date) {\n", | |
"\t try {\n", | |
"\t d3_date = d3_date_utc;\n", | |
"\t var utc = new d3_date();\n", | |
"\t utc._ = date;\n", | |
"\t return local(utc);\n", | |
"\t } finally {\n", | |
"\t d3_date = Date;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t format.parse = function(string) {\n", | |
"\t try {\n", | |
"\t d3_date = d3_date_utc;\n", | |
"\t var date = local.parse(string);\n", | |
"\t return date && date._;\n", | |
"\t } finally {\n", | |
"\t d3_date = Date;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t format.toString = local.toString;\n", | |
"\t return format;\n", | |
"\t };\n", | |
"\t d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti;\n", | |
"\t var d3_time_periodLookup = d3.map(), d3_time_dayRe = d3_time_formatRe(locale_days), d3_time_dayLookup = d3_time_formatLookup(locale_days), d3_time_dayAbbrevRe = d3_time_formatRe(locale_shortDays), d3_time_dayAbbrevLookup = d3_time_formatLookup(locale_shortDays), d3_time_monthRe = d3_time_formatRe(locale_months), d3_time_monthLookup = d3_time_formatLookup(locale_months), d3_time_monthAbbrevRe = d3_time_formatRe(locale_shortMonths), d3_time_monthAbbrevLookup = d3_time_formatLookup(locale_shortMonths);\n", | |
"\t locale_periods.forEach(function(p, i) {\n", | |
"\t d3_time_periodLookup.set(p.toLowerCase(), i);\n", | |
"\t });\n", | |
"\t var d3_time_formats = {\n", | |
"\t a: function(d) {\n", | |
"\t return locale_shortDays[d.getDay()];\n", | |
"\t },\n", | |
"\t A: function(d) {\n", | |
"\t return locale_days[d.getDay()];\n", | |
"\t },\n", | |
"\t b: function(d) {\n", | |
"\t return locale_shortMonths[d.getMonth()];\n", | |
"\t },\n", | |
"\t B: function(d) {\n", | |
"\t return locale_months[d.getMonth()];\n", | |
"\t },\n", | |
"\t c: d3_time_format(locale_dateTime),\n", | |
"\t d: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getDate(), p, 2);\n", | |
"\t },\n", | |
"\t e: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getDate(), p, 2);\n", | |
"\t },\n", | |
"\t H: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getHours(), p, 2);\n", | |
"\t },\n", | |
"\t I: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getHours() % 12 || 12, p, 2);\n", | |
"\t },\n", | |
"\t j: function(d, p) {\n", | |
"\t return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3);\n", | |
"\t },\n", | |
"\t L: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getMilliseconds(), p, 3);\n", | |
"\t },\n", | |
"\t m: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getMonth() + 1, p, 2);\n", | |
"\t },\n", | |
"\t M: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getMinutes(), p, 2);\n", | |
"\t },\n", | |
"\t p: function(d) {\n", | |
"\t return locale_periods[+(d.getHours() >= 12)];\n", | |
"\t },\n", | |
"\t S: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getSeconds(), p, 2);\n", | |
"\t },\n", | |
"\t U: function(d, p) {\n", | |
"\t return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2);\n", | |
"\t },\n", | |
"\t w: function(d) {\n", | |
"\t return d.getDay();\n", | |
"\t },\n", | |
"\t W: function(d, p) {\n", | |
"\t return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2);\n", | |
"\t },\n", | |
"\t x: d3_time_format(locale_date),\n", | |
"\t X: d3_time_format(locale_time),\n", | |
"\t y: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getFullYear() % 100, p, 2);\n", | |
"\t },\n", | |
"\t Y: function(d, p) {\n", | |
"\t return d3_time_formatPad(d.getFullYear() % 1e4, p, 4);\n", | |
"\t },\n", | |
"\t Z: d3_time_zone,\n", | |
"\t \"%\": function() {\n", | |
"\t return \"%\";\n", | |
"\t }\n", | |
"\t };\n", | |
"\t var d3_time_parsers = {\n", | |
"\t a: d3_time_parseWeekdayAbbrev,\n", | |
"\t A: d3_time_parseWeekday,\n", | |
"\t b: d3_time_parseMonthAbbrev,\n", | |
"\t B: d3_time_parseMonth,\n", | |
"\t c: d3_time_parseLocaleFull,\n", | |
"\t d: d3_time_parseDay,\n", | |
"\t e: d3_time_parseDay,\n", | |
"\t H: d3_time_parseHour24,\n", | |
"\t I: d3_time_parseHour24,\n", | |
"\t j: d3_time_parseDayOfYear,\n", | |
"\t L: d3_time_parseMilliseconds,\n", | |
"\t m: d3_time_parseMonthNumber,\n", | |
"\t M: d3_time_parseMinutes,\n", | |
"\t p: d3_time_parseAmPm,\n", | |
"\t S: d3_time_parseSeconds,\n", | |
"\t U: d3_time_parseWeekNumberSunday,\n", | |
"\t w: d3_time_parseWeekdayNumber,\n", | |
"\t W: d3_time_parseWeekNumberMonday,\n", | |
"\t x: d3_time_parseLocaleDate,\n", | |
"\t X: d3_time_parseLocaleTime,\n", | |
"\t y: d3_time_parseYear,\n", | |
"\t Y: d3_time_parseFullYear,\n", | |
"\t Z: d3_time_parseZone,\n", | |
"\t \"%\": d3_time_parseLiteralPercent\n", | |
"\t };\n", | |
"\t function d3_time_parseWeekdayAbbrev(date, string, i) {\n", | |
"\t d3_time_dayAbbrevRe.lastIndex = 0;\n", | |
"\t var n = d3_time_dayAbbrevRe.exec(string.slice(i));\n", | |
"\t return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseWeekday(date, string, i) {\n", | |
"\t d3_time_dayRe.lastIndex = 0;\n", | |
"\t var n = d3_time_dayRe.exec(string.slice(i));\n", | |
"\t return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseMonthAbbrev(date, string, i) {\n", | |
"\t d3_time_monthAbbrevRe.lastIndex = 0;\n", | |
"\t var n = d3_time_monthAbbrevRe.exec(string.slice(i));\n", | |
"\t return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseMonth(date, string, i) {\n", | |
"\t d3_time_monthRe.lastIndex = 0;\n", | |
"\t var n = d3_time_monthRe.exec(string.slice(i));\n", | |
"\t return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseLocaleFull(date, string, i) {\n", | |
"\t return d3_time_parse(date, d3_time_formats.c.toString(), string, i);\n", | |
"\t }\n", | |
"\t function d3_time_parseLocaleDate(date, string, i) {\n", | |
"\t return d3_time_parse(date, d3_time_formats.x.toString(), string, i);\n", | |
"\t }\n", | |
"\t function d3_time_parseLocaleTime(date, string, i) {\n", | |
"\t return d3_time_parse(date, d3_time_formats.X.toString(), string, i);\n", | |
"\t }\n", | |
"\t function d3_time_parseAmPm(date, string, i) {\n", | |
"\t var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase());\n", | |
"\t return n == null ? -1 : (date.p = n, i);\n", | |
"\t }\n", | |
"\t return d3_time_format;\n", | |
"\t }\n", | |
"\t var d3_time_formatPads = {\n", | |
"\t \"-\": \"\",\n", | |
"\t _: \" \",\n", | |
"\t \"0\": \"0\"\n", | |
"\t }, d3_time_numberRe = /^\\s*\\d+/, d3_time_percentRe = /^%/;\n", | |
"\t function d3_time_formatPad(value, fill, width) {\n", | |
"\t var sign = value < 0 ? \"-\" : \"\", string = (sign ? -value : value) + \"\", length = string.length;\n", | |
"\t return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);\n", | |
"\t }\n", | |
"\t function d3_time_formatRe(names) {\n", | |
"\t return new RegExp(\"^(?:\" + names.map(d3.requote).join(\"|\") + \")\", \"i\");\n", | |
"\t }\n", | |
"\t function d3_time_formatLookup(names) {\n", | |
"\t var map = new d3_Map(), i = -1, n = names.length;\n", | |
"\t while (++i < n) map.set(names[i].toLowerCase(), i);\n", | |
"\t return map;\n", | |
"\t }\n", | |
"\t function d3_time_parseWeekdayNumber(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 1));\n", | |
"\t return n ? (date.w = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseWeekNumberSunday(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i));\n", | |
"\t return n ? (date.U = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseWeekNumberMonday(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i));\n", | |
"\t return n ? (date.W = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseFullYear(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 4));\n", | |
"\t return n ? (date.y = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseYear(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n", | |
"\t return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseZone(date, string, i) {\n", | |
"\t return /^[+-]\\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string, \n", | |
"\t i + 5) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_expandYear(d) {\n", | |
"\t return d + (d > 68 ? 1900 : 2e3);\n", | |
"\t }\n", | |
"\t function d3_time_parseMonthNumber(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n", | |
"\t return n ? (date.m = n[0] - 1, i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseDay(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n", | |
"\t return n ? (date.d = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseDayOfYear(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 3));\n", | |
"\t return n ? (date.j = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseHour24(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n", | |
"\t return n ? (date.H = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseMinutes(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n", | |
"\t return n ? (date.M = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseSeconds(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n", | |
"\t return n ? (date.S = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_parseMilliseconds(date, string, i) {\n", | |
"\t d3_time_numberRe.lastIndex = 0;\n", | |
"\t var n = d3_time_numberRe.exec(string.slice(i, i + 3));\n", | |
"\t return n ? (date.L = +n[0], i + n[0].length) : -1;\n", | |
"\t }\n", | |
"\t function d3_time_zone(d) {\n", | |
"\t var z = d.getTimezoneOffset(), zs = z > 0 ? \"-\" : \"+\", zh = abs(z) / 60 | 0, zm = abs(z) % 60;\n", | |
"\t return zs + d3_time_formatPad(zh, \"0\", 2) + d3_time_formatPad(zm, \"0\", 2);\n", | |
"\t }\n", | |
"\t function d3_time_parseLiteralPercent(date, string, i) {\n", | |
"\t d3_time_percentRe.lastIndex = 0;\n", | |
"\t var n = d3_time_percentRe.exec(string.slice(i, i + 1));\n", | |
"\t return n ? i + n[0].length : -1;\n", | |
"\t }\n", | |
"\t function d3_time_formatMulti(formats) {\n", | |
"\t var n = formats.length, i = -1;\n", | |
"\t while (++i < n) formats[i][0] = this(formats[i][0]);\n", | |
"\t return function(date) {\n", | |
"\t var i = 0, f = formats[i];\n", | |
"\t while (!f[1](date)) f = formats[++i];\n", | |
"\t return f[0](date);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.locale = function(locale) {\n", | |
"\t return {\n", | |
"\t numberFormat: d3_locale_numberFormat(locale),\n", | |
"\t timeFormat: d3_locale_timeFormat(locale)\n", | |
"\t };\n", | |
"\t };\n", | |
"\t var d3_locale_enUS = d3.locale({\n", | |
"\t decimal: \".\",\n", | |
"\t thousands: \",\",\n", | |
"\t grouping: [ 3 ],\n", | |
"\t currency: [ \"$\", \"\" ],\n", | |
"\t dateTime: \"%a %b %e %X %Y\",\n", | |
"\t date: \"%m/%d/%Y\",\n", | |
"\t time: \"%H:%M:%S\",\n", | |
"\t periods: [ \"AM\", \"PM\" ],\n", | |
"\t days: [ \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\" ],\n", | |
"\t shortDays: [ \"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\" ],\n", | |
"\t months: [ \"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\" ],\n", | |
"\t shortMonths: [ \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" ]\n", | |
"\t });\n", | |
"\t d3.format = d3_locale_enUS.numberFormat;\n", | |
"\t d3.geo = {};\n", | |
"\t function d3_adder() {}\n", | |
"\t d3_adder.prototype = {\n", | |
"\t s: 0,\n", | |
"\t t: 0,\n", | |
"\t add: function(y) {\n", | |
"\t d3_adderSum(y, this.t, d3_adderTemp);\n", | |
"\t d3_adderSum(d3_adderTemp.s, this.s, this);\n", | |
"\t if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t;\n", | |
"\t },\n", | |
"\t reset: function() {\n", | |
"\t this.s = this.t = 0;\n", | |
"\t },\n", | |
"\t valueOf: function() {\n", | |
"\t return this.s;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t var d3_adderTemp = new d3_adder();\n", | |
"\t function d3_adderSum(a, b, o) {\n", | |
"\t var x = o.s = a + b, bv = x - a, av = x - bv;\n", | |
"\t o.t = a - av + (b - bv);\n", | |
"\t }\n", | |
"\t d3.geo.stream = function(object, listener) {\n", | |
"\t if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) {\n", | |
"\t d3_geo_streamObjectType[object.type](object, listener);\n", | |
"\t } else {\n", | |
"\t d3_geo_streamGeometry(object, listener);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geo_streamGeometry(geometry, listener) {\n", | |
"\t if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {\n", | |
"\t d3_geo_streamGeometryType[geometry.type](geometry, listener);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var d3_geo_streamObjectType = {\n", | |
"\t Feature: function(feature, listener) {\n", | |
"\t d3_geo_streamGeometry(feature.geometry, listener);\n", | |
"\t },\n", | |
"\t FeatureCollection: function(object, listener) {\n", | |
"\t var features = object.features, i = -1, n = features.length;\n", | |
"\t while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t var d3_geo_streamGeometryType = {\n", | |
"\t Sphere: function(object, listener) {\n", | |
"\t listener.sphere();\n", | |
"\t },\n", | |
"\t Point: function(object, listener) {\n", | |
"\t object = object.coordinates;\n", | |
"\t listener.point(object[0], object[1], object[2]);\n", | |
"\t },\n", | |
"\t MultiPoint: function(object, listener) {\n", | |
"\t var coordinates = object.coordinates, i = -1, n = coordinates.length;\n", | |
"\t while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]);\n", | |
"\t },\n", | |
"\t LineString: function(object, listener) {\n", | |
"\t d3_geo_streamLine(object.coordinates, listener, 0);\n", | |
"\t },\n", | |
"\t MultiLineString: function(object, listener) {\n", | |
"\t var coordinates = object.coordinates, i = -1, n = coordinates.length;\n", | |
"\t while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0);\n", | |
"\t },\n", | |
"\t Polygon: function(object, listener) {\n", | |
"\t d3_geo_streamPolygon(object.coordinates, listener);\n", | |
"\t },\n", | |
"\t MultiPolygon: function(object, listener) {\n", | |
"\t var coordinates = object.coordinates, i = -1, n = coordinates.length;\n", | |
"\t while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);\n", | |
"\t },\n", | |
"\t GeometryCollection: function(object, listener) {\n", | |
"\t var geometries = object.geometries, i = -1, n = geometries.length;\n", | |
"\t while (++i < n) d3_geo_streamGeometry(geometries[i], listener);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geo_streamLine(coordinates, listener, closed) {\n", | |
"\t var i = -1, n = coordinates.length - closed, coordinate;\n", | |
"\t listener.lineStart();\n", | |
"\t while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]);\n", | |
"\t listener.lineEnd();\n", | |
"\t }\n", | |
"\t function d3_geo_streamPolygon(coordinates, listener) {\n", | |
"\t var i = -1, n = coordinates.length;\n", | |
"\t listener.polygonStart();\n", | |
"\t while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1);\n", | |
"\t listener.polygonEnd();\n", | |
"\t }\n", | |
"\t d3.geo.area = function(object) {\n", | |
"\t d3_geo_areaSum = 0;\n", | |
"\t d3.geo.stream(object, d3_geo_area);\n", | |
"\t return d3_geo_areaSum;\n", | |
"\t };\n", | |
"\t var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder();\n", | |
"\t var d3_geo_area = {\n", | |
"\t sphere: function() {\n", | |
"\t d3_geo_areaSum += 4 * π;\n", | |
"\t },\n", | |
"\t point: d3_noop,\n", | |
"\t lineStart: d3_noop,\n", | |
"\t lineEnd: d3_noop,\n", | |
"\t polygonStart: function() {\n", | |
"\t d3_geo_areaRingSum.reset();\n", | |
"\t d3_geo_area.lineStart = d3_geo_areaRingStart;\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t var area = 2 * d3_geo_areaRingSum;\n", | |
"\t d3_geo_areaSum += area < 0 ? 4 * π + area : area;\n", | |
"\t d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geo_areaRingStart() {\n", | |
"\t var λ00, φ00, λ0, cosφ0, sinφ0;\n", | |
"\t d3_geo_area.point = function(λ, φ) {\n", | |
"\t d3_geo_area.point = nextPoint;\n", | |
"\t λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), \n", | |
"\t sinφ0 = Math.sin(φ);\n", | |
"\t };\n", | |
"\t function nextPoint(λ, φ) {\n", | |
"\t λ *= d3_radians;\n", | |
"\t φ = φ * d3_radians / 2 + π / 4;\n", | |
"\t var dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(adλ), v = k * sdλ * Math.sin(adλ);\n", | |
"\t d3_geo_areaRingSum.add(Math.atan2(v, u));\n", | |
"\t λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ;\n", | |
"\t }\n", | |
"\t d3_geo_area.lineEnd = function() {\n", | |
"\t nextPoint(λ00, φ00);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_cartesian(spherical) {\n", | |
"\t var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ);\n", | |
"\t return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ];\n", | |
"\t }\n", | |
"\t function d3_geo_cartesianDot(a, b) {\n", | |
"\t return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n", | |
"\t }\n", | |
"\t function d3_geo_cartesianCross(a, b) {\n", | |
"\t return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ];\n", | |
"\t }\n", | |
"\t function d3_geo_cartesianAdd(a, b) {\n", | |
"\t a[0] += b[0];\n", | |
"\t a[1] += b[1];\n", | |
"\t a[2] += b[2];\n", | |
"\t }\n", | |
"\t function d3_geo_cartesianScale(vector, k) {\n", | |
"\t return [ vector[0] * k, vector[1] * k, vector[2] * k ];\n", | |
"\t }\n", | |
"\t function d3_geo_cartesianNormalize(d) {\n", | |
"\t var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);\n", | |
"\t d[0] /= l;\n", | |
"\t d[1] /= l;\n", | |
"\t d[2] /= l;\n", | |
"\t }\n", | |
"\t function d3_geo_spherical(cartesian) {\n", | |
"\t return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ];\n", | |
"\t }\n", | |
"\t function d3_geo_sphericalEqual(a, b) {\n", | |
"\t return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε;\n", | |
"\t }\n", | |
"\t d3.geo.bounds = function() {\n", | |
"\t var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range;\n", | |
"\t var bound = {\n", | |
"\t point: point,\n", | |
"\t lineStart: lineStart,\n", | |
"\t lineEnd: lineEnd,\n", | |
"\t polygonStart: function() {\n", | |
"\t bound.point = ringPoint;\n", | |
"\t bound.lineStart = ringStart;\n", | |
"\t bound.lineEnd = ringEnd;\n", | |
"\t dλSum = 0;\n", | |
"\t d3_geo_area.polygonStart();\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t d3_geo_area.polygonEnd();\n", | |
"\t bound.point = point;\n", | |
"\t bound.lineStart = lineStart;\n", | |
"\t bound.lineEnd = lineEnd;\n", | |
"\t if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90;\n", | |
"\t range[0] = λ0, range[1] = λ1;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function point(λ, φ) {\n", | |
"\t ranges.push(range = [ λ0 = λ, λ1 = λ ]);\n", | |
"\t if (φ < φ0) φ0 = φ;\n", | |
"\t if (φ > φ1) φ1 = φ;\n", | |
"\t }\n", | |
"\t function linePoint(λ, φ) {\n", | |
"\t var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]);\n", | |
"\t if (p0) {\n", | |
"\t var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal);\n", | |
"\t d3_geo_cartesianNormalize(inflection);\n", | |
"\t inflection = d3_geo_spherical(inflection);\n", | |
"\t var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180;\n", | |
"\t if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) {\n", | |
"\t var φi = inflection[1] * d3_degrees;\n", | |
"\t if (φi > φ1) φ1 = φi;\n", | |
"\t } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) {\n", | |
"\t var φi = -inflection[1] * d3_degrees;\n", | |
"\t if (φi < φ0) φ0 = φi;\n", | |
"\t } else {\n", | |
"\t if (φ < φ0) φ0 = φ;\n", | |
"\t if (φ > φ1) φ1 = φ;\n", | |
"\t }\n", | |
"\t if (antimeridian) {\n", | |
"\t if (λ < λ_) {\n", | |
"\t if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;\n", | |
"\t } else {\n", | |
"\t if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t if (λ1 >= λ0) {\n", | |
"\t if (λ < λ0) λ0 = λ;\n", | |
"\t if (λ > λ1) λ1 = λ;\n", | |
"\t } else {\n", | |
"\t if (λ > λ_) {\n", | |
"\t if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;\n", | |
"\t } else {\n", | |
"\t if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t point(λ, φ);\n", | |
"\t }\n", | |
"\t p0 = p, λ_ = λ;\n", | |
"\t }\n", | |
"\t function lineStart() {\n", | |
"\t bound.point = linePoint;\n", | |
"\t }\n", | |
"\t function lineEnd() {\n", | |
"\t range[0] = λ0, range[1] = λ1;\n", | |
"\t bound.point = point;\n", | |
"\t p0 = null;\n", | |
"\t }\n", | |
"\t function ringPoint(λ, φ) {\n", | |
"\t if (p0) {\n", | |
"\t var dλ = λ - λ_;\n", | |
"\t dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ;\n", | |
"\t } else λ__ = λ, φ__ = φ;\n", | |
"\t d3_geo_area.point(λ, φ);\n", | |
"\t linePoint(λ, φ);\n", | |
"\t }\n", | |
"\t function ringStart() {\n", | |
"\t d3_geo_area.lineStart();\n", | |
"\t }\n", | |
"\t function ringEnd() {\n", | |
"\t ringPoint(λ__, φ__);\n", | |
"\t d3_geo_area.lineEnd();\n", | |
"\t if (abs(dλSum) > ε) λ0 = -(λ1 = 180);\n", | |
"\t range[0] = λ0, range[1] = λ1;\n", | |
"\t p0 = null;\n", | |
"\t }\n", | |
"\t function angle(λ0, λ1) {\n", | |
"\t return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1;\n", | |
"\t }\n", | |
"\t function compareRanges(a, b) {\n", | |
"\t return a[0] - b[0];\n", | |
"\t }\n", | |
"\t function withinRange(x, range) {\n", | |
"\t return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;\n", | |
"\t }\n", | |
"\t return function(feature) {\n", | |
"\t φ1 = λ1 = -(λ0 = φ0 = Infinity);\n", | |
"\t ranges = [];\n", | |
"\t d3.geo.stream(feature, bound);\n", | |
"\t var n = ranges.length;\n", | |
"\t if (n) {\n", | |
"\t ranges.sort(compareRanges);\n", | |
"\t for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) {\n", | |
"\t b = ranges[i];\n", | |
"\t if (withinRange(b[0], a) || withinRange(b[1], a)) {\n", | |
"\t if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];\n", | |
"\t if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];\n", | |
"\t } else {\n", | |
"\t merged.push(a = b);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var best = -Infinity, dλ;\n", | |
"\t for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) {\n", | |
"\t b = merged[i];\n", | |
"\t if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t ranges = range = null;\n", | |
"\t return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ];\n", | |
"\t };\n", | |
"\t }();\n", | |
"\t d3.geo.centroid = function(object) {\n", | |
"\t d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0;\n", | |
"\t d3.geo.stream(object, d3_geo_centroid);\n", | |
"\t var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z;\n", | |
"\t if (m < ε2) {\n", | |
"\t x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1;\n", | |
"\t if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0;\n", | |
"\t m = x * x + y * y + z * z;\n", | |
"\t if (m < ε2) return [ NaN, NaN ];\n", | |
"\t }\n", | |
"\t return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ];\n", | |
"\t };\n", | |
"\t var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2;\n", | |
"\t var d3_geo_centroid = {\n", | |
"\t sphere: d3_noop,\n", | |
"\t point: d3_geo_centroidPoint,\n", | |
"\t lineStart: d3_geo_centroidLineStart,\n", | |
"\t lineEnd: d3_geo_centroidLineEnd,\n", | |
"\t polygonStart: function() {\n", | |
"\t d3_geo_centroid.lineStart = d3_geo_centroidRingStart;\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t d3_geo_centroid.lineStart = d3_geo_centroidLineStart;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geo_centroidPoint(λ, φ) {\n", | |
"\t λ *= d3_radians;\n", | |
"\t var cosφ = Math.cos(φ *= d3_radians);\n", | |
"\t d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ));\n", | |
"\t }\n", | |
"\t function d3_geo_centroidPointXYZ(x, y, z) {\n", | |
"\t ++d3_geo_centroidW0;\n", | |
"\t d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0;\n", | |
"\t d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0;\n", | |
"\t d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0;\n", | |
"\t }\n", | |
"\t function d3_geo_centroidLineStart() {\n", | |
"\t var x0, y0, z0;\n", | |
"\t d3_geo_centroid.point = function(λ, φ) {\n", | |
"\t λ *= d3_radians;\n", | |
"\t var cosφ = Math.cos(φ *= d3_radians);\n", | |
"\t x0 = cosφ * Math.cos(λ);\n", | |
"\t y0 = cosφ * Math.sin(λ);\n", | |
"\t z0 = Math.sin(φ);\n", | |
"\t d3_geo_centroid.point = nextPoint;\n", | |
"\t d3_geo_centroidPointXYZ(x0, y0, z0);\n", | |
"\t };\n", | |
"\t function nextPoint(λ, φ) {\n", | |
"\t λ *= d3_radians;\n", | |
"\t var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z);\n", | |
"\t d3_geo_centroidW1 += w;\n", | |
"\t d3_geo_centroidX1 += w * (x0 + (x0 = x));\n", | |
"\t d3_geo_centroidY1 += w * (y0 + (y0 = y));\n", | |
"\t d3_geo_centroidZ1 += w * (z0 + (z0 = z));\n", | |
"\t d3_geo_centroidPointXYZ(x0, y0, z0);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geo_centroidLineEnd() {\n", | |
"\t d3_geo_centroid.point = d3_geo_centroidPoint;\n", | |
"\t }\n", | |
"\t function d3_geo_centroidRingStart() {\n", | |
"\t var λ00, φ00, x0, y0, z0;\n", | |
"\t d3_geo_centroid.point = function(λ, φ) {\n", | |
"\t λ00 = λ, φ00 = φ;\n", | |
"\t d3_geo_centroid.point = nextPoint;\n", | |
"\t λ *= d3_radians;\n", | |
"\t var cosφ = Math.cos(φ *= d3_radians);\n", | |
"\t x0 = cosφ * Math.cos(λ);\n", | |
"\t y0 = cosφ * Math.sin(λ);\n", | |
"\t z0 = Math.sin(φ);\n", | |
"\t d3_geo_centroidPointXYZ(x0, y0, z0);\n", | |
"\t };\n", | |
"\t d3_geo_centroid.lineEnd = function() {\n", | |
"\t nextPoint(λ00, φ00);\n", | |
"\t d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd;\n", | |
"\t d3_geo_centroid.point = d3_geo_centroidPoint;\n", | |
"\t };\n", | |
"\t function nextPoint(λ, φ) {\n", | |
"\t λ *= d3_radians;\n", | |
"\t var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u);\n", | |
"\t d3_geo_centroidX2 += v * cx;\n", | |
"\t d3_geo_centroidY2 += v * cy;\n", | |
"\t d3_geo_centroidZ2 += v * cz;\n", | |
"\t d3_geo_centroidW1 += w;\n", | |
"\t d3_geo_centroidX1 += w * (x0 + (x0 = x));\n", | |
"\t d3_geo_centroidY1 += w * (y0 + (y0 = y));\n", | |
"\t d3_geo_centroidZ1 += w * (z0 + (z0 = z));\n", | |
"\t d3_geo_centroidPointXYZ(x0, y0, z0);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geo_compose(a, b) {\n", | |
"\t function compose(x, y) {\n", | |
"\t return x = a(x, y), b(x[0], x[1]);\n", | |
"\t }\n", | |
"\t if (a.invert && b.invert) compose.invert = function(x, y) {\n", | |
"\t return x = b.invert(x, y), x && a.invert(x[0], x[1]);\n", | |
"\t };\n", | |
"\t return compose;\n", | |
"\t }\n", | |
"\t function d3_true() {\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) {\n", | |
"\t var subject = [], clip = [];\n", | |
"\t segments.forEach(function(segment) {\n", | |
"\t if ((n = segment.length - 1) <= 0) return;\n", | |
"\t var n, p0 = segment[0], p1 = segment[n];\n", | |
"\t if (d3_geo_sphericalEqual(p0, p1)) {\n", | |
"\t listener.lineStart();\n", | |
"\t for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]);\n", | |
"\t listener.lineEnd();\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false);\n", | |
"\t a.o = b;\n", | |
"\t subject.push(a);\n", | |
"\t clip.push(b);\n", | |
"\t a = new d3_geo_clipPolygonIntersection(p1, segment, null, false);\n", | |
"\t b = new d3_geo_clipPolygonIntersection(p1, null, a, true);\n", | |
"\t a.o = b;\n", | |
"\t subject.push(a);\n", | |
"\t clip.push(b);\n", | |
"\t });\n", | |
"\t clip.sort(compare);\n", | |
"\t d3_geo_clipPolygonLinkCircular(subject);\n", | |
"\t d3_geo_clipPolygonLinkCircular(clip);\n", | |
"\t if (!subject.length) return;\n", | |
"\t for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) {\n", | |
"\t clip[i].e = entry = !entry;\n", | |
"\t }\n", | |
"\t var start = subject[0], points, point;\n", | |
"\t while (1) {\n", | |
"\t var current = start, isSubject = true;\n", | |
"\t while (current.v) if ((current = current.n) === start) return;\n", | |
"\t points = current.z;\n", | |
"\t listener.lineStart();\n", | |
"\t do {\n", | |
"\t current.v = current.o.v = true;\n", | |
"\t if (current.e) {\n", | |
"\t if (isSubject) {\n", | |
"\t for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]);\n", | |
"\t } else {\n", | |
"\t interpolate(current.x, current.n.x, 1, listener);\n", | |
"\t }\n", | |
"\t current = current.n;\n", | |
"\t } else {\n", | |
"\t if (isSubject) {\n", | |
"\t points = current.p.z;\n", | |
"\t for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]);\n", | |
"\t } else {\n", | |
"\t interpolate(current.x, current.p.x, -1, listener);\n", | |
"\t }\n", | |
"\t current = current.p;\n", | |
"\t }\n", | |
"\t current = current.o;\n", | |
"\t points = current.z;\n", | |
"\t isSubject = !isSubject;\n", | |
"\t } while (!current.v);\n", | |
"\t listener.lineEnd();\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geo_clipPolygonLinkCircular(array) {\n", | |
"\t if (!(n = array.length)) return;\n", | |
"\t var n, i = 0, a = array[0], b;\n", | |
"\t while (++i < n) {\n", | |
"\t a.n = b = array[i];\n", | |
"\t b.p = a;\n", | |
"\t a = b;\n", | |
"\t }\n", | |
"\t a.n = b = array[0];\n", | |
"\t b.p = a;\n", | |
"\t }\n", | |
"\t function d3_geo_clipPolygonIntersection(point, points, other, entry) {\n", | |
"\t this.x = point;\n", | |
"\t this.z = points;\n", | |
"\t this.o = other;\n", | |
"\t this.e = entry;\n", | |
"\t this.v = false;\n", | |
"\t this.n = this.p = null;\n", | |
"\t }\n", | |
"\t function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {\n", | |
"\t return function(rotate, listener) {\n", | |
"\t var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]);\n", | |
"\t var clip = {\n", | |
"\t point: point,\n", | |
"\t lineStart: lineStart,\n", | |
"\t lineEnd: lineEnd,\n", | |
"\t polygonStart: function() {\n", | |
"\t clip.point = pointRing;\n", | |
"\t clip.lineStart = ringStart;\n", | |
"\t clip.lineEnd = ringEnd;\n", | |
"\t segments = [];\n", | |
"\t polygon = [];\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t clip.point = point;\n", | |
"\t clip.lineStart = lineStart;\n", | |
"\t clip.lineEnd = lineEnd;\n", | |
"\t segments = d3.merge(segments);\n", | |
"\t var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon);\n", | |
"\t if (segments.length) {\n", | |
"\t if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n", | |
"\t d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener);\n", | |
"\t } else if (clipStartInside) {\n", | |
"\t if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n", | |
"\t listener.lineStart();\n", | |
"\t interpolate(null, null, 1, listener);\n", | |
"\t listener.lineEnd();\n", | |
"\t }\n", | |
"\t if (polygonStarted) listener.polygonEnd(), polygonStarted = false;\n", | |
"\t segments = polygon = null;\n", | |
"\t },\n", | |
"\t sphere: function() {\n", | |
"\t listener.polygonStart();\n", | |
"\t listener.lineStart();\n", | |
"\t interpolate(null, null, 1, listener);\n", | |
"\t listener.lineEnd();\n", | |
"\t listener.polygonEnd();\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function point(λ, φ) {\n", | |
"\t var point = rotate(λ, φ);\n", | |
"\t if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ);\n", | |
"\t }\n", | |
"\t function pointLine(λ, φ) {\n", | |
"\t var point = rotate(λ, φ);\n", | |
"\t line.point(point[0], point[1]);\n", | |
"\t }\n", | |
"\t function lineStart() {\n", | |
"\t clip.point = pointLine;\n", | |
"\t line.lineStart();\n", | |
"\t }\n", | |
"\t function lineEnd() {\n", | |
"\t clip.point = point;\n", | |
"\t line.lineEnd();\n", | |
"\t }\n", | |
"\t var segments;\n", | |
"\t var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring;\n", | |
"\t function pointRing(λ, φ) {\n", | |
"\t ring.push([ λ, φ ]);\n", | |
"\t var point = rotate(λ, φ);\n", | |
"\t ringListener.point(point[0], point[1]);\n", | |
"\t }\n", | |
"\t function ringStart() {\n", | |
"\t ringListener.lineStart();\n", | |
"\t ring = [];\n", | |
"\t }\n", | |
"\t function ringEnd() {\n", | |
"\t pointRing(ring[0][0], ring[0][1]);\n", | |
"\t ringListener.lineEnd();\n", | |
"\t var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length;\n", | |
"\t ring.pop();\n", | |
"\t polygon.push(ring);\n", | |
"\t ring = null;\n", | |
"\t if (!n) return;\n", | |
"\t if (clean & 1) {\n", | |
"\t segment = ringSegments[0];\n", | |
"\t var n = segment.length - 1, i = -1, point;\n", | |
"\t if (n > 0) {\n", | |
"\t if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n", | |
"\t listener.lineStart();\n", | |
"\t while (++i < n) listener.point((point = segment[i])[0], point[1]);\n", | |
"\t listener.lineEnd();\n", | |
"\t }\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));\n", | |
"\t segments.push(ringSegments.filter(d3_geo_clipSegmentLength1));\n", | |
"\t }\n", | |
"\t return clip;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_clipSegmentLength1(segment) {\n", | |
"\t return segment.length > 1;\n", | |
"\t }\n", | |
"\t function d3_geo_clipBufferListener() {\n", | |
"\t var lines = [], line;\n", | |
"\t return {\n", | |
"\t lineStart: function() {\n", | |
"\t lines.push(line = []);\n", | |
"\t },\n", | |
"\t point: function(λ, φ) {\n", | |
"\t line.push([ λ, φ ]);\n", | |
"\t },\n", | |
"\t lineEnd: d3_noop,\n", | |
"\t buffer: function() {\n", | |
"\t var buffer = lines;\n", | |
"\t lines = [];\n", | |
"\t line = null;\n", | |
"\t return buffer;\n", | |
"\t },\n", | |
"\t rejoin: function() {\n", | |
"\t if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_clipSort(a, b) {\n", | |
"\t return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]);\n", | |
"\t }\n", | |
"\t var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]);\n", | |
"\t function d3_geo_clipAntimeridianLine(listener) {\n", | |
"\t var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean;\n", | |
"\t return {\n", | |
"\t lineStart: function() {\n", | |
"\t listener.lineStart();\n", | |
"\t clean = 1;\n", | |
"\t },\n", | |
"\t point: function(λ1, φ1) {\n", | |
"\t var sλ1 = λ1 > 0 ? π : -π, dλ = abs(λ1 - λ0);\n", | |
"\t if (abs(dλ - π) < ε) {\n", | |
"\t listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ);\n", | |
"\t listener.point(sλ0, φ0);\n", | |
"\t listener.lineEnd();\n", | |
"\t listener.lineStart();\n", | |
"\t listener.point(sλ1, φ0);\n", | |
"\t listener.point(λ1, φ0);\n", | |
"\t clean = 0;\n", | |
"\t } else if (sλ0 !== sλ1 && dλ >= π) {\n", | |
"\t if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε;\n", | |
"\t if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε;\n", | |
"\t φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1);\n", | |
"\t listener.point(sλ0, φ0);\n", | |
"\t listener.lineEnd();\n", | |
"\t listener.lineStart();\n", | |
"\t listener.point(sλ1, φ0);\n", | |
"\t clean = 0;\n", | |
"\t }\n", | |
"\t listener.point(λ0 = λ1, φ0 = φ1);\n", | |
"\t sλ0 = sλ1;\n", | |
"\t },\n", | |
"\t lineEnd: function() {\n", | |
"\t listener.lineEnd();\n", | |
"\t λ0 = φ0 = NaN;\n", | |
"\t },\n", | |
"\t clean: function() {\n", | |
"\t return 2 - clean;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) {\n", | |
"\t var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1);\n", | |
"\t return abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2;\n", | |
"\t }\n", | |
"\t function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) {\n", | |
"\t var φ;\n", | |
"\t if (from == null) {\n", | |
"\t φ = direction * halfπ;\n", | |
"\t listener.point(-π, φ);\n", | |
"\t listener.point(0, φ);\n", | |
"\t listener.point(π, φ);\n", | |
"\t listener.point(π, 0);\n", | |
"\t listener.point(π, -φ);\n", | |
"\t listener.point(0, -φ);\n", | |
"\t listener.point(-π, -φ);\n", | |
"\t listener.point(-π, 0);\n", | |
"\t listener.point(-π, φ);\n", | |
"\t } else if (abs(from[0] - to[0]) > ε) {\n", | |
"\t var s = from[0] < to[0] ? π : -π;\n", | |
"\t φ = direction * s / 2;\n", | |
"\t listener.point(-s, φ);\n", | |
"\t listener.point(0, φ);\n", | |
"\t listener.point(s, φ);\n", | |
"\t } else {\n", | |
"\t listener.point(to[0], to[1]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geo_pointInPolygon(point, polygon) {\n", | |
"\t var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;\n", | |
"\t d3_geo_areaRingSum.reset();\n", | |
"\t for (var i = 0, n = polygon.length; i < n; ++i) {\n", | |
"\t var ring = polygon[i], m = ring.length;\n", | |
"\t if (!m) continue;\n", | |
"\t var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1;\n", | |
"\t while (true) {\n", | |
"\t if (j === m) j = 0;\n", | |
"\t point = ring[j];\n", | |
"\t var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ;\n", | |
"\t d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ)));\n", | |
"\t polarAngle += antimeridian ? dλ + sdλ * τ : dλ;\n", | |
"\t if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) {\n", | |
"\t var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));\n", | |
"\t d3_geo_cartesianNormalize(arc);\n", | |
"\t var intersection = d3_geo_cartesianCross(meridianNormal, arc);\n", | |
"\t d3_geo_cartesianNormalize(intersection);\n", | |
"\t var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]);\n", | |
"\t if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) {\n", | |
"\t winding += antimeridian ^ dλ >= 0 ? 1 : -1;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (!j++) break;\n", | |
"\t λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1;\n", | |
"\t }\n", | |
"\t function d3_geo_clipCircle(radius) {\n", | |
"\t var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians);\n", | |
"\t return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]);\n", | |
"\t function visible(λ, φ) {\n", | |
"\t return Math.cos(λ) * Math.cos(φ) > cr;\n", | |
"\t }\n", | |
"\t function clipLine(listener) {\n", | |
"\t var point0, c0, v0, v00, clean;\n", | |
"\t return {\n", | |
"\t lineStart: function() {\n", | |
"\t v00 = v0 = false;\n", | |
"\t clean = 1;\n", | |
"\t },\n", | |
"\t point: function(λ, φ) {\n", | |
"\t var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0;\n", | |
"\t if (!point0 && (v00 = v0 = v)) listener.lineStart();\n", | |
"\t if (v !== v0) {\n", | |
"\t point2 = intersect(point0, point1);\n", | |
"\t if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) {\n", | |
"\t point1[0] += ε;\n", | |
"\t point1[1] += ε;\n", | |
"\t v = visible(point1[0], point1[1]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (v !== v0) {\n", | |
"\t clean = 0;\n", | |
"\t if (v) {\n", | |
"\t listener.lineStart();\n", | |
"\t point2 = intersect(point1, point0);\n", | |
"\t listener.point(point2[0], point2[1]);\n", | |
"\t } else {\n", | |
"\t point2 = intersect(point0, point1);\n", | |
"\t listener.point(point2[0], point2[1]);\n", | |
"\t listener.lineEnd();\n", | |
"\t }\n", | |
"\t point0 = point2;\n", | |
"\t } else if (notHemisphere && point0 && smallRadius ^ v) {\n", | |
"\t var t;\n", | |
"\t if (!(c & c0) && (t = intersect(point1, point0, true))) {\n", | |
"\t clean = 0;\n", | |
"\t if (smallRadius) {\n", | |
"\t listener.lineStart();\n", | |
"\t listener.point(t[0][0], t[0][1]);\n", | |
"\t listener.point(t[1][0], t[1][1]);\n", | |
"\t listener.lineEnd();\n", | |
"\t } else {\n", | |
"\t listener.point(t[1][0], t[1][1]);\n", | |
"\t listener.lineEnd();\n", | |
"\t listener.lineStart();\n", | |
"\t listener.point(t[0][0], t[0][1]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) {\n", | |
"\t listener.point(point1[0], point1[1]);\n", | |
"\t }\n", | |
"\t point0 = point1, v0 = v, c0 = c;\n", | |
"\t },\n", | |
"\t lineEnd: function() {\n", | |
"\t if (v0) listener.lineEnd();\n", | |
"\t point0 = null;\n", | |
"\t },\n", | |
"\t clean: function() {\n", | |
"\t return clean | (v00 && v0) << 1;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function intersect(a, b, two) {\n", | |
"\t var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b);\n", | |
"\t var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;\n", | |
"\t if (!determinant) return !two && a;\n", | |
"\t var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2);\n", | |
"\t d3_geo_cartesianAdd(A, B);\n", | |
"\t var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1);\n", | |
"\t if (t2 < 0) return;\n", | |
"\t var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu);\n", | |
"\t d3_geo_cartesianAdd(q, A);\n", | |
"\t q = d3_geo_spherical(q);\n", | |
"\t if (!two) return q;\n", | |
"\t var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z;\n", | |
"\t if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z;\n", | |
"\t var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε;\n", | |
"\t if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z;\n", | |
"\t if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) {\n", | |
"\t var q1 = d3_geo_cartesianScale(u, (-w + t) / uu);\n", | |
"\t d3_geo_cartesianAdd(q1, A);\n", | |
"\t return [ q, d3_geo_spherical(q1) ];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function code(λ, φ) {\n", | |
"\t var r = smallRadius ? radius : π - radius, code = 0;\n", | |
"\t if (λ < -r) code |= 1; else if (λ > r) code |= 2;\n", | |
"\t if (φ < -r) code |= 4; else if (φ > r) code |= 8;\n", | |
"\t return code;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geom_clipLine(x0, y0, x1, y1) {\n", | |
"\t return function(line) {\n", | |
"\t var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r;\n", | |
"\t r = x0 - ax;\n", | |
"\t if (!dx && r > 0) return;\n", | |
"\t r /= dx;\n", | |
"\t if (dx < 0) {\n", | |
"\t if (r < t0) return;\n", | |
"\t if (r < t1) t1 = r;\n", | |
"\t } else if (dx > 0) {\n", | |
"\t if (r > t1) return;\n", | |
"\t if (r > t0) t0 = r;\n", | |
"\t }\n", | |
"\t r = x1 - ax;\n", | |
"\t if (!dx && r < 0) return;\n", | |
"\t r /= dx;\n", | |
"\t if (dx < 0) {\n", | |
"\t if (r > t1) return;\n", | |
"\t if (r > t0) t0 = r;\n", | |
"\t } else if (dx > 0) {\n", | |
"\t if (r < t0) return;\n", | |
"\t if (r < t1) t1 = r;\n", | |
"\t }\n", | |
"\t r = y0 - ay;\n", | |
"\t if (!dy && r > 0) return;\n", | |
"\t r /= dy;\n", | |
"\t if (dy < 0) {\n", | |
"\t if (r < t0) return;\n", | |
"\t if (r < t1) t1 = r;\n", | |
"\t } else if (dy > 0) {\n", | |
"\t if (r > t1) return;\n", | |
"\t if (r > t0) t0 = r;\n", | |
"\t }\n", | |
"\t r = y1 - ay;\n", | |
"\t if (!dy && r < 0) return;\n", | |
"\t r /= dy;\n", | |
"\t if (dy < 0) {\n", | |
"\t if (r > t1) return;\n", | |
"\t if (r > t0) t0 = r;\n", | |
"\t } else if (dy > 0) {\n", | |
"\t if (r < t0) return;\n", | |
"\t if (r < t1) t1 = r;\n", | |
"\t }\n", | |
"\t if (t0 > 0) line.a = {\n", | |
"\t x: ax + t0 * dx,\n", | |
"\t y: ay + t0 * dy\n", | |
"\t };\n", | |
"\t if (t1 < 1) line.b = {\n", | |
"\t x: ax + t1 * dx,\n", | |
"\t y: ay + t1 * dy\n", | |
"\t };\n", | |
"\t return line;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t var d3_geo_clipExtentMAX = 1e9;\n", | |
"\t d3.geo.clipExtent = function() {\n", | |
"\t var x0, y0, x1, y1, stream, clip, clipExtent = {\n", | |
"\t stream: function(output) {\n", | |
"\t if (stream) stream.valid = false;\n", | |
"\t stream = clip(output);\n", | |
"\t stream.valid = true;\n", | |
"\t return stream;\n", | |
"\t },\n", | |
"\t extent: function(_) {\n", | |
"\t if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];\n", | |
"\t clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]);\n", | |
"\t if (stream) stream.valid = false, stream = null;\n", | |
"\t return clipExtent;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]);\n", | |
"\t };\n", | |
"\t function d3_geo_clipExtent(x0, y0, x1, y1) {\n", | |
"\t return function(listener) {\n", | |
"\t var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring;\n", | |
"\t var clip = {\n", | |
"\t point: point,\n", | |
"\t lineStart: lineStart,\n", | |
"\t lineEnd: lineEnd,\n", | |
"\t polygonStart: function() {\n", | |
"\t listener = bufferListener;\n", | |
"\t segments = [];\n", | |
"\t polygon = [];\n", | |
"\t clean = true;\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t listener = listener_;\n", | |
"\t segments = d3.merge(segments);\n", | |
"\t var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length;\n", | |
"\t if (inside || visible) {\n", | |
"\t listener.polygonStart();\n", | |
"\t if (inside) {\n", | |
"\t listener.lineStart();\n", | |
"\t interpolate(null, null, 1, listener);\n", | |
"\t listener.lineEnd();\n", | |
"\t }\n", | |
"\t if (visible) {\n", | |
"\t d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener);\n", | |
"\t }\n", | |
"\t listener.polygonEnd();\n", | |
"\t }\n", | |
"\t segments = polygon = ring = null;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function insidePolygon(p) {\n", | |
"\t var wn = 0, n = polygon.length, y = p[1];\n", | |
"\t for (var i = 0; i < n; ++i) {\n", | |
"\t for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {\n", | |
"\t b = v[j];\n", | |
"\t if (a[1] <= y) {\n", | |
"\t if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn;\n", | |
"\t } else {\n", | |
"\t if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn;\n", | |
"\t }\n", | |
"\t a = b;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return wn !== 0;\n", | |
"\t }\n", | |
"\t function interpolate(from, to, direction, listener) {\n", | |
"\t var a = 0, a1 = 0;\n", | |
"\t if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) {\n", | |
"\t do {\n", | |
"\t listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);\n", | |
"\t } while ((a = (a + direction + 4) % 4) !== a1);\n", | |
"\t } else {\n", | |
"\t listener.point(to[0], to[1]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function pointVisible(x, y) {\n", | |
"\t return x0 <= x && x <= x1 && y0 <= y && y <= y1;\n", | |
"\t }\n", | |
"\t function point(x, y) {\n", | |
"\t if (pointVisible(x, y)) listener.point(x, y);\n", | |
"\t }\n", | |
"\t var x__, y__, v__, x_, y_, v_, first, clean;\n", | |
"\t function lineStart() {\n", | |
"\t clip.point = linePoint;\n", | |
"\t if (polygon) polygon.push(ring = []);\n", | |
"\t first = true;\n", | |
"\t v_ = false;\n", | |
"\t x_ = y_ = NaN;\n", | |
"\t }\n", | |
"\t function lineEnd() {\n", | |
"\t if (segments) {\n", | |
"\t linePoint(x__, y__);\n", | |
"\t if (v__ && v_) bufferListener.rejoin();\n", | |
"\t segments.push(bufferListener.buffer());\n", | |
"\t }\n", | |
"\t clip.point = point;\n", | |
"\t if (v_) listener.lineEnd();\n", | |
"\t }\n", | |
"\t function linePoint(x, y) {\n", | |
"\t x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x));\n", | |
"\t y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y));\n", | |
"\t var v = pointVisible(x, y);\n", | |
"\t if (polygon) ring.push([ x, y ]);\n", | |
"\t if (first) {\n", | |
"\t x__ = x, y__ = y, v__ = v;\n", | |
"\t first = false;\n", | |
"\t if (v) {\n", | |
"\t listener.lineStart();\n", | |
"\t listener.point(x, y);\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t if (v && v_) listener.point(x, y); else {\n", | |
"\t var l = {\n", | |
"\t a: {\n", | |
"\t x: x_,\n", | |
"\t y: y_\n", | |
"\t },\n", | |
"\t b: {\n", | |
"\t x: x,\n", | |
"\t y: y\n", | |
"\t }\n", | |
"\t };\n", | |
"\t if (clipLine(l)) {\n", | |
"\t if (!v_) {\n", | |
"\t listener.lineStart();\n", | |
"\t listener.point(l.a.x, l.a.y);\n", | |
"\t }\n", | |
"\t listener.point(l.b.x, l.b.y);\n", | |
"\t if (!v) listener.lineEnd();\n", | |
"\t clean = false;\n", | |
"\t } else if (v) {\n", | |
"\t listener.lineStart();\n", | |
"\t listener.point(x, y);\n", | |
"\t clean = false;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t x_ = x, y_ = y, v_ = v;\n", | |
"\t }\n", | |
"\t return clip;\n", | |
"\t };\n", | |
"\t function corner(p, direction) {\n", | |
"\t return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;\n", | |
"\t }\n", | |
"\t function compare(a, b) {\n", | |
"\t return comparePoints(a.x, b.x);\n", | |
"\t }\n", | |
"\t function comparePoints(a, b) {\n", | |
"\t var ca = corner(a, 1), cb = corner(b, 1);\n", | |
"\t return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geo_conic(projectAt) {\n", | |
"\t var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1);\n", | |
"\t p.parallels = function(_) {\n", | |
"\t if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ];\n", | |
"\t return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180);\n", | |
"\t };\n", | |
"\t return p;\n", | |
"\t }\n", | |
"\t function d3_geo_conicEqualArea(φ0, φ1) {\n", | |
"\t var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n;\n", | |
"\t function forward(λ, φ) {\n", | |
"\t var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n;\n", | |
"\t return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ];\n", | |
"\t }\n", | |
"\t forward.invert = function(x, y) {\n", | |
"\t var ρ0_y = ρ0 - y;\n", | |
"\t return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ];\n", | |
"\t };\n", | |
"\t return forward;\n", | |
"\t }\n", | |
"\t (d3.geo.conicEqualArea = function() {\n", | |
"\t return d3_geo_conic(d3_geo_conicEqualArea);\n", | |
"\t }).raw = d3_geo_conicEqualArea;\n", | |
"\t d3.geo.albers = function() {\n", | |
"\t return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070);\n", | |
"\t };\n", | |
"\t d3.geo.albersUsa = function() {\n", | |
"\t var lower48 = d3.geo.albers();\n", | |
"\t var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]);\n", | |
"\t var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]);\n", | |
"\t var point, pointStream = {\n", | |
"\t point: function(x, y) {\n", | |
"\t point = [ x, y ];\n", | |
"\t }\n", | |
"\t }, lower48Point, alaskaPoint, hawaiiPoint;\n", | |
"\t function albersUsa(coordinates) {\n", | |
"\t var x = coordinates[0], y = coordinates[1];\n", | |
"\t point = null;\n", | |
"\t (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y);\n", | |
"\t return point;\n", | |
"\t }\n", | |
"\t albersUsa.invert = function(coordinates) {\n", | |
"\t var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k;\n", | |
"\t return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates);\n", | |
"\t };\n", | |
"\t albersUsa.stream = function(stream) {\n", | |
"\t var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream);\n", | |
"\t return {\n", | |
"\t point: function(x, y) {\n", | |
"\t lower48Stream.point(x, y);\n", | |
"\t alaskaStream.point(x, y);\n", | |
"\t hawaiiStream.point(x, y);\n", | |
"\t },\n", | |
"\t sphere: function() {\n", | |
"\t lower48Stream.sphere();\n", | |
"\t alaskaStream.sphere();\n", | |
"\t hawaiiStream.sphere();\n", | |
"\t },\n", | |
"\t lineStart: function() {\n", | |
"\t lower48Stream.lineStart();\n", | |
"\t alaskaStream.lineStart();\n", | |
"\t hawaiiStream.lineStart();\n", | |
"\t },\n", | |
"\t lineEnd: function() {\n", | |
"\t lower48Stream.lineEnd();\n", | |
"\t alaskaStream.lineEnd();\n", | |
"\t hawaiiStream.lineEnd();\n", | |
"\t },\n", | |
"\t polygonStart: function() {\n", | |
"\t lower48Stream.polygonStart();\n", | |
"\t alaskaStream.polygonStart();\n", | |
"\t hawaiiStream.polygonStart();\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t lower48Stream.polygonEnd();\n", | |
"\t alaskaStream.polygonEnd();\n", | |
"\t hawaiiStream.polygonEnd();\n", | |
"\t }\n", | |
"\t };\n", | |
"\t };\n", | |
"\t albersUsa.precision = function(_) {\n", | |
"\t if (!arguments.length) return lower48.precision();\n", | |
"\t lower48.precision(_);\n", | |
"\t alaska.precision(_);\n", | |
"\t hawaii.precision(_);\n", | |
"\t return albersUsa;\n", | |
"\t };\n", | |
"\t albersUsa.scale = function(_) {\n", | |
"\t if (!arguments.length) return lower48.scale();\n", | |
"\t lower48.scale(_);\n", | |
"\t alaska.scale(_ * .35);\n", | |
"\t hawaii.scale(_);\n", | |
"\t return albersUsa.translate(lower48.translate());\n", | |
"\t };\n", | |
"\t albersUsa.translate = function(_) {\n", | |
"\t if (!arguments.length) return lower48.translate();\n", | |
"\t var k = lower48.scale(), x = +_[0], y = +_[1];\n", | |
"\t lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point;\n", | |
"\t alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point;\n", | |
"\t hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point;\n", | |
"\t return albersUsa;\n", | |
"\t };\n", | |
"\t return albersUsa.scale(1070);\n", | |
"\t };\n", | |
"\t var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = {\n", | |
"\t point: d3_noop,\n", | |
"\t lineStart: d3_noop,\n", | |
"\t lineEnd: d3_noop,\n", | |
"\t polygonStart: function() {\n", | |
"\t d3_geo_pathAreaPolygon = 0;\n", | |
"\t d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart;\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop;\n", | |
"\t d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geo_pathAreaRingStart() {\n", | |
"\t var x00, y00, x0, y0;\n", | |
"\t d3_geo_pathArea.point = function(x, y) {\n", | |
"\t d3_geo_pathArea.point = nextPoint;\n", | |
"\t x00 = x0 = x, y00 = y0 = y;\n", | |
"\t };\n", | |
"\t function nextPoint(x, y) {\n", | |
"\t d3_geo_pathAreaPolygon += y0 * x - x0 * y;\n", | |
"\t x0 = x, y0 = y;\n", | |
"\t }\n", | |
"\t d3_geo_pathArea.lineEnd = function() {\n", | |
"\t nextPoint(x00, y00);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1;\n", | |
"\t var d3_geo_pathBounds = {\n", | |
"\t point: d3_geo_pathBoundsPoint,\n", | |
"\t lineStart: d3_noop,\n", | |
"\t lineEnd: d3_noop,\n", | |
"\t polygonStart: d3_noop,\n", | |
"\t polygonEnd: d3_noop\n", | |
"\t };\n", | |
"\t function d3_geo_pathBoundsPoint(x, y) {\n", | |
"\t if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x;\n", | |
"\t if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x;\n", | |
"\t if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y;\n", | |
"\t if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y;\n", | |
"\t }\n", | |
"\t function d3_geo_pathBuffer() {\n", | |
"\t var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = [];\n", | |
"\t var stream = {\n", | |
"\t point: point,\n", | |
"\t lineStart: function() {\n", | |
"\t stream.point = pointLineStart;\n", | |
"\t },\n", | |
"\t lineEnd: lineEnd,\n", | |
"\t polygonStart: function() {\n", | |
"\t stream.lineEnd = lineEndPolygon;\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t stream.lineEnd = lineEnd;\n", | |
"\t stream.point = point;\n", | |
"\t },\n", | |
"\t pointRadius: function(_) {\n", | |
"\t pointCircle = d3_geo_pathBufferCircle(_);\n", | |
"\t return stream;\n", | |
"\t },\n", | |
"\t result: function() {\n", | |
"\t if (buffer.length) {\n", | |
"\t var result = buffer.join(\"\");\n", | |
"\t buffer = [];\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function point(x, y) {\n", | |
"\t buffer.push(\"M\", x, \",\", y, pointCircle);\n", | |
"\t }\n", | |
"\t function pointLineStart(x, y) {\n", | |
"\t buffer.push(\"M\", x, \",\", y);\n", | |
"\t stream.point = pointLine;\n", | |
"\t }\n", | |
"\t function pointLine(x, y) {\n", | |
"\t buffer.push(\"L\", x, \",\", y);\n", | |
"\t }\n", | |
"\t function lineEnd() {\n", | |
"\t stream.point = point;\n", | |
"\t }\n", | |
"\t function lineEndPolygon() {\n", | |
"\t buffer.push(\"Z\");\n", | |
"\t }\n", | |
"\t return stream;\n", | |
"\t }\n", | |
"\t function d3_geo_pathBufferCircle(radius) {\n", | |
"\t return \"m0,\" + radius + \"a\" + radius + \",\" + radius + \" 0 1,1 0,\" + -2 * radius + \"a\" + radius + \",\" + radius + \" 0 1,1 0,\" + 2 * radius + \"z\";\n", | |
"\t }\n", | |
"\t var d3_geo_pathCentroid = {\n", | |
"\t point: d3_geo_pathCentroidPoint,\n", | |
"\t lineStart: d3_geo_pathCentroidLineStart,\n", | |
"\t lineEnd: d3_geo_pathCentroidLineEnd,\n", | |
"\t polygonStart: function() {\n", | |
"\t d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart;\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;\n", | |
"\t d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart;\n", | |
"\t d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geo_pathCentroidPoint(x, y) {\n", | |
"\t d3_geo_centroidX0 += x;\n", | |
"\t d3_geo_centroidY0 += y;\n", | |
"\t ++d3_geo_centroidZ0;\n", | |
"\t }\n", | |
"\t function d3_geo_pathCentroidLineStart() {\n", | |
"\t var x0, y0;\n", | |
"\t d3_geo_pathCentroid.point = function(x, y) {\n", | |
"\t d3_geo_pathCentroid.point = nextPoint;\n", | |
"\t d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n", | |
"\t };\n", | |
"\t function nextPoint(x, y) {\n", | |
"\t var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);\n", | |
"\t d3_geo_centroidX1 += z * (x0 + x) / 2;\n", | |
"\t d3_geo_centroidY1 += z * (y0 + y) / 2;\n", | |
"\t d3_geo_centroidZ1 += z;\n", | |
"\t d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geo_pathCentroidLineEnd() {\n", | |
"\t d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;\n", | |
"\t }\n", | |
"\t function d3_geo_pathCentroidRingStart() {\n", | |
"\t var x00, y00, x0, y0;\n", | |
"\t d3_geo_pathCentroid.point = function(x, y) {\n", | |
"\t d3_geo_pathCentroid.point = nextPoint;\n", | |
"\t d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y);\n", | |
"\t };\n", | |
"\t function nextPoint(x, y) {\n", | |
"\t var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);\n", | |
"\t d3_geo_centroidX1 += z * (x0 + x) / 2;\n", | |
"\t d3_geo_centroidY1 += z * (y0 + y) / 2;\n", | |
"\t d3_geo_centroidZ1 += z;\n", | |
"\t z = y0 * x - x0 * y;\n", | |
"\t d3_geo_centroidX2 += z * (x0 + x);\n", | |
"\t d3_geo_centroidY2 += z * (y0 + y);\n", | |
"\t d3_geo_centroidZ2 += z * 3;\n", | |
"\t d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n", | |
"\t }\n", | |
"\t d3_geo_pathCentroid.lineEnd = function() {\n", | |
"\t nextPoint(x00, y00);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_pathContext(context) {\n", | |
"\t var pointRadius = 4.5;\n", | |
"\t var stream = {\n", | |
"\t point: point,\n", | |
"\t lineStart: function() {\n", | |
"\t stream.point = pointLineStart;\n", | |
"\t },\n", | |
"\t lineEnd: lineEnd,\n", | |
"\t polygonStart: function() {\n", | |
"\t stream.lineEnd = lineEndPolygon;\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t stream.lineEnd = lineEnd;\n", | |
"\t stream.point = point;\n", | |
"\t },\n", | |
"\t pointRadius: function(_) {\n", | |
"\t pointRadius = _;\n", | |
"\t return stream;\n", | |
"\t },\n", | |
"\t result: d3_noop\n", | |
"\t };\n", | |
"\t function point(x, y) {\n", | |
"\t context.moveTo(x + pointRadius, y);\n", | |
"\t context.arc(x, y, pointRadius, 0, τ);\n", | |
"\t }\n", | |
"\t function pointLineStart(x, y) {\n", | |
"\t context.moveTo(x, y);\n", | |
"\t stream.point = pointLine;\n", | |
"\t }\n", | |
"\t function pointLine(x, y) {\n", | |
"\t context.lineTo(x, y);\n", | |
"\t }\n", | |
"\t function lineEnd() {\n", | |
"\t stream.point = point;\n", | |
"\t }\n", | |
"\t function lineEndPolygon() {\n", | |
"\t context.closePath();\n", | |
"\t }\n", | |
"\t return stream;\n", | |
"\t }\n", | |
"\t function d3_geo_resample(project) {\n", | |
"\t var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16;\n", | |
"\t function resample(stream) {\n", | |
"\t return (maxDepth ? resampleRecursive : resampleNone)(stream);\n", | |
"\t }\n", | |
"\t function resampleNone(stream) {\n", | |
"\t return d3_geo_transformPoint(stream, function(x, y) {\n", | |
"\t x = project(x, y);\n", | |
"\t stream.point(x[0], x[1]);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function resampleRecursive(stream) {\n", | |
"\t var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0;\n", | |
"\t var resample = {\n", | |
"\t point: point,\n", | |
"\t lineStart: lineStart,\n", | |
"\t lineEnd: lineEnd,\n", | |
"\t polygonStart: function() {\n", | |
"\t stream.polygonStart();\n", | |
"\t resample.lineStart = ringStart;\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t stream.polygonEnd();\n", | |
"\t resample.lineStart = lineStart;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function point(x, y) {\n", | |
"\t x = project(x, y);\n", | |
"\t stream.point(x[0], x[1]);\n", | |
"\t }\n", | |
"\t function lineStart() {\n", | |
"\t x0 = NaN;\n", | |
"\t resample.point = linePoint;\n", | |
"\t stream.lineStart();\n", | |
"\t }\n", | |
"\t function linePoint(λ, φ) {\n", | |
"\t var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ);\n", | |
"\t resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);\n", | |
"\t stream.point(x0, y0);\n", | |
"\t }\n", | |
"\t function lineEnd() {\n", | |
"\t resample.point = point;\n", | |
"\t stream.lineEnd();\n", | |
"\t }\n", | |
"\t function ringStart() {\n", | |
"\t lineStart();\n", | |
"\t resample.point = ringPoint;\n", | |
"\t resample.lineEnd = ringEnd;\n", | |
"\t }\n", | |
"\t function ringPoint(λ, φ) {\n", | |
"\t linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;\n", | |
"\t resample.point = linePoint;\n", | |
"\t }\n", | |
"\t function ringEnd() {\n", | |
"\t resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream);\n", | |
"\t resample.lineEnd = lineEnd;\n", | |
"\t lineEnd();\n", | |
"\t }\n", | |
"\t return resample;\n", | |
"\t }\n", | |
"\t function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) {\n", | |
"\t var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;\n", | |
"\t if (d2 > 4 * δ2 && depth--) {\n", | |
"\t var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2;\n", | |
"\t if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {\n", | |
"\t resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream);\n", | |
"\t stream.point(x2, y2);\n", | |
"\t resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t resample.precision = function(_) {\n", | |
"\t if (!arguments.length) return Math.sqrt(δ2);\n", | |
"\t maxDepth = (δ2 = _ * _) > 0 && 16;\n", | |
"\t return resample;\n", | |
"\t };\n", | |
"\t return resample;\n", | |
"\t }\n", | |
"\t d3.geo.path = function() {\n", | |
"\t var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream;\n", | |
"\t function path(object) {\n", | |
"\t if (object) {\n", | |
"\t if (typeof pointRadius === \"function\") contextStream.pointRadius(+pointRadius.apply(this, arguments));\n", | |
"\t if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream);\n", | |
"\t d3.geo.stream(object, cacheStream);\n", | |
"\t }\n", | |
"\t return contextStream.result();\n", | |
"\t }\n", | |
"\t path.area = function(object) {\n", | |
"\t d3_geo_pathAreaSum = 0;\n", | |
"\t d3.geo.stream(object, projectStream(d3_geo_pathArea));\n", | |
"\t return d3_geo_pathAreaSum;\n", | |
"\t };\n", | |
"\t path.centroid = function(object) {\n", | |
"\t d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0;\n", | |
"\t d3.geo.stream(object, projectStream(d3_geo_pathCentroid));\n", | |
"\t return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ];\n", | |
"\t };\n", | |
"\t path.bounds = function(object) {\n", | |
"\t d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity);\n", | |
"\t d3.geo.stream(object, projectStream(d3_geo_pathBounds));\n", | |
"\t return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ];\n", | |
"\t };\n", | |
"\t path.projection = function(_) {\n", | |
"\t if (!arguments.length) return projection;\n", | |
"\t projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity;\n", | |
"\t return reset();\n", | |
"\t };\n", | |
"\t path.context = function(_) {\n", | |
"\t if (!arguments.length) return context;\n", | |
"\t contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_);\n", | |
"\t if (typeof pointRadius !== \"function\") contextStream.pointRadius(pointRadius);\n", | |
"\t return reset();\n", | |
"\t };\n", | |
"\t path.pointRadius = function(_) {\n", | |
"\t if (!arguments.length) return pointRadius;\n", | |
"\t pointRadius = typeof _ === \"function\" ? _ : (contextStream.pointRadius(+_), +_);\n", | |
"\t return path;\n", | |
"\t };\n", | |
"\t function reset() {\n", | |
"\t cacheStream = null;\n", | |
"\t return path;\n", | |
"\t }\n", | |
"\t return path.projection(d3.geo.albersUsa()).context(null);\n", | |
"\t };\n", | |
"\t function d3_geo_pathProjectStream(project) {\n", | |
"\t var resample = d3_geo_resample(function(x, y) {\n", | |
"\t return project([ x * d3_degrees, y * d3_degrees ]);\n", | |
"\t });\n", | |
"\t return function(stream) {\n", | |
"\t return d3_geo_projectionRadians(resample(stream));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.geo.transform = function(methods) {\n", | |
"\t return {\n", | |
"\t stream: function(stream) {\n", | |
"\t var transform = new d3_geo_transform(stream);\n", | |
"\t for (var k in methods) transform[k] = methods[k];\n", | |
"\t return transform;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t };\n", | |
"\t function d3_geo_transform(stream) {\n", | |
"\t this.stream = stream;\n", | |
"\t }\n", | |
"\t d3_geo_transform.prototype = {\n", | |
"\t point: function(x, y) {\n", | |
"\t this.stream.point(x, y);\n", | |
"\t },\n", | |
"\t sphere: function() {\n", | |
"\t this.stream.sphere();\n", | |
"\t },\n", | |
"\t lineStart: function() {\n", | |
"\t this.stream.lineStart();\n", | |
"\t },\n", | |
"\t lineEnd: function() {\n", | |
"\t this.stream.lineEnd();\n", | |
"\t },\n", | |
"\t polygonStart: function() {\n", | |
"\t this.stream.polygonStart();\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t this.stream.polygonEnd();\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geo_transformPoint(stream, point) {\n", | |
"\t return {\n", | |
"\t point: point,\n", | |
"\t sphere: function() {\n", | |
"\t stream.sphere();\n", | |
"\t },\n", | |
"\t lineStart: function() {\n", | |
"\t stream.lineStart();\n", | |
"\t },\n", | |
"\t lineEnd: function() {\n", | |
"\t stream.lineEnd();\n", | |
"\t },\n", | |
"\t polygonStart: function() {\n", | |
"\t stream.polygonStart();\n", | |
"\t },\n", | |
"\t polygonEnd: function() {\n", | |
"\t stream.polygonEnd();\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.geo.projection = d3_geo_projection;\n", | |
"\t d3.geo.projectionMutator = d3_geo_projectionMutator;\n", | |
"\t function d3_geo_projection(project) {\n", | |
"\t return d3_geo_projectionMutator(function() {\n", | |
"\t return project;\n", | |
"\t })();\n", | |
"\t }\n", | |
"\t function d3_geo_projectionMutator(projectAt) {\n", | |
"\t var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) {\n", | |
"\t x = project(x, y);\n", | |
"\t return [ x[0] * k + δx, δy - x[1] * k ];\n", | |
"\t }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream;\n", | |
"\t function projection(point) {\n", | |
"\t point = projectRotate(point[0] * d3_radians, point[1] * d3_radians);\n", | |
"\t return [ point[0] * k + δx, δy - point[1] * k ];\n", | |
"\t }\n", | |
"\t function invert(point) {\n", | |
"\t point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k);\n", | |
"\t return point && [ point[0] * d3_degrees, point[1] * d3_degrees ];\n", | |
"\t }\n", | |
"\t projection.stream = function(output) {\n", | |
"\t if (stream) stream.valid = false;\n", | |
"\t stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output))));\n", | |
"\t stream.valid = true;\n", | |
"\t return stream;\n", | |
"\t };\n", | |
"\t projection.clipAngle = function(_) {\n", | |
"\t if (!arguments.length) return clipAngle;\n", | |
"\t preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians);\n", | |
"\t return invalidate();\n", | |
"\t };\n", | |
"\t projection.clipExtent = function(_) {\n", | |
"\t if (!arguments.length) return clipExtent;\n", | |
"\t clipExtent = _;\n", | |
"\t postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity;\n", | |
"\t return invalidate();\n", | |
"\t };\n", | |
"\t projection.scale = function(_) {\n", | |
"\t if (!arguments.length) return k;\n", | |
"\t k = +_;\n", | |
"\t return reset();\n", | |
"\t };\n", | |
"\t projection.translate = function(_) {\n", | |
"\t if (!arguments.length) return [ x, y ];\n", | |
"\t x = +_[0];\n", | |
"\t y = +_[1];\n", | |
"\t return reset();\n", | |
"\t };\n", | |
"\t projection.center = function(_) {\n", | |
"\t if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ];\n", | |
"\t λ = _[0] % 360 * d3_radians;\n", | |
"\t φ = _[1] % 360 * d3_radians;\n", | |
"\t return reset();\n", | |
"\t };\n", | |
"\t projection.rotate = function(_) {\n", | |
"\t if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ];\n", | |
"\t δλ = _[0] % 360 * d3_radians;\n", | |
"\t δφ = _[1] % 360 * d3_radians;\n", | |
"\t δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0;\n", | |
"\t return reset();\n", | |
"\t };\n", | |
"\t d3.rebind(projection, projectResample, \"precision\");\n", | |
"\t function reset() {\n", | |
"\t projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project);\n", | |
"\t var center = project(λ, φ);\n", | |
"\t δx = x - center[0] * k;\n", | |
"\t δy = y + center[1] * k;\n", | |
"\t return invalidate();\n", | |
"\t }\n", | |
"\t function invalidate() {\n", | |
"\t if (stream) stream.valid = false, stream = null;\n", | |
"\t return projection;\n", | |
"\t }\n", | |
"\t return function() {\n", | |
"\t project = projectAt.apply(this, arguments);\n", | |
"\t projection.invert = project.invert && invert;\n", | |
"\t return reset();\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_projectionRadians(stream) {\n", | |
"\t return d3_geo_transformPoint(stream, function(x, y) {\n", | |
"\t stream.point(x * d3_radians, y * d3_radians);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function d3_geo_equirectangular(λ, φ) {\n", | |
"\t return [ λ, φ ];\n", | |
"\t }\n", | |
"\t (d3.geo.equirectangular = function() {\n", | |
"\t return d3_geo_projection(d3_geo_equirectangular);\n", | |
"\t }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;\n", | |
"\t d3.geo.rotation = function(rotate) {\n", | |
"\t rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0);\n", | |
"\t function forward(coordinates) {\n", | |
"\t coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians);\n", | |
"\t return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;\n", | |
"\t }\n", | |
"\t forward.invert = function(coordinates) {\n", | |
"\t coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians);\n", | |
"\t return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;\n", | |
"\t };\n", | |
"\t return forward;\n", | |
"\t };\n", | |
"\t function d3_geo_identityRotation(λ, φ) {\n", | |
"\t return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];\n", | |
"\t }\n", | |
"\t d3_geo_identityRotation.invert = d3_geo_equirectangular;\n", | |
"\t function d3_geo_rotation(δλ, δφ, δγ) {\n", | |
"\t return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation;\n", | |
"\t }\n", | |
"\t function d3_geo_forwardRotationλ(δλ) {\n", | |
"\t return function(λ, φ) {\n", | |
"\t return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_rotationλ(δλ) {\n", | |
"\t var rotation = d3_geo_forwardRotationλ(δλ);\n", | |
"\t rotation.invert = d3_geo_forwardRotationλ(-δλ);\n", | |
"\t return rotation;\n", | |
"\t }\n", | |
"\t function d3_geo_rotationφγ(δφ, δγ) {\n", | |
"\t var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ);\n", | |
"\t function rotation(λ, φ) {\n", | |
"\t var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ;\n", | |
"\t return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ];\n", | |
"\t }\n", | |
"\t rotation.invert = function(λ, φ) {\n", | |
"\t var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ;\n", | |
"\t return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ];\n", | |
"\t };\n", | |
"\t return rotation;\n", | |
"\t }\n", | |
"\t d3.geo.circle = function() {\n", | |
"\t var origin = [ 0, 0 ], angle, precision = 6, interpolate;\n", | |
"\t function circle() {\n", | |
"\t var center = typeof origin === \"function\" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = [];\n", | |
"\t interpolate(null, null, 1, {\n", | |
"\t point: function(x, y) {\n", | |
"\t ring.push(x = rotate(x, y));\n", | |
"\t x[0] *= d3_degrees, x[1] *= d3_degrees;\n", | |
"\t }\n", | |
"\t });\n", | |
"\t return {\n", | |
"\t type: \"Polygon\",\n", | |
"\t coordinates: [ ring ]\n", | |
"\t };\n", | |
"\t }\n", | |
"\t circle.origin = function(x) {\n", | |
"\t if (!arguments.length) return origin;\n", | |
"\t origin = x;\n", | |
"\t return circle;\n", | |
"\t };\n", | |
"\t circle.angle = function(x) {\n", | |
"\t if (!arguments.length) return angle;\n", | |
"\t interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians);\n", | |
"\t return circle;\n", | |
"\t };\n", | |
"\t circle.precision = function(_) {\n", | |
"\t if (!arguments.length) return precision;\n", | |
"\t interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians);\n", | |
"\t return circle;\n", | |
"\t };\n", | |
"\t return circle.angle(90);\n", | |
"\t };\n", | |
"\t function d3_geo_circleInterpolate(radius, precision) {\n", | |
"\t var cr = Math.cos(radius), sr = Math.sin(radius);\n", | |
"\t return function(from, to, direction, listener) {\n", | |
"\t var step = direction * precision;\n", | |
"\t if (from != null) {\n", | |
"\t from = d3_geo_circleAngle(cr, from);\n", | |
"\t to = d3_geo_circleAngle(cr, to);\n", | |
"\t if (direction > 0 ? from < to : from > to) from += direction * τ;\n", | |
"\t } else {\n", | |
"\t from = radius + direction * τ;\n", | |
"\t to = radius - .5 * step;\n", | |
"\t }\n", | |
"\t for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) {\n", | |
"\t listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_circleAngle(cr, point) {\n", | |
"\t var a = d3_geo_cartesian(point);\n", | |
"\t a[0] -= cr;\n", | |
"\t d3_geo_cartesianNormalize(a);\n", | |
"\t var angle = d3_acos(-a[1]);\n", | |
"\t return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI);\n", | |
"\t }\n", | |
"\t d3.geo.distance = function(a, b) {\n", | |
"\t var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t;\n", | |
"\t return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ);\n", | |
"\t };\n", | |
"\t d3.geo.graticule = function() {\n", | |
"\t var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5;\n", | |
"\t function graticule() {\n", | |
"\t return {\n", | |
"\t type: \"MultiLineString\",\n", | |
"\t coordinates: lines()\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function lines() {\n", | |
"\t return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) {\n", | |
"\t return abs(x % DX) > ε;\n", | |
"\t }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) {\n", | |
"\t return abs(y % DY) > ε;\n", | |
"\t }).map(y));\n", | |
"\t }\n", | |
"\t graticule.lines = function() {\n", | |
"\t return lines().map(function(coordinates) {\n", | |
"\t return {\n", | |
"\t type: \"LineString\",\n", | |
"\t coordinates: coordinates\n", | |
"\t };\n", | |
"\t });\n", | |
"\t };\n", | |
"\t graticule.outline = function() {\n", | |
"\t return {\n", | |
"\t type: \"Polygon\",\n", | |
"\t coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ]\n", | |
"\t };\n", | |
"\t };\n", | |
"\t graticule.extent = function(_) {\n", | |
"\t if (!arguments.length) return graticule.minorExtent();\n", | |
"\t return graticule.majorExtent(_).minorExtent(_);\n", | |
"\t };\n", | |
"\t graticule.majorExtent = function(_) {\n", | |
"\t if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ];\n", | |
"\t X0 = +_[0][0], X1 = +_[1][0];\n", | |
"\t Y0 = +_[0][1], Y1 = +_[1][1];\n", | |
"\t if (X0 > X1) _ = X0, X0 = X1, X1 = _;\n", | |
"\t if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;\n", | |
"\t return graticule.precision(precision);\n", | |
"\t };\n", | |
"\t graticule.minorExtent = function(_) {\n", | |
"\t if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];\n", | |
"\t x0 = +_[0][0], x1 = +_[1][0];\n", | |
"\t y0 = +_[0][1], y1 = +_[1][1];\n", | |
"\t if (x0 > x1) _ = x0, x0 = x1, x1 = _;\n", | |
"\t if (y0 > y1) _ = y0, y0 = y1, y1 = _;\n", | |
"\t return graticule.precision(precision);\n", | |
"\t };\n", | |
"\t graticule.step = function(_) {\n", | |
"\t if (!arguments.length) return graticule.minorStep();\n", | |
"\t return graticule.majorStep(_).minorStep(_);\n", | |
"\t };\n", | |
"\t graticule.majorStep = function(_) {\n", | |
"\t if (!arguments.length) return [ DX, DY ];\n", | |
"\t DX = +_[0], DY = +_[1];\n", | |
"\t return graticule;\n", | |
"\t };\n", | |
"\t graticule.minorStep = function(_) {\n", | |
"\t if (!arguments.length) return [ dx, dy ];\n", | |
"\t dx = +_[0], dy = +_[1];\n", | |
"\t return graticule;\n", | |
"\t };\n", | |
"\t graticule.precision = function(_) {\n", | |
"\t if (!arguments.length) return precision;\n", | |
"\t precision = +_;\n", | |
"\t x = d3_geo_graticuleX(y0, y1, 90);\n", | |
"\t y = d3_geo_graticuleY(x0, x1, precision);\n", | |
"\t X = d3_geo_graticuleX(Y0, Y1, 90);\n", | |
"\t Y = d3_geo_graticuleY(X0, X1, precision);\n", | |
"\t return graticule;\n", | |
"\t };\n", | |
"\t return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]);\n", | |
"\t };\n", | |
"\t function d3_geo_graticuleX(y0, y1, dy) {\n", | |
"\t var y = d3.range(y0, y1 - ε, dy).concat(y1);\n", | |
"\t return function(x) {\n", | |
"\t return y.map(function(y) {\n", | |
"\t return [ x, y ];\n", | |
"\t });\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geo_graticuleY(x0, x1, dx) {\n", | |
"\t var x = d3.range(x0, x1 - ε, dx).concat(x1);\n", | |
"\t return function(y) {\n", | |
"\t return x.map(function(x) {\n", | |
"\t return [ x, y ];\n", | |
"\t });\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_source(d) {\n", | |
"\t return d.source;\n", | |
"\t }\n", | |
"\t function d3_target(d) {\n", | |
"\t return d.target;\n", | |
"\t }\n", | |
"\t d3.geo.greatArc = function() {\n", | |
"\t var source = d3_source, source_, target = d3_target, target_;\n", | |
"\t function greatArc() {\n", | |
"\t return {\n", | |
"\t type: \"LineString\",\n", | |
"\t coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ]\n", | |
"\t };\n", | |
"\t }\n", | |
"\t greatArc.distance = function() {\n", | |
"\t return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments));\n", | |
"\t };\n", | |
"\t greatArc.source = function(_) {\n", | |
"\t if (!arguments.length) return source;\n", | |
"\t source = _, source_ = typeof _ === \"function\" ? null : _;\n", | |
"\t return greatArc;\n", | |
"\t };\n", | |
"\t greatArc.target = function(_) {\n", | |
"\t if (!arguments.length) return target;\n", | |
"\t target = _, target_ = typeof _ === \"function\" ? null : _;\n", | |
"\t return greatArc;\n", | |
"\t };\n", | |
"\t greatArc.precision = function() {\n", | |
"\t return arguments.length ? greatArc : 0;\n", | |
"\t };\n", | |
"\t return greatArc;\n", | |
"\t };\n", | |
"\t d3.geo.interpolate = function(source, target) {\n", | |
"\t return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians);\n", | |
"\t };\n", | |
"\t function d3_geo_interpolate(x0, y0, x1, y1) {\n", | |
"\t var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d);\n", | |
"\t var interpolate = d ? function(t) {\n", | |
"\t var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1;\n", | |
"\t return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ];\n", | |
"\t } : function() {\n", | |
"\t return [ x0 * d3_degrees, y0 * d3_degrees ];\n", | |
"\t };\n", | |
"\t interpolate.distance = d;\n", | |
"\t return interpolate;\n", | |
"\t }\n", | |
"\t d3.geo.length = function(object) {\n", | |
"\t d3_geo_lengthSum = 0;\n", | |
"\t d3.geo.stream(object, d3_geo_length);\n", | |
"\t return d3_geo_lengthSum;\n", | |
"\t };\n", | |
"\t var d3_geo_lengthSum;\n", | |
"\t var d3_geo_length = {\n", | |
"\t sphere: d3_noop,\n", | |
"\t point: d3_noop,\n", | |
"\t lineStart: d3_geo_lengthLineStart,\n", | |
"\t lineEnd: d3_noop,\n", | |
"\t polygonStart: d3_noop,\n", | |
"\t polygonEnd: d3_noop\n", | |
"\t };\n", | |
"\t function d3_geo_lengthLineStart() {\n", | |
"\t var λ0, sinφ0, cosφ0;\n", | |
"\t d3_geo_length.point = function(λ, φ) {\n", | |
"\t λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ);\n", | |
"\t d3_geo_length.point = nextPoint;\n", | |
"\t };\n", | |
"\t d3_geo_length.lineEnd = function() {\n", | |
"\t d3_geo_length.point = d3_geo_length.lineEnd = d3_noop;\n", | |
"\t };\n", | |
"\t function nextPoint(λ, φ) {\n", | |
"\t var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t);\n", | |
"\t d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ);\n", | |
"\t λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geo_azimuthal(scale, angle) {\n", | |
"\t function azimuthal(λ, φ) {\n", | |
"\t var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ);\n", | |
"\t return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ];\n", | |
"\t }\n", | |
"\t azimuthal.invert = function(x, y) {\n", | |
"\t var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c);\n", | |
"\t return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ];\n", | |
"\t };\n", | |
"\t return azimuthal;\n", | |
"\t }\n", | |
"\t var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) {\n", | |
"\t return Math.sqrt(2 / (1 + cosλcosφ));\n", | |
"\t }, function(ρ) {\n", | |
"\t return 2 * Math.asin(ρ / 2);\n", | |
"\t });\n", | |
"\t (d3.geo.azimuthalEqualArea = function() {\n", | |
"\t return d3_geo_projection(d3_geo_azimuthalEqualArea);\n", | |
"\t }).raw = d3_geo_azimuthalEqualArea;\n", | |
"\t var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) {\n", | |
"\t var c = Math.acos(cosλcosφ);\n", | |
"\t return c && c / Math.sin(c);\n", | |
"\t }, d3_identity);\n", | |
"\t (d3.geo.azimuthalEquidistant = function() {\n", | |
"\t return d3_geo_projection(d3_geo_azimuthalEquidistant);\n", | |
"\t }).raw = d3_geo_azimuthalEquidistant;\n", | |
"\t function d3_geo_conicConformal(φ0, φ1) {\n", | |
"\t var cosφ0 = Math.cos(φ0), t = function(φ) {\n", | |
"\t return Math.tan(π / 4 + φ / 2);\n", | |
"\t }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n;\n", | |
"\t if (!n) return d3_geo_mercator;\n", | |
"\t function forward(λ, φ) {\n", | |
"\t if (F > 0) {\n", | |
"\t if (φ < -halfπ + ε) φ = -halfπ + ε;\n", | |
"\t } else {\n", | |
"\t if (φ > halfπ - ε) φ = halfπ - ε;\n", | |
"\t }\n", | |
"\t var ρ = F / Math.pow(t(φ), n);\n", | |
"\t return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ];\n", | |
"\t }\n", | |
"\t forward.invert = function(x, y) {\n", | |
"\t var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y);\n", | |
"\t return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ];\n", | |
"\t };\n", | |
"\t return forward;\n", | |
"\t }\n", | |
"\t (d3.geo.conicConformal = function() {\n", | |
"\t return d3_geo_conic(d3_geo_conicConformal);\n", | |
"\t }).raw = d3_geo_conicConformal;\n", | |
"\t function d3_geo_conicEquidistant(φ0, φ1) {\n", | |
"\t var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0;\n", | |
"\t if (abs(n) < ε) return d3_geo_equirectangular;\n", | |
"\t function forward(λ, φ) {\n", | |
"\t var ρ = G - φ;\n", | |
"\t return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ];\n", | |
"\t }\n", | |
"\t forward.invert = function(x, y) {\n", | |
"\t var ρ0_y = G - y;\n", | |
"\t return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ];\n", | |
"\t };\n", | |
"\t return forward;\n", | |
"\t }\n", | |
"\t (d3.geo.conicEquidistant = function() {\n", | |
"\t return d3_geo_conic(d3_geo_conicEquidistant);\n", | |
"\t }).raw = d3_geo_conicEquidistant;\n", | |
"\t var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) {\n", | |
"\t return 1 / cosλcosφ;\n", | |
"\t }, Math.atan);\n", | |
"\t (d3.geo.gnomonic = function() {\n", | |
"\t return d3_geo_projection(d3_geo_gnomonic);\n", | |
"\t }).raw = d3_geo_gnomonic;\n", | |
"\t function d3_geo_mercator(λ, φ) {\n", | |
"\t return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ];\n", | |
"\t }\n", | |
"\t d3_geo_mercator.invert = function(x, y) {\n", | |
"\t return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ];\n", | |
"\t };\n", | |
"\t function d3_geo_mercatorProjection(project) {\n", | |
"\t var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto;\n", | |
"\t m.scale = function() {\n", | |
"\t var v = scale.apply(m, arguments);\n", | |
"\t return v === m ? clipAuto ? m.clipExtent(null) : m : v;\n", | |
"\t };\n", | |
"\t m.translate = function() {\n", | |
"\t var v = translate.apply(m, arguments);\n", | |
"\t return v === m ? clipAuto ? m.clipExtent(null) : m : v;\n", | |
"\t };\n", | |
"\t m.clipExtent = function(_) {\n", | |
"\t var v = clipExtent.apply(m, arguments);\n", | |
"\t if (v === m) {\n", | |
"\t if (clipAuto = _ == null) {\n", | |
"\t var k = π * scale(), t = translate();\n", | |
"\t clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]);\n", | |
"\t }\n", | |
"\t } else if (clipAuto) {\n", | |
"\t v = null;\n", | |
"\t }\n", | |
"\t return v;\n", | |
"\t };\n", | |
"\t return m.clipExtent(null);\n", | |
"\t }\n", | |
"\t (d3.geo.mercator = function() {\n", | |
"\t return d3_geo_mercatorProjection(d3_geo_mercator);\n", | |
"\t }).raw = d3_geo_mercator;\n", | |
"\t var d3_geo_orthographic = d3_geo_azimuthal(function() {\n", | |
"\t return 1;\n", | |
"\t }, Math.asin);\n", | |
"\t (d3.geo.orthographic = function() {\n", | |
"\t return d3_geo_projection(d3_geo_orthographic);\n", | |
"\t }).raw = d3_geo_orthographic;\n", | |
"\t var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) {\n", | |
"\t return 1 / (1 + cosλcosφ);\n", | |
"\t }, function(ρ) {\n", | |
"\t return 2 * Math.atan(ρ);\n", | |
"\t });\n", | |
"\t (d3.geo.stereographic = function() {\n", | |
"\t return d3_geo_projection(d3_geo_stereographic);\n", | |
"\t }).raw = d3_geo_stereographic;\n", | |
"\t function d3_geo_transverseMercator(λ, φ) {\n", | |
"\t return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ];\n", | |
"\t }\n", | |
"\t d3_geo_transverseMercator.invert = function(x, y) {\n", | |
"\t return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ];\n", | |
"\t };\n", | |
"\t (d3.geo.transverseMercator = function() {\n", | |
"\t var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate;\n", | |
"\t projection.center = function(_) {\n", | |
"\t return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]);\n", | |
"\t };\n", | |
"\t projection.rotate = function(_) {\n", | |
"\t return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), \n", | |
"\t [ _[0], _[1], _[2] - 90 ]);\n", | |
"\t };\n", | |
"\t return rotate([ 0, 0, 90 ]);\n", | |
"\t }).raw = d3_geo_transverseMercator;\n", | |
"\t d3.geom = {};\n", | |
"\t function d3_geom_pointX(d) {\n", | |
"\t return d[0];\n", | |
"\t }\n", | |
"\t function d3_geom_pointY(d) {\n", | |
"\t return d[1];\n", | |
"\t }\n", | |
"\t d3.geom.hull = function(vertices) {\n", | |
"\t var x = d3_geom_pointX, y = d3_geom_pointY;\n", | |
"\t if (arguments.length) return hull(vertices);\n", | |
"\t function hull(data) {\n", | |
"\t if (data.length < 3) return [];\n", | |
"\t var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = [];\n", | |
"\t for (i = 0; i < n; i++) {\n", | |
"\t points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]);\n", | |
"\t }\n", | |
"\t points.sort(d3_geom_hullOrder);\n", | |
"\t for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]);\n", | |
"\t var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints);\n", | |
"\t var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = [];\n", | |
"\t for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]);\n", | |
"\t for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]);\n", | |
"\t return polygon;\n", | |
"\t }\n", | |
"\t hull.x = function(_) {\n", | |
"\t return arguments.length ? (x = _, hull) : x;\n", | |
"\t };\n", | |
"\t hull.y = function(_) {\n", | |
"\t return arguments.length ? (y = _, hull) : y;\n", | |
"\t };\n", | |
"\t return hull;\n", | |
"\t };\n", | |
"\t function d3_geom_hullUpper(points) {\n", | |
"\t var n = points.length, hull = [ 0, 1 ], hs = 2;\n", | |
"\t for (var i = 2; i < n; i++) {\n", | |
"\t while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs;\n", | |
"\t hull[hs++] = i;\n", | |
"\t }\n", | |
"\t return hull.slice(0, hs);\n", | |
"\t }\n", | |
"\t function d3_geom_hullOrder(a, b) {\n", | |
"\t return a[0] - b[0] || a[1] - b[1];\n", | |
"\t }\n", | |
"\t d3.geom.polygon = function(coordinates) {\n", | |
"\t d3_subclass(coordinates, d3_geom_polygonPrototype);\n", | |
"\t return coordinates;\n", | |
"\t };\n", | |
"\t var d3_geom_polygonPrototype = d3.geom.polygon.prototype = [];\n", | |
"\t d3_geom_polygonPrototype.area = function() {\n", | |
"\t var i = -1, n = this.length, a, b = this[n - 1], area = 0;\n", | |
"\t while (++i < n) {\n", | |
"\t a = b;\n", | |
"\t b = this[i];\n", | |
"\t area += a[1] * b[0] - a[0] * b[1];\n", | |
"\t }\n", | |
"\t return area * .5;\n", | |
"\t };\n", | |
"\t d3_geom_polygonPrototype.centroid = function(k) {\n", | |
"\t var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c;\n", | |
"\t if (!arguments.length) k = -1 / (6 * this.area());\n", | |
"\t while (++i < n) {\n", | |
"\t a = b;\n", | |
"\t b = this[i];\n", | |
"\t c = a[0] * b[1] - b[0] * a[1];\n", | |
"\t x += (a[0] + b[0]) * c;\n", | |
"\t y += (a[1] + b[1]) * c;\n", | |
"\t }\n", | |
"\t return [ x * k, y * k ];\n", | |
"\t };\n", | |
"\t d3_geom_polygonPrototype.clip = function(subject) {\n", | |
"\t var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d;\n", | |
"\t while (++i < n) {\n", | |
"\t input = subject.slice();\n", | |
"\t subject.length = 0;\n", | |
"\t b = this[i];\n", | |
"\t c = input[(m = input.length - closed) - 1];\n", | |
"\t j = -1;\n", | |
"\t while (++j < m) {\n", | |
"\t d = input[j];\n", | |
"\t if (d3_geom_polygonInside(d, a, b)) {\n", | |
"\t if (!d3_geom_polygonInside(c, a, b)) {\n", | |
"\t subject.push(d3_geom_polygonIntersect(c, d, a, b));\n", | |
"\t }\n", | |
"\t subject.push(d);\n", | |
"\t } else if (d3_geom_polygonInside(c, a, b)) {\n", | |
"\t subject.push(d3_geom_polygonIntersect(c, d, a, b));\n", | |
"\t }\n", | |
"\t c = d;\n", | |
"\t }\n", | |
"\t if (closed) subject.push(subject[0]);\n", | |
"\t a = b;\n", | |
"\t }\n", | |
"\t return subject;\n", | |
"\t };\n", | |
"\t function d3_geom_polygonInside(p, a, b) {\n", | |
"\t return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);\n", | |
"\t }\n", | |
"\t function d3_geom_polygonIntersect(c, d, a, b) {\n", | |
"\t var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21);\n", | |
"\t return [ x1 + ua * x21, y1 + ua * y21 ];\n", | |
"\t }\n", | |
"\t function d3_geom_polygonClosed(coordinates) {\n", | |
"\t var a = coordinates[0], b = coordinates[coordinates.length - 1];\n", | |
"\t return !(a[0] - b[0] || a[1] - b[1]);\n", | |
"\t }\n", | |
"\t var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = [];\n", | |
"\t function d3_geom_voronoiBeach() {\n", | |
"\t d3_geom_voronoiRedBlackNode(this);\n", | |
"\t this.edge = this.site = this.circle = null;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiCreateBeach(site) {\n", | |
"\t var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach();\n", | |
"\t beach.site = site;\n", | |
"\t return beach;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiDetachBeach(beach) {\n", | |
"\t d3_geom_voronoiDetachCircle(beach);\n", | |
"\t d3_geom_voronoiBeaches.remove(beach);\n", | |
"\t d3_geom_voronoiBeachPool.push(beach);\n", | |
"\t d3_geom_voronoiRedBlackNode(beach);\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiRemoveBeach(beach) {\n", | |
"\t var circle = beach.circle, x = circle.x, y = circle.cy, vertex = {\n", | |
"\t x: x,\n", | |
"\t y: y\n", | |
"\t }, previous = beach.P, next = beach.N, disappearing = [ beach ];\n", | |
"\t d3_geom_voronoiDetachBeach(beach);\n", | |
"\t var lArc = previous;\n", | |
"\t while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) {\n", | |
"\t previous = lArc.P;\n", | |
"\t disappearing.unshift(lArc);\n", | |
"\t d3_geom_voronoiDetachBeach(lArc);\n", | |
"\t lArc = previous;\n", | |
"\t }\n", | |
"\t disappearing.unshift(lArc);\n", | |
"\t d3_geom_voronoiDetachCircle(lArc);\n", | |
"\t var rArc = next;\n", | |
"\t while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) {\n", | |
"\t next = rArc.N;\n", | |
"\t disappearing.push(rArc);\n", | |
"\t d3_geom_voronoiDetachBeach(rArc);\n", | |
"\t rArc = next;\n", | |
"\t }\n", | |
"\t disappearing.push(rArc);\n", | |
"\t d3_geom_voronoiDetachCircle(rArc);\n", | |
"\t var nArcs = disappearing.length, iArc;\n", | |
"\t for (iArc = 1; iArc < nArcs; ++iArc) {\n", | |
"\t rArc = disappearing[iArc];\n", | |
"\t lArc = disappearing[iArc - 1];\n", | |
"\t d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);\n", | |
"\t }\n", | |
"\t lArc = disappearing[0];\n", | |
"\t rArc = disappearing[nArcs - 1];\n", | |
"\t rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex);\n", | |
"\t d3_geom_voronoiAttachCircle(lArc);\n", | |
"\t d3_geom_voronoiAttachCircle(rArc);\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiAddBeach(site) {\n", | |
"\t var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._;\n", | |
"\t while (node) {\n", | |
"\t dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x;\n", | |
"\t if (dxl > ε) node = node.L; else {\n", | |
"\t dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix);\n", | |
"\t if (dxr > ε) {\n", | |
"\t if (!node.R) {\n", | |
"\t lArc = node;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t node = node.R;\n", | |
"\t } else {\n", | |
"\t if (dxl > -ε) {\n", | |
"\t lArc = node.P;\n", | |
"\t rArc = node;\n", | |
"\t } else if (dxr > -ε) {\n", | |
"\t lArc = node;\n", | |
"\t rArc = node.N;\n", | |
"\t } else {\n", | |
"\t lArc = rArc = node;\n", | |
"\t }\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var newArc = d3_geom_voronoiCreateBeach(site);\n", | |
"\t d3_geom_voronoiBeaches.insert(lArc, newArc);\n", | |
"\t if (!lArc && !rArc) return;\n", | |
"\t if (lArc === rArc) {\n", | |
"\t d3_geom_voronoiDetachCircle(lArc);\n", | |
"\t rArc = d3_geom_voronoiCreateBeach(lArc.site);\n", | |
"\t d3_geom_voronoiBeaches.insert(newArc, rArc);\n", | |
"\t newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);\n", | |
"\t d3_geom_voronoiAttachCircle(lArc);\n", | |
"\t d3_geom_voronoiAttachCircle(rArc);\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t if (!rArc) {\n", | |
"\t newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t d3_geom_voronoiDetachCircle(lArc);\n", | |
"\t d3_geom_voronoiDetachCircle(rArc);\n", | |
"\t var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = {\n", | |
"\t x: (cy * hb - by * hc) / d + ax,\n", | |
"\t y: (bx * hc - cx * hb) / d + ay\n", | |
"\t };\n", | |
"\t d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex);\n", | |
"\t newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex);\n", | |
"\t rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex);\n", | |
"\t d3_geom_voronoiAttachCircle(lArc);\n", | |
"\t d3_geom_voronoiAttachCircle(rArc);\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiLeftBreakPoint(arc, directrix) {\n", | |
"\t var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix;\n", | |
"\t if (!pby2) return rfocx;\n", | |
"\t var lArc = arc.P;\n", | |
"\t if (!lArc) return -Infinity;\n", | |
"\t site = lArc.site;\n", | |
"\t var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix;\n", | |
"\t if (!plby2) return lfocx;\n", | |
"\t var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2;\n", | |
"\t if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;\n", | |
"\t return (rfocx + lfocx) / 2;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiRightBreakPoint(arc, directrix) {\n", | |
"\t var rArc = arc.N;\n", | |
"\t if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix);\n", | |
"\t var site = arc.site;\n", | |
"\t return site.y === directrix ? site.x : Infinity;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiCell(site) {\n", | |
"\t this.site = site;\n", | |
"\t this.edges = [];\n", | |
"\t }\n", | |
"\t d3_geom_voronoiCell.prototype.prepare = function() {\n", | |
"\t var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge;\n", | |
"\t while (iHalfEdge--) {\n", | |
"\t edge = halfEdges[iHalfEdge].edge;\n", | |
"\t if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1);\n", | |
"\t }\n", | |
"\t halfEdges.sort(d3_geom_voronoiHalfEdgeOrder);\n", | |
"\t return halfEdges.length;\n", | |
"\t };\n", | |
"\t function d3_geom_voronoiCloseCells(extent) {\n", | |
"\t var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end;\n", | |
"\t while (iCell--) {\n", | |
"\t cell = cells[iCell];\n", | |
"\t if (!cell || !cell.prepare()) continue;\n", | |
"\t halfEdges = cell.edges;\n", | |
"\t nHalfEdges = halfEdges.length;\n", | |
"\t iHalfEdge = 0;\n", | |
"\t while (iHalfEdge < nHalfEdges) {\n", | |
"\t end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y;\n", | |
"\t start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y;\n", | |
"\t if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) {\n", | |
"\t halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? {\n", | |
"\t x: x0,\n", | |
"\t y: abs(x2 - x0) < ε ? y2 : y1\n", | |
"\t } : abs(y3 - y1) < ε && x1 - x3 > ε ? {\n", | |
"\t x: abs(y2 - y1) < ε ? x2 : x1,\n", | |
"\t y: y1\n", | |
"\t } : abs(x3 - x1) < ε && y3 - y0 > ε ? {\n", | |
"\t x: x1,\n", | |
"\t y: abs(x2 - x1) < ε ? y2 : y0\n", | |
"\t } : abs(y3 - y0) < ε && x3 - x0 > ε ? {\n", | |
"\t x: abs(y2 - y0) < ε ? x2 : x0,\n", | |
"\t y: y0\n", | |
"\t } : null), cell.site, null));\n", | |
"\t ++nHalfEdges;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiHalfEdgeOrder(a, b) {\n", | |
"\t return b.angle - a.angle;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiCircle() {\n", | |
"\t d3_geom_voronoiRedBlackNode(this);\n", | |
"\t this.x = this.y = this.arc = this.site = this.cy = null;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiAttachCircle(arc) {\n", | |
"\t var lArc = arc.P, rArc = arc.N;\n", | |
"\t if (!lArc || !rArc) return;\n", | |
"\t var lSite = lArc.site, cSite = arc.site, rSite = rArc.site;\n", | |
"\t if (lSite === rSite) return;\n", | |
"\t var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by;\n", | |
"\t var d = 2 * (ax * cy - ay * cx);\n", | |
"\t if (d >= -ε2) return;\n", | |
"\t var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by;\n", | |
"\t var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle();\n", | |
"\t circle.arc = arc;\n", | |
"\t circle.site = cSite;\n", | |
"\t circle.x = x + bx;\n", | |
"\t circle.y = cy + Math.sqrt(x * x + y * y);\n", | |
"\t circle.cy = cy;\n", | |
"\t arc.circle = circle;\n", | |
"\t var before = null, node = d3_geom_voronoiCircles._;\n", | |
"\t while (node) {\n", | |
"\t if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) {\n", | |
"\t if (node.L) node = node.L; else {\n", | |
"\t before = node.P;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t if (node.R) node = node.R; else {\n", | |
"\t before = node;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3_geom_voronoiCircles.insert(before, circle);\n", | |
"\t if (!before) d3_geom_voronoiFirstCircle = circle;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiDetachCircle(arc) {\n", | |
"\t var circle = arc.circle;\n", | |
"\t if (circle) {\n", | |
"\t if (!circle.P) d3_geom_voronoiFirstCircle = circle.N;\n", | |
"\t d3_geom_voronoiCircles.remove(circle);\n", | |
"\t d3_geom_voronoiCirclePool.push(circle);\n", | |
"\t d3_geom_voronoiRedBlackNode(circle);\n", | |
"\t arc.circle = null;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiClipEdges(extent) {\n", | |
"\t var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e;\n", | |
"\t while (i--) {\n", | |
"\t e = edges[i];\n", | |
"\t if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) {\n", | |
"\t e.a = e.b = null;\n", | |
"\t edges.splice(i, 1);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiConnectEdge(edge, extent) {\n", | |
"\t var vb = edge.b;\n", | |
"\t if (vb) return true;\n", | |
"\t var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb;\n", | |
"\t if (ry === ly) {\n", | |
"\t if (fx < x0 || fx >= x1) return;\n", | |
"\t if (lx > rx) {\n", | |
"\t if (!va) va = {\n", | |
"\t x: fx,\n", | |
"\t y: y0\n", | |
"\t }; else if (va.y >= y1) return;\n", | |
"\t vb = {\n", | |
"\t x: fx,\n", | |
"\t y: y1\n", | |
"\t };\n", | |
"\t } else {\n", | |
"\t if (!va) va = {\n", | |
"\t x: fx,\n", | |
"\t y: y1\n", | |
"\t }; else if (va.y < y0) return;\n", | |
"\t vb = {\n", | |
"\t x: fx,\n", | |
"\t y: y0\n", | |
"\t };\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t fm = (lx - rx) / (ry - ly);\n", | |
"\t fb = fy - fm * fx;\n", | |
"\t if (fm < -1 || fm > 1) {\n", | |
"\t if (lx > rx) {\n", | |
"\t if (!va) va = {\n", | |
"\t x: (y0 - fb) / fm,\n", | |
"\t y: y0\n", | |
"\t }; else if (va.y >= y1) return;\n", | |
"\t vb = {\n", | |
"\t x: (y1 - fb) / fm,\n", | |
"\t y: y1\n", | |
"\t };\n", | |
"\t } else {\n", | |
"\t if (!va) va = {\n", | |
"\t x: (y1 - fb) / fm,\n", | |
"\t y: y1\n", | |
"\t }; else if (va.y < y0) return;\n", | |
"\t vb = {\n", | |
"\t x: (y0 - fb) / fm,\n", | |
"\t y: y0\n", | |
"\t };\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t if (ly < ry) {\n", | |
"\t if (!va) va = {\n", | |
"\t x: x0,\n", | |
"\t y: fm * x0 + fb\n", | |
"\t }; else if (va.x >= x1) return;\n", | |
"\t vb = {\n", | |
"\t x: x1,\n", | |
"\t y: fm * x1 + fb\n", | |
"\t };\n", | |
"\t } else {\n", | |
"\t if (!va) va = {\n", | |
"\t x: x1,\n", | |
"\t y: fm * x1 + fb\n", | |
"\t }; else if (va.x < x0) return;\n", | |
"\t vb = {\n", | |
"\t x: x0,\n", | |
"\t y: fm * x0 + fb\n", | |
"\t };\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t edge.a = va;\n", | |
"\t edge.b = vb;\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiEdge(lSite, rSite) {\n", | |
"\t this.l = lSite;\n", | |
"\t this.r = rSite;\n", | |
"\t this.a = this.b = null;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) {\n", | |
"\t var edge = new d3_geom_voronoiEdge(lSite, rSite);\n", | |
"\t d3_geom_voronoiEdges.push(edge);\n", | |
"\t if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va);\n", | |
"\t if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb);\n", | |
"\t d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite));\n", | |
"\t d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite));\n", | |
"\t return edge;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) {\n", | |
"\t var edge = new d3_geom_voronoiEdge(lSite, null);\n", | |
"\t edge.a = va;\n", | |
"\t edge.b = vb;\n", | |
"\t d3_geom_voronoiEdges.push(edge);\n", | |
"\t return edge;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) {\n", | |
"\t if (!edge.a && !edge.b) {\n", | |
"\t edge.a = vertex;\n", | |
"\t edge.l = lSite;\n", | |
"\t edge.r = rSite;\n", | |
"\t } else if (edge.l === rSite) {\n", | |
"\t edge.b = vertex;\n", | |
"\t } else {\n", | |
"\t edge.a = vertex;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiHalfEdge(edge, lSite, rSite) {\n", | |
"\t var va = edge.a, vb = edge.b;\n", | |
"\t this.edge = edge;\n", | |
"\t this.site = lSite;\n", | |
"\t this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y);\n", | |
"\t }\n", | |
"\t d3_geom_voronoiHalfEdge.prototype = {\n", | |
"\t start: function() {\n", | |
"\t return this.edge.l === this.site ? this.edge.a : this.edge.b;\n", | |
"\t },\n", | |
"\t end: function() {\n", | |
"\t return this.edge.l === this.site ? this.edge.b : this.edge.a;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geom_voronoiRedBlackTree() {\n", | |
"\t this._ = null;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiRedBlackNode(node) {\n", | |
"\t node.U = node.C = node.L = node.R = node.P = node.N = null;\n", | |
"\t }\n", | |
"\t d3_geom_voronoiRedBlackTree.prototype = {\n", | |
"\t insert: function(after, node) {\n", | |
"\t var parent, grandpa, uncle;\n", | |
"\t if (after) {\n", | |
"\t node.P = after;\n", | |
"\t node.N = after.N;\n", | |
"\t if (after.N) after.N.P = node;\n", | |
"\t after.N = node;\n", | |
"\t if (after.R) {\n", | |
"\t after = after.R;\n", | |
"\t while (after.L) after = after.L;\n", | |
"\t after.L = node;\n", | |
"\t } else {\n", | |
"\t after.R = node;\n", | |
"\t }\n", | |
"\t parent = after;\n", | |
"\t } else if (this._) {\n", | |
"\t after = d3_geom_voronoiRedBlackFirst(this._);\n", | |
"\t node.P = null;\n", | |
"\t node.N = after;\n", | |
"\t after.P = after.L = node;\n", | |
"\t parent = after;\n", | |
"\t } else {\n", | |
"\t node.P = node.N = null;\n", | |
"\t this._ = node;\n", | |
"\t parent = null;\n", | |
"\t }\n", | |
"\t node.L = node.R = null;\n", | |
"\t node.U = parent;\n", | |
"\t node.C = true;\n", | |
"\t after = node;\n", | |
"\t while (parent && parent.C) {\n", | |
"\t grandpa = parent.U;\n", | |
"\t if (parent === grandpa.L) {\n", | |
"\t uncle = grandpa.R;\n", | |
"\t if (uncle && uncle.C) {\n", | |
"\t parent.C = uncle.C = false;\n", | |
"\t grandpa.C = true;\n", | |
"\t after = grandpa;\n", | |
"\t } else {\n", | |
"\t if (after === parent.R) {\n", | |
"\t d3_geom_voronoiRedBlackRotateLeft(this, parent);\n", | |
"\t after = parent;\n", | |
"\t parent = after.U;\n", | |
"\t }\n", | |
"\t parent.C = false;\n", | |
"\t grandpa.C = true;\n", | |
"\t d3_geom_voronoiRedBlackRotateRight(this, grandpa);\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t uncle = grandpa.L;\n", | |
"\t if (uncle && uncle.C) {\n", | |
"\t parent.C = uncle.C = false;\n", | |
"\t grandpa.C = true;\n", | |
"\t after = grandpa;\n", | |
"\t } else {\n", | |
"\t if (after === parent.L) {\n", | |
"\t d3_geom_voronoiRedBlackRotateRight(this, parent);\n", | |
"\t after = parent;\n", | |
"\t parent = after.U;\n", | |
"\t }\n", | |
"\t parent.C = false;\n", | |
"\t grandpa.C = true;\n", | |
"\t d3_geom_voronoiRedBlackRotateLeft(this, grandpa);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t parent = after.U;\n", | |
"\t }\n", | |
"\t this._.C = false;\n", | |
"\t },\n", | |
"\t remove: function(node) {\n", | |
"\t if (node.N) node.N.P = node.P;\n", | |
"\t if (node.P) node.P.N = node.N;\n", | |
"\t node.N = node.P = null;\n", | |
"\t var parent = node.U, sibling, left = node.L, right = node.R, next, red;\n", | |
"\t if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right);\n", | |
"\t if (parent) {\n", | |
"\t if (parent.L === node) parent.L = next; else parent.R = next;\n", | |
"\t } else {\n", | |
"\t this._ = next;\n", | |
"\t }\n", | |
"\t if (left && right) {\n", | |
"\t red = next.C;\n", | |
"\t next.C = node.C;\n", | |
"\t next.L = left;\n", | |
"\t left.U = next;\n", | |
"\t if (next !== right) {\n", | |
"\t parent = next.U;\n", | |
"\t next.U = node.U;\n", | |
"\t node = next.R;\n", | |
"\t parent.L = node;\n", | |
"\t next.R = right;\n", | |
"\t right.U = next;\n", | |
"\t } else {\n", | |
"\t next.U = parent;\n", | |
"\t parent = next;\n", | |
"\t node = next.R;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t red = node.C;\n", | |
"\t node = next;\n", | |
"\t }\n", | |
"\t if (node) node.U = parent;\n", | |
"\t if (red) return;\n", | |
"\t if (node && node.C) {\n", | |
"\t node.C = false;\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t do {\n", | |
"\t if (node === this._) break;\n", | |
"\t if (node === parent.L) {\n", | |
"\t sibling = parent.R;\n", | |
"\t if (sibling.C) {\n", | |
"\t sibling.C = false;\n", | |
"\t parent.C = true;\n", | |
"\t d3_geom_voronoiRedBlackRotateLeft(this, parent);\n", | |
"\t sibling = parent.R;\n", | |
"\t }\n", | |
"\t if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {\n", | |
"\t if (!sibling.R || !sibling.R.C) {\n", | |
"\t sibling.L.C = false;\n", | |
"\t sibling.C = true;\n", | |
"\t d3_geom_voronoiRedBlackRotateRight(this, sibling);\n", | |
"\t sibling = parent.R;\n", | |
"\t }\n", | |
"\t sibling.C = parent.C;\n", | |
"\t parent.C = sibling.R.C = false;\n", | |
"\t d3_geom_voronoiRedBlackRotateLeft(this, parent);\n", | |
"\t node = this._;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t sibling = parent.L;\n", | |
"\t if (sibling.C) {\n", | |
"\t sibling.C = false;\n", | |
"\t parent.C = true;\n", | |
"\t d3_geom_voronoiRedBlackRotateRight(this, parent);\n", | |
"\t sibling = parent.L;\n", | |
"\t }\n", | |
"\t if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {\n", | |
"\t if (!sibling.L || !sibling.L.C) {\n", | |
"\t sibling.R.C = false;\n", | |
"\t sibling.C = true;\n", | |
"\t d3_geom_voronoiRedBlackRotateLeft(this, sibling);\n", | |
"\t sibling = parent.L;\n", | |
"\t }\n", | |
"\t sibling.C = parent.C;\n", | |
"\t parent.C = sibling.L.C = false;\n", | |
"\t d3_geom_voronoiRedBlackRotateRight(this, parent);\n", | |
"\t node = this._;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t sibling.C = true;\n", | |
"\t node = parent;\n", | |
"\t parent = parent.U;\n", | |
"\t } while (!node.C);\n", | |
"\t if (node) node.C = false;\n", | |
"\t }\n", | |
"\t };\n", | |
"\t function d3_geom_voronoiRedBlackRotateLeft(tree, node) {\n", | |
"\t var p = node, q = node.R, parent = p.U;\n", | |
"\t if (parent) {\n", | |
"\t if (parent.L === p) parent.L = q; else parent.R = q;\n", | |
"\t } else {\n", | |
"\t tree._ = q;\n", | |
"\t }\n", | |
"\t q.U = parent;\n", | |
"\t p.U = q;\n", | |
"\t p.R = q.L;\n", | |
"\t if (p.R) p.R.U = p;\n", | |
"\t q.L = p;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiRedBlackRotateRight(tree, node) {\n", | |
"\t var p = node, q = node.L, parent = p.U;\n", | |
"\t if (parent) {\n", | |
"\t if (parent.L === p) parent.L = q; else parent.R = q;\n", | |
"\t } else {\n", | |
"\t tree._ = q;\n", | |
"\t }\n", | |
"\t q.U = parent;\n", | |
"\t p.U = q;\n", | |
"\t p.L = q.R;\n", | |
"\t if (p.L) p.L.U = p;\n", | |
"\t q.R = p;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiRedBlackFirst(node) {\n", | |
"\t while (node.L) node = node.L;\n", | |
"\t return node;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoi(sites, bbox) {\n", | |
"\t var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle;\n", | |
"\t d3_geom_voronoiEdges = [];\n", | |
"\t d3_geom_voronoiCells = new Array(sites.length);\n", | |
"\t d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree();\n", | |
"\t d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree();\n", | |
"\t while (true) {\n", | |
"\t circle = d3_geom_voronoiFirstCircle;\n", | |
"\t if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) {\n", | |
"\t if (site.x !== x0 || site.y !== y0) {\n", | |
"\t d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site);\n", | |
"\t d3_geom_voronoiAddBeach(site);\n", | |
"\t x0 = site.x, y0 = site.y;\n", | |
"\t }\n", | |
"\t site = sites.pop();\n", | |
"\t } else if (circle) {\n", | |
"\t d3_geom_voronoiRemoveBeach(circle.arc);\n", | |
"\t } else {\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox);\n", | |
"\t var diagram = {\n", | |
"\t cells: d3_geom_voronoiCells,\n", | |
"\t edges: d3_geom_voronoiEdges\n", | |
"\t };\n", | |
"\t d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null;\n", | |
"\t return diagram;\n", | |
"\t }\n", | |
"\t function d3_geom_voronoiVertexOrder(a, b) {\n", | |
"\t return b.y - a.y || b.x - a.x;\n", | |
"\t }\n", | |
"\t d3.geom.voronoi = function(points) {\n", | |
"\t var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent;\n", | |
"\t if (points) return voronoi(points);\n", | |
"\t function voronoi(data) {\n", | |
"\t var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1];\n", | |
"\t d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) {\n", | |
"\t var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) {\n", | |
"\t var s = e.start();\n", | |
"\t return [ s.x, s.y ];\n", | |
"\t }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : [];\n", | |
"\t polygon.point = data[i];\n", | |
"\t });\n", | |
"\t return polygons;\n", | |
"\t }\n", | |
"\t function sites(data) {\n", | |
"\t return data.map(function(d, i) {\n", | |
"\t return {\n", | |
"\t x: Math.round(fx(d, i) / ε) * ε,\n", | |
"\t y: Math.round(fy(d, i) / ε) * ε,\n", | |
"\t i: i\n", | |
"\t };\n", | |
"\t });\n", | |
"\t }\n", | |
"\t voronoi.links = function(data) {\n", | |
"\t return d3_geom_voronoi(sites(data)).edges.filter(function(edge) {\n", | |
"\t return edge.l && edge.r;\n", | |
"\t }).map(function(edge) {\n", | |
"\t return {\n", | |
"\t source: data[edge.l.i],\n", | |
"\t target: data[edge.r.i]\n", | |
"\t };\n", | |
"\t });\n", | |
"\t };\n", | |
"\t voronoi.triangles = function(data) {\n", | |
"\t var triangles = [];\n", | |
"\t d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) {\n", | |
"\t var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l;\n", | |
"\t while (++j < m) {\n", | |
"\t e0 = e1;\n", | |
"\t s0 = s1;\n", | |
"\t e1 = edges[j].edge;\n", | |
"\t s1 = e1.l === site ? e1.r : e1.l;\n", | |
"\t if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) {\n", | |
"\t triangles.push([ data[i], data[s0.i], data[s1.i] ]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t });\n", | |
"\t return triangles;\n", | |
"\t };\n", | |
"\t voronoi.x = function(_) {\n", | |
"\t return arguments.length ? (fx = d3_functor(x = _), voronoi) : x;\n", | |
"\t };\n", | |
"\t voronoi.y = function(_) {\n", | |
"\t return arguments.length ? (fy = d3_functor(y = _), voronoi) : y;\n", | |
"\t };\n", | |
"\t voronoi.clipExtent = function(_) {\n", | |
"\t if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent;\n", | |
"\t clipExtent = _ == null ? d3_geom_voronoiClipExtent : _;\n", | |
"\t return voronoi;\n", | |
"\t };\n", | |
"\t voronoi.size = function(_) {\n", | |
"\t if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1];\n", | |
"\t return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]);\n", | |
"\t };\n", | |
"\t return voronoi;\n", | |
"\t };\n", | |
"\t var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ];\n", | |
"\t function d3_geom_voronoiTriangleArea(a, b, c) {\n", | |
"\t return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y);\n", | |
"\t }\n", | |
"\t d3.geom.delaunay = function(vertices) {\n", | |
"\t return d3.geom.voronoi().triangles(vertices);\n", | |
"\t };\n", | |
"\t d3.geom.quadtree = function(points, x1, y1, x2, y2) {\n", | |
"\t var x = d3_geom_pointX, y = d3_geom_pointY, compat;\n", | |
"\t if (compat = arguments.length) {\n", | |
"\t x = d3_geom_quadtreeCompatX;\n", | |
"\t y = d3_geom_quadtreeCompatY;\n", | |
"\t if (compat === 3) {\n", | |
"\t y2 = y1;\n", | |
"\t x2 = x1;\n", | |
"\t y1 = x1 = 0;\n", | |
"\t }\n", | |
"\t return quadtree(points);\n", | |
"\t }\n", | |
"\t function quadtree(data) {\n", | |
"\t var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_;\n", | |
"\t if (x1 != null) {\n", | |
"\t x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2;\n", | |
"\t } else {\n", | |
"\t x2_ = y2_ = -(x1_ = y1_ = Infinity);\n", | |
"\t xs = [], ys = [];\n", | |
"\t n = data.length;\n", | |
"\t if (compat) for (i = 0; i < n; ++i) {\n", | |
"\t d = data[i];\n", | |
"\t if (d.x < x1_) x1_ = d.x;\n", | |
"\t if (d.y < y1_) y1_ = d.y;\n", | |
"\t if (d.x > x2_) x2_ = d.x;\n", | |
"\t if (d.y > y2_) y2_ = d.y;\n", | |
"\t xs.push(d.x);\n", | |
"\t ys.push(d.y);\n", | |
"\t } else for (i = 0; i < n; ++i) {\n", | |
"\t var x_ = +fx(d = data[i], i), y_ = +fy(d, i);\n", | |
"\t if (x_ < x1_) x1_ = x_;\n", | |
"\t if (y_ < y1_) y1_ = y_;\n", | |
"\t if (x_ > x2_) x2_ = x_;\n", | |
"\t if (y_ > y2_) y2_ = y_;\n", | |
"\t xs.push(x_);\n", | |
"\t ys.push(y_);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var dx = x2_ - x1_, dy = y2_ - y1_;\n", | |
"\t if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy;\n", | |
"\t function insert(n, d, x, y, x1, y1, x2, y2) {\n", | |
"\t if (isNaN(x) || isNaN(y)) return;\n", | |
"\t if (n.leaf) {\n", | |
"\t var nx = n.x, ny = n.y;\n", | |
"\t if (nx != null) {\n", | |
"\t if (abs(nx - x) + abs(ny - y) < .01) {\n", | |
"\t insertChild(n, d, x, y, x1, y1, x2, y2);\n", | |
"\t } else {\n", | |
"\t var nPoint = n.point;\n", | |
"\t n.x = n.y = n.point = null;\n", | |
"\t insertChild(n, nPoint, nx, ny, x1, y1, x2, y2);\n", | |
"\t insertChild(n, d, x, y, x1, y1, x2, y2);\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t n.x = x, n.y = y, n.point = d;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t insertChild(n, d, x, y, x1, y1, x2, y2);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function insertChild(n, d, x, y, x1, y1, x2, y2) {\n", | |
"\t var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right;\n", | |
"\t n.leaf = false;\n", | |
"\t n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());\n", | |
"\t if (right) x1 = xm; else x2 = xm;\n", | |
"\t if (below) y1 = ym; else y2 = ym;\n", | |
"\t insert(n, d, x, y, x1, y1, x2, y2);\n", | |
"\t }\n", | |
"\t var root = d3_geom_quadtreeNode();\n", | |
"\t root.add = function(d) {\n", | |
"\t insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_);\n", | |
"\t };\n", | |
"\t root.visit = function(f) {\n", | |
"\t d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);\n", | |
"\t };\n", | |
"\t root.find = function(point) {\n", | |
"\t return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);\n", | |
"\t };\n", | |
"\t i = -1;\n", | |
"\t if (x1 == null) {\n", | |
"\t while (++i < n) {\n", | |
"\t insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_);\n", | |
"\t }\n", | |
"\t --i;\n", | |
"\t } else data.forEach(root.add);\n", | |
"\t xs = ys = data = d = null;\n", | |
"\t return root;\n", | |
"\t }\n", | |
"\t quadtree.x = function(_) {\n", | |
"\t return arguments.length ? (x = _, quadtree) : x;\n", | |
"\t };\n", | |
"\t quadtree.y = function(_) {\n", | |
"\t return arguments.length ? (y = _, quadtree) : y;\n", | |
"\t };\n", | |
"\t quadtree.extent = function(_) {\n", | |
"\t if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];\n", | |
"\t if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], \n", | |
"\t y2 = +_[1][1];\n", | |
"\t return quadtree;\n", | |
"\t };\n", | |
"\t quadtree.size = function(_) {\n", | |
"\t if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ];\n", | |
"\t if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1];\n", | |
"\t return quadtree;\n", | |
"\t };\n", | |
"\t return quadtree;\n", | |
"\t };\n", | |
"\t function d3_geom_quadtreeCompatX(d) {\n", | |
"\t return d.x;\n", | |
"\t }\n", | |
"\t function d3_geom_quadtreeCompatY(d) {\n", | |
"\t return d.y;\n", | |
"\t }\n", | |
"\t function d3_geom_quadtreeNode() {\n", | |
"\t return {\n", | |
"\t leaf: true,\n", | |
"\t nodes: [],\n", | |
"\t point: null,\n", | |
"\t x: null,\n", | |
"\t y: null\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {\n", | |
"\t if (!f(node, x1, y1, x2, y2)) {\n", | |
"\t var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes;\n", | |
"\t if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);\n", | |
"\t if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);\n", | |
"\t if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);\n", | |
"\t if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) {\n", | |
"\t var minDistance2 = Infinity, closestPoint;\n", | |
"\t (function find(node, x1, y1, x2, y2) {\n", | |
"\t if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return;\n", | |
"\t if (point = node.point) {\n", | |
"\t var point, dx = x - node.x, dy = y - node.y, distance2 = dx * dx + dy * dy;\n", | |
"\t if (distance2 < minDistance2) {\n", | |
"\t var distance = Math.sqrt(minDistance2 = distance2);\n", | |
"\t x0 = x - distance, y0 = y - distance;\n", | |
"\t x3 = x + distance, y3 = y + distance;\n", | |
"\t closestPoint = point;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym;\n", | |
"\t for (var i = below << 1 | right, j = i + 4; i < j; ++i) {\n", | |
"\t if (node = children[i & 3]) switch (i & 3) {\n", | |
"\t case 0:\n", | |
"\t find(node, x1, y1, xm, ym);\n", | |
"\t break;\n", | |
"\t\n", | |
"\t case 1:\n", | |
"\t find(node, xm, y1, x2, ym);\n", | |
"\t break;\n", | |
"\t\n", | |
"\t case 2:\n", | |
"\t find(node, x1, ym, xm, y2);\n", | |
"\t break;\n", | |
"\t\n", | |
"\t case 3:\n", | |
"\t find(node, xm, ym, x2, y2);\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t })(root, x0, y0, x3, y3);\n", | |
"\t return closestPoint;\n", | |
"\t }\n", | |
"\t d3.interpolateRgb = d3_interpolateRgb;\n", | |
"\t function d3_interpolateRgb(a, b) {\n", | |
"\t a = d3.rgb(a);\n", | |
"\t b = d3.rgb(b);\n", | |
"\t var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab;\n", | |
"\t return function(t) {\n", | |
"\t return \"#\" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.interpolateObject = d3_interpolateObject;\n", | |
"\t function d3_interpolateObject(a, b) {\n", | |
"\t var i = {}, c = {}, k;\n", | |
"\t for (k in a) {\n", | |
"\t if (k in b) {\n", | |
"\t i[k] = d3_interpolate(a[k], b[k]);\n", | |
"\t } else {\n", | |
"\t c[k] = a[k];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t for (k in b) {\n", | |
"\t if (!(k in a)) {\n", | |
"\t c[k] = b[k];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return function(t) {\n", | |
"\t for (k in i) c[k] = i[k](t);\n", | |
"\t return c;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.interpolateNumber = d3_interpolateNumber;\n", | |
"\t function d3_interpolateNumber(a, b) {\n", | |
"\t a = +a, b = +b;\n", | |
"\t return function(t) {\n", | |
"\t return a * (1 - t) + b * t;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.interpolateString = d3_interpolateString;\n", | |
"\t function d3_interpolateString(a, b) {\n", | |
"\t var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];\n", | |
"\t a = a + \"\", b = b + \"\";\n", | |
"\t while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) {\n", | |
"\t if ((bs = bm.index) > bi) {\n", | |
"\t bs = b.slice(bi, bs);\n", | |
"\t if (s[i]) s[i] += bs; else s[++i] = bs;\n", | |
"\t }\n", | |
"\t if ((am = am[0]) === (bm = bm[0])) {\n", | |
"\t if (s[i]) s[i] += bm; else s[++i] = bm;\n", | |
"\t } else {\n", | |
"\t s[++i] = null;\n", | |
"\t q.push({\n", | |
"\t i: i,\n", | |
"\t x: d3_interpolateNumber(am, bm)\n", | |
"\t });\n", | |
"\t }\n", | |
"\t bi = d3_interpolate_numberB.lastIndex;\n", | |
"\t }\n", | |
"\t if (bi < b.length) {\n", | |
"\t bs = b.slice(bi);\n", | |
"\t if (s[i]) s[i] += bs; else s[++i] = bs;\n", | |
"\t }\n", | |
"\t return s.length < 2 ? q[0] ? (b = q[0].x, function(t) {\n", | |
"\t return b(t) + \"\";\n", | |
"\t }) : function() {\n", | |
"\t return b;\n", | |
"\t } : (b = q.length, function(t) {\n", | |
"\t for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);\n", | |
"\t return s.join(\"\");\n", | |
"\t });\n", | |
"\t }\n", | |
"\t var d3_interpolate_numberA = /[-+]?(?:\\d+\\.?\\d*|\\.?\\d+)(?:[eE][-+]?\\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, \"g\");\n", | |
"\t d3.interpolate = d3_interpolate;\n", | |
"\t function d3_interpolate(a, b) {\n", | |
"\t var i = d3.interpolators.length, f;\n", | |
"\t while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ;\n", | |
"\t return f;\n", | |
"\t }\n", | |
"\t d3.interpolators = [ function(a, b) {\n", | |
"\t var t = typeof b;\n", | |
"\t return (t === \"string\" ? d3_rgb_names.has(b.toLowerCase()) || /^(#|rgb\\(|hsl\\()/i.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === \"object\" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b);\n", | |
"\t } ];\n", | |
"\t d3.interpolateArray = d3_interpolateArray;\n", | |
"\t function d3_interpolateArray(a, b) {\n", | |
"\t var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i;\n", | |
"\t for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i]));\n", | |
"\t for (;i < na; ++i) c[i] = a[i];\n", | |
"\t for (;i < nb; ++i) c[i] = b[i];\n", | |
"\t return function(t) {\n", | |
"\t for (i = 0; i < n0; ++i) c[i] = x[i](t);\n", | |
"\t return c;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t var d3_ease_default = function() {\n", | |
"\t return d3_identity;\n", | |
"\t };\n", | |
"\t var d3_ease = d3.map({\n", | |
"\t linear: d3_ease_default,\n", | |
"\t poly: d3_ease_poly,\n", | |
"\t quad: function() {\n", | |
"\t return d3_ease_quad;\n", | |
"\t },\n", | |
"\t cubic: function() {\n", | |
"\t return d3_ease_cubic;\n", | |
"\t },\n", | |
"\t sin: function() {\n", | |
"\t return d3_ease_sin;\n", | |
"\t },\n", | |
"\t exp: function() {\n", | |
"\t return d3_ease_exp;\n", | |
"\t },\n", | |
"\t circle: function() {\n", | |
"\t return d3_ease_circle;\n", | |
"\t },\n", | |
"\t elastic: d3_ease_elastic,\n", | |
"\t back: d3_ease_back,\n", | |
"\t bounce: function() {\n", | |
"\t return d3_ease_bounce;\n", | |
"\t }\n", | |
"\t });\n", | |
"\t var d3_ease_mode = d3.map({\n", | |
"\t \"in\": d3_identity,\n", | |
"\t out: d3_ease_reverse,\n", | |
"\t \"in-out\": d3_ease_reflect,\n", | |
"\t \"out-in\": function(f) {\n", | |
"\t return d3_ease_reflect(d3_ease_reverse(f));\n", | |
"\t }\n", | |
"\t });\n", | |
"\t d3.ease = function(name) {\n", | |
"\t var i = name.indexOf(\"-\"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : \"in\";\n", | |
"\t t = d3_ease.get(t) || d3_ease_default;\n", | |
"\t m = d3_ease_mode.get(m) || d3_identity;\n", | |
"\t return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1))));\n", | |
"\t };\n", | |
"\t function d3_ease_clamp(f) {\n", | |
"\t return function(t) {\n", | |
"\t return t <= 0 ? 0 : t >= 1 ? 1 : f(t);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_ease_reverse(f) {\n", | |
"\t return function(t) {\n", | |
"\t return 1 - f(1 - t);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_ease_reflect(f) {\n", | |
"\t return function(t) {\n", | |
"\t return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_ease_quad(t) {\n", | |
"\t return t * t;\n", | |
"\t }\n", | |
"\t function d3_ease_cubic(t) {\n", | |
"\t return t * t * t;\n", | |
"\t }\n", | |
"\t function d3_ease_cubicInOut(t) {\n", | |
"\t if (t <= 0) return 0;\n", | |
"\t if (t >= 1) return 1;\n", | |
"\t var t2 = t * t, t3 = t2 * t;\n", | |
"\t return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75);\n", | |
"\t }\n", | |
"\t function d3_ease_poly(e) {\n", | |
"\t return function(t) {\n", | |
"\t return Math.pow(t, e);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_ease_sin(t) {\n", | |
"\t return 1 - Math.cos(t * halfπ);\n", | |
"\t }\n", | |
"\t function d3_ease_exp(t) {\n", | |
"\t return Math.pow(2, 10 * (t - 1));\n", | |
"\t }\n", | |
"\t function d3_ease_circle(t) {\n", | |
"\t return 1 - Math.sqrt(1 - t * t);\n", | |
"\t }\n", | |
"\t function d3_ease_elastic(a, p) {\n", | |
"\t var s;\n", | |
"\t if (arguments.length < 2) p = .45;\n", | |
"\t if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4;\n", | |
"\t return function(t) {\n", | |
"\t return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_ease_back(s) {\n", | |
"\t if (!s) s = 1.70158;\n", | |
"\t return function(t) {\n", | |
"\t return t * t * ((s + 1) * t - s);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_ease_bounce(t) {\n", | |
"\t return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;\n", | |
"\t }\n", | |
"\t d3.interpolateHcl = d3_interpolateHcl;\n", | |
"\t function d3_interpolateHcl(a, b) {\n", | |
"\t a = d3.hcl(a);\n", | |
"\t b = d3.hcl(b);\n", | |
"\t var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al;\n", | |
"\t if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac;\n", | |
"\t if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;\n", | |
"\t return function(t) {\n", | |
"\t return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + \"\";\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.interpolateHsl = d3_interpolateHsl;\n", | |
"\t function d3_interpolateHsl(a, b) {\n", | |
"\t a = d3.hsl(a);\n", | |
"\t b = d3.hsl(b);\n", | |
"\t var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al;\n", | |
"\t if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as;\n", | |
"\t if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;\n", | |
"\t return function(t) {\n", | |
"\t return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + \"\";\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.interpolateLab = d3_interpolateLab;\n", | |
"\t function d3_interpolateLab(a, b) {\n", | |
"\t a = d3.lab(a);\n", | |
"\t b = d3.lab(b);\n", | |
"\t var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab;\n", | |
"\t return function(t) {\n", | |
"\t return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + \"\";\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.interpolateRound = d3_interpolateRound;\n", | |
"\t function d3_interpolateRound(a, b) {\n", | |
"\t b -= a;\n", | |
"\t return function(t) {\n", | |
"\t return Math.round(a + b * t);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.transform = function(string) {\n", | |
"\t var g = d3_document.createElementNS(d3.ns.prefix.svg, \"g\");\n", | |
"\t return (d3.transform = function(string) {\n", | |
"\t if (string != null) {\n", | |
"\t g.setAttribute(\"transform\", string);\n", | |
"\t var t = g.transform.baseVal.consolidate();\n", | |
"\t }\n", | |
"\t return new d3_transform(t ? t.matrix : d3_transformIdentity);\n", | |
"\t })(string);\n", | |
"\t };\n", | |
"\t function d3_transform(m) {\n", | |
"\t var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0;\n", | |
"\t if (r0[0] * r1[1] < r1[0] * r0[1]) {\n", | |
"\t r0[0] *= -1;\n", | |
"\t r0[1] *= -1;\n", | |
"\t kx *= -1;\n", | |
"\t kz *= -1;\n", | |
"\t }\n", | |
"\t this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees;\n", | |
"\t this.translate = [ m.e, m.f ];\n", | |
"\t this.scale = [ kx, ky ];\n", | |
"\t this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0;\n", | |
"\t }\n", | |
"\t d3_transform.prototype.toString = function() {\n", | |
"\t return \"translate(\" + this.translate + \")rotate(\" + this.rotate + \")skewX(\" + this.skew + \")scale(\" + this.scale + \")\";\n", | |
"\t };\n", | |
"\t function d3_transformDot(a, b) {\n", | |
"\t return a[0] * b[0] + a[1] * b[1];\n", | |
"\t }\n", | |
"\t function d3_transformNormalize(a) {\n", | |
"\t var k = Math.sqrt(d3_transformDot(a, a));\n", | |
"\t if (k) {\n", | |
"\t a[0] /= k;\n", | |
"\t a[1] /= k;\n", | |
"\t }\n", | |
"\t return k;\n", | |
"\t }\n", | |
"\t function d3_transformCombine(a, b, k) {\n", | |
"\t a[0] += k * b[0];\n", | |
"\t a[1] += k * b[1];\n", | |
"\t return a;\n", | |
"\t }\n", | |
"\t var d3_transformIdentity = {\n", | |
"\t a: 1,\n", | |
"\t b: 0,\n", | |
"\t c: 0,\n", | |
"\t d: 1,\n", | |
"\t e: 0,\n", | |
"\t f: 0\n", | |
"\t };\n", | |
"\t d3.interpolateTransform = d3_interpolateTransform;\n", | |
"\t function d3_interpolateTransformPop(s) {\n", | |
"\t return s.length ? s.pop() + \",\" : \"\";\n", | |
"\t }\n", | |
"\t function d3_interpolateTranslate(ta, tb, s, q) {\n", | |
"\t if (ta[0] !== tb[0] || ta[1] !== tb[1]) {\n", | |
"\t var i = s.push(\"translate(\", null, \",\", null, \")\");\n", | |
"\t q.push({\n", | |
"\t i: i - 4,\n", | |
"\t x: d3_interpolateNumber(ta[0], tb[0])\n", | |
"\t }, {\n", | |
"\t i: i - 2,\n", | |
"\t x: d3_interpolateNumber(ta[1], tb[1])\n", | |
"\t });\n", | |
"\t } else if (tb[0] || tb[1]) {\n", | |
"\t s.push(\"translate(\" + tb + \")\");\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_interpolateRotate(ra, rb, s, q) {\n", | |
"\t if (ra !== rb) {\n", | |
"\t if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360;\n", | |
"\t q.push({\n", | |
"\t i: s.push(d3_interpolateTransformPop(s) + \"rotate(\", null, \")\") - 2,\n", | |
"\t x: d3_interpolateNumber(ra, rb)\n", | |
"\t });\n", | |
"\t } else if (rb) {\n", | |
"\t s.push(d3_interpolateTransformPop(s) + \"rotate(\" + rb + \")\");\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_interpolateSkew(wa, wb, s, q) {\n", | |
"\t if (wa !== wb) {\n", | |
"\t q.push({\n", | |
"\t i: s.push(d3_interpolateTransformPop(s) + \"skewX(\", null, \")\") - 2,\n", | |
"\t x: d3_interpolateNumber(wa, wb)\n", | |
"\t });\n", | |
"\t } else if (wb) {\n", | |
"\t s.push(d3_interpolateTransformPop(s) + \"skewX(\" + wb + \")\");\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_interpolateScale(ka, kb, s, q) {\n", | |
"\t if (ka[0] !== kb[0] || ka[1] !== kb[1]) {\n", | |
"\t var i = s.push(d3_interpolateTransformPop(s) + \"scale(\", null, \",\", null, \")\");\n", | |
"\t q.push({\n", | |
"\t i: i - 4,\n", | |
"\t x: d3_interpolateNumber(ka[0], kb[0])\n", | |
"\t }, {\n", | |
"\t i: i - 2,\n", | |
"\t x: d3_interpolateNumber(ka[1], kb[1])\n", | |
"\t });\n", | |
"\t } else if (kb[0] !== 1 || kb[1] !== 1) {\n", | |
"\t s.push(d3_interpolateTransformPop(s) + \"scale(\" + kb + \")\");\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_interpolateTransform(a, b) {\n", | |
"\t var s = [], q = [];\n", | |
"\t a = d3.transform(a), b = d3.transform(b);\n", | |
"\t d3_interpolateTranslate(a.translate, b.translate, s, q);\n", | |
"\t d3_interpolateRotate(a.rotate, b.rotate, s, q);\n", | |
"\t d3_interpolateSkew(a.skew, b.skew, s, q);\n", | |
"\t d3_interpolateScale(a.scale, b.scale, s, q);\n", | |
"\t a = b = null;\n", | |
"\t return function(t) {\n", | |
"\t var i = -1, n = q.length, o;\n", | |
"\t while (++i < n) s[(o = q[i]).i] = o.x(t);\n", | |
"\t return s.join(\"\");\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_uninterpolateNumber(a, b) {\n", | |
"\t b = (b -= a = +a) || 1 / b;\n", | |
"\t return function(x) {\n", | |
"\t return (x - a) / b;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_uninterpolateClamp(a, b) {\n", | |
"\t b = (b -= a = +a) || 1 / b;\n", | |
"\t return function(x) {\n", | |
"\t return Math.max(0, Math.min(1, (x - a) / b));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.layout = {};\n", | |
"\t d3.layout.bundle = function() {\n", | |
"\t return function(links) {\n", | |
"\t var paths = [], i = -1, n = links.length;\n", | |
"\t while (++i < n) paths.push(d3_layout_bundlePath(links[i]));\n", | |
"\t return paths;\n", | |
"\t };\n", | |
"\t };\n", | |
"\t function d3_layout_bundlePath(link) {\n", | |
"\t var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ];\n", | |
"\t while (start !== lca) {\n", | |
"\t start = start.parent;\n", | |
"\t points.push(start);\n", | |
"\t }\n", | |
"\t var k = points.length;\n", | |
"\t while (end !== lca) {\n", | |
"\t points.splice(k, 0, end);\n", | |
"\t end = end.parent;\n", | |
"\t }\n", | |
"\t return points;\n", | |
"\t }\n", | |
"\t function d3_layout_bundleAncestors(node) {\n", | |
"\t var ancestors = [], parent = node.parent;\n", | |
"\t while (parent != null) {\n", | |
"\t ancestors.push(node);\n", | |
"\t node = parent;\n", | |
"\t parent = parent.parent;\n", | |
"\t }\n", | |
"\t ancestors.push(node);\n", | |
"\t return ancestors;\n", | |
"\t }\n", | |
"\t function d3_layout_bundleLeastCommonAncestor(a, b) {\n", | |
"\t if (a === b) return a;\n", | |
"\t var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null;\n", | |
"\t while (aNode === bNode) {\n", | |
"\t sharedNode = aNode;\n", | |
"\t aNode = aNodes.pop();\n", | |
"\t bNode = bNodes.pop();\n", | |
"\t }\n", | |
"\t return sharedNode;\n", | |
"\t }\n", | |
"\t d3.layout.chord = function() {\n", | |
"\t var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;\n", | |
"\t function relayout() {\n", | |
"\t var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j;\n", | |
"\t chords = [];\n", | |
"\t groups = [];\n", | |
"\t k = 0, i = -1;\n", | |
"\t while (++i < n) {\n", | |
"\t x = 0, j = -1;\n", | |
"\t while (++j < n) {\n", | |
"\t x += matrix[i][j];\n", | |
"\t }\n", | |
"\t groupSums.push(x);\n", | |
"\t subgroupIndex.push(d3.range(n));\n", | |
"\t k += x;\n", | |
"\t }\n", | |
"\t if (sortGroups) {\n", | |
"\t groupIndex.sort(function(a, b) {\n", | |
"\t return sortGroups(groupSums[a], groupSums[b]);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t if (sortSubgroups) {\n", | |
"\t subgroupIndex.forEach(function(d, i) {\n", | |
"\t d.sort(function(a, b) {\n", | |
"\t return sortSubgroups(matrix[i][a], matrix[i][b]);\n", | |
"\t });\n", | |
"\t });\n", | |
"\t }\n", | |
"\t k = (τ - padding * n) / k;\n", | |
"\t x = 0, i = -1;\n", | |
"\t while (++i < n) {\n", | |
"\t x0 = x, j = -1;\n", | |
"\t while (++j < n) {\n", | |
"\t var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;\n", | |
"\t subgroups[di + \"-\" + dj] = {\n", | |
"\t index: di,\n", | |
"\t subindex: dj,\n", | |
"\t startAngle: a0,\n", | |
"\t endAngle: a1,\n", | |
"\t value: v\n", | |
"\t };\n", | |
"\t }\n", | |
"\t groups[di] = {\n", | |
"\t index: di,\n", | |
"\t startAngle: x0,\n", | |
"\t endAngle: x,\n", | |
"\t value: groupSums[di]\n", | |
"\t };\n", | |
"\t x += padding;\n", | |
"\t }\n", | |
"\t i = -1;\n", | |
"\t while (++i < n) {\n", | |
"\t j = i - 1;\n", | |
"\t while (++j < n) {\n", | |
"\t var source = subgroups[i + \"-\" + j], target = subgroups[j + \"-\" + i];\n", | |
"\t if (source.value || target.value) {\n", | |
"\t chords.push(source.value < target.value ? {\n", | |
"\t source: target,\n", | |
"\t target: source\n", | |
"\t } : {\n", | |
"\t source: source,\n", | |
"\t target: target\n", | |
"\t });\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (sortChords) resort();\n", | |
"\t }\n", | |
"\t function resort() {\n", | |
"\t chords.sort(function(a, b) {\n", | |
"\t return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t chord.matrix = function(x) {\n", | |
"\t if (!arguments.length) return matrix;\n", | |
"\t n = (matrix = x) && matrix.length;\n", | |
"\t chords = groups = null;\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.padding = function(x) {\n", | |
"\t if (!arguments.length) return padding;\n", | |
"\t padding = x;\n", | |
"\t chords = groups = null;\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.sortGroups = function(x) {\n", | |
"\t if (!arguments.length) return sortGroups;\n", | |
"\t sortGroups = x;\n", | |
"\t chords = groups = null;\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.sortSubgroups = function(x) {\n", | |
"\t if (!arguments.length) return sortSubgroups;\n", | |
"\t sortSubgroups = x;\n", | |
"\t chords = null;\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.sortChords = function(x) {\n", | |
"\t if (!arguments.length) return sortChords;\n", | |
"\t sortChords = x;\n", | |
"\t if (chords) resort();\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.chords = function() {\n", | |
"\t if (!chords) relayout();\n", | |
"\t return chords;\n", | |
"\t };\n", | |
"\t chord.groups = function() {\n", | |
"\t if (!groups) relayout();\n", | |
"\t return groups;\n", | |
"\t };\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t d3.layout.force = function() {\n", | |
"\t var force = {}, event = d3.dispatch(\"start\", \"tick\", \"end\"), timer, size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges;\n", | |
"\t function repulse(node) {\n", | |
"\t return function(quad, x1, _, x2) {\n", | |
"\t if (quad.point !== node) {\n", | |
"\t var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy;\n", | |
"\t if (dw * dw / theta2 < dn) {\n", | |
"\t if (dn < chargeDistance2) {\n", | |
"\t var k = quad.charge / dn;\n", | |
"\t node.px -= dx * k;\n", | |
"\t node.py -= dy * k;\n", | |
"\t }\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t if (quad.point && dn && dn < chargeDistance2) {\n", | |
"\t var k = quad.pointCharge / dn;\n", | |
"\t node.px -= dx * k;\n", | |
"\t node.py -= dy * k;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return !quad.charge;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t force.tick = function() {\n", | |
"\t if ((alpha *= .99) < .005) {\n", | |
"\t timer = null;\n", | |
"\t event.end({\n", | |
"\t type: \"end\",\n", | |
"\t alpha: alpha = 0\n", | |
"\t });\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y;\n", | |
"\t for (i = 0; i < m; ++i) {\n", | |
"\t o = links[i];\n", | |
"\t s = o.source;\n", | |
"\t t = o.target;\n", | |
"\t x = t.x - s.x;\n", | |
"\t y = t.y - s.y;\n", | |
"\t if (l = x * x + y * y) {\n", | |
"\t l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;\n", | |
"\t x *= l;\n", | |
"\t y *= l;\n", | |
"\t t.x -= x * (k = s.weight + t.weight ? s.weight / (s.weight + t.weight) : .5);\n", | |
"\t t.y -= y * k;\n", | |
"\t s.x += x * (k = 1 - k);\n", | |
"\t s.y += y * k;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (k = alpha * gravity) {\n", | |
"\t x = size[0] / 2;\n", | |
"\t y = size[1] / 2;\n", | |
"\t i = -1;\n", | |
"\t if (k) while (++i < n) {\n", | |
"\t o = nodes[i];\n", | |
"\t o.x += (x - o.x) * k;\n", | |
"\t o.y += (y - o.y) * k;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (charge) {\n", | |
"\t d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);\n", | |
"\t i = -1;\n", | |
"\t while (++i < n) {\n", | |
"\t if (!(o = nodes[i]).fixed) {\n", | |
"\t q.visit(repulse(o));\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t i = -1;\n", | |
"\t while (++i < n) {\n", | |
"\t o = nodes[i];\n", | |
"\t if (o.fixed) {\n", | |
"\t o.x = o.px;\n", | |
"\t o.y = o.py;\n", | |
"\t } else {\n", | |
"\t o.x -= (o.px - (o.px = o.x)) * friction;\n", | |
"\t o.y -= (o.py - (o.py = o.y)) * friction;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t event.tick({\n", | |
"\t type: \"tick\",\n", | |
"\t alpha: alpha\n", | |
"\t });\n", | |
"\t };\n", | |
"\t force.nodes = function(x) {\n", | |
"\t if (!arguments.length) return nodes;\n", | |
"\t nodes = x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.links = function(x) {\n", | |
"\t if (!arguments.length) return links;\n", | |
"\t links = x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.size = function(x) {\n", | |
"\t if (!arguments.length) return size;\n", | |
"\t size = x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.linkDistance = function(x) {\n", | |
"\t if (!arguments.length) return linkDistance;\n", | |
"\t linkDistance = typeof x === \"function\" ? x : +x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.distance = force.linkDistance;\n", | |
"\t force.linkStrength = function(x) {\n", | |
"\t if (!arguments.length) return linkStrength;\n", | |
"\t linkStrength = typeof x === \"function\" ? x : +x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.friction = function(x) {\n", | |
"\t if (!arguments.length) return friction;\n", | |
"\t friction = +x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.charge = function(x) {\n", | |
"\t if (!arguments.length) return charge;\n", | |
"\t charge = typeof x === \"function\" ? x : +x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.chargeDistance = function(x) {\n", | |
"\t if (!arguments.length) return Math.sqrt(chargeDistance2);\n", | |
"\t chargeDistance2 = x * x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.gravity = function(x) {\n", | |
"\t if (!arguments.length) return gravity;\n", | |
"\t gravity = +x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.theta = function(x) {\n", | |
"\t if (!arguments.length) return Math.sqrt(theta2);\n", | |
"\t theta2 = x * x;\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.alpha = function(x) {\n", | |
"\t if (!arguments.length) return alpha;\n", | |
"\t x = +x;\n", | |
"\t if (alpha) {\n", | |
"\t if (x > 0) {\n", | |
"\t alpha = x;\n", | |
"\t } else {\n", | |
"\t timer.c = null, timer.t = NaN, timer = null;\n", | |
"\t event.end({\n", | |
"\t type: \"end\",\n", | |
"\t alpha: alpha = 0\n", | |
"\t });\n", | |
"\t }\n", | |
"\t } else if (x > 0) {\n", | |
"\t event.start({\n", | |
"\t type: \"start\",\n", | |
"\t alpha: alpha = x\n", | |
"\t });\n", | |
"\t timer = d3_timer(force.tick);\n", | |
"\t }\n", | |
"\t return force;\n", | |
"\t };\n", | |
"\t force.start = function() {\n", | |
"\t var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o;\n", | |
"\t for (i = 0; i < n; ++i) {\n", | |
"\t (o = nodes[i]).index = i;\n", | |
"\t o.weight = 0;\n", | |
"\t }\n", | |
"\t for (i = 0; i < m; ++i) {\n", | |
"\t o = links[i];\n", | |
"\t if (typeof o.source == \"number\") o.source = nodes[o.source];\n", | |
"\t if (typeof o.target == \"number\") o.target = nodes[o.target];\n", | |
"\t ++o.source.weight;\n", | |
"\t ++o.target.weight;\n", | |
"\t }\n", | |
"\t for (i = 0; i < n; ++i) {\n", | |
"\t o = nodes[i];\n", | |
"\t if (isNaN(o.x)) o.x = position(\"x\", w);\n", | |
"\t if (isNaN(o.y)) o.y = position(\"y\", h);\n", | |
"\t if (isNaN(o.px)) o.px = o.x;\n", | |
"\t if (isNaN(o.py)) o.py = o.y;\n", | |
"\t }\n", | |
"\t distances = [];\n", | |
"\t if (typeof linkDistance === \"function\") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance;\n", | |
"\t strengths = [];\n", | |
"\t if (typeof linkStrength === \"function\") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength;\n", | |
"\t charges = [];\n", | |
"\t if (typeof charge === \"function\") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge;\n", | |
"\t function position(dimension, size) {\n", | |
"\t if (!neighbors) {\n", | |
"\t neighbors = new Array(n);\n", | |
"\t for (j = 0; j < n; ++j) {\n", | |
"\t neighbors[j] = [];\n", | |
"\t }\n", | |
"\t for (j = 0; j < m; ++j) {\n", | |
"\t var o = links[j];\n", | |
"\t neighbors[o.source.index].push(o.target);\n", | |
"\t neighbors[o.target.index].push(o.source);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var candidates = neighbors[i], j = -1, l = candidates.length, x;\n", | |
"\t while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x;\n", | |
"\t return Math.random() * size;\n", | |
"\t }\n", | |
"\t return force.resume();\n", | |
"\t };\n", | |
"\t force.resume = function() {\n", | |
"\t return force.alpha(.1);\n", | |
"\t };\n", | |
"\t force.stop = function() {\n", | |
"\t return force.alpha(0);\n", | |
"\t };\n", | |
"\t force.drag = function() {\n", | |
"\t if (!drag) drag = d3.behavior.drag().origin(d3_identity).on(\"dragstart.force\", d3_layout_forceDragstart).on(\"drag.force\", dragmove).on(\"dragend.force\", d3_layout_forceDragend);\n", | |
"\t if (!arguments.length) return drag;\n", | |
"\t this.on(\"mouseover.force\", d3_layout_forceMouseover).on(\"mouseout.force\", d3_layout_forceMouseout).call(drag);\n", | |
"\t };\n", | |
"\t function dragmove(d) {\n", | |
"\t d.px = d3.event.x, d.py = d3.event.y;\n", | |
"\t force.resume();\n", | |
"\t }\n", | |
"\t return d3.rebind(force, event, \"on\");\n", | |
"\t };\n", | |
"\t function d3_layout_forceDragstart(d) {\n", | |
"\t d.fixed |= 2;\n", | |
"\t }\n", | |
"\t function d3_layout_forceDragend(d) {\n", | |
"\t d.fixed &= ~6;\n", | |
"\t }\n", | |
"\t function d3_layout_forceMouseover(d) {\n", | |
"\t d.fixed |= 4;\n", | |
"\t d.px = d.x, d.py = d.y;\n", | |
"\t }\n", | |
"\t function d3_layout_forceMouseout(d) {\n", | |
"\t d.fixed &= ~4;\n", | |
"\t }\n", | |
"\t function d3_layout_forceAccumulate(quad, alpha, charges) {\n", | |
"\t var cx = 0, cy = 0;\n", | |
"\t quad.charge = 0;\n", | |
"\t if (!quad.leaf) {\n", | |
"\t var nodes = quad.nodes, n = nodes.length, i = -1, c;\n", | |
"\t while (++i < n) {\n", | |
"\t c = nodes[i];\n", | |
"\t if (c == null) continue;\n", | |
"\t d3_layout_forceAccumulate(c, alpha, charges);\n", | |
"\t quad.charge += c.charge;\n", | |
"\t cx += c.charge * c.cx;\n", | |
"\t cy += c.charge * c.cy;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (quad.point) {\n", | |
"\t if (!quad.leaf) {\n", | |
"\t quad.point.x += Math.random() - .5;\n", | |
"\t quad.point.y += Math.random() - .5;\n", | |
"\t }\n", | |
"\t var k = alpha * charges[quad.point.index];\n", | |
"\t quad.charge += quad.pointCharge = k;\n", | |
"\t cx += k * quad.point.x;\n", | |
"\t cy += k * quad.point.y;\n", | |
"\t }\n", | |
"\t quad.cx = cx / quad.charge;\n", | |
"\t quad.cy = cy / quad.charge;\n", | |
"\t }\n", | |
"\t var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity;\n", | |
"\t d3.layout.hierarchy = function() {\n", | |
"\t var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;\n", | |
"\t function hierarchy(root) {\n", | |
"\t var stack = [ root ], nodes = [], node;\n", | |
"\t root.depth = 0;\n", | |
"\t while ((node = stack.pop()) != null) {\n", | |
"\t nodes.push(node);\n", | |
"\t if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) {\n", | |
"\t var n, childs, child;\n", | |
"\t while (--n >= 0) {\n", | |
"\t stack.push(child = childs[n]);\n", | |
"\t child.parent = node;\n", | |
"\t child.depth = node.depth + 1;\n", | |
"\t }\n", | |
"\t if (value) node.value = 0;\n", | |
"\t node.children = childs;\n", | |
"\t } else {\n", | |
"\t if (value) node.value = +value.call(hierarchy, node, node.depth) || 0;\n", | |
"\t delete node.children;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3_layout_hierarchyVisitAfter(root, function(node) {\n", | |
"\t var childs, parent;\n", | |
"\t if (sort && (childs = node.children)) childs.sort(sort);\n", | |
"\t if (value && (parent = node.parent)) parent.value += node.value;\n", | |
"\t });\n", | |
"\t return nodes;\n", | |
"\t }\n", | |
"\t hierarchy.sort = function(x) {\n", | |
"\t if (!arguments.length) return sort;\n", | |
"\t sort = x;\n", | |
"\t return hierarchy;\n", | |
"\t };\n", | |
"\t hierarchy.children = function(x) {\n", | |
"\t if (!arguments.length) return children;\n", | |
"\t children = x;\n", | |
"\t return hierarchy;\n", | |
"\t };\n", | |
"\t hierarchy.value = function(x) {\n", | |
"\t if (!arguments.length) return value;\n", | |
"\t value = x;\n", | |
"\t return hierarchy;\n", | |
"\t };\n", | |
"\t hierarchy.revalue = function(root) {\n", | |
"\t if (value) {\n", | |
"\t d3_layout_hierarchyVisitBefore(root, function(node) {\n", | |
"\t if (node.children) node.value = 0;\n", | |
"\t });\n", | |
"\t d3_layout_hierarchyVisitAfter(root, function(node) {\n", | |
"\t var parent;\n", | |
"\t if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;\n", | |
"\t if (parent = node.parent) parent.value += node.value;\n", | |
"\t });\n", | |
"\t }\n", | |
"\t return root;\n", | |
"\t };\n", | |
"\t return hierarchy;\n", | |
"\t };\n", | |
"\t function d3_layout_hierarchyRebind(object, hierarchy) {\n", | |
"\t d3.rebind(object, hierarchy, \"sort\", \"children\", \"value\");\n", | |
"\t object.nodes = object;\n", | |
"\t object.links = d3_layout_hierarchyLinks;\n", | |
"\t return object;\n", | |
"\t }\n", | |
"\t function d3_layout_hierarchyVisitBefore(node, callback) {\n", | |
"\t var nodes = [ node ];\n", | |
"\t while ((node = nodes.pop()) != null) {\n", | |
"\t callback(node);\n", | |
"\t if ((children = node.children) && (n = children.length)) {\n", | |
"\t var n, children;\n", | |
"\t while (--n >= 0) nodes.push(children[n]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_layout_hierarchyVisitAfter(node, callback) {\n", | |
"\t var nodes = [ node ], nodes2 = [];\n", | |
"\t while ((node = nodes.pop()) != null) {\n", | |
"\t nodes2.push(node);\n", | |
"\t if ((children = node.children) && (n = children.length)) {\n", | |
"\t var i = -1, n, children;\n", | |
"\t while (++i < n) nodes.push(children[i]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t while ((node = nodes2.pop()) != null) {\n", | |
"\t callback(node);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_layout_hierarchyChildren(d) {\n", | |
"\t return d.children;\n", | |
"\t }\n", | |
"\t function d3_layout_hierarchyValue(d) {\n", | |
"\t return d.value;\n", | |
"\t }\n", | |
"\t function d3_layout_hierarchySort(a, b) {\n", | |
"\t return b.value - a.value;\n", | |
"\t }\n", | |
"\t function d3_layout_hierarchyLinks(nodes) {\n", | |
"\t return d3.merge(nodes.map(function(parent) {\n", | |
"\t return (parent.children || []).map(function(child) {\n", | |
"\t return {\n", | |
"\t source: parent,\n", | |
"\t target: child\n", | |
"\t };\n", | |
"\t });\n", | |
"\t }));\n", | |
"\t }\n", | |
"\t d3.layout.partition = function() {\n", | |
"\t var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ];\n", | |
"\t function position(node, x, dx, dy) {\n", | |
"\t var children = node.children;\n", | |
"\t node.x = x;\n", | |
"\t node.y = node.depth * dy;\n", | |
"\t node.dx = dx;\n", | |
"\t node.dy = dy;\n", | |
"\t if (children && (n = children.length)) {\n", | |
"\t var i = -1, n, c, d;\n", | |
"\t dx = node.value ? dx / node.value : 0;\n", | |
"\t while (++i < n) {\n", | |
"\t position(c = children[i], x, d = c.value * dx, dy);\n", | |
"\t x += d;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function depth(node) {\n", | |
"\t var children = node.children, d = 0;\n", | |
"\t if (children && (n = children.length)) {\n", | |
"\t var i = -1, n;\n", | |
"\t while (++i < n) d = Math.max(d, depth(children[i]));\n", | |
"\t }\n", | |
"\t return 1 + d;\n", | |
"\t }\n", | |
"\t function partition(d, i) {\n", | |
"\t var nodes = hierarchy.call(this, d, i);\n", | |
"\t position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));\n", | |
"\t return nodes;\n", | |
"\t }\n", | |
"\t partition.size = function(x) {\n", | |
"\t if (!arguments.length) return size;\n", | |
"\t size = x;\n", | |
"\t return partition;\n", | |
"\t };\n", | |
"\t return d3_layout_hierarchyRebind(partition, hierarchy);\n", | |
"\t };\n", | |
"\t d3.layout.pie = function() {\n", | |
"\t var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0;\n", | |
"\t function pie(data) {\n", | |
"\t var n = data.length, values = data.map(function(d, i) {\n", | |
"\t return +value.call(pie, d, i);\n", | |
"\t }), a = +(typeof startAngle === \"function\" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === \"function\" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === \"function\" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), sum = d3.sum(values), k = sum ? (da - n * pa) / sum : 0, index = d3.range(n), arcs = [], v;\n", | |
"\t if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {\n", | |
"\t return values[j] - values[i];\n", | |
"\t } : function(i, j) {\n", | |
"\t return sort(data[i], data[j]);\n", | |
"\t });\n", | |
"\t index.forEach(function(i) {\n", | |
"\t arcs[i] = {\n", | |
"\t data: data[i],\n", | |
"\t value: v = values[i],\n", | |
"\t startAngle: a,\n", | |
"\t endAngle: a += v * k + pa,\n", | |
"\t padAngle: p\n", | |
"\t };\n", | |
"\t });\n", | |
"\t return arcs;\n", | |
"\t }\n", | |
"\t pie.value = function(_) {\n", | |
"\t if (!arguments.length) return value;\n", | |
"\t value = _;\n", | |
"\t return pie;\n", | |
"\t };\n", | |
"\t pie.sort = function(_) {\n", | |
"\t if (!arguments.length) return sort;\n", | |
"\t sort = _;\n", | |
"\t return pie;\n", | |
"\t };\n", | |
"\t pie.startAngle = function(_) {\n", | |
"\t if (!arguments.length) return startAngle;\n", | |
"\t startAngle = _;\n", | |
"\t return pie;\n", | |
"\t };\n", | |
"\t pie.endAngle = function(_) {\n", | |
"\t if (!arguments.length) return endAngle;\n", | |
"\t endAngle = _;\n", | |
"\t return pie;\n", | |
"\t };\n", | |
"\t pie.padAngle = function(_) {\n", | |
"\t if (!arguments.length) return padAngle;\n", | |
"\t padAngle = _;\n", | |
"\t return pie;\n", | |
"\t };\n", | |
"\t return pie;\n", | |
"\t };\n", | |
"\t var d3_layout_pieSortByValue = {};\n", | |
"\t d3.layout.stack = function() {\n", | |
"\t var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY;\n", | |
"\t function stack(data, index) {\n", | |
"\t if (!(n = data.length)) return data;\n", | |
"\t var series = data.map(function(d, i) {\n", | |
"\t return values.call(stack, d, i);\n", | |
"\t });\n", | |
"\t var points = series.map(function(d) {\n", | |
"\t return d.map(function(v, i) {\n", | |
"\t return [ x.call(stack, v, i), y.call(stack, v, i) ];\n", | |
"\t });\n", | |
"\t });\n", | |
"\t var orders = order.call(stack, points, index);\n", | |
"\t series = d3.permute(series, orders);\n", | |
"\t points = d3.permute(points, orders);\n", | |
"\t var offsets = offset.call(stack, points, index);\n", | |
"\t var m = series[0].length, n, i, j, o;\n", | |
"\t for (j = 0; j < m; ++j) {\n", | |
"\t out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);\n", | |
"\t for (i = 1; i < n; ++i) {\n", | |
"\t out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return data;\n", | |
"\t }\n", | |
"\t stack.values = function(x) {\n", | |
"\t if (!arguments.length) return values;\n", | |
"\t values = x;\n", | |
"\t return stack;\n", | |
"\t };\n", | |
"\t stack.order = function(x) {\n", | |
"\t if (!arguments.length) return order;\n", | |
"\t order = typeof x === \"function\" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;\n", | |
"\t return stack;\n", | |
"\t };\n", | |
"\t stack.offset = function(x) {\n", | |
"\t if (!arguments.length) return offset;\n", | |
"\t offset = typeof x === \"function\" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;\n", | |
"\t return stack;\n", | |
"\t };\n", | |
"\t stack.x = function(z) {\n", | |
"\t if (!arguments.length) return x;\n", | |
"\t x = z;\n", | |
"\t return stack;\n", | |
"\t };\n", | |
"\t stack.y = function(z) {\n", | |
"\t if (!arguments.length) return y;\n", | |
"\t y = z;\n", | |
"\t return stack;\n", | |
"\t };\n", | |
"\t stack.out = function(z) {\n", | |
"\t if (!arguments.length) return out;\n", | |
"\t out = z;\n", | |
"\t return stack;\n", | |
"\t };\n", | |
"\t return stack;\n", | |
"\t };\n", | |
"\t function d3_layout_stackX(d) {\n", | |
"\t return d.x;\n", | |
"\t }\n", | |
"\t function d3_layout_stackY(d) {\n", | |
"\t return d.y;\n", | |
"\t }\n", | |
"\t function d3_layout_stackOut(d, y0, y) {\n", | |
"\t d.y0 = y0;\n", | |
"\t d.y = y;\n", | |
"\t }\n", | |
"\t var d3_layout_stackOrders = d3.map({\n", | |
"\t \"inside-out\": function(data) {\n", | |
"\t var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) {\n", | |
"\t return max[a] - max[b];\n", | |
"\t }), top = 0, bottom = 0, tops = [], bottoms = [];\n", | |
"\t for (i = 0; i < n; ++i) {\n", | |
"\t j = index[i];\n", | |
"\t if (top < bottom) {\n", | |
"\t top += sums[j];\n", | |
"\t tops.push(j);\n", | |
"\t } else {\n", | |
"\t bottom += sums[j];\n", | |
"\t bottoms.push(j);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return bottoms.reverse().concat(tops);\n", | |
"\t },\n", | |
"\t reverse: function(data) {\n", | |
"\t return d3.range(data.length).reverse();\n", | |
"\t },\n", | |
"\t \"default\": d3_layout_stackOrderDefault\n", | |
"\t });\n", | |
"\t var d3_layout_stackOffsets = d3.map({\n", | |
"\t silhouette: function(data) {\n", | |
"\t var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = [];\n", | |
"\t for (j = 0; j < m; ++j) {\n", | |
"\t for (i = 0, o = 0; i < n; i++) o += data[i][j][1];\n", | |
"\t if (o > max) max = o;\n", | |
"\t sums.push(o);\n", | |
"\t }\n", | |
"\t for (j = 0; j < m; ++j) {\n", | |
"\t y0[j] = (max - sums[j]) / 2;\n", | |
"\t }\n", | |
"\t return y0;\n", | |
"\t },\n", | |
"\t wiggle: function(data) {\n", | |
"\t var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = [];\n", | |
"\t y0[0] = o = o0 = 0;\n", | |
"\t for (j = 1; j < m; ++j) {\n", | |
"\t for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];\n", | |
"\t for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {\n", | |
"\t for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {\n", | |
"\t s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;\n", | |
"\t }\n", | |
"\t s2 += s3 * data[i][j][1];\n", | |
"\t }\n", | |
"\t y0[j] = o -= s1 ? s2 / s1 * dx : 0;\n", | |
"\t if (o < o0) o0 = o;\n", | |
"\t }\n", | |
"\t for (j = 0; j < m; ++j) y0[j] -= o0;\n", | |
"\t return y0;\n", | |
"\t },\n", | |
"\t expand: function(data) {\n", | |
"\t var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = [];\n", | |
"\t for (j = 0; j < m; ++j) {\n", | |
"\t for (i = 0, o = 0; i < n; i++) o += data[i][j][1];\n", | |
"\t if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k;\n", | |
"\t }\n", | |
"\t for (j = 0; j < m; ++j) y0[j] = 0;\n", | |
"\t return y0;\n", | |
"\t },\n", | |
"\t zero: d3_layout_stackOffsetZero\n", | |
"\t });\n", | |
"\t function d3_layout_stackOrderDefault(data) {\n", | |
"\t return d3.range(data.length);\n", | |
"\t }\n", | |
"\t function d3_layout_stackOffsetZero(data) {\n", | |
"\t var j = -1, m = data[0].length, y0 = [];\n", | |
"\t while (++j < m) y0[j] = 0;\n", | |
"\t return y0;\n", | |
"\t }\n", | |
"\t function d3_layout_stackMaxIndex(array) {\n", | |
"\t var i = 1, j = 0, v = array[0][1], k, n = array.length;\n", | |
"\t for (;i < n; ++i) {\n", | |
"\t if ((k = array[i][1]) > v) {\n", | |
"\t j = i;\n", | |
"\t v = k;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return j;\n", | |
"\t }\n", | |
"\t function d3_layout_stackReduceSum(d) {\n", | |
"\t return d.reduce(d3_layout_stackSum, 0);\n", | |
"\t }\n", | |
"\t function d3_layout_stackSum(p, d) {\n", | |
"\t return p + d[1];\n", | |
"\t }\n", | |
"\t d3.layout.histogram = function() {\n", | |
"\t var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges;\n", | |
"\t function histogram(data, i) {\n", | |
"\t var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x;\n", | |
"\t while (++i < m) {\n", | |
"\t bin = bins[i] = [];\n", | |
"\t bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);\n", | |
"\t bin.y = 0;\n", | |
"\t }\n", | |
"\t if (m > 0) {\n", | |
"\t i = -1;\n", | |
"\t while (++i < n) {\n", | |
"\t x = values[i];\n", | |
"\t if (x >= range[0] && x <= range[1]) {\n", | |
"\t bin = bins[d3.bisect(thresholds, x, 1, m) - 1];\n", | |
"\t bin.y += k;\n", | |
"\t bin.push(data[i]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return bins;\n", | |
"\t }\n", | |
"\t histogram.value = function(x) {\n", | |
"\t if (!arguments.length) return valuer;\n", | |
"\t valuer = x;\n", | |
"\t return histogram;\n", | |
"\t };\n", | |
"\t histogram.range = function(x) {\n", | |
"\t if (!arguments.length) return ranger;\n", | |
"\t ranger = d3_functor(x);\n", | |
"\t return histogram;\n", | |
"\t };\n", | |
"\t histogram.bins = function(x) {\n", | |
"\t if (!arguments.length) return binner;\n", | |
"\t binner = typeof x === \"number\" ? function(range) {\n", | |
"\t return d3_layout_histogramBinFixed(range, x);\n", | |
"\t } : d3_functor(x);\n", | |
"\t return histogram;\n", | |
"\t };\n", | |
"\t histogram.frequency = function(x) {\n", | |
"\t if (!arguments.length) return frequency;\n", | |
"\t frequency = !!x;\n", | |
"\t return histogram;\n", | |
"\t };\n", | |
"\t return histogram;\n", | |
"\t };\n", | |
"\t function d3_layout_histogramBinSturges(range, values) {\n", | |
"\t return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));\n", | |
"\t }\n", | |
"\t function d3_layout_histogramBinFixed(range, n) {\n", | |
"\t var x = -1, b = +range[0], m = (range[1] - b) / n, f = [];\n", | |
"\t while (++x <= n) f[x] = m * x + b;\n", | |
"\t return f;\n", | |
"\t }\n", | |
"\t function d3_layout_histogramRange(values) {\n", | |
"\t return [ d3.min(values), d3.max(values) ];\n", | |
"\t }\n", | |
"\t d3.layout.pack = function() {\n", | |
"\t var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius;\n", | |
"\t function pack(d, i) {\n", | |
"\t var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === \"function\" ? radius : function() {\n", | |
"\t return radius;\n", | |
"\t };\n", | |
"\t root.x = root.y = 0;\n", | |
"\t d3_layout_hierarchyVisitAfter(root, function(d) {\n", | |
"\t d.r = +r(d.value);\n", | |
"\t });\n", | |
"\t d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);\n", | |
"\t if (padding) {\n", | |
"\t var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2;\n", | |
"\t d3_layout_hierarchyVisitAfter(root, function(d) {\n", | |
"\t d.r += dr;\n", | |
"\t });\n", | |
"\t d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);\n", | |
"\t d3_layout_hierarchyVisitAfter(root, function(d) {\n", | |
"\t d.r -= dr;\n", | |
"\t });\n", | |
"\t }\n", | |
"\t d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h));\n", | |
"\t return nodes;\n", | |
"\t }\n", | |
"\t pack.size = function(_) {\n", | |
"\t if (!arguments.length) return size;\n", | |
"\t size = _;\n", | |
"\t return pack;\n", | |
"\t };\n", | |
"\t pack.radius = function(_) {\n", | |
"\t if (!arguments.length) return radius;\n", | |
"\t radius = _ == null || typeof _ === \"function\" ? _ : +_;\n", | |
"\t return pack;\n", | |
"\t };\n", | |
"\t pack.padding = function(_) {\n", | |
"\t if (!arguments.length) return padding;\n", | |
"\t padding = +_;\n", | |
"\t return pack;\n", | |
"\t };\n", | |
"\t return d3_layout_hierarchyRebind(pack, hierarchy);\n", | |
"\t };\n", | |
"\t function d3_layout_packSort(a, b) {\n", | |
"\t return a.value - b.value;\n", | |
"\t }\n", | |
"\t function d3_layout_packInsert(a, b) {\n", | |
"\t var c = a._pack_next;\n", | |
"\t a._pack_next = b;\n", | |
"\t b._pack_prev = a;\n", | |
"\t b._pack_next = c;\n", | |
"\t c._pack_prev = b;\n", | |
"\t }\n", | |
"\t function d3_layout_packSplice(a, b) {\n", | |
"\t a._pack_next = b;\n", | |
"\t b._pack_prev = a;\n", | |
"\t }\n", | |
"\t function d3_layout_packIntersects(a, b) {\n", | |
"\t var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r;\n", | |
"\t return .999 * dr * dr > dx * dx + dy * dy;\n", | |
"\t }\n", | |
"\t function d3_layout_packSiblings(node) {\n", | |
"\t if (!(nodes = node.children) || !(n = nodes.length)) return;\n", | |
"\t var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n;\n", | |
"\t function bound(node) {\n", | |
"\t xMin = Math.min(node.x - node.r, xMin);\n", | |
"\t xMax = Math.max(node.x + node.r, xMax);\n", | |
"\t yMin = Math.min(node.y - node.r, yMin);\n", | |
"\t yMax = Math.max(node.y + node.r, yMax);\n", | |
"\t }\n", | |
"\t nodes.forEach(d3_layout_packLink);\n", | |
"\t a = nodes[0];\n", | |
"\t a.x = -a.r;\n", | |
"\t a.y = 0;\n", | |
"\t bound(a);\n", | |
"\t if (n > 1) {\n", | |
"\t b = nodes[1];\n", | |
"\t b.x = b.r;\n", | |
"\t b.y = 0;\n", | |
"\t bound(b);\n", | |
"\t if (n > 2) {\n", | |
"\t c = nodes[2];\n", | |
"\t d3_layout_packPlace(a, b, c);\n", | |
"\t bound(c);\n", | |
"\t d3_layout_packInsert(a, c);\n", | |
"\t a._pack_prev = c;\n", | |
"\t d3_layout_packInsert(c, b);\n", | |
"\t b = a._pack_next;\n", | |
"\t for (i = 3; i < n; i++) {\n", | |
"\t d3_layout_packPlace(a, b, c = nodes[i]);\n", | |
"\t var isect = 0, s1 = 1, s2 = 1;\n", | |
"\t for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {\n", | |
"\t if (d3_layout_packIntersects(j, c)) {\n", | |
"\t isect = 1;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (isect == 1) {\n", | |
"\t for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {\n", | |
"\t if (d3_layout_packIntersects(k, c)) {\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (isect) {\n", | |
"\t if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b);\n", | |
"\t i--;\n", | |
"\t } else {\n", | |
"\t d3_layout_packInsert(a, c);\n", | |
"\t b = c;\n", | |
"\t bound(c);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0;\n", | |
"\t for (i = 0; i < n; i++) {\n", | |
"\t c = nodes[i];\n", | |
"\t c.x -= cx;\n", | |
"\t c.y -= cy;\n", | |
"\t cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y));\n", | |
"\t }\n", | |
"\t node.r = cr;\n", | |
"\t nodes.forEach(d3_layout_packUnlink);\n", | |
"\t }\n", | |
"\t function d3_layout_packLink(node) {\n", | |
"\t node._pack_next = node._pack_prev = node;\n", | |
"\t }\n", | |
"\t function d3_layout_packUnlink(node) {\n", | |
"\t delete node._pack_next;\n", | |
"\t delete node._pack_prev;\n", | |
"\t }\n", | |
"\t function d3_layout_packTransform(node, x, y, k) {\n", | |
"\t var children = node.children;\n", | |
"\t node.x = x += k * node.x;\n", | |
"\t node.y = y += k * node.y;\n", | |
"\t node.r *= k;\n", | |
"\t if (children) {\n", | |
"\t var i = -1, n = children.length;\n", | |
"\t while (++i < n) d3_layout_packTransform(children[i], x, y, k);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_layout_packPlace(a, b, c) {\n", | |
"\t var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y;\n", | |
"\t if (db && (dx || dy)) {\n", | |
"\t var da = b.r + c.r, dc = dx * dx + dy * dy;\n", | |
"\t da *= da;\n", | |
"\t db *= db;\n", | |
"\t var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);\n", | |
"\t c.x = a.x + x * dx + y * dy;\n", | |
"\t c.y = a.y + x * dy - y * dx;\n", | |
"\t } else {\n", | |
"\t c.x = a.x + db;\n", | |
"\t c.y = a.y;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3.layout.tree = function() {\n", | |
"\t var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null;\n", | |
"\t function tree(d, i) {\n", | |
"\t var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0);\n", | |
"\t d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z;\n", | |
"\t d3_layout_hierarchyVisitBefore(root1, secondWalk);\n", | |
"\t if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else {\n", | |
"\t var left = root0, right = root0, bottom = root0;\n", | |
"\t d3_layout_hierarchyVisitBefore(root0, function(node) {\n", | |
"\t if (node.x < left.x) left = node;\n", | |
"\t if (node.x > right.x) right = node;\n", | |
"\t if (node.depth > bottom.depth) bottom = node;\n", | |
"\t });\n", | |
"\t var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1);\n", | |
"\t d3_layout_hierarchyVisitBefore(root0, function(node) {\n", | |
"\t node.x = (node.x + tx) * kx;\n", | |
"\t node.y = node.depth * ky;\n", | |
"\t });\n", | |
"\t }\n", | |
"\t return nodes;\n", | |
"\t }\n", | |
"\t function wrapTree(root0) {\n", | |
"\t var root1 = {\n", | |
"\t A: null,\n", | |
"\t children: [ root0 ]\n", | |
"\t }, queue = [ root1 ], node1;\n", | |
"\t while ((node1 = queue.pop()) != null) {\n", | |
"\t for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) {\n", | |
"\t queue.push((children[i] = child = {\n", | |
"\t _: children[i],\n", | |
"\t parent: node1,\n", | |
"\t children: (child = children[i].children) && child.slice() || [],\n", | |
"\t A: null,\n", | |
"\t a: null,\n", | |
"\t z: 0,\n", | |
"\t m: 0,\n", | |
"\t c: 0,\n", | |
"\t s: 0,\n", | |
"\t t: null,\n", | |
"\t i: i\n", | |
"\t }).a = child);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return root1.children[0];\n", | |
"\t }\n", | |
"\t function firstWalk(v) {\n", | |
"\t var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;\n", | |
"\t if (children.length) {\n", | |
"\t d3_layout_treeShift(v);\n", | |
"\t var midpoint = (children[0].z + children[children.length - 1].z) / 2;\n", | |
"\t if (w) {\n", | |
"\t v.z = w.z + separation(v._, w._);\n", | |
"\t v.m = v.z - midpoint;\n", | |
"\t } else {\n", | |
"\t v.z = midpoint;\n", | |
"\t }\n", | |
"\t } else if (w) {\n", | |
"\t v.z = w.z + separation(v._, w._);\n", | |
"\t }\n", | |
"\t v.parent.A = apportion(v, w, v.parent.A || siblings[0]);\n", | |
"\t }\n", | |
"\t function secondWalk(v) {\n", | |
"\t v._.x = v.z + v.parent.m;\n", | |
"\t v.m += v.parent.m;\n", | |
"\t }\n", | |
"\t function apportion(v, w, ancestor) {\n", | |
"\t if (w) {\n", | |
"\t var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift;\n", | |
"\t while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {\n", | |
"\t vom = d3_layout_treeLeft(vom);\n", | |
"\t vop = d3_layout_treeRight(vop);\n", | |
"\t vop.a = v;\n", | |
"\t shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);\n", | |
"\t if (shift > 0) {\n", | |
"\t d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift);\n", | |
"\t sip += shift;\n", | |
"\t sop += shift;\n", | |
"\t }\n", | |
"\t sim += vim.m;\n", | |
"\t sip += vip.m;\n", | |
"\t som += vom.m;\n", | |
"\t sop += vop.m;\n", | |
"\t }\n", | |
"\t if (vim && !d3_layout_treeRight(vop)) {\n", | |
"\t vop.t = vim;\n", | |
"\t vop.m += sim - sop;\n", | |
"\t }\n", | |
"\t if (vip && !d3_layout_treeLeft(vom)) {\n", | |
"\t vom.t = vip;\n", | |
"\t vom.m += sip - som;\n", | |
"\t ancestor = v;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return ancestor;\n", | |
"\t }\n", | |
"\t function sizeNode(node) {\n", | |
"\t node.x *= size[0];\n", | |
"\t node.y = node.depth * size[1];\n", | |
"\t }\n", | |
"\t tree.separation = function(x) {\n", | |
"\t if (!arguments.length) return separation;\n", | |
"\t separation = x;\n", | |
"\t return tree;\n", | |
"\t };\n", | |
"\t tree.size = function(x) {\n", | |
"\t if (!arguments.length) return nodeSize ? null : size;\n", | |
"\t nodeSize = (size = x) == null ? sizeNode : null;\n", | |
"\t return tree;\n", | |
"\t };\n", | |
"\t tree.nodeSize = function(x) {\n", | |
"\t if (!arguments.length) return nodeSize ? size : null;\n", | |
"\t nodeSize = (size = x) == null ? null : sizeNode;\n", | |
"\t return tree;\n", | |
"\t };\n", | |
"\t return d3_layout_hierarchyRebind(tree, hierarchy);\n", | |
"\t };\n", | |
"\t function d3_layout_treeSeparation(a, b) {\n", | |
"\t return a.parent == b.parent ? 1 : 2;\n", | |
"\t }\n", | |
"\t function d3_layout_treeLeft(v) {\n", | |
"\t var children = v.children;\n", | |
"\t return children.length ? children[0] : v.t;\n", | |
"\t }\n", | |
"\t function d3_layout_treeRight(v) {\n", | |
"\t var children = v.children, n;\n", | |
"\t return (n = children.length) ? children[n - 1] : v.t;\n", | |
"\t }\n", | |
"\t function d3_layout_treeMove(wm, wp, shift) {\n", | |
"\t var change = shift / (wp.i - wm.i);\n", | |
"\t wp.c -= change;\n", | |
"\t wp.s += shift;\n", | |
"\t wm.c += change;\n", | |
"\t wp.z += shift;\n", | |
"\t wp.m += shift;\n", | |
"\t }\n", | |
"\t function d3_layout_treeShift(v) {\n", | |
"\t var shift = 0, change = 0, children = v.children, i = children.length, w;\n", | |
"\t while (--i >= 0) {\n", | |
"\t w = children[i];\n", | |
"\t w.z += shift;\n", | |
"\t w.m += shift;\n", | |
"\t shift += w.s + (change += w.c);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function d3_layout_treeAncestor(vim, v, ancestor) {\n", | |
"\t return vim.a.parent === v.parent ? vim.a : ancestor;\n", | |
"\t }\n", | |
"\t d3.layout.cluster = function() {\n", | |
"\t var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;\n", | |
"\t function cluster(d, i) {\n", | |
"\t var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;\n", | |
"\t d3_layout_hierarchyVisitAfter(root, function(node) {\n", | |
"\t var children = node.children;\n", | |
"\t if (children && children.length) {\n", | |
"\t node.x = d3_layout_clusterX(children);\n", | |
"\t node.y = d3_layout_clusterY(children);\n", | |
"\t } else {\n", | |
"\t node.x = previousNode ? x += separation(node, previousNode) : 0;\n", | |
"\t node.y = 0;\n", | |
"\t previousNode = node;\n", | |
"\t }\n", | |
"\t });\n", | |
"\t var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2;\n", | |
"\t d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) {\n", | |
"\t node.x = (node.x - root.x) * size[0];\n", | |
"\t node.y = (root.y - node.y) * size[1];\n", | |
"\t } : function(node) {\n", | |
"\t node.x = (node.x - x0) / (x1 - x0) * size[0];\n", | |
"\t node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];\n", | |
"\t });\n", | |
"\t return nodes;\n", | |
"\t }\n", | |
"\t cluster.separation = function(x) {\n", | |
"\t if (!arguments.length) return separation;\n", | |
"\t separation = x;\n", | |
"\t return cluster;\n", | |
"\t };\n", | |
"\t cluster.size = function(x) {\n", | |
"\t if (!arguments.length) return nodeSize ? null : size;\n", | |
"\t nodeSize = (size = x) == null;\n", | |
"\t return cluster;\n", | |
"\t };\n", | |
"\t cluster.nodeSize = function(x) {\n", | |
"\t if (!arguments.length) return nodeSize ? size : null;\n", | |
"\t nodeSize = (size = x) != null;\n", | |
"\t return cluster;\n", | |
"\t };\n", | |
"\t return d3_layout_hierarchyRebind(cluster, hierarchy);\n", | |
"\t };\n", | |
"\t function d3_layout_clusterY(children) {\n", | |
"\t return 1 + d3.max(children, function(child) {\n", | |
"\t return child.y;\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function d3_layout_clusterX(children) {\n", | |
"\t return children.reduce(function(x, child) {\n", | |
"\t return x + child.x;\n", | |
"\t }, 0) / children.length;\n", | |
"\t }\n", | |
"\t function d3_layout_clusterLeft(node) {\n", | |
"\t var children = node.children;\n", | |
"\t return children && children.length ? d3_layout_clusterLeft(children[0]) : node;\n", | |
"\t }\n", | |
"\t function d3_layout_clusterRight(node) {\n", | |
"\t var children = node.children, n;\n", | |
"\t return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;\n", | |
"\t }\n", | |
"\t d3.layout.treemap = function() {\n", | |
"\t var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = \"squarify\", ratio = .5 * (1 + Math.sqrt(5));\n", | |
"\t function scale(children, k) {\n", | |
"\t var i = -1, n = children.length, child, area;\n", | |
"\t while (++i < n) {\n", | |
"\t area = (child = children[i]).value * (k < 0 ? 0 : k);\n", | |
"\t child.area = isNaN(area) || area <= 0 ? 0 : area;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function squarify(node) {\n", | |
"\t var children = node.children;\n", | |
"\t if (children && children.length) {\n", | |
"\t var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === \"slice\" ? rect.dx : mode === \"dice\" ? rect.dy : mode === \"slice-dice\" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n;\n", | |
"\t scale(remaining, rect.dx * rect.dy / node.value);\n", | |
"\t row.area = 0;\n", | |
"\t while ((n = remaining.length) > 0) {\n", | |
"\t row.push(child = remaining[n - 1]);\n", | |
"\t row.area += child.area;\n", | |
"\t if (mode !== \"squarify\" || (score = worst(row, u)) <= best) {\n", | |
"\t remaining.pop();\n", | |
"\t best = score;\n", | |
"\t } else {\n", | |
"\t row.area -= row.pop().area;\n", | |
"\t position(row, u, rect, false);\n", | |
"\t u = Math.min(rect.dx, rect.dy);\n", | |
"\t row.length = row.area = 0;\n", | |
"\t best = Infinity;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (row.length) {\n", | |
"\t position(row, u, rect, true);\n", | |
"\t row.length = row.area = 0;\n", | |
"\t }\n", | |
"\t children.forEach(squarify);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function stickify(node) {\n", | |
"\t var children = node.children;\n", | |
"\t if (children && children.length) {\n", | |
"\t var rect = pad(node), remaining = children.slice(), child, row = [];\n", | |
"\t scale(remaining, rect.dx * rect.dy / node.value);\n", | |
"\t row.area = 0;\n", | |
"\t while (child = remaining.pop()) {\n", | |
"\t row.push(child);\n", | |
"\t row.area += child.area;\n", | |
"\t if (child.z != null) {\n", | |
"\t position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);\n", | |
"\t row.length = row.area = 0;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t children.forEach(stickify);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function worst(row, u) {\n", | |
"\t var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length;\n", | |
"\t while (++i < n) {\n", | |
"\t if (!(r = row[i].area)) continue;\n", | |
"\t if (r < rmin) rmin = r;\n", | |
"\t if (r > rmax) rmax = r;\n", | |
"\t }\n", | |
"\t s *= s;\n", | |
"\t u *= u;\n", | |
"\t return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity;\n", | |
"\t }\n", | |
"\t function position(row, u, rect, flush) {\n", | |
"\t var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o;\n", | |
"\t if (u == rect.dx) {\n", | |
"\t if (flush || v > rect.dy) v = rect.dy;\n", | |
"\t while (++i < n) {\n", | |
"\t o = row[i];\n", | |
"\t o.x = x;\n", | |
"\t o.y = y;\n", | |
"\t o.dy = v;\n", | |
"\t x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);\n", | |
"\t }\n", | |
"\t o.z = true;\n", | |
"\t o.dx += rect.x + rect.dx - x;\n", | |
"\t rect.y += v;\n", | |
"\t rect.dy -= v;\n", | |
"\t } else {\n", | |
"\t if (flush || v > rect.dx) v = rect.dx;\n", | |
"\t while (++i < n) {\n", | |
"\t o = row[i];\n", | |
"\t o.x = x;\n", | |
"\t o.y = y;\n", | |
"\t o.dx = v;\n", | |
"\t y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);\n", | |
"\t }\n", | |
"\t o.z = false;\n", | |
"\t o.dy += rect.y + rect.dy - y;\n", | |
"\t rect.x += v;\n", | |
"\t rect.dx -= v;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function treemap(d) {\n", | |
"\t var nodes = stickies || hierarchy(d), root = nodes[0];\n", | |
"\t root.x = root.y = 0;\n", | |
"\t if (root.value) root.dx = size[0], root.dy = size[1]; else root.dx = root.dy = 0;\n", | |
"\t if (stickies) hierarchy.revalue(root);\n", | |
"\t scale([ root ], root.dx * root.dy / root.value);\n", | |
"\t (stickies ? stickify : squarify)(root);\n", | |
"\t if (sticky) stickies = nodes;\n", | |
"\t return nodes;\n", | |
"\t }\n", | |
"\t treemap.size = function(x) {\n", | |
"\t if (!arguments.length) return size;\n", | |
"\t size = x;\n", | |
"\t return treemap;\n", | |
"\t };\n", | |
"\t treemap.padding = function(x) {\n", | |
"\t if (!arguments.length) return padding;\n", | |
"\t function padFunction(node) {\n", | |
"\t var p = x.call(treemap, node, node.depth);\n", | |
"\t return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === \"number\" ? [ p, p, p, p ] : p);\n", | |
"\t }\n", | |
"\t function padConstant(node) {\n", | |
"\t return d3_layout_treemapPad(node, x);\n", | |
"\t }\n", | |
"\t var type;\n", | |
"\t pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === \"function\" ? padFunction : type === \"number\" ? (x = [ x, x, x, x ], \n", | |
"\t padConstant) : padConstant;\n", | |
"\t return treemap;\n", | |
"\t };\n", | |
"\t treemap.round = function(x) {\n", | |
"\t if (!arguments.length) return round != Number;\n", | |
"\t round = x ? Math.round : Number;\n", | |
"\t return treemap;\n", | |
"\t };\n", | |
"\t treemap.sticky = function(x) {\n", | |
"\t if (!arguments.length) return sticky;\n", | |
"\t sticky = x;\n", | |
"\t stickies = null;\n", | |
"\t return treemap;\n", | |
"\t };\n", | |
"\t treemap.ratio = function(x) {\n", | |
"\t if (!arguments.length) return ratio;\n", | |
"\t ratio = x;\n", | |
"\t return treemap;\n", | |
"\t };\n", | |
"\t treemap.mode = function(x) {\n", | |
"\t if (!arguments.length) return mode;\n", | |
"\t mode = x + \"\";\n", | |
"\t return treemap;\n", | |
"\t };\n", | |
"\t return d3_layout_hierarchyRebind(treemap, hierarchy);\n", | |
"\t };\n", | |
"\t function d3_layout_treemapPadNull(node) {\n", | |
"\t return {\n", | |
"\t x: node.x,\n", | |
"\t y: node.y,\n", | |
"\t dx: node.dx,\n", | |
"\t dy: node.dy\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_layout_treemapPad(node, padding) {\n", | |
"\t var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2];\n", | |
"\t if (dx < 0) {\n", | |
"\t x += dx / 2;\n", | |
"\t dx = 0;\n", | |
"\t }\n", | |
"\t if (dy < 0) {\n", | |
"\t y += dy / 2;\n", | |
"\t dy = 0;\n", | |
"\t }\n", | |
"\t return {\n", | |
"\t x: x,\n", | |
"\t y: y,\n", | |
"\t dx: dx,\n", | |
"\t dy: dy\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.random = {\n", | |
"\t normal: function(µ, σ) {\n", | |
"\t var n = arguments.length;\n", | |
"\t if (n < 2) σ = 1;\n", | |
"\t if (n < 1) µ = 0;\n", | |
"\t return function() {\n", | |
"\t var x, y, r;\n", | |
"\t do {\n", | |
"\t x = Math.random() * 2 - 1;\n", | |
"\t y = Math.random() * 2 - 1;\n", | |
"\t r = x * x + y * y;\n", | |
"\t } while (!r || r > 1);\n", | |
"\t return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);\n", | |
"\t };\n", | |
"\t },\n", | |
"\t logNormal: function() {\n", | |
"\t var random = d3.random.normal.apply(d3, arguments);\n", | |
"\t return function() {\n", | |
"\t return Math.exp(random());\n", | |
"\t };\n", | |
"\t },\n", | |
"\t bates: function(m) {\n", | |
"\t var random = d3.random.irwinHall(m);\n", | |
"\t return function() {\n", | |
"\t return random() / m;\n", | |
"\t };\n", | |
"\t },\n", | |
"\t irwinHall: function(m) {\n", | |
"\t return function() {\n", | |
"\t for (var s = 0, j = 0; j < m; j++) s += Math.random();\n", | |
"\t return s;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t };\n", | |
"\t d3.scale = {};\n", | |
"\t function d3_scaleExtent(domain) {\n", | |
"\t var start = domain[0], stop = domain[domain.length - 1];\n", | |
"\t return start < stop ? [ start, stop ] : [ stop, start ];\n", | |
"\t }\n", | |
"\t function d3_scaleRange(scale) {\n", | |
"\t return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());\n", | |
"\t }\n", | |
"\t function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {\n", | |
"\t var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]);\n", | |
"\t return function(x) {\n", | |
"\t return i(u(x));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_scale_nice(domain, nice) {\n", | |
"\t var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx;\n", | |
"\t if (x1 < x0) {\n", | |
"\t dx = i0, i0 = i1, i1 = dx;\n", | |
"\t dx = x0, x0 = x1, x1 = dx;\n", | |
"\t }\n", | |
"\t domain[i0] = nice.floor(x0);\n", | |
"\t domain[i1] = nice.ceil(x1);\n", | |
"\t return domain;\n", | |
"\t }\n", | |
"\t function d3_scale_niceStep(step) {\n", | |
"\t return step ? {\n", | |
"\t floor: function(x) {\n", | |
"\t return Math.floor(x / step) * step;\n", | |
"\t },\n", | |
"\t ceil: function(x) {\n", | |
"\t return Math.ceil(x / step) * step;\n", | |
"\t }\n", | |
"\t } : d3_scale_niceIdentity;\n", | |
"\t }\n", | |
"\t var d3_scale_niceIdentity = {\n", | |
"\t floor: d3_identity,\n", | |
"\t ceil: d3_identity\n", | |
"\t };\n", | |
"\t function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {\n", | |
"\t var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1;\n", | |
"\t if (domain[k] < domain[0]) {\n", | |
"\t domain = domain.slice().reverse();\n", | |
"\t range = range.slice().reverse();\n", | |
"\t }\n", | |
"\t while (++j <= k) {\n", | |
"\t u.push(uninterpolate(domain[j - 1], domain[j]));\n", | |
"\t i.push(interpolate(range[j - 1], range[j]));\n", | |
"\t }\n", | |
"\t return function(x) {\n", | |
"\t var j = d3.bisect(domain, x, 1, k) - 1;\n", | |
"\t return i[j](u[j](x));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.scale.linear = function() {\n", | |
"\t return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false);\n", | |
"\t };\n", | |
"\t function d3_scale_linear(domain, range, interpolate, clamp) {\n", | |
"\t var output, input;\n", | |
"\t function rescale() {\n", | |
"\t var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;\n", | |
"\t output = linear(domain, range, uninterpolate, interpolate);\n", | |
"\t input = linear(range, domain, uninterpolate, d3_interpolate);\n", | |
"\t return scale;\n", | |
"\t }\n", | |
"\t function scale(x) {\n", | |
"\t return output(x);\n", | |
"\t }\n", | |
"\t scale.invert = function(y) {\n", | |
"\t return input(y);\n", | |
"\t };\n", | |
"\t scale.domain = function(x) {\n", | |
"\t if (!arguments.length) return domain;\n", | |
"\t domain = x.map(Number);\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.range = function(x) {\n", | |
"\t if (!arguments.length) return range;\n", | |
"\t range = x;\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.rangeRound = function(x) {\n", | |
"\t return scale.range(x).interpolate(d3_interpolateRound);\n", | |
"\t };\n", | |
"\t scale.clamp = function(x) {\n", | |
"\t if (!arguments.length) return clamp;\n", | |
"\t clamp = x;\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.interpolate = function(x) {\n", | |
"\t if (!arguments.length) return interpolate;\n", | |
"\t interpolate = x;\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.ticks = function(m) {\n", | |
"\t return d3_scale_linearTicks(domain, m);\n", | |
"\t };\n", | |
"\t scale.tickFormat = function(m, format) {\n", | |
"\t return d3_scale_linearTickFormat(domain, m, format);\n", | |
"\t };\n", | |
"\t scale.nice = function(m) {\n", | |
"\t d3_scale_linearNice(domain, m);\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.copy = function() {\n", | |
"\t return d3_scale_linear(domain, range, interpolate, clamp);\n", | |
"\t };\n", | |
"\t return rescale();\n", | |
"\t }\n", | |
"\t function d3_scale_linearRebind(scale, linear) {\n", | |
"\t return d3.rebind(scale, linear, \"range\", \"rangeRound\", \"interpolate\", \"clamp\");\n", | |
"\t }\n", | |
"\t function d3_scale_linearNice(domain, m) {\n", | |
"\t d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));\n", | |
"\t d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));\n", | |
"\t return domain;\n", | |
"\t }\n", | |
"\t function d3_scale_linearTickRange(domain, m) {\n", | |
"\t if (m == null) m = 10;\n", | |
"\t var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step;\n", | |
"\t if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;\n", | |
"\t extent[0] = Math.ceil(extent[0] / step) * step;\n", | |
"\t extent[1] = Math.floor(extent[1] / step) * step + step * .5;\n", | |
"\t extent[2] = step;\n", | |
"\t return extent;\n", | |
"\t }\n", | |
"\t function d3_scale_linearTicks(domain, m) {\n", | |
"\t return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));\n", | |
"\t }\n", | |
"\t function d3_scale_linearTickFormat(domain, m, format) {\n", | |
"\t var range = d3_scale_linearTickRange(domain, m);\n", | |
"\t if (format) {\n", | |
"\t var match = d3_format_re.exec(format);\n", | |
"\t match.shift();\n", | |
"\t if (match[8] === \"s\") {\n", | |
"\t var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1])));\n", | |
"\t if (!match[7]) match[7] = \".\" + d3_scale_linearPrecision(prefix.scale(range[2]));\n", | |
"\t match[8] = \"f\";\n", | |
"\t format = d3.format(match.join(\"\"));\n", | |
"\t return function(d) {\n", | |
"\t return format(prefix.scale(d)) + prefix.symbol;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t if (!match[7]) match[7] = \".\" + d3_scale_linearFormatPrecision(match[8], range);\n", | |
"\t format = match.join(\"\");\n", | |
"\t } else {\n", | |
"\t format = \",.\" + d3_scale_linearPrecision(range[2]) + \"f\";\n", | |
"\t }\n", | |
"\t return d3.format(format);\n", | |
"\t }\n", | |
"\t var d3_scale_linearFormatSignificant = {\n", | |
"\t s: 1,\n", | |
"\t g: 1,\n", | |
"\t p: 1,\n", | |
"\t r: 1,\n", | |
"\t e: 1\n", | |
"\t };\n", | |
"\t function d3_scale_linearPrecision(value) {\n", | |
"\t return -Math.floor(Math.log(value) / Math.LN10 + .01);\n", | |
"\t }\n", | |
"\t function d3_scale_linearFormatPrecision(type, range) {\n", | |
"\t var p = d3_scale_linearPrecision(range[2]);\n", | |
"\t return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range[0]), abs(range[1])))) + +(type !== \"e\") : p - (type === \"%\") * 2;\n", | |
"\t }\n", | |
"\t d3.scale.log = function() {\n", | |
"\t return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]);\n", | |
"\t };\n", | |
"\t function d3_scale_log(linear, base, positive, domain) {\n", | |
"\t function log(x) {\n", | |
"\t return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base);\n", | |
"\t }\n", | |
"\t function pow(x) {\n", | |
"\t return positive ? Math.pow(base, x) : -Math.pow(base, -x);\n", | |
"\t }\n", | |
"\t function scale(x) {\n", | |
"\t return linear(log(x));\n", | |
"\t }\n", | |
"\t scale.invert = function(x) {\n", | |
"\t return pow(linear.invert(x));\n", | |
"\t };\n", | |
"\t scale.domain = function(x) {\n", | |
"\t if (!arguments.length) return domain;\n", | |
"\t positive = x[0] >= 0;\n", | |
"\t linear.domain((domain = x.map(Number)).map(log));\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.base = function(_) {\n", | |
"\t if (!arguments.length) return base;\n", | |
"\t base = +_;\n", | |
"\t linear.domain(domain.map(log));\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.nice = function() {\n", | |
"\t var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative);\n", | |
"\t linear.domain(niced);\n", | |
"\t domain = niced.map(pow);\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.ticks = function() {\n", | |
"\t var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base;\n", | |
"\t if (isFinite(j - i)) {\n", | |
"\t if (positive) {\n", | |
"\t for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k);\n", | |
"\t ticks.push(pow(i));\n", | |
"\t } else {\n", | |
"\t ticks.push(pow(i));\n", | |
"\t for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k);\n", | |
"\t }\n", | |
"\t for (i = 0; ticks[i] < u; i++) {}\n", | |
"\t for (j = ticks.length; ticks[j - 1] > v; j--) {}\n", | |
"\t ticks = ticks.slice(i, j);\n", | |
"\t }\n", | |
"\t return ticks;\n", | |
"\t };\n", | |
"\t scale.tickFormat = function(n, format) {\n", | |
"\t if (!arguments.length) return d3_scale_logFormat;\n", | |
"\t if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== \"function\") format = d3.format(format);\n", | |
"\t var k = Math.max(1, base * n / scale.ticks().length);\n", | |
"\t return function(d) {\n", | |
"\t var i = d / pow(Math.round(log(d)));\n", | |
"\t if (i * base < base - .5) i *= base;\n", | |
"\t return i <= k ? format(d) : \"\";\n", | |
"\t };\n", | |
"\t };\n", | |
"\t scale.copy = function() {\n", | |
"\t return d3_scale_log(linear.copy(), base, positive, domain);\n", | |
"\t };\n", | |
"\t return d3_scale_linearRebind(scale, linear);\n", | |
"\t }\n", | |
"\t var d3_scale_logFormat = d3.format(\".0e\"), d3_scale_logNiceNegative = {\n", | |
"\t floor: function(x) {\n", | |
"\t return -Math.ceil(-x);\n", | |
"\t },\n", | |
"\t ceil: function(x) {\n", | |
"\t return -Math.floor(-x);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t d3.scale.pow = function() {\n", | |
"\t return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]);\n", | |
"\t };\n", | |
"\t function d3_scale_pow(linear, exponent, domain) {\n", | |
"\t var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);\n", | |
"\t function scale(x) {\n", | |
"\t return linear(powp(x));\n", | |
"\t }\n", | |
"\t scale.invert = function(x) {\n", | |
"\t return powb(linear.invert(x));\n", | |
"\t };\n", | |
"\t scale.domain = function(x) {\n", | |
"\t if (!arguments.length) return domain;\n", | |
"\t linear.domain((domain = x.map(Number)).map(powp));\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.ticks = function(m) {\n", | |
"\t return d3_scale_linearTicks(domain, m);\n", | |
"\t };\n", | |
"\t scale.tickFormat = function(m, format) {\n", | |
"\t return d3_scale_linearTickFormat(domain, m, format);\n", | |
"\t };\n", | |
"\t scale.nice = function(m) {\n", | |
"\t return scale.domain(d3_scale_linearNice(domain, m));\n", | |
"\t };\n", | |
"\t scale.exponent = function(x) {\n", | |
"\t if (!arguments.length) return exponent;\n", | |
"\t powp = d3_scale_powPow(exponent = x);\n", | |
"\t powb = d3_scale_powPow(1 / exponent);\n", | |
"\t linear.domain(domain.map(powp));\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.copy = function() {\n", | |
"\t return d3_scale_pow(linear.copy(), exponent, domain);\n", | |
"\t };\n", | |
"\t return d3_scale_linearRebind(scale, linear);\n", | |
"\t }\n", | |
"\t function d3_scale_powPow(e) {\n", | |
"\t return function(x) {\n", | |
"\t return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.scale.sqrt = function() {\n", | |
"\t return d3.scale.pow().exponent(.5);\n", | |
"\t };\n", | |
"\t d3.scale.ordinal = function() {\n", | |
"\t return d3_scale_ordinal([], {\n", | |
"\t t: \"range\",\n", | |
"\t a: [ [] ]\n", | |
"\t });\n", | |
"\t };\n", | |
"\t function d3_scale_ordinal(domain, ranger) {\n", | |
"\t var index, range, rangeBand;\n", | |
"\t function scale(x) {\n", | |
"\t return range[((index.get(x) || (ranger.t === \"range\" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length];\n", | |
"\t }\n", | |
"\t function steps(start, step) {\n", | |
"\t return d3.range(domain.length).map(function(i) {\n", | |
"\t return start + step * i;\n", | |
"\t });\n", | |
"\t }\n", | |
"\t scale.domain = function(x) {\n", | |
"\t if (!arguments.length) return domain;\n", | |
"\t domain = [];\n", | |
"\t index = new d3_Map();\n", | |
"\t var i = -1, n = x.length, xi;\n", | |
"\t while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));\n", | |
"\t return scale[ranger.t].apply(scale, ranger.a);\n", | |
"\t };\n", | |
"\t scale.range = function(x) {\n", | |
"\t if (!arguments.length) return range;\n", | |
"\t range = x;\n", | |
"\t rangeBand = 0;\n", | |
"\t ranger = {\n", | |
"\t t: \"range\",\n", | |
"\t a: arguments\n", | |
"\t };\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.rangePoints = function(x, padding) {\n", | |
"\t if (arguments.length < 2) padding = 0;\n", | |
"\t var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2, \n", | |
"\t 0) : (stop - start) / (domain.length - 1 + padding);\n", | |
"\t range = steps(start + step * padding / 2, step);\n", | |
"\t rangeBand = 0;\n", | |
"\t ranger = {\n", | |
"\t t: \"rangePoints\",\n", | |
"\t a: arguments\n", | |
"\t };\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.rangeRoundPoints = function(x, padding) {\n", | |
"\t if (arguments.length < 2) padding = 0;\n", | |
"\t var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2), \n", | |
"\t 0) : (stop - start) / (domain.length - 1 + padding) | 0;\n", | |
"\t range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step);\n", | |
"\t rangeBand = 0;\n", | |
"\t ranger = {\n", | |
"\t t: \"rangeRoundPoints\",\n", | |
"\t a: arguments\n", | |
"\t };\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.rangeBands = function(x, padding, outerPadding) {\n", | |
"\t if (arguments.length < 2) padding = 0;\n", | |
"\t if (arguments.length < 3) outerPadding = padding;\n", | |
"\t var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding);\n", | |
"\t range = steps(start + step * outerPadding, step);\n", | |
"\t if (reverse) range.reverse();\n", | |
"\t rangeBand = step * (1 - padding);\n", | |
"\t ranger = {\n", | |
"\t t: \"rangeBands\",\n", | |
"\t a: arguments\n", | |
"\t };\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.rangeRoundBands = function(x, padding, outerPadding) {\n", | |
"\t if (arguments.length < 2) padding = 0;\n", | |
"\t if (arguments.length < 3) outerPadding = padding;\n", | |
"\t var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding));\n", | |
"\t range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);\n", | |
"\t if (reverse) range.reverse();\n", | |
"\t rangeBand = Math.round(step * (1 - padding));\n", | |
"\t ranger = {\n", | |
"\t t: \"rangeRoundBands\",\n", | |
"\t a: arguments\n", | |
"\t };\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.rangeBand = function() {\n", | |
"\t return rangeBand;\n", | |
"\t };\n", | |
"\t scale.rangeExtent = function() {\n", | |
"\t return d3_scaleExtent(ranger.a[0]);\n", | |
"\t };\n", | |
"\t scale.copy = function() {\n", | |
"\t return d3_scale_ordinal(domain, ranger);\n", | |
"\t };\n", | |
"\t return scale.domain(domain);\n", | |
"\t }\n", | |
"\t d3.scale.category10 = function() {\n", | |
"\t return d3.scale.ordinal().range(d3_category10);\n", | |
"\t };\n", | |
"\t d3.scale.category20 = function() {\n", | |
"\t return d3.scale.ordinal().range(d3_category20);\n", | |
"\t };\n", | |
"\t d3.scale.category20b = function() {\n", | |
"\t return d3.scale.ordinal().range(d3_category20b);\n", | |
"\t };\n", | |
"\t d3.scale.category20c = function() {\n", | |
"\t return d3.scale.ordinal().range(d3_category20c);\n", | |
"\t };\n", | |
"\t var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString);\n", | |
"\t var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString);\n", | |
"\t var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString);\n", | |
"\t var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString);\n", | |
"\t d3.scale.quantile = function() {\n", | |
"\t return d3_scale_quantile([], []);\n", | |
"\t };\n", | |
"\t function d3_scale_quantile(domain, range) {\n", | |
"\t var thresholds;\n", | |
"\t function rescale() {\n", | |
"\t var k = 0, q = range.length;\n", | |
"\t thresholds = [];\n", | |
"\t while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);\n", | |
"\t return scale;\n", | |
"\t }\n", | |
"\t function scale(x) {\n", | |
"\t if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)];\n", | |
"\t }\n", | |
"\t scale.domain = function(x) {\n", | |
"\t if (!arguments.length) return domain;\n", | |
"\t domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending);\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.range = function(x) {\n", | |
"\t if (!arguments.length) return range;\n", | |
"\t range = x;\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.quantiles = function() {\n", | |
"\t return thresholds;\n", | |
"\t };\n", | |
"\t scale.invertExtent = function(y) {\n", | |
"\t y = range.indexOf(y);\n", | |
"\t return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ];\n", | |
"\t };\n", | |
"\t scale.copy = function() {\n", | |
"\t return d3_scale_quantile(domain, range);\n", | |
"\t };\n", | |
"\t return rescale();\n", | |
"\t }\n", | |
"\t d3.scale.quantize = function() {\n", | |
"\t return d3_scale_quantize(0, 1, [ 0, 1 ]);\n", | |
"\t };\n", | |
"\t function d3_scale_quantize(x0, x1, range) {\n", | |
"\t var kx, i;\n", | |
"\t function scale(x) {\n", | |
"\t return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];\n", | |
"\t }\n", | |
"\t function rescale() {\n", | |
"\t kx = range.length / (x1 - x0);\n", | |
"\t i = range.length - 1;\n", | |
"\t return scale;\n", | |
"\t }\n", | |
"\t scale.domain = function(x) {\n", | |
"\t if (!arguments.length) return [ x0, x1 ];\n", | |
"\t x0 = +x[0];\n", | |
"\t x1 = +x[x.length - 1];\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.range = function(x) {\n", | |
"\t if (!arguments.length) return range;\n", | |
"\t range = x;\n", | |
"\t return rescale();\n", | |
"\t };\n", | |
"\t scale.invertExtent = function(y) {\n", | |
"\t y = range.indexOf(y);\n", | |
"\t y = y < 0 ? NaN : y / kx + x0;\n", | |
"\t return [ y, y + 1 / kx ];\n", | |
"\t };\n", | |
"\t scale.copy = function() {\n", | |
"\t return d3_scale_quantize(x0, x1, range);\n", | |
"\t };\n", | |
"\t return rescale();\n", | |
"\t }\n", | |
"\t d3.scale.threshold = function() {\n", | |
"\t return d3_scale_threshold([ .5 ], [ 0, 1 ]);\n", | |
"\t };\n", | |
"\t function d3_scale_threshold(domain, range) {\n", | |
"\t function scale(x) {\n", | |
"\t if (x <= x) return range[d3.bisect(domain, x)];\n", | |
"\t }\n", | |
"\t scale.domain = function(_) {\n", | |
"\t if (!arguments.length) return domain;\n", | |
"\t domain = _;\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.range = function(_) {\n", | |
"\t if (!arguments.length) return range;\n", | |
"\t range = _;\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t scale.invertExtent = function(y) {\n", | |
"\t y = range.indexOf(y);\n", | |
"\t return [ domain[y - 1], domain[y] ];\n", | |
"\t };\n", | |
"\t scale.copy = function() {\n", | |
"\t return d3_scale_threshold(domain, range);\n", | |
"\t };\n", | |
"\t return scale;\n", | |
"\t }\n", | |
"\t d3.scale.identity = function() {\n", | |
"\t return d3_scale_identity([ 0, 1 ]);\n", | |
"\t };\n", | |
"\t function d3_scale_identity(domain) {\n", | |
"\t function identity(x) {\n", | |
"\t return +x;\n", | |
"\t }\n", | |
"\t identity.invert = identity;\n", | |
"\t identity.domain = identity.range = function(x) {\n", | |
"\t if (!arguments.length) return domain;\n", | |
"\t domain = x.map(identity);\n", | |
"\t return identity;\n", | |
"\t };\n", | |
"\t identity.ticks = function(m) {\n", | |
"\t return d3_scale_linearTicks(domain, m);\n", | |
"\t };\n", | |
"\t identity.tickFormat = function(m, format) {\n", | |
"\t return d3_scale_linearTickFormat(domain, m, format);\n", | |
"\t };\n", | |
"\t identity.copy = function() {\n", | |
"\t return d3_scale_identity(domain);\n", | |
"\t };\n", | |
"\t return identity;\n", | |
"\t }\n", | |
"\t d3.svg = {};\n", | |
"\t function d3_zero() {\n", | |
"\t return 0;\n", | |
"\t }\n", | |
"\t d3.svg.arc = function() {\n", | |
"\t var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, cornerRadius = d3_zero, padRadius = d3_svg_arcAuto, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle, padAngle = d3_svg_arcPadAngle;\n", | |
"\t function arc() {\n", | |
"\t var r0 = Math.max(0, +innerRadius.apply(this, arguments)), r1 = Math.max(0, +outerRadius.apply(this, arguments)), a0 = startAngle.apply(this, arguments) - halfπ, a1 = endAngle.apply(this, arguments) - halfπ, da = Math.abs(a1 - a0), cw = a0 > a1 ? 0 : 1;\n", | |
"\t if (r1 < r0) rc = r1, r1 = r0, r0 = rc;\n", | |
"\t if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : \"\") + \"Z\";\n", | |
"\t var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = [];\n", | |
"\t if (ap = (+padAngle.apply(this, arguments) || 0) / 2) {\n", | |
"\t rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments);\n", | |
"\t if (!cw) p1 *= -1;\n", | |
"\t if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap));\n", | |
"\t if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap));\n", | |
"\t }\n", | |
"\t if (r1) {\n", | |
"\t x0 = r1 * Math.cos(a0 + p1);\n", | |
"\t y0 = r1 * Math.sin(a0 + p1);\n", | |
"\t x1 = r1 * Math.cos(a1 - p1);\n", | |
"\t y1 = r1 * Math.sin(a1 - p1);\n", | |
"\t var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1;\n", | |
"\t if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) {\n", | |
"\t var h1 = (a0 + a1) / 2;\n", | |
"\t x0 = r1 * Math.cos(h1);\n", | |
"\t y0 = r1 * Math.sin(h1);\n", | |
"\t x1 = y1 = null;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t x0 = y0 = 0;\n", | |
"\t }\n", | |
"\t if (r0) {\n", | |
"\t x2 = r0 * Math.cos(a1 - p0);\n", | |
"\t y2 = r0 * Math.sin(a1 - p0);\n", | |
"\t x3 = r0 * Math.cos(a0 + p0);\n", | |
"\t y3 = r0 * Math.sin(a0 + p0);\n", | |
"\t var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1;\n", | |
"\t if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) {\n", | |
"\t var h0 = (a0 + a1) / 2;\n", | |
"\t x2 = r0 * Math.cos(h0);\n", | |
"\t y2 = r0 * Math.sin(h0);\n", | |
"\t x3 = y3 = null;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t x2 = y2 = 0;\n", | |
"\t }\n", | |
"\t if (da > ε && (rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {\n", | |
"\t cr = r0 < r1 ^ cw ? 0 : 1;\n", | |
"\t var rc1 = rc, rc0 = rc;\n", | |
"\t if (da < π) {\n", | |
"\t var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]);\n", | |
"\t rc0 = Math.min(rc, (r0 - lc) / (kc - 1));\n", | |
"\t rc1 = Math.min(rc, (r1 - lc) / (kc + 1));\n", | |
"\t }\n", | |
"\t if (x1 != null) {\n", | |
"\t var t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw);\n", | |
"\t if (rc === rc1) {\n", | |
"\t path.push(\"M\", t30[0], \"A\", rc1, \",\", rc1, \" 0 0,\", cr, \" \", t30[1], \"A\", r1, \",\", r1, \" 0 \", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), \",\", cw, \" \", t12[1], \"A\", rc1, \",\", rc1, \" 0 0,\", cr, \" \", t12[0]);\n", | |
"\t } else {\n", | |
"\t path.push(\"M\", t30[0], \"A\", rc1, \",\", rc1, \" 0 1,\", cr, \" \", t12[0]);\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t path.push(\"M\", x0, \",\", y0);\n", | |
"\t }\n", | |
"\t if (x3 != null) {\n", | |
"\t var t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw);\n", | |
"\t if (rc === rc0) {\n", | |
"\t path.push(\"L\", t21[0], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t21[1], \"A\", r0, \",\", r0, \" 0 \", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), \",\", 1 - cw, \" \", t03[1], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t03[0]);\n", | |
"\t } else {\n", | |
"\t path.push(\"L\", t21[0], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t03[0]);\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t path.push(\"L\", x2, \",\", y2);\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t path.push(\"M\", x0, \",\", y0);\n", | |
"\t if (x1 != null) path.push(\"A\", r1, \",\", r1, \" 0 \", l1, \",\", cw, \" \", x1, \",\", y1);\n", | |
"\t path.push(\"L\", x2, \",\", y2);\n", | |
"\t if (x3 != null) path.push(\"A\", r0, \",\", r0, \" 0 \", l0, \",\", 1 - cw, \" \", x3, \",\", y3);\n", | |
"\t }\n", | |
"\t path.push(\"Z\");\n", | |
"\t return path.join(\"\");\n", | |
"\t }\n", | |
"\t function circleSegment(r1, cw) {\n", | |
"\t return \"M0,\" + r1 + \"A\" + r1 + \",\" + r1 + \" 0 1,\" + cw + \" 0,\" + -r1 + \"A\" + r1 + \",\" + r1 + \" 0 1,\" + cw + \" 0,\" + r1;\n", | |
"\t }\n", | |
"\t arc.innerRadius = function(v) {\n", | |
"\t if (!arguments.length) return innerRadius;\n", | |
"\t innerRadius = d3_functor(v);\n", | |
"\t return arc;\n", | |
"\t };\n", | |
"\t arc.outerRadius = function(v) {\n", | |
"\t if (!arguments.length) return outerRadius;\n", | |
"\t outerRadius = d3_functor(v);\n", | |
"\t return arc;\n", | |
"\t };\n", | |
"\t arc.cornerRadius = function(v) {\n", | |
"\t if (!arguments.length) return cornerRadius;\n", | |
"\t cornerRadius = d3_functor(v);\n", | |
"\t return arc;\n", | |
"\t };\n", | |
"\t arc.padRadius = function(v) {\n", | |
"\t if (!arguments.length) return padRadius;\n", | |
"\t padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v);\n", | |
"\t return arc;\n", | |
"\t };\n", | |
"\t arc.startAngle = function(v) {\n", | |
"\t if (!arguments.length) return startAngle;\n", | |
"\t startAngle = d3_functor(v);\n", | |
"\t return arc;\n", | |
"\t };\n", | |
"\t arc.endAngle = function(v) {\n", | |
"\t if (!arguments.length) return endAngle;\n", | |
"\t endAngle = d3_functor(v);\n", | |
"\t return arc;\n", | |
"\t };\n", | |
"\t arc.padAngle = function(v) {\n", | |
"\t if (!arguments.length) return padAngle;\n", | |
"\t padAngle = d3_functor(v);\n", | |
"\t return arc;\n", | |
"\t };\n", | |
"\t arc.centroid = function() {\n", | |
"\t var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ;\n", | |
"\t return [ Math.cos(a) * r, Math.sin(a) * r ];\n", | |
"\t };\n", | |
"\t return arc;\n", | |
"\t };\n", | |
"\t var d3_svg_arcAuto = \"auto\";\n", | |
"\t function d3_svg_arcInnerRadius(d) {\n", | |
"\t return d.innerRadius;\n", | |
"\t }\n", | |
"\t function d3_svg_arcOuterRadius(d) {\n", | |
"\t return d.outerRadius;\n", | |
"\t }\n", | |
"\t function d3_svg_arcStartAngle(d) {\n", | |
"\t return d.startAngle;\n", | |
"\t }\n", | |
"\t function d3_svg_arcEndAngle(d) {\n", | |
"\t return d.endAngle;\n", | |
"\t }\n", | |
"\t function d3_svg_arcPadAngle(d) {\n", | |
"\t return d && d.padAngle;\n", | |
"\t }\n", | |
"\t function d3_svg_arcSweep(x0, y0, x1, y1) {\n", | |
"\t return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;\n", | |
"\t }\n", | |
"\t function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {\n", | |
"\t var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3;\n", | |
"\t if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;\n", | |
"\t return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];\n", | |
"\t }\n", | |
"\t function d3_svg_line(projection) {\n", | |
"\t var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;\n", | |
"\t function line(data) {\n", | |
"\t var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y);\n", | |
"\t function segment() {\n", | |
"\t segments.push(\"M\", interpolate(projection(points), tension));\n", | |
"\t }\n", | |
"\t while (++i < n) {\n", | |
"\t if (defined.call(this, d = data[i], i)) {\n", | |
"\t points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]);\n", | |
"\t } else if (points.length) {\n", | |
"\t segment();\n", | |
"\t points = [];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (points.length) segment();\n", | |
"\t return segments.length ? segments.join(\"\") : null;\n", | |
"\t }\n", | |
"\t line.x = function(_) {\n", | |
"\t if (!arguments.length) return x;\n", | |
"\t x = _;\n", | |
"\t return line;\n", | |
"\t };\n", | |
"\t line.y = function(_) {\n", | |
"\t if (!arguments.length) return y;\n", | |
"\t y = _;\n", | |
"\t return line;\n", | |
"\t };\n", | |
"\t line.defined = function(_) {\n", | |
"\t if (!arguments.length) return defined;\n", | |
"\t defined = _;\n", | |
"\t return line;\n", | |
"\t };\n", | |
"\t line.interpolate = function(_) {\n", | |
"\t if (!arguments.length) return interpolateKey;\n", | |
"\t if (typeof _ === \"function\") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;\n", | |
"\t return line;\n", | |
"\t };\n", | |
"\t line.tension = function(_) {\n", | |
"\t if (!arguments.length) return tension;\n", | |
"\t tension = _;\n", | |
"\t return line;\n", | |
"\t };\n", | |
"\t return line;\n", | |
"\t }\n", | |
"\t d3.svg.line = function() {\n", | |
"\t return d3_svg_line(d3_identity);\n", | |
"\t };\n", | |
"\t var d3_svg_lineInterpolators = d3.map({\n", | |
"\t linear: d3_svg_lineLinear,\n", | |
"\t \"linear-closed\": d3_svg_lineLinearClosed,\n", | |
"\t step: d3_svg_lineStep,\n", | |
"\t \"step-before\": d3_svg_lineStepBefore,\n", | |
"\t \"step-after\": d3_svg_lineStepAfter,\n", | |
"\t basis: d3_svg_lineBasis,\n", | |
"\t \"basis-open\": d3_svg_lineBasisOpen,\n", | |
"\t \"basis-closed\": d3_svg_lineBasisClosed,\n", | |
"\t bundle: d3_svg_lineBundle,\n", | |
"\t cardinal: d3_svg_lineCardinal,\n", | |
"\t \"cardinal-open\": d3_svg_lineCardinalOpen,\n", | |
"\t \"cardinal-closed\": d3_svg_lineCardinalClosed,\n", | |
"\t monotone: d3_svg_lineMonotone\n", | |
"\t });\n", | |
"\t d3_svg_lineInterpolators.forEach(function(key, value) {\n", | |
"\t value.key = key;\n", | |
"\t value.closed = /-closed$/.test(key);\n", | |
"\t });\n", | |
"\t function d3_svg_lineLinear(points) {\n", | |
"\t return points.length > 1 ? points.join(\"L\") : points + \"Z\";\n", | |
"\t }\n", | |
"\t function d3_svg_lineLinearClosed(points) {\n", | |
"\t return points.join(\"L\") + \"Z\";\n", | |
"\t }\n", | |
"\t function d3_svg_lineStep(points) {\n", | |
"\t var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n", | |
"\t while (++i < n) path.push(\"H\", (p[0] + (p = points[i])[0]) / 2, \"V\", p[1]);\n", | |
"\t if (n > 1) path.push(\"H\", p[0]);\n", | |
"\t return path.join(\"\");\n", | |
"\t }\n", | |
"\t function d3_svg_lineStepBefore(points) {\n", | |
"\t var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n", | |
"\t while (++i < n) path.push(\"V\", (p = points[i])[1], \"H\", p[0]);\n", | |
"\t return path.join(\"\");\n", | |
"\t }\n", | |
"\t function d3_svg_lineStepAfter(points) {\n", | |
"\t var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n", | |
"\t while (++i < n) path.push(\"H\", (p = points[i])[0], \"V\", p[1]);\n", | |
"\t return path.join(\"\");\n", | |
"\t }\n", | |
"\t function d3_svg_lineCardinalOpen(points, tension) {\n", | |
"\t return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));\n", | |
"\t }\n", | |
"\t function d3_svg_lineCardinalClosed(points, tension) {\n", | |
"\t return points.length < 3 ? d3_svg_lineLinearClosed(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), \n", | |
"\t points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));\n", | |
"\t }\n", | |
"\t function d3_svg_lineCardinal(points, tension) {\n", | |
"\t return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension));\n", | |
"\t }\n", | |
"\t function d3_svg_lineHermite(points, tangents) {\n", | |
"\t if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) {\n", | |
"\t return d3_svg_lineLinear(points);\n", | |
"\t }\n", | |
"\t var quad = points.length != tangents.length, path = \"\", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1;\n", | |
"\t if (quad) {\n", | |
"\t path += \"Q\" + (p[0] - t0[0] * 2 / 3) + \",\" + (p[1] - t0[1] * 2 / 3) + \",\" + p[0] + \",\" + p[1];\n", | |
"\t p0 = points[1];\n", | |
"\t pi = 2;\n", | |
"\t }\n", | |
"\t if (tangents.length > 1) {\n", | |
"\t t = tangents[1];\n", | |
"\t p = points[pi];\n", | |
"\t pi++;\n", | |
"\t path += \"C\" + (p0[0] + t0[0]) + \",\" + (p0[1] + t0[1]) + \",\" + (p[0] - t[0]) + \",\" + (p[1] - t[1]) + \",\" + p[0] + \",\" + p[1];\n", | |
"\t for (var i = 2; i < tangents.length; i++, pi++) {\n", | |
"\t p = points[pi];\n", | |
"\t t = tangents[i];\n", | |
"\t path += \"S\" + (p[0] - t[0]) + \",\" + (p[1] - t[1]) + \",\" + p[0] + \",\" + p[1];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (quad) {\n", | |
"\t var lp = points[pi];\n", | |
"\t path += \"Q\" + (p[0] + t[0] * 2 / 3) + \",\" + (p[1] + t[1] * 2 / 3) + \",\" + lp[0] + \",\" + lp[1];\n", | |
"\t }\n", | |
"\t return path;\n", | |
"\t }\n", | |
"\t function d3_svg_lineCardinalTangents(points, tension) {\n", | |
"\t var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length;\n", | |
"\t while (++i < n) {\n", | |
"\t p0 = p1;\n", | |
"\t p1 = p2;\n", | |
"\t p2 = points[i];\n", | |
"\t tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]);\n", | |
"\t }\n", | |
"\t return tangents;\n", | |
"\t }\n", | |
"\t function d3_svg_lineBasis(points) {\n", | |
"\t if (points.length < 3) return d3_svg_lineLinear(points);\n", | |
"\t var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, \",\", y0, \"L\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];\n", | |
"\t points.push(points[n - 1]);\n", | |
"\t while (++i <= n) {\n", | |
"\t pi = points[i];\n", | |
"\t px.shift();\n", | |
"\t px.push(pi[0]);\n", | |
"\t py.shift();\n", | |
"\t py.push(pi[1]);\n", | |
"\t d3_svg_lineBasisBezier(path, px, py);\n", | |
"\t }\n", | |
"\t points.pop();\n", | |
"\t path.push(\"L\", pi);\n", | |
"\t return path.join(\"\");\n", | |
"\t }\n", | |
"\t function d3_svg_lineBasisOpen(points) {\n", | |
"\t if (points.length < 4) return d3_svg_lineLinear(points);\n", | |
"\t var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ];\n", | |
"\t while (++i < 3) {\n", | |
"\t pi = points[i];\n", | |
"\t px.push(pi[0]);\n", | |
"\t py.push(pi[1]);\n", | |
"\t }\n", | |
"\t path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + \",\" + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));\n", | |
"\t --i;\n", | |
"\t while (++i < n) {\n", | |
"\t pi = points[i];\n", | |
"\t px.shift();\n", | |
"\t px.push(pi[0]);\n", | |
"\t py.shift();\n", | |
"\t py.push(pi[1]);\n", | |
"\t d3_svg_lineBasisBezier(path, px, py);\n", | |
"\t }\n", | |
"\t return path.join(\"\");\n", | |
"\t }\n", | |
"\t function d3_svg_lineBasisClosed(points) {\n", | |
"\t var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = [];\n", | |
"\t while (++i < 4) {\n", | |
"\t pi = points[i % n];\n", | |
"\t px.push(pi[0]);\n", | |
"\t py.push(pi[1]);\n", | |
"\t }\n", | |
"\t path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];\n", | |
"\t --i;\n", | |
"\t while (++i < m) {\n", | |
"\t pi = points[i % n];\n", | |
"\t px.shift();\n", | |
"\t px.push(pi[0]);\n", | |
"\t py.shift();\n", | |
"\t py.push(pi[1]);\n", | |
"\t d3_svg_lineBasisBezier(path, px, py);\n", | |
"\t }\n", | |
"\t return path.join(\"\");\n", | |
"\t }\n", | |
"\t function d3_svg_lineBundle(points, tension) {\n", | |
"\t var n = points.length - 1;\n", | |
"\t if (n) {\n", | |
"\t var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t;\n", | |
"\t while (++i <= n) {\n", | |
"\t p = points[i];\n", | |
"\t t = i / n;\n", | |
"\t p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);\n", | |
"\t p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_svg_lineBasis(points);\n", | |
"\t }\n", | |
"\t function d3_svg_lineDot4(a, b) {\n", | |
"\t return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n", | |
"\t }\n", | |
"\t var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ];\n", | |
"\t function d3_svg_lineBasisBezier(path, x, y) {\n", | |
"\t path.push(\"C\", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y));\n", | |
"\t }\n", | |
"\t function d3_svg_lineSlope(p0, p1) {\n", | |
"\t return (p1[1] - p0[1]) / (p1[0] - p0[0]);\n", | |
"\t }\n", | |
"\t function d3_svg_lineFiniteDifferences(points) {\n", | |
"\t var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1);\n", | |
"\t while (++i < j) {\n", | |
"\t m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2;\n", | |
"\t }\n", | |
"\t m[i] = d;\n", | |
"\t return m;\n", | |
"\t }\n", | |
"\t function d3_svg_lineMonotoneTangents(points) {\n", | |
"\t var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1;\n", | |
"\t while (++i < j) {\n", | |
"\t d = d3_svg_lineSlope(points[i], points[i + 1]);\n", | |
"\t if (abs(d) < ε) {\n", | |
"\t m[i] = m[i + 1] = 0;\n", | |
"\t } else {\n", | |
"\t a = m[i] / d;\n", | |
"\t b = m[i + 1] / d;\n", | |
"\t s = a * a + b * b;\n", | |
"\t if (s > 9) {\n", | |
"\t s = d * 3 / Math.sqrt(s);\n", | |
"\t m[i] = s * a;\n", | |
"\t m[i + 1] = s * b;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t i = -1;\n", | |
"\t while (++i <= j) {\n", | |
"\t s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));\n", | |
"\t tangents.push([ s || 0, m[i] * s || 0 ]);\n", | |
"\t }\n", | |
"\t return tangents;\n", | |
"\t }\n", | |
"\t function d3_svg_lineMonotone(points) {\n", | |
"\t return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));\n", | |
"\t }\n", | |
"\t d3.svg.line.radial = function() {\n", | |
"\t var line = d3_svg_line(d3_svg_lineRadial);\n", | |
"\t line.radius = line.x, delete line.x;\n", | |
"\t line.angle = line.y, delete line.y;\n", | |
"\t return line;\n", | |
"\t };\n", | |
"\t function d3_svg_lineRadial(points) {\n", | |
"\t var point, i = -1, n = points.length, r, a;\n", | |
"\t while (++i < n) {\n", | |
"\t point = points[i];\n", | |
"\t r = point[0];\n", | |
"\t a = point[1] - halfπ;\n", | |
"\t point[0] = r * Math.cos(a);\n", | |
"\t point[1] = r * Math.sin(a);\n", | |
"\t }\n", | |
"\t return points;\n", | |
"\t }\n", | |
"\t function d3_svg_area(projection) {\n", | |
"\t var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = \"L\", tension = .7;\n", | |
"\t function area(data) {\n", | |
"\t var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() {\n", | |
"\t return x;\n", | |
"\t } : d3_functor(x1), fy1 = y0 === y1 ? function() {\n", | |
"\t return y;\n", | |
"\t } : d3_functor(y1), x, y;\n", | |
"\t function segment() {\n", | |
"\t segments.push(\"M\", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), \"Z\");\n", | |
"\t }\n", | |
"\t while (++i < n) {\n", | |
"\t if (defined.call(this, d = data[i], i)) {\n", | |
"\t points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]);\n", | |
"\t points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]);\n", | |
"\t } else if (points0.length) {\n", | |
"\t segment();\n", | |
"\t points0 = [];\n", | |
"\t points1 = [];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (points0.length) segment();\n", | |
"\t return segments.length ? segments.join(\"\") : null;\n", | |
"\t }\n", | |
"\t area.x = function(_) {\n", | |
"\t if (!arguments.length) return x1;\n", | |
"\t x0 = x1 = _;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t area.x0 = function(_) {\n", | |
"\t if (!arguments.length) return x0;\n", | |
"\t x0 = _;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t area.x1 = function(_) {\n", | |
"\t if (!arguments.length) return x1;\n", | |
"\t x1 = _;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t area.y = function(_) {\n", | |
"\t if (!arguments.length) return y1;\n", | |
"\t y0 = y1 = _;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t area.y0 = function(_) {\n", | |
"\t if (!arguments.length) return y0;\n", | |
"\t y0 = _;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t area.y1 = function(_) {\n", | |
"\t if (!arguments.length) return y1;\n", | |
"\t y1 = _;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t area.defined = function(_) {\n", | |
"\t if (!arguments.length) return defined;\n", | |
"\t defined = _;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t area.interpolate = function(_) {\n", | |
"\t if (!arguments.length) return interpolateKey;\n", | |
"\t if (typeof _ === \"function\") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;\n", | |
"\t interpolateReverse = interpolate.reverse || interpolate;\n", | |
"\t L = interpolate.closed ? \"M\" : \"L\";\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t area.tension = function(_) {\n", | |
"\t if (!arguments.length) return tension;\n", | |
"\t tension = _;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t return area;\n", | |
"\t }\n", | |
"\t d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;\n", | |
"\t d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;\n", | |
"\t d3.svg.area = function() {\n", | |
"\t return d3_svg_area(d3_identity);\n", | |
"\t };\n", | |
"\t d3.svg.area.radial = function() {\n", | |
"\t var area = d3_svg_area(d3_svg_lineRadial);\n", | |
"\t area.radius = area.x, delete area.x;\n", | |
"\t area.innerRadius = area.x0, delete area.x0;\n", | |
"\t area.outerRadius = area.x1, delete area.x1;\n", | |
"\t area.angle = area.y, delete area.y;\n", | |
"\t area.startAngle = area.y0, delete area.y0;\n", | |
"\t area.endAngle = area.y1, delete area.y1;\n", | |
"\t return area;\n", | |
"\t };\n", | |
"\t d3.svg.chord = function() {\n", | |
"\t var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;\n", | |
"\t function chord(d, i) {\n", | |
"\t var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i);\n", | |
"\t return \"M\" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + \"Z\";\n", | |
"\t }\n", | |
"\t function subgroup(self, f, d, i) {\n", | |
"\t var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) - halfπ, a1 = endAngle.call(self, subgroup, i) - halfπ;\n", | |
"\t return {\n", | |
"\t r: r,\n", | |
"\t a0: a0,\n", | |
"\t a1: a1,\n", | |
"\t p0: [ r * Math.cos(a0), r * Math.sin(a0) ],\n", | |
"\t p1: [ r * Math.cos(a1), r * Math.sin(a1) ]\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function equals(a, b) {\n", | |
"\t return a.a0 == b.a0 && a.a1 == b.a1;\n", | |
"\t }\n", | |
"\t function arc(r, p, a) {\n", | |
"\t return \"A\" + r + \",\" + r + \" 0 \" + +(a > π) + \",1 \" + p;\n", | |
"\t }\n", | |
"\t function curve(r0, p0, r1, p1) {\n", | |
"\t return \"Q 0,0 \" + p1;\n", | |
"\t }\n", | |
"\t chord.radius = function(v) {\n", | |
"\t if (!arguments.length) return radius;\n", | |
"\t radius = d3_functor(v);\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.source = function(v) {\n", | |
"\t if (!arguments.length) return source;\n", | |
"\t source = d3_functor(v);\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.target = function(v) {\n", | |
"\t if (!arguments.length) return target;\n", | |
"\t target = d3_functor(v);\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.startAngle = function(v) {\n", | |
"\t if (!arguments.length) return startAngle;\n", | |
"\t startAngle = d3_functor(v);\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t chord.endAngle = function(v) {\n", | |
"\t if (!arguments.length) return endAngle;\n", | |
"\t endAngle = d3_functor(v);\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t return chord;\n", | |
"\t };\n", | |
"\t function d3_svg_chordRadius(d) {\n", | |
"\t return d.radius;\n", | |
"\t }\n", | |
"\t d3.svg.diagonal = function() {\n", | |
"\t var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection;\n", | |
"\t function diagonal(d, i) {\n", | |
"\t var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, {\n", | |
"\t x: p0.x,\n", | |
"\t y: m\n", | |
"\t }, {\n", | |
"\t x: p3.x,\n", | |
"\t y: m\n", | |
"\t }, p3 ];\n", | |
"\t p = p.map(projection);\n", | |
"\t return \"M\" + p[0] + \"C\" + p[1] + \" \" + p[2] + \" \" + p[3];\n", | |
"\t }\n", | |
"\t diagonal.source = function(x) {\n", | |
"\t if (!arguments.length) return source;\n", | |
"\t source = d3_functor(x);\n", | |
"\t return diagonal;\n", | |
"\t };\n", | |
"\t diagonal.target = function(x) {\n", | |
"\t if (!arguments.length) return target;\n", | |
"\t target = d3_functor(x);\n", | |
"\t return diagonal;\n", | |
"\t };\n", | |
"\t diagonal.projection = function(x) {\n", | |
"\t if (!arguments.length) return projection;\n", | |
"\t projection = x;\n", | |
"\t return diagonal;\n", | |
"\t };\n", | |
"\t return diagonal;\n", | |
"\t };\n", | |
"\t function d3_svg_diagonalProjection(d) {\n", | |
"\t return [ d.x, d.y ];\n", | |
"\t }\n", | |
"\t d3.svg.diagonal.radial = function() {\n", | |
"\t var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection;\n", | |
"\t diagonal.projection = function(x) {\n", | |
"\t return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection;\n", | |
"\t };\n", | |
"\t return diagonal;\n", | |
"\t };\n", | |
"\t function d3_svg_diagonalRadialProjection(projection) {\n", | |
"\t return function() {\n", | |
"\t var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ;\n", | |
"\t return [ r * Math.cos(a), r * Math.sin(a) ];\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3.svg.symbol = function() {\n", | |
"\t var type = d3_svg_symbolType, size = d3_svg_symbolSize;\n", | |
"\t function symbol(d, i) {\n", | |
"\t return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i));\n", | |
"\t }\n", | |
"\t symbol.type = function(x) {\n", | |
"\t if (!arguments.length) return type;\n", | |
"\t type = d3_functor(x);\n", | |
"\t return symbol;\n", | |
"\t };\n", | |
"\t symbol.size = function(x) {\n", | |
"\t if (!arguments.length) return size;\n", | |
"\t size = d3_functor(x);\n", | |
"\t return symbol;\n", | |
"\t };\n", | |
"\t return symbol;\n", | |
"\t };\n", | |
"\t function d3_svg_symbolSize() {\n", | |
"\t return 64;\n", | |
"\t }\n", | |
"\t function d3_svg_symbolType() {\n", | |
"\t return \"circle\";\n", | |
"\t }\n", | |
"\t function d3_svg_symbolCircle(size) {\n", | |
"\t var r = Math.sqrt(size / π);\n", | |
"\t return \"M0,\" + r + \"A\" + r + \",\" + r + \" 0 1,1 0,\" + -r + \"A\" + r + \",\" + r + \" 0 1,1 0,\" + r + \"Z\";\n", | |
"\t }\n", | |
"\t var d3_svg_symbols = d3.map({\n", | |
"\t circle: d3_svg_symbolCircle,\n", | |
"\t cross: function(size) {\n", | |
"\t var r = Math.sqrt(size / 5) / 2;\n", | |
"\t return \"M\" + -3 * r + \",\" + -r + \"H\" + -r + \"V\" + -3 * r + \"H\" + r + \"V\" + -r + \"H\" + 3 * r + \"V\" + r + \"H\" + r + \"V\" + 3 * r + \"H\" + -r + \"V\" + r + \"H\" + -3 * r + \"Z\";\n", | |
"\t },\n", | |
"\t diamond: function(size) {\n", | |
"\t var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30;\n", | |
"\t return \"M0,\" + -ry + \"L\" + rx + \",0\" + \" 0,\" + ry + \" \" + -rx + \",0\" + \"Z\";\n", | |
"\t },\n", | |
"\t square: function(size) {\n", | |
"\t var r = Math.sqrt(size) / 2;\n", | |
"\t return \"M\" + -r + \",\" + -r + \"L\" + r + \",\" + -r + \" \" + r + \",\" + r + \" \" + -r + \",\" + r + \"Z\";\n", | |
"\t },\n", | |
"\t \"triangle-down\": function(size) {\n", | |
"\t var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;\n", | |
"\t return \"M0,\" + ry + \"L\" + rx + \",\" + -ry + \" \" + -rx + \",\" + -ry + \"Z\";\n", | |
"\t },\n", | |
"\t \"triangle-up\": function(size) {\n", | |
"\t var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;\n", | |
"\t return \"M0,\" + -ry + \"L\" + rx + \",\" + ry + \" \" + -rx + \",\" + ry + \"Z\";\n", | |
"\t }\n", | |
"\t });\n", | |
"\t d3.svg.symbolTypes = d3_svg_symbols.keys();\n", | |
"\t var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);\n", | |
"\t d3_selectionPrototype.transition = function(name) {\n", | |
"\t var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || {\n", | |
"\t time: Date.now(),\n", | |
"\t ease: d3_ease_cubicInOut,\n", | |
"\t delay: 0,\n", | |
"\t duration: 250\n", | |
"\t };\n", | |
"\t for (var j = -1, m = this.length; ++j < m; ) {\n", | |
"\t subgroups.push(subgroup = []);\n", | |
"\t for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n", | |
"\t if (node = group[i]) d3_transitionNode(node, i, ns, id, transition);\n", | |
"\t subgroup.push(node);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_transition(subgroups, ns, id);\n", | |
"\t };\n", | |
"\t d3_selectionPrototype.interrupt = function(name) {\n", | |
"\t return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name)));\n", | |
"\t };\n", | |
"\t var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace());\n", | |
"\t function d3_selection_interruptNS(ns) {\n", | |
"\t return function() {\n", | |
"\t var lock, activeId, active;\n", | |
"\t if ((lock = this[ns]) && (active = lock[activeId = lock.active])) {\n", | |
"\t active.timer.c = null;\n", | |
"\t active.timer.t = NaN;\n", | |
"\t if (--lock.count) delete lock[activeId]; else delete this[ns];\n", | |
"\t lock.active += .5;\n", | |
"\t active.event && active.event.interrupt.call(this, this.__data__, active.index);\n", | |
"\t }\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function d3_transition(groups, ns, id) {\n", | |
"\t d3_subclass(groups, d3_transitionPrototype);\n", | |
"\t groups.namespace = ns;\n", | |
"\t groups.id = id;\n", | |
"\t return groups;\n", | |
"\t }\n", | |
"\t var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit;\n", | |
"\t d3_transitionPrototype.call = d3_selectionPrototype.call;\n", | |
"\t d3_transitionPrototype.empty = d3_selectionPrototype.empty;\n", | |
"\t d3_transitionPrototype.node = d3_selectionPrototype.node;\n", | |
"\t d3_transitionPrototype.size = d3_selectionPrototype.size;\n", | |
"\t d3.transition = function(selection, name) {\n", | |
"\t return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3.selection().transition(selection);\n", | |
"\t };\n", | |
"\t d3.transition.prototype = d3_transitionPrototype;\n", | |
"\t d3_transitionPrototype.select = function(selector) {\n", | |
"\t var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;\n", | |
"\t selector = d3_selection_selector(selector);\n", | |
"\t for (var j = -1, m = this.length; ++j < m; ) {\n", | |
"\t subgroups.push(subgroup = []);\n", | |
"\t for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n", | |
"\t if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {\n", | |
"\t if (\"__data__\" in node) subnode.__data__ = node.__data__;\n", | |
"\t d3_transitionNode(subnode, i, ns, id, node[ns][id]);\n", | |
"\t subgroup.push(subnode);\n", | |
"\t } else {\n", | |
"\t subgroup.push(null);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_transition(subgroups, ns, id);\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.selectAll = function(selector) {\n", | |
"\t var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;\n", | |
"\t selector = d3_selection_selectorAll(selector);\n", | |
"\t for (var j = -1, m = this.length; ++j < m; ) {\n", | |
"\t for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n", | |
"\t if (node = group[i]) {\n", | |
"\t transition = node[ns][id];\n", | |
"\t subnodes = selector.call(node, node.__data__, i, j);\n", | |
"\t subgroups.push(subgroup = []);\n", | |
"\t for (var k = -1, o = subnodes.length; ++k < o; ) {\n", | |
"\t if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);\n", | |
"\t subgroup.push(subnode);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_transition(subgroups, ns, id);\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.filter = function(filter) {\n", | |
"\t var subgroups = [], subgroup, group, node;\n", | |
"\t if (typeof filter !== \"function\") filter = d3_selection_filter(filter);\n", | |
"\t for (var j = 0, m = this.length; j < m; j++) {\n", | |
"\t subgroups.push(subgroup = []);\n", | |
"\t for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n", | |
"\t if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {\n", | |
"\t subgroup.push(node);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_transition(subgroups, this.namespace, this.id);\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.tween = function(name, tween) {\n", | |
"\t var id = this.id, ns = this.namespace;\n", | |
"\t if (arguments.length < 2) return this.node()[ns][id].tween.get(name);\n", | |
"\t return d3_selection_each(this, tween == null ? function(node) {\n", | |
"\t node[ns][id].tween.remove(name);\n", | |
"\t } : function(node) {\n", | |
"\t node[ns][id].tween.set(name, tween);\n", | |
"\t });\n", | |
"\t };\n", | |
"\t function d3_transition_tween(groups, name, value, tween) {\n", | |
"\t var id = groups.id, ns = groups.namespace;\n", | |
"\t return d3_selection_each(groups, typeof value === \"function\" ? function(node, i, j) {\n", | |
"\t node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j)));\n", | |
"\t } : (value = tween(value), function(node) {\n", | |
"\t node[ns][id].tween.set(name, value);\n", | |
"\t }));\n", | |
"\t }\n", | |
"\t d3_transitionPrototype.attr = function(nameNS, value) {\n", | |
"\t if (arguments.length < 2) {\n", | |
"\t for (value in nameNS) this.attr(value, nameNS[value]);\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t var interpolate = nameNS == \"transform\" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS);\n", | |
"\t function attrNull() {\n", | |
"\t this.removeAttribute(name);\n", | |
"\t }\n", | |
"\t function attrNullNS() {\n", | |
"\t this.removeAttributeNS(name.space, name.local);\n", | |
"\t }\n", | |
"\t function attrTween(b) {\n", | |
"\t return b == null ? attrNull : (b += \"\", function() {\n", | |
"\t var a = this.getAttribute(name), i;\n", | |
"\t return a !== b && (i = interpolate(a, b), function(t) {\n", | |
"\t this.setAttribute(name, i(t));\n", | |
"\t });\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function attrTweenNS(b) {\n", | |
"\t return b == null ? attrNullNS : (b += \"\", function() {\n", | |
"\t var a = this.getAttributeNS(name.space, name.local), i;\n", | |
"\t return a !== b && (i = interpolate(a, b), function(t) {\n", | |
"\t this.setAttributeNS(name.space, name.local, i(t));\n", | |
"\t });\n", | |
"\t });\n", | |
"\t }\n", | |
"\t return d3_transition_tween(this, \"attr.\" + nameNS, value, name.local ? attrTweenNS : attrTween);\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.attrTween = function(nameNS, tween) {\n", | |
"\t var name = d3.ns.qualify(nameNS);\n", | |
"\t function attrTween(d, i) {\n", | |
"\t var f = tween.call(this, d, i, this.getAttribute(name));\n", | |
"\t return f && function(t) {\n", | |
"\t this.setAttribute(name, f(t));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t function attrTweenNS(d, i) {\n", | |
"\t var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));\n", | |
"\t return f && function(t) {\n", | |
"\t this.setAttributeNS(name.space, name.local, f(t));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t return this.tween(\"attr.\" + nameNS, name.local ? attrTweenNS : attrTween);\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.style = function(name, value, priority) {\n", | |
"\t var n = arguments.length;\n", | |
"\t if (n < 3) {\n", | |
"\t if (typeof name !== \"string\") {\n", | |
"\t if (n < 2) value = \"\";\n", | |
"\t for (priority in name) this.style(priority, name[priority], value);\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t priority = \"\";\n", | |
"\t }\n", | |
"\t function styleNull() {\n", | |
"\t this.style.removeProperty(name);\n", | |
"\t }\n", | |
"\t function styleString(b) {\n", | |
"\t return b == null ? styleNull : (b += \"\", function() {\n", | |
"\t var a = d3_window(this).getComputedStyle(this, null).getPropertyValue(name), i;\n", | |
"\t return a !== b && (i = d3_interpolate(a, b), function(t) {\n", | |
"\t this.style.setProperty(name, i(t), priority);\n", | |
"\t });\n", | |
"\t });\n", | |
"\t }\n", | |
"\t return d3_transition_tween(this, \"style.\" + name, value, styleString);\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.styleTween = function(name, tween, priority) {\n", | |
"\t if (arguments.length < 3) priority = \"\";\n", | |
"\t function styleTween(d, i) {\n", | |
"\t var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name));\n", | |
"\t return f && function(t) {\n", | |
"\t this.style.setProperty(name, f(t), priority);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t return this.tween(\"style.\" + name, styleTween);\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.text = function(value) {\n", | |
"\t return d3_transition_tween(this, \"text\", value, d3_transition_text);\n", | |
"\t };\n", | |
"\t function d3_transition_text(b) {\n", | |
"\t if (b == null) b = \"\";\n", | |
"\t return function() {\n", | |
"\t this.textContent = b;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t d3_transitionPrototype.remove = function() {\n", | |
"\t var ns = this.namespace;\n", | |
"\t return this.each(\"end.transition\", function() {\n", | |
"\t var p;\n", | |
"\t if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);\n", | |
"\t });\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.ease = function(value) {\n", | |
"\t var id = this.id, ns = this.namespace;\n", | |
"\t if (arguments.length < 1) return this.node()[ns][id].ease;\n", | |
"\t if (typeof value !== \"function\") value = d3.ease.apply(d3, arguments);\n", | |
"\t return d3_selection_each(this, function(node) {\n", | |
"\t node[ns][id].ease = value;\n", | |
"\t });\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.delay = function(value) {\n", | |
"\t var id = this.id, ns = this.namespace;\n", | |
"\t if (arguments.length < 1) return this.node()[ns][id].delay;\n", | |
"\t return d3_selection_each(this, typeof value === \"function\" ? function(node, i, j) {\n", | |
"\t node[ns][id].delay = +value.call(node, node.__data__, i, j);\n", | |
"\t } : (value = +value, function(node) {\n", | |
"\t node[ns][id].delay = value;\n", | |
"\t }));\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.duration = function(value) {\n", | |
"\t var id = this.id, ns = this.namespace;\n", | |
"\t if (arguments.length < 1) return this.node()[ns][id].duration;\n", | |
"\t return d3_selection_each(this, typeof value === \"function\" ? function(node, i, j) {\n", | |
"\t node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j));\n", | |
"\t } : (value = Math.max(1, value), function(node) {\n", | |
"\t node[ns][id].duration = value;\n", | |
"\t }));\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.each = function(type, listener) {\n", | |
"\t var id = this.id, ns = this.namespace;\n", | |
"\t if (arguments.length < 2) {\n", | |
"\t var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;\n", | |
"\t try {\n", | |
"\t d3_transitionInheritId = id;\n", | |
"\t d3_selection_each(this, function(node, i, j) {\n", | |
"\t d3_transitionInherit = node[ns][id];\n", | |
"\t type.call(node, node.__data__, i, j);\n", | |
"\t });\n", | |
"\t } finally {\n", | |
"\t d3_transitionInherit = inherit;\n", | |
"\t d3_transitionInheritId = inheritId;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t d3_selection_each(this, function(node) {\n", | |
"\t var transition = node[ns][id];\n", | |
"\t (transition.event || (transition.event = d3.dispatch(\"start\", \"end\", \"interrupt\"))).on(type, listener);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t return this;\n", | |
"\t };\n", | |
"\t d3_transitionPrototype.transition = function() {\n", | |
"\t var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition;\n", | |
"\t for (var j = 0, m = this.length; j < m; j++) {\n", | |
"\t subgroups.push(subgroup = []);\n", | |
"\t for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n", | |
"\t if (node = group[i]) {\n", | |
"\t transition = node[ns][id0];\n", | |
"\t d3_transitionNode(node, i, ns, id1, {\n", | |
"\t time: transition.time,\n", | |
"\t ease: transition.ease,\n", | |
"\t delay: transition.delay + transition.duration,\n", | |
"\t duration: transition.duration\n", | |
"\t });\n", | |
"\t }\n", | |
"\t subgroup.push(node);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return d3_transition(subgroups, ns, id1);\n", | |
"\t };\n", | |
"\t function d3_transitionNamespace(name) {\n", | |
"\t return name == null ? \"__transition__\" : \"__transition_\" + name + \"__\";\n", | |
"\t }\n", | |
"\t function d3_transitionNode(node, i, ns, id, inherit) {\n", | |
"\t var lock = node[ns] || (node[ns] = {\n", | |
"\t active: 0,\n", | |
"\t count: 0\n", | |
"\t }), transition = lock[id], time, timer, duration, ease, tweens;\n", | |
"\t function schedule(elapsed) {\n", | |
"\t var delay = transition.delay;\n", | |
"\t timer.t = delay + time;\n", | |
"\t if (delay <= elapsed) return start(elapsed - delay);\n", | |
"\t timer.c = start;\n", | |
"\t }\n", | |
"\t function start(elapsed) {\n", | |
"\t var activeId = lock.active, active = lock[activeId];\n", | |
"\t if (active) {\n", | |
"\t active.timer.c = null;\n", | |
"\t active.timer.t = NaN;\n", | |
"\t --lock.count;\n", | |
"\t delete lock[activeId];\n", | |
"\t active.event && active.event.interrupt.call(node, node.__data__, active.index);\n", | |
"\t }\n", | |
"\t for (var cancelId in lock) {\n", | |
"\t if (+cancelId < id) {\n", | |
"\t var cancel = lock[cancelId];\n", | |
"\t cancel.timer.c = null;\n", | |
"\t cancel.timer.t = NaN;\n", | |
"\t --lock.count;\n", | |
"\t delete lock[cancelId];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t timer.c = tick;\n", | |
"\t d3_timer(function() {\n", | |
"\t if (timer.c && tick(elapsed || 1)) {\n", | |
"\t timer.c = null;\n", | |
"\t timer.t = NaN;\n", | |
"\t }\n", | |
"\t return 1;\n", | |
"\t }, 0, time);\n", | |
"\t lock.active = id;\n", | |
"\t transition.event && transition.event.start.call(node, node.__data__, i);\n", | |
"\t tweens = [];\n", | |
"\t transition.tween.forEach(function(key, value) {\n", | |
"\t if (value = value.call(node, node.__data__, i)) {\n", | |
"\t tweens.push(value);\n", | |
"\t }\n", | |
"\t });\n", | |
"\t ease = transition.ease;\n", | |
"\t duration = transition.duration;\n", | |
"\t }\n", | |
"\t function tick(elapsed) {\n", | |
"\t var t = elapsed / duration, e = ease(t), n = tweens.length;\n", | |
"\t while (n > 0) {\n", | |
"\t tweens[--n].call(node, e);\n", | |
"\t }\n", | |
"\t if (t >= 1) {\n", | |
"\t transition.event && transition.event.end.call(node, node.__data__, i);\n", | |
"\t if (--lock.count) delete lock[id]; else delete node[ns];\n", | |
"\t return 1;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (!transition) {\n", | |
"\t time = inherit.time;\n", | |
"\t timer = d3_timer(schedule, 0, time);\n", | |
"\t transition = lock[id] = {\n", | |
"\t tween: new d3_Map(),\n", | |
"\t time: time,\n", | |
"\t timer: timer,\n", | |
"\t delay: inherit.delay,\n", | |
"\t duration: inherit.duration,\n", | |
"\t ease: inherit.ease,\n", | |
"\t index: i\n", | |
"\t };\n", | |
"\t inherit = null;\n", | |
"\t ++lock.count;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t d3.svg.axis = function() {\n", | |
"\t var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_;\n", | |
"\t function axis(g) {\n", | |
"\t g.each(function() {\n", | |
"\t var g = d3.select(this);\n", | |
"\t var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();\n", | |
"\t var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(\".tick\").data(ticks, scale1), tickEnter = tick.enter().insert(\"g\", \".domain\").attr(\"class\", \"tick\").style(\"opacity\", ε), tickExit = d3.transition(tick.exit()).style(\"opacity\", ε).remove(), tickUpdate = d3.transition(tick.order()).style(\"opacity\", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform;\n", | |
"\t var range = d3_scaleRange(scale1), path = g.selectAll(\".domain\").data([ 0 ]), pathUpdate = (path.enter().append(\"path\").attr(\"class\", \"domain\"), \n", | |
"\t d3.transition(path));\n", | |
"\t tickEnter.append(\"line\");\n", | |
"\t tickEnter.append(\"text\");\n", | |
"\t var lineEnter = tickEnter.select(\"line\"), lineUpdate = tickUpdate.select(\"line\"), text = tick.select(\"text\").text(tickFormat), textEnter = tickEnter.select(\"text\"), textUpdate = tickUpdate.select(\"text\"), sign = orient === \"top\" || orient === \"left\" ? -1 : 1, x1, x2, y1, y2;\n", | |
"\t if (orient === \"bottom\" || orient === \"top\") {\n", | |
"\t tickTransform = d3_svg_axisX, x1 = \"x\", y1 = \"y\", x2 = \"x2\", y2 = \"y2\";\n", | |
"\t text.attr(\"dy\", sign < 0 ? \"0em\" : \".71em\").style(\"text-anchor\", \"middle\");\n", | |
"\t pathUpdate.attr(\"d\", \"M\" + range[0] + \",\" + sign * outerTickSize + \"V0H\" + range[1] + \"V\" + sign * outerTickSize);\n", | |
"\t } else {\n", | |
"\t tickTransform = d3_svg_axisY, x1 = \"y\", y1 = \"x\", x2 = \"y2\", y2 = \"x2\";\n", | |
"\t text.attr(\"dy\", \".32em\").style(\"text-anchor\", sign < 0 ? \"end\" : \"start\");\n", | |
"\t pathUpdate.attr(\"d\", \"M\" + sign * outerTickSize + \",\" + range[0] + \"H0V\" + range[1] + \"H\" + sign * outerTickSize);\n", | |
"\t }\n", | |
"\t lineEnter.attr(y2, sign * innerTickSize);\n", | |
"\t textEnter.attr(y1, sign * tickSpacing);\n", | |
"\t lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize);\n", | |
"\t textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing);\n", | |
"\t if (scale1.rangeBand) {\n", | |
"\t var x = scale1, dx = x.rangeBand() / 2;\n", | |
"\t scale0 = scale1 = function(d) {\n", | |
"\t return x(d) + dx;\n", | |
"\t };\n", | |
"\t } else if (scale0.rangeBand) {\n", | |
"\t scale0 = scale1;\n", | |
"\t } else {\n", | |
"\t tickExit.call(tickTransform, scale1, scale0);\n", | |
"\t }\n", | |
"\t tickEnter.call(tickTransform, scale0, scale1);\n", | |
"\t tickUpdate.call(tickTransform, scale1, scale1);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t axis.scale = function(x) {\n", | |
"\t if (!arguments.length) return scale;\n", | |
"\t scale = x;\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.orient = function(x) {\n", | |
"\t if (!arguments.length) return orient;\n", | |
"\t orient = x in d3_svg_axisOrients ? x + \"\" : d3_svg_axisDefaultOrient;\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.ticks = function() {\n", | |
"\t if (!arguments.length) return tickArguments_;\n", | |
"\t tickArguments_ = d3_array(arguments);\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.tickValues = function(x) {\n", | |
"\t if (!arguments.length) return tickValues;\n", | |
"\t tickValues = x;\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.tickFormat = function(x) {\n", | |
"\t if (!arguments.length) return tickFormat_;\n", | |
"\t tickFormat_ = x;\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.tickSize = function(x) {\n", | |
"\t var n = arguments.length;\n", | |
"\t if (!n) return innerTickSize;\n", | |
"\t innerTickSize = +x;\n", | |
"\t outerTickSize = +arguments[n - 1];\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.innerTickSize = function(x) {\n", | |
"\t if (!arguments.length) return innerTickSize;\n", | |
"\t innerTickSize = +x;\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.outerTickSize = function(x) {\n", | |
"\t if (!arguments.length) return outerTickSize;\n", | |
"\t outerTickSize = +x;\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.tickPadding = function(x) {\n", | |
"\t if (!arguments.length) return tickPadding;\n", | |
"\t tickPadding = +x;\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t axis.tickSubdivide = function() {\n", | |
"\t return arguments.length && axis;\n", | |
"\t };\n", | |
"\t return axis;\n", | |
"\t };\n", | |
"\t var d3_svg_axisDefaultOrient = \"bottom\", d3_svg_axisOrients = {\n", | |
"\t top: 1,\n", | |
"\t right: 1,\n", | |
"\t bottom: 1,\n", | |
"\t left: 1\n", | |
"\t };\n", | |
"\t function d3_svg_axisX(selection, x0, x1) {\n", | |
"\t selection.attr(\"transform\", function(d) {\n", | |
"\t var v0 = x0(d);\n", | |
"\t return \"translate(\" + (isFinite(v0) ? v0 : x1(d)) + \",0)\";\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function d3_svg_axisY(selection, y0, y1) {\n", | |
"\t selection.attr(\"transform\", function(d) {\n", | |
"\t var v0 = y0(d);\n", | |
"\t return \"translate(0,\" + (isFinite(v0) ? v0 : y1(d)) + \")\";\n", | |
"\t });\n", | |
"\t }\n", | |
"\t d3.svg.brush = function() {\n", | |
"\t var event = d3_eventDispatch(brush, \"brushstart\", \"brush\", \"brushend\"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0];\n", | |
"\t function brush(g) {\n", | |
"\t g.each(function() {\n", | |
"\t var g = d3.select(this).style(\"pointer-events\", \"all\").style(\"-webkit-tap-highlight-color\", \"rgba(0,0,0,0)\").on(\"mousedown.brush\", brushstart).on(\"touchstart.brush\", brushstart);\n", | |
"\t var background = g.selectAll(\".background\").data([ 0 ]);\n", | |
"\t background.enter().append(\"rect\").attr(\"class\", \"background\").style(\"visibility\", \"hidden\").style(\"cursor\", \"crosshair\");\n", | |
"\t g.selectAll(\".extent\").data([ 0 ]).enter().append(\"rect\").attr(\"class\", \"extent\").style(\"cursor\", \"move\");\n", | |
"\t var resize = g.selectAll(\".resize\").data(resizes, d3_identity);\n", | |
"\t resize.exit().remove();\n", | |
"\t resize.enter().append(\"g\").attr(\"class\", function(d) {\n", | |
"\t return \"resize \" + d;\n", | |
"\t }).style(\"cursor\", function(d) {\n", | |
"\t return d3_svg_brushCursor[d];\n", | |
"\t }).append(\"rect\").attr(\"x\", function(d) {\n", | |
"\t return /[ew]$/.test(d) ? -3 : null;\n", | |
"\t }).attr(\"y\", function(d) {\n", | |
"\t return /^[ns]/.test(d) ? -3 : null;\n", | |
"\t }).attr(\"width\", 6).attr(\"height\", 6).style(\"visibility\", \"hidden\");\n", | |
"\t resize.style(\"display\", brush.empty() ? \"none\" : null);\n", | |
"\t var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range;\n", | |
"\t if (x) {\n", | |
"\t range = d3_scaleRange(x);\n", | |
"\t backgroundUpdate.attr(\"x\", range[0]).attr(\"width\", range[1] - range[0]);\n", | |
"\t redrawX(gUpdate);\n", | |
"\t }\n", | |
"\t if (y) {\n", | |
"\t range = d3_scaleRange(y);\n", | |
"\t backgroundUpdate.attr(\"y\", range[0]).attr(\"height\", range[1] - range[0]);\n", | |
"\t redrawY(gUpdate);\n", | |
"\t }\n", | |
"\t redraw(gUpdate);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t brush.event = function(g) {\n", | |
"\t g.each(function() {\n", | |
"\t var event_ = event.of(this, arguments), extent1 = {\n", | |
"\t x: xExtent,\n", | |
"\t y: yExtent,\n", | |
"\t i: xExtentDomain,\n", | |
"\t j: yExtentDomain\n", | |
"\t }, extent0 = this.__chart__ || extent1;\n", | |
"\t this.__chart__ = extent1;\n", | |
"\t if (d3_transitionInheritId) {\n", | |
"\t d3.select(this).transition().each(\"start.brush\", function() {\n", | |
"\t xExtentDomain = extent0.i;\n", | |
"\t yExtentDomain = extent0.j;\n", | |
"\t xExtent = extent0.x;\n", | |
"\t yExtent = extent0.y;\n", | |
"\t event_({\n", | |
"\t type: \"brushstart\"\n", | |
"\t });\n", | |
"\t }).tween(\"brush:brush\", function() {\n", | |
"\t var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y);\n", | |
"\t xExtentDomain = yExtentDomain = null;\n", | |
"\t return function(t) {\n", | |
"\t xExtent = extent1.x = xi(t);\n", | |
"\t yExtent = extent1.y = yi(t);\n", | |
"\t event_({\n", | |
"\t type: \"brush\",\n", | |
"\t mode: \"resize\"\n", | |
"\t });\n", | |
"\t };\n", | |
"\t }).each(\"end.brush\", function() {\n", | |
"\t xExtentDomain = extent1.i;\n", | |
"\t yExtentDomain = extent1.j;\n", | |
"\t event_({\n", | |
"\t type: \"brush\",\n", | |
"\t mode: \"resize\"\n", | |
"\t });\n", | |
"\t event_({\n", | |
"\t type: \"brushend\"\n", | |
"\t });\n", | |
"\t });\n", | |
"\t } else {\n", | |
"\t event_({\n", | |
"\t type: \"brushstart\"\n", | |
"\t });\n", | |
"\t event_({\n", | |
"\t type: \"brush\",\n", | |
"\t mode: \"resize\"\n", | |
"\t });\n", | |
"\t event_({\n", | |
"\t type: \"brushend\"\n", | |
"\t });\n", | |
"\t }\n", | |
"\t });\n", | |
"\t };\n", | |
"\t function redraw(g) {\n", | |
"\t g.selectAll(\".resize\").attr(\"transform\", function(d) {\n", | |
"\t return \"translate(\" + xExtent[+/e$/.test(d)] + \",\" + yExtent[+/^s/.test(d)] + \")\";\n", | |
"\t });\n", | |
"\t }\n", | |
"\t function redrawX(g) {\n", | |
"\t g.select(\".extent\").attr(\"x\", xExtent[0]);\n", | |
"\t g.selectAll(\".extent,.n>rect,.s>rect\").attr(\"width\", xExtent[1] - xExtent[0]);\n", | |
"\t }\n", | |
"\t function redrawY(g) {\n", | |
"\t g.select(\".extent\").attr(\"y\", yExtent[0]);\n", | |
"\t g.selectAll(\".extent,.e>rect,.w>rect\").attr(\"height\", yExtent[1] - yExtent[0]);\n", | |
"\t }\n", | |
"\t function brushstart() {\n", | |
"\t var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed(\"extent\"), dragRestore = d3_event_dragSuppress(target), center, origin = d3.mouse(target), offset;\n", | |
"\t var w = d3.select(d3_window(target)).on(\"keydown.brush\", keydown).on(\"keyup.brush\", keyup);\n", | |
"\t if (d3.event.changedTouches) {\n", | |
"\t w.on(\"touchmove.brush\", brushmove).on(\"touchend.brush\", brushend);\n", | |
"\t } else {\n", | |
"\t w.on(\"mousemove.brush\", brushmove).on(\"mouseup.brush\", brushend);\n", | |
"\t }\n", | |
"\t g.interrupt().selectAll(\"*\").interrupt();\n", | |
"\t if (dragging) {\n", | |
"\t origin[0] = xExtent[0] - origin[0];\n", | |
"\t origin[1] = yExtent[0] - origin[1];\n", | |
"\t } else if (resizing) {\n", | |
"\t var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing);\n", | |
"\t offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ];\n", | |
"\t origin[0] = xExtent[ex];\n", | |
"\t origin[1] = yExtent[ey];\n", | |
"\t } else if (d3.event.altKey) center = origin.slice();\n", | |
"\t g.style(\"pointer-events\", \"none\").selectAll(\".resize\").style(\"display\", null);\n", | |
"\t d3.select(\"body\").style(\"cursor\", eventTarget.style(\"cursor\"));\n", | |
"\t event_({\n", | |
"\t type: \"brushstart\"\n", | |
"\t });\n", | |
"\t brushmove();\n", | |
"\t function keydown() {\n", | |
"\t if (d3.event.keyCode == 32) {\n", | |
"\t if (!dragging) {\n", | |
"\t center = null;\n", | |
"\t origin[0] -= xExtent[1];\n", | |
"\t origin[1] -= yExtent[1];\n", | |
"\t dragging = 2;\n", | |
"\t }\n", | |
"\t d3_eventPreventDefault();\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function keyup() {\n", | |
"\t if (d3.event.keyCode == 32 && dragging == 2) {\n", | |
"\t origin[0] += xExtent[1];\n", | |
"\t origin[1] += yExtent[1];\n", | |
"\t dragging = 0;\n", | |
"\t d3_eventPreventDefault();\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function brushmove() {\n", | |
"\t var point = d3.mouse(target), moved = false;\n", | |
"\t if (offset) {\n", | |
"\t point[0] += offset[0];\n", | |
"\t point[1] += offset[1];\n", | |
"\t }\n", | |
"\t if (!dragging) {\n", | |
"\t if (d3.event.altKey) {\n", | |
"\t if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ];\n", | |
"\t origin[0] = xExtent[+(point[0] < center[0])];\n", | |
"\t origin[1] = yExtent[+(point[1] < center[1])];\n", | |
"\t } else center = null;\n", | |
"\t }\n", | |
"\t if (resizingX && move1(point, x, 0)) {\n", | |
"\t redrawX(g);\n", | |
"\t moved = true;\n", | |
"\t }\n", | |
"\t if (resizingY && move1(point, y, 1)) {\n", | |
"\t redrawY(g);\n", | |
"\t moved = true;\n", | |
"\t }\n", | |
"\t if (moved) {\n", | |
"\t redraw(g);\n", | |
"\t event_({\n", | |
"\t type: \"brush\",\n", | |
"\t mode: dragging ? \"move\" : \"resize\"\n", | |
"\t });\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function move1(point, scale, i) {\n", | |
"\t var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max;\n", | |
"\t if (dragging) {\n", | |
"\t r0 -= position;\n", | |
"\t r1 -= size + position;\n", | |
"\t }\n", | |
"\t min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i];\n", | |
"\t if (dragging) {\n", | |
"\t max = (min += position) + size;\n", | |
"\t } else {\n", | |
"\t if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));\n", | |
"\t if (position < min) {\n", | |
"\t max = min;\n", | |
"\t min = position;\n", | |
"\t } else {\n", | |
"\t max = position;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (extent[0] != min || extent[1] != max) {\n", | |
"\t if (i) yExtentDomain = null; else xExtentDomain = null;\n", | |
"\t extent[0] = min;\n", | |
"\t extent[1] = max;\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t function brushend() {\n", | |
"\t brushmove();\n", | |
"\t g.style(\"pointer-events\", \"all\").selectAll(\".resize\").style(\"display\", brush.empty() ? \"none\" : null);\n", | |
"\t d3.select(\"body\").style(\"cursor\", null);\n", | |
"\t w.on(\"mousemove.brush\", null).on(\"mouseup.brush\", null).on(\"touchmove.brush\", null).on(\"touchend.brush\", null).on(\"keydown.brush\", null).on(\"keyup.brush\", null);\n", | |
"\t dragRestore();\n", | |
"\t event_({\n", | |
"\t type: \"brushend\"\n", | |
"\t });\n", | |
"\t }\n", | |
"\t }\n", | |
"\t brush.x = function(z) {\n", | |
"\t if (!arguments.length) return x;\n", | |
"\t x = z;\n", | |
"\t resizes = d3_svg_brushResizes[!x << 1 | !y];\n", | |
"\t return brush;\n", | |
"\t };\n", | |
"\t brush.y = function(z) {\n", | |
"\t if (!arguments.length) return y;\n", | |
"\t y = z;\n", | |
"\t resizes = d3_svg_brushResizes[!x << 1 | !y];\n", | |
"\t return brush;\n", | |
"\t };\n", | |
"\t brush.clamp = function(z) {\n", | |
"\t if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null;\n", | |
"\t if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z;\n", | |
"\t return brush;\n", | |
"\t };\n", | |
"\t brush.extent = function(z) {\n", | |
"\t var x0, x1, y0, y1, t;\n", | |
"\t if (!arguments.length) {\n", | |
"\t if (x) {\n", | |
"\t if (xExtentDomain) {\n", | |
"\t x0 = xExtentDomain[0], x1 = xExtentDomain[1];\n", | |
"\t } else {\n", | |
"\t x0 = xExtent[0], x1 = xExtent[1];\n", | |
"\t if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);\n", | |
"\t if (x1 < x0) t = x0, x0 = x1, x1 = t;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (y) {\n", | |
"\t if (yExtentDomain) {\n", | |
"\t y0 = yExtentDomain[0], y1 = yExtentDomain[1];\n", | |
"\t } else {\n", | |
"\t y0 = yExtent[0], y1 = yExtent[1];\n", | |
"\t if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);\n", | |
"\t if (y1 < y0) t = y0, y0 = y1, y1 = t;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ];\n", | |
"\t }\n", | |
"\t if (x) {\n", | |
"\t x0 = z[0], x1 = z[1];\n", | |
"\t if (y) x0 = x0[0], x1 = x1[0];\n", | |
"\t xExtentDomain = [ x0, x1 ];\n", | |
"\t if (x.invert) x0 = x(x0), x1 = x(x1);\n", | |
"\t if (x1 < x0) t = x0, x0 = x1, x1 = t;\n", | |
"\t if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ];\n", | |
"\t }\n", | |
"\t if (y) {\n", | |
"\t y0 = z[0], y1 = z[1];\n", | |
"\t if (x) y0 = y0[1], y1 = y1[1];\n", | |
"\t yExtentDomain = [ y0, y1 ];\n", | |
"\t if (y.invert) y0 = y(y0), y1 = y(y1);\n", | |
"\t if (y1 < y0) t = y0, y0 = y1, y1 = t;\n", | |
"\t if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ];\n", | |
"\t }\n", | |
"\t return brush;\n", | |
"\t };\n", | |
"\t brush.clear = function() {\n", | |
"\t if (!brush.empty()) {\n", | |
"\t xExtent = [ 0, 0 ], yExtent = [ 0, 0 ];\n", | |
"\t xExtentDomain = yExtentDomain = null;\n", | |
"\t }\n", | |
"\t return brush;\n", | |
"\t };\n", | |
"\t brush.empty = function() {\n", | |
"\t return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1];\n", | |
"\t };\n", | |
"\t return d3.rebind(brush, event, \"on\");\n", | |
"\t };\n", | |
"\t var d3_svg_brushCursor = {\n", | |
"\t n: \"ns-resize\",\n", | |
"\t e: \"ew-resize\",\n", | |
"\t s: \"ns-resize\",\n", | |
"\t w: \"ew-resize\",\n", | |
"\t nw: \"nwse-resize\",\n", | |
"\t ne: \"nesw-resize\",\n", | |
"\t se: \"nwse-resize\",\n", | |
"\t sw: \"nesw-resize\"\n", | |
"\t };\n", | |
"\t var d3_svg_brushResizes = [ [ \"n\", \"e\", \"s\", \"w\", \"nw\", \"ne\", \"se\", \"sw\" ], [ \"e\", \"w\" ], [ \"n\", \"s\" ], [] ];\n", | |
"\t var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat;\n", | |
"\t var d3_time_formatUtc = d3_time_format.utc;\n", | |
"\t var d3_time_formatIso = d3_time_formatUtc(\"%Y-%m-%dT%H:%M:%S.%LZ\");\n", | |
"\t d3_time_format.iso = Date.prototype.toISOString && +new Date(\"2000-01-01T00:00:00.000Z\") ? d3_time_formatIsoNative : d3_time_formatIso;\n", | |
"\t function d3_time_formatIsoNative(date) {\n", | |
"\t return date.toISOString();\n", | |
"\t }\n", | |
"\t d3_time_formatIsoNative.parse = function(string) {\n", | |
"\t var date = new Date(string);\n", | |
"\t return isNaN(date) ? null : date;\n", | |
"\t };\n", | |
"\t d3_time_formatIsoNative.toString = d3_time_formatIso.toString;\n", | |
"\t d3_time.second = d3_time_interval(function(date) {\n", | |
"\t return new d3_date(Math.floor(date / 1e3) * 1e3);\n", | |
"\t }, function(date, offset) {\n", | |
"\t date.setTime(date.getTime() + Math.floor(offset) * 1e3);\n", | |
"\t }, function(date) {\n", | |
"\t return date.getSeconds();\n", | |
"\t });\n", | |
"\t d3_time.seconds = d3_time.second.range;\n", | |
"\t d3_time.seconds.utc = d3_time.second.utc.range;\n", | |
"\t d3_time.minute = d3_time_interval(function(date) {\n", | |
"\t return new d3_date(Math.floor(date / 6e4) * 6e4);\n", | |
"\t }, function(date, offset) {\n", | |
"\t date.setTime(date.getTime() + Math.floor(offset) * 6e4);\n", | |
"\t }, function(date) {\n", | |
"\t return date.getMinutes();\n", | |
"\t });\n", | |
"\t d3_time.minutes = d3_time.minute.range;\n", | |
"\t d3_time.minutes.utc = d3_time.minute.utc.range;\n", | |
"\t d3_time.hour = d3_time_interval(function(date) {\n", | |
"\t var timezone = date.getTimezoneOffset() / 60;\n", | |
"\t return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);\n", | |
"\t }, function(date, offset) {\n", | |
"\t date.setTime(date.getTime() + Math.floor(offset) * 36e5);\n", | |
"\t }, function(date) {\n", | |
"\t return date.getHours();\n", | |
"\t });\n", | |
"\t d3_time.hours = d3_time.hour.range;\n", | |
"\t d3_time.hours.utc = d3_time.hour.utc.range;\n", | |
"\t d3_time.month = d3_time_interval(function(date) {\n", | |
"\t date = d3_time.day(date);\n", | |
"\t date.setDate(1);\n", | |
"\t return date;\n", | |
"\t }, function(date, offset) {\n", | |
"\t date.setMonth(date.getMonth() + offset);\n", | |
"\t }, function(date) {\n", | |
"\t return date.getMonth();\n", | |
"\t });\n", | |
"\t d3_time.months = d3_time.month.range;\n", | |
"\t d3_time.months.utc = d3_time.month.utc.range;\n", | |
"\t function d3_time_scale(linear, methods, format) {\n", | |
"\t function scale(x) {\n", | |
"\t return linear(x);\n", | |
"\t }\n", | |
"\t scale.invert = function(x) {\n", | |
"\t return d3_time_scaleDate(linear.invert(x));\n", | |
"\t };\n", | |
"\t scale.domain = function(x) {\n", | |
"\t if (!arguments.length) return linear.domain().map(d3_time_scaleDate);\n", | |
"\t linear.domain(x);\n", | |
"\t return scale;\n", | |
"\t };\n", | |
"\t function tickMethod(extent, count) {\n", | |
"\t var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target);\n", | |
"\t return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) {\n", | |
"\t return d / 31536e6;\n", | |
"\t }), count)[2] ] : !i ? [ d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2] ] : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i];\n", | |
"\t }\n", | |
"\t scale.nice = function(interval, skip) {\n", | |
"\t var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === \"number\" && tickMethod(extent, interval);\n", | |
"\t if (method) interval = method[0], skip = method[1];\n", | |
"\t function skipped(date) {\n", | |
"\t return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length;\n", | |
"\t }\n", | |
"\t return scale.domain(d3_scale_nice(domain, skip > 1 ? {\n", | |
"\t floor: function(date) {\n", | |
"\t while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1);\n", | |
"\t return date;\n", | |
"\t },\n", | |
"\t ceil: function(date) {\n", | |
"\t while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1);\n", | |
"\t return date;\n", | |
"\t }\n", | |
"\t } : interval));\n", | |
"\t };\n", | |
"\t scale.ticks = function(interval, skip) {\n", | |
"\t var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === \"number\" ? tickMethod(extent, interval) : !interval.range && [ {\n", | |
"\t range: interval\n", | |
"\t }, skip ];\n", | |
"\t if (method) interval = method[0], skip = method[1];\n", | |
"\t return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip);\n", | |
"\t };\n", | |
"\t scale.tickFormat = function() {\n", | |
"\t return format;\n", | |
"\t };\n", | |
"\t scale.copy = function() {\n", | |
"\t return d3_time_scale(linear.copy(), methods, format);\n", | |
"\t };\n", | |
"\t return d3_scale_linearRebind(scale, linear);\n", | |
"\t }\n", | |
"\t function d3_time_scaleDate(t) {\n", | |
"\t return new Date(t);\n", | |
"\t }\n", | |
"\t var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ];\n", | |
"\t var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ];\n", | |
"\t var d3_time_scaleLocalFormat = d3_time_format.multi([ [ \".%L\", function(d) {\n", | |
"\t return d.getMilliseconds();\n", | |
"\t } ], [ \":%S\", function(d) {\n", | |
"\t return d.getSeconds();\n", | |
"\t } ], [ \"%I:%M\", function(d) {\n", | |
"\t return d.getMinutes();\n", | |
"\t } ], [ \"%I %p\", function(d) {\n", | |
"\t return d.getHours();\n", | |
"\t } ], [ \"%a %d\", function(d) {\n", | |
"\t return d.getDay() && d.getDate() != 1;\n", | |
"\t } ], [ \"%b %d\", function(d) {\n", | |
"\t return d.getDate() != 1;\n", | |
"\t } ], [ \"%B\", function(d) {\n", | |
"\t return d.getMonth();\n", | |
"\t } ], [ \"%Y\", d3_true ] ]);\n", | |
"\t var d3_time_scaleMilliseconds = {\n", | |
"\t range: function(start, stop, step) {\n", | |
"\t return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate);\n", | |
"\t },\n", | |
"\t floor: d3_identity,\n", | |
"\t ceil: d3_identity\n", | |
"\t };\n", | |
"\t d3_time_scaleLocalMethods.year = d3_time.year;\n", | |
"\t d3_time.scale = function() {\n", | |
"\t return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);\n", | |
"\t };\n", | |
"\t var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) {\n", | |
"\t return [ m[0].utc, m[1] ];\n", | |
"\t });\n", | |
"\t var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ \".%L\", function(d) {\n", | |
"\t return d.getUTCMilliseconds();\n", | |
"\t } ], [ \":%S\", function(d) {\n", | |
"\t return d.getUTCSeconds();\n", | |
"\t } ], [ \"%I:%M\", function(d) {\n", | |
"\t return d.getUTCMinutes();\n", | |
"\t } ], [ \"%I %p\", function(d) {\n", | |
"\t return d.getUTCHours();\n", | |
"\t } ], [ \"%a %d\", function(d) {\n", | |
"\t return d.getUTCDay() && d.getUTCDate() != 1;\n", | |
"\t } ], [ \"%b %d\", function(d) {\n", | |
"\t return d.getUTCDate() != 1;\n", | |
"\t } ], [ \"%B\", function(d) {\n", | |
"\t return d.getUTCMonth();\n", | |
"\t } ], [ \"%Y\", d3_true ] ]);\n", | |
"\t d3_time_scaleUtcMethods.year = d3_time.year.utc;\n", | |
"\t d3_time.scale.utc = function() {\n", | |
"\t return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat);\n", | |
"\t };\n", | |
"\t d3.text = d3_xhrType(function(request) {\n", | |
"\t return request.responseText;\n", | |
"\t });\n", | |
"\t d3.json = function(url, callback) {\n", | |
"\t return d3_xhr(url, \"application/json\", d3_json, callback);\n", | |
"\t };\n", | |
"\t function d3_json(request) {\n", | |
"\t return JSON.parse(request.responseText);\n", | |
"\t }\n", | |
"\t d3.html = function(url, callback) {\n", | |
"\t return d3_xhr(url, \"text/html\", d3_html, callback);\n", | |
"\t };\n", | |
"\t function d3_html(request) {\n", | |
"\t var range = d3_document.createRange();\n", | |
"\t range.selectNode(d3_document.body);\n", | |
"\t return range.createContextualFragment(request.responseText);\n", | |
"\t }\n", | |
"\t d3.xml = d3_xhrType(function(request) {\n", | |
"\t return request.responseXML;\n", | |
"\t });\n", | |
"\t if (true) this.d3 = d3, !(__WEBPACK_AMD_DEFINE_FACTORY__ = (d3), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); else if (typeof module === \"object\" && module.exports) module.exports = d3; else this.d3 = d3;\n", | |
"\t}();\n", | |
"\n", | |
"/***/ },\n", | |
"/* 3 */\n", | |
"/***/ function(module, exports, __webpack_require__) {\n", | |
"\n", | |
"\t'use strict';\n", | |
"\t\n", | |
"\tObject.defineProperty(exports, \"__esModule\", {\n", | |
"\t value: true\n", | |
"\t});\n", | |
"\t\n", | |
"\tvar _d = __webpack_require__(2);\n", | |
"\t\n", | |
"\tvar _d2 = _interopRequireDefault(_d);\n", | |
"\t\n", | |
"\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n", | |
"\t\n", | |
"\tfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n", | |
"\t\n", | |
"\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n", | |
"\t\n", | |
"\tvar Barchart =\n", | |
"\t// svg: d3 object with the svg in question\n", | |
"\t// exp_array: list of (feature_name, weight)\n", | |
"\tfunction Barchart(svg, exp_array) {\n", | |
"\t var two_sided = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n", | |
"\t var titles = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;\n", | |
"\t var colors = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : ['red', 'green'];\n", | |
"\t var show_numbers = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;\n", | |
"\t var bar_height = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 5;\n", | |
"\t\n", | |
"\t _classCallCheck(this, Barchart);\n", | |
"\t\n", | |
"\t var svg_width = Math.min(600, parseInt(svg.style('width')));\n", | |
"\t var bar_width = two_sided ? svg_width / 2 : svg_width;\n", | |
"\t if (titles === undefined) {\n", | |
"\t titles = two_sided ? ['Cons', 'Pros'] : 'Pros';\n", | |
"\t }\n", | |
"\t if (show_numbers) {\n", | |
"\t bar_width = bar_width - 30;\n", | |
"\t }\n", | |
"\t var x_offset = two_sided ? svg_width / 2 : 10;\n", | |
"\t // 13.1 is +- the width of W, the widest letter.\n", | |
"\t if (two_sided && titles.length == 2) {\n", | |
"\t svg.append('text').attr('x', svg_width / 4).attr('y', 15).attr('font-size', '20').attr('text-anchor', 'middle').style('fill', colors[0]).text(titles[0]);\n", | |
"\t\n", | |
"\t svg.append('text').attr('x', svg_width / 4 * 3).attr('y', 15).attr('font-size', '20').attr('text-anchor', 'middle').style('fill', colors[1]).text(titles[1]);\n", | |
"\t } else {\n", | |
"\t var pos = two_sided ? svg_width / 2 : x_offset;\n", | |
"\t var anchor = two_sided ? 'middle' : 'begin';\n", | |
"\t svg.append('text').attr('x', pos).attr('y', 15).attr('font-size', '20').attr('text-anchor', anchor).text(titles);\n", | |
"\t }\n", | |
"\t var yshift = 20;\n", | |
"\t var space_between_bars = 0;\n", | |
"\t var text_height = 16;\n", | |
"\t var space_between_bar_and_text = 3;\n", | |
"\t var total_bar_height = text_height + space_between_bar_and_text + bar_height + space_between_bars;\n", | |
"\t var total_height = total_bar_height * exp_array.length;\n", | |
"\t this.svg_height = total_height + yshift;\n", | |
"\t var yscale = _d2.default.scale.linear().domain([0, exp_array.length]).range([yshift, yshift + total_height]);\n", | |
"\t var names = exp_array.map(function (v) {\n", | |
"\t return v[0];\n", | |
"\t });\n", | |
"\t var weights = exp_array.map(function (v) {\n", | |
"\t return v[1];\n", | |
"\t });\n", | |
"\t var max_weight = Math.max.apply(Math, _toConsumableArray(weights.map(function (v) {\n", | |
"\t return Math.abs(v);\n", | |
"\t })));\n", | |
"\t var xscale = _d2.default.scale.linear().domain([0, Math.max(1, max_weight)]).range([0, bar_width]);\n", | |
"\t\n", | |
"\t for (var i = 0; i < exp_array.length; ++i) {\n", | |
"\t var name = names[i];\n", | |
"\t var weight = weights[i];\n", | |
"\t var size = xscale(Math.abs(weight));\n", | |
"\t var to_the_right = weight > 0 || !two_sided;\n", | |
"\t var text = svg.append('text').attr('x', to_the_right ? x_offset + 2 : x_offset - 2).attr('y', yscale(i) + text_height).attr('text-anchor', to_the_right ? 'begin' : 'end').attr('font-size', '14').text(name);\n", | |
"\t while (text.node().getBBox()['width'] + 1 > bar_width) {\n", | |
"\t var cur_text = text.text().slice(0, text.text().length - 5);\n", | |
"\t text.text(cur_text + '...');\n", | |
"\t if (text === '...') {\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var bar = svg.append('rect').attr('height', bar_height).attr('x', to_the_right ? x_offset : x_offset - size).attr('y', text_height + yscale(i) + space_between_bar_and_text) // + bar_height)\n", | |
"\t .attr('width', size).style('fill', weight > 0 ? colors[1] : colors[0]);\n", | |
"\t if (show_numbers) {\n", | |
"\t var bartext = svg.append('text').attr('x', to_the_right ? x_offset + size + 1 : x_offset - size - 1).attr('text-anchor', weight > 0 || !two_sided ? 'begin' : 'end').attr('y', bar_height + yscale(i) + text_height + space_between_bar_and_text).attr('font-size', '10').text(Math.abs(weight).toFixed(2));\n", | |
"\t }\n", | |
"\t }\n", | |
"\t var line = svg.append(\"line\").attr(\"x1\", x_offset).attr(\"x2\", x_offset).attr(\"y1\", bar_height + yshift).attr(\"y2\", Math.max(bar_height, yscale(exp_array.length))).style(\"stroke-width\", 2).style(\"stroke\", \"black\");\n", | |
"\t};\n", | |
"\t\n", | |
"\texports.default = Barchart;\n", | |
"\n", | |
"/***/ },\n", | |
"/* 4 */\n", | |
"/***/ function(module, exports, __webpack_require__) {\n", | |
"\n", | |
"\tvar __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(global, module) {/**\n", | |
"\t * @license\n", | |
"\t * lodash <https://lodash.com/>\n", | |
"\t * Copyright JS Foundation and other contributors <https://js.foundation/>\n", | |
"\t * Released under MIT license <https://lodash.com/license>\n", | |
"\t * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n", | |
"\t * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n", | |
"\t */\n", | |
"\t;(function() {\n", | |
"\t\n", | |
"\t /** Used as a safe reference for `undefined` in pre-ES5 environments. */\n", | |
"\t var undefined;\n", | |
"\t\n", | |
"\t /** Used as the semantic version number. */\n", | |
"\t var VERSION = '4.16.6';\n", | |
"\t\n", | |
"\t /** Used as the size to enable large array optimizations. */\n", | |
"\t var LARGE_ARRAY_SIZE = 200;\n", | |
"\t\n", | |
"\t /** Error message constants. */\n", | |
"\t var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.',\n", | |
"\t FUNC_ERROR_TEXT = 'Expected a function';\n", | |
"\t\n", | |
"\t /** Used to stand-in for `undefined` hash values. */\n", | |
"\t var HASH_UNDEFINED = '__lodash_hash_undefined__';\n", | |
"\t\n", | |
"\t /** Used as the maximum memoize cache size. */\n", | |
"\t var MAX_MEMOIZE_SIZE = 500;\n", | |
"\t\n", | |
"\t /** Used as the internal argument placeholder. */\n", | |
"\t var PLACEHOLDER = '__lodash_placeholder__';\n", | |
"\t\n", | |
"\t /** Used to compose bitmasks for function metadata. */\n", | |
"\t var BIND_FLAG = 1,\n", | |
"\t BIND_KEY_FLAG = 2,\n", | |
"\t CURRY_BOUND_FLAG = 4,\n", | |
"\t CURRY_FLAG = 8,\n", | |
"\t CURRY_RIGHT_FLAG = 16,\n", | |
"\t PARTIAL_FLAG = 32,\n", | |
"\t PARTIAL_RIGHT_FLAG = 64,\n", | |
"\t ARY_FLAG = 128,\n", | |
"\t REARG_FLAG = 256,\n", | |
"\t FLIP_FLAG = 512;\n", | |
"\t\n", | |
"\t /** Used to compose bitmasks for comparison styles. */\n", | |
"\t var UNORDERED_COMPARE_FLAG = 1,\n", | |
"\t PARTIAL_COMPARE_FLAG = 2;\n", | |
"\t\n", | |
"\t /** Used as default options for `_.truncate`. */\n", | |
"\t var DEFAULT_TRUNC_LENGTH = 30,\n", | |
"\t DEFAULT_TRUNC_OMISSION = '...';\n", | |
"\t\n", | |
"\t /** Used to detect hot functions by number of calls within a span of milliseconds. */\n", | |
"\t var HOT_COUNT = 800,\n", | |
"\t HOT_SPAN = 16;\n", | |
"\t\n", | |
"\t /** Used to indicate the type of lazy iteratees. */\n", | |
"\t var LAZY_FILTER_FLAG = 1,\n", | |
"\t LAZY_MAP_FLAG = 2,\n", | |
"\t LAZY_WHILE_FLAG = 3;\n", | |
"\t\n", | |
"\t /** Used as references for various `Number` constants. */\n", | |
"\t var INFINITY = 1 / 0,\n", | |
"\t MAX_SAFE_INTEGER = 9007199254740991,\n", | |
"\t MAX_INTEGER = 1.7976931348623157e+308,\n", | |
"\t NAN = 0 / 0;\n", | |
"\t\n", | |
"\t /** Used as references for the maximum length and index of an array. */\n", | |
"\t var MAX_ARRAY_LENGTH = 4294967295,\n", | |
"\t MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,\n", | |
"\t HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;\n", | |
"\t\n", | |
"\t /** Used to associate wrap methods with their bit flags. */\n", | |
"\t var wrapFlags = [\n", | |
"\t ['ary', ARY_FLAG],\n", | |
"\t ['bind', BIND_FLAG],\n", | |
"\t ['bindKey', BIND_KEY_FLAG],\n", | |
"\t ['curry', CURRY_FLAG],\n", | |
"\t ['curryRight', CURRY_RIGHT_FLAG],\n", | |
"\t ['flip', FLIP_FLAG],\n", | |
"\t ['partial', PARTIAL_FLAG],\n", | |
"\t ['partialRight', PARTIAL_RIGHT_FLAG],\n", | |
"\t ['rearg', REARG_FLAG]\n", | |
"\t ];\n", | |
"\t\n", | |
"\t /** `Object#toString` result references. */\n", | |
"\t var argsTag = '[object Arguments]',\n", | |
"\t arrayTag = '[object Array]',\n", | |
"\t asyncTag = '[object AsyncFunction]',\n", | |
"\t boolTag = '[object Boolean]',\n", | |
"\t dateTag = '[object Date]',\n", | |
"\t domExcTag = '[object DOMException]',\n", | |
"\t errorTag = '[object Error]',\n", | |
"\t funcTag = '[object Function]',\n", | |
"\t genTag = '[object GeneratorFunction]',\n", | |
"\t mapTag = '[object Map]',\n", | |
"\t numberTag = '[object Number]',\n", | |
"\t nullTag = '[object Null]',\n", | |
"\t objectTag = '[object Object]',\n", | |
"\t promiseTag = '[object Promise]',\n", | |
"\t proxyTag = '[object Proxy]',\n", | |
"\t regexpTag = '[object RegExp]',\n", | |
"\t setTag = '[object Set]',\n", | |
"\t stringTag = '[object String]',\n", | |
"\t symbolTag = '[object Symbol]',\n", | |
"\t undefinedTag = '[object Undefined]',\n", | |
"\t weakMapTag = '[object WeakMap]',\n", | |
"\t weakSetTag = '[object WeakSet]';\n", | |
"\t\n", | |
"\t var arrayBufferTag = '[object ArrayBuffer]',\n", | |
"\t dataViewTag = '[object DataView]',\n", | |
"\t float32Tag = '[object Float32Array]',\n", | |
"\t float64Tag = '[object Float64Array]',\n", | |
"\t int8Tag = '[object Int8Array]',\n", | |
"\t int16Tag = '[object Int16Array]',\n", | |
"\t int32Tag = '[object Int32Array]',\n", | |
"\t uint8Tag = '[object Uint8Array]',\n", | |
"\t uint8ClampedTag = '[object Uint8ClampedArray]',\n", | |
"\t uint16Tag = '[object Uint16Array]',\n", | |
"\t uint32Tag = '[object Uint32Array]';\n", | |
"\t\n", | |
"\t /** Used to match empty string literals in compiled template source. */\n", | |
"\t var reEmptyStringLeading = /\\b__p \\+= '';/g,\n", | |
"\t reEmptyStringMiddle = /\\b(__p \\+=) '' \\+/g,\n", | |
"\t reEmptyStringTrailing = /(__e\\(.*?\\)|\\b__t\\)) \\+\\n'';/g;\n", | |
"\t\n", | |
"\t /** Used to match HTML entities and HTML characters. */\n", | |
"\t var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,\n", | |
"\t reUnescapedHtml = /[&<>\"']/g,\n", | |
"\t reHasEscapedHtml = RegExp(reEscapedHtml.source),\n", | |
"\t reHasUnescapedHtml = RegExp(reUnescapedHtml.source);\n", | |
"\t\n", | |
"\t /** Used to match template delimiters. */\n", | |
"\t var reEscape = /<%-([\\s\\S]+?)%>/g,\n", | |
"\t reEvaluate = /<%([\\s\\S]+?)%>/g,\n", | |
"\t reInterpolate = /<%=([\\s\\S]+?)%>/g;\n", | |
"\t\n", | |
"\t /** Used to match property names within property paths. */\n", | |
"\t var reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n", | |
"\t reIsPlainProp = /^\\w*$/,\n", | |
"\t reLeadingDot = /^\\./,\n", | |
"\t rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to match `RegExp`\n", | |
"\t * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n", | |
"\t */\n", | |
"\t var reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g,\n", | |
"\t reHasRegExpChar = RegExp(reRegExpChar.source);\n", | |
"\t\n", | |
"\t /** Used to match leading and trailing whitespace. */\n", | |
"\t var reTrim = /^\\s+|\\s+$/g,\n", | |
"\t reTrimStart = /^\\s+/,\n", | |
"\t reTrimEnd = /\\s+$/;\n", | |
"\t\n", | |
"\t /** Used to match wrap detail comments. */\n", | |
"\t var reWrapComment = /\\{(?:\\n\\/\\* \\[wrapped with .+\\] \\*\\/)?\\n?/,\n", | |
"\t reWrapDetails = /\\{\\n\\/\\* \\[wrapped with (.+)\\] \\*/,\n", | |
"\t reSplitDetails = /,? & /;\n", | |
"\t\n", | |
"\t /** Used to match words composed of alphanumeric characters. */\n", | |
"\t var reAsciiWord = /[^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]+/g;\n", | |
"\t\n", | |
"\t /** Used to match backslashes in property paths. */\n", | |
"\t var reEscapeChar = /\\\\(\\\\)?/g;\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to match\n", | |
"\t * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).\n", | |
"\t */\n", | |
"\t var reEsTemplate = /\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g;\n", | |
"\t\n", | |
"\t /** Used to match `RegExp` flags from their coerced string values. */\n", | |
"\t var reFlags = /\\w*$/;\n", | |
"\t\n", | |
"\t /** Used to detect bad signed hexadecimal string values. */\n", | |
"\t var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n", | |
"\t\n", | |
"\t /** Used to detect binary string values. */\n", | |
"\t var reIsBinary = /^0b[01]+$/i;\n", | |
"\t\n", | |
"\t /** Used to detect host constructors (Safari). */\n", | |
"\t var reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n", | |
"\t\n", | |
"\t /** Used to detect octal string values. */\n", | |
"\t var reIsOctal = /^0o[0-7]+$/i;\n", | |
"\t\n", | |
"\t /** Used to detect unsigned integer values. */\n", | |
"\t var reIsUint = /^(?:0|[1-9]\\d*)$/;\n", | |
"\t\n", | |
"\t /** Used to match Latin Unicode letters (excluding mathematical operators). */\n", | |
"\t var reLatin = /[\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\xff\\u0100-\\u017f]/g;\n", | |
"\t\n", | |
"\t /** Used to ensure capturing order of template delimiters. */\n", | |
"\t var reNoMatch = /($^)/;\n", | |
"\t\n", | |
"\t /** Used to match unescaped characters in compiled string literals. */\n", | |
"\t var reUnescapedString = /['\\n\\r\\u2028\\u2029\\\\]/g;\n", | |
"\t\n", | |
"\t /** Used to compose unicode character classes. */\n", | |
"\t var rsAstralRange = '\\\\ud800-\\\\udfff',\n", | |
"\t rsComboMarksRange = '\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe23',\n", | |
"\t rsComboSymbolsRange = '\\\\u20d0-\\\\u20f0',\n", | |
"\t rsDingbatRange = '\\\\u2700-\\\\u27bf',\n", | |
"\t rsLowerRange = 'a-z\\\\xdf-\\\\xf6\\\\xf8-\\\\xff',\n", | |
"\t rsMathOpRange = '\\\\xac\\\\xb1\\\\xd7\\\\xf7',\n", | |
"\t rsNonCharRange = '\\\\x00-\\\\x2f\\\\x3a-\\\\x40\\\\x5b-\\\\x60\\\\x7b-\\\\xbf',\n", | |
"\t rsPunctuationRange = '\\\\u2000-\\\\u206f',\n", | |
"\t rsSpaceRange = ' \\\\t\\\\x0b\\\\f\\\\xa0\\\\ufeff\\\\n\\\\r\\\\u2028\\\\u2029\\\\u1680\\\\u180e\\\\u2000\\\\u2001\\\\u2002\\\\u2003\\\\u2004\\\\u2005\\\\u2006\\\\u2007\\\\u2008\\\\u2009\\\\u200a\\\\u202f\\\\u205f\\\\u3000',\n", | |
"\t rsUpperRange = 'A-Z\\\\xc0-\\\\xd6\\\\xd8-\\\\xde',\n", | |
"\t rsVarRange = '\\\\ufe0e\\\\ufe0f',\n", | |
"\t rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;\n", | |
"\t\n", | |
"\t /** Used to compose unicode capture groups. */\n", | |
"\t var rsApos = \"['\\u2019]\",\n", | |
"\t rsAstral = '[' + rsAstralRange + ']',\n", | |
"\t rsBreak = '[' + rsBreakRange + ']',\n", | |
"\t rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',\n", | |
"\t rsDigits = '\\\\d+',\n", | |
"\t rsDingbat = '[' + rsDingbatRange + ']',\n", | |
"\t rsLower = '[' + rsLowerRange + ']',\n", | |
"\t rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',\n", | |
"\t rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]',\n", | |
"\t rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',\n", | |
"\t rsNonAstral = '[^' + rsAstralRange + ']',\n", | |
"\t rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}',\n", | |
"\t rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]',\n", | |
"\t rsUpper = '[' + rsUpperRange + ']',\n", | |
"\t rsZWJ = '\\\\u200d';\n", | |
"\t\n", | |
"\t /** Used to compose unicode regexes. */\n", | |
"\t var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',\n", | |
"\t rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',\n", | |
"\t rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',\n", | |
"\t rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',\n", | |
"\t reOptMod = rsModifier + '?',\n", | |
"\t rsOptVar = '[' + rsVarRange + ']?',\n", | |
"\t rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',\n", | |
"\t rsOrdLower = '\\\\d*(?:(?:1st|2nd|3rd|(?![123])\\\\dth)\\\\b)',\n", | |
"\t rsOrdUpper = '\\\\d*(?:(?:1ST|2ND|3RD|(?![123])\\\\dTH)\\\\b)',\n", | |
"\t rsSeq = rsOptVar + reOptMod + rsOptJoin,\n", | |
"\t rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,\n", | |
"\t rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';\n", | |
"\t\n", | |
"\t /** Used to match apostrophes. */\n", | |
"\t var reApos = RegExp(rsApos, 'g');\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and\n", | |
"\t * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).\n", | |
"\t */\n", | |
"\t var reComboMark = RegExp(rsCombo, 'g');\n", | |
"\t\n", | |
"\t /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */\n", | |
"\t var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');\n", | |
"\t\n", | |
"\t /** Used to match complex or compound words. */\n", | |
"\t var reUnicodeWord = RegExp([\n", | |
"\t rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',\n", | |
"\t rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',\n", | |
"\t rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,\n", | |
"\t rsUpper + '+' + rsOptContrUpper,\n", | |
"\t rsOrdUpper,\n", | |
"\t rsOrdLower,\n", | |
"\t rsDigits,\n", | |
"\t rsEmoji\n", | |
"\t ].join('|'), 'g');\n", | |
"\t\n", | |
"\t /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */\n", | |
"\t var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');\n", | |
"\t\n", | |
"\t /** Used to detect strings that need a more robust regexp to match words. */\n", | |
"\t var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;\n", | |
"\t\n", | |
"\t /** Used to assign default `context` object properties. */\n", | |
"\t var contextProps = [\n", | |
"\t 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',\n", | |
"\t 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',\n", | |
"\t 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',\n", | |
"\t 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',\n", | |
"\t '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'\n", | |
"\t ];\n", | |
"\t\n", | |
"\t /** Used to make template sourceURLs easier to identify. */\n", | |
"\t var templateCounter = -1;\n", | |
"\t\n", | |
"\t /** Used to identify `toStringTag` values of typed arrays. */\n", | |
"\t var typedArrayTags = {};\n", | |
"\t typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\n", | |
"\t typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\n", | |
"\t typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\n", | |
"\t typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\n", | |
"\t typedArrayTags[uint32Tag] = true;\n", | |
"\t typedArrayTags[argsTag] = typedArrayTags[arrayTag] =\n", | |
"\t typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\n", | |
"\t typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\n", | |
"\t typedArrayTags[errorTag] = typedArrayTags[funcTag] =\n", | |
"\t typedArrayTags[mapTag] = typedArrayTags[numberTag] =\n", | |
"\t typedArrayTags[objectTag] = typedArrayTags[regexpTag] =\n", | |
"\t typedArrayTags[setTag] = typedArrayTags[stringTag] =\n", | |
"\t typedArrayTags[weakMapTag] = false;\n", | |
"\t\n", | |
"\t /** Used to identify `toStringTag` values supported by `_.clone`. */\n", | |
"\t var cloneableTags = {};\n", | |
"\t cloneableTags[argsTag] = cloneableTags[arrayTag] =\n", | |
"\t cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =\n", | |
"\t cloneableTags[boolTag] = cloneableTags[dateTag] =\n", | |
"\t cloneableTags[float32Tag] = cloneableTags[float64Tag] =\n", | |
"\t cloneableTags[int8Tag] = cloneableTags[int16Tag] =\n", | |
"\t cloneableTags[int32Tag] = cloneableTags[mapTag] =\n", | |
"\t cloneableTags[numberTag] = cloneableTags[objectTag] =\n", | |
"\t cloneableTags[regexpTag] = cloneableTags[setTag] =\n", | |
"\t cloneableTags[stringTag] = cloneableTags[symbolTag] =\n", | |
"\t cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =\n", | |
"\t cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;\n", | |
"\t cloneableTags[errorTag] = cloneableTags[funcTag] =\n", | |
"\t cloneableTags[weakMapTag] = false;\n", | |
"\t\n", | |
"\t /** Used to map Latin Unicode letters to basic Latin letters. */\n", | |
"\t var deburredLetters = {\n", | |
"\t // Latin-1 Supplement block.\n", | |
"\t '\\xc0': 'A', '\\xc1': 'A', '\\xc2': 'A', '\\xc3': 'A', '\\xc4': 'A', '\\xc5': 'A',\n", | |
"\t '\\xe0': 'a', '\\xe1': 'a', '\\xe2': 'a', '\\xe3': 'a', '\\xe4': 'a', '\\xe5': 'a',\n", | |
"\t '\\xc7': 'C', '\\xe7': 'c',\n", | |
"\t '\\xd0': 'D', '\\xf0': 'd',\n", | |
"\t '\\xc8': 'E', '\\xc9': 'E', '\\xca': 'E', '\\xcb': 'E',\n", | |
"\t '\\xe8': 'e', '\\xe9': 'e', '\\xea': 'e', '\\xeb': 'e',\n", | |
"\t '\\xcc': 'I', '\\xcd': 'I', '\\xce': 'I', '\\xcf': 'I',\n", | |
"\t '\\xec': 'i', '\\xed': 'i', '\\xee': 'i', '\\xef': 'i',\n", | |
"\t '\\xd1': 'N', '\\xf1': 'n',\n", | |
"\t '\\xd2': 'O', '\\xd3': 'O', '\\xd4': 'O', '\\xd5': 'O', '\\xd6': 'O', '\\xd8': 'O',\n", | |
"\t '\\xf2': 'o', '\\xf3': 'o', '\\xf4': 'o', '\\xf5': 'o', '\\xf6': 'o', '\\xf8': 'o',\n", | |
"\t '\\xd9': 'U', '\\xda': 'U', '\\xdb': 'U', '\\xdc': 'U',\n", | |
"\t '\\xf9': 'u', '\\xfa': 'u', '\\xfb': 'u', '\\xfc': 'u',\n", | |
"\t '\\xdd': 'Y', '\\xfd': 'y', '\\xff': 'y',\n", | |
"\t '\\xc6': 'Ae', '\\xe6': 'ae',\n", | |
"\t '\\xde': 'Th', '\\xfe': 'th',\n", | |
"\t '\\xdf': 'ss',\n", | |
"\t // Latin Extended-A block.\n", | |
"\t '\\u0100': 'A', '\\u0102': 'A', '\\u0104': 'A',\n", | |
"\t '\\u0101': 'a', '\\u0103': 'a', '\\u0105': 'a',\n", | |
"\t '\\u0106': 'C', '\\u0108': 'C', '\\u010a': 'C', '\\u010c': 'C',\n", | |
"\t '\\u0107': 'c', '\\u0109': 'c', '\\u010b': 'c', '\\u010d': 'c',\n", | |
"\t '\\u010e': 'D', '\\u0110': 'D', '\\u010f': 'd', '\\u0111': 'd',\n", | |
"\t '\\u0112': 'E', '\\u0114': 'E', '\\u0116': 'E', '\\u0118': 'E', '\\u011a': 'E',\n", | |
"\t '\\u0113': 'e', '\\u0115': 'e', '\\u0117': 'e', '\\u0119': 'e', '\\u011b': 'e',\n", | |
"\t '\\u011c': 'G', '\\u011e': 'G', '\\u0120': 'G', '\\u0122': 'G',\n", | |
"\t '\\u011d': 'g', '\\u011f': 'g', '\\u0121': 'g', '\\u0123': 'g',\n", | |
"\t '\\u0124': 'H', '\\u0126': 'H', '\\u0125': 'h', '\\u0127': 'h',\n", | |
"\t '\\u0128': 'I', '\\u012a': 'I', '\\u012c': 'I', '\\u012e': 'I', '\\u0130': 'I',\n", | |
"\t '\\u0129': 'i', '\\u012b': 'i', '\\u012d': 'i', '\\u012f': 'i', '\\u0131': 'i',\n", | |
"\t '\\u0134': 'J', '\\u0135': 'j',\n", | |
"\t '\\u0136': 'K', '\\u0137': 'k', '\\u0138': 'k',\n", | |
"\t '\\u0139': 'L', '\\u013b': 'L', '\\u013d': 'L', '\\u013f': 'L', '\\u0141': 'L',\n", | |
"\t '\\u013a': 'l', '\\u013c': 'l', '\\u013e': 'l', '\\u0140': 'l', '\\u0142': 'l',\n", | |
"\t '\\u0143': 'N', '\\u0145': 'N', '\\u0147': 'N', '\\u014a': 'N',\n", | |
"\t '\\u0144': 'n', '\\u0146': 'n', '\\u0148': 'n', '\\u014b': 'n',\n", | |
"\t '\\u014c': 'O', '\\u014e': 'O', '\\u0150': 'O',\n", | |
"\t '\\u014d': 'o', '\\u014f': 'o', '\\u0151': 'o',\n", | |
"\t '\\u0154': 'R', '\\u0156': 'R', '\\u0158': 'R',\n", | |
"\t '\\u0155': 'r', '\\u0157': 'r', '\\u0159': 'r',\n", | |
"\t '\\u015a': 'S', '\\u015c': 'S', '\\u015e': 'S', '\\u0160': 'S',\n", | |
"\t '\\u015b': 's', '\\u015d': 's', '\\u015f': 's', '\\u0161': 's',\n", | |
"\t '\\u0162': 'T', '\\u0164': 'T', '\\u0166': 'T',\n", | |
"\t '\\u0163': 't', '\\u0165': 't', '\\u0167': 't',\n", | |
"\t '\\u0168': 'U', '\\u016a': 'U', '\\u016c': 'U', '\\u016e': 'U', '\\u0170': 'U', '\\u0172': 'U',\n", | |
"\t '\\u0169': 'u', '\\u016b': 'u', '\\u016d': 'u', '\\u016f': 'u', '\\u0171': 'u', '\\u0173': 'u',\n", | |
"\t '\\u0174': 'W', '\\u0175': 'w',\n", | |
"\t '\\u0176': 'Y', '\\u0177': 'y', '\\u0178': 'Y',\n", | |
"\t '\\u0179': 'Z', '\\u017b': 'Z', '\\u017d': 'Z',\n", | |
"\t '\\u017a': 'z', '\\u017c': 'z', '\\u017e': 'z',\n", | |
"\t '\\u0132': 'IJ', '\\u0133': 'ij',\n", | |
"\t '\\u0152': 'Oe', '\\u0153': 'oe',\n", | |
"\t '\\u0149': \"'n\", '\\u017f': 's'\n", | |
"\t };\n", | |
"\t\n", | |
"\t /** Used to map characters to HTML entities. */\n", | |
"\t var htmlEscapes = {\n", | |
"\t '&': '&',\n", | |
"\t '<': '<',\n", | |
"\t '>': '>',\n", | |
"\t '\"': '"',\n", | |
"\t \"'\": '''\n", | |
"\t };\n", | |
"\t\n", | |
"\t /** Used to map HTML entities to characters. */\n", | |
"\t var htmlUnescapes = {\n", | |
"\t '&': '&',\n", | |
"\t '<': '<',\n", | |
"\t '>': '>',\n", | |
"\t '"': '\"',\n", | |
"\t ''': \"'\"\n", | |
"\t };\n", | |
"\t\n", | |
"\t /** Used to escape characters for inclusion in compiled string literals. */\n", | |
"\t var stringEscapes = {\n", | |
"\t '\\\\': '\\\\',\n", | |
"\t \"'\": \"'\",\n", | |
"\t '\\n': 'n',\n", | |
"\t '\\r': 'r',\n", | |
"\t '\\u2028': 'u2028',\n", | |
"\t '\\u2029': 'u2029'\n", | |
"\t };\n", | |
"\t\n", | |
"\t /** Built-in method references without a dependency on `root`. */\n", | |
"\t var freeParseFloat = parseFloat,\n", | |
"\t freeParseInt = parseInt;\n", | |
"\t\n", | |
"\t /** Detect free variable `global` from Node.js. */\n", | |
"\t var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n", | |
"\t\n", | |
"\t /** Detect free variable `self`. */\n", | |
"\t var freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n", | |
"\t\n", | |
"\t /** Used as a reference to the global object. */\n", | |
"\t var root = freeGlobal || freeSelf || Function('return this')();\n", | |
"\t\n", | |
"\t /** Detect free variable `exports`. */\n", | |
"\t var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n", | |
"\t\n", | |
"\t /** Detect free variable `module`. */\n", | |
"\t var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n", | |
"\t\n", | |
"\t /** Detect the popular CommonJS extension `module.exports`. */\n", | |
"\t var moduleExports = freeModule && freeModule.exports === freeExports;\n", | |
"\t\n", | |
"\t /** Detect free variable `process` from Node.js. */\n", | |
"\t var freeProcess = moduleExports && freeGlobal.process;\n", | |
"\t\n", | |
"\t /** Used to access faster Node.js helpers. */\n", | |
"\t var nodeUtil = (function() {\n", | |
"\t try {\n", | |
"\t return freeProcess && freeProcess.binding('util');\n", | |
"\t } catch (e) {}\n", | |
"\t }());\n", | |
"\t\n", | |
"\t /* Node.js helper references. */\n", | |
"\t var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,\n", | |
"\t nodeIsDate = nodeUtil && nodeUtil.isDate,\n", | |
"\t nodeIsMap = nodeUtil && nodeUtil.isMap,\n", | |
"\t nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,\n", | |
"\t nodeIsSet = nodeUtil && nodeUtil.isSet,\n", | |
"\t nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n", | |
"\t\n", | |
"\t /*--------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Adds the key-value `pair` to `map`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} map The map to modify.\n", | |
"\t * @param {Array} pair The key-value pair to add.\n", | |
"\t * @returns {Object} Returns `map`.\n", | |
"\t */\n", | |
"\t function addMapEntry(map, pair) {\n", | |
"\t // Don't return `map.set` because it's not chainable in IE 11.\n", | |
"\t map.set(pair[0], pair[1]);\n", | |
"\t return map;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Adds `value` to `set`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} set The set to modify.\n", | |
"\t * @param {*} value The value to add.\n", | |
"\t * @returns {Object} Returns `set`.\n", | |
"\t */\n", | |
"\t function addSetEntry(set, value) {\n", | |
"\t // Don't return `set.add` because it's not chainable in IE 11.\n", | |
"\t set.add(value);\n", | |
"\t return set;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A faster alternative to `Function#apply`, this function invokes `func`\n", | |
"\t * with the `this` binding of `thisArg` and the arguments of `args`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to invoke.\n", | |
"\t * @param {*} thisArg The `this` binding of `func`.\n", | |
"\t * @param {Array} args The arguments to invoke `func` with.\n", | |
"\t * @returns {*} Returns the result of `func`.\n", | |
"\t */\n", | |
"\t function apply(func, thisArg, args) {\n", | |
"\t switch (args.length) {\n", | |
"\t case 0: return func.call(thisArg);\n", | |
"\t case 1: return func.call(thisArg, args[0]);\n", | |
"\t case 2: return func.call(thisArg, args[0], args[1]);\n", | |
"\t case 3: return func.call(thisArg, args[0], args[1], args[2]);\n", | |
"\t }\n", | |
"\t return func.apply(thisArg, args);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseAggregator` for arrays.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} setter The function to set `accumulator` values.\n", | |
"\t * @param {Function} iteratee The iteratee to transform keys.\n", | |
"\t * @param {Object} accumulator The initial aggregated object.\n", | |
"\t * @returns {Function} Returns `accumulator`.\n", | |
"\t */\n", | |
"\t function arrayAggregator(array, setter, iteratee, accumulator) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index];\n", | |
"\t setter(accumulator, value, iteratee(value), array);\n", | |
"\t }\n", | |
"\t return accumulator;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.forEach` for arrays without support for\n", | |
"\t * iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function arrayEach(array, iteratee) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t if (iteratee(array[index], index, array) === false) {\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.forEachRight` for arrays without support for\n", | |
"\t * iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function arrayEachRight(array, iteratee) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t\n", | |
"\t while (length--) {\n", | |
"\t if (iteratee(array[length], length, array) === false) {\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.every` for arrays without support for\n", | |
"\t * iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @returns {boolean} Returns `true` if all elements pass the predicate check,\n", | |
"\t * else `false`.\n", | |
"\t */\n", | |
"\t function arrayEvery(array, predicate) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t if (!predicate(array[index], index, array)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.filter` for arrays without support for\n", | |
"\t * iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the new filtered array.\n", | |
"\t */\n", | |
"\t function arrayFilter(array, predicate) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length,\n", | |
"\t resIndex = 0,\n", | |
"\t result = [];\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index];\n", | |
"\t if (predicate(value, index, array)) {\n", | |
"\t result[resIndex++] = value;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.includes` for arrays without support for\n", | |
"\t * specifying an index to search from.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to inspect.\n", | |
"\t * @param {*} target The value to search for.\n", | |
"\t * @returns {boolean} Returns `true` if `target` is found, else `false`.\n", | |
"\t */\n", | |
"\t function arrayIncludes(array, value) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t return !!length && baseIndexOf(array, value, 0) > -1;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This function is like `arrayIncludes` except that it accepts a comparator.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to inspect.\n", | |
"\t * @param {*} target The value to search for.\n", | |
"\t * @param {Function} comparator The comparator invoked per element.\n", | |
"\t * @returns {boolean} Returns `true` if `target` is found, else `false`.\n", | |
"\t */\n", | |
"\t function arrayIncludesWith(array, value, comparator) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t if (comparator(value, array[index])) {\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.map` for arrays without support for iteratee\n", | |
"\t * shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the new mapped array.\n", | |
"\t */\n", | |
"\t function arrayMap(array, iteratee) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length,\n", | |
"\t result = Array(length);\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t result[index] = iteratee(array[index], index, array);\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Appends the elements of `values` to `array`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {Array} values The values to append.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function arrayPush(array, values) {\n", | |
"\t var index = -1,\n", | |
"\t length = values.length,\n", | |
"\t offset = array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t array[offset + index] = values[index];\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.reduce` for arrays without support for\n", | |
"\t * iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @param {*} [accumulator] The initial value.\n", | |
"\t * @param {boolean} [initAccum] Specify using the first element of `array` as\n", | |
"\t * the initial value.\n", | |
"\t * @returns {*} Returns the accumulated value.\n", | |
"\t */\n", | |
"\t function arrayReduce(array, iteratee, accumulator, initAccum) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length;\n", | |
"\t\n", | |
"\t if (initAccum && length) {\n", | |
"\t accumulator = array[++index];\n", | |
"\t }\n", | |
"\t while (++index < length) {\n", | |
"\t accumulator = iteratee(accumulator, array[index], index, array);\n", | |
"\t }\n", | |
"\t return accumulator;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.reduceRight` for arrays without support for\n", | |
"\t * iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @param {*} [accumulator] The initial value.\n", | |
"\t * @param {boolean} [initAccum] Specify using the last element of `array` as\n", | |
"\t * the initial value.\n", | |
"\t * @returns {*} Returns the accumulated value.\n", | |
"\t */\n", | |
"\t function arrayReduceRight(array, iteratee, accumulator, initAccum) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (initAccum && length) {\n", | |
"\t accumulator = array[--length];\n", | |
"\t }\n", | |
"\t while (length--) {\n", | |
"\t accumulator = iteratee(accumulator, array[length], length, array);\n", | |
"\t }\n", | |
"\t return accumulator;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.some` for arrays without support for iteratee\n", | |
"\t * shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} [array] The array to iterate over.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @returns {boolean} Returns `true` if any element passes the predicate check,\n", | |
"\t * else `false`.\n", | |
"\t */\n", | |
"\t function arraySome(array, predicate) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t if (predicate(array[index], index, array)) {\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the size of an ASCII `string`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string inspect.\n", | |
"\t * @returns {number} Returns the string size.\n", | |
"\t */\n", | |
"\t var asciiSize = baseProperty('length');\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts an ASCII `string` to an array.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string to convert.\n", | |
"\t * @returns {Array} Returns the converted array.\n", | |
"\t */\n", | |
"\t function asciiToArray(string) {\n", | |
"\t return string.split('');\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Splits an ASCII `string` into an array of its words.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} The string to inspect.\n", | |
"\t * @returns {Array} Returns the words of `string`.\n", | |
"\t */\n", | |
"\t function asciiWords(string) {\n", | |
"\t return string.match(reAsciiWord) || [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of methods like `_.findKey` and `_.findLastKey`,\n", | |
"\t * without support for iteratee shorthands, which iterates over `collection`\n", | |
"\t * using `eachFunc`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to inspect.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @param {Function} eachFunc The function to iterate over `collection`.\n", | |
"\t * @returns {*} Returns the found element or its key, else `undefined`.\n", | |
"\t */\n", | |
"\t function baseFindKey(collection, predicate, eachFunc) {\n", | |
"\t var result;\n", | |
"\t eachFunc(collection, function(value, key, collection) {\n", | |
"\t if (predicate(value, key, collection)) {\n", | |
"\t result = key;\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.findIndex` and `_.findLastIndex` without\n", | |
"\t * support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @param {number} fromIndex The index to search from.\n", | |
"\t * @param {boolean} [fromRight] Specify iterating from right to left.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t */\n", | |
"\t function baseFindIndex(array, predicate, fromIndex, fromRight) {\n", | |
"\t var length = array.length,\n", | |
"\t index = fromIndex + (fromRight ? 1 : -1);\n", | |
"\t\n", | |
"\t while ((fromRight ? index-- : ++index < length)) {\n", | |
"\t if (predicate(array[index], index, array)) {\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.indexOf` without `fromIndex` bounds checks.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @param {number} fromIndex The index to search from.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t */\n", | |
"\t function baseIndexOf(array, value, fromIndex) {\n", | |
"\t return value === value\n", | |
"\t ? strictIndexOf(array, value, fromIndex)\n", | |
"\t : baseFindIndex(array, baseIsNaN, fromIndex);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This function is like `baseIndexOf` except that it accepts a comparator.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @param {number} fromIndex The index to search from.\n", | |
"\t * @param {Function} comparator The comparator invoked per element.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t */\n", | |
"\t function baseIndexOfWith(array, value, fromIndex, comparator) {\n", | |
"\t var index = fromIndex - 1,\n", | |
"\t length = array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t if (comparator(array[index], value)) {\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isNaN` without support for number objects.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsNaN(value) {\n", | |
"\t return value !== value;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.mean` and `_.meanBy` without support for\n", | |
"\t * iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {number} Returns the mean.\n", | |
"\t */\n", | |
"\t function baseMean(array, iteratee) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t return length ? (baseSum(array, iteratee) / length) : NAN;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.property` without support for deep paths.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} key The key of the property to get.\n", | |
"\t * @returns {Function} Returns the new accessor function.\n", | |
"\t */\n", | |
"\t function baseProperty(key) {\n", | |
"\t return function(object) {\n", | |
"\t return object == null ? undefined : object[key];\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.propertyOf` without support for deep paths.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Function} Returns the new accessor function.\n", | |
"\t */\n", | |
"\t function basePropertyOf(object) {\n", | |
"\t return function(key) {\n", | |
"\t return object == null ? undefined : object[key];\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.reduce` and `_.reduceRight`, without support\n", | |
"\t * for iteratee shorthands, which iterates over `collection` using `eachFunc`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @param {*} accumulator The initial value.\n", | |
"\t * @param {boolean} initAccum Specify using the first or last element of\n", | |
"\t * `collection` as the initial value.\n", | |
"\t * @param {Function} eachFunc The function to iterate over `collection`.\n", | |
"\t * @returns {*} Returns the accumulated value.\n", | |
"\t */\n", | |
"\t function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {\n", | |
"\t eachFunc(collection, function(value, index, collection) {\n", | |
"\t accumulator = initAccum\n", | |
"\t ? (initAccum = false, value)\n", | |
"\t : iteratee(accumulator, value, index, collection);\n", | |
"\t });\n", | |
"\t return accumulator;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.sortBy` which uses `comparer` to define the\n", | |
"\t * sort order of `array` and replaces criteria objects with their corresponding\n", | |
"\t * values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to sort.\n", | |
"\t * @param {Function} comparer The function to define sort order.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function baseSortBy(array, comparer) {\n", | |
"\t var length = array.length;\n", | |
"\t\n", | |
"\t array.sort(comparer);\n", | |
"\t while (length--) {\n", | |
"\t array[length] = array[length].value;\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.sum` and `_.sumBy` without support for\n", | |
"\t * iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {number} Returns the sum.\n", | |
"\t */\n", | |
"\t function baseSum(array, iteratee) {\n", | |
"\t var result,\n", | |
"\t index = -1,\n", | |
"\t length = array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var current = iteratee(array[index]);\n", | |
"\t if (current !== undefined) {\n", | |
"\t result = result === undefined ? current : (result + current);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.times` without support for iteratee shorthands\n", | |
"\t * or max array length checks.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {number} n The number of times to invoke `iteratee`.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the array of results.\n", | |
"\t */\n", | |
"\t function baseTimes(n, iteratee) {\n", | |
"\t var index = -1,\n", | |
"\t result = Array(n);\n", | |
"\t\n", | |
"\t while (++index < n) {\n", | |
"\t result[index] = iteratee(index);\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array\n", | |
"\t * of key-value pairs for `object` corresponding to the property names of `props`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @param {Array} props The property names to get values for.\n", | |
"\t * @returns {Object} Returns the key-value pairs.\n", | |
"\t */\n", | |
"\t function baseToPairs(object, props) {\n", | |
"\t return arrayMap(props, function(key) {\n", | |
"\t return [key, object[key]];\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.unary` without support for storing metadata.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to cap arguments for.\n", | |
"\t * @returns {Function} Returns the new capped function.\n", | |
"\t */\n", | |
"\t function baseUnary(func) {\n", | |
"\t return function(value) {\n", | |
"\t return func(value);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.values` and `_.valuesIn` which creates an\n", | |
"\t * array of `object` property values corresponding to the property names\n", | |
"\t * of `props`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @param {Array} props The property names to get values for.\n", | |
"\t * @returns {Object} Returns the array of property values.\n", | |
"\t */\n", | |
"\t function baseValues(object, props) {\n", | |
"\t return arrayMap(props, function(key) {\n", | |
"\t return object[key];\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if a `cache` value for `key` exists.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} cache The cache to query.\n", | |
"\t * @param {string} key The key of the entry to check.\n", | |
"\t * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n", | |
"\t */\n", | |
"\t function cacheHas(cache, key) {\n", | |
"\t return cache.has(key);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol\n", | |
"\t * that is not found in the character symbols.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} strSymbols The string symbols to inspect.\n", | |
"\t * @param {Array} chrSymbols The character symbols to find.\n", | |
"\t * @returns {number} Returns the index of the first unmatched string symbol.\n", | |
"\t */\n", | |
"\t function charsStartIndex(strSymbols, chrSymbols) {\n", | |
"\t var index = -1,\n", | |
"\t length = strSymbols.length;\n", | |
"\t\n", | |
"\t while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol\n", | |
"\t * that is not found in the character symbols.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} strSymbols The string symbols to inspect.\n", | |
"\t * @param {Array} chrSymbols The character symbols to find.\n", | |
"\t * @returns {number} Returns the index of the last unmatched string symbol.\n", | |
"\t */\n", | |
"\t function charsEndIndex(strSymbols, chrSymbols) {\n", | |
"\t var index = strSymbols.length;\n", | |
"\t\n", | |
"\t while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the number of `placeholder` occurrences in `array`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} placeholder The placeholder to search for.\n", | |
"\t * @returns {number} Returns the placeholder count.\n", | |
"\t */\n", | |
"\t function countHolders(array, placeholder) {\n", | |
"\t var length = array.length,\n", | |
"\t result = 0;\n", | |
"\t\n", | |
"\t while (length--) {\n", | |
"\t if (array[length] === placeholder) {\n", | |
"\t ++result;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A\n", | |
"\t * letters to basic Latin letters.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} letter The matched letter to deburr.\n", | |
"\t * @returns {string} Returns the deburred letter.\n", | |
"\t */\n", | |
"\t var deburrLetter = basePropertyOf(deburredLetters);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.escape` to convert characters to HTML entities.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} chr The matched character to escape.\n", | |
"\t * @returns {string} Returns the escaped character.\n", | |
"\t */\n", | |
"\t var escapeHtmlChar = basePropertyOf(htmlEscapes);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.template` to escape characters for inclusion in compiled string literals.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} chr The matched character to escape.\n", | |
"\t * @returns {string} Returns the escaped character.\n", | |
"\t */\n", | |
"\t function escapeStringChar(chr) {\n", | |
"\t return '\\\\' + stringEscapes[chr];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the value at `key` of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} [object] The object to query.\n", | |
"\t * @param {string} key The key of the property to get.\n", | |
"\t * @returns {*} Returns the property value.\n", | |
"\t */\n", | |
"\t function getValue(object, key) {\n", | |
"\t return object == null ? undefined : object[key];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `string` contains Unicode symbols.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string to inspect.\n", | |
"\t * @returns {boolean} Returns `true` if a symbol is found, else `false`.\n", | |
"\t */\n", | |
"\t function hasUnicode(string) {\n", | |
"\t return reHasUnicode.test(string);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `string` contains a word composed of Unicode symbols.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string to inspect.\n", | |
"\t * @returns {boolean} Returns `true` if a word is found, else `false`.\n", | |
"\t */\n", | |
"\t function hasUnicodeWord(string) {\n", | |
"\t return reHasUnicodeWord.test(string);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `iterator` to an array.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} iterator The iterator to convert.\n", | |
"\t * @returns {Array} Returns the converted array.\n", | |
"\t */\n", | |
"\t function iteratorToArray(iterator) {\n", | |
"\t var data,\n", | |
"\t result = [];\n", | |
"\t\n", | |
"\t while (!(data = iterator.next()).done) {\n", | |
"\t result.push(data.value);\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `map` to its key-value pairs.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} map The map to convert.\n", | |
"\t * @returns {Array} Returns the key-value pairs.\n", | |
"\t */\n", | |
"\t function mapToArray(map) {\n", | |
"\t var index = -1,\n", | |
"\t result = Array(map.size);\n", | |
"\t\n", | |
"\t map.forEach(function(value, key) {\n", | |
"\t result[++index] = [key, value];\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a unary function that invokes `func` with its argument transformed.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to wrap.\n", | |
"\t * @param {Function} transform The argument transform.\n", | |
"\t * @returns {Function} Returns the new function.\n", | |
"\t */\n", | |
"\t function overArg(func, transform) {\n", | |
"\t return function(arg) {\n", | |
"\t return func(transform(arg));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Replaces all `placeholder` elements in `array` with an internal placeholder\n", | |
"\t * and returns an array of their indexes.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {*} placeholder The placeholder to replace.\n", | |
"\t * @returns {Array} Returns the new array of placeholder indexes.\n", | |
"\t */\n", | |
"\t function replaceHolders(array, placeholder) {\n", | |
"\t var index = -1,\n", | |
"\t length = array.length,\n", | |
"\t resIndex = 0,\n", | |
"\t result = [];\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index];\n", | |
"\t if (value === placeholder || value === PLACEHOLDER) {\n", | |
"\t array[index] = PLACEHOLDER;\n", | |
"\t result[resIndex++] = index;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `set` to an array of its values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} set The set to convert.\n", | |
"\t * @returns {Array} Returns the values.\n", | |
"\t */\n", | |
"\t function setToArray(set) {\n", | |
"\t var index = -1,\n", | |
"\t result = Array(set.size);\n", | |
"\t\n", | |
"\t set.forEach(function(value) {\n", | |
"\t result[++index] = value;\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `set` to its value-value pairs.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} set The set to convert.\n", | |
"\t * @returns {Array} Returns the value-value pairs.\n", | |
"\t */\n", | |
"\t function setToPairs(set) {\n", | |
"\t var index = -1,\n", | |
"\t result = Array(set.size);\n", | |
"\t\n", | |
"\t set.forEach(function(value) {\n", | |
"\t result[++index] = [value, value];\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.indexOf` which performs strict equality\n", | |
"\t * comparisons of values, i.e. `===`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @param {number} fromIndex The index to search from.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t */\n", | |
"\t function strictIndexOf(array, value, fromIndex) {\n", | |
"\t var index = fromIndex - 1,\n", | |
"\t length = array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t if (array[index] === value) {\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.lastIndexOf` which performs strict equality\n", | |
"\t * comparisons of values, i.e. `===`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @param {number} fromIndex The index to search from.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t */\n", | |
"\t function strictLastIndexOf(array, value, fromIndex) {\n", | |
"\t var index = fromIndex + 1;\n", | |
"\t while (index--) {\n", | |
"\t if (array[index] === value) {\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the number of symbols in `string`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string to inspect.\n", | |
"\t * @returns {number} Returns the string size.\n", | |
"\t */\n", | |
"\t function stringSize(string) {\n", | |
"\t return hasUnicode(string)\n", | |
"\t ? unicodeSize(string)\n", | |
"\t : asciiSize(string);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `string` to an array.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string to convert.\n", | |
"\t * @returns {Array} Returns the converted array.\n", | |
"\t */\n", | |
"\t function stringToArray(string) {\n", | |
"\t return hasUnicode(string)\n", | |
"\t ? unicodeToArray(string)\n", | |
"\t : asciiToArray(string);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.unescape` to convert HTML entities to characters.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} chr The matched character to unescape.\n", | |
"\t * @returns {string} Returns the unescaped character.\n", | |
"\t */\n", | |
"\t var unescapeHtmlChar = basePropertyOf(htmlUnescapes);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the size of a Unicode `string`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string inspect.\n", | |
"\t * @returns {number} Returns the string size.\n", | |
"\t */\n", | |
"\t function unicodeSize(string) {\n", | |
"\t var result = reUnicode.lastIndex = 0;\n", | |
"\t while (reUnicode.test(string)) {\n", | |
"\t ++result;\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts a Unicode `string` to an array.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string to convert.\n", | |
"\t * @returns {Array} Returns the converted array.\n", | |
"\t */\n", | |
"\t function unicodeToArray(string) {\n", | |
"\t return string.match(reUnicode) || [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Splits a Unicode `string` into an array of its words.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} The string to inspect.\n", | |
"\t * @returns {Array} Returns the words of `string`.\n", | |
"\t */\n", | |
"\t function unicodeWords(string) {\n", | |
"\t return string.match(reUnicodeWord) || [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /*--------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Create a new pristine `lodash` function using the `context` object.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 1.1.0\n", | |
"\t * @category Util\n", | |
"\t * @param {Object} [context=root] The context object.\n", | |
"\t * @returns {Function} Returns a new `lodash` function.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.mixin({ 'foo': _.constant('foo') });\n", | |
"\t *\n", | |
"\t * var lodash = _.runInContext();\n", | |
"\t * lodash.mixin({ 'bar': lodash.constant('bar') });\n", | |
"\t *\n", | |
"\t * _.isFunction(_.foo);\n", | |
"\t * // => true\n", | |
"\t * _.isFunction(_.bar);\n", | |
"\t * // => false\n", | |
"\t *\n", | |
"\t * lodash.isFunction(lodash.foo);\n", | |
"\t * // => false\n", | |
"\t * lodash.isFunction(lodash.bar);\n", | |
"\t * // => true\n", | |
"\t *\n", | |
"\t * // Create a suped-up `defer` in Node.js.\n", | |
"\t * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;\n", | |
"\t */\n", | |
"\t var runInContext = (function runInContext(context) {\n", | |
"\t context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));\n", | |
"\t\n", | |
"\t /** Built-in constructor references. */\n", | |
"\t var Array = context.Array,\n", | |
"\t Date = context.Date,\n", | |
"\t Error = context.Error,\n", | |
"\t Function = context.Function,\n", | |
"\t Math = context.Math,\n", | |
"\t Object = context.Object,\n", | |
"\t RegExp = context.RegExp,\n", | |
"\t String = context.String,\n", | |
"\t TypeError = context.TypeError;\n", | |
"\t\n", | |
"\t /** Used for built-in method references. */\n", | |
"\t var arrayProto = Array.prototype,\n", | |
"\t funcProto = Function.prototype,\n", | |
"\t objectProto = Object.prototype;\n", | |
"\t\n", | |
"\t /** Used to detect overreaching core-js shims. */\n", | |
"\t var coreJsData = context['__core-js_shared__'];\n", | |
"\t\n", | |
"\t /** Used to resolve the decompiled source of functions. */\n", | |
"\t var funcToString = funcProto.toString;\n", | |
"\t\n", | |
"\t /** Used to check objects for own properties. */\n", | |
"\t var hasOwnProperty = objectProto.hasOwnProperty;\n", | |
"\t\n", | |
"\t /** Used to generate unique IDs. */\n", | |
"\t var idCounter = 0;\n", | |
"\t\n", | |
"\t /** Used to detect methods masquerading as native. */\n", | |
"\t var maskSrcKey = (function() {\n", | |
"\t var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n", | |
"\t return uid ? ('Symbol(src)_1.' + uid) : '';\n", | |
"\t }());\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to resolve the\n", | |
"\t * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n", | |
"\t * of values.\n", | |
"\t */\n", | |
"\t var nativeObjectToString = objectProto.toString;\n", | |
"\t\n", | |
"\t /** Used to infer the `Object` constructor. */\n", | |
"\t var objectCtorString = funcToString.call(Object);\n", | |
"\t\n", | |
"\t /** Used to restore the original `_` reference in `_.noConflict`. */\n", | |
"\t var oldDash = root._;\n", | |
"\t\n", | |
"\t /** Used to detect if a method is native. */\n", | |
"\t var reIsNative = RegExp('^' +\n", | |
"\t funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n", | |
"\t .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n", | |
"\t );\n", | |
"\t\n", | |
"\t /** Built-in value references. */\n", | |
"\t var Buffer = moduleExports ? context.Buffer : undefined,\n", | |
"\t Symbol = context.Symbol,\n", | |
"\t Uint8Array = context.Uint8Array,\n", | |
"\t allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,\n", | |
"\t getPrototype = overArg(Object.getPrototypeOf, Object),\n", | |
"\t objectCreate = Object.create,\n", | |
"\t propertyIsEnumerable = objectProto.propertyIsEnumerable,\n", | |
"\t splice = arrayProto.splice,\n", | |
"\t spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,\n", | |
"\t symIterator = Symbol ? Symbol.iterator : undefined,\n", | |
"\t symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n", | |
"\t\n", | |
"\t var defineProperty = (function() {\n", | |
"\t try {\n", | |
"\t var func = getNative(Object, 'defineProperty');\n", | |
"\t func({}, '', {});\n", | |
"\t return func;\n", | |
"\t } catch (e) {}\n", | |
"\t }());\n", | |
"\t\n", | |
"\t /** Mocked built-ins. */\n", | |
"\t var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,\n", | |
"\t ctxNow = Date && Date.now !== root.Date.now && Date.now,\n", | |
"\t ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;\n", | |
"\t\n", | |
"\t /* Built-in method references for those with the same name as other `lodash` methods. */\n", | |
"\t var nativeCeil = Math.ceil,\n", | |
"\t nativeFloor = Math.floor,\n", | |
"\t nativeGetSymbols = Object.getOwnPropertySymbols,\n", | |
"\t nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,\n", | |
"\t nativeIsFinite = context.isFinite,\n", | |
"\t nativeJoin = arrayProto.join,\n", | |
"\t nativeKeys = overArg(Object.keys, Object),\n", | |
"\t nativeMax = Math.max,\n", | |
"\t nativeMin = Math.min,\n", | |
"\t nativeNow = Date.now,\n", | |
"\t nativeParseInt = context.parseInt,\n", | |
"\t nativeRandom = Math.random,\n", | |
"\t nativeReverse = arrayProto.reverse;\n", | |
"\t\n", | |
"\t /* Built-in method references that are verified to be native. */\n", | |
"\t var DataView = getNative(context, 'DataView'),\n", | |
"\t Map = getNative(context, 'Map'),\n", | |
"\t Promise = getNative(context, 'Promise'),\n", | |
"\t Set = getNative(context, 'Set'),\n", | |
"\t WeakMap = getNative(context, 'WeakMap'),\n", | |
"\t nativeCreate = getNative(Object, 'create');\n", | |
"\t\n", | |
"\t /** Used to store function metadata. */\n", | |
"\t var metaMap = WeakMap && new WeakMap;\n", | |
"\t\n", | |
"\t /** Used to lookup unminified function names. */\n", | |
"\t var realNames = {};\n", | |
"\t\n", | |
"\t /** Used to detect maps, sets, and weakmaps. */\n", | |
"\t var dataViewCtorString = toSource(DataView),\n", | |
"\t mapCtorString = toSource(Map),\n", | |
"\t promiseCtorString = toSource(Promise),\n", | |
"\t setCtorString = toSource(Set),\n", | |
"\t weakMapCtorString = toSource(WeakMap);\n", | |
"\t\n", | |
"\t /** Used to convert symbols to primitives and strings. */\n", | |
"\t var symbolProto = Symbol ? Symbol.prototype : undefined,\n", | |
"\t symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,\n", | |
"\t symbolToString = symbolProto ? symbolProto.toString : undefined;\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a `lodash` object which wraps `value` to enable implicit method\n", | |
"\t * chain sequences. Methods that operate on and return arrays, collections,\n", | |
"\t * and functions can be chained together. Methods that retrieve a single value\n", | |
"\t * or may return a primitive value will automatically end the chain sequence\n", | |
"\t * and return the unwrapped value. Otherwise, the value must be unwrapped\n", | |
"\t * with `_#value`.\n", | |
"\t *\n", | |
"\t * Explicit chain sequences, which must be unwrapped with `_#value`, may be\n", | |
"\t * enabled using `_.chain`.\n", | |
"\t *\n", | |
"\t * The execution of chained methods is lazy, that is, it's deferred until\n", | |
"\t * `_#value` is implicitly or explicitly called.\n", | |
"\t *\n", | |
"\t * Lazy evaluation allows several methods to support shortcut fusion.\n", | |
"\t * Shortcut fusion is an optimization to merge iteratee calls; this avoids\n", | |
"\t * the creation of intermediate arrays and can greatly reduce the number of\n", | |
"\t * iteratee executions. Sections of a chain sequence qualify for shortcut\n", | |
"\t * fusion if the section is applied to an array of at least `200` elements\n", | |
"\t * and any iteratees accept only one argument. The heuristic for whether a\n", | |
"\t * section qualifies for shortcut fusion is subject to change.\n", | |
"\t *\n", | |
"\t * Chaining is supported in custom builds as long as the `_#value` method is\n", | |
"\t * directly or indirectly included in the build.\n", | |
"\t *\n", | |
"\t * In addition to lodash methods, wrappers have `Array` and `String` methods.\n", | |
"\t *\n", | |
"\t * The wrapper `Array` methods are:\n", | |
"\t * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`\n", | |
"\t *\n", | |
"\t * The wrapper `String` methods are:\n", | |
"\t * `replace` and `split`\n", | |
"\t *\n", | |
"\t * The wrapper methods that support shortcut fusion are:\n", | |
"\t * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,\n", | |
"\t * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,\n", | |
"\t * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`\n", | |
"\t *\n", | |
"\t * The chainable wrapper methods are:\n", | |
"\t * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,\n", | |
"\t * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,\n", | |
"\t * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,\n", | |
"\t * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,\n", | |
"\t * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,\n", | |
"\t * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,\n", | |
"\t * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,\n", | |
"\t * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,\n", | |
"\t * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,\n", | |
"\t * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,\n", | |
"\t * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,\n", | |
"\t * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,\n", | |
"\t * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,\n", | |
"\t * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,\n", | |
"\t * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,\n", | |
"\t * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,\n", | |
"\t * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,\n", | |
"\t * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,\n", | |
"\t * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,\n", | |
"\t * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,\n", | |
"\t * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,\n", | |
"\t * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,\n", | |
"\t * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,\n", | |
"\t * `zipObject`, `zipObjectDeep`, and `zipWith`\n", | |
"\t *\n", | |
"\t * The wrapper methods that are **not** chainable by default are:\n", | |
"\t * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,\n", | |
"\t * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,\n", | |
"\t * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,\n", | |
"\t * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,\n", | |
"\t * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,\n", | |
"\t * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,\n", | |
"\t * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,\n", | |
"\t * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,\n", | |
"\t * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,\n", | |
"\t * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,\n", | |
"\t * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,\n", | |
"\t * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,\n", | |
"\t * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,\n", | |
"\t * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,\n", | |
"\t * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,\n", | |
"\t * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,\n", | |
"\t * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,\n", | |
"\t * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,\n", | |
"\t * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,\n", | |
"\t * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,\n", | |
"\t * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,\n", | |
"\t * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,\n", | |
"\t * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,\n", | |
"\t * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,\n", | |
"\t * `upperFirst`, `value`, and `words`\n", | |
"\t *\n", | |
"\t * @name _\n", | |
"\t * @constructor\n", | |
"\t * @category Seq\n", | |
"\t * @param {*} value The value to wrap in a `lodash` instance.\n", | |
"\t * @returns {Object} Returns the new `lodash` wrapper instance.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * function square(n) {\n", | |
"\t * return n * n;\n", | |
"\t * }\n", | |
"\t *\n", | |
"\t * var wrapped = _([1, 2, 3]);\n", | |
"\t *\n", | |
"\t * // Returns an unwrapped value.\n", | |
"\t * wrapped.reduce(_.add);\n", | |
"\t * // => 6\n", | |
"\t *\n", | |
"\t * // Returns a wrapped value.\n", | |
"\t * var squares = wrapped.map(square);\n", | |
"\t *\n", | |
"\t * _.isArray(squares);\n", | |
"\t * // => false\n", | |
"\t *\n", | |
"\t * _.isArray(squares.value());\n", | |
"\t * // => true\n", | |
"\t */\n", | |
"\t function lodash(value) {\n", | |
"\t if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {\n", | |
"\t if (value instanceof LodashWrapper) {\n", | |
"\t return value;\n", | |
"\t }\n", | |
"\t if (hasOwnProperty.call(value, '__wrapped__')) {\n", | |
"\t return wrapperClone(value);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return new LodashWrapper(value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.create` without support for assigning\n", | |
"\t * properties to the created object.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} proto The object to inherit from.\n", | |
"\t * @returns {Object} Returns the new object.\n", | |
"\t */\n", | |
"\t var baseCreate = (function() {\n", | |
"\t function object() {}\n", | |
"\t return function(proto) {\n", | |
"\t if (!isObject(proto)) {\n", | |
"\t return {};\n", | |
"\t }\n", | |
"\t if (objectCreate) {\n", | |
"\t return objectCreate(proto);\n", | |
"\t }\n", | |
"\t object.prototype = proto;\n", | |
"\t var result = new object;\n", | |
"\t object.prototype = undefined;\n", | |
"\t return result;\n", | |
"\t };\n", | |
"\t }());\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The function whose prototype chain sequence wrappers inherit from.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t */\n", | |
"\t function baseLodash() {\n", | |
"\t // No operation performed.\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base constructor for creating `lodash` wrapper objects.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to wrap.\n", | |
"\t * @param {boolean} [chainAll] Enable explicit method chain sequences.\n", | |
"\t */\n", | |
"\t function LodashWrapper(value, chainAll) {\n", | |
"\t this.__wrapped__ = value;\n", | |
"\t this.__actions__ = [];\n", | |
"\t this.__chain__ = !!chainAll;\n", | |
"\t this.__index__ = 0;\n", | |
"\t this.__values__ = undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * By default, the template delimiters used by lodash are like those in\n", | |
"\t * embedded Ruby (ERB). Change the following template settings to use\n", | |
"\t * alternative delimiters.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @type {Object}\n", | |
"\t */\n", | |
"\t lodash.templateSettings = {\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to detect `data` property values to be HTML-escaped.\n", | |
"\t *\n", | |
"\t * @memberOf _.templateSettings\n", | |
"\t * @type {RegExp}\n", | |
"\t */\n", | |
"\t 'escape': reEscape,\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to detect code to be evaluated.\n", | |
"\t *\n", | |
"\t * @memberOf _.templateSettings\n", | |
"\t * @type {RegExp}\n", | |
"\t */\n", | |
"\t 'evaluate': reEvaluate,\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to detect `data` property values to inject.\n", | |
"\t *\n", | |
"\t * @memberOf _.templateSettings\n", | |
"\t * @type {RegExp}\n", | |
"\t */\n", | |
"\t 'interpolate': reInterpolate,\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to reference the data object in the template text.\n", | |
"\t *\n", | |
"\t * @memberOf _.templateSettings\n", | |
"\t * @type {string}\n", | |
"\t */\n", | |
"\t 'variable': '',\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used to import variables into the compiled template.\n", | |
"\t *\n", | |
"\t * @memberOf _.templateSettings\n", | |
"\t * @type {Object}\n", | |
"\t */\n", | |
"\t 'imports': {\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A reference to the `lodash` function.\n", | |
"\t *\n", | |
"\t * @memberOf _.templateSettings.imports\n", | |
"\t * @type {Function}\n", | |
"\t */\n", | |
"\t '_': lodash\n", | |
"\t }\n", | |
"\t };\n", | |
"\t\n", | |
"\t // Ensure wrappers are instances of `baseLodash`.\n", | |
"\t lodash.prototype = baseLodash.prototype;\n", | |
"\t lodash.prototype.constructor = lodash;\n", | |
"\t\n", | |
"\t LodashWrapper.prototype = baseCreate(baseLodash.prototype);\n", | |
"\t LodashWrapper.prototype.constructor = LodashWrapper;\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @constructor\n", | |
"\t * @param {*} value The value to wrap.\n", | |
"\t */\n", | |
"\t function LazyWrapper(value) {\n", | |
"\t this.__wrapped__ = value;\n", | |
"\t this.__actions__ = [];\n", | |
"\t this.__dir__ = 1;\n", | |
"\t this.__filtered__ = false;\n", | |
"\t this.__iteratees__ = [];\n", | |
"\t this.__takeCount__ = MAX_ARRAY_LENGTH;\n", | |
"\t this.__views__ = [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of the lazy wrapper object.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name clone\n", | |
"\t * @memberOf LazyWrapper\n", | |
"\t * @returns {Object} Returns the cloned `LazyWrapper` object.\n", | |
"\t */\n", | |
"\t function lazyClone() {\n", | |
"\t var result = new LazyWrapper(this.__wrapped__);\n", | |
"\t result.__actions__ = copyArray(this.__actions__);\n", | |
"\t result.__dir__ = this.__dir__;\n", | |
"\t result.__filtered__ = this.__filtered__;\n", | |
"\t result.__iteratees__ = copyArray(this.__iteratees__);\n", | |
"\t result.__takeCount__ = this.__takeCount__;\n", | |
"\t result.__views__ = copyArray(this.__views__);\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Reverses the direction of lazy iteration.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name reverse\n", | |
"\t * @memberOf LazyWrapper\n", | |
"\t * @returns {Object} Returns the new reversed `LazyWrapper` object.\n", | |
"\t */\n", | |
"\t function lazyReverse() {\n", | |
"\t if (this.__filtered__) {\n", | |
"\t var result = new LazyWrapper(this);\n", | |
"\t result.__dir__ = -1;\n", | |
"\t result.__filtered__ = true;\n", | |
"\t } else {\n", | |
"\t result = this.clone();\n", | |
"\t result.__dir__ *= -1;\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Extracts the unwrapped value from its lazy wrapper.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name value\n", | |
"\t * @memberOf LazyWrapper\n", | |
"\t * @returns {*} Returns the unwrapped value.\n", | |
"\t */\n", | |
"\t function lazyValue() {\n", | |
"\t var array = this.__wrapped__.value(),\n", | |
"\t dir = this.__dir__,\n", | |
"\t isArr = isArray(array),\n", | |
"\t isRight = dir < 0,\n", | |
"\t arrLength = isArr ? array.length : 0,\n", | |
"\t view = getView(0, arrLength, this.__views__),\n", | |
"\t start = view.start,\n", | |
"\t end = view.end,\n", | |
"\t length = end - start,\n", | |
"\t index = isRight ? end : (start - 1),\n", | |
"\t iteratees = this.__iteratees__,\n", | |
"\t iterLength = iteratees.length,\n", | |
"\t resIndex = 0,\n", | |
"\t takeCount = nativeMin(length, this.__takeCount__);\n", | |
"\t\n", | |
"\t if (!isArr || arrLength < LARGE_ARRAY_SIZE ||\n", | |
"\t (arrLength == length && takeCount == length)) {\n", | |
"\t return baseWrapperValue(array, this.__actions__);\n", | |
"\t }\n", | |
"\t var result = [];\n", | |
"\t\n", | |
"\t outer:\n", | |
"\t while (length-- && resIndex < takeCount) {\n", | |
"\t index += dir;\n", | |
"\t\n", | |
"\t var iterIndex = -1,\n", | |
"\t value = array[index];\n", | |
"\t\n", | |
"\t while (++iterIndex < iterLength) {\n", | |
"\t var data = iteratees[iterIndex],\n", | |
"\t iteratee = data.iteratee,\n", | |
"\t type = data.type,\n", | |
"\t computed = iteratee(value);\n", | |
"\t\n", | |
"\t if (type == LAZY_MAP_FLAG) {\n", | |
"\t value = computed;\n", | |
"\t } else if (!computed) {\n", | |
"\t if (type == LAZY_FILTER_FLAG) {\n", | |
"\t continue outer;\n", | |
"\t } else {\n", | |
"\t break outer;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t result[resIndex++] = value;\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t // Ensure `LazyWrapper` is an instance of `baseLodash`.\n", | |
"\t LazyWrapper.prototype = baseCreate(baseLodash.prototype);\n", | |
"\t LazyWrapper.prototype.constructor = LazyWrapper;\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a hash object.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @constructor\n", | |
"\t * @param {Array} [entries] The key-value pairs to cache.\n", | |
"\t */\n", | |
"\t function Hash(entries) {\n", | |
"\t var index = -1,\n", | |
"\t length = entries == null ? 0 : entries.length;\n", | |
"\t\n", | |
"\t this.clear();\n", | |
"\t while (++index < length) {\n", | |
"\t var entry = entries[index];\n", | |
"\t this.set(entry[0], entry[1]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes all key-value entries from the hash.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name clear\n", | |
"\t * @memberOf Hash\n", | |
"\t */\n", | |
"\t function hashClear() {\n", | |
"\t this.__data__ = nativeCreate ? nativeCreate(null) : {};\n", | |
"\t this.size = 0;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes `key` and its value from the hash.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name delete\n", | |
"\t * @memberOf Hash\n", | |
"\t * @param {Object} hash The hash to modify.\n", | |
"\t * @param {string} key The key of the value to remove.\n", | |
"\t * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n", | |
"\t */\n", | |
"\t function hashDelete(key) {\n", | |
"\t var result = this.has(key) && delete this.__data__[key];\n", | |
"\t this.size -= result ? 1 : 0;\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the hash value for `key`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name get\n", | |
"\t * @memberOf Hash\n", | |
"\t * @param {string} key The key of the value to get.\n", | |
"\t * @returns {*} Returns the entry value.\n", | |
"\t */\n", | |
"\t function hashGet(key) {\n", | |
"\t var data = this.__data__;\n", | |
"\t if (nativeCreate) {\n", | |
"\t var result = data[key];\n", | |
"\t return result === HASH_UNDEFINED ? undefined : result;\n", | |
"\t }\n", | |
"\t return hasOwnProperty.call(data, key) ? data[key] : undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if a hash value for `key` exists.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name has\n", | |
"\t * @memberOf Hash\n", | |
"\t * @param {string} key The key of the entry to check.\n", | |
"\t * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n", | |
"\t */\n", | |
"\t function hashHas(key) {\n", | |
"\t var data = this.__data__;\n", | |
"\t return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Sets the hash `key` to `value`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name set\n", | |
"\t * @memberOf Hash\n", | |
"\t * @param {string} key The key of the value to set.\n", | |
"\t * @param {*} value The value to set.\n", | |
"\t * @returns {Object} Returns the hash instance.\n", | |
"\t */\n", | |
"\t function hashSet(key, value) {\n", | |
"\t var data = this.__data__;\n", | |
"\t this.size += this.has(key) ? 0 : 1;\n", | |
"\t data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t\n", | |
"\t // Add methods to `Hash`.\n", | |
"\t Hash.prototype.clear = hashClear;\n", | |
"\t Hash.prototype['delete'] = hashDelete;\n", | |
"\t Hash.prototype.get = hashGet;\n", | |
"\t Hash.prototype.has = hashHas;\n", | |
"\t Hash.prototype.set = hashSet;\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an list cache object.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @constructor\n", | |
"\t * @param {Array} [entries] The key-value pairs to cache.\n", | |
"\t */\n", | |
"\t function ListCache(entries) {\n", | |
"\t var index = -1,\n", | |
"\t length = entries == null ? 0 : entries.length;\n", | |
"\t\n", | |
"\t this.clear();\n", | |
"\t while (++index < length) {\n", | |
"\t var entry = entries[index];\n", | |
"\t this.set(entry[0], entry[1]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes all key-value entries from the list cache.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name clear\n", | |
"\t * @memberOf ListCache\n", | |
"\t */\n", | |
"\t function listCacheClear() {\n", | |
"\t this.__data__ = [];\n", | |
"\t this.size = 0;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes `key` and its value from the list cache.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name delete\n", | |
"\t * @memberOf ListCache\n", | |
"\t * @param {string} key The key of the value to remove.\n", | |
"\t * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n", | |
"\t */\n", | |
"\t function listCacheDelete(key) {\n", | |
"\t var data = this.__data__,\n", | |
"\t index = assocIndexOf(data, key);\n", | |
"\t\n", | |
"\t if (index < 0) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t var lastIndex = data.length - 1;\n", | |
"\t if (index == lastIndex) {\n", | |
"\t data.pop();\n", | |
"\t } else {\n", | |
"\t splice.call(data, index, 1);\n", | |
"\t }\n", | |
"\t --this.size;\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the list cache value for `key`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name get\n", | |
"\t * @memberOf ListCache\n", | |
"\t * @param {string} key The key of the value to get.\n", | |
"\t * @returns {*} Returns the entry value.\n", | |
"\t */\n", | |
"\t function listCacheGet(key) {\n", | |
"\t var data = this.__data__,\n", | |
"\t index = assocIndexOf(data, key);\n", | |
"\t\n", | |
"\t return index < 0 ? undefined : data[index][1];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if a list cache value for `key` exists.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name has\n", | |
"\t * @memberOf ListCache\n", | |
"\t * @param {string} key The key of the entry to check.\n", | |
"\t * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n", | |
"\t */\n", | |
"\t function listCacheHas(key) {\n", | |
"\t return assocIndexOf(this.__data__, key) > -1;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Sets the list cache `key` to `value`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name set\n", | |
"\t * @memberOf ListCache\n", | |
"\t * @param {string} key The key of the value to set.\n", | |
"\t * @param {*} value The value to set.\n", | |
"\t * @returns {Object} Returns the list cache instance.\n", | |
"\t */\n", | |
"\t function listCacheSet(key, value) {\n", | |
"\t var data = this.__data__,\n", | |
"\t index = assocIndexOf(data, key);\n", | |
"\t\n", | |
"\t if (index < 0) {\n", | |
"\t ++this.size;\n", | |
"\t data.push([key, value]);\n", | |
"\t } else {\n", | |
"\t data[index][1] = value;\n", | |
"\t }\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t\n", | |
"\t // Add methods to `ListCache`.\n", | |
"\t ListCache.prototype.clear = listCacheClear;\n", | |
"\t ListCache.prototype['delete'] = listCacheDelete;\n", | |
"\t ListCache.prototype.get = listCacheGet;\n", | |
"\t ListCache.prototype.has = listCacheHas;\n", | |
"\t ListCache.prototype.set = listCacheSet;\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a map cache object to store key-value pairs.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @constructor\n", | |
"\t * @param {Array} [entries] The key-value pairs to cache.\n", | |
"\t */\n", | |
"\t function MapCache(entries) {\n", | |
"\t var index = -1,\n", | |
"\t length = entries == null ? 0 : entries.length;\n", | |
"\t\n", | |
"\t this.clear();\n", | |
"\t while (++index < length) {\n", | |
"\t var entry = entries[index];\n", | |
"\t this.set(entry[0], entry[1]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes all key-value entries from the map.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name clear\n", | |
"\t * @memberOf MapCache\n", | |
"\t */\n", | |
"\t function mapCacheClear() {\n", | |
"\t this.size = 0;\n", | |
"\t this.__data__ = {\n", | |
"\t 'hash': new Hash,\n", | |
"\t 'map': new (Map || ListCache),\n", | |
"\t 'string': new Hash\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes `key` and its value from the map.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name delete\n", | |
"\t * @memberOf MapCache\n", | |
"\t * @param {string} key The key of the value to remove.\n", | |
"\t * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n", | |
"\t */\n", | |
"\t function mapCacheDelete(key) {\n", | |
"\t var result = getMapData(this, key)['delete'](key);\n", | |
"\t this.size -= result ? 1 : 0;\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the map value for `key`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name get\n", | |
"\t * @memberOf MapCache\n", | |
"\t * @param {string} key The key of the value to get.\n", | |
"\t * @returns {*} Returns the entry value.\n", | |
"\t */\n", | |
"\t function mapCacheGet(key) {\n", | |
"\t return getMapData(this, key).get(key);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if a map value for `key` exists.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name has\n", | |
"\t * @memberOf MapCache\n", | |
"\t * @param {string} key The key of the entry to check.\n", | |
"\t * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n", | |
"\t */\n", | |
"\t function mapCacheHas(key) {\n", | |
"\t return getMapData(this, key).has(key);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Sets the map `key` to `value`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name set\n", | |
"\t * @memberOf MapCache\n", | |
"\t * @param {string} key The key of the value to set.\n", | |
"\t * @param {*} value The value to set.\n", | |
"\t * @returns {Object} Returns the map cache instance.\n", | |
"\t */\n", | |
"\t function mapCacheSet(key, value) {\n", | |
"\t var data = getMapData(this, key),\n", | |
"\t size = data.size;\n", | |
"\t\n", | |
"\t data.set(key, value);\n", | |
"\t this.size += data.size == size ? 0 : 1;\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t\n", | |
"\t // Add methods to `MapCache`.\n", | |
"\t MapCache.prototype.clear = mapCacheClear;\n", | |
"\t MapCache.prototype['delete'] = mapCacheDelete;\n", | |
"\t MapCache.prototype.get = mapCacheGet;\n", | |
"\t MapCache.prototype.has = mapCacheHas;\n", | |
"\t MapCache.prototype.set = mapCacheSet;\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t *\n", | |
"\t * Creates an array cache object to store unique values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @constructor\n", | |
"\t * @param {Array} [values] The values to cache.\n", | |
"\t */\n", | |
"\t function SetCache(values) {\n", | |
"\t var index = -1,\n", | |
"\t length = values == null ? 0 : values.length;\n", | |
"\t\n", | |
"\t this.__data__ = new MapCache;\n", | |
"\t while (++index < length) {\n", | |
"\t this.add(values[index]);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Adds `value` to the array cache.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name add\n", | |
"\t * @memberOf SetCache\n", | |
"\t * @alias push\n", | |
"\t * @param {*} value The value to cache.\n", | |
"\t * @returns {Object} Returns the cache instance.\n", | |
"\t */\n", | |
"\t function setCacheAdd(value) {\n", | |
"\t this.__data__.set(value, HASH_UNDEFINED);\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `value` is in the array cache.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name has\n", | |
"\t * @memberOf SetCache\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @returns {number} Returns `true` if `value` is found, else `false`.\n", | |
"\t */\n", | |
"\t function setCacheHas(value) {\n", | |
"\t return this.__data__.has(value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t // Add methods to `SetCache`.\n", | |
"\t SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\n", | |
"\t SetCache.prototype.has = setCacheHas;\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a stack cache object to store key-value pairs.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @constructor\n", | |
"\t * @param {Array} [entries] The key-value pairs to cache.\n", | |
"\t */\n", | |
"\t function Stack(entries) {\n", | |
"\t var data = this.__data__ = new ListCache(entries);\n", | |
"\t this.size = data.size;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes all key-value entries from the stack.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name clear\n", | |
"\t * @memberOf Stack\n", | |
"\t */\n", | |
"\t function stackClear() {\n", | |
"\t this.__data__ = new ListCache;\n", | |
"\t this.size = 0;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes `key` and its value from the stack.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name delete\n", | |
"\t * @memberOf Stack\n", | |
"\t * @param {string} key The key of the value to remove.\n", | |
"\t * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n", | |
"\t */\n", | |
"\t function stackDelete(key) {\n", | |
"\t var data = this.__data__,\n", | |
"\t result = data['delete'](key);\n", | |
"\t\n", | |
"\t this.size = data.size;\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the stack value for `key`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name get\n", | |
"\t * @memberOf Stack\n", | |
"\t * @param {string} key The key of the value to get.\n", | |
"\t * @returns {*} Returns the entry value.\n", | |
"\t */\n", | |
"\t function stackGet(key) {\n", | |
"\t return this.__data__.get(key);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if a stack value for `key` exists.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name has\n", | |
"\t * @memberOf Stack\n", | |
"\t * @param {string} key The key of the entry to check.\n", | |
"\t * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n", | |
"\t */\n", | |
"\t function stackHas(key) {\n", | |
"\t return this.__data__.has(key);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Sets the stack `key` to `value`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @name set\n", | |
"\t * @memberOf Stack\n", | |
"\t * @param {string} key The key of the value to set.\n", | |
"\t * @param {*} value The value to set.\n", | |
"\t * @returns {Object} Returns the stack cache instance.\n", | |
"\t */\n", | |
"\t function stackSet(key, value) {\n", | |
"\t var data = this.__data__;\n", | |
"\t if (data instanceof ListCache) {\n", | |
"\t var pairs = data.__data__;\n", | |
"\t if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n", | |
"\t pairs.push([key, value]);\n", | |
"\t this.size = ++data.size;\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t data = this.__data__ = new MapCache(pairs);\n", | |
"\t }\n", | |
"\t data.set(key, value);\n", | |
"\t this.size = data.size;\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t\n", | |
"\t // Add methods to `Stack`.\n", | |
"\t Stack.prototype.clear = stackClear;\n", | |
"\t Stack.prototype['delete'] = stackDelete;\n", | |
"\t Stack.prototype.get = stackGet;\n", | |
"\t Stack.prototype.has = stackHas;\n", | |
"\t Stack.prototype.set = stackSet;\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of the enumerable property names of the array-like `value`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to query.\n", | |
"\t * @param {boolean} inherited Specify returning inherited property names.\n", | |
"\t * @returns {Array} Returns the array of property names.\n", | |
"\t */\n", | |
"\t function arrayLikeKeys(value, inherited) {\n", | |
"\t var isArr = isArray(value),\n", | |
"\t isArg = !isArr && isArguments(value),\n", | |
"\t isBuff = !isArr && !isArg && isBuffer(value),\n", | |
"\t isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n", | |
"\t skipIndexes = isArr || isArg || isBuff || isType,\n", | |
"\t result = skipIndexes ? baseTimes(value.length, String) : [],\n", | |
"\t length = result.length;\n", | |
"\t\n", | |
"\t for (var key in value) {\n", | |
"\t if ((inherited || hasOwnProperty.call(value, key)) &&\n", | |
"\t !(skipIndexes && (\n", | |
"\t // Safari 9 has enumerable `arguments.length` in strict mode.\n", | |
"\t key == 'length' ||\n", | |
"\t // Node.js 0.10 has enumerable non-index properties on buffers.\n", | |
"\t (isBuff && (key == 'offset' || key == 'parent')) ||\n", | |
"\t // PhantomJS 2 has enumerable non-index properties on typed arrays.\n", | |
"\t (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n", | |
"\t // Skip index properties.\n", | |
"\t isIndex(key, length)\n", | |
"\t ))) {\n", | |
"\t result.push(key);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.sample` for arrays.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to sample.\n", | |
"\t * @returns {*} Returns the random element.\n", | |
"\t */\n", | |
"\t function arraySample(array) {\n", | |
"\t var length = array.length;\n", | |
"\t return length ? array[baseRandom(0, length - 1)] : undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.sampleSize` for arrays.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to sample.\n", | |
"\t * @param {number} n The number of elements to sample.\n", | |
"\t * @returns {Array} Returns the random elements.\n", | |
"\t */\n", | |
"\t function arraySampleSize(array, n) {\n", | |
"\t return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.shuffle` for arrays.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to shuffle.\n", | |
"\t * @returns {Array} Returns the new shuffled array.\n", | |
"\t */\n", | |
"\t function arrayShuffle(array) {\n", | |
"\t return shuffleSelf(copyArray(array));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.defaults` to customize its `_.assignIn` use.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} objValue The destination value.\n", | |
"\t * @param {*} srcValue The source value.\n", | |
"\t * @param {string} key The key of the property to assign.\n", | |
"\t * @param {Object} object The parent object of `objValue`.\n", | |
"\t * @returns {*} Returns the value to assign.\n", | |
"\t */\n", | |
"\t function assignInDefaults(objValue, srcValue, key, object) {\n", | |
"\t if (objValue === undefined ||\n", | |
"\t (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {\n", | |
"\t return srcValue;\n", | |
"\t }\n", | |
"\t return objValue;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This function is like `assignValue` except that it doesn't assign\n", | |
"\t * `undefined` values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to modify.\n", | |
"\t * @param {string} key The key of the property to assign.\n", | |
"\t * @param {*} value The value to assign.\n", | |
"\t */\n", | |
"\t function assignMergeValue(object, key, value) {\n", | |
"\t if ((value !== undefined && !eq(object[key], value)) ||\n", | |
"\t (value === undefined && !(key in object))) {\n", | |
"\t baseAssignValue(object, key, value);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Assigns `value` to `key` of `object` if the existing value is not equivalent\n", | |
"\t * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n", | |
"\t * for equality comparisons.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to modify.\n", | |
"\t * @param {string} key The key of the property to assign.\n", | |
"\t * @param {*} value The value to assign.\n", | |
"\t */\n", | |
"\t function assignValue(object, key, value) {\n", | |
"\t var objValue = object[key];\n", | |
"\t if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||\n", | |
"\t (value === undefined && !(key in object))) {\n", | |
"\t baseAssignValue(object, key, value);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the index at which the `key` is found in `array` of key-value pairs.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} key The key to search for.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t */\n", | |
"\t function assocIndexOf(array, key) {\n", | |
"\t var length = array.length;\n", | |
"\t while (length--) {\n", | |
"\t if (eq(array[length][0], key)) {\n", | |
"\t return length;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Aggregates elements of `collection` on `accumulator` with keys transformed\n", | |
"\t * by `iteratee` and values set by `setter`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function} setter The function to set `accumulator` values.\n", | |
"\t * @param {Function} iteratee The iteratee to transform keys.\n", | |
"\t * @param {Object} accumulator The initial aggregated object.\n", | |
"\t * @returns {Function} Returns `accumulator`.\n", | |
"\t */\n", | |
"\t function baseAggregator(collection, setter, iteratee, accumulator) {\n", | |
"\t baseEach(collection, function(value, key, collection) {\n", | |
"\t setter(accumulator, value, iteratee(value), collection);\n", | |
"\t });\n", | |
"\t return accumulator;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.assign` without support for multiple sources\n", | |
"\t * or `customizer` functions.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The destination object.\n", | |
"\t * @param {Object} source The source object.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t function baseAssign(object, source) {\n", | |
"\t return object && copyObject(source, keys(source), object);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `assignValue` and `assignMergeValue` without\n", | |
"\t * value checks.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to modify.\n", | |
"\t * @param {string} key The key of the property to assign.\n", | |
"\t * @param {*} value The value to assign.\n", | |
"\t */\n", | |
"\t function baseAssignValue(object, key, value) {\n", | |
"\t if (key == '__proto__' && defineProperty) {\n", | |
"\t defineProperty(object, key, {\n", | |
"\t 'configurable': true,\n", | |
"\t 'enumerable': true,\n", | |
"\t 'value': value,\n", | |
"\t 'writable': true\n", | |
"\t });\n", | |
"\t } else {\n", | |
"\t object[key] = value;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.at` without support for individual paths.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to iterate over.\n", | |
"\t * @param {string[]} paths The property paths of elements to pick.\n", | |
"\t * @returns {Array} Returns the picked elements.\n", | |
"\t */\n", | |
"\t function baseAt(object, paths) {\n", | |
"\t var index = -1,\n", | |
"\t length = paths.length,\n", | |
"\t result = Array(length),\n", | |
"\t skip = object == null;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t result[index] = skip ? undefined : get(object, paths[index]);\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.clamp` which doesn't coerce arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {number} number The number to clamp.\n", | |
"\t * @param {number} [lower] The lower bound.\n", | |
"\t * @param {number} upper The upper bound.\n", | |
"\t * @returns {number} Returns the clamped number.\n", | |
"\t */\n", | |
"\t function baseClamp(number, lower, upper) {\n", | |
"\t if (number === number) {\n", | |
"\t if (upper !== undefined) {\n", | |
"\t number = number <= upper ? number : upper;\n", | |
"\t }\n", | |
"\t if (lower !== undefined) {\n", | |
"\t number = number >= lower ? number : lower;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return number;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.clone` and `_.cloneDeep` which tracks\n", | |
"\t * traversed objects.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to clone.\n", | |
"\t * @param {boolean} [isDeep] Specify a deep clone.\n", | |
"\t * @param {boolean} [isFull] Specify a clone including symbols.\n", | |
"\t * @param {Function} [customizer] The function to customize cloning.\n", | |
"\t * @param {string} [key] The key of `value`.\n", | |
"\t * @param {Object} [object] The parent object of `value`.\n", | |
"\t * @param {Object} [stack] Tracks traversed objects and their clone counterparts.\n", | |
"\t * @returns {*} Returns the cloned value.\n", | |
"\t */\n", | |
"\t function baseClone(value, isDeep, isFull, customizer, key, object, stack) {\n", | |
"\t var result;\n", | |
"\t if (customizer) {\n", | |
"\t result = object ? customizer(value, key, object, stack) : customizer(value);\n", | |
"\t }\n", | |
"\t if (result !== undefined) {\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t if (!isObject(value)) {\n", | |
"\t return value;\n", | |
"\t }\n", | |
"\t var isArr = isArray(value);\n", | |
"\t if (isArr) {\n", | |
"\t result = initCloneArray(value);\n", | |
"\t if (!isDeep) {\n", | |
"\t return copyArray(value, result);\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t var tag = getTag(value),\n", | |
"\t isFunc = tag == funcTag || tag == genTag;\n", | |
"\t\n", | |
"\t if (isBuffer(value)) {\n", | |
"\t return cloneBuffer(value, isDeep);\n", | |
"\t }\n", | |
"\t if (tag == objectTag || tag == argsTag || (isFunc && !object)) {\n", | |
"\t result = initCloneObject(isFunc ? {} : value);\n", | |
"\t if (!isDeep) {\n", | |
"\t return copySymbols(value, baseAssign(result, value));\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t if (!cloneableTags[tag]) {\n", | |
"\t return object ? value : {};\n", | |
"\t }\n", | |
"\t result = initCloneByTag(value, tag, baseClone, isDeep);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t // Check for circular references and return its corresponding clone.\n", | |
"\t stack || (stack = new Stack);\n", | |
"\t var stacked = stack.get(value);\n", | |
"\t if (stacked) {\n", | |
"\t return stacked;\n", | |
"\t }\n", | |
"\t stack.set(value, result);\n", | |
"\t\n", | |
"\t var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value);\n", | |
"\t arrayEach(props || value, function(subValue, key) {\n", | |
"\t if (props) {\n", | |
"\t key = subValue;\n", | |
"\t subValue = value[key];\n", | |
"\t }\n", | |
"\t // Recursively populate clone (susceptible to call stack limits).\n", | |
"\t assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.conforms` which doesn't clone `source`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} source The object of property predicates to conform to.\n", | |
"\t * @returns {Function} Returns the new spec function.\n", | |
"\t */\n", | |
"\t function baseConforms(source) {\n", | |
"\t var props = keys(source);\n", | |
"\t return function(object) {\n", | |
"\t return baseConformsTo(object, source, props);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.conformsTo` which accepts `props` to check.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to inspect.\n", | |
"\t * @param {Object} source The object of property predicates to conform to.\n", | |
"\t * @returns {boolean} Returns `true` if `object` conforms, else `false`.\n", | |
"\t */\n", | |
"\t function baseConformsTo(object, source, props) {\n", | |
"\t var length = props.length;\n", | |
"\t if (object == null) {\n", | |
"\t return !length;\n", | |
"\t }\n", | |
"\t object = Object(object);\n", | |
"\t while (length--) {\n", | |
"\t var key = props[length],\n", | |
"\t predicate = source[key],\n", | |
"\t value = object[key];\n", | |
"\t\n", | |
"\t if ((value === undefined && !(key in object)) || !predicate(value)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.delay` and `_.defer` which accepts `args`\n", | |
"\t * to provide to `func`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to delay.\n", | |
"\t * @param {number} wait The number of milliseconds to delay invocation.\n", | |
"\t * @param {Array} args The arguments to provide to `func`.\n", | |
"\t * @returns {number|Object} Returns the timer id or timeout object.\n", | |
"\t */\n", | |
"\t function baseDelay(func, wait, args) {\n", | |
"\t if (typeof func != 'function') {\n", | |
"\t throw new TypeError(FUNC_ERROR_TEXT);\n", | |
"\t }\n", | |
"\t return setTimeout(function() { func.apply(undefined, args); }, wait);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of methods like `_.difference` without support\n", | |
"\t * for excluding multiple arrays or iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Array} values The values to exclude.\n", | |
"\t * @param {Function} [iteratee] The iteratee invoked per element.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t */\n", | |
"\t function baseDifference(array, values, iteratee, comparator) {\n", | |
"\t var index = -1,\n", | |
"\t includes = arrayIncludes,\n", | |
"\t isCommon = true,\n", | |
"\t length = array.length,\n", | |
"\t result = [],\n", | |
"\t valuesLength = values.length;\n", | |
"\t\n", | |
"\t if (!length) {\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t if (iteratee) {\n", | |
"\t values = arrayMap(values, baseUnary(iteratee));\n", | |
"\t }\n", | |
"\t if (comparator) {\n", | |
"\t includes = arrayIncludesWith;\n", | |
"\t isCommon = false;\n", | |
"\t }\n", | |
"\t else if (values.length >= LARGE_ARRAY_SIZE) {\n", | |
"\t includes = cacheHas;\n", | |
"\t isCommon = false;\n", | |
"\t values = new SetCache(values);\n", | |
"\t }\n", | |
"\t outer:\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index],\n", | |
"\t computed = iteratee == null ? value : iteratee(value);\n", | |
"\t\n", | |
"\t value = (comparator || value !== 0) ? value : 0;\n", | |
"\t if (isCommon && computed === computed) {\n", | |
"\t var valuesIndex = valuesLength;\n", | |
"\t while (valuesIndex--) {\n", | |
"\t if (values[valuesIndex] === computed) {\n", | |
"\t continue outer;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t result.push(value);\n", | |
"\t }\n", | |
"\t else if (!includes(values, computed, comparator)) {\n", | |
"\t result.push(value);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.forEach` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Array|Object} Returns `collection`.\n", | |
"\t */\n", | |
"\t var baseEach = createBaseEach(baseForOwn);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.forEachRight` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Array|Object} Returns `collection`.\n", | |
"\t */\n", | |
"\t var baseEachRight = createBaseEach(baseForOwnRight, true);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.every` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @returns {boolean} Returns `true` if all elements pass the predicate check,\n", | |
"\t * else `false`\n", | |
"\t */\n", | |
"\t function baseEvery(collection, predicate) {\n", | |
"\t var result = true;\n", | |
"\t baseEach(collection, function(value, index, collection) {\n", | |
"\t result = !!predicate(value, index, collection);\n", | |
"\t return result;\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of methods like `_.max` and `_.min` which accepts a\n", | |
"\t * `comparator` to determine the extremum value.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to iterate over.\n", | |
"\t * @param {Function} iteratee The iteratee invoked per iteration.\n", | |
"\t * @param {Function} comparator The comparator used to compare values.\n", | |
"\t * @returns {*} Returns the extremum value.\n", | |
"\t */\n", | |
"\t function baseExtremum(array, iteratee, comparator) {\n", | |
"\t var index = -1,\n", | |
"\t length = array.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index],\n", | |
"\t current = iteratee(value);\n", | |
"\t\n", | |
"\t if (current != null && (computed === undefined\n", | |
"\t ? (current === current && !isSymbol(current))\n", | |
"\t : comparator(current, computed)\n", | |
"\t )) {\n", | |
"\t var computed = current,\n", | |
"\t result = value;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.fill` without an iteratee call guard.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to fill.\n", | |
"\t * @param {*} value The value to fill `array` with.\n", | |
"\t * @param {number} [start=0] The start position.\n", | |
"\t * @param {number} [end=array.length] The end position.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function baseFill(array, value, start, end) {\n", | |
"\t var length = array.length;\n", | |
"\t\n", | |
"\t start = toInteger(start);\n", | |
"\t if (start < 0) {\n", | |
"\t start = -start > length ? 0 : (length + start);\n", | |
"\t }\n", | |
"\t end = (end === undefined || end > length) ? length : toInteger(end);\n", | |
"\t if (end < 0) {\n", | |
"\t end += length;\n", | |
"\t }\n", | |
"\t end = start > end ? 0 : toLength(end);\n", | |
"\t while (start < end) {\n", | |
"\t array[start++] = value;\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.filter` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the new filtered array.\n", | |
"\t */\n", | |
"\t function baseFilter(collection, predicate) {\n", | |
"\t var result = [];\n", | |
"\t baseEach(collection, function(value, index, collection) {\n", | |
"\t if (predicate(value, index, collection)) {\n", | |
"\t result.push(value);\n", | |
"\t }\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.flatten` with support for restricting flattening.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to flatten.\n", | |
"\t * @param {number} depth The maximum recursion depth.\n", | |
"\t * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.\n", | |
"\t * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.\n", | |
"\t * @param {Array} [result=[]] The initial result value.\n", | |
"\t * @returns {Array} Returns the new flattened array.\n", | |
"\t */\n", | |
"\t function baseFlatten(array, depth, predicate, isStrict, result) {\n", | |
"\t var index = -1,\n", | |
"\t length = array.length;\n", | |
"\t\n", | |
"\t predicate || (predicate = isFlattenable);\n", | |
"\t result || (result = []);\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index];\n", | |
"\t if (depth > 0 && predicate(value)) {\n", | |
"\t if (depth > 1) {\n", | |
"\t // Recursively flatten arrays (susceptible to call stack limits).\n", | |
"\t baseFlatten(value, depth - 1, predicate, isStrict, result);\n", | |
"\t } else {\n", | |
"\t arrayPush(result, value);\n", | |
"\t }\n", | |
"\t } else if (!isStrict) {\n", | |
"\t result[result.length] = value;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `baseForOwn` which iterates over `object`\n", | |
"\t * properties returned by `keysFunc` and invokes `iteratee` for each property.\n", | |
"\t * Iteratee functions may exit iteration early by explicitly returning `false`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @param {Function} keysFunc The function to get the keys of `object`.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t var baseFor = createBaseFor();\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This function is like `baseFor` except that it iterates over properties\n", | |
"\t * in the opposite order.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @param {Function} keysFunc The function to get the keys of `object`.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t var baseForRight = createBaseFor(true);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.forOwn` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t function baseForOwn(object, iteratee) {\n", | |
"\t return object && baseFor(object, iteratee, keys);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.forOwnRight` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t function baseForOwnRight(object, iteratee) {\n", | |
"\t return object && baseForRight(object, iteratee, keys);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.functions` which creates an array of\n", | |
"\t * `object` function property names filtered from `props`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to inspect.\n", | |
"\t * @param {Array} props The property names to filter.\n", | |
"\t * @returns {Array} Returns the function names.\n", | |
"\t */\n", | |
"\t function baseFunctions(object, props) {\n", | |
"\t return arrayFilter(props, function(key) {\n", | |
"\t return isFunction(object[key]);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.get` without support for default values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @param {Array|string} path The path of the property to get.\n", | |
"\t * @returns {*} Returns the resolved value.\n", | |
"\t */\n", | |
"\t function baseGet(object, path) {\n", | |
"\t path = isKey(path, object) ? [path] : castPath(path);\n", | |
"\t\n", | |
"\t var index = 0,\n", | |
"\t length = path.length;\n", | |
"\t\n", | |
"\t while (object != null && index < length) {\n", | |
"\t object = object[toKey(path[index++])];\n", | |
"\t }\n", | |
"\t return (index && index == length) ? object : undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n", | |
"\t * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n", | |
"\t * symbols of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @param {Function} keysFunc The function to get the keys of `object`.\n", | |
"\t * @param {Function} symbolsFunc The function to get the symbols of `object`.\n", | |
"\t * @returns {Array} Returns the array of property names and symbols.\n", | |
"\t */\n", | |
"\t function baseGetAllKeys(object, keysFunc, symbolsFunc) {\n", | |
"\t var result = keysFunc(object);\n", | |
"\t return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `getTag` without fallbacks for buggy environments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to query.\n", | |
"\t * @returns {string} Returns the `toStringTag`.\n", | |
"\t */\n", | |
"\t function baseGetTag(value) {\n", | |
"\t if (value == null) {\n", | |
"\t return value === undefined ? undefinedTag : nullTag;\n", | |
"\t }\n", | |
"\t value = Object(value);\n", | |
"\t return (symToStringTag && symToStringTag in value)\n", | |
"\t ? getRawTag(value)\n", | |
"\t : objectToString(value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.gt` which doesn't coerce arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to compare.\n", | |
"\t * @param {*} other The other value to compare.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is greater than `other`,\n", | |
"\t * else `false`.\n", | |
"\t */\n", | |
"\t function baseGt(value, other) {\n", | |
"\t return value > other;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.has` without support for deep paths.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} [object] The object to query.\n", | |
"\t * @param {Array|string} key The key to check.\n", | |
"\t * @returns {boolean} Returns `true` if `key` exists, else `false`.\n", | |
"\t */\n", | |
"\t function baseHas(object, key) {\n", | |
"\t return object != null && hasOwnProperty.call(object, key);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.hasIn` without support for deep paths.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} [object] The object to query.\n", | |
"\t * @param {Array|string} key The key to check.\n", | |
"\t * @returns {boolean} Returns `true` if `key` exists, else `false`.\n", | |
"\t */\n", | |
"\t function baseHasIn(object, key) {\n", | |
"\t return object != null && key in Object(object);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.inRange` which doesn't coerce arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {number} number The number to check.\n", | |
"\t * @param {number} start The start of the range.\n", | |
"\t * @param {number} end The end of the range.\n", | |
"\t * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\n", | |
"\t */\n", | |
"\t function baseInRange(number, start, end) {\n", | |
"\t return number >= nativeMin(start, end) && number < nativeMax(start, end);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of methods like `_.intersection`, without support\n", | |
"\t * for iteratee shorthands, that accepts an array of arrays to inspect.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} arrays The arrays to inspect.\n", | |
"\t * @param {Function} [iteratee] The iteratee invoked per element.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of shared values.\n", | |
"\t */\n", | |
"\t function baseIntersection(arrays, iteratee, comparator) {\n", | |
"\t var includes = comparator ? arrayIncludesWith : arrayIncludes,\n", | |
"\t length = arrays[0].length,\n", | |
"\t othLength = arrays.length,\n", | |
"\t othIndex = othLength,\n", | |
"\t caches = Array(othLength),\n", | |
"\t maxLength = Infinity,\n", | |
"\t result = [];\n", | |
"\t\n", | |
"\t while (othIndex--) {\n", | |
"\t var array = arrays[othIndex];\n", | |
"\t if (othIndex && iteratee) {\n", | |
"\t array = arrayMap(array, baseUnary(iteratee));\n", | |
"\t }\n", | |
"\t maxLength = nativeMin(array.length, maxLength);\n", | |
"\t caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))\n", | |
"\t ? new SetCache(othIndex && array)\n", | |
"\t : undefined;\n", | |
"\t }\n", | |
"\t array = arrays[0];\n", | |
"\t\n", | |
"\t var index = -1,\n", | |
"\t seen = caches[0];\n", | |
"\t\n", | |
"\t outer:\n", | |
"\t while (++index < length && result.length < maxLength) {\n", | |
"\t var value = array[index],\n", | |
"\t computed = iteratee ? iteratee(value) : value;\n", | |
"\t\n", | |
"\t value = (comparator || value !== 0) ? value : 0;\n", | |
"\t if (!(seen\n", | |
"\t ? cacheHas(seen, computed)\n", | |
"\t : includes(result, computed, comparator)\n", | |
"\t )) {\n", | |
"\t othIndex = othLength;\n", | |
"\t while (--othIndex) {\n", | |
"\t var cache = caches[othIndex];\n", | |
"\t if (!(cache\n", | |
"\t ? cacheHas(cache, computed)\n", | |
"\t : includes(arrays[othIndex], computed, comparator))\n", | |
"\t ) {\n", | |
"\t continue outer;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (seen) {\n", | |
"\t seen.push(computed);\n", | |
"\t }\n", | |
"\t result.push(value);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.invert` and `_.invertBy` which inverts\n", | |
"\t * `object` with values transformed by `iteratee` and set by `setter`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to iterate over.\n", | |
"\t * @param {Function} setter The function to set `accumulator` values.\n", | |
"\t * @param {Function} iteratee The iteratee to transform values.\n", | |
"\t * @param {Object} accumulator The initial inverted object.\n", | |
"\t * @returns {Function} Returns `accumulator`.\n", | |
"\t */\n", | |
"\t function baseInverter(object, setter, iteratee, accumulator) {\n", | |
"\t baseForOwn(object, function(value, key, object) {\n", | |
"\t setter(accumulator, iteratee(value), key, object);\n", | |
"\t });\n", | |
"\t return accumulator;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.invoke` without support for individual\n", | |
"\t * method arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @param {Array|string} path The path of the method to invoke.\n", | |
"\t * @param {Array} args The arguments to invoke the method with.\n", | |
"\t * @returns {*} Returns the result of the invoked method.\n", | |
"\t */\n", | |
"\t function baseInvoke(object, path, args) {\n", | |
"\t if (!isKey(path, object)) {\n", | |
"\t path = castPath(path);\n", | |
"\t object = parent(object, path);\n", | |
"\t path = last(path);\n", | |
"\t }\n", | |
"\t var func = object == null ? object : object[toKey(path)];\n", | |
"\t return func == null ? undefined : apply(func, object, args);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isArguments`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n", | |
"\t */\n", | |
"\t function baseIsArguments(value) {\n", | |
"\t return isObjectLike(value) && baseGetTag(value) == argsTag;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isArrayBuffer` without Node.js optimizations.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsArrayBuffer(value) {\n", | |
"\t return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isDate` without Node.js optimizations.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a date object, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsDate(value) {\n", | |
"\t return isObjectLike(value) && baseGetTag(value) == dateTag;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isEqual` which supports partial comparisons\n", | |
"\t * and tracks traversed objects.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to compare.\n", | |
"\t * @param {*} other The other value to compare.\n", | |
"\t * @param {Function} [customizer] The function to customize comparisons.\n", | |
"\t * @param {boolean} [bitmask] The bitmask of comparison flags.\n", | |
"\t * The bitmask may be composed of the following flags:\n", | |
"\t * 1 - Unordered comparison\n", | |
"\t * 2 - Partial comparison\n", | |
"\t * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n", | |
"\t * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsEqual(value, other, customizer, bitmask, stack) {\n", | |
"\t if (value === other) {\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {\n", | |
"\t return value !== value && other !== other;\n", | |
"\t }\n", | |
"\t return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseIsEqual` for arrays and objects which performs\n", | |
"\t * deep comparisons and tracks traversed objects enabling objects with circular\n", | |
"\t * references to be compared.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to compare.\n", | |
"\t * @param {Object} other The other object to compare.\n", | |
"\t * @param {Function} equalFunc The function to determine equivalents of values.\n", | |
"\t * @param {Function} [customizer] The function to customize comparisons.\n", | |
"\t * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`\n", | |
"\t * for more details.\n", | |
"\t * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n", | |
"\t * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {\n", | |
"\t var objIsArr = isArray(object),\n", | |
"\t othIsArr = isArray(other),\n", | |
"\t objTag = arrayTag,\n", | |
"\t othTag = arrayTag;\n", | |
"\t\n", | |
"\t if (!objIsArr) {\n", | |
"\t objTag = getTag(object);\n", | |
"\t objTag = objTag == argsTag ? objectTag : objTag;\n", | |
"\t }\n", | |
"\t if (!othIsArr) {\n", | |
"\t othTag = getTag(other);\n", | |
"\t othTag = othTag == argsTag ? objectTag : othTag;\n", | |
"\t }\n", | |
"\t var objIsObj = objTag == objectTag,\n", | |
"\t othIsObj = othTag == objectTag,\n", | |
"\t isSameTag = objTag == othTag;\n", | |
"\t\n", | |
"\t if (isSameTag && isBuffer(object)) {\n", | |
"\t if (!isBuffer(other)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t objIsArr = true;\n", | |
"\t objIsObj = false;\n", | |
"\t }\n", | |
"\t if (isSameTag && !objIsObj) {\n", | |
"\t stack || (stack = new Stack);\n", | |
"\t return (objIsArr || isTypedArray(object))\n", | |
"\t ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)\n", | |
"\t : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);\n", | |
"\t }\n", | |
"\t if (!(bitmask & PARTIAL_COMPARE_FLAG)) {\n", | |
"\t var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n", | |
"\t othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n", | |
"\t\n", | |
"\t if (objIsWrapped || othIsWrapped) {\n", | |
"\t var objUnwrapped = objIsWrapped ? object.value() : object,\n", | |
"\t othUnwrapped = othIsWrapped ? other.value() : other;\n", | |
"\t\n", | |
"\t stack || (stack = new Stack);\n", | |
"\t return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (!isSameTag) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t stack || (stack = new Stack);\n", | |
"\t return equalObjects(object, other, equalFunc, customizer, bitmask, stack);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isMap` without Node.js optimizations.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a map, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsMap(value) {\n", | |
"\t return isObjectLike(value) && getTag(value) == mapTag;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isMatch` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to inspect.\n", | |
"\t * @param {Object} source The object of property values to match.\n", | |
"\t * @param {Array} matchData The property names, values, and compare flags to match.\n", | |
"\t * @param {Function} [customizer] The function to customize comparisons.\n", | |
"\t * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsMatch(object, source, matchData, customizer) {\n", | |
"\t var index = matchData.length,\n", | |
"\t length = index,\n", | |
"\t noCustomizer = !customizer;\n", | |
"\t\n", | |
"\t if (object == null) {\n", | |
"\t return !length;\n", | |
"\t }\n", | |
"\t object = Object(object);\n", | |
"\t while (index--) {\n", | |
"\t var data = matchData[index];\n", | |
"\t if ((noCustomizer && data[2])\n", | |
"\t ? data[1] !== object[data[0]]\n", | |
"\t : !(data[0] in object)\n", | |
"\t ) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t while (++index < length) {\n", | |
"\t data = matchData[index];\n", | |
"\t var key = data[0],\n", | |
"\t objValue = object[key],\n", | |
"\t srcValue = data[1];\n", | |
"\t\n", | |
"\t if (noCustomizer && data[2]) {\n", | |
"\t if (objValue === undefined && !(key in object)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t var stack = new Stack;\n", | |
"\t if (customizer) {\n", | |
"\t var result = customizer(objValue, srcValue, key, object, source, stack);\n", | |
"\t }\n", | |
"\t if (!(result === undefined\n", | |
"\t ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)\n", | |
"\t : result\n", | |
"\t )) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isNative` without bad shim checks.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a native function,\n", | |
"\t * else `false`.\n", | |
"\t */\n", | |
"\t function baseIsNative(value) {\n", | |
"\t if (!isObject(value) || isMasked(value)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n", | |
"\t return pattern.test(toSource(value));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isRegExp` without Node.js optimizations.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsRegExp(value) {\n", | |
"\t return isObjectLike(value) && baseGetTag(value) == regexpTag;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isSet` without Node.js optimizations.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a set, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsSet(value) {\n", | |
"\t return isObjectLike(value) && getTag(value) == setTag;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.isTypedArray` without Node.js optimizations.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n", | |
"\t */\n", | |
"\t function baseIsTypedArray(value) {\n", | |
"\t return isObjectLike(value) &&\n", | |
"\t isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.iteratee`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} [value=_.identity] The value to convert to an iteratee.\n", | |
"\t * @returns {Function} Returns the iteratee.\n", | |
"\t */\n", | |
"\t function baseIteratee(value) {\n", | |
"\t // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.\n", | |
"\t // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.\n", | |
"\t if (typeof value == 'function') {\n", | |
"\t return value;\n", | |
"\t }\n", | |
"\t if (value == null) {\n", | |
"\t return identity;\n", | |
"\t }\n", | |
"\t if (typeof value == 'object') {\n", | |
"\t return isArray(value)\n", | |
"\t ? baseMatchesProperty(value[0], value[1])\n", | |
"\t : baseMatches(value);\n", | |
"\t }\n", | |
"\t return property(value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Array} Returns the array of property names.\n", | |
"\t */\n", | |
"\t function baseKeys(object) {\n", | |
"\t if (!isPrototype(object)) {\n", | |
"\t return nativeKeys(object);\n", | |
"\t }\n", | |
"\t var result = [];\n", | |
"\t for (var key in Object(object)) {\n", | |
"\t if (hasOwnProperty.call(object, key) && key != 'constructor') {\n", | |
"\t result.push(key);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Array} Returns the array of property names.\n", | |
"\t */\n", | |
"\t function baseKeysIn(object) {\n", | |
"\t if (!isObject(object)) {\n", | |
"\t return nativeKeysIn(object);\n", | |
"\t }\n", | |
"\t var isProto = isPrototype(object),\n", | |
"\t result = [];\n", | |
"\t\n", | |
"\t for (var key in object) {\n", | |
"\t if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n", | |
"\t result.push(key);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.lt` which doesn't coerce arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to compare.\n", | |
"\t * @param {*} other The other value to compare.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is less than `other`,\n", | |
"\t * else `false`.\n", | |
"\t */\n", | |
"\t function baseLt(value, other) {\n", | |
"\t return value < other;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.map` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function} iteratee The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the new mapped array.\n", | |
"\t */\n", | |
"\t function baseMap(collection, iteratee) {\n", | |
"\t var index = -1,\n", | |
"\t result = isArrayLike(collection) ? Array(collection.length) : [];\n", | |
"\t\n", | |
"\t baseEach(collection, function(value, key, collection) {\n", | |
"\t result[++index] = iteratee(value, key, collection);\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.matches` which doesn't clone `source`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} source The object of property values to match.\n", | |
"\t * @returns {Function} Returns the new spec function.\n", | |
"\t */\n", | |
"\t function baseMatches(source) {\n", | |
"\t var matchData = getMatchData(source);\n", | |
"\t if (matchData.length == 1 && matchData[0][2]) {\n", | |
"\t return matchesStrictComparable(matchData[0][0], matchData[0][1]);\n", | |
"\t }\n", | |
"\t return function(object) {\n", | |
"\t return object === source || baseIsMatch(object, source, matchData);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} path The path of the property to get.\n", | |
"\t * @param {*} srcValue The value to match.\n", | |
"\t * @returns {Function} Returns the new spec function.\n", | |
"\t */\n", | |
"\t function baseMatchesProperty(path, srcValue) {\n", | |
"\t if (isKey(path) && isStrictComparable(srcValue)) {\n", | |
"\t return matchesStrictComparable(toKey(path), srcValue);\n", | |
"\t }\n", | |
"\t return function(object) {\n", | |
"\t var objValue = get(object, path);\n", | |
"\t return (objValue === undefined && objValue === srcValue)\n", | |
"\t ? hasIn(object, path)\n", | |
"\t : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.merge` without support for multiple sources.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The destination object.\n", | |
"\t * @param {Object} source The source object.\n", | |
"\t * @param {number} srcIndex The index of `source`.\n", | |
"\t * @param {Function} [customizer] The function to customize merged values.\n", | |
"\t * @param {Object} [stack] Tracks traversed source values and their merged\n", | |
"\t * counterparts.\n", | |
"\t */\n", | |
"\t function baseMerge(object, source, srcIndex, customizer, stack) {\n", | |
"\t if (object === source) {\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t baseFor(source, function(srcValue, key) {\n", | |
"\t if (isObject(srcValue)) {\n", | |
"\t stack || (stack = new Stack);\n", | |
"\t baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);\n", | |
"\t }\n", | |
"\t else {\n", | |
"\t var newValue = customizer\n", | |
"\t ? customizer(object[key], srcValue, (key + ''), object, source, stack)\n", | |
"\t : undefined;\n", | |
"\t\n", | |
"\t if (newValue === undefined) {\n", | |
"\t newValue = srcValue;\n", | |
"\t }\n", | |
"\t assignMergeValue(object, key, newValue);\n", | |
"\t }\n", | |
"\t }, keysIn);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseMerge` for arrays and objects which performs\n", | |
"\t * deep merges and tracks traversed objects enabling objects with circular\n", | |
"\t * references to be merged.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The destination object.\n", | |
"\t * @param {Object} source The source object.\n", | |
"\t * @param {string} key The key of the value to merge.\n", | |
"\t * @param {number} srcIndex The index of `source`.\n", | |
"\t * @param {Function} mergeFunc The function to merge values.\n", | |
"\t * @param {Function} [customizer] The function to customize assigned values.\n", | |
"\t * @param {Object} [stack] Tracks traversed source values and their merged\n", | |
"\t * counterparts.\n", | |
"\t */\n", | |
"\t function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {\n", | |
"\t var objValue = object[key],\n", | |
"\t srcValue = source[key],\n", | |
"\t stacked = stack.get(srcValue);\n", | |
"\t\n", | |
"\t if (stacked) {\n", | |
"\t assignMergeValue(object, key, stacked);\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t var newValue = customizer\n", | |
"\t ? customizer(objValue, srcValue, (key + ''), object, source, stack)\n", | |
"\t : undefined;\n", | |
"\t\n", | |
"\t var isCommon = newValue === undefined;\n", | |
"\t\n", | |
"\t if (isCommon) {\n", | |
"\t var isArr = isArray(srcValue),\n", | |
"\t isBuff = !isArr && isBuffer(srcValue),\n", | |
"\t isTyped = !isArr && !isBuff && isTypedArray(srcValue);\n", | |
"\t\n", | |
"\t newValue = srcValue;\n", | |
"\t if (isArr || isBuff || isTyped) {\n", | |
"\t if (isArray(objValue)) {\n", | |
"\t newValue = objValue;\n", | |
"\t }\n", | |
"\t else if (isArrayLikeObject(objValue)) {\n", | |
"\t newValue = copyArray(objValue);\n", | |
"\t }\n", | |
"\t else if (isBuff) {\n", | |
"\t isCommon = false;\n", | |
"\t newValue = cloneBuffer(srcValue, true);\n", | |
"\t }\n", | |
"\t else if (isTyped) {\n", | |
"\t isCommon = false;\n", | |
"\t newValue = cloneTypedArray(srcValue, true);\n", | |
"\t }\n", | |
"\t else {\n", | |
"\t newValue = [];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t else if (isPlainObject(srcValue) || isArguments(srcValue)) {\n", | |
"\t newValue = objValue;\n", | |
"\t if (isArguments(objValue)) {\n", | |
"\t newValue = toPlainObject(objValue);\n", | |
"\t }\n", | |
"\t else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {\n", | |
"\t newValue = initCloneObject(srcValue);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t else {\n", | |
"\t isCommon = false;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (isCommon) {\n", | |
"\t // Recursively merge objects and arrays (susceptible to call stack limits).\n", | |
"\t stack.set(srcValue, newValue);\n", | |
"\t mergeFunc(newValue, srcValue, srcIndex, customizer, stack);\n", | |
"\t stack['delete'](srcValue);\n", | |
"\t }\n", | |
"\t assignMergeValue(object, key, newValue);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.nth` which doesn't coerce arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {number} n The index of the element to return.\n", | |
"\t * @returns {*} Returns the nth element of `array`.\n", | |
"\t */\n", | |
"\t function baseNth(array, n) {\n", | |
"\t var length = array.length;\n", | |
"\t if (!length) {\n", | |
"\t return;\n", | |
"\t }\n", | |
"\t n += n < 0 ? length : 0;\n", | |
"\t return isIndex(n, length) ? array[n] : undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.orderBy` without param guards.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.\n", | |
"\t * @param {string[]} orders The sort orders of `iteratees`.\n", | |
"\t * @returns {Array} Returns the new sorted array.\n", | |
"\t */\n", | |
"\t function baseOrderBy(collection, iteratees, orders) {\n", | |
"\t var index = -1;\n", | |
"\t iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));\n", | |
"\t\n", | |
"\t var result = baseMap(collection, function(value, key, collection) {\n", | |
"\t var criteria = arrayMap(iteratees, function(iteratee) {\n", | |
"\t return iteratee(value);\n", | |
"\t });\n", | |
"\t return { 'criteria': criteria, 'index': ++index, 'value': value };\n", | |
"\t });\n", | |
"\t\n", | |
"\t return baseSortBy(result, function(object, other) {\n", | |
"\t return compareMultiple(object, other, orders);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.pick` without support for individual\n", | |
"\t * property identifiers.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The source object.\n", | |
"\t * @param {string[]} props The property identifiers to pick.\n", | |
"\t * @returns {Object} Returns the new object.\n", | |
"\t */\n", | |
"\t function basePick(object, props) {\n", | |
"\t object = Object(object);\n", | |
"\t return basePickBy(object, props, function(value, key) {\n", | |
"\t return key in object;\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.pickBy` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The source object.\n", | |
"\t * @param {string[]} props The property identifiers to pick from.\n", | |
"\t * @param {Function} predicate The function invoked per property.\n", | |
"\t * @returns {Object} Returns the new object.\n", | |
"\t */\n", | |
"\t function basePickBy(object, props, predicate) {\n", | |
"\t var index = -1,\n", | |
"\t length = props.length,\n", | |
"\t result = {};\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var key = props[index],\n", | |
"\t value = object[key];\n", | |
"\t\n", | |
"\t if (predicate(value, key)) {\n", | |
"\t baseAssignValue(result, key, value);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseProperty` which supports deep paths.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|string} path The path of the property to get.\n", | |
"\t * @returns {Function} Returns the new accessor function.\n", | |
"\t */\n", | |
"\t function basePropertyDeep(path) {\n", | |
"\t return function(object) {\n", | |
"\t return baseGet(object, path);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.pullAllBy` without support for iteratee\n", | |
"\t * shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {Array} values The values to remove.\n", | |
"\t * @param {Function} [iteratee] The iteratee invoked per element.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function basePullAll(array, values, iteratee, comparator) {\n", | |
"\t var indexOf = comparator ? baseIndexOfWith : baseIndexOf,\n", | |
"\t index = -1,\n", | |
"\t length = values.length,\n", | |
"\t seen = array;\n", | |
"\t\n", | |
"\t if (array === values) {\n", | |
"\t values = copyArray(values);\n", | |
"\t }\n", | |
"\t if (iteratee) {\n", | |
"\t seen = arrayMap(array, baseUnary(iteratee));\n", | |
"\t }\n", | |
"\t while (++index < length) {\n", | |
"\t var fromIndex = 0,\n", | |
"\t value = values[index],\n", | |
"\t computed = iteratee ? iteratee(value) : value;\n", | |
"\t\n", | |
"\t while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {\n", | |
"\t if (seen !== array) {\n", | |
"\t splice.call(seen, fromIndex, 1);\n", | |
"\t }\n", | |
"\t splice.call(array, fromIndex, 1);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.pullAt` without support for individual\n", | |
"\t * indexes or capturing the removed elements.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {number[]} indexes The indexes of elements to remove.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function basePullAt(array, indexes) {\n", | |
"\t var length = array ? indexes.length : 0,\n", | |
"\t lastIndex = length - 1;\n", | |
"\t\n", | |
"\t while (length--) {\n", | |
"\t var index = indexes[length];\n", | |
"\t if (length == lastIndex || index !== previous) {\n", | |
"\t var previous = index;\n", | |
"\t if (isIndex(index)) {\n", | |
"\t splice.call(array, index, 1);\n", | |
"\t }\n", | |
"\t else if (!isKey(index, array)) {\n", | |
"\t var path = castPath(index),\n", | |
"\t object = parent(array, path);\n", | |
"\t\n", | |
"\t if (object != null) {\n", | |
"\t delete object[toKey(last(path))];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t else {\n", | |
"\t delete array[toKey(index)];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.random` without support for returning\n", | |
"\t * floating-point numbers.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {number} lower The lower bound.\n", | |
"\t * @param {number} upper The upper bound.\n", | |
"\t * @returns {number} Returns the random number.\n", | |
"\t */\n", | |
"\t function baseRandom(lower, upper) {\n", | |
"\t return lower + nativeFloor(nativeRandom() * (upper - lower + 1));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.range` and `_.rangeRight` which doesn't\n", | |
"\t * coerce arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {number} start The start of the range.\n", | |
"\t * @param {number} end The end of the range.\n", | |
"\t * @param {number} step The value to increment or decrement by.\n", | |
"\t * @param {boolean} [fromRight] Specify iterating from right to left.\n", | |
"\t * @returns {Array} Returns the range of numbers.\n", | |
"\t */\n", | |
"\t function baseRange(start, end, step, fromRight) {\n", | |
"\t var index = -1,\n", | |
"\t length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),\n", | |
"\t result = Array(length);\n", | |
"\t\n", | |
"\t while (length--) {\n", | |
"\t result[fromRight ? length : ++index] = start;\n", | |
"\t start += step;\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.repeat` which doesn't coerce arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string to repeat.\n", | |
"\t * @param {number} n The number of times to repeat the string.\n", | |
"\t * @returns {string} Returns the repeated string.\n", | |
"\t */\n", | |
"\t function baseRepeat(string, n) {\n", | |
"\t var result = '';\n", | |
"\t if (!string || n < 1 || n > MAX_SAFE_INTEGER) {\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t // Leverage the exponentiation by squaring algorithm for a faster repeat.\n", | |
"\t // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.\n", | |
"\t do {\n", | |
"\t if (n % 2) {\n", | |
"\t result += string;\n", | |
"\t }\n", | |
"\t n = nativeFloor(n / 2);\n", | |
"\t if (n) {\n", | |
"\t string += string;\n", | |
"\t }\n", | |
"\t } while (n);\n", | |
"\t\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to apply a rest parameter to.\n", | |
"\t * @param {number} [start=func.length-1] The start position of the rest parameter.\n", | |
"\t * @returns {Function} Returns the new function.\n", | |
"\t */\n", | |
"\t function baseRest(func, start) {\n", | |
"\t return setToString(overRest(func, start, identity), func + '');\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.sample`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to sample.\n", | |
"\t * @returns {*} Returns the random element.\n", | |
"\t */\n", | |
"\t function baseSample(collection) {\n", | |
"\t return arraySample(values(collection));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.sampleSize` without param guards.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to sample.\n", | |
"\t * @param {number} n The number of elements to sample.\n", | |
"\t * @returns {Array} Returns the random elements.\n", | |
"\t */\n", | |
"\t function baseSampleSize(collection, n) {\n", | |
"\t var array = values(collection);\n", | |
"\t return shuffleSelf(array, baseClamp(n, 0, array.length));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.set`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to modify.\n", | |
"\t * @param {Array|string} path The path of the property to set.\n", | |
"\t * @param {*} value The value to set.\n", | |
"\t * @param {Function} [customizer] The function to customize path creation.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t function baseSet(object, path, value, customizer) {\n", | |
"\t if (!isObject(object)) {\n", | |
"\t return object;\n", | |
"\t }\n", | |
"\t path = isKey(path, object) ? [path] : castPath(path);\n", | |
"\t\n", | |
"\t var index = -1,\n", | |
"\t length = path.length,\n", | |
"\t lastIndex = length - 1,\n", | |
"\t nested = object;\n", | |
"\t\n", | |
"\t while (nested != null && ++index < length) {\n", | |
"\t var key = toKey(path[index]),\n", | |
"\t newValue = value;\n", | |
"\t\n", | |
"\t if (index != lastIndex) {\n", | |
"\t var objValue = nested[key];\n", | |
"\t newValue = customizer ? customizer(objValue, key, nested) : undefined;\n", | |
"\t if (newValue === undefined) {\n", | |
"\t newValue = isObject(objValue)\n", | |
"\t ? objValue\n", | |
"\t : (isIndex(path[index + 1]) ? [] : {});\n", | |
"\t }\n", | |
"\t }\n", | |
"\t assignValue(nested, key, newValue);\n", | |
"\t nested = nested[key];\n", | |
"\t }\n", | |
"\t return object;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `setData` without support for hot loop shorting.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to associate metadata with.\n", | |
"\t * @param {*} data The metadata.\n", | |
"\t * @returns {Function} Returns `func`.\n", | |
"\t */\n", | |
"\t var baseSetData = !metaMap ? identity : function(func, data) {\n", | |
"\t metaMap.set(func, data);\n", | |
"\t return func;\n", | |
"\t };\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `setToString` without support for hot loop shorting.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to modify.\n", | |
"\t * @param {Function} string The `toString` result.\n", | |
"\t * @returns {Function} Returns `func`.\n", | |
"\t */\n", | |
"\t var baseSetToString = !defineProperty ? identity : function(func, string) {\n", | |
"\t return defineProperty(func, 'toString', {\n", | |
"\t 'configurable': true,\n", | |
"\t 'enumerable': false,\n", | |
"\t 'value': constant(string),\n", | |
"\t 'writable': true\n", | |
"\t });\n", | |
"\t };\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.shuffle`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to shuffle.\n", | |
"\t * @returns {Array} Returns the new shuffled array.\n", | |
"\t */\n", | |
"\t function baseShuffle(collection) {\n", | |
"\t return shuffleSelf(values(collection));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.slice` without an iteratee call guard.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to slice.\n", | |
"\t * @param {number} [start=0] The start position.\n", | |
"\t * @param {number} [end=array.length] The end position.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t */\n", | |
"\t function baseSlice(array, start, end) {\n", | |
"\t var index = -1,\n", | |
"\t length = array.length;\n", | |
"\t\n", | |
"\t if (start < 0) {\n", | |
"\t start = -start > length ? 0 : (length + start);\n", | |
"\t }\n", | |
"\t end = end > length ? length : end;\n", | |
"\t if (end < 0) {\n", | |
"\t end += length;\n", | |
"\t }\n", | |
"\t length = start > end ? 0 : ((end - start) >>> 0);\n", | |
"\t start >>>= 0;\n", | |
"\t\n", | |
"\t var result = Array(length);\n", | |
"\t while (++index < length) {\n", | |
"\t result[index] = array[index + start];\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.some` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array|Object} collection The collection to iterate over.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @returns {boolean} Returns `true` if any element passes the predicate check,\n", | |
"\t * else `false`.\n", | |
"\t */\n", | |
"\t function baseSome(collection, predicate) {\n", | |
"\t var result;\n", | |
"\t\n", | |
"\t baseEach(collection, function(value, index, collection) {\n", | |
"\t result = predicate(value, index, collection);\n", | |
"\t return !result;\n", | |
"\t });\n", | |
"\t return !!result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which\n", | |
"\t * performs a binary search of `array` to determine the index at which `value`\n", | |
"\t * should be inserted into `array` in order to maintain its sort order.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The sorted array to inspect.\n", | |
"\t * @param {*} value The value to evaluate.\n", | |
"\t * @param {boolean} [retHighest] Specify returning the highest qualified index.\n", | |
"\t * @returns {number} Returns the index at which `value` should be inserted\n", | |
"\t * into `array`.\n", | |
"\t */\n", | |
"\t function baseSortedIndex(array, value, retHighest) {\n", | |
"\t var low = 0,\n", | |
"\t high = array == null ? low : array.length;\n", | |
"\t\n", | |
"\t if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {\n", | |
"\t while (low < high) {\n", | |
"\t var mid = (low + high) >>> 1,\n", | |
"\t computed = array[mid];\n", | |
"\t\n", | |
"\t if (computed !== null && !isSymbol(computed) &&\n", | |
"\t (retHighest ? (computed <= value) : (computed < value))) {\n", | |
"\t low = mid + 1;\n", | |
"\t } else {\n", | |
"\t high = mid;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return high;\n", | |
"\t }\n", | |
"\t return baseSortedIndexBy(array, value, identity, retHighest);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`\n", | |
"\t * which invokes `iteratee` for `value` and each element of `array` to compute\n", | |
"\t * their sort ranking. The iteratee is invoked with one argument; (value).\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The sorted array to inspect.\n", | |
"\t * @param {*} value The value to evaluate.\n", | |
"\t * @param {Function} iteratee The iteratee invoked per element.\n", | |
"\t * @param {boolean} [retHighest] Specify returning the highest qualified index.\n", | |
"\t * @returns {number} Returns the index at which `value` should be inserted\n", | |
"\t * into `array`.\n", | |
"\t */\n", | |
"\t function baseSortedIndexBy(array, value, iteratee, retHighest) {\n", | |
"\t value = iteratee(value);\n", | |
"\t\n", | |
"\t var low = 0,\n", | |
"\t high = array == null ? 0 : array.length,\n", | |
"\t valIsNaN = value !== value,\n", | |
"\t valIsNull = value === null,\n", | |
"\t valIsSymbol = isSymbol(value),\n", | |
"\t valIsUndefined = value === undefined;\n", | |
"\t\n", | |
"\t while (low < high) {\n", | |
"\t var mid = nativeFloor((low + high) / 2),\n", | |
"\t computed = iteratee(array[mid]),\n", | |
"\t othIsDefined = computed !== undefined,\n", | |
"\t othIsNull = computed === null,\n", | |
"\t othIsReflexive = computed === computed,\n", | |
"\t othIsSymbol = isSymbol(computed);\n", | |
"\t\n", | |
"\t if (valIsNaN) {\n", | |
"\t var setLow = retHighest || othIsReflexive;\n", | |
"\t } else if (valIsUndefined) {\n", | |
"\t setLow = othIsReflexive && (retHighest || othIsDefined);\n", | |
"\t } else if (valIsNull) {\n", | |
"\t setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);\n", | |
"\t } else if (valIsSymbol) {\n", | |
"\t setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);\n", | |
"\t } else if (othIsNull || othIsSymbol) {\n", | |
"\t setLow = false;\n", | |
"\t } else {\n", | |
"\t setLow = retHighest ? (computed <= value) : (computed < value);\n", | |
"\t }\n", | |
"\t if (setLow) {\n", | |
"\t low = mid + 1;\n", | |
"\t } else {\n", | |
"\t high = mid;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return nativeMin(high, MAX_ARRAY_INDEX);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without\n", | |
"\t * support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Function} [iteratee] The iteratee invoked per element.\n", | |
"\t * @returns {Array} Returns the new duplicate free array.\n", | |
"\t */\n", | |
"\t function baseSortedUniq(array, iteratee) {\n", | |
"\t var index = -1,\n", | |
"\t length = array.length,\n", | |
"\t resIndex = 0,\n", | |
"\t result = [];\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index],\n", | |
"\t computed = iteratee ? iteratee(value) : value;\n", | |
"\t\n", | |
"\t if (!index || !eq(computed, seen)) {\n", | |
"\t var seen = computed;\n", | |
"\t result[resIndex++] = value === 0 ? 0 : value;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.toNumber` which doesn't ensure correct\n", | |
"\t * conversions of binary, hexadecimal, or octal string values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to process.\n", | |
"\t * @returns {number} Returns the number.\n", | |
"\t */\n", | |
"\t function baseToNumber(value) {\n", | |
"\t if (typeof value == 'number') {\n", | |
"\t return value;\n", | |
"\t }\n", | |
"\t if (isSymbol(value)) {\n", | |
"\t return NAN;\n", | |
"\t }\n", | |
"\t return +value;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.toString` which doesn't convert nullish\n", | |
"\t * values to empty strings.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to process.\n", | |
"\t * @returns {string} Returns the string.\n", | |
"\t */\n", | |
"\t function baseToString(value) {\n", | |
"\t // Exit early for strings to avoid a performance hit in some environments.\n", | |
"\t if (typeof value == 'string') {\n", | |
"\t return value;\n", | |
"\t }\n", | |
"\t if (isArray(value)) {\n", | |
"\t // Recursively convert values (susceptible to call stack limits).\n", | |
"\t return arrayMap(value, baseToString) + '';\n", | |
"\t }\n", | |
"\t if (isSymbol(value)) {\n", | |
"\t return symbolToString ? symbolToString.call(value) : '';\n", | |
"\t }\n", | |
"\t var result = (value + '');\n", | |
"\t return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.uniqBy` without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Function} [iteratee] The iteratee invoked per element.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new duplicate free array.\n", | |
"\t */\n", | |
"\t function baseUniq(array, iteratee, comparator) {\n", | |
"\t var index = -1,\n", | |
"\t includes = arrayIncludes,\n", | |
"\t length = array.length,\n", | |
"\t isCommon = true,\n", | |
"\t result = [],\n", | |
"\t seen = result;\n", | |
"\t\n", | |
"\t if (comparator) {\n", | |
"\t isCommon = false;\n", | |
"\t includes = arrayIncludesWith;\n", | |
"\t }\n", | |
"\t else if (length >= LARGE_ARRAY_SIZE) {\n", | |
"\t var set = iteratee ? null : createSet(array);\n", | |
"\t if (set) {\n", | |
"\t return setToArray(set);\n", | |
"\t }\n", | |
"\t isCommon = false;\n", | |
"\t includes = cacheHas;\n", | |
"\t seen = new SetCache;\n", | |
"\t }\n", | |
"\t else {\n", | |
"\t seen = iteratee ? [] : result;\n", | |
"\t }\n", | |
"\t outer:\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index],\n", | |
"\t computed = iteratee ? iteratee(value) : value;\n", | |
"\t\n", | |
"\t value = (comparator || value !== 0) ? value : 0;\n", | |
"\t if (isCommon && computed === computed) {\n", | |
"\t var seenIndex = seen.length;\n", | |
"\t while (seenIndex--) {\n", | |
"\t if (seen[seenIndex] === computed) {\n", | |
"\t continue outer;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t if (iteratee) {\n", | |
"\t seen.push(computed);\n", | |
"\t }\n", | |
"\t result.push(value);\n", | |
"\t }\n", | |
"\t else if (!includes(seen, computed, comparator)) {\n", | |
"\t if (seen !== result) {\n", | |
"\t seen.push(computed);\n", | |
"\t }\n", | |
"\t result.push(value);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.unset`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to modify.\n", | |
"\t * @param {Array|string} path The path of the property to unset.\n", | |
"\t * @returns {boolean} Returns `true` if the property is deleted, else `false`.\n", | |
"\t */\n", | |
"\t function baseUnset(object, path) {\n", | |
"\t path = isKey(path, object) ? [path] : castPath(path);\n", | |
"\t object = parent(object, path);\n", | |
"\t\n", | |
"\t var key = toKey(last(path));\n", | |
"\t return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `_.update`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to modify.\n", | |
"\t * @param {Array|string} path The path of the property to update.\n", | |
"\t * @param {Function} updater The function to produce the updated value.\n", | |
"\t * @param {Function} [customizer] The function to customize path creation.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t function baseUpdate(object, path, updater, customizer) {\n", | |
"\t return baseSet(object, path, updater(baseGet(object, path)), customizer);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of methods like `_.dropWhile` and `_.takeWhile`\n", | |
"\t * without support for iteratee shorthands.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {Function} predicate The function invoked per iteration.\n", | |
"\t * @param {boolean} [isDrop] Specify dropping elements instead of taking them.\n", | |
"\t * @param {boolean} [fromRight] Specify iterating from right to left.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t */\n", | |
"\t function baseWhile(array, predicate, isDrop, fromRight) {\n", | |
"\t var length = array.length,\n", | |
"\t index = fromRight ? length : -1;\n", | |
"\t\n", | |
"\t while ((fromRight ? index-- : ++index < length) &&\n", | |
"\t predicate(array[index], index, array)) {}\n", | |
"\t\n", | |
"\t return isDrop\n", | |
"\t ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))\n", | |
"\t : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of `wrapperValue` which returns the result of\n", | |
"\t * performing a sequence of actions on the unwrapped `value`, where each\n", | |
"\t * successive action is supplied the return value of the previous.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The unwrapped value.\n", | |
"\t * @param {Array} actions Actions to perform to resolve the unwrapped value.\n", | |
"\t * @returns {*} Returns the resolved value.\n", | |
"\t */\n", | |
"\t function baseWrapperValue(value, actions) {\n", | |
"\t var result = value;\n", | |
"\t if (result instanceof LazyWrapper) {\n", | |
"\t result = result.value();\n", | |
"\t }\n", | |
"\t return arrayReduce(actions, function(result, action) {\n", | |
"\t return action.func.apply(action.thisArg, arrayPush([result], action.args));\n", | |
"\t }, result);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The base implementation of methods like `_.xor`, without support for\n", | |
"\t * iteratee shorthands, that accepts an array of arrays to inspect.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} arrays The arrays to inspect.\n", | |
"\t * @param {Function} [iteratee] The iteratee invoked per element.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of values.\n", | |
"\t */\n", | |
"\t function baseXor(arrays, iteratee, comparator) {\n", | |
"\t var length = arrays.length;\n", | |
"\t if (length < 2) {\n", | |
"\t return length ? baseUniq(arrays[0]) : [];\n", | |
"\t }\n", | |
"\t var index = -1,\n", | |
"\t result = Array(length);\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var array = arrays[index],\n", | |
"\t othIndex = -1;\n", | |
"\t\n", | |
"\t while (++othIndex < length) {\n", | |
"\t if (othIndex != index) {\n", | |
"\t result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return baseUniq(baseFlatten(result, 1), iteratee, comparator);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This base implementation of `_.zipObject` which assigns values using `assignFunc`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} props The property identifiers.\n", | |
"\t * @param {Array} values The property values.\n", | |
"\t * @param {Function} assignFunc The function to assign values.\n", | |
"\t * @returns {Object} Returns the new object.\n", | |
"\t */\n", | |
"\t function baseZipObject(props, values, assignFunc) {\n", | |
"\t var index = -1,\n", | |
"\t length = props.length,\n", | |
"\t valsLength = values.length,\n", | |
"\t result = {};\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var value = index < valsLength ? values[index] : undefined;\n", | |
"\t assignFunc(result, props[index], value);\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Casts `value` to an empty array if it's not an array like object.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to inspect.\n", | |
"\t * @returns {Array|Object} Returns the cast array-like object.\n", | |
"\t */\n", | |
"\t function castArrayLikeObject(value) {\n", | |
"\t return isArrayLikeObject(value) ? value : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Casts `value` to `identity` if it's not a function.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to inspect.\n", | |
"\t * @returns {Function} Returns cast function.\n", | |
"\t */\n", | |
"\t function castFunction(value) {\n", | |
"\t return typeof value == 'function' ? value : identity;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Casts `value` to a path array if it's not one.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to inspect.\n", | |
"\t * @returns {Array} Returns the cast property path array.\n", | |
"\t */\n", | |
"\t function castPath(value) {\n", | |
"\t return isArray(value) ? value : stringToPath(value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A `baseRest` alias which can be replaced with `identity` by module\n", | |
"\t * replacement plugins.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @type {Function}\n", | |
"\t * @param {Function} func The function to apply a rest parameter to.\n", | |
"\t * @returns {Function} Returns the new function.\n", | |
"\t */\n", | |
"\t var castRest = baseRest;\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Casts `array` to a slice if it's needed.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {number} start The start position.\n", | |
"\t * @param {number} [end=array.length] The end position.\n", | |
"\t * @returns {Array} Returns the cast slice.\n", | |
"\t */\n", | |
"\t function castSlice(array, start, end) {\n", | |
"\t var length = array.length;\n", | |
"\t end = end === undefined ? length : end;\n", | |
"\t return (!start && end >= length) ? array : baseSlice(array, start, end);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {number|Object} id The timer id or timeout object of the timer to clear.\n", | |
"\t */\n", | |
"\t var clearTimeout = ctxClearTimeout || function(id) {\n", | |
"\t return root.clearTimeout(id);\n", | |
"\t };\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of `buffer`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Buffer} buffer The buffer to clone.\n", | |
"\t * @param {boolean} [isDeep] Specify a deep clone.\n", | |
"\t * @returns {Buffer} Returns the cloned buffer.\n", | |
"\t */\n", | |
"\t function cloneBuffer(buffer, isDeep) {\n", | |
"\t if (isDeep) {\n", | |
"\t return buffer.slice();\n", | |
"\t }\n", | |
"\t var length = buffer.length,\n", | |
"\t result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);\n", | |
"\t\n", | |
"\t buffer.copy(result);\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of `arrayBuffer`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {ArrayBuffer} arrayBuffer The array buffer to clone.\n", | |
"\t * @returns {ArrayBuffer} Returns the cloned array buffer.\n", | |
"\t */\n", | |
"\t function cloneArrayBuffer(arrayBuffer) {\n", | |
"\t var result = new arrayBuffer.constructor(arrayBuffer.byteLength);\n", | |
"\t new Uint8Array(result).set(new Uint8Array(arrayBuffer));\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of `dataView`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} dataView The data view to clone.\n", | |
"\t * @param {boolean} [isDeep] Specify a deep clone.\n", | |
"\t * @returns {Object} Returns the cloned data view.\n", | |
"\t */\n", | |
"\t function cloneDataView(dataView, isDeep) {\n", | |
"\t var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;\n", | |
"\t return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of `map`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} map The map to clone.\n", | |
"\t * @param {Function} cloneFunc The function to clone values.\n", | |
"\t * @param {boolean} [isDeep] Specify a deep clone.\n", | |
"\t * @returns {Object} Returns the cloned map.\n", | |
"\t */\n", | |
"\t function cloneMap(map, isDeep, cloneFunc) {\n", | |
"\t var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);\n", | |
"\t return arrayReduce(array, addMapEntry, new map.constructor);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of `regexp`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} regexp The regexp to clone.\n", | |
"\t * @returns {Object} Returns the cloned regexp.\n", | |
"\t */\n", | |
"\t function cloneRegExp(regexp) {\n", | |
"\t var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));\n", | |
"\t result.lastIndex = regexp.lastIndex;\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of `set`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} set The set to clone.\n", | |
"\t * @param {Function} cloneFunc The function to clone values.\n", | |
"\t * @param {boolean} [isDeep] Specify a deep clone.\n", | |
"\t * @returns {Object} Returns the cloned set.\n", | |
"\t */\n", | |
"\t function cloneSet(set, isDeep, cloneFunc) {\n", | |
"\t var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);\n", | |
"\t return arrayReduce(array, addSetEntry, new set.constructor);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of the `symbol` object.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} symbol The symbol object to clone.\n", | |
"\t * @returns {Object} Returns the cloned symbol object.\n", | |
"\t */\n", | |
"\t function cloneSymbol(symbol) {\n", | |
"\t return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of `typedArray`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} typedArray The typed array to clone.\n", | |
"\t * @param {boolean} [isDeep] Specify a deep clone.\n", | |
"\t * @returns {Object} Returns the cloned typed array.\n", | |
"\t */\n", | |
"\t function cloneTypedArray(typedArray, isDeep) {\n", | |
"\t var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;\n", | |
"\t return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Compares values to sort them in ascending order.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to compare.\n", | |
"\t * @param {*} other The other value to compare.\n", | |
"\t * @returns {number} Returns the sort order indicator for `value`.\n", | |
"\t */\n", | |
"\t function compareAscending(value, other) {\n", | |
"\t if (value !== other) {\n", | |
"\t var valIsDefined = value !== undefined,\n", | |
"\t valIsNull = value === null,\n", | |
"\t valIsReflexive = value === value,\n", | |
"\t valIsSymbol = isSymbol(value);\n", | |
"\t\n", | |
"\t var othIsDefined = other !== undefined,\n", | |
"\t othIsNull = other === null,\n", | |
"\t othIsReflexive = other === other,\n", | |
"\t othIsSymbol = isSymbol(other);\n", | |
"\t\n", | |
"\t if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||\n", | |
"\t (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||\n", | |
"\t (valIsNull && othIsDefined && othIsReflexive) ||\n", | |
"\t (!valIsDefined && othIsReflexive) ||\n", | |
"\t !valIsReflexive) {\n", | |
"\t return 1;\n", | |
"\t }\n", | |
"\t if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||\n", | |
"\t (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||\n", | |
"\t (othIsNull && valIsDefined && valIsReflexive) ||\n", | |
"\t (!othIsDefined && valIsReflexive) ||\n", | |
"\t !othIsReflexive) {\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return 0;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.orderBy` to compare multiple properties of a value to another\n", | |
"\t * and stable sort them.\n", | |
"\t *\n", | |
"\t * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,\n", | |
"\t * specify an order of \"desc\" for descending or \"asc\" for ascending sort order\n", | |
"\t * of corresponding values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to compare.\n", | |
"\t * @param {Object} other The other object to compare.\n", | |
"\t * @param {boolean[]|string[]} orders The order to sort by for each property.\n", | |
"\t * @returns {number} Returns the sort order indicator for `object`.\n", | |
"\t */\n", | |
"\t function compareMultiple(object, other, orders) {\n", | |
"\t var index = -1,\n", | |
"\t objCriteria = object.criteria,\n", | |
"\t othCriteria = other.criteria,\n", | |
"\t length = objCriteria.length,\n", | |
"\t ordersLength = orders.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var result = compareAscending(objCriteria[index], othCriteria[index]);\n", | |
"\t if (result) {\n", | |
"\t if (index >= ordersLength) {\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t var order = orders[index];\n", | |
"\t return result * (order == 'desc' ? -1 : 1);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications\n", | |
"\t // that causes it, under certain circumstances, to provide the same value for\n", | |
"\t // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247\n", | |
"\t // for more details.\n", | |
"\t //\n", | |
"\t // This also ensures a stable sort in V8 and other engines.\n", | |
"\t // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.\n", | |
"\t return object.index - other.index;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array that is the composition of partially applied arguments,\n", | |
"\t * placeholders, and provided arguments into a single array of arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} args The provided arguments.\n", | |
"\t * @param {Array} partials The arguments to prepend to those provided.\n", | |
"\t * @param {Array} holders The `partials` placeholder indexes.\n", | |
"\t * @params {boolean} [isCurried] Specify composing for a curried function.\n", | |
"\t * @returns {Array} Returns the new array of composed arguments.\n", | |
"\t */\n", | |
"\t function composeArgs(args, partials, holders, isCurried) {\n", | |
"\t var argsIndex = -1,\n", | |
"\t argsLength = args.length,\n", | |
"\t holdersLength = holders.length,\n", | |
"\t leftIndex = -1,\n", | |
"\t leftLength = partials.length,\n", | |
"\t rangeLength = nativeMax(argsLength - holdersLength, 0),\n", | |
"\t result = Array(leftLength + rangeLength),\n", | |
"\t isUncurried = !isCurried;\n", | |
"\t\n", | |
"\t while (++leftIndex < leftLength) {\n", | |
"\t result[leftIndex] = partials[leftIndex];\n", | |
"\t }\n", | |
"\t while (++argsIndex < holdersLength) {\n", | |
"\t if (isUncurried || argsIndex < argsLength) {\n", | |
"\t result[holders[argsIndex]] = args[argsIndex];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t while (rangeLength--) {\n", | |
"\t result[leftIndex++] = args[argsIndex++];\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This function is like `composeArgs` except that the arguments composition\n", | |
"\t * is tailored for `_.partialRight`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} args The provided arguments.\n", | |
"\t * @param {Array} partials The arguments to append to those provided.\n", | |
"\t * @param {Array} holders The `partials` placeholder indexes.\n", | |
"\t * @params {boolean} [isCurried] Specify composing for a curried function.\n", | |
"\t * @returns {Array} Returns the new array of composed arguments.\n", | |
"\t */\n", | |
"\t function composeArgsRight(args, partials, holders, isCurried) {\n", | |
"\t var argsIndex = -1,\n", | |
"\t argsLength = args.length,\n", | |
"\t holdersIndex = -1,\n", | |
"\t holdersLength = holders.length,\n", | |
"\t rightIndex = -1,\n", | |
"\t rightLength = partials.length,\n", | |
"\t rangeLength = nativeMax(argsLength - holdersLength, 0),\n", | |
"\t result = Array(rangeLength + rightLength),\n", | |
"\t isUncurried = !isCurried;\n", | |
"\t\n", | |
"\t while (++argsIndex < rangeLength) {\n", | |
"\t result[argsIndex] = args[argsIndex];\n", | |
"\t }\n", | |
"\t var offset = argsIndex;\n", | |
"\t while (++rightIndex < rightLength) {\n", | |
"\t result[offset + rightIndex] = partials[rightIndex];\n", | |
"\t }\n", | |
"\t while (++holdersIndex < holdersLength) {\n", | |
"\t if (isUncurried || argsIndex < argsLength) {\n", | |
"\t result[offset + holders[holdersIndex]] = args[argsIndex++];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Copies the values of `source` to `array`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} source The array to copy values from.\n", | |
"\t * @param {Array} [array=[]] The array to copy values to.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function copyArray(source, array) {\n", | |
"\t var index = -1,\n", | |
"\t length = source.length;\n", | |
"\t\n", | |
"\t array || (array = Array(length));\n", | |
"\t while (++index < length) {\n", | |
"\t array[index] = source[index];\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Copies properties of `source` to `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} source The object to copy properties from.\n", | |
"\t * @param {Array} props The property identifiers to copy.\n", | |
"\t * @param {Object} [object={}] The object to copy properties to.\n", | |
"\t * @param {Function} [customizer] The function to customize copied values.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t function copyObject(source, props, object, customizer) {\n", | |
"\t var isNew = !object;\n", | |
"\t object || (object = {});\n", | |
"\t\n", | |
"\t var index = -1,\n", | |
"\t length = props.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var key = props[index];\n", | |
"\t\n", | |
"\t var newValue = customizer\n", | |
"\t ? customizer(object[key], source[key], key, object, source)\n", | |
"\t : undefined;\n", | |
"\t\n", | |
"\t if (newValue === undefined) {\n", | |
"\t newValue = source[key];\n", | |
"\t }\n", | |
"\t if (isNew) {\n", | |
"\t baseAssignValue(object, key, newValue);\n", | |
"\t } else {\n", | |
"\t assignValue(object, key, newValue);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return object;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Copies own symbol properties of `source` to `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} source The object to copy symbols from.\n", | |
"\t * @param {Object} [object={}] The object to copy symbols to.\n", | |
"\t * @returns {Object} Returns `object`.\n", | |
"\t */\n", | |
"\t function copySymbols(source, object) {\n", | |
"\t return copyObject(source, getSymbols(source), object);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function like `_.groupBy`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} setter The function to set accumulator values.\n", | |
"\t * @param {Function} [initializer] The accumulator object initializer.\n", | |
"\t * @returns {Function} Returns the new aggregator function.\n", | |
"\t */\n", | |
"\t function createAggregator(setter, initializer) {\n", | |
"\t return function(collection, iteratee) {\n", | |
"\t var func = isArray(collection) ? arrayAggregator : baseAggregator,\n", | |
"\t accumulator = initializer ? initializer() : {};\n", | |
"\t\n", | |
"\t return func(collection, setter, getIteratee(iteratee, 2), accumulator);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function like `_.assign`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} assigner The function to assign values.\n", | |
"\t * @returns {Function} Returns the new assigner function.\n", | |
"\t */\n", | |
"\t function createAssigner(assigner) {\n", | |
"\t return baseRest(function(object, sources) {\n", | |
"\t var index = -1,\n", | |
"\t length = sources.length,\n", | |
"\t customizer = length > 1 ? sources[length - 1] : undefined,\n", | |
"\t guard = length > 2 ? sources[2] : undefined;\n", | |
"\t\n", | |
"\t customizer = (assigner.length > 3 && typeof customizer == 'function')\n", | |
"\t ? (length--, customizer)\n", | |
"\t : undefined;\n", | |
"\t\n", | |
"\t if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n", | |
"\t customizer = length < 3 ? undefined : customizer;\n", | |
"\t length = 1;\n", | |
"\t }\n", | |
"\t object = Object(object);\n", | |
"\t while (++index < length) {\n", | |
"\t var source = sources[index];\n", | |
"\t if (source) {\n", | |
"\t assigner(object, source, index, customizer);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return object;\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a `baseEach` or `baseEachRight` function.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} eachFunc The function to iterate over a collection.\n", | |
"\t * @param {boolean} [fromRight] Specify iterating from right to left.\n", | |
"\t * @returns {Function} Returns the new base function.\n", | |
"\t */\n", | |
"\t function createBaseEach(eachFunc, fromRight) {\n", | |
"\t return function(collection, iteratee) {\n", | |
"\t if (collection == null) {\n", | |
"\t return collection;\n", | |
"\t }\n", | |
"\t if (!isArrayLike(collection)) {\n", | |
"\t return eachFunc(collection, iteratee);\n", | |
"\t }\n", | |
"\t var length = collection.length,\n", | |
"\t index = fromRight ? length : -1,\n", | |
"\t iterable = Object(collection);\n", | |
"\t\n", | |
"\t while ((fromRight ? index-- : ++index < length)) {\n", | |
"\t if (iteratee(iterable[index], index, iterable) === false) {\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return collection;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a base function for methods like `_.forIn` and `_.forOwn`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {boolean} [fromRight] Specify iterating from right to left.\n", | |
"\t * @returns {Function} Returns the new base function.\n", | |
"\t */\n", | |
"\t function createBaseFor(fromRight) {\n", | |
"\t return function(object, iteratee, keysFunc) {\n", | |
"\t var index = -1,\n", | |
"\t iterable = Object(object),\n", | |
"\t props = keysFunc(object),\n", | |
"\t length = props.length;\n", | |
"\t\n", | |
"\t while (length--) {\n", | |
"\t var key = props[fromRight ? length : ++index];\n", | |
"\t if (iteratee(iterable[key], key, iterable) === false) {\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return object;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that wraps `func` to invoke it with the optional `this`\n", | |
"\t * binding of `thisArg`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to wrap.\n", | |
"\t * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n", | |
"\t * @param {*} [thisArg] The `this` binding of `func`.\n", | |
"\t * @returns {Function} Returns the new wrapped function.\n", | |
"\t */\n", | |
"\t function createBind(func, bitmask, thisArg) {\n", | |
"\t var isBind = bitmask & BIND_FLAG,\n", | |
"\t Ctor = createCtor(func);\n", | |
"\t\n", | |
"\t function wrapper() {\n", | |
"\t var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n", | |
"\t return fn.apply(isBind ? thisArg : this, arguments);\n", | |
"\t }\n", | |
"\t return wrapper;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function like `_.lowerFirst`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} methodName The name of the `String` case method to use.\n", | |
"\t * @returns {Function} Returns the new case function.\n", | |
"\t */\n", | |
"\t function createCaseFirst(methodName) {\n", | |
"\t return function(string) {\n", | |
"\t string = toString(string);\n", | |
"\t\n", | |
"\t var strSymbols = hasUnicode(string)\n", | |
"\t ? stringToArray(string)\n", | |
"\t : undefined;\n", | |
"\t\n", | |
"\t var chr = strSymbols\n", | |
"\t ? strSymbols[0]\n", | |
"\t : string.charAt(0);\n", | |
"\t\n", | |
"\t var trailing = strSymbols\n", | |
"\t ? castSlice(strSymbols, 1).join('')\n", | |
"\t : string.slice(1);\n", | |
"\t\n", | |
"\t return chr[methodName]() + trailing;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function like `_.camelCase`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} callback The function to combine each word.\n", | |
"\t * @returns {Function} Returns the new compounder function.\n", | |
"\t */\n", | |
"\t function createCompounder(callback) {\n", | |
"\t return function(string) {\n", | |
"\t return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that produces an instance of `Ctor` regardless of\n", | |
"\t * whether it was invoked as part of a `new` expression or by `call` or `apply`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} Ctor The constructor to wrap.\n", | |
"\t * @returns {Function} Returns the new wrapped function.\n", | |
"\t */\n", | |
"\t function createCtor(Ctor) {\n", | |
"\t return function() {\n", | |
"\t // Use a `switch` statement to work with class constructors. See\n", | |
"\t // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist\n", | |
"\t // for more details.\n", | |
"\t var args = arguments;\n", | |
"\t switch (args.length) {\n", | |
"\t case 0: return new Ctor;\n", | |
"\t case 1: return new Ctor(args[0]);\n", | |
"\t case 2: return new Ctor(args[0], args[1]);\n", | |
"\t case 3: return new Ctor(args[0], args[1], args[2]);\n", | |
"\t case 4: return new Ctor(args[0], args[1], args[2], args[3]);\n", | |
"\t case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);\n", | |
"\t case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);\n", | |
"\t case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);\n", | |
"\t }\n", | |
"\t var thisBinding = baseCreate(Ctor.prototype),\n", | |
"\t result = Ctor.apply(thisBinding, args);\n", | |
"\t\n", | |
"\t // Mimic the constructor's `return` behavior.\n", | |
"\t // See https://es5.github.io/#x13.2.2 for more details.\n", | |
"\t return isObject(result) ? result : thisBinding;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that wraps `func` to enable currying.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to wrap.\n", | |
"\t * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n", | |
"\t * @param {number} arity The arity of `func`.\n", | |
"\t * @returns {Function} Returns the new wrapped function.\n", | |
"\t */\n", | |
"\t function createCurry(func, bitmask, arity) {\n", | |
"\t var Ctor = createCtor(func);\n", | |
"\t\n", | |
"\t function wrapper() {\n", | |
"\t var length = arguments.length,\n", | |
"\t args = Array(length),\n", | |
"\t index = length,\n", | |
"\t placeholder = getHolder(wrapper);\n", | |
"\t\n", | |
"\t while (index--) {\n", | |
"\t args[index] = arguments[index];\n", | |
"\t }\n", | |
"\t var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)\n", | |
"\t ? []\n", | |
"\t : replaceHolders(args, placeholder);\n", | |
"\t\n", | |
"\t length -= holders.length;\n", | |
"\t if (length < arity) {\n", | |
"\t return createRecurry(\n", | |
"\t func, bitmask, createHybrid, wrapper.placeholder, undefined,\n", | |
"\t args, holders, undefined, undefined, arity - length);\n", | |
"\t }\n", | |
"\t var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n", | |
"\t return apply(fn, this, args);\n", | |
"\t }\n", | |
"\t return wrapper;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a `_.find` or `_.findLast` function.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} findIndexFunc The function to find the collection index.\n", | |
"\t * @returns {Function} Returns the new find function.\n", | |
"\t */\n", | |
"\t function createFind(findIndexFunc) {\n", | |
"\t return function(collection, predicate, fromIndex) {\n", | |
"\t var iterable = Object(collection);\n", | |
"\t if (!isArrayLike(collection)) {\n", | |
"\t var iteratee = getIteratee(predicate, 3);\n", | |
"\t collection = keys(collection);\n", | |
"\t predicate = function(key) { return iteratee(iterable[key], key, iterable); };\n", | |
"\t }\n", | |
"\t var index = findIndexFunc(collection, predicate, fromIndex);\n", | |
"\t return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a `_.flow` or `_.flowRight` function.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {boolean} [fromRight] Specify iterating from right to left.\n", | |
"\t * @returns {Function} Returns the new flow function.\n", | |
"\t */\n", | |
"\t function createFlow(fromRight) {\n", | |
"\t return flatRest(function(funcs) {\n", | |
"\t var length = funcs.length,\n", | |
"\t index = length,\n", | |
"\t prereq = LodashWrapper.prototype.thru;\n", | |
"\t\n", | |
"\t if (fromRight) {\n", | |
"\t funcs.reverse();\n", | |
"\t }\n", | |
"\t while (index--) {\n", | |
"\t var func = funcs[index];\n", | |
"\t if (typeof func != 'function') {\n", | |
"\t throw new TypeError(FUNC_ERROR_TEXT);\n", | |
"\t }\n", | |
"\t if (prereq && !wrapper && getFuncName(func) == 'wrapper') {\n", | |
"\t var wrapper = new LodashWrapper([], true);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t index = wrapper ? index : length;\n", | |
"\t while (++index < length) {\n", | |
"\t func = funcs[index];\n", | |
"\t\n", | |
"\t var funcName = getFuncName(func),\n", | |
"\t data = funcName == 'wrapper' ? getData(func) : undefined;\n", | |
"\t\n", | |
"\t if (data && isLaziable(data[0]) &&\n", | |
"\t data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&\n", | |
"\t !data[4].length && data[9] == 1\n", | |
"\t ) {\n", | |
"\t wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);\n", | |
"\t } else {\n", | |
"\t wrapper = (func.length == 1 && isLaziable(func))\n", | |
"\t ? wrapper[funcName]()\n", | |
"\t : wrapper.thru(func);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return function() {\n", | |
"\t var args = arguments,\n", | |
"\t value = args[0];\n", | |
"\t\n", | |
"\t if (wrapper && args.length == 1 &&\n", | |
"\t isArray(value) && value.length >= LARGE_ARRAY_SIZE) {\n", | |
"\t return wrapper.plant(value).value();\n", | |
"\t }\n", | |
"\t var index = 0,\n", | |
"\t result = length ? funcs[index].apply(this, args) : value;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t result = funcs[index].call(this, result);\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t };\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that wraps `func` to invoke it with optional `this`\n", | |
"\t * binding of `thisArg`, partial application, and currying.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function|string} func The function or method name to wrap.\n", | |
"\t * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n", | |
"\t * @param {*} [thisArg] The `this` binding of `func`.\n", | |
"\t * @param {Array} [partials] The arguments to prepend to those provided to\n", | |
"\t * the new function.\n", | |
"\t * @param {Array} [holders] The `partials` placeholder indexes.\n", | |
"\t * @param {Array} [partialsRight] The arguments to append to those provided\n", | |
"\t * to the new function.\n", | |
"\t * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.\n", | |
"\t * @param {Array} [argPos] The argument positions of the new function.\n", | |
"\t * @param {number} [ary] The arity cap of `func`.\n", | |
"\t * @param {number} [arity] The arity of `func`.\n", | |
"\t * @returns {Function} Returns the new wrapped function.\n", | |
"\t */\n", | |
"\t function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {\n", | |
"\t var isAry = bitmask & ARY_FLAG,\n", | |
"\t isBind = bitmask & BIND_FLAG,\n", | |
"\t isBindKey = bitmask & BIND_KEY_FLAG,\n", | |
"\t isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),\n", | |
"\t isFlip = bitmask & FLIP_FLAG,\n", | |
"\t Ctor = isBindKey ? undefined : createCtor(func);\n", | |
"\t\n", | |
"\t function wrapper() {\n", | |
"\t var length = arguments.length,\n", | |
"\t args = Array(length),\n", | |
"\t index = length;\n", | |
"\t\n", | |
"\t while (index--) {\n", | |
"\t args[index] = arguments[index];\n", | |
"\t }\n", | |
"\t if (isCurried) {\n", | |
"\t var placeholder = getHolder(wrapper),\n", | |
"\t holdersCount = countHolders(args, placeholder);\n", | |
"\t }\n", | |
"\t if (partials) {\n", | |
"\t args = composeArgs(args, partials, holders, isCurried);\n", | |
"\t }\n", | |
"\t if (partialsRight) {\n", | |
"\t args = composeArgsRight(args, partialsRight, holdersRight, isCurried);\n", | |
"\t }\n", | |
"\t length -= holdersCount;\n", | |
"\t if (isCurried && length < arity) {\n", | |
"\t var newHolders = replaceHolders(args, placeholder);\n", | |
"\t return createRecurry(\n", | |
"\t func, bitmask, createHybrid, wrapper.placeholder, thisArg,\n", | |
"\t args, newHolders, argPos, ary, arity - length\n", | |
"\t );\n", | |
"\t }\n", | |
"\t var thisBinding = isBind ? thisArg : this,\n", | |
"\t fn = isBindKey ? thisBinding[func] : func;\n", | |
"\t\n", | |
"\t length = args.length;\n", | |
"\t if (argPos) {\n", | |
"\t args = reorder(args, argPos);\n", | |
"\t } else if (isFlip && length > 1) {\n", | |
"\t args.reverse();\n", | |
"\t }\n", | |
"\t if (isAry && ary < length) {\n", | |
"\t args.length = ary;\n", | |
"\t }\n", | |
"\t if (this && this !== root && this instanceof wrapper) {\n", | |
"\t fn = Ctor || createCtor(fn);\n", | |
"\t }\n", | |
"\t return fn.apply(thisBinding, args);\n", | |
"\t }\n", | |
"\t return wrapper;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function like `_.invertBy`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} setter The function to set accumulator values.\n", | |
"\t * @param {Function} toIteratee The function to resolve iteratees.\n", | |
"\t * @returns {Function} Returns the new inverter function.\n", | |
"\t */\n", | |
"\t function createInverter(setter, toIteratee) {\n", | |
"\t return function(object, iteratee) {\n", | |
"\t return baseInverter(object, setter, toIteratee(iteratee), {});\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that performs a mathematical operation on two values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} operator The function to perform the operation.\n", | |
"\t * @param {number} [defaultValue] The value used for `undefined` arguments.\n", | |
"\t * @returns {Function} Returns the new mathematical operation function.\n", | |
"\t */\n", | |
"\t function createMathOperation(operator, defaultValue) {\n", | |
"\t return function(value, other) {\n", | |
"\t var result;\n", | |
"\t if (value === undefined && other === undefined) {\n", | |
"\t return defaultValue;\n", | |
"\t }\n", | |
"\t if (value !== undefined) {\n", | |
"\t result = value;\n", | |
"\t }\n", | |
"\t if (other !== undefined) {\n", | |
"\t if (result === undefined) {\n", | |
"\t return other;\n", | |
"\t }\n", | |
"\t if (typeof value == 'string' || typeof other == 'string') {\n", | |
"\t value = baseToString(value);\n", | |
"\t other = baseToString(other);\n", | |
"\t } else {\n", | |
"\t value = baseToNumber(value);\n", | |
"\t other = baseToNumber(other);\n", | |
"\t }\n", | |
"\t result = operator(value, other);\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function like `_.over`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} arrayFunc The function to iterate over iteratees.\n", | |
"\t * @returns {Function} Returns the new over function.\n", | |
"\t */\n", | |
"\t function createOver(arrayFunc) {\n", | |
"\t return flatRest(function(iteratees) {\n", | |
"\t iteratees = arrayMap(iteratees, baseUnary(getIteratee()));\n", | |
"\t return baseRest(function(args) {\n", | |
"\t var thisArg = this;\n", | |
"\t return arrayFunc(iteratees, function(iteratee) {\n", | |
"\t return apply(iteratee, thisArg, args);\n", | |
"\t });\n", | |
"\t });\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates the padding for `string` based on `length`. The `chars` string\n", | |
"\t * is truncated if the number of characters exceeds `length`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {number} length The padding length.\n", | |
"\t * @param {string} [chars=' '] The string used as padding.\n", | |
"\t * @returns {string} Returns the padding for `string`.\n", | |
"\t */\n", | |
"\t function createPadding(length, chars) {\n", | |
"\t chars = chars === undefined ? ' ' : baseToString(chars);\n", | |
"\t\n", | |
"\t var charsLength = chars.length;\n", | |
"\t if (charsLength < 2) {\n", | |
"\t return charsLength ? baseRepeat(chars, length) : chars;\n", | |
"\t }\n", | |
"\t var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));\n", | |
"\t return hasUnicode(chars)\n", | |
"\t ? castSlice(stringToArray(result), 0, length).join('')\n", | |
"\t : result.slice(0, length);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that wraps `func` to invoke it with the `this` binding\n", | |
"\t * of `thisArg` and `partials` prepended to the arguments it receives.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to wrap.\n", | |
"\t * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n", | |
"\t * @param {*} thisArg The `this` binding of `func`.\n", | |
"\t * @param {Array} partials The arguments to prepend to those provided to\n", | |
"\t * the new function.\n", | |
"\t * @returns {Function} Returns the new wrapped function.\n", | |
"\t */\n", | |
"\t function createPartial(func, bitmask, thisArg, partials) {\n", | |
"\t var isBind = bitmask & BIND_FLAG,\n", | |
"\t Ctor = createCtor(func);\n", | |
"\t\n", | |
"\t function wrapper() {\n", | |
"\t var argsIndex = -1,\n", | |
"\t argsLength = arguments.length,\n", | |
"\t leftIndex = -1,\n", | |
"\t leftLength = partials.length,\n", | |
"\t args = Array(leftLength + argsLength),\n", | |
"\t fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n", | |
"\t\n", | |
"\t while (++leftIndex < leftLength) {\n", | |
"\t args[leftIndex] = partials[leftIndex];\n", | |
"\t }\n", | |
"\t while (argsLength--) {\n", | |
"\t args[leftIndex++] = arguments[++argsIndex];\n", | |
"\t }\n", | |
"\t return apply(fn, isBind ? thisArg : this, args);\n", | |
"\t }\n", | |
"\t return wrapper;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a `_.range` or `_.rangeRight` function.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {boolean} [fromRight] Specify iterating from right to left.\n", | |
"\t * @returns {Function} Returns the new range function.\n", | |
"\t */\n", | |
"\t function createRange(fromRight) {\n", | |
"\t return function(start, end, step) {\n", | |
"\t if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {\n", | |
"\t end = step = undefined;\n", | |
"\t }\n", | |
"\t // Ensure the sign of `-0` is preserved.\n", | |
"\t start = toFinite(start);\n", | |
"\t if (end === undefined) {\n", | |
"\t end = start;\n", | |
"\t start = 0;\n", | |
"\t } else {\n", | |
"\t end = toFinite(end);\n", | |
"\t }\n", | |
"\t step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);\n", | |
"\t return baseRange(start, end, step, fromRight);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that performs a relational operation on two values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} operator The function to perform the operation.\n", | |
"\t * @returns {Function} Returns the new relational operation function.\n", | |
"\t */\n", | |
"\t function createRelationalOperation(operator) {\n", | |
"\t return function(value, other) {\n", | |
"\t if (!(typeof value == 'string' && typeof other == 'string')) {\n", | |
"\t value = toNumber(value);\n", | |
"\t other = toNumber(other);\n", | |
"\t }\n", | |
"\t return operator(value, other);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that wraps `func` to continue currying.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to wrap.\n", | |
"\t * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n", | |
"\t * @param {Function} wrapFunc The function to create the `func` wrapper.\n", | |
"\t * @param {*} placeholder The placeholder value.\n", | |
"\t * @param {*} [thisArg] The `this` binding of `func`.\n", | |
"\t * @param {Array} [partials] The arguments to prepend to those provided to\n", | |
"\t * the new function.\n", | |
"\t * @param {Array} [holders] The `partials` placeholder indexes.\n", | |
"\t * @param {Array} [argPos] The argument positions of the new function.\n", | |
"\t * @param {number} [ary] The arity cap of `func`.\n", | |
"\t * @param {number} [arity] The arity of `func`.\n", | |
"\t * @returns {Function} Returns the new wrapped function.\n", | |
"\t */\n", | |
"\t function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {\n", | |
"\t var isCurry = bitmask & CURRY_FLAG,\n", | |
"\t newHolders = isCurry ? holders : undefined,\n", | |
"\t newHoldersRight = isCurry ? undefined : holders,\n", | |
"\t newPartials = isCurry ? partials : undefined,\n", | |
"\t newPartialsRight = isCurry ? undefined : partials;\n", | |
"\t\n", | |
"\t bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);\n", | |
"\t bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);\n", | |
"\t\n", | |
"\t if (!(bitmask & CURRY_BOUND_FLAG)) {\n", | |
"\t bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);\n", | |
"\t }\n", | |
"\t var newData = [\n", | |
"\t func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,\n", | |
"\t newHoldersRight, argPos, ary, arity\n", | |
"\t ];\n", | |
"\t\n", | |
"\t var result = wrapFunc.apply(undefined, newData);\n", | |
"\t if (isLaziable(func)) {\n", | |
"\t setData(result, newData);\n", | |
"\t }\n", | |
"\t result.placeholder = placeholder;\n", | |
"\t return setWrapToString(result, func, bitmask);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function like `_.round`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} methodName The name of the `Math` method to use when rounding.\n", | |
"\t * @returns {Function} Returns the new round function.\n", | |
"\t */\n", | |
"\t function createRound(methodName) {\n", | |
"\t var func = Math[methodName];\n", | |
"\t return function(number, precision) {\n", | |
"\t number = toNumber(number);\n", | |
"\t precision = nativeMin(toInteger(precision), 292);\n", | |
"\t if (precision) {\n", | |
"\t // Shift with exponential notation to avoid floating-point issues.\n", | |
"\t // See [MDN](https://mdn.io/round#Examples) for more details.\n", | |
"\t var pair = (toString(number) + 'e').split('e'),\n", | |
"\t value = func(pair[0] + 'e' + (+pair[1] + precision));\n", | |
"\t\n", | |
"\t pair = (toString(value) + 'e').split('e');\n", | |
"\t return +(pair[0] + 'e' + (+pair[1] - precision));\n", | |
"\t }\n", | |
"\t return func(number);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a set object of `values`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} values The values to add to the set.\n", | |
"\t * @returns {Object} Returns the new set.\n", | |
"\t */\n", | |
"\t var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {\n", | |
"\t return new Set(values);\n", | |
"\t };\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a `_.toPairs` or `_.toPairsIn` function.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} keysFunc The function to get the keys of a given object.\n", | |
"\t * @returns {Function} Returns the new pairs function.\n", | |
"\t */\n", | |
"\t function createToPairs(keysFunc) {\n", | |
"\t return function(object) {\n", | |
"\t var tag = getTag(object);\n", | |
"\t if (tag == mapTag) {\n", | |
"\t return mapToArray(object);\n", | |
"\t }\n", | |
"\t if (tag == setTag) {\n", | |
"\t return setToPairs(object);\n", | |
"\t }\n", | |
"\t return baseToPairs(object, keysFunc(object));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that either curries or invokes `func` with optional\n", | |
"\t * `this` binding and partially applied arguments.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function|string} func The function or method name to wrap.\n", | |
"\t * @param {number} bitmask The bitmask flags.\n", | |
"\t * The bitmask may be composed of the following flags:\n", | |
"\t * 1 - `_.bind`\n", | |
"\t * 2 - `_.bindKey`\n", | |
"\t * 4 - `_.curry` or `_.curryRight` of a bound function\n", | |
"\t * 8 - `_.curry`\n", | |
"\t * 16 - `_.curryRight`\n", | |
"\t * 32 - `_.partial`\n", | |
"\t * 64 - `_.partialRight`\n", | |
"\t * 128 - `_.rearg`\n", | |
"\t * 256 - `_.ary`\n", | |
"\t * 512 - `_.flip`\n", | |
"\t * @param {*} [thisArg] The `this` binding of `func`.\n", | |
"\t * @param {Array} [partials] The arguments to be partially applied.\n", | |
"\t * @param {Array} [holders] The `partials` placeholder indexes.\n", | |
"\t * @param {Array} [argPos] The argument positions of the new function.\n", | |
"\t * @param {number} [ary] The arity cap of `func`.\n", | |
"\t * @param {number} [arity] The arity of `func`.\n", | |
"\t * @returns {Function} Returns the new wrapped function.\n", | |
"\t */\n", | |
"\t function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {\n", | |
"\t var isBindKey = bitmask & BIND_KEY_FLAG;\n", | |
"\t if (!isBindKey && typeof func != 'function') {\n", | |
"\t throw new TypeError(FUNC_ERROR_TEXT);\n", | |
"\t }\n", | |
"\t var length = partials ? partials.length : 0;\n", | |
"\t if (!length) {\n", | |
"\t bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);\n", | |
"\t partials = holders = undefined;\n", | |
"\t }\n", | |
"\t ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);\n", | |
"\t arity = arity === undefined ? arity : toInteger(arity);\n", | |
"\t length -= holders ? holders.length : 0;\n", | |
"\t\n", | |
"\t if (bitmask & PARTIAL_RIGHT_FLAG) {\n", | |
"\t var partialsRight = partials,\n", | |
"\t holdersRight = holders;\n", | |
"\t\n", | |
"\t partials = holders = undefined;\n", | |
"\t }\n", | |
"\t var data = isBindKey ? undefined : getData(func);\n", | |
"\t\n", | |
"\t var newData = [\n", | |
"\t func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,\n", | |
"\t argPos, ary, arity\n", | |
"\t ];\n", | |
"\t\n", | |
"\t if (data) {\n", | |
"\t mergeData(newData, data);\n", | |
"\t }\n", | |
"\t func = newData[0];\n", | |
"\t bitmask = newData[1];\n", | |
"\t thisArg = newData[2];\n", | |
"\t partials = newData[3];\n", | |
"\t holders = newData[4];\n", | |
"\t arity = newData[9] = newData[9] == null\n", | |
"\t ? (isBindKey ? 0 : func.length)\n", | |
"\t : nativeMax(newData[9] - length, 0);\n", | |
"\t\n", | |
"\t if (!arity && bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG)) {\n", | |
"\t bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG);\n", | |
"\t }\n", | |
"\t if (!bitmask || bitmask == BIND_FLAG) {\n", | |
"\t var result = createBind(func, bitmask, thisArg);\n", | |
"\t } else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) {\n", | |
"\t result = createCurry(func, bitmask, arity);\n", | |
"\t } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) {\n", | |
"\t result = createPartial(func, bitmask, thisArg, partials);\n", | |
"\t } else {\n", | |
"\t result = createHybrid.apply(undefined, newData);\n", | |
"\t }\n", | |
"\t var setter = data ? baseSetData : setData;\n", | |
"\t return setWrapToString(setter(result, newData), func, bitmask);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseIsEqualDeep` for arrays with support for\n", | |
"\t * partial deep comparisons.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to compare.\n", | |
"\t * @param {Array} other The other array to compare.\n", | |
"\t * @param {Function} equalFunc The function to determine equivalents of values.\n", | |
"\t * @param {Function} customizer The function to customize comparisons.\n", | |
"\t * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n", | |
"\t * for more details.\n", | |
"\t * @param {Object} stack Tracks traversed `array` and `other` objects.\n", | |
"\t * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n", | |
"\t */\n", | |
"\t function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {\n", | |
"\t var isPartial = bitmask & PARTIAL_COMPARE_FLAG,\n", | |
"\t arrLength = array.length,\n", | |
"\t othLength = other.length;\n", | |
"\t\n", | |
"\t if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t // Assume cyclic values are equal.\n", | |
"\t var stacked = stack.get(array);\n", | |
"\t if (stacked && stack.get(other)) {\n", | |
"\t return stacked == other;\n", | |
"\t }\n", | |
"\t var index = -1,\n", | |
"\t result = true,\n", | |
"\t seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;\n", | |
"\t\n", | |
"\t stack.set(array, other);\n", | |
"\t stack.set(other, array);\n", | |
"\t\n", | |
"\t // Ignore non-index properties.\n", | |
"\t while (++index < arrLength) {\n", | |
"\t var arrValue = array[index],\n", | |
"\t othValue = other[index];\n", | |
"\t\n", | |
"\t if (customizer) {\n", | |
"\t var compared = isPartial\n", | |
"\t ? customizer(othValue, arrValue, index, other, array, stack)\n", | |
"\t : customizer(arrValue, othValue, index, array, other, stack);\n", | |
"\t }\n", | |
"\t if (compared !== undefined) {\n", | |
"\t if (compared) {\n", | |
"\t continue;\n", | |
"\t }\n", | |
"\t result = false;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t // Recursively compare arrays (susceptible to call stack limits).\n", | |
"\t if (seen) {\n", | |
"\t if (!arraySome(other, function(othValue, othIndex) {\n", | |
"\t if (!cacheHas(seen, othIndex) &&\n", | |
"\t (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {\n", | |
"\t return seen.push(othIndex);\n", | |
"\t }\n", | |
"\t })) {\n", | |
"\t result = false;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t } else if (!(\n", | |
"\t arrValue === othValue ||\n", | |
"\t equalFunc(arrValue, othValue, customizer, bitmask, stack)\n", | |
"\t )) {\n", | |
"\t result = false;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t stack['delete'](array);\n", | |
"\t stack['delete'](other);\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseIsEqualDeep` for comparing objects of\n", | |
"\t * the same `toStringTag`.\n", | |
"\t *\n", | |
"\t * **Note:** This function only supports comparing values with tags of\n", | |
"\t * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to compare.\n", | |
"\t * @param {Object} other The other object to compare.\n", | |
"\t * @param {string} tag The `toStringTag` of the objects to compare.\n", | |
"\t * @param {Function} equalFunc The function to determine equivalents of values.\n", | |
"\t * @param {Function} customizer The function to customize comparisons.\n", | |
"\t * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n", | |
"\t * for more details.\n", | |
"\t * @param {Object} stack Tracks traversed `object` and `other` objects.\n", | |
"\t * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n", | |
"\t */\n", | |
"\t function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {\n", | |
"\t switch (tag) {\n", | |
"\t case dataViewTag:\n", | |
"\t if ((object.byteLength != other.byteLength) ||\n", | |
"\t (object.byteOffset != other.byteOffset)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t object = object.buffer;\n", | |
"\t other = other.buffer;\n", | |
"\t\n", | |
"\t case arrayBufferTag:\n", | |
"\t if ((object.byteLength != other.byteLength) ||\n", | |
"\t !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t return true;\n", | |
"\t\n", | |
"\t case boolTag:\n", | |
"\t case dateTag:\n", | |
"\t case numberTag:\n", | |
"\t // Coerce booleans to `1` or `0` and dates to milliseconds.\n", | |
"\t // Invalid dates are coerced to `NaN`.\n", | |
"\t return eq(+object, +other);\n", | |
"\t\n", | |
"\t case errorTag:\n", | |
"\t return object.name == other.name && object.message == other.message;\n", | |
"\t\n", | |
"\t case regexpTag:\n", | |
"\t case stringTag:\n", | |
"\t // Coerce regexes to strings and treat strings, primitives and objects,\n", | |
"\t // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n", | |
"\t // for more details.\n", | |
"\t return object == (other + '');\n", | |
"\t\n", | |
"\t case mapTag:\n", | |
"\t var convert = mapToArray;\n", | |
"\t\n", | |
"\t case setTag:\n", | |
"\t var isPartial = bitmask & PARTIAL_COMPARE_FLAG;\n", | |
"\t convert || (convert = setToArray);\n", | |
"\t\n", | |
"\t if (object.size != other.size && !isPartial) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t // Assume cyclic values are equal.\n", | |
"\t var stacked = stack.get(object);\n", | |
"\t if (stacked) {\n", | |
"\t return stacked == other;\n", | |
"\t }\n", | |
"\t bitmask |= UNORDERED_COMPARE_FLAG;\n", | |
"\t\n", | |
"\t // Recursively compare objects (susceptible to call stack limits).\n", | |
"\t stack.set(object, other);\n", | |
"\t var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);\n", | |
"\t stack['delete'](object);\n", | |
"\t return result;\n", | |
"\t\n", | |
"\t case symbolTag:\n", | |
"\t if (symbolValueOf) {\n", | |
"\t return symbolValueOf.call(object) == symbolValueOf.call(other);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseIsEqualDeep` for objects with support for\n", | |
"\t * partial deep comparisons.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to compare.\n", | |
"\t * @param {Object} other The other object to compare.\n", | |
"\t * @param {Function} equalFunc The function to determine equivalents of values.\n", | |
"\t * @param {Function} customizer The function to customize comparisons.\n", | |
"\t * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`\n", | |
"\t * for more details.\n", | |
"\t * @param {Object} stack Tracks traversed `object` and `other` objects.\n", | |
"\t * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n", | |
"\t */\n", | |
"\t function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {\n", | |
"\t var isPartial = bitmask & PARTIAL_COMPARE_FLAG,\n", | |
"\t objProps = keys(object),\n", | |
"\t objLength = objProps.length,\n", | |
"\t othProps = keys(other),\n", | |
"\t othLength = othProps.length;\n", | |
"\t\n", | |
"\t if (objLength != othLength && !isPartial) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t var index = objLength;\n", | |
"\t while (index--) {\n", | |
"\t var key = objProps[index];\n", | |
"\t if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t // Assume cyclic values are equal.\n", | |
"\t var stacked = stack.get(object);\n", | |
"\t if (stacked && stack.get(other)) {\n", | |
"\t return stacked == other;\n", | |
"\t }\n", | |
"\t var result = true;\n", | |
"\t stack.set(object, other);\n", | |
"\t stack.set(other, object);\n", | |
"\t\n", | |
"\t var skipCtor = isPartial;\n", | |
"\t while (++index < objLength) {\n", | |
"\t key = objProps[index];\n", | |
"\t var objValue = object[key],\n", | |
"\t othValue = other[key];\n", | |
"\t\n", | |
"\t if (customizer) {\n", | |
"\t var compared = isPartial\n", | |
"\t ? customizer(othValue, objValue, key, other, object, stack)\n", | |
"\t : customizer(objValue, othValue, key, object, other, stack);\n", | |
"\t }\n", | |
"\t // Recursively compare objects (susceptible to call stack limits).\n", | |
"\t if (!(compared === undefined\n", | |
"\t ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))\n", | |
"\t : compared\n", | |
"\t )) {\n", | |
"\t result = false;\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t skipCtor || (skipCtor = key == 'constructor');\n", | |
"\t }\n", | |
"\t if (result && !skipCtor) {\n", | |
"\t var objCtor = object.constructor,\n", | |
"\t othCtor = other.constructor;\n", | |
"\t\n", | |
"\t // Non `Object` object instances with different constructors are not equal.\n", | |
"\t if (objCtor != othCtor &&\n", | |
"\t ('constructor' in object && 'constructor' in other) &&\n", | |
"\t !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n", | |
"\t typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n", | |
"\t result = false;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t stack['delete'](object);\n", | |
"\t stack['delete'](other);\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseRest` which flattens the rest array.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to apply a rest parameter to.\n", | |
"\t * @returns {Function} Returns the new function.\n", | |
"\t */\n", | |
"\t function flatRest(func) {\n", | |
"\t return setToString(overRest(func, undefined, flatten), func + '');\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of own enumerable property names and symbols of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Array} Returns the array of property names and symbols.\n", | |
"\t */\n", | |
"\t function getAllKeys(object) {\n", | |
"\t return baseGetAllKeys(object, keys, getSymbols);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of own and inherited enumerable property names and\n", | |
"\t * symbols of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Array} Returns the array of property names and symbols.\n", | |
"\t */\n", | |
"\t function getAllKeysIn(object) {\n", | |
"\t return baseGetAllKeys(object, keysIn, getSymbolsIn);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets metadata for `func`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to query.\n", | |
"\t * @returns {*} Returns the metadata for `func`.\n", | |
"\t */\n", | |
"\t var getData = !metaMap ? noop : function(func) {\n", | |
"\t return metaMap.get(func);\n", | |
"\t };\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the name of `func`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to query.\n", | |
"\t * @returns {string} Returns the function name.\n", | |
"\t */\n", | |
"\t function getFuncName(func) {\n", | |
"\t var result = (func.name + ''),\n", | |
"\t array = realNames[result],\n", | |
"\t length = hasOwnProperty.call(realNames, result) ? array.length : 0;\n", | |
"\t\n", | |
"\t while (length--) {\n", | |
"\t var data = array[length],\n", | |
"\t otherFunc = data.func;\n", | |
"\t if (otherFunc == null || otherFunc == func) {\n", | |
"\t return data.name;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the argument placeholder value for `func`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to inspect.\n", | |
"\t * @returns {*} Returns the placeholder value.\n", | |
"\t */\n", | |
"\t function getHolder(func) {\n", | |
"\t var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;\n", | |
"\t return object.placeholder;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the appropriate \"iteratee\" function. If `_.iteratee` is customized,\n", | |
"\t * this function returns the custom method, otherwise it returns `baseIteratee`.\n", | |
"\t * If arguments are provided, the chosen function is invoked with them and\n", | |
"\t * its result is returned.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} [value] The value to convert to an iteratee.\n", | |
"\t * @param {number} [arity] The arity of the created iteratee.\n", | |
"\t * @returns {Function} Returns the chosen function or its result.\n", | |
"\t */\n", | |
"\t function getIteratee() {\n", | |
"\t var result = lodash.iteratee || iteratee;\n", | |
"\t result = result === iteratee ? baseIteratee : result;\n", | |
"\t return arguments.length ? result(arguments[0], arguments[1]) : result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the data for `map`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} map The map to query.\n", | |
"\t * @param {string} key The reference key.\n", | |
"\t * @returns {*} Returns the map data.\n", | |
"\t */\n", | |
"\t function getMapData(map, key) {\n", | |
"\t var data = map.__data__;\n", | |
"\t return isKeyable(key)\n", | |
"\t ? data[typeof key == 'string' ? 'string' : 'hash']\n", | |
"\t : data.map;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the property names, values, and compare flags of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Array} Returns the match data of `object`.\n", | |
"\t */\n", | |
"\t function getMatchData(object) {\n", | |
"\t var result = keys(object),\n", | |
"\t length = result.length;\n", | |
"\t\n", | |
"\t while (length--) {\n", | |
"\t var key = result[length],\n", | |
"\t value = object[key];\n", | |
"\t\n", | |
"\t result[length] = [key, value, isStrictComparable(value)];\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the native function at `key` of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @param {string} key The key of the method to get.\n", | |
"\t * @returns {*} Returns the function if it's native, else `undefined`.\n", | |
"\t */\n", | |
"\t function getNative(object, key) {\n", | |
"\t var value = getValue(object, key);\n", | |
"\t return baseIsNative(value) ? value : undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to query.\n", | |
"\t * @returns {string} Returns the raw `toStringTag`.\n", | |
"\t */\n", | |
"\t function getRawTag(value) {\n", | |
"\t var isOwn = hasOwnProperty.call(value, symToStringTag),\n", | |
"\t tag = value[symToStringTag];\n", | |
"\t\n", | |
"\t try {\n", | |
"\t value[symToStringTag] = undefined;\n", | |
"\t var unmasked = true;\n", | |
"\t } catch (e) {}\n", | |
"\t\n", | |
"\t var result = nativeObjectToString.call(value);\n", | |
"\t if (unmasked) {\n", | |
"\t if (isOwn) {\n", | |
"\t value[symToStringTag] = tag;\n", | |
"\t } else {\n", | |
"\t delete value[symToStringTag];\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of the own enumerable symbol properties of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Array} Returns the array of symbols.\n", | |
"\t */\n", | |
"\t var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of the own and inherited enumerable symbol properties\n", | |
"\t * of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Array} Returns the array of symbols.\n", | |
"\t */\n", | |
"\t var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {\n", | |
"\t var result = [];\n", | |
"\t while (object) {\n", | |
"\t arrayPush(result, getSymbols(object));\n", | |
"\t object = getPrototype(object);\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t };\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the `toStringTag` of `value`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to query.\n", | |
"\t * @returns {string} Returns the `toStringTag`.\n", | |
"\t */\n", | |
"\t var getTag = baseGetTag;\n", | |
"\t\n", | |
"\t // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\n", | |
"\t if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n", | |
"\t (Map && getTag(new Map) != mapTag) ||\n", | |
"\t (Promise && getTag(Promise.resolve()) != promiseTag) ||\n", | |
"\t (Set && getTag(new Set) != setTag) ||\n", | |
"\t (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n", | |
"\t getTag = function(value) {\n", | |
"\t var result = baseGetTag(value),\n", | |
"\t Ctor = result == objectTag ? value.constructor : undefined,\n", | |
"\t ctorString = Ctor ? toSource(Ctor) : '';\n", | |
"\t\n", | |
"\t if (ctorString) {\n", | |
"\t switch (ctorString) {\n", | |
"\t case dataViewCtorString: return dataViewTag;\n", | |
"\t case mapCtorString: return mapTag;\n", | |
"\t case promiseCtorString: return promiseTag;\n", | |
"\t case setCtorString: return setTag;\n", | |
"\t case weakMapCtorString: return weakMapTag;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the view, applying any `transforms` to the `start` and `end` positions.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {number} start The start of the view.\n", | |
"\t * @param {number} end The end of the view.\n", | |
"\t * @param {Array} transforms The transformations to apply to the view.\n", | |
"\t * @returns {Object} Returns an object containing the `start` and `end`\n", | |
"\t * positions of the view.\n", | |
"\t */\n", | |
"\t function getView(start, end, transforms) {\n", | |
"\t var index = -1,\n", | |
"\t length = transforms.length;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var data = transforms[index],\n", | |
"\t size = data.size;\n", | |
"\t\n", | |
"\t switch (data.type) {\n", | |
"\t case 'drop': start += size; break;\n", | |
"\t case 'dropRight': end -= size; break;\n", | |
"\t case 'take': end = nativeMin(end, start + size); break;\n", | |
"\t case 'takeRight': start = nativeMax(start, end - size); break;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return { 'start': start, 'end': end };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Extracts wrapper details from the `source` body comment.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} source The source to inspect.\n", | |
"\t * @returns {Array} Returns the wrapper details.\n", | |
"\t */\n", | |
"\t function getWrapDetails(source) {\n", | |
"\t var match = source.match(reWrapDetails);\n", | |
"\t return match ? match[1].split(reSplitDetails) : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `path` exists on `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @param {Array|string} path The path to check.\n", | |
"\t * @param {Function} hasFunc The function to check properties.\n", | |
"\t * @returns {boolean} Returns `true` if `path` exists, else `false`.\n", | |
"\t */\n", | |
"\t function hasPath(object, path, hasFunc) {\n", | |
"\t path = isKey(path, object) ? [path] : castPath(path);\n", | |
"\t\n", | |
"\t var index = -1,\n", | |
"\t length = path.length,\n", | |
"\t result = false;\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var key = toKey(path[index]);\n", | |
"\t if (!(result = object != null && hasFunc(object, key))) {\n", | |
"\t break;\n", | |
"\t }\n", | |
"\t object = object[key];\n", | |
"\t }\n", | |
"\t if (result || ++index != length) {\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t length = object == null ? 0 : object.length;\n", | |
"\t return !!length && isLength(length) && isIndex(key, length) &&\n", | |
"\t (isArray(object) || isArguments(object));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Initializes an array clone.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to clone.\n", | |
"\t * @returns {Array} Returns the initialized clone.\n", | |
"\t */\n", | |
"\t function initCloneArray(array) {\n", | |
"\t var length = array.length,\n", | |
"\t result = array.constructor(length);\n", | |
"\t\n", | |
"\t // Add properties assigned by `RegExp#exec`.\n", | |
"\t if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {\n", | |
"\t result.index = array.index;\n", | |
"\t result.input = array.input;\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Initializes an object clone.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to clone.\n", | |
"\t * @returns {Object} Returns the initialized clone.\n", | |
"\t */\n", | |
"\t function initCloneObject(object) {\n", | |
"\t return (typeof object.constructor == 'function' && !isPrototype(object))\n", | |
"\t ? baseCreate(getPrototype(object))\n", | |
"\t : {};\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Initializes an object clone based on its `toStringTag`.\n", | |
"\t *\n", | |
"\t * **Note:** This function only supports cloning values with tags of\n", | |
"\t * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to clone.\n", | |
"\t * @param {string} tag The `toStringTag` of the object to clone.\n", | |
"\t * @param {Function} cloneFunc The function to clone values.\n", | |
"\t * @param {boolean} [isDeep] Specify a deep clone.\n", | |
"\t * @returns {Object} Returns the initialized clone.\n", | |
"\t */\n", | |
"\t function initCloneByTag(object, tag, cloneFunc, isDeep) {\n", | |
"\t var Ctor = object.constructor;\n", | |
"\t switch (tag) {\n", | |
"\t case arrayBufferTag:\n", | |
"\t return cloneArrayBuffer(object);\n", | |
"\t\n", | |
"\t case boolTag:\n", | |
"\t case dateTag:\n", | |
"\t return new Ctor(+object);\n", | |
"\t\n", | |
"\t case dataViewTag:\n", | |
"\t return cloneDataView(object, isDeep);\n", | |
"\t\n", | |
"\t case float32Tag: case float64Tag:\n", | |
"\t case int8Tag: case int16Tag: case int32Tag:\n", | |
"\t case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:\n", | |
"\t return cloneTypedArray(object, isDeep);\n", | |
"\t\n", | |
"\t case mapTag:\n", | |
"\t return cloneMap(object, isDeep, cloneFunc);\n", | |
"\t\n", | |
"\t case numberTag:\n", | |
"\t case stringTag:\n", | |
"\t return new Ctor(object);\n", | |
"\t\n", | |
"\t case regexpTag:\n", | |
"\t return cloneRegExp(object);\n", | |
"\t\n", | |
"\t case setTag:\n", | |
"\t return cloneSet(object, isDeep, cloneFunc);\n", | |
"\t\n", | |
"\t case symbolTag:\n", | |
"\t return cloneSymbol(object);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Inserts wrapper `details` in a comment at the top of the `source` body.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} source The source to modify.\n", | |
"\t * @returns {Array} details The details to insert.\n", | |
"\t * @returns {string} Returns the modified source.\n", | |
"\t */\n", | |
"\t function insertWrapDetails(source, details) {\n", | |
"\t var length = details.length;\n", | |
"\t if (!length) {\n", | |
"\t return source;\n", | |
"\t }\n", | |
"\t var lastIndex = length - 1;\n", | |
"\t details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];\n", | |
"\t details = details.join(length > 2 ? ', ' : ' ');\n", | |
"\t return source.replace(reWrapComment, '{\\n/* [wrapped with ' + details + '] */\\n');\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `value` is a flattenable `arguments` object or array.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.\n", | |
"\t */\n", | |
"\t function isFlattenable(value) {\n", | |
"\t return isArray(value) || isArguments(value) ||\n", | |
"\t !!(spreadableSymbol && value && value[spreadableSymbol]);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `value` is a valid array-like index.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n", | |
"\t */\n", | |
"\t function isIndex(value, length) {\n", | |
"\t length = length == null ? MAX_SAFE_INTEGER : length;\n", | |
"\t return !!length &&\n", | |
"\t (typeof value == 'number' || reIsUint.test(value)) &&\n", | |
"\t (value > -1 && value % 1 == 0 && value < length);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if the given arguments are from an iteratee call.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The potential iteratee value argument.\n", | |
"\t * @param {*} index The potential iteratee index or key argument.\n", | |
"\t * @param {*} object The potential iteratee object argument.\n", | |
"\t * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n", | |
"\t * else `false`.\n", | |
"\t */\n", | |
"\t function isIterateeCall(value, index, object) {\n", | |
"\t if (!isObject(object)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t var type = typeof index;\n", | |
"\t if (type == 'number'\n", | |
"\t ? (isArrayLike(object) && isIndex(index, object.length))\n", | |
"\t : (type == 'string' && index in object)\n", | |
"\t ) {\n", | |
"\t return eq(object[index], value);\n", | |
"\t }\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `value` is a property name and not a property path.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @param {Object} [object] The object to query keys on.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n", | |
"\t */\n", | |
"\t function isKey(value, object) {\n", | |
"\t if (isArray(value)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t var type = typeof value;\n", | |
"\t if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n", | |
"\t value == null || isSymbol(value)) {\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n", | |
"\t (object != null && value in Object(object));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `value` is suitable for use as unique object key.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n", | |
"\t */\n", | |
"\t function isKeyable(value) {\n", | |
"\t var type = typeof value;\n", | |
"\t return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n", | |
"\t ? (value !== '__proto__')\n", | |
"\t : (value === null);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `func` has a lazy counterpart.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to check.\n", | |
"\t * @returns {boolean} Returns `true` if `func` has a lazy counterpart,\n", | |
"\t * else `false`.\n", | |
"\t */\n", | |
"\t function isLaziable(func) {\n", | |
"\t var funcName = getFuncName(func),\n", | |
"\t other = lodash[funcName];\n", | |
"\t\n", | |
"\t if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t if (func === other) {\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t var data = getData(other);\n", | |
"\t return !!data && func === data[0];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `func` has its source masked.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to check.\n", | |
"\t * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n", | |
"\t */\n", | |
"\t function isMasked(func) {\n", | |
"\t return !!maskSrcKey && (maskSrcKey in func);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `func` is capable of being masked.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `func` is maskable, else `false`.\n", | |
"\t */\n", | |
"\t var isMaskable = coreJsData ? isFunction : stubFalse;\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `value` is likely a prototype object.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n", | |
"\t */\n", | |
"\t function isPrototype(value) {\n", | |
"\t var Ctor = value && value.constructor,\n", | |
"\t proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n", | |
"\t\n", | |
"\t return value === proto;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to check.\n", | |
"\t * @returns {boolean} Returns `true` if `value` if suitable for strict\n", | |
"\t * equality comparisons, else `false`.\n", | |
"\t */\n", | |
"\t function isStrictComparable(value) {\n", | |
"\t return value === value && !isObject(value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `matchesProperty` for source values suitable\n", | |
"\t * for strict equality comparisons, i.e. `===`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} key The key of the property to get.\n", | |
"\t * @param {*} srcValue The value to match.\n", | |
"\t * @returns {Function} Returns the new spec function.\n", | |
"\t */\n", | |
"\t function matchesStrictComparable(key, srcValue) {\n", | |
"\t return function(object) {\n", | |
"\t if (object == null) {\n", | |
"\t return false;\n", | |
"\t }\n", | |
"\t return object[key] === srcValue &&\n", | |
"\t (srcValue !== undefined || (key in Object(object)));\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.memoize` which clears the memoized function's\n", | |
"\t * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to have its output memoized.\n", | |
"\t * @returns {Function} Returns the new memoized function.\n", | |
"\t */\n", | |
"\t function memoizeCapped(func) {\n", | |
"\t var result = memoize(func, function(key) {\n", | |
"\t if (cache.size === MAX_MEMOIZE_SIZE) {\n", | |
"\t cache.clear();\n", | |
"\t }\n", | |
"\t return key;\n", | |
"\t });\n", | |
"\t\n", | |
"\t var cache = result.cache;\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Merges the function metadata of `source` into `data`.\n", | |
"\t *\n", | |
"\t * Merging metadata reduces the number of wrappers used to invoke a function.\n", | |
"\t * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`\n", | |
"\t * may be applied regardless of execution order. Methods like `_.ary` and\n", | |
"\t * `_.rearg` modify function arguments, making the order in which they are\n", | |
"\t * executed important, preventing the merging of metadata. However, we make\n", | |
"\t * an exception for a safe combined case where curried functions have `_.ary`\n", | |
"\t * and or `_.rearg` applied.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} data The destination metadata.\n", | |
"\t * @param {Array} source The source metadata.\n", | |
"\t * @returns {Array} Returns `data`.\n", | |
"\t */\n", | |
"\t function mergeData(data, source) {\n", | |
"\t var bitmask = data[1],\n", | |
"\t srcBitmask = source[1],\n", | |
"\t newBitmask = bitmask | srcBitmask,\n", | |
"\t isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);\n", | |
"\t\n", | |
"\t var isCombo =\n", | |
"\t ((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||\n", | |
"\t ((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||\n", | |
"\t ((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));\n", | |
"\t\n", | |
"\t // Exit early if metadata can't be merged.\n", | |
"\t if (!(isCommon || isCombo)) {\n", | |
"\t return data;\n", | |
"\t }\n", | |
"\t // Use source `thisArg` if available.\n", | |
"\t if (srcBitmask & BIND_FLAG) {\n", | |
"\t data[2] = source[2];\n", | |
"\t // Set when currying a bound function.\n", | |
"\t newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;\n", | |
"\t }\n", | |
"\t // Compose partial arguments.\n", | |
"\t var value = source[3];\n", | |
"\t if (value) {\n", | |
"\t var partials = data[3];\n", | |
"\t data[3] = partials ? composeArgs(partials, value, source[4]) : value;\n", | |
"\t data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];\n", | |
"\t }\n", | |
"\t // Compose partial right arguments.\n", | |
"\t value = source[5];\n", | |
"\t if (value) {\n", | |
"\t partials = data[5];\n", | |
"\t data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;\n", | |
"\t data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];\n", | |
"\t }\n", | |
"\t // Use source `argPos` if available.\n", | |
"\t value = source[7];\n", | |
"\t if (value) {\n", | |
"\t data[7] = value;\n", | |
"\t }\n", | |
"\t // Use source `ary` if it's smaller.\n", | |
"\t if (srcBitmask & ARY_FLAG) {\n", | |
"\t data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);\n", | |
"\t }\n", | |
"\t // Use source `arity` if one is not provided.\n", | |
"\t if (data[9] == null) {\n", | |
"\t data[9] = source[9];\n", | |
"\t }\n", | |
"\t // Use source `func` and merge bitmasks.\n", | |
"\t data[0] = source[0];\n", | |
"\t data[1] = newBitmask;\n", | |
"\t\n", | |
"\t return data;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Used by `_.defaultsDeep` to customize its `_.merge` use.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} objValue The destination value.\n", | |
"\t * @param {*} srcValue The source value.\n", | |
"\t * @param {string} key The key of the property to merge.\n", | |
"\t * @param {Object} object The parent object of `objValue`.\n", | |
"\t * @param {Object} source The parent object of `srcValue`.\n", | |
"\t * @param {Object} [stack] Tracks traversed source values and their merged\n", | |
"\t * counterparts.\n", | |
"\t * @returns {*} Returns the value to assign.\n", | |
"\t */\n", | |
"\t function mergeDefaults(objValue, srcValue, key, object, source, stack) {\n", | |
"\t if (isObject(objValue) && isObject(srcValue)) {\n", | |
"\t // Recursively merge objects and arrays (susceptible to call stack limits).\n", | |
"\t stack.set(srcValue, objValue);\n", | |
"\t baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);\n", | |
"\t stack['delete'](srcValue);\n", | |
"\t }\n", | |
"\t return objValue;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This function is like\n", | |
"\t * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n", | |
"\t * except that it includes inherited enumerable properties.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @returns {Array} Returns the array of property names.\n", | |
"\t */\n", | |
"\t function nativeKeysIn(object) {\n", | |
"\t var result = [];\n", | |
"\t if (object != null) {\n", | |
"\t for (var key in Object(object)) {\n", | |
"\t result.push(key);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `value` to a string using `Object.prototype.toString`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to convert.\n", | |
"\t * @returns {string} Returns the converted string.\n", | |
"\t */\n", | |
"\t function objectToString(value) {\n", | |
"\t return nativeObjectToString.call(value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `baseRest` which transforms the rest array.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to apply a rest parameter to.\n", | |
"\t * @param {number} [start=func.length-1] The start position of the rest parameter.\n", | |
"\t * @param {Function} transform The rest array transform.\n", | |
"\t * @returns {Function} Returns the new function.\n", | |
"\t */\n", | |
"\t function overRest(func, start, transform) {\n", | |
"\t start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n", | |
"\t return function() {\n", | |
"\t var args = arguments,\n", | |
"\t index = -1,\n", | |
"\t length = nativeMax(args.length - start, 0),\n", | |
"\t array = Array(length);\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t array[index] = args[start + index];\n", | |
"\t }\n", | |
"\t index = -1;\n", | |
"\t var otherArgs = Array(start + 1);\n", | |
"\t while (++index < start) {\n", | |
"\t otherArgs[index] = args[index];\n", | |
"\t }\n", | |
"\t otherArgs[start] = transform(array);\n", | |
"\t return apply(func, this, otherArgs);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the parent value at `path` of `object`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} object The object to query.\n", | |
"\t * @param {Array} path The path to get the parent value of.\n", | |
"\t * @returns {*} Returns the parent value.\n", | |
"\t */\n", | |
"\t function parent(object, path) {\n", | |
"\t return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Reorder `array` according to the specified indexes where the element at\n", | |
"\t * the first index is assigned as the first element, the element at\n", | |
"\t * the second index is assigned as the second element, and so on.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to reorder.\n", | |
"\t * @param {Array} indexes The arranged array indexes.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function reorder(array, indexes) {\n", | |
"\t var arrLength = array.length,\n", | |
"\t length = nativeMin(indexes.length, arrLength),\n", | |
"\t oldArray = copyArray(array);\n", | |
"\t\n", | |
"\t while (length--) {\n", | |
"\t var index = indexes[length];\n", | |
"\t array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Sets metadata for `func`.\n", | |
"\t *\n", | |
"\t * **Note:** If this function becomes hot, i.e. is invoked a lot in a short\n", | |
"\t * period of time, it will trip its breaker and transition to an identity\n", | |
"\t * function to avoid garbage collection pauses in V8. See\n", | |
"\t * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)\n", | |
"\t * for more details.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to associate metadata with.\n", | |
"\t * @param {*} data The metadata.\n", | |
"\t * @returns {Function} Returns `func`.\n", | |
"\t */\n", | |
"\t var setData = shortOut(baseSetData);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to delay.\n", | |
"\t * @param {number} wait The number of milliseconds to delay invocation.\n", | |
"\t * @returns {number|Object} Returns the timer id or timeout object.\n", | |
"\t */\n", | |
"\t var setTimeout = ctxSetTimeout || function(func, wait) {\n", | |
"\t return root.setTimeout(func, wait);\n", | |
"\t };\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Sets the `toString` method of `func` to return `string`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to modify.\n", | |
"\t * @param {Function} string The `toString` result.\n", | |
"\t * @returns {Function} Returns `func`.\n", | |
"\t */\n", | |
"\t var setToString = shortOut(baseSetToString);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Sets the `toString` method of `wrapper` to mimic the source of `reference`\n", | |
"\t * with wrapper details in a comment at the top of the source body.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} wrapper The function to modify.\n", | |
"\t * @param {Function} reference The reference function.\n", | |
"\t * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n", | |
"\t * @returns {Function} Returns `wrapper`.\n", | |
"\t */\n", | |
"\t function setWrapToString(wrapper, reference, bitmask) {\n", | |
"\t var source = (reference + '');\n", | |
"\t return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a function that'll short out and invoke `identity` instead\n", | |
"\t * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`\n", | |
"\t * milliseconds.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to restrict.\n", | |
"\t * @returns {Function} Returns the new shortable function.\n", | |
"\t */\n", | |
"\t function shortOut(func) {\n", | |
"\t var count = 0,\n", | |
"\t lastCalled = 0;\n", | |
"\t\n", | |
"\t return function() {\n", | |
"\t var stamp = nativeNow(),\n", | |
"\t remaining = HOT_SPAN - (stamp - lastCalled);\n", | |
"\t\n", | |
"\t lastCalled = stamp;\n", | |
"\t if (remaining > 0) {\n", | |
"\t if (++count >= HOT_COUNT) {\n", | |
"\t return arguments[0];\n", | |
"\t }\n", | |
"\t } else {\n", | |
"\t count = 0;\n", | |
"\t }\n", | |
"\t return func.apply(undefined, arguments);\n", | |
"\t };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * A specialized version of `_.shuffle` which mutates and sets the size of `array`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Array} array The array to shuffle.\n", | |
"\t * @param {number} [size=array.length] The size of `array`.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t */\n", | |
"\t function shuffleSelf(array, size) {\n", | |
"\t var index = -1,\n", | |
"\t length = array.length,\n", | |
"\t lastIndex = length - 1;\n", | |
"\t\n", | |
"\t size = size === undefined ? length : size;\n", | |
"\t while (++index < size) {\n", | |
"\t var rand = baseRandom(index, lastIndex),\n", | |
"\t value = array[rand];\n", | |
"\t\n", | |
"\t array[rand] = array[index];\n", | |
"\t array[index] = value;\n", | |
"\t }\n", | |
"\t array.length = size;\n", | |
"\t return array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `string` to a property path array.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {string} string The string to convert.\n", | |
"\t * @returns {Array} Returns the property path array.\n", | |
"\t */\n", | |
"\t var stringToPath = memoizeCapped(function(string) {\n", | |
"\t string = toString(string);\n", | |
"\t\n", | |
"\t var result = [];\n", | |
"\t if (reLeadingDot.test(string)) {\n", | |
"\t result.push('');\n", | |
"\t }\n", | |
"\t string.replace(rePropName, function(match, number, quote, string) {\n", | |
"\t result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));\n", | |
"\t });\n", | |
"\t return result;\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `value` to a string key if it's not a string or symbol.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {*} value The value to inspect.\n", | |
"\t * @returns {string|symbol} Returns the key.\n", | |
"\t */\n", | |
"\t function toKey(value) {\n", | |
"\t if (typeof value == 'string' || isSymbol(value)) {\n", | |
"\t return value;\n", | |
"\t }\n", | |
"\t var result = (value + '');\n", | |
"\t return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts `func` to its source code.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Function} func The function to convert.\n", | |
"\t * @returns {string} Returns the source code.\n", | |
"\t */\n", | |
"\t function toSource(func) {\n", | |
"\t if (func != null) {\n", | |
"\t try {\n", | |
"\t return funcToString.call(func);\n", | |
"\t } catch (e) {}\n", | |
"\t try {\n", | |
"\t return (func + '');\n", | |
"\t } catch (e) {}\n", | |
"\t }\n", | |
"\t return '';\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Updates wrapper `details` based on `bitmask` flags.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @returns {Array} details The details to modify.\n", | |
"\t * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n", | |
"\t * @returns {Array} Returns `details`.\n", | |
"\t */\n", | |
"\t function updateWrapDetails(details, bitmask) {\n", | |
"\t arrayEach(wrapFlags, function(pair) {\n", | |
"\t var value = '_.' + pair[0];\n", | |
"\t if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {\n", | |
"\t details.push(value);\n", | |
"\t }\n", | |
"\t });\n", | |
"\t return details.sort();\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of `wrapper`.\n", | |
"\t *\n", | |
"\t * @private\n", | |
"\t * @param {Object} wrapper The wrapper to clone.\n", | |
"\t * @returns {Object} Returns the cloned wrapper.\n", | |
"\t */\n", | |
"\t function wrapperClone(wrapper) {\n", | |
"\t if (wrapper instanceof LazyWrapper) {\n", | |
"\t return wrapper.clone();\n", | |
"\t }\n", | |
"\t var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);\n", | |
"\t result.__actions__ = copyArray(wrapper.__actions__);\n", | |
"\t result.__index__ = wrapper.__index__;\n", | |
"\t result.__values__ = wrapper.__values__;\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of elements split into groups the length of `size`.\n", | |
"\t * If `array` can't be split evenly, the final chunk will be the remaining\n", | |
"\t * elements.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to process.\n", | |
"\t * @param {number} [size=1] The length of each chunk\n", | |
"\t * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n", | |
"\t * @returns {Array} Returns the new array of chunks.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.chunk(['a', 'b', 'c', 'd'], 2);\n", | |
"\t * // => [['a', 'b'], ['c', 'd']]\n", | |
"\t *\n", | |
"\t * _.chunk(['a', 'b', 'c', 'd'], 3);\n", | |
"\t * // => [['a', 'b', 'c'], ['d']]\n", | |
"\t */\n", | |
"\t function chunk(array, size, guard) {\n", | |
"\t if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n", | |
"\t size = 1;\n", | |
"\t } else {\n", | |
"\t size = nativeMax(toInteger(size), 0);\n", | |
"\t }\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length || size < 1) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t var index = 0,\n", | |
"\t resIndex = 0,\n", | |
"\t result = Array(nativeCeil(length / size));\n", | |
"\t\n", | |
"\t while (index < length) {\n", | |
"\t result[resIndex++] = baseSlice(array, index, (index += size));\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array with all falsey values removed. The values `false`, `null`,\n", | |
"\t * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to compact.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.compact([0, 1, false, 2, '', 3]);\n", | |
"\t * // => [1, 2, 3]\n", | |
"\t */\n", | |
"\t function compact(array) {\n", | |
"\t var index = -1,\n", | |
"\t length = array == null ? 0 : array.length,\n", | |
"\t resIndex = 0,\n", | |
"\t result = [];\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index];\n", | |
"\t if (value) {\n", | |
"\t result[resIndex++] = value;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a new array concatenating `array` with any additional arrays\n", | |
"\t * and/or values.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to concatenate.\n", | |
"\t * @param {...*} [values] The values to concatenate.\n", | |
"\t * @returns {Array} Returns the new concatenated array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = [1];\n", | |
"\t * var other = _.concat(array, 2, [3], [[4]]);\n", | |
"\t *\n", | |
"\t * console.log(other);\n", | |
"\t * // => [1, 2, 3, [4]]\n", | |
"\t *\n", | |
"\t * console.log(array);\n", | |
"\t * // => [1]\n", | |
"\t */\n", | |
"\t function concat() {\n", | |
"\t var length = arguments.length;\n", | |
"\t if (!length) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t var args = Array(length - 1),\n", | |
"\t array = arguments[0],\n", | |
"\t index = length;\n", | |
"\t\n", | |
"\t while (index--) {\n", | |
"\t args[index - 1] = arguments[index];\n", | |
"\t }\n", | |
"\t return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of `array` values not included in the other given arrays\n", | |
"\t * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n", | |
"\t * for equality comparisons. The order and references of result values are\n", | |
"\t * determined by the first array.\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.pullAll`, this method returns a new array.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {...Array} [values] The values to exclude.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t * @see _.without, _.xor\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.difference([2, 1], [2, 3]);\n", | |
"\t * // => [1]\n", | |
"\t */\n", | |
"\t var difference = baseRest(function(array, values) {\n", | |
"\t return isArrayLikeObject(array)\n", | |
"\t ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))\n", | |
"\t : [];\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.difference` except that it accepts `iteratee` which\n", | |
"\t * is invoked for each element of `array` and `values` to generate the criterion\n", | |
"\t * by which they're compared. The order and references of result values are\n", | |
"\t * determined by the first array. The iteratee is invoked with one argument:\n", | |
"\t * (value).\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.pullAllBy`, this method returns a new array.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {...Array} [values] The values to exclude.\n", | |
"\t * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n", | |
"\t * // => [1.2]\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');\n", | |
"\t * // => [{ 'x': 2 }]\n", | |
"\t */\n", | |
"\t var differenceBy = baseRest(function(array, values) {\n", | |
"\t var iteratee = last(values);\n", | |
"\t if (isArrayLikeObject(iteratee)) {\n", | |
"\t iteratee = undefined;\n", | |
"\t }\n", | |
"\t return isArrayLikeObject(array)\n", | |
"\t ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))\n", | |
"\t : [];\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.difference` except that it accepts `comparator`\n", | |
"\t * which is invoked to compare elements of `array` to `values`. The order and\n", | |
"\t * references of result values are determined by the first array. The comparator\n", | |
"\t * is invoked with two arguments: (arrVal, othVal).\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.pullAllWith`, this method returns a new array.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {...Array} [values] The values to exclude.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n", | |
"\t *\n", | |
"\t * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);\n", | |
"\t * // => [{ 'x': 2, 'y': 1 }]\n", | |
"\t */\n", | |
"\t var differenceWith = baseRest(function(array, values) {\n", | |
"\t var comparator = last(values);\n", | |
"\t if (isArrayLikeObject(comparator)) {\n", | |
"\t comparator = undefined;\n", | |
"\t }\n", | |
"\t return isArrayLikeObject(array)\n", | |
"\t ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)\n", | |
"\t : [];\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` with `n` elements dropped from the beginning.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.5.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {number} [n=1] The number of elements to drop.\n", | |
"\t * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.drop([1, 2, 3]);\n", | |
"\t * // => [2, 3]\n", | |
"\t *\n", | |
"\t * _.drop([1, 2, 3], 2);\n", | |
"\t * // => [3]\n", | |
"\t *\n", | |
"\t * _.drop([1, 2, 3], 5);\n", | |
"\t * // => []\n", | |
"\t *\n", | |
"\t * _.drop([1, 2, 3], 0);\n", | |
"\t * // => [1, 2, 3]\n", | |
"\t */\n", | |
"\t function drop(array, n, guard) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t n = (guard || n === undefined) ? 1 : toInteger(n);\n", | |
"\t return baseSlice(array, n < 0 ? 0 : n, length);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` with `n` elements dropped from the end.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {number} [n=1] The number of elements to drop.\n", | |
"\t * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.dropRight([1, 2, 3]);\n", | |
"\t * // => [1, 2]\n", | |
"\t *\n", | |
"\t * _.dropRight([1, 2, 3], 2);\n", | |
"\t * // => [1]\n", | |
"\t *\n", | |
"\t * _.dropRight([1, 2, 3], 5);\n", | |
"\t * // => []\n", | |
"\t *\n", | |
"\t * _.dropRight([1, 2, 3], 0);\n", | |
"\t * // => [1, 2, 3]\n", | |
"\t */\n", | |
"\t function dropRight(array, n, guard) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t n = (guard || n === undefined) ? 1 : toInteger(n);\n", | |
"\t n = length - n;\n", | |
"\t return baseSlice(array, 0, n < 0 ? 0 : n);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` excluding elements dropped from the end.\n", | |
"\t * Elements are dropped until `predicate` returns falsey. The predicate is\n", | |
"\t * invoked with three arguments: (value, index, array).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {Function} [predicate=_.identity] The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var users = [\n", | |
"\t * { 'user': 'barney', 'active': true },\n", | |
"\t * { 'user': 'fred', 'active': false },\n", | |
"\t * { 'user': 'pebbles', 'active': false }\n", | |
"\t * ];\n", | |
"\t *\n", | |
"\t * _.dropRightWhile(users, function(o) { return !o.active; });\n", | |
"\t * // => objects for ['barney']\n", | |
"\t *\n", | |
"\t * // The `_.matches` iteratee shorthand.\n", | |
"\t * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });\n", | |
"\t * // => objects for ['barney', 'fred']\n", | |
"\t *\n", | |
"\t * // The `_.matchesProperty` iteratee shorthand.\n", | |
"\t * _.dropRightWhile(users, ['active', false]);\n", | |
"\t * // => objects for ['barney']\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.dropRightWhile(users, 'active');\n", | |
"\t * // => objects for ['barney', 'fred', 'pebbles']\n", | |
"\t */\n", | |
"\t function dropRightWhile(array, predicate) {\n", | |
"\t return (array && array.length)\n", | |
"\t ? baseWhile(array, getIteratee(predicate, 3), true, true)\n", | |
"\t : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` excluding elements dropped from the beginning.\n", | |
"\t * Elements are dropped until `predicate` returns falsey. The predicate is\n", | |
"\t * invoked with three arguments: (value, index, array).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {Function} [predicate=_.identity] The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var users = [\n", | |
"\t * { 'user': 'barney', 'active': false },\n", | |
"\t * { 'user': 'fred', 'active': false },\n", | |
"\t * { 'user': 'pebbles', 'active': true }\n", | |
"\t * ];\n", | |
"\t *\n", | |
"\t * _.dropWhile(users, function(o) { return !o.active; });\n", | |
"\t * // => objects for ['pebbles']\n", | |
"\t *\n", | |
"\t * // The `_.matches` iteratee shorthand.\n", | |
"\t * _.dropWhile(users, { 'user': 'barney', 'active': false });\n", | |
"\t * // => objects for ['fred', 'pebbles']\n", | |
"\t *\n", | |
"\t * // The `_.matchesProperty` iteratee shorthand.\n", | |
"\t * _.dropWhile(users, ['active', false]);\n", | |
"\t * // => objects for ['pebbles']\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.dropWhile(users, 'active');\n", | |
"\t * // => objects for ['barney', 'fred', 'pebbles']\n", | |
"\t */\n", | |
"\t function dropWhile(array, predicate) {\n", | |
"\t return (array && array.length)\n", | |
"\t ? baseWhile(array, getIteratee(predicate, 3), true)\n", | |
"\t : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Fills elements of `array` with `value` from `start` up to, but not\n", | |
"\t * including, `end`.\n", | |
"\t *\n", | |
"\t * **Note:** This method mutates `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.2.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to fill.\n", | |
"\t * @param {*} value The value to fill `array` with.\n", | |
"\t * @param {number} [start=0] The start position.\n", | |
"\t * @param {number} [end=array.length] The end position.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = [1, 2, 3];\n", | |
"\t *\n", | |
"\t * _.fill(array, 'a');\n", | |
"\t * console.log(array);\n", | |
"\t * // => ['a', 'a', 'a']\n", | |
"\t *\n", | |
"\t * _.fill(Array(3), 2);\n", | |
"\t * // => [2, 2, 2]\n", | |
"\t *\n", | |
"\t * _.fill([4, 6, 8, 10], '*', 1, 3);\n", | |
"\t * // => [4, '*', '*', 10]\n", | |
"\t */\n", | |
"\t function fill(array, value, start, end) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {\n", | |
"\t start = 0;\n", | |
"\t end = length;\n", | |
"\t }\n", | |
"\t return baseFill(array, value, start, end);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.find` except that it returns the index of the first\n", | |
"\t * element `predicate` returns truthy for instead of the element itself.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 1.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Function} [predicate=_.identity] The function invoked per iteration.\n", | |
"\t * @param {number} [fromIndex=0] The index to search from.\n", | |
"\t * @returns {number} Returns the index of the found element, else `-1`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var users = [\n", | |
"\t * { 'user': 'barney', 'active': false },\n", | |
"\t * { 'user': 'fred', 'active': false },\n", | |
"\t * { 'user': 'pebbles', 'active': true }\n", | |
"\t * ];\n", | |
"\t *\n", | |
"\t * _.findIndex(users, function(o) { return o.user == 'barney'; });\n", | |
"\t * // => 0\n", | |
"\t *\n", | |
"\t * // The `_.matches` iteratee shorthand.\n", | |
"\t * _.findIndex(users, { 'user': 'fred', 'active': false });\n", | |
"\t * // => 1\n", | |
"\t *\n", | |
"\t * // The `_.matchesProperty` iteratee shorthand.\n", | |
"\t * _.findIndex(users, ['active', false]);\n", | |
"\t * // => 0\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.findIndex(users, 'active');\n", | |
"\t * // => 2\n", | |
"\t */\n", | |
"\t function findIndex(array, predicate, fromIndex) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t var index = fromIndex == null ? 0 : toInteger(fromIndex);\n", | |
"\t if (index < 0) {\n", | |
"\t index = nativeMax(length + index, 0);\n", | |
"\t }\n", | |
"\t return baseFindIndex(array, getIteratee(predicate, 3), index);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.findIndex` except that it iterates over elements\n", | |
"\t * of `collection` from right to left.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 2.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Function} [predicate=_.identity] The function invoked per iteration.\n", | |
"\t * @param {number} [fromIndex=array.length-1] The index to search from.\n", | |
"\t * @returns {number} Returns the index of the found element, else `-1`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var users = [\n", | |
"\t * { 'user': 'barney', 'active': true },\n", | |
"\t * { 'user': 'fred', 'active': false },\n", | |
"\t * { 'user': 'pebbles', 'active': false }\n", | |
"\t * ];\n", | |
"\t *\n", | |
"\t * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });\n", | |
"\t * // => 2\n", | |
"\t *\n", | |
"\t * // The `_.matches` iteratee shorthand.\n", | |
"\t * _.findLastIndex(users, { 'user': 'barney', 'active': true });\n", | |
"\t * // => 0\n", | |
"\t *\n", | |
"\t * // The `_.matchesProperty` iteratee shorthand.\n", | |
"\t * _.findLastIndex(users, ['active', false]);\n", | |
"\t * // => 2\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.findLastIndex(users, 'active');\n", | |
"\t * // => 0\n", | |
"\t */\n", | |
"\t function findLastIndex(array, predicate, fromIndex) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t var index = length - 1;\n", | |
"\t if (fromIndex !== undefined) {\n", | |
"\t index = toInteger(fromIndex);\n", | |
"\t index = fromIndex < 0\n", | |
"\t ? nativeMax(length + index, 0)\n", | |
"\t : nativeMin(index, length - 1);\n", | |
"\t }\n", | |
"\t return baseFindIndex(array, getIteratee(predicate, 3), index, true);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Flattens `array` a single level deep.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to flatten.\n", | |
"\t * @returns {Array} Returns the new flattened array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.flatten([1, [2, [3, [4]], 5]]);\n", | |
"\t * // => [1, 2, [3, [4]], 5]\n", | |
"\t */\n", | |
"\t function flatten(array) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t return length ? baseFlatten(array, 1) : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Recursively flattens `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to flatten.\n", | |
"\t * @returns {Array} Returns the new flattened array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.flattenDeep([1, [2, [3, [4]], 5]]);\n", | |
"\t * // => [1, 2, 3, 4, 5]\n", | |
"\t */\n", | |
"\t function flattenDeep(array) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t return length ? baseFlatten(array, INFINITY) : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Recursively flatten `array` up to `depth` times.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.4.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to flatten.\n", | |
"\t * @param {number} [depth=1] The maximum recursion depth.\n", | |
"\t * @returns {Array} Returns the new flattened array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = [1, [2, [3, [4]], 5]];\n", | |
"\t *\n", | |
"\t * _.flattenDepth(array, 1);\n", | |
"\t * // => [1, 2, [3, [4]], 5]\n", | |
"\t *\n", | |
"\t * _.flattenDepth(array, 2);\n", | |
"\t * // => [1, 2, 3, [4], 5]\n", | |
"\t */\n", | |
"\t function flattenDepth(array, depth) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t depth = depth === undefined ? 1 : toInteger(depth);\n", | |
"\t return baseFlatten(array, depth);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * The inverse of `_.toPairs`; this method returns an object composed\n", | |
"\t * from key-value `pairs`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} pairs The key-value pairs.\n", | |
"\t * @returns {Object} Returns the new object.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.fromPairs([['a', 1], ['b', 2]]);\n", | |
"\t * // => { 'a': 1, 'b': 2 }\n", | |
"\t */\n", | |
"\t function fromPairs(pairs) {\n", | |
"\t var index = -1,\n", | |
"\t length = pairs == null ? 0 : pairs.length,\n", | |
"\t result = {};\n", | |
"\t\n", | |
"\t while (++index < length) {\n", | |
"\t var pair = pairs[index];\n", | |
"\t result[pair[0]] = pair[1];\n", | |
"\t }\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the first element of `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @alias first\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @returns {*} Returns the first element of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.head([1, 2, 3]);\n", | |
"\t * // => 1\n", | |
"\t *\n", | |
"\t * _.head([]);\n", | |
"\t * // => undefined\n", | |
"\t */\n", | |
"\t function head(array) {\n", | |
"\t return (array && array.length) ? array[0] : undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the index at which the first occurrence of `value` is found in `array`\n", | |
"\t * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n", | |
"\t * for equality comparisons. If `fromIndex` is negative, it's used as the\n", | |
"\t * offset from the end of `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @param {number} [fromIndex=0] The index to search from.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.indexOf([1, 2, 1, 2], 2);\n", | |
"\t * // => 1\n", | |
"\t *\n", | |
"\t * // Search from the `fromIndex`.\n", | |
"\t * _.indexOf([1, 2, 1, 2], 2, 2);\n", | |
"\t * // => 3\n", | |
"\t */\n", | |
"\t function indexOf(array, value, fromIndex) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t var index = fromIndex == null ? 0 : toInteger(fromIndex);\n", | |
"\t if (index < 0) {\n", | |
"\t index = nativeMax(length + index, 0);\n", | |
"\t }\n", | |
"\t return baseIndexOf(array, value, index);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets all but the last element of `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.initial([1, 2, 3]);\n", | |
"\t * // => [1, 2]\n", | |
"\t */\n", | |
"\t function initial(array) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t return length ? baseSlice(array, 0, -1) : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of unique values that are included in all given arrays\n", | |
"\t * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n", | |
"\t * for equality comparisons. The order and references of result values are\n", | |
"\t * determined by the first array.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @returns {Array} Returns the new array of intersecting values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.intersection([2, 1], [2, 3]);\n", | |
"\t * // => [2]\n", | |
"\t */\n", | |
"\t var intersection = baseRest(function(arrays) {\n", | |
"\t var mapped = arrayMap(arrays, castArrayLikeObject);\n", | |
"\t return (mapped.length && mapped[0] === arrays[0])\n", | |
"\t ? baseIntersection(mapped)\n", | |
"\t : [];\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.intersection` except that it accepts `iteratee`\n", | |
"\t * which is invoked for each element of each `arrays` to generate the criterion\n", | |
"\t * by which they're compared. The order and references of result values are\n", | |
"\t * determined by the first array. The iteratee is invoked with one argument:\n", | |
"\t * (value).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of intersecting values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n", | |
"\t * // => [2.1]\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n", | |
"\t * // => [{ 'x': 1 }]\n", | |
"\t */\n", | |
"\t var intersectionBy = baseRest(function(arrays) {\n", | |
"\t var iteratee = last(arrays),\n", | |
"\t mapped = arrayMap(arrays, castArrayLikeObject);\n", | |
"\t\n", | |
"\t if (iteratee === last(mapped)) {\n", | |
"\t iteratee = undefined;\n", | |
"\t } else {\n", | |
"\t mapped.pop();\n", | |
"\t }\n", | |
"\t return (mapped.length && mapped[0] === arrays[0])\n", | |
"\t ? baseIntersection(mapped, getIteratee(iteratee, 2))\n", | |
"\t : [];\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.intersection` except that it accepts `comparator`\n", | |
"\t * which is invoked to compare elements of `arrays`. The order and references\n", | |
"\t * of result values are determined by the first array. The comparator is\n", | |
"\t * invoked with two arguments: (arrVal, othVal).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of intersecting values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n", | |
"\t * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n", | |
"\t *\n", | |
"\t * _.intersectionWith(objects, others, _.isEqual);\n", | |
"\t * // => [{ 'x': 1, 'y': 2 }]\n", | |
"\t */\n", | |
"\t var intersectionWith = baseRest(function(arrays) {\n", | |
"\t var comparator = last(arrays),\n", | |
"\t mapped = arrayMap(arrays, castArrayLikeObject);\n", | |
"\t\n", | |
"\t comparator = typeof comparator == 'function' ? comparator : undefined;\n", | |
"\t if (comparator) {\n", | |
"\t mapped.pop();\n", | |
"\t }\n", | |
"\t return (mapped.length && mapped[0] === arrays[0])\n", | |
"\t ? baseIntersection(mapped, undefined, comparator)\n", | |
"\t : [];\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Converts all elements in `array` into a string separated by `separator`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to convert.\n", | |
"\t * @param {string} [separator=','] The element separator.\n", | |
"\t * @returns {string} Returns the joined string.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.join(['a', 'b', 'c'], '~');\n", | |
"\t * // => 'a~b~c'\n", | |
"\t */\n", | |
"\t function join(array, separator) {\n", | |
"\t return array == null ? '' : nativeJoin.call(array, separator);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the last element of `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @returns {*} Returns the last element of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.last([1, 2, 3]);\n", | |
"\t * // => 3\n", | |
"\t */\n", | |
"\t function last(array) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t return length ? array[length - 1] : undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.indexOf` except that it iterates over elements of\n", | |
"\t * `array` from right to left.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @param {number} [fromIndex=array.length-1] The index to search from.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.lastIndexOf([1, 2, 1, 2], 2);\n", | |
"\t * // => 3\n", | |
"\t *\n", | |
"\t * // Search from the `fromIndex`.\n", | |
"\t * _.lastIndexOf([1, 2, 1, 2], 2, 2);\n", | |
"\t * // => 1\n", | |
"\t */\n", | |
"\t function lastIndexOf(array, value, fromIndex) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t var index = length;\n", | |
"\t if (fromIndex !== undefined) {\n", | |
"\t index = toInteger(fromIndex);\n", | |
"\t index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);\n", | |
"\t }\n", | |
"\t return value === value\n", | |
"\t ? strictLastIndexOf(array, value, index)\n", | |
"\t : baseFindIndex(array, baseIsNaN, index, true);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the element at index `n` of `array`. If `n` is negative, the nth\n", | |
"\t * element from the end is returned.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.11.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {number} [n=0] The index of the element to return.\n", | |
"\t * @returns {*} Returns the nth element of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = ['a', 'b', 'c', 'd'];\n", | |
"\t *\n", | |
"\t * _.nth(array, 1);\n", | |
"\t * // => 'b'\n", | |
"\t *\n", | |
"\t * _.nth(array, -2);\n", | |
"\t * // => 'c';\n", | |
"\t */\n", | |
"\t function nth(array, n) {\n", | |
"\t return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes all given values from `array` using\n", | |
"\t * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n", | |
"\t * for equality comparisons.\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`\n", | |
"\t * to remove elements from an array by predicate.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 2.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {...*} [values] The values to remove.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = ['a', 'b', 'c', 'a', 'b', 'c'];\n", | |
"\t *\n", | |
"\t * _.pull(array, 'a', 'c');\n", | |
"\t * console.log(array);\n", | |
"\t * // => ['b', 'b']\n", | |
"\t */\n", | |
"\t var pull = baseRest(pullAll);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.pull` except that it accepts an array of values to remove.\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.difference`, this method mutates `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {Array} values The values to remove.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = ['a', 'b', 'c', 'a', 'b', 'c'];\n", | |
"\t *\n", | |
"\t * _.pullAll(array, ['a', 'c']);\n", | |
"\t * console.log(array);\n", | |
"\t * // => ['b', 'b']\n", | |
"\t */\n", | |
"\t function pullAll(array, values) {\n", | |
"\t return (array && array.length && values && values.length)\n", | |
"\t ? basePullAll(array, values)\n", | |
"\t : array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.pullAll` except that it accepts `iteratee` which is\n", | |
"\t * invoked for each element of `array` and `values` to generate the criterion\n", | |
"\t * by which they're compared. The iteratee is invoked with one argument: (value).\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.differenceBy`, this method mutates `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {Array} values The values to remove.\n", | |
"\t * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];\n", | |
"\t *\n", | |
"\t * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');\n", | |
"\t * console.log(array);\n", | |
"\t * // => [{ 'x': 2 }]\n", | |
"\t */\n", | |
"\t function pullAllBy(array, values, iteratee) {\n", | |
"\t return (array && array.length && values && values.length)\n", | |
"\t ? basePullAll(array, values, getIteratee(iteratee, 2))\n", | |
"\t : array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.pullAll` except that it accepts `comparator` which\n", | |
"\t * is invoked to compare elements of `array` to `values`. The comparator is\n", | |
"\t * invoked with two arguments: (arrVal, othVal).\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.differenceWith`, this method mutates `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.6.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {Array} values The values to remove.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];\n", | |
"\t *\n", | |
"\t * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);\n", | |
"\t * console.log(array);\n", | |
"\t * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]\n", | |
"\t */\n", | |
"\t function pullAllWith(array, values, comparator) {\n", | |
"\t return (array && array.length && values && values.length)\n", | |
"\t ? basePullAll(array, values, undefined, comparator)\n", | |
"\t : array;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes elements from `array` corresponding to `indexes` and returns an\n", | |
"\t * array of removed elements.\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.at`, this method mutates `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {...(number|number[])} [indexes] The indexes of elements to remove.\n", | |
"\t * @returns {Array} Returns the new array of removed elements.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = ['a', 'b', 'c', 'd'];\n", | |
"\t * var pulled = _.pullAt(array, [1, 3]);\n", | |
"\t *\n", | |
"\t * console.log(array);\n", | |
"\t * // => ['a', 'c']\n", | |
"\t *\n", | |
"\t * console.log(pulled);\n", | |
"\t * // => ['b', 'd']\n", | |
"\t */\n", | |
"\t var pullAt = flatRest(function(array, indexes) {\n", | |
"\t var length = array == null ? 0 : array.length,\n", | |
"\t result = baseAt(array, indexes);\n", | |
"\t\n", | |
"\t basePullAt(array, arrayMap(indexes, function(index) {\n", | |
"\t return isIndex(index, length) ? +index : index;\n", | |
"\t }).sort(compareAscending));\n", | |
"\t\n", | |
"\t return result;\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Removes all elements from `array` that `predicate` returns truthy for\n", | |
"\t * and returns an array of the removed elements. The predicate is invoked\n", | |
"\t * with three arguments: (value, index, array).\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`\n", | |
"\t * to pull elements from an array by value.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 2.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @param {Function} [predicate=_.identity] The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the new array of removed elements.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = [1, 2, 3, 4];\n", | |
"\t * var evens = _.remove(array, function(n) {\n", | |
"\t * return n % 2 == 0;\n", | |
"\t * });\n", | |
"\t *\n", | |
"\t * console.log(array);\n", | |
"\t * // => [1, 3]\n", | |
"\t *\n", | |
"\t * console.log(evens);\n", | |
"\t * // => [2, 4]\n", | |
"\t */\n", | |
"\t function remove(array, predicate) {\n", | |
"\t var result = [];\n", | |
"\t if (!(array && array.length)) {\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t var index = -1,\n", | |
"\t indexes = [],\n", | |
"\t length = array.length;\n", | |
"\t\n", | |
"\t predicate = getIteratee(predicate, 3);\n", | |
"\t while (++index < length) {\n", | |
"\t var value = array[index];\n", | |
"\t if (predicate(value, index, array)) {\n", | |
"\t result.push(value);\n", | |
"\t indexes.push(index);\n", | |
"\t }\n", | |
"\t }\n", | |
"\t basePullAt(array, indexes);\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Reverses `array` so that the first element becomes the last, the second\n", | |
"\t * element becomes the second to last, and so on.\n", | |
"\t *\n", | |
"\t * **Note:** This method mutates `array` and is based on\n", | |
"\t * [`Array#reverse`](https://mdn.io/Array/reverse).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to modify.\n", | |
"\t * @returns {Array} Returns `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = [1, 2, 3];\n", | |
"\t *\n", | |
"\t * _.reverse(array);\n", | |
"\t * // => [3, 2, 1]\n", | |
"\t *\n", | |
"\t * console.log(array);\n", | |
"\t * // => [3, 2, 1]\n", | |
"\t */\n", | |
"\t function reverse(array) {\n", | |
"\t return array == null ? array : nativeReverse.call(array);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` from `start` up to, but not including, `end`.\n", | |
"\t *\n", | |
"\t * **Note:** This method is used instead of\n", | |
"\t * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are\n", | |
"\t * returned.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to slice.\n", | |
"\t * @param {number} [start=0] The start position.\n", | |
"\t * @param {number} [end=array.length] The end position.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t */\n", | |
"\t function slice(array, start, end) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {\n", | |
"\t start = 0;\n", | |
"\t end = length;\n", | |
"\t }\n", | |
"\t else {\n", | |
"\t start = start == null ? 0 : toInteger(start);\n", | |
"\t end = end === undefined ? length : toInteger(end);\n", | |
"\t }\n", | |
"\t return baseSlice(array, start, end);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Uses a binary search to determine the lowest index at which `value`\n", | |
"\t * should be inserted into `array` in order to maintain its sort order.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The sorted array to inspect.\n", | |
"\t * @param {*} value The value to evaluate.\n", | |
"\t * @returns {number} Returns the index at which `value` should be inserted\n", | |
"\t * into `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.sortedIndex([30, 50], 40);\n", | |
"\t * // => 1\n", | |
"\t */\n", | |
"\t function sortedIndex(array, value) {\n", | |
"\t return baseSortedIndex(array, value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.sortedIndex` except that it accepts `iteratee`\n", | |
"\t * which is invoked for `value` and each element of `array` to compute their\n", | |
"\t * sort ranking. The iteratee is invoked with one argument: (value).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The sorted array to inspect.\n", | |
"\t * @param {*} value The value to evaluate.\n", | |
"\t * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n", | |
"\t * @returns {number} Returns the index at which `value` should be inserted\n", | |
"\t * into `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var objects = [{ 'x': 4 }, { 'x': 5 }];\n", | |
"\t *\n", | |
"\t * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });\n", | |
"\t * // => 0\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.sortedIndexBy(objects, { 'x': 4 }, 'x');\n", | |
"\t * // => 0\n", | |
"\t */\n", | |
"\t function sortedIndexBy(array, value, iteratee) {\n", | |
"\t return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.indexOf` except that it performs a binary\n", | |
"\t * search on a sorted `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.sortedIndexOf([4, 5, 5, 5, 6], 5);\n", | |
"\t * // => 1\n", | |
"\t */\n", | |
"\t function sortedIndexOf(array, value) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (length) {\n", | |
"\t var index = baseSortedIndex(array, value);\n", | |
"\t if (index < length && eq(array[index], value)) {\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.sortedIndex` except that it returns the highest\n", | |
"\t * index at which `value` should be inserted into `array` in order to\n", | |
"\t * maintain its sort order.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The sorted array to inspect.\n", | |
"\t * @param {*} value The value to evaluate.\n", | |
"\t * @returns {number} Returns the index at which `value` should be inserted\n", | |
"\t * into `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.sortedLastIndex([4, 5, 5, 5, 6], 5);\n", | |
"\t * // => 4\n", | |
"\t */\n", | |
"\t function sortedLastIndex(array, value) {\n", | |
"\t return baseSortedIndex(array, value, true);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.sortedLastIndex` except that it accepts `iteratee`\n", | |
"\t * which is invoked for `value` and each element of `array` to compute their\n", | |
"\t * sort ranking. The iteratee is invoked with one argument: (value).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The sorted array to inspect.\n", | |
"\t * @param {*} value The value to evaluate.\n", | |
"\t * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n", | |
"\t * @returns {number} Returns the index at which `value` should be inserted\n", | |
"\t * into `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var objects = [{ 'x': 4 }, { 'x': 5 }];\n", | |
"\t *\n", | |
"\t * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });\n", | |
"\t * // => 1\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');\n", | |
"\t * // => 1\n", | |
"\t */\n", | |
"\t function sortedLastIndexBy(array, value, iteratee) {\n", | |
"\t return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.lastIndexOf` except that it performs a binary\n", | |
"\t * search on a sorted `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {*} value The value to search for.\n", | |
"\t * @returns {number} Returns the index of the matched value, else `-1`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);\n", | |
"\t * // => 3\n", | |
"\t */\n", | |
"\t function sortedLastIndexOf(array, value) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (length) {\n", | |
"\t var index = baseSortedIndex(array, value, true) - 1;\n", | |
"\t if (eq(array[index], value)) {\n", | |
"\t return index;\n", | |
"\t }\n", | |
"\t }\n", | |
"\t return -1;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.uniq` except that it's designed and optimized\n", | |
"\t * for sorted arrays.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @returns {Array} Returns the new duplicate free array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.sortedUniq([1, 1, 2]);\n", | |
"\t * // => [1, 2]\n", | |
"\t */\n", | |
"\t function sortedUniq(array) {\n", | |
"\t return (array && array.length)\n", | |
"\t ? baseSortedUniq(array)\n", | |
"\t : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.uniqBy` except that it's designed and optimized\n", | |
"\t * for sorted arrays.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Function} [iteratee] The iteratee invoked per element.\n", | |
"\t * @returns {Array} Returns the new duplicate free array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);\n", | |
"\t * // => [1.1, 2.3]\n", | |
"\t */\n", | |
"\t function sortedUniqBy(array, iteratee) {\n", | |
"\t return (array && array.length)\n", | |
"\t ? baseSortedUniq(array, getIteratee(iteratee, 2))\n", | |
"\t : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets all but the first element of `array`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.tail([1, 2, 3]);\n", | |
"\t * // => [2, 3]\n", | |
"\t */\n", | |
"\t function tail(array) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t return length ? baseSlice(array, 1, length) : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` with `n` elements taken from the beginning.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {number} [n=1] The number of elements to take.\n", | |
"\t * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.take([1, 2, 3]);\n", | |
"\t * // => [1]\n", | |
"\t *\n", | |
"\t * _.take([1, 2, 3], 2);\n", | |
"\t * // => [1, 2]\n", | |
"\t *\n", | |
"\t * _.take([1, 2, 3], 5);\n", | |
"\t * // => [1, 2, 3]\n", | |
"\t *\n", | |
"\t * _.take([1, 2, 3], 0);\n", | |
"\t * // => []\n", | |
"\t */\n", | |
"\t function take(array, n, guard) {\n", | |
"\t if (!(array && array.length)) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t n = (guard || n === undefined) ? 1 : toInteger(n);\n", | |
"\t return baseSlice(array, 0, n < 0 ? 0 : n);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` with `n` elements taken from the end.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {number} [n=1] The number of elements to take.\n", | |
"\t * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.takeRight([1, 2, 3]);\n", | |
"\t * // => [3]\n", | |
"\t *\n", | |
"\t * _.takeRight([1, 2, 3], 2);\n", | |
"\t * // => [2, 3]\n", | |
"\t *\n", | |
"\t * _.takeRight([1, 2, 3], 5);\n", | |
"\t * // => [1, 2, 3]\n", | |
"\t *\n", | |
"\t * _.takeRight([1, 2, 3], 0);\n", | |
"\t * // => []\n", | |
"\t */\n", | |
"\t function takeRight(array, n, guard) {\n", | |
"\t var length = array == null ? 0 : array.length;\n", | |
"\t if (!length) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t n = (guard || n === undefined) ? 1 : toInteger(n);\n", | |
"\t n = length - n;\n", | |
"\t return baseSlice(array, n < 0 ? 0 : n, length);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` with elements taken from the end. Elements are\n", | |
"\t * taken until `predicate` returns falsey. The predicate is invoked with\n", | |
"\t * three arguments: (value, index, array).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {Function} [predicate=_.identity] The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var users = [\n", | |
"\t * { 'user': 'barney', 'active': true },\n", | |
"\t * { 'user': 'fred', 'active': false },\n", | |
"\t * { 'user': 'pebbles', 'active': false }\n", | |
"\t * ];\n", | |
"\t *\n", | |
"\t * _.takeRightWhile(users, function(o) { return !o.active; });\n", | |
"\t * // => objects for ['fred', 'pebbles']\n", | |
"\t *\n", | |
"\t * // The `_.matches` iteratee shorthand.\n", | |
"\t * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });\n", | |
"\t * // => objects for ['pebbles']\n", | |
"\t *\n", | |
"\t * // The `_.matchesProperty` iteratee shorthand.\n", | |
"\t * _.takeRightWhile(users, ['active', false]);\n", | |
"\t * // => objects for ['fred', 'pebbles']\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.takeRightWhile(users, 'active');\n", | |
"\t * // => []\n", | |
"\t */\n", | |
"\t function takeRightWhile(array, predicate) {\n", | |
"\t return (array && array.length)\n", | |
"\t ? baseWhile(array, getIteratee(predicate, 3), false, true)\n", | |
"\t : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a slice of `array` with elements taken from the beginning. Elements\n", | |
"\t * are taken until `predicate` returns falsey. The predicate is invoked with\n", | |
"\t * three arguments: (value, index, array).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to query.\n", | |
"\t * @param {Function} [predicate=_.identity] The function invoked per iteration.\n", | |
"\t * @returns {Array} Returns the slice of `array`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var users = [\n", | |
"\t * { 'user': 'barney', 'active': false },\n", | |
"\t * { 'user': 'fred', 'active': false},\n", | |
"\t * { 'user': 'pebbles', 'active': true }\n", | |
"\t * ];\n", | |
"\t *\n", | |
"\t * _.takeWhile(users, function(o) { return !o.active; });\n", | |
"\t * // => objects for ['barney', 'fred']\n", | |
"\t *\n", | |
"\t * // The `_.matches` iteratee shorthand.\n", | |
"\t * _.takeWhile(users, { 'user': 'barney', 'active': false });\n", | |
"\t * // => objects for ['barney']\n", | |
"\t *\n", | |
"\t * // The `_.matchesProperty` iteratee shorthand.\n", | |
"\t * _.takeWhile(users, ['active', false]);\n", | |
"\t * // => objects for ['barney', 'fred']\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.takeWhile(users, 'active');\n", | |
"\t * // => []\n", | |
"\t */\n", | |
"\t function takeWhile(array, predicate) {\n", | |
"\t return (array && array.length)\n", | |
"\t ? baseWhile(array, getIteratee(predicate, 3))\n", | |
"\t : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of unique values, in order, from all given arrays using\n", | |
"\t * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n", | |
"\t * for equality comparisons.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @returns {Array} Returns the new array of combined values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.union([2], [1, 2]);\n", | |
"\t * // => [2, 1]\n", | |
"\t */\n", | |
"\t var union = baseRest(function(arrays) {\n", | |
"\t return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.union` except that it accepts `iteratee` which is\n", | |
"\t * invoked for each element of each `arrays` to generate the criterion by\n", | |
"\t * which uniqueness is computed. Result values are chosen from the first\n", | |
"\t * array in which the value occurs. The iteratee is invoked with one argument:\n", | |
"\t * (value).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of combined values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.unionBy([2.1], [1.2, 2.3], Math.floor);\n", | |
"\t * // => [2.1, 1.2]\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n", | |
"\t * // => [{ 'x': 1 }, { 'x': 2 }]\n", | |
"\t */\n", | |
"\t var unionBy = baseRest(function(arrays) {\n", | |
"\t var iteratee = last(arrays);\n", | |
"\t if (isArrayLikeObject(iteratee)) {\n", | |
"\t iteratee = undefined;\n", | |
"\t }\n", | |
"\t return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.union` except that it accepts `comparator` which\n", | |
"\t * is invoked to compare elements of `arrays`. Result values are chosen from\n", | |
"\t * the first array in which the value occurs. The comparator is invoked\n", | |
"\t * with two arguments: (arrVal, othVal).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of combined values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n", | |
"\t * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n", | |
"\t *\n", | |
"\t * _.unionWith(objects, others, _.isEqual);\n", | |
"\t * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]\n", | |
"\t */\n", | |
"\t var unionWith = baseRest(function(arrays) {\n", | |
"\t var comparator = last(arrays);\n", | |
"\t comparator = typeof comparator == 'function' ? comparator : undefined;\n", | |
"\t return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a duplicate-free version of an array, using\n", | |
"\t * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n", | |
"\t * for equality comparisons, in which only the first occurrence of each element\n", | |
"\t * is kept. The order of result values is determined by the order they occur\n", | |
"\t * in the array.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @returns {Array} Returns the new duplicate free array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.uniq([2, 1, 2]);\n", | |
"\t * // => [2, 1]\n", | |
"\t */\n", | |
"\t function uniq(array) {\n", | |
"\t return (array && array.length) ? baseUniq(array) : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.uniq` except that it accepts `iteratee` which is\n", | |
"\t * invoked for each element in `array` to generate the criterion by which\n", | |
"\t * uniqueness is computed. The order of result values is determined by the\n", | |
"\t * order they occur in the array. The iteratee is invoked with one argument:\n", | |
"\t * (value).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n", | |
"\t * @returns {Array} Returns the new duplicate free array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.uniqBy([2.1, 1.2, 2.3], Math.floor);\n", | |
"\t * // => [2.1, 1.2]\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');\n", | |
"\t * // => [{ 'x': 1 }, { 'x': 2 }]\n", | |
"\t */\n", | |
"\t function uniqBy(array, iteratee) {\n", | |
"\t return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.uniq` except that it accepts `comparator` which\n", | |
"\t * is invoked to compare elements of `array`. The order of result values is\n", | |
"\t * determined by the order they occur in the array.The comparator is invoked\n", | |
"\t * with two arguments: (arrVal, othVal).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new duplicate free array.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];\n", | |
"\t *\n", | |
"\t * _.uniqWith(objects, _.isEqual);\n", | |
"\t * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]\n", | |
"\t */\n", | |
"\t function uniqWith(array, comparator) {\n", | |
"\t comparator = typeof comparator == 'function' ? comparator : undefined;\n", | |
"\t return (array && array.length) ? baseUniq(array, undefined, comparator) : [];\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.zip` except that it accepts an array of grouped\n", | |
"\t * elements and creates an array regrouping the elements to their pre-zip\n", | |
"\t * configuration.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 1.2.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array of grouped elements to process.\n", | |
"\t * @returns {Array} Returns the new array of regrouped elements.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);\n", | |
"\t * // => [['a', 1, true], ['b', 2, false]]\n", | |
"\t *\n", | |
"\t * _.unzip(zipped);\n", | |
"\t * // => [['a', 'b'], [1, 2], [true, false]]\n", | |
"\t */\n", | |
"\t function unzip(array) {\n", | |
"\t if (!(array && array.length)) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t var length = 0;\n", | |
"\t array = arrayFilter(array, function(group) {\n", | |
"\t if (isArrayLikeObject(group)) {\n", | |
"\t length = nativeMax(group.length, length);\n", | |
"\t return true;\n", | |
"\t }\n", | |
"\t });\n", | |
"\t return baseTimes(length, function(index) {\n", | |
"\t return arrayMap(array, baseProperty(index));\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.unzip` except that it accepts `iteratee` to specify\n", | |
"\t * how regrouped values should be combined. The iteratee is invoked with the\n", | |
"\t * elements of each group: (...group).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.8.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array of grouped elements to process.\n", | |
"\t * @param {Function} [iteratee=_.identity] The function to combine\n", | |
"\t * regrouped values.\n", | |
"\t * @returns {Array} Returns the new array of regrouped elements.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var zipped = _.zip([1, 2], [10, 20], [100, 200]);\n", | |
"\t * // => [[1, 10, 100], [2, 20, 200]]\n", | |
"\t *\n", | |
"\t * _.unzipWith(zipped, _.add);\n", | |
"\t * // => [3, 30, 300]\n", | |
"\t */\n", | |
"\t function unzipWith(array, iteratee) {\n", | |
"\t if (!(array && array.length)) {\n", | |
"\t return [];\n", | |
"\t }\n", | |
"\t var result = unzip(array);\n", | |
"\t if (iteratee == null) {\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t return arrayMap(result, function(group) {\n", | |
"\t return apply(iteratee, undefined, group);\n", | |
"\t });\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array excluding all given values using\n", | |
"\t * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n", | |
"\t * for equality comparisons.\n", | |
"\t *\n", | |
"\t * **Note:** Unlike `_.pull`, this method returns a new array.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} array The array to inspect.\n", | |
"\t * @param {...*} [values] The values to exclude.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t * @see _.difference, _.xor\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.without([2, 1, 2, 3], 1, 2);\n", | |
"\t * // => [3]\n", | |
"\t */\n", | |
"\t var without = baseRest(function(array, values) {\n", | |
"\t return isArrayLikeObject(array)\n", | |
"\t ? baseDifference(array, values)\n", | |
"\t : [];\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of unique values that is the\n", | |
"\t * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)\n", | |
"\t * of the given arrays. The order of result values is determined by the order\n", | |
"\t * they occur in the arrays.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 2.4.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t * @see _.difference, _.without\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.xor([2, 1], [2, 3]);\n", | |
"\t * // => [1, 3]\n", | |
"\t */\n", | |
"\t var xor = baseRest(function(arrays) {\n", | |
"\t return baseXor(arrayFilter(arrays, isArrayLikeObject));\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.xor` except that it accepts `iteratee` which is\n", | |
"\t * invoked for each element of each `arrays` to generate the criterion by\n", | |
"\t * which by which they're compared. The order of result values is determined\n", | |
"\t * by the order they occur in the arrays. The iteratee is invoked with one\n", | |
"\t * argument: (value).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n", | |
"\t * // => [1.2, 3.4]\n", | |
"\t *\n", | |
"\t * // The `_.property` iteratee shorthand.\n", | |
"\t * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');\n", | |
"\t * // => [{ 'x': 2 }]\n", | |
"\t */\n", | |
"\t var xorBy = baseRest(function(arrays) {\n", | |
"\t var iteratee = last(arrays);\n", | |
"\t if (isArrayLikeObject(iteratee)) {\n", | |
"\t iteratee = undefined;\n", | |
"\t }\n", | |
"\t return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.xor` except that it accepts `comparator` which is\n", | |
"\t * invoked to compare elements of `arrays`. The order of result values is\n", | |
"\t * determined by the order they occur in the arrays. The comparator is invoked\n", | |
"\t * with two arguments: (arrVal, othVal).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to inspect.\n", | |
"\t * @param {Function} [comparator] The comparator invoked per element.\n", | |
"\t * @returns {Array} Returns the new array of filtered values.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];\n", | |
"\t * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];\n", | |
"\t *\n", | |
"\t * _.xorWith(objects, others, _.isEqual);\n", | |
"\t * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]\n", | |
"\t */\n", | |
"\t var xorWith = baseRest(function(arrays) {\n", | |
"\t var comparator = last(arrays);\n", | |
"\t comparator = typeof comparator == 'function' ? comparator : undefined;\n", | |
"\t return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates an array of grouped elements, the first of which contains the\n", | |
"\t * first elements of the given arrays, the second of which contains the\n", | |
"\t * second elements of the given arrays, and so on.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to process.\n", | |
"\t * @returns {Array} Returns the new array of grouped elements.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.zip(['a', 'b'], [1, 2], [true, false]);\n", | |
"\t * // => [['a', 1, true], ['b', 2, false]]\n", | |
"\t */\n", | |
"\t var zip = baseRest(unzip);\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.fromPairs` except that it accepts two arrays,\n", | |
"\t * one of property identifiers and one of corresponding values.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.4.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} [props=[]] The property identifiers.\n", | |
"\t * @param {Array} [values=[]] The property values.\n", | |
"\t * @returns {Object} Returns the new object.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.zipObject(['a', 'b'], [1, 2]);\n", | |
"\t * // => { 'a': 1, 'b': 2 }\n", | |
"\t */\n", | |
"\t function zipObject(props, values) {\n", | |
"\t return baseZipObject(props || [], values || [], assignValue);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.zipObject` except that it supports property paths.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.1.0\n", | |
"\t * @category Array\n", | |
"\t * @param {Array} [props=[]] The property identifiers.\n", | |
"\t * @param {Array} [values=[]] The property values.\n", | |
"\t * @returns {Object} Returns the new object.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);\n", | |
"\t * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }\n", | |
"\t */\n", | |
"\t function zipObjectDeep(props, values) {\n", | |
"\t return baseZipObject(props || [], values || [], baseSet);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.zip` except that it accepts `iteratee` to specify\n", | |
"\t * how grouped values should be combined. The iteratee is invoked with the\n", | |
"\t * elements of each group: (...group).\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.8.0\n", | |
"\t * @category Array\n", | |
"\t * @param {...Array} [arrays] The arrays to process.\n", | |
"\t * @param {Function} [iteratee=_.identity] The function to combine\n", | |
"\t * grouped values.\n", | |
"\t * @returns {Array} Returns the new array of grouped elements.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {\n", | |
"\t * return a + b + c;\n", | |
"\t * });\n", | |
"\t * // => [111, 222]\n", | |
"\t */\n", | |
"\t var zipWith = baseRest(function(arrays) {\n", | |
"\t var length = arrays.length,\n", | |
"\t iteratee = length > 1 ? arrays[length - 1] : undefined;\n", | |
"\t\n", | |
"\t iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;\n", | |
"\t return unzipWith(arrays, iteratee);\n", | |
"\t });\n", | |
"\t\n", | |
"\t /*------------------------------------------------------------------------*/\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a `lodash` wrapper instance that wraps `value` with explicit method\n", | |
"\t * chain sequences enabled. The result of such sequences must be unwrapped\n", | |
"\t * with `_#value`.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 1.3.0\n", | |
"\t * @category Seq\n", | |
"\t * @param {*} value The value to wrap.\n", | |
"\t * @returns {Object} Returns the new `lodash` wrapper instance.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var users = [\n", | |
"\t * { 'user': 'barney', 'age': 36 },\n", | |
"\t * { 'user': 'fred', 'age': 40 },\n", | |
"\t * { 'user': 'pebbles', 'age': 1 }\n", | |
"\t * ];\n", | |
"\t *\n", | |
"\t * var youngest = _\n", | |
"\t * .chain(users)\n", | |
"\t * .sortBy('age')\n", | |
"\t * .map(function(o) {\n", | |
"\t * return o.user + ' is ' + o.age;\n", | |
"\t * })\n", | |
"\t * .head()\n", | |
"\t * .value();\n", | |
"\t * // => 'pebbles is 1'\n", | |
"\t */\n", | |
"\t function chain(value) {\n", | |
"\t var result = lodash(value);\n", | |
"\t result.__chain__ = true;\n", | |
"\t return result;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method invokes `interceptor` and returns `value`. The interceptor\n", | |
"\t * is invoked with one argument; (value). The purpose of this method is to\n", | |
"\t * \"tap into\" a method chain sequence in order to modify intermediate results.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Seq\n", | |
"\t * @param {*} value The value to provide to `interceptor`.\n", | |
"\t * @param {Function} interceptor The function to invoke.\n", | |
"\t * @returns {*} Returns `value`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _([1, 2, 3])\n", | |
"\t * .tap(function(array) {\n", | |
"\t * // Mutate input array.\n", | |
"\t * array.pop();\n", | |
"\t * })\n", | |
"\t * .reverse()\n", | |
"\t * .value();\n", | |
"\t * // => [2, 1]\n", | |
"\t */\n", | |
"\t function tap(value, interceptor) {\n", | |
"\t interceptor(value);\n", | |
"\t return value;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is like `_.tap` except that it returns the result of `interceptor`.\n", | |
"\t * The purpose of this method is to \"pass thru\" values replacing intermediate\n", | |
"\t * results in a method chain sequence.\n", | |
"\t *\n", | |
"\t * @static\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.0.0\n", | |
"\t * @category Seq\n", | |
"\t * @param {*} value The value to provide to `interceptor`.\n", | |
"\t * @param {Function} interceptor The function to invoke.\n", | |
"\t * @returns {*} Returns the result of `interceptor`.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * _(' abc ')\n", | |
"\t * .chain()\n", | |
"\t * .trim()\n", | |
"\t * .thru(function(value) {\n", | |
"\t * return [value];\n", | |
"\t * })\n", | |
"\t * .value();\n", | |
"\t * // => ['abc']\n", | |
"\t */\n", | |
"\t function thru(value, interceptor) {\n", | |
"\t return interceptor(value);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * This method is the wrapper version of `_.at`.\n", | |
"\t *\n", | |
"\t * @name at\n", | |
"\t * @memberOf _\n", | |
"\t * @since 1.0.0\n", | |
"\t * @category Seq\n", | |
"\t * @param {...(string|string[])} [paths] The property paths of elements to pick.\n", | |
"\t * @returns {Object} Returns the new `lodash` wrapper instance.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };\n", | |
"\t *\n", | |
"\t * _(object).at(['a[0].b.c', 'a[1]']).value();\n", | |
"\t * // => [3, 4]\n", | |
"\t */\n", | |
"\t var wrapperAt = flatRest(function(paths) {\n", | |
"\t var length = paths.length,\n", | |
"\t start = length ? paths[0] : 0,\n", | |
"\t value = this.__wrapped__,\n", | |
"\t interceptor = function(object) { return baseAt(object, paths); };\n", | |
"\t\n", | |
"\t if (length > 1 || this.__actions__.length ||\n", | |
"\t !(value instanceof LazyWrapper) || !isIndex(start)) {\n", | |
"\t return this.thru(interceptor);\n", | |
"\t }\n", | |
"\t value = value.slice(start, +start + (length ? 1 : 0));\n", | |
"\t value.__actions__.push({\n", | |
"\t 'func': thru,\n", | |
"\t 'args': [interceptor],\n", | |
"\t 'thisArg': undefined\n", | |
"\t });\n", | |
"\t return new LodashWrapper(value, this.__chain__).thru(function(array) {\n", | |
"\t if (length && !array.length) {\n", | |
"\t array.push(undefined);\n", | |
"\t }\n", | |
"\t return array;\n", | |
"\t });\n", | |
"\t });\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.\n", | |
"\t *\n", | |
"\t * @name chain\n", | |
"\t * @memberOf _\n", | |
"\t * @since 0.1.0\n", | |
"\t * @category Seq\n", | |
"\t * @returns {Object} Returns the new `lodash` wrapper instance.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var users = [\n", | |
"\t * { 'user': 'barney', 'age': 36 },\n", | |
"\t * { 'user': 'fred', 'age': 40 }\n", | |
"\t * ];\n", | |
"\t *\n", | |
"\t * // A sequence without explicit chaining.\n", | |
"\t * _(users).head();\n", | |
"\t * // => { 'user': 'barney', 'age': 36 }\n", | |
"\t *\n", | |
"\t * // A sequence with explicit chaining.\n", | |
"\t * _(users)\n", | |
"\t * .chain()\n", | |
"\t * .head()\n", | |
"\t * .pick('user')\n", | |
"\t * .value();\n", | |
"\t * // => { 'user': 'barney' }\n", | |
"\t */\n", | |
"\t function wrapperChain() {\n", | |
"\t return chain(this);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Executes the chain sequence and returns the wrapped result.\n", | |
"\t *\n", | |
"\t * @name commit\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.2.0\n", | |
"\t * @category Seq\n", | |
"\t * @returns {Object} Returns the new `lodash` wrapper instance.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var array = [1, 2];\n", | |
"\t * var wrapped = _(array).push(3);\n", | |
"\t *\n", | |
"\t * console.log(array);\n", | |
"\t * // => [1, 2]\n", | |
"\t *\n", | |
"\t * wrapped = wrapped.commit();\n", | |
"\t * console.log(array);\n", | |
"\t * // => [1, 2, 3]\n", | |
"\t *\n", | |
"\t * wrapped.last();\n", | |
"\t * // => 3\n", | |
"\t *\n", | |
"\t * console.log(array);\n", | |
"\t * // => [1, 2, 3]\n", | |
"\t */\n", | |
"\t function wrapperCommit() {\n", | |
"\t return new LodashWrapper(this.value(), this.__chain__);\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Gets the next value on a wrapped object following the\n", | |
"\t * [iterator protocol](https://mdn.io/iteration_protocols#iterator).\n", | |
"\t *\n", | |
"\t * @name next\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Seq\n", | |
"\t * @returns {Object} Returns the next iterator value.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var wrapped = _([1, 2]);\n", | |
"\t *\n", | |
"\t * wrapped.next();\n", | |
"\t * // => { 'done': false, 'value': 1 }\n", | |
"\t *\n", | |
"\t * wrapped.next();\n", | |
"\t * // => { 'done': false, 'value': 2 }\n", | |
"\t *\n", | |
"\t * wrapped.next();\n", | |
"\t * // => { 'done': true, 'value': undefined }\n", | |
"\t */\n", | |
"\t function wrapperNext() {\n", | |
"\t if (this.__values__ === undefined) {\n", | |
"\t this.__values__ = toArray(this.value());\n", | |
"\t }\n", | |
"\t var done = this.__index__ >= this.__values__.length,\n", | |
"\t value = done ? undefined : this.__values__[this.__index__++];\n", | |
"\t\n", | |
"\t return { 'done': done, 'value': value };\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Enables the wrapper to be iterable.\n", | |
"\t *\n", | |
"\t * @name Symbol.iterator\n", | |
"\t * @memberOf _\n", | |
"\t * @since 4.0.0\n", | |
"\t * @category Seq\n", | |
"\t * @returns {Object} Returns the wrapper object.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * var wrapped = _([1, 2]);\n", | |
"\t *\n", | |
"\t * wrapped[Symbol.iterator]() === wrapped;\n", | |
"\t * // => true\n", | |
"\t *\n", | |
"\t * Array.from(wrapped);\n", | |
"\t * // => [1, 2]\n", | |
"\t */\n", | |
"\t function wrapperToIterator() {\n", | |
"\t return this;\n", | |
"\t }\n", | |
"\t\n", | |
"\t /**\n", | |
"\t * Creates a clone of the chain sequence planting `value` as the wrapped value.\n", | |
"\t *\n", | |
"\t * @name plant\n", | |
"\t * @memberOf _\n", | |
"\t * @since 3.2.0\n", | |
"\t * @category Seq\n", | |
"\t * @param {*} value The value to plant.\n", | |
"\t * @returns {Object} Returns the new `lodash` wrapper instance.\n", | |
"\t * @example\n", | |
"\t *\n", | |
"\t * function square(n) {\n", | |
"\t * return n * n;\n", | |
"\t * }\n", | |
"\t *\n", | |
"\t * var wrapped = _([1, 2]).map(square);\n", | |
"\t * var other = wrapped.plant([3, 4]);\n", | |
"\t *\n", | |
"\t * other.value();\n", | |
"\t * // => [9, 16]\n", | |
"\t *\n", | |
"\t * wrapped.value();\n", | |
"\t * // => [1, 4]\n", | |
"\t */\n", | |
"\t function wrapperPlant(value) {\n", | |
"\t var result,\n", | |
"\t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment