UNPKG

514 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3 typeof define === 'function' && define.amd ? define(['exports'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["d3-state-visualizer"] = {}));
5})(this, (function (exports) { 'use strict';
6
7 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
9 function getDefaultExportFromCjs (x) {
10 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11 }
12
13 var toConsumableArray = {exports: {}};
14
15 var arrayWithoutHoles = {exports: {}};
16
17 var arrayLikeToArray = {exports: {}};
18
19 (function (module) {
20 function _arrayLikeToArray(arr, len) {
21 if (len == null || len > arr.length) len = arr.length;
22
23 for (var i = 0, arr2 = new Array(len); i < len; i++) {
24 arr2[i] = arr[i];
25 }
26
27 return arr2;
28 }
29
30 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
31 }(arrayLikeToArray));
32
33 (function (module) {
34 var arrayLikeToArray$1 = arrayLikeToArray.exports;
35
36 function _arrayWithoutHoles(arr) {
37 if (Array.isArray(arr)) return arrayLikeToArray$1(arr);
38 }
39
40 module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
41 }(arrayWithoutHoles));
42
43 var iterableToArray = {exports: {}};
44
45 (function (module) {
46 function _iterableToArray(iter) {
47 if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
48 }
49
50 module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
51 }(iterableToArray));
52
53 var unsupportedIterableToArray = {exports: {}};
54
55 (function (module) {
56 var arrayLikeToArray$1 = arrayLikeToArray.exports;
57
58 function _unsupportedIterableToArray(o, minLen) {
59 if (!o) return;
60 if (typeof o === "string") return arrayLikeToArray$1(o, minLen);
61 var n = Object.prototype.toString.call(o).slice(8, -1);
62 if (n === "Object" && o.constructor) n = o.constructor.name;
63 if (n === "Map" || n === "Set") return Array.from(o);
64 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray$1(o, minLen);
65 }
66
67 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
68 }(unsupportedIterableToArray));
69
70 var nonIterableSpread = {exports: {}};
71
72 (function (module) {
73 function _nonIterableSpread() {
74 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
75 }
76
77 module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
78 }(nonIterableSpread));
79
80 (function (module) {
81 var arrayWithoutHoles$1 = arrayWithoutHoles.exports;
82
83 var iterableToArray$1 = iterableToArray.exports;
84
85 var unsupportedIterableToArray$1 = unsupportedIterableToArray.exports;
86
87 var nonIterableSpread$1 = nonIterableSpread.exports;
88
89 function _toConsumableArray(arr) {
90 return arrayWithoutHoles$1(arr) || iterableToArray$1(arr) || unsupportedIterableToArray$1(arr) || nonIterableSpread$1();
91 }
92
93 module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
94 }(toConsumableArray));
95
96 var _toConsumableArray = /*@__PURE__*/getDefaultExportFromCjs(toConsumableArray.exports);
97
98 var defineProperty$2 = {exports: {}};
99
100 (function (module) {
101 function _defineProperty(obj, key, value) {
102 if (key in obj) {
103 Object.defineProperty(obj, key, {
104 value: value,
105 enumerable: true,
106 configurable: true,
107 writable: true
108 });
109 } else {
110 obj[key] = value;
111 }
112
113 return obj;
114 }
115
116 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
117 }(defineProperty$2));
118
119 var _defineProperty$2 = /*@__PURE__*/getDefaultExportFromCjs(defineProperty$2.exports);
120
121 var d3$1 = {exports: {}};
122
123 (function (module) {
124 !function() {
125 var d3 = {
126 version: "3.5.17"
127 };
128 var d3_arraySlice = [].slice, d3_array = function(list) {
129 return d3_arraySlice.call(list);
130 };
131 var d3_document = this.document;
132 function d3_documentElement(node) {
133 return node && (node.ownerDocument || node.document || node).documentElement;
134 }
135 function d3_window(node) {
136 return node && (node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView);
137 }
138 if (d3_document) {
139 try {
140 d3_array(d3_document.documentElement.childNodes)[0].nodeType;
141 } catch (e) {
142 d3_array = function(list) {
143 var i = list.length, array = new Array(i);
144 while (i--) array[i] = list[i];
145 return array;
146 };
147 }
148 }
149 if (!Date.now) Date.now = function() {
150 return +new Date();
151 };
152 if (d3_document) {
153 try {
154 d3_document.createElement("DIV").style.setProperty("opacity", 0, "");
155 } catch (error) {
156 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;
157 d3_element_prototype.setAttribute = function(name, value) {
158 d3_element_setAttribute.call(this, name, value + "");
159 };
160 d3_element_prototype.setAttributeNS = function(space, local, value) {
161 d3_element_setAttributeNS.call(this, space, local, value + "");
162 };
163 d3_style_prototype.setProperty = function(name, value, priority) {
164 d3_style_setProperty.call(this, name, value + "", priority);
165 };
166 }
167 }
168 d3.ascending = d3_ascending;
169 function d3_ascending(a, b) {
170 return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
171 }
172 d3.descending = function(a, b) {
173 return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
174 };
175 d3.min = function(array, f) {
176 var i = -1, n = array.length, a, b;
177 if (arguments.length === 1) {
178 while (++i < n) if ((b = array[i]) != null && b >= b) {
179 a = b;
180 break;
181 }
182 while (++i < n) if ((b = array[i]) != null && a > b) a = b;
183 } else {
184 while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
185 a = b;
186 break;
187 }
188 while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
189 }
190 return a;
191 };
192 d3.max = function(array, f) {
193 var i = -1, n = array.length, a, b;
194 if (arguments.length === 1) {
195 while (++i < n) if ((b = array[i]) != null && b >= b) {
196 a = b;
197 break;
198 }
199 while (++i < n) if ((b = array[i]) != null && b > a) a = b;
200 } else {
201 while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
202 a = b;
203 break;
204 }
205 while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
206 }
207 return a;
208 };
209 d3.extent = function(array, f) {
210 var i = -1, n = array.length, a, b, c;
211 if (arguments.length === 1) {
212 while (++i < n) if ((b = array[i]) != null && b >= b) {
213 a = c = b;
214 break;
215 }
216 while (++i < n) if ((b = array[i]) != null) {
217 if (a > b) a = b;
218 if (c < b) c = b;
219 }
220 } else {
221 while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
222 a = c = b;
223 break;
224 }
225 while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
226 if (a > b) a = b;
227 if (c < b) c = b;
228 }
229 }
230 return [ a, c ];
231 };
232 function d3_number(x) {
233 return x === null ? NaN : +x;
234 }
235 function d3_numeric(x) {
236 return !isNaN(x);
237 }
238 d3.sum = function(array, f) {
239 var s = 0, n = array.length, a, i = -1;
240 if (arguments.length === 1) {
241 while (++i < n) if (d3_numeric(a = +array[i])) s += a;
242 } else {
243 while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a;
244 }
245 return s;
246 };
247 d3.mean = function(array, f) {
248 var s = 0, n = array.length, a, i = -1, j = n;
249 if (arguments.length === 1) {
250 while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j;
251 } else {
252 while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j;
253 }
254 if (j) return s / j;
255 };
256 d3.quantile = function(values, p) {
257 var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
258 return e ? v + e * (values[h] - v) : v;
259 };
260 d3.median = function(array, f) {
261 var numbers = [], n = array.length, a, i = -1;
262 if (arguments.length === 1) {
263 while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a);
264 } else {
265 while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a);
266 }
267 if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5);
268 };
269 d3.variance = function(array, f) {
270 var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0;
271 if (arguments.length === 1) {
272 while (++i < n) {
273 if (d3_numeric(a = d3_number(array[i]))) {
274 d = a - m;
275 m += d / ++j;
276 s += d * (a - m);
277 }
278 }
279 } else {
280 while (++i < n) {
281 if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) {
282 d = a - m;
283 m += d / ++j;
284 s += d * (a - m);
285 }
286 }
287 }
288 if (j > 1) return s / (j - 1);
289 };
290 d3.deviation = function() {
291 var v = d3.variance.apply(this, arguments);
292 return v ? Math.sqrt(v) : v;
293 };
294 function d3_bisector(compare) {
295 return {
296 left: function(a, x, lo, hi) {
297 if (arguments.length < 3) lo = 0;
298 if (arguments.length < 4) hi = a.length;
299 while (lo < hi) {
300 var mid = lo + hi >>> 1;
301 if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid;
302 }
303 return lo;
304 },
305 right: function(a, x, lo, hi) {
306 if (arguments.length < 3) lo = 0;
307 if (arguments.length < 4) hi = a.length;
308 while (lo < hi) {
309 var mid = lo + hi >>> 1;
310 if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1;
311 }
312 return lo;
313 }
314 };
315 }
316 var d3_bisect = d3_bisector(d3_ascending);
317 d3.bisectLeft = d3_bisect.left;
318 d3.bisect = d3.bisectRight = d3_bisect.right;
319 d3.bisector = function(f) {
320 return d3_bisector(f.length === 1 ? function(d, x) {
321 return d3_ascending(f(d), x);
322 } : f);
323 };
324 d3.shuffle = function(array, i0, i1) {
325 if ((m = arguments.length) < 3) {
326 i1 = array.length;
327 if (m < 2) i0 = 0;
328 }
329 var m = i1 - i0, t, i;
330 while (m) {
331 i = Math.random() * m-- | 0;
332 t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t;
333 }
334 return array;
335 };
336 d3.permute = function(array, indexes) {
337 var i = indexes.length, permutes = new Array(i);
338 while (i--) permutes[i] = array[indexes[i]];
339 return permutes;
340 };
341 d3.pairs = function(array) {
342 var i = 0, n = array.length - 1, p1 = array[0], pairs = new Array(n < 0 ? 0 : n);
343 while (i < n) pairs[i] = [ p1, p1 = array[++i] ];
344 return pairs;
345 };
346 d3.transpose = function(matrix) {
347 if (!(n = matrix.length)) return [];
348 for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) {
349 for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n; ) {
350 row[j] = matrix[j][i];
351 }
352 }
353 return transpose;
354 };
355 function d3_transposeLength(d) {
356 return d.length;
357 }
358 d3.zip = function() {
359 return d3.transpose(arguments);
360 };
361 d3.keys = function(map) {
362 var keys = [];
363 for (var key in map) keys.push(key);
364 return keys;
365 };
366 d3.values = function(map) {
367 var values = [];
368 for (var key in map) values.push(map[key]);
369 return values;
370 };
371 d3.entries = function(map) {
372 var entries = [];
373 for (var key in map) entries.push({
374 key: key,
375 value: map[key]
376 });
377 return entries;
378 };
379 d3.merge = function(arrays) {
380 var n = arrays.length, m, i = -1, j = 0, merged, array;
381 while (++i < n) j += arrays[i].length;
382 merged = new Array(j);
383 while (--n >= 0) {
384 array = arrays[n];
385 m = array.length;
386 while (--m >= 0) {
387 merged[--j] = array[m];
388 }
389 }
390 return merged;
391 };
392 var abs = Math.abs;
393 d3.range = function(start, stop, step) {
394 if (arguments.length < 3) {
395 step = 1;
396 if (arguments.length < 2) {
397 stop = start;
398 start = 0;
399 }
400 }
401 if ((stop - start) / step === Infinity) throw new Error("infinite range");
402 var range = [], k = d3_range_integerScale(abs(step)), i = -1, j;
403 start *= k, stop *= k, step *= k;
404 if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k);
405 return range;
406 };
407 function d3_range_integerScale(x) {
408 var k = 1;
409 while (x * k % 1) k *= 10;
410 return k;
411 }
412 function d3_class(ctor, properties) {
413 for (var key in properties) {
414 Object.defineProperty(ctor.prototype, key, {
415 value: properties[key],
416 enumerable: false
417 });
418 }
419 }
420 d3.map = function(object, f) {
421 var map = new d3_Map();
422 if (object instanceof d3_Map) {
423 object.forEach(function(key, value) {
424 map.set(key, value);
425 });
426 } else if (Array.isArray(object)) {
427 var i = -1, n = object.length, o;
428 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);
429 } else {
430 for (var key in object) map.set(key, object[key]);
431 }
432 return map;
433 };
434 function d3_Map() {
435 this._ = Object.create(null);
436 }
437 var d3_map_proto = "__proto__", d3_map_zero = "\x00";
438 d3_class(d3_Map, {
439 has: d3_map_has,
440 get: function(key) {
441 return this._[d3_map_escape(key)];
442 },
443 set: function(key, value) {
444 return this._[d3_map_escape(key)] = value;
445 },
446 remove: d3_map_remove,
447 keys: d3_map_keys,
448 values: function() {
449 var values = [];
450 for (var key in this._) values.push(this._[key]);
451 return values;
452 },
453 entries: function() {
454 var entries = [];
455 for (var key in this._) entries.push({
456 key: d3_map_unescape(key),
457 value: this._[key]
458 });
459 return entries;
460 },
461 size: d3_map_size,
462 empty: d3_map_empty,
463 forEach: function(f) {
464 for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]);
465 }
466 });
467 function d3_map_escape(key) {
468 return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key;
469 }
470 function d3_map_unescape(key) {
471 return (key += "")[0] === d3_map_zero ? key.slice(1) : key;
472 }
473 function d3_map_has(key) {
474 return d3_map_escape(key) in this._;
475 }
476 function d3_map_remove(key) {
477 return (key = d3_map_escape(key)) in this._ && delete this._[key];
478 }
479 function d3_map_keys() {
480 var keys = [];
481 for (var key in this._) keys.push(d3_map_unescape(key));
482 return keys;
483 }
484 function d3_map_size() {
485 var size = 0;
486 for (var key in this._) ++size;
487 return size;
488 }
489 function d3_map_empty() {
490 for (var key in this._) return false;
491 return true;
492 }
493 d3.nest = function() {
494 var nest = {}, keys = [], sortKeys = [], sortValues, rollup;
495 function map(mapType, array, depth) {
496 if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;
497 var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values;
498 while (++i < n) {
499 if (values = valuesByKey.get(keyValue = key(object = array[i]))) {
500 values.push(object);
501 } else {
502 valuesByKey.set(keyValue, [ object ]);
503 }
504 }
505 if (mapType) {
506 object = mapType();
507 setter = function(keyValue, values) {
508 object.set(keyValue, map(mapType, values, depth));
509 };
510 } else {
511 object = {};
512 setter = function(keyValue, values) {
513 object[keyValue] = map(mapType, values, depth);
514 };
515 }
516 valuesByKey.forEach(setter);
517 return object;
518 }
519 function entries(map, depth) {
520 if (depth >= keys.length) return map;
521 var array = [], sortKey = sortKeys[depth++];
522 map.forEach(function(key, keyMap) {
523 array.push({
524 key: key,
525 values: entries(keyMap, depth)
526 });
527 });
528 return sortKey ? array.sort(function(a, b) {
529 return sortKey(a.key, b.key);
530 }) : array;
531 }
532 nest.map = function(array, mapType) {
533 return map(mapType, array, 0);
534 };
535 nest.entries = function(array) {
536 return entries(map(d3.map, array, 0), 0);
537 };
538 nest.key = function(d) {
539 keys.push(d);
540 return nest;
541 };
542 nest.sortKeys = function(order) {
543 sortKeys[keys.length - 1] = order;
544 return nest;
545 };
546 nest.sortValues = function(order) {
547 sortValues = order;
548 return nest;
549 };
550 nest.rollup = function(f) {
551 rollup = f;
552 return nest;
553 };
554 return nest;
555 };
556 d3.set = function(array) {
557 var set = new d3_Set();
558 if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);
559 return set;
560 };
561 function d3_Set() {
562 this._ = Object.create(null);
563 }
564 d3_class(d3_Set, {
565 has: d3_map_has,
566 add: function(key) {
567 this._[d3_map_escape(key += "")] = true;
568 return key;
569 },
570 remove: d3_map_remove,
571 values: d3_map_keys,
572 size: d3_map_size,
573 empty: d3_map_empty,
574 forEach: function(f) {
575 for (var key in this._) f.call(this, d3_map_unescape(key));
576 }
577 });
578 d3.behavior = {};
579 function d3_identity(d) {
580 return d;
581 }
582 d3.rebind = function(target, source) {
583 var i = 1, n = arguments.length, method;
584 while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);
585 return target;
586 };
587 function d3_rebind(target, source, method) {
588 return function() {
589 var value = method.apply(source, arguments);
590 return value === source ? target : value;
591 };
592 }
593 function d3_vendorSymbol(object, name) {
594 if (name in object) return name;
595 name = name.charAt(0).toUpperCase() + name.slice(1);
596 for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) {
597 var prefixName = d3_vendorPrefixes[i] + name;
598 if (prefixName in object) return prefixName;
599 }
600 }
601 var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ];
602 function d3_noop() {}
603 d3.dispatch = function() {
604 var dispatch = new d3_dispatch(), i = -1, n = arguments.length;
605 while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
606 return dispatch;
607 };
608 function d3_dispatch() {}
609 d3_dispatch.prototype.on = function(type, listener) {
610 var i = type.indexOf("."), name = "";
611 if (i >= 0) {
612 name = type.slice(i + 1);
613 type = type.slice(0, i);
614 }
615 if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);
616 if (arguments.length === 2) {
617 if (listener == null) for (type in this) {
618 if (this.hasOwnProperty(type)) this[type].on(name, null);
619 }
620 return this;
621 }
622 };
623 function d3_dispatch_event(dispatch) {
624 var listeners = [], listenerByName = new d3_Map();
625 function event() {
626 var z = listeners, i = -1, n = z.length, l;
627 while (++i < n) if (l = z[i].on) l.apply(this, arguments);
628 return dispatch;
629 }
630 event.on = function(name, listener) {
631 var l = listenerByName.get(name), i;
632 if (arguments.length < 2) return l && l.on;
633 if (l) {
634 l.on = null;
635 listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
636 listenerByName.remove(name);
637 }
638 if (listener) listeners.push(listenerByName.set(name, {
639 on: listener
640 }));
641 return dispatch;
642 };
643 return event;
644 }
645 d3.event = null;
646 function d3_eventPreventDefault() {
647 d3.event.preventDefault();
648 }
649 function d3_eventSource() {
650 var e = d3.event, s;
651 while (s = e.sourceEvent) e = s;
652 return e;
653 }
654 function d3_eventDispatch(target) {
655 var dispatch = new d3_dispatch(), i = 0, n = arguments.length;
656 while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
657 dispatch.of = function(thiz, argumentz) {
658 return function(e1) {
659 try {
660 var e0 = e1.sourceEvent = d3.event;
661 e1.target = target;
662 d3.event = e1;
663 dispatch[e1.type].apply(thiz, argumentz);
664 } finally {
665 d3.event = e0;
666 }
667 };
668 };
669 return dispatch;
670 }
671 d3.requote = function(s) {
672 return s.replace(d3_requote_re, "\\$&");
673 };
674 var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
675 var d3_subclass = function(object, prototype) {
676 for (var property in prototype) object[property] = prototype[property];
677 };
678 function d3_selection(groups) {
679 d3_subclass(groups, d3_selectionPrototype);
680 return groups;
681 }
682 var d3_select = function(s, n) {
683 return n.querySelector(s);
684 }, d3_selectAll = function(s, n) {
685 return n.querySelectorAll(s);
686 }, d3_selectMatches = function(n, s) {
687 var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, "matchesSelector")];
688 d3_selectMatches = function(n, s) {
689 return d3_selectMatcher.call(n, s);
690 };
691 return d3_selectMatches(n, s);
692 };
693 if (typeof Sizzle === "function") {
694 d3_select = function(s, n) {
695 return Sizzle(s, n)[0] || null;
696 };
697 d3_selectAll = Sizzle;
698 d3_selectMatches = Sizzle.matchesSelector;
699 }
700 d3.selection = function() {
701 return d3.select(d3_document.documentElement);
702 };
703 var d3_selectionPrototype = d3.selection.prototype = [];
704 d3_selectionPrototype.select = function(selector) {
705 var subgroups = [], subgroup, subnode, group, node;
706 selector = d3_selection_selector(selector);
707 for (var j = -1, m = this.length; ++j < m; ) {
708 subgroups.push(subgroup = []);
709 subgroup.parentNode = (group = this[j]).parentNode;
710 for (var i = -1, n = group.length; ++i < n; ) {
711 if (node = group[i]) {
712 subgroup.push(subnode = selector.call(node, node.__data__, i, j));
713 if (subnode && "__data__" in node) subnode.__data__ = node.__data__;
714 } else {
715 subgroup.push(null);
716 }
717 }
718 }
719 return d3_selection(subgroups);
720 };
721 function d3_selection_selector(selector) {
722 return typeof selector === "function" ? selector : function() {
723 return d3_select(selector, this);
724 };
725 }
726 d3_selectionPrototype.selectAll = function(selector) {
727 var subgroups = [], subgroup, node;
728 selector = d3_selection_selectorAll(selector);
729 for (var j = -1, m = this.length; ++j < m; ) {
730 for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
731 if (node = group[i]) {
732 subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j)));
733 subgroup.parentNode = node;
734 }
735 }
736 }
737 return d3_selection(subgroups);
738 };
739 function d3_selection_selectorAll(selector) {
740 return typeof selector === "function" ? selector : function() {
741 return d3_selectAll(selector, this);
742 };
743 }
744 var d3_nsXhtml = "http://www.w3.org/1999/xhtml";
745 var d3_nsPrefix = {
746 svg: "http://www.w3.org/2000/svg",
747 xhtml: d3_nsXhtml,
748 xlink: "http://www.w3.org/1999/xlink",
749 xml: "http://www.w3.org/XML/1998/namespace",
750 xmlns: "http://www.w3.org/2000/xmlns/"
751 };
752 d3.ns = {
753 prefix: d3_nsPrefix,
754 qualify: function(name) {
755 var i = name.indexOf(":"), prefix = name;
756 if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1);
757 return d3_nsPrefix.hasOwnProperty(prefix) ? {
758 space: d3_nsPrefix[prefix],
759 local: name
760 } : name;
761 }
762 };
763 d3_selectionPrototype.attr = function(name, value) {
764 if (arguments.length < 2) {
765 if (typeof name === "string") {
766 var node = this.node();
767 name = d3.ns.qualify(name);
768 return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name);
769 }
770 for (value in name) this.each(d3_selection_attr(value, name[value]));
771 return this;
772 }
773 return this.each(d3_selection_attr(name, value));
774 };
775 function d3_selection_attr(name, value) {
776 name = d3.ns.qualify(name);
777 function attrNull() {
778 this.removeAttribute(name);
779 }
780 function attrNullNS() {
781 this.removeAttributeNS(name.space, name.local);
782 }
783 function attrConstant() {
784 this.setAttribute(name, value);
785 }
786 function attrConstantNS() {
787 this.setAttributeNS(name.space, name.local, value);
788 }
789 function attrFunction() {
790 var x = value.apply(this, arguments);
791 if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);
792 }
793 function attrFunctionNS() {
794 var x = value.apply(this, arguments);
795 if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);
796 }
797 return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;
798 }
799 function d3_collapse(s) {
800 return s.trim().replace(/\s+/g, " ");
801 }
802 d3_selectionPrototype.classed = function(name, value) {
803 if (arguments.length < 2) {
804 if (typeof name === "string") {
805 var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1;
806 if (value = node.classList) {
807 while (++i < n) if (!value.contains(name[i])) return false;
808 } else {
809 value = node.getAttribute("class");
810 while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false;
811 }
812 return true;
813 }
814 for (value in name) this.each(d3_selection_classed(value, name[value]));
815 return this;
816 }
817 return this.each(d3_selection_classed(name, value));
818 };
819 function d3_selection_classedRe(name) {
820 return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
821 }
822 function d3_selection_classes(name) {
823 return (name + "").trim().split(/^|\s+/);
824 }
825 function d3_selection_classed(name, value) {
826 name = d3_selection_classes(name).map(d3_selection_classedName);
827 var n = name.length;
828 function classedConstant() {
829 var i = -1;
830 while (++i < n) name[i](this, value);
831 }
832 function classedFunction() {
833 var i = -1, x = value.apply(this, arguments);
834 while (++i < n) name[i](this, x);
835 }
836 return typeof value === "function" ? classedFunction : classedConstant;
837 }
838 function d3_selection_classedName(name) {
839 var re = d3_selection_classedRe(name);
840 return function(node, value) {
841 if (c = node.classList) return value ? c.add(name) : c.remove(name);
842 var c = node.getAttribute("class") || "";
843 if (value) {
844 re.lastIndex = 0;
845 if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name));
846 } else {
847 node.setAttribute("class", d3_collapse(c.replace(re, " ")));
848 }
849 };
850 }
851 d3_selectionPrototype.style = function(name, value, priority) {
852 var n = arguments.length;
853 if (n < 3) {
854 if (typeof name !== "string") {
855 if (n < 2) value = "";
856 for (priority in name) this.each(d3_selection_style(priority, name[priority], value));
857 return this;
858 }
859 if (n < 2) {
860 var node = this.node();
861 return d3_window(node).getComputedStyle(node, null).getPropertyValue(name);
862 }
863 priority = "";
864 }
865 return this.each(d3_selection_style(name, value, priority));
866 };
867 function d3_selection_style(name, value, priority) {
868 function styleNull() {
869 this.style.removeProperty(name);
870 }
871 function styleConstant() {
872 this.style.setProperty(name, value, priority);
873 }
874 function styleFunction() {
875 var x = value.apply(this, arguments);
876 if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);
877 }
878 return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant;
879 }
880 d3_selectionPrototype.property = function(name, value) {
881 if (arguments.length < 2) {
882 if (typeof name === "string") return this.node()[name];
883 for (value in name) this.each(d3_selection_property(value, name[value]));
884 return this;
885 }
886 return this.each(d3_selection_property(name, value));
887 };
888 function d3_selection_property(name, value) {
889 function propertyNull() {
890 delete this[name];
891 }
892 function propertyConstant() {
893 this[name] = value;
894 }
895 function propertyFunction() {
896 var x = value.apply(this, arguments);
897 if (x == null) delete this[name]; else this[name] = x;
898 }
899 return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant;
900 }
901 d3_selectionPrototype.text = function(value) {
902 return arguments.length ? this.each(typeof value === "function" ? function() {
903 var v = value.apply(this, arguments);
904 this.textContent = v == null ? "" : v;
905 } : value == null ? function() {
906 this.textContent = "";
907 } : function() {
908 this.textContent = value;
909 }) : this.node().textContent;
910 };
911 d3_selectionPrototype.html = function(value) {
912 return arguments.length ? this.each(typeof value === "function" ? function() {
913 var v = value.apply(this, arguments);
914 this.innerHTML = v == null ? "" : v;
915 } : value == null ? function() {
916 this.innerHTML = "";
917 } : function() {
918 this.innerHTML = value;
919 }) : this.node().innerHTML;
920 };
921 d3_selectionPrototype.append = function(name) {
922 name = d3_selection_creator(name);
923 return this.select(function() {
924 return this.appendChild(name.apply(this, arguments));
925 });
926 };
927 function d3_selection_creator(name) {
928 function create() {
929 var document = this.ownerDocument, namespace = this.namespaceURI;
930 return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name);
931 }
932 function createNS() {
933 return this.ownerDocument.createElementNS(name.space, name.local);
934 }
935 return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? createNS : create;
936 }
937 d3_selectionPrototype.insert = function(name, before) {
938 name = d3_selection_creator(name);
939 before = d3_selection_selector(before);
940 return this.select(function() {
941 return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null);
942 });
943 };
944 d3_selectionPrototype.remove = function() {
945 return this.each(d3_selectionRemove);
946 };
947 function d3_selectionRemove() {
948 var parent = this.parentNode;
949 if (parent) parent.removeChild(this);
950 }
951 d3_selectionPrototype.data = function(value, key) {
952 var i = -1, n = this.length, group, node;
953 if (!arguments.length) {
954 value = new Array(n = (group = this[0]).length);
955 while (++i < n) {
956 if (node = group[i]) {
957 value[i] = node.__data__;
958 }
959 }
960 return value;
961 }
962 function bind(group, groupData) {
963 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;
964 if (key) {
965 var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue;
966 for (i = -1; ++i < n; ) {
967 if (node = group[i]) {
968 if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) {
969 exitNodes[i] = node;
970 } else {
971 nodeByKeyValue.set(keyValue, node);
972 }
973 keyValues[i] = keyValue;
974 }
975 }
976 for (i = -1; ++i < m; ) {
977 if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) {
978 enterNodes[i] = d3_selection_dataNode(nodeData);
979 } else if (node !== true) {
980 updateNodes[i] = node;
981 node.__data__ = nodeData;
982 }
983 nodeByKeyValue.set(keyValue, true);
984 }
985 for (i = -1; ++i < n; ) {
986 if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) {
987 exitNodes[i] = group[i];
988 }
989 }
990 } else {
991 for (i = -1; ++i < n0; ) {
992 node = group[i];
993 nodeData = groupData[i];
994 if (node) {
995 node.__data__ = nodeData;
996 updateNodes[i] = node;
997 } else {
998 enterNodes[i] = d3_selection_dataNode(nodeData);
999 }
1000 }
1001 for (;i < m; ++i) {
1002 enterNodes[i] = d3_selection_dataNode(groupData[i]);
1003 }
1004 for (;i < n; ++i) {
1005 exitNodes[i] = group[i];
1006 }
1007 }
1008 enterNodes.update = updateNodes;
1009 enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;
1010 enter.push(enterNodes);
1011 update.push(updateNodes);
1012 exit.push(exitNodes);
1013 }
1014 var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);
1015 if (typeof value === "function") {
1016 while (++i < n) {
1017 bind(group = this[i], value.call(group, group.parentNode.__data__, i));
1018 }
1019 } else {
1020 while (++i < n) {
1021 bind(group = this[i], value);
1022 }
1023 }
1024 update.enter = function() {
1025 return enter;
1026 };
1027 update.exit = function() {
1028 return exit;
1029 };
1030 return update;
1031 };
1032 function d3_selection_dataNode(data) {
1033 return {
1034 __data__: data
1035 };
1036 }
1037 d3_selectionPrototype.datum = function(value) {
1038 return arguments.length ? this.property("__data__", value) : this.property("__data__");
1039 };
1040 d3_selectionPrototype.filter = function(filter) {
1041 var subgroups = [], subgroup, group, node;
1042 if (typeof filter !== "function") filter = d3_selection_filter(filter);
1043 for (var j = 0, m = this.length; j < m; j++) {
1044 subgroups.push(subgroup = []);
1045 subgroup.parentNode = (group = this[j]).parentNode;
1046 for (var i = 0, n = group.length; i < n; i++) {
1047 if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {
1048 subgroup.push(node);
1049 }
1050 }
1051 }
1052 return d3_selection(subgroups);
1053 };
1054 function d3_selection_filter(selector) {
1055 return function() {
1056 return d3_selectMatches(this, selector);
1057 };
1058 }
1059 d3_selectionPrototype.order = function() {
1060 for (var j = -1, m = this.length; ++j < m; ) {
1061 for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {
1062 if (node = group[i]) {
1063 if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
1064 next = node;
1065 }
1066 }
1067 }
1068 return this;
1069 };
1070 d3_selectionPrototype.sort = function(comparator) {
1071 comparator = d3_selection_sortComparator.apply(this, arguments);
1072 for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator);
1073 return this.order();
1074 };
1075 function d3_selection_sortComparator(comparator) {
1076 if (!arguments.length) comparator = d3_ascending;
1077 return function(a, b) {
1078 return a && b ? comparator(a.__data__, b.__data__) : !a - !b;
1079 };
1080 }
1081 d3_selectionPrototype.each = function(callback) {
1082 return d3_selection_each(this, function(node, i, j) {
1083 callback.call(node, node.__data__, i, j);
1084 });
1085 };
1086 function d3_selection_each(groups, callback) {
1087 for (var j = 0, m = groups.length; j < m; j++) {
1088 for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {
1089 if (node = group[i]) callback(node, i, j);
1090 }
1091 }
1092 return groups;
1093 }
1094 d3_selectionPrototype.call = function(callback) {
1095 var args = d3_array(arguments);
1096 callback.apply(args[0] = this, args);
1097 return this;
1098 };
1099 d3_selectionPrototype.empty = function() {
1100 return !this.node();
1101 };
1102 d3_selectionPrototype.node = function() {
1103 for (var j = 0, m = this.length; j < m; j++) {
1104 for (var group = this[j], i = 0, n = group.length; i < n; i++) {
1105 var node = group[i];
1106 if (node) return node;
1107 }
1108 }
1109 return null;
1110 };
1111 d3_selectionPrototype.size = function() {
1112 var n = 0;
1113 d3_selection_each(this, function() {
1114 ++n;
1115 });
1116 return n;
1117 };
1118 function d3_selection_enter(selection) {
1119 d3_subclass(selection, d3_selection_enterPrototype);
1120 return selection;
1121 }
1122 var d3_selection_enterPrototype = [];
1123 d3.selection.enter = d3_selection_enter;
1124 d3.selection.enter.prototype = d3_selection_enterPrototype;
1125 d3_selection_enterPrototype.append = d3_selectionPrototype.append;
1126 d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
1127 d3_selection_enterPrototype.node = d3_selectionPrototype.node;
1128 d3_selection_enterPrototype.call = d3_selectionPrototype.call;
1129 d3_selection_enterPrototype.size = d3_selectionPrototype.size;
1130 d3_selection_enterPrototype.select = function(selector) {
1131 var subgroups = [], subgroup, subnode, upgroup, group, node;
1132 for (var j = -1, m = this.length; ++j < m; ) {
1133 upgroup = (group = this[j]).update;
1134 subgroups.push(subgroup = []);
1135 subgroup.parentNode = group.parentNode;
1136 for (var i = -1, n = group.length; ++i < n; ) {
1137 if (node = group[i]) {
1138 subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j));
1139 subnode.__data__ = node.__data__;
1140 } else {
1141 subgroup.push(null);
1142 }
1143 }
1144 }
1145 return d3_selection(subgroups);
1146 };
1147 d3_selection_enterPrototype.insert = function(name, before) {
1148 if (arguments.length < 2) before = d3_selection_enterInsertBefore(this);
1149 return d3_selectionPrototype.insert.call(this, name, before);
1150 };
1151 function d3_selection_enterInsertBefore(enter) {
1152 var i0, j0;
1153 return function(d, i, j) {
1154 var group = enter[j].update, n = group.length, node;
1155 if (j != j0) j0 = j, i0 = 0;
1156 if (i >= i0) i0 = i + 1;
1157 while (!(node = group[i0]) && ++i0 < n) ;
1158 return node;
1159 };
1160 }
1161 d3.select = function(node) {
1162 var group;
1163 if (typeof node === "string") {
1164 group = [ d3_select(node, d3_document) ];
1165 group.parentNode = d3_document.documentElement;
1166 } else {
1167 group = [ node ];
1168 group.parentNode = d3_documentElement(node);
1169 }
1170 return d3_selection([ group ]);
1171 };
1172 d3.selectAll = function(nodes) {
1173 var group;
1174 if (typeof nodes === "string") {
1175 group = d3_array(d3_selectAll(nodes, d3_document));
1176 group.parentNode = d3_document.documentElement;
1177 } else {
1178 group = d3_array(nodes);
1179 group.parentNode = null;
1180 }
1181 return d3_selection([ group ]);
1182 };
1183 d3_selectionPrototype.on = function(type, listener, capture) {
1184 var n = arguments.length;
1185 if (n < 3) {
1186 if (typeof type !== "string") {
1187 if (n < 2) listener = false;
1188 for (capture in type) this.each(d3_selection_on(capture, type[capture], listener));
1189 return this;
1190 }
1191 if (n < 2) return (n = this.node()["__on" + type]) && n._;
1192 capture = false;
1193 }
1194 return this.each(d3_selection_on(type, listener, capture));
1195 };
1196 function d3_selection_on(type, listener, capture) {
1197 var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener;
1198 if (i > 0) type = type.slice(0, i);
1199 var filter = d3_selection_onFilters.get(type);
1200 if (filter) type = filter, wrap = d3_selection_onFilter;
1201 function onRemove() {
1202 var l = this[name];
1203 if (l) {
1204 this.removeEventListener(type, l, l.$);
1205 delete this[name];
1206 }
1207 }
1208 function onAdd() {
1209 var l = wrap(listener, d3_array(arguments));
1210 onRemove.call(this);
1211 this.addEventListener(type, this[name] = l, l.$ = capture);
1212 l._ = listener;
1213 }
1214 function removeAll() {
1215 var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match;
1216 for (var name in this) {
1217 if (match = name.match(re)) {
1218 var l = this[name];
1219 this.removeEventListener(match[1], l, l.$);
1220 delete this[name];
1221 }
1222 }
1223 }
1224 return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll;
1225 }
1226 var d3_selection_onFilters = d3.map({
1227 mouseenter: "mouseover",
1228 mouseleave: "mouseout"
1229 });
1230 if (d3_document) {
1231 d3_selection_onFilters.forEach(function(k) {
1232 if ("on" + k in d3_document) d3_selection_onFilters.remove(k);
1233 });
1234 }
1235 function d3_selection_onListener(listener, argumentz) {
1236 return function(e) {
1237 var o = d3.event;
1238 d3.event = e;
1239 argumentz[0] = this.__data__;
1240 try {
1241 listener.apply(this, argumentz);
1242 } finally {
1243 d3.event = o;
1244 }
1245 };
1246 }
1247 function d3_selection_onFilter(listener, argumentz) {
1248 var l = d3_selection_onListener(listener, argumentz);
1249 return function(e) {
1250 var target = this, related = e.relatedTarget;
1251 if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) {
1252 l.call(target, e);
1253 }
1254 };
1255 }
1256 var d3_event_dragSelect, d3_event_dragId = 0;
1257 function d3_event_dragSuppress(node) {
1258 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);
1259 if (d3_event_dragSelect == null) {
1260 d3_event_dragSelect = "onselectstart" in node ? false : d3_vendorSymbol(node.style, "userSelect");
1261 }
1262 if (d3_event_dragSelect) {
1263 var style = d3_documentElement(node).style, select = style[d3_event_dragSelect];
1264 style[d3_event_dragSelect] = "none";
1265 }
1266 return function(suppressClick) {
1267 w.on(name, null);
1268 if (d3_event_dragSelect) style[d3_event_dragSelect] = select;
1269 if (suppressClick) {
1270 var off = function() {
1271 w.on(click, null);
1272 };
1273 w.on(click, function() {
1274 d3_eventPreventDefault();
1275 off();
1276 }, true);
1277 setTimeout(off, 0);
1278 }
1279 };
1280 }
1281 d3.mouse = function(container) {
1282 return d3_mousePoint(container, d3_eventSource());
1283 };
1284 var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0;
1285 function d3_mousePoint(container, e) {
1286 if (e.changedTouches) e = e.changedTouches[0];
1287 var svg = container.ownerSVGElement || container;
1288 if (svg.createSVGPoint) {
1289 var point = svg.createSVGPoint();
1290 if (d3_mouse_bug44083 < 0) {
1291 var window = d3_window(container);
1292 if (window.scrollX || window.scrollY) {
1293 svg = d3.select("body").append("svg").style({
1294 position: "absolute",
1295 top: 0,
1296 left: 0,
1297 margin: 0,
1298 padding: 0,
1299 border: "none"
1300 }, "important");
1301 var ctm = svg[0][0].getScreenCTM();
1302 d3_mouse_bug44083 = !(ctm.f || ctm.e);
1303 svg.remove();
1304 }
1305 }
1306 if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX,
1307 point.y = e.clientY;
1308 point = point.matrixTransform(container.getScreenCTM().inverse());
1309 return [ point.x, point.y ];
1310 }
1311 var rect = container.getBoundingClientRect();
1312 return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];
1313 }
1314 d3.touch = function(container, touches, identifier) {
1315 if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;
1316 if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {
1317 if ((touch = touches[i]).identifier === identifier) {
1318 return d3_mousePoint(container, touch);
1319 }
1320 }
1321 };
1322 d3.behavior.drag = function() {
1323 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");
1324 function drag() {
1325 this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart);
1326 }
1327 function dragstart(id, position, subject, move, end) {
1328 return function() {
1329 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);
1330 if (origin) {
1331 dragOffset = origin.apply(that, arguments);
1332 dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ];
1333 } else {
1334 dragOffset = [ 0, 0 ];
1335 }
1336 dispatch({
1337 type: "dragstart"
1338 });
1339 function moved() {
1340 var position1 = position(parent, dragId), dx, dy;
1341 if (!position1) return;
1342 dx = position1[0] - position0[0];
1343 dy = position1[1] - position0[1];
1344 dragged |= dx | dy;
1345 position0 = position1;
1346 dispatch({
1347 type: "drag",
1348 x: position1[0] + dragOffset[0],
1349 y: position1[1] + dragOffset[1],
1350 dx: dx,
1351 dy: dy
1352 });
1353 }
1354 function ended() {
1355 if (!position(parent, dragId)) return;
1356 dragSubject.on(move + dragName, null).on(end + dragName, null);
1357 dragRestore(dragged);
1358 dispatch({
1359 type: "dragend"
1360 });
1361 }
1362 };
1363 }
1364 drag.origin = function(x) {
1365 if (!arguments.length) return origin;
1366 origin = x;
1367 return drag;
1368 };
1369 return d3.rebind(drag, event, "on");
1370 };
1371 function d3_behavior_dragTouchId() {
1372 return d3.event.changedTouches[0].identifier;
1373 }
1374 d3.touches = function(container, touches) {
1375 if (arguments.length < 2) touches = d3_eventSource().touches;
1376 return touches ? d3_array(touches).map(function(touch) {
1377 var point = d3_mousePoint(container, touch);
1378 point.identifier = touch.identifier;
1379 return point;
1380 }) : [];
1381 };
1382 var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
1383 function d3_sgn(x) {
1384 return x > 0 ? 1 : x < 0 ? -1 : 0;
1385 }
1386 function d3_cross2d(a, b, c) {
1387 return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
1388 }
1389 function d3_acos(x) {
1390 return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
1391 }
1392 function d3_asin(x) {
1393 return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x);
1394 }
1395 function d3_sinh(x) {
1396 return ((x = Math.exp(x)) - 1 / x) / 2;
1397 }
1398 function d3_cosh(x) {
1399 return ((x = Math.exp(x)) + 1 / x) / 2;
1400 }
1401 function d3_tanh(x) {
1402 return ((x = Math.exp(2 * x)) - 1) / (x + 1);
1403 }
1404 function d3_haversin(x) {
1405 return (x = Math.sin(x / 2)) * x;
1406 }
1407 var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4;
1408 d3.interpolateZoom = function(p0, p1) {
1409 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;
1410 if (d2 < ε2) {
1411 S = Math.log(w1 / w0) / ρ;
1412 i = function(t) {
1413 return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * t * S) ];
1414 };
1415 } else {
1416 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);
1417 S = (r1 - r0) / ρ;
1418 i = function(t) {
1419 var s = t * S, coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0));
1420 return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ];
1421 };
1422 }
1423 i.duration = S * 1e3;
1424 return i;
1425 };
1426 d3.behavior.zoom = function() {
1427 var view = {
1428 x: 0,
1429 y: 0,
1430 k: 1
1431 }, 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;
1432 if (!d3_behavior_zoomWheel) {
1433 d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() {
1434 return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1);
1435 }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() {
1436 return d3.event.wheelDelta;
1437 }, "mousewheel") : (d3_behavior_zoomDelta = function() {
1438 return -d3.event.detail;
1439 }, "MozMousePixelScroll");
1440 }
1441 function zoom(g) {
1442 g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1443 }
1444 zoom.event = function(g) {
1445 g.each(function() {
1446 var dispatch = event.of(this, arguments), view1 = view;
1447 if (d3_transitionInheritId) {
1448 d3.select(this).transition().each("start.zoom", function() {
1449 view = this.__chart__ || {
1450 x: 0,
1451 y: 0,
1452 k: 1
1453 };
1454 zoomstarted(dispatch);
1455 }).tween("zoom:zoom", function() {
1456 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 ]);
1457 return function(t) {
1458 var l = i(t), k = dx / l[2];
1459 this.__chart__ = view = {
1460 x: cx - l[0] * k,
1461 y: cy - l[1] * k,
1462 k: k
1463 };
1464 zoomed(dispatch);
1465 };
1466 }).each("interrupt.zoom", function() {
1467 zoomended(dispatch);
1468 }).each("end.zoom", function() {
1469 zoomended(dispatch);
1470 });
1471 } else {
1472 this.__chart__ = view;
1473 zoomstarted(dispatch);
1474 zoomed(dispatch);
1475 zoomended(dispatch);
1476 }
1477 });
1478 };
1479 zoom.translate = function(_) {
1480 if (!arguments.length) return [ view.x, view.y ];
1481 view = {
1482 x: +_[0],
1483 y: +_[1],
1484 k: view.k
1485 };
1486 rescale();
1487 return zoom;
1488 };
1489 zoom.scale = function(_) {
1490 if (!arguments.length) return view.k;
1491 view = {
1492 x: view.x,
1493 y: view.y,
1494 k: null
1495 };
1496 scaleTo(+_);
1497 rescale();
1498 return zoom;
1499 };
1500 zoom.scaleExtent = function(_) {
1501 if (!arguments.length) return scaleExtent;
1502 scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ];
1503 return zoom;
1504 };
1505 zoom.center = function(_) {
1506 if (!arguments.length) return center;
1507 center = _ && [ +_[0], +_[1] ];
1508 return zoom;
1509 };
1510 zoom.size = function(_) {
1511 if (!arguments.length) return size;
1512 size = _ && [ +_[0], +_[1] ];
1513 return zoom;
1514 };
1515 zoom.duration = function(_) {
1516 if (!arguments.length) return duration;
1517 duration = +_;
1518 return zoom;
1519 };
1520 zoom.x = function(z) {
1521 if (!arguments.length) return x1;
1522 x1 = z;
1523 x0 = z.copy();
1524 view = {
1525 x: 0,
1526 y: 0,
1527 k: 1
1528 };
1529 return zoom;
1530 };
1531 zoom.y = function(z) {
1532 if (!arguments.length) return y1;
1533 y1 = z;
1534 y0 = z.copy();
1535 view = {
1536 x: 0,
1537 y: 0,
1538 k: 1
1539 };
1540 return zoom;
1541 };
1542 function location(p) {
1543 return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ];
1544 }
1545 function point(l) {
1546 return [ l[0] * view.k + view.x, l[1] * view.k + view.y ];
1547 }
1548 function scaleTo(s) {
1549 view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
1550 }
1551 function translateTo(p, l) {
1552 l = point(l);
1553 view.x += p[0] - l[0];
1554 view.y += p[1] - l[1];
1555 }
1556 function zoomTo(that, p, l, k) {
1557 that.__chart__ = {
1558 x: view.x,
1559 y: view.y,
1560 k: view.k
1561 };
1562 scaleTo(Math.pow(2, k));
1563 translateTo(center0 = p, l);
1564 that = d3.select(that);
1565 if (duration > 0) that = that.transition().duration(duration);
1566 that.call(zoom.event);
1567 }
1568 function rescale() {
1569 if (x1) x1.domain(x0.range().map(function(x) {
1570 return (x - view.x) / view.k;
1571 }).map(x0.invert));
1572 if (y1) y1.domain(y0.range().map(function(y) {
1573 return (y - view.y) / view.k;
1574 }).map(y0.invert));
1575 }
1576 function zoomstarted(dispatch) {
1577 if (!zooming++) dispatch({
1578 type: "zoomstart"
1579 });
1580 }
1581 function zoomed(dispatch) {
1582 rescale();
1583 dispatch({
1584 type: "zoom",
1585 scale: view.k,
1586 translate: [ view.x, view.y ]
1587 });
1588 }
1589 function zoomended(dispatch) {
1590 if (!--zooming) dispatch({
1591 type: "zoomend"
1592 }), center0 = null;
1593 }
1594 function mousedowned() {
1595 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);
1596 d3_selection_interrupt.call(that);
1597 zoomstarted(dispatch);
1598 function moved() {
1599 dragged = 1;
1600 translateTo(d3.mouse(that), location0);
1601 zoomed(dispatch);
1602 }
1603 function ended() {
1604 subject.on(mousemove, null).on(mouseup, null);
1605 dragRestore(dragged);
1606 zoomended(dispatch);
1607 }
1608 }
1609 function touchstarted() {
1610 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);
1611 started();
1612 zoomstarted(dispatch);
1613 subject.on(mousedown, null).on(touchstart, started);
1614 function relocate() {
1615 var touches = d3.touches(that);
1616 scale0 = view.k;
1617 touches.forEach(function(t) {
1618 if (t.identifier in locations0) locations0[t.identifier] = location(t);
1619 });
1620 return touches;
1621 }
1622 function started() {
1623 var target = d3.event.target;
1624 d3.select(target).on(touchmove, moved).on(touchend, ended);
1625 targets.push(target);
1626 var changed = d3.event.changedTouches;
1627 for (var i = 0, n = changed.length; i < n; ++i) {
1628 locations0[changed[i].identifier] = null;
1629 }
1630 var touches = relocate(), now = Date.now();
1631 if (touches.length === 1) {
1632 if (now - touchtime < 500) {
1633 var p = touches[0];
1634 zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);
1635 d3_eventPreventDefault();
1636 }
1637 touchtime = now;
1638 } else if (touches.length > 1) {
1639 var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];
1640 distance0 = dx * dx + dy * dy;
1641 }
1642 }
1643 function moved() {
1644 var touches = d3.touches(that), p0, l0, p1, l1;
1645 d3_selection_interrupt.call(that);
1646 for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {
1647 p1 = touches[i];
1648 if (l1 = locations0[p1.identifier]) {
1649 if (l0) break;
1650 p0 = p1, l0 = l1;
1651 }
1652 }
1653 if (l1) {
1654 var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0);
1655 p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];
1656 l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];
1657 scaleTo(scale1 * scale0);
1658 }
1659 touchtime = null;
1660 translateTo(p0, l0);
1661 zoomed(dispatch);
1662 }
1663 function ended() {
1664 if (d3.event.touches.length) {
1665 var changed = d3.event.changedTouches;
1666 for (var i = 0, n = changed.length; i < n; ++i) {
1667 delete locations0[changed[i].identifier];
1668 }
1669 for (var identifier in locations0) {
1670 return void relocate();
1671 }
1672 }
1673 d3.selectAll(targets).on(zoomName, null);
1674 subject.on(mousedown, mousedowned).on(touchstart, touchstarted);
1675 dragRestore();
1676 zoomended(dispatch);
1677 }
1678 }
1679 function mousewheeled() {
1680 var dispatch = event.of(this, arguments);
1681 if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this),
1682 translate0 = location(center0 = center || d3.mouse(this)), zoomstarted(dispatch);
1683 mousewheelTimer = setTimeout(function() {
1684 mousewheelTimer = null;
1685 zoomended(dispatch);
1686 }, 50);
1687 d3_eventPreventDefault();
1688 scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);
1689 translateTo(center0, translate0);
1690 zoomed(dispatch);
1691 }
1692 function dblclicked() {
1693 var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2;
1694 zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1);
1695 }
1696 return d3.rebind(zoom, event, "on");
1697 };
1698 var d3_behavior_zoomInfinity = [ 0, Infinity ], d3_behavior_zoomDelta, d3_behavior_zoomWheel;
1699 d3.color = d3_color;
1700 function d3_color() {}
1701 d3_color.prototype.toString = function() {
1702 return this.rgb() + "";
1703 };
1704 d3.hsl = d3_hsl;
1705 function d3_hsl(h, s, l) {
1706 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);
1707 }
1708 var d3_hslPrototype = d3_hsl.prototype = new d3_color();
1709 d3_hslPrototype.brighter = function(k) {
1710 k = Math.pow(.7, arguments.length ? k : 1);
1711 return new d3_hsl(this.h, this.s, this.l / k);
1712 };
1713 d3_hslPrototype.darker = function(k) {
1714 k = Math.pow(.7, arguments.length ? k : 1);
1715 return new d3_hsl(this.h, this.s, k * this.l);
1716 };
1717 d3_hslPrototype.rgb = function() {
1718 return d3_hsl_rgb(this.h, this.s, this.l);
1719 };
1720 function d3_hsl_rgb(h, s, l) {
1721 var m1, m2;
1722 h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;
1723 s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;
1724 l = l < 0 ? 0 : l > 1 ? 1 : l;
1725 m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
1726 m1 = 2 * l - m2;
1727 function v(h) {
1728 if (h > 360) h -= 360; else if (h < 0) h += 360;
1729 if (h < 60) return m1 + (m2 - m1) * h / 60;
1730 if (h < 180) return m2;
1731 if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
1732 return m1;
1733 }
1734 function vv(h) {
1735 return Math.round(v(h) * 255);
1736 }
1737 return new d3_rgb(vv(h + 120), vv(h), vv(h - 120));
1738 }
1739 d3.hcl = d3_hcl;
1740 function d3_hcl(h, c, l) {
1741 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);
1742 }
1743 var d3_hclPrototype = d3_hcl.prototype = new d3_color();
1744 d3_hclPrototype.brighter = function(k) {
1745 return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));
1746 };
1747 d3_hclPrototype.darker = function(k) {
1748 return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));
1749 };
1750 d3_hclPrototype.rgb = function() {
1751 return d3_hcl_lab(this.h, this.c, this.l).rgb();
1752 };
1753 function d3_hcl_lab(h, c, l) {
1754 if (isNaN(h)) h = 0;
1755 if (isNaN(c)) c = 0;
1756 return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);
1757 }
1758 d3.lab = d3_lab;
1759 function d3_lab(l, a, b) {
1760 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);
1761 }
1762 var d3_lab_K = 18;
1763 var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;
1764 var d3_labPrototype = d3_lab.prototype = new d3_color();
1765 d3_labPrototype.brighter = function(k) {
1766 return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1767 };
1768 d3_labPrototype.darker = function(k) {
1769 return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1770 };
1771 d3_labPrototype.rgb = function() {
1772 return d3_lab_rgb(this.l, this.a, this.b);
1773 };
1774 function d3_lab_rgb(l, a, b) {
1775 var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;
1776 x = d3_lab_xyz(x) * d3_lab_X;
1777 y = d3_lab_xyz(y) * d3_lab_Y;
1778 z = d3_lab_xyz(z) * d3_lab_Z;
1779 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));
1780 }
1781 function d3_lab_hcl(l, a, b) {
1782 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);
1783 }
1784 function d3_lab_xyz(x) {
1785 return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
1786 }
1787 function d3_xyz_lab(x) {
1788 return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;
1789 }
1790 function d3_xyz_rgb(r) {
1791 return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));
1792 }
1793 d3.rgb = d3_rgb;
1794 function d3_rgb(r, g, b) {
1795 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);
1796 }
1797 function d3_rgbNumber(value) {
1798 return new d3_rgb(value >> 16, value >> 8 & 255, value & 255);
1799 }
1800 function d3_rgbString(value) {
1801 return d3_rgbNumber(value) + "";
1802 }
1803 var d3_rgbPrototype = d3_rgb.prototype = new d3_color();
1804 d3_rgbPrototype.brighter = function(k) {
1805 k = Math.pow(.7, arguments.length ? k : 1);
1806 var r = this.r, g = this.g, b = this.b, i = 30;
1807 if (!r && !g && !b) return new d3_rgb(i, i, i);
1808 if (r && r < i) r = i;
1809 if (g && g < i) g = i;
1810 if (b && b < i) b = i;
1811 return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k));
1812 };
1813 d3_rgbPrototype.darker = function(k) {
1814 k = Math.pow(.7, arguments.length ? k : 1);
1815 return new d3_rgb(k * this.r, k * this.g, k * this.b);
1816 };
1817 d3_rgbPrototype.hsl = function() {
1818 return d3_rgb_hsl(this.r, this.g, this.b);
1819 };
1820 d3_rgbPrototype.toString = function() {
1821 return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);
1822 };
1823 function d3_rgb_hex(v) {
1824 return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);
1825 }
1826 function d3_rgb_parse(format, rgb, hsl) {
1827 var r = 0, g = 0, b = 0, m1, m2, color;
1828 m1 = /([a-z]+)\((.*)\)/.exec(format = format.toLowerCase());
1829 if (m1) {
1830 m2 = m1[2].split(",");
1831 switch (m1[1]) {
1832 case "hsl":
1833 {
1834 return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);
1835 }
1836
1837 case "rgb":
1838 {
1839 return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));
1840 }
1841 }
1842 }
1843 if (color = d3_rgb_names.get(format)) {
1844 return rgb(color.r, color.g, color.b);
1845 }
1846 if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) {
1847 if (format.length === 4) {
1848 r = (color & 3840) >> 4;
1849 r = r >> 4 | r;
1850 g = color & 240;
1851 g = g >> 4 | g;
1852 b = color & 15;
1853 b = b << 4 | b;
1854 } else if (format.length === 7) {
1855 r = (color & 16711680) >> 16;
1856 g = (color & 65280) >> 8;
1857 b = color & 255;
1858 }
1859 }
1860 return rgb(r, g, b);
1861 }
1862 function d3_rgb_hsl(r, g, b) {
1863 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;
1864 if (d) {
1865 s = l < .5 ? d / (max + min) : d / (2 - max - min);
1866 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;
1867 h *= 60;
1868 } else {
1869 h = NaN;
1870 s = l > 0 && l < 1 ? 0 : h;
1871 }
1872 return new d3_hsl(h, s, l);
1873 }
1874 function d3_rgb_lab(r, g, b) {
1875 r = d3_rgb_xyz(r);
1876 g = d3_rgb_xyz(g);
1877 b = d3_rgb_xyz(b);
1878 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);
1879 return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z));
1880 }
1881 function d3_rgb_xyz(r) {
1882 return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4);
1883 }
1884 function d3_rgb_parseNumber(c) {
1885 var f = parseFloat(c);
1886 return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f;
1887 }
1888 var d3_rgb_names = d3.map({
1889 aliceblue: 15792383,
1890 antiquewhite: 16444375,
1891 aqua: 65535,
1892 aquamarine: 8388564,
1893 azure: 15794175,
1894 beige: 16119260,
1895 bisque: 16770244,
1896 black: 0,
1897 blanchedalmond: 16772045,
1898 blue: 255,
1899 blueviolet: 9055202,
1900 brown: 10824234,
1901 burlywood: 14596231,
1902 cadetblue: 6266528,
1903 chartreuse: 8388352,
1904 chocolate: 13789470,
1905 coral: 16744272,
1906 cornflowerblue: 6591981,
1907 cornsilk: 16775388,
1908 crimson: 14423100,
1909 cyan: 65535,
1910 darkblue: 139,
1911 darkcyan: 35723,
1912 darkgoldenrod: 12092939,
1913 darkgray: 11119017,
1914 darkgreen: 25600,
1915 darkgrey: 11119017,
1916 darkkhaki: 12433259,
1917 darkmagenta: 9109643,
1918 darkolivegreen: 5597999,
1919 darkorange: 16747520,
1920 darkorchid: 10040012,
1921 darkred: 9109504,
1922 darksalmon: 15308410,
1923 darkseagreen: 9419919,
1924 darkslateblue: 4734347,
1925 darkslategray: 3100495,
1926 darkslategrey: 3100495,
1927 darkturquoise: 52945,
1928 darkviolet: 9699539,
1929 deeppink: 16716947,
1930 deepskyblue: 49151,
1931 dimgray: 6908265,
1932 dimgrey: 6908265,
1933 dodgerblue: 2003199,
1934 firebrick: 11674146,
1935 floralwhite: 16775920,
1936 forestgreen: 2263842,
1937 fuchsia: 16711935,
1938 gainsboro: 14474460,
1939 ghostwhite: 16316671,
1940 gold: 16766720,
1941 goldenrod: 14329120,
1942 gray: 8421504,
1943 green: 32768,
1944 greenyellow: 11403055,
1945 grey: 8421504,
1946 honeydew: 15794160,
1947 hotpink: 16738740,
1948 indianred: 13458524,
1949 indigo: 4915330,
1950 ivory: 16777200,
1951 khaki: 15787660,
1952 lavender: 15132410,
1953 lavenderblush: 16773365,
1954 lawngreen: 8190976,
1955 lemonchiffon: 16775885,
1956 lightblue: 11393254,
1957 lightcoral: 15761536,
1958 lightcyan: 14745599,
1959 lightgoldenrodyellow: 16448210,
1960 lightgray: 13882323,
1961 lightgreen: 9498256,
1962 lightgrey: 13882323,
1963 lightpink: 16758465,
1964 lightsalmon: 16752762,
1965 lightseagreen: 2142890,
1966 lightskyblue: 8900346,
1967 lightslategray: 7833753,
1968 lightslategrey: 7833753,
1969 lightsteelblue: 11584734,
1970 lightyellow: 16777184,
1971 lime: 65280,
1972 limegreen: 3329330,
1973 linen: 16445670,
1974 magenta: 16711935,
1975 maroon: 8388608,
1976 mediumaquamarine: 6737322,
1977 mediumblue: 205,
1978 mediumorchid: 12211667,
1979 mediumpurple: 9662683,
1980 mediumseagreen: 3978097,
1981 mediumslateblue: 8087790,
1982 mediumspringgreen: 64154,
1983 mediumturquoise: 4772300,
1984 mediumvioletred: 13047173,
1985 midnightblue: 1644912,
1986 mintcream: 16121850,
1987 mistyrose: 16770273,
1988 moccasin: 16770229,
1989 navajowhite: 16768685,
1990 navy: 128,
1991 oldlace: 16643558,
1992 olive: 8421376,
1993 olivedrab: 7048739,
1994 orange: 16753920,
1995 orangered: 16729344,
1996 orchid: 14315734,
1997 palegoldenrod: 15657130,
1998 palegreen: 10025880,
1999 paleturquoise: 11529966,
2000 palevioletred: 14381203,
2001 papayawhip: 16773077,
2002 peachpuff: 16767673,
2003 peru: 13468991,
2004 pink: 16761035,
2005 plum: 14524637,
2006 powderblue: 11591910,
2007 purple: 8388736,
2008 rebeccapurple: 6697881,
2009 red: 16711680,
2010 rosybrown: 12357519,
2011 royalblue: 4286945,
2012 saddlebrown: 9127187,
2013 salmon: 16416882,
2014 sandybrown: 16032864,
2015 seagreen: 3050327,
2016 seashell: 16774638,
2017 sienna: 10506797,
2018 silver: 12632256,
2019 skyblue: 8900331,
2020 slateblue: 6970061,
2021 slategray: 7372944,
2022 slategrey: 7372944,
2023 snow: 16775930,
2024 springgreen: 65407,
2025 steelblue: 4620980,
2026 tan: 13808780,
2027 teal: 32896,
2028 thistle: 14204888,
2029 tomato: 16737095,
2030 turquoise: 4251856,
2031 violet: 15631086,
2032 wheat: 16113331,
2033 white: 16777215,
2034 whitesmoke: 16119285,
2035 yellow: 16776960,
2036 yellowgreen: 10145074
2037 });
2038 d3_rgb_names.forEach(function(key, value) {
2039 d3_rgb_names.set(key, d3_rgbNumber(value));
2040 });
2041 function d3_functor(v) {
2042 return typeof v === "function" ? v : function() {
2043 return v;
2044 };
2045 }
2046 d3.functor = d3_functor;
2047 d3.xhr = d3_xhrType(d3_identity);
2048 function d3_xhrType(response) {
2049 return function(url, mimeType, callback) {
2050 if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType,
2051 mimeType = null;
2052 return d3_xhr(url, mimeType, response, callback);
2053 };
2054 }
2055 function d3_xhr(url, mimeType, response, callback) {
2056 var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null;
2057 if (this.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest();
2058 "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {
2059 request.readyState > 3 && respond();
2060 };
2061 function respond() {
2062 var status = request.status, result;
2063 if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) {
2064 try {
2065 result = response.call(xhr, request);
2066 } catch (e) {
2067 dispatch.error.call(xhr, e);
2068 return;
2069 }
2070 dispatch.load.call(xhr, result);
2071 } else {
2072 dispatch.error.call(xhr, request);
2073 }
2074 }
2075 request.onprogress = function(event) {
2076 var o = d3.event;
2077 d3.event = event;
2078 try {
2079 dispatch.progress.call(xhr, request);
2080 } finally {
2081 d3.event = o;
2082 }
2083 };
2084 xhr.header = function(name, value) {
2085 name = (name + "").toLowerCase();
2086 if (arguments.length < 2) return headers[name];
2087 if (value == null) delete headers[name]; else headers[name] = value + "";
2088 return xhr;
2089 };
2090 xhr.mimeType = function(value) {
2091 if (!arguments.length) return mimeType;
2092 mimeType = value == null ? null : value + "";
2093 return xhr;
2094 };
2095 xhr.responseType = function(value) {
2096 if (!arguments.length) return responseType;
2097 responseType = value;
2098 return xhr;
2099 };
2100 xhr.response = function(value) {
2101 response = value;
2102 return xhr;
2103 };
2104 [ "get", "post" ].forEach(function(method) {
2105 xhr[method] = function() {
2106 return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments)));
2107 };
2108 });
2109 xhr.send = function(method, data, callback) {
2110 if (arguments.length === 2 && typeof data === "function") callback = data, data = null;
2111 request.open(method, url, true);
2112 if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*";
2113 if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]);
2114 if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType);
2115 if (responseType != null) request.responseType = responseType;
2116 if (callback != null) xhr.on("error", callback).on("load", function(request) {
2117 callback(null, request);
2118 });
2119 dispatch.beforesend.call(xhr, request);
2120 request.send(data == null ? null : data);
2121 return xhr;
2122 };
2123 xhr.abort = function() {
2124 request.abort();
2125 return xhr;
2126 };
2127 d3.rebind(xhr, dispatch, "on");
2128 return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));
2129 }
2130 function d3_xhr_fixCallback(callback) {
2131 return callback.length === 1 ? function(error, request) {
2132 callback(error == null ? request : null);
2133 } : callback;
2134 }
2135 function d3_xhrHasResponse(request) {
2136 var type = request.responseType;
2137 return type && type !== "text" ? request.response : request.responseText;
2138 }
2139 d3.dsv = function(delimiter, mimeType) {
2140 var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0);
2141 function dsv(url, row, callback) {
2142 if (arguments.length < 3) callback = row, row = null;
2143 var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback);
2144 xhr.row = function(_) {
2145 return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row;
2146 };
2147 return xhr;
2148 }
2149 function response(request) {
2150 return dsv.parse(request.responseText);
2151 }
2152 function typedResponse(f) {
2153 return function(request) {
2154 return dsv.parse(request.responseText, f);
2155 };
2156 }
2157 dsv.parse = function(text, f) {
2158 var o;
2159 return dsv.parseRows(text, function(row, i) {
2160 if (o) return o(row, i - 1);
2161 var a = new Function("d", "return {" + row.map(function(name, i) {
2162 return JSON.stringify(name) + ": d[" + i + "]";
2163 }).join(",") + "}");
2164 o = f ? function(row, i) {
2165 return f(a(row), i);
2166 } : a;
2167 });
2168 };
2169 dsv.parseRows = function(text, f) {
2170 var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol;
2171 function token() {
2172 if (I >= N) return EOF;
2173 if (eol) return eol = false, EOL;
2174 var j = I;
2175 if (text.charCodeAt(j) === 34) {
2176 var i = j;
2177 while (i++ < N) {
2178 if (text.charCodeAt(i) === 34) {
2179 if (text.charCodeAt(i + 1) !== 34) break;
2180 ++i;
2181 }
2182 }
2183 I = i + 2;
2184 var c = text.charCodeAt(i + 1);
2185 if (c === 13) {
2186 eol = true;
2187 if (text.charCodeAt(i + 2) === 10) ++I;
2188 } else if (c === 10) {
2189 eol = true;
2190 }
2191 return text.slice(j + 1, i).replace(/""/g, '"');
2192 }
2193 while (I < N) {
2194 var c = text.charCodeAt(I++), k = 1;
2195 if (c === 10) eol = true; else if (c === 13) {
2196 eol = true;
2197 if (text.charCodeAt(I) === 10) ++I, ++k;
2198 } else if (c !== delimiterCode) continue;
2199 return text.slice(j, I - k);
2200 }
2201 return text.slice(j);
2202 }
2203 while ((t = token()) !== EOF) {
2204 var a = [];
2205 while (t !== EOL && t !== EOF) {
2206 a.push(t);
2207 t = token();
2208 }
2209 if (f && (a = f(a, n++)) == null) continue;
2210 rows.push(a);
2211 }
2212 return rows;
2213 };
2214 dsv.format = function(rows) {
2215 if (Array.isArray(rows[0])) return dsv.formatRows(rows);
2216 var fieldSet = new d3_Set(), fields = [];
2217 rows.forEach(function(row) {
2218 for (var field in row) {
2219 if (!fieldSet.has(field)) {
2220 fields.push(fieldSet.add(field));
2221 }
2222 }
2223 });
2224 return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) {
2225 return fields.map(function(field) {
2226 return formatValue(row[field]);
2227 }).join(delimiter);
2228 })).join("\n");
2229 };
2230 dsv.formatRows = function(rows) {
2231 return rows.map(formatRow).join("\n");
2232 };
2233 function formatRow(row) {
2234 return row.map(formatValue).join(delimiter);
2235 }
2236 function formatValue(text) {
2237 return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text;
2238 }
2239 return dsv;
2240 };
2241 d3.csv = d3.dsv(",", "text/csv");
2242 d3.tsv = d3.dsv(" ", "text/tab-separated-values");
2243 var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_frame = this[d3_vendorSymbol(this, "requestAnimationFrame")] || function(callback) {
2244 setTimeout(callback, 17);
2245 };
2246 d3.timer = function() {
2247 d3_timer.apply(this, arguments);
2248 };
2249 function d3_timer(callback, delay, then) {
2250 var n = arguments.length;
2251 if (n < 2) delay = 0;
2252 if (n < 3) then = Date.now();
2253 var time = then + delay, timer = {
2254 c: callback,
2255 t: time,
2256 n: null
2257 };
2258 if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer;
2259 d3_timer_queueTail = timer;
2260 if (!d3_timer_interval) {
2261 d3_timer_timeout = clearTimeout(d3_timer_timeout);
2262 d3_timer_interval = 1;
2263 d3_timer_frame(d3_timer_step);
2264 }
2265 return timer;
2266 }
2267 function d3_timer_step() {
2268 var now = d3_timer_mark(), delay = d3_timer_sweep() - now;
2269 if (delay > 24) {
2270 if (isFinite(delay)) {
2271 clearTimeout(d3_timer_timeout);
2272 d3_timer_timeout = setTimeout(d3_timer_step, delay);
2273 }
2274 d3_timer_interval = 0;
2275 } else {
2276 d3_timer_interval = 1;
2277 d3_timer_frame(d3_timer_step);
2278 }
2279 }
2280 d3.timer.flush = function() {
2281 d3_timer_mark();
2282 d3_timer_sweep();
2283 };
2284 function d3_timer_mark() {
2285 var now = Date.now(), timer = d3_timer_queueHead;
2286 while (timer) {
2287 if (now >= timer.t && timer.c(now - timer.t)) timer.c = null;
2288 timer = timer.n;
2289 }
2290 return now;
2291 }
2292 function d3_timer_sweep() {
2293 var t0, t1 = d3_timer_queueHead, time = Infinity;
2294 while (t1) {
2295 if (t1.c) {
2296 if (t1.t < time) time = t1.t;
2297 t1 = (t0 = t1).n;
2298 } else {
2299 t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n;
2300 }
2301 }
2302 d3_timer_queueTail = t0;
2303 return time;
2304 }
2305 function d3_format_precision(x, p) {
2306 return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1);
2307 }
2308 d3.round = function(x, n) {
2309 return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);
2310 };
2311 var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix);
2312 d3.formatPrefix = function(value, precision) {
2313 var i = 0;
2314 if (value = +value) {
2315 if (value < 0) value *= -1;
2316 if (precision) value = d3.round(value, d3_format_precision(value, precision));
2317 i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
2318 i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3));
2319 }
2320 return d3_formatPrefixes[8 + i / 3];
2321 };
2322 function d3_formatPrefix(d, i) {
2323 var k = Math.pow(10, abs(8 - i) * 3);
2324 return {
2325 scale: i > 8 ? function(d) {
2326 return d / k;
2327 } : function(d) {
2328 return d * k;
2329 },
2330 symbol: d
2331 };
2332 }
2333 function d3_locale_numberFormat(locale) {
2334 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) {
2335 var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0;
2336 while (i > 0 && g > 0) {
2337 if (length + g + 1 > width) g = Math.max(1, width - length);
2338 t.push(value.substring(i -= g, i + g));
2339 if ((length += g + 1) > width) break;
2340 g = locale_grouping[j = (j + 1) % locale_grouping.length];
2341 }
2342 return t.reverse().join(locale_thousands);
2343 } : d3_identity;
2344 return function(specifier) {
2345 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;
2346 if (precision) precision = +precision.substring(1);
2347 if (zfill || fill === "0" && align === "=") {
2348 zfill = fill = "0";
2349 align = "=";
2350 }
2351 switch (type) {
2352 case "n":
2353 comma = true;
2354 type = "g";
2355 break;
2356
2357 case "%":
2358 scale = 100;
2359 suffix = "%";
2360 type = "f";
2361 break;
2362
2363 case "p":
2364 scale = 100;
2365 suffix = "%";
2366 type = "r";
2367 break;
2368
2369 case "b":
2370 case "o":
2371 case "x":
2372 case "X":
2373 if (symbol === "#") prefix = "0" + type.toLowerCase();
2374
2375 case "c":
2376 exponent = false;
2377
2378 case "d":
2379 integer = true;
2380 precision = 0;
2381 break;
2382
2383 case "s":
2384 scale = -1;
2385 type = "r";
2386 break;
2387 }
2388 if (symbol === "$") prefix = locale_currency[0], suffix = locale_currency[1];
2389 if (type == "r" && !precision) type = "g";
2390 if (precision != null) {
2391 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));
2392 }
2393 type = d3_format_types.get(type) || d3_format_typeDefault;
2394 var zcomma = zfill && comma;
2395 return function(value) {
2396 var fullSuffix = suffix;
2397 if (integer && value % 1) return "";
2398 var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign === "-" ? "" : sign;
2399 if (scale < 0) {
2400 var unit = d3.formatPrefix(value, precision);
2401 value = unit.scale(value);
2402 fullSuffix = unit.symbol + suffix;
2403 } else {
2404 value *= scale;
2405 }
2406 value = type(value, precision);
2407 var i = value.lastIndexOf("."), before, after;
2408 if (i < 0) {
2409 var j = exponent ? value.lastIndexOf("e") : -1;
2410 if (j < 0) before = value, after = ""; else before = value.substring(0, j), after = value.substring(j);
2411 } else {
2412 before = value.substring(0, i);
2413 after = locale_decimal + value.substring(i + 1);
2414 }
2415 if (!zfill && comma) before = formatGroup(before, Infinity);
2416 var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : "";
2417 if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity);
2418 negative += prefix;
2419 value = before + after;
2420 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;
2421 };
2422 };
2423 }
2424 var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i;
2425 var d3_format_types = d3.map({
2426 b: function(x) {
2427 return x.toString(2);
2428 },
2429 c: function(x) {
2430 return String.fromCharCode(x);
2431 },
2432 o: function(x) {
2433 return x.toString(8);
2434 },
2435 x: function(x) {
2436 return x.toString(16);
2437 },
2438 X: function(x) {
2439 return x.toString(16).toUpperCase();
2440 },
2441 g: function(x, p) {
2442 return x.toPrecision(p);
2443 },
2444 e: function(x, p) {
2445 return x.toExponential(p);
2446 },
2447 f: function(x, p) {
2448 return x.toFixed(p);
2449 },
2450 r: function(x, p) {
2451 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))));
2452 }
2453 });
2454 function d3_format_typeDefault(x) {
2455 return x + "";
2456 }
2457 var d3_time = d3.time = {}, d3_date = Date;
2458 function d3_date_utc() {
2459 this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);
2460 }
2461 d3_date_utc.prototype = {
2462 getDate: function() {
2463 return this._.getUTCDate();
2464 },
2465 getDay: function() {
2466 return this._.getUTCDay();
2467 },
2468 getFullYear: function() {
2469 return this._.getUTCFullYear();
2470 },
2471 getHours: function() {
2472 return this._.getUTCHours();
2473 },
2474 getMilliseconds: function() {
2475 return this._.getUTCMilliseconds();
2476 },
2477 getMinutes: function() {
2478 return this._.getUTCMinutes();
2479 },
2480 getMonth: function() {
2481 return this._.getUTCMonth();
2482 },
2483 getSeconds: function() {
2484 return this._.getUTCSeconds();
2485 },
2486 getTime: function() {
2487 return this._.getTime();
2488 },
2489 getTimezoneOffset: function() {
2490 return 0;
2491 },
2492 valueOf: function() {
2493 return this._.valueOf();
2494 },
2495 setDate: function() {
2496 d3_time_prototype.setUTCDate.apply(this._, arguments);
2497 },
2498 setDay: function() {
2499 d3_time_prototype.setUTCDay.apply(this._, arguments);
2500 },
2501 setFullYear: function() {
2502 d3_time_prototype.setUTCFullYear.apply(this._, arguments);
2503 },
2504 setHours: function() {
2505 d3_time_prototype.setUTCHours.apply(this._, arguments);
2506 },
2507 setMilliseconds: function() {
2508 d3_time_prototype.setUTCMilliseconds.apply(this._, arguments);
2509 },
2510 setMinutes: function() {
2511 d3_time_prototype.setUTCMinutes.apply(this._, arguments);
2512 },
2513 setMonth: function() {
2514 d3_time_prototype.setUTCMonth.apply(this._, arguments);
2515 },
2516 setSeconds: function() {
2517 d3_time_prototype.setUTCSeconds.apply(this._, arguments);
2518 },
2519 setTime: function() {
2520 d3_time_prototype.setTime.apply(this._, arguments);
2521 }
2522 };
2523 var d3_time_prototype = Date.prototype;
2524 function d3_time_interval(local, step, number) {
2525 function round(date) {
2526 var d0 = local(date), d1 = offset(d0, 1);
2527 return date - d0 < d1 - date ? d0 : d1;
2528 }
2529 function ceil(date) {
2530 step(date = local(new d3_date(date - 1)), 1);
2531 return date;
2532 }
2533 function offset(date, k) {
2534 step(date = new d3_date(+date), k);
2535 return date;
2536 }
2537 function range(t0, t1, dt) {
2538 var time = ceil(t0), times = [];
2539 if (dt > 1) {
2540 while (time < t1) {
2541 if (!(number(time) % dt)) times.push(new Date(+time));
2542 step(time, 1);
2543 }
2544 } else {
2545 while (time < t1) times.push(new Date(+time)), step(time, 1);
2546 }
2547 return times;
2548 }
2549 function range_utc(t0, t1, dt) {
2550 try {
2551 d3_date = d3_date_utc;
2552 var utc = new d3_date_utc();
2553 utc._ = t0;
2554 return range(utc, t1, dt);
2555 } finally {
2556 d3_date = Date;
2557 }
2558 }
2559 local.floor = local;
2560 local.round = round;
2561 local.ceil = ceil;
2562 local.offset = offset;
2563 local.range = range;
2564 var utc = local.utc = d3_time_interval_utc(local);
2565 utc.floor = utc;
2566 utc.round = d3_time_interval_utc(round);
2567 utc.ceil = d3_time_interval_utc(ceil);
2568 utc.offset = d3_time_interval_utc(offset);
2569 utc.range = range_utc;
2570 return local;
2571 }
2572 function d3_time_interval_utc(method) {
2573 return function(date, k) {
2574 try {
2575 d3_date = d3_date_utc;
2576 var utc = new d3_date_utc();
2577 utc._ = date;
2578 return method(utc, k)._;
2579 } finally {
2580 d3_date = Date;
2581 }
2582 };
2583 }
2584 d3_time.year = d3_time_interval(function(date) {
2585 date = d3_time.day(date);
2586 date.setMonth(0, 1);
2587 return date;
2588 }, function(date, offset) {
2589 date.setFullYear(date.getFullYear() + offset);
2590 }, function(date) {
2591 return date.getFullYear();
2592 });
2593 d3_time.years = d3_time.year.range;
2594 d3_time.years.utc = d3_time.year.utc.range;
2595 d3_time.day = d3_time_interval(function(date) {
2596 var day = new d3_date(2e3, 0);
2597 day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
2598 return day;
2599 }, function(date, offset) {
2600 date.setDate(date.getDate() + offset);
2601 }, function(date) {
2602 return date.getDate() - 1;
2603 });
2604 d3_time.days = d3_time.day.range;
2605 d3_time.days.utc = d3_time.day.utc.range;
2606 d3_time.dayOfYear = function(date) {
2607 var year = d3_time.year(date);
2608 return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);
2609 };
2610 [ "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" ].forEach(function(day, i) {
2611 i = 7 - i;
2612 var interval = d3_time[day] = d3_time_interval(function(date) {
2613 (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
2614 return date;
2615 }, function(date, offset) {
2616 date.setDate(date.getDate() + Math.floor(offset) * 7);
2617 }, function(date) {
2618 var day = d3_time.year(date).getDay();
2619 return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
2620 });
2621 d3_time[day + "s"] = interval.range;
2622 d3_time[day + "s"].utc = interval.utc.range;
2623 d3_time[day + "OfYear"] = function(date) {
2624 var day = d3_time.year(date).getDay();
2625 return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7);
2626 };
2627 });
2628 d3_time.week = d3_time.sunday;
2629 d3_time.weeks = d3_time.sunday.range;
2630 d3_time.weeks.utc = d3_time.sunday.utc.range;
2631 d3_time.weekOfYear = d3_time.sundayOfYear;
2632 function d3_locale_timeFormat(locale) {
2633 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;
2634 function d3_time_format(template) {
2635 var n = template.length;
2636 function format(date) {
2637 var string = [], i = -1, j = 0, c, p, f;
2638 while (++i < n) {
2639 if (template.charCodeAt(i) === 37) {
2640 string.push(template.slice(j, i));
2641 if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i);
2642 if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p);
2643 string.push(c);
2644 j = i + 1;
2645 }
2646 }
2647 string.push(template.slice(j, i));
2648 return string.join("");
2649 }
2650 format.parse = function(string) {
2651 var d = {
2652 y: 1900,
2653 m: 0,
2654 d: 1,
2655 H: 0,
2656 M: 0,
2657 S: 0,
2658 L: 0,
2659 Z: null
2660 }, i = d3_time_parse(d, template, string, 0);
2661 if (i != string.length) return null;
2662 if ("p" in d) d.H = d.H % 12 + d.p * 12;
2663 var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)();
2664 if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("W" in d || "U" in d) {
2665 if (!("w" in d)) d.w = "W" in d ? 1 : 0;
2666 date.setFullYear(d.y, 0, 1);
2667 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);
2668 } else date.setFullYear(d.y, d.m, d.d);
2669 date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L);
2670 return localZ ? date._ : date;
2671 };
2672 format.toString = function() {
2673 return template;
2674 };
2675 return format;
2676 }
2677 function d3_time_parse(date, template, string, j) {
2678 var c, p, t, i = 0, n = template.length, m = string.length;
2679 while (i < n) {
2680 if (j >= m) return -1;
2681 c = template.charCodeAt(i++);
2682 if (c === 37) {
2683 t = template.charAt(i++);
2684 p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t];
2685 if (!p || (j = p(date, string, j)) < 0) return -1;
2686 } else if (c != string.charCodeAt(j++)) {
2687 return -1;
2688 }
2689 }
2690 return j;
2691 }
2692 d3_time_format.utc = function(template) {
2693 var local = d3_time_format(template);
2694 function format(date) {
2695 try {
2696 d3_date = d3_date_utc;
2697 var utc = new d3_date();
2698 utc._ = date;
2699 return local(utc);
2700 } finally {
2701 d3_date = Date;
2702 }
2703 }
2704 format.parse = function(string) {
2705 try {
2706 d3_date = d3_date_utc;
2707 var date = local.parse(string);
2708 return date && date._;
2709 } finally {
2710 d3_date = Date;
2711 }
2712 };
2713 format.toString = local.toString;
2714 return format;
2715 };
2716 d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti;
2717 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);
2718 locale_periods.forEach(function(p, i) {
2719 d3_time_periodLookup.set(p.toLowerCase(), i);
2720 });
2721 var d3_time_formats = {
2722 a: function(d) {
2723 return locale_shortDays[d.getDay()];
2724 },
2725 A: function(d) {
2726 return locale_days[d.getDay()];
2727 },
2728 b: function(d) {
2729 return locale_shortMonths[d.getMonth()];
2730 },
2731 B: function(d) {
2732 return locale_months[d.getMonth()];
2733 },
2734 c: d3_time_format(locale_dateTime),
2735 d: function(d, p) {
2736 return d3_time_formatPad(d.getDate(), p, 2);
2737 },
2738 e: function(d, p) {
2739 return d3_time_formatPad(d.getDate(), p, 2);
2740 },
2741 H: function(d, p) {
2742 return d3_time_formatPad(d.getHours(), p, 2);
2743 },
2744 I: function(d, p) {
2745 return d3_time_formatPad(d.getHours() % 12 || 12, p, 2);
2746 },
2747 j: function(d, p) {
2748 return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3);
2749 },
2750 L: function(d, p) {
2751 return d3_time_formatPad(d.getMilliseconds(), p, 3);
2752 },
2753 m: function(d, p) {
2754 return d3_time_formatPad(d.getMonth() + 1, p, 2);
2755 },
2756 M: function(d, p) {
2757 return d3_time_formatPad(d.getMinutes(), p, 2);
2758 },
2759 p: function(d) {
2760 return locale_periods[+(d.getHours() >= 12)];
2761 },
2762 S: function(d, p) {
2763 return d3_time_formatPad(d.getSeconds(), p, 2);
2764 },
2765 U: function(d, p) {
2766 return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2);
2767 },
2768 w: function(d) {
2769 return d.getDay();
2770 },
2771 W: function(d, p) {
2772 return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2);
2773 },
2774 x: d3_time_format(locale_date),
2775 X: d3_time_format(locale_time),
2776 y: function(d, p) {
2777 return d3_time_formatPad(d.getFullYear() % 100, p, 2);
2778 },
2779 Y: function(d, p) {
2780 return d3_time_formatPad(d.getFullYear() % 1e4, p, 4);
2781 },
2782 Z: d3_time_zone,
2783 "%": function() {
2784 return "%";
2785 }
2786 };
2787 var d3_time_parsers = {
2788 a: d3_time_parseWeekdayAbbrev,
2789 A: d3_time_parseWeekday,
2790 b: d3_time_parseMonthAbbrev,
2791 B: d3_time_parseMonth,
2792 c: d3_time_parseLocaleFull,
2793 d: d3_time_parseDay,
2794 e: d3_time_parseDay,
2795 H: d3_time_parseHour24,
2796 I: d3_time_parseHour24,
2797 j: d3_time_parseDayOfYear,
2798 L: d3_time_parseMilliseconds,
2799 m: d3_time_parseMonthNumber,
2800 M: d3_time_parseMinutes,
2801 p: d3_time_parseAmPm,
2802 S: d3_time_parseSeconds,
2803 U: d3_time_parseWeekNumberSunday,
2804 w: d3_time_parseWeekdayNumber,
2805 W: d3_time_parseWeekNumberMonday,
2806 x: d3_time_parseLocaleDate,
2807 X: d3_time_parseLocaleTime,
2808 y: d3_time_parseYear,
2809 Y: d3_time_parseFullYear,
2810 Z: d3_time_parseZone,
2811 "%": d3_time_parseLiteralPercent
2812 };
2813 function d3_time_parseWeekdayAbbrev(date, string, i) {
2814 d3_time_dayAbbrevRe.lastIndex = 0;
2815 var n = d3_time_dayAbbrevRe.exec(string.slice(i));
2816 return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2817 }
2818 function d3_time_parseWeekday(date, string, i) {
2819 d3_time_dayRe.lastIndex = 0;
2820 var n = d3_time_dayRe.exec(string.slice(i));
2821 return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2822 }
2823 function d3_time_parseMonthAbbrev(date, string, i) {
2824 d3_time_monthAbbrevRe.lastIndex = 0;
2825 var n = d3_time_monthAbbrevRe.exec(string.slice(i));
2826 return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2827 }
2828 function d3_time_parseMonth(date, string, i) {
2829 d3_time_monthRe.lastIndex = 0;
2830 var n = d3_time_monthRe.exec(string.slice(i));
2831 return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2832 }
2833 function d3_time_parseLocaleFull(date, string, i) {
2834 return d3_time_parse(date, d3_time_formats.c.toString(), string, i);
2835 }
2836 function d3_time_parseLocaleDate(date, string, i) {
2837 return d3_time_parse(date, d3_time_formats.x.toString(), string, i);
2838 }
2839 function d3_time_parseLocaleTime(date, string, i) {
2840 return d3_time_parse(date, d3_time_formats.X.toString(), string, i);
2841 }
2842 function d3_time_parseAmPm(date, string, i) {
2843 var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase());
2844 return n == null ? -1 : (date.p = n, i);
2845 }
2846 return d3_time_format;
2847 }
2848 var d3_time_formatPads = {
2849 "-": "",
2850 _: " ",
2851 "0": "0"
2852 }, d3_time_numberRe = /^\s*\d+/, d3_time_percentRe = /^%/;
2853 function d3_time_formatPad(value, fill, width) {
2854 var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length;
2855 return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
2856 }
2857 function d3_time_formatRe(names) {
2858 return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i");
2859 }
2860 function d3_time_formatLookup(names) {
2861 var map = new d3_Map(), i = -1, n = names.length;
2862 while (++i < n) map.set(names[i].toLowerCase(), i);
2863 return map;
2864 }
2865 function d3_time_parseWeekdayNumber(date, string, i) {
2866 d3_time_numberRe.lastIndex = 0;
2867 var n = d3_time_numberRe.exec(string.slice(i, i + 1));
2868 return n ? (date.w = +n[0], i + n[0].length) : -1;
2869 }
2870 function d3_time_parseWeekNumberSunday(date, string, i) {
2871 d3_time_numberRe.lastIndex = 0;
2872 var n = d3_time_numberRe.exec(string.slice(i));
2873 return n ? (date.U = +n[0], i + n[0].length) : -1;
2874 }
2875 function d3_time_parseWeekNumberMonday(date, string, i) {
2876 d3_time_numberRe.lastIndex = 0;
2877 var n = d3_time_numberRe.exec(string.slice(i));
2878 return n ? (date.W = +n[0], i + n[0].length) : -1;
2879 }
2880 function d3_time_parseFullYear(date, string, i) {
2881 d3_time_numberRe.lastIndex = 0;
2882 var n = d3_time_numberRe.exec(string.slice(i, i + 4));
2883 return n ? (date.y = +n[0], i + n[0].length) : -1;
2884 }
2885 function d3_time_parseYear(date, string, i) {
2886 d3_time_numberRe.lastIndex = 0;
2887 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2888 return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;
2889 }
2890 function d3_time_parseZone(date, string, i) {
2891 return /^[+-]\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string,
2892 i + 5) : -1;
2893 }
2894 function d3_time_expandYear(d) {
2895 return d + (d > 68 ? 1900 : 2e3);
2896 }
2897 function d3_time_parseMonthNumber(date, string, i) {
2898 d3_time_numberRe.lastIndex = 0;
2899 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2900 return n ? (date.m = n[0] - 1, i + n[0].length) : -1;
2901 }
2902 function d3_time_parseDay(date, string, i) {
2903 d3_time_numberRe.lastIndex = 0;
2904 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2905 return n ? (date.d = +n[0], i + n[0].length) : -1;
2906 }
2907 function d3_time_parseDayOfYear(date, string, i) {
2908 d3_time_numberRe.lastIndex = 0;
2909 var n = d3_time_numberRe.exec(string.slice(i, i + 3));
2910 return n ? (date.j = +n[0], i + n[0].length) : -1;
2911 }
2912 function d3_time_parseHour24(date, string, i) {
2913 d3_time_numberRe.lastIndex = 0;
2914 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2915 return n ? (date.H = +n[0], i + n[0].length) : -1;
2916 }
2917 function d3_time_parseMinutes(date, string, i) {
2918 d3_time_numberRe.lastIndex = 0;
2919 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2920 return n ? (date.M = +n[0], i + n[0].length) : -1;
2921 }
2922 function d3_time_parseSeconds(date, string, i) {
2923 d3_time_numberRe.lastIndex = 0;
2924 var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2925 return n ? (date.S = +n[0], i + n[0].length) : -1;
2926 }
2927 function d3_time_parseMilliseconds(date, string, i) {
2928 d3_time_numberRe.lastIndex = 0;
2929 var n = d3_time_numberRe.exec(string.slice(i, i + 3));
2930 return n ? (date.L = +n[0], i + n[0].length) : -1;
2931 }
2932 function d3_time_zone(d) {
2933 var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = abs(z) / 60 | 0, zm = abs(z) % 60;
2934 return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2);
2935 }
2936 function d3_time_parseLiteralPercent(date, string, i) {
2937 d3_time_percentRe.lastIndex = 0;
2938 var n = d3_time_percentRe.exec(string.slice(i, i + 1));
2939 return n ? i + n[0].length : -1;
2940 }
2941 function d3_time_formatMulti(formats) {
2942 var n = formats.length, i = -1;
2943 while (++i < n) formats[i][0] = this(formats[i][0]);
2944 return function(date) {
2945 var i = 0, f = formats[i];
2946 while (!f[1](date)) f = formats[++i];
2947 return f[0](date);
2948 };
2949 }
2950 d3.locale = function(locale) {
2951 return {
2952 numberFormat: d3_locale_numberFormat(locale),
2953 timeFormat: d3_locale_timeFormat(locale)
2954 };
2955 };
2956 var d3_locale_enUS = d3.locale({
2957 decimal: ".",
2958 thousands: ",",
2959 grouping: [ 3 ],
2960 currency: [ "$", "" ],
2961 dateTime: "%a %b %e %X %Y",
2962 date: "%m/%d/%Y",
2963 time: "%H:%M:%S",
2964 periods: [ "AM", "PM" ],
2965 days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
2966 shortDays: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
2967 months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
2968 shortMonths: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]
2969 });
2970 d3.format = d3_locale_enUS.numberFormat;
2971 d3.geo = {};
2972 function d3_adder() {}
2973 d3_adder.prototype = {
2974 s: 0,
2975 t: 0,
2976 add: function(y) {
2977 d3_adderSum(y, this.t, d3_adderTemp);
2978 d3_adderSum(d3_adderTemp.s, this.s, this);
2979 if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t;
2980 },
2981 reset: function() {
2982 this.s = this.t = 0;
2983 },
2984 valueOf: function() {
2985 return this.s;
2986 }
2987 };
2988 var d3_adderTemp = new d3_adder();
2989 function d3_adderSum(a, b, o) {
2990 var x = o.s = a + b, bv = x - a, av = x - bv;
2991 o.t = a - av + (b - bv);
2992 }
2993 d3.geo.stream = function(object, listener) {
2994 if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) {
2995 d3_geo_streamObjectType[object.type](object, listener);
2996 } else {
2997 d3_geo_streamGeometry(object, listener);
2998 }
2999 };
3000 function d3_geo_streamGeometry(geometry, listener) {
3001 if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {
3002 d3_geo_streamGeometryType[geometry.type](geometry, listener);
3003 }
3004 }
3005 var d3_geo_streamObjectType = {
3006 Feature: function(feature, listener) {
3007 d3_geo_streamGeometry(feature.geometry, listener);
3008 },
3009 FeatureCollection: function(object, listener) {
3010 var features = object.features, i = -1, n = features.length;
3011 while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);
3012 }
3013 };
3014 var d3_geo_streamGeometryType = {
3015 Sphere: function(object, listener) {
3016 listener.sphere();
3017 },
3018 Point: function(object, listener) {
3019 object = object.coordinates;
3020 listener.point(object[0], object[1], object[2]);
3021 },
3022 MultiPoint: function(object, listener) {
3023 var coordinates = object.coordinates, i = -1, n = coordinates.length;
3024 while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]);
3025 },
3026 LineString: function(object, listener) {
3027 d3_geo_streamLine(object.coordinates, listener, 0);
3028 },
3029 MultiLineString: function(object, listener) {
3030 var coordinates = object.coordinates, i = -1, n = coordinates.length;
3031 while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0);
3032 },
3033 Polygon: function(object, listener) {
3034 d3_geo_streamPolygon(object.coordinates, listener);
3035 },
3036 MultiPolygon: function(object, listener) {
3037 var coordinates = object.coordinates, i = -1, n = coordinates.length;
3038 while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);
3039 },
3040 GeometryCollection: function(object, listener) {
3041 var geometries = object.geometries, i = -1, n = geometries.length;
3042 while (++i < n) d3_geo_streamGeometry(geometries[i], listener);
3043 }
3044 };
3045 function d3_geo_streamLine(coordinates, listener, closed) {
3046 var i = -1, n = coordinates.length - closed, coordinate;
3047 listener.lineStart();
3048 while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]);
3049 listener.lineEnd();
3050 }
3051 function d3_geo_streamPolygon(coordinates, listener) {
3052 var i = -1, n = coordinates.length;
3053 listener.polygonStart();
3054 while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1);
3055 listener.polygonEnd();
3056 }
3057 d3.geo.area = function(object) {
3058 d3_geo_areaSum = 0;
3059 d3.geo.stream(object, d3_geo_area);
3060 return d3_geo_areaSum;
3061 };
3062 var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder();
3063 var d3_geo_area = {
3064 sphere: function() {
3065 d3_geo_areaSum += 4 * π;
3066 },
3067 point: d3_noop,
3068 lineStart: d3_noop,
3069 lineEnd: d3_noop,
3070 polygonStart: function() {
3071 d3_geo_areaRingSum.reset();
3072 d3_geo_area.lineStart = d3_geo_areaRingStart;
3073 },
3074 polygonEnd: function() {
3075 var area = 2 * d3_geo_areaRingSum;
3076 d3_geo_areaSum += area < 0 ? 4 * π + area : area;
3077 d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop;
3078 }
3079 };
3080 function d3_geo_areaRingStart() {
3081 var λ00, φ00, λ0, cosφ0, sinφ0;
3082 d3_geo_area.point = function(λ, φ) {
3083 d3_geo_area.point = nextPoint;
3084 λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4),
3085 sinφ0 = Math.sin(φ);
3086 };
3087 function nextPoint(λ, φ) {
3088 λ *= d3_radians;
3089 φ = φ * d3_radians / 2 + π / 4;
3090 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λ);
3091 d3_geo_areaRingSum.add(Math.atan2(v, u));
3092 λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ;
3093 }
3094 d3_geo_area.lineEnd = function() {
3095 nextPoint(λ00, φ00);
3096 };
3097 }
3098 function d3_geo_cartesian(spherical) {
3099 var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ);
3100 return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ];
3101 }
3102 function d3_geo_cartesianDot(a, b) {
3103 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
3104 }
3105 function d3_geo_cartesianCross(a, b) {
3106 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] ];
3107 }
3108 function d3_geo_cartesianAdd(a, b) {
3109 a[0] += b[0];
3110 a[1] += b[1];
3111 a[2] += b[2];
3112 }
3113 function d3_geo_cartesianScale(vector, k) {
3114 return [ vector[0] * k, vector[1] * k, vector[2] * k ];
3115 }
3116 function d3_geo_cartesianNormalize(d) {
3117 var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
3118 d[0] /= l;
3119 d[1] /= l;
3120 d[2] /= l;
3121 }
3122 function d3_geo_spherical(cartesian) {
3123 return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ];
3124 }
3125 function d3_geo_sphericalEqual(a, b) {
3126 return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε;
3127 }
3128 d3.geo.bounds = function() {
3129 var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range;
3130 var bound = {
3131 point: point,
3132 lineStart: lineStart,
3133 lineEnd: lineEnd,
3134 polygonStart: function() {
3135 bound.point = ringPoint;
3136 bound.lineStart = ringStart;
3137 bound.lineEnd = ringEnd;
3138 dλSum = 0;
3139 d3_geo_area.polygonStart();
3140 },
3141 polygonEnd: function() {
3142 d3_geo_area.polygonEnd();
3143 bound.point = point;
3144 bound.lineStart = lineStart;
3145 bound.lineEnd = lineEnd;
3146 if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90;
3147 range[0] = λ0, range[1] = λ1;
3148 }
3149 };
3150 function point(λ, φ) {
3151 ranges.push(range = [ λ0 = λ, λ1 = λ ]);
3152 if (φ < φ0) φ0 = φ;
3153 if (φ > φ1) φ1 = φ;
3154 }
3155 function linePoint(λ, φ) {
3156 var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]);
3157 if (p0) {
3158 var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal);
3159 d3_geo_cartesianNormalize(inflection);
3160 inflection = d3_geo_spherical(inflection);
3161 var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180;
3162 if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) {
3163 var φi = inflection[1] * d3_degrees;
3164 if (φi > φ1) φ1 = φi;
3165 } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) {
3166 var φi = -inflection[1] * d3_degrees;
3167 if (φi < φ0) φ0 = φi;
3168 } else {
3169 if (φ < φ0) φ0 = φ;
3170 if (φ > φ1) φ1 = φ;
3171 }
3172 if (antimeridian) {
3173 if (λ < λ_) {
3174 if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;
3175 } else {
3176 if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;
3177 }
3178 } else {
3179 if (λ1 >= λ0) {
3180 if (λ < λ0) λ0 = λ;
3181 if (λ > λ1) λ1 = λ;
3182 } else {
3183 if (λ > λ_) {
3184 if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;
3185 } else {
3186 if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;
3187 }
3188 }
3189 }
3190 } else {
3191 point(λ, φ);
3192 }
3193 p0 = p, λ_ = λ;
3194 }
3195 function lineStart() {
3196 bound.point = linePoint;
3197 }
3198 function lineEnd() {
3199 range[0] = λ0, range[1] = λ1;
3200 bound.point = point;
3201 p0 = null;
3202 }
3203 function ringPoint(λ, φ) {
3204 if (p0) {
3205 var dλ = λ - λ_;
3206 dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ;
3207 } else λ__ = λ, φ__ = φ;
3208 d3_geo_area.point(λ, φ);
3209 linePoint(λ, φ);
3210 }
3211 function ringStart() {
3212 d3_geo_area.lineStart();
3213 }
3214 function ringEnd() {
3215 ringPoint(λ__, φ__);
3216 d3_geo_area.lineEnd();
3217 if (abs(dλSum) > ε) λ0 = -(λ1 = 180);
3218 range[0] = λ0, range[1] = λ1;
3219 p0 = null;
3220 }
3221 function angle(λ0, λ1) {
3222 return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1;
3223 }
3224 function compareRanges(a, b) {
3225 return a[0] - b[0];
3226 }
3227 function withinRange(x, range) {
3228 return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;
3229 }
3230 return function(feature) {
3231 φ1 = λ1 = -(λ0 = φ0 = Infinity);
3232 ranges = [];
3233 d3.geo.stream(feature, bound);
3234 var n = ranges.length;
3235 if (n) {
3236 ranges.sort(compareRanges);
3237 for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) {
3238 b = ranges[i];
3239 if (withinRange(b[0], a) || withinRange(b[1], a)) {
3240 if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];
3241 if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];
3242 } else {
3243 merged.push(a = b);
3244 }
3245 }
3246 var best = -Infinity, dλ;
3247 for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) {
3248 b = merged[i];
3249 if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1];
3250 }
3251 }
3252 ranges = range = null;
3253 return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ];
3254 };
3255 }();
3256 d3.geo.centroid = function(object) {
3257 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;
3258 d3.geo.stream(object, d3_geo_centroid);
3259 var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z;
3260 if (m < ε2) {
3261 x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1;
3262 if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0;
3263 m = x * x + y * y + z * z;
3264 if (m < ε2) return [ NaN, NaN ];
3265 }
3266 return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ];
3267 };
3268 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;
3269 var d3_geo_centroid = {
3270 sphere: d3_noop,
3271 point: d3_geo_centroidPoint,
3272 lineStart: d3_geo_centroidLineStart,
3273 lineEnd: d3_geo_centroidLineEnd,
3274 polygonStart: function() {
3275 d3_geo_centroid.lineStart = d3_geo_centroidRingStart;
3276 },
3277 polygonEnd: function() {
3278 d3_geo_centroid.lineStart = d3_geo_centroidLineStart;
3279 }
3280 };
3281 function d3_geo_centroidPoint(λ, φ) {
3282 λ *= d3_radians;
3283 var cosφ = Math.cos(φ *= d3_radians);
3284 d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ));
3285 }
3286 function d3_geo_centroidPointXYZ(x, y, z) {
3287 ++d3_geo_centroidW0;
3288 d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0;
3289 d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0;
3290 d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0;
3291 }
3292 function d3_geo_centroidLineStart() {
3293 var x0, y0, z0;
3294 d3_geo_centroid.point = function(λ, φ) {
3295 λ *= d3_radians;
3296 var cosφ = Math.cos(φ *= d3_radians);
3297 x0 = cosφ * Math.cos(λ);
3298 y0 = cosφ * Math.sin(λ);
3299 z0 = Math.sin(φ);
3300 d3_geo_centroid.point = nextPoint;
3301 d3_geo_centroidPointXYZ(x0, y0, z0);
3302 };
3303 function nextPoint(λ, φ) {
3304 λ *= d3_radians;
3305 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);
3306 d3_geo_centroidW1 += w;
3307 d3_geo_centroidX1 += w * (x0 + (x0 = x));
3308 d3_geo_centroidY1 += w * (y0 + (y0 = y));
3309 d3_geo_centroidZ1 += w * (z0 + (z0 = z));
3310 d3_geo_centroidPointXYZ(x0, y0, z0);
3311 }
3312 }
3313 function d3_geo_centroidLineEnd() {
3314 d3_geo_centroid.point = d3_geo_centroidPoint;
3315 }
3316 function d3_geo_centroidRingStart() {
3317 var λ00, φ00, x0, y0, z0;
3318 d3_geo_centroid.point = function(λ, φ) {
3319 λ00 = λ, φ00 = φ;
3320 d3_geo_centroid.point = nextPoint;
3321 λ *= d3_radians;
3322 var cosφ = Math.cos(φ *= d3_radians);
3323 x0 = cosφ * Math.cos(λ);
3324 y0 = cosφ * Math.sin(λ);
3325 z0 = Math.sin(φ);
3326 d3_geo_centroidPointXYZ(x0, y0, z0);
3327 };
3328 d3_geo_centroid.lineEnd = function() {
3329 nextPoint(λ00, φ00);
3330 d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd;
3331 d3_geo_centroid.point = d3_geo_centroidPoint;
3332 };
3333 function nextPoint(λ, φ) {
3334 λ *= d3_radians;
3335 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);
3336 d3_geo_centroidX2 += v * cx;
3337 d3_geo_centroidY2 += v * cy;
3338 d3_geo_centroidZ2 += v * cz;
3339 d3_geo_centroidW1 += w;
3340 d3_geo_centroidX1 += w * (x0 + (x0 = x));
3341 d3_geo_centroidY1 += w * (y0 + (y0 = y));
3342 d3_geo_centroidZ1 += w * (z0 + (z0 = z));
3343 d3_geo_centroidPointXYZ(x0, y0, z0);
3344 }
3345 }
3346 function d3_geo_compose(a, b) {
3347 function compose(x, y) {
3348 return x = a(x, y), b(x[0], x[1]);
3349 }
3350 if (a.invert && b.invert) compose.invert = function(x, y) {
3351 return x = b.invert(x, y), x && a.invert(x[0], x[1]);
3352 };
3353 return compose;
3354 }
3355 function d3_true() {
3356 return true;
3357 }
3358 function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) {
3359 var subject = [], clip = [];
3360 segments.forEach(function(segment) {
3361 if ((n = segment.length - 1) <= 0) return;
3362 var n, p0 = segment[0], p1 = segment[n];
3363 if (d3_geo_sphericalEqual(p0, p1)) {
3364 listener.lineStart();
3365 for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]);
3366 listener.lineEnd();
3367 return;
3368 }
3369 var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false);
3370 a.o = b;
3371 subject.push(a);
3372 clip.push(b);
3373 a = new d3_geo_clipPolygonIntersection(p1, segment, null, false);
3374 b = new d3_geo_clipPolygonIntersection(p1, null, a, true);
3375 a.o = b;
3376 subject.push(a);
3377 clip.push(b);
3378 });
3379 clip.sort(compare);
3380 d3_geo_clipPolygonLinkCircular(subject);
3381 d3_geo_clipPolygonLinkCircular(clip);
3382 if (!subject.length) return;
3383 for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) {
3384 clip[i].e = entry = !entry;
3385 }
3386 var start = subject[0], points, point;
3387 while (1) {
3388 var current = start, isSubject = true;
3389 while (current.v) if ((current = current.n) === start) return;
3390 points = current.z;
3391 listener.lineStart();
3392 do {
3393 current.v = current.o.v = true;
3394 if (current.e) {
3395 if (isSubject) {
3396 for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]);
3397 } else {
3398 interpolate(current.x, current.n.x, 1, listener);
3399 }
3400 current = current.n;
3401 } else {
3402 if (isSubject) {
3403 points = current.p.z;
3404 for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]);
3405 } else {
3406 interpolate(current.x, current.p.x, -1, listener);
3407 }
3408 current = current.p;
3409 }
3410 current = current.o;
3411 points = current.z;
3412 isSubject = !isSubject;
3413 } while (!current.v);
3414 listener.lineEnd();
3415 }
3416 }
3417 function d3_geo_clipPolygonLinkCircular(array) {
3418 if (!(n = array.length)) return;
3419 var n, i = 0, a = array[0], b;
3420 while (++i < n) {
3421 a.n = b = array[i];
3422 b.p = a;
3423 a = b;
3424 }
3425 a.n = b = array[0];
3426 b.p = a;
3427 }
3428 function d3_geo_clipPolygonIntersection(point, points, other, entry) {
3429 this.x = point;
3430 this.z = points;
3431 this.o = other;
3432 this.e = entry;
3433 this.v = false;
3434 this.n = this.p = null;
3435 }
3436 function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {
3437 return function(rotate, listener) {
3438 var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]);
3439 var clip = {
3440 point: point,
3441 lineStart: lineStart,
3442 lineEnd: lineEnd,
3443 polygonStart: function() {
3444 clip.point = pointRing;
3445 clip.lineStart = ringStart;
3446 clip.lineEnd = ringEnd;
3447 segments = [];
3448 polygon = [];
3449 },
3450 polygonEnd: function() {
3451 clip.point = point;
3452 clip.lineStart = lineStart;
3453 clip.lineEnd = lineEnd;
3454 segments = d3.merge(segments);
3455 var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon);
3456 if (segments.length) {
3457 if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3458 d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener);
3459 } else if (clipStartInside) {
3460 if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3461 listener.lineStart();
3462 interpolate(null, null, 1, listener);
3463 listener.lineEnd();
3464 }
3465 if (polygonStarted) listener.polygonEnd(), polygonStarted = false;
3466 segments = polygon = null;
3467 },
3468 sphere: function() {
3469 listener.polygonStart();
3470 listener.lineStart();
3471 interpolate(null, null, 1, listener);
3472 listener.lineEnd();
3473 listener.polygonEnd();
3474 }
3475 };
3476 function point(λ, φ) {
3477 var point = rotate(λ, φ);
3478 if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ);
3479 }
3480 function pointLine(λ, φ) {
3481 var point = rotate(λ, φ);
3482 line.point(point[0], point[1]);
3483 }
3484 function lineStart() {
3485 clip.point = pointLine;
3486 line.lineStart();
3487 }
3488 function lineEnd() {
3489 clip.point = point;
3490 line.lineEnd();
3491 }
3492 var segments;
3493 var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring;
3494 function pointRing(λ, φ) {
3495 ring.push([ λ, φ ]);
3496 var point = rotate(λ, φ);
3497 ringListener.point(point[0], point[1]);
3498 }
3499 function ringStart() {
3500 ringListener.lineStart();
3501 ring = [];
3502 }
3503 function ringEnd() {
3504 pointRing(ring[0][0], ring[0][1]);
3505 ringListener.lineEnd();
3506 var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length;
3507 ring.pop();
3508 polygon.push(ring);
3509 ring = null;
3510 if (!n) return;
3511 if (clean & 1) {
3512 segment = ringSegments[0];
3513 var n = segment.length - 1, i = -1, point;
3514 if (n > 0) {
3515 if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3516 listener.lineStart();
3517 while (++i < n) listener.point((point = segment[i])[0], point[1]);
3518 listener.lineEnd();
3519 }
3520 return;
3521 }
3522 if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
3523 segments.push(ringSegments.filter(d3_geo_clipSegmentLength1));
3524 }
3525 return clip;
3526 };
3527 }
3528 function d3_geo_clipSegmentLength1(segment) {
3529 return segment.length > 1;
3530 }
3531 function d3_geo_clipBufferListener() {
3532 var lines = [], line;
3533 return {
3534 lineStart: function() {
3535 lines.push(line = []);
3536 },
3537 point: function(λ, φ) {
3538 line.push([ λ, φ ]);
3539 },
3540 lineEnd: d3_noop,
3541 buffer: function() {
3542 var buffer = lines;
3543 lines = [];
3544 line = null;
3545 return buffer;
3546 },
3547 rejoin: function() {
3548 if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
3549 }
3550 };
3551 }
3552 function d3_geo_clipSort(a, b) {
3553 return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]);
3554 }
3555 var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]);
3556 function d3_geo_clipAntimeridianLine(listener) {
3557 var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean;
3558 return {
3559 lineStart: function() {
3560 listener.lineStart();
3561 clean = 1;
3562 },
3563 point: function(λ1, φ1) {
3564 var sλ1 = λ1 > 0 ? π : -π, dλ = abs(λ1 - λ0);
3565 if (abs(dλ - π) < ε) {
3566 listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ);
3567 listener.point(sλ0, φ0);
3568 listener.lineEnd();
3569 listener.lineStart();
3570 listener.point(sλ1, φ0);
3571 listener.point(λ1, φ0);
3572 clean = 0;
3573 } else if (sλ0 !== sλ1 && dλ >= π) {
3574 if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε;
3575 if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε;
3576 φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1);
3577 listener.point(sλ0, φ0);
3578 listener.lineEnd();
3579 listener.lineStart();
3580 listener.point(sλ1, φ0);
3581 clean = 0;
3582 }
3583 listener.point(λ0 = λ1, φ0 = φ1);
3584 sλ0 = sλ1;
3585 },
3586 lineEnd: function() {
3587 listener.lineEnd();
3588 λ0 = φ0 = NaN;
3589 },
3590 clean: function() {
3591 return 2 - clean;
3592 }
3593 };
3594 }
3595 function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) {
3596 var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1);
3597 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;
3598 }
3599 function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) {
3600 var φ;
3601 if (from == null) {
3602 φ = direction * halfπ;
3603 listener.point(-π, φ);
3604 listener.point(0, φ);
3605 listener.point(π, φ);
3606 listener.point(π, 0);
3607 listener.point(π, -φ);
3608 listener.point(0, -φ);
3609 listener.point(-π, -φ);
3610 listener.point(-π, 0);
3611 listener.point(-π, φ);
3612 } else if (abs(from[0] - to[0]) > ε) {
3613 var s = from[0] < to[0] ? π : -π;
3614 φ = direction * s / 2;
3615 listener.point(-s, φ);
3616 listener.point(0, φ);
3617 listener.point(s, φ);
3618 } else {
3619 listener.point(to[0], to[1]);
3620 }
3621 }
3622 function d3_geo_pointInPolygon(point, polygon) {
3623 var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;
3624 d3_geo_areaRingSum.reset();
3625 for (var i = 0, n = polygon.length; i < n; ++i) {
3626 var ring = polygon[i], m = ring.length;
3627 if (!m) continue;
3628 var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1;
3629 while (true) {
3630 if (j === m) j = 0;
3631 point = ring[j];
3632 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φ;
3633 d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ)));
3634 polarAngle += antimeridian ? dλ + sdλ * τ : dλ;
3635 if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) {
3636 var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));
3637 d3_geo_cartesianNormalize(arc);
3638 var intersection = d3_geo_cartesianCross(meridianNormal, arc);
3639 d3_geo_cartesianNormalize(intersection);
3640 var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]);
3641 if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) {
3642 winding += antimeridian ^ dλ >= 0 ? 1 : -1;
3643 }
3644 }
3645 if (!j++) break;
3646 λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;
3647 }
3648 }
3649 return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1;
3650 }
3651 function d3_geo_clipCircle(radius) {
3652 var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians);
3653 return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]);
3654 function visible(λ, φ) {
3655 return Math.cos(λ) * Math.cos(φ) > cr;
3656 }
3657 function clipLine(listener) {
3658 var point0, c0, v0, v00, clean;
3659 return {
3660 lineStart: function() {
3661 v00 = v0 = false;
3662 clean = 1;
3663 },
3664 point: function(λ, φ) {
3665 var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0;
3666 if (!point0 && (v00 = v0 = v)) listener.lineStart();
3667 if (v !== v0) {
3668 point2 = intersect(point0, point1);
3669 if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) {
3670 point1[0] += ε;
3671 point1[1] += ε;
3672 v = visible(point1[0], point1[1]);
3673 }
3674 }
3675 if (v !== v0) {
3676 clean = 0;
3677 if (v) {
3678 listener.lineStart();
3679 point2 = intersect(point1, point0);
3680 listener.point(point2[0], point2[1]);
3681 } else {
3682 point2 = intersect(point0, point1);
3683 listener.point(point2[0], point2[1]);
3684 listener.lineEnd();
3685 }
3686 point0 = point2;
3687 } else if (notHemisphere && point0 && smallRadius ^ v) {
3688 var t;
3689 if (!(c & c0) && (t = intersect(point1, point0, true))) {
3690 clean = 0;
3691 if (smallRadius) {
3692 listener.lineStart();
3693 listener.point(t[0][0], t[0][1]);
3694 listener.point(t[1][0], t[1][1]);
3695 listener.lineEnd();
3696 } else {
3697 listener.point(t[1][0], t[1][1]);
3698 listener.lineEnd();
3699 listener.lineStart();
3700 listener.point(t[0][0], t[0][1]);
3701 }
3702 }
3703 }
3704 if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) {
3705 listener.point(point1[0], point1[1]);
3706 }
3707 point0 = point1, v0 = v, c0 = c;
3708 },
3709 lineEnd: function() {
3710 if (v0) listener.lineEnd();
3711 point0 = null;
3712 },
3713 clean: function() {
3714 return clean | (v00 && v0) << 1;
3715 }
3716 };
3717 }
3718 function intersect(a, b, two) {
3719 var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b);
3720 var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;
3721 if (!determinant) return !two && a;
3722 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);
3723 d3_geo_cartesianAdd(A, B);
3724 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);
3725 if (t2 < 0) return;
3726 var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu);
3727 d3_geo_cartesianAdd(q, A);
3728 q = d3_geo_spherical(q);
3729 if (!two) return q;
3730 var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z;
3731 if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z;
3732 var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε;
3733 if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z;
3734 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)) {
3735 var q1 = d3_geo_cartesianScale(u, (-w + t) / uu);
3736 d3_geo_cartesianAdd(q1, A);
3737 return [ q, d3_geo_spherical(q1) ];
3738 }
3739 }
3740 function code(λ, φ) {
3741 var r = smallRadius ? radius : π - radius, code = 0;
3742 if (λ < -r) code |= 1; else if (λ > r) code |= 2;
3743 if (φ < -r) code |= 4; else if (φ > r) code |= 8;
3744 return code;
3745 }
3746 }
3747 function d3_geom_clipLine(x0, y0, x1, y1) {
3748 return function(line) {
3749 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;
3750 r = x0 - ax;
3751 if (!dx && r > 0) return;
3752 r /= dx;
3753 if (dx < 0) {
3754 if (r < t0) return;
3755 if (r < t1) t1 = r;
3756 } else if (dx > 0) {
3757 if (r > t1) return;
3758 if (r > t0) t0 = r;
3759 }
3760 r = x1 - ax;
3761 if (!dx && r < 0) return;
3762 r /= dx;
3763 if (dx < 0) {
3764 if (r > t1) return;
3765 if (r > t0) t0 = r;
3766 } else if (dx > 0) {
3767 if (r < t0) return;
3768 if (r < t1) t1 = r;
3769 }
3770 r = y0 - ay;
3771 if (!dy && r > 0) return;
3772 r /= dy;
3773 if (dy < 0) {
3774 if (r < t0) return;
3775 if (r < t1) t1 = r;
3776 } else if (dy > 0) {
3777 if (r > t1) return;
3778 if (r > t0) t0 = r;
3779 }
3780 r = y1 - ay;
3781 if (!dy && r < 0) return;
3782 r /= dy;
3783 if (dy < 0) {
3784 if (r > t1) return;
3785 if (r > t0) t0 = r;
3786 } else if (dy > 0) {
3787 if (r < t0) return;
3788 if (r < t1) t1 = r;
3789 }
3790 if (t0 > 0) line.a = {
3791 x: ax + t0 * dx,
3792 y: ay + t0 * dy
3793 };
3794 if (t1 < 1) line.b = {
3795 x: ax + t1 * dx,
3796 y: ay + t1 * dy
3797 };
3798 return line;
3799 };
3800 }
3801 var d3_geo_clipExtentMAX = 1e9;
3802 d3.geo.clipExtent = function() {
3803 var x0, y0, x1, y1, stream, clip, clipExtent = {
3804 stream: function(output) {
3805 if (stream) stream.valid = false;
3806 stream = clip(output);
3807 stream.valid = true;
3808 return stream;
3809 },
3810 extent: function(_) {
3811 if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];
3812 clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]);
3813 if (stream) stream.valid = false, stream = null;
3814 return clipExtent;
3815 }
3816 };
3817 return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]);
3818 };
3819 function d3_geo_clipExtent(x0, y0, x1, y1) {
3820 return function(listener) {
3821 var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring;
3822 var clip = {
3823 point: point,
3824 lineStart: lineStart,
3825 lineEnd: lineEnd,
3826 polygonStart: function() {
3827 listener = bufferListener;
3828 segments = [];
3829 polygon = [];
3830 clean = true;
3831 },
3832 polygonEnd: function() {
3833 listener = listener_;
3834 segments = d3.merge(segments);
3835 var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length;
3836 if (inside || visible) {
3837 listener.polygonStart();
3838 if (inside) {
3839 listener.lineStart();
3840 interpolate(null, null, 1, listener);
3841 listener.lineEnd();
3842 }
3843 if (visible) {
3844 d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener);
3845 }
3846 listener.polygonEnd();
3847 }
3848 segments = polygon = ring = null;
3849 }
3850 };
3851 function insidePolygon(p) {
3852 var wn = 0, n = polygon.length, y = p[1];
3853 for (var i = 0; i < n; ++i) {
3854 for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {
3855 b = v[j];
3856 if (a[1] <= y) {
3857 if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn;
3858 } else {
3859 if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn;
3860 }
3861 a = b;
3862 }
3863 }
3864 return wn !== 0;
3865 }
3866 function interpolate(from, to, direction, listener) {
3867 var a = 0, a1 = 0;
3868 if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) {
3869 do {
3870 listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
3871 } while ((a = (a + direction + 4) % 4) !== a1);
3872 } else {
3873 listener.point(to[0], to[1]);
3874 }
3875 }
3876 function pointVisible(x, y) {
3877 return x0 <= x && x <= x1 && y0 <= y && y <= y1;
3878 }
3879 function point(x, y) {
3880 if (pointVisible(x, y)) listener.point(x, y);
3881 }
3882 var x__, y__, v__, x_, y_, v_, first, clean;
3883 function lineStart() {
3884 clip.point = linePoint;
3885 if (polygon) polygon.push(ring = []);
3886 first = true;
3887 v_ = false;
3888 x_ = y_ = NaN;
3889 }
3890 function lineEnd() {
3891 if (segments) {
3892 linePoint(x__, y__);
3893 if (v__ && v_) bufferListener.rejoin();
3894 segments.push(bufferListener.buffer());
3895 }
3896 clip.point = point;
3897 if (v_) listener.lineEnd();
3898 }
3899 function linePoint(x, y) {
3900 x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x));
3901 y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y));
3902 var v = pointVisible(x, y);
3903 if (polygon) ring.push([ x, y ]);
3904 if (first) {
3905 x__ = x, y__ = y, v__ = v;
3906 first = false;
3907 if (v) {
3908 listener.lineStart();
3909 listener.point(x, y);
3910 }
3911 } else {
3912 if (v && v_) listener.point(x, y); else {
3913 var l = {
3914 a: {
3915 x: x_,
3916 y: y_
3917 },
3918 b: {
3919 x: x,
3920 y: y
3921 }
3922 };
3923 if (clipLine(l)) {
3924 if (!v_) {
3925 listener.lineStart();
3926 listener.point(l.a.x, l.a.y);
3927 }
3928 listener.point(l.b.x, l.b.y);
3929 if (!v) listener.lineEnd();
3930 clean = false;
3931 } else if (v) {
3932 listener.lineStart();
3933 listener.point(x, y);
3934 clean = false;
3935 }
3936 }
3937 }
3938 x_ = x, y_ = y, v_ = v;
3939 }
3940 return clip;
3941 };
3942 function corner(p, direction) {
3943 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;
3944 }
3945 function compare(a, b) {
3946 return comparePoints(a.x, b.x);
3947 }
3948 function comparePoints(a, b) {
3949 var ca = corner(a, 1), cb = corner(b, 1);
3950 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];
3951 }
3952 }
3953 function d3_geo_conic(projectAt) {
3954 var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1);
3955 p.parallels = function(_) {
3956 if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ];
3957 return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180);
3958 };
3959 return p;
3960 }
3961 function d3_geo_conicEqualArea(φ0, φ1) {
3962 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;
3963 function forward(λ, φ) {
3964 var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n;
3965 return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ];
3966 }
3967 forward.invert = function(x, y) {
3968 var ρ0_y = ρ0 - y;
3969 return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ];
3970 };
3971 return forward;
3972 }
3973 (d3.geo.conicEqualArea = function() {
3974 return d3_geo_conic(d3_geo_conicEqualArea);
3975 }).raw = d3_geo_conicEqualArea;
3976 d3.geo.albers = function() {
3977 return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070);
3978 };
3979 d3.geo.albersUsa = function() {
3980 var lower48 = d3.geo.albers();
3981 var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]);
3982 var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]);
3983 var point, pointStream = {
3984 point: function(x, y) {
3985 point = [ x, y ];
3986 }
3987 }, lower48Point, alaskaPoint, hawaiiPoint;
3988 function albersUsa(coordinates) {
3989 var x = coordinates[0], y = coordinates[1];
3990 point = null;
3991 (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y);
3992 return point;
3993 }
3994 albersUsa.invert = function(coordinates) {
3995 var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k;
3996 return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates);
3997 };
3998 albersUsa.stream = function(stream) {
3999 var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream);
4000 return {
4001 point: function(x, y) {
4002 lower48Stream.point(x, y);
4003 alaskaStream.point(x, y);
4004 hawaiiStream.point(x, y);
4005 },
4006 sphere: function() {
4007 lower48Stream.sphere();
4008 alaskaStream.sphere();
4009 hawaiiStream.sphere();
4010 },
4011 lineStart: function() {
4012 lower48Stream.lineStart();
4013 alaskaStream.lineStart();
4014 hawaiiStream.lineStart();
4015 },
4016 lineEnd: function() {
4017 lower48Stream.lineEnd();
4018 alaskaStream.lineEnd();
4019 hawaiiStream.lineEnd();
4020 },
4021 polygonStart: function() {
4022 lower48Stream.polygonStart();
4023 alaskaStream.polygonStart();
4024 hawaiiStream.polygonStart();
4025 },
4026 polygonEnd: function() {
4027 lower48Stream.polygonEnd();
4028 alaskaStream.polygonEnd();
4029 hawaiiStream.polygonEnd();
4030 }
4031 };
4032 };
4033 albersUsa.precision = function(_) {
4034 if (!arguments.length) return lower48.precision();
4035 lower48.precision(_);
4036 alaska.precision(_);
4037 hawaii.precision(_);
4038 return albersUsa;
4039 };
4040 albersUsa.scale = function(_) {
4041 if (!arguments.length) return lower48.scale();
4042 lower48.scale(_);
4043 alaska.scale(_ * .35);
4044 hawaii.scale(_);
4045 return albersUsa.translate(lower48.translate());
4046 };
4047 albersUsa.translate = function(_) {
4048 if (!arguments.length) return lower48.translate();
4049 var k = lower48.scale(), x = +_[0], y = +_[1];
4050 lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point;
4051 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;
4052 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;
4053 return albersUsa;
4054 };
4055 return albersUsa.scale(1070);
4056 };
4057 var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = {
4058 point: d3_noop,
4059 lineStart: d3_noop,
4060 lineEnd: d3_noop,
4061 polygonStart: function() {
4062 d3_geo_pathAreaPolygon = 0;
4063 d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart;
4064 },
4065 polygonEnd: function() {
4066 d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop;
4067 d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2);
4068 }
4069 };
4070 function d3_geo_pathAreaRingStart() {
4071 var x00, y00, x0, y0;
4072 d3_geo_pathArea.point = function(x, y) {
4073 d3_geo_pathArea.point = nextPoint;
4074 x00 = x0 = x, y00 = y0 = y;
4075 };
4076 function nextPoint(x, y) {
4077 d3_geo_pathAreaPolygon += y0 * x - x0 * y;
4078 x0 = x, y0 = y;
4079 }
4080 d3_geo_pathArea.lineEnd = function() {
4081 nextPoint(x00, y00);
4082 };
4083 }
4084 var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1;
4085 var d3_geo_pathBounds = {
4086 point: d3_geo_pathBoundsPoint,
4087 lineStart: d3_noop,
4088 lineEnd: d3_noop,
4089 polygonStart: d3_noop,
4090 polygonEnd: d3_noop
4091 };
4092 function d3_geo_pathBoundsPoint(x, y) {
4093 if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x;
4094 if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x;
4095 if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y;
4096 if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y;
4097 }
4098 function d3_geo_pathBuffer() {
4099 var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = [];
4100 var stream = {
4101 point: point,
4102 lineStart: function() {
4103 stream.point = pointLineStart;
4104 },
4105 lineEnd: lineEnd,
4106 polygonStart: function() {
4107 stream.lineEnd = lineEndPolygon;
4108 },
4109 polygonEnd: function() {
4110 stream.lineEnd = lineEnd;
4111 stream.point = point;
4112 },
4113 pointRadius: function(_) {
4114 pointCircle = d3_geo_pathBufferCircle(_);
4115 return stream;
4116 },
4117 result: function() {
4118 if (buffer.length) {
4119 var result = buffer.join("");
4120 buffer = [];
4121 return result;
4122 }
4123 }
4124 };
4125 function point(x, y) {
4126 buffer.push("M", x, ",", y, pointCircle);
4127 }
4128 function pointLineStart(x, y) {
4129 buffer.push("M", x, ",", y);
4130 stream.point = pointLine;
4131 }
4132 function pointLine(x, y) {
4133 buffer.push("L", x, ",", y);
4134 }
4135 function lineEnd() {
4136 stream.point = point;
4137 }
4138 function lineEndPolygon() {
4139 buffer.push("Z");
4140 }
4141 return stream;
4142 }
4143 function d3_geo_pathBufferCircle(radius) {
4144 return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z";
4145 }
4146 var d3_geo_pathCentroid = {
4147 point: d3_geo_pathCentroidPoint,
4148 lineStart: d3_geo_pathCentroidLineStart,
4149 lineEnd: d3_geo_pathCentroidLineEnd,
4150 polygonStart: function() {
4151 d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart;
4152 },
4153 polygonEnd: function() {
4154 d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
4155 d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart;
4156 d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd;
4157 }
4158 };
4159 function d3_geo_pathCentroidPoint(x, y) {
4160 d3_geo_centroidX0 += x;
4161 d3_geo_centroidY0 += y;
4162 ++d3_geo_centroidZ0;
4163 }
4164 function d3_geo_pathCentroidLineStart() {
4165 var x0, y0;
4166 d3_geo_pathCentroid.point = function(x, y) {
4167 d3_geo_pathCentroid.point = nextPoint;
4168 d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4169 };
4170 function nextPoint(x, y) {
4171 var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);
4172 d3_geo_centroidX1 += z * (x0 + x) / 2;
4173 d3_geo_centroidY1 += z * (y0 + y) / 2;
4174 d3_geo_centroidZ1 += z;
4175 d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4176 }
4177 }
4178 function d3_geo_pathCentroidLineEnd() {
4179 d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
4180 }
4181 function d3_geo_pathCentroidRingStart() {
4182 var x00, y00, x0, y0;
4183 d3_geo_pathCentroid.point = function(x, y) {
4184 d3_geo_pathCentroid.point = nextPoint;
4185 d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y);
4186 };
4187 function nextPoint(x, y) {
4188 var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);
4189 d3_geo_centroidX1 += z * (x0 + x) / 2;
4190 d3_geo_centroidY1 += z * (y0 + y) / 2;
4191 d3_geo_centroidZ1 += z;
4192 z = y0 * x - x0 * y;
4193 d3_geo_centroidX2 += z * (x0 + x);
4194 d3_geo_centroidY2 += z * (y0 + y);
4195 d3_geo_centroidZ2 += z * 3;
4196 d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4197 }
4198 d3_geo_pathCentroid.lineEnd = function() {
4199 nextPoint(x00, y00);
4200 };
4201 }
4202 function d3_geo_pathContext(context) {
4203 var pointRadius = 4.5;
4204 var stream = {
4205 point: point,
4206 lineStart: function() {
4207 stream.point = pointLineStart;
4208 },
4209 lineEnd: lineEnd,
4210 polygonStart: function() {
4211 stream.lineEnd = lineEndPolygon;
4212 },
4213 polygonEnd: function() {
4214 stream.lineEnd = lineEnd;
4215 stream.point = point;
4216 },
4217 pointRadius: function(_) {
4218 pointRadius = _;
4219 return stream;
4220 },
4221 result: d3_noop
4222 };
4223 function point(x, y) {
4224 context.moveTo(x + pointRadius, y);
4225 context.arc(x, y, pointRadius, 0, τ);
4226 }
4227 function pointLineStart(x, y) {
4228 context.moveTo(x, y);
4229 stream.point = pointLine;
4230 }
4231 function pointLine(x, y) {
4232 context.lineTo(x, y);
4233 }
4234 function lineEnd() {
4235 stream.point = point;
4236 }
4237 function lineEndPolygon() {
4238 context.closePath();
4239 }
4240 return stream;
4241 }
4242 function d3_geo_resample(project) {
4243 var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16;
4244 function resample(stream) {
4245 return (maxDepth ? resampleRecursive : resampleNone)(stream);
4246 }
4247 function resampleNone(stream) {
4248 return d3_geo_transformPoint(stream, function(x, y) {
4249 x = project(x, y);
4250 stream.point(x[0], x[1]);
4251 });
4252 }
4253 function resampleRecursive(stream) {
4254 var λ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0;
4255 var resample = {
4256 point: point,
4257 lineStart: lineStart,
4258 lineEnd: lineEnd,
4259 polygonStart: function() {
4260 stream.polygonStart();
4261 resample.lineStart = ringStart;
4262 },
4263 polygonEnd: function() {
4264 stream.polygonEnd();
4265 resample.lineStart = lineStart;
4266 }
4267 };
4268 function point(x, y) {
4269 x = project(x, y);
4270 stream.point(x[0], x[1]);
4271 }
4272 function lineStart() {
4273 x0 = NaN;
4274 resample.point = linePoint;
4275 stream.lineStart();
4276 }
4277 function linePoint(λ, φ) {
4278 var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ);
4279 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);
4280 stream.point(x0, y0);
4281 }
4282 function lineEnd() {
4283 resample.point = point;
4284 stream.lineEnd();
4285 }
4286 function ringStart() {
4287 lineStart();
4288 resample.point = ringPoint;
4289 resample.lineEnd = ringEnd;
4290 }
4291 function ringPoint(λ, φ) {
4292 linePoint(λ00 = λ, φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;
4293 resample.point = linePoint;
4294 }
4295 function ringEnd() {
4296 resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream);
4297 resample.lineEnd = lineEnd;
4298 lineEnd();
4299 }
4300 return resample;
4301 }
4302 function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) {
4303 var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;
4304 if (d2 > 4 * δ2 && depth--) {
4305 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) < ε || abs0 - λ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;
4306 if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
4307 resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream);
4308 stream.point(x2, y2);
4309 resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream);
4310 }
4311 }
4312 }
4313 resample.precision = function(_) {
4314 if (!arguments.length) return Math.sqrt(δ2);
4315 maxDepth = (δ2 = _ * _) > 0 && 16;
4316 return resample;
4317 };
4318 return resample;
4319 }
4320 d3.geo.path = function() {
4321 var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream;
4322 function path(object) {
4323 if (object) {
4324 if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
4325 if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream);
4326 d3.geo.stream(object, cacheStream);
4327 }
4328 return contextStream.result();
4329 }
4330 path.area = function(object) {
4331 d3_geo_pathAreaSum = 0;
4332 d3.geo.stream(object, projectStream(d3_geo_pathArea));
4333 return d3_geo_pathAreaSum;
4334 };
4335 path.centroid = function(object) {
4336 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;
4337 d3.geo.stream(object, projectStream(d3_geo_pathCentroid));
4338 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 ];
4339 };
4340 path.bounds = function(object) {
4341 d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity);
4342 d3.geo.stream(object, projectStream(d3_geo_pathBounds));
4343 return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ];
4344 };
4345 path.projection = function(_) {
4346 if (!arguments.length) return projection;
4347 projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity;
4348 return reset();
4349 };
4350 path.context = function(_) {
4351 if (!arguments.length) return context;
4352 contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_);
4353 if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
4354 return reset();
4355 };
4356 path.pointRadius = function(_) {
4357 if (!arguments.length) return pointRadius;
4358 pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_);
4359 return path;
4360 };
4361 function reset() {
4362 cacheStream = null;
4363 return path;
4364 }
4365 return path.projection(d3.geo.albersUsa()).context(null);
4366 };
4367 function d3_geo_pathProjectStream(project) {
4368 var resample = d3_geo_resample(function(x, y) {
4369 return project([ x * d3_degrees, y * d3_degrees ]);
4370 });
4371 return function(stream) {
4372 return d3_geo_projectionRadians(resample(stream));
4373 };
4374 }
4375 d3.geo.transform = function(methods) {
4376 return {
4377 stream: function(stream) {
4378 var transform = new d3_geo_transform(stream);
4379 for (var k in methods) transform[k] = methods[k];
4380 return transform;
4381 }
4382 };
4383 };
4384 function d3_geo_transform(stream) {
4385 this.stream = stream;
4386 }
4387 d3_geo_transform.prototype = {
4388 point: function(x, y) {
4389 this.stream.point(x, y);
4390 },
4391 sphere: function() {
4392 this.stream.sphere();
4393 },
4394 lineStart: function() {
4395 this.stream.lineStart();
4396 },
4397 lineEnd: function() {
4398 this.stream.lineEnd();
4399 },
4400 polygonStart: function() {
4401 this.stream.polygonStart();
4402 },
4403 polygonEnd: function() {
4404 this.stream.polygonEnd();
4405 }
4406 };
4407 function d3_geo_transformPoint(stream, point) {
4408 return {
4409 point: point,
4410 sphere: function() {
4411 stream.sphere();
4412 },
4413 lineStart: function() {
4414 stream.lineStart();
4415 },
4416 lineEnd: function() {
4417 stream.lineEnd();
4418 },
4419 polygonStart: function() {
4420 stream.polygonStart();
4421 },
4422 polygonEnd: function() {
4423 stream.polygonEnd();
4424 }
4425 };
4426 }
4427 d3.geo.projection = d3_geo_projection;
4428 d3.geo.projectionMutator = d3_geo_projectionMutator;
4429 function d3_geo_projection(project) {
4430 return d3_geo_projectionMutator(function() {
4431 return project;
4432 })();
4433 }
4434 function d3_geo_projectionMutator(projectAt) {
4435 var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) {
4436 x = project(x, y);
4437 return [ x[0] * k + δx, δy - x[1] * k ];
4438 }), 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;
4439 function projection(point) {
4440 point = projectRotate(point[0] * d3_radians, point[1] * d3_radians);
4441 return [ point[0] * k + δx, δy - point[1] * k ];
4442 }
4443 function invert(point) {
4444 point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k);
4445 return point && [ point[0] * d3_degrees, point[1] * d3_degrees ];
4446 }
4447 projection.stream = function(output) {
4448 if (stream) stream.valid = false;
4449 stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output))));
4450 stream.valid = true;
4451 return stream;
4452 };
4453 projection.clipAngle = function(_) {
4454 if (!arguments.length) return clipAngle;
4455 preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians);
4456 return invalidate();
4457 };
4458 projection.clipExtent = function(_) {
4459 if (!arguments.length) return clipExtent;
4460 clipExtent = _;
4461 postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity;
4462 return invalidate();
4463 };
4464 projection.scale = function(_) {
4465 if (!arguments.length) return k;
4466 k = +_;
4467 return reset();
4468 };
4469 projection.translate = function(_) {
4470 if (!arguments.length) return [ x, y ];
4471 x = +_[0];
4472 y = +_[1];
4473 return reset();
4474 };
4475 projection.center = function(_) {
4476 if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ];
4477 λ = _[0] % 360 * d3_radians;
4478 φ = _[1] % 360 * d3_radians;
4479 return reset();
4480 };
4481 projection.rotate = function(_) {
4482 if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ];
4483 δλ = _[0] % 360 * d3_radians;
4484 δφ = _[1] % 360 * d3_radians;
4485 δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0;
4486 return reset();
4487 };
4488 d3.rebind(projection, projectResample, "precision");
4489 function reset() {
4490 projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project);
4491 var center = project(λ, φ);
4492 δx = x - center[0] * k;
4493 δy = y + center[1] * k;
4494 return invalidate();
4495 }
4496 function invalidate() {
4497 if (stream) stream.valid = false, stream = null;
4498 return projection;
4499 }
4500 return function() {
4501 project = projectAt.apply(this, arguments);
4502 projection.invert = project.invert && invert;
4503 return reset();
4504 };
4505 }
4506 function d3_geo_projectionRadians(stream) {
4507 return d3_geo_transformPoint(stream, function(x, y) {
4508 stream.point(x * d3_radians, y * d3_radians);
4509 });
4510 }
4511 function d3_geo_equirectangular(λ, φ) {
4512 return [ λ, φ ];
4513 }
4514 (d3.geo.equirectangular = function() {
4515 return d3_geo_projection(d3_geo_equirectangular);
4516 }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;
4517 d3.geo.rotation = function(rotate) {
4518 rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0);
4519 function forward(coordinates) {
4520 coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
4521 return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
4522 }
4523 forward.invert = function(coordinates) {
4524 coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
4525 return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
4526 };
4527 return forward;
4528 };
4529 function d3_geo_identityRotation(λ, φ) {
4530 return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];
4531 }
4532 d3_geo_identityRotation.invert = d3_geo_equirectangular;
4533 function d3_geo_rotation(δλ, δφ, δγ) {
4534 return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation;
4535 }
4536 function d3_geo_forwardRotationλ(δλ) {
4537 return function(λ, φ) {
4538 return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];
4539 };
4540 }
4541 function d3_geo_rotationλ(δλ) {
4542 var rotation = d3_geo_forwardRotationλ(δλ);
4543 rotation.invert = d3_geo_forwardRotationλ(-δλ);
4544 return rotation;
4545 }
4546 function d3_geo_rotationφγ(δφ, δγ) {
4547 var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ);
4548 function rotation(λ, φ) {
4549 var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ;
4550 return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ];
4551 }
4552 rotation.invert = function(λ, φ) {
4553 var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ;
4554 return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ];
4555 };
4556 return rotation;
4557 }
4558 d3.geo.circle = function() {
4559 var origin = [ 0, 0 ], angle, precision = 6, interpolate;
4560 function circle() {
4561 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 = [];
4562 interpolate(null, null, 1, {
4563 point: function(x, y) {
4564 ring.push(x = rotate(x, y));
4565 x[0] *= d3_degrees, x[1] *= d3_degrees;
4566 }
4567 });
4568 return {
4569 type: "Polygon",
4570 coordinates: [ ring ]
4571 };
4572 }
4573 circle.origin = function(x) {
4574 if (!arguments.length) return origin;
4575 origin = x;
4576 return circle;
4577 };
4578 circle.angle = function(x) {
4579 if (!arguments.length) return angle;
4580 interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians);
4581 return circle;
4582 };
4583 circle.precision = function(_) {
4584 if (!arguments.length) return precision;
4585 interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians);
4586 return circle;
4587 };
4588 return circle.angle(90);
4589 };
4590 function d3_geo_circleInterpolate(radius, precision) {
4591 var cr = Math.cos(radius), sr = Math.sin(radius);
4592 return function(from, to, direction, listener) {
4593 var step = direction * precision;
4594 if (from != null) {
4595 from = d3_geo_circleAngle(cr, from);
4596 to = d3_geo_circleAngle(cr, to);
4597 if (direction > 0 ? from < to : from > to) from += direction * τ;
4598 } else {
4599 from = radius + direction * τ;
4600 to = radius - .5 * step;
4601 }
4602 for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) {
4603 listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]);
4604 }
4605 };
4606 }
4607 function d3_geo_circleAngle(cr, point) {
4608 var a = d3_geo_cartesian(point);
4609 a[0] -= cr;
4610 d3_geo_cartesianNormalize(a);
4611 var angle = d3_acos(-a[1]);
4612 return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI);
4613 }
4614 d3.geo.distance = function(a, b) {
4615 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;
4616 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Δλ);
4617 };
4618 d3.geo.graticule = function() {
4619 var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5;
4620 function graticule() {
4621 return {
4622 type: "MultiLineString",
4623 coordinates: lines()
4624 };
4625 }
4626 function lines() {
4627 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) {
4628 return abs(x % DX) > ε;
4629 }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) {
4630 return abs(y % DY) > ε;
4631 }).map(y));
4632 }
4633 graticule.lines = function() {
4634 return lines().map(function(coordinates) {
4635 return {
4636 type: "LineString",
4637 coordinates: coordinates
4638 };
4639 });
4640 };
4641 graticule.outline = function() {
4642 return {
4643 type: "Polygon",
4644 coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ]
4645 };
4646 };
4647 graticule.extent = function(_) {
4648 if (!arguments.length) return graticule.minorExtent();
4649 return graticule.majorExtent(_).minorExtent(_);
4650 };
4651 graticule.majorExtent = function(_) {
4652 if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ];
4653 X0 = +_[0][0], X1 = +_[1][0];
4654 Y0 = +_[0][1], Y1 = +_[1][1];
4655 if (X0 > X1) _ = X0, X0 = X1, X1 = _;
4656 if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;
4657 return graticule.precision(precision);
4658 };
4659 graticule.minorExtent = function(_) {
4660 if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];
4661 x0 = +_[0][0], x1 = +_[1][0];
4662 y0 = +_[0][1], y1 = +_[1][1];
4663 if (x0 > x1) _ = x0, x0 = x1, x1 = _;
4664 if (y0 > y1) _ = y0, y0 = y1, y1 = _;
4665 return graticule.precision(precision);
4666 };
4667 graticule.step = function(_) {
4668 if (!arguments.length) return graticule.minorStep();
4669 return graticule.majorStep(_).minorStep(_);
4670 };
4671 graticule.majorStep = function(_) {
4672 if (!arguments.length) return [ DX, DY ];
4673 DX = +_[0], DY = +_[1];
4674 return graticule;
4675 };
4676 graticule.minorStep = function(_) {
4677 if (!arguments.length) return [ dx, dy ];
4678 dx = +_[0], dy = +_[1];
4679 return graticule;
4680 };
4681 graticule.precision = function(_) {
4682 if (!arguments.length) return precision;
4683 precision = +_;
4684 x = d3_geo_graticuleX(y0, y1, 90);
4685 y = d3_geo_graticuleY(x0, x1, precision);
4686 X = d3_geo_graticuleX(Y0, Y1, 90);
4687 Y = d3_geo_graticuleY(X0, X1, precision);
4688 return graticule;
4689 };
4690 return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]);
4691 };
4692 function d3_geo_graticuleX(y0, y1, dy) {
4693 var y = d3.range(y0, y1 - ε, dy).concat(y1);
4694 return function(x) {
4695 return y.map(function(y) {
4696 return [ x, y ];
4697 });
4698 };
4699 }
4700 function d3_geo_graticuleY(x0, x1, dx) {
4701 var x = d3.range(x0, x1 - ε, dx).concat(x1);
4702 return function(y) {
4703 return x.map(function(x) {
4704 return [ x, y ];
4705 });
4706 };
4707 }
4708 function d3_source(d) {
4709 return d.source;
4710 }
4711 function d3_target(d) {
4712 return d.target;
4713 }
4714 d3.geo.greatArc = function() {
4715 var source = d3_source, source_, target = d3_target, target_;
4716 function greatArc() {
4717 return {
4718 type: "LineString",
4719 coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ]
4720 };
4721 }
4722 greatArc.distance = function() {
4723 return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments));
4724 };
4725 greatArc.source = function(_) {
4726 if (!arguments.length) return source;
4727 source = _, source_ = typeof _ === "function" ? null : _;
4728 return greatArc;
4729 };
4730 greatArc.target = function(_) {
4731 if (!arguments.length) return target;
4732 target = _, target_ = typeof _ === "function" ? null : _;
4733 return greatArc;
4734 };
4735 greatArc.precision = function() {
4736 return arguments.length ? greatArc : 0;
4737 };
4738 return greatArc;
4739 };
4740 d3.geo.interpolate = function(source, target) {
4741 return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians);
4742 };
4743 function d3_geo_interpolate(x0, y0, x1, y1) {
4744 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);
4745 var interpolate = d ? function(t) {
4746 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;
4747 return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ];
4748 } : function() {
4749 return [ x0 * d3_degrees, y0 * d3_degrees ];
4750 };
4751 interpolate.distance = d;
4752 return interpolate;
4753 }
4754 d3.geo.length = function(object) {
4755 d3_geo_lengthSum = 0;
4756 d3.geo.stream(object, d3_geo_length);
4757 return d3_geo_lengthSum;
4758 };
4759 var d3_geo_lengthSum;
4760 var d3_geo_length = {
4761 sphere: d3_noop,
4762 point: d3_noop,
4763 lineStart: d3_geo_lengthLineStart,
4764 lineEnd: d3_noop,
4765 polygonStart: d3_noop,
4766 polygonEnd: d3_noop
4767 };
4768 function d3_geo_lengthLineStart() {
4769 var λ0, sinφ0, cosφ0;
4770 d3_geo_length.point = function(λ, φ) {
4771 λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ);
4772 d3_geo_length.point = nextPoint;
4773 };
4774 d3_geo_length.lineEnd = function() {
4775 d3_geo_length.point = d3_geo_length.lineEnd = d3_noop;
4776 };
4777 function nextPoint(λ, φ) {
4778 var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t);
4779 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Δλ);
4780 λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ;
4781 }
4782 }
4783 function d3_geo_azimuthal(scale, angle) {
4784 function azimuthal(λ, φ) {
4785 var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ);
4786 return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ];
4787 }
4788 azimuthal.invert = function(x, y) {
4789 var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c);
4790 return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ];
4791 };
4792 return azimuthal;
4793 }
4794 var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) {
4795 return Math.sqrt(2 / (1 + cosλcosφ));
4796 }, function(ρ) {
4797 return 2 * Math.asin(ρ / 2);
4798 });
4799 (d3.geo.azimuthalEqualArea = function() {
4800 return d3_geo_projection(d3_geo_azimuthalEqualArea);
4801 }).raw = d3_geo_azimuthalEqualArea;
4802 var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) {
4803 var c = Math.acos(cosλcosφ);
4804 return c && c / Math.sin(c);
4805 }, d3_identity);
4806 (d3.geo.azimuthalEquidistant = function() {
4807 return d3_geo_projection(d3_geo_azimuthalEquidistant);
4808 }).raw = d3_geo_azimuthalEquidistant;
4809 function d3_geo_conicConformal(φ0, φ1) {
4810 var cosφ0 = Math.cos(φ0), t = function(φ) {
4811 return Math.tan(π / 4 + φ / 2);
4812 }, 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;
4813 if (!n) return d3_geo_mercator;
4814 function forward(λ, φ) {
4815 if (F > 0) {
4816 if (φ < -halfπ + ε) φ = -halfπ + ε;
4817 } else {
4818 if (φ > halfπ - ε) φ = halfπ - ε;
4819 }
4820 var ρ = F / Math.pow(t(φ), n);
4821 return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ];
4822 }
4823 forward.invert = function(x, y) {
4824 var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y);
4825 return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ];
4826 };
4827 return forward;
4828 }
4829 (d3.geo.conicConformal = function() {
4830 return d3_geo_conic(d3_geo_conicConformal);
4831 }).raw = d3_geo_conicConformal;
4832 function d3_geo_conicEquidistant(φ0, φ1) {
4833 var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0;
4834 if (abs(n) < ε) return d3_geo_equirectangular;
4835 function forward(λ, φ) {
4836 var ρ = G - φ;
4837 return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ];
4838 }
4839 forward.invert = function(x, y) {
4840 var ρ0_y = G - y;
4841 return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ];
4842 };
4843 return forward;
4844 }
4845 (d3.geo.conicEquidistant = function() {
4846 return d3_geo_conic(d3_geo_conicEquidistant);
4847 }).raw = d3_geo_conicEquidistant;
4848 var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) {
4849 return 1 / cosλcosφ;
4850 }, Math.atan);
4851 (d3.geo.gnomonic = function() {
4852 return d3_geo_projection(d3_geo_gnomonic);
4853 }).raw = d3_geo_gnomonic;
4854 function d3_geo_mercator(λ, φ) {
4855 return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ];
4856 }
4857 d3_geo_mercator.invert = function(x, y) {
4858 return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ];
4859 };
4860 function d3_geo_mercatorProjection(project) {
4861 var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto;
4862 m.scale = function() {
4863 var v = scale.apply(m, arguments);
4864 return v === m ? clipAuto ? m.clipExtent(null) : m : v;
4865 };
4866 m.translate = function() {
4867 var v = translate.apply(m, arguments);
4868 return v === m ? clipAuto ? m.clipExtent(null) : m : v;
4869 };
4870 m.clipExtent = function(_) {
4871 var v = clipExtent.apply(m, arguments);
4872 if (v === m) {
4873 if (clipAuto = _ == null) {
4874 var k = π * scale(), t = translate();
4875 clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]);
4876 }
4877 } else if (clipAuto) {
4878 v = null;
4879 }
4880 return v;
4881 };
4882 return m.clipExtent(null);
4883 }
4884 (d3.geo.mercator = function() {
4885 return d3_geo_mercatorProjection(d3_geo_mercator);
4886 }).raw = d3_geo_mercator;
4887 var d3_geo_orthographic = d3_geo_azimuthal(function() {
4888 return 1;
4889 }, Math.asin);
4890 (d3.geo.orthographic = function() {
4891 return d3_geo_projection(d3_geo_orthographic);
4892 }).raw = d3_geo_orthographic;
4893 var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) {
4894 return 1 / (1 + cosλcosφ);
4895 }, function(ρ) {
4896 return 2 * Math.atan(ρ);
4897 });
4898 (d3.geo.stereographic = function() {
4899 return d3_geo_projection(d3_geo_stereographic);
4900 }).raw = d3_geo_stereographic;
4901 function d3_geo_transverseMercator(λ, φ) {
4902 return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ];
4903 }
4904 d3_geo_transverseMercator.invert = function(x, y) {
4905 return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ];
4906 };
4907 (d3.geo.transverseMercator = function() {
4908 var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate;
4909 projection.center = function(_) {
4910 return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]);
4911 };
4912 projection.rotate = function(_) {
4913 return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(),
4914 [ _[0], _[1], _[2] - 90 ]);
4915 };
4916 return rotate([ 0, 0, 90 ]);
4917 }).raw = d3_geo_transverseMercator;
4918 d3.geom = {};
4919 function d3_geom_pointX(d) {
4920 return d[0];
4921 }
4922 function d3_geom_pointY(d) {
4923 return d[1];
4924 }
4925 d3.geom.hull = function(vertices) {
4926 var x = d3_geom_pointX, y = d3_geom_pointY;
4927 if (arguments.length) return hull(vertices);
4928 function hull(data) {
4929 if (data.length < 3) return [];
4930 var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = [];
4931 for (i = 0; i < n; i++) {
4932 points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]);
4933 }
4934 points.sort(d3_geom_hullOrder);
4935 for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]);
4936 var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints);
4937 var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = [];
4938 for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]);
4939 for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]);
4940 return polygon;
4941 }
4942 hull.x = function(_) {
4943 return arguments.length ? (x = _, hull) : x;
4944 };
4945 hull.y = function(_) {
4946 return arguments.length ? (y = _, hull) : y;
4947 };
4948 return hull;
4949 };
4950 function d3_geom_hullUpper(points) {
4951 var n = points.length, hull = [ 0, 1 ], hs = 2;
4952 for (var i = 2; i < n; i++) {
4953 while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs;
4954 hull[hs++] = i;
4955 }
4956 return hull.slice(0, hs);
4957 }
4958 function d3_geom_hullOrder(a, b) {
4959 return a[0] - b[0] || a[1] - b[1];
4960 }
4961 d3.geom.polygon = function(coordinates) {
4962 d3_subclass(coordinates, d3_geom_polygonPrototype);
4963 return coordinates;
4964 };
4965 var d3_geom_polygonPrototype = d3.geom.polygon.prototype = [];
4966 d3_geom_polygonPrototype.area = function() {
4967 var i = -1, n = this.length, a, b = this[n - 1], area = 0;
4968 while (++i < n) {
4969 a = b;
4970 b = this[i];
4971 area += a[1] * b[0] - a[0] * b[1];
4972 }
4973 return area * .5;
4974 };
4975 d3_geom_polygonPrototype.centroid = function(k) {
4976 var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c;
4977 if (!arguments.length) k = -1 / (6 * this.area());
4978 while (++i < n) {
4979 a = b;
4980 b = this[i];
4981 c = a[0] * b[1] - b[0] * a[1];
4982 x += (a[0] + b[0]) * c;
4983 y += (a[1] + b[1]) * c;
4984 }
4985 return [ x * k, y * k ];
4986 };
4987 d3_geom_polygonPrototype.clip = function(subject) {
4988 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;
4989 while (++i < n) {
4990 input = subject.slice();
4991 subject.length = 0;
4992 b = this[i];
4993 c = input[(m = input.length - closed) - 1];
4994 j = -1;
4995 while (++j < m) {
4996 d = input[j];
4997 if (d3_geom_polygonInside(d, a, b)) {
4998 if (!d3_geom_polygonInside(c, a, b)) {
4999 subject.push(d3_geom_polygonIntersect(c, d, a, b));
5000 }
5001 subject.push(d);
5002 } else if (d3_geom_polygonInside(c, a, b)) {
5003 subject.push(d3_geom_polygonIntersect(c, d, a, b));
5004 }
5005 c = d;
5006 }
5007 if (closed) subject.push(subject[0]);
5008 a = b;
5009 }
5010 return subject;
5011 };
5012 function d3_geom_polygonInside(p, a, b) {
5013 return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);
5014 }
5015 function d3_geom_polygonIntersect(c, d, a, b) {
5016 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);
5017 return [ x1 + ua * x21, y1 + ua * y21 ];
5018 }
5019 function d3_geom_polygonClosed(coordinates) {
5020 var a = coordinates[0], b = coordinates[coordinates.length - 1];
5021 return !(a[0] - b[0] || a[1] - b[1]);
5022 }
5023 var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = [];
5024 function d3_geom_voronoiBeach() {
5025 d3_geom_voronoiRedBlackNode(this);
5026 this.edge = this.site = this.circle = null;
5027 }
5028 function d3_geom_voronoiCreateBeach(site) {
5029 var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach();
5030 beach.site = site;
5031 return beach;
5032 }
5033 function d3_geom_voronoiDetachBeach(beach) {
5034 d3_geom_voronoiDetachCircle(beach);
5035 d3_geom_voronoiBeaches.remove(beach);
5036 d3_geom_voronoiBeachPool.push(beach);
5037 d3_geom_voronoiRedBlackNode(beach);
5038 }
5039 function d3_geom_voronoiRemoveBeach(beach) {
5040 var circle = beach.circle, x = circle.x, y = circle.cy, vertex = {
5041 x: x,
5042 y: y
5043 }, previous = beach.P, next = beach.N, disappearing = [ beach ];
5044 d3_geom_voronoiDetachBeach(beach);
5045 var lArc = previous;
5046 while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) {
5047 previous = lArc.P;
5048 disappearing.unshift(lArc);
5049 d3_geom_voronoiDetachBeach(lArc);
5050 lArc = previous;
5051 }
5052 disappearing.unshift(lArc);
5053 d3_geom_voronoiDetachCircle(lArc);
5054 var rArc = next;
5055 while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) {
5056 next = rArc.N;
5057 disappearing.push(rArc);
5058 d3_geom_voronoiDetachBeach(rArc);
5059 rArc = next;
5060 }
5061 disappearing.push(rArc);
5062 d3_geom_voronoiDetachCircle(rArc);
5063 var nArcs = disappearing.length, iArc;
5064 for (iArc = 1; iArc < nArcs; ++iArc) {
5065 rArc = disappearing[iArc];
5066 lArc = disappearing[iArc - 1];
5067 d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);
5068 }
5069 lArc = disappearing[0];
5070 rArc = disappearing[nArcs - 1];
5071 rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex);
5072 d3_geom_voronoiAttachCircle(lArc);
5073 d3_geom_voronoiAttachCircle(rArc);
5074 }
5075 function d3_geom_voronoiAddBeach(site) {
5076 var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._;
5077 while (node) {
5078 dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x;
5079 if (dxl > ε) node = node.L; else {
5080 dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix);
5081 if (dxr > ε) {
5082 if (!node.R) {
5083 lArc = node;
5084 break;
5085 }
5086 node = node.R;
5087 } else {
5088 if (dxl > -ε) {
5089 lArc = node.P;
5090 rArc = node;
5091 } else if (dxr > -ε) {
5092 lArc = node;
5093 rArc = node.N;
5094 } else {
5095 lArc = rArc = node;
5096 }
5097 break;
5098 }
5099 }
5100 }
5101 var newArc = d3_geom_voronoiCreateBeach(site);
5102 d3_geom_voronoiBeaches.insert(lArc, newArc);
5103 if (!lArc && !rArc) return;
5104 if (lArc === rArc) {
5105 d3_geom_voronoiDetachCircle(lArc);
5106 rArc = d3_geom_voronoiCreateBeach(lArc.site);
5107 d3_geom_voronoiBeaches.insert(newArc, rArc);
5108 newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);
5109 d3_geom_voronoiAttachCircle(lArc);
5110 d3_geom_voronoiAttachCircle(rArc);
5111 return;
5112 }
5113 if (!rArc) {
5114 newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);
5115 return;
5116 }
5117 d3_geom_voronoiDetachCircle(lArc);
5118 d3_geom_voronoiDetachCircle(rArc);
5119 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 = {
5120 x: (cy * hb - by * hc) / d + ax,
5121 y: (bx * hc - cx * hb) / d + ay
5122 };
5123 d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex);
5124 newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex);
5125 rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex);
5126 d3_geom_voronoiAttachCircle(lArc);
5127 d3_geom_voronoiAttachCircle(rArc);
5128 }
5129 function d3_geom_voronoiLeftBreakPoint(arc, directrix) {
5130 var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix;
5131 if (!pby2) return rfocx;
5132 var lArc = arc.P;
5133 if (!lArc) return -Infinity;
5134 site = lArc.site;
5135 var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix;
5136 if (!plby2) return lfocx;
5137 var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2;
5138 if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;
5139 return (rfocx + lfocx) / 2;
5140 }
5141 function d3_geom_voronoiRightBreakPoint(arc, directrix) {
5142 var rArc = arc.N;
5143 if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix);
5144 var site = arc.site;
5145 return site.y === directrix ? site.x : Infinity;
5146 }
5147 function d3_geom_voronoiCell(site) {
5148 this.site = site;
5149 this.edges = [];
5150 }
5151 d3_geom_voronoiCell.prototype.prepare = function() {
5152 var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge;
5153 while (iHalfEdge--) {
5154 edge = halfEdges[iHalfEdge].edge;
5155 if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1);
5156 }
5157 halfEdges.sort(d3_geom_voronoiHalfEdgeOrder);
5158 return halfEdges.length;
5159 };
5160 function d3_geom_voronoiCloseCells(extent) {
5161 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;
5162 while (iCell--) {
5163 cell = cells[iCell];
5164 if (!cell || !cell.prepare()) continue;
5165 halfEdges = cell.edges;
5166 nHalfEdges = halfEdges.length;
5167 iHalfEdge = 0;
5168 while (iHalfEdge < nHalfEdges) {
5169 end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y;
5170 start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y;
5171 if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) {
5172 halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? {
5173 x: x0,
5174 y: abs(x2 - x0) < ε ? y2 : y1
5175 } : abs(y3 - y1) < ε && x1 - x3 > ε ? {
5176 x: abs(y2 - y1) < ε ? x2 : x1,
5177 y: y1
5178 } : abs(x3 - x1) < ε && y3 - y0 > ε ? {
5179 x: x1,
5180 y: abs(x2 - x1) < ε ? y2 : y0
5181 } : abs(y3 - y0) < ε && x3 - x0 > ε ? {
5182 x: abs(y2 - y0) < ε ? x2 : x0,
5183 y: y0
5184 } : null), cell.site, null));
5185 ++nHalfEdges;
5186 }
5187 }
5188 }
5189 }
5190 function d3_geom_voronoiHalfEdgeOrder(a, b) {
5191 return b.angle - a.angle;
5192 }
5193 function d3_geom_voronoiCircle() {
5194 d3_geom_voronoiRedBlackNode(this);
5195 this.x = this.y = this.arc = this.site = this.cy = null;
5196 }
5197 function d3_geom_voronoiAttachCircle(arc) {
5198 var lArc = arc.P, rArc = arc.N;
5199 if (!lArc || !rArc) return;
5200 var lSite = lArc.site, cSite = arc.site, rSite = rArc.site;
5201 if (lSite === rSite) return;
5202 var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by;
5203 var d = 2 * (ax * cy - ay * cx);
5204 if (d >= -ε2) return;
5205 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;
5206 var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle();
5207 circle.arc = arc;
5208 circle.site = cSite;
5209 circle.x = x + bx;
5210 circle.y = cy + Math.sqrt(x * x + y * y);
5211 circle.cy = cy;
5212 arc.circle = circle;
5213 var before = null, node = d3_geom_voronoiCircles._;
5214 while (node) {
5215 if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) {
5216 if (node.L) node = node.L; else {
5217 before = node.P;
5218 break;
5219 }
5220 } else {
5221 if (node.R) node = node.R; else {
5222 before = node;
5223 break;
5224 }
5225 }
5226 }
5227 d3_geom_voronoiCircles.insert(before, circle);
5228 if (!before) d3_geom_voronoiFirstCircle = circle;
5229 }
5230 function d3_geom_voronoiDetachCircle(arc) {
5231 var circle = arc.circle;
5232 if (circle) {
5233 if (!circle.P) d3_geom_voronoiFirstCircle = circle.N;
5234 d3_geom_voronoiCircles.remove(circle);
5235 d3_geom_voronoiCirclePool.push(circle);
5236 d3_geom_voronoiRedBlackNode(circle);
5237 arc.circle = null;
5238 }
5239 }
5240 function d3_geom_voronoiClipEdges(extent) {
5241 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;
5242 while (i--) {
5243 e = edges[i];
5244 if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) {
5245 e.a = e.b = null;
5246 edges.splice(i, 1);
5247 }
5248 }
5249 }
5250 function d3_geom_voronoiConnectEdge(edge, extent) {
5251 var vb = edge.b;
5252 if (vb) return true;
5253 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;
5254 if (ry === ly) {
5255 if (fx < x0 || fx >= x1) return;
5256 if (lx > rx) {
5257 if (!va) va = {
5258 x: fx,
5259 y: y0
5260 }; else if (va.y >= y1) return;
5261 vb = {
5262 x: fx,
5263 y: y1
5264 };
5265 } else {
5266 if (!va) va = {
5267 x: fx,
5268 y: y1
5269 }; else if (va.y < y0) return;
5270 vb = {
5271 x: fx,
5272 y: y0
5273 };
5274 }
5275 } else {
5276 fm = (lx - rx) / (ry - ly);
5277 fb = fy - fm * fx;
5278 if (fm < -1 || fm > 1) {
5279 if (lx > rx) {
5280 if (!va) va = {
5281 x: (y0 - fb) / fm,
5282 y: y0
5283 }; else if (va.y >= y1) return;
5284 vb = {
5285 x: (y1 - fb) / fm,
5286 y: y1
5287 };
5288 } else {
5289 if (!va) va = {
5290 x: (y1 - fb) / fm,
5291 y: y1
5292 }; else if (va.y < y0) return;
5293 vb = {
5294 x: (y0 - fb) / fm,
5295 y: y0
5296 };
5297 }
5298 } else {
5299 if (ly < ry) {
5300 if (!va) va = {
5301 x: x0,
5302 y: fm * x0 + fb
5303 }; else if (va.x >= x1) return;
5304 vb = {
5305 x: x1,
5306 y: fm * x1 + fb
5307 };
5308 } else {
5309 if (!va) va = {
5310 x: x1,
5311 y: fm * x1 + fb
5312 }; else if (va.x < x0) return;
5313 vb = {
5314 x: x0,
5315 y: fm * x0 + fb
5316 };
5317 }
5318 }
5319 }
5320 edge.a = va;
5321 edge.b = vb;
5322 return true;
5323 }
5324 function d3_geom_voronoiEdge(lSite, rSite) {
5325 this.l = lSite;
5326 this.r = rSite;
5327 this.a = this.b = null;
5328 }
5329 function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) {
5330 var edge = new d3_geom_voronoiEdge(lSite, rSite);
5331 d3_geom_voronoiEdges.push(edge);
5332 if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va);
5333 if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb);
5334 d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite));
5335 d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite));
5336 return edge;
5337 }
5338 function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) {
5339 var edge = new d3_geom_voronoiEdge(lSite, null);
5340 edge.a = va;
5341 edge.b = vb;
5342 d3_geom_voronoiEdges.push(edge);
5343 return edge;
5344 }
5345 function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) {
5346 if (!edge.a && !edge.b) {
5347 edge.a = vertex;
5348 edge.l = lSite;
5349 edge.r = rSite;
5350 } else if (edge.l === rSite) {
5351 edge.b = vertex;
5352 } else {
5353 edge.a = vertex;
5354 }
5355 }
5356 function d3_geom_voronoiHalfEdge(edge, lSite, rSite) {
5357 var va = edge.a, vb = edge.b;
5358 this.edge = edge;
5359 this.site = lSite;
5360 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);
5361 }
5362 d3_geom_voronoiHalfEdge.prototype = {
5363 start: function() {
5364 return this.edge.l === this.site ? this.edge.a : this.edge.b;
5365 },
5366 end: function() {
5367 return this.edge.l === this.site ? this.edge.b : this.edge.a;
5368 }
5369 };
5370 function d3_geom_voronoiRedBlackTree() {
5371 this._ = null;
5372 }
5373 function d3_geom_voronoiRedBlackNode(node) {
5374 node.U = node.C = node.L = node.R = node.P = node.N = null;
5375 }
5376 d3_geom_voronoiRedBlackTree.prototype = {
5377 insert: function(after, node) {
5378 var parent, grandpa, uncle;
5379 if (after) {
5380 node.P = after;
5381 node.N = after.N;
5382 if (after.N) after.N.P = node;
5383 after.N = node;
5384 if (after.R) {
5385 after = after.R;
5386 while (after.L) after = after.L;
5387 after.L = node;
5388 } else {
5389 after.R = node;
5390 }
5391 parent = after;
5392 } else if (this._) {
5393 after = d3_geom_voronoiRedBlackFirst(this._);
5394 node.P = null;
5395 node.N = after;
5396 after.P = after.L = node;
5397 parent = after;
5398 } else {
5399 node.P = node.N = null;
5400 this._ = node;
5401 parent = null;
5402 }
5403 node.L = node.R = null;
5404 node.U = parent;
5405 node.C = true;
5406 after = node;
5407 while (parent && parent.C) {
5408 grandpa = parent.U;
5409 if (parent === grandpa.L) {
5410 uncle = grandpa.R;
5411 if (uncle && uncle.C) {
5412 parent.C = uncle.C = false;
5413 grandpa.C = true;
5414 after = grandpa;
5415 } else {
5416 if (after === parent.R) {
5417 d3_geom_voronoiRedBlackRotateLeft(this, parent);
5418 after = parent;
5419 parent = after.U;
5420 }
5421 parent.C = false;
5422 grandpa.C = true;
5423 d3_geom_voronoiRedBlackRotateRight(this, grandpa);
5424 }
5425 } else {
5426 uncle = grandpa.L;
5427 if (uncle && uncle.C) {
5428 parent.C = uncle.C = false;
5429 grandpa.C = true;
5430 after = grandpa;
5431 } else {
5432 if (after === parent.L) {
5433 d3_geom_voronoiRedBlackRotateRight(this, parent);
5434 after = parent;
5435 parent = after.U;
5436 }
5437 parent.C = false;
5438 grandpa.C = true;
5439 d3_geom_voronoiRedBlackRotateLeft(this, grandpa);
5440 }
5441 }
5442 parent = after.U;
5443 }
5444 this._.C = false;
5445 },
5446 remove: function(node) {
5447 if (node.N) node.N.P = node.P;
5448 if (node.P) node.P.N = node.N;
5449 node.N = node.P = null;
5450 var parent = node.U, sibling, left = node.L, right = node.R, next, red;
5451 if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right);
5452 if (parent) {
5453 if (parent.L === node) parent.L = next; else parent.R = next;
5454 } else {
5455 this._ = next;
5456 }
5457 if (left && right) {
5458 red = next.C;
5459 next.C = node.C;
5460 next.L = left;
5461 left.U = next;
5462 if (next !== right) {
5463 parent = next.U;
5464 next.U = node.U;
5465 node = next.R;
5466 parent.L = node;
5467 next.R = right;
5468 right.U = next;
5469 } else {
5470 next.U = parent;
5471 parent = next;
5472 node = next.R;
5473 }
5474 } else {
5475 red = node.C;
5476 node = next;
5477 }
5478 if (node) node.U = parent;
5479 if (red) return;
5480 if (node && node.C) {
5481 node.C = false;
5482 return;
5483 }
5484 do {
5485 if (node === this._) break;
5486 if (node === parent.L) {
5487 sibling = parent.R;
5488 if (sibling.C) {
5489 sibling.C = false;
5490 parent.C = true;
5491 d3_geom_voronoiRedBlackRotateLeft(this, parent);
5492 sibling = parent.R;
5493 }
5494 if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
5495 if (!sibling.R || !sibling.R.C) {
5496 sibling.L.C = false;
5497 sibling.C = true;
5498 d3_geom_voronoiRedBlackRotateRight(this, sibling);
5499 sibling = parent.R;
5500 }
5501 sibling.C = parent.C;
5502 parent.C = sibling.R.C = false;
5503 d3_geom_voronoiRedBlackRotateLeft(this, parent);
5504 node = this._;
5505 break;
5506 }
5507 } else {
5508 sibling = parent.L;
5509 if (sibling.C) {
5510 sibling.C = false;
5511 parent.C = true;
5512 d3_geom_voronoiRedBlackRotateRight(this, parent);
5513 sibling = parent.L;
5514 }
5515 if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
5516 if (!sibling.L || !sibling.L.C) {
5517 sibling.R.C = false;
5518 sibling.C = true;
5519 d3_geom_voronoiRedBlackRotateLeft(this, sibling);
5520 sibling = parent.L;
5521 }
5522 sibling.C = parent.C;
5523 parent.C = sibling.L.C = false;
5524 d3_geom_voronoiRedBlackRotateRight(this, parent);
5525 node = this._;
5526 break;
5527 }
5528 }
5529 sibling.C = true;
5530 node = parent;
5531 parent = parent.U;
5532 } while (!node.C);
5533 if (node) node.C = false;
5534 }
5535 };
5536 function d3_geom_voronoiRedBlackRotateLeft(tree, node) {
5537 var p = node, q = node.R, parent = p.U;
5538 if (parent) {
5539 if (parent.L === p) parent.L = q; else parent.R = q;
5540 } else {
5541 tree._ = q;
5542 }
5543 q.U = parent;
5544 p.U = q;
5545 p.R = q.L;
5546 if (p.R) p.R.U = p;
5547 q.L = p;
5548 }
5549 function d3_geom_voronoiRedBlackRotateRight(tree, node) {
5550 var p = node, q = node.L, parent = p.U;
5551 if (parent) {
5552 if (parent.L === p) parent.L = q; else parent.R = q;
5553 } else {
5554 tree._ = q;
5555 }
5556 q.U = parent;
5557 p.U = q;
5558 p.L = q.R;
5559 if (p.L) p.L.U = p;
5560 q.R = p;
5561 }
5562 function d3_geom_voronoiRedBlackFirst(node) {
5563 while (node.L) node = node.L;
5564 return node;
5565 }
5566 function d3_geom_voronoi(sites, bbox) {
5567 var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle;
5568 d3_geom_voronoiEdges = [];
5569 d3_geom_voronoiCells = new Array(sites.length);
5570 d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree();
5571 d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree();
5572 while (true) {
5573 circle = d3_geom_voronoiFirstCircle;
5574 if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) {
5575 if (site.x !== x0 || site.y !== y0) {
5576 d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site);
5577 d3_geom_voronoiAddBeach(site);
5578 x0 = site.x, y0 = site.y;
5579 }
5580 site = sites.pop();
5581 } else if (circle) {
5582 d3_geom_voronoiRemoveBeach(circle.arc);
5583 } else {
5584 break;
5585 }
5586 }
5587 if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox);
5588 var diagram = {
5589 cells: d3_geom_voronoiCells,
5590 edges: d3_geom_voronoiEdges
5591 };
5592 d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null;
5593 return diagram;
5594 }
5595 function d3_geom_voronoiVertexOrder(a, b) {
5596 return b.y - a.y || b.x - a.x;
5597 }
5598 d3.geom.voronoi = function(points) {
5599 var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent;
5600 if (points) return voronoi(points);
5601 function voronoi(data) {
5602 var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1];
5603 d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) {
5604 var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) {
5605 var s = e.start();
5606 return [ s.x, s.y ];
5607 }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : [];
5608 polygon.point = data[i];
5609 });
5610 return polygons;
5611 }
5612 function sites(data) {
5613 return data.map(function(d, i) {
5614 return {
5615 x: Math.round(fx(d, i) / ε) * ε,
5616 y: Math.round(fy(d, i) / ε) * ε,
5617 i: i
5618 };
5619 });
5620 }
5621 voronoi.links = function(data) {
5622 return d3_geom_voronoi(sites(data)).edges.filter(function(edge) {
5623 return edge.l && edge.r;
5624 }).map(function(edge) {
5625 return {
5626 source: data[edge.l.i],
5627 target: data[edge.r.i]
5628 };
5629 });
5630 };
5631 voronoi.triangles = function(data) {
5632 var triangles = [];
5633 d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) {
5634 var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l;
5635 while (++j < m) {
5636 s0 = s1;
5637 e1 = edges[j].edge;
5638 s1 = e1.l === site ? e1.r : e1.l;
5639 if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) {
5640 triangles.push([ data[i], data[s0.i], data[s1.i] ]);
5641 }
5642 }
5643 });
5644 return triangles;
5645 };
5646 voronoi.x = function(_) {
5647 return arguments.length ? (fx = d3_functor(x = _), voronoi) : x;
5648 };
5649 voronoi.y = function(_) {
5650 return arguments.length ? (fy = d3_functor(y = _), voronoi) : y;
5651 };
5652 voronoi.clipExtent = function(_) {
5653 if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent;
5654 clipExtent = _ == null ? d3_geom_voronoiClipExtent : _;
5655 return voronoi;
5656 };
5657 voronoi.size = function(_) {
5658 if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1];
5659 return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]);
5660 };
5661 return voronoi;
5662 };
5663 var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ];
5664 function d3_geom_voronoiTriangleArea(a, b, c) {
5665 return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y);
5666 }
5667 d3.geom.delaunay = function(vertices) {
5668 return d3.geom.voronoi().triangles(vertices);
5669 };
5670 d3.geom.quadtree = function(points, x1, y1, x2, y2) {
5671 var x = d3_geom_pointX, y = d3_geom_pointY, compat;
5672 if (compat = arguments.length) {
5673 x = d3_geom_quadtreeCompatX;
5674 y = d3_geom_quadtreeCompatY;
5675 if (compat === 3) {
5676 y2 = y1;
5677 x2 = x1;
5678 y1 = x1 = 0;
5679 }
5680 return quadtree(points);
5681 }
5682 function quadtree(data) {
5683 var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_;
5684 if (x1 != null) {
5685 x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2;
5686 } else {
5687 x2_ = y2_ = -(x1_ = y1_ = Infinity);
5688 xs = [], ys = [];
5689 n = data.length;
5690 if (compat) for (i = 0; i < n; ++i) {
5691 d = data[i];
5692 if (d.x < x1_) x1_ = d.x;
5693 if (d.y < y1_) y1_ = d.y;
5694 if (d.x > x2_) x2_ = d.x;
5695 if (d.y > y2_) y2_ = d.y;
5696 xs.push(d.x);
5697 ys.push(d.y);
5698 } else for (i = 0; i < n; ++i) {
5699 var x_ = +fx(d = data[i], i), y_ = +fy(d, i);
5700 if (x_ < x1_) x1_ = x_;
5701 if (y_ < y1_) y1_ = y_;
5702 if (x_ > x2_) x2_ = x_;
5703 if (y_ > y2_) y2_ = y_;
5704 xs.push(x_);
5705 ys.push(y_);
5706 }
5707 }
5708 var dx = x2_ - x1_, dy = y2_ - y1_;
5709 if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy;
5710 function insert(n, d, x, y, x1, y1, x2, y2) {
5711 if (isNaN(x) || isNaN(y)) return;
5712 if (n.leaf) {
5713 var nx = n.x, ny = n.y;
5714 if (nx != null) {
5715 if (abs(nx - x) + abs(ny - y) < .01) {
5716 insertChild(n, d, x, y, x1, y1, x2, y2);
5717 } else {
5718 var nPoint = n.point;
5719 n.x = n.y = n.point = null;
5720 insertChild(n, nPoint, nx, ny, x1, y1, x2, y2);
5721 insertChild(n, d, x, y, x1, y1, x2, y2);
5722 }
5723 } else {
5724 n.x = x, n.y = y, n.point = d;
5725 }
5726 } else {
5727 insertChild(n, d, x, y, x1, y1, x2, y2);
5728 }
5729 }
5730 function insertChild(n, d, x, y, x1, y1, x2, y2) {
5731 var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right;
5732 n.leaf = false;
5733 n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());
5734 if (right) x1 = xm; else x2 = xm;
5735 if (below) y1 = ym; else y2 = ym;
5736 insert(n, d, x, y, x1, y1, x2, y2);
5737 }
5738 var root = d3_geom_quadtreeNode();
5739 root.add = function(d) {
5740 insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_);
5741 };
5742 root.visit = function(f) {
5743 d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);
5744 };
5745 root.find = function(point) {
5746 return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);
5747 };
5748 i = -1;
5749 if (x1 == null) {
5750 while (++i < n) {
5751 insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_);
5752 }
5753 --i;
5754 } else data.forEach(root.add);
5755 xs = ys = data = d = null;
5756 return root;
5757 }
5758 quadtree.x = function(_) {
5759 return arguments.length ? (x = _, quadtree) : x;
5760 };
5761 quadtree.y = function(_) {
5762 return arguments.length ? (y = _, quadtree) : y;
5763 };
5764 quadtree.extent = function(_) {
5765 if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];
5766 if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0],
5767 y2 = +_[1][1];
5768 return quadtree;
5769 };
5770 quadtree.size = function(_) {
5771 if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ];
5772 if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1];
5773 return quadtree;
5774 };
5775 return quadtree;
5776 };
5777 function d3_geom_quadtreeCompatX(d) {
5778 return d.x;
5779 }
5780 function d3_geom_quadtreeCompatY(d) {
5781 return d.y;
5782 }
5783 function d3_geom_quadtreeNode() {
5784 return {
5785 leaf: true,
5786 nodes: [],
5787 point: null,
5788 x: null,
5789 y: null
5790 };
5791 }
5792 function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {
5793 if (!f(node, x1, y1, x2, y2)) {
5794 var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes;
5795 if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);
5796 if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);
5797 if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);
5798 if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
5799 }
5800 }
5801 function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) {
5802 var minDistance2 = Infinity, closestPoint;
5803 (function find(node, x1, y1, x2, y2) {
5804 if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return;
5805 if (point = node.point) {
5806 var point, dx = x - node.x, dy = y - node.y, distance2 = dx * dx + dy * dy;
5807 if (distance2 < minDistance2) {
5808 var distance = Math.sqrt(minDistance2 = distance2);
5809 x0 = x - distance, y0 = y - distance;
5810 x3 = x + distance, y3 = y + distance;
5811 closestPoint = point;
5812 }
5813 }
5814 var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym;
5815 for (var i = below << 1 | right, j = i + 4; i < j; ++i) {
5816 if (node = children[i & 3]) switch (i & 3) {
5817 case 0:
5818 find(node, x1, y1, xm, ym);
5819 break;
5820
5821 case 1:
5822 find(node, xm, y1, x2, ym);
5823 break;
5824
5825 case 2:
5826 find(node, x1, ym, xm, y2);
5827 break;
5828
5829 case 3:
5830 find(node, xm, ym, x2, y2);
5831 break;
5832 }
5833 }
5834 })(root, x0, y0, x3, y3);
5835 return closestPoint;
5836 }
5837 d3.interpolateRgb = d3_interpolateRgb;
5838 function d3_interpolateRgb(a, b) {
5839 a = d3.rgb(a);
5840 b = d3.rgb(b);
5841 var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab;
5842 return function(t) {
5843 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));
5844 };
5845 }
5846 d3.interpolateObject = d3_interpolateObject;
5847 function d3_interpolateObject(a, b) {
5848 var i = {}, c = {}, k;
5849 for (k in a) {
5850 if (k in b) {
5851 i[k] = d3_interpolate(a[k], b[k]);
5852 } else {
5853 c[k] = a[k];
5854 }
5855 }
5856 for (k in b) {
5857 if (!(k in a)) {
5858 c[k] = b[k];
5859 }
5860 }
5861 return function(t) {
5862 for (k in i) c[k] = i[k](t);
5863 return c;
5864 };
5865 }
5866 d3.interpolateNumber = d3_interpolateNumber;
5867 function d3_interpolateNumber(a, b) {
5868 a = +a, b = +b;
5869 return function(t) {
5870 return a * (1 - t) + b * t;
5871 };
5872 }
5873 d3.interpolateString = d3_interpolateString;
5874 function d3_interpolateString(a, b) {
5875 var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];
5876 a = a + "", b = b + "";
5877 while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) {
5878 if ((bs = bm.index) > bi) {
5879 bs = b.slice(bi, bs);
5880 if (s[i]) s[i] += bs; else s[++i] = bs;
5881 }
5882 if ((am = am[0]) === (bm = bm[0])) {
5883 if (s[i]) s[i] += bm; else s[++i] = bm;
5884 } else {
5885 s[++i] = null;
5886 q.push({
5887 i: i,
5888 x: d3_interpolateNumber(am, bm)
5889 });
5890 }
5891 bi = d3_interpolate_numberB.lastIndex;
5892 }
5893 if (bi < b.length) {
5894 bs = b.slice(bi);
5895 if (s[i]) s[i] += bs; else s[++i] = bs;
5896 }
5897 return s.length < 2 ? q[0] ? (b = q[0].x, function(t) {
5898 return b(t) + "";
5899 }) : function() {
5900 return b;
5901 } : (b = q.length, function(t) {
5902 for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
5903 return s.join("");
5904 });
5905 }
5906 var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g");
5907 d3.interpolate = d3_interpolate;
5908 function d3_interpolate(a, b) {
5909 var i = d3.interpolators.length, f;
5910 while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ;
5911 return f;
5912 }
5913 d3.interpolators = [ function(a, b) {
5914 var t = typeof b;
5915 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);
5916 } ];
5917 d3.interpolateArray = d3_interpolateArray;
5918 function d3_interpolateArray(a, b) {
5919 var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i;
5920 for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i]));
5921 for (;i < na; ++i) c[i] = a[i];
5922 for (;i < nb; ++i) c[i] = b[i];
5923 return function(t) {
5924 for (i = 0; i < n0; ++i) c[i] = x[i](t);
5925 return c;
5926 };
5927 }
5928 var d3_ease_default = function() {
5929 return d3_identity;
5930 };
5931 var d3_ease = d3.map({
5932 linear: d3_ease_default,
5933 poly: d3_ease_poly,
5934 quad: function() {
5935 return d3_ease_quad;
5936 },
5937 cubic: function() {
5938 return d3_ease_cubic;
5939 },
5940 sin: function() {
5941 return d3_ease_sin;
5942 },
5943 exp: function() {
5944 return d3_ease_exp;
5945 },
5946 circle: function() {
5947 return d3_ease_circle;
5948 },
5949 elastic: d3_ease_elastic,
5950 back: d3_ease_back,
5951 bounce: function() {
5952 return d3_ease_bounce;
5953 }
5954 });
5955 var d3_ease_mode = d3.map({
5956 "in": d3_identity,
5957 out: d3_ease_reverse,
5958 "in-out": d3_ease_reflect,
5959 "out-in": function(f) {
5960 return d3_ease_reflect(d3_ease_reverse(f));
5961 }
5962 });
5963 d3.ease = function(name) {
5964 var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in";
5965 t = d3_ease.get(t) || d3_ease_default;
5966 m = d3_ease_mode.get(m) || d3_identity;
5967 return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1))));
5968 };
5969 function d3_ease_clamp(f) {
5970 return function(t) {
5971 return t <= 0 ? 0 : t >= 1 ? 1 : f(t);
5972 };
5973 }
5974 function d3_ease_reverse(f) {
5975 return function(t) {
5976 return 1 - f(1 - t);
5977 };
5978 }
5979 function d3_ease_reflect(f) {
5980 return function(t) {
5981 return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t));
5982 };
5983 }
5984 function d3_ease_quad(t) {
5985 return t * t;
5986 }
5987 function d3_ease_cubic(t) {
5988 return t * t * t;
5989 }
5990 function d3_ease_cubicInOut(t) {
5991 if (t <= 0) return 0;
5992 if (t >= 1) return 1;
5993 var t2 = t * t, t3 = t2 * t;
5994 return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75);
5995 }
5996 function d3_ease_poly(e) {
5997 return function(t) {
5998 return Math.pow(t, e);
5999 };
6000 }
6001 function d3_ease_sin(t) {
6002 return 1 - Math.cos(t * halfπ);
6003 }
6004 function d3_ease_exp(t) {
6005 return Math.pow(2, 10 * (t - 1));
6006 }
6007 function d3_ease_circle(t) {
6008 return 1 - Math.sqrt(1 - t * t);
6009 }
6010 function d3_ease_elastic(a, p) {
6011 var s;
6012 if (arguments.length < 2) p = .45;
6013 if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4;
6014 return function(t) {
6015 return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p);
6016 };
6017 }
6018 function d3_ease_back(s) {
6019 if (!s) s = 1.70158;
6020 return function(t) {
6021 return t * t * ((s + 1) * t - s);
6022 };
6023 }
6024 function d3_ease_bounce(t) {
6025 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;
6026 }
6027 d3.interpolateHcl = d3_interpolateHcl;
6028 function d3_interpolateHcl(a, b) {
6029 a = d3.hcl(a);
6030 b = d3.hcl(b);
6031 var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al;
6032 if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac;
6033 if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
6034 return function(t) {
6035 return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + "";
6036 };
6037 }
6038 d3.interpolateHsl = d3_interpolateHsl;
6039 function d3_interpolateHsl(a, b) {
6040 a = d3.hsl(a);
6041 b = d3.hsl(b);
6042 var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al;
6043 if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as;
6044 if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
6045 return function(t) {
6046 return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + "";
6047 };
6048 }
6049 d3.interpolateLab = d3_interpolateLab;
6050 function d3_interpolateLab(a, b) {
6051 a = d3.lab(a);
6052 b = d3.lab(b);
6053 var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab;
6054 return function(t) {
6055 return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + "";
6056 };
6057 }
6058 d3.interpolateRound = d3_interpolateRound;
6059 function d3_interpolateRound(a, b) {
6060 b -= a;
6061 return function(t) {
6062 return Math.round(a + b * t);
6063 };
6064 }
6065 d3.transform = function(string) {
6066 var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
6067 return (d3.transform = function(string) {
6068 if (string != null) {
6069 g.setAttribute("transform", string);
6070 var t = g.transform.baseVal.consolidate();
6071 }
6072 return new d3_transform(t ? t.matrix : d3_transformIdentity);
6073 })(string);
6074 };
6075 function d3_transform(m) {
6076 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;
6077 if (r0[0] * r1[1] < r1[0] * r0[1]) {
6078 r0[0] *= -1;
6079 r0[1] *= -1;
6080 kx *= -1;
6081 kz *= -1;
6082 }
6083 this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees;
6084 this.translate = [ m.e, m.f ];
6085 this.scale = [ kx, ky ];
6086 this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0;
6087 }
6088 d3_transform.prototype.toString = function() {
6089 return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")";
6090 };
6091 function d3_transformDot(a, b) {
6092 return a[0] * b[0] + a[1] * b[1];
6093 }
6094 function d3_transformNormalize(a) {
6095 var k = Math.sqrt(d3_transformDot(a, a));
6096 if (k) {
6097 a[0] /= k;
6098 a[1] /= k;
6099 }
6100 return k;
6101 }
6102 function d3_transformCombine(a, b, k) {
6103 a[0] += k * b[0];
6104 a[1] += k * b[1];
6105 return a;
6106 }
6107 var d3_transformIdentity = {
6108 a: 1,
6109 b: 0,
6110 c: 0,
6111 d: 1,
6112 e: 0,
6113 f: 0
6114 };
6115 d3.interpolateTransform = d3_interpolateTransform;
6116 function d3_interpolateTransformPop(s) {
6117 return s.length ? s.pop() + "," : "";
6118 }
6119 function d3_interpolateTranslate(ta, tb, s, q) {
6120 if (ta[0] !== tb[0] || ta[1] !== tb[1]) {
6121 var i = s.push("translate(", null, ",", null, ")");
6122 q.push({
6123 i: i - 4,
6124 x: d3_interpolateNumber(ta[0], tb[0])
6125 }, {
6126 i: i - 2,
6127 x: d3_interpolateNumber(ta[1], tb[1])
6128 });
6129 } else if (tb[0] || tb[1]) {
6130 s.push("translate(" + tb + ")");
6131 }
6132 }
6133 function d3_interpolateRotate(ra, rb, s, q) {
6134 if (ra !== rb) {
6135 if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360;
6136 q.push({
6137 i: s.push(d3_interpolateTransformPop(s) + "rotate(", null, ")") - 2,
6138 x: d3_interpolateNumber(ra, rb)
6139 });
6140 } else if (rb) {
6141 s.push(d3_interpolateTransformPop(s) + "rotate(" + rb + ")");
6142 }
6143 }
6144 function d3_interpolateSkew(wa, wb, s, q) {
6145 if (wa !== wb) {
6146 q.push({
6147 i: s.push(d3_interpolateTransformPop(s) + "skewX(", null, ")") - 2,
6148 x: d3_interpolateNumber(wa, wb)
6149 });
6150 } else if (wb) {
6151 s.push(d3_interpolateTransformPop(s) + "skewX(" + wb + ")");
6152 }
6153 }
6154 function d3_interpolateScale(ka, kb, s, q) {
6155 if (ka[0] !== kb[0] || ka[1] !== kb[1]) {
6156 var i = s.push(d3_interpolateTransformPop(s) + "scale(", null, ",", null, ")");
6157 q.push({
6158 i: i - 4,
6159 x: d3_interpolateNumber(ka[0], kb[0])
6160 }, {
6161 i: i - 2,
6162 x: d3_interpolateNumber(ka[1], kb[1])
6163 });
6164 } else if (kb[0] !== 1 || kb[1] !== 1) {
6165 s.push(d3_interpolateTransformPop(s) + "scale(" + kb + ")");
6166 }
6167 }
6168 function d3_interpolateTransform(a, b) {
6169 var s = [], q = [];
6170 a = d3.transform(a), b = d3.transform(b);
6171 d3_interpolateTranslate(a.translate, b.translate, s, q);
6172 d3_interpolateRotate(a.rotate, b.rotate, s, q);
6173 d3_interpolateSkew(a.skew, b.skew, s, q);
6174 d3_interpolateScale(a.scale, b.scale, s, q);
6175 a = b = null;
6176 return function(t) {
6177 var i = -1, n = q.length, o;
6178 while (++i < n) s[(o = q[i]).i] = o.x(t);
6179 return s.join("");
6180 };
6181 }
6182 function d3_uninterpolateNumber(a, b) {
6183 b = (b -= a = +a) || 1 / b;
6184 return function(x) {
6185 return (x - a) / b;
6186 };
6187 }
6188 function d3_uninterpolateClamp(a, b) {
6189 b = (b -= a = +a) || 1 / b;
6190 return function(x) {
6191 return Math.max(0, Math.min(1, (x - a) / b));
6192 };
6193 }
6194 d3.layout = {};
6195 d3.layout.bundle = function() {
6196 return function(links) {
6197 var paths = [], i = -1, n = links.length;
6198 while (++i < n) paths.push(d3_layout_bundlePath(links[i]));
6199 return paths;
6200 };
6201 };
6202 function d3_layout_bundlePath(link) {
6203 var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ];
6204 while (start !== lca) {
6205 start = start.parent;
6206 points.push(start);
6207 }
6208 var k = points.length;
6209 while (end !== lca) {
6210 points.splice(k, 0, end);
6211 end = end.parent;
6212 }
6213 return points;
6214 }
6215 function d3_layout_bundleAncestors(node) {
6216 var ancestors = [], parent = node.parent;
6217 while (parent != null) {
6218 ancestors.push(node);
6219 node = parent;
6220 parent = parent.parent;
6221 }
6222 ancestors.push(node);
6223 return ancestors;
6224 }
6225 function d3_layout_bundleLeastCommonAncestor(a, b) {
6226 if (a === b) return a;
6227 var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null;
6228 while (aNode === bNode) {
6229 sharedNode = aNode;
6230 aNode = aNodes.pop();
6231 bNode = bNodes.pop();
6232 }
6233 return sharedNode;
6234 }
6235 d3.layout.chord = function() {
6236 var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;
6237 function relayout() {
6238 var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j;
6239 chords = [];
6240 groups = [];
6241 k = 0, i = -1;
6242 while (++i < n) {
6243 x = 0, j = -1;
6244 while (++j < n) {
6245 x += matrix[i][j];
6246 }
6247 groupSums.push(x);
6248 subgroupIndex.push(d3.range(n));
6249 k += x;
6250 }
6251 if (sortGroups) {
6252 groupIndex.sort(function(a, b) {
6253 return sortGroups(groupSums[a], groupSums[b]);
6254 });
6255 }
6256 if (sortSubgroups) {
6257 subgroupIndex.forEach(function(d, i) {
6258 d.sort(function(a, b) {
6259 return sortSubgroups(matrix[i][a], matrix[i][b]);
6260 });
6261 });
6262 }
6263 k = (τ - padding * n) / k;
6264 x = 0, i = -1;
6265 while (++i < n) {
6266 x0 = x, j = -1;
6267 while (++j < n) {
6268 var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;
6269 subgroups[di + "-" + dj] = {
6270 index: di,
6271 subindex: dj,
6272 startAngle: a0,
6273 endAngle: a1,
6274 value: v
6275 };
6276 }
6277 groups[di] = {
6278 index: di,
6279 startAngle: x0,
6280 endAngle: x,
6281 value: groupSums[di]
6282 };
6283 x += padding;
6284 }
6285 i = -1;
6286 while (++i < n) {
6287 j = i - 1;
6288 while (++j < n) {
6289 var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i];
6290 if (source.value || target.value) {
6291 chords.push(source.value < target.value ? {
6292 source: target,
6293 target: source
6294 } : {
6295 source: source,
6296 target: target
6297 });
6298 }
6299 }
6300 }
6301 if (sortChords) resort();
6302 }
6303 function resort() {
6304 chords.sort(function(a, b) {
6305 return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2);
6306 });
6307 }
6308 chord.matrix = function(x) {
6309 if (!arguments.length) return matrix;
6310 n = (matrix = x) && matrix.length;
6311 chords = groups = null;
6312 return chord;
6313 };
6314 chord.padding = function(x) {
6315 if (!arguments.length) return padding;
6316 padding = x;
6317 chords = groups = null;
6318 return chord;
6319 };
6320 chord.sortGroups = function(x) {
6321 if (!arguments.length) return sortGroups;
6322 sortGroups = x;
6323 chords = groups = null;
6324 return chord;
6325 };
6326 chord.sortSubgroups = function(x) {
6327 if (!arguments.length) return sortSubgroups;
6328 sortSubgroups = x;
6329 chords = null;
6330 return chord;
6331 };
6332 chord.sortChords = function(x) {
6333 if (!arguments.length) return sortChords;
6334 sortChords = x;
6335 if (chords) resort();
6336 return chord;
6337 };
6338 chord.chords = function() {
6339 if (!chords) relayout();
6340 return chords;
6341 };
6342 chord.groups = function() {
6343 if (!groups) relayout();
6344 return groups;
6345 };
6346 return chord;
6347 };
6348 d3.layout.force = function() {
6349 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;
6350 function repulse(node) {
6351 return function(quad, x1, _, x2) {
6352 if (quad.point !== node) {
6353 var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy;
6354 if (dw * dw / theta2 < dn) {
6355 if (dn < chargeDistance2) {
6356 var k = quad.charge / dn;
6357 node.px -= dx * k;
6358 node.py -= dy * k;
6359 }
6360 return true;
6361 }
6362 if (quad.point && dn && dn < chargeDistance2) {
6363 var k = quad.pointCharge / dn;
6364 node.px -= dx * k;
6365 node.py -= dy * k;
6366 }
6367 }
6368 return !quad.charge;
6369 };
6370 }
6371 force.tick = function() {
6372 if ((alpha *= .99) < .005) {
6373 timer = null;
6374 event.end({
6375 type: "end",
6376 alpha: alpha = 0
6377 });
6378 return true;
6379 }
6380 var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y;
6381 for (i = 0; i < m; ++i) {
6382 o = links[i];
6383 s = o.source;
6384 t = o.target;
6385 x = t.x - s.x;
6386 y = t.y - s.y;
6387 if (l = x * x + y * y) {
6388 l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
6389 x *= l;
6390 y *= l;
6391 t.x -= x * (k = s.weight + t.weight ? s.weight / (s.weight + t.weight) : .5);
6392 t.y -= y * k;
6393 s.x += x * (k = 1 - k);
6394 s.y += y * k;
6395 }
6396 }
6397 if (k = alpha * gravity) {
6398 x = size[0] / 2;
6399 y = size[1] / 2;
6400 i = -1;
6401 if (k) while (++i < n) {
6402 o = nodes[i];
6403 o.x += (x - o.x) * k;
6404 o.y += (y - o.y) * k;
6405 }
6406 }
6407 if (charge) {
6408 d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);
6409 i = -1;
6410 while (++i < n) {
6411 if (!(o = nodes[i]).fixed) {
6412 q.visit(repulse(o));
6413 }
6414 }
6415 }
6416 i = -1;
6417 while (++i < n) {
6418 o = nodes[i];
6419 if (o.fixed) {
6420 o.x = o.px;
6421 o.y = o.py;
6422 } else {
6423 o.x -= (o.px - (o.px = o.x)) * friction;
6424 o.y -= (o.py - (o.py = o.y)) * friction;
6425 }
6426 }
6427 event.tick({
6428 type: "tick",
6429 alpha: alpha
6430 });
6431 };
6432 force.nodes = function(x) {
6433 if (!arguments.length) return nodes;
6434 nodes = x;
6435 return force;
6436 };
6437 force.links = function(x) {
6438 if (!arguments.length) return links;
6439 links = x;
6440 return force;
6441 };
6442 force.size = function(x) {
6443 if (!arguments.length) return size;
6444 size = x;
6445 return force;
6446 };
6447 force.linkDistance = function(x) {
6448 if (!arguments.length) return linkDistance;
6449 linkDistance = typeof x === "function" ? x : +x;
6450 return force;
6451 };
6452 force.distance = force.linkDistance;
6453 force.linkStrength = function(x) {
6454 if (!arguments.length) return linkStrength;
6455 linkStrength = typeof x === "function" ? x : +x;
6456 return force;
6457 };
6458 force.friction = function(x) {
6459 if (!arguments.length) return friction;
6460 friction = +x;
6461 return force;
6462 };
6463 force.charge = function(x) {
6464 if (!arguments.length) return charge;
6465 charge = typeof x === "function" ? x : +x;
6466 return force;
6467 };
6468 force.chargeDistance = function(x) {
6469 if (!arguments.length) return Math.sqrt(chargeDistance2);
6470 chargeDistance2 = x * x;
6471 return force;
6472 };
6473 force.gravity = function(x) {
6474 if (!arguments.length) return gravity;
6475 gravity = +x;
6476 return force;
6477 };
6478 force.theta = function(x) {
6479 if (!arguments.length) return Math.sqrt(theta2);
6480 theta2 = x * x;
6481 return force;
6482 };
6483 force.alpha = function(x) {
6484 if (!arguments.length) return alpha;
6485 x = +x;
6486 if (alpha) {
6487 if (x > 0) {
6488 alpha = x;
6489 } else {
6490 timer.c = null, timer.t = NaN, timer = null;
6491 event.end({
6492 type: "end",
6493 alpha: alpha = 0
6494 });
6495 }
6496 } else if (x > 0) {
6497 event.start({
6498 type: "start",
6499 alpha: alpha = x
6500 });
6501 timer = d3_timer(force.tick);
6502 }
6503 return force;
6504 };
6505 force.start = function() {
6506 var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o;
6507 for (i = 0; i < n; ++i) {
6508 (o = nodes[i]).index = i;
6509 o.weight = 0;
6510 }
6511 for (i = 0; i < m; ++i) {
6512 o = links[i];
6513 if (typeof o.source == "number") o.source = nodes[o.source];
6514 if (typeof o.target == "number") o.target = nodes[o.target];
6515 ++o.source.weight;
6516 ++o.target.weight;
6517 }
6518 for (i = 0; i < n; ++i) {
6519 o = nodes[i];
6520 if (isNaN(o.x)) o.x = position("x", w);
6521 if (isNaN(o.y)) o.y = position("y", h);
6522 if (isNaN(o.px)) o.px = o.x;
6523 if (isNaN(o.py)) o.py = o.y;
6524 }
6525 distances = [];
6526 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;
6527 strengths = [];
6528 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;
6529 charges = [];
6530 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;
6531 function position(dimension, size) {
6532 if (!neighbors) {
6533 neighbors = new Array(n);
6534 for (j = 0; j < n; ++j) {
6535 neighbors[j] = [];
6536 }
6537 for (j = 0; j < m; ++j) {
6538 var o = links[j];
6539 neighbors[o.source.index].push(o.target);
6540 neighbors[o.target.index].push(o.source);
6541 }
6542 }
6543 var candidates = neighbors[i], j = -1, l = candidates.length, x;
6544 while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x;
6545 return Math.random() * size;
6546 }
6547 return force.resume();
6548 };
6549 force.resume = function() {
6550 return force.alpha(.1);
6551 };
6552 force.stop = function() {
6553 return force.alpha(0);
6554 };
6555 force.drag = function() {
6556 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);
6557 if (!arguments.length) return drag;
6558 this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag);
6559 };
6560 function dragmove(d) {
6561 d.px = d3.event.x, d.py = d3.event.y;
6562 force.resume();
6563 }
6564 return d3.rebind(force, event, "on");
6565 };
6566 function d3_layout_forceDragstart(d) {
6567 d.fixed |= 2;
6568 }
6569 function d3_layout_forceDragend(d) {
6570 d.fixed &= ~6;
6571 }
6572 function d3_layout_forceMouseover(d) {
6573 d.fixed |= 4;
6574 d.px = d.x, d.py = d.y;
6575 }
6576 function d3_layout_forceMouseout(d) {
6577 d.fixed &= ~4;
6578 }
6579 function d3_layout_forceAccumulate(quad, alpha, charges) {
6580 var cx = 0, cy = 0;
6581 quad.charge = 0;
6582 if (!quad.leaf) {
6583 var nodes = quad.nodes, n = nodes.length, i = -1, c;
6584 while (++i < n) {
6585 c = nodes[i];
6586 if (c == null) continue;
6587 d3_layout_forceAccumulate(c, alpha, charges);
6588 quad.charge += c.charge;
6589 cx += c.charge * c.cx;
6590 cy += c.charge * c.cy;
6591 }
6592 }
6593 if (quad.point) {
6594 if (!quad.leaf) {
6595 quad.point.x += Math.random() - .5;
6596 quad.point.y += Math.random() - .5;
6597 }
6598 var k = alpha * charges[quad.point.index];
6599 quad.charge += quad.pointCharge = k;
6600 cx += k * quad.point.x;
6601 cy += k * quad.point.y;
6602 }
6603 quad.cx = cx / quad.charge;
6604 quad.cy = cy / quad.charge;
6605 }
6606 var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity;
6607 d3.layout.hierarchy = function() {
6608 var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;
6609 function hierarchy(root) {
6610 var stack = [ root ], nodes = [], node;
6611 root.depth = 0;
6612 while ((node = stack.pop()) != null) {
6613 nodes.push(node);
6614 if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) {
6615 var n, childs, child;
6616 while (--n >= 0) {
6617 stack.push(child = childs[n]);
6618 child.parent = node;
6619 child.depth = node.depth + 1;
6620 }
6621 if (value) node.value = 0;
6622 node.children = childs;
6623 } else {
6624 if (value) node.value = +value.call(hierarchy, node, node.depth) || 0;
6625 delete node.children;
6626 }
6627 }
6628 d3_layout_hierarchyVisitAfter(root, function(node) {
6629 var childs, parent;
6630 if (sort && (childs = node.children)) childs.sort(sort);
6631 if (value && (parent = node.parent)) parent.value += node.value;
6632 });
6633 return nodes;
6634 }
6635 hierarchy.sort = function(x) {
6636 if (!arguments.length) return sort;
6637 sort = x;
6638 return hierarchy;
6639 };
6640 hierarchy.children = function(x) {
6641 if (!arguments.length) return children;
6642 children = x;
6643 return hierarchy;
6644 };
6645 hierarchy.value = function(x) {
6646 if (!arguments.length) return value;
6647 value = x;
6648 return hierarchy;
6649 };
6650 hierarchy.revalue = function(root) {
6651 if (value) {
6652 d3_layout_hierarchyVisitBefore(root, function(node) {
6653 if (node.children) node.value = 0;
6654 });
6655 d3_layout_hierarchyVisitAfter(root, function(node) {
6656 var parent;
6657 if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;
6658 if (parent = node.parent) parent.value += node.value;
6659 });
6660 }
6661 return root;
6662 };
6663 return hierarchy;
6664 };
6665 function d3_layout_hierarchyRebind(object, hierarchy) {
6666 d3.rebind(object, hierarchy, "sort", "children", "value");
6667 object.nodes = object;
6668 object.links = d3_layout_hierarchyLinks;
6669 return object;
6670 }
6671 function d3_layout_hierarchyVisitBefore(node, callback) {
6672 var nodes = [ node ];
6673 while ((node = nodes.pop()) != null) {
6674 callback(node);
6675 if ((children = node.children) && (n = children.length)) {
6676 var n, children;
6677 while (--n >= 0) nodes.push(children[n]);
6678 }
6679 }
6680 }
6681 function d3_layout_hierarchyVisitAfter(node, callback) {
6682 var nodes = [ node ], nodes2 = [];
6683 while ((node = nodes.pop()) != null) {
6684 nodes2.push(node);
6685 if ((children = node.children) && (n = children.length)) {
6686 var i = -1, n, children;
6687 while (++i < n) nodes.push(children[i]);
6688 }
6689 }
6690 while ((node = nodes2.pop()) != null) {
6691 callback(node);
6692 }
6693 }
6694 function d3_layout_hierarchyChildren(d) {
6695 return d.children;
6696 }
6697 function d3_layout_hierarchyValue(d) {
6698 return d.value;
6699 }
6700 function d3_layout_hierarchySort(a, b) {
6701 return b.value - a.value;
6702 }
6703 function d3_layout_hierarchyLinks(nodes) {
6704 return d3.merge(nodes.map(function(parent) {
6705 return (parent.children || []).map(function(child) {
6706 return {
6707 source: parent,
6708 target: child
6709 };
6710 });
6711 }));
6712 }
6713 d3.layout.partition = function() {
6714 var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ];
6715 function position(node, x, dx, dy) {
6716 var children = node.children;
6717 node.x = x;
6718 node.y = node.depth * dy;
6719 node.dx = dx;
6720 node.dy = dy;
6721 if (children && (n = children.length)) {
6722 var i = -1, n, c, d;
6723 dx = node.value ? dx / node.value : 0;
6724 while (++i < n) {
6725 position(c = children[i], x, d = c.value * dx, dy);
6726 x += d;
6727 }
6728 }
6729 }
6730 function depth(node) {
6731 var children = node.children, d = 0;
6732 if (children && (n = children.length)) {
6733 var i = -1, n;
6734 while (++i < n) d = Math.max(d, depth(children[i]));
6735 }
6736 return 1 + d;
6737 }
6738 function partition(d, i) {
6739 var nodes = hierarchy.call(this, d, i);
6740 position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));
6741 return nodes;
6742 }
6743 partition.size = function(x) {
6744 if (!arguments.length) return size;
6745 size = x;
6746 return partition;
6747 };
6748 return d3_layout_hierarchyRebind(partition, hierarchy);
6749 };
6750 d3.layout.pie = function() {
6751 var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0;
6752 function pie(data) {
6753 var n = data.length, values = data.map(function(d, i) {
6754 return +value.call(pie, d, i);
6755 }), 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;
6756 if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
6757 return values[j] - values[i];
6758 } : function(i, j) {
6759 return sort(data[i], data[j]);
6760 });
6761 index.forEach(function(i) {
6762 arcs[i] = {
6763 data: data[i],
6764 value: v = values[i],
6765 startAngle: a,
6766 endAngle: a += v * k + pa,
6767 padAngle: p
6768 };
6769 });
6770 return arcs;
6771 }
6772 pie.value = function(_) {
6773 if (!arguments.length) return value;
6774 value = _;
6775 return pie;
6776 };
6777 pie.sort = function(_) {
6778 if (!arguments.length) return sort;
6779 sort = _;
6780 return pie;
6781 };
6782 pie.startAngle = function(_) {
6783 if (!arguments.length) return startAngle;
6784 startAngle = _;
6785 return pie;
6786 };
6787 pie.endAngle = function(_) {
6788 if (!arguments.length) return endAngle;
6789 endAngle = _;
6790 return pie;
6791 };
6792 pie.padAngle = function(_) {
6793 if (!arguments.length) return padAngle;
6794 padAngle = _;
6795 return pie;
6796 };
6797 return pie;
6798 };
6799 var d3_layout_pieSortByValue = {};
6800 d3.layout.stack = function() {
6801 var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY;
6802 function stack(data, index) {
6803 if (!(n = data.length)) return data;
6804 var series = data.map(function(d, i) {
6805 return values.call(stack, d, i);
6806 });
6807 var points = series.map(function(d) {
6808 return d.map(function(v, i) {
6809 return [ x.call(stack, v, i), y.call(stack, v, i) ];
6810 });
6811 });
6812 var orders = order.call(stack, points, index);
6813 series = d3.permute(series, orders);
6814 points = d3.permute(points, orders);
6815 var offsets = offset.call(stack, points, index);
6816 var m = series[0].length, n, i, j, o;
6817 for (j = 0; j < m; ++j) {
6818 out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);
6819 for (i = 1; i < n; ++i) {
6820 out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);
6821 }
6822 }
6823 return data;
6824 }
6825 stack.values = function(x) {
6826 if (!arguments.length) return values;
6827 values = x;
6828 return stack;
6829 };
6830 stack.order = function(x) {
6831 if (!arguments.length) return order;
6832 order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;
6833 return stack;
6834 };
6835 stack.offset = function(x) {
6836 if (!arguments.length) return offset;
6837 offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;
6838 return stack;
6839 };
6840 stack.x = function(z) {
6841 if (!arguments.length) return x;
6842 x = z;
6843 return stack;
6844 };
6845 stack.y = function(z) {
6846 if (!arguments.length) return y;
6847 y = z;
6848 return stack;
6849 };
6850 stack.out = function(z) {
6851 if (!arguments.length) return out;
6852 out = z;
6853 return stack;
6854 };
6855 return stack;
6856 };
6857 function d3_layout_stackX(d) {
6858 return d.x;
6859 }
6860 function d3_layout_stackY(d) {
6861 return d.y;
6862 }
6863 function d3_layout_stackOut(d, y0, y) {
6864 d.y0 = y0;
6865 d.y = y;
6866 }
6867 var d3_layout_stackOrders = d3.map({
6868 "inside-out": function(data) {
6869 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) {
6870 return max[a] - max[b];
6871 }), top = 0, bottom = 0, tops = [], bottoms = [];
6872 for (i = 0; i < n; ++i) {
6873 j = index[i];
6874 if (top < bottom) {
6875 top += sums[j];
6876 tops.push(j);
6877 } else {
6878 bottom += sums[j];
6879 bottoms.push(j);
6880 }
6881 }
6882 return bottoms.reverse().concat(tops);
6883 },
6884 reverse: function(data) {
6885 return d3.range(data.length).reverse();
6886 },
6887 "default": d3_layout_stackOrderDefault
6888 });
6889 var d3_layout_stackOffsets = d3.map({
6890 silhouette: function(data) {
6891 var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = [];
6892 for (j = 0; j < m; ++j) {
6893 for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
6894 if (o > max) max = o;
6895 sums.push(o);
6896 }
6897 for (j = 0; j < m; ++j) {
6898 y0[j] = (max - sums[j]) / 2;
6899 }
6900 return y0;
6901 },
6902 wiggle: function(data) {
6903 var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = [];
6904 y0[0] = o = o0 = 0;
6905 for (j = 1; j < m; ++j) {
6906 for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];
6907 for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {
6908 for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {
6909 s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;
6910 }
6911 s2 += s3 * data[i][j][1];
6912 }
6913 y0[j] = o -= s1 ? s2 / s1 * dx : 0;
6914 if (o < o0) o0 = o;
6915 }
6916 for (j = 0; j < m; ++j) y0[j] -= o0;
6917 return y0;
6918 },
6919 expand: function(data) {
6920 var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = [];
6921 for (j = 0; j < m; ++j) {
6922 for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
6923 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;
6924 }
6925 for (j = 0; j < m; ++j) y0[j] = 0;
6926 return y0;
6927 },
6928 zero: d3_layout_stackOffsetZero
6929 });
6930 function d3_layout_stackOrderDefault(data) {
6931 return d3.range(data.length);
6932 }
6933 function d3_layout_stackOffsetZero(data) {
6934 var j = -1, m = data[0].length, y0 = [];
6935 while (++j < m) y0[j] = 0;
6936 return y0;
6937 }
6938 function d3_layout_stackMaxIndex(array) {
6939 var i = 1, j = 0, v = array[0][1], k, n = array.length;
6940 for (;i < n; ++i) {
6941 if ((k = array[i][1]) > v) {
6942 j = i;
6943 v = k;
6944 }
6945 }
6946 return j;
6947 }
6948 function d3_layout_stackReduceSum(d) {
6949 return d.reduce(d3_layout_stackSum, 0);
6950 }
6951 function d3_layout_stackSum(p, d) {
6952 return p + d[1];
6953 }
6954 d3.layout.histogram = function() {
6955 var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges;
6956 function histogram(data, i) {
6957 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;
6958 while (++i < m) {
6959 bin = bins[i] = [];
6960 bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);
6961 bin.y = 0;
6962 }
6963 if (m > 0) {
6964 i = -1;
6965 while (++i < n) {
6966 x = values[i];
6967 if (x >= range[0] && x <= range[1]) {
6968 bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
6969 bin.y += k;
6970 bin.push(data[i]);
6971 }
6972 }
6973 }
6974 return bins;
6975 }
6976 histogram.value = function(x) {
6977 if (!arguments.length) return valuer;
6978 valuer = x;
6979 return histogram;
6980 };
6981 histogram.range = function(x) {
6982 if (!arguments.length) return ranger;
6983 ranger = d3_functor(x);
6984 return histogram;
6985 };
6986 histogram.bins = function(x) {
6987 if (!arguments.length) return binner;
6988 binner = typeof x === "number" ? function(range) {
6989 return d3_layout_histogramBinFixed(range, x);
6990 } : d3_functor(x);
6991 return histogram;
6992 };
6993 histogram.frequency = function(x) {
6994 if (!arguments.length) return frequency;
6995 frequency = !!x;
6996 return histogram;
6997 };
6998 return histogram;
6999 };
7000 function d3_layout_histogramBinSturges(range, values) {
7001 return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));
7002 }
7003 function d3_layout_histogramBinFixed(range, n) {
7004 var x = -1, b = +range[0], m = (range[1] - b) / n, f = [];
7005 while (++x <= n) f[x] = m * x + b;
7006 return f;
7007 }
7008 function d3_layout_histogramRange(values) {
7009 return [ d3.min(values), d3.max(values) ];
7010 }
7011 d3.layout.pack = function() {
7012 var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius;
7013 function pack(d, i) {
7014 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() {
7015 return radius;
7016 };
7017 root.x = root.y = 0;
7018 d3_layout_hierarchyVisitAfter(root, function(d) {
7019 d.r = +r(d.value);
7020 });
7021 d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
7022 if (padding) {
7023 var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2;
7024 d3_layout_hierarchyVisitAfter(root, function(d) {
7025 d.r += dr;
7026 });
7027 d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
7028 d3_layout_hierarchyVisitAfter(root, function(d) {
7029 d.r -= dr;
7030 });
7031 }
7032 d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h));
7033 return nodes;
7034 }
7035 pack.size = function(_) {
7036 if (!arguments.length) return size;
7037 size = _;
7038 return pack;
7039 };
7040 pack.radius = function(_) {
7041 if (!arguments.length) return radius;
7042 radius = _ == null || typeof _ === "function" ? _ : +_;
7043 return pack;
7044 };
7045 pack.padding = function(_) {
7046 if (!arguments.length) return padding;
7047 padding = +_;
7048 return pack;
7049 };
7050 return d3_layout_hierarchyRebind(pack, hierarchy);
7051 };
7052 function d3_layout_packSort(a, b) {
7053 return a.value - b.value;
7054 }
7055 function d3_layout_packInsert(a, b) {
7056 var c = a._pack_next;
7057 a._pack_next = b;
7058 b._pack_prev = a;
7059 b._pack_next = c;
7060 c._pack_prev = b;
7061 }
7062 function d3_layout_packSplice(a, b) {
7063 a._pack_next = b;
7064 b._pack_prev = a;
7065 }
7066 function d3_layout_packIntersects(a, b) {
7067 var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r;
7068 return .999 * dr * dr > dx * dx + dy * dy;
7069 }
7070 function d3_layout_packSiblings(node) {
7071 if (!(nodes = node.children) || !(n = nodes.length)) return;
7072 var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n;
7073 function bound(node) {
7074 xMin = Math.min(node.x - node.r, xMin);
7075 xMax = Math.max(node.x + node.r, xMax);
7076 yMin = Math.min(node.y - node.r, yMin);
7077 yMax = Math.max(node.y + node.r, yMax);
7078 }
7079 nodes.forEach(d3_layout_packLink);
7080 a = nodes[0];
7081 a.x = -a.r;
7082 a.y = 0;
7083 bound(a);
7084 if (n > 1) {
7085 b = nodes[1];
7086 b.x = b.r;
7087 b.y = 0;
7088 bound(b);
7089 if (n > 2) {
7090 c = nodes[2];
7091 d3_layout_packPlace(a, b, c);
7092 bound(c);
7093 d3_layout_packInsert(a, c);
7094 a._pack_prev = c;
7095 d3_layout_packInsert(c, b);
7096 b = a._pack_next;
7097 for (i = 3; i < n; i++) {
7098 d3_layout_packPlace(a, b, c = nodes[i]);
7099 var isect = 0, s1 = 1, s2 = 1;
7100 for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {
7101 if (d3_layout_packIntersects(j, c)) {
7102 isect = 1;
7103 break;
7104 }
7105 }
7106 if (isect == 1) {
7107 for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {
7108 if (d3_layout_packIntersects(k, c)) {
7109 break;
7110 }
7111 }
7112 }
7113 if (isect) {
7114 if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b);
7115 i--;
7116 } else {
7117 d3_layout_packInsert(a, c);
7118 b = c;
7119 bound(c);
7120 }
7121 }
7122 }
7123 }
7124 var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0;
7125 for (i = 0; i < n; i++) {
7126 c = nodes[i];
7127 c.x -= cx;
7128 c.y -= cy;
7129 cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y));
7130 }
7131 node.r = cr;
7132 nodes.forEach(d3_layout_packUnlink);
7133 }
7134 function d3_layout_packLink(node) {
7135 node._pack_next = node._pack_prev = node;
7136 }
7137 function d3_layout_packUnlink(node) {
7138 delete node._pack_next;
7139 delete node._pack_prev;
7140 }
7141 function d3_layout_packTransform(node, x, y, k) {
7142 var children = node.children;
7143 node.x = x += k * node.x;
7144 node.y = y += k * node.y;
7145 node.r *= k;
7146 if (children) {
7147 var i = -1, n = children.length;
7148 while (++i < n) d3_layout_packTransform(children[i], x, y, k);
7149 }
7150 }
7151 function d3_layout_packPlace(a, b, c) {
7152 var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y;
7153 if (db && (dx || dy)) {
7154 var da = b.r + c.r, dc = dx * dx + dy * dy;
7155 da *= da;
7156 db *= db;
7157 var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);
7158 c.x = a.x + x * dx + y * dy;
7159 c.y = a.y + x * dy - y * dx;
7160 } else {
7161 c.x = a.x + db;
7162 c.y = a.y;
7163 }
7164 }
7165 d3.layout.tree = function() {
7166 var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null;
7167 function tree(d, i) {
7168 var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0);
7169 d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z;
7170 d3_layout_hierarchyVisitBefore(root1, secondWalk);
7171 if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else {
7172 var left = root0, right = root0, bottom = root0;
7173 d3_layout_hierarchyVisitBefore(root0, function(node) {
7174 if (node.x < left.x) left = node;
7175 if (node.x > right.x) right = node;
7176 if (node.depth > bottom.depth) bottom = node;
7177 });
7178 var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1);
7179 d3_layout_hierarchyVisitBefore(root0, function(node) {
7180 node.x = (node.x + tx) * kx;
7181 node.y = node.depth * ky;
7182 });
7183 }
7184 return nodes;
7185 }
7186 function wrapTree(root0) {
7187 var root1 = {
7188 A: null,
7189 children: [ root0 ]
7190 }, queue = [ root1 ], node1;
7191 while ((node1 = queue.pop()) != null) {
7192 for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) {
7193 queue.push((children[i] = child = {
7194 _: children[i],
7195 parent: node1,
7196 children: (child = children[i].children) && child.slice() || [],
7197 A: null,
7198 a: null,
7199 z: 0,
7200 m: 0,
7201 c: 0,
7202 s: 0,
7203 t: null,
7204 i: i
7205 }).a = child);
7206 }
7207 }
7208 return root1.children[0];
7209 }
7210 function firstWalk(v) {
7211 var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;
7212 if (children.length) {
7213 d3_layout_treeShift(v);
7214 var midpoint = (children[0].z + children[children.length - 1].z) / 2;
7215 if (w) {
7216 v.z = w.z + separation(v._, w._);
7217 v.m = v.z - midpoint;
7218 } else {
7219 v.z = midpoint;
7220 }
7221 } else if (w) {
7222 v.z = w.z + separation(v._, w._);
7223 }
7224 v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
7225 }
7226 function secondWalk(v) {
7227 v._.x = v.z + v.parent.m;
7228 v.m += v.parent.m;
7229 }
7230 function apportion(v, w, ancestor) {
7231 if (w) {
7232 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;
7233 while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
7234 vom = d3_layout_treeLeft(vom);
7235 vop = d3_layout_treeRight(vop);
7236 vop.a = v;
7237 shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
7238 if (shift > 0) {
7239 d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift);
7240 sip += shift;
7241 sop += shift;
7242 }
7243 sim += vim.m;
7244 sip += vip.m;
7245 som += vom.m;
7246 sop += vop.m;
7247 }
7248 if (vim && !d3_layout_treeRight(vop)) {
7249 vop.t = vim;
7250 vop.m += sim - sop;
7251 }
7252 if (vip && !d3_layout_treeLeft(vom)) {
7253 vom.t = vip;
7254 vom.m += sip - som;
7255 ancestor = v;
7256 }
7257 }
7258 return ancestor;
7259 }
7260 function sizeNode(node) {
7261 node.x *= size[0];
7262 node.y = node.depth * size[1];
7263 }
7264 tree.separation = function(x) {
7265 if (!arguments.length) return separation;
7266 separation = x;
7267 return tree;
7268 };
7269 tree.size = function(x) {
7270 if (!arguments.length) return nodeSize ? null : size;
7271 nodeSize = (size = x) == null ? sizeNode : null;
7272 return tree;
7273 };
7274 tree.nodeSize = function(x) {
7275 if (!arguments.length) return nodeSize ? size : null;
7276 nodeSize = (size = x) == null ? null : sizeNode;
7277 return tree;
7278 };
7279 return d3_layout_hierarchyRebind(tree, hierarchy);
7280 };
7281 function d3_layout_treeSeparation(a, b) {
7282 return a.parent == b.parent ? 1 : 2;
7283 }
7284 function d3_layout_treeLeft(v) {
7285 var children = v.children;
7286 return children.length ? children[0] : v.t;
7287 }
7288 function d3_layout_treeRight(v) {
7289 var children = v.children, n;
7290 return (n = children.length) ? children[n - 1] : v.t;
7291 }
7292 function d3_layout_treeMove(wm, wp, shift) {
7293 var change = shift / (wp.i - wm.i);
7294 wp.c -= change;
7295 wp.s += shift;
7296 wm.c += change;
7297 wp.z += shift;
7298 wp.m += shift;
7299 }
7300 function d3_layout_treeShift(v) {
7301 var shift = 0, change = 0, children = v.children, i = children.length, w;
7302 while (--i >= 0) {
7303 w = children[i];
7304 w.z += shift;
7305 w.m += shift;
7306 shift += w.s + (change += w.c);
7307 }
7308 }
7309 function d3_layout_treeAncestor(vim, v, ancestor) {
7310 return vim.a.parent === v.parent ? vim.a : ancestor;
7311 }
7312 d3.layout.cluster = function() {
7313 var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
7314 function cluster(d, i) {
7315 var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;
7316 d3_layout_hierarchyVisitAfter(root, function(node) {
7317 var children = node.children;
7318 if (children && children.length) {
7319 node.x = d3_layout_clusterX(children);
7320 node.y = d3_layout_clusterY(children);
7321 } else {
7322 node.x = previousNode ? x += separation(node, previousNode) : 0;
7323 node.y = 0;
7324 previousNode = node;
7325 }
7326 });
7327 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;
7328 d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) {
7329 node.x = (node.x - root.x) * size[0];
7330 node.y = (root.y - node.y) * size[1];
7331 } : function(node) {
7332 node.x = (node.x - x0) / (x1 - x0) * size[0];
7333 node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];
7334 });
7335 return nodes;
7336 }
7337 cluster.separation = function(x) {
7338 if (!arguments.length) return separation;
7339 separation = x;
7340 return cluster;
7341 };
7342 cluster.size = function(x) {
7343 if (!arguments.length) return nodeSize ? null : size;
7344 nodeSize = (size = x) == null;
7345 return cluster;
7346 };
7347 cluster.nodeSize = function(x) {
7348 if (!arguments.length) return nodeSize ? size : null;
7349 nodeSize = (size = x) != null;
7350 return cluster;
7351 };
7352 return d3_layout_hierarchyRebind(cluster, hierarchy);
7353 };
7354 function d3_layout_clusterY(children) {
7355 return 1 + d3.max(children, function(child) {
7356 return child.y;
7357 });
7358 }
7359 function d3_layout_clusterX(children) {
7360 return children.reduce(function(x, child) {
7361 return x + child.x;
7362 }, 0) / children.length;
7363 }
7364 function d3_layout_clusterLeft(node) {
7365 var children = node.children;
7366 return children && children.length ? d3_layout_clusterLeft(children[0]) : node;
7367 }
7368 function d3_layout_clusterRight(node) {
7369 var children = node.children, n;
7370 return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;
7371 }
7372 d3.layout.treemap = function() {
7373 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));
7374 function scale(children, k) {
7375 var i = -1, n = children.length, child, area;
7376 while (++i < n) {
7377 area = (child = children[i]).value * (k < 0 ? 0 : k);
7378 child.area = isNaN(area) || area <= 0 ? 0 : area;
7379 }
7380 }
7381 function squarify(node) {
7382 var children = node.children;
7383 if (children && children.length) {
7384 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;
7385 scale(remaining, rect.dx * rect.dy / node.value);
7386 row.area = 0;
7387 while ((n = remaining.length) > 0) {
7388 row.push(child = remaining[n - 1]);
7389 row.area += child.area;
7390 if (mode !== "squarify" || (score = worst(row, u)) <= best) {
7391 remaining.pop();
7392 best = score;
7393 } else {
7394 row.area -= row.pop().area;
7395 position(row, u, rect, false);
7396 u = Math.min(rect.dx, rect.dy);
7397 row.length = row.area = 0;
7398 best = Infinity;
7399 }
7400 }
7401 if (row.length) {
7402 position(row, u, rect, true);
7403 row.length = row.area = 0;
7404 }
7405 children.forEach(squarify);
7406 }
7407 }
7408 function stickify(node) {
7409 var children = node.children;
7410 if (children && children.length) {
7411 var rect = pad(node), remaining = children.slice(), child, row = [];
7412 scale(remaining, rect.dx * rect.dy / node.value);
7413 row.area = 0;
7414 while (child = remaining.pop()) {
7415 row.push(child);
7416 row.area += child.area;
7417 if (child.z != null) {
7418 position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);
7419 row.length = row.area = 0;
7420 }
7421 }
7422 children.forEach(stickify);
7423 }
7424 }
7425 function worst(row, u) {
7426 var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length;
7427 while (++i < n) {
7428 if (!(r = row[i].area)) continue;
7429 if (r < rmin) rmin = r;
7430 if (r > rmax) rmax = r;
7431 }
7432 s *= s;
7433 u *= u;
7434 return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity;
7435 }
7436 function position(row, u, rect, flush) {
7437 var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o;
7438 if (u == rect.dx) {
7439 if (flush || v > rect.dy) v = rect.dy;
7440 while (++i < n) {
7441 o = row[i];
7442 o.x = x;
7443 o.y = y;
7444 o.dy = v;
7445 x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);
7446 }
7447 o.z = true;
7448 o.dx += rect.x + rect.dx - x;
7449 rect.y += v;
7450 rect.dy -= v;
7451 } else {
7452 if (flush || v > rect.dx) v = rect.dx;
7453 while (++i < n) {
7454 o = row[i];
7455 o.x = x;
7456 o.y = y;
7457 o.dx = v;
7458 y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);
7459 }
7460 o.z = false;
7461 o.dy += rect.y + rect.dy - y;
7462 rect.x += v;
7463 rect.dx -= v;
7464 }
7465 }
7466 function treemap(d) {
7467 var nodes = stickies || hierarchy(d), root = nodes[0];
7468 root.x = root.y = 0;
7469 if (root.value) root.dx = size[0], root.dy = size[1]; else root.dx = root.dy = 0;
7470 if (stickies) hierarchy.revalue(root);
7471 scale([ root ], root.dx * root.dy / root.value);
7472 (stickies ? stickify : squarify)(root);
7473 if (sticky) stickies = nodes;
7474 return nodes;
7475 }
7476 treemap.size = function(x) {
7477 if (!arguments.length) return size;
7478 size = x;
7479 return treemap;
7480 };
7481 treemap.padding = function(x) {
7482 if (!arguments.length) return padding;
7483 function padFunction(node) {
7484 var p = x.call(treemap, node, node.depth);
7485 return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p);
7486 }
7487 function padConstant(node) {
7488 return d3_layout_treemapPad(node, x);
7489 }
7490 var type;
7491 pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ],
7492 padConstant) : padConstant;
7493 return treemap;
7494 };
7495 treemap.round = function(x) {
7496 if (!arguments.length) return round != Number;
7497 round = x ? Math.round : Number;
7498 return treemap;
7499 };
7500 treemap.sticky = function(x) {
7501 if (!arguments.length) return sticky;
7502 sticky = x;
7503 stickies = null;
7504 return treemap;
7505 };
7506 treemap.ratio = function(x) {
7507 if (!arguments.length) return ratio;
7508 ratio = x;
7509 return treemap;
7510 };
7511 treemap.mode = function(x) {
7512 if (!arguments.length) return mode;
7513 mode = x + "";
7514 return treemap;
7515 };
7516 return d3_layout_hierarchyRebind(treemap, hierarchy);
7517 };
7518 function d3_layout_treemapPadNull(node) {
7519 return {
7520 x: node.x,
7521 y: node.y,
7522 dx: node.dx,
7523 dy: node.dy
7524 };
7525 }
7526 function d3_layout_treemapPad(node, padding) {
7527 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];
7528 if (dx < 0) {
7529 x += dx / 2;
7530 dx = 0;
7531 }
7532 if (dy < 0) {
7533 y += dy / 2;
7534 dy = 0;
7535 }
7536 return {
7537 x: x,
7538 y: y,
7539 dx: dx,
7540 dy: dy
7541 };
7542 }
7543 d3.random = {
7544 normal: function(µ, σ) {
7545 var n = arguments.length;
7546 if (n < 2) σ = 1;
7547 if (n < 1) µ = 0;
7548 return function() {
7549 var x, y, r;
7550 do {
7551 x = Math.random() * 2 - 1;
7552 y = Math.random() * 2 - 1;
7553 r = x * x + y * y;
7554 } while (!r || r > 1);
7555 return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);
7556 };
7557 },
7558 logNormal: function() {
7559 var random = d3.random.normal.apply(d3, arguments);
7560 return function() {
7561 return Math.exp(random());
7562 };
7563 },
7564 bates: function(m) {
7565 var random = d3.random.irwinHall(m);
7566 return function() {
7567 return random() / m;
7568 };
7569 },
7570 irwinHall: function(m) {
7571 return function() {
7572 for (var s = 0, j = 0; j < m; j++) s += Math.random();
7573 return s;
7574 };
7575 }
7576 };
7577 d3.scale = {};
7578 function d3_scaleExtent(domain) {
7579 var start = domain[0], stop = domain[domain.length - 1];
7580 return start < stop ? [ start, stop ] : [ stop, start ];
7581 }
7582 function d3_scaleRange(scale) {
7583 return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
7584 }
7585 function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {
7586 var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]);
7587 return function(x) {
7588 return i(u(x));
7589 };
7590 }
7591 function d3_scale_nice(domain, nice) {
7592 var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx;
7593 if (x1 < x0) {
7594 dx = i0, i0 = i1, i1 = dx;
7595 dx = x0, x0 = x1, x1 = dx;
7596 }
7597 domain[i0] = nice.floor(x0);
7598 domain[i1] = nice.ceil(x1);
7599 return domain;
7600 }
7601 function d3_scale_niceStep(step) {
7602 return step ? {
7603 floor: function(x) {
7604 return Math.floor(x / step) * step;
7605 },
7606 ceil: function(x) {
7607 return Math.ceil(x / step) * step;
7608 }
7609 } : d3_scale_niceIdentity;
7610 }
7611 var d3_scale_niceIdentity = {
7612 floor: d3_identity,
7613 ceil: d3_identity
7614 };
7615 function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
7616 var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1;
7617 if (domain[k] < domain[0]) {
7618 domain = domain.slice().reverse();
7619 range = range.slice().reverse();
7620 }
7621 while (++j <= k) {
7622 u.push(uninterpolate(domain[j - 1], domain[j]));
7623 i.push(interpolate(range[j - 1], range[j]));
7624 }
7625 return function(x) {
7626 var j = d3.bisect(domain, x, 1, k) - 1;
7627 return i[j](u[j](x));
7628 };
7629 }
7630 d3.scale.linear = function() {
7631 return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false);
7632 };
7633 function d3_scale_linear(domain, range, interpolate, clamp) {
7634 var output, input;
7635 function rescale() {
7636 var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
7637 output = linear(domain, range, uninterpolate, interpolate);
7638 input = linear(range, domain, uninterpolate, d3_interpolate);
7639 return scale;
7640 }
7641 function scale(x) {
7642 return output(x);
7643 }
7644 scale.invert = function(y) {
7645 return input(y);
7646 };
7647 scale.domain = function(x) {
7648 if (!arguments.length) return domain;
7649 domain = x.map(Number);
7650 return rescale();
7651 };
7652 scale.range = function(x) {
7653 if (!arguments.length) return range;
7654 range = x;
7655 return rescale();
7656 };
7657 scale.rangeRound = function(x) {
7658 return scale.range(x).interpolate(d3_interpolateRound);
7659 };
7660 scale.clamp = function(x) {
7661 if (!arguments.length) return clamp;
7662 clamp = x;
7663 return rescale();
7664 };
7665 scale.interpolate = function(x) {
7666 if (!arguments.length) return interpolate;
7667 interpolate = x;
7668 return rescale();
7669 };
7670 scale.ticks = function(m) {
7671 return d3_scale_linearTicks(domain, m);
7672 };
7673 scale.tickFormat = function(m, format) {
7674 return d3_scale_linearTickFormat(domain, m, format);
7675 };
7676 scale.nice = function(m) {
7677 d3_scale_linearNice(domain, m);
7678 return rescale();
7679 };
7680 scale.copy = function() {
7681 return d3_scale_linear(domain, range, interpolate, clamp);
7682 };
7683 return rescale();
7684 }
7685 function d3_scale_linearRebind(scale, linear) {
7686 return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
7687 }
7688 function d3_scale_linearNice(domain, m) {
7689 d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));
7690 d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));
7691 return domain;
7692 }
7693 function d3_scale_linearTickRange(domain, m) {
7694 if (m == null) m = 10;
7695 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;
7696 if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;
7697 extent[0] = Math.ceil(extent[0] / step) * step;
7698 extent[1] = Math.floor(extent[1] / step) * step + step * .5;
7699 extent[2] = step;
7700 return extent;
7701 }
7702 function d3_scale_linearTicks(domain, m) {
7703 return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));
7704 }
7705 function d3_scale_linearTickFormat(domain, m, format) {
7706 var range = d3_scale_linearTickRange(domain, m);
7707 if (format) {
7708 var match = d3_format_re.exec(format);
7709 match.shift();
7710 if (match[8] === "s") {
7711 var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1])));
7712 if (!match[7]) match[7] = "." + d3_scale_linearPrecision(prefix.scale(range[2]));
7713 match[8] = "f";
7714 format = d3.format(match.join(""));
7715 return function(d) {
7716 return format(prefix.scale(d)) + prefix.symbol;
7717 };
7718 }
7719 if (!match[7]) match[7] = "." + d3_scale_linearFormatPrecision(match[8], range);
7720 format = match.join("");
7721 } else {
7722 format = ",." + d3_scale_linearPrecision(range[2]) + "f";
7723 }
7724 return d3.format(format);
7725 }
7726 var d3_scale_linearFormatSignificant = {
7727 s: 1,
7728 g: 1,
7729 p: 1,
7730 r: 1,
7731 e: 1
7732 };
7733 function d3_scale_linearPrecision(value) {
7734 return -Math.floor(Math.log(value) / Math.LN10 + .01);
7735 }
7736 function d3_scale_linearFormatPrecision(type, range) {
7737 var p = d3_scale_linearPrecision(range[2]);
7738 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;
7739 }
7740 d3.scale.log = function() {
7741 return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]);
7742 };
7743 function d3_scale_log(linear, base, positive, domain) {
7744 function log(x) {
7745 return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base);
7746 }
7747 function pow(x) {
7748 return positive ? Math.pow(base, x) : -Math.pow(base, -x);
7749 }
7750 function scale(x) {
7751 return linear(log(x));
7752 }
7753 scale.invert = function(x) {
7754 return pow(linear.invert(x));
7755 };
7756 scale.domain = function(x) {
7757 if (!arguments.length) return domain;
7758 positive = x[0] >= 0;
7759 linear.domain((domain = x.map(Number)).map(log));
7760 return scale;
7761 };
7762 scale.base = function(_) {
7763 if (!arguments.length) return base;
7764 base = +_;
7765 linear.domain(domain.map(log));
7766 return scale;
7767 };
7768 scale.nice = function() {
7769 var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative);
7770 linear.domain(niced);
7771 domain = niced.map(pow);
7772 return scale;
7773 };
7774 scale.ticks = function() {
7775 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;
7776 if (isFinite(j - i)) {
7777 if (positive) {
7778 for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k);
7779 ticks.push(pow(i));
7780 } else {
7781 ticks.push(pow(i));
7782 for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k);
7783 }
7784 for (i = 0; ticks[i] < u; i++) {}
7785 for (j = ticks.length; ticks[j - 1] > v; j--) {}
7786 ticks = ticks.slice(i, j);
7787 }
7788 return ticks;
7789 };
7790 scale.tickFormat = function(n, format) {
7791 if (!arguments.length) return d3_scale_logFormat;
7792 if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format);
7793 var k = Math.max(1, base * n / scale.ticks().length);
7794 return function(d) {
7795 var i = d / pow(Math.round(log(d)));
7796 if (i * base < base - .5) i *= base;
7797 return i <= k ? format(d) : "";
7798 };
7799 };
7800 scale.copy = function() {
7801 return d3_scale_log(linear.copy(), base, positive, domain);
7802 };
7803 return d3_scale_linearRebind(scale, linear);
7804 }
7805 var d3_scale_logFormat = d3.format(".0e"), d3_scale_logNiceNegative = {
7806 floor: function(x) {
7807 return -Math.ceil(-x);
7808 },
7809 ceil: function(x) {
7810 return -Math.floor(-x);
7811 }
7812 };
7813 d3.scale.pow = function() {
7814 return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]);
7815 };
7816 function d3_scale_pow(linear, exponent, domain) {
7817 var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);
7818 function scale(x) {
7819 return linear(powp(x));
7820 }
7821 scale.invert = function(x) {
7822 return powb(linear.invert(x));
7823 };
7824 scale.domain = function(x) {
7825 if (!arguments.length) return domain;
7826 linear.domain((domain = x.map(Number)).map(powp));
7827 return scale;
7828 };
7829 scale.ticks = function(m) {
7830 return d3_scale_linearTicks(domain, m);
7831 };
7832 scale.tickFormat = function(m, format) {
7833 return d3_scale_linearTickFormat(domain, m, format);
7834 };
7835 scale.nice = function(m) {
7836 return scale.domain(d3_scale_linearNice(domain, m));
7837 };
7838 scale.exponent = function(x) {
7839 if (!arguments.length) return exponent;
7840 powp = d3_scale_powPow(exponent = x);
7841 powb = d3_scale_powPow(1 / exponent);
7842 linear.domain(domain.map(powp));
7843 return scale;
7844 };
7845 scale.copy = function() {
7846 return d3_scale_pow(linear.copy(), exponent, domain);
7847 };
7848 return d3_scale_linearRebind(scale, linear);
7849 }
7850 function d3_scale_powPow(e) {
7851 return function(x) {
7852 return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
7853 };
7854 }
7855 d3.scale.sqrt = function() {
7856 return d3.scale.pow().exponent(.5);
7857 };
7858 d3.scale.ordinal = function() {
7859 return d3_scale_ordinal([], {
7860 t: "range",
7861 a: [ [] ]
7862 });
7863 };
7864 function d3_scale_ordinal(domain, ranger) {
7865 var index, range, rangeBand;
7866 function scale(x) {
7867 return range[((index.get(x) || (ranger.t === "range" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length];
7868 }
7869 function steps(start, step) {
7870 return d3.range(domain.length).map(function(i) {
7871 return start + step * i;
7872 });
7873 }
7874 scale.domain = function(x) {
7875 if (!arguments.length) return domain;
7876 domain = [];
7877 index = new d3_Map();
7878 var i = -1, n = x.length, xi;
7879 while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));
7880 return scale[ranger.t].apply(scale, ranger.a);
7881 };
7882 scale.range = function(x) {
7883 if (!arguments.length) return range;
7884 range = x;
7885 rangeBand = 0;
7886 ranger = {
7887 t: "range",
7888 a: arguments
7889 };
7890 return scale;
7891 };
7892 scale.rangePoints = function(x, padding) {
7893 if (arguments.length < 2) padding = 0;
7894 var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2,
7895 0) : (stop - start) / (domain.length - 1 + padding);
7896 range = steps(start + step * padding / 2, step);
7897 rangeBand = 0;
7898 ranger = {
7899 t: "rangePoints",
7900 a: arguments
7901 };
7902 return scale;
7903 };
7904 scale.rangeRoundPoints = function(x, padding) {
7905 if (arguments.length < 2) padding = 0;
7906 var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2),
7907 0) : (stop - start) / (domain.length - 1 + padding) | 0;
7908 range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step);
7909 rangeBand = 0;
7910 ranger = {
7911 t: "rangeRoundPoints",
7912 a: arguments
7913 };
7914 return scale;
7915 };
7916 scale.rangeBands = function(x, padding, outerPadding) {
7917 if (arguments.length < 2) padding = 0;
7918 if (arguments.length < 3) outerPadding = padding;
7919 var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding);
7920 range = steps(start + step * outerPadding, step);
7921 if (reverse) range.reverse();
7922 rangeBand = step * (1 - padding);
7923 ranger = {
7924 t: "rangeBands",
7925 a: arguments
7926 };
7927 return scale;
7928 };
7929 scale.rangeRoundBands = function(x, padding, outerPadding) {
7930 if (arguments.length < 2) padding = 0;
7931 if (arguments.length < 3) outerPadding = padding;
7932 var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding));
7933 range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);
7934 if (reverse) range.reverse();
7935 rangeBand = Math.round(step * (1 - padding));
7936 ranger = {
7937 t: "rangeRoundBands",
7938 a: arguments
7939 };
7940 return scale;
7941 };
7942 scale.rangeBand = function() {
7943 return rangeBand;
7944 };
7945 scale.rangeExtent = function() {
7946 return d3_scaleExtent(ranger.a[0]);
7947 };
7948 scale.copy = function() {
7949 return d3_scale_ordinal(domain, ranger);
7950 };
7951 return scale.domain(domain);
7952 }
7953 d3.scale.category10 = function() {
7954 return d3.scale.ordinal().range(d3_category10);
7955 };
7956 d3.scale.category20 = function() {
7957 return d3.scale.ordinal().range(d3_category20);
7958 };
7959 d3.scale.category20b = function() {
7960 return d3.scale.ordinal().range(d3_category20b);
7961 };
7962 d3.scale.category20c = function() {
7963 return d3.scale.ordinal().range(d3_category20c);
7964 };
7965 var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString);
7966 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);
7967 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);
7968 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);
7969 d3.scale.quantile = function() {
7970 return d3_scale_quantile([], []);
7971 };
7972 function d3_scale_quantile(domain, range) {
7973 var thresholds;
7974 function rescale() {
7975 var k = 0, q = range.length;
7976 thresholds = [];
7977 while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);
7978 return scale;
7979 }
7980 function scale(x) {
7981 if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)];
7982 }
7983 scale.domain = function(x) {
7984 if (!arguments.length) return domain;
7985 domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending);
7986 return rescale();
7987 };
7988 scale.range = function(x) {
7989 if (!arguments.length) return range;
7990 range = x;
7991 return rescale();
7992 };
7993 scale.quantiles = function() {
7994 return thresholds;
7995 };
7996 scale.invertExtent = function(y) {
7997 y = range.indexOf(y);
7998 return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ];
7999 };
8000 scale.copy = function() {
8001 return d3_scale_quantile(domain, range);
8002 };
8003 return rescale();
8004 }
8005 d3.scale.quantize = function() {
8006 return d3_scale_quantize(0, 1, [ 0, 1 ]);
8007 };
8008 function d3_scale_quantize(x0, x1, range) {
8009 var kx, i;
8010 function scale(x) {
8011 return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];
8012 }
8013 function rescale() {
8014 kx = range.length / (x1 - x0);
8015 i = range.length - 1;
8016 return scale;
8017 }
8018 scale.domain = function(x) {
8019 if (!arguments.length) return [ x0, x1 ];
8020 x0 = +x[0];
8021 x1 = +x[x.length - 1];
8022 return rescale();
8023 };
8024 scale.range = function(x) {
8025 if (!arguments.length) return range;
8026 range = x;
8027 return rescale();
8028 };
8029 scale.invertExtent = function(y) {
8030 y = range.indexOf(y);
8031 y = y < 0 ? NaN : y / kx + x0;
8032 return [ y, y + 1 / kx ];
8033 };
8034 scale.copy = function() {
8035 return d3_scale_quantize(x0, x1, range);
8036 };
8037 return rescale();
8038 }
8039 d3.scale.threshold = function() {
8040 return d3_scale_threshold([ .5 ], [ 0, 1 ]);
8041 };
8042 function d3_scale_threshold(domain, range) {
8043 function scale(x) {
8044 if (x <= x) return range[d3.bisect(domain, x)];
8045 }
8046 scale.domain = function(_) {
8047 if (!arguments.length) return domain;
8048 domain = _;
8049 return scale;
8050 };
8051 scale.range = function(_) {
8052 if (!arguments.length) return range;
8053 range = _;
8054 return scale;
8055 };
8056 scale.invertExtent = function(y) {
8057 y = range.indexOf(y);
8058 return [ domain[y - 1], domain[y] ];
8059 };
8060 scale.copy = function() {
8061 return d3_scale_threshold(domain, range);
8062 };
8063 return scale;
8064 }
8065 d3.scale.identity = function() {
8066 return d3_scale_identity([ 0, 1 ]);
8067 };
8068 function d3_scale_identity(domain) {
8069 function identity(x) {
8070 return +x;
8071 }
8072 identity.invert = identity;
8073 identity.domain = identity.range = function(x) {
8074 if (!arguments.length) return domain;
8075 domain = x.map(identity);
8076 return identity;
8077 };
8078 identity.ticks = function(m) {
8079 return d3_scale_linearTicks(domain, m);
8080 };
8081 identity.tickFormat = function(m, format) {
8082 return d3_scale_linearTickFormat(domain, m, format);
8083 };
8084 identity.copy = function() {
8085 return d3_scale_identity(domain);
8086 };
8087 return identity;
8088 }
8089 d3.svg = {};
8090 function d3_zero() {
8091 return 0;
8092 }
8093 d3.svg.arc = function() {
8094 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;
8095 function arc() {
8096 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;
8097 if (r1 < r0) rc = r1, r1 = r0, r0 = rc;
8098 if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z";
8099 var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = [];
8100 if (ap = (+padAngle.apply(this, arguments) || 0) / 2) {
8101 rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments);
8102 if (!cw) p1 *= -1;
8103 if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap));
8104 if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap));
8105 }
8106 if (r1) {
8107 x0 = r1 * Math.cos(a0 + p1);
8108 y0 = r1 * Math.sin(a0 + p1);
8109 x1 = r1 * Math.cos(a1 - p1);
8110 y1 = r1 * Math.sin(a1 - p1);
8111 var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1;
8112 if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) {
8113 var h1 = (a0 + a1) / 2;
8114 x0 = r1 * Math.cos(h1);
8115 y0 = r1 * Math.sin(h1);
8116 x1 = y1 = null;
8117 }
8118 } else {
8119 x0 = y0 = 0;
8120 }
8121 if (r0) {
8122 x2 = r0 * Math.cos(a1 - p0);
8123 y2 = r0 * Math.sin(a1 - p0);
8124 x3 = r0 * Math.cos(a0 + p0);
8125 y3 = r0 * Math.sin(a0 + p0);
8126 var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1;
8127 if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) {
8128 var h0 = (a0 + a1) / 2;
8129 x2 = r0 * Math.cos(h0);
8130 y2 = r0 * Math.sin(h0);
8131 x3 = y3 = null;
8132 }
8133 } else {
8134 x2 = y2 = 0;
8135 }
8136 if (da > ε && (rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {
8137 cr = r0 < r1 ^ cw ? 0 : 1;
8138 var rc1 = rc, rc0 = rc;
8139 if (da < π) {
8140 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]);
8141 rc0 = Math.min(rc, (r0 - lc) / (kc - 1));
8142 rc1 = Math.min(rc, (r1 - lc) / (kc + 1));
8143 }
8144 if (x1 != null) {
8145 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);
8146 if (rc === rc1) {
8147 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]);
8148 } else {
8149 path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]);
8150 }
8151 } else {
8152 path.push("M", x0, ",", y0);
8153 }
8154 if (x3 != null) {
8155 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);
8156 if (rc === rc0) {
8157 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]);
8158 } else {
8159 path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]);
8160 }
8161 } else {
8162 path.push("L", x2, ",", y2);
8163 }
8164 } else {
8165 path.push("M", x0, ",", y0);
8166 if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1);
8167 path.push("L", x2, ",", y2);
8168 if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3);
8169 }
8170 path.push("Z");
8171 return path.join("");
8172 }
8173 function circleSegment(r1, cw) {
8174 return "M0," + r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + -r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + r1;
8175 }
8176 arc.innerRadius = function(v) {
8177 if (!arguments.length) return innerRadius;
8178 innerRadius = d3_functor(v);
8179 return arc;
8180 };
8181 arc.outerRadius = function(v) {
8182 if (!arguments.length) return outerRadius;
8183 outerRadius = d3_functor(v);
8184 return arc;
8185 };
8186 arc.cornerRadius = function(v) {
8187 if (!arguments.length) return cornerRadius;
8188 cornerRadius = d3_functor(v);
8189 return arc;
8190 };
8191 arc.padRadius = function(v) {
8192 if (!arguments.length) return padRadius;
8193 padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v);
8194 return arc;
8195 };
8196 arc.startAngle = function(v) {
8197 if (!arguments.length) return startAngle;
8198 startAngle = d3_functor(v);
8199 return arc;
8200 };
8201 arc.endAngle = function(v) {
8202 if (!arguments.length) return endAngle;
8203 endAngle = d3_functor(v);
8204 return arc;
8205 };
8206 arc.padAngle = function(v) {
8207 if (!arguments.length) return padAngle;
8208 padAngle = d3_functor(v);
8209 return arc;
8210 };
8211 arc.centroid = function() {
8212 var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ;
8213 return [ Math.cos(a) * r, Math.sin(a) * r ];
8214 };
8215 return arc;
8216 };
8217 var d3_svg_arcAuto = "auto";
8218 function d3_svg_arcInnerRadius(d) {
8219 return d.innerRadius;
8220 }
8221 function d3_svg_arcOuterRadius(d) {
8222 return d.outerRadius;
8223 }
8224 function d3_svg_arcStartAngle(d) {
8225 return d.startAngle;
8226 }
8227 function d3_svg_arcEndAngle(d) {
8228 return d.endAngle;
8229 }
8230 function d3_svg_arcPadAngle(d) {
8231 return d && d.padAngle;
8232 }
8233 function d3_svg_arcSweep(x0, y0, x1, y1) {
8234 return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;
8235 }
8236 function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {
8237 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;
8238 if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
8239 return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];
8240 }
8241 function d3_svg_line(projection) {
8242 var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;
8243 function line(data) {
8244 var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y);
8245 function segment() {
8246 segments.push("M", interpolate(projection(points), tension));
8247 }
8248 while (++i < n) {
8249 if (defined.call(this, d = data[i], i)) {
8250 points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]);
8251 } else if (points.length) {
8252 segment();
8253 points = [];
8254 }
8255 }
8256 if (points.length) segment();
8257 return segments.length ? segments.join("") : null;
8258 }
8259 line.x = function(_) {
8260 if (!arguments.length) return x;
8261 x = _;
8262 return line;
8263 };
8264 line.y = function(_) {
8265 if (!arguments.length) return y;
8266 y = _;
8267 return line;
8268 };
8269 line.defined = function(_) {
8270 if (!arguments.length) return defined;
8271 defined = _;
8272 return line;
8273 };
8274 line.interpolate = function(_) {
8275 if (!arguments.length) return interpolateKey;
8276 if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
8277 return line;
8278 };
8279 line.tension = function(_) {
8280 if (!arguments.length) return tension;
8281 tension = _;
8282 return line;
8283 };
8284 return line;
8285 }
8286 d3.svg.line = function() {
8287 return d3_svg_line(d3_identity);
8288 };
8289 var d3_svg_lineInterpolators = d3.map({
8290 linear: d3_svg_lineLinear,
8291 "linear-closed": d3_svg_lineLinearClosed,
8292 step: d3_svg_lineStep,
8293 "step-before": d3_svg_lineStepBefore,
8294 "step-after": d3_svg_lineStepAfter,
8295 basis: d3_svg_lineBasis,
8296 "basis-open": d3_svg_lineBasisOpen,
8297 "basis-closed": d3_svg_lineBasisClosed,
8298 bundle: d3_svg_lineBundle,
8299 cardinal: d3_svg_lineCardinal,
8300 "cardinal-open": d3_svg_lineCardinalOpen,
8301 "cardinal-closed": d3_svg_lineCardinalClosed,
8302 monotone: d3_svg_lineMonotone
8303 });
8304 d3_svg_lineInterpolators.forEach(function(key, value) {
8305 value.key = key;
8306 value.closed = /-closed$/.test(key);
8307 });
8308 function d3_svg_lineLinear(points) {
8309 return points.length > 1 ? points.join("L") : points + "Z";
8310 }
8311 function d3_svg_lineLinearClosed(points) {
8312 return points.join("L") + "Z";
8313 }
8314 function d3_svg_lineStep(points) {
8315 var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8316 while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]);
8317 if (n > 1) path.push("H", p[0]);
8318 return path.join("");
8319 }
8320 function d3_svg_lineStepBefore(points) {
8321 var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8322 while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]);
8323 return path.join("");
8324 }
8325 function d3_svg_lineStepAfter(points) {
8326 var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8327 while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]);
8328 return path.join("");
8329 }
8330 function d3_svg_lineCardinalOpen(points, tension) {
8331 return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));
8332 }
8333 function d3_svg_lineCardinalClosed(points, tension) {
8334 return points.length < 3 ? d3_svg_lineLinearClosed(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
8335 points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));
8336 }
8337 function d3_svg_lineCardinal(points, tension) {
8338 return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension));
8339 }
8340 function d3_svg_lineHermite(points, tangents) {
8341 if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) {
8342 return d3_svg_lineLinear(points);
8343 }
8344 var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1;
8345 if (quad) {
8346 path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1];
8347 p0 = points[1];
8348 pi = 2;
8349 }
8350 if (tangents.length > 1) {
8351 t = tangents[1];
8352 p = points[pi];
8353 pi++;
8354 path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
8355 for (var i = 2; i < tangents.length; i++, pi++) {
8356 p = points[pi];
8357 t = tangents[i];
8358 path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
8359 }
8360 }
8361 if (quad) {
8362 var lp = points[pi];
8363 path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1];
8364 }
8365 return path;
8366 }
8367 function d3_svg_lineCardinalTangents(points, tension) {
8368 var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length;
8369 while (++i < n) {
8370 p0 = p1;
8371 p1 = p2;
8372 p2 = points[i];
8373 tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]);
8374 }
8375 return tangents;
8376 }
8377 function d3_svg_lineBasis(points) {
8378 if (points.length < 3) return d3_svg_lineLinear(points);
8379 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) ];
8380 points.push(points[n - 1]);
8381 while (++i <= n) {
8382 pi = points[i];
8383 px.shift();
8384 px.push(pi[0]);
8385 py.shift();
8386 py.push(pi[1]);
8387 d3_svg_lineBasisBezier(path, px, py);
8388 }
8389 points.pop();
8390 path.push("L", pi);
8391 return path.join("");
8392 }
8393 function d3_svg_lineBasisOpen(points) {
8394 if (points.length < 4) return d3_svg_lineLinear(points);
8395 var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ];
8396 while (++i < 3) {
8397 pi = points[i];
8398 px.push(pi[0]);
8399 py.push(pi[1]);
8400 }
8401 path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));
8402 --i;
8403 while (++i < n) {
8404 pi = points[i];
8405 px.shift();
8406 px.push(pi[0]);
8407 py.shift();
8408 py.push(pi[1]);
8409 d3_svg_lineBasisBezier(path, px, py);
8410 }
8411 return path.join("");
8412 }
8413 function d3_svg_lineBasisClosed(points) {
8414 var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = [];
8415 while (++i < 4) {
8416 pi = points[i % n];
8417 px.push(pi[0]);
8418 py.push(pi[1]);
8419 }
8420 path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];
8421 --i;
8422 while (++i < m) {
8423 pi = points[i % n];
8424 px.shift();
8425 px.push(pi[0]);
8426 py.shift();
8427 py.push(pi[1]);
8428 d3_svg_lineBasisBezier(path, px, py);
8429 }
8430 return path.join("");
8431 }
8432 function d3_svg_lineBundle(points, tension) {
8433 var n = points.length - 1;
8434 if (n) {
8435 var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t;
8436 while (++i <= n) {
8437 p = points[i];
8438 t = i / n;
8439 p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
8440 p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
8441 }
8442 }
8443 return d3_svg_lineBasis(points);
8444 }
8445 function d3_svg_lineDot4(a, b) {
8446 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
8447 }
8448 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 ];
8449 function d3_svg_lineBasisBezier(path, x, y) {
8450 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));
8451 }
8452 function d3_svg_lineSlope(p0, p1) {
8453 return (p1[1] - p0[1]) / (p1[0] - p0[0]);
8454 }
8455 function d3_svg_lineFiniteDifferences(points) {
8456 var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1);
8457 while (++i < j) {
8458 m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2;
8459 }
8460 m[i] = d;
8461 return m;
8462 }
8463 function d3_svg_lineMonotoneTangents(points) {
8464 var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1;
8465 while (++i < j) {
8466 d = d3_svg_lineSlope(points[i], points[i + 1]);
8467 if (abs(d) < ε) {
8468 m[i] = m[i + 1] = 0;
8469 } else {
8470 a = m[i] / d;
8471 b = m[i + 1] / d;
8472 s = a * a + b * b;
8473 if (s > 9) {
8474 s = d * 3 / Math.sqrt(s);
8475 m[i] = s * a;
8476 m[i + 1] = s * b;
8477 }
8478 }
8479 }
8480 i = -1;
8481 while (++i <= j) {
8482 s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));
8483 tangents.push([ s || 0, m[i] * s || 0 ]);
8484 }
8485 return tangents;
8486 }
8487 function d3_svg_lineMonotone(points) {
8488 return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
8489 }
8490 d3.svg.line.radial = function() {
8491 var line = d3_svg_line(d3_svg_lineRadial);
8492 line.radius = line.x, delete line.x;
8493 line.angle = line.y, delete line.y;
8494 return line;
8495 };
8496 function d3_svg_lineRadial(points) {
8497 var point, i = -1, n = points.length, r, a;
8498 while (++i < n) {
8499 point = points[i];
8500 r = point[0];
8501 a = point[1] - halfπ;
8502 point[0] = r * Math.cos(a);
8503 point[1] = r * Math.sin(a);
8504 }
8505 return points;
8506 }
8507 function d3_svg_area(projection) {
8508 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;
8509 function area(data) {
8510 var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() {
8511 return x;
8512 } : d3_functor(x1), fy1 = y0 === y1 ? function() {
8513 return y;
8514 } : d3_functor(y1), x, y;
8515 function segment() {
8516 segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z");
8517 }
8518 while (++i < n) {
8519 if (defined.call(this, d = data[i], i)) {
8520 points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]);
8521 points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]);
8522 } else if (points0.length) {
8523 segment();
8524 points0 = [];
8525 points1 = [];
8526 }
8527 }
8528 if (points0.length) segment();
8529 return segments.length ? segments.join("") : null;
8530 }
8531 area.x = function(_) {
8532 if (!arguments.length) return x1;
8533 x0 = x1 = _;
8534 return area;
8535 };
8536 area.x0 = function(_) {
8537 if (!arguments.length) return x0;
8538 x0 = _;
8539 return area;
8540 };
8541 area.x1 = function(_) {
8542 if (!arguments.length) return x1;
8543 x1 = _;
8544 return area;
8545 };
8546 area.y = function(_) {
8547 if (!arguments.length) return y1;
8548 y0 = y1 = _;
8549 return area;
8550 };
8551 area.y0 = function(_) {
8552 if (!arguments.length) return y0;
8553 y0 = _;
8554 return area;
8555 };
8556 area.y1 = function(_) {
8557 if (!arguments.length) return y1;
8558 y1 = _;
8559 return area;
8560 };
8561 area.defined = function(_) {
8562 if (!arguments.length) return defined;
8563 defined = _;
8564 return area;
8565 };
8566 area.interpolate = function(_) {
8567 if (!arguments.length) return interpolateKey;
8568 if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
8569 interpolateReverse = interpolate.reverse || interpolate;
8570 L = interpolate.closed ? "M" : "L";
8571 return area;
8572 };
8573 area.tension = function(_) {
8574 if (!arguments.length) return tension;
8575 tension = _;
8576 return area;
8577 };
8578 return area;
8579 }
8580 d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;
8581 d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;
8582 d3.svg.area = function() {
8583 return d3_svg_area(d3_identity);
8584 };
8585 d3.svg.area.radial = function() {
8586 var area = d3_svg_area(d3_svg_lineRadial);
8587 area.radius = area.x, delete area.x;
8588 area.innerRadius = area.x0, delete area.x0;
8589 area.outerRadius = area.x1, delete area.x1;
8590 area.angle = area.y, delete area.y;
8591 area.startAngle = area.y0, delete area.y0;
8592 area.endAngle = area.y1, delete area.y1;
8593 return area;
8594 };
8595 d3.svg.chord = function() {
8596 var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;
8597 function chord(d, i) {
8598 var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i);
8599 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";
8600 }
8601 function subgroup(self, f, d, i) {
8602 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π;
8603 return {
8604 r: r,
8605 a0: a0,
8606 a1: a1,
8607 p0: [ r * Math.cos(a0), r * Math.sin(a0) ],
8608 p1: [ r * Math.cos(a1), r * Math.sin(a1) ]
8609 };
8610 }
8611 function equals(a, b) {
8612 return a.a0 == b.a0 && a.a1 == b.a1;
8613 }
8614 function arc(r, p, a) {
8615 return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p;
8616 }
8617 function curve(r0, p0, r1, p1) {
8618 return "Q 0,0 " + p1;
8619 }
8620 chord.radius = function(v) {
8621 if (!arguments.length) return radius;
8622 radius = d3_functor(v);
8623 return chord;
8624 };
8625 chord.source = function(v) {
8626 if (!arguments.length) return source;
8627 source = d3_functor(v);
8628 return chord;
8629 };
8630 chord.target = function(v) {
8631 if (!arguments.length) return target;
8632 target = d3_functor(v);
8633 return chord;
8634 };
8635 chord.startAngle = function(v) {
8636 if (!arguments.length) return startAngle;
8637 startAngle = d3_functor(v);
8638 return chord;
8639 };
8640 chord.endAngle = function(v) {
8641 if (!arguments.length) return endAngle;
8642 endAngle = d3_functor(v);
8643 return chord;
8644 };
8645 return chord;
8646 };
8647 function d3_svg_chordRadius(d) {
8648 return d.radius;
8649 }
8650 d3.svg.diagonal = function() {
8651 var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection;
8652 function diagonal(d, i) {
8653 var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, {
8654 x: p0.x,
8655 y: m
8656 }, {
8657 x: p3.x,
8658 y: m
8659 }, p3 ];
8660 p = p.map(projection);
8661 return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3];
8662 }
8663 diagonal.source = function(x) {
8664 if (!arguments.length) return source;
8665 source = d3_functor(x);
8666 return diagonal;
8667 };
8668 diagonal.target = function(x) {
8669 if (!arguments.length) return target;
8670 target = d3_functor(x);
8671 return diagonal;
8672 };
8673 diagonal.projection = function(x) {
8674 if (!arguments.length) return projection;
8675 projection = x;
8676 return diagonal;
8677 };
8678 return diagonal;
8679 };
8680 function d3_svg_diagonalProjection(d) {
8681 return [ d.x, d.y ];
8682 }
8683 d3.svg.diagonal.radial = function() {
8684 var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection;
8685 diagonal.projection = function(x) {
8686 return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection;
8687 };
8688 return diagonal;
8689 };
8690 function d3_svg_diagonalRadialProjection(projection) {
8691 return function() {
8692 var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ;
8693 return [ r * Math.cos(a), r * Math.sin(a) ];
8694 };
8695 }
8696 d3.svg.symbol = function() {
8697 var type = d3_svg_symbolType, size = d3_svg_symbolSize;
8698 function symbol(d, i) {
8699 return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i));
8700 }
8701 symbol.type = function(x) {
8702 if (!arguments.length) return type;
8703 type = d3_functor(x);
8704 return symbol;
8705 };
8706 symbol.size = function(x) {
8707 if (!arguments.length) return size;
8708 size = d3_functor(x);
8709 return symbol;
8710 };
8711 return symbol;
8712 };
8713 function d3_svg_symbolSize() {
8714 return 64;
8715 }
8716 function d3_svg_symbolType() {
8717 return "circle";
8718 }
8719 function d3_svg_symbolCircle(size) {
8720 var r = Math.sqrt(size / π);
8721 return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z";
8722 }
8723 var d3_svg_symbols = d3.map({
8724 circle: d3_svg_symbolCircle,
8725 cross: function(size) {
8726 var r = Math.sqrt(size / 5) / 2;
8727 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";
8728 },
8729 diamond: function(size) {
8730 var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30;
8731 return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z";
8732 },
8733 square: function(size) {
8734 var r = Math.sqrt(size) / 2;
8735 return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z";
8736 },
8737 "triangle-down": function(size) {
8738 var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;
8739 return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z";
8740 },
8741 "triangle-up": function(size) {
8742 var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;
8743 return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z";
8744 }
8745 });
8746 d3.svg.symbolTypes = d3_svg_symbols.keys();
8747 var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);
8748 d3_selectionPrototype.transition = function(name) {
8749 var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || {
8750 time: Date.now(),
8751 ease: d3_ease_cubicInOut,
8752 delay: 0,
8753 duration: 250
8754 };
8755 for (var j = -1, m = this.length; ++j < m; ) {
8756 subgroups.push(subgroup = []);
8757 for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8758 if (node = group[i]) d3_transitionNode(node, i, ns, id, transition);
8759 subgroup.push(node);
8760 }
8761 }
8762 return d3_transition(subgroups, ns, id);
8763 };
8764 d3_selectionPrototype.interrupt = function(name) {
8765 return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name)));
8766 };
8767 var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace());
8768 function d3_selection_interruptNS(ns) {
8769 return function() {
8770 var lock, activeId, active;
8771 if ((lock = this[ns]) && (active = lock[activeId = lock.active])) {
8772 active.timer.c = null;
8773 active.timer.t = NaN;
8774 if (--lock.count) delete lock[activeId]; else delete this[ns];
8775 lock.active += .5;
8776 active.event && active.event.interrupt.call(this, this.__data__, active.index);
8777 }
8778 };
8779 }
8780 function d3_transition(groups, ns, id) {
8781 d3_subclass(groups, d3_transitionPrototype);
8782 groups.namespace = ns;
8783 groups.id = id;
8784 return groups;
8785 }
8786 var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit;
8787 d3_transitionPrototype.call = d3_selectionPrototype.call;
8788 d3_transitionPrototype.empty = d3_selectionPrototype.empty;
8789 d3_transitionPrototype.node = d3_selectionPrototype.node;
8790 d3_transitionPrototype.size = d3_selectionPrototype.size;
8791 d3.transition = function(selection, name) {
8792 return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3.selection().transition(selection);
8793 };
8794 d3.transition.prototype = d3_transitionPrototype;
8795 d3_transitionPrototype.select = function(selector) {
8796 var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;
8797 selector = d3_selection_selector(selector);
8798 for (var j = -1, m = this.length; ++j < m; ) {
8799 subgroups.push(subgroup = []);
8800 for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8801 if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {
8802 if ("__data__" in node) subnode.__data__ = node.__data__;
8803 d3_transitionNode(subnode, i, ns, id, node[ns][id]);
8804 subgroup.push(subnode);
8805 } else {
8806 subgroup.push(null);
8807 }
8808 }
8809 }
8810 return d3_transition(subgroups, ns, id);
8811 };
8812 d3_transitionPrototype.selectAll = function(selector) {
8813 var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;
8814 selector = d3_selection_selectorAll(selector);
8815 for (var j = -1, m = this.length; ++j < m; ) {
8816 for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8817 if (node = group[i]) {
8818 transition = node[ns][id];
8819 subnodes = selector.call(node, node.__data__, i, j);
8820 subgroups.push(subgroup = []);
8821 for (var k = -1, o = subnodes.length; ++k < o; ) {
8822 if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);
8823 subgroup.push(subnode);
8824 }
8825 }
8826 }
8827 }
8828 return d3_transition(subgroups, ns, id);
8829 };
8830 d3_transitionPrototype.filter = function(filter) {
8831 var subgroups = [], subgroup, group, node;
8832 if (typeof filter !== "function") filter = d3_selection_filter(filter);
8833 for (var j = 0, m = this.length; j < m; j++) {
8834 subgroups.push(subgroup = []);
8835 for (var group = this[j], i = 0, n = group.length; i < n; i++) {
8836 if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {
8837 subgroup.push(node);
8838 }
8839 }
8840 }
8841 return d3_transition(subgroups, this.namespace, this.id);
8842 };
8843 d3_transitionPrototype.tween = function(name, tween) {
8844 var id = this.id, ns = this.namespace;
8845 if (arguments.length < 2) return this.node()[ns][id].tween.get(name);
8846 return d3_selection_each(this, tween == null ? function(node) {
8847 node[ns][id].tween.remove(name);
8848 } : function(node) {
8849 node[ns][id].tween.set(name, tween);
8850 });
8851 };
8852 function d3_transition_tween(groups, name, value, tween) {
8853 var id = groups.id, ns = groups.namespace;
8854 return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) {
8855 node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j)));
8856 } : (value = tween(value), function(node) {
8857 node[ns][id].tween.set(name, value);
8858 }));
8859 }
8860 d3_transitionPrototype.attr = function(nameNS, value) {
8861 if (arguments.length < 2) {
8862 for (value in nameNS) this.attr(value, nameNS[value]);
8863 return this;
8864 }
8865 var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS);
8866 function attrNull() {
8867 this.removeAttribute(name);
8868 }
8869 function attrNullNS() {
8870 this.removeAttributeNS(name.space, name.local);
8871 }
8872 function attrTween(b) {
8873 return b == null ? attrNull : (b += "", function() {
8874 var a = this.getAttribute(name), i;
8875 return a !== b && (i = interpolate(a, b), function(t) {
8876 this.setAttribute(name, i(t));
8877 });
8878 });
8879 }
8880 function attrTweenNS(b) {
8881 return b == null ? attrNullNS : (b += "", function() {
8882 var a = this.getAttributeNS(name.space, name.local), i;
8883 return a !== b && (i = interpolate(a, b), function(t) {
8884 this.setAttributeNS(name.space, name.local, i(t));
8885 });
8886 });
8887 }
8888 return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween);
8889 };
8890 d3_transitionPrototype.attrTween = function(nameNS, tween) {
8891 var name = d3.ns.qualify(nameNS);
8892 function attrTween(d, i) {
8893 var f = tween.call(this, d, i, this.getAttribute(name));
8894 return f && function(t) {
8895 this.setAttribute(name, f(t));
8896 };
8897 }
8898 function attrTweenNS(d, i) {
8899 var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
8900 return f && function(t) {
8901 this.setAttributeNS(name.space, name.local, f(t));
8902 };
8903 }
8904 return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
8905 };
8906 d3_transitionPrototype.style = function(name, value, priority) {
8907 var n = arguments.length;
8908 if (n < 3) {
8909 if (typeof name !== "string") {
8910 if (n < 2) value = "";
8911 for (priority in name) this.style(priority, name[priority], value);
8912 return this;
8913 }
8914 priority = "";
8915 }
8916 function styleNull() {
8917 this.style.removeProperty(name);
8918 }
8919 function styleString(b) {
8920 return b == null ? styleNull : (b += "", function() {
8921 var a = d3_window(this).getComputedStyle(this, null).getPropertyValue(name), i;
8922 return a !== b && (i = d3_interpolate(a, b), function(t) {
8923 this.style.setProperty(name, i(t), priority);
8924 });
8925 });
8926 }
8927 return d3_transition_tween(this, "style." + name, value, styleString);
8928 };
8929 d3_transitionPrototype.styleTween = function(name, tween, priority) {
8930 if (arguments.length < 3) priority = "";
8931 function styleTween(d, i) {
8932 var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name));
8933 return f && function(t) {
8934 this.style.setProperty(name, f(t), priority);
8935 };
8936 }
8937 return this.tween("style." + name, styleTween);
8938 };
8939 d3_transitionPrototype.text = function(value) {
8940 return d3_transition_tween(this, "text", value, d3_transition_text);
8941 };
8942 function d3_transition_text(b) {
8943 if (b == null) b = "";
8944 return function() {
8945 this.textContent = b;
8946 };
8947 }
8948 d3_transitionPrototype.remove = function() {
8949 var ns = this.namespace;
8950 return this.each("end.transition", function() {
8951 var p;
8952 if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);
8953 });
8954 };
8955 d3_transitionPrototype.ease = function(value) {
8956 var id = this.id, ns = this.namespace;
8957 if (arguments.length < 1) return this.node()[ns][id].ease;
8958 if (typeof value !== "function") value = d3.ease.apply(d3, arguments);
8959 return d3_selection_each(this, function(node) {
8960 node[ns][id].ease = value;
8961 });
8962 };
8963 d3_transitionPrototype.delay = function(value) {
8964 var id = this.id, ns = this.namespace;
8965 if (arguments.length < 1) return this.node()[ns][id].delay;
8966 return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8967 node[ns][id].delay = +value.call(node, node.__data__, i, j);
8968 } : (value = +value, function(node) {
8969 node[ns][id].delay = value;
8970 }));
8971 };
8972 d3_transitionPrototype.duration = function(value) {
8973 var id = this.id, ns = this.namespace;
8974 if (arguments.length < 1) return this.node()[ns][id].duration;
8975 return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8976 node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j));
8977 } : (value = Math.max(1, value), function(node) {
8978 node[ns][id].duration = value;
8979 }));
8980 };
8981 d3_transitionPrototype.each = function(type, listener) {
8982 var id = this.id, ns = this.namespace;
8983 if (arguments.length < 2) {
8984 var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;
8985 try {
8986 d3_transitionInheritId = id;
8987 d3_selection_each(this, function(node, i, j) {
8988 d3_transitionInherit = node[ns][id];
8989 type.call(node, node.__data__, i, j);
8990 });
8991 } finally {
8992 d3_transitionInherit = inherit;
8993 d3_transitionInheritId = inheritId;
8994 }
8995 } else {
8996 d3_selection_each(this, function(node) {
8997 var transition = node[ns][id];
8998 (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener);
8999 });
9000 }
9001 return this;
9002 };
9003 d3_transitionPrototype.transition = function() {
9004 var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition;
9005 for (var j = 0, m = this.length; j < m; j++) {
9006 subgroups.push(subgroup = []);
9007 for (var group = this[j], i = 0, n = group.length; i < n; i++) {
9008 if (node = group[i]) {
9009 transition = node[ns][id0];
9010 d3_transitionNode(node, i, ns, id1, {
9011 time: transition.time,
9012 ease: transition.ease,
9013 delay: transition.delay + transition.duration,
9014 duration: transition.duration
9015 });
9016 }
9017 subgroup.push(node);
9018 }
9019 }
9020 return d3_transition(subgroups, ns, id1);
9021 };
9022 function d3_transitionNamespace(name) {
9023 return name == null ? "__transition__" : "__transition_" + name + "__";
9024 }
9025 function d3_transitionNode(node, i, ns, id, inherit) {
9026 var lock = node[ns] || (node[ns] = {
9027 active: 0,
9028 count: 0
9029 }), transition = lock[id], time, timer, duration, ease, tweens;
9030 function schedule(elapsed) {
9031 var delay = transition.delay;
9032 timer.t = delay + time;
9033 if (delay <= elapsed) return start(elapsed - delay);
9034 timer.c = start;
9035 }
9036 function start(elapsed) {
9037 var activeId = lock.active, active = lock[activeId];
9038 if (active) {
9039 active.timer.c = null;
9040 active.timer.t = NaN;
9041 --lock.count;
9042 delete lock[activeId];
9043 active.event && active.event.interrupt.call(node, node.__data__, active.index);
9044 }
9045 for (var cancelId in lock) {
9046 if (+cancelId < id) {
9047 var cancel = lock[cancelId];
9048 cancel.timer.c = null;
9049 cancel.timer.t = NaN;
9050 --lock.count;
9051 delete lock[cancelId];
9052 }
9053 }
9054 timer.c = tick;
9055 d3_timer(function() {
9056 if (timer.c && tick(elapsed || 1)) {
9057 timer.c = null;
9058 timer.t = NaN;
9059 }
9060 return 1;
9061 }, 0, time);
9062 lock.active = id;
9063 transition.event && transition.event.start.call(node, node.__data__, i);
9064 tweens = [];
9065 transition.tween.forEach(function(key, value) {
9066 if (value = value.call(node, node.__data__, i)) {
9067 tweens.push(value);
9068 }
9069 });
9070 ease = transition.ease;
9071 duration = transition.duration;
9072 }
9073 function tick(elapsed) {
9074 var t = elapsed / duration, e = ease(t), n = tweens.length;
9075 while (n > 0) {
9076 tweens[--n].call(node, e);
9077 }
9078 if (t >= 1) {
9079 transition.event && transition.event.end.call(node, node.__data__, i);
9080 if (--lock.count) delete lock[id]; else delete node[ns];
9081 return 1;
9082 }
9083 }
9084 if (!transition) {
9085 time = inherit.time;
9086 timer = d3_timer(schedule, 0, time);
9087 transition = lock[id] = {
9088 tween: new d3_Map(),
9089 time: time,
9090 timer: timer,
9091 delay: inherit.delay,
9092 duration: inherit.duration,
9093 ease: inherit.ease,
9094 index: i
9095 };
9096 inherit = null;
9097 ++lock.count;
9098 }
9099 }
9100 d3.svg.axis = function() {
9101 var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_;
9102 function axis(g) {
9103 g.each(function() {
9104 var g = d3.select(this);
9105 var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();
9106 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;
9107 var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
9108 d3.transition(path));
9109 tickEnter.append("line");
9110 tickEnter.append("text");
9111 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;
9112 if (orient === "bottom" || orient === "top") {
9113 tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2";
9114 text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle");
9115 pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize);
9116 } else {
9117 tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2";
9118 text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start");
9119 pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize);
9120 }
9121 lineEnter.attr(y2, sign * innerTickSize);
9122 textEnter.attr(y1, sign * tickSpacing);
9123 lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize);
9124 textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing);
9125 if (scale1.rangeBand) {
9126 var x = scale1, dx = x.rangeBand() / 2;
9127 scale0 = scale1 = function(d) {
9128 return x(d) + dx;
9129 };
9130 } else if (scale0.rangeBand) {
9131 scale0 = scale1;
9132 } else {
9133 tickExit.call(tickTransform, scale1, scale0);
9134 }
9135 tickEnter.call(tickTransform, scale0, scale1);
9136 tickUpdate.call(tickTransform, scale1, scale1);
9137 });
9138 }
9139 axis.scale = function(x) {
9140 if (!arguments.length) return scale;
9141 scale = x;
9142 return axis;
9143 };
9144 axis.orient = function(x) {
9145 if (!arguments.length) return orient;
9146 orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient;
9147 return axis;
9148 };
9149 axis.ticks = function() {
9150 if (!arguments.length) return tickArguments_;
9151 tickArguments_ = d3_array(arguments);
9152 return axis;
9153 };
9154 axis.tickValues = function(x) {
9155 if (!arguments.length) return tickValues;
9156 tickValues = x;
9157 return axis;
9158 };
9159 axis.tickFormat = function(x) {
9160 if (!arguments.length) return tickFormat_;
9161 tickFormat_ = x;
9162 return axis;
9163 };
9164 axis.tickSize = function(x) {
9165 var n = arguments.length;
9166 if (!n) return innerTickSize;
9167 innerTickSize = +x;
9168 outerTickSize = +arguments[n - 1];
9169 return axis;
9170 };
9171 axis.innerTickSize = function(x) {
9172 if (!arguments.length) return innerTickSize;
9173 innerTickSize = +x;
9174 return axis;
9175 };
9176 axis.outerTickSize = function(x) {
9177 if (!arguments.length) return outerTickSize;
9178 outerTickSize = +x;
9179 return axis;
9180 };
9181 axis.tickPadding = function(x) {
9182 if (!arguments.length) return tickPadding;
9183 tickPadding = +x;
9184 return axis;
9185 };
9186 axis.tickSubdivide = function() {
9187 return arguments.length && axis;
9188 };
9189 return axis;
9190 };
9191 var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = {
9192 top: 1,
9193 right: 1,
9194 bottom: 1,
9195 left: 1
9196 };
9197 function d3_svg_axisX(selection, x0, x1) {
9198 selection.attr("transform", function(d) {
9199 var v0 = x0(d);
9200 return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)";
9201 });
9202 }
9203 function d3_svg_axisY(selection, y0, y1) {
9204 selection.attr("transform", function(d) {
9205 var v0 = y0(d);
9206 return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")";
9207 });
9208 }
9209 d3.svg.brush = function() {
9210 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];
9211 function brush(g) {
9212 g.each(function() {
9213 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);
9214 var background = g.selectAll(".background").data([ 0 ]);
9215 background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair");
9216 g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move");
9217 var resize = g.selectAll(".resize").data(resizes, d3_identity);
9218 resize.exit().remove();
9219 resize.enter().append("g").attr("class", function(d) {
9220 return "resize " + d;
9221 }).style("cursor", function(d) {
9222 return d3_svg_brushCursor[d];
9223 }).append("rect").attr("x", function(d) {
9224 return /[ew]$/.test(d) ? -3 : null;
9225 }).attr("y", function(d) {
9226 return /^[ns]/.test(d) ? -3 : null;
9227 }).attr("width", 6).attr("height", 6).style("visibility", "hidden");
9228 resize.style("display", brush.empty() ? "none" : null);
9229 var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range;
9230 if (x) {
9231 range = d3_scaleRange(x);
9232 backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]);
9233 redrawX(gUpdate);
9234 }
9235 if (y) {
9236 range = d3_scaleRange(y);
9237 backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]);
9238 redrawY(gUpdate);
9239 }
9240 redraw(gUpdate);
9241 });
9242 }
9243 brush.event = function(g) {
9244 g.each(function() {
9245 var event_ = event.of(this, arguments), extent1 = {
9246 x: xExtent,
9247 y: yExtent,
9248 i: xExtentDomain,
9249 j: yExtentDomain
9250 }, extent0 = this.__chart__ || extent1;
9251 this.__chart__ = extent1;
9252 if (d3_transitionInheritId) {
9253 d3.select(this).transition().each("start.brush", function() {
9254 xExtentDomain = extent0.i;
9255 yExtentDomain = extent0.j;
9256 xExtent = extent0.x;
9257 yExtent = extent0.y;
9258 event_({
9259 type: "brushstart"
9260 });
9261 }).tween("brush:brush", function() {
9262 var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y);
9263 xExtentDomain = yExtentDomain = null;
9264 return function(t) {
9265 xExtent = extent1.x = xi(t);
9266 yExtent = extent1.y = yi(t);
9267 event_({
9268 type: "brush",
9269 mode: "resize"
9270 });
9271 };
9272 }).each("end.brush", function() {
9273 xExtentDomain = extent1.i;
9274 yExtentDomain = extent1.j;
9275 event_({
9276 type: "brush",
9277 mode: "resize"
9278 });
9279 event_({
9280 type: "brushend"
9281 });
9282 });
9283 } else {
9284 event_({
9285 type: "brushstart"
9286 });
9287 event_({
9288 type: "brush",
9289 mode: "resize"
9290 });
9291 event_({
9292 type: "brushend"
9293 });
9294 }
9295 });
9296 };
9297 function redraw(g) {
9298 g.selectAll(".resize").attr("transform", function(d) {
9299 return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")";
9300 });
9301 }
9302 function redrawX(g) {
9303 g.select(".extent").attr("x", xExtent[0]);
9304 g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]);
9305 }
9306 function redrawY(g) {
9307 g.select(".extent").attr("y", yExtent[0]);
9308 g.selectAll(".extent,.e>rect,.w>rect").attr("height", yExtent[1] - yExtent[0]);
9309 }
9310 function brushstart() {
9311 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;
9312 var w = d3.select(d3_window(target)).on("keydown.brush", keydown).on("keyup.brush", keyup);
9313 if (d3.event.changedTouches) {
9314 w.on("touchmove.brush", brushmove).on("touchend.brush", brushend);
9315 } else {
9316 w.on("mousemove.brush", brushmove).on("mouseup.brush", brushend);
9317 }
9318 g.interrupt().selectAll("*").interrupt();
9319 if (dragging) {
9320 origin[0] = xExtent[0] - origin[0];
9321 origin[1] = yExtent[0] - origin[1];
9322 } else if (resizing) {
9323 var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing);
9324 offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ];
9325 origin[0] = xExtent[ex];
9326 origin[1] = yExtent[ey];
9327 } else if (d3.event.altKey) center = origin.slice();
9328 g.style("pointer-events", "none").selectAll(".resize").style("display", null);
9329 d3.select("body").style("cursor", eventTarget.style("cursor"));
9330 event_({
9331 type: "brushstart"
9332 });
9333 brushmove();
9334 function keydown() {
9335 if (d3.event.keyCode == 32) {
9336 if (!dragging) {
9337 center = null;
9338 origin[0] -= xExtent[1];
9339 origin[1] -= yExtent[1];
9340 dragging = 2;
9341 }
9342 d3_eventPreventDefault();
9343 }
9344 }
9345 function keyup() {
9346 if (d3.event.keyCode == 32 && dragging == 2) {
9347 origin[0] += xExtent[1];
9348 origin[1] += yExtent[1];
9349 dragging = 0;
9350 d3_eventPreventDefault();
9351 }
9352 }
9353 function brushmove() {
9354 var point = d3.mouse(target), moved = false;
9355 if (offset) {
9356 point[0] += offset[0];
9357 point[1] += offset[1];
9358 }
9359 if (!dragging) {
9360 if (d3.event.altKey) {
9361 if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ];
9362 origin[0] = xExtent[+(point[0] < center[0])];
9363 origin[1] = yExtent[+(point[1] < center[1])];
9364 } else center = null;
9365 }
9366 if (resizingX && move1(point, x, 0)) {
9367 redrawX(g);
9368 moved = true;
9369 }
9370 if (resizingY && move1(point, y, 1)) {
9371 redrawY(g);
9372 moved = true;
9373 }
9374 if (moved) {
9375 redraw(g);
9376 event_({
9377 type: "brush",
9378 mode: dragging ? "move" : "resize"
9379 });
9380 }
9381 }
9382 function move1(point, scale, i) {
9383 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;
9384 if (dragging) {
9385 r0 -= position;
9386 r1 -= size + position;
9387 }
9388 min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i];
9389 if (dragging) {
9390 max = (min += position) + size;
9391 } else {
9392 if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));
9393 if (position < min) {
9394 max = min;
9395 min = position;
9396 } else {
9397 max = position;
9398 }
9399 }
9400 if (extent[0] != min || extent[1] != max) {
9401 if (i) yExtentDomain = null; else xExtentDomain = null;
9402 extent[0] = min;
9403 extent[1] = max;
9404 return true;
9405 }
9406 }
9407 function brushend() {
9408 brushmove();
9409 g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null);
9410 d3.select("body").style("cursor", null);
9411 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);
9412 dragRestore();
9413 event_({
9414 type: "brushend"
9415 });
9416 }
9417 }
9418 brush.x = function(z) {
9419 if (!arguments.length) return x;
9420 x = z;
9421 resizes = d3_svg_brushResizes[!x << 1 | !y];
9422 return brush;
9423 };
9424 brush.y = function(z) {
9425 if (!arguments.length) return y;
9426 y = z;
9427 resizes = d3_svg_brushResizes[!x << 1 | !y];
9428 return brush;
9429 };
9430 brush.clamp = function(z) {
9431 if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null;
9432 if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z;
9433 return brush;
9434 };
9435 brush.extent = function(z) {
9436 var x0, x1, y0, y1, t;
9437 if (!arguments.length) {
9438 if (x) {
9439 if (xExtentDomain) {
9440 x0 = xExtentDomain[0], x1 = xExtentDomain[1];
9441 } else {
9442 x0 = xExtent[0], x1 = xExtent[1];
9443 if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);
9444 if (x1 < x0) t = x0, x0 = x1, x1 = t;
9445 }
9446 }
9447 if (y) {
9448 if (yExtentDomain) {
9449 y0 = yExtentDomain[0], y1 = yExtentDomain[1];
9450 } else {
9451 y0 = yExtent[0], y1 = yExtent[1];
9452 if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);
9453 if (y1 < y0) t = y0, y0 = y1, y1 = t;
9454 }
9455 }
9456 return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ];
9457 }
9458 if (x) {
9459 x0 = z[0], x1 = z[1];
9460 if (y) x0 = x0[0], x1 = x1[0];
9461 xExtentDomain = [ x0, x1 ];
9462 if (x.invert) x0 = x(x0), x1 = x(x1);
9463 if (x1 < x0) t = x0, x0 = x1, x1 = t;
9464 if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ];
9465 }
9466 if (y) {
9467 y0 = z[0], y1 = z[1];
9468 if (x) y0 = y0[1], y1 = y1[1];
9469 yExtentDomain = [ y0, y1 ];
9470 if (y.invert) y0 = y(y0), y1 = y(y1);
9471 if (y1 < y0) t = y0, y0 = y1, y1 = t;
9472 if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ];
9473 }
9474 return brush;
9475 };
9476 brush.clear = function() {
9477 if (!brush.empty()) {
9478 xExtent = [ 0, 0 ], yExtent = [ 0, 0 ];
9479 xExtentDomain = yExtentDomain = null;
9480 }
9481 return brush;
9482 };
9483 brush.empty = function() {
9484 return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1];
9485 };
9486 return d3.rebind(brush, event, "on");
9487 };
9488 var d3_svg_brushCursor = {
9489 n: "ns-resize",
9490 e: "ew-resize",
9491 s: "ns-resize",
9492 w: "ew-resize",
9493 nw: "nwse-resize",
9494 ne: "nesw-resize",
9495 se: "nwse-resize",
9496 sw: "nesw-resize"
9497 };
9498 var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ];
9499 var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat;
9500 var d3_time_formatUtc = d3_time_format.utc;
9501 var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ");
9502 d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso;
9503 function d3_time_formatIsoNative(date) {
9504 return date.toISOString();
9505 }
9506 d3_time_formatIsoNative.parse = function(string) {
9507 var date = new Date(string);
9508 return isNaN(date) ? null : date;
9509 };
9510 d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
9511 d3_time.second = d3_time_interval(function(date) {
9512 return new d3_date(Math.floor(date / 1e3) * 1e3);
9513 }, function(date, offset) {
9514 date.setTime(date.getTime() + Math.floor(offset) * 1e3);
9515 }, function(date) {
9516 return date.getSeconds();
9517 });
9518 d3_time.seconds = d3_time.second.range;
9519 d3_time.seconds.utc = d3_time.second.utc.range;
9520 d3_time.minute = d3_time_interval(function(date) {
9521 return new d3_date(Math.floor(date / 6e4) * 6e4);
9522 }, function(date, offset) {
9523 date.setTime(date.getTime() + Math.floor(offset) * 6e4);
9524 }, function(date) {
9525 return date.getMinutes();
9526 });
9527 d3_time.minutes = d3_time.minute.range;
9528 d3_time.minutes.utc = d3_time.minute.utc.range;
9529 d3_time.hour = d3_time_interval(function(date) {
9530 var timezone = date.getTimezoneOffset() / 60;
9531 return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
9532 }, function(date, offset) {
9533 date.setTime(date.getTime() + Math.floor(offset) * 36e5);
9534 }, function(date) {
9535 return date.getHours();
9536 });
9537 d3_time.hours = d3_time.hour.range;
9538 d3_time.hours.utc = d3_time.hour.utc.range;
9539 d3_time.month = d3_time_interval(function(date) {
9540 date = d3_time.day(date);
9541 date.setDate(1);
9542 return date;
9543 }, function(date, offset) {
9544 date.setMonth(date.getMonth() + offset);
9545 }, function(date) {
9546 return date.getMonth();
9547 });
9548 d3_time.months = d3_time.month.range;
9549 d3_time.months.utc = d3_time.month.utc.range;
9550 function d3_time_scale(linear, methods, format) {
9551 function scale(x) {
9552 return linear(x);
9553 }
9554 scale.invert = function(x) {
9555 return d3_time_scaleDate(linear.invert(x));
9556 };
9557 scale.domain = function(x) {
9558 if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
9559 linear.domain(x);
9560 return scale;
9561 };
9562 function tickMethod(extent, count) {
9563 var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target);
9564 return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) {
9565 return d / 31536e6;
9566 }), 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];
9567 }
9568 scale.nice = function(interval, skip) {
9569 var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" && tickMethod(extent, interval);
9570 if (method) interval = method[0], skip = method[1];
9571 function skipped(date) {
9572 return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length;
9573 }
9574 return scale.domain(d3_scale_nice(domain, skip > 1 ? {
9575 floor: function(date) {
9576 while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1);
9577 return date;
9578 },
9579 ceil: function(date) {
9580 while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1);
9581 return date;
9582 }
9583 } : interval));
9584 };
9585 scale.ticks = function(interval, skip) {
9586 var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" ? tickMethod(extent, interval) : !interval.range && [ {
9587 range: interval
9588 }, skip ];
9589 if (method) interval = method[0], skip = method[1];
9590 return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip);
9591 };
9592 scale.tickFormat = function() {
9593 return format;
9594 };
9595 scale.copy = function() {
9596 return d3_time_scale(linear.copy(), methods, format);
9597 };
9598 return d3_scale_linearRebind(scale, linear);
9599 }
9600 function d3_time_scaleDate(t) {
9601 return new Date(t);
9602 }
9603 var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ];
9604 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 ] ];
9605 var d3_time_scaleLocalFormat = d3_time_format.multi([ [ ".%L", function(d) {
9606 return d.getMilliseconds();
9607 } ], [ ":%S", function(d) {
9608 return d.getSeconds();
9609 } ], [ "%I:%M", function(d) {
9610 return d.getMinutes();
9611 } ], [ "%I %p", function(d) {
9612 return d.getHours();
9613 } ], [ "%a %d", function(d) {
9614 return d.getDay() && d.getDate() != 1;
9615 } ], [ "%b %d", function(d) {
9616 return d.getDate() != 1;
9617 } ], [ "%B", function(d) {
9618 return d.getMonth();
9619 } ], [ "%Y", d3_true ] ]);
9620 var d3_time_scaleMilliseconds = {
9621 range: function(start, stop, step) {
9622 return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate);
9623 },
9624 floor: d3_identity,
9625 ceil: d3_identity
9626 };
9627 d3_time_scaleLocalMethods.year = d3_time.year;
9628 d3_time.scale = function() {
9629 return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);
9630 };
9631 var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) {
9632 return [ m[0].utc, m[1] ];
9633 });
9634 var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ ".%L", function(d) {
9635 return d.getUTCMilliseconds();
9636 } ], [ ":%S", function(d) {
9637 return d.getUTCSeconds();
9638 } ], [ "%I:%M", function(d) {
9639 return d.getUTCMinutes();
9640 } ], [ "%I %p", function(d) {
9641 return d.getUTCHours();
9642 } ], [ "%a %d", function(d) {
9643 return d.getUTCDay() && d.getUTCDate() != 1;
9644 } ], [ "%b %d", function(d) {
9645 return d.getUTCDate() != 1;
9646 } ], [ "%B", function(d) {
9647 return d.getUTCMonth();
9648 } ], [ "%Y", d3_true ] ]);
9649 d3_time_scaleUtcMethods.year = d3_time.year.utc;
9650 d3_time.scale.utc = function() {
9651 return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat);
9652 };
9653 d3.text = d3_xhrType(function(request) {
9654 return request.responseText;
9655 });
9656 d3.json = function(url, callback) {
9657 return d3_xhr(url, "application/json", d3_json, callback);
9658 };
9659 function d3_json(request) {
9660 return JSON.parse(request.responseText);
9661 }
9662 d3.html = function(url, callback) {
9663 return d3_xhr(url, "text/html", d3_html, callback);
9664 };
9665 function d3_html(request) {
9666 var range = d3_document.createRange();
9667 range.selectNode(d3_document.body);
9668 return range.createContextualFragment(request.responseText);
9669 }
9670 d3.xml = d3_xhrType(function(request) {
9671 return request.responseXML;
9672 });
9673 if (module.exports) module.exports = d3; else this.d3 = d3;
9674 }();
9675 }(d3$1));
9676
9677 var d3 = d3$1.exports;
9678
9679 function _isPlaceholder(a) {
9680 return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true;
9681 }
9682
9683 /**
9684 * Optimized internal one-arity curry function.
9685 *
9686 * @private
9687 * @category Function
9688 * @param {Function} fn The function to curry.
9689 * @return {Function} The curried function.
9690 */
9691
9692 function _curry1(fn) {
9693 return function f1(a) {
9694 if (arguments.length === 0 || _isPlaceholder(a)) {
9695 return f1;
9696 } else {
9697 return fn.apply(this, arguments);
9698 }
9699 };
9700 }
9701
9702 /**
9703 * Optimized internal two-arity curry function.
9704 *
9705 * @private
9706 * @category Function
9707 * @param {Function} fn The function to curry.
9708 * @return {Function} The curried function.
9709 */
9710
9711 function _curry2(fn) {
9712 return function f2(a, b) {
9713 switch (arguments.length) {
9714 case 0:
9715 return f2;
9716
9717 case 1:
9718 return _isPlaceholder(a) ? f2 : _curry1(function (_b) {
9719 return fn(a, _b);
9720 });
9721
9722 default:
9723 return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function (_a) {
9724 return fn(_a, b);
9725 }) : _isPlaceholder(b) ? _curry1(function (_b) {
9726 return fn(a, _b);
9727 }) : fn(a, b);
9728 }
9729 };
9730 }
9731
9732 function _arity(n, fn) {
9733 /* eslint-disable no-unused-vars */
9734 switch (n) {
9735 case 0:
9736 return function () {
9737 return fn.apply(this, arguments);
9738 };
9739
9740 case 1:
9741 return function (a0) {
9742 return fn.apply(this, arguments);
9743 };
9744
9745 case 2:
9746 return function (a0, a1) {
9747 return fn.apply(this, arguments);
9748 };
9749
9750 case 3:
9751 return function (a0, a1, a2) {
9752 return fn.apply(this, arguments);
9753 };
9754
9755 case 4:
9756 return function (a0, a1, a2, a3) {
9757 return fn.apply(this, arguments);
9758 };
9759
9760 case 5:
9761 return function (a0, a1, a2, a3, a4) {
9762 return fn.apply(this, arguments);
9763 };
9764
9765 case 6:
9766 return function (a0, a1, a2, a3, a4, a5) {
9767 return fn.apply(this, arguments);
9768 };
9769
9770 case 7:
9771 return function (a0, a1, a2, a3, a4, a5, a6) {
9772 return fn.apply(this, arguments);
9773 };
9774
9775 case 8:
9776 return function (a0, a1, a2, a3, a4, a5, a6, a7) {
9777 return fn.apply(this, arguments);
9778 };
9779
9780 case 9:
9781 return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {
9782 return fn.apply(this, arguments);
9783 };
9784
9785 case 10:
9786 return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
9787 return fn.apply(this, arguments);
9788 };
9789
9790 default:
9791 throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
9792 }
9793 }
9794
9795 /**
9796 * Internal curryN function.
9797 *
9798 * @private
9799 * @category Function
9800 * @param {Number} length The arity of the curried function.
9801 * @param {Array} received An array of arguments received thus far.
9802 * @param {Function} fn The function to curry.
9803 * @return {Function} The curried function.
9804 */
9805
9806 function _curryN(length, received, fn) {
9807 return function () {
9808 var combined = [];
9809 var argsIdx = 0;
9810 var left = length;
9811 var combinedIdx = 0;
9812
9813 while (combinedIdx < received.length || argsIdx < arguments.length) {
9814 var result;
9815
9816 if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) {
9817 result = received[combinedIdx];
9818 } else {
9819 result = arguments[argsIdx];
9820 argsIdx += 1;
9821 }
9822
9823 combined[combinedIdx] = result;
9824
9825 if (!_isPlaceholder(result)) {
9826 left -= 1;
9827 }
9828
9829 combinedIdx += 1;
9830 }
9831
9832 return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn));
9833 };
9834 }
9835
9836 /**
9837 * Returns a curried equivalent of the provided function, with the specified
9838 * arity. The curried function has two unusual capabilities. First, its
9839 * arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the
9840 * following are equivalent:
9841 *
9842 * - `g(1)(2)(3)`
9843 * - `g(1)(2, 3)`
9844 * - `g(1, 2)(3)`
9845 * - `g(1, 2, 3)`
9846 *
9847 * Secondly, the special placeholder value [`R.__`](#__) may be used to specify
9848 * "gaps", allowing partial application of any combination of arguments,
9849 * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__),
9850 * the following are equivalent:
9851 *
9852 * - `g(1, 2, 3)`
9853 * - `g(_, 2, 3)(1)`
9854 * - `g(_, _, 3)(1)(2)`
9855 * - `g(_, _, 3)(1, 2)`
9856 * - `g(_, 2)(1)(3)`
9857 * - `g(_, 2)(1, 3)`
9858 * - `g(_, 2)(_, 3)(1)`
9859 *
9860 * @func
9861 * @memberOf R
9862 * @since v0.5.0
9863 * @category Function
9864 * @sig Number -> (* -> a) -> (* -> a)
9865 * @param {Number} length The arity for the returned function.
9866 * @param {Function} fn The function to curry.
9867 * @return {Function} A new, curried function.
9868 * @see R.curry
9869 * @example
9870 *
9871 * const sumArgs = (...args) => R.sum(args);
9872 *
9873 * const curriedAddFourNumbers = R.curryN(4, sumArgs);
9874 * const f = curriedAddFourNumbers(1, 2);
9875 * const g = f(3);
9876 * g(4); //=> 10
9877 */
9878
9879 var curryN =
9880 /*#__PURE__*/
9881 _curry2(function curryN(length, fn) {
9882 if (length === 1) {
9883 return _curry1(fn);
9884 }
9885
9886 return _arity(length, _curryN(length, [], fn));
9887 });
9888
9889 var curryN$1 = curryN;
9890
9891 /**
9892 * Optimized internal three-arity curry function.
9893 *
9894 * @private
9895 * @category Function
9896 * @param {Function} fn The function to curry.
9897 * @return {Function} The curried function.
9898 */
9899
9900 function _curry3(fn) {
9901 return function f3(a, b, c) {
9902 switch (arguments.length) {
9903 case 0:
9904 return f3;
9905
9906 case 1:
9907 return _isPlaceholder(a) ? f3 : _curry2(function (_b, _c) {
9908 return fn(a, _b, _c);
9909 });
9910
9911 case 2:
9912 return _isPlaceholder(a) && _isPlaceholder(b) ? f3 : _isPlaceholder(a) ? _curry2(function (_a, _c) {
9913 return fn(_a, b, _c);
9914 }) : _isPlaceholder(b) ? _curry2(function (_b, _c) {
9915 return fn(a, _b, _c);
9916 }) : _curry1(function (_c) {
9917 return fn(a, b, _c);
9918 });
9919
9920 default:
9921 return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function (_a, _b) {
9922 return fn(_a, _b, c);
9923 }) : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function (_a, _c) {
9924 return fn(_a, b, _c);
9925 }) : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function (_b, _c) {
9926 return fn(a, _b, _c);
9927 }) : _isPlaceholder(a) ? _curry1(function (_a) {
9928 return fn(_a, b, c);
9929 }) : _isPlaceholder(b) ? _curry1(function (_b) {
9930 return fn(a, _b, c);
9931 }) : _isPlaceholder(c) ? _curry1(function (_c) {
9932 return fn(a, b, _c);
9933 }) : fn(a, b, c);
9934 }
9935 };
9936 }
9937
9938 /**
9939 * Tests whether or not an object is an array.
9940 *
9941 * @private
9942 * @param {*} val The object to test.
9943 * @return {Boolean} `true` if `val` is an array, `false` otherwise.
9944 * @example
9945 *
9946 * _isArray([]); //=> true
9947 * _isArray(null); //=> false
9948 * _isArray({}); //=> false
9949 */
9950 var _isArray = Array.isArray || function _isArray(val) {
9951 return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]';
9952 };
9953
9954 function _isTransformer(obj) {
9955 return obj != null && typeof obj['@@transducer/step'] === 'function';
9956 }
9957
9958 /**
9959 * Returns a function that dispatches with different strategies based on the
9960 * object in list position (last argument). If it is an array, executes [fn].
9961 * Otherwise, if it has a function with one of the given method names, it will
9962 * execute that function (functor case). Otherwise, if it is a transformer,
9963 * uses transducer [xf] to return a new transformer (transducer case).
9964 * Otherwise, it will default to executing [fn].
9965 *
9966 * @private
9967 * @param {Array} methodNames properties to check for a custom implementation
9968 * @param {Function} xf transducer to initialize if object is transformer
9969 * @param {Function} fn default ramda implementation
9970 * @return {Function} A function that dispatches on object in list position
9971 */
9972
9973 function _dispatchable(methodNames, xf, fn) {
9974 return function () {
9975 if (arguments.length === 0) {
9976 return fn();
9977 }
9978
9979 var args = Array.prototype.slice.call(arguments, 0);
9980 var obj = args.pop();
9981
9982 if (!_isArray(obj)) {
9983 var idx = 0;
9984
9985 while (idx < methodNames.length) {
9986 if (typeof obj[methodNames[idx]] === 'function') {
9987 return obj[methodNames[idx]].apply(obj, args);
9988 }
9989
9990 idx += 1;
9991 }
9992
9993 if (_isTransformer(obj)) {
9994 var transducer = xf.apply(null, args);
9995 return transducer(obj);
9996 }
9997 }
9998
9999 return fn.apply(this, arguments);
10000 };
10001 }
10002
10003 var _xfBase = {
10004 init: function () {
10005 return this.xf['@@transducer/init']();
10006 },
10007 result: function (result) {
10008 return this.xf['@@transducer/result'](result);
10009 }
10010 };
10011
10012 function _map(fn, functor) {
10013 var idx = 0;
10014 var len = functor.length;
10015 var result = Array(len);
10016
10017 while (idx < len) {
10018 result[idx] = fn(functor[idx]);
10019 idx += 1;
10020 }
10021
10022 return result;
10023 }
10024
10025 function _isString(x) {
10026 return Object.prototype.toString.call(x) === '[object String]';
10027 }
10028
10029 /**
10030 * Tests whether or not an object is similar to an array.
10031 *
10032 * @private
10033 * @category Type
10034 * @category List
10035 * @sig * -> Boolean
10036 * @param {*} x The object to test.
10037 * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise.
10038 * @example
10039 *
10040 * _isArrayLike([]); //=> true
10041 * _isArrayLike(true); //=> false
10042 * _isArrayLike({}); //=> false
10043 * _isArrayLike({length: 10}); //=> false
10044 * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true
10045 */
10046
10047 var _isArrayLike =
10048 /*#__PURE__*/
10049 _curry1(function isArrayLike(x) {
10050 if (_isArray(x)) {
10051 return true;
10052 }
10053
10054 if (!x) {
10055 return false;
10056 }
10057
10058 if (typeof x !== 'object') {
10059 return false;
10060 }
10061
10062 if (_isString(x)) {
10063 return false;
10064 }
10065
10066 if (x.nodeType === 1) {
10067 return !!x.length;
10068 }
10069
10070 if (x.length === 0) {
10071 return true;
10072 }
10073
10074 if (x.length > 0) {
10075 return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
10076 }
10077
10078 return false;
10079 });
10080
10081 var _isArrayLike$1 = _isArrayLike;
10082
10083 var XWrap =
10084 /*#__PURE__*/
10085 function () {
10086 function XWrap(fn) {
10087 this.f = fn;
10088 }
10089
10090 XWrap.prototype['@@transducer/init'] = function () {
10091 throw new Error('init not implemented on XWrap');
10092 };
10093
10094 XWrap.prototype['@@transducer/result'] = function (acc) {
10095 return acc;
10096 };
10097
10098 XWrap.prototype['@@transducer/step'] = function (acc, x) {
10099 return this.f(acc, x);
10100 };
10101
10102 return XWrap;
10103 }();
10104
10105 function _xwrap(fn) {
10106 return new XWrap(fn);
10107 }
10108
10109 /**
10110 * Creates a function that is bound to a context.
10111 * Note: `R.bind` does not provide the additional argument-binding capabilities of
10112 * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
10113 *
10114 * @func
10115 * @memberOf R
10116 * @since v0.6.0
10117 * @category Function
10118 * @category Object
10119 * @sig (* -> *) -> {*} -> (* -> *)
10120 * @param {Function} fn The function to bind to context
10121 * @param {Object} thisObj The context to bind `fn` to
10122 * @return {Function} A function that will execute in the context of `thisObj`.
10123 * @see R.partial
10124 * @example
10125 *
10126 * const log = R.bind(console.log, console);
10127 * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
10128 * // logs {a: 2}
10129 * @symb R.bind(f, o)(a, b) = f.call(o, a, b)
10130 */
10131
10132 var bind =
10133 /*#__PURE__*/
10134 _curry2(function bind(fn, thisObj) {
10135 return _arity(fn.length, function () {
10136 return fn.apply(thisObj, arguments);
10137 });
10138 });
10139
10140 var bind$1 = bind;
10141
10142 function _arrayReduce(xf, acc, list) {
10143 var idx = 0;
10144 var len = list.length;
10145
10146 while (idx < len) {
10147 acc = xf['@@transducer/step'](acc, list[idx]);
10148
10149 if (acc && acc['@@transducer/reduced']) {
10150 acc = acc['@@transducer/value'];
10151 break;
10152 }
10153
10154 idx += 1;
10155 }
10156
10157 return xf['@@transducer/result'](acc);
10158 }
10159
10160 function _iterableReduce(xf, acc, iter) {
10161 var step = iter.next();
10162
10163 while (!step.done) {
10164 acc = xf['@@transducer/step'](acc, step.value);
10165
10166 if (acc && acc['@@transducer/reduced']) {
10167 acc = acc['@@transducer/value'];
10168 break;
10169 }
10170
10171 step = iter.next();
10172 }
10173
10174 return xf['@@transducer/result'](acc);
10175 }
10176
10177 function _methodReduce(xf, acc, obj, methodName) {
10178 return xf['@@transducer/result'](obj[methodName](bind$1(xf['@@transducer/step'], xf), acc));
10179 }
10180
10181 var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
10182 function _reduce(fn, acc, list) {
10183 if (typeof fn === 'function') {
10184 fn = _xwrap(fn);
10185 }
10186
10187 if (_isArrayLike$1(list)) {
10188 return _arrayReduce(fn, acc, list);
10189 }
10190
10191 if (typeof list['fantasy-land/reduce'] === 'function') {
10192 return _methodReduce(fn, acc, list, 'fantasy-land/reduce');
10193 }
10194
10195 if (list[symIterator] != null) {
10196 return _iterableReduce(fn, acc, list[symIterator]());
10197 }
10198
10199 if (typeof list.next === 'function') {
10200 return _iterableReduce(fn, acc, list);
10201 }
10202
10203 if (typeof list.reduce === 'function') {
10204 return _methodReduce(fn, acc, list, 'reduce');
10205 }
10206
10207 throw new TypeError('reduce: list must be array or iterable');
10208 }
10209
10210 function _has(prop, obj) {
10211 return Object.prototype.hasOwnProperty.call(obj, prop);
10212 }
10213
10214 var toString$4 = Object.prototype.toString;
10215
10216 var _isArguments =
10217 /*#__PURE__*/
10218 function () {
10219 return toString$4.call(arguments) === '[object Arguments]' ? function _isArguments(x) {
10220 return toString$4.call(x) === '[object Arguments]';
10221 } : function _isArguments(x) {
10222 return _has('callee', x);
10223 };
10224 }();
10225
10226 var _isArguments$1 = _isArguments;
10227
10228 var hasEnumBug = !
10229 /*#__PURE__*/
10230 {
10231 toString: null
10232 }.propertyIsEnumerable('toString');
10233 var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug
10234
10235 var hasArgsEnumBug =
10236 /*#__PURE__*/
10237 function () {
10238
10239 return arguments.propertyIsEnumerable('length');
10240 }();
10241
10242 var contains = function contains(list, item) {
10243 var idx = 0;
10244
10245 while (idx < list.length) {
10246 if (list[idx] === item) {
10247 return true;
10248 }
10249
10250 idx += 1;
10251 }
10252
10253 return false;
10254 };
10255 /**
10256 * Returns a list containing the names of all the enumerable own properties of
10257 * the supplied object.
10258 * Note that the order of the output array is not guaranteed to be consistent
10259 * across different JS platforms.
10260 *
10261 * @func
10262 * @memberOf R
10263 * @since v0.1.0
10264 * @category Object
10265 * @sig {k: v} -> [k]
10266 * @param {Object} obj The object to extract properties from
10267 * @return {Array} An array of the object's own properties.
10268 * @see R.keysIn, R.values
10269 * @example
10270 *
10271 * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
10272 */
10273
10274
10275 var keys$4 = typeof Object.keys === 'function' && !hasArgsEnumBug ?
10276 /*#__PURE__*/
10277 _curry1(function keys(obj) {
10278 return Object(obj) !== obj ? [] : Object.keys(obj);
10279 }) :
10280 /*#__PURE__*/
10281 _curry1(function keys(obj) {
10282 if (Object(obj) !== obj) {
10283 return [];
10284 }
10285
10286 var prop, nIdx;
10287 var ks = [];
10288
10289 var checkArgsLength = hasArgsEnumBug && _isArguments$1(obj);
10290
10291 for (prop in obj) {
10292 if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
10293 ks[ks.length] = prop;
10294 }
10295 }
10296
10297 if (hasEnumBug) {
10298 nIdx = nonEnumerableProps.length - 1;
10299
10300 while (nIdx >= 0) {
10301 prop = nonEnumerableProps[nIdx];
10302
10303 if (_has(prop, obj) && !contains(ks, prop)) {
10304 ks[ks.length] = prop;
10305 }
10306
10307 nIdx -= 1;
10308 }
10309 }
10310
10311 return ks;
10312 });
10313 var keys$5 = keys$4;
10314
10315 /**
10316 * Returns a single item by iterating through the list, successively calling
10317 * the iterator function and passing it an accumulator value and the current
10318 * value from the array, and then passing the result to the next call.
10319 *
10320 * The iterator function receives two values: *(acc, value)*. It may use
10321 * [`R.reduced`](#reduced) to shortcut the iteration.
10322 *
10323 * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function
10324 * is *(value, acc)*.
10325 *
10326 * Note: `R.reduce` does not skip deleted or unassigned indices (sparse
10327 * arrays), unlike the native `Array.prototype.reduce` method. For more details
10328 * on this behavior, see:
10329 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description
10330 *
10331 * Dispatches to the `reduce` method of the third argument, if present. When
10332 * doing so, it is up to the user to handle the [`R.reduced`](#reduced)
10333 * shortcuting, as this is not implemented by `reduce`.
10334 *
10335 * @func
10336 * @memberOf R
10337 * @since v0.1.0
10338 * @category List
10339 * @sig ((a, b) -> a) -> a -> [b] -> a
10340 * @param {Function} fn The iterator function. Receives two values, the accumulator and the
10341 * current element from the array.
10342 * @param {*} acc The accumulator value.
10343 * @param {Array} list The list to iterate over.
10344 * @return {*} The final, accumulated value.
10345 * @see R.reduced, R.addIndex, R.reduceRight
10346 * @example
10347 *
10348 * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10
10349 * // - -10
10350 * // / \ / \
10351 * // - 4 -6 4
10352 * // / \ / \
10353 * // - 3 ==> -3 3
10354 * // / \ / \
10355 * // - 2 -1 2
10356 * // / \ / \
10357 * // 0 1 0 1
10358 *
10359 * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d)
10360 */
10361
10362 var reduce =
10363 /*#__PURE__*/
10364 _curry3(_reduce);
10365
10366 var reduce$1 = reduce;
10367
10368 function _isFunction(x) {
10369 var type = Object.prototype.toString.call(x);
10370 return type === '[object Function]' || type === '[object AsyncFunction]' || type === '[object GeneratorFunction]' || type === '[object AsyncGeneratorFunction]';
10371 }
10372
10373 /**
10374 * Gives a single-word string description of the (native) type of a value,
10375 * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
10376 * attempt to distinguish user Object types any further, reporting them all as
10377 * 'Object'.
10378 *
10379 * @func
10380 * @memberOf R
10381 * @since v0.8.0
10382 * @category Type
10383 * @sig (* -> {*}) -> String
10384 * @param {*} val The value to test
10385 * @return {String}
10386 * @example
10387 *
10388 * R.type({}); //=> "Object"
10389 * R.type(1); //=> "Number"
10390 * R.type(false); //=> "Boolean"
10391 * R.type('s'); //=> "String"
10392 * R.type(null); //=> "Null"
10393 * R.type([]); //=> "Array"
10394 * R.type(/[A-z]/); //=> "RegExp"
10395 * R.type(() => {}); //=> "Function"
10396 * R.type(undefined); //=> "Undefined"
10397 */
10398
10399 var type =
10400 /*#__PURE__*/
10401 _curry1(function type(val) {
10402 return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
10403 });
10404
10405 var type$1 = type;
10406
10407 function _pipe(f, g) {
10408 return function () {
10409 return g.call(this, f.apply(this, arguments));
10410 };
10411 }
10412
10413 /**
10414 * This checks whether a function has a [methodname] function. If it isn't an
10415 * array it will execute that function otherwise it will default to the ramda
10416 * implementation.
10417 *
10418 * @private
10419 * @param {Function} fn ramda implemtation
10420 * @param {String} methodname property to check for a custom implementation
10421 * @return {Object} Whatever the return value of the method is.
10422 */
10423
10424 function _checkForMethod(methodname, fn) {
10425 return function () {
10426 var length = arguments.length;
10427
10428 if (length === 0) {
10429 return fn();
10430 }
10431
10432 var obj = arguments[length - 1];
10433 return _isArray(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
10434 };
10435 }
10436
10437 /**
10438 * Returns the elements of the given list or string (or object with a `slice`
10439 * method) from `fromIndex` (inclusive) to `toIndex` (exclusive).
10440 *
10441 * Dispatches to the `slice` method of the third argument, if present.
10442 *
10443 * @func
10444 * @memberOf R
10445 * @since v0.1.4
10446 * @category List
10447 * @sig Number -> Number -> [a] -> [a]
10448 * @sig Number -> Number -> String -> String
10449 * @param {Number} fromIndex The start index (inclusive).
10450 * @param {Number} toIndex The end index (exclusive).
10451 * @param {*} list
10452 * @return {*}
10453 * @example
10454 *
10455 * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
10456 * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
10457 * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
10458 * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
10459 * R.slice(0, 3, 'ramda'); //=> 'ram'
10460 */
10461
10462 var slice =
10463 /*#__PURE__*/
10464 _curry3(
10465 /*#__PURE__*/
10466 _checkForMethod('slice', function slice(fromIndex, toIndex, list) {
10467 return Array.prototype.slice.call(list, fromIndex, toIndex);
10468 }));
10469
10470 var slice$1 = slice;
10471
10472 /**
10473 * Returns all but the first element of the given list or string (or object
10474 * with a `tail` method).
10475 *
10476 * Dispatches to the `slice` method of the first argument, if present.
10477 *
10478 * @func
10479 * @memberOf R
10480 * @since v0.1.0
10481 * @category List
10482 * @sig [a] -> [a]
10483 * @sig String -> String
10484 * @param {*} list
10485 * @return {*}
10486 * @see R.head, R.init, R.last
10487 * @example
10488 *
10489 * R.tail([1, 2, 3]); //=> [2, 3]
10490 * R.tail([1, 2]); //=> [2]
10491 * R.tail([1]); //=> []
10492 * R.tail([]); //=> []
10493 *
10494 * R.tail('abc'); //=> 'bc'
10495 * R.tail('ab'); //=> 'b'
10496 * R.tail('a'); //=> ''
10497 * R.tail(''); //=> ''
10498 */
10499
10500 var tail =
10501 /*#__PURE__*/
10502 _curry1(
10503 /*#__PURE__*/
10504 _checkForMethod('tail',
10505 /*#__PURE__*/
10506 slice$1(1, Infinity)));
10507
10508 var tail$1 = tail;
10509
10510 /**
10511 * Performs left-to-right function composition. The first argument may have
10512 * any arity; the remaining arguments must be unary.
10513 *
10514 * In some libraries this function is named `sequence`.
10515 *
10516 * **Note:** The result of pipe is not automatically curried.
10517 *
10518 * @func
10519 * @memberOf R
10520 * @since v0.1.0
10521 * @category Function
10522 * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
10523 * @param {...Function} functions
10524 * @return {Function}
10525 * @see R.compose
10526 * @example
10527 *
10528 * const f = R.pipe(Math.pow, R.negate, R.inc);
10529 *
10530 * f(3, 4); // -(3^4) + 1
10531 * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
10532 */
10533
10534 function pipe() {
10535 if (arguments.length === 0) {
10536 throw new Error('pipe requires at least one argument');
10537 }
10538
10539 return _arity(arguments[0].length, reduce$1(_pipe, arguments[0], tail$1(arguments)));
10540 }
10541
10542 function _arrayFromIterator(iter) {
10543 var list = [];
10544 var next;
10545
10546 while (!(next = iter.next()).done) {
10547 list.push(next.value);
10548 }
10549
10550 return list;
10551 }
10552
10553 function _includesWith(pred, x, list) {
10554 var idx = 0;
10555 var len = list.length;
10556
10557 while (idx < len) {
10558 if (pred(x, list[idx])) {
10559 return true;
10560 }
10561
10562 idx += 1;
10563 }
10564
10565 return false;
10566 }
10567
10568 function _functionName(f) {
10569 // String(x => x) evaluates to "x => x", so the pattern may not match.
10570 var match = String(f).match(/^function (\w*)/);
10571 return match == null ? '' : match[1];
10572 }
10573
10574 // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
10575 function _objectIs(a, b) {
10576 // SameValue algorithm
10577 if (a === b) {
10578 // Steps 1-5, 7-10
10579 // Steps 6.b-6.e: +0 != -0
10580 return a !== 0 || 1 / a === 1 / b;
10581 } else {
10582 // Step 6.a: NaN == NaN
10583 return a !== a && b !== b;
10584 }
10585 }
10586
10587 var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
10588
10589 /**
10590 * private _uniqContentEquals function.
10591 * That function is checking equality of 2 iterator contents with 2 assumptions
10592 * - iterators lengths are the same
10593 * - iterators values are unique
10594 *
10595 * false-positive result will be returned for comparision of, e.g.
10596 * - [1,2,3] and [1,2,3,4]
10597 * - [1,1,1] and [1,2,3]
10598 * */
10599
10600 function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
10601 var a = _arrayFromIterator(aIterator);
10602
10603 var b = _arrayFromIterator(bIterator);
10604
10605 function eq(_a, _b) {
10606 return _equals(_a, _b, stackA.slice(), stackB.slice());
10607 } // if *a* array contains any element that is not included in *b*
10608
10609
10610 return !_includesWith(function (b, aItem) {
10611 return !_includesWith(eq, aItem, b);
10612 }, b, a);
10613 }
10614
10615 function _equals(a, b, stackA, stackB) {
10616 if (_objectIs$1(a, b)) {
10617 return true;
10618 }
10619
10620 var typeA = type$1(a);
10621
10622 if (typeA !== type$1(b)) {
10623 return false;
10624 }
10625
10626 if (a == null || b == null) {
10627 return false;
10628 }
10629
10630 if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
10631 return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a);
10632 }
10633
10634 if (typeof a.equals === 'function' || typeof b.equals === 'function') {
10635 return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a);
10636 }
10637
10638 switch (typeA) {
10639 case 'Arguments':
10640 case 'Array':
10641 case 'Object':
10642 if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') {
10643 return a === b;
10644 }
10645
10646 break;
10647
10648 case 'Boolean':
10649 case 'Number':
10650 case 'String':
10651 if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
10652 return false;
10653 }
10654
10655 break;
10656
10657 case 'Date':
10658 if (!_objectIs$1(a.valueOf(), b.valueOf())) {
10659 return false;
10660 }
10661
10662 break;
10663
10664 case 'Error':
10665 return a.name === b.name && a.message === b.message;
10666
10667 case 'RegExp':
10668 if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
10669 return false;
10670 }
10671
10672 break;
10673 }
10674
10675 var idx = stackA.length - 1;
10676
10677 while (idx >= 0) {
10678 if (stackA[idx] === a) {
10679 return stackB[idx] === b;
10680 }
10681
10682 idx -= 1;
10683 }
10684
10685 switch (typeA) {
10686 case 'Map':
10687 if (a.size !== b.size) {
10688 return false;
10689 }
10690
10691 return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
10692
10693 case 'Set':
10694 if (a.size !== b.size) {
10695 return false;
10696 }
10697
10698 return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
10699
10700 case 'Arguments':
10701 case 'Array':
10702 case 'Object':
10703 case 'Boolean':
10704 case 'Number':
10705 case 'String':
10706 case 'Date':
10707 case 'Error':
10708 case 'RegExp':
10709 case 'Int8Array':
10710 case 'Uint8Array':
10711 case 'Uint8ClampedArray':
10712 case 'Int16Array':
10713 case 'Uint16Array':
10714 case 'Int32Array':
10715 case 'Uint32Array':
10716 case 'Float32Array':
10717 case 'Float64Array':
10718 case 'ArrayBuffer':
10719 break;
10720
10721 default:
10722 // Values of other types are only equal if identical.
10723 return false;
10724 }
10725
10726 var keysA = keys$5(a);
10727
10728 if (keysA.length !== keys$5(b).length) {
10729 return false;
10730 }
10731
10732 var extendedStackA = stackA.concat([a]);
10733 var extendedStackB = stackB.concat([b]);
10734 idx = keysA.length - 1;
10735
10736 while (idx >= 0) {
10737 var key = keysA[idx];
10738
10739 if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
10740 return false;
10741 }
10742
10743 idx -= 1;
10744 }
10745
10746 return true;
10747 }
10748
10749 /**
10750 * Returns `true` if its arguments are equivalent, `false` otherwise. Handles
10751 * cyclical data structures.
10752 *
10753 * Dispatches symmetrically to the `equals` methods of both arguments, if
10754 * present.
10755 *
10756 * @func
10757 * @memberOf R
10758 * @since v0.15.0
10759 * @category Relation
10760 * @sig a -> b -> Boolean
10761 * @param {*} a
10762 * @param {*} b
10763 * @return {Boolean}
10764 * @example
10765 *
10766 * R.equals(1, 1); //=> true
10767 * R.equals(1, '1'); //=> false
10768 * R.equals([1, 2, 3], [1, 2, 3]); //=> true
10769 *
10770 * const a = {}; a.v = a;
10771 * const b = {}; b.v = b;
10772 * R.equals(a, b); //=> true
10773 */
10774
10775 var equals =
10776 /*#__PURE__*/
10777 _curry2(function equals(a, b) {
10778 return _equals(a, b, [], []);
10779 });
10780
10781 var equals$1 = equals;
10782
10783 function _indexOf(list, a, idx) {
10784 var inf, item; // Array.prototype.indexOf doesn't exist below IE9
10785
10786 if (typeof list.indexOf === 'function') {
10787 switch (typeof a) {
10788 case 'number':
10789 if (a === 0) {
10790 // manually crawl the list to distinguish between +0 and -0
10791 inf = 1 / a;
10792
10793 while (idx < list.length) {
10794 item = list[idx];
10795
10796 if (item === 0 && 1 / item === inf) {
10797 return idx;
10798 }
10799
10800 idx += 1;
10801 }
10802
10803 return -1;
10804 } else if (a !== a) {
10805 // NaN
10806 while (idx < list.length) {
10807 item = list[idx];
10808
10809 if (typeof item === 'number' && item !== item) {
10810 return idx;
10811 }
10812
10813 idx += 1;
10814 }
10815
10816 return -1;
10817 } // non-zero numbers can utilise Set
10818
10819
10820 return list.indexOf(a, idx);
10821 // all these types can utilise Set
10822
10823 case 'string':
10824 case 'boolean':
10825 case 'function':
10826 case 'undefined':
10827 return list.indexOf(a, idx);
10828
10829 case 'object':
10830 if (a === null) {
10831 // null can utilise Set
10832 return list.indexOf(a, idx);
10833 }
10834
10835 }
10836 } // anything else not covered above, defer to R.equals
10837
10838
10839 while (idx < list.length) {
10840 if (equals$1(list[idx], a)) {
10841 return idx;
10842 }
10843
10844 idx += 1;
10845 }
10846
10847 return -1;
10848 }
10849
10850 function _includes(a, list) {
10851 return _indexOf(list, a, 0) >= 0;
10852 }
10853
10854 function _quote(s) {
10855 var escaped = s.replace(/\\/g, '\\\\').replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace
10856 .replace(/\f/g, '\\f').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t').replace(/\v/g, '\\v').replace(/\0/g, '\\0');
10857 return '"' + escaped.replace(/"/g, '\\"') + '"';
10858 }
10859
10860 /**
10861 * Polyfill from <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString>.
10862 */
10863 var pad = function pad(n) {
10864 return (n < 10 ? '0' : '') + n;
10865 };
10866
10867 var _toISOString = typeof Date.prototype.toISOString === 'function' ? function _toISOString(d) {
10868 return d.toISOString();
10869 } : function _toISOString(d) {
10870 return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + '.' + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z';
10871 };
10872
10873 var _toISOString$1 = _toISOString;
10874
10875 function _complement(f) {
10876 return function () {
10877 return !f.apply(this, arguments);
10878 };
10879 }
10880
10881 function _filter(fn, list) {
10882 var idx = 0;
10883 var len = list.length;
10884 var result = [];
10885
10886 while (idx < len) {
10887 if (fn(list[idx])) {
10888 result[result.length] = list[idx];
10889 }
10890
10891 idx += 1;
10892 }
10893
10894 return result;
10895 }
10896
10897 function _isObject(x) {
10898 return Object.prototype.toString.call(x) === '[object Object]';
10899 }
10900
10901 var XFilter =
10902 /*#__PURE__*/
10903 function () {
10904 function XFilter(f, xf) {
10905 this.xf = xf;
10906 this.f = f;
10907 }
10908
10909 XFilter.prototype['@@transducer/init'] = _xfBase.init;
10910 XFilter.prototype['@@transducer/result'] = _xfBase.result;
10911
10912 XFilter.prototype['@@transducer/step'] = function (result, input) {
10913 return this.f(input) ? this.xf['@@transducer/step'](result, input) : result;
10914 };
10915
10916 return XFilter;
10917 }();
10918
10919 var _xfilter =
10920 /*#__PURE__*/
10921 _curry2(function _xfilter(f, xf) {
10922 return new XFilter(f, xf);
10923 });
10924
10925 var _xfilter$1 = _xfilter;
10926
10927 /**
10928 * Takes a predicate and a `Filterable`, and returns a new filterable of the
10929 * same type containing the members of the given filterable which satisfy the
10930 * given predicate. Filterable objects include plain objects or any object
10931 * that has a filter method such as `Array`.
10932 *
10933 * Dispatches to the `filter` method of the second argument, if present.
10934 *
10935 * Acts as a transducer if a transformer is given in list position.
10936 *
10937 * @func
10938 * @memberOf R
10939 * @since v0.1.0
10940 * @category List
10941 * @sig Filterable f => (a -> Boolean) -> f a -> f a
10942 * @param {Function} pred
10943 * @param {Array} filterable
10944 * @return {Array} Filterable
10945 * @see R.reject, R.transduce, R.addIndex
10946 * @example
10947 *
10948 * const isEven = n => n % 2 === 0;
10949 *
10950 * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
10951 *
10952 * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
10953 */
10954
10955 var filter =
10956 /*#__PURE__*/
10957 _curry2(
10958 /*#__PURE__*/
10959 _dispatchable(['filter'], _xfilter$1, function (pred, filterable) {
10960 return _isObject(filterable) ? _reduce(function (acc, key) {
10961 if (pred(filterable[key])) {
10962 acc[key] = filterable[key];
10963 }
10964
10965 return acc;
10966 }, {}, keys$5(filterable)) : // else
10967 _filter(pred, filterable);
10968 }));
10969
10970 var filter$1 = filter;
10971
10972 /**
10973 * The complement of [`filter`](#filter).
10974 *
10975 * Acts as a transducer if a transformer is given in list position. Filterable
10976 * objects include plain objects or any object that has a filter method such
10977 * as `Array`.
10978 *
10979 * @func
10980 * @memberOf R
10981 * @since v0.1.0
10982 * @category List
10983 * @sig Filterable f => (a -> Boolean) -> f a -> f a
10984 * @param {Function} pred
10985 * @param {Array} filterable
10986 * @return {Array}
10987 * @see R.filter, R.transduce, R.addIndex
10988 * @example
10989 *
10990 * const isOdd = (n) => n % 2 === 1;
10991 *
10992 * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]
10993 *
10994 * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
10995 */
10996
10997 var reject =
10998 /*#__PURE__*/
10999 _curry2(function reject(pred, filterable) {
11000 return filter$1(_complement(pred), filterable);
11001 });
11002
11003 var reject$1 = reject;
11004
11005 function _toString(x, seen) {
11006 var recur = function recur(y) {
11007 var xs = seen.concat([x]);
11008 return _includes(y, xs) ? '<Circular>' : _toString(y, xs);
11009 }; // mapPairs :: (Object, [String]) -> [String]
11010
11011
11012 var mapPairs = function (obj, keys) {
11013 return _map(function (k) {
11014 return _quote(k) + ': ' + recur(obj[k]);
11015 }, keys.slice().sort());
11016 };
11017
11018 switch (Object.prototype.toString.call(x)) {
11019 case '[object Arguments]':
11020 return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))';
11021
11022 case '[object Array]':
11023 return '[' + _map(recur, x).concat(mapPairs(x, reject$1(function (k) {
11024 return /^\d+$/.test(k);
11025 }, keys$5(x)))).join(', ') + ']';
11026
11027 case '[object Boolean]':
11028 return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString();
11029
11030 case '[object Date]':
11031 return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString$1(x))) + ')';
11032
11033 case '[object Null]':
11034 return 'null';
11035
11036 case '[object Number]':
11037 return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10);
11038
11039 case '[object String]':
11040 return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x);
11041
11042 case '[object Undefined]':
11043 return 'undefined';
11044
11045 default:
11046 if (typeof x.toString === 'function') {
11047 var repr = x.toString();
11048
11049 if (repr !== '[object Object]') {
11050 return repr;
11051 }
11052 }
11053
11054 return '{' + mapPairs(x, keys$5(x)).join(', ') + '}';
11055 }
11056 }
11057
11058 /**
11059 * Returns the string representation of the given value. `eval`'ing the output
11060 * should result in a value equivalent to the input value. Many of the built-in
11061 * `toString` methods do not satisfy this requirement.
11062 *
11063 * If the given value is an `[object Object]` with a `toString` method other
11064 * than `Object.prototype.toString`, this method is invoked with no arguments
11065 * to produce the return value. This means user-defined constructor functions
11066 * can provide a suitable `toString` method. For example:
11067 *
11068 * function Point(x, y) {
11069 * this.x = x;
11070 * this.y = y;
11071 * }
11072 *
11073 * Point.prototype.toString = function() {
11074 * return 'new Point(' + this.x + ', ' + this.y + ')';
11075 * };
11076 *
11077 * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)'
11078 *
11079 * @func
11080 * @memberOf R
11081 * @since v0.14.0
11082 * @category String
11083 * @sig * -> String
11084 * @param {*} val
11085 * @return {String}
11086 * @example
11087 *
11088 * R.toString(42); //=> '42'
11089 * R.toString('abc'); //=> '"abc"'
11090 * R.toString([1, 2, 3]); //=> '[1, 2, 3]'
11091 * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}'
11092 * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")'
11093 */
11094
11095 var toString$2 =
11096 /*#__PURE__*/
11097 _curry1(function toString(val) {
11098 return _toString(val, []);
11099 });
11100
11101 var toString$3 = toString$2;
11102
11103 /**
11104 * Returns the empty value of its argument's type. Ramda defines the empty
11105 * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other
11106 * types are supported if they define `<Type>.empty`,
11107 * `<Type>.prototype.empty` or implement the
11108 * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
11109 *
11110 * Dispatches to the `empty` method of the first argument, if present.
11111 *
11112 * @func
11113 * @memberOf R
11114 * @since v0.3.0
11115 * @category Function
11116 * @sig a -> a
11117 * @param {*} x
11118 * @return {*}
11119 * @example
11120 *
11121 * R.empty(Just(42)); //=> Nothing()
11122 * R.empty([1, 2, 3]); //=> []
11123 * R.empty('unicorns'); //=> ''
11124 * R.empty({x: 1, y: 2}); //=> {}
11125 */
11126
11127 var empty =
11128 /*#__PURE__*/
11129 _curry1(function empty(x) {
11130 return x != null && typeof x['fantasy-land/empty'] === 'function' ? x['fantasy-land/empty']() : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function' ? x.constructor['fantasy-land/empty']() : x != null && typeof x.empty === 'function' ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === 'function' ? x.constructor.empty() : _isArray(x) ? [] : _isString(x) ? '' : _isObject(x) ? {} : _isArguments$1(x) ? function () {
11131 return arguments;
11132 }() : void 0 // else
11133 ;
11134 });
11135
11136 var empty$1 = empty;
11137
11138 /**
11139 * Turns a named method with a specified arity into a function that can be
11140 * called directly supplied with arguments and a target object.
11141 *
11142 * The returned function is curried and accepts `arity + 1` parameters where
11143 * the final parameter is the target object.
11144 *
11145 * @func
11146 * @memberOf R
11147 * @since v0.1.0
11148 * @category Function
11149 * @sig Number -> String -> (a -> b -> ... -> n -> Object -> *)
11150 * @param {Number} arity Number of arguments the returned function should take
11151 * before the target object.
11152 * @param {String} method Name of any of the target object's methods to call.
11153 * @return {Function} A new curried function.
11154 * @see R.construct
11155 * @example
11156 *
11157 * const sliceFrom = R.invoker(1, 'slice');
11158 * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm'
11159 * const sliceFrom6 = R.invoker(2, 'slice')(6);
11160 * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh'
11161 *
11162 * const dog = {
11163 * speak: async () => 'Woof!'
11164 * };
11165 * const speak = R.invoker(0, 'speak');
11166 * speak(dog).then(console.log) //~> 'Woof!'
11167 *
11168 * @symb R.invoker(0, 'method')(o) = o['method']()
11169 * @symb R.invoker(1, 'method')(a, o) = o['method'](a)
11170 * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b)
11171 */
11172
11173 var invoker =
11174 /*#__PURE__*/
11175 _curry2(function invoker(arity, method) {
11176 return curryN$1(arity + 1, function () {
11177 var target = arguments[arity];
11178
11179 if (target != null && _isFunction(target[method])) {
11180 return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity));
11181 }
11182
11183 throw new TypeError(toString$3(target) + ' does not have a method named "' + method + '"');
11184 });
11185 });
11186
11187 var invoker$1 = invoker;
11188
11189 /**
11190 * See if an object (`val`) is an instance of the supplied constructor. This
11191 * function will check up the inheritance chain, if any.
11192 *
11193 * @func
11194 * @memberOf R
11195 * @since v0.3.0
11196 * @category Type
11197 * @sig (* -> {*}) -> a -> Boolean
11198 * @param {Object} ctor A constructor
11199 * @param {*} val The value to test
11200 * @return {Boolean}
11201 * @example
11202 *
11203 * R.is(Object, {}); //=> true
11204 * R.is(Number, 1); //=> true
11205 * R.is(Object, 1); //=> false
11206 * R.is(String, 's'); //=> true
11207 * R.is(String, new String('')); //=> true
11208 * R.is(Object, new String('')); //=> true
11209 * R.is(Object, 's'); //=> false
11210 * R.is(Number, {}); //=> false
11211 */
11212
11213 var is =
11214 /*#__PURE__*/
11215 _curry2(function is(Ctor, val) {
11216 return val != null && val.constructor === Ctor || val instanceof Ctor;
11217 });
11218
11219 var is$1 = is;
11220
11221 /**
11222 * Returns `true` if the given value is its type's empty value; `false`
11223 * otherwise.
11224 *
11225 * @func
11226 * @memberOf R
11227 * @since v0.1.0
11228 * @category Logic
11229 * @sig a -> Boolean
11230 * @param {*} x
11231 * @return {Boolean}
11232 * @see R.empty
11233 * @example
11234 *
11235 * R.isEmpty([1, 2, 3]); //=> false
11236 * R.isEmpty([]); //=> true
11237 * R.isEmpty(''); //=> true
11238 * R.isEmpty(null); //=> false
11239 * R.isEmpty({}); //=> true
11240 * R.isEmpty({length: 0}); //=> false
11241 */
11242
11243 var isEmpty =
11244 /*#__PURE__*/
11245 _curry1(function isEmpty(x) {
11246 return x != null && equals$1(x, empty$1(x));
11247 });
11248
11249 var isEmpty$1 = isEmpty;
11250
11251 /**
11252 * Returns a string made by inserting the `separator` between each element and
11253 * concatenating all the elements into a single string.
11254 *
11255 * @func
11256 * @memberOf R
11257 * @since v0.1.0
11258 * @category List
11259 * @sig String -> [a] -> String
11260 * @param {Number|String} separator The string used to separate the elements.
11261 * @param {Array} xs The elements to join into a string.
11262 * @return {String} str The string made by concatenating `xs` with `separator`.
11263 * @see R.split
11264 * @example
11265 *
11266 * const spacer = R.join(' ');
11267 * spacer(['a', 2, 3.4]); //=> 'a 2 3.4'
11268 * R.join('|', [1, 2, 3]); //=> '1|2|3'
11269 */
11270
11271 var join =
11272 /*#__PURE__*/
11273 invoker$1(1, 'join');
11274 var join$1 = join;
11275
11276 /**
11277 * An Object-specific version of [`map`](#map). The function is applied to three
11278 * arguments: *(value, key, obj)*. If only the value is significant, use
11279 * [`map`](#map) instead.
11280 *
11281 * @func
11282 * @memberOf R
11283 * @since v0.9.0
11284 * @category Object
11285 * @sig ((*, String, Object) -> *) -> Object -> Object
11286 * @param {Function} fn
11287 * @param {Object} obj
11288 * @return {Object}
11289 * @see R.map
11290 * @example
11291 *
11292 * const xyz = { x: 1, y: 2, z: 3 };
11293 * const prependKeyAndDouble = (num, key, obj) => key + (num * 2);
11294 *
11295 * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' }
11296 */
11297
11298 var mapObjIndexed =
11299 /*#__PURE__*/
11300 _curry2(function mapObjIndexed(fn, obj) {
11301 return _reduce(function (acc, key) {
11302 acc[key] = fn(obj[key], key, obj);
11303 return acc;
11304 }, {}, keys$5(obj));
11305 });
11306
11307 var mapObjIndexed$1 = mapObjIndexed;
11308
11309 /**
11310 * Replace a substring or regex match in a string with a replacement.
11311 *
11312 * The first two parameters correspond to the parameters of the
11313 * `String.prototype.replace()` function, so the second parameter can also be a
11314 * function.
11315 *
11316 * @func
11317 * @memberOf R
11318 * @since v0.7.0
11319 * @category String
11320 * @sig RegExp|String -> String -> String -> String
11321 * @param {RegExp|String} pattern A regular expression or a substring to match.
11322 * @param {String} replacement The string to replace the matches with.
11323 * @param {String} str The String to do the search and replacement in.
11324 * @return {String} The result.
11325 * @example
11326 *
11327 * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
11328 * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'
11329 *
11330 * // Use the "g" (global) flag to replace all occurrences:
11331 * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
11332 */
11333
11334 var replace =
11335 /*#__PURE__*/
11336 _curry3(function replace(regex, replacement, str) {
11337 return str.replace(regex, replacement);
11338 });
11339
11340 var replace$1 = replace;
11341
11342 function _defineProperty$1(obj, key, value) {
11343 if (key in obj) {
11344 Object.defineProperty(obj, key, {
11345 value: value,
11346 enumerable: true,
11347 configurable: true,
11348 writable: true
11349 });
11350 } else {
11351 obj[key] = value;
11352 }
11353
11354 return obj;
11355 }
11356
11357 /**
11358 * Checks if `value` is classified as an `Array` object.
11359 *
11360 * @static
11361 * @memberOf _
11362 * @since 0.1.0
11363 * @category Lang
11364 * @param {*} value The value to check.
11365 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
11366 * @example
11367 *
11368 * _.isArray([1, 2, 3]);
11369 * // => true
11370 *
11371 * _.isArray(document.body.children);
11372 * // => false
11373 *
11374 * _.isArray('abc');
11375 * // => false
11376 *
11377 * _.isArray(_.noop);
11378 * // => false
11379 */
11380
11381 var isArray$8 = Array.isArray;
11382
11383 var isArray_1 = isArray$8;
11384
11385 /** Detect free variable `global` from Node.js. */
11386
11387 var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
11388
11389 var _freeGlobal = freeGlobal$1;
11390
11391 var freeGlobal = _freeGlobal;
11392
11393 /** Detect free variable `self`. */
11394 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
11395
11396 /** Used as a reference to the global object. */
11397 var root$8 = freeGlobal || freeSelf || Function('return this')();
11398
11399 var _root = root$8;
11400
11401 var root$7 = _root;
11402
11403 /** Built-in value references. */
11404 var Symbol$5 = root$7.Symbol;
11405
11406 var _Symbol = Symbol$5;
11407
11408 var Symbol$4 = _Symbol;
11409
11410 /** Used for built-in method references. */
11411 var objectProto$c = Object.prototype;
11412
11413 /** Used to check objects for own properties. */
11414 var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
11415
11416 /**
11417 * Used to resolve the
11418 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11419 * of values.
11420 */
11421 var nativeObjectToString$1 = objectProto$c.toString;
11422
11423 /** Built-in value references. */
11424 var symToStringTag$1 = Symbol$4 ? Symbol$4.toStringTag : undefined;
11425
11426 /**
11427 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
11428 *
11429 * @private
11430 * @param {*} value The value to query.
11431 * @returns {string} Returns the raw `toStringTag`.
11432 */
11433 function getRawTag$1(value) {
11434 var isOwn = hasOwnProperty$9.call(value, symToStringTag$1),
11435 tag = value[symToStringTag$1];
11436
11437 try {
11438 value[symToStringTag$1] = undefined;
11439 var unmasked = true;
11440 } catch (e) {}
11441
11442 var result = nativeObjectToString$1.call(value);
11443 if (unmasked) {
11444 if (isOwn) {
11445 value[symToStringTag$1] = tag;
11446 } else {
11447 delete value[symToStringTag$1];
11448 }
11449 }
11450 return result;
11451 }
11452
11453 var _getRawTag = getRawTag$1;
11454
11455 /** Used for built-in method references. */
11456
11457 var objectProto$b = Object.prototype;
11458
11459 /**
11460 * Used to resolve the
11461 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11462 * of values.
11463 */
11464 var nativeObjectToString = objectProto$b.toString;
11465
11466 /**
11467 * Converts `value` to a string using `Object.prototype.toString`.
11468 *
11469 * @private
11470 * @param {*} value The value to convert.
11471 * @returns {string} Returns the converted string.
11472 */
11473 function objectToString$1(value) {
11474 return nativeObjectToString.call(value);
11475 }
11476
11477 var _objectToString = objectToString$1;
11478
11479 var Symbol$3 = _Symbol,
11480 getRawTag = _getRawTag,
11481 objectToString = _objectToString;
11482
11483 /** `Object#toString` result references. */
11484 var nullTag = '[object Null]',
11485 undefinedTag = '[object Undefined]';
11486
11487 /** Built-in value references. */
11488 var symToStringTag = Symbol$3 ? Symbol$3.toStringTag : undefined;
11489
11490 /**
11491 * The base implementation of `getTag` without fallbacks for buggy environments.
11492 *
11493 * @private
11494 * @param {*} value The value to query.
11495 * @returns {string} Returns the `toStringTag`.
11496 */
11497 function baseGetTag$6(value) {
11498 if (value == null) {
11499 return value === undefined ? undefinedTag : nullTag;
11500 }
11501 return (symToStringTag && symToStringTag in Object(value))
11502 ? getRawTag(value)
11503 : objectToString(value);
11504 }
11505
11506 var _baseGetTag = baseGetTag$6;
11507
11508 /**
11509 * Creates a unary function that invokes `func` with its argument transformed.
11510 *
11511 * @private
11512 * @param {Function} func The function to wrap.
11513 * @param {Function} transform The argument transform.
11514 * @returns {Function} Returns the new function.
11515 */
11516
11517 function overArg$2(func, transform) {
11518 return function(arg) {
11519 return func(transform(arg));
11520 };
11521 }
11522
11523 var _overArg = overArg$2;
11524
11525 var overArg$1 = _overArg;
11526
11527 /** Built-in value references. */
11528 var getPrototype$1 = overArg$1(Object.getPrototypeOf, Object);
11529
11530 var _getPrototype = getPrototype$1;
11531
11532 /**
11533 * Checks if `value` is object-like. A value is object-like if it's not `null`
11534 * and has a `typeof` result of "object".
11535 *
11536 * @static
11537 * @memberOf _
11538 * @since 4.0.0
11539 * @category Lang
11540 * @param {*} value The value to check.
11541 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11542 * @example
11543 *
11544 * _.isObjectLike({});
11545 * // => true
11546 *
11547 * _.isObjectLike([1, 2, 3]);
11548 * // => true
11549 *
11550 * _.isObjectLike(_.noop);
11551 * // => false
11552 *
11553 * _.isObjectLike(null);
11554 * // => false
11555 */
11556
11557 function isObjectLike$6(value) {
11558 return value != null && typeof value == 'object';
11559 }
11560
11561 var isObjectLike_1 = isObjectLike$6;
11562
11563 var baseGetTag$5 = _baseGetTag,
11564 getPrototype = _getPrototype,
11565 isObjectLike$5 = isObjectLike_1;
11566
11567 /** `Object#toString` result references. */
11568 var objectTag$3 = '[object Object]';
11569
11570 /** Used for built-in method references. */
11571 var funcProto$2 = Function.prototype,
11572 objectProto$a = Object.prototype;
11573
11574 /** Used to resolve the decompiled source of functions. */
11575 var funcToString$2 = funcProto$2.toString;
11576
11577 /** Used to check objects for own properties. */
11578 var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
11579
11580 /** Used to infer the `Object` constructor. */
11581 var objectCtorString = funcToString$2.call(Object);
11582
11583 /**
11584 * Checks if `value` is a plain object, that is, an object created by the
11585 * `Object` constructor or one with a `[[Prototype]]` of `null`.
11586 *
11587 * @static
11588 * @memberOf _
11589 * @since 0.8.0
11590 * @category Lang
11591 * @param {*} value The value to check.
11592 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
11593 * @example
11594 *
11595 * function Foo() {
11596 * this.a = 1;
11597 * }
11598 *
11599 * _.isPlainObject(new Foo);
11600 * // => false
11601 *
11602 * _.isPlainObject([1, 2, 3]);
11603 * // => false
11604 *
11605 * _.isPlainObject({ 'x': 0, 'y': 0 });
11606 * // => true
11607 *
11608 * _.isPlainObject(Object.create(null));
11609 * // => true
11610 */
11611 function isPlainObject(value) {
11612 if (!isObjectLike$5(value) || baseGetTag$5(value) != objectTag$3) {
11613 return false;
11614 }
11615 var proto = getPrototype(value);
11616 if (proto === null) {
11617 return true;
11618 }
11619 var Ctor = hasOwnProperty$8.call(proto, 'constructor') && proto.constructor;
11620 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
11621 funcToString$2.call(Ctor) == objectCtorString;
11622 }
11623
11624 var isPlainObject_1 = isPlainObject;
11625
11626 /**
11627 * Checks if `value` is the
11628 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11629 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11630 *
11631 * @static
11632 * @memberOf _
11633 * @since 0.1.0
11634 * @category Lang
11635 * @param {*} value The value to check.
11636 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11637 * @example
11638 *
11639 * _.isObject({});
11640 * // => true
11641 *
11642 * _.isObject([1, 2, 3]);
11643 * // => true
11644 *
11645 * _.isObject(_.noop);
11646 * // => true
11647 *
11648 * _.isObject(null);
11649 * // => false
11650 */
11651
11652 function isObject$3(value) {
11653 var type = typeof value;
11654 return value != null && (type == 'object' || type == 'function');
11655 }
11656
11657 var isObject_1 = isObject$3;
11658
11659 var baseGetTag$4 = _baseGetTag,
11660 isObject$2 = isObject_1;
11661
11662 /** `Object#toString` result references. */
11663 var asyncTag = '[object AsyncFunction]',
11664 funcTag$1 = '[object Function]',
11665 genTag = '[object GeneratorFunction]',
11666 proxyTag = '[object Proxy]';
11667
11668 /**
11669 * Checks if `value` is classified as a `Function` object.
11670 *
11671 * @static
11672 * @memberOf _
11673 * @since 0.1.0
11674 * @category Lang
11675 * @param {*} value The value to check.
11676 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11677 * @example
11678 *
11679 * _.isFunction(_);
11680 * // => true
11681 *
11682 * _.isFunction(/abc/);
11683 * // => false
11684 */
11685 function isFunction$2(value) {
11686 if (!isObject$2(value)) {
11687 return false;
11688 }
11689 // The use of `Object#toString` avoids issues with the `typeof` operator
11690 // in Safari 9 which returns 'object' for typed arrays and other constructors.
11691 var tag = baseGetTag$4(value);
11692 return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
11693 }
11694
11695 var isFunction_1 = isFunction$2;
11696
11697 var root$6 = _root;
11698
11699 /** Used to detect overreaching core-js shims. */
11700 var coreJsData$1 = root$6['__core-js_shared__'];
11701
11702 var _coreJsData = coreJsData$1;
11703
11704 var coreJsData = _coreJsData;
11705
11706 /** Used to detect methods masquerading as native. */
11707 var maskSrcKey = (function() {
11708 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
11709 return uid ? ('Symbol(src)_1.' + uid) : '';
11710 }());
11711
11712 /**
11713 * Checks if `func` has its source masked.
11714 *
11715 * @private
11716 * @param {Function} func The function to check.
11717 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
11718 */
11719 function isMasked$1(func) {
11720 return !!maskSrcKey && (maskSrcKey in func);
11721 }
11722
11723 var _isMasked = isMasked$1;
11724
11725 /** Used for built-in method references. */
11726
11727 var funcProto$1 = Function.prototype;
11728
11729 /** Used to resolve the decompiled source of functions. */
11730 var funcToString$1 = funcProto$1.toString;
11731
11732 /**
11733 * Converts `func` to its source code.
11734 *
11735 * @private
11736 * @param {Function} func The function to convert.
11737 * @returns {string} Returns the source code.
11738 */
11739 function toSource$2(func) {
11740 if (func != null) {
11741 try {
11742 return funcToString$1.call(func);
11743 } catch (e) {}
11744 try {
11745 return (func + '');
11746 } catch (e) {}
11747 }
11748 return '';
11749 }
11750
11751 var _toSource = toSource$2;
11752
11753 var isFunction$1 = isFunction_1,
11754 isMasked = _isMasked,
11755 isObject$1 = isObject_1,
11756 toSource$1 = _toSource;
11757
11758 /**
11759 * Used to match `RegExp`
11760 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
11761 */
11762 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
11763
11764 /** Used to detect host constructors (Safari). */
11765 var reIsHostCtor = /^\[object .+?Constructor\]$/;
11766
11767 /** Used for built-in method references. */
11768 var funcProto = Function.prototype,
11769 objectProto$9 = Object.prototype;
11770
11771 /** Used to resolve the decompiled source of functions. */
11772 var funcToString = funcProto.toString;
11773
11774 /** Used to check objects for own properties. */
11775 var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
11776
11777 /** Used to detect if a method is native. */
11778 var reIsNative = RegExp('^' +
11779 funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
11780 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
11781 );
11782
11783 /**
11784 * The base implementation of `_.isNative` without bad shim checks.
11785 *
11786 * @private
11787 * @param {*} value The value to check.
11788 * @returns {boolean} Returns `true` if `value` is a native function,
11789 * else `false`.
11790 */
11791 function baseIsNative$1(value) {
11792 if (!isObject$1(value) || isMasked(value)) {
11793 return false;
11794 }
11795 var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
11796 return pattern.test(toSource$1(value));
11797 }
11798
11799 var _baseIsNative = baseIsNative$1;
11800
11801 /**
11802 * Gets the value at `key` of `object`.
11803 *
11804 * @private
11805 * @param {Object} [object] The object to query.
11806 * @param {string} key The key of the property to get.
11807 * @returns {*} Returns the property value.
11808 */
11809
11810 function getValue$1(object, key) {
11811 return object == null ? undefined : object[key];
11812 }
11813
11814 var _getValue = getValue$1;
11815
11816 var baseIsNative = _baseIsNative,
11817 getValue = _getValue;
11818
11819 /**
11820 * Gets the native function at `key` of `object`.
11821 *
11822 * @private
11823 * @param {Object} object The object to query.
11824 * @param {string} key The key of the method to get.
11825 * @returns {*} Returns the function if it's native, else `undefined`.
11826 */
11827 function getNative$7(object, key) {
11828 var value = getValue(object, key);
11829 return baseIsNative(value) ? value : undefined;
11830 }
11831
11832 var _getNative = getNative$7;
11833
11834 var getNative$6 = _getNative;
11835
11836 var defineProperty$1 = (function() {
11837 try {
11838 var func = getNative$6(Object, 'defineProperty');
11839 func({}, '', {});
11840 return func;
11841 } catch (e) {}
11842 }());
11843
11844 var _defineProperty = defineProperty$1;
11845
11846 var defineProperty = _defineProperty;
11847
11848 /**
11849 * The base implementation of `assignValue` and `assignMergeValue` without
11850 * value checks.
11851 *
11852 * @private
11853 * @param {Object} object The object to modify.
11854 * @param {string} key The key of the property to assign.
11855 * @param {*} value The value to assign.
11856 */
11857 function baseAssignValue$1(object, key, value) {
11858 if (key == '__proto__' && defineProperty) {
11859 defineProperty(object, key, {
11860 'configurable': true,
11861 'enumerable': true,
11862 'value': value,
11863 'writable': true
11864 });
11865 } else {
11866 object[key] = value;
11867 }
11868 }
11869
11870 var _baseAssignValue = baseAssignValue$1;
11871
11872 /**
11873 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
11874 *
11875 * @private
11876 * @param {boolean} [fromRight] Specify iterating from right to left.
11877 * @returns {Function} Returns the new base function.
11878 */
11879
11880 function createBaseFor$1(fromRight) {
11881 return function(object, iteratee, keysFunc) {
11882 var index = -1,
11883 iterable = Object(object),
11884 props = keysFunc(object),
11885 length = props.length;
11886
11887 while (length--) {
11888 var key = props[fromRight ? length : ++index];
11889 if (iteratee(iterable[key], key, iterable) === false) {
11890 break;
11891 }
11892 }
11893 return object;
11894 };
11895 }
11896
11897 var _createBaseFor = createBaseFor$1;
11898
11899 var createBaseFor = _createBaseFor;
11900
11901 /**
11902 * The base implementation of `baseForOwn` which iterates over `object`
11903 * properties returned by `keysFunc` and invokes `iteratee` for each property.
11904 * Iteratee functions may exit iteration early by explicitly returning `false`.
11905 *
11906 * @private
11907 * @param {Object} object The object to iterate over.
11908 * @param {Function} iteratee The function invoked per iteration.
11909 * @param {Function} keysFunc The function to get the keys of `object`.
11910 * @returns {Object} Returns `object`.
11911 */
11912 var baseFor$1 = createBaseFor();
11913
11914 var _baseFor = baseFor$1;
11915
11916 /**
11917 * The base implementation of `_.times` without support for iteratee shorthands
11918 * or max array length checks.
11919 *
11920 * @private
11921 * @param {number} n The number of times to invoke `iteratee`.
11922 * @param {Function} iteratee The function invoked per iteration.
11923 * @returns {Array} Returns the array of results.
11924 */
11925
11926 function baseTimes$1(n, iteratee) {
11927 var index = -1,
11928 result = Array(n);
11929
11930 while (++index < n) {
11931 result[index] = iteratee(index);
11932 }
11933 return result;
11934 }
11935
11936 var _baseTimes = baseTimes$1;
11937
11938 var baseGetTag$3 = _baseGetTag,
11939 isObjectLike$4 = isObjectLike_1;
11940
11941 /** `Object#toString` result references. */
11942 var argsTag$2 = '[object Arguments]';
11943
11944 /**
11945 * The base implementation of `_.isArguments`.
11946 *
11947 * @private
11948 * @param {*} value The value to check.
11949 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11950 */
11951 function baseIsArguments$1(value) {
11952 return isObjectLike$4(value) && baseGetTag$3(value) == argsTag$2;
11953 }
11954
11955 var _baseIsArguments = baseIsArguments$1;
11956
11957 var baseIsArguments = _baseIsArguments,
11958 isObjectLike$3 = isObjectLike_1;
11959
11960 /** Used for built-in method references. */
11961 var objectProto$8 = Object.prototype;
11962
11963 /** Used to check objects for own properties. */
11964 var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
11965
11966 /** Built-in value references. */
11967 var propertyIsEnumerable$1 = objectProto$8.propertyIsEnumerable;
11968
11969 /**
11970 * Checks if `value` is likely an `arguments` object.
11971 *
11972 * @static
11973 * @memberOf _
11974 * @since 0.1.0
11975 * @category Lang
11976 * @param {*} value The value to check.
11977 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
11978 * else `false`.
11979 * @example
11980 *
11981 * _.isArguments(function() { return arguments; }());
11982 * // => true
11983 *
11984 * _.isArguments([1, 2, 3]);
11985 * // => false
11986 */
11987 var isArguments$2 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
11988 return isObjectLike$3(value) && hasOwnProperty$6.call(value, 'callee') &&
11989 !propertyIsEnumerable$1.call(value, 'callee');
11990 };
11991
11992 var isArguments_1 = isArguments$2;
11993
11994 var isBuffer$2 = {exports: {}};
11995
11996 /**
11997 * This method returns `false`.
11998 *
11999 * @static
12000 * @memberOf _
12001 * @since 4.13.0
12002 * @category Util
12003 * @returns {boolean} Returns `false`.
12004 * @example
12005 *
12006 * _.times(2, _.stubFalse);
12007 * // => [false, false]
12008 */
12009
12010 function stubFalse() {
12011 return false;
12012 }
12013
12014 var stubFalse_1 = stubFalse;
12015
12016 (function (module, exports) {
12017 var root = _root,
12018 stubFalse = stubFalse_1;
12019
12020 /** Detect free variable `exports`. */
12021 var freeExports = exports && !exports.nodeType && exports;
12022
12023 /** Detect free variable `module`. */
12024 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12025
12026 /** Detect the popular CommonJS extension `module.exports`. */
12027 var moduleExports = freeModule && freeModule.exports === freeExports;
12028
12029 /** Built-in value references. */
12030 var Buffer = moduleExports ? root.Buffer : undefined;
12031
12032 /* Built-in method references for those with the same name as other `lodash` methods. */
12033 var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
12034
12035 /**
12036 * Checks if `value` is a buffer.
12037 *
12038 * @static
12039 * @memberOf _
12040 * @since 4.3.0
12041 * @category Lang
12042 * @param {*} value The value to check.
12043 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
12044 * @example
12045 *
12046 * _.isBuffer(new Buffer(2));
12047 * // => true
12048 *
12049 * _.isBuffer(new Uint8Array(2));
12050 * // => false
12051 */
12052 var isBuffer = nativeIsBuffer || stubFalse;
12053
12054 module.exports = isBuffer;
12055 }(isBuffer$2, isBuffer$2.exports));
12056
12057 /** Used as references for various `Number` constants. */
12058
12059 var MAX_SAFE_INTEGER$1 = 9007199254740991;
12060
12061 /** Used to detect unsigned integer values. */
12062 var reIsUint = /^(?:0|[1-9]\d*)$/;
12063
12064 /**
12065 * Checks if `value` is a valid array-like index.
12066 *
12067 * @private
12068 * @param {*} value The value to check.
12069 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
12070 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
12071 */
12072 function isIndex$2(value, length) {
12073 var type = typeof value;
12074 length = length == null ? MAX_SAFE_INTEGER$1 : length;
12075
12076 return !!length &&
12077 (type == 'number' ||
12078 (type != 'symbol' && reIsUint.test(value))) &&
12079 (value > -1 && value % 1 == 0 && value < length);
12080 }
12081
12082 var _isIndex = isIndex$2;
12083
12084 /** Used as references for various `Number` constants. */
12085
12086 var MAX_SAFE_INTEGER = 9007199254740991;
12087
12088 /**
12089 * Checks if `value` is a valid array-like length.
12090 *
12091 * **Note:** This method is loosely based on
12092 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12093 *
12094 * @static
12095 * @memberOf _
12096 * @since 4.0.0
12097 * @category Lang
12098 * @param {*} value The value to check.
12099 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
12100 * @example
12101 *
12102 * _.isLength(3);
12103 * // => true
12104 *
12105 * _.isLength(Number.MIN_VALUE);
12106 * // => false
12107 *
12108 * _.isLength(Infinity);
12109 * // => false
12110 *
12111 * _.isLength('3');
12112 * // => false
12113 */
12114 function isLength$3(value) {
12115 return typeof value == 'number' &&
12116 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
12117 }
12118
12119 var isLength_1 = isLength$3;
12120
12121 var baseGetTag$2 = _baseGetTag,
12122 isLength$2 = isLength_1,
12123 isObjectLike$2 = isObjectLike_1;
12124
12125 /** `Object#toString` result references. */
12126 var argsTag$1 = '[object Arguments]',
12127 arrayTag$1 = '[object Array]',
12128 boolTag$1 = '[object Boolean]',
12129 dateTag$1 = '[object Date]',
12130 errorTag$1 = '[object Error]',
12131 funcTag = '[object Function]',
12132 mapTag$2 = '[object Map]',
12133 numberTag$1 = '[object Number]',
12134 objectTag$2 = '[object Object]',
12135 regexpTag$1 = '[object RegExp]',
12136 setTag$2 = '[object Set]',
12137 stringTag$1 = '[object String]',
12138 weakMapTag$1 = '[object WeakMap]';
12139
12140 var arrayBufferTag$1 = '[object ArrayBuffer]',
12141 dataViewTag$2 = '[object DataView]',
12142 float32Tag = '[object Float32Array]',
12143 float64Tag = '[object Float64Array]',
12144 int8Tag = '[object Int8Array]',
12145 int16Tag = '[object Int16Array]',
12146 int32Tag = '[object Int32Array]',
12147 uint8Tag = '[object Uint8Array]',
12148 uint8ClampedTag = '[object Uint8ClampedArray]',
12149 uint16Tag = '[object Uint16Array]',
12150 uint32Tag = '[object Uint32Array]';
12151
12152 /** Used to identify `toStringTag` values of typed arrays. */
12153 var typedArrayTags = {};
12154 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
12155 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
12156 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
12157 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
12158 typedArrayTags[uint32Tag] = true;
12159 typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
12160 typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
12161 typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] =
12162 typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
12163 typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] =
12164 typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] =
12165 typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] =
12166 typedArrayTags[weakMapTag$1] = false;
12167
12168 /**
12169 * The base implementation of `_.isTypedArray` without Node.js optimizations.
12170 *
12171 * @private
12172 * @param {*} value The value to check.
12173 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12174 */
12175 function baseIsTypedArray$1(value) {
12176 return isObjectLike$2(value) &&
12177 isLength$2(value.length) && !!typedArrayTags[baseGetTag$2(value)];
12178 }
12179
12180 var _baseIsTypedArray = baseIsTypedArray$1;
12181
12182 /**
12183 * The base implementation of `_.unary` without support for storing metadata.
12184 *
12185 * @private
12186 * @param {Function} func The function to cap arguments for.
12187 * @returns {Function} Returns the new capped function.
12188 */
12189
12190 function baseUnary$1(func) {
12191 return function(value) {
12192 return func(value);
12193 };
12194 }
12195
12196 var _baseUnary = baseUnary$1;
12197
12198 var _nodeUtil = {exports: {}};
12199
12200 (function (module, exports) {
12201 var freeGlobal = _freeGlobal;
12202
12203 /** Detect free variable `exports`. */
12204 var freeExports = exports && !exports.nodeType && exports;
12205
12206 /** Detect free variable `module`. */
12207 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12208
12209 /** Detect the popular CommonJS extension `module.exports`. */
12210 var moduleExports = freeModule && freeModule.exports === freeExports;
12211
12212 /** Detect free variable `process` from Node.js. */
12213 var freeProcess = moduleExports && freeGlobal.process;
12214
12215 /** Used to access faster Node.js helpers. */
12216 var nodeUtil = (function() {
12217 try {
12218 // Use `util.types` for Node.js 10+.
12219 var types = freeModule && freeModule.require && freeModule.require('util').types;
12220
12221 if (types) {
12222 return types;
12223 }
12224
12225 // Legacy `process.binding('util')` for Node.js < 10.
12226 return freeProcess && freeProcess.binding && freeProcess.binding('util');
12227 } catch (e) {}
12228 }());
12229
12230 module.exports = nodeUtil;
12231 }(_nodeUtil, _nodeUtil.exports));
12232
12233 var baseIsTypedArray = _baseIsTypedArray,
12234 baseUnary = _baseUnary,
12235 nodeUtil = _nodeUtil.exports;
12236
12237 /* Node.js helper references. */
12238 var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
12239
12240 /**
12241 * Checks if `value` is classified as a typed array.
12242 *
12243 * @static
12244 * @memberOf _
12245 * @since 3.0.0
12246 * @category Lang
12247 * @param {*} value The value to check.
12248 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12249 * @example
12250 *
12251 * _.isTypedArray(new Uint8Array);
12252 * // => true
12253 *
12254 * _.isTypedArray([]);
12255 * // => false
12256 */
12257 var isTypedArray$2 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
12258
12259 var isTypedArray_1 = isTypedArray$2;
12260
12261 var baseTimes = _baseTimes,
12262 isArguments$1 = isArguments_1,
12263 isArray$7 = isArray_1,
12264 isBuffer$1 = isBuffer$2.exports,
12265 isIndex$1 = _isIndex,
12266 isTypedArray$1 = isTypedArray_1;
12267
12268 /** Used for built-in method references. */
12269 var objectProto$7 = Object.prototype;
12270
12271 /** Used to check objects for own properties. */
12272 var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
12273
12274 /**
12275 * Creates an array of the enumerable property names of the array-like `value`.
12276 *
12277 * @private
12278 * @param {*} value The value to query.
12279 * @param {boolean} inherited Specify returning inherited property names.
12280 * @returns {Array} Returns the array of property names.
12281 */
12282 function arrayLikeKeys$1(value, inherited) {
12283 var isArr = isArray$7(value),
12284 isArg = !isArr && isArguments$1(value),
12285 isBuff = !isArr && !isArg && isBuffer$1(value),
12286 isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
12287 skipIndexes = isArr || isArg || isBuff || isType,
12288 result = skipIndexes ? baseTimes(value.length, String) : [],
12289 length = result.length;
12290
12291 for (var key in value) {
12292 if ((inherited || hasOwnProperty$5.call(value, key)) &&
12293 !(skipIndexes && (
12294 // Safari 9 has enumerable `arguments.length` in strict mode.
12295 key == 'length' ||
12296 // Node.js 0.10 has enumerable non-index properties on buffers.
12297 (isBuff && (key == 'offset' || key == 'parent')) ||
12298 // PhantomJS 2 has enumerable non-index properties on typed arrays.
12299 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
12300 // Skip index properties.
12301 isIndex$1(key, length)
12302 ))) {
12303 result.push(key);
12304 }
12305 }
12306 return result;
12307 }
12308
12309 var _arrayLikeKeys = arrayLikeKeys$1;
12310
12311 /** Used for built-in method references. */
12312
12313 var objectProto$6 = Object.prototype;
12314
12315 /**
12316 * Checks if `value` is likely a prototype object.
12317 *
12318 * @private
12319 * @param {*} value The value to check.
12320 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
12321 */
12322 function isPrototype$1(value) {
12323 var Ctor = value && value.constructor,
12324 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
12325
12326 return value === proto;
12327 }
12328
12329 var _isPrototype = isPrototype$1;
12330
12331 var overArg = _overArg;
12332
12333 /* Built-in method references for those with the same name as other `lodash` methods. */
12334 var nativeKeys$1 = overArg(Object.keys, Object);
12335
12336 var _nativeKeys = nativeKeys$1;
12337
12338 var isPrototype = _isPrototype,
12339 nativeKeys = _nativeKeys;
12340
12341 /** Used for built-in method references. */
12342 var objectProto$5 = Object.prototype;
12343
12344 /** Used to check objects for own properties. */
12345 var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
12346
12347 /**
12348 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
12349 *
12350 * @private
12351 * @param {Object} object The object to query.
12352 * @returns {Array} Returns the array of property names.
12353 */
12354 function baseKeys$1(object) {
12355 if (!isPrototype(object)) {
12356 return nativeKeys(object);
12357 }
12358 var result = [];
12359 for (var key in Object(object)) {
12360 if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
12361 result.push(key);
12362 }
12363 }
12364 return result;
12365 }
12366
12367 var _baseKeys = baseKeys$1;
12368
12369 var isFunction = isFunction_1,
12370 isLength$1 = isLength_1;
12371
12372 /**
12373 * Checks if `value` is array-like. A value is considered array-like if it's
12374 * not a function and has a `value.length` that's an integer greater than or
12375 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
12376 *
12377 * @static
12378 * @memberOf _
12379 * @since 4.0.0
12380 * @category Lang
12381 * @param {*} value The value to check.
12382 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
12383 * @example
12384 *
12385 * _.isArrayLike([1, 2, 3]);
12386 * // => true
12387 *
12388 * _.isArrayLike(document.body.children);
12389 * // => true
12390 *
12391 * _.isArrayLike('abc');
12392 * // => true
12393 *
12394 * _.isArrayLike(_.noop);
12395 * // => false
12396 */
12397 function isArrayLike$1(value) {
12398 return value != null && isLength$1(value.length) && !isFunction(value);
12399 }
12400
12401 var isArrayLike_1 = isArrayLike$1;
12402
12403 var arrayLikeKeys = _arrayLikeKeys,
12404 baseKeys = _baseKeys,
12405 isArrayLike = isArrayLike_1;
12406
12407 /**
12408 * Creates an array of the own enumerable property names of `object`.
12409 *
12410 * **Note:** Non-object values are coerced to objects. See the
12411 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
12412 * for more details.
12413 *
12414 * @static
12415 * @since 0.1.0
12416 * @memberOf _
12417 * @category Object
12418 * @param {Object} object The object to query.
12419 * @returns {Array} Returns the array of property names.
12420 * @example
12421 *
12422 * function Foo() {
12423 * this.a = 1;
12424 * this.b = 2;
12425 * }
12426 *
12427 * Foo.prototype.c = 3;
12428 *
12429 * _.keys(new Foo);
12430 * // => ['a', 'b'] (iteration order is not guaranteed)
12431 *
12432 * _.keys('hi');
12433 * // => ['0', '1']
12434 */
12435 function keys$3(object) {
12436 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
12437 }
12438
12439 var keys_1 = keys$3;
12440
12441 var baseFor = _baseFor,
12442 keys$2 = keys_1;
12443
12444 /**
12445 * The base implementation of `_.forOwn` without support for iteratee shorthands.
12446 *
12447 * @private
12448 * @param {Object} object The object to iterate over.
12449 * @param {Function} iteratee The function invoked per iteration.
12450 * @returns {Object} Returns `object`.
12451 */
12452 function baseForOwn$1(object, iteratee) {
12453 return object && baseFor(object, iteratee, keys$2);
12454 }
12455
12456 var _baseForOwn = baseForOwn$1;
12457
12458 /**
12459 * Removes all key-value entries from the list cache.
12460 *
12461 * @private
12462 * @name clear
12463 * @memberOf ListCache
12464 */
12465
12466 function listCacheClear$1() {
12467 this.__data__ = [];
12468 this.size = 0;
12469 }
12470
12471 var _listCacheClear = listCacheClear$1;
12472
12473 /**
12474 * Performs a
12475 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
12476 * comparison between two values to determine if they are equivalent.
12477 *
12478 * @static
12479 * @memberOf _
12480 * @since 4.0.0
12481 * @category Lang
12482 * @param {*} value The value to compare.
12483 * @param {*} other The other value to compare.
12484 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
12485 * @example
12486 *
12487 * var object = { 'a': 1 };
12488 * var other = { 'a': 1 };
12489 *
12490 * _.eq(object, object);
12491 * // => true
12492 *
12493 * _.eq(object, other);
12494 * // => false
12495 *
12496 * _.eq('a', 'a');
12497 * // => true
12498 *
12499 * _.eq('a', Object('a'));
12500 * // => false
12501 *
12502 * _.eq(NaN, NaN);
12503 * // => true
12504 */
12505
12506 function eq$2(value, other) {
12507 return value === other || (value !== value && other !== other);
12508 }
12509
12510 var eq_1 = eq$2;
12511
12512 var eq$1 = eq_1;
12513
12514 /**
12515 * Gets the index at which the `key` is found in `array` of key-value pairs.
12516 *
12517 * @private
12518 * @param {Array} array The array to inspect.
12519 * @param {*} key The key to search for.
12520 * @returns {number} Returns the index of the matched value, else `-1`.
12521 */
12522 function assocIndexOf$4(array, key) {
12523 var length = array.length;
12524 while (length--) {
12525 if (eq$1(array[length][0], key)) {
12526 return length;
12527 }
12528 }
12529 return -1;
12530 }
12531
12532 var _assocIndexOf = assocIndexOf$4;
12533
12534 var assocIndexOf$3 = _assocIndexOf;
12535
12536 /** Used for built-in method references. */
12537 var arrayProto = Array.prototype;
12538
12539 /** Built-in value references. */
12540 var splice = arrayProto.splice;
12541
12542 /**
12543 * Removes `key` and its value from the list cache.
12544 *
12545 * @private
12546 * @name delete
12547 * @memberOf ListCache
12548 * @param {string} key The key of the value to remove.
12549 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
12550 */
12551 function listCacheDelete$1(key) {
12552 var data = this.__data__,
12553 index = assocIndexOf$3(data, key);
12554
12555 if (index < 0) {
12556 return false;
12557 }
12558 var lastIndex = data.length - 1;
12559 if (index == lastIndex) {
12560 data.pop();
12561 } else {
12562 splice.call(data, index, 1);
12563 }
12564 --this.size;
12565 return true;
12566 }
12567
12568 var _listCacheDelete = listCacheDelete$1;
12569
12570 var assocIndexOf$2 = _assocIndexOf;
12571
12572 /**
12573 * Gets the list cache value for `key`.
12574 *
12575 * @private
12576 * @name get
12577 * @memberOf ListCache
12578 * @param {string} key The key of the value to get.
12579 * @returns {*} Returns the entry value.
12580 */
12581 function listCacheGet$1(key) {
12582 var data = this.__data__,
12583 index = assocIndexOf$2(data, key);
12584
12585 return index < 0 ? undefined : data[index][1];
12586 }
12587
12588 var _listCacheGet = listCacheGet$1;
12589
12590 var assocIndexOf$1 = _assocIndexOf;
12591
12592 /**
12593 * Checks if a list cache value for `key` exists.
12594 *
12595 * @private
12596 * @name has
12597 * @memberOf ListCache
12598 * @param {string} key The key of the entry to check.
12599 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
12600 */
12601 function listCacheHas$1(key) {
12602 return assocIndexOf$1(this.__data__, key) > -1;
12603 }
12604
12605 var _listCacheHas = listCacheHas$1;
12606
12607 var assocIndexOf = _assocIndexOf;
12608
12609 /**
12610 * Sets the list cache `key` to `value`.
12611 *
12612 * @private
12613 * @name set
12614 * @memberOf ListCache
12615 * @param {string} key The key of the value to set.
12616 * @param {*} value The value to set.
12617 * @returns {Object} Returns the list cache instance.
12618 */
12619 function listCacheSet$1(key, value) {
12620 var data = this.__data__,
12621 index = assocIndexOf(data, key);
12622
12623 if (index < 0) {
12624 ++this.size;
12625 data.push([key, value]);
12626 } else {
12627 data[index][1] = value;
12628 }
12629 return this;
12630 }
12631
12632 var _listCacheSet = listCacheSet$1;
12633
12634 var listCacheClear = _listCacheClear,
12635 listCacheDelete = _listCacheDelete,
12636 listCacheGet = _listCacheGet,
12637 listCacheHas = _listCacheHas,
12638 listCacheSet = _listCacheSet;
12639
12640 /**
12641 * Creates an list cache object.
12642 *
12643 * @private
12644 * @constructor
12645 * @param {Array} [entries] The key-value pairs to cache.
12646 */
12647 function ListCache$4(entries) {
12648 var index = -1,
12649 length = entries == null ? 0 : entries.length;
12650
12651 this.clear();
12652 while (++index < length) {
12653 var entry = entries[index];
12654 this.set(entry[0], entry[1]);
12655 }
12656 }
12657
12658 // Add methods to `ListCache`.
12659 ListCache$4.prototype.clear = listCacheClear;
12660 ListCache$4.prototype['delete'] = listCacheDelete;
12661 ListCache$4.prototype.get = listCacheGet;
12662 ListCache$4.prototype.has = listCacheHas;
12663 ListCache$4.prototype.set = listCacheSet;
12664
12665 var _ListCache = ListCache$4;
12666
12667 var ListCache$3 = _ListCache;
12668
12669 /**
12670 * Removes all key-value entries from the stack.
12671 *
12672 * @private
12673 * @name clear
12674 * @memberOf Stack
12675 */
12676 function stackClear$1() {
12677 this.__data__ = new ListCache$3;
12678 this.size = 0;
12679 }
12680
12681 var _stackClear = stackClear$1;
12682
12683 /**
12684 * Removes `key` and its value from the stack.
12685 *
12686 * @private
12687 * @name delete
12688 * @memberOf Stack
12689 * @param {string} key The key of the value to remove.
12690 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
12691 */
12692
12693 function stackDelete$1(key) {
12694 var data = this.__data__,
12695 result = data['delete'](key);
12696
12697 this.size = data.size;
12698 return result;
12699 }
12700
12701 var _stackDelete = stackDelete$1;
12702
12703 /**
12704 * Gets the stack value for `key`.
12705 *
12706 * @private
12707 * @name get
12708 * @memberOf Stack
12709 * @param {string} key The key of the value to get.
12710 * @returns {*} Returns the entry value.
12711 */
12712
12713 function stackGet$1(key) {
12714 return this.__data__.get(key);
12715 }
12716
12717 var _stackGet = stackGet$1;
12718
12719 /**
12720 * Checks if a stack value for `key` exists.
12721 *
12722 * @private
12723 * @name has
12724 * @memberOf Stack
12725 * @param {string} key The key of the entry to check.
12726 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
12727 */
12728
12729 function stackHas$1(key) {
12730 return this.__data__.has(key);
12731 }
12732
12733 var _stackHas = stackHas$1;
12734
12735 var getNative$5 = _getNative,
12736 root$5 = _root;
12737
12738 /* Built-in method references that are verified to be native. */
12739 var Map$3 = getNative$5(root$5, 'Map');
12740
12741 var _Map = Map$3;
12742
12743 var getNative$4 = _getNative;
12744
12745 /* Built-in method references that are verified to be native. */
12746 var nativeCreate$4 = getNative$4(Object, 'create');
12747
12748 var _nativeCreate = nativeCreate$4;
12749
12750 var nativeCreate$3 = _nativeCreate;
12751
12752 /**
12753 * Removes all key-value entries from the hash.
12754 *
12755 * @private
12756 * @name clear
12757 * @memberOf Hash
12758 */
12759 function hashClear$1() {
12760 this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
12761 this.size = 0;
12762 }
12763
12764 var _hashClear = hashClear$1;
12765
12766 /**
12767 * Removes `key` and its value from the hash.
12768 *
12769 * @private
12770 * @name delete
12771 * @memberOf Hash
12772 * @param {Object} hash The hash to modify.
12773 * @param {string} key The key of the value to remove.
12774 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
12775 */
12776
12777 function hashDelete$1(key) {
12778 var result = this.has(key) && delete this.__data__[key];
12779 this.size -= result ? 1 : 0;
12780 return result;
12781 }
12782
12783 var _hashDelete = hashDelete$1;
12784
12785 var nativeCreate$2 = _nativeCreate;
12786
12787 /** Used to stand-in for `undefined` hash values. */
12788 var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
12789
12790 /** Used for built-in method references. */
12791 var objectProto$4 = Object.prototype;
12792
12793 /** Used to check objects for own properties. */
12794 var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
12795
12796 /**
12797 * Gets the hash value for `key`.
12798 *
12799 * @private
12800 * @name get
12801 * @memberOf Hash
12802 * @param {string} key The key of the value to get.
12803 * @returns {*} Returns the entry value.
12804 */
12805 function hashGet$1(key) {
12806 var data = this.__data__;
12807 if (nativeCreate$2) {
12808 var result = data[key];
12809 return result === HASH_UNDEFINED$2 ? undefined : result;
12810 }
12811 return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
12812 }
12813
12814 var _hashGet = hashGet$1;
12815
12816 var nativeCreate$1 = _nativeCreate;
12817
12818 /** Used for built-in method references. */
12819 var objectProto$3 = Object.prototype;
12820
12821 /** Used to check objects for own properties. */
12822 var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
12823
12824 /**
12825 * Checks if a hash value for `key` exists.
12826 *
12827 * @private
12828 * @name has
12829 * @memberOf Hash
12830 * @param {string} key The key of the entry to check.
12831 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
12832 */
12833 function hashHas$1(key) {
12834 var data = this.__data__;
12835 return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty$2.call(data, key);
12836 }
12837
12838 var _hashHas = hashHas$1;
12839
12840 var nativeCreate = _nativeCreate;
12841
12842 /** Used to stand-in for `undefined` hash values. */
12843 var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
12844
12845 /**
12846 * Sets the hash `key` to `value`.
12847 *
12848 * @private
12849 * @name set
12850 * @memberOf Hash
12851 * @param {string} key The key of the value to set.
12852 * @param {*} value The value to set.
12853 * @returns {Object} Returns the hash instance.
12854 */
12855 function hashSet$1(key, value) {
12856 var data = this.__data__;
12857 this.size += this.has(key) ? 0 : 1;
12858 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
12859 return this;
12860 }
12861
12862 var _hashSet = hashSet$1;
12863
12864 var hashClear = _hashClear,
12865 hashDelete = _hashDelete,
12866 hashGet = _hashGet,
12867 hashHas = _hashHas,
12868 hashSet = _hashSet;
12869
12870 /**
12871 * Creates a hash object.
12872 *
12873 * @private
12874 * @constructor
12875 * @param {Array} [entries] The key-value pairs to cache.
12876 */
12877 function Hash$1(entries) {
12878 var index = -1,
12879 length = entries == null ? 0 : entries.length;
12880
12881 this.clear();
12882 while (++index < length) {
12883 var entry = entries[index];
12884 this.set(entry[0], entry[1]);
12885 }
12886 }
12887
12888 // Add methods to `Hash`.
12889 Hash$1.prototype.clear = hashClear;
12890 Hash$1.prototype['delete'] = hashDelete;
12891 Hash$1.prototype.get = hashGet;
12892 Hash$1.prototype.has = hashHas;
12893 Hash$1.prototype.set = hashSet;
12894
12895 var _Hash = Hash$1;
12896
12897 var Hash = _Hash,
12898 ListCache$2 = _ListCache,
12899 Map$2 = _Map;
12900
12901 /**
12902 * Removes all key-value entries from the map.
12903 *
12904 * @private
12905 * @name clear
12906 * @memberOf MapCache
12907 */
12908 function mapCacheClear$1() {
12909 this.size = 0;
12910 this.__data__ = {
12911 'hash': new Hash,
12912 'map': new (Map$2 || ListCache$2),
12913 'string': new Hash
12914 };
12915 }
12916
12917 var _mapCacheClear = mapCacheClear$1;
12918
12919 /**
12920 * Checks if `value` is suitable for use as unique object key.
12921 *
12922 * @private
12923 * @param {*} value The value to check.
12924 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
12925 */
12926
12927 function isKeyable$1(value) {
12928 var type = typeof value;
12929 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
12930 ? (value !== '__proto__')
12931 : (value === null);
12932 }
12933
12934 var _isKeyable = isKeyable$1;
12935
12936 var isKeyable = _isKeyable;
12937
12938 /**
12939 * Gets the data for `map`.
12940 *
12941 * @private
12942 * @param {Object} map The map to query.
12943 * @param {string} key The reference key.
12944 * @returns {*} Returns the map data.
12945 */
12946 function getMapData$4(map, key) {
12947 var data = map.__data__;
12948 return isKeyable(key)
12949 ? data[typeof key == 'string' ? 'string' : 'hash']
12950 : data.map;
12951 }
12952
12953 var _getMapData = getMapData$4;
12954
12955 var getMapData$3 = _getMapData;
12956
12957 /**
12958 * Removes `key` and its value from the map.
12959 *
12960 * @private
12961 * @name delete
12962 * @memberOf MapCache
12963 * @param {string} key The key of the value to remove.
12964 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
12965 */
12966 function mapCacheDelete$1(key) {
12967 var result = getMapData$3(this, key)['delete'](key);
12968 this.size -= result ? 1 : 0;
12969 return result;
12970 }
12971
12972 var _mapCacheDelete = mapCacheDelete$1;
12973
12974 var getMapData$2 = _getMapData;
12975
12976 /**
12977 * Gets the map value for `key`.
12978 *
12979 * @private
12980 * @name get
12981 * @memberOf MapCache
12982 * @param {string} key The key of the value to get.
12983 * @returns {*} Returns the entry value.
12984 */
12985 function mapCacheGet$1(key) {
12986 return getMapData$2(this, key).get(key);
12987 }
12988
12989 var _mapCacheGet = mapCacheGet$1;
12990
12991 var getMapData$1 = _getMapData;
12992
12993 /**
12994 * Checks if a map value for `key` exists.
12995 *
12996 * @private
12997 * @name has
12998 * @memberOf MapCache
12999 * @param {string} key The key of the entry to check.
13000 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
13001 */
13002 function mapCacheHas$1(key) {
13003 return getMapData$1(this, key).has(key);
13004 }
13005
13006 var _mapCacheHas = mapCacheHas$1;
13007
13008 var getMapData = _getMapData;
13009
13010 /**
13011 * Sets the map `key` to `value`.
13012 *
13013 * @private
13014 * @name set
13015 * @memberOf MapCache
13016 * @param {string} key The key of the value to set.
13017 * @param {*} value The value to set.
13018 * @returns {Object} Returns the map cache instance.
13019 */
13020 function mapCacheSet$1(key, value) {
13021 var data = getMapData(this, key),
13022 size = data.size;
13023
13024 data.set(key, value);
13025 this.size += data.size == size ? 0 : 1;
13026 return this;
13027 }
13028
13029 var _mapCacheSet = mapCacheSet$1;
13030
13031 var mapCacheClear = _mapCacheClear,
13032 mapCacheDelete = _mapCacheDelete,
13033 mapCacheGet = _mapCacheGet,
13034 mapCacheHas = _mapCacheHas,
13035 mapCacheSet = _mapCacheSet;
13036
13037 /**
13038 * Creates a map cache object to store key-value pairs.
13039 *
13040 * @private
13041 * @constructor
13042 * @param {Array} [entries] The key-value pairs to cache.
13043 */
13044 function MapCache$3(entries) {
13045 var index = -1,
13046 length = entries == null ? 0 : entries.length;
13047
13048 this.clear();
13049 while (++index < length) {
13050 var entry = entries[index];
13051 this.set(entry[0], entry[1]);
13052 }
13053 }
13054
13055 // Add methods to `MapCache`.
13056 MapCache$3.prototype.clear = mapCacheClear;
13057 MapCache$3.prototype['delete'] = mapCacheDelete;
13058 MapCache$3.prototype.get = mapCacheGet;
13059 MapCache$3.prototype.has = mapCacheHas;
13060 MapCache$3.prototype.set = mapCacheSet;
13061
13062 var _MapCache = MapCache$3;
13063
13064 var ListCache$1 = _ListCache,
13065 Map$1 = _Map,
13066 MapCache$2 = _MapCache;
13067
13068 /** Used as the size to enable large array optimizations. */
13069 var LARGE_ARRAY_SIZE = 200;
13070
13071 /**
13072 * Sets the stack `key` to `value`.
13073 *
13074 * @private
13075 * @name set
13076 * @memberOf Stack
13077 * @param {string} key The key of the value to set.
13078 * @param {*} value The value to set.
13079 * @returns {Object} Returns the stack cache instance.
13080 */
13081 function stackSet$1(key, value) {
13082 var data = this.__data__;
13083 if (data instanceof ListCache$1) {
13084 var pairs = data.__data__;
13085 if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
13086 pairs.push([key, value]);
13087 this.size = ++data.size;
13088 return this;
13089 }
13090 data = this.__data__ = new MapCache$2(pairs);
13091 }
13092 data.set(key, value);
13093 this.size = data.size;
13094 return this;
13095 }
13096
13097 var _stackSet = stackSet$1;
13098
13099 var ListCache = _ListCache,
13100 stackClear = _stackClear,
13101 stackDelete = _stackDelete,
13102 stackGet = _stackGet,
13103 stackHas = _stackHas,
13104 stackSet = _stackSet;
13105
13106 /**
13107 * Creates a stack cache object to store key-value pairs.
13108 *
13109 * @private
13110 * @constructor
13111 * @param {Array} [entries] The key-value pairs to cache.
13112 */
13113 function Stack$2(entries) {
13114 var data = this.__data__ = new ListCache(entries);
13115 this.size = data.size;
13116 }
13117
13118 // Add methods to `Stack`.
13119 Stack$2.prototype.clear = stackClear;
13120 Stack$2.prototype['delete'] = stackDelete;
13121 Stack$2.prototype.get = stackGet;
13122 Stack$2.prototype.has = stackHas;
13123 Stack$2.prototype.set = stackSet;
13124
13125 var _Stack = Stack$2;
13126
13127 /** Used to stand-in for `undefined` hash values. */
13128
13129 var HASH_UNDEFINED = '__lodash_hash_undefined__';
13130
13131 /**
13132 * Adds `value` to the array cache.
13133 *
13134 * @private
13135 * @name add
13136 * @memberOf SetCache
13137 * @alias push
13138 * @param {*} value The value to cache.
13139 * @returns {Object} Returns the cache instance.
13140 */
13141 function setCacheAdd$1(value) {
13142 this.__data__.set(value, HASH_UNDEFINED);
13143 return this;
13144 }
13145
13146 var _setCacheAdd = setCacheAdd$1;
13147
13148 /**
13149 * Checks if `value` is in the array cache.
13150 *
13151 * @private
13152 * @name has
13153 * @memberOf SetCache
13154 * @param {*} value The value to search for.
13155 * @returns {number} Returns `true` if `value` is found, else `false`.
13156 */
13157
13158 function setCacheHas$1(value) {
13159 return this.__data__.has(value);
13160 }
13161
13162 var _setCacheHas = setCacheHas$1;
13163
13164 var MapCache$1 = _MapCache,
13165 setCacheAdd = _setCacheAdd,
13166 setCacheHas = _setCacheHas;
13167
13168 /**
13169 *
13170 * Creates an array cache object to store unique values.
13171 *
13172 * @private
13173 * @constructor
13174 * @param {Array} [values] The values to cache.
13175 */
13176 function SetCache$1(values) {
13177 var index = -1,
13178 length = values == null ? 0 : values.length;
13179
13180 this.__data__ = new MapCache$1;
13181 while (++index < length) {
13182 this.add(values[index]);
13183 }
13184 }
13185
13186 // Add methods to `SetCache`.
13187 SetCache$1.prototype.add = SetCache$1.prototype.push = setCacheAdd;
13188 SetCache$1.prototype.has = setCacheHas;
13189
13190 var _SetCache = SetCache$1;
13191
13192 /**
13193 * A specialized version of `_.some` for arrays without support for iteratee
13194 * shorthands.
13195 *
13196 * @private
13197 * @param {Array} [array] The array to iterate over.
13198 * @param {Function} predicate The function invoked per iteration.
13199 * @returns {boolean} Returns `true` if any element passes the predicate check,
13200 * else `false`.
13201 */
13202
13203 function arraySome$1(array, predicate) {
13204 var index = -1,
13205 length = array == null ? 0 : array.length;
13206
13207 while (++index < length) {
13208 if (predicate(array[index], index, array)) {
13209 return true;
13210 }
13211 }
13212 return false;
13213 }
13214
13215 var _arraySome = arraySome$1;
13216
13217 /**
13218 * Checks if a `cache` value for `key` exists.
13219 *
13220 * @private
13221 * @param {Object} cache The cache to query.
13222 * @param {string} key The key of the entry to check.
13223 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
13224 */
13225
13226 function cacheHas$1(cache, key) {
13227 return cache.has(key);
13228 }
13229
13230 var _cacheHas = cacheHas$1;
13231
13232 var SetCache = _SetCache,
13233 arraySome = _arraySome,
13234 cacheHas = _cacheHas;
13235
13236 /** Used to compose bitmasks for value comparisons. */
13237 var COMPARE_PARTIAL_FLAG$5 = 1,
13238 COMPARE_UNORDERED_FLAG$3 = 2;
13239
13240 /**
13241 * A specialized version of `baseIsEqualDeep` for arrays with support for
13242 * partial deep comparisons.
13243 *
13244 * @private
13245 * @param {Array} array The array to compare.
13246 * @param {Array} other The other array to compare.
13247 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
13248 * @param {Function} customizer The function to customize comparisons.
13249 * @param {Function} equalFunc The function to determine equivalents of values.
13250 * @param {Object} stack Tracks traversed `array` and `other` objects.
13251 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
13252 */
13253 function equalArrays$2(array, other, bitmask, customizer, equalFunc, stack) {
13254 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
13255 arrLength = array.length,
13256 othLength = other.length;
13257
13258 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
13259 return false;
13260 }
13261 // Check that cyclic values are equal.
13262 var arrStacked = stack.get(array);
13263 var othStacked = stack.get(other);
13264 if (arrStacked && othStacked) {
13265 return arrStacked == other && othStacked == array;
13266 }
13267 var index = -1,
13268 result = true,
13269 seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new SetCache : undefined;
13270
13271 stack.set(array, other);
13272 stack.set(other, array);
13273
13274 // Ignore non-index properties.
13275 while (++index < arrLength) {
13276 var arrValue = array[index],
13277 othValue = other[index];
13278
13279 if (customizer) {
13280 var compared = isPartial
13281 ? customizer(othValue, arrValue, index, other, array, stack)
13282 : customizer(arrValue, othValue, index, array, other, stack);
13283 }
13284 if (compared !== undefined) {
13285 if (compared) {
13286 continue;
13287 }
13288 result = false;
13289 break;
13290 }
13291 // Recursively compare arrays (susceptible to call stack limits).
13292 if (seen) {
13293 if (!arraySome(other, function(othValue, othIndex) {
13294 if (!cacheHas(seen, othIndex) &&
13295 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
13296 return seen.push(othIndex);
13297 }
13298 })) {
13299 result = false;
13300 break;
13301 }
13302 } else if (!(
13303 arrValue === othValue ||
13304 equalFunc(arrValue, othValue, bitmask, customizer, stack)
13305 )) {
13306 result = false;
13307 break;
13308 }
13309 }
13310 stack['delete'](array);
13311 stack['delete'](other);
13312 return result;
13313 }
13314
13315 var _equalArrays = equalArrays$2;
13316
13317 var root$4 = _root;
13318
13319 /** Built-in value references. */
13320 var Uint8Array$1 = root$4.Uint8Array;
13321
13322 var _Uint8Array = Uint8Array$1;
13323
13324 /**
13325 * Converts `map` to its key-value pairs.
13326 *
13327 * @private
13328 * @param {Object} map The map to convert.
13329 * @returns {Array} Returns the key-value pairs.
13330 */
13331
13332 function mapToArray$1(map) {
13333 var index = -1,
13334 result = Array(map.size);
13335
13336 map.forEach(function(value, key) {
13337 result[++index] = [key, value];
13338 });
13339 return result;
13340 }
13341
13342 var _mapToArray = mapToArray$1;
13343
13344 /**
13345 * Converts `set` to an array of its values.
13346 *
13347 * @private
13348 * @param {Object} set The set to convert.
13349 * @returns {Array} Returns the values.
13350 */
13351
13352 function setToArray$1(set) {
13353 var index = -1,
13354 result = Array(set.size);
13355
13356 set.forEach(function(value) {
13357 result[++index] = value;
13358 });
13359 return result;
13360 }
13361
13362 var _setToArray = setToArray$1;
13363
13364 var Symbol$2 = _Symbol,
13365 Uint8Array = _Uint8Array,
13366 eq = eq_1,
13367 equalArrays$1 = _equalArrays,
13368 mapToArray = _mapToArray,
13369 setToArray = _setToArray;
13370
13371 /** Used to compose bitmasks for value comparisons. */
13372 var COMPARE_PARTIAL_FLAG$4 = 1,
13373 COMPARE_UNORDERED_FLAG$2 = 2;
13374
13375 /** `Object#toString` result references. */
13376 var boolTag = '[object Boolean]',
13377 dateTag = '[object Date]',
13378 errorTag = '[object Error]',
13379 mapTag$1 = '[object Map]',
13380 numberTag = '[object Number]',
13381 regexpTag = '[object RegExp]',
13382 setTag$1 = '[object Set]',
13383 stringTag = '[object String]',
13384 symbolTag$1 = '[object Symbol]';
13385
13386 var arrayBufferTag = '[object ArrayBuffer]',
13387 dataViewTag$1 = '[object DataView]';
13388
13389 /** Used to convert symbols to primitives and strings. */
13390 var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : undefined,
13391 symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
13392
13393 /**
13394 * A specialized version of `baseIsEqualDeep` for comparing objects of
13395 * the same `toStringTag`.
13396 *
13397 * **Note:** This function only supports comparing values with tags of
13398 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
13399 *
13400 * @private
13401 * @param {Object} object The object to compare.
13402 * @param {Object} other The other object to compare.
13403 * @param {string} tag The `toStringTag` of the objects to compare.
13404 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
13405 * @param {Function} customizer The function to customize comparisons.
13406 * @param {Function} equalFunc The function to determine equivalents of values.
13407 * @param {Object} stack Tracks traversed `object` and `other` objects.
13408 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
13409 */
13410 function equalByTag$1(object, other, tag, bitmask, customizer, equalFunc, stack) {
13411 switch (tag) {
13412 case dataViewTag$1:
13413 if ((object.byteLength != other.byteLength) ||
13414 (object.byteOffset != other.byteOffset)) {
13415 return false;
13416 }
13417 object = object.buffer;
13418 other = other.buffer;
13419
13420 case arrayBufferTag:
13421 if ((object.byteLength != other.byteLength) ||
13422 !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
13423 return false;
13424 }
13425 return true;
13426
13427 case boolTag:
13428 case dateTag:
13429 case numberTag:
13430 // Coerce booleans to `1` or `0` and dates to milliseconds.
13431 // Invalid dates are coerced to `NaN`.
13432 return eq(+object, +other);
13433
13434 case errorTag:
13435 return object.name == other.name && object.message == other.message;
13436
13437 case regexpTag:
13438 case stringTag:
13439 // Coerce regexes to strings and treat strings, primitives and objects,
13440 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
13441 // for more details.
13442 return object == (other + '');
13443
13444 case mapTag$1:
13445 var convert = mapToArray;
13446
13447 case setTag$1:
13448 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
13449 convert || (convert = setToArray);
13450
13451 if (object.size != other.size && !isPartial) {
13452 return false;
13453 }
13454 // Assume cyclic values are equal.
13455 var stacked = stack.get(object);
13456 if (stacked) {
13457 return stacked == other;
13458 }
13459 bitmask |= COMPARE_UNORDERED_FLAG$2;
13460
13461 // Recursively compare objects (susceptible to call stack limits).
13462 stack.set(object, other);
13463 var result = equalArrays$1(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
13464 stack['delete'](object);
13465 return result;
13466
13467 case symbolTag$1:
13468 if (symbolValueOf) {
13469 return symbolValueOf.call(object) == symbolValueOf.call(other);
13470 }
13471 }
13472 return false;
13473 }
13474
13475 var _equalByTag = equalByTag$1;
13476
13477 /**
13478 * Appends the elements of `values` to `array`.
13479 *
13480 * @private
13481 * @param {Array} array The array to modify.
13482 * @param {Array} values The values to append.
13483 * @returns {Array} Returns `array`.
13484 */
13485
13486 function arrayPush$1(array, values) {
13487 var index = -1,
13488 length = values.length,
13489 offset = array.length;
13490
13491 while (++index < length) {
13492 array[offset + index] = values[index];
13493 }
13494 return array;
13495 }
13496
13497 var _arrayPush = arrayPush$1;
13498
13499 var arrayPush = _arrayPush,
13500 isArray$6 = isArray_1;
13501
13502 /**
13503 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
13504 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
13505 * symbols of `object`.
13506 *
13507 * @private
13508 * @param {Object} object The object to query.
13509 * @param {Function} keysFunc The function to get the keys of `object`.
13510 * @param {Function} symbolsFunc The function to get the symbols of `object`.
13511 * @returns {Array} Returns the array of property names and symbols.
13512 */
13513 function baseGetAllKeys$1(object, keysFunc, symbolsFunc) {
13514 var result = keysFunc(object);
13515 return isArray$6(object) ? result : arrayPush(result, symbolsFunc(object));
13516 }
13517
13518 var _baseGetAllKeys = baseGetAllKeys$1;
13519
13520 /**
13521 * A specialized version of `_.filter` for arrays without support for
13522 * iteratee shorthands.
13523 *
13524 * @private
13525 * @param {Array} [array] The array to iterate over.
13526 * @param {Function} predicate The function invoked per iteration.
13527 * @returns {Array} Returns the new filtered array.
13528 */
13529
13530 function arrayFilter$1(array, predicate) {
13531 var index = -1,
13532 length = array == null ? 0 : array.length,
13533 resIndex = 0,
13534 result = [];
13535
13536 while (++index < length) {
13537 var value = array[index];
13538 if (predicate(value, index, array)) {
13539 result[resIndex++] = value;
13540 }
13541 }
13542 return result;
13543 }
13544
13545 var _arrayFilter = arrayFilter$1;
13546
13547 /**
13548 * This method returns a new empty array.
13549 *
13550 * @static
13551 * @memberOf _
13552 * @since 4.13.0
13553 * @category Util
13554 * @returns {Array} Returns the new empty array.
13555 * @example
13556 *
13557 * var arrays = _.times(2, _.stubArray);
13558 *
13559 * console.log(arrays);
13560 * // => [[], []]
13561 *
13562 * console.log(arrays[0] === arrays[1]);
13563 * // => false
13564 */
13565
13566 function stubArray$1() {
13567 return [];
13568 }
13569
13570 var stubArray_1 = stubArray$1;
13571
13572 var arrayFilter = _arrayFilter,
13573 stubArray = stubArray_1;
13574
13575 /** Used for built-in method references. */
13576 var objectProto$2 = Object.prototype;
13577
13578 /** Built-in value references. */
13579 var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
13580
13581 /* Built-in method references for those with the same name as other `lodash` methods. */
13582 var nativeGetSymbols = Object.getOwnPropertySymbols;
13583
13584 /**
13585 * Creates an array of the own enumerable symbols of `object`.
13586 *
13587 * @private
13588 * @param {Object} object The object to query.
13589 * @returns {Array} Returns the array of symbols.
13590 */
13591 var getSymbols$1 = !nativeGetSymbols ? stubArray : function(object) {
13592 if (object == null) {
13593 return [];
13594 }
13595 object = Object(object);
13596 return arrayFilter(nativeGetSymbols(object), function(symbol) {
13597 return propertyIsEnumerable.call(object, symbol);
13598 });
13599 };
13600
13601 var _getSymbols = getSymbols$1;
13602
13603 var baseGetAllKeys = _baseGetAllKeys,
13604 getSymbols = _getSymbols,
13605 keys$1 = keys_1;
13606
13607 /**
13608 * Creates an array of own enumerable property names and symbols of `object`.
13609 *
13610 * @private
13611 * @param {Object} object The object to query.
13612 * @returns {Array} Returns the array of property names and symbols.
13613 */
13614 function getAllKeys$1(object) {
13615 return baseGetAllKeys(object, keys$1, getSymbols);
13616 }
13617
13618 var _getAllKeys = getAllKeys$1;
13619
13620 var getAllKeys = _getAllKeys;
13621
13622 /** Used to compose bitmasks for value comparisons. */
13623 var COMPARE_PARTIAL_FLAG$3 = 1;
13624
13625 /** Used for built-in method references. */
13626 var objectProto$1 = Object.prototype;
13627
13628 /** Used to check objects for own properties. */
13629 var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
13630
13631 /**
13632 * A specialized version of `baseIsEqualDeep` for objects with support for
13633 * partial deep comparisons.
13634 *
13635 * @private
13636 * @param {Object} object The object to compare.
13637 * @param {Object} other The other object to compare.
13638 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
13639 * @param {Function} customizer The function to customize comparisons.
13640 * @param {Function} equalFunc The function to determine equivalents of values.
13641 * @param {Object} stack Tracks traversed `object` and `other` objects.
13642 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
13643 */
13644 function equalObjects$1(object, other, bitmask, customizer, equalFunc, stack) {
13645 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
13646 objProps = getAllKeys(object),
13647 objLength = objProps.length,
13648 othProps = getAllKeys(other),
13649 othLength = othProps.length;
13650
13651 if (objLength != othLength && !isPartial) {
13652 return false;
13653 }
13654 var index = objLength;
13655 while (index--) {
13656 var key = objProps[index];
13657 if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
13658 return false;
13659 }
13660 }
13661 // Check that cyclic values are equal.
13662 var objStacked = stack.get(object);
13663 var othStacked = stack.get(other);
13664 if (objStacked && othStacked) {
13665 return objStacked == other && othStacked == object;
13666 }
13667 var result = true;
13668 stack.set(object, other);
13669 stack.set(other, object);
13670
13671 var skipCtor = isPartial;
13672 while (++index < objLength) {
13673 key = objProps[index];
13674 var objValue = object[key],
13675 othValue = other[key];
13676
13677 if (customizer) {
13678 var compared = isPartial
13679 ? customizer(othValue, objValue, key, other, object, stack)
13680 : customizer(objValue, othValue, key, object, other, stack);
13681 }
13682 // Recursively compare objects (susceptible to call stack limits).
13683 if (!(compared === undefined
13684 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
13685 : compared
13686 )) {
13687 result = false;
13688 break;
13689 }
13690 skipCtor || (skipCtor = key == 'constructor');
13691 }
13692 if (result && !skipCtor) {
13693 var objCtor = object.constructor,
13694 othCtor = other.constructor;
13695
13696 // Non `Object` object instances with different constructors are not equal.
13697 if (objCtor != othCtor &&
13698 ('constructor' in object && 'constructor' in other) &&
13699 !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
13700 typeof othCtor == 'function' && othCtor instanceof othCtor)) {
13701 result = false;
13702 }
13703 }
13704 stack['delete'](object);
13705 stack['delete'](other);
13706 return result;
13707 }
13708
13709 var _equalObjects = equalObjects$1;
13710
13711 var getNative$3 = _getNative,
13712 root$3 = _root;
13713
13714 /* Built-in method references that are verified to be native. */
13715 var DataView$1 = getNative$3(root$3, 'DataView');
13716
13717 var _DataView = DataView$1;
13718
13719 var getNative$2 = _getNative,
13720 root$2 = _root;
13721
13722 /* Built-in method references that are verified to be native. */
13723 var Promise$2 = getNative$2(root$2, 'Promise');
13724
13725 var _Promise = Promise$2;
13726
13727 var getNative$1 = _getNative,
13728 root$1 = _root;
13729
13730 /* Built-in method references that are verified to be native. */
13731 var Set$1 = getNative$1(root$1, 'Set');
13732
13733 var _Set = Set$1;
13734
13735 var getNative = _getNative,
13736 root = _root;
13737
13738 /* Built-in method references that are verified to be native. */
13739 var WeakMap$1 = getNative(root, 'WeakMap');
13740
13741 var _WeakMap = WeakMap$1;
13742
13743 var DataView = _DataView,
13744 Map = _Map,
13745 Promise$1 = _Promise,
13746 Set = _Set,
13747 WeakMap = _WeakMap,
13748 baseGetTag$1 = _baseGetTag,
13749 toSource = _toSource;
13750
13751 /** `Object#toString` result references. */
13752 var mapTag = '[object Map]',
13753 objectTag$1 = '[object Object]',
13754 promiseTag = '[object Promise]',
13755 setTag = '[object Set]',
13756 weakMapTag = '[object WeakMap]';
13757
13758 var dataViewTag = '[object DataView]';
13759
13760 /** Used to detect maps, sets, and weakmaps. */
13761 var dataViewCtorString = toSource(DataView),
13762 mapCtorString = toSource(Map),
13763 promiseCtorString = toSource(Promise$1),
13764 setCtorString = toSource(Set),
13765 weakMapCtorString = toSource(WeakMap);
13766
13767 /**
13768 * Gets the `toStringTag` of `value`.
13769 *
13770 * @private
13771 * @param {*} value The value to query.
13772 * @returns {string} Returns the `toStringTag`.
13773 */
13774 var getTag$1 = baseGetTag$1;
13775
13776 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
13777 if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
13778 (Map && getTag$1(new Map) != mapTag) ||
13779 (Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) ||
13780 (Set && getTag$1(new Set) != setTag) ||
13781 (WeakMap && getTag$1(new WeakMap) != weakMapTag)) {
13782 getTag$1 = function(value) {
13783 var result = baseGetTag$1(value),
13784 Ctor = result == objectTag$1 ? value.constructor : undefined,
13785 ctorString = Ctor ? toSource(Ctor) : '';
13786
13787 if (ctorString) {
13788 switch (ctorString) {
13789 case dataViewCtorString: return dataViewTag;
13790 case mapCtorString: return mapTag;
13791 case promiseCtorString: return promiseTag;
13792 case setCtorString: return setTag;
13793 case weakMapCtorString: return weakMapTag;
13794 }
13795 }
13796 return result;
13797 };
13798 }
13799
13800 var _getTag = getTag$1;
13801
13802 var Stack$1 = _Stack,
13803 equalArrays = _equalArrays,
13804 equalByTag = _equalByTag,
13805 equalObjects = _equalObjects,
13806 getTag = _getTag,
13807 isArray$5 = isArray_1,
13808 isBuffer = isBuffer$2.exports,
13809 isTypedArray = isTypedArray_1;
13810
13811 /** Used to compose bitmasks for value comparisons. */
13812 var COMPARE_PARTIAL_FLAG$2 = 1;
13813
13814 /** `Object#toString` result references. */
13815 var argsTag = '[object Arguments]',
13816 arrayTag = '[object Array]',
13817 objectTag = '[object Object]';
13818
13819 /** Used for built-in method references. */
13820 var objectProto = Object.prototype;
13821
13822 /** Used to check objects for own properties. */
13823 var hasOwnProperty = objectProto.hasOwnProperty;
13824
13825 /**
13826 * A specialized version of `baseIsEqual` for arrays and objects which performs
13827 * deep comparisons and tracks traversed objects enabling objects with circular
13828 * references to be compared.
13829 *
13830 * @private
13831 * @param {Object} object The object to compare.
13832 * @param {Object} other The other object to compare.
13833 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
13834 * @param {Function} customizer The function to customize comparisons.
13835 * @param {Function} equalFunc The function to determine equivalents of values.
13836 * @param {Object} [stack] Tracks traversed `object` and `other` objects.
13837 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
13838 */
13839 function baseIsEqualDeep$1(object, other, bitmask, customizer, equalFunc, stack) {
13840 var objIsArr = isArray$5(object),
13841 othIsArr = isArray$5(other),
13842 objTag = objIsArr ? arrayTag : getTag(object),
13843 othTag = othIsArr ? arrayTag : getTag(other);
13844
13845 objTag = objTag == argsTag ? objectTag : objTag;
13846 othTag = othTag == argsTag ? objectTag : othTag;
13847
13848 var objIsObj = objTag == objectTag,
13849 othIsObj = othTag == objectTag,
13850 isSameTag = objTag == othTag;
13851
13852 if (isSameTag && isBuffer(object)) {
13853 if (!isBuffer(other)) {
13854 return false;
13855 }
13856 objIsArr = true;
13857 objIsObj = false;
13858 }
13859 if (isSameTag && !objIsObj) {
13860 stack || (stack = new Stack$1);
13861 return (objIsArr || isTypedArray(object))
13862 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
13863 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
13864 }
13865 if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
13866 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
13867 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
13868
13869 if (objIsWrapped || othIsWrapped) {
13870 var objUnwrapped = objIsWrapped ? object.value() : object,
13871 othUnwrapped = othIsWrapped ? other.value() : other;
13872
13873 stack || (stack = new Stack$1);
13874 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
13875 }
13876 }
13877 if (!isSameTag) {
13878 return false;
13879 }
13880 stack || (stack = new Stack$1);
13881 return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
13882 }
13883
13884 var _baseIsEqualDeep = baseIsEqualDeep$1;
13885
13886 var baseIsEqualDeep = _baseIsEqualDeep,
13887 isObjectLike$1 = isObjectLike_1;
13888
13889 /**
13890 * The base implementation of `_.isEqual` which supports partial comparisons
13891 * and tracks traversed objects.
13892 *
13893 * @private
13894 * @param {*} value The value to compare.
13895 * @param {*} other The other value to compare.
13896 * @param {boolean} bitmask The bitmask flags.
13897 * 1 - Unordered comparison
13898 * 2 - Partial comparison
13899 * @param {Function} [customizer] The function to customize comparisons.
13900 * @param {Object} [stack] Tracks traversed `value` and `other` objects.
13901 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
13902 */
13903 function baseIsEqual$2(value, other, bitmask, customizer, stack) {
13904 if (value === other) {
13905 return true;
13906 }
13907 if (value == null || other == null || (!isObjectLike$1(value) && !isObjectLike$1(other))) {
13908 return value !== value && other !== other;
13909 }
13910 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual$2, stack);
13911 }
13912
13913 var _baseIsEqual = baseIsEqual$2;
13914
13915 var Stack = _Stack,
13916 baseIsEqual$1 = _baseIsEqual;
13917
13918 /** Used to compose bitmasks for value comparisons. */
13919 var COMPARE_PARTIAL_FLAG$1 = 1,
13920 COMPARE_UNORDERED_FLAG$1 = 2;
13921
13922 /**
13923 * The base implementation of `_.isMatch` without support for iteratee shorthands.
13924 *
13925 * @private
13926 * @param {Object} object The object to inspect.
13927 * @param {Object} source The object of property values to match.
13928 * @param {Array} matchData The property names, values, and compare flags to match.
13929 * @param {Function} [customizer] The function to customize comparisons.
13930 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
13931 */
13932 function baseIsMatch$1(object, source, matchData, customizer) {
13933 var index = matchData.length,
13934 length = index,
13935 noCustomizer = !customizer;
13936
13937 if (object == null) {
13938 return !length;
13939 }
13940 object = Object(object);
13941 while (index--) {
13942 var data = matchData[index];
13943 if ((noCustomizer && data[2])
13944 ? data[1] !== object[data[0]]
13945 : !(data[0] in object)
13946 ) {
13947 return false;
13948 }
13949 }
13950 while (++index < length) {
13951 data = matchData[index];
13952 var key = data[0],
13953 objValue = object[key],
13954 srcValue = data[1];
13955
13956 if (noCustomizer && data[2]) {
13957 if (objValue === undefined && !(key in object)) {
13958 return false;
13959 }
13960 } else {
13961 var stack = new Stack;
13962 if (customizer) {
13963 var result = customizer(objValue, srcValue, key, object, source, stack);
13964 }
13965 if (!(result === undefined
13966 ? baseIsEqual$1(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack)
13967 : result
13968 )) {
13969 return false;
13970 }
13971 }
13972 }
13973 return true;
13974 }
13975
13976 var _baseIsMatch = baseIsMatch$1;
13977
13978 var isObject = isObject_1;
13979
13980 /**
13981 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
13982 *
13983 * @private
13984 * @param {*} value The value to check.
13985 * @returns {boolean} Returns `true` if `value` if suitable for strict
13986 * equality comparisons, else `false`.
13987 */
13988 function isStrictComparable$2(value) {
13989 return value === value && !isObject(value);
13990 }
13991
13992 var _isStrictComparable = isStrictComparable$2;
13993
13994 var isStrictComparable$1 = _isStrictComparable,
13995 keys = keys_1;
13996
13997 /**
13998 * Gets the property names, values, and compare flags of `object`.
13999 *
14000 * @private
14001 * @param {Object} object The object to query.
14002 * @returns {Array} Returns the match data of `object`.
14003 */
14004 function getMatchData$1(object) {
14005 var result = keys(object),
14006 length = result.length;
14007
14008 while (length--) {
14009 var key = result[length],
14010 value = object[key];
14011
14012 result[length] = [key, value, isStrictComparable$1(value)];
14013 }
14014 return result;
14015 }
14016
14017 var _getMatchData = getMatchData$1;
14018
14019 /**
14020 * A specialized version of `matchesProperty` for source values suitable
14021 * for strict equality comparisons, i.e. `===`.
14022 *
14023 * @private
14024 * @param {string} key The key of the property to get.
14025 * @param {*} srcValue The value to match.
14026 * @returns {Function} Returns the new spec function.
14027 */
14028
14029 function matchesStrictComparable$2(key, srcValue) {
14030 return function(object) {
14031 if (object == null) {
14032 return false;
14033 }
14034 return object[key] === srcValue &&
14035 (srcValue !== undefined || (key in Object(object)));
14036 };
14037 }
14038
14039 var _matchesStrictComparable = matchesStrictComparable$2;
14040
14041 var baseIsMatch = _baseIsMatch,
14042 getMatchData = _getMatchData,
14043 matchesStrictComparable$1 = _matchesStrictComparable;
14044
14045 /**
14046 * The base implementation of `_.matches` which doesn't clone `source`.
14047 *
14048 * @private
14049 * @param {Object} source The object of property values to match.
14050 * @returns {Function} Returns the new spec function.
14051 */
14052 function baseMatches$1(source) {
14053 var matchData = getMatchData(source);
14054 if (matchData.length == 1 && matchData[0][2]) {
14055 return matchesStrictComparable$1(matchData[0][0], matchData[0][1]);
14056 }
14057 return function(object) {
14058 return object === source || baseIsMatch(object, source, matchData);
14059 };
14060 }
14061
14062 var _baseMatches = baseMatches$1;
14063
14064 var baseGetTag = _baseGetTag,
14065 isObjectLike = isObjectLike_1;
14066
14067 /** `Object#toString` result references. */
14068 var symbolTag = '[object Symbol]';
14069
14070 /**
14071 * Checks if `value` is classified as a `Symbol` primitive or object.
14072 *
14073 * @static
14074 * @memberOf _
14075 * @since 4.0.0
14076 * @category Lang
14077 * @param {*} value The value to check.
14078 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
14079 * @example
14080 *
14081 * _.isSymbol(Symbol.iterator);
14082 * // => true
14083 *
14084 * _.isSymbol('abc');
14085 * // => false
14086 */
14087 function isSymbol$3(value) {
14088 return typeof value == 'symbol' ||
14089 (isObjectLike(value) && baseGetTag(value) == symbolTag);
14090 }
14091
14092 var isSymbol_1 = isSymbol$3;
14093
14094 var isArray$4 = isArray_1,
14095 isSymbol$2 = isSymbol_1;
14096
14097 /** Used to match property names within property paths. */
14098 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
14099 reIsPlainProp = /^\w*$/;
14100
14101 /**
14102 * Checks if `value` is a property name and not a property path.
14103 *
14104 * @private
14105 * @param {*} value The value to check.
14106 * @param {Object} [object] The object to query keys on.
14107 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
14108 */
14109 function isKey$3(value, object) {
14110 if (isArray$4(value)) {
14111 return false;
14112 }
14113 var type = typeof value;
14114 if (type == 'number' || type == 'symbol' || type == 'boolean' ||
14115 value == null || isSymbol$2(value)) {
14116 return true;
14117 }
14118 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
14119 (object != null && value in Object(object));
14120 }
14121
14122 var _isKey = isKey$3;
14123
14124 var MapCache = _MapCache;
14125
14126 /** Error message constants. */
14127 var FUNC_ERROR_TEXT = 'Expected a function';
14128
14129 /**
14130 * Creates a function that memoizes the result of `func`. If `resolver` is
14131 * provided, it determines the cache key for storing the result based on the
14132 * arguments provided to the memoized function. By default, the first argument
14133 * provided to the memoized function is used as the map cache key. The `func`
14134 * is invoked with the `this` binding of the memoized function.
14135 *
14136 * **Note:** The cache is exposed as the `cache` property on the memoized
14137 * function. Its creation may be customized by replacing the `_.memoize.Cache`
14138 * constructor with one whose instances implement the
14139 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
14140 * method interface of `clear`, `delete`, `get`, `has`, and `set`.
14141 *
14142 * @static
14143 * @memberOf _
14144 * @since 0.1.0
14145 * @category Function
14146 * @param {Function} func The function to have its output memoized.
14147 * @param {Function} [resolver] The function to resolve the cache key.
14148 * @returns {Function} Returns the new memoized function.
14149 * @example
14150 *
14151 * var object = { 'a': 1, 'b': 2 };
14152 * var other = { 'c': 3, 'd': 4 };
14153 *
14154 * var values = _.memoize(_.values);
14155 * values(object);
14156 * // => [1, 2]
14157 *
14158 * values(other);
14159 * // => [3, 4]
14160 *
14161 * object.a = 2;
14162 * values(object);
14163 * // => [1, 2]
14164 *
14165 * // Modify the result cache.
14166 * values.cache.set(object, ['a', 'b']);
14167 * values(object);
14168 * // => ['a', 'b']
14169 *
14170 * // Replace `_.memoize.Cache`.
14171 * _.memoize.Cache = WeakMap;
14172 */
14173 function memoize$1(func, resolver) {
14174 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
14175 throw new TypeError(FUNC_ERROR_TEXT);
14176 }
14177 var memoized = function() {
14178 var args = arguments,
14179 key = resolver ? resolver.apply(this, args) : args[0],
14180 cache = memoized.cache;
14181
14182 if (cache.has(key)) {
14183 return cache.get(key);
14184 }
14185 var result = func.apply(this, args);
14186 memoized.cache = cache.set(key, result) || cache;
14187 return result;
14188 };
14189 memoized.cache = new (memoize$1.Cache || MapCache);
14190 return memoized;
14191 }
14192
14193 // Expose `MapCache`.
14194 memoize$1.Cache = MapCache;
14195
14196 var memoize_1 = memoize$1;
14197
14198 var memoize = memoize_1;
14199
14200 /** Used as the maximum memoize cache size. */
14201 var MAX_MEMOIZE_SIZE = 500;
14202
14203 /**
14204 * A specialized version of `_.memoize` which clears the memoized function's
14205 * cache when it exceeds `MAX_MEMOIZE_SIZE`.
14206 *
14207 * @private
14208 * @param {Function} func The function to have its output memoized.
14209 * @returns {Function} Returns the new memoized function.
14210 */
14211 function memoizeCapped$1(func) {
14212 var result = memoize(func, function(key) {
14213 if (cache.size === MAX_MEMOIZE_SIZE) {
14214 cache.clear();
14215 }
14216 return key;
14217 });
14218
14219 var cache = result.cache;
14220 return result;
14221 }
14222
14223 var _memoizeCapped = memoizeCapped$1;
14224
14225 var memoizeCapped = _memoizeCapped;
14226
14227 /** Used to match property names within property paths. */
14228 var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
14229
14230 /** Used to match backslashes in property paths. */
14231 var reEscapeChar = /\\(\\)?/g;
14232
14233 /**
14234 * Converts `string` to a property path array.
14235 *
14236 * @private
14237 * @param {string} string The string to convert.
14238 * @returns {Array} Returns the property path array.
14239 */
14240 var stringToPath$1 = memoizeCapped(function(string) {
14241 var result = [];
14242 if (string.charCodeAt(0) === 46 /* . */) {
14243 result.push('');
14244 }
14245 string.replace(rePropName, function(match, number, quote, subString) {
14246 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
14247 });
14248 return result;
14249 });
14250
14251 var _stringToPath = stringToPath$1;
14252
14253 /**
14254 * A specialized version of `_.map` for arrays without support for iteratee
14255 * shorthands.
14256 *
14257 * @private
14258 * @param {Array} [array] The array to iterate over.
14259 * @param {Function} iteratee The function invoked per iteration.
14260 * @returns {Array} Returns the new mapped array.
14261 */
14262
14263 function arrayMap$1(array, iteratee) {
14264 var index = -1,
14265 length = array == null ? 0 : array.length,
14266 result = Array(length);
14267
14268 while (++index < length) {
14269 result[index] = iteratee(array[index], index, array);
14270 }
14271 return result;
14272 }
14273
14274 var _arrayMap = arrayMap$1;
14275
14276 var Symbol$1 = _Symbol,
14277 arrayMap = _arrayMap,
14278 isArray$3 = isArray_1,
14279 isSymbol$1 = isSymbol_1;
14280
14281 /** Used as references for various `Number` constants. */
14282 var INFINITY$1 = 1 / 0;
14283
14284 /** Used to convert symbols to primitives and strings. */
14285 var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
14286 symbolToString = symbolProto ? symbolProto.toString : undefined;
14287
14288 /**
14289 * The base implementation of `_.toString` which doesn't convert nullish
14290 * values to empty strings.
14291 *
14292 * @private
14293 * @param {*} value The value to process.
14294 * @returns {string} Returns the string.
14295 */
14296 function baseToString$1(value) {
14297 // Exit early for strings to avoid a performance hit in some environments.
14298 if (typeof value == 'string') {
14299 return value;
14300 }
14301 if (isArray$3(value)) {
14302 // Recursively convert values (susceptible to call stack limits).
14303 return arrayMap(value, baseToString$1) + '';
14304 }
14305 if (isSymbol$1(value)) {
14306 return symbolToString ? symbolToString.call(value) : '';
14307 }
14308 var result = (value + '');
14309 return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
14310 }
14311
14312 var _baseToString = baseToString$1;
14313
14314 var baseToString = _baseToString;
14315
14316 /**
14317 * Converts `value` to a string. An empty string is returned for `null`
14318 * and `undefined` values. The sign of `-0` is preserved.
14319 *
14320 * @static
14321 * @memberOf _
14322 * @since 4.0.0
14323 * @category Lang
14324 * @param {*} value The value to convert.
14325 * @returns {string} Returns the converted string.
14326 * @example
14327 *
14328 * _.toString(null);
14329 * // => ''
14330 *
14331 * _.toString(-0);
14332 * // => '-0'
14333 *
14334 * _.toString([1, 2, 3]);
14335 * // => '1,2,3'
14336 */
14337 function toString$1(value) {
14338 return value == null ? '' : baseToString(value);
14339 }
14340
14341 var toString_1 = toString$1;
14342
14343 var isArray$2 = isArray_1,
14344 isKey$2 = _isKey,
14345 stringToPath = _stringToPath,
14346 toString = toString_1;
14347
14348 /**
14349 * Casts `value` to a path array if it's not one.
14350 *
14351 * @private
14352 * @param {*} value The value to inspect.
14353 * @param {Object} [object] The object to query keys on.
14354 * @returns {Array} Returns the cast property path array.
14355 */
14356 function castPath$2(value, object) {
14357 if (isArray$2(value)) {
14358 return value;
14359 }
14360 return isKey$2(value, object) ? [value] : stringToPath(toString(value));
14361 }
14362
14363 var _castPath = castPath$2;
14364
14365 var isSymbol = isSymbol_1;
14366
14367 /** Used as references for various `Number` constants. */
14368 var INFINITY = 1 / 0;
14369
14370 /**
14371 * Converts `value` to a string key if it's not a string or symbol.
14372 *
14373 * @private
14374 * @param {*} value The value to inspect.
14375 * @returns {string|symbol} Returns the key.
14376 */
14377 function toKey$4(value) {
14378 if (typeof value == 'string' || isSymbol(value)) {
14379 return value;
14380 }
14381 var result = (value + '');
14382 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
14383 }
14384
14385 var _toKey = toKey$4;
14386
14387 var castPath$1 = _castPath,
14388 toKey$3 = _toKey;
14389
14390 /**
14391 * The base implementation of `_.get` without support for default values.
14392 *
14393 * @private
14394 * @param {Object} object The object to query.
14395 * @param {Array|string} path The path of the property to get.
14396 * @returns {*} Returns the resolved value.
14397 */
14398 function baseGet$2(object, path) {
14399 path = castPath$1(path, object);
14400
14401 var index = 0,
14402 length = path.length;
14403
14404 while (object != null && index < length) {
14405 object = object[toKey$3(path[index++])];
14406 }
14407 return (index && index == length) ? object : undefined;
14408 }
14409
14410 var _baseGet = baseGet$2;
14411
14412 var baseGet$1 = _baseGet;
14413
14414 /**
14415 * Gets the value at `path` of `object`. If the resolved value is
14416 * `undefined`, the `defaultValue` is returned in its place.
14417 *
14418 * @static
14419 * @memberOf _
14420 * @since 3.7.0
14421 * @category Object
14422 * @param {Object} object The object to query.
14423 * @param {Array|string} path The path of the property to get.
14424 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
14425 * @returns {*} Returns the resolved value.
14426 * @example
14427 *
14428 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
14429 *
14430 * _.get(object, 'a[0].b.c');
14431 * // => 3
14432 *
14433 * _.get(object, ['a', '0', 'b', 'c']);
14434 * // => 3
14435 *
14436 * _.get(object, 'a.b.c', 'default');
14437 * // => 'default'
14438 */
14439 function get$1(object, path, defaultValue) {
14440 var result = object == null ? undefined : baseGet$1(object, path);
14441 return result === undefined ? defaultValue : result;
14442 }
14443
14444 var get_1 = get$1;
14445
14446 /**
14447 * The base implementation of `_.hasIn` without support for deep paths.
14448 *
14449 * @private
14450 * @param {Object} [object] The object to query.
14451 * @param {Array|string} key The key to check.
14452 * @returns {boolean} Returns `true` if `key` exists, else `false`.
14453 */
14454
14455 function baseHasIn$1(object, key) {
14456 return object != null && key in Object(object);
14457 }
14458
14459 var _baseHasIn = baseHasIn$1;
14460
14461 var castPath = _castPath,
14462 isArguments = isArguments_1,
14463 isArray$1 = isArray_1,
14464 isIndex = _isIndex,
14465 isLength = isLength_1,
14466 toKey$2 = _toKey;
14467
14468 /**
14469 * Checks if `path` exists on `object`.
14470 *
14471 * @private
14472 * @param {Object} object The object to query.
14473 * @param {Array|string} path The path to check.
14474 * @param {Function} hasFunc The function to check properties.
14475 * @returns {boolean} Returns `true` if `path` exists, else `false`.
14476 */
14477 function hasPath$1(object, path, hasFunc) {
14478 path = castPath(path, object);
14479
14480 var index = -1,
14481 length = path.length,
14482 result = false;
14483
14484 while (++index < length) {
14485 var key = toKey$2(path[index]);
14486 if (!(result = object != null && hasFunc(object, key))) {
14487 break;
14488 }
14489 object = object[key];
14490 }
14491 if (result || ++index != length) {
14492 return result;
14493 }
14494 length = object == null ? 0 : object.length;
14495 return !!length && isLength(length) && isIndex(key, length) &&
14496 (isArray$1(object) || isArguments(object));
14497 }
14498
14499 var _hasPath = hasPath$1;
14500
14501 var baseHasIn = _baseHasIn,
14502 hasPath = _hasPath;
14503
14504 /**
14505 * Checks if `path` is a direct or inherited property of `object`.
14506 *
14507 * @static
14508 * @memberOf _
14509 * @since 4.0.0
14510 * @category Object
14511 * @param {Object} object The object to query.
14512 * @param {Array|string} path The path to check.
14513 * @returns {boolean} Returns `true` if `path` exists, else `false`.
14514 * @example
14515 *
14516 * var object = _.create({ 'a': _.create({ 'b': 2 }) });
14517 *
14518 * _.hasIn(object, 'a');
14519 * // => true
14520 *
14521 * _.hasIn(object, 'a.b');
14522 * // => true
14523 *
14524 * _.hasIn(object, ['a', 'b']);
14525 * // => true
14526 *
14527 * _.hasIn(object, 'b');
14528 * // => false
14529 */
14530 function hasIn$1(object, path) {
14531 return object != null && hasPath(object, path, baseHasIn);
14532 }
14533
14534 var hasIn_1 = hasIn$1;
14535
14536 var baseIsEqual = _baseIsEqual,
14537 get = get_1,
14538 hasIn = hasIn_1,
14539 isKey$1 = _isKey,
14540 isStrictComparable = _isStrictComparable,
14541 matchesStrictComparable = _matchesStrictComparable,
14542 toKey$1 = _toKey;
14543
14544 /** Used to compose bitmasks for value comparisons. */
14545 var COMPARE_PARTIAL_FLAG = 1,
14546 COMPARE_UNORDERED_FLAG = 2;
14547
14548 /**
14549 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
14550 *
14551 * @private
14552 * @param {string} path The path of the property to get.
14553 * @param {*} srcValue The value to match.
14554 * @returns {Function} Returns the new spec function.
14555 */
14556 function baseMatchesProperty$1(path, srcValue) {
14557 if (isKey$1(path) && isStrictComparable(srcValue)) {
14558 return matchesStrictComparable(toKey$1(path), srcValue);
14559 }
14560 return function(object) {
14561 var objValue = get(object, path);
14562 return (objValue === undefined && objValue === srcValue)
14563 ? hasIn(object, path)
14564 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
14565 };
14566 }
14567
14568 var _baseMatchesProperty = baseMatchesProperty$1;
14569
14570 /**
14571 * This method returns the first argument it receives.
14572 *
14573 * @static
14574 * @since 0.1.0
14575 * @memberOf _
14576 * @category Util
14577 * @param {*} value Any value.
14578 * @returns {*} Returns `value`.
14579 * @example
14580 *
14581 * var object = { 'a': 1 };
14582 *
14583 * console.log(_.identity(object) === object);
14584 * // => true
14585 */
14586
14587 function identity$1(value) {
14588 return value;
14589 }
14590
14591 var identity_1 = identity$1;
14592
14593 /**
14594 * The base implementation of `_.property` without support for deep paths.
14595 *
14596 * @private
14597 * @param {string} key The key of the property to get.
14598 * @returns {Function} Returns the new accessor function.
14599 */
14600
14601 function baseProperty$1(key) {
14602 return function(object) {
14603 return object == null ? undefined : object[key];
14604 };
14605 }
14606
14607 var _baseProperty = baseProperty$1;
14608
14609 var baseGet = _baseGet;
14610
14611 /**
14612 * A specialized version of `baseProperty` which supports deep paths.
14613 *
14614 * @private
14615 * @param {Array|string} path The path of the property to get.
14616 * @returns {Function} Returns the new accessor function.
14617 */
14618 function basePropertyDeep$1(path) {
14619 return function(object) {
14620 return baseGet(object, path);
14621 };
14622 }
14623
14624 var _basePropertyDeep = basePropertyDeep$1;
14625
14626 var baseProperty = _baseProperty,
14627 basePropertyDeep = _basePropertyDeep,
14628 isKey = _isKey,
14629 toKey = _toKey;
14630
14631 /**
14632 * Creates a function that returns the value at `path` of a given object.
14633 *
14634 * @static
14635 * @memberOf _
14636 * @since 2.4.0
14637 * @category Util
14638 * @param {Array|string} path The path of the property to get.
14639 * @returns {Function} Returns the new accessor function.
14640 * @example
14641 *
14642 * var objects = [
14643 * { 'a': { 'b': 2 } },
14644 * { 'a': { 'b': 1 } }
14645 * ];
14646 *
14647 * _.map(objects, _.property('a.b'));
14648 * // => [2, 1]
14649 *
14650 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
14651 * // => [1, 2]
14652 */
14653 function property$1(path) {
14654 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
14655 }
14656
14657 var property_1 = property$1;
14658
14659 var baseMatches = _baseMatches,
14660 baseMatchesProperty = _baseMatchesProperty,
14661 identity = identity_1,
14662 isArray = isArray_1,
14663 property = property_1;
14664
14665 /**
14666 * The base implementation of `_.iteratee`.
14667 *
14668 * @private
14669 * @param {*} [value=_.identity] The value to convert to an iteratee.
14670 * @returns {Function} Returns the iteratee.
14671 */
14672 function baseIteratee$1(value) {
14673 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
14674 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
14675 if (typeof value == 'function') {
14676 return value;
14677 }
14678 if (value == null) {
14679 return identity;
14680 }
14681 if (typeof value == 'object') {
14682 return isArray(value)
14683 ? baseMatchesProperty(value[0], value[1])
14684 : baseMatches(value);
14685 }
14686 return property(value);
14687 }
14688
14689 var _baseIteratee = baseIteratee$1;
14690
14691 var baseAssignValue = _baseAssignValue,
14692 baseForOwn = _baseForOwn,
14693 baseIteratee = _baseIteratee;
14694
14695 /**
14696 * Creates an object with the same keys as `object` and values generated
14697 * by running each own enumerable string keyed property of `object` thru
14698 * `iteratee`. The iteratee is invoked with three arguments:
14699 * (value, key, object).
14700 *
14701 * @static
14702 * @memberOf _
14703 * @since 2.4.0
14704 * @category Object
14705 * @param {Object} object The object to iterate over.
14706 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
14707 * @returns {Object} Returns the new mapped object.
14708 * @see _.mapKeys
14709 * @example
14710 *
14711 * var users = {
14712 * 'fred': { 'user': 'fred', 'age': 40 },
14713 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
14714 * };
14715 *
14716 * _.mapValues(users, function(o) { return o.age; });
14717 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
14718 *
14719 * // The `_.property` iteratee shorthand.
14720 * _.mapValues(users, 'age');
14721 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
14722 */
14723 function mapValues(object, iteratee) {
14724 var result = {};
14725 iteratee = baseIteratee(iteratee);
14726
14727 baseForOwn(object, function(value, key, object) {
14728 baseAssignValue(result, key, iteratee(value, key, object));
14729 });
14730 return result;
14731 }
14732
14733 var mapValues_1 = mapValues;
14734
14735 function visit$1(parent, visitFn, childrenFn) {
14736 if (!parent) return;
14737 visitFn(parent);
14738 var children = childrenFn(parent);
14739
14740 if (children) {
14741 var count = children.length;
14742
14743 for (var i = 0; i < count; i++) {
14744 visit$1(children[i], visitFn, childrenFn);
14745 }
14746 }
14747 }
14748
14749 function getNode(tree, key) {
14750 var node = null;
14751 visit$1(tree, function (d) {
14752 if (d.name === key) {
14753 node = d;
14754 }
14755 }, function (d) {
14756 return d.children;
14757 });
14758 return node;
14759 }
14760
14761 function map2tree( // eslint-disable-next-line @typescript-eslint/ban-types
14762 root) {
14763 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14764 var tree = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
14765 name: options.key || 'state',
14766 children: []
14767 };
14768
14769 // eslint-disable-next-line @typescript-eslint/ban-types
14770 if (!isPlainObject_1(root) && root && !root.toJS) {
14771 return {};
14772 }
14773
14774 var _options$key = options.key,
14775 rootNodeKey = _options$key === void 0 ? 'state' : _options$key,
14776 _options$pushMethod = options.pushMethod,
14777 pushMethod = _options$pushMethod === void 0 ? 'push' : _options$pushMethod;
14778 var currentNode = getNode(tree, rootNodeKey);
14779
14780 if (currentNode === null) {
14781 return {};
14782 }
14783
14784 mapValues_1( // eslint-disable-next-line @typescript-eslint/ban-types
14785 root && root.toJS ? // eslint-disable-next-line @typescript-eslint/ban-types
14786 root.toJS() : // eslint-disable-next-line @typescript-eslint/ban-types
14787 root, // eslint-disable-next-line @typescript-eslint/ban-types
14788 function (maybeImmutable, key) {
14789 var value = maybeImmutable && maybeImmutable.toJS ? maybeImmutable.toJS() : maybeImmutable;
14790 var newNode = {
14791 name: key
14792 };
14793
14794 if (isArray_1(value)) {
14795 newNode.children = [];
14796
14797 for (var i = 0; i < value.length; i++) {
14798 newNode.children[pushMethod](_defineProperty$1({
14799 name: "".concat(key, "[").concat(i, "]")
14800 }, isPlainObject_1(value[i]) ? 'object' : 'value', value[i]));
14801 }
14802 } else if (isPlainObject_1(value)) {
14803 newNode.children = [];
14804 } else {
14805 newNode.value = value;
14806 }
14807
14808 currentNode.children[pushMethod](newNode);
14809 map2tree(value, {
14810 key: key,
14811 pushMethod: pushMethod
14812 }, tree);
14813 });
14814 return tree;
14815 }
14816
14817 var isMergeableObject = function isMergeableObject(value) {
14818 return isNonNullObject(value)
14819 && !isSpecial(value)
14820 };
14821
14822 function isNonNullObject(value) {
14823 return !!value && typeof value === 'object'
14824 }
14825
14826 function isSpecial(value) {
14827 var stringValue = Object.prototype.toString.call(value);
14828
14829 return stringValue === '[object RegExp]'
14830 || stringValue === '[object Date]'
14831 || isReactElement(value)
14832 }
14833
14834 // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
14835 var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
14836 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
14837
14838 function isReactElement(value) {
14839 return value.$$typeof === REACT_ELEMENT_TYPE
14840 }
14841
14842 function emptyTarget(val) {
14843 return Array.isArray(val) ? [] : {}
14844 }
14845
14846 function cloneUnlessOtherwiseSpecified(value, options) {
14847 return (options.clone !== false && options.isMergeableObject(value))
14848 ? deepmerge(emptyTarget(value), value, options)
14849 : value
14850 }
14851
14852 function defaultArrayMerge(target, source, options) {
14853 return target.concat(source).map(function(element) {
14854 return cloneUnlessOtherwiseSpecified(element, options)
14855 })
14856 }
14857
14858 function getMergeFunction(key, options) {
14859 if (!options.customMerge) {
14860 return deepmerge
14861 }
14862 var customMerge = options.customMerge(key);
14863 return typeof customMerge === 'function' ? customMerge : deepmerge
14864 }
14865
14866 function getEnumerableOwnPropertySymbols(target) {
14867 return Object.getOwnPropertySymbols
14868 ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
14869 return target.propertyIsEnumerable(symbol)
14870 })
14871 : []
14872 }
14873
14874 function getKeys(target) {
14875 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
14876 }
14877
14878 function propertyIsOnObject(object, property) {
14879 try {
14880 return property in object
14881 } catch(_) {
14882 return false
14883 }
14884 }
14885
14886 // Protects from prototype poisoning and unexpected merging up the prototype chain.
14887 function propertyIsUnsafe(target, key) {
14888 return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
14889 && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
14890 && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
14891 }
14892
14893 function mergeObject(target, source, options) {
14894 var destination = {};
14895 if (options.isMergeableObject(target)) {
14896 getKeys(target).forEach(function(key) {
14897 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
14898 });
14899 }
14900 getKeys(source).forEach(function(key) {
14901 if (propertyIsUnsafe(target, key)) {
14902 return
14903 }
14904
14905 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
14906 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
14907 } else {
14908 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
14909 }
14910 });
14911 return destination
14912 }
14913
14914 function deepmerge(target, source, options) {
14915 options = options || {};
14916 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
14917 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
14918 // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
14919 // implementations can use it. The caller may not replace it.
14920 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
14921
14922 var sourceIsArray = Array.isArray(source);
14923 var targetIsArray = Array.isArray(target);
14924 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
14925
14926 if (!sourceAndTargetTypesMatch) {
14927 return cloneUnlessOtherwiseSpecified(source, options)
14928 } else if (sourceIsArray) {
14929 return options.arrayMerge(target, source, options)
14930 } else {
14931 return mergeObject(target, source, options)
14932 }
14933 }
14934
14935 deepmerge.all = function deepmergeAll(array, options) {
14936 if (!Array.isArray(array)) {
14937 throw new Error('first argument should be an array')
14938 }
14939
14940 return array.reduce(function(prev, next) {
14941 return deepmerge(prev, next, options)
14942 }, {})
14943 };
14944
14945 var deepmerge_1 = deepmerge;
14946
14947 var cjs = deepmerge_1;
14948
14949 var _typeof$1 = {exports: {}};
14950
14951 (function (module) {
14952 function _typeof(obj) {
14953 "@babel/helpers - typeof";
14954
14955 return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
14956 return typeof obj;
14957 } : function (obj) {
14958 return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
14959 }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
14960 }
14961
14962 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
14963 }(_typeof$1));
14964
14965 var _typeof = /*@__PURE__*/getDefaultExportFromCjs(_typeof$1.exports);
14966
14967 function sortObject(obj, strict) {
14968 if (obj instanceof Array) {
14969 var ary;
14970
14971 if (strict) {
14972 ary = obj.sort();
14973 } else {
14974 ary = obj;
14975 }
14976
14977 return ary;
14978 }
14979
14980 if (obj && _typeof(obj) === 'object') {
14981 var tObj = {};
14982 Object.keys(obj).sort().forEach(function (key) {
14983 return tObj[key] = sortObject(obj[key]);
14984 });
14985 return tObj;
14986 }
14987
14988 return obj;
14989 }
14990
14991 function sortAndSerialize(obj) {
14992 return JSON.stringify(sortObject(obj, true), undefined, 2);
14993 }
14994
14995 function toggleChildren(node) {
14996 if (node.children) {
14997 node._children = node.children;
14998 node.children = null;
14999 } else if (node._children) {
15000 node.children = node._children;
15001 node._children = null;
15002 }
15003
15004 return node;
15005 }
15006 function visit(parent, visitFn, childrenFn) {
15007 if (!parent) {
15008 return;
15009 }
15010
15011 visitFn(parent);
15012 var children = childrenFn(parent);
15013
15014 if (children) {
15015 var count = children.length;
15016
15017 for (var i = 0; i < count; i++) {
15018 visit(children[i], visitFn, childrenFn);
15019 }
15020 }
15021 }
15022 function getNodeGroupByDepthCount(rootNode) {
15023 var nodeGroupByDepthCount = [1];
15024
15025 var traverseFrom = function traverseFrom(node) {
15026 var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
15027
15028 if (!node.children || node.children.length === 0) {
15029 return 0;
15030 }
15031
15032 if (nodeGroupByDepthCount.length <= depth + 1) {
15033 nodeGroupByDepthCount.push(0);
15034 }
15035
15036 nodeGroupByDepthCount[depth + 1] += node.children.length;
15037 node.children.forEach(function (childNode) {
15038 traverseFrom(childNode, depth + 1);
15039 });
15040 };
15041
15042 traverseFrom(rootNode);
15043 return nodeGroupByDepthCount;
15044 }
15045 function getTooltipString(node, i, _ref) {
15046 var _ref$indentationSize = _ref.indentationSize,
15047 indentationSize = _ref$indentationSize === void 0 ? 4 : _ref$indentationSize;
15048 if (!is$1(Object, node)) return '';
15049 var spacer = join$1('&nbsp;&nbsp;');
15050 var cr2br = replace$1(/\n/g, '<br/>');
15051 var spaces2nbsp = replace$1(/\s{2}/g, spacer(new Array(indentationSize)));
15052 var json2html = pipe(sortAndSerialize, cr2br, spaces2nbsp);
15053 var children = node.children || node._children;
15054 if (typeof node.value !== 'undefined') return json2html(node.value);
15055 if (typeof node.object !== 'undefined') return json2html(node.object);
15056 if (children && children.length) return "childrenCount: ".concat(children.length);
15057 return 'empty';
15058 }
15059
15060 function _arrayWithHoles(arr) {
15061 if (Array.isArray(arr)) return arr;
15062 }
15063
15064 function _iterableToArrayLimit(arr, i) {
15065 var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
15066
15067 if (_i == null) return;
15068 var _arr = [];
15069 var _n = true;
15070 var _d = false;
15071
15072 var _s, _e;
15073
15074 try {
15075 for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
15076 _arr.push(_s.value);
15077
15078 if (i && _arr.length === i) break;
15079 }
15080 } catch (err) {
15081 _d = true;
15082 _e = err;
15083 } finally {
15084 try {
15085 if (!_n && _i["return"] != null) _i["return"]();
15086 } finally {
15087 if (_d) throw _e;
15088 }
15089 }
15090
15091 return _arr;
15092 }
15093
15094 function _arrayLikeToArray(arr, len) {
15095 if (len == null || len > arr.length) len = arr.length;
15096
15097 for (var i = 0, arr2 = new Array(len); i < len; i++) {
15098 arr2[i] = arr[i];
15099 }
15100
15101 return arr2;
15102 }
15103
15104 function _unsupportedIterableToArray(o, minLen) {
15105 if (!o) return;
15106 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
15107 var n = Object.prototype.toString.call(o).slice(8, -1);
15108 if (n === "Object" && o.constructor) n = o.constructor.name;
15109 if (n === "Map" || n === "Set") return Array.from(o);
15110 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
15111 }
15112
15113 function _nonIterableRest() {
15114 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
15115 }
15116
15117 function _slicedToArray(arr, i) {
15118 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
15119 }
15120
15121 function functor$1(v) {
15122 return is$1(Function, v) ? v : function () {
15123 return v;
15124 };
15125 }
15126
15127 function prependClass$1(className) {
15128 return mapObjIndexed$1(function (value, key) {
15129 if (key === 'class') {
15130 var fn = functor$1(value);
15131 return function (d, i) {
15132 var classNames = fn(d, i);
15133
15134 if (classNames !== className) {
15135 return join$1(' ', [className, classNames]);
15136 }
15137
15138 return classNames;
15139 };
15140 }
15141
15142 return value;
15143 });
15144 }
15145
15146 var utils = {
15147 prependClass: prependClass$1,
15148 functor: functor$1
15149 };
15150
15151 function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15152
15153 function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15154 var prependClass = utils.prependClass,
15155 functor = utils.functor;
15156 var defaultOptions$1 = {
15157 left: undefined,
15158 top: undefined,
15159 offset: {
15160 left: 0,
15161 top: 0
15162 },
15163 root: undefined
15164 };
15165 function tooltip(d3) {
15166 var className = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'tooltip';
15167 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
15168
15169 var _defaultOptions$optio = _objectSpread$1(_objectSpread$1({}, defaultOptions$1), options),
15170 left = _defaultOptions$optio.left,
15171 top = _defaultOptions$optio.top,
15172 offset = _defaultOptions$optio.offset,
15173 root = _defaultOptions$optio.root;
15174
15175 var attrs = {
15176 class: className
15177 };
15178
15179 var text = function text(node) {
15180 return '';
15181 };
15182
15183 var styles = {};
15184 var el;
15185 var anchor = root || d3.select('body');
15186 var rootNode = anchor.node();
15187
15188 function tip(selection) {
15189 selection.on('mouseover.tip', function (node) {
15190 var _d3$mouse = d3.mouse(rootNode),
15191 _d3$mouse2 = _slicedToArray(_d3$mouse, 2),
15192 mouseX = _d3$mouse2[0],
15193 mouseY = _d3$mouse2[1];
15194
15195 var x = left || mouseX + offset.left,
15196 y = top || mouseY - offset.top;
15197 anchor.selectAll("div.".concat(className)).remove();
15198 el = anchor.append('div').attr(prependClass(className)(attrs)).style(_objectSpread$1({
15199 position: 'absolute',
15200 'z-index': 1001,
15201 left: "".concat(x, "px"),
15202 top: "".concat(y, "px")
15203 }, styles)).html(function () {
15204 return text(node);
15205 });
15206 });
15207 selection.on('mousemove.tip', function (node) {
15208 var _d3$mouse3 = d3.mouse(rootNode),
15209 _d3$mouse4 = _slicedToArray(_d3$mouse3, 2),
15210 mouseX = _d3$mouse4[0],
15211 mouseY = _d3$mouse4[1];
15212
15213 var x = left || mouseX + offset.left,
15214 y = top || mouseY - offset.top;
15215 el.style({
15216 left: "".concat(x, "px"),
15217 top: "".concat(y, "px")
15218 }).html(function () {
15219 return text(node);
15220 });
15221 });
15222 selection.on('mouseout.tip', function () {
15223 return el.remove();
15224 });
15225 }
15226
15227 tip.attr = function setAttr(d) {
15228 if (is$1(Object, d)) {
15229 attrs = _objectSpread$1(_objectSpread$1({}, attrs), d);
15230 }
15231
15232 return this;
15233 };
15234
15235 tip.style = function setStyle(d) {
15236 if (is$1(Object, d)) {
15237 styles = _objectSpread$1(_objectSpread$1({}, styles), d);
15238 }
15239
15240 return this;
15241 };
15242
15243 tip.text = function setText(d) {
15244 text = functor(d);
15245 return this;
15246 };
15247
15248 return tip;
15249 }
15250
15251 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15252
15253 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15254 var defaultOptions = {
15255 state: undefined,
15256 rootKeyName: 'state',
15257 pushMethod: 'push',
15258 tree: undefined,
15259 id: 'd3svg',
15260 style: {
15261 node: {
15262 colors: {
15263 default: '#ccc',
15264 collapsed: 'lightsteelblue',
15265 parent: 'white'
15266 },
15267 radius: 7
15268 },
15269 text: {
15270 colors: {
15271 default: 'black',
15272 hover: 'skyblue'
15273 }
15274 },
15275 link: {
15276 stroke: '#000',
15277 fill: 'none'
15278 }
15279 },
15280 size: 500,
15281 aspectRatio: 1.0,
15282 initialZoom: 1,
15283 margin: {
15284 top: 10,
15285 right: 10,
15286 bottom: 10,
15287 left: 50
15288 },
15289 isSorted: false,
15290 heightBetweenNodesCoeff: 2,
15291 widthBetweenNodesCoeff: 1,
15292 transitionDuration: 750,
15293 blinkDuration: 100,
15294 onClickText: function onClickText() {// noop
15295 },
15296 tooltipOptions: {
15297 disabled: false,
15298 left: undefined,
15299 top: undefined,
15300 offset: {
15301 left: 0,
15302 top: 0
15303 },
15304 style: undefined
15305 }
15306 };
15307 function tree (DOMNode) {
15308 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15309
15310 var _deepmerge = cjs(defaultOptions, options),
15311 id = _deepmerge.id,
15312 style = _deepmerge.style,
15313 size = _deepmerge.size,
15314 aspectRatio = _deepmerge.aspectRatio,
15315 initialZoom = _deepmerge.initialZoom,
15316 margin = _deepmerge.margin,
15317 isSorted = _deepmerge.isSorted,
15318 widthBetweenNodesCoeff = _deepmerge.widthBetweenNodesCoeff,
15319 heightBetweenNodesCoeff = _deepmerge.heightBetweenNodesCoeff,
15320 transitionDuration = _deepmerge.transitionDuration,
15321 blinkDuration = _deepmerge.blinkDuration,
15322 state = _deepmerge.state,
15323 rootKeyName = _deepmerge.rootKeyName,
15324 pushMethod = _deepmerge.pushMethod,
15325 tree = _deepmerge.tree,
15326 tooltipOptions = _deepmerge.tooltipOptions,
15327 onClickText = _deepmerge.onClickText;
15328
15329 var width = size - margin.left - margin.right;
15330 var height = size * aspectRatio - margin.top - margin.bottom;
15331 var fullWidth = size;
15332 var fullHeight = size * aspectRatio;
15333 var attr = {
15334 id: id,
15335 preserveAspectRatio: 'xMinYMin slice'
15336 };
15337
15338 if (!style.width) {
15339 attr.width = fullWidth;
15340 }
15341
15342 if (!style.width || !style.height) {
15343 attr.viewBox = "0 0 ".concat(fullWidth, " ").concat(fullHeight);
15344 }
15345
15346 var root = d3.select(DOMNode);
15347 var zoom = d3.behavior.zoom().scaleExtent([0.1, 3]).scale(initialZoom);
15348 var vis = root.append('svg').attr(attr).style(_objectSpread({
15349 cursor: '-webkit-grab'
15350 }, style)).call(zoom.on('zoom', function () {
15351 var _d3$event = d3.event,
15352 translate = _d3$event.translate,
15353 scale = _d3$event.scale;
15354 vis.attr('transform', "translate(".concat(translate.toString(), ")scale(").concat(scale, ")"));
15355 })).append('g').attr({
15356 transform: "translate(".concat(margin.left + style.node.radius, ", ").concat(margin.top, ") scale(").concat(initialZoom, ")")
15357 });
15358 var layout = d3.layout.tree().size([width, height]);
15359 var data;
15360
15361 if (isSorted) {
15362 layout.sort(function (a, b) {
15363 return b.name.toLowerCase() < a.name.toLowerCase() ? 1 : -1;
15364 });
15365 } // previousNodePositionsById stores node x and y
15366 // as well as hierarchy (id / parentId);
15367 // helps animating transitions
15368
15369
15370 var previousNodePositionsById = {
15371 root: {
15372 id: 'root',
15373 parentId: null,
15374 x: height / 2,
15375 y: 0
15376 }
15377 }; // traverses a map with node positions by going through the chain
15378 // of parent ids; once a parent that matches the given filter is found,
15379 // the parent position gets returned
15380
15381 function findParentNodePosition(nodePositionsById, nodeId, filter) {
15382 var currentPosition = nodePositionsById[nodeId];
15383
15384 while (currentPosition) {
15385 currentPosition = nodePositionsById[currentPosition.parentId];
15386
15387 if (!currentPosition) {
15388 return null;
15389 }
15390
15391 if (!filter || filter(currentPosition)) {
15392 return currentPosition;
15393 }
15394 }
15395 }
15396
15397 return function renderChart() {
15398 var nextState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : tree || state;
15399 data = !tree ? // eslint-disable-next-line @typescript-eslint/ban-types
15400 map2tree(nextState, {
15401 key: rootKeyName,
15402 pushMethod: pushMethod
15403 }) : nextState;
15404
15405 if (isEmpty$1(data) || !data.name) {
15406 data = {
15407 name: 'error',
15408 message: 'Please provide a state map or a tree structure'
15409 };
15410 }
15411
15412 var nodeIndex = 0;
15413 var maxLabelLength = 0; // nodes are assigned with string ids, which reflect their location
15414 // within the hierarcy; e.g. "root|branch|subBranch|subBranch[0]|property"
15415 // top-level elemnt always has id "root"
15416
15417 visit(data, function (node) {
15418 maxLabelLength = Math.max(node.name.length, maxLabelLength);
15419 node.id = node.id || 'root';
15420 }, function (node) {
15421 return node.children && node.children.length > 0 ? node.children.map(function (c) {
15422 c.id = "".concat(node.id || '', "|").concat(c.name);
15423 return c;
15424 }) : null;
15425 });
15426 update();
15427
15428 function update() {
15429 // path generator for links
15430 var diagonal = d3.svg.diagonal().projection(function (d) {
15431 return [d.y, d.x];
15432 }); // set tree dimensions and spacing between branches and nodes
15433
15434 var maxNodeCountByLevel = Math.max.apply(Math, _toConsumableArray(getNodeGroupByDepthCount(data)));
15435 layout = layout.size([maxNodeCountByLevel * 25 * heightBetweenNodesCoeff, width]);
15436 var nodes = layout.nodes(data);
15437 var links = layout.links(nodes);
15438 nodes.forEach(function (node) {
15439 return node.y = node.depth * (maxLabelLength * 7 * widthBetweenNodesCoeff);
15440 });
15441 var nodePositions = nodes.map(function (n) {
15442 return {
15443 parentId: n.parent && n.parent.id,
15444 id: n.id,
15445 x: n.x,
15446 y: n.y
15447 };
15448 });
15449 var nodePositionsById = {};
15450 nodePositions.forEach(function (node) {
15451 return nodePositionsById[node.id] = node;
15452 }); // process the node selection
15453
15454 var node = vis.selectAll('g.node').property('__oldData__', function (d) {
15455 return d;
15456 }).data(nodes, function (d) {
15457 return d.id || (d.id = ++nodeIndex);
15458 });
15459 var nodeEnter = node.enter().append('g').attr({
15460 class: 'node',
15461 transform: function transform(d) {
15462 var position = findParentNodePosition(nodePositionsById, d.id, function (n) {
15463 return !!previousNodePositionsById[n.id];
15464 });
15465 var previousPosition = position && previousNodePositionsById[position.id] || previousNodePositionsById.root;
15466 return "translate(".concat(previousPosition.y, ",").concat(previousPosition.x, ")");
15467 }
15468 }).style({
15469 fill: style.text.colors.default,
15470 cursor: 'pointer'
15471 }).on('mouseover', function mouseover() {
15472 d3.select(this).style({
15473 fill: style.text.colors.hover
15474 });
15475 }).on('mouseout', function mouseout() {
15476 d3.select(this).style({
15477 fill: style.text.colors.default
15478 });
15479 });
15480
15481 if (!tooltipOptions.disabled) {
15482 nodeEnter.call(tooltip(d3, 'tooltip', _objectSpread(_objectSpread({}, tooltipOptions), {}, {
15483 root: root
15484 })).text(function (d, i) {
15485 return getTooltipString(d, i, tooltipOptions);
15486 }).style(tooltipOptions.style));
15487 } // g inside node contains circle and text
15488 // this extra wrapper helps run d3 transitions in parallel
15489
15490
15491 var nodeEnterInnerGroup = nodeEnter.append('g');
15492 nodeEnterInnerGroup.append('circle').attr({
15493 class: 'nodeCircle',
15494 r: 0
15495 }).on('click', function (clickedNode) {
15496 if (d3.event.defaultPrevented) return;
15497 toggleChildren(clickedNode);
15498 update();
15499 });
15500 nodeEnterInnerGroup.append('text').attr({
15501 class: 'nodeText',
15502 'text-anchor': 'middle',
15503 transform: 'translate(0,0)',
15504 dy: '.35em'
15505 }).style({
15506 'fill-opacity': 0
15507 }).text(function (d) {
15508 return d.name;
15509 }).on('click', onClickText); // update the text to reflect whether node has children or not
15510
15511 node.select('text').text(function (d) {
15512 return d.name;
15513 }); // change the circle fill depending on whether it has children and is collapsed
15514
15515 node.select('circle').style({
15516 stroke: 'black',
15517 'stroke-width': '1.5px',
15518 fill: function fill(d) {
15519 return d._children ? style.node.colors.collapsed : d.children ? style.node.colors.parent : style.node.colors.default;
15520 }
15521 }); // transition nodes to their new position
15522
15523 var nodeUpdate = node.transition().duration(transitionDuration).attr({
15524 transform: function transform(d) {
15525 return "translate(".concat(d.y, ",").concat(d.x, ")");
15526 }
15527 }); // ensure circle radius is correct
15528
15529 nodeUpdate.select('circle').attr('r', style.node.radius); // fade the text in and align it
15530
15531 nodeUpdate.select('text').style('fill-opacity', 1).attr({
15532 transform: function transform(d) {
15533 var x = (d.children || d._children ? -1 : 1) * (this.getBBox().width / 2 + style.node.radius + 5);
15534 return "translate(".concat(x, ",0)");
15535 }
15536 }); // blink updated nodes
15537
15538 node.filter(function flick(d) {
15539 // test whether the relevant properties of d match
15540 // the equivalent property of the oldData
15541 // also test whether the old data exists,
15542 // to catch the entering elements!
15543 return this.__oldData__ && d.value !== this.__oldData__.value;
15544 }).select('g').style('opacity', '0.3').transition().duration(blinkDuration).style('opacity', '1'); // transition exiting nodes to the parent's new position
15545
15546 var nodeExit = node.exit().transition().duration(transitionDuration).attr({
15547 transform: function transform(d) {
15548 var position = findParentNodePosition(previousNodePositionsById, d.id, function (n) {
15549 return !!nodePositionsById[n.id];
15550 });
15551 var futurePosition = position && nodePositionsById[position.id] || nodePositionsById.root;
15552 return "translate(".concat(futurePosition.y, ",").concat(futurePosition.x, ")");
15553 }
15554 }).remove();
15555 nodeExit.select('circle').attr('r', 0);
15556 nodeExit.select('text').style('fill-opacity', 0); // update the links
15557
15558 var link = vis.selectAll('path.link').data(links, function (d) {
15559 return d.target.id;
15560 }); // enter any new links at the parent's previous position
15561
15562 link.enter().insert('path', 'g').attr({
15563 class: 'link',
15564 d: function d(_d) {
15565 var position = findParentNodePosition(nodePositionsById, _d.target.id, function (n) {
15566 return !!previousNodePositionsById[n.id];
15567 });
15568 var previousPosition = position && previousNodePositionsById[position.id] || previousNodePositionsById.root;
15569 return diagonal({
15570 source: previousPosition,
15571 target: previousPosition
15572 });
15573 }
15574 }).style(style.link); // transition links to their new position
15575
15576 link.transition().duration(transitionDuration).attr({
15577 d: diagonal
15578 }); // transition exiting nodes to the parent's new position
15579
15580 link.exit().transition().duration(transitionDuration).attr({
15581 d: function d(_d2) {
15582 var position = findParentNodePosition(previousNodePositionsById, _d2.target.id, function (n) {
15583 return !!nodePositionsById[n.id];
15584 });
15585 var futurePosition = position && nodePositionsById[position.id] || nodePositionsById.root;
15586 return diagonal({
15587 source: futurePosition,
15588 target: futurePosition
15589 });
15590 }
15591 }).remove(); // delete the old data once it's no longer needed
15592
15593 node.property('__oldData__', null); // stash the old positions for transition
15594
15595 previousNodePositionsById = nodePositionsById;
15596 }
15597 };
15598 }
15599
15600 exports.tree = tree;
15601
15602 Object.defineProperty(exports, '__esModule', { value: true });
15603
15604}));