PageSourceSearch

https://trainfo.ca/wp-content/plugins/relish-freemium/js/vendor/d3.js?ver=6.5.12

js trainfo.ca collected 2026-10-03 21:01:20 UTC 515,704 bytes, 18,568 lines download raw bytes

vendor: 12,622 bytes, lines 1-541
1// https://d3js.org v5.16.0 Copyright 2020 Mike Bostock
2(function (global, factory) {
3typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4typeof define === 'function' && define.amd ? define(['exports'], factory) :
5(global = global || self, factory(global.d3 = global.d3 || {}));
6}(this, function (exports) { 'use strict';
7
8var version = "5.16.0";
9
10function ascending(a, b) {
11  return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
12}
13
14function bisector(compare) {
15  if (compare.length === 1) compare = ascendingComparator(compare);
16  return {
17    left: function(a, x, lo, hi) {
18      if (lo == null) lo = 0;
19      if (hi == null) hi = a.length;
20      while (lo < hi) {
21        var mid = lo + hi >>> 1;
22        if (compare(a[mid], x) < 0) lo = mid + 1;
23        else hi = mid;
24      }
25      return lo;
26    },
27    right: function(a, x, lo, hi) {
28      if (lo == null) lo = 0;
29      if (hi == null) hi = a.length;
30      while (lo < hi) {
31        var mid = lo + hi >>> 1;
32        if (compare(a[mid], x) > 0) hi = mid;
33        else lo = mid + 1;
34      }
35      return lo;
36    }
37  };
38}
39
40function ascendingComparator(f) {
41  return function(d, x) {
42    return ascending(f(d), x);
43  };
44}
45
46var ascendingBisect = bisector(ascending);
47var bisectRight = ascendingBisect.right;
48var bisectLeft = ascendingBisect.left;
49
50function pairs(array, f) {
51  if (f == null) f = pair;
52  var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
53  while (i < n) pairs[i] = f(p, p = array[++i]);
54  return pairs;
55}
56
57function pair(a, b) {
58  return [a, b];
59}
60
61function cross(values0, values1, reduce) {
62  var n0 = values0.length,
63      n1 = values1.length,
64      values = new Array(n0 * n1),
65      i0,
66      i1,
67      i,
68      value0;
69
70  if (reduce == null) reduce = pair;
71
72  for (i0 = i = 0; i0 < n0; ++i0) {
73    for (value0 = values0[i0], i1 = 0; i1 < n1; ++i1, ++i) {
74      values[i] = reduce(value0, values1[i1]);
75    }
76  }
77
78  return values;
79}
80
81function descending(a, b) {
82  return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
83}
84
85function number(x) {
86  return x === null ? NaN : +x;
87}
88
89function variance(values, valueof) {
90  var n = values.length,
91      m = 0,
92      i = -1,
93      mean = 0,
94      value,
95      delta,
96      sum = 0;
97
98  if (valueof == null) {
99    while (++i < n) {
100      if (!isNaN(value = number(values[i]))) {
101        delta = value - mean;
102        mean += delta / ++m;
103        sum += delta * (value - mean);
104      }
105    }
106  }
107
108  else {
109    while (++i < n) {
110      if (!isNaN(value = number(valueof(values[i], i, values)))) {
111        delta = value - mean;
112        mean += delta / ++m;
113        sum += delta * (value - mean);
114      }
115    }
116  }
117
118  if (m > 1) return sum / (m - 1);
119}
120
121function deviation(array, f) {
122  var v = variance(array, f);
123  return v ? Math.sqrt(v) : v;
124}
125
126function extent(values, valueof) {
127  var n = values.length,
128      i = -1,
129      value,
130      min,
131      max;
132
133  if (valueof == null) {
134    while (++i < n) { // Find the first comparable value.
135      if ((value = values[i]) != null && value >= value) {
136        min = max = value;
137        while (++i < n) { // Compare the remaining values.
138          if ((value = values[i]) != null) {
139            if (min > value) min = value;
140            if (max < value) max = value;
141          }
142        }
143      }
144    }
145  }
146
147  else {
148    while (++i < n) { // Find the first comparable value.
149      if ((value = valueof(values[i], i, values)) != null && value >= value) {
150        min = max = value;
151        while (++i < n) { // Compare the remaining values.
152          if ((value = valueof(values[i], i, values)) != null) {
153            if (min > value) min = value;
154            if (max < value) max = value;
155          }
156        }
157      }
158    }
159  }
160
161  return [min, max];
162}
163
164var array = Array.prototype;
165
166var slice = array.slice;
167var map = array.map;
168
169function constant(x) {
170  return function() {
171    return x;
172  };
173}
174
175function identity(x) {
176  return x;
177}
178
179function sequence(start, stop, step) {
180  start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
181
182  var i = -1,
183      n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
184      range = new Array(n);
185
186  while (++i < n) {
187    range[i] = start + i * step;
188  }
189
190  return range;
191}
192
193var e10 = Math.sqrt(50),
194    e5 = Math.sqrt(10),
195    e2 = Math.sqrt(2);
196
197function ticks(start, stop, count) {
198  var reverse,
199      i = -1,
200      n,
201      ticks,
202      step;
203
204  stop = +stop, start = +start, count = +count;
205  if (start === stop && count > 0) return [start];
206  if (reverse = stop < start) n = start, start = stop, stop = n;
207  if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
208
209  if (step > 0) {
210    start = Math.ceil(start / step);
211    stop = Math.floor(stop / step);
212    ticks = new Array(n = Math.ceil(stop - start + 1));
213    while (++i < n) ticks[i] = (start + i) * step;
214  } else {
215    start = Math.floor(start * step);
216    stop = Math.ceil(stop * step);
217    ticks = new Array(n = Math.ceil(start - stop + 1));
218    while (++i < n) ticks[i] = (start - i) / step;
219  }
220
221  if (reverse) ticks.reverse();
222
223  return ticks;
224}
225
226function tickIncrement(start, stop, count) {
227  var step = (stop - start) / Math.max(0, count),
228      power = Math.floor(Math.log(step) / Math.LN10),
229      error = step / Math.pow(10, power);
230  return power >= 0
231      ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
232      : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
233}
234
235function tickStep(start, stop, count) {
236  var step0 = Math.abs(stop - start) / Math.max(0, count),
237      step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
238      error = step0 / step1;
239  if (error >= e10) step1 *= 10;
240  else if (error >= e5) step1 *= 5;
241  else if (error >= e2) step1 *= 2;
242  return stop < start ? -step1 : step1;
243}
244
245function thresholdSturges(values) {
246  return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
247}
248
249function histogram() {
250  var value = identity,
251      domain = extent,
252      threshold = thresholdSturges;
253
254  function histogram(data) {
255    var i,
256        n = data.length,
257        x,
258        values = new Array(n);
259
260    for (i = 0; i < n; ++i) {
261      values[i] = value(data[i], i, data);
262    }
263
264    var xz = domain(values),
265        x0 = xz[0],
266        x1 = xz[1],
267        tz = threshold(values, x0, x1);
268
269    // Convert number of thresholds into uniform thresholds.
270    if (!Array.isArray(tz)) {
271      tz = tickStep(x0, x1, tz);
272      tz = sequence(Math.ceil(x0 / tz) * tz, x1, tz); // exclusive
273    }
274
275    // Remove any thresholds outside the domain.
276    var m = tz.length;
277    while (tz[0] <= x0) tz.shift(), --m;
278    while (tz[m - 1] > x1) tz.pop(), --m;
279
280    var bins = new Array(m + 1),
281        bin;
282
283    // Initialize bins.
284    for (i = 0; i <= m; ++i) {
285      bin = bins[i] = [];
286      bin.x0 = i > 0 ? tz[i - 1] : x0;
287      bin.x1 = i < m ? tz[i] : x1;
288    }
289
290    // Assign data to bins by value, ignoring any outside the domain.
291    for (i = 0; i < n; ++i) {
292      x = values[i];
293      if (x0 <= x && x <= x1) {
294        bins[bisectRight(tz, x, 0, m)].push(data[i]);
295      }
296    }
297
298    return bins;
299  }
300
301  histogram.value = function(_) {
302    return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram) : value;
303  };
304
305  histogram.domain = function(_) {
306    return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram) : domain;
307  };
308
309  histogram.thresholds = function(_) {
310    return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
311  };
312
313  return histogram;
314}
315
316function threshold(values, p, valueof) {
317  if (valueof == null) valueof = number;
318  if (!(n = values.length)) return;
319  if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
320  if (p >= 1) return +valueof(values[n - 1], n - 1, values);
321  var n,
322      i = (n - 1) * p,
323      i0 = Math.floor(i),
324      value0 = +valueof(values[i0], i0, values),
325      value1 = +valueof(values[i0 + 1], i0 + 1, values);
326  return value0 + (value1 - value0) * (i - i0);
327}
328
329function freedmanDiaconis(values, min, max) {
330  values = map.call(values, number).sort(ascending);
331  return Math.ceil((max - min) / (2 * (threshold(values, 0.75) - threshold(values, 0.25)) * Math.pow(values.length, -1 / 3)));
332}
333
334function scott(values, min, max) {
335  return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
336}
337
338function max(values, valueof) {
339  var n = values.length,
340      i = -1,
341      value,
342      max;
343
344  if (valueof == null) {
345    while (++i < n) { // Find the first comparable value.
346      if ((value = values[i]) != null && value >= value) {
347        max = value;
348        while (++i < n) { // Compare the remaining values.
349          if ((value = values[i]) != null && value > max) {
350            max = value;
351          }
352        }
353      }
354    }
355  }
356
357  else {
358    while (++i < n) { // Find the first comparable value.
359      if ((value = valueof(values[i], i, values)) != null && value >= value) {
360        max = value;
361        while (++i < n) { // Compare the remaining values.
362          if ((value = valueof(values[i], i, values)) != null && value > max) {
363            max = value;
364          }
365        }
366      }
367    }
368  }
369
370  return max;
371}
372
373function mean(values, valueof) {
374  var n = values.length,
375      m = n,
376      i = -1,
377      value,
378      sum = 0;
379
380  if (valueof == null) {
381    while (++i < n) {
382      if (!isNaN(value = number(values[i]))) sum += value;
383      else --m;
384    }
385  }
386
387  else {
388    while (++i < n) {
389      if (!isNaN(value = number(valueof(values[i], i, values)))) sum += value;
390      else --m;
391    }
392  }
393
394  if (m) return sum / m;
395}
396
397function median(values, valueof) {
398  var n = values.length,
399      i = -1,
400      value,
401      numbers = [];
402
403  if (valueof == null) {
404    while (++i < n) {
405      if (!isNaN(value = number(values[i]))) {
406        numbers.push(value);
407      }
408    }
409  }
410
411  else {
412    while (++i < n) {
413      if (!isNaN(value = number(valueof(values[i], i, values)))) {
414        numbers.push(value);
415      }
416    }
417  }
418
419  return threshold(numbers.sort(ascending), 0.5);
420}
421
422function merge(arrays) {
423  var n = arrays.length,
424      m,
425      i = -1,
426      j = 0,
427      merged,
428      array;
429
430  while (++i < n) j += arrays[i].length;
431  merged = new Array(j);
432
433  while (--n >= 0) {
434    array = arrays[n];
435    m = array.length;
436    while (--m >= 0) {
437      merged[--j] = array[m];
438    }
439  }
440
441  return merged;
442}
443
444function min(values, valueof) {
445  var n = values.length,
446      i = -1,
447      value,
448      min;
449
450  if (valueof == null) {
451    while (++i < n) { // Find the first comparable value.
452      if ((value = values[i]) != null && value >= value) {
453        min = value;
454        while (++i < n) { // Compare the remaining values.
455          if ((value = values[i]) != null && min > value) {
456            min = value;
457          }
458        }
459      }
460    }
461  }
462
463  else {
464    while (++i < n) { // Find the first comparable value.
465      if ((value = valueof(values[i], i, values)) != null && value >= value) {
466        min = value;
467        while (++i < n) { // Compare the remaining values.
468          if ((value = valueof(values[i], i, values)) != null && min > value) {
469            min = value;
470          }
471        }
472      }
473    }
474  }
475
476  return min;
477}
478
479function permute(array, indexes) {
480  var i = indexes.length, permutes = new Array(i);
481  while (i--) permutes[i] = array[indexes[i]];
482  return permutes;
483}
484
485function scan(values, compare) {
486  if (!(n = values.length)) return;
487  var n,
488      i = 0,
489      j = 0,
490      xi,
491      xj = values[j];
492
493  if (compare == null) compare = ascending;
494
495  while (++i < n) {
496    if (compare(xi = values[i], xj) < 0 || compare(xj, xj) !== 0) {
497      xj = xi, j = i;
498    }
499  }
500
501  if (compare(xj, xj) === 0) return j;
502}
503
504function shuffle(array, i0, i1) {
505  var m = (i1 == null ? array.length : i1) - (i0 = i0 == null ? 0 : +i0),
506      t,
507      i;
508
509  while (m) {
510    i = Math.random() * m-- | 0;
511    t = array[m + i0];
512    array[m + i0] = array[i + i0];
513    array[i + i0] = t;
514  }
515
516  return array;
517}
518
519function sum(values, valueof) {
520  var n = values.length,
521      i = -1,
522      value,
523      sum = 0;
524
525  if (valueof == null) {
526    while (++i < n) {
527      if (value = +values[i]) sum += value; // Note: zero and null are equivalent.
528    }
529  }
530
531  else {
532    while (++i < n) {
533      if (value = +valueof(values[i], i, values)) sum += value;
534    }
535  }
536
537  return sum;
538}
539
540function transpose(matrix) {
541  if (!(n = matrix.length)) return [];
vendor: 6,412 bytes, lines 542-763
542  for (var i = -1, m = min(matrix, length), transpose = new Array(m); ++i < m;) {
543    for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) {
544      row[j] = matrix[j][i];
545    }
546  }
547  return transpose;
548}
549
550function length(d) {
551  return d.length;
552}
553
554function zip() {
555  return transpose(arguments);
556}
557
558var slice$1 = Array.prototype.slice;
559
560function identity$1(x) {
561  return x;
562}
563
564var top = 1,
565    right = 2,
566    bottom = 3,
567    left = 4,
568    epsilon = 1e-6;
569
570function translateX(x) {
571  return "translate(" + (x + 0.5) + ",0)";
572}
573
574function translateY(y) {
575  return "translate(0," + (y + 0.5) + ")";
576}
577
578function number$1(scale) {
579  return function(d) {
580    return +scale(d);
581  };
582}
583
584function center(scale) {
585  var offset = Math.max(0, scale.bandwidth() - 1) / 2; // Adjust for 0.5px offset.
586  if (scale.round()) offset = Math.round(offset);
587  return function(d) {
588    return +scale(d) + offset;
589  };
590}
591
592function entering() {
593  return !this.__axis;
594}
595
596function axis(orient, scale) {
597  var tickArguments = [],
598      tickValues = null,
599      tickFormat = null,
600      tickSizeInner = 6,
601      tickSizeOuter = 6,
602      tickPadding = 3,
603      k = orient === top || orient === left ? -1 : 1,
604      x = orient === left || orient === right ? "x" : "y",
605      transform = orient === top || orient === bottom ? translateX : translateY;
606
607  function axis(context) {
608    var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues,
609        format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$1) : tickFormat,
610        spacing = Math.max(tickSizeInner, 0) + tickPadding,
611        range = scale.range(),
612        range0 = +range[0] + 0.5,
613        range1 = +range[range.length - 1] + 0.5,
614        position = (scale.bandwidth ? center : number$1)(scale.copy()),
615        selection = context.selection ? context.selection() : context,
616        path = selection.selectAll(".domain").data([null]),
617        tick = selection.selectAll(".tick").data(values, scale).order(),
618        tickExit = tick.exit(),
619        tickEnter = tick.enter().append("g").attr("class", "tick"),
620        line = tick.select("line"),
621        text = tick.select("text");
622
623    path = path.merge(path.enter().insert("path", ".tick")
624        .attr("class", "domain")
625        .attr("stroke", "currentColor"));
626
627    tick = tick.merge(tickEnter);
628
629    line = line.merge(tickEnter.append("line")
630        .attr("stroke", "currentColor")
631        .attr(x + "2", k * tickSizeInner));
632
633    text = text.merge(tickEnter.append("text")
634        .attr("fill", "currentColor")
635        .attr(x, k * spacing)
636        .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em"));
637
638    if (context !== selection) {
639      path = path.transition(context);
640      tick = tick.transition(context);
641      line = line.transition(context);
642      text = text.transition(context);
643
644      tickExit = tickExit.transition(context)
645          .attr("opacity", epsilon)
646          .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d) : this.getAttribute("transform"); });
647
648      tickEnter
649          .attr("opacity", epsilon)
650          .attr("transform", function(d) { var p = this.parentNode.__axis; return transform(p && isFinite(p = p(d)) ? p : position(d)); });
651    }
652
653    tickExit.remove();
654
655    path
656        .attr("d", orient === left || orient == right
657            ? (tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H0.5V" + range1 + "H" + k * tickSizeOuter : "M0.5," + range0 + "V" + range1)
658            : (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V0.5H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + ",0.5H" + range1));
659
660    tick
661        .attr("opacity", 1)
662        .attr("transform", function(d) { return transform(position(d)); });
663
664    line
665        .attr(x + "2", k * tickSizeInner);
666
667    text
668        .attr(x, k * spacing)
669        .text(format);
670
671    selection.filter(entering)
672        .attr("fill", "none")
673        .attr("font-size", 10)
674        .attr("font-family", "sans-serif")
675        .attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle");
676
677    selection
678        .each(function() { this.__axis = position; });
679  }
680
681  axis.scale = function(_) {
682    return arguments.length ? (scale = _, axis) : scale;
683  };
684
685  axis.ticks = function() {
686    return tickArguments = slice$1.call(arguments), axis;
687  };
688
689  axis.tickArguments = function(_) {
690    return arguments.length ? (tickArguments = _ == null ? [] : slice$1.call(_), axis) : tickArguments.slice();
691  };
692
693  axis.tickValues = function(_) {
694    return arguments.length ? (tickValues = _ == null ? null : slice$1.call(_), axis) : tickValues && tickValues.slice();
695  };
696
697  axis.tickFormat = function(_) {
698    return arguments.length ? (tickFormat = _, axis) : tickFormat;
699  };
700
701  axis.tickSize = function(_) {
702    return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner;
703  };
704
705  axis.tickSizeInner = function(_) {
706    return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner;
707  };
708
709  axis.tickSizeOuter = function(_) {
710    return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter;
711  };
712
713  axis.tickPadding = function(_) {
714    return arguments.length ? (tickPadding = +_, axis) : tickPadding;
715  };
716
717  return axis;
718}
719
720function axisTop(scale) {
721  return axis(top, scale);
722}
723
724function axisRight(scale) {
725  return axis(right, scale);
726}
727
728function axisBottom(scale) {
729  return axis(bottom, scale);
730}
731
732function axisLeft(scale) {
733  return axis(left, scale);
734}
735
736var noop = {value: function() {}};
737
738function dispatch() {
739  for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
740    if (!(t = arguments[i] + "") || (t in _) || /[\s.]/.test(t)) throw new Error("illegal type: " + t);
741    _[t] = [];
742  }
743  return new Dispatch(_);
744}
745
746function Dispatch(_) {
747  this._ = _;
748}
749
750function parseTypenames(typenames, types) {
751  return typenames.trim().split(/^|\s+/).map(function(t) {
752    var name = "", i = t.indexOf(".");
753    if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
754    if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t);
755    return {type: t, name: name};
756  });
757}
758
759Dispatch.prototype = dispatch.prototype = {
760  constructor: Dispatch,
761  on: function(typename, callback) {
762    var _ = this._,
763        T = parseTypenames(typename + "", _),
vendor: 7,890 bytes, lines 764-1029
764        t,
765        i = -1,
766        n = T.length;
767
768    // If no callback was specified, return the callback of the given type and name.
769    if (arguments.length < 2) {
770      while (++i < n) if ((t = (typename = T[i]).type) && (t = get(_[t], typename.name))) return t;
771      return;
772    }
773
774    // If a type was specified, set the callback for the given type and name.
775    // Otherwise, if a null callback was specified, remove callbacks of the given name.
776    if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
777    while (++i < n) {
778      if (t = (typename = T[i]).type) _[t] = set(_[t], typename.name, callback);
779      else if (callback == null) for (t in _) _[t] = set(_[t], typename.name, null);
780    }
781
782    return this;
783  },
784  copy: function() {
785    var copy = {}, _ = this._;
786    for (var t in _) copy[t] = _[t].slice();
787    return new Dispatch(copy);
788  },
789  call: function(type, that) {
790    if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
791    if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
792    for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
793  },
794  apply: function(type, that, args) {
795    if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
796    for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
797  }
798};
799
800function get(type, name) {
801  for (var i = 0, n = type.length, c; i < n; ++i) {
802    if ((c = type[i]).name === name) {
803      return c.value;
804    }
805  }
806}
807
808function set(type, name, callback) {
809  for (var i = 0, n = type.length; i < n; ++i) {
810    if (type[i].name === name) {
811      type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
812      break;
813    }
814  }
815  if (callback != null) type.push({name: name, value: callback});
816  return type;
817}
818
819var xhtml = "http://www.w3.org/1999/xhtml";
820
821var namespaces = {
822  svg: "http://www.w3.org/2000/svg",
823  xhtml: xhtml,
824  xlink: "http://www.w3.org/1999/xlink",
825  xml: "http://www.w3.org/XML/1998/namespace",
826  xmlns: "http://www.w3.org/2000/xmlns/"
827};
828
829function namespace(name) {
830  var prefix = name += "", i = prefix.indexOf(":");
831  if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1);
832  return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name;
833}
834
835function creatorInherit(name) {
836  return function() {
837    var document = this.ownerDocument,
838        uri = this.namespaceURI;
839    return uri === xhtml && document.documentElement.namespaceURI === xhtml
840        ? document.createElement(name)
841        : document.createElementNS(uri, name);
842  };
843}
844
845function creatorFixed(fullname) {
846  return function() {
847    return this.ownerDocument.createElementNS(fullname.space, fullname.local);
848  };
849}
850
851function creator(name) {
852  var fullname = namespace(name);
853  return (fullname.local
854      ? creatorFixed
855      : creatorInherit)(fullname);
856}
857
858function none() {}
859
860function selector(selector) {
861  return selector == null ? none : function() {
862    return this.querySelector(selector);
863  };
864}
865
866function selection_select(select) {
867  if (typeof select !== "function") select = selector(select);
868
869  for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
870    for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
871      if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
872        if ("__data__" in node) subnode.__data__ = node.__data__;
873        subgroup[i] = subnode;
874      }
875    }
876  }
877
878  return new Selection(subgroups, this._parents);
879}
880
881function empty() {
882  return [];
883}
884
885function selectorAll(selector) {
886  return selector == null ? empty : function() {
887    return this.querySelectorAll(selector);
888  };
889}
890
891function selection_selectAll(select) {
892  if (typeof select !== "function") select = selectorAll(select);
893
894  for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
895    for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
896      if (node = group[i]) {
897        subgroups.push(select.call(node, node.__data__, i, group));
898        parents.push(node);
899      }
900    }
901  }
902
903  return new Selection(subgroups, parents);
904}
905
906function matcher(selector) {
907  return function() {
908    return this.matches(selector);
909  };
910}
911
912function selection_filter(match) {
913  if (typeof match !== "function") match = matcher(match);
914
915  for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
916    for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
917      if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
918        subgroup.push(node);
919      }
920    }
921  }
922
923  return new Selection(subgroups, this._parents);
924}
925
926function sparse(update) {
927  return new Array(update.length);
928}
929
930function selection_enter() {
931  return new Selection(this._enter || this._groups.map(sparse), this._parents);
932}
933
934function EnterNode(parent, datum) {
935  this.ownerDocument = parent.ownerDocument;
936  this.namespaceURI = parent.namespaceURI;
937  this._next = null;
938  this._parent = parent;
939  this.__data__ = datum;
940}
941
942EnterNode.prototype = {
943  constructor: EnterNode,
944  appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
945  insertBefore: function(child, next) { return this._parent.insertBefore(child, next); },
946  querySelector: function(selector) { return this._parent.querySelector(selector); },
947  querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); }
948};
949
950function constant$1(x) {
951  return function() {
952    return x;
953  };
954}
955
956var keyPrefix = "$"; // Protect against keys like “__proto__”.
957
958function bindIndex(parent, group, enter, update, exit, data) {
959  var i = 0,
960      node,
961      groupLength = group.length,
962      dataLength = data.length;
963
964  // Put any non-null nodes that fit into update.
965  // Put any null nodes into enter.
966  // Put any remaining data into enter.
967  for (; i < dataLength; ++i) {
968    if (node = group[i]) {
969      node.__data__ = data[i];
970      update[i] = node;
971    } else {
972      enter[i] = new EnterNode(parent, data[i]);
973    }
974  }
975
976  // Put any non-null nodes that don’t fit into exit.
977  for (; i < groupLength; ++i) {
978    if (node = group[i]) {
979      exit[i] = node;
980    }
981  }
982}
983
984function bindKey(parent, group, enter, update, exit, data, key) {
985  var i,
986      node,
987      nodeByKeyValue = {},
988      groupLength = group.length,
989      dataLength = data.length,
990      keyValues = new Array(groupLength),
991      keyValue;
992
993  // Compute the key for each node.
994  // If multiple nodes have the same key, the duplicates are added to exit.
995  for (i = 0; i < groupLength; ++i) {
996    if (node = group[i]) {
997      keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, group);
998      if (keyValue in nodeByKeyValue) {
999        exit[i] = node;
1000      } else {
1001        nodeByKeyValue[keyValue] = node;
1002      }
1003    }
1004  }
1005
1006  // Compute the key for each datum.
1007  // If there a node associated with this key, join and add it to update.
1008  // If there is not (or the key is a duplicate), add it to enter.
1009  for (i = 0; i < dataLength; ++i) {
1010    keyValue = keyPrefix + key.call(parent, data[i], i, data);
1011    if (node = nodeByKeyValue[keyValue]) {
1012      update[i] = node;
1013      node.__data__ = data[i];
1014      nodeByKeyValue[keyValue] = null;
1015    } else {
1016      enter[i] = new EnterNode(parent, data[i]);
1017    }
1018  }
1019
1020  // Add any remaining nodes that were not bound to data to exit.
1021  for (i = 0; i < groupLength; ++i) {
1022    if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) {
1023      exit[i] = node;
1024    }
1025  }
1026}
1027
1028function selection_data(value, key) {
1029  if (!value) {
vendor: 4,090 bytes, lines 1030-1164
1030    data = new Array(this.size()), j = -1;
1031    this.each(function(d) { data[++j] = d; });
1032    return data;
1033  }
1034
1035  var bind = key ? bindKey : bindIndex,
1036      parents = this._parents,
1037      groups = this._groups;
1038
1039  if (typeof value !== "function") value = constant$1(value);
1040
1041  for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
1042    var parent = parents[j],
1043        group = groups[j],
1044        groupLength = group.length,
1045        data = value.call(parent, parent && parent.__data__, j, parents),
1046        dataLength = data.length,
1047        enterGroup = enter[j] = new Array(dataLength),
1048        updateGroup = update[j] = new Array(dataLength),
1049        exitGroup = exit[j] = new Array(groupLength);
1050
1051    bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
1052
1053    // Now connect the enter nodes to their following update node, such that
1054    // appendChild can insert the materialized enter node before this node,
1055    // rather than at the end of the parent node.
1056    for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
1057      if (previous = enterGroup[i0]) {
1058        if (i0 >= i1) i1 = i0 + 1;
1059        while (!(next = updateGroup[i1]) && ++i1 < dataLength);
1060        previous._next = next || null;
1061      }
1062    }
1063  }
1064
1065  update = new Selection(update, parents);
1066  update._enter = enter;
1067  update._exit = exit;
1068  return update;
1069}
1070
1071function selection_exit() {
1072  return new Selection(this._exit || this._groups.map(sparse), this._parents);
1073}
1074
1075function selection_join(onenter, onupdate, onexit) {
1076  var enter = this.enter(), update = this, exit = this.exit();
1077  enter = typeof onenter === "function" ? onenter(enter) : enter.append(onenter + "");
1078  if (onupdate != null) update = onupdate(update);
1079  if (onexit == null) exit.remove(); else onexit(exit);
1080  return enter && update ? enter.merge(update).order() : update;
1081}
1082
1083function selection_merge(selection) {
1084
1085  for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
1086    for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
1087      if (node = group0[i] || group1[i]) {
1088        merge[i] = node;
1089      }
1090    }
1091  }
1092
1093  for (; j < m0; ++j) {
1094    merges[j] = groups0[j];
1095  }
1096
1097  return new Selection(merges, this._parents);
1098}
1099
1100function selection_order() {
1101
1102  for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) {
1103    for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
1104      if (node = group[i]) {
1105        if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next);
1106        next = node;
1107      }
1108    }
1109  }
1110
1111  return this;
1112}
1113
1114function selection_sort(compare) {
1115  if (!compare) compare = ascending$1;
1116
1117  function compareNode(a, b) {
1118    return a && b ? compare(a.__data__, b.__data__) : !a - !b;
1119  }
1120
1121  for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {
1122    for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {
1123      if (node = group[i]) {
1124        sortgroup[i] = node;
1125      }
1126    }
1127    sortgroup.sort(compareNode);
1128  }
1129
1130  return new Selection(sortgroups, this._parents).order();
1131}
1132
1133function ascending$1(a, b) {
1134  return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
1135}
1136
1137function selection_call() {
1138  var callback = arguments[0];
1139  arguments[0] = this;
1140  callback.apply(null, arguments);
1141  return this;
1142}
1143
1144function selection_nodes() {
1145  var nodes = new Array(this.size()), i = -1;
1146  this.each(function() { nodes[++i] = this; });
1147  return nodes;
1148}
1149
1150function selection_node() {
1151
1152  for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
1153    for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {
1154      var node = group[i];
1155      if (node) return node;
1156    }
1157  }
1158
1159  return null;
1160}
1161
1162function selection_size() {
1163  var size = 0;
1164  this.each(function() { ++size; });
vendor: 8,004 bytes, lines 1164-1499
1164
1165  return size;
1166}
1167
1168function selection_empty() {
1169  return !this.node();
1170}
1171
1172function selection_each(callback) {
1173
1174  for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
1175    for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
1176      if (node = group[i]) callback.call(node, node.__data__, i, group);
1177    }
1178  }
1179
1180  return this;
1181}
1182
1183function attrRemove(name) {
1184  return function() {
1185    this.removeAttribute(name);
1186  };
1187}
1188
1189function attrRemoveNS(fullname) {
1190  return function() {
1191    this.removeAttributeNS(fullname.space, fullname.local);
1192  };
1193}
1194
1195function attrConstant(name, value) {
1196  return function() {
1197    this.setAttribute(name, value);
1198  };
1199}
1200
1201function attrConstantNS(fullname, value) {
1202  return function() {
1203    this.setAttributeNS(fullname.space, fullname.local, value);
1204  };
1205}
1206
1207function attrFunction(name, value) {
1208  return function() {
1209    var v = value.apply(this, arguments);
1210    if (v == null) this.removeAttribute(name);
1211    else this.setAttribute(name, v);
1212  };
1213}
1214
1215function attrFunctionNS(fullname, value) {
1216  return function() {
1217    var v = value.apply(this, arguments);
1218    if (v == null) this.removeAttributeNS(fullname.space, fullname.local);
1219    else this.setAttributeNS(fullname.space, fullname.local, v);
1220  };
1221}
1222
1223function selection_attr(name, value) {
1224  var fullname = namespace(name);
1225
1226  if (arguments.length < 2) {
1227    var node = this.node();
1228    return fullname.local
1229        ? node.getAttributeNS(fullname.space, fullname.local)
1230        : node.getAttribute(fullname);
1231  }
1232
1233  return this.each((value == null
1234      ? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
1235      ? (fullname.local ? attrFunctionNS : attrFunction)
1236      : (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
1237}
1238
1239function defaultView(node) {
1240  return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
1241      || (node.document && node) // node is a Window
1242      || node.defaultView; // node is a Document
1243}
1244
1245function styleRemove(name) {
1246  return function() {
1247    this.style.removeProperty(name);
1248  };
1249}
1250
1251function styleConstant(name, value, priority) {
1252  return function() {
1253    this.style.setProperty(name, value, priority);
1254  };
1255}
1256
1257function styleFunction(name, value, priority) {
1258  return function() {
1259    var v = value.apply(this, arguments);
1260    if (v == null) this.style.removeProperty(name);
1261    else this.style.setProperty(name, v, priority);
1262  };
1263}
1264
1265function selection_style(name, value, priority) {
1266  return arguments.length > 1
1267      ? this.each((value == null
1268            ? styleRemove : typeof value === "function"
1269            ? styleFunction
1270            : styleConstant)(name, value, priority == null ? "" : priority))
1271      : styleValue(this.node(), name);
1272}
1273
1274function styleValue(node, name) {
1275  return node.style.getPropertyValue(name)
1276      || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
1277}
1278
1279function propertyRemove(name) {
1280  return function() {
1281    delete this[name];
1282  };
1283}
1284
1285function propertyConstant(name, value) {
1286  return function() {
1287    this[name] = value;
1288  };
1289}
1290
1291function propertyFunction(name, value) {
1292  return function() {
1293    var v = value.apply(this, arguments);
1294    if (v == null) delete this[name];
1295    else this[name] = v;
1296  };
1297}
1298
1299function selection_property(name, value) {
1300  return arguments.length > 1
1301      ? this.each((value == null
1302          ? propertyRemove : typeof value === "function"
1303          ? propertyFunction
1304          : propertyConstant)(name, value))
1305      : this.node()[name];
1306}
1307
1308function classArray(string) {
1309  return string.trim().split(/^|\s+/);
1310}
1311
1312function classList(node) {
1313  return node.classList || new ClassList(node);
1314}
1315
1316function ClassList(node) {
1317  this._node = node;
1318  this._names = classArray(node.getAttribute("class") || "");
1319}
1320
1321ClassList.prototype = {
1322  add: function(name) {
1323    var i = this._names.indexOf(name);
1324    if (i < 0) {
1325      this._names.push(name);
1326      this._node.setAttribute("class", this._names.join(" "));
1327    }
1328  },
1329  remove: function(name) {
1330    var i = this._names.indexOf(name);
1331    if (i >= 0) {
1332      this._names.splice(i, 1);
1333      this._node.setAttribute("class", this._names.join(" "));
1334    }
1335  },
1336  contains: function(name) {
1337    return this._names.indexOf(name) >= 0;
1338  }
1339};
1340
1341function classedAdd(node, names) {
1342  var list = classList(node), i = -1, n = names.length;
1343  while (++i < n) list.add(names[i]);
1344}
1345
1346function classedRemove(node, names) {
1347  var list = classList(node), i = -1, n = names.length;
1348  while (++i < n) list.remove(names[i]);
1349}
1350
1351function classedTrue(names) {
1352  return function() {
1353    classedAdd(this, names);
1354  };
1355}
1356
1357function classedFalse(names) {
1358  return function() {
1359    classedRemove(this, names);
1360  };
1361}
1362
1363function classedFunction(names, value) {
1364  return function() {
1365    (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
1366  };
1367}
1368
1369function selection_classed(name, value) {
1370  var names = classArray(name + "");
1371
1372  if (arguments.length < 2) {
1373    var list = classList(this.node()), i = -1, n = names.length;
1374    while (++i < n) if (!list.contains(names[i])) return false;
1375    return true;
1376  }
1377
1378  return this.each((typeof value === "function"
1379      ? classedFunction : value
1380      ? classedTrue
1381      : classedFalse)(names, value));
1382}
1383
1384function textRemove() {
1385  this.textContent = "";
1386}
1387
1388function textConstant(value) {
1389  return function() {
1390    this.textContent = value;
1391  };
1392}
1393
1394function textFunction(value) {
1395  return function() {
1396    var v = value.apply(this, arguments);
1397    this.textContent = v == null ? "" : v;
1398  };
1399}
1400
1401function selection_text(value) {
1402  return arguments.length
1403      ? this.each(value == null
1404          ? textRemove : (typeof value === "function"
1405          ? textFunction
1406          : textConstant)(value))
1407      : this.node().textContent;
1408}
1409
1410function htmlRemove() {
1411  this.innerHTML = "";
1412}
1413
1414function htmlConstant(value) {
1415  return function() {
1416    this.innerHTML = value;
1417  };
1418}
1419
1420function htmlFunction(value) {
1421  return function() {
1422    var v = value.apply(this, arguments);
1423    this.innerHTML = v == null ? "" : v;
1424  };
1425}
1426
1427function selection_html(value) {
1428  return arguments.length
1429      ? this.each(value == null
1430          ? htmlRemove : (typeof value === "function"
1431          ? htmlFunction
1432          : htmlConstant)(value))
1433      : this.node().innerHTML;
1434}
1435
1436function raise() {
1437  if (this.nextSibling) this.parentNode.appendChild(this);
1438}
1439
1440function selection_raise() {
1441  return this.each(raise);
1442}
1443
1444function lower() {
1445  if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
1446}
1447
1448function selection_lower() {
1449  return this.each(lower);
1450}
1451
1452function selection_append(name) {
1453  var create = typeof name === "function" ? name : creator(name);
1454  return this.select(function() {
1455    return this.appendChild(create.apply(this, arguments));
1456  });
1457}
1458
1459function constantNull() {
1460  return null;
1461}
1462
1463function selection_insert(name, before) {
1464  var create = typeof name === "function" ? name : creator(name),
1465      select = before == null ? constantNull : typeof before === "function" ? before : selector(before);
1466  return this.select(function() {
1467    return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
1468  });
1469}
1470
1471function remove() {
1472  var parent = this.parentNode;
1473  if (parent) parent.removeChild(this);
1474}
1475
1476function selection_remove() {
1477  return this.each(remove);
1478}
1479
1480function selection_cloneShallow() {
1481  var clone = this.cloneNode(false), parent = this.parentNode;
1482  return parent ? parent.insertBefore(clone, this.nextSibling) : clone;
1483}
1484
1485function selection_cloneDeep() {
1486  var clone = this.cloneNode(true), parent = this.parentNode;
1487  return parent ? parent.insertBefore(clone, this.nextSibling) : clone;
1488}
1489
1490function selection_clone(deep) {
1491  return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
1492}
1493
1494function selection_datum(value) {
1495  return arguments.length
1496      ? this.property("__data__", value)
1497      : this.node().__data__;
1498}
1499
vendor: 2,836 bytes, lines 1500-1592
1500var filterEvents = {};
1501
1502exports.event = null;
1503
1504if (typeof document !== "undefined") {
1505  var element = document.documentElement;
1506  if (!("onmouseenter" in element)) {
1507    filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"};
1508  }
1509}
1510
1511function filterContextListener(listener, index, group) {
1512  listener = contextListener(listener, index, group);
1513  return function(event) {
1514    var related = event.relatedTarget;
1515    if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
1516      listener.call(this, event);
1517    }
1518  };
1519}
1520
1521function contextListener(listener, index, group) {
1522  return function(event1) {
1523    var event0 = exports.event; // Events can be reentrant (e.g., focus).
1524    exports.event = event1;
1525    try {
1526      listener.call(this, this.__data__, index, group);
1527    } finally {
1528      exports.event = event0;
1529    }
1530  };
1531}
1532
1533function parseTypenames$1(typenames) {
1534  return typenames.trim().split(/^|\s+/).map(function(t) {
1535    var name = "", i = t.indexOf(".");
1536    if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
1537    return {type: t, name: name};
1538  });
1539}
1540
1541function onRemove(typename) {
1542  return function() {
1543    var on = this.__on;
1544    if (!on) return;
1545    for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {
1546      if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) {
1547        this.removeEventListener(o.type, o.listener, o.capture);
1548      } else {
1549        on[++i] = o;
1550      }
1551    }
1552    if (++i) on.length = i;
1553    else delete this.__on;
1554  };
1555}
1556
1557function onAdd(typename, value, capture) {
1558  var wrap = filterEvents.hasOwnProperty(typename.type) ? filterContextListener : contextListener;
1559  return function(d, i, group) {
1560    var on = this.__on, o, listener = wrap(value, i, group);
1561    if (on) for (var j = 0, m = on.length; j < m; ++j) {
1562      if ((o = on[j]).type === typename.type && o.name === typename.name) {
1563        this.removeEventListener(o.type, o.listener, o.capture);
1564        this.addEventListener(o.type, o.listener = listener, o.capture = capture);
1565        o.value = value;
1566        return;
1567      }
1568    }
1569    this.addEventListener(typename.type, listener, capture);
1570    o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture};
1571    if (!on) this.__on = [o];
1572    else on.push(o);
1573  };
1574}
1575
1576function selection_on(typename, value, capture) {
1577  var typenames = parseTypenames$1(typename + ""), i, n = typenames.length, t;
1578
1579  if (arguments.length < 2) {
1580    var on = this.node().__on;
1581    if (on) for (var j = 0, m = on.length, o; j < m; ++j) {
1582      for (i = 0, o = on[j]; i < n; ++i) {
1583        if ((t = typenames[i]).type === o.type && t.name === o.name) {
1584          return o.value;
1585        }
1586      }
1587    }
1588    return;
1589  }
1590
1591  on = value ? onAdd : onRemove;
1592  if (capture == null) capture = false;
1593  for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture));
1594  return this;
1595}
1596
1597function customEvent(event1, listener, that, args) {
1598  var event0 = exports.event;
1599  event1.sourceEvent = exports.event;
1600  exports.event = event1;
1601  try {
1602    return listener.apply(that, args);
1603  } finally {
1604    exports.event = event0;
1605  }
1606}
1607
1608function dispatchEvent(node, type, params) {
1609  var window = defaultView(node),
1610      event = window.CustomEvent;
1611
1612  if (typeof event === "function") {
1613    event = new event(type, params);
1614  } else {
1615    event = window.document.createEvent("Event");
1616    if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
1617    else event.initEvent(type, false, false);
1618  }
1619
1620  node.dispatchEvent(event);
1621}
1622
1623function dispatchConstant(type, params) {
1624  return function() {
1625    return dispatchEvent(this, type, params);
1626  };
1627}
1628
1629function dispatchFunction(type, params) {
1630  return function() {
1631    return dispatchEvent(this, type, params.apply(this, arguments));
1632  };
1633}
1634
1635function selection_dispatch(type, params) {
1636  return this.each((typeof params === "function"
1637      ? dispatchFunction
1638      : dispatchConstant)(type, params));
1639}
1640
1641var root = [null];
1642
1643function Selection(groups, parents) {
1644  this._groups = groups;
1645  this._parents = parents;
1646}
1647
1648function selection() {
1649  return new Selection([[document.documentElement]], root);
1650}
1651
1652Selection.prototype = selection.prototype = {
1653  constructor: Selection,
1654  select: selection_select,
1655  selectAll: selection_selectAll,
1656  filter: selection_filter,
1657  data: selection_data,
1658  enter: selection_enter,
1659  exit: selection_exit,
1660  join: selection_join,
1661  merge: selection_merge,
1662  order: selection_order,
1663  sort: selection_sort,
1664  call: selection_call,
1665  nodes: selection_nodes,
1666  node: selection_node,
1667  size: selection_size,
1668  empty: selection_empty,
1669  each: selection_each,
1670  attr: selection_attr,
1671  style: selection_style,
1672  property: selection_property,
1673  classed: selection_classed,
1674  text: selection_text,
1675  html: selection_html,
1676  raise: selection_raise,
1677  lower: selection_lower,
1678  append: selection_append,
1679  insert: selection_insert,
1680  remove: selection_remove,
1681  clone: selection_clone,
1682  datum: selection_datum,
1683  on: selection_on,
1684  dispatch: selection_dispatch
1685};
1686
1687function select(selector) {
1688  return typeof selector === "string"
1689      ? new Selection([[document.querySelector(selector)]], [document.documentElement])
1690      : new Selection([[selector]], root);
1691}
1692
1693function create(name) {
1694  return select(creator(name).call(document.documentElement));
1695}
1696
1697var nextId = 0;
1698
1699function local() {
1700  return new Local;
1701}
1702
1703function Local() {
1704  this._ = "@" + (++nextId).toString(36);
1705}
1706
1707Local.prototype = local.prototype = {
1708  constructor: Local,
1709  get: function(node) {
1710    var id = this._;
1711    while (!(id in node)) if (!(node = node.parentNode)) return;
1712    return node[id];
1713  },
1714  set: function(node, value) {
1715    return node[this._] = value;
1716  },
1717  remove: function(node) {
1718    return this._ in node && delete node[this._];
1719  },
1720  toString: function() {
1721    return this._;
1722  }
1723};
1724
1725function sourceEvent() {
1726  var current = exports.event, source;
1727  while (source = current.sourceEvent) current = source;
1728  return current;
1729}
1730
1731function point(node, event) {
1732  var svg = node.ownerSVGElement || node;
1733
1734  if (svg.createSVGPoint) {
1735    var point = svg.createSVGPoint();
1736    point.x = event.clientX, point.y = event.clientY;
1737    point = point.matrixTransform(node.getScreenCTM().inverse());
1738    return [point.x, point.y];
1739  }
1740
1741  var rect = node.getBoundingClientRect();
1742  return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
1743}
1744
1745function mouse(node) {
1746  var event = sourceEvent();
1747  if (event.changedTouches) event = event.changedTouches[0];
1748  return point(node, event);
1749}
1750
1751function selectAll(selector) {
1752  return typeof selector === "string"
1753      ? new Selection([document.querySelectorAll(selector)], [document.documentElement])
1754      : new Selection([selector == null ? [] : selector], root);
1755}
1756
1757function touch(node, touches, identifier) {
1758  if (arguments.length < 3) identifier = touches, touches = sourceEvent().changedTouches;
1759
1760  for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) {
1761    if ((touch = touches[i]).identifier === identifier) {
1762      return point(node, touch);
1763    }
1764  }
1765
1766  return null;
1767}
1768
1769function touches(node, touches) {
1770  if (touches == null) touches = sourceEvent().touches;
1771
1772  for (var i = 0, n = touches ? touches.length : 0, points = new Array(n); i < n; ++i) {
1773    points[i] = point(node, touches[i]);
1774  }
1775
1776  return points;
1777}
1778
1779function nopropagation() {
1780  exports.event.stopImmediatePropagation();
1781}
1782
1783function noevent() {
1784  exports.event.preventDefault();
1785  exports.event.stopImmediatePropagation();
1786}
1787
1788function dragDisable(view) {
1789  var root = view.document.documentElement,
1790      selection = select(view).on("dragstart.drag", noevent, true);
1791  if ("onselectstart" in root) {
1792    selection.on("selectstart.drag", noevent, true);
1793  } else {
1794    root.__noselect = root.style.MozUserSelect;
1795    root.style.MozUserSelect = "none";
1796  }
1797}
1798
1799function yesdrag(view, noclick) {
1800  var root = view.document.documentElement,
1801      selection = select(view).on("dragstart.drag", null);
1802  if (noclick) {
1803    selection.on("click.drag", noevent, true);
1804    setTimeout(function() { selection.on("click.drag", null); }, 0);
1805  }
1806  if ("onselectstart" in root) {
1807    selection.on("selectstart.drag", null);
1808  } else {
1809    root.style.MozUserSelect = root.__noselect;
1810    delete root.__noselect;
1811  }
1812}
1813
1814function constant$2(x) {
1815  return function() {
1816    return x;
1817  };
1818}
1819
1820function DragEvent(target, type, subject, id, active, x, y, dx, dy, dispatch) {
1821  this.target = target;
1822  this.type = type;
1823  this.subject = subject;
1824  this.identifier = id;
1825  this.active = active;
1826  this.x = x;
1827  this.y = y;
1828  this.dx = dx;
1829  this.dy = dy;
1830  this._ = dispatch;
1831}
1832
1833DragEvent.prototype.on = function() {
1834  var value = this._.on.apply(this._, arguments);
1835  return value === this._ ? this : value;
1836};
1837
1838// Ignore right-click, since that should open the context menu.
1839function defaultFilter() {
1840  return !exports.event.ctrlKey && !exports.event.button;
1841}
1842
1843function defaultContainer() {
1844  return this.parentNode;
1845}
1846
1847function defaultSubject(d) {
1848  return d == null ? {x: exports.event.x, y: exports.event.y} : d;
1849}
1850
1851function defaultTouchable() {
1852  return navigator.maxTouchPoints || ("ontouchstart" in this);
1853}
1854
1855function drag() {
1856  var filter = defaultFilter,
1857      container = defaultContainer,
1858      subject = defaultSubject,
1859      touchable = defaultTouchable,
1860      gestures = {},
1861      listeners = dispatch("start", "drag", "end"),
1862      active = 0,
1863      mousedownx,
1864      mousedowny,
1865      mousemoving,
1866      touchending,
1867      clickDistance2 = 0;
1868
1869  function drag(selection) {
1870    selection
1871        .on("mousedown.drag", mousedowned)
1872      .filter(touchable)
1873        .on("touchstart.drag", touchstarted)
1874        .on("touchmove.drag", touchmoved)
1875        .on("touchend.drag touchcancel.drag", touchended)
1876        .style("touch-action", "none")
1877        .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
1878  }
1879
1880  function mousedowned() {
1881    if (touchending || !filter.apply(this, arguments)) return;
1882    var gesture = beforestart("mouse", container.apply(this, arguments), mouse, this, arguments);
1883    if (!gesture) return;
1884    select(exports.event.view).on("mousemove.drag", mousemoved, true).on("mouseup.drag", mouseupped, true);
1885    dragDisable(exports.event.view);
1886    nopropagation();
1887    mousemoving = false;
1888    mousedownx = exports.event.clientX;
1889    mousedowny = exports.event.clientY;
1890    gesture("start");
1891  }
1892
1893  function mousemoved() {
1894    noevent();
1895    if (!mousemoving) {
1896      var dx = exports.event.clientX - mousedownx, dy = exports.event.clientY - mousedowny;
1897      mousemoving = dx * dx + dy * dy > clickDistance2;
1898    }
1899    gestures.mouse("drag");
1900  }
1901
1902  function mouseupped() {
1903    select(exports.event.view).on("mousemove.drag mouseup.drag", null);
1904    yesdrag(exports.event.view, mousemoving);
1905    noevent();
1906    gestures.mouse("end");
1907  }
1908
1909  function touchstarted() {
1910    if (!filter.apply(this, arguments)) return;
1911    var touches = exports.event.changedTouches,
1912        c = container.apply(this, arguments),
1913        n = touches.length, i, gesture;
1914
1915    for (i = 0; i < n; ++i) {
1916      if (gesture = beforestart(touches[i].identifier, c, touch, this, arguments)) {
1917        nopropagation();
1918        gesture("start");
1919      }
1920    }
1921  }
1922
1923  function touchmoved() {
1924    var touches = exports.event.changedTouches,
1925        n = touches.length, i, gesture;
1926
1927    for (i = 0; i < n; ++i) {
1928      if (gesture = gestures[touches[i].identifier]) {
1929        noevent();
1930        gesture("drag");
1931      }
1932    }
1933  }
1934
1935  function touchended() {
1936    var touches = exports.event.changedTouches,
1937        n = touches.length, i, gesture;
1938
1939    if (touchending) clearTimeout(touchending);
1940    touchending = setTimeout(function() { touchending = null; }, 500); // Ghost clicks are delayed!
1941    for (i = 0; i < n; ++i) {
1942      if (gesture = gestures[touches[i].identifier]) {
1943        nopropagation();
1944        gesture("end");
1945      }
1946    }
1947  }
1948
1949  function beforestart(id, container, point, that, args) {
1950    var p = point(container, id), s, dx, dy,
1951        sublisteners = listeners.copy();
1952
1953    if (!customEvent(new DragEvent(drag, "beforestart", s, id, active, p[0], p[1], 0, 0, sublisteners), function() {
1954      if ((exports.event.subject = s = subject.apply(that, args)) == null) return false;
1955      dx = s.x - p[0] || 0;
1956      dy = s.y - p[1] || 0;
1957      return true;
1958    })) return;
1959
1960    return function gesture(type) {
1961      var p0 = p, n;
1962      switch (type) {
1963        case "start": gestures[id] = gesture, n = active++; break;
1964        case "end": delete gestures[id], --active; // nobreak
1965        case "drag": p = point(container, id), n = active; break;
1966      }
1967      customEvent(new DragEvent(drag, type, s, id, n, p[0] + dx, p[1] + dy, p[0] - p0[0], p[1] - p0[1], sublisteners), sublisteners.apply, sublisteners, [type, that, args]);
1968    };
1969  }
1970
1971  drag.filter = function(_) {
1972    return arguments.length ? (filter = typeof _ === "function" ? _ : constant$2(!!_), drag) : filter;
1973  };
1974
1975  drag.container = function(_) {
1976    return arguments.length ? (container = typeof _ === "function" ? _ : constant$2(_), drag) : container;
1977  };
1978
1979  drag.subject = function(_) {
1980    return arguments.length ? (subject = typeof _ === "function" ? _ : constant$2(_), drag) : subject;
1981  };
1982
1983  drag.touchable = function(_) {
1984    return arguments.length ? (touchable = typeof _ === "function" ? _ : constant$2(!!_), drag) : touchable;
1985  };
1986
1987  drag.on = function() {
1988    var value = listeners.on.apply(listeners, arguments);
1989    return value === listeners ? drag : value;
1990  };
1991
1992  drag.clickDistance = function(_) {
1993    return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
1994  };
1995
1996  return drag
vendor: 10,883 bytes, lines 1996-2379
1996;
1997}
1998
1999function define(constructor, factory, prototype) {
2000  constructor.prototype = factory.prototype = prototype;
2001  prototype.constructor = constructor;
2002}
2003
2004function extend(parent, definition) {
2005  var prototype = Object.create(parent.prototype);
2006  for (var key in definition) prototype[key] = definition[key];
2007  return prototype;
2008}
2009
2010function Color() {}
2011
2012var darker = 0.7;
2013var brighter = 1 / darker;
2014
2015var reI = "\\s*([+-]?\\d+)\\s*",
2016    reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
2017    reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
2018    reHex = /^#([0-9a-f]{3,8})$/,
2019    reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"),
2020    reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"),
2021    reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"),
2022    reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"),
2023    reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"),
2024    reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
2025
2026var named = {
2027  aliceblue: 0xf0f8ff,
2028  antiquewhite: 0xfaebd7,
2029  aqua: 0x00ffff,
2030  aquamarine: 0x7fffd4,
2031  azure: 0xf0ffff,
2032  beige: 0xf5f5dc,
2033  bisque: 0xffe4c4,
2034  black: 0x000000,
2035  blanchedalmond: 0xffebcd,
2036  blue: 0x0000ff,
2037  blueviolet: 0x8a2be2,
2038  brown: 0xa52a2a,
2039  burlywood: 0xdeb887,
2040  cadetblue: 0x5f9ea0,
2041  chartreuse: 0x7fff00,
2042  chocolate: 0xd2691e,
2043  coral: 0xff7f50,
2044  cornflowerblue: 0x6495ed,
2045  cornsilk: 0xfff8dc,
2046  crimson: 0xdc143c,
2047  cyan: 0x00ffff,
2048  darkblue: 0x00008b,
2049  darkcyan: 0x008b8b,
2050  darkgoldenrod: 0xb8860b,
2051  darkgray: 0xa9a9a9,
2052  darkgreen: 0x006400,
2053  darkgrey: 0xa9a9a9,
2054  darkkhaki: 0xbdb76b,
2055  darkmagenta: 0x8b008b,
2056  darkolivegreen: 0x556b2f,
2057  darkorange: 0xff8c00,
2058  darkorchid: 0x9932cc,
2059  darkred: 0x8b0000,
2060  darksalmon: 0xe9967a,
2061  darkseagreen: 0x8fbc8f,
2062  darkslateblue: 0x483d8b,
2063  darkslategray: 0x2f4f4f,
2064  darkslategrey: 0x2f4f4f,
2065  darkturquoise: 0x00ced1,
2066  darkviolet: 0x9400d3,
2067  deeppink: 0xff1493,
2068  deepskyblue: 0x00bfff,
2069  dimgray: 0x696969,
2070  dimgrey: 0x696969,
2071  dodgerblue: 0x1e90ff,
2072  firebrick: 0xb22222,
2073  floralwhite: 0xfffaf0,
2074  forestgreen: 0x228b22,
2075  fuchsia: 0xff00ff,
2076  gainsboro: 0xdcdcdc,
2077  ghostwhite: 0xf8f8ff,
2078  gold: 0xffd700,
2079  goldenrod: 0xdaa520,
2080  gray: 0x808080,
2081  green: 0x008000,
2082  greenyellow: 0xadff2f,
2083  grey: 0x808080,
2084  honeydew: 0xf0fff0,
2085  hotpink: 0xff69b4,
2086  indianred: 0xcd5c5c,
2087  indigo: 0x4b0082,
2088  ivory: 0xfffff0,
2089  khaki: 0xf0e68c,
2090  lavender: 0xe6e6fa,
2091  lavenderblush: 0xfff0f5,
2092  lawngreen: 0x7cfc00,
2093  lemonchiffon: 0xfffacd,
2094  lightblue: 0xadd8e6,
2095  lightcoral: 0xf08080,
2096  lightcyan: 0xe0ffff,
2097  lightgoldenrodyellow: 0xfafad2,
2098  lightgray: 0xd3d3d3,
2099  lightgreen: 0x90ee90,
2100  lightgrey: 0xd3d3d3,
2101  lightpink: 0xffb6c1,
2102  lightsalmon: 0xffa07a,
2103  lightseagreen: 0x20b2aa,
2104  lightskyblue: 0x87cefa,
2105  lightslategray: 0x778899,
2106  lightslategrey: 0x778899,
2107  lightsteelblue: 0xb0c4de,
2108  lightyellow: 0xffffe0,
2109  lime: 0x00ff00,
2110  limegreen: 0x32cd32,
2111  linen: 0xfaf0e6,
2112  magenta: 0xff00ff,
2113  maroon: 0x800000,
2114  mediumaquamarine: 0x66cdaa,
2115  mediumblue: 0x0000cd,
2116  mediumorchid: 0xba55d3,
2117  mediumpurple: 0x9370db,
2118  mediumseagreen: 0x3cb371,
2119  mediumslateblue: 0x7b68ee,
2120  mediumspringgreen: 0x00fa9a,
2121  mediumturquoise: 0x48d1cc,
2122  mediumvioletred: 0xc71585,
2123  midnightblue: 0x191970,
2124  mintcream: 0xf5fffa,
2125  mistyrose: 0xffe4e1,
2126  moccasin: 0xffe4b5,
2127  navajowhite: 0xffdead,
2128  navy: 0x000080,
2129  oldlace: 0xfdf5e6,
2130  olive: 0x808000,
2131  olivedrab: 0x6b8e23,
2132  orange: 0xffa500,
2133  orangered: 0xff4500,
2134  orchid: 0xda70d6,
2135  palegoldenrod: 0xeee8aa,
2136  palegreen: 0x98fb98,
2137  paleturquoise: 0xafeeee,
2138  palevioletred: 0xdb7093,
2139  papayawhip: 0xffefd5,
2140  peachpuff: 0xffdab9,
2141  peru: 0xcd853f,
2142  pink: 0xffc0cb,
2143  plum: 0xdda0dd,
2144  powderblue: 0xb0e0e6,
2145  purple: 0x800080,
2146  rebeccapurple: 0x663399,
2147  red: 0xff0000,
2148  rosybrown: 0xbc8f8f,
2149  royalblue: 0x4169e1,
2150  saddlebrown: 0x8b4513,
2151  salmon: 0xfa8072,
2152  sandybrown: 0xf4a460,
2153  seagreen: 0x2e8b57,
2154  seashell: 0xfff5ee,
2155  sienna: 0xa0522d,
2156  silver: 0xc0c0c0,
2157  skyblue: 0x87ceeb,
2158  slateblue: 0x6a5acd,
2159  slategray: 0x708090,
2160  slategrey: 0x708090,
2161  snow: 0xfffafa,
2162  springgreen: 0x00ff7f,
2163  steelblue: 0x4682b4,
2164  tan: 0xd2b48c,
2165  teal: 0x008080,
2166  thistle: 0xd8bfd8,
2167  tomato: 0xff6347,
2168  turquoise: 0x40e0d0,
2169  violet: 0xee82ee,
2170  wheat: 0xf5deb3,
2171  white: 0xffffff,
2172  whitesmoke: 0xf5f5f5,
2173  yellow: 0xffff00,
2174  yellowgreen: 0x9acd32
2175};
2176
2177define(Color, color, {
2178  copy: function(channels) {
2179    return Object.assign(new this.constructor, this, channels);
2180  },
2181  displayable: function() {
2182    return this.rgb().displayable();
2183  },
2184  hex: color_formatHex, // Deprecated! Use color.formatHex.
2185  formatHex: color_formatHex,
2186  formatHsl: color_formatHsl,
2187  formatRgb: color_formatRgb,
2188  toString: color_formatRgb
2189});
2190
2191function color_formatHex() {
2192  return this.rgb().formatHex();
2193}
2194
2195function color_formatHsl() {
2196  return hslConvert(this).formatHsl();
2197}
2198
2199function color_formatRgb() {
2200  return this.rgb().formatRgb();
2201}
2202
2203function color(format) {
2204  var m, l;
2205  format = (format + "").trim().toLowerCase();
2206  return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
2207      : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
2208      : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
2209      : l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
2210      : null) // invalid hex
2211      : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
2212      : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
2213      : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
2214      : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
2215      : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
2216      : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
2217      : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
2218      : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
2219      : null;
2220}
2221
2222function rgbn(n) {
2223  return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
2224}
2225
2226function rgba(r, g, b, a) {
2227  if (a <= 0) r = g = b = NaN;
2228  return new Rgb(r, g, b, a);
2229}
2230
2231function rgbConvert(o) {
2232  if (!(o instanceof Color)) o = color(o);
2233  if (!o) return new Rgb;
2234  o = o.rgb();
2235  return new Rgb(o.r, o.g, o.b, o.opacity);
2236}
2237
2238function rgb(r, g, b, opacity) {
2239  return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
2240}
2241
2242function Rgb(r, g, b, opacity) {
2243  this.r = +r;
2244  this.g = +g;
2245  this.b = +b;
2246  this.opacity = +opacity;
2247}
2248
2249define(Rgb, rgb, extend(Color, {
2250  brighter: function(k) {
2251    k = k == null ? brighter : Math.pow(brighter, k);
2252    return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
2253  },
2254  darker: function(k) {
2255    k = k == null ? darker : Math.pow(darker, k);
2256    return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
2257  },
2258  rgb: function() {
2259    return this;
2260  },
2261  displayable: function() {
2262    return (-0.5 <= this.r && this.r < 255.5)
2263        && (-0.5 <= this.g && this.g < 255.5)
2264        && (-0.5 <= this.b && this.b < 255.5)
2265        && (0 <= this.opacity && this.opacity <= 1);
2266  },
2267  hex: rgb_formatHex, // Deprecated! Use color.formatHex.
2268  formatHex: rgb_formatHex,
2269  formatRgb: rgb_formatRgb,
2270  toString: rgb_formatRgb
2271}));
2272
2273function rgb_formatHex() {
2274  return "#" + hex(this.r) + hex(this.g) + hex(this.b);
2275}
2276
2277function rgb_formatRgb() {
2278  var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
2279  return (a === 1 ? "rgb(" : "rgba(")
2280      + Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", "
2281      + Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", "
2282      + Math.max(0, Math.min(255, Math.round(this.b) || 0))
2283      + (a === 1 ? ")" : ", " + a + ")");
2284}
2285
2286function hex(value) {
2287  value = Math.max(0, Math.min(255, Math.round(value) || 0));
2288  return (value < 16 ? "0" : "") + value.toString(16);
2289}
2290
2291function hsla(h, s, l, a) {
2292  if (a <= 0) h = s = l = NaN;
2293  else if (l <= 0 || l >= 1) h = s = NaN;
2294  else if (s <= 0) h = NaN;
2295  return new Hsl(h, s, l, a);
2296}
2297
2298function hslConvert(o) {
2299  if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
2300  if (!(o instanceof Color)) o = color(o);
2301  if (!o) return new Hsl;
2302  if (o instanceof Hsl) return o;
2303  o = o.rgb();
2304  var r = o.r / 255,
2305      g = o.g / 255,
2306      b = o.b / 255,
2307      min = Math.min(r, g, b),
2308      max = Math.max(r, g, b),
2309      h = NaN,
2310      s = max - min,
2311      l = (max + min) / 2;
2312  if (s) {
2313    if (r === max) h = (g - b) / s + (g < b) * 6;
2314    else if (g === max) h = (b - r) / s + 2;
2315    else h = (r - g) / s + 4;
2316    s /= l < 0.5 ? max + min : 2 - max - min;
2317    h *= 60;
2318  } else {
2319    s = l > 0 && l < 1 ? 0 : h;
2320  }
2321  return new Hsl(h, s, l, o.opacity);
2322}
2323
2324function hsl(h, s, l, opacity) {
2325  return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
2326}
2327
2328function Hsl(h, s, l, opacity) {
2329  this.h = +h;
2330  this.s = +s;
2331  this.l = +l;
2332  this.opacity = +opacity;
2333}
2334
2335define(Hsl, hsl, extend(Color, {
2336  brighter: function(k) {
2337    k = k == null ? brighter : Math.pow(brighter, k);
2338    return new Hsl(this.h, this.s, this.l * k, this.opacity);
2339  },
2340  darker: function(k) {
2341    k = k == null ? darker : Math.pow(darker, k);
2342    return new Hsl(this.h, this.s, this.l * k, this.opacity);
2343  },
2344  rgb: function() {
2345    var h = this.h % 360 + (this.h < 0) * 360,
2346        s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
2347        l = this.l,
2348        m2 = l + (l < 0.5 ? l : 1 - l) * s,
2349        m1 = 2 * l - m2;
2350    return new Rgb(
2351      hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
2352      hsl2rgb(h, m1, m2),
2353      hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
2354      this.opacity
2355    );
2356  },
2357  displayable: function() {
2358    return (0 <= this.s && this.s <= 1 || isNaN(this.s))
2359        && (0 <= this.l && this.l <= 1)
2360        && (0 <= this.opacity && this.opacity <= 1);
2361  },
2362  formatHsl: function() {
2363    var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
2364    return (a === 1 ? "hsl(" : "hsla(")
2365        + (this.h || 0) + ", "
2366        + (this.s || 0) * 100 + "%, "
2367        + (this.l || 0) * 100 + "%"
2368        + (a === 1 ? ")" : ", " + a + ")");
2369  }
2370}));
2371
2372/* From FvD 13.37, CSS Color Module Level 3 */
2373function hsl2rgb(h, m1, m2) {
2374  return (h < 60 ? m1 + (m2 - m1) * h / 60
2375      : h < 180 ? m2
2376      : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
2377      : m1) * 255;
2378}
2379
vendor: 58,515 bytes, lines 2380-4610
2380var deg2rad = Math.PI / 180;
2381var rad2deg = 180 / Math.PI;
2382
2383// https://observablehq.com/@mbostock/lab-and-rgb
2384var K = 18,
2385    Xn = 0.96422,
2386    Yn = 1,
2387    Zn = 0.82521,
2388    t0 = 4 / 29,
2389    t1 = 6 / 29,
2390    t2 = 3 * t1 * t1,
2391    t3 = t1 * t1 * t1;
2392
2393function labConvert(o) {
2394  if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
2395  if (o instanceof Hcl) return hcl2lab(o);
2396  if (!(o instanceof Rgb)) o = rgbConvert(o);
2397  var r = rgb2lrgb(o.r),
2398      g = rgb2lrgb(o.g),
2399      b = rgb2lrgb(o.b),
2400      y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z;
2401  if (r === g && g === b) x = z = y; else {
2402    x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
2403    z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
2404  }
2405  return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
2406}
2407
2408function gray(l, opacity) {
2409  return new Lab(l, 0, 0, opacity == null ? 1 : opacity);
2410}
2411
2412function lab(l, a, b, opacity) {
2413  return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
2414}
2415
2416function Lab(l, a, b, opacity) {
2417  this.l = +l;
2418  this.a = +a;
2419  this.b = +b;
2420  this.opacity = +opacity;
2421}
2422
2423define(Lab, lab, extend(Color, {
2424  brighter: function(k) {
2425    return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
2426  },
2427  darker: function(k) {
2428    return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
2429  },
2430  rgb: function() {
2431    var y = (this.l + 16) / 116,
2432        x = isNaN(this.a) ? y : y + this.a / 500,
2433        z = isNaN(this.b) ? y : y - this.b / 200;
2434    x = Xn * lab2xyz(x);
2435    y = Yn * lab2xyz(y);
2436    z = Zn * lab2xyz(z);
2437    return new Rgb(
2438      lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z),
2439      lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),
2440      lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z),
2441      this.opacity
2442    );
2443  }
2444}));
2445
2446function xyz2lab(t) {
2447  return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
2448}
2449
2450function lab2xyz(t) {
2451  return t > t1 ? t * t * t : t2 * (t - t0);
2452}
2453
2454function lrgb2rgb(x) {
2455  return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
2456}
2457
2458function rgb2lrgb(x) {
2459  return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
2460}
2461
2462function hclConvert(o) {
2463  if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
2464  if (!(o instanceof Lab)) o = labConvert(o);
2465  if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity);
2466  var h = Math.atan2(o.b, o.a) * rad2deg;
2467  return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
2468}
2469
2470function lch(l, c, h, opacity) {
2471  return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
2472}
2473
2474function hcl(h, c, l, opacity) {
2475  return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
2476}
2477
2478function Hcl(h, c, l, opacity) {
2479  this.h = +h;
2480  this.c = +c;
2481  this.l = +l;
2482  this.opacity = +opacity;
2483}
2484
2485function hcl2lab(o) {
2486  if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
2487  var h = o.h * deg2rad;
2488  return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
2489}
2490
2491define(Hcl, hcl, extend(Color, {
2492  brighter: function(k) {
2493    return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
2494  },
2495  darker: function(k) {
2496    return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
2497  },
2498  rgb: function() {
2499    return hcl2lab(this).rgb();
2500  }
2501}));
2502
2503var A = -0.14861,
2504    B = +1.78277,
2505    C = -0.29227,
2506    D = -0.90649,
2507    E = +1.97294,
2508    ED = E * D,
2509    EB = E * B,
2510    BC_DA = B * C - D * A;
2511
2512function cubehelixConvert(o) {
2513  if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
2514  if (!(o instanceof Rgb)) o = rgbConvert(o);
2515  var r = o.r / 255,
2516      g = o.g / 255,
2517      b = o.b / 255,
2518      l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
2519      bl = b - l,
2520      k = (E * (g - l) - C * bl) / D,
2521      s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
2522      h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN;
2523  return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
2524}
2525
2526function cubehelix(h, s, l, opacity) {
2527  return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
2528}
2529
2530function Cubehelix(h, s, l, opacity) {
2531  this.h = +h;
2532  this.s = +s;
2533  this.l = +l;
2534  this.opacity = +opacity;
2535}
2536
2537define(Cubehelix, cubehelix, extend(Color, {
2538  brighter: function(k) {
2539    k = k == null ? brighter : Math.pow(brighter, k);
2540    return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
2541  },
2542  darker: function(k) {
2543    k = k == null ? darker : Math.pow(darker, k);
2544    return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
2545  },
2546  rgb: function() {
2547    var h = isNaN(this.h) ? 0 : (this.h + 120) * deg2rad,
2548        l = +this.l,
2549        a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
2550        cosh = Math.cos(h),
2551        sinh = Math.sin(h);
2552    return new Rgb(
2553      255 * (l + a * (A * cosh + B * sinh)),
2554      255 * (l + a * (C * cosh + D * sinh)),
2555      255 * (l + a * (E * cosh)),
2556      this.opacity
2557    );
2558  }
2559}));
2560
2561function basis(t1, v0, v1, v2, v3) {
2562  var t2 = t1 * t1, t3 = t2 * t1;
2563  return ((1 - 3 * t1 + 3 * t2 - t3) * v0
2564      + (4 - 6 * t2 + 3 * t3) * v1
2565      + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2
2566      + t3 * v3) / 6;
2567}
2568
2569function basis$1(values) {
2570  var n = values.length - 1;
2571  return function(t) {
2572    var i = t <= 0 ? (t = 0) : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
2573        v1 = values[i],
2574        v2 = values[i + 1],
2575        v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
2576        v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
2577    return basis((t - i / n) * n, v0, v1, v2, v3);
2578  };
2579}
2580
2581function basisClosed(values) {
2582  var n = values.length;
2583  return function(t) {
2584    var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
2585        v0 = values[(i + n - 1) % n],
2586        v1 = values[i % n],
2587        v2 = values[(i + 1) % n],
2588        v3 = values[(i + 2) % n];
2589    return basis((t - i / n) * n, v0, v1, v2, v3);
2590  };
2591}
2592
2593function constant$3(x) {
2594  return function() {
2595    return x;
2596  };
2597}
2598
2599function linear(a, d) {
2600  return function(t) {
2601    return a + t * d;
2602  };
2603}
2604
2605function exponential(a, b, y) {
2606  return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
2607    return Math.pow(a + t * b, y);
2608  };
2609}
2610
2611function hue(a, b) {
2612  var d = b - a;
2613  return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$3(isNaN(a) ? b : a);
2614}
2615
2616function gamma(y) {
2617  return (y = +y) === 1 ? nogamma : function(a, b) {
2618    return b - a ? exponential(a, b, y) : constant$3(isNaN(a) ? b : a);
2619  };
2620}
2621
2622function nogamma(a, b) {
2623  var d = b - a;
2624  return d ? linear(a, d) : constant$3(isNaN(a) ? b : a);
2625}
2626
2627var interpolateRgb = (function rgbGamma(y) {
2628  var color = gamma(y);
2629
2630  function rgb$1(start, end) {
2631    var r = color((start = rgb(start)).r, (end = rgb(end)).r),
2632        g = color(start.g, end.g),
2633        b = color(start.b, end.b),
2634        opacity = nogamma(start.opacity, end.opacity);
2635    return function(t) {
2636      start.r = r(t);
2637      start.g = g(t);
2638      start.b = b(t);
2639      start.opacity = opacity(t);
2640      return start + "";
2641    };
2642  }
2643
2644  rgb$1.gamma = rgbGamma;
2645
2646  return rgb$1;
2647})(1);
2648
2649function rgbSpline(spline) {
2650  return function(colors) {
2651    var n = colors.length,
2652        r = new Array(n),
2653        g = new Array(n),
2654        b = new Array(n),
2655        i, color;
2656    for (i = 0; i < n; ++i) {
2657      color = rgb(colors[i]);
2658      r[i] = color.r || 0;
2659      g[i] = color.g || 0;
2660      b[i] = color.b || 0;
2661    }
2662    r = spline(r);
2663    g = spline(g);
2664    b = spline(b);
2665    color.opacity = 1;
2666    return function(t) {
2667      color.r = r(t);
2668      color.g = g(t);
2669      color.b = b(t);
2670      return color + "";
2671    };
2672  };
2673}
2674
2675var rgbBasis = rgbSpline(basis$1);
2676var rgbBasisClosed = rgbSpline(basisClosed);
2677
2678function numberArray(a, b) {
2679  if (!b) b = [];
2680  var n = a ? Math.min(b.length, a.length) : 0,
2681      c = b.slice(),
2682      i;
2683  return function(t) {
2684    for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
2685    return c;
2686  };
2687}
2688
2689function isNumberArray(x) {
2690  return ArrayBuffer.isView(x) && !(x instanceof DataView);
2691}
2692
2693function array$1(a, b) {
2694  return (isNumberArray(b) ? numberArray : genericArray)(a, b);
2695}
2696
2697function genericArray(a, b) {
2698  var nb = b ? b.length : 0,
2699      na = a ? Math.min(nb, a.length) : 0,
2700      x = new Array(na),
2701      c = new Array(nb),
2702      i;
2703
2704  for (i = 0; i < na; ++i) x[i] = interpolateValue(a[i], b[i]);
2705  for (; i < nb; ++i) c[i] = b[i];
2706
2707  return function(t) {
2708    for (i = 0; i < na; ++i) c[i] = x[i](t);
2709    return c;
2710  };
2711}
2712
2713function date(a, b) {
2714  var d = new Date;
2715  return a = +a, b = +b, function(t) {
2716    return d.setTime(a * (1 - t) + b * t), d;
2717  };
2718}
2719
2720function interpolateNumber(a, b) {
2721  return a = +a, b = +b, function(t) {
2722    return a * (1 - t) + b * t;
2723  };
2724}
2725
2726function object(a, b) {
2727  var i = {},
2728      c = {},
2729      k;
2730
2731  if (a === null || typeof a !== "object") a = {};
2732  if (b === null || typeof b !== "object") b = {};
2733
2734  for (k in b) {
2735    if (k in a) {
2736      i[k] = interpolateValue(a[k], b[k]);
2737    } else {
2738      c[k] = b[k];
2739    }
2740  }
2741
2742  return function(t) {
2743    for (k in i) c[k] = i[k](t);
2744    return c;
2745  };
2746}
2747
2748var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
2749    reB = new RegExp(reA.source, "g");
2750
2751function zero(b) {
2752  return function() {
2753    return b;
2754  };
2755}
2756
2757function one(b) {
2758  return function(t) {
2759    return b(t) + "";
2760  };
2761}
2762
2763function interpolateString(a, b) {
2764  var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
2765      am, // current match in a
2766      bm, // current match in b
2767      bs, // string preceding current number in b, if any
2768      i = -1, // index in s
2769      s = [], // string constants and placeholders
2770      q = []; // number interpolators
2771
2772  // Coerce inputs to strings.
2773  a = a + "", b = b + "";
2774
2775  // Interpolate pairs of numbers in a & b.
2776  while ((am = reA.exec(a))
2777      && (bm = reB.exec(b))) {
2778    if ((bs = bm.index) > bi) { // a string precedes the next number in b
2779      bs = b.slice(bi, bs);
2780      if (s[i]) s[i] += bs; // coalesce with previous string
2781      else s[++i] = bs;
2782    }
2783    if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
2784      if (s[i]) s[i] += bm; // coalesce with previous string
2785      else s[++i] = bm;
2786    } else { // interpolate non-matching numbers
2787      s[++i] = null;
2788      q.push({i: i, x: interpolateNumber(am, bm)});
2789    }
2790    bi = reB.lastIndex;
2791  }
2792
2793  // Add remains of b.
2794  if (bi < b.length) {
2795    bs = b.slice(bi);
2796    if (s[i]) s[i] += bs; // coalesce with previous string
2797    else s[++i] = bs;
2798  }
2799
2800  // Special optimization for only a single match.
2801  // Otherwise, interpolate each of the numbers and rejoin the string.
2802  return s.length < 2 ? (q[0]
2803      ? one(q[0].x)
2804      : zero(b))
2805      : (b = q.length, function(t) {
2806          for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
2807          return s.join("");
2808        });
2809}
2810
2811function interpolateValue(a, b) {
2812  var t = typeof b, c;
2813  return b == null || t === "boolean" ? constant$3(b)
2814      : (t === "number" ? interpolateNumber
2815      : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString)
2816      : b instanceof color ? interpolateRgb
2817      : b instanceof Date ? date
2818      : isNumberArray(b) ? numberArray
2819      : Array.isArray(b) ? genericArray
2820      : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
2821      : interpolateNumber)(a, b);
2822}
2823
2824function discrete(range) {
2825  var n = range.length;
2826  return function(t) {
2827    return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
2828  };
2829}
2830
2831function hue$1(a, b) {
2832  var i = hue(+a, +b);
2833  return function(t) {
2834    var x = i(t);
2835    return x - 360 * Math.floor(x / 360);
2836  };
2837}
2838
2839function interpolateRound(a, b) {
2840  return a = +a, b = +b, function(t) {
2841    return Math.round(a * (1 - t) + b * t);
2842  };
2843}
2844
2845var degrees = 180 / Math.PI;
2846
2847var identity$2 = {
2848  translateX: 0,
2849  translateY: 0,
2850  rotate: 0,
2851  skewX: 0,
2852  scaleX: 1,
2853  scaleY: 1
2854};
2855
2856function decompose(a, b, c, d, e, f) {
2857  var scaleX, scaleY, skewX;
2858  if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
2859  if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
2860  if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
2861  if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
2862  return {
2863    translateX: e,
2864    translateY: f,
2865    rotate: Math.atan2(b, a) * degrees,
2866    skewX: Math.atan(skewX) * degrees,
2867    scaleX: scaleX,
2868    scaleY: scaleY
2869  };
2870}
2871
2872var cssNode,
2873    cssRoot,
2874    cssView,
2875    svgNode;
2876
2877function parseCss(value) {
2878  if (value === "none") return identity$2;
2879  if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
2880  cssNode.style.transform = value;
2881  value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
2882  cssRoot.removeChild(cssNode);
2883  value = value.slice(7, -1).split(",");
2884  return decompose(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
2885}
2886
2887function parseSvg(value) {
2888  if (value == null) return identity$2;
2889  if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
2890  svgNode.setAttribute("transform", value);
2891  if (!(value = svgNode.transform.baseVal.consolidate())) return identity$2;
2892  value = value.matrix;
2893  return decompose(value.a, value.b, value.c, value.d, value.e, value.f);
2894}
2895
2896function interpolateTransform(parse, pxComma, pxParen, degParen) {
2897
2898  function pop(s) {
2899    return s.length ? s.pop() + " " : "";
2900  }
2901
2902  function translate(xa, ya, xb, yb, s, q) {
2903    if (xa !== xb || ya !== yb) {
2904      var i = s.push("translate(", null, pxComma, null, pxParen);
2905      q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)});
2906    } else if (xb || yb) {
2907      s.push("translate(" + xb + pxComma + yb + pxParen);
2908    }
2909  }
2910
2911  function rotate(a, b, s, q) {
2912    if (a !== b) {
2913      if (a - b > 180) b += 360; else if (b - a > 180) a += 360; // shortest path
2914      q.push({i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: interpolateNumber(a, b)});
2915    } else if (b) {
2916      s.push(pop(s) + "rotate(" + b + degParen);
2917    }
2918  }
2919
2920  function skewX(a, b, s, q) {
2921    if (a !== b) {
2922      q.push({i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: interpolateNumber(a, b)});
2923    } else if (b) {
2924      s.push(pop(s) + "skewX(" + b + degParen);
2925    }
2926  }
2927
2928  function scale(xa, ya, xb, yb, s, q) {
2929    if (xa !== xb || ya !== yb) {
2930      var i = s.push(pop(s) + "scale(", null, ",", null, ")");
2931      q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)});
2932    } else if (xb !== 1 || yb !== 1) {
2933      s.push(pop(s) + "scale(" + xb + "," + yb + ")");
2934    }
2935  }
2936
2937  return function(a, b) {
2938    var s = [], // string constants and placeholders
2939        q = []; // number interpolators
2940    a = parse(a), b = parse(b);
2941    translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
2942    rotate(a.rotate, b.rotate, s, q);
2943    skewX(a.skewX, b.skewX, s, q);
2944    scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
2945    a = b = null; // gc
2946    return function(t) {
2947      var i = -1, n = q.length, o;
2948      while (++i < n) s[(o = q[i]).i] = o.x(t);
2949      return s.join("");
2950    };
2951  };
2952}
2953
2954var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)");
2955var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
2956
2957var rho = Math.SQRT2,
2958    rho2 = 2,
2959    rho4 = 4,
2960    epsilon2 = 1e-12;
2961
2962function cosh(x) {
2963  return ((x = Math.exp(x)) + 1 / x) / 2;
2964}
2965
2966function sinh(x) {
2967  return ((x = Math.exp(x)) - 1 / x) / 2;
2968}
2969
2970function tanh(x) {
2971  return ((x = Math.exp(2 * x)) - 1) / (x + 1);
2972}
2973
2974// p0 = [ux0, uy0, w0]
2975// p1 = [ux1, uy1, w1]
2976function interpolateZoom(p0, p1) {
2977  var ux0 = p0[0], uy0 = p0[1], w0 = p0[2],
2978      ux1 = p1[0], uy1 = p1[1], w1 = p1[2],
2979      dx = ux1 - ux0,
2980      dy = uy1 - uy0,
2981      d2 = dx * dx + dy * dy,
2982      i,
2983      S;
2984
2985  // Special case for u0 ≅ u1.
2986  if (d2 < epsilon2) {
2987    S = Math.log(w1 / w0) / rho;
2988    i = function(t) {
2989      return [
2990        ux0 + t * dx,
2991        uy0 + t * dy,
2992        w0 * Math.exp(rho * t * S)
2993      ];
2994    };
2995  }
2996
2997  // General case.
2998  else {
2999    var d1 = Math.sqrt(d2),
3000        b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
3001        b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
3002        r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
3003        r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
3004    S = (r1 - r0) / rho;
3005    i = function(t) {
3006      var s = t * S,
3007          coshr0 = cosh(r0),
3008          u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
3009      return [
3010        ux0 + u * dx,
3011        uy0 + u * dy,
3012        w0 * coshr0 / cosh(rho * s + r0)
3013      ];
3014    };
3015  }
3016
3017  i.duration = S * 1000;
3018
3019  return i;
3020}
3021
3022function hsl$1(hue) {
3023  return function(start, end) {
3024    var h = hue((start = hsl(start)).h, (end = hsl(end)).h),
3025        s = nogamma(start.s, end.s),
3026        l = nogamma(start.l, end.l),
3027        opacity = nogamma(start.opacity, end.opacity);
3028    return function(t) {
3029      start.h = h(t);
3030      start.s = s(t);
3031      start.l = l(t);
3032      start.opacity = opacity(t);
3033      return start + "";
3034    };
3035  }
3036}
3037
3038var hsl$2 = hsl$1(hue);
3039var hslLong = hsl$1(nogamma);
3040
3041function lab$1(start, end) {
3042  var l = nogamma((start = lab(start)).l, (end = lab(end)).l),
3043      a = nogamma(start.a, end.a),
3044      b = nogamma(start.b, end.b),
3045      opacity = nogamma(start.opacity, end.opacity);
3046  return function(t) {
3047    start.l = l(t);
3048    start.a = a(t);
3049    start.b = b(t);
3050    start.opacity = opacity(t);
3051    return start + "";
3052  };
3053}
3054
3055function hcl$1(hue) {
3056  return function(start, end) {
3057    var h = hue((start = hcl(start)).h, (end = hcl(end)).h),
3058        c = nogamma(start.c, end.c),
3059        l = nogamma(start.l, end.l),
3060        opacity = nogamma(start.opacity, end.opacity);
3061    return function(t) {
3062      start.h = h(t);
3063      start.c = c(t);
3064      start.l = l(t);
3065      start.opacity = opacity(t);
3066      return start + "";
3067    };
3068  }
3069}
3070
3071var hcl$2 = hcl$1(hue);
3072var hclLong = hcl$1(nogamma);
3073
3074function cubehelix$1(hue) {
3075  return (function cubehelixGamma(y) {
3076    y = +y;
3077
3078    function cubehelix$1(start, end) {
3079      var h = hue((start = cubehelix(start)).h, (end = cubehelix(end)).h),
3080          s = nogamma(start.s, end.s),
3081          l = nogamma(start.l, end.l),
3082          opacity = nogamma(start.opacity, end.opacity);
3083      return function(t) {
3084        start.h = h(t);
3085        start.s = s(t);
3086        start.l = l(Math.pow(t, y));
3087        start.opacity = opacity(t);
3088        return start + "";
3089      };
3090    }
3091
3092    cubehelix$1.gamma = cubehelixGamma;
3093
3094    return cubehelix$1;
3095  })(1);
3096}
3097
3098var cubehelix$2 = cubehelix$1(hue);
3099var cubehelixLong = cubehelix$1(nogamma);
3100
3101function piecewise(interpolate, values) {
3102  var i = 0, n = values.length - 1, v = values[0], I = new Array(n < 0 ? 0 : n);
3103  while (i < n) I[i] = interpolate(v, v = values[++i]);
3104  return function(t) {
3105    var i = Math.max(0, Math.min(n - 1, Math.floor(t *= n)));
3106    return I[i](t - i);
3107  };
3108}
3109
3110function quantize(interpolator, n) {
3111  var samples = new Array(n);
3112  for (var i = 0; i < n; ++i) samples[i] = interpolator(i / (n - 1));
3113  return samples;
3114}
3115
3116var frame = 0, // is an animation frame pending?
3117    timeout = 0, // is a timeout pending?
3118    interval = 0, // are any timers active?
3119    pokeDelay = 1000, // how frequently we check for clock skew
3120    taskHead,
3121    taskTail,
3122    clockLast = 0,
3123    clockNow = 0,
3124    clockSkew = 0,
3125    clock = typeof performance === "object" && performance.now ? performance : Date,
3126    setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
3127
3128function now() {
3129  return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
3130}
3131
3132function clearNow() {
3133  clockNow = 0;
3134}
3135
3136function Timer() {
3137  this._call =
3138  this._time =
3139  this._next = null;
3140}
3141
3142Timer.prototype = timer.prototype = {
3143  constructor: Timer,
3144  restart: function(callback, delay, time) {
3145    if (typeof callback !== "function") throw new TypeError("callback is not a function");
3146    time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
3147    if (!this._next && taskTail !== this) {
3148      if (taskTail) taskTail._next = this;
3149      else taskHead = this;
3150      taskTail = this;
3151    }
3152    this._call = callback;
3153    this._time = time;
3154    sleep();
3155  },
3156  stop: function() {
3157    if (this._call) {
3158      this._call = null;
3159      this._time = Infinity;
3160      sleep();
3161    }
3162  }
3163};
3164
3165function timer(callback, delay, time) {
3166  var t = new Timer;
3167  t.restart(callback, delay, time);
3168  return t;
3169}
3170
3171function timerFlush() {
3172  now(); // Get the current time, if not already set.
3173  ++frame; // Pretend we’ve set an alarm, if we haven’t already.
3174  var t = taskHead, e;
3175  while (t) {
3176    if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
3177    t = t._next;
3178  }
3179  --frame;
3180}
3181
3182function wake() {
3183  clockNow = (clockLast = clock.now()) + clockSkew;
3184  frame = timeout = 0;
3185  try {
3186    timerFlush();
3187  } finally {
3188    frame = 0;
3189    nap();
3190    clockNow = 0;
3191  }
3192}
3193
3194function poke() {
3195  var now = clock.now(), delay = now - clockLast;
3196  if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
3197}
3198
3199function nap() {
3200  var t0, t1 = taskHead, t2, time = Infinity;
3201  while (t1) {
3202    if (t1._call) {
3203      if (time > t1._time) time = t1._time;
3204      t0 = t1, t1 = t1._next;
3205    } else {
3206      t2 = t1._next, t1._next = null;
3207      t1 = t0 ? t0._next = t2 : taskHead = t2;
3208    }
3209  }
3210  taskTail = t0;
3211  sleep(time);
3212}
3213
3214function sleep(time) {
3215  if (frame) return; // Soonest alarm already set, or will be.
3216  if (timeout) timeout = clearTimeout(timeout);
3217  var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
3218  if (delay > 24) {
3219    if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
3220    if (interval) interval = clearInterval(interval);
3221  } else {
3222    if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
3223    frame = 1, setFrame(wake);
3224  }
3225}
3226
3227function timeout$1(callback, delay, time) {
3228  var t = new Timer;
3229  delay = delay == null ? 0 : +delay;
3230  t.restart(function(elapsed) {
3231    t.stop();
3232    callback(elapsed + delay);
3233  }, delay, time);
3234  return t;
3235}
3236
3237function interval$1(callback, delay, time) {
3238  var t = new Timer, total = delay;
3239  if (delay == null) return t.restart(callback, delay, time), t;
3240  delay = +delay, time = time == null ? now() : +time;
3241  t.restart(function tick(elapsed) {
3242    elapsed += total;
3243    t.restart(tick, total += delay, time);
3244    callback(elapsed);
3245  }, delay, time);
3246  return t;
3247}
3248
3249var emptyOn = dispatch("start", "end", "cancel", "interrupt");
3250var emptyTween = [];
3251
3252var CREATED = 0;
3253var SCHEDULED = 1;
3254var STARTING = 2;
3255var STARTED = 3;
3256var RUNNING = 4;
3257var ENDING = 5;
3258var ENDED = 6;
3259
3260function schedule(node, name, id, index, group, timing) {
3261  var schedules = node.__transition;
3262  if (!schedules) node.__transition = {};
3263  else if (id in schedules) return;
3264  create$1(node, id, {
3265    name: name,
3266    index: index, // For context during callback.
3267    group: group, // For context during callback.
3268    on: emptyOn,
3269    tween: emptyTween,
3270    time: timing.time,
3271    delay: timing.delay,
3272    duration: timing.duration,
3273    ease: timing.ease,
3274    timer: null,
3275    state: CREATED
3276  });
3277}
3278
3279function init(node, id) {
3280  var schedule = get$1(node, id);
3281  if (schedule.state > CREATED) throw new Error("too late; already scheduled");
3282  return schedule;
3283}
3284
3285function set$1(node, id) {
3286  var schedule = get$1(node, id);
3287  if (schedule.state > STARTED) throw new Error("too late; already running");
3288  return schedule;
3289}
3290
3291function get$1(node, id) {
3292  var schedule = node.__transition;
3293  if (!schedule || !(schedule = schedule[id])) throw new Error("transition not found");
3294  return schedule;
3295}
3296
3297function create$1(node, id, self) {
3298  var schedules = node.__transition,
3299      tween;
3300
3301  // Initialize the self timer when the transition is created.
3302  // Note the actual delay is not known until the first callback!
3303  schedules[id] = self;
3304  self.timer = timer(schedule, 0, self.time);
3305
3306  function schedule(elapsed) {
3307    self.state = SCHEDULED;
3308    self.timer.restart(start, self.delay, self.time);
3309
3310    // If the elapsed delay is less than our first sleep, start immediately.
3311    if (self.delay <= elapsed) start(elapsed - self.delay);
3312  }
3313
3314  function start(elapsed) {
3315    var i, j, n, o;
3316
3317    // If the state is not SCHEDULED, then we previously errored on start.
3318    if (self.state !== SCHEDULED) return stop();
3319
3320    for (i in schedules) {
3321      o = schedules[i];
3322      if (o.name !== self.name) continue;
3323
3324      // While this element already has a starting transition during this frame,
3325      // defer starting an interrupting transition until that transition has a
3326      // chance to tick (and possibly end); see d3/d3-transition#54!
3327      if (o.state === STARTED) return timeout$1(start);
3328
3329      // Interrupt the active transition, if any.
3330      if (o.state === RUNNING) {
3331        o.state = ENDED;
3332        o.timer.stop();
3333        o.on.call("interrupt", node, node.__data__, o.index, o.group);
3334        delete schedules[i];
3335      }
3336
3337      // Cancel any pre-empted transitions.
3338      else if (+i < id) {
3339        o.state = ENDED;
3340        o.timer.stop();
3341        o.on.call("cancel", node, node.__data__, o.index, o.group);
3342        delete schedules[i];
3343      }
3344    }
3345
3346    // Defer the first tick to end of the current frame; see d3/d3#1576.
3347    // Note the transition may be canceled after start and before the first tick!
3348    // Note this must be scheduled before the start event; see d3/d3-transition#16!
3349    // Assuming this is successful, subsequent callbacks go straight to tick.
3350    timeout$1(function() {
3351      if (self.state === STARTED) {
3352        self.state = RUNNING;
3353        self.timer.restart(tick, self.delay, self.time);
3354        tick(elapsed);
3355      }
3356    });
3357
3358    // Dispatch the start event.
3359    // Note this must be done before the tween are initialized.
3360    self.state = STARTING;
3361    self.on.call("start", node, node.__data__, self.index, self.group);
3362    if (self.state !== STARTING) return; // interrupted
3363    self.state = STARTED;
3364
3365    // Initialize the tween, deleting null tween.
3366    tween = new Array(n = self.tween.length);
3367    for (i = 0, j = -1; i < n; ++i) {
3368      if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) {
3369        tween[++j] = o;
3370      }
3371    }
3372    tween.length = j + 1;
3373  }
3374
3375  function tick(elapsed) {
3376    var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1),
3377        i = -1,
3378        n = tween.length;
3379
3380    while (++i < n) {
3381      tween[i].call(node, t);
3382    }
3383
3384    // Dispatch the end event.
3385    if (self.state === ENDING) {
3386      self.on.call("end", node, node.__data__, self.index, self.group);
3387      stop();
3388    }
3389  }
3390
3391  function stop() {
3392    self.state = ENDED;
3393    self.timer.stop();
3394    delete schedules[id];
3395    for (var i in schedules) return; // eslint-disable-line no-unused-vars
3396    delete node.__transition;
3397  }
3398}
3399
3400function interrupt(node, name) {
3401  var schedules = node.__transition,
3402      schedule,
3403      active,
3404      empty = true,
3405      i;
3406
3407  if (!schedules) return;
3408
3409  name = name == null ? null : name + "";
3410
3411  for (i in schedules) {
3412    if ((schedule = schedules[i]).name !== name) { empty = false; continue; }
3413    active = schedule.state > STARTING && schedule.state < ENDING;
3414    schedule.state = ENDED;
3415    schedule.timer.stop();
3416    schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group);
3417    delete schedules[i];
3418  }
3419
3420  if (empty) delete node.__transition;
3421}
3422
3423function selection_interrupt(name) {
3424  return this.each(function() {
3425    interrupt(this, name);
3426  });
3427}
3428
3429function tweenRemove(id, name) {
3430  var tween0, tween1;
3431  return function() {
3432    var schedule = set$1(this, id),
3433        tween = schedule.tween;
3434
3435    // If this node shared tween with the previous node,
3436    // just assign the updated shared tween and we’re done!
3437    // Otherwise, copy-on-write.
3438    if (tween !== tween0) {
3439      tween1 = tween0 = tween;
3440      for (var i = 0, n = tween1.length; i < n; ++i) {
3441        if (tween1[i].name === name) {
3442          tween1 = tween1.slice();
3443          tween1.splice(i, 1);
3444          break;
3445        }
3446      }
3447    }
3448
3449    schedule.tween = tween1;
3450  };
3451}
3452
3453function tweenFunction(id, name, value) {
3454  var tween0, tween1;
3455  if (typeof value !== "function") throw new Error;
3456  return function() {
3457    var schedule = set$1(this, id),
3458        tween = schedule.tween;
3459
3460    // If this node shared tween with the previous node,
3461    // just assign the updated shared tween and we’re done!
3462    // Otherwise, copy-on-write.
3463    if (tween !== tween0) {
3464      tween1 = (tween0 = tween).slice();
3465      for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) {
3466        if (tween1[i].name === name) {
3467          tween1[i] = t;
3468          break;
3469        }
3470      }
3471      if (i === n) tween1.push(t);
3472    }
3473
3474    schedule.tween = tween1;
3475  };
3476}
3477
3478function transition_tween(name, value) {
3479  var id = this._id;
3480
3481  name += "";
3482
3483  if (arguments.length < 2) {
3484    var tween = get$1(this.node(), id).tween;
3485    for (var i = 0, n = tween.length, t; i < n; ++i) {
3486      if ((t = tween[i]).name === name) {
3487        return t.value;
3488      }
3489    }
3490    return null;
3491  }
3492
3493  return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value));
3494}
3495
3496function tweenValue(transition, name, value) {
3497  var id = transition._id;
3498
3499  transition.each(function() {
3500    var schedule = set$1(this, id);
3501    (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
3502  });
3503
3504  return function(node) {
3505    return get$1(node, id).value[name];
3506  };
3507}
3508
3509function interpolate(a, b) {
3510  var c;
3511  return (typeof b === "number" ? interpolateNumber
3512      : b instanceof color ? interpolateRgb
3513      : (c = color(b)) ? (b = c, interpolateRgb)
3514      : interpolateString)(a, b);
3515}
3516
3517function attrRemove$1(name) {
3518  return function() {
3519    this.removeAttribute(name);
3520  };
3521}
3522
3523function attrRemoveNS$1(fullname) {
3524  return function() {
3525    this.removeAttributeNS(fullname.space, fullname.local);
3526  };
3527}
3528
3529function attrConstant$1(name, interpolate, value1) {
3530  var string00,
3531      string1 = value1 + "",
3532      interpolate0;
3533  return function() {
3534    var string0 = this.getAttribute(name);
3535    return string0 === string1 ? null
3536        : string0 === string00 ? interpolate0
3537        : interpolate0 = interpolate(string00 = string0, value1);
3538  };
3539}
3540
3541function attrConstantNS$1(fullname, interpolate, value1) {
3542  var string00,
3543      string1 = value1 + "",
3544      interpolate0;
3545  return function() {
3546    var string0 = this.getAttributeNS(fullname.space, fullname.local);
3547    return string0 === string1 ? null
3548        : string0 === string00 ? interpolate0
3549        : interpolate0 = interpolate(string00 = string0, value1);
3550  };
3551}
3552
3553function attrFunction$1(name, interpolate, value) {
3554  var string00,
3555      string10,
3556      interpolate0;
3557  return function() {
3558    var string0, value1 = value(this), string1;
3559    if (value1 == null) return void this.removeAttribute(name);
3560    string0 = this.getAttribute(name);
3561    string1 = value1 + "";
3562    return string0 === string1 ? null
3563        : string0 === string00 && string1 === string10 ? interpolate0
3564        : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
3565  };
3566}
3567
3568function attrFunctionNS$1(fullname, interpolate, value) {
3569  var string00,
3570      string10,
3571      interpolate0;
3572  return function() {
3573    var string0, value1 = value(this), string1;
3574    if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
3575    string0 = this.getAttributeNS(fullname.space, fullname.local);
3576    string1 = value1 + "";
3577    return string0 === string1 ? null
3578        : string0 === string00 && string1 === string10 ? interpolate0
3579        : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
3580  };
3581}
3582
3583function transition_attr(name, value) {
3584  var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate;
3585  return this.attrTween(name, typeof value === "function"
3586      ? (fullname.local ? attrFunctionNS$1 : attrFunction$1)(fullname, i, tweenValue(this, "attr." + name, value))
3587      : value == null ? (fullname.local ? attrRemoveNS$1 : attrRemove$1)(fullname)
3588      : (fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, i, value));
3589}
3590
3591function attrInterpolate(name, i) {
3592  return function(t) {
3593    this.setAttribute(name, i.call(this, t));
3594  };
3595}
3596
3597function attrInterpolateNS(fullname, i) {
3598  return function(t) {
3599    this.setAttributeNS(fullname.space, fullname.local, i.call(this, t));
3600  };
3601}
3602
3603function attrTweenNS(fullname, value) {
3604  var t0, i0;
3605  function tween() {
3606    var i = value.apply(this, arguments);
3607    if (i !== i0) t0 = (i0 = i) && attrInterpolateNS(fullname, i);
3608    return t0;
3609  }
3610  tween._value = value;
3611  return tween;
3612}
3613
3614function attrTween(name, value) {
3615  var t0, i0;
3616  function tween() {
3617    var i = value.apply(this, arguments);
3618    if (i !== i0) t0 = (i0 = i) && attrInterpolate(name, i);
3619    return t0;
3620  }
3621  tween._value = value;
3622  return tween;
3623}
3624
3625function transition_attrTween(name, value) {
3626  var key = "attr." + name;
3627  if (arguments.length < 2) return (key = this.tween(key)) && key._value;
3628  if (value == null) return this.tween(key, null);
3629  if (typeof value !== "function") throw new Error;
3630  var fullname = namespace(name);
3631  return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
3632}
3633
3634function delayFunction(id, value) {
3635  return function() {
3636    init(this, id).delay = +value.apply(this, arguments);
3637  };
3638}
3639
3640function delayConstant(id, value) {
3641  return value = +value, function() {
3642    init(this, id).delay = value;
3643  };
3644}
3645
3646function transition_delay(value) {
3647  var id = this._id;
3648
3649  return arguments.length
3650      ? this.each((typeof value === "function"
3651          ? delayFunction
3652          : delayConstant)(id, value))
3653      : get$1(this.node(), id).delay;
3654}
3655
3656function durationFunction(id, value) {
3657  return function() {
3658    set$1(this, id).duration = +value.apply(this, arguments);
3659  };
3660}
3661
3662function durationConstant(id, value) {
3663  return value = +value, function() {
3664    set$1(this, id).duration = value;
3665  };
3666}
3667
3668function transition_duration(value) {
3669  var id = this._id;
3670
3671  return arguments.length
3672      ? this.each((typeof value === "function"
3673          ? durationFunction
3674          : durationConstant)(id, value))
3675      : get$1(this.node(), id).duration;
3676}
3677
3678function easeConstant(id, value) {
3679  if (typeof value !== "function") throw new Error;
3680  return function() {
3681    set$1(this, id).ease = value;
3682  };
3683}
3684
3685function transition_ease(value) {
3686  var id = this._id;
3687
3688  return arguments.length
3689      ? this.each(easeConstant(id, value))
3690      : get$1(this.node(), id).ease;
3691}
3692
3693function transition_filter(match) {
3694  if (typeof match !== "function") match = matcher(match);
3695
3696  for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
3697    for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
3698      if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
3699        subgroup.push(node);
3700      }
3701    }
3702  }
3703
3704  return new Transition(subgroups, this._parents, this._name, this._id);
3705}
3706
3707function transition_merge(transition) {
3708  if (transition._id !== this._id) throw new Error;
3709
3710  for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
3711    for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
3712      if (node = group0[i] || group1[i]) {
3713        merge[i] = node;
3714      }
3715    }
3716  }
3717
3718  for (; j < m0; ++j) {
3719    merges[j] = groups0[j];
3720  }
3721
3722  return new Transition(merges, this._parents, this._name, this._id);
3723}
3724
3725function start(name) {
3726  return (name + "").trim().split(/^|\s+/).every(function(t) {
3727    var i = t.indexOf(".");
3728    if (i >= 0) t = t.slice(0, i);
3729    return !t || t === "start";
3730  });
3731}
3732
3733function onFunction(id, name, listener) {
3734  var on0, on1, sit = start(name) ? init : set$1;
3735  return function() {
3736    var schedule = sit(this, id),
3737        on = schedule.on;
3738
3739    // If this node shared a dispatch with the previous node,
3740    // just assign the updated shared dispatch and we’re done!
3741    // Otherwise, copy-on-write.
3742    if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
3743
3744    schedule.on = on1;
3745  };
3746}
3747
3748function transition_on(name, listener) {
3749  var id = this._id;
3750
3751  return arguments.length < 2
3752      ? get$1(this.node(), id).on.on(name)
3753      : this.each(onFunction(id, name, listener));
3754}
3755
3756function removeFunction(id) {
3757  return function() {
3758    var parent = this.parentNode;
3759    for (var i in this.__transition) if (+i !== id) return;
3760    if (parent) parent.removeChild(this);
3761  };
3762}
3763
3764function transition_remove() {
3765  return this.on("end.remove", removeFunction(this._id));
3766}
3767
3768function transition_select(select) {
3769  var name = this._name,
3770      id = this._id;
3771
3772  if (typeof select !== "function") select = selector(select);
3773
3774  for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
3775    for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
3776      if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
3777        if ("__data__" in node) subnode.__data__ = node.__data__;
3778        subgroup[i] = subnode;
3779        schedule(subgroup[i], name, id, i, subgroup, get$1(node, id));
3780      }
3781    }
3782  }
3783
3784  return new Transition(subgroups, this._parents, name, id);
3785}
3786
3787function transition_selectAll(select) {
3788  var name = this._name,
3789      id = this._id;
3790
3791  if (typeof select !== "function") select = selectorAll(select);
3792
3793  for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
3794    for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
3795      if (node = group[i]) {
3796        for (var children = select.call(node, node.__data__, i, group), child, inherit = get$1(node, id), k = 0, l = children.length; k < l; ++k) {
3797          if (child = children[k]) {
3798            schedule(child, name, id, k, children, inherit);
3799          }
3800        }
3801        subgroups.push(children);
3802        parents.push(node);
3803      }
3804    }
3805  }
3806
3807  return new Transition(subgroups, parents, name, id);
3808}
3809
3810var Selection$1 = selection.prototype.constructor;
3811
3812function transition_selection() {
3813  return new Selection$1(this._groups, this._parents);
3814}
3815
3816function styleNull(name, interpolate) {
3817  var string00,
3818      string10,
3819      interpolate0;
3820  return function() {
3821    var string0 = styleValue(this, name),
3822        string1 = (this.style.removeProperty(name), styleValue(this, name));
3823    return string0 === string1 ? null
3824        : string0 === string00 && string1 === string10 ? interpolate0
3825        : interpolate0 = interpolate(string00 = string0, string10 = string1);
3826  };
3827}
3828
3829function styleRemove$1(name) {
3830  return function() {
3831    this.style.removeProperty(name);
3832  };
3833}
3834
3835function styleConstant$1(name, interpolate, value1) {
3836  var string00,
3837      string1 = value1 + "",
3838      interpolate0;
3839  return function() {
3840    var string0 = styleValue(this, name);
3841    return string0 === string1 ? null
3842        : string0 === string00 ? interpolate0
3843        : interpolate0 = interpolate(string00 = string0, value1);
3844  };
3845}
3846
3847function styleFunction$1(name, interpolate, value) {
3848  var string00,
3849      string10,
3850      interpolate0;
3851  return function() {
3852    var string0 = styleValue(this, name),
3853        value1 = value(this),
3854        string1 = value1 + "";
3855    if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name));
3856    return string0 === string1 ? null
3857        : string0 === string00 && string1 === string10 ? interpolate0
3858        : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
3859  };
3860}
3861
3862function styleMaybeRemove(id, name) {
3863  var on0, on1, listener0, key = "style." + name, event = "end." + key, remove;
3864  return function() {
3865    var schedule = set$1(this, id),
3866        on = schedule.on,
3867        listener = schedule.value[key] == null ? remove || (remove = styleRemove$1(name)) : undefined;
3868
3869    // If this node shared a dispatch with the previous node,
3870    // just assign the updated shared dispatch and we’re done!
3871    // Otherwise, copy-on-write.
3872    if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener);
3873
3874    schedule.on = on1;
3875  };
3876}
3877
3878function transition_style(name, value, priority) {
3879  var i = (name += "") === "transform" ? interpolateTransformCss : interpolate;
3880  return value == null ? this
3881      .styleTween(name, styleNull(name, i))
3882      .on("end.style." + name, styleRemove$1(name))
3883    : typeof value === "function" ? this
3884      .styleTween(name, styleFunction$1(name, i, tweenValue(this, "style." + name, value)))
3885      .each(styleMaybeRemove(this._id, name))
3886    : this
3887      .styleTween(name, styleConstant$1(name, i, value), priority)
3888      .on("end.style." + name, null);
3889}
3890
3891function styleInterpolate(name, i, priority) {
3892  return function(t) {
3893    this.style.setProperty(name, i.call(this, t), priority);
3894  };
3895}
3896
3897function styleTween(name, value, priority) {
3898  var t, i0;
3899  function tween() {
3900    var i = value.apply(this, arguments);
3901    if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority);
3902    return t;
3903  }
3904  tween._value = value;
3905  return tween;
3906}
3907
3908function transition_styleTween(name, value, priority) {
3909  var key = "style." + (name += "");
3910  if (arguments.length < 2) return (key = this.tween(key)) && key._value;
3911  if (value == null) return this.tween(key, null);
3912  if (typeof value !== "function") throw new Error;
3913  return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
3914}
3915
3916function textConstant$1(value) {
3917  return function() {
3918    this.textContent = value;
3919  };
3920}
3921
3922function textFunction$1(value) {
3923  return function() {
3924    var value1 = value(this);
3925    this.textContent = value1 == null ? "" : value1;
3926  };
3927}
3928
3929function transition_text(value) {
3930  return this.tween("text", typeof value === "function"
3931      ? textFunction$1(tweenValue(this, "text", value))
3932      : textConstant$1(value == null ? "" : value + ""));
3933}
3934
3935function textInterpolate(i) {
3936  return function(t) {
3937    this.textContent = i.call(this, t);
3938  };
3939}
3940
3941function textTween(value) {
3942  var t0, i0;
3943  function tween() {
3944    var i = value.apply(this, arguments);
3945    if (i !== i0) t0 = (i0 = i) && textInterpolate(i);
3946    return t0;
3947  }
3948  tween._value = value;
3949  return tween;
3950}
3951
3952function transition_textTween(value) {
3953  var key = "text";
3954  if (arguments.length < 1) return (key = this.tween(key)) && key._value;
3955  if (value == null) return this.tween(key, null);
3956  if (typeof value !== "function") throw new Error;
3957  return this.tween(key, textTween(value));
3958}
3959
3960function transition_transition() {
3961  var name = this._name,
3962      id0 = this._id,
3963      id1 = newId();
3964
3965  for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
3966    for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
3967      if (node = group[i]) {
3968        var inherit = get$1(node, id0);
3969        schedule(node, name, id1, i, group, {
3970          time: inherit.time + inherit.delay + inherit.duration,
3971          delay: 0,
3972          duration: inherit.duration,
3973          ease: inherit.ease
3974        });
3975      }
3976    }
3977  }
3978
3979  return new Transition(groups, this._parents, name, id1);
3980}
3981
3982function transition_end() {
3983  var on0, on1, that = this, id = that._id, size = that.size();
3984  return new Promise(function(resolve, reject) {
3985    var cancel = {value: reject},
3986        end = {value: function() { if (--size === 0) resolve(); }};
3987
3988    that.each(function() {
3989      var schedule = set$1(this, id),
3990          on = schedule.on;
3991
3992      // If this node shared a dispatch with the previous node,
3993      // just assign the updated shared dispatch and we’re done!
3994      // Otherwise, copy-on-write.
3995      if (on !== on0) {
3996        on1 = (on0 = on).copy();
3997        on1._.cancel.push(cancel);
3998        on1._.interrupt.push(cancel);
3999        on1._.end.push(end);
4000      }
4001
4002      schedule.on = on1;
4003    });
4004  });
4005}
4006
4007var id = 0;
4008
4009function Transition(groups, parents, name, id) {
4010  this._groups = groups;
4011  this._parents = parents;
4012  this._name = name;
4013  this._id = id;
4014}
4015
4016function transition(name) {
4017  return selection().transition(name);
4018}
4019
4020function newId() {
4021  return ++id;
4022}
4023
4024var selection_prototype = selection.prototype;
4025
4026Transition.prototype = transition.prototype = {
4027  constructor: Transition,
4028  select: transition_select,
4029  selectAll: transition_selectAll,
4030  filter: transition_filter,
4031  merge: transition_merge,
4032  selection: transition_selection,
4033  transition: transition_transition,
4034  call: selection_prototype.call,
4035  nodes: selection_prototype.nodes,
4036  node: selection_prototype.node,
4037  size: selection_prototype.size,
4038  empty: selection_prototype.empty,
4039  each: selection_prototype.each,
4040  on: transition_on,
4041  attr: transition_attr,
4042  attrTween: transition_attrTween,
4043  style: transition_style,
4044  styleTween: transition_styleTween,
4045  text: transition_text,
4046  textTween: transition_textTween,
4047  remove: transition_remove,
4048  tween: transition_tween,
4049  delay: transition_delay,
4050  duration: transition_duration,
4051  ease: transition_ease,
4052  end: transition_end
4053};
4054
4055function linear$1(t) {
4056  return +t;
4057}
4058
4059function quadIn(t) {
4060  return t * t;
4061}
4062
4063function quadOut(t) {
4064  return t * (2 - t);
4065}
4066
4067function quadInOut(t) {
4068  return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
4069}
4070
4071function cubicIn(t) {
4072  return t * t * t;
4073}
4074
4075function cubicOut(t) {
4076  return --t * t * t + 1;
4077}
4078
4079function cubicInOut(t) {
4080  return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
4081}
4082
4083var exponent = 3;
4084
4085var polyIn = (function custom(e) {
4086  e = +e;
4087
4088  function polyIn(t) {
4089    return Math.pow(t, e);
4090  }
4091
4092  polyIn.exponent = custom;
4093
4094  return polyIn;
4095})(exponent);
4096
4097var polyOut = (function custom(e) {
4098  e = +e;
4099
4100  function polyOut(t) {
4101    return 1 - Math.pow(1 - t, e);
4102  }
4103
4104  polyOut.exponent = custom;
4105
4106  return polyOut;
4107})(exponent);
4108
4109var polyInOut = (function custom(e) {
4110  e = +e;
4111
4112  function polyInOut(t) {
4113    return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
4114  }
4115
4116  polyInOut.exponent = custom;
4117
4118  return polyInOut;
4119})(exponent);
4120
4121var pi = Math.PI,
4122    halfPi = pi / 2;
4123
4124function sinIn(t) {
4125  return 1 - Math.cos(t * halfPi);
4126}
4127
4128function sinOut(t) {
4129  return Math.sin(t * halfPi);
4130}
4131
4132function sinInOut(t) {
4133  return (1 - Math.cos(pi * t)) / 2;
4134}
4135
4136function expIn(t) {
4137  return Math.pow(2, 10 * t - 10);
4138}
4139
4140function expOut(t) {
4141  return 1 - Math.pow(2, -10 * t);
4142}
4143
4144function expInOut(t) {
4145  return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 2;
4146}
4147
4148function circleIn(t) {
4149  return 1 - Math.sqrt(1 - t * t);
4150}
4151
4152function circleOut(t) {
4153  return Math.sqrt(1 - --t * t);
4154}
4155
4156function circleInOut(t) {
4157  return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
4158}
4159
4160var b1 = 4 / 11,
4161    b2 = 6 / 11,
4162    b3 = 8 / 11,
4163    b4 = 3 / 4,
4164    b5 = 9 / 11,
4165    b6 = 10 / 11,
4166    b7 = 15 / 16,
4167    b8 = 21 / 22,
4168    b9 = 63 / 64,
4169    b0 = 1 / b1 / b1;
4170
4171function bounceIn(t) {
4172  return 1 - bounceOut(1 - t);
4173}
4174
4175function bounceOut(t) {
4176  return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
4177}
4178
4179function bounceInOut(t) {
4180  return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
4181}
4182
4183var overshoot = 1.70158;
4184
4185var backIn = (function custom(s) {
4186  s = +s;
4187
4188  function backIn(t) {
4189    return t * t * ((s + 1) * t - s);
4190  }
4191
4192  backIn.overshoot = custom;
4193
4194  return backIn;
4195})(overshoot);
4196
4197var backOut = (function custom(s) {
4198  s = +s;
4199
4200  function backOut(t) {
4201    return --t * t * ((s + 1) * t + s) + 1;
4202  }
4203
4204  backOut.overshoot = custom;
4205
4206  return backOut;
4207})(overshoot);
4208
4209var backInOut = (function custom(s) {
4210  s = +s;
4211
4212  function backInOut(t) {
4213    return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
4214  }
4215
4216  backInOut.overshoot = custom;
4217
4218  return backInOut;
4219})(overshoot);
4220
4221var tau = 2 * Math.PI,
4222    amplitude = 1,
4223    period = 0.3;
4224
4225var elasticIn = (function custom(a, p) {
4226  var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
4227
4228  function elasticIn(t) {
4229    return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p);
4230  }
4231
4232  elasticIn.amplitude = function(a) { return custom(a, p * tau); };
4233  elasticIn.period = function(p) { return custom(a, p); };
4234
4235  return elasticIn;
4236})(amplitude, period);
4237
4238var elasticOut = (function custom(a, p) {
4239  var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
4240
4241  function elasticOut(t) {
4242    return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p);
4243  }
4244
4245  elasticOut.amplitude = function(a) { return custom(a, p * tau); };
4246  elasticOut.period = function(p) { return custom(a, p); };
4247
4248  return elasticOut;
4249})(amplitude, period);
4250
4251var elasticInOut = (function custom(a, p) {
4252  var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
4253
4254  function elasticInOut(t) {
4255    return ((t = t * 2 - 1) < 0
4256        ? a * Math.pow(2, 10 * t) * Math.sin((s - t) / p)
4257        : 2 - a * Math.pow(2, -10 * t) * Math.sin((s + t) / p)) / 2;
4258  }
4259
4260  elasticInOut.amplitude = function(a) { return custom(a, p * tau); };
4261  elasticInOut.period = function(p) { return custom(a, p); };
4262
4263  return elasticInOut;
4264})(amplitude, period);
4265
4266var defaultTiming = {
4267  time: null, // Set on use.
4268  delay: 0,
4269  duration: 250,
4270  ease: cubicInOut
4271};
4272
4273function inherit(node, id) {
4274  var timing;
4275  while (!(timing = node.__transition) || !(timing = timing[id])) {
4276    if (!(node = node.parentNode)) {
4277      return defaultTiming.time = now(), defaultTiming;
4278    }
4279  }
4280  return timing;
4281}
4282
4283function selection_transition(name) {
4284  var id,
4285      timing;
4286
4287  if (name instanceof Transition) {
4288    id = name._id, name = name._name;
4289  } else {
4290    id = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
4291  }
4292
4293  for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
4294    for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
4295      if (node = group[i]) {
4296        schedule(node, name, id, i, group, timing || inherit(node, id));
4297      }
4298    }
4299  }
4300
4301  return new Transition(groups, this._parents, name, id);
4302}
4303
4304selection.prototype.interrupt = selection_interrupt;
4305selection.prototype.transition = selection_transition;
4306
4307var root$1 = [null];
4308
4309function active(node, name) {
4310  var schedules = node.__transition,
4311      schedule,
4312      i;
4313
4314  if (schedules) {
4315    name = name == null ? null : name + "";
4316    for (i in schedules) {
4317      if ((schedule = schedules[i]).state > SCHEDULED && schedule.name === name) {
4318        return new Transition([[node]], root$1, name, +i);
4319      }
4320    }
4321  }
4322
4323  return null;
4324}
4325
4326function constant$4(x) {
4327  return function() {
4328    return x;
4329  };
4330}
4331
4332function BrushEvent(target, type, selection) {
4333  this.target = target;
4334  this.type = type;
4335  this.selection = selection;
4336}
4337
4338function nopropagation$1() {
4339  exports.event.stopImmediatePropagation();
4340}
4341
4342function noevent$1() {
4343  exports.event.preventDefault();
4344  exports.event.stopImmediatePropagation();
4345}
4346
4347var MODE_DRAG = {name: "drag"},
4348    MODE_SPACE = {name: "space"},
4349    MODE_HANDLE = {name: "handle"},
4350    MODE_CENTER = {name: "center"};
4351
4352function number1(e) {
4353  return [+e[0], +e[1]];
4354}
4355
4356function number2(e) {
4357  return [number1(e[0]), number1(e[1])];
4358}
4359
4360function toucher(identifier) {
4361  return function(target) {
4362    return touch(target, exports.event.touches, identifier);
4363  };
4364}
4365
4366var X = {
4367  name: "x",
4368  handles: ["w", "e"].map(type),
4369  input: function(x, e) { return x == null ? null : [[+x[0], e[0][1]], [+x[1], e[1][1]]]; },
4370  output: function(xy) { return xy && [xy[0][0], xy[1][0]]; }
4371};
4372
4373var Y = {
4374  name: "y",
4375  handles: ["n", "s"].map(type),
4376  input: function(y, e) { return y == null ? null : [[e[0][0], +y[0]], [e[1][0], +y[1]]]; },
4377  output: function(xy) { return xy && [xy[0][1], xy[1][1]]; }
4378};
4379
4380var XY = {
4381  name: "xy",
4382  handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type),
4383  input: function(xy) { return xy == null ? null : number2(xy); },
4384  output: function(xy) { return xy; }
4385};
4386
4387var cursors = {
4388  overlay: "crosshair",
4389  selection: "move",
4390  n: "ns-resize",
4391  e: "ew-resize",
4392  s: "ns-resize",
4393  w: "ew-resize",
4394  nw: "nwse-resize",
4395  ne: "nesw-resize",
4396  se: "nwse-resize",
4397  sw: "nesw-resize"
4398};
4399
4400var flipX = {
4401  e: "w",
4402  w: "e",
4403  nw: "ne",
4404  ne: "nw",
4405  se: "sw",
4406  sw: "se"
4407};
4408
4409var flipY = {
4410  n: "s",
4411  s: "n",
4412  nw: "sw",
4413  ne: "se",
4414  se: "ne",
4415  sw: "nw"
4416};
4417
4418var signsX = {
4419  overlay: +1,
4420  selection: +1,
4421  n: null,
4422  e: +1,
4423  s: null,
4424  w: -1,
4425  nw: -1,
4426  ne: +1,
4427  se: +1,
4428  sw: -1
4429};
4430
4431var signsY = {
4432  overlay: +1,
4433  selection: +1,
4434  n: -1,
4435  e: null,
4436  s: +1,
4437  w: null,
4438  nw: -1,
4439  ne: -1,
4440  se: +1,
4441  sw: +1
4442};
4443
4444function type(t) {
4445  return {type: t};
4446}
4447
4448// Ignore right-click, since that should open the context menu.
4449function defaultFilter$1() {
4450  return !exports.event.ctrlKey && !exports.event.button;
4451}
4452
4453function defaultExtent() {
4454  var svg = this.ownerSVGElement || this;
4455  if (svg.hasAttribute("viewBox")) {
4456    svg = svg.viewBox.baseVal;
4457    return [[svg.x, svg.y], [svg.x + svg.width, svg.y + svg.height]];
4458  }
4459  return [[0, 0], [svg.width.baseVal.value, svg.height.baseVal.value]];
4460}
4461
4462function defaultTouchable$1() {
4463  return navigator.maxTouchPoints || ("ontouchstart" in this);
4464}
4465
4466// Like d3.local, but with the name “__brush” rather than auto-generated.
4467function local$1(node) {
4468  while (!node.__brush) if (!(node = node.parentNode)) return;
4469  return node.__brush;
4470}
4471
4472function empty$1(extent) {
4473  return extent[0][0] === extent[1][0]
4474      || extent[0][1] === extent[1][1];
4475}
4476
4477function brushSelection(node) {
4478  var state = node.__brush;
4479  return state ? state.dim.output(state.selection) : null;
4480}
4481
4482function brushX() {
4483  return brush$1(X);
4484}
4485
4486function brushY() {
4487  return brush$1(Y);
4488}
4489
4490function brush() {
4491  return brush$1(XY);
4492}
4493
4494function brush$1(dim) {
4495  var extent = defaultExtent,
4496      filter = defaultFilter$1,
4497      touchable = defaultTouchable$1,
4498      keys = true,
4499      listeners = dispatch("start", "brush", "end"),
4500      handleSize = 6,
4501      touchending;
4502
4503  function brush(group) {
4504    var overlay = group
4505        .property("__brush", initialize)
4506      .selectAll(".overlay")
4507      .data([type("overlay")]);
4508
4509    overlay.enter().append("rect")
4510        .attr("class", "overlay")
4511        .attr("pointer-events", "all")
4512        .attr("cursor", cursors.overlay)
4513      .merge(overlay)
4514        .each(function() {
4515          var extent = local$1(this).extent;
4516          select(this)
4517              .attr("x", extent[0][0])
4518              .attr("y", extent[0][1])
4519              .attr("width", extent[1][0] - extent[0][0])
4520              .attr("height", extent[1][1] - extent[0][1]);
4521        });
4522
4523    group.selectAll(".selection")
4524      .data([type("selection")])
4525      .enter().append("rect")
4526        .attr("class", "selection")
4527        .attr("cursor", cursors.selection)
4528        .attr("fill", "#777")
4529        .attr("fill-opacity", 0.3)
4530        .attr("stroke", "#fff")
4531        .attr("shape-rendering", "crispEdges");
4532
4533    var handle = group.selectAll(".handle")
4534      .data(dim.handles, function(d) { return d.type; });
4535
4536    handle.exit().remove();
4537
4538    handle.enter().append("rect")
4539        .attr("class", function(d) { return "handle handle--" + d.type; })
4540        .attr("cursor", function(d) { return cursors[d.type]; });
4541
4542    group
4543        .each(redraw)
4544        .attr("fill", "none")
4545        .attr("pointer-events", "all")
4546        .on("mousedown.brush", started)
4547      .filter(touchable)
4548        .on("touchstart.brush", started)
4549        .on("touchmove.brush", touchmoved)
4550        .on("touchend.brush touchcancel.brush", touchended)
4551        .style("touch-action", "none")
4552        .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
4553  }
4554
4555  brush.move = function(group, selection) {
4556    if (group.selection) {
4557      group
4558          .on("start.brush", function() { emitter(this, arguments).beforestart().start(); })
4559          .on("interrupt.brush end.brush", function() { emitter(this, arguments).end(); })
4560          .tween("brush", function() {
4561            var that = this,
4562                state = that.__brush,
4563                emit = emitter(that, arguments),
4564                selection0 = state.selection,
4565                selection1 = dim.input(typeof selection === "function" ? selection.apply(this, arguments) : selection, state.extent),
4566                i = interpolateValue(selection0, selection1);
4567
4568            function tween(t) {
4569              state.selection = t === 1 && selection1 === null ? null : i(t);
4570              redraw.call(that);
4571              emit.brush();
4572            }
4573
4574            return selection0 !== null && selection1 !== null ? tween : tween(1);
4575          });
4576    } else {
4577      group
4578          .each(function() {
4579            var that = this,
4580                args = arguments,
4581                state = that.__brush,
4582                selection1 = dim.input(typeof selection === "function" ? selection.apply(that, args) : selection, state.extent),
4583                emit = emitter(that, args).beforestart();
4584
4585            interrupt(that);
4586            state.selection = selection1 === null ? null : selection1;
4587            redraw.call(that);
4588            emit.start().brush().end();
4589          });
4590    }
4591  };
4592
4593  brush.clear = function(group) {
4594    brush.move(group, null);
4595  };
4596
4597  function redraw() {
4598    var group = select(this),
4599        selection = local$1(this).selection;
4600
4601    if (selection) {
4602      group.selectAll(".selection")
4603          .style("display", null)
4604          .attr("x", selection[0][0])
4605          .attr("y", selection[0][1])
4606          .attr("width", selection[1][0] - selection[0][0])
4607          .attr("height", selection[1][1] - selection[0][1]);
4608
4609      group.selectAll(".handle")
4610          .style("display", null)
4611          .attr("x", function(d) { return d.type[d.type.length - 1] === "e" ? selection[1][0] - handleSize / 2 : selection[0][0] - handleSize / 2; })
4612          .attr("y", function(d) { return d.type[0] === "s" ? selection[1][1] - handleSize / 2 : selection[0][1] - handleSize / 2; })
4613          .attr("width", function(d) { return d.type === "n" || d.type === "s" ? selection[1][0] - selection[0][0] + handleSize : handleSize; })
4614          .attr("height", function(d) { return d.type === "e" || d.type === "w" ? selection[1][1] - selection[0][1] + handleSize : handleSize; });
4615    }
4616
4617    else {
4618      group.selectAll(".selection,.handle")
4619          .style("display", "none")
4620          .attr("x", null)
4621          .attr("y", null)
4622          .attr("width", null)
4623          .attr("height", null);
4624    }
4625  }
4626
4627  function emitter(that, args, clean) {
4628    return (!clean && that.__brush.emitter) || new Emitter(that, args);
4629  }
4630
4631  function Emitter(that, args) {
4632    this.that = that;
4633    this.args = args;
4634    this.state = that.__brush;
4635    this.active = 0;
4636  }
4637
4638  Emitter.prototype = {
4639    beforestart: function() {
4640      if (++this.active === 1) this.state.emitter = this, this.starting = true;
4641      return this;
4642    },
4643    start: function() {
4644      if (this.starting) this.starting = false, this.emit("start");
4645      else this.emit("brush");
4646      return this;
4647    },
4648    brush: function() {
4649      this.emit("brush");
4650      return this;
4651    },
4652    end: function() {
4653      if (--this.active === 0) delete this.state.emitter, this.emit("end");
4654      return this;
4655    },
4656    emit: function(type) {
4657      customEvent(new BrushEvent(brush, type, dim.output(this.state.selection)), listeners.apply, listeners, [type, this.that, this.args]);
4658    }
4659  };
4660
4661  function started() {
4662    if (touchending && !exports.event.touches) return;
4663    if (!filter.apply(this, arguments)) return;
4664
4665    var that = this,
4666        type = exports.event.target.__data__.type,
4667        mode = (keys && exports.event.metaKey ? type = "overlay" : type) === "selection" ? MODE_DRAG : (keys && exports.event.altKey ? MODE_CENTER : MODE_HANDLE),
4668        signX = dim === Y ? null : signsX[type],
4669        signY = dim === X ? null : signsY[type],
4670        state = local$1(that),
4671        extent = state.extent,
4672        selection = state.selection,
4673        W = extent[0][0], w0, w1,
4674        N = extent[0][1], n0, n1,
4675        E = extent[1][0], e0, e1,
4676        S = extent[1][1], s0, s1,
4677        dx = 0,
4678        dy = 0,
4679        moving,
4680        shifting = signX && signY && keys && exports.event.shiftKey,
4681        lockX,
4682        lockY,
4683        pointer = exports.event.touches ? toucher(exports.event.changedTouches[0].identifier) : mouse,
4684        point0 = pointer(that),
4685        point = point0,
4686        emit = emitter(that, arguments, true).beforestart();
4687
4688    if (type === "overlay") {
4689      if (selection) moving = true;
4690      state.selection = selection = [
4691        [w0 = dim === Y ? W : point0[0], n0 = dim === X ? N : point0[1]],
4692        [e0 = dim === Y ? E : w0, s0 = dim === X ? S : n0]
4693      ];
4694    } else {
4695      w0 = selection[0][0];
4696      n0 = selection[0][1];
4697      e0 = selection[1][0];
4698      s0 = selection[1][1];
4699    }
4700
4701    w1 = w0;
4702    n1 = n0;
4703    e1 = e0;
4704    s1 = s0;
4705
4706    var group = select(that)
4707        .attr("pointer-events", "none");
4708
4709    var overlay = group.selectAll(".overlay")
4710        .attr("cursor", cursors[type]);
4711
4712    if (exports.event.touches) {
4713      emit.moved = moved;
4714      emit.ended = ended;
4715    } else {
4716      var view = select(exports.event.view)
4717          .on("mousemove.brush", moved, true)
4718          .on("mouseup.brush", ended, true);
4719      if (keys) view
4720          .on("keydown.brush", keydowned, true)
4721          .on("keyup.brush", keyupped, true);
4722
4723      dragDisable(exports.event.view);
4724    }
4725
4726    nopropagation$1();
4727    interrupt(that);
4728    redraw.call(that);
4729    emit.start();
4730
4731    function moved() {
4732      var point1 = pointer(that);
4733      if (shifting && !lockX && !lockY) {
4734        if (Math.abs(point1[0] - point[0]) > Math.abs(point1[1] - point[1])) lockY = true;
4735        else lockX = true;
4736      }
4737      point = point1;
4738      moving = true;
4739      noevent$1();
4740      move();
4741    }
4742
4743    function move() {
4744      var t;
4745
4746      dx = point[0] - point0[0];
4747      dy = point[1] - point0[1];
4748
4749      switch (mode) {
4750        case MODE_SPACE:
4751        case MODE_DRAG: {
4752          if (signX) dx = Math.max(W - w0, Math.min(E - e0, dx)), w1 = w0 + dx, e1 = e0 + dx;
4753          if (signY) dy = Math.max(N - n0, Math.min(S - s0, dy)), n1 = n0 + dy, s1 = s0 + dy;
4754          break;
4755        }
4756        case MODE_HANDLE: {
4757          if (signX < 0) dx = Math.max(W - w0, Math.min(E - w0, dx)
4757), w1 = w0 + dx, e1 = e0;
4758          else if (signX > 0) dx = Math.max(W - e0, Math.min(E - e0, dx)), w1 = w0, e1 = e0 + dx;
4759          if (signY < 0) dy = Math.max(N - n0, Math.min(S - n0, dy)), n1 = n0 + dy, s1 = s0;
4760          else if (signY > 0) dy = Math.max(N - s0, Math.min(S - s0, dy)), n1 = n0, s1 = s0 + dy;
4761          break;
4762        }
4763        case MODE_CENTER: {
4764          if (signX) w1 = Math.max(W, Math.min(E, w0 - dx * signX)), e1 = Math.max(W, Math.min(E, e0 + dx * signX));
4765          if (signY) n1 = Math.max(N, Math.min(S, n0 - dy * signY)), s1 = Math.max(N, Math.min(S, s0 + dy * signY));
4766          break;
4767        }
4768      }
4769
4770      if (e1 < w1) {
4771        signX *= -1;
4772        t = w0, w0 = e0, e0 = t;
4773        t = w1, w1 = e1, e1 = t;
4774        if (type in flipX) overlay.attr("cursor", cursors[type = flipX[type]]);
4775      }
4776
4777      if (s1 < n1) {
4778        signY *= -1;
4779        t = n0, n0 = s0, s0 = t;
4780        t = n1, n1 = s1, s1 = t;
4781        if (type in flipY) overlay.attr("cursor", cursors[type = flipY[type]]);
4782      }
4783
4784      if (state.selection) selection = state.selection; // May be set by brush.move!
4785      if (lockX) w1 = selection[0][0], e1 = selection[1][0];
4786      if (lockY) n1 = selection[0][1], s1 = selection[1][1];
4787
4788      if (selection[0][0] !== w1
4789          || selection[0][1] !== n1
4790          || selection[1][0] !== e1
4791          || selection[1][1] !== s1) {
4792        state.selection = [[w1, n1], [e1, s1]];
4793        redraw.call(that);
4794        emit.brush();
4795      }
4796    }
4797
4798    function ended() {
4799      nopropagation$1();
4800      if (exports.event.touches) {
4801        if (exports.event.touches.length) return;
4802        if (touchending) clearTimeout(touchending);
4803        touchending = setTimeout(function() { touchending = null; }, 500); // Ghost clicks are delayed!
4804      } else {
4805        yesdrag(exports.event.view, moving);
4806        view.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
4807      }
4808      group.attr("pointer-events", "all");
4809      overlay.attr("cursor", cursors.overlay);
4810      if (state.selection) selection = state.selection; // May be set by brush.move (on start)!
4811      if (empty$1(selection)) state.selection = null, redraw.call(that);
4812      emit.end();
4813    }
4814
4815    function keydowned() {
4816      switch (exports.event.keyCode) {
4817        case 16: { // SHIFT
4818          shifting = signX && signY;
4819          break;
4820        }
4821        case 18: { // ALT
4822          if (mode === MODE_HANDLE) {
4823            if (signX) e0 = e1 - dx * signX, w0 = w1 + dx * signX;
4824            if (signY) s0 = s1 - dy * signY, n0 = n1 + dy * signY;
4825            mode = MODE_CENTER;
4826            move();
4827          }
4828          break;
4829        }
4830        case 32: { // SPACE; takes priority over ALT
4831          if (mode === MODE_HANDLE || mode === MODE_CENTER) {
4832            if (signX < 0) e0 = e1 - dx; else if (signX > 0) w0 = w1 - dx;
4833            if (signY < 0) s0 = s1 - dy; else if (signY > 0) n0 = n1 - dy;
4834            mode = MODE_SPACE;
4835            overlay.attr("cursor", cursors.selection);
4836            move();
4837          }
4838          break;
4839        }
4840        default: return;
4841      }
4842      noevent$1();
4843    }
4844
4845    function keyupped() {
4846      switch (exports.event.keyCode) {
4847        case 16: { // SHIFT
4848          if (shifting) {
4849            lockX = lockY = shifting = false;
4850            move();
4851          }
4852          break;
4853        }
4854        case 18: { // ALT
4855          if (mode === MODE_CENTER) {
4856            if (signX < 0) e0 = e1; else if (signX > 0) w0 = w1;
4857            if (signY < 0) s0 = s1; else if (signY > 0) n0 = n1;
4858            mode = MODE_HANDLE;
4859            move();
4860          }
4861          break;
4862        }
4863        case 32: { // SPACE
4864          if (mode === MODE_SPACE) {
4865            if (exports.event.altKey) {
4866              if (signX) e0 = e1 - dx * signX, w0 = w1 + dx * signX;
4867              if (signY) s0 = s1 - dy * signY, n0 = n1 + dy * signY;
4868              mode = MODE_CENTER;
4869            } else {
4870              if (signX < 0) e0 = e1; else if (signX > 0) w0 = w1;
4871              if (signY < 0) s0 = s1; else if (signY > 0) n0 = n1;
4872              mode = MODE_HANDLE;
4873            }
4874            overlay.attr("cursor", cursors[type]);
4875            move();
4876          }
4877          break;
4878        }
4879        default: return;
4880      }
4881      noevent$1();
4882    }
4883  }
4884
4885  function touchmoved() {
4886    emitter(this, arguments).moved();
4887  }
4888
4889  function touchended() {
4890    emitter(this, arguments).ended();
4891  }
4892
4893  function initialize() {
4894    var state = this.__brush || {selection: null};
4895    state.extent = number2(extent.apply(this, arguments));
4896    state.dim = dim;
4897    return state;
4898  }
4899
4900  brush.extent = function(_) {
4901    return arguments.length ? (extent = typeof _ === "function" ? _ : constant$4(number2(_)), brush) : extent;
4902  };
4903
4904  brush.filter = function(_) {
4905    return arguments.length ? (filter = typeof _ === "function" ? _ : constant$4(!!_), brush) : filter;
4906  };
4907
4908  brush.touchable = function(_) {
4909    return arguments.length ? (touchable = typeof _ === "function" ? _ : constant$4(!!_), brush) : touchable;
4910  };
4911
4912  brush.handleSize = function(_) {
4913    return arguments.length ? (handleSize = +_, brush) : handleSize;
4914  };
4915
4916  brush.keyModifiers = function(_) {
4917    return arguments.length ? (keys = !!_, brush) : keys;
4918  };
4919
4920  brush.on = function() {
4921    var value = listeners.on.apply(listeners, arguments);
4922    return value === listeners ? brush : value;
4923  };
4924
4925  return brush;
4926}
4927
4928var cos = Math.cos;
4929var sin = Math.sin;
4930var pi$1 = Math.PI;
4931var halfPi$1 = pi$1 / 2;
4932var tau$1 = pi$1 * 2;
4933var max$1 = Math.max;
4934
4935function compareValue(compare) {
4936  return function(a, b) {
4937    return compare(
4938      a.source.value + a.target.value,
4939      b.source.value + b.target.value
4940    );
4941  };
4942}
4943
4944function chord() {
4945  var padAngle = 0,
4946      sortGroups = null,
4947      sortSubgroups = null,
4948      sortChords = null;
4949
4950  function chord(matrix) {
4951    var n = matrix.length,
4952        groupSums = [],
4953        groupIndex = sequence(n),
4954        subgroupIndex = [],
4955        chords = [],
4956        groups = chords.groups = new Array(n),
4957        subgroups = new Array(n * n),
4958        k,
4959        x,
4960        x0,
4961        dx,
4962        i,
4963        j;
4964
4965    // Compute the sum.
4966    k = 0, i = -1; while (++i < n) {
4967      x = 0, j = -1; while (++j < n) {
4968        x += matrix[i][j];
4969      }
4970      groupSums.push(x);
4971      subgroupIndex.push(sequence(n));
4972      k += x;
4973    }
4974
4975    // Sort groups…
4976    if (sortGroups) groupIndex.sort(function(a, b) {
4977      return sortGroups(groupSums[a], groupSums[b]);
4978    });
4979
4980    // Sort subgroups…
4981    if (sortSubgroups) subgroupIndex.forEach(function(d, i) {
4982      d.sort(function(a, b) {
4983        return sortSubgroups(matrix[i][a], matrix[i][b]);
4984      });
4985    });
4986
4987    // Convert the sum to scaling factor for [0, 2pi].
4988    // TODO Allow start and end angle to be specified?
4989    // TODO Allow padding to be specified as percentage?
4990    k = max$1(0, tau$1 - padAngle * n) / k;
4991    dx = k ? padAngle : tau$1 / n;
4992
4993    // Compute the start and end angle for each group and subgroup.
4994    // Note: Opera has a bug reordering object literal properties!
4995    x = 0, i = -1; while (++i < n) {
4996      x0 = x, j = -1; while (++j < n) {
4997        var di = groupIndex[i],
4998            dj = subgroupIndex[di][j],
4999            v = matrix[di][dj],
5000            a0 = x,
5001            a1 = x += v * k;
5002        subgroups[dj * n + di] = {
5003          index: di,
5004          subindex: dj,
5005          startAngle: a0,
5006          endAngle: a1,
5007          value: v
5008        };
5009      }
5010      groups[di] = {
5011        index: di,
5012        startAngle: x0,
5013        endAngle: x,
5014        value: groupSums[di]
5015      };
5016      x += dx;
5017    }
5018
5019    // Generate chords for each (non-empty) subgroup-subgroup link.
5020    i = -1; while (++i < n) {
vendor: 11,349 bytes, lines 5021-5415
5021      j = i - 1; while (++j < n) {
5022        var source = subgroups[j * n + i],
5023            target = subgroups[i * n + j];
5024        if (source.value || target.value) {
5025          chords.push(source.value < target.value
5026              ? {source: target, target: source}
5027              : {source: source, target: target});
5028        }
5029      }
5030    }
5031
5032    return sortChords ? chords.sort(sortChords) : chords;
5033  }
5034
5035  chord.padAngle = function(_) {
5036    return arguments.length ? (padAngle = max$1(0, _), chord) : padAngle;
5037  };
5038
5039  chord.sortGroups = function(_) {
5040    return arguments.length ? (sortGroups = _, chord) : sortGroups;
5041  };
5042
5043  chord.sortSubgroups = function(_) {
5044    return arguments.length ? (sortSubgroups = _, chord) : sortSubgroups;
5045  };
5046
5047  chord.sortChords = function(_) {
5048    return arguments.length ? (_ == null ? sortChords = null : (sortChords = compareValue(_))._ = _, chord) : sortChords && sortChords._;
5049  };
5050
5051  return chord;
5052}
5053
5054var slice$2 = Array.prototype.slice;
5055
5056function constant$5(x) {
5057  return function() {
5058    return x;
5059  };
5060}
5061
5062var pi$2 = Math.PI,
5063    tau$2 = 2 * pi$2,
5064    epsilon$1 = 1e-6,
5065    tauEpsilon = tau$2 - epsilon$1;
5066
5067function Path() {
5068  this._x0 = this._y0 = // start of current subpath
5069  this._x1 = this._y1 = null; // end of current subpath
5070  this._ = "";
5071}
5072
5073function path() {
5074  return new Path;
5075}
5076
5077Path.prototype = path.prototype = {
5078  constructor: Path,
5079  moveTo: function(x, y) {
5080    this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
5081  },
5082  closePath: function() {
5083    if (this._x1 !== null) {
5084      this._x1 = this._x0, this._y1 = this._y0;
5085      this._ += "Z";
5086    }
5087  },
5088  lineTo: function(x, y) {
5089    this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
5090  },
5091  quadraticCurveTo: function(x1, y1, x, y) {
5092    this._ += "Q" + (+x1) + "," + (+y1) + "," + (this._x1 = +x) + "," + (this._y1 = +y);
5093  },
5094  bezierCurveTo: function(x1, y1, x2, y2, x, y) {
5095    this._ += "C" + (+x1) + "," + (+y1) + "," + (+x2) + "," + (+y2) + "," + (this._x1 = +x) + "," + (this._y1 = +y);
5096  },
5097  arcTo: function(x1, y1, x2, y2, r) {
5098    x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
5099    var x0 = this._x1,
5100        y0 = this._y1,
5101        x21 = x2 - x1,
5102        y21 = y2 - y1,
5103        x01 = x0 - x1,
5104        y01 = y0 - y1,
5105        l01_2 = x01 * x01 + y01 * y01;
5106
5107    // Is the radius negative? Error.
5108    if (r < 0) throw new Error("negative radius: " + r);
5109
5110    // Is this path empty? Move to (x1,y1).
5111    if (this._x1 === null) {
5112      this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
5113    }
5114
5115    // Or, is (x1,y1) coincident with (x0,y0)? Do nothing.
5116    else if (!(l01_2 > epsilon$1));
5117
5118    // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?
5119    // Equivalently, is (x1,y1) coincident with (x2,y2)?
5120    // Or, is the radius zero? Line to (x1,y1).
5121    else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon$1) || !r) {
5122      this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
5123    }
5124
5125    // Otherwise, draw an arc!
5126    else {
5127      var x20 = x2 - x0,
5128          y20 = y2 - y0,
5129          l21_2 = x21 * x21 + y21 * y21,
5130          l20_2 = x20 * x20 + y20 * y20,
5131          l21 = Math.sqrt(l21_2),
5132          l01 = Math.sqrt(l01_2),
5133          l = r * Math.tan((pi$2 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),
5134          t01 = l / l01,
5135          t21 = l / l21;
5136
5137      // If the start tangent is not coincident with (x0,y0), line to.
5138      if (Math.abs(t01 - 1) > epsilon$1) {
5139        this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
5140      }
5141
5142      this._ += "A" + r + "," + r + ",0,0," + (+(y01 * x20 > x01 * y20)) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
5143    }
5144  },
5145  arc: function(x, y, r, a0, a1, ccw) {
5146    x = +x, y = +y, r = +r, ccw = !!ccw;
5147    var dx = r * Math.cos(a0),
5148        dy = r * Math.sin(a0),
5149        x0 = x + dx,
5150        y0 = y + dy,
5151        cw = 1 ^ ccw,
5152        da = ccw ? a0 - a1 : a1 - a0;
5153
5154    // Is the radius negative? Error.
5155    if (r < 0) throw new Error("negative radius: " + r);
5156
5157    // Is this path empty? Move to (x0,y0).
5158    if (this._x1 === null) {
5159      this._ += "M" + x0 + "," + y0;
5160    }
5161
5162    // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).
5163    else if (Math.abs(this._x1 - x0) > epsilon$1 || Math.abs(this._y1 - y0) > epsilon$1) {
5164      this._ += "L" + x0 + "," + y0;
5165    }
5166
5167    // Is this arc empty? We’re done.
5168    if (!r) return;
5169
5170    // Does the angle go the wrong way? Flip the direction.
5171    if (da < 0) da = da % tau$2 + tau$2;
5172
5173    // Is this a complete circle? Draw two arcs to complete the circle.
5174    if (da > tauEpsilon) {
5175      this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
5176    }
5177
5178    // Is this arc non-empty? Draw an arc!
5179    else if (da > epsilon$1) {
5180      this._ += "A" + r + "," + r + ",0," + (+(da >= pi$2)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
5181    }
5182  },
5183  rect: function(x, y, w, h) {
5184    this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + (+w) + "v" + (+h) + "h" + (-w) + "Z";
5185  },
5186  toString: function() {
5187    return this._;
5188  }
5189};
5190
5191function defaultSource(d) {
5192  return d.source;
5193}
5194
5195function defaultTarget(d) {
5196  return d.target;
5197}
5198
5199function defaultRadius(d) {
5200  return d.radius;
5201}
5202
5203function defaultStartAngle(d) {
5204  return d.startAngle;
5205}
5206
5207function defaultEndAngle(d) {
5208  return d.endAngle;
5209}
5210
5211function ribbon() {
5212  var source = defaultSource,
5213      target = defaultTarget,
5214      radius = defaultRadius,
5215      startAngle = defaultStartAngle,
5216      endAngle = defaultEndAngle,
5217      context = null;
5218
5219  function ribbon() {
5220    var buffer,
5221        argv = slice$2.call(arguments),
5222        s = source.apply(this, argv),
5223        t = target.apply(this, argv),
5224        sr = +radius.apply(this, (argv[0] = s, argv)),
5225        sa0 = startAngle.apply(this, argv) - halfPi$1,
5226        sa1 = endAngle.apply(this, argv) - halfPi$1,
5227        sx0 = sr * cos(sa0),
5228        sy0 = sr * sin(sa0),
5229        tr = +radius.apply(this, (argv[0] = t, argv)),
5230        ta0 = startAngle.apply(this, argv) - halfPi$1,
5231        ta1 = endAngle.apply(this, argv) - halfPi$1;
5232
5233    if (!context) context = buffer = path();
5234
5235    context.moveTo(sx0, sy0);
5236    context.arc(0, 0, sr, sa0, sa1);
5237    if (sa0 !== ta0 || sa1 !== ta1) { // TODO sr !== tr?
5238      context.quadraticCurveTo(0, 0, tr * cos(ta0), tr * sin(ta0));
5239      context.arc(0, 0, tr, ta0, ta1);
5240    }
5241    context.quadraticCurveTo(0, 0, sx0, sy0);
5242    context.closePath();
5243
5244    if (buffer) return context = null, buffer + "" || null;
5245  }
5246
5247  ribbon.radius = function(_) {
5248    return arguments.length ? (radius = typeof _ === "function" ? _ : constant$5(+_), ribbon) : radius;
5249  };
5250
5251  ribbon.startAngle = function(_) {
5252    return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$5(+_), ribbon) : startAngle;
5253  };
5254
5255  ribbon.endAngle = function(_) {
5256    return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$5(+_), ribbon) : endAngle;
5257  };
5258
5259  ribbon.source = function(_) {
5260    return arguments.length ? (source = _, ribbon) : source;
5261  };
5262
5263  ribbon.target = function(_) {
5264    return arguments.length ? (target = _, ribbon) : target;
5265  };
5266
5267  ribbon.context = function(_) {
5268    return arguments.length ? ((context = _ == null ? null : _), ribbon) : context;
5269  };
5270
5271  return ribbon;
5272}
5273
5274var prefix = "$";
5275
5276function Map() {}
5277
5278Map.prototype = map$1.prototype = {
5279  constructor: Map,
5280  has: function(key) {
5281    return (prefix + key) in this;
5282  },
5283  get: function(key) {
5284    return this[prefix + key];
5285  },
5286  set: function(key, value) {
5287    this[prefix + key] = value;
5288    return this;
5289  },
5290  remove: function(key) {
5291    var property = prefix + key;
5292    return property in this && delete this[property];
5293  },
5294  clear: function() {
5295    for (var property in this) if (property[0] === prefix) delete this[property];
5296  },
5297  keys: function() {
5298    var keys = [];
5299    for (var property in this) if (property[0] === prefix) keys.push(property.slice(1));
5300    return keys;
5301  },
5302  values: function() {
5303    var values = [];
5304    for (var property in this) if (property[0] === prefix) values.push(this[property]);
5305    return values;
5306  },
5307  entries: function() {
5308    var entries = [];
5309    for (var property in this) if (property[0] === prefix) entries.push({key: property.slice(1), value: this[property]});
5310    return entries;
5311  },
5312  size: function() {
5313    var size = 0;
5314    for (var property in this) if (property[0] === prefix) ++size;
5315    return size;
5316  },
5317  empty: function() {
5318    for (var property in this) if (property[0] === prefix) return false;
5319    return true;
5320  },
5321  each: function(f) {
5322    for (var property in this) if (property[0] === prefix) f(this[property], property.slice(1), this);
5323  }
5324};
5325
5326function map$1(object, f) {
5327  var map = new Map;
5328
5329  // Copy constructor.
5330  if (object instanceof Map) object.each(function(value, key) { map.set(key, value); });
5331
5332  // Index array by numeric index or specified key function.
5333  else if (Array.isArray(object)) {
5334    var i = -1,
5335        n = object.length,
5336        o;
5337
5338    if (f == null) while (++i < n) map.set(i, object[i]);
5339    else while (++i < n) map.set(f(o = object[i], i, object), o);
5340  }
5341
5342  // Convert object to map.
5343  else if (object) for (var key in object) map.set(key, object[key]);
5344
5345  return map;
5346}
5347
5348function nest() {
5349  var keys = [],
5350      sortKeys = [],
5351      sortValues,
5352      rollup,
5353      nest;
5354
5355  function apply(array, depth, createResult, setResult) {
5356    if (depth >= keys.length) {
5357      if (sortValues != null) array.sort(sortValues);
5358      return rollup != null ? rollup(array) : array;
5359    }
5360
5361    var i = -1,
5362        n = array.length,
5363        key = keys[depth++],
5364        keyValue,
5365        value,
5366        valuesByKey = map$1(),
5367        values,
5368        result = createResult();
5369
5370    while (++i < n) {
5371      if (values = valuesByKey.get(keyValue = key(value = array[i]) + "")) {
5372        values.push(value);
5373      } else {
5374        valuesByKey.set(keyValue, [value]);
5375      }
5376    }
5377
5378    valuesByKey.each(function(values, key) {
5379      setResult(result, key, apply(values, depth, createResult, setResult));
5380    });
5381
5382    return result;
5383  }
5384
5385  function entries(map, depth) {
5386    if (++depth > keys.length) return map;
5387    var array, sortKey = sortKeys[depth - 1];
5388    if (rollup != null && depth >= keys.length) array = map.entries();
5389    else array = [], map.each(function(v, k) { array.push({key: k, values: entries(v, depth)}); });
5390    return sortKey != null ? array.sort(function(a, b) { return sortKey(a.key, b.key); }) : array;
5391  }
5392
5393  return nest = {
5394    object: function(array) { return apply(array, 0, createObject, setObject); },
5395    map: function(array) { return apply(array, 0, createMap, setMap); },
5396    entries: function(array) { return entries(apply(array, 0, createMap, setMap), 0); },
5397    key: function(d) { keys.push(d); return nest; },
5398    sortKeys: function(order) { sortKeys[keys.length - 1] = order; return nest; },
5399    sortValues: function(order) { sortValues = order; return nest; },
5400    rollup: function(f) { rollup = f; return nest; }
5401  };
5402}
5403
5404function createObject() {
5405  return {};
5406}
5407
5408function setObject(object, key, value) {
5409  object[key] = value;
5410}
5411
5412function createMap() {
5413  return map$1();
5414}
5415
vendor: 4,668 bytes, lines 5416-5603
5416function setMap(map, key, value) {
5417  map.set(key, value);
5418}
5419
5420function Set() {}
5421
5422var proto = map$1.prototype;
5423
5424Set.prototype = set$2.prototype = {
5425  constructor: Set,
5426  has: proto.has,
5427  add: function(value) {
5428    value += "";
5429    this[prefix + value] = value;
5430    return this;
5431  },
5432  remove: proto.remove,
5433  clear: proto.clear,
5434  values: proto.keys,
5435  size: proto.size,
5436  empty: proto.empty,
5437  each: proto.each
5438};
5439
5440function set$2(object, f) {
5441  var set = new Set;
5442
5443  // Copy constructor.
5444  if (object instanceof Set) object.each(function(value) { set.add(value); });
5445
5446  // Otherwise, assume it’s an array.
5447  else if (object) {
5448    var i = -1, n = object.length;
5449    if (f == null) while (++i < n) set.add(object[i]);
5450    else while (++i < n) set.add(f(object[i], i, object));
5451  }
5452
5453  return set;
5454}
5455
5456function keys(map) {
5457  var keys = [];
5458  for (var key in map) keys.push(key);
5459  return keys;
5460}
5461
5462function values(map) {
5463  var values = [];
5464  for (var key in map) values.push(map[key]);
5465  return values;
5466}
5467
5468function entries(map) {
5469  var entries = [];
5470  for (var key in map) entries.push({key: key, value: map[key]});
5471  return entries;
5472}
5473
5474var array$2 = Array.prototype;
5475
5476var slice$3 = array$2.slice;
5477
5478function ascending$2(a, b) {
5479  return a - b;
5480}
5481
5482function area(ring) {
5483  var i = 0, n = ring.length, area = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1];
5484  while (++i < n) area += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1];
5485  return area;
5486}
5487
5488function constant$6(x) {
5489  return function() {
5490    return x;
5491  };
5492}
5493
5494function contains(ring, hole) {
5495  var i = -1, n = hole.length, c;
5496  while (++i < n) if (c = ringContains(ring, hole[i])) return c;
5497  return 0;
5498}
5499
5500function ringContains(ring, point) {
5501  var x = point[0], y = point[1], contains = -1;
5502  for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) {
5503    var pi = ring[i], xi = pi[0], yi = pi[1], pj = ring[j], xj = pj[0], yj = pj[1];
5504    if (segmentContains(pi, pj, point)) return 0;
5505    if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) contains = -contains;
5506  }
5507  return contains;
5508}
5509
5510function segmentContains(a, b, c) {
5511  var i; return collinear(a, b, c) && within(a[i = +(a[0] === b[0])], c[i], b[i]);
5512}
5513
5514function collinear(a, b, c) {
5515  return (b[0] - a[0]) * (c[1] - a[1]) === (c[0] - a[0]) * (b[1] - a[1]);
5516}
5517
5518function within(p, q, r) {
5519  return p <= q && q <= r || r <= q && q <= p;
5520}
5521
5522function noop$1() {}
5523
5524var cases = [
5525  [],
5526  [[[1.0, 1.5], [0.5, 1.0]]],
5527  [[[1.5, 1.0], [1.0, 1.5]]],
5528  [[[1.5, 1.0], [0.5, 1.0]]],
5529  [[[1.0, 0.5], [1.5, 1.0]]],
5530  [[[1.0, 1.5], [0.5, 1.0]], [[1.0, 0.5], [1.5, 1.0]]],
5531  [[[1.0, 0.5], [1.0, 1.5]]],
5532  [[[1.0, 0.5], [0.5, 1.0]]],
5533  [[[0.5, 1.0], [1.0, 0.5]]],
5534  [[[1.0, 1.5], [1.0, 0.5]]],
5535  [[[0.5, 1.0], [1.0, 0.5]], [[1.5, 1.0], [1.0, 1.5]]],
5536  [[[1.5, 1.0], [1.0, 0.5]]],
5537  [[[0.5, 1.0], [1.5, 1.0]]],
5538  [[[1.0, 1.5], [1.5, 1.0]]],
5539  [[[0.5, 1.0], [1.0, 1.5]]],
5540  []
5541];
5542
5543function contours() {
5544  var dx = 1,
5545      dy = 1,
5546      threshold = thresholdSturges,
5547      smooth = smoothLinear;
5548
5549  function contours(values) {
5550    var tz = threshold(values);
5551
5552    // Convert number of thresholds into uniform thresholds.
5553    if (!Array.isArray(tz)) {
5554      var domain = extent(values), start = domain[0], stop = domain[1];
5555      tz = tickStep(start, stop, tz);
5556      tz = sequence(Math.floor(start / tz) * tz, Math.floor(stop / tz) * tz, tz);
5557    } else {
5558      tz = tz.slice().sort(ascending$2);
5559    }
5560
5561    return tz.map(function(value) {
5562      return contour(values, value);
5563    });
5564  }
5565
5566  // Accumulate, smooth contour rings, assign holes to exterior rings.
5567  // Based on https://github.com/mbostock/shapefile/blob/v0.6.2/shp/polygon.js
5568  function contour(values, value) {
5569    var polygons = [],
5570        holes = [];
5571
5572    isorings(values, value, function(ring) {
5573      smooth(ring, values, value);
5574      if (area(ring) > 0) polygons.push([ring]);
5575      else holes.push(ring);
5576    });
5577
5578    holes.forEach(function(hole) {
5579      for (var i = 0, n = polygons.length, polygon; i < n; ++i) {
5580        if (contains((polygon = polygons[i])[0], hole) !== -1) {
5581          polygon.push(hole);
5582          return;
5583        }
5584      }
5585    });
5586
5587    return {
5588      type: "MultiPolygon",
5589      value: value,
5590      coordinates: polygons
5591    };
5592  }
5593
5594  // Marching squares with isolines stitched into rings.
5595  // Based on https://github.com/topojson/topojson-client/blob/v3.0.0/src/stitch.js
5596  function isorings(values, value, callback) {
5597    var fragmentByStart = new Array,
5598        fragmentByEnd = new Array,
5599        x, y, t0, t1, t2, t3;
5600
5601    // Special case for the first row (y = -1, t2 = t3 = 0).
5602    x = y = -1;
5603    t1 = values[0] >= value;
vendor: 4,889 bytes, lines 5604-5771
5604    cases[t1 << 1].forEach(stitch);
5605    while (++x < dx - 1) {
5606      t0 = t1, t1 = values[x + 1] >= value;
5607      cases[t0 | t1 << 1].forEach(stitch);
5608    }
5609    cases[t1 << 0].forEach(stitch);
5610
5611    // General case for the intermediate rows.
5612    while (++y < dy - 1) {
5613      x = -1;
5614      t1 = values[y * dx + dx] >= value;
5615      t2 = values[y * dx] >= value;
5616      cases[t1 << 1 | t2 << 2].forEach(stitch);
5617      while (++x < dx - 1) {
5618        t0 = t1, t1 = values[y * dx + dx + x + 1] >= value;
5619        t3 = t2, t2 = values[y * dx + x + 1] >= value;
5620        cases[t0 | t1 << 1 | t2 << 2 | t3 << 3].forEach(stitch);
5621      }
5622      cases[t1 | t2 << 3].forEach(stitch);
5623    }
5624
5625    // Special case for the last row (y = dy - 1, t0 = t1 = 0).
5626    x = -1;
5627    t2 = values[y * dx] >= value;
5628    cases[t2 << 2].forEach(stitch);
5629    while (++x < dx - 1) {
5630      t3 = t2, t2 = values[y * dx + x + 1] >= value;
5631      cases[t2 << 2 | t3 << 3].forEach(stitch);
5632    }
5633    cases[t2 << 3].forEach(stitch);
5634
5635    function stitch(line) {
5636      var start = [line[0][0] + x, line[0][1] + y],
5637          end = [line[1][0] + x, line[1][1] + y],
5638          startIndex = index(start),
5639          endIndex = index(end),
5640          f, g;
5641      if (f = fragmentByEnd[startIndex]) {
5642        if (g = fragmentByStart[endIndex]) {
5643          delete fragmentByEnd[f.end];
5644          delete fragmentByStart[g.start];
5645          if (f === g) {
5646            f.ring.push(end);
5647            callback(f.ring);
5648          } else {
5649            fragmentByStart[f.start] = fragmentByEnd[g.end] = {start: f.start, end: g.end, ring: f.ring.concat(g.ring)};
5650          }
5651        } else {
5652          delete fragmentByEnd[f.end];
5653          f.ring.push(end);
5654          fragmentByEnd[f.end = endIndex] = f;
5655        }
5656      } else if (f = fragmentByStart[endIndex]) {
5657        if (g = fragmentByEnd[startIndex]) {
5658          delete fragmentByStart[f.start];
5659          delete fragmentByEnd[g.end];
5660          if (f === g) {
5661            f.ring.push(end);
5662            callback(f.ring);
5663          } else {
5664            fragmentByStart[g.start] = fragmentByEnd[f.end] = {start: g.start, end: f.end, ring: g.ring.concat(f.ring)};
5665          }
5666        } else {
5667          delete fragmentByStart[f.start];
5668          f.ring.unshift(start);
5669          fragmentByStart[f.start = startIndex] = f;
5670        }
5671      } else {
5672        fragmentByStart[startIndex] = fragmentByEnd[endIndex] = {start: startIndex, end: endIndex, ring: [start, end]};
5673      }
5674    }
5675  }
5676
5677  function index(point) {
5678    return point[0] * 2 + point[1] * (dx + 1) * 4;
5679  }
5680
5681  function smoothLinear(ring, values, value) {
5682    ring.forEach(function(point) {
5683      var x = point[0],
5684          y = point[1],
5685          xt = x | 0,
5686          yt = y | 0,
5687          v0,
5688          v1 = values[yt * dx + xt];
5689      if (x > 0 && x < dx && xt === x) {
5690        v0 = values[yt * dx + xt - 1];
5691        point[0] = x + (value - v0) / (v1 - v0) - 0.5;
5692      }
5693      if (y > 0 && y < dy && yt === y) {
5694        v0 = values[(yt - 1) * dx + xt];
5695        point[1] = y + (value - v0) / (v1 - v0) - 0.5;
5696      }
5697    });
5698  }
5699
5700  contours.contour = contour;
5701
5702  contours.size = function(_) {
5703    if (!arguments.length) return [dx, dy];
5704    var _0 = Math.ceil(_[0]), _1 = Math.ceil(_[1]);
5705    if (!(_0 > 0) || !(_1 > 0)) throw new Error("invalid size");
5706    return dx = _0, dy = _1, contours;
5707  };
5708
5709  contours.thresholds = function(_) {
5710    return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant$6(slice$3.call(_)) : constant$6(_), contours) : threshold;
5711  };
5712
5713  contours.smooth = function(_) {
5714    return arguments.length ? (smooth = _ ? smoothLinear : noop$1, contours) : smooth === smoothLinear;
5715  };
5716
5717  return contours;
5718}
5719
5720// TODO Optimize edge cases.
5721// TODO Optimize index calculation.
5722// TODO Optimize arguments.
5723function blurX(source, target, r) {
5724  var n = source.width,
5725      m = source.height,
5726      w = (r << 1) + 1;
5727  for (var j = 0; j < m; ++j) {
5728    for (var i = 0, sr = 0; i < n + r; ++i) {
5729      if (i < n) {
5730        sr += source.data[i + j * n];
5731      }
5732      if (i >= r) {
5733        if (i >= w) {
5734          sr -= source.data[i - w + j * n];
5735        }
5736        target.data[i - r + j * n] = sr / Math.min(i + 1, n - 1 + w - i, w);
5737      }
5738    }
5739  }
5740}
5741
5742// TODO Optimize edge cases.
5743// TODO Optimize index calculation.
5744// TODO Optimize arguments.
5745function blurY(source, target, r) {
5746  var n = source.width,
5747      m = source.height,
5748      w = (r << 1) + 1;
5749  for (var i = 0; i < n; ++i) {
5750    for (var j = 0, sr = 0; j < m + r; ++j) {
5751      if (j < m) {
5752        sr += source.data[i + j * n];
5753      }
5754      if (j >= r) {
5755        if (j >= w) {
5756          sr -= source.data[i + (j - w) * n];
5757        }
5758        target.data[i + (j - r) * n] = sr / Math.min(j + 1, m - 1 + w - j, w);
5759      }
5760    }
5761  }
5762}
5763
5764function defaultX(d) {
5765  return d[0];
5766}
5767
5768function defaultY(d) {
5769  return d[1];
5770}
5771
5772function defaultWeight() {
5773  return 1;
5774}
5775
5776function density() {
5777  var x = defaultX,
5778      y = defaultY,
5779      weight = defaultWeight,
5780      dx = 960,
5781      dy = 500,
5782      r = 20, // blur radius
5783      k = 2, // log2(grid cell size)
5784      o = r * 3, // grid offset, to pad for blur
5785      n = (dx + o * 2) >> k, // grid width
5786      m = (dy + o * 2) >> k, // grid height
5787      threshold = constant$6(20);
5788
5789  function density(data) {
5790    var values0 = new Float32Array(n * m),
5791        values1 = new Float32Array(n * m);
5792
5793    data.forEach(function(d, i, data) {
5794      var xi = (+x(d, i, data) + o) >> k,
5795          yi = (+y(d, i, data) + o) >> k,
5796          wi = +weight(d, i, data);
5797      if (xi >= 0 && xi < n && yi >= 0 && yi < m) {
5798        values0[xi + yi * n] += wi;
5799      }
5800    });
5801
5802    // TODO Optimize.
5803    blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k);
5804    blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k);
5805    blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k);
5806    blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k);
5807    blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k);
5808    blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k);
5809
5810    var tz = threshold(values0);
5811
5812    // Convert number of thresholds into uniform thresholds.
5813    if (!Array.isArray(tz)) {
5814      var stop = max(values0);
5815      tz = tickStep(0, stop, tz);
5816      tz = sequence(0, Math.floor(stop / tz) * tz, tz);
5817      tz.shift();
5818    }
5819
5820    return contours()
5821        .thresholds(tz)
5822        .size([n, m])
5823      (values0)
5824        .map(transform);
5825  }
5826
5827  function transform(geometry) {
5828    geometry.value *= Math.pow(2, -2 * k); // Density in points per square pixel.
5829    geometry.coordinates.forEach(transformPolygon);
5830    return geometry;
5831  }
5832
5833  function transformPolygon(coordinates) {
5834    coordinates.forEach(transformRing);
5835  }
5836
5837  function transformRing(coordinates) {
5838    coordinates.forEach(transformPoint);
5839  }
5840
5841  // TODO Optimize.
5842  function transformPoint(coordinates) {
5843    coordinates[0] = coordinates[0] * Math.pow(2, k) - o;
5844    coordinates[1] = coordinates[1] * Math.pow(2, k) - o;
5845  }
5846
5847  function resize() {
5848    o = r * 3;
5849    n = (dx + o * 2) >> k;
5850    m = (dy + o * 2) >> k;
5851    return density;
5852  }
5853
5854  density.x = function(_) {
5855    return arguments.length ? (x = typeof _ === "function" ? _ : constant$6(+_), density) : x;
5856  };
5857
5858  density.y = function(_) {
5859    return arguments.length ? (y = typeof _ === "function" ? _ : constant$6(+_), density) : y;
5860  };
5861
5862  density.weight = function(_) {
5863    return arguments.length ? (weight = typeof _ === "function" ? _ : constant$6(+_), density) : weight;
5864  };
5865
5866  density.size = function(_) {
5867    if (!arguments.length) return [dx, dy];
5868    var _0 = Math.ceil(_[0]), _1 = Math.ceil(_[1]);
5869    if (!(_0 >= 0) && !(_0 >= 0)) throw new Error("invalid size");
5870    return dx = _0, dy = _1, resize();
5871  };
5872
5873  density.cellSize = function(_) {
5874    if (!arguments.length) return 1 << k;
5875    if (!((_ = +_) >= 1)) throw new Error("invalid cell size");
5876    return k = Math.floor(Math.log(_) / Math.LN2), resize();
5877  };
5878
5879  density.thresholds = function(_) {
5880    return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant$6(slice$3.call(_)) : constant$6(_), density) : threshold;
5881  };
5882
5883  density.bandwidth = function(_) {
5884    if (!arguments.length) return Math.sqrt(r * (r + 1));
5885    if (!((_ = +_) >= 0)) throw new Error("invalid bandwidth");
5886    return r = Math.round((Math.sqrt(4 * _ * _ + 1) - 1) / 2), resize();
5887  };
5888
5889  return density;
5890}
5891
5892var EOL = {},
5893    EOF = {},
5894    QUOTE = 34,
5895    NEWLINE = 10,
5896    RETURN = 13;
5897
5898function objectConverter(columns) {
5899  return new Function("d", "return {" + columns.map(function(name, i) {
5900    return JSON.stringify(name) + ": d[" + i + "] || \"\"";
5901  }).join(",") + "}");
5902}
5903
5904function customConverter(columns, f) {
5905  var object = objectConverter(columns);
5906  return function(row, i) {
5907    return f(object(row), i, columns);
5908  };
5909}
5910
5911// Compute unique columns in order of discovery.
5912function inferColumns(rows) {
5913  var columnSet = Object.create(null),
5914      columns = [];
5915
5916  rows.forEach(function(row) {
5917    for (var column in row) {
5918      if (!(column in columnSet)) {
5919        columns.push(columnSet[column] = column);
5920      }
5921    }
5922  });
5923
5924  return columns;
5925}
5926
5927function pad(value, width) {
5928  var s = value + "", length = s.length;
5929  return length < width ? new Array(width - length + 1).join(0) + s : s;
5930}
5931
5932function formatYear(year) {
vendor: 10,983 bytes, lines 5933-6328
5933  return year < 0 ? "-" + pad(-year, 6)
5934    : year > 9999 ? "+" + pad(year, 6)
5935    : pad(year, 4);
5936}
5937
5938function formatDate(date) {
5939  var hours = date.getUTCHours(),
5940      minutes = date.getUTCMinutes(),
5941      seconds = date.getUTCSeconds(),
5942      milliseconds = date.getUTCMilliseconds();
5943  return isNaN(date) ? "Invalid Date"
5944      : formatYear(date.getUTCFullYear()) + "-" + pad(date.getUTCMonth() + 1, 2) + "-" + pad(date.getUTCDate(), 2)
5945      + (milliseconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "." + pad(milliseconds, 3) + "Z"
5946      : seconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "Z"
5947      : minutes || hours ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + "Z"
5948      : "");
5949}
5950
5951function dsvFormat(delimiter) {
5952  var reFormat = new RegExp("[\"" + delimiter + "\n\r]"),
5953      DELIMITER = delimiter.charCodeAt(0);
5954
5955  function parse(text, f) {
5956    var convert, columns, rows = parseRows(text, function(row, i) {
5957      if (convert) return convert(row, i - 1);
5958      columns = row, convert = f ? customConverter(row, f) : objectConverter(row);
5959    });
5960    rows.columns = columns || [];
5961    return rows;
5962  }
5963
5964  function parseRows(text, f) {
5965    var rows = [], // output rows
5966        N = text.length,
5967        I = 0, // current character index
5968        n = 0, // current line number
5969        t, // current token
5970        eof = N <= 0, // current token followed by EOF?
5971        eol = false; // current token followed by EOL?
5972
5973    // Strip the trailing newline.
5974    if (text.charCodeAt(N - 1) === NEWLINE) --N;
5975    if (text.charCodeAt(N - 1) === RETURN) --N;
5976
5977    function token() {
5978      if (eof) return EOF;
5979      if (eol) return eol = false, EOL;
5980
5981      // Unescape quotes.
5982      var i, j = I, c;
5983      if (text.charCodeAt(j) === QUOTE) {
5984        while (I++ < N && text.charCodeAt(I) !== QUOTE || text.charCodeAt(++I) === QUOTE);
5985        if ((i = I) >= N) eof = true;
5986        else if ((c = text.charCodeAt(I++)) === NEWLINE) eol = true;
5987        else if (c === RETURN) { eol = true; if (text.charCodeAt(I) === NEWLINE) ++I; }
5988        return text.slice(j + 1, i - 1).replace(/""/g, "\"");
5989      }
5990
5991      // Find next delimiter or newline.
5992      while (I < N) {
5993        if ((c = text.charCodeAt(i = I++)) === NEWLINE) eol = true;
5994        else if (c === RETURN) { eol = true; if (text.charCodeAt(I) === NEWLINE) ++I; }
5995        else if (c !== DELIMITER) continue;
5996        return text.slice(j, i);
5997      }
5998
5999      // Return last token before EOF.
6000      return eof = true, text.slice(j, N);
6001    }
6002
6003    while ((t = token()) !== EOF) {
6004      var row = [];
6005      while (t !== EOL && t !== EOF) row.push(t), t = token();
6006      if (f && (row = f(row, n++)) == null) continue;
6007      rows.push(row);
6008    }
6009
6010    return rows;
6011  }
6012
6013  function preformatBody(rows, columns) {
6014    return rows.map(function(row) {
6015      return columns.map(function(column) {
6016        return formatValue(row[column]);
6017      }).join(delimiter);
6018    });
6019  }
6020
6021  function format(rows, columns) {
6022    if (columns == null) columns = inferColumns(rows);
6023    return [columns.map(formatValue).join(delimiter)].concat(preformatBody(rows, columns)).join("\n");
6024  }
6025
6026  function formatBody(rows, columns) {
6027    if (columns == null) columns = inferColumns(rows);
6028    return preformatBody(rows, columns).join("\n");
6029  }
6030
6031  function formatRows(rows) {
6032    return rows.map(formatRow).join("\n");
6033  }
6034
6035  function formatRow(row) {
6036    return row.map(formatValue).join(delimiter);
6037  }
6038
6039  function formatValue(value) {
6040    return value == null ? ""
6041        : value instanceof Date ? formatDate(value)
6042        : reFormat.test(value += "") ? "\"" + value.replace(/"/g, "\"\"") + "\""
6043        : value;
6044  }
6045
6046  return {
6047    parse: parse,
6048    parseRows: parseRows,
6049    format: format,
6050    formatBody: formatBody,
6051    formatRows: formatRows,
6052    formatRow: formatRow,
6053    formatValue: formatValue
6054  };
6055}
6056
6057var csv = dsvFormat(",");
6058
6059var csvParse = csv.parse;
6060var csvParseRows = csv.parseRows;
6061var csvFormat = csv.format;
6062var csvFormatBody = csv.formatBody;
6063var csvFormatRows = csv.formatRows;
6064var csvFormatRow = csv.formatRow;
6065var csvFormatValue = csv.formatValue;
6066
6067var tsv = dsvFormat("\t");
6068
6069var tsvParse = tsv.parse;
6070var tsvParseRows = tsv.parseRows;
6071var tsvFormat = tsv.format;
6072var tsvFormatBody = tsv.formatBody;
6073var tsvFormatRows = tsv.formatRows;
6074var tsvFormatRow = tsv.formatRow;
6075var tsvFormatValue = tsv.formatValue;
6076
6077function autoType(object) {
6078  for (var key in object) {
6079    var value = object[key].trim(), number, m;
6080    if (!value) value = null;
6081    else if (value === "true") value = true;
6082    else if (value === "false") value = false;
6083    else if (value === "NaN") value = NaN;
6084    else if (!isNaN(number = +value)) value = number;
6085    else if (m = value.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)) {
6086      if (fixtz && !!m[4] && !m[7]) value = value.replace(/-/g, "/").replace(/T/, " ");
6087      value = new Date(value);
6088    }
6089    else continue;
6090    object[key] = value;
6091  }
6092  return object;
6093}
6094
6095// https://github.com/d3/d3-dsv/issues/45
6096var fixtz = new Date("2019-01-01T00:00").getHours() || new Date("2019-07-01T00:00").getHours();
6097
6098function responseBlob(response) {
6099  if (!response.ok) throw new Error(response.status + " " + response.statusText);
6100  return response.blob();
6101}
6102
6103function blob(input, init) {
6104  return fetch(input, init).then(responseBlob);
6105}
6106
6107function responseArrayBuffer(response) {
6108  if (!response.ok) throw new Error(response.status + " " + response.statusText);
6109  return response.arrayBuffer();
6110}
6111
6112function buffer(input, init) {
6113  return fetch(input, init).then(responseArrayBuffer);
6114}
6115
6116function responseText(response) {
6117  if (!response.ok) throw new Error(response.status + " " + response.statusText);
6118  return response.text();
6119}
6120
6121function text(input, init) {
6122  return fetch(input, init).then(responseText);
6123}
6124
6125function dsvParse(parse) {
6126  return function(input, init, row) {
6127    if (arguments.length === 2 && typeof init === "function") row = init, init = undefined;
6128    return text(input, init).then(function(response) {
6129      return parse(response, row);
6130    });
6131  };
6132}
6133
6134function dsv(delimiter, input, init, row) {
6135  if (arguments.length === 3 && typeof init === "function") row = init, init = undefined;
6136  var format = dsvFormat(delimiter);
6137  return text(input, init).then(function(response) {
6138    return format.parse(response, row);
6139  });
6140}
6141
6142var csv$1 = dsvParse(csvParse);
6143var tsv$1 = dsvParse(tsvParse);
6144
6145function image(input, init) {
6146  return new Promise(function(resolve, reject) {
6147    var image = new Image;
6148    for (var key in init) image[key] = init[key];
6149    image.onerror = reject;
6150    image.onload = function() { resolve(image); };
6151    image.src = input;
6152  });
6153}
6154
6155function responseJson(response) {
6156  if (!response.ok) throw new Error(response.status + " " + response.statusText);
6157  return response.json();
6158}
6159
6160function json(input, init) {
6161  return fetch(input, init).then(responseJson);
6162}
6163
6164function parser(type) {
6165  return function(input, init)  {
6166    return text(input, init).then(function(text) {
6167      return (new DOMParser).parseFromString(text, type);
6168    });
6169  };
6170}
6171
6172var xml = parser("application/xml");
6173
6174var html = parser("text/html");
6175
6176var svg = parser("image/svg+xml");
6177
6178function center$1(x, y) {
6179  var nodes;
6180
6181  if (x == null) x = 0;
6182  if (y == null) y = 0;
6183
6184  function force() {
6185    var i,
6186        n = nodes.length,
6187        node,
6188        sx = 0,
6189        sy = 0;
6190
6191    for (i = 0; i < n; ++i) {
6192      node = nodes[i], sx += node.x, sy += node.y;
6193    }
6194
6195    for (sx = sx / n - x, sy = sy / n - y, i = 0; i < n; ++i) {
6196      node = nodes[i], node.x -= sx, node.y -= sy;
6197    }
6198  }
6199
6200  force.initialize = function(_) {
6201    nodes = _;
6202  };
6203
6204  force.x = function(_) {
6205    return arguments.length ? (x = +_, force) : x;
6206  };
6207
6208  force.y = function(_) {
6209    return arguments.length ? (y = +_, force) : y;
6210  };
6211
6212  return force;
6213}
6214
6215function constant$7(x) {
6216  return function() {
6217    return x;
6218  };
6219}
6220
6221function jiggle() {
6222  return (Math.random() - 0.5) * 1e-6;
6223}
6224
6225function tree_add(d) {
6226  var x = +this._x.call(null, d),
6227      y = +this._y.call(null, d);
6228  return add(this.cover(x, y), x, y, d);
6229}
6230
6231function add(tree, x, y, d) {
6232  if (isNaN(x) || isNaN(y)) return tree; // ignore invalid points
6233
6234  var parent,
6235      node = tree._root,
6236      leaf = {data: d},
6237      x0 = tree._x0,
6238      y0 = tree._y0,
6239      x1 = tree._x1,
6240      y1 = tree._y1,
6241      xm,
6242      ym,
6243      xp,
6244      yp,
6245      right,
6246      bottom,
6247      i,
6248      j;
6249
6250  // If the tree is empty, initialize the root as a leaf.
6251  if (!node) return tree._root = leaf, tree;
6252
6253  // Find the existing leaf for the new point, or add it.
6254  while (node.length) {
6255    if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
6256    if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
6257    if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
6258  }
6259
6260  // Is the new point is exactly coincident with the existing point?
6261  xp = +tree._x.call(null, node.data);
6262  yp = +tree._y.call(null, node.data);
6263  if (x === xp && y === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
6264
6265  // Otherwise, split the leaf node until the old and new point are separated.
6266  do {
6267    parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
6268    if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
6269    if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
6270  } while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | (xp >= xm)));
6271  return parent[j] = node, parent[i] = leaf, tree;
6272}
6273
6274function addAll(data) {
6275  var d, i, n = data.length,
6276      x,
6277      y,
6278      xz = new Array(n),
6279      yz = new Array(n),
6280      x0 = Infinity,
6281      y0 = Infinity,
6282      x1 = -Infinity,
6283      y1 = -Infinity;
6284
6285  // Compute the points and their extent.
6286  for (i = 0; i < n; ++i) {
6287    if (isNaN(x = +this._x.call(null, d = data[i])) || isNaN(y = +this._y.call(null, d))) continue;
6288    xz[i] = x;
6289    yz[i] = y;
6290    if (x < x0) x0 = x;
6291    if (x > x1) x1 = x;
6292    if (y < y0) y0 = y;
6293    if (y > y1) y1 = y;
6294  }
6295
6296  // If there were no (valid) points, abort.
6297  if (x0 > x1 || y0 > y1) return this;
6298
6299  // Expand the tree to cover the new points.
6300  this.cover(x0, y0).cover(x1, y1);
6301
6302  // Add the new points.
6303  for (i = 0; i < n; ++i) {
6304    add(this, xz[i], yz[i], data[i]);
6305  }
6306
6307  return this;
6308}
6309
6310function tree_cover(x, y) {
6311  if (isNaN(x = +x) || isNaN(y = +y)) return this; // ignore invalid points
6312
6313  var x0 = this._x0,
6314      y0 = this._y0,
6315      x1 = this._x1,
6316      y1 = this._y1;
6317
6318  // If the quadtree has no extent, initialize them.
6319  // Integer extent are necessary so that if we later double the extent,
6320  // the existing quadrant boundaries don’t change due to floating point error!
6321  if (isNaN(x0)) {
6322    x1 = (x0 = Math.floor(x)) + 1;
6323    y1 = (y0 = Math.floor(y)) + 1;
6324  }
6325
6326  // Otherwise, double repeatedly to cover.
6327  else {
6328    var z = x1 - x0
vendor: 6,271 bytes, lines 6328-6555
6328,
6329        node = this._root,
6330        parent,
6331        i;
6332
6333    while (x0 > x || x >= x1 || y0 > y || y >= y1) {
6334      i = (y < y0) << 1 | (x < x0);
6335      parent = new Array(4), parent[i] = node, node = parent, z *= 2;
6336      switch (i) {
6337        case 0: x1 = x0 + z, y1 = y0 + z; break;
6338        case 1: x0 = x1 - z, y1 = y0 + z; break;
6339        case 2: x1 = x0 + z, y0 = y1 - z; break;
6340        case 3: x0 = x1 - z, y0 = y1 - z; break;
6341      }
6342    }
6343
6344    if (this._root && this._root.length) this._root = node;
6345  }
6346
6347  this._x0 = x0;
6348  this._y0 = y0;
6349  this._x1 = x1;
6350  this._y1 = y1;
6351  return this;
6352}
6353
6354function tree_data() {
6355  var data = [];
6356  this.visit(function(node) {
6357    if (!node.length) do data.push(node.data); while (node = node.next)
6358  });
6359  return data;
6360}
6361
6362function tree_extent(_) {
6363  return arguments.length
6364      ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1])
6365      : isNaN(this._x0) ? undefined : [[this._x0, this._y0], [this._x1, this._y1]];
6366}
6367
6368function Quad(node, x0, y0, x1, y1) {
6369  this.node = node;
6370  this.x0 = x0;
6371  this.y0 = y0;
6372  this.x1 = x1;
6373  this.y1 = y1;
6374}
6375
6376function tree_find(x, y, radius) {
6377  var data,
6378      x0 = this._x0,
6379      y0 = this._y0,
6380      x1,
6381      y1,
6382      x2,
6383      y2,
6384      x3 = this._x1,
6385      y3 = this._y1,
6386      quads = [],
6387      node = this._root,
6388      q,
6389      i;
6390
6391  if (node) quads.push(new Quad(node, x0, y0, x3, y3));
6392  if (radius == null) radius = Infinity;
6393  else {
6394    x0 = x - radius, y0 = y - radius;
6395    x3 = x + radius, y3 = y + radius;
6396    radius *= radius;
6397  }
6398
6399  while (q = quads.pop()) {
6400
6401    // Stop searching if this quadrant can’t contain a closer node.
6402    if (!(node = q.node)
6403        || (x1 = q.x0) > x3
6404        || (y1 = q.y0) > y3
6405        || (x2 = q.x1) < x0
6406        || (y2 = q.y1) < y0) continue;
6407
6408    // Bisect the current quadrant.
6409    if (node.length) {
6410      var xm = (x1 + x2) / 2,
6411          ym = (y1 + y2) / 2;
6412
6413      quads.push(
6414        new Quad(node[3], xm, ym, x2, y2),
6415        new Quad(node[2], x1, ym, xm, y2),
6416        new Quad(node[1], xm, y1, x2, ym),
6417        new Quad(node[0], x1, y1, xm, ym)
6418      );
6419
6420      // Visit the closest quadrant first.
6421      if (i = (y >= ym) << 1 | (x >= xm)) {
6422        q = quads[quads.length - 1];
6423        quads[quads.length - 1] = quads[quads.length - 1 - i];
6424        quads[quads.length - 1 - i] = q;
6425      }
6426    }
6427
6428    // Visit this point. (Visiting coincident points isn’t necessary!)
6429    else {
6430      var dx = x - +this._x.call(null, node.data),
6431          dy = y - +this._y.call(null, node.data),
6432          d2 = dx * dx + dy * dy;
6433      if (d2 < radius) {
6434        var d = Math.sqrt(radius = d2);
6435        x0 = x - d, y0 = y - d;
6436        x3 = x + d, y3 = y + d;
6437        data = node.data;
6438      }
6439    }
6440  }
6441
6442  return data;
6443}
6444
6445function tree_remove(d) {
6446  if (isNaN(x = +this._x.call(null, d)) || isNaN(y = +this._y.call(null, d))) return this; // ignore invalid points
6447
6448  var parent,
6449      node = this._root,
6450      retainer,
6451      previous,
6452      next,
6453      x0 = this._x0,
6454      y0 = this._y0,
6455      x1 = this._x1,
6456      y1 = this._y1,
6457      x,
6458      y,
6459      xm,
6460      ym,
6461      right,
6462      bottom,
6463      i,
6464      j;
6465
6466  // If the tree is empty, initialize the root as a leaf.
6467  if (!node) return this;
6468
6469  // Find the leaf node for the point.
6470  // While descending, also retain the deepest parent with a non-removed sibling.
6471  if (node.length) while (true) {
6472    if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
6473    if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
6474    if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
6475    if (!node.length) break;
6476    if (parent[(i + 1) & 3] || parent[(i + 2) & 3] || parent[(i + 3) & 3]) retainer = parent, j = i;
6477  }
6478
6479  // Find the point to remove.
6480  while (node.data !== d) if (!(previous = node, node = node.next)) return this;
6481  if (next = node.next) delete node.next;
6482
6483  // If there are multiple coincident points, remove just the point.
6484  if (previous) return (next ? previous.next = next : delete previous.next), this;
6485
6486  // If this is the root point, remove it.
6487  if (!parent) return this._root = next, this;
6488
6489  // Remove this leaf.
6490  next ? parent[i] = next : delete parent[i];
6491
6492  // If the parent now contains exactly one leaf, collapse superfluous parents.
6493  if ((node = parent[0] || parent[1] || parent[2] || parent[3])
6494      && node === (parent[3] || parent[2] || parent[1] || parent[0])
6495      && !node.length) {
6496    if (retainer) retainer[j] = node;
6497    else this._root = node;
6498  }
6499
6500  return this;
6501}
6502
6503function removeAll(data) {
6504  for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]);
6505  return this;
6506}
6507
6508function tree_root() {
6509  return this._root;
6510}
6511
6512function tree_size() {
6513  var size = 0;
6514  this.visit(function(node) {
6515    if (!node.length) do ++size; while (node = node.next)
6516  });
6517  return size;
6518}
6519
6520function tree_visit(callback) {
6521  var quads = [], q, node = this._root, child, x0, y0, x1, y1;
6522  if (node) quads.push(new Quad(node, this._x0, this._y0, this._x1, this._y1));
6523  while (q = quads.pop()) {
6524    if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
6525      var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
6526      if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
6527      if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
6528      if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
6529      if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
6530    }
6531  }
6532  return this;
6533}
6534
6535function tree_visitAfter(callback) {
6536  var quads = [], next = [], q;
6537  if (this._root) quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1));
6538  while (q = quads.pop()) {
6539    var node = q.node;
6540    if (node.length) {
6541      var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
6542      if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
6543      if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
6544      if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
6545      if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
6546    }
6547    next.push(q);
6548  }
6549  while (q = next.pop()) {
6550    callback(q.node, q.x0, q.y0, q.x1, q.y1);
6551  }
6552  return this;
6553}
6554
6555function defaultX
vendor: 17,594 bytes, lines 6555-7237
6555$1(d) {
6556  return d[0];
6557}
6558
6559function tree_x(_) {
6560  return arguments.length ? (this._x = _, this) : this._x;
6561}
6562
6563function defaultY$1(d) {
6564  return d[1];
6565}
6566
6567function tree_y(_) {
6568  return arguments.length ? (this._y = _, this) : this._y;
6569}
6570
6571function quadtree(nodes, x, y) {
6572  var tree = new Quadtree(x == null ? defaultX$1 : x, y == null ? defaultY$1 : y, NaN, NaN, NaN, NaN);
6573  return nodes == null ? tree : tree.addAll(nodes);
6574}
6575
6576function Quadtree(x, y, x0, y0, x1, y1) {
6577  this._x = x;
6578  this._y = y;
6579  this._x0 = x0;
6580  this._y0 = y0;
6581  this._x1 = x1;
6582  this._y1 = y1;
6583  this._root = undefined;
6584}
6585
6586function leaf_copy(leaf) {
6587  var copy = {data: leaf.data}, next = copy;
6588  while (leaf = leaf.next) next = next.next = {data: leaf.data};
6589  return copy;
6590}
6591
6592var treeProto = quadtree.prototype = Quadtree.prototype;
6593
6594treeProto.copy = function() {
6595  var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1),
6596      node = this._root,
6597      nodes,
6598      child;
6599
6600  if (!node) return copy;
6601
6602  if (!node.length) return copy._root = leaf_copy(node), copy;
6603
6604  nodes = [{source: node, target: copy._root = new Array(4)}];
6605  while (node = nodes.pop()) {
6606    for (var i = 0; i < 4; ++i) {
6607      if (child = node.source[i]) {
6608        if (child.length) nodes.push({source: child, target: node.target[i] = new Array(4)});
6609        else node.target[i] = leaf_copy(child);
6610      }
6611    }
6612  }
6613
6614  return copy;
6615};
6616
6617treeProto.add = tree_add;
6618treeProto.addAll = addAll;
6619treeProto.cover = tree_cover;
6620treeProto.data = tree_data;
6621treeProto.extent = tree_extent;
6622treeProto.find = tree_find;
6623treeProto.remove = tree_remove;
6624treeProto.removeAll = removeAll;
6625treeProto.root = tree_root;
6626treeProto.size = tree_size;
6627treeProto.visit = tree_visit;
6628treeProto.visitAfter = tree_visitAfter;
6629treeProto.x = tree_x;
6630treeProto.y = tree_y;
6631
6632function x(d) {
6633  return d.x + d.vx;
6634}
6635
6636function y(d) {
6637  return d.y + d.vy;
6638}
6639
6640function collide(radius) {
6641  var nodes,
6642      radii,
6643      strength = 1,
6644      iterations = 1;
6645
6646  if (typeof radius !== "function") radius = constant$7(radius == null ? 1 : +radius);
6647
6648  function force() {
6649    var i, n = nodes.length,
6650        tree,
6651        node,
6652        xi,
6653        yi,
6654        ri,
6655        ri2;
6656
6657    for (var k = 0; k < iterations; ++k) {
6658      tree = quadtree(nodes, x, y).visitAfter(prepare);
6659      for (i = 0; i < n; ++i) {
6660        node = nodes[i];
6661        ri = radii[node.index], ri2 = ri * ri;
6662        xi = node.x + node.vx;
6663        yi = node.y + node.vy;
6664        tree.visit(apply);
6665      }
6666    }
6667
6668    function apply(quad, x0, y0, x1, y1) {
6669      var data = quad.data, rj = quad.r, r = ri + rj;
6670      if (data) {
6671        if (data.index > node.index) {
6672          var x = xi - data.x - data.vx,
6673              y = yi - data.y - data.vy,
6674              l = x * x + y * y;
6675          if (l < r * r) {
6676            if (x === 0) x = jiggle(), l += x * x;
6677            if (y === 0) y = jiggle(), l += y * y;
6678            l = (r - (l = Math.sqrt(l))) / l * strength;
6679            node.vx += (x *= l) * (r = (rj *= rj) / (ri2 + rj));
6680            node.vy += (y *= l) * r;
6681            data.vx -= x * (r = 1 - r);
6682            data.vy -= y * r;
6683          }
6684        }
6685        return;
6686      }
6687      return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
6688    }
6689  }
6690
6691  function prepare(quad) {
6692    if (quad.data) return quad.r = radii[quad.data.index];
6693    for (var i = quad.r = 0; i < 4; ++i) {
6694      if (quad[i] && quad[i].r > quad.r) {
6695        quad.r = quad[i].r;
6696      }
6697    }
6698  }
6699
6700  function initialize() {
6701    if (!nodes) return;
6702    var i, n = nodes.length, node;
6703    radii = new Array(n);
6704    for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
6705  }
6706
6707  force.initialize = function(_) {
6708    nodes = _;
6709    initialize();
6710  };
6711
6712  force.iterations = function(_) {
6713    return arguments.length ? (iterations = +_, force) : iterations;
6714  };
6715
6716  force.strength = function(_) {
6717    return arguments.length ? (strength = +_, force) : strength;
6718  };
6719
6720  force.radius = function(_) {
6721    return arguments.length ? (radius = typeof _ === "function" ? _ : constant$7(+_), initialize(), force) : radius;
6722  };
6723
6724  return force;
6725}
6726
6727function index(d) {
6728  return d.index;
6729}
6730
6731function find(nodeById, nodeId) {
6732  var node = nodeById.get(nodeId);
6733  if (!node) throw new Error("missing: " + nodeId);
6734  return node;
6735}
6736
6737function link(links) {
6738  var id = index,
6739      strength = defaultStrength,
6740      strengths,
6741      distance = constant$7(30),
6742      distances,
6743      nodes,
6744      count,
6745      bias,
6746      iterations = 1;
6747
6748  if (links == null) links = [];
6749
6750  function defaultStrength(link) {
6751    return 1 / Math.min(count[link.source.index], count[link.target.index]);
6752  }
6753
6754  function force(alpha) {
6755    for (var k = 0, n = links.length; k < iterations; ++k) {
6756      for (var i = 0, link, source, target, x, y, l, b; i < n; ++i) {
6757        link = links[i], source = link.source, target = link.target;
6758        x = target.x + target.vx - source.x - source.vx || jiggle();
6759        y = target.y + target.vy - source.y - source.vy || jiggle();
6760        l = Math.sqrt(x * x + y * y);
6761        l = (l - distances[i]) / l * alpha * strengths[i];
6762        x *= l, y *= l;
6763        target.vx -= x * (b = bias[i]);
6764        target.vy -= y * b;
6765        source.vx += x * (b = 1 - b);
6766        source.vy += y * b;
6767      }
6768    }
6769  }
6770
6771  function initialize() {
6772    if (!nodes) return;
6773
6774    var i,
6775        n = nodes.length,
6776        m = links.length,
6777        nodeById = map$1(nodes, id),
6778        link;
6779
6780    for (i = 0, count = new Array(n); i < m; ++i) {
6781      link = links[i], link.index = i;
6782      if (typeof link.source !== "object") link.source = find(nodeById, link.source);
6783      if (typeof link.target !== "object") link.target = find(nodeById, link.target);
6784      count[link.source.index] = (count[link.source.index] || 0) + 1;
6785      count[link.target.index] = (count[link.target.index] || 0) + 1;
6786    }
6787
6788    for (i = 0, bias = new Array(m); i < m; ++i) {
6789      link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);
6790    }
6791
6792    strengths = new Array(m), initializeStrength();
6793    distances = new Array(m), initializeDistance();
6794  }
6795
6796  function initializeStrength() {
6797    if (!nodes) return;
6798
6799    for (var i = 0, n = links.length; i < n; ++i) {
6800      strengths[i] = +strength(links[i], i, links);
6801    }
6802  }
6803
6804  function initializeDistance() {
6805    if (!nodes) return;
6806
6807    for (var i = 0, n = links.length; i < n; ++i) {
6808      distances[i] = +distance(links[i], i, links);
6809    }
6810  }
6811
6812  force.initialize = function(_) {
6813    nodes = _;
6814    initialize();
6815  };
6816
6817  force.links = function(_) {
6818    return arguments.length ? (links = _, initialize(), force) : links;
6819  };
6820
6821  force.id = function(_) {
6822    return arguments.length ? (id = _, force) : id;
6823  };
6824
6825  force.iterations = function(_) {
6826    return arguments.length ? (iterations = +_, force) : iterations;
6827  };
6828
6829  force.strength = function(_) {
6830    return arguments.length ? (strength = typeof _ === "function" ? _ : constant$7(+_), initializeStrength(), force) : strength;
6831  };
6832
6833  force.distance = function(_) {
6834    return arguments.length ? (distance = typeof _ === "function" ? _ : constant$7(+_), initializeDistance(), force) : distance;
6835  };
6836
6837  return force;
6838}
6839
6840function x$1(d) {
6841  return d.x;
6842}
6843
6844function y$1(d) {
6845  return d.y;
6846}
6847
6848var initialRadius = 10,
6849    initialAngle = Math.PI * (3 - Math.sqrt(5));
6850
6851function simulation(nodes) {
6852  var simulation,
6853      alpha = 1,
6854      alphaMin = 0.001,
6855      alphaDecay = 1 - Math.pow(alphaMin, 1 / 300),
6856      alphaTarget = 0,
6857      velocityDecay = 0.6,
6858      forces = map$1(),
6859      stepper = timer(step),
6860      event = dispatch("tick", "end");
6861
6862  if (nodes == null) nodes = [];
6863
6864  function step() {
6865    tick();
6866    event.call("tick", simulation);
6867    if (alpha < alphaMin) {
6868      stepper.stop();
6869      event.call("end", simulation);
6870    }
6871  }
6872
6873  function tick(iterations) {
6874    var i, n = nodes.length, node;
6875
6876    if (iterations === undefined) iterations = 1;
6877
6878    for (var k = 0; k < iterations; ++k) {
6879      alpha += (alphaTarget - alpha) * alphaDecay;
6880
6881      forces.each(function (force) {
6882        force(alpha);
6883      });
6884
6885      for (i = 0; i < n; ++i) {
6886        node = nodes[i];
6887        if (node.fx == null) node.x += node.vx *= velocityDecay;
6888        else node.x = node.fx, node.vx = 0;
6889        if (node.fy == null) node.y += node.vy *= velocityDecay;
6890        else node.y = node.fy, node.vy = 0;
6891      }
6892    }
6893
6894    return simulation;
6895  }
6896
6897  function initializeNodes() {
6898    for (var i = 0, n = nodes.length, node; i < n; ++i) {
6899      node = nodes[i], node.index = i;
6900      if (node.fx != null) node.x = node.fx;
6901      if (node.fy != null) node.y = node.fy;
6902      if (isNaN(node.x) || isNaN(node.y)) {
6903        var radius = initialRadius * Math.sqrt(i), angle = i * initialAngle;
6904        node.x = radius * Math.cos(angle);
6905        node.y = radius * Math.sin(angle);
6906      }
6907      if (isNaN(node.vx) || isNaN(node.vy)) {
6908        node.vx = node.vy = 0;
6909      }
6910    }
6911  }
6912
6913  function initializeForce(force) {
6914    if (force.initialize) force.initialize(nodes);
6915    return force;
6916  }
6917
6918  initializeNodes();
6919
6920  return simulation = {
6921    tick: tick,
6922
6923    restart: function() {
6924      return stepper.restart(step), simulation;
6925    },
6926
6927    stop: function() {
6928      return stepper.stop(), simulation;
6929    },
6930
6931    nodes: function(_) {
6932      return arguments.length ? (nodes = _, initializeNodes(), forces.each(initializeForce), simulation) : nodes;
6933    },
6934
6935    alpha: function(_) {
6936      return arguments.length ? (alpha = +_, simulation) : alpha;
6937    },
6938
6939    alphaMin: function(_) {
6940      return arguments.length ? (alphaMin = +_, simulation) : alphaMin;
6941    },
6942
6943    alphaDecay: function(_) {
6944      return arguments.length ? (alphaDecay = +_, simulation) : +alphaDecay;
6945    },
6946
6947    alphaTarget: function(_) {
6948      return arguments.length ? (alphaTarget = +_, simulation) : alphaTarget;
6949    },
6950
6951    velocityDecay: function(_) {
6952      return arguments.length ? (velocityDecay = 1 - _, simulation) : 1 - velocityDecay;
6953    },
6954
6955    force: function(name, _) {
6956      return arguments.length > 1 ? ((_ == null ? forces.remove(name) : forces.set(name, initializeForce(_))), simulation) : forces.get(name);
6957    },
6958
6959    find: function(x, y, radius) {
6960      var i = 0,
6961          n = nodes.length,
6962          dx,
6963          dy,
6964          d2,
6965          node,
6966          closest;
6967
6968      if (radius == null) radius = Infinity;
6969      else radius *= radius;
6970
6971      for (i = 0; i < n; ++i) {
6972        node = nodes[i];
6973        dx = x - node.x;
6974        dy = y - node.y;
6975        d2 = dx * dx + dy * dy;
6976        if (d2 < radius) closest = node, radius = d2;
6977      }
6978
6979      return closest;
6980    },
6981
6982    on: function(name, _) {
6983      return arguments.length > 1 ? (event.on(name, _), simulation) : event.on(name);
6984    }
6985  };
6986}
6987
6988function manyBody() {
6989  var nodes,
6990      node,
6991      alpha,
6992      strength = constant$7(-30),
6993      strengths,
6994      distanceMin2 = 1,
6995      distanceMax2 = Infinity,
6996      theta2 = 0.81;
6997
6998  function force(_) {
6999    var i, n = nodes.length, tree = quadtree(nodes, x$1, y$1).visitAfter(accumulate);
7000    for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply);
7001  }
7002
7003  function initialize() {
7004    if (!nodes) return;
7005    var i, n = nodes.length, node;
7006    strengths = new Array(n);
7007    for (i = 0; i < n; ++i) node = nodes[i], strengths[node.index] = +strength(node, i, nodes);
7008  }
7009
7010  function accumulate(quad) {
7011    var strength = 0, q, c, weight = 0, x, y, i;
7012
7013    // For internal nodes, accumulate forces from child quadrants.
7014    if (quad.length) {
7015      for (x = y = i = 0; i < 4; ++i) {
7016        if ((q = quad[i]) && (c = Math.abs(q.value))) {
7017          strength += q.value, weight += c, x += c * q.x, y += c * q.y;
7018        }
7019      }
7020      quad.x = x / weight;
7021      quad.y = y / weight;
7022    }
7023
7024    // For leaf nodes, accumulate forces from coincident quadrants.
7025    else {
7026      q = quad;
7027      q.x = q.data.x;
7028      q.y = q.data.y;
7029      do strength += strengths[q.data.index];
7030      while (q = q.next);
7031    }
7032
7033    quad.value = strength;
7034  }
7035
7036  function apply(quad, x1, _, x2) {
7037    if (!quad.value) return true;
7038
7039    var x = quad.x - node.x,
7040        y = quad.y - node.y,
7041        w = x2 - x1,
7042        l = x * x + y * y;
7043
7044    // Apply the Barnes-Hut approximation if possible.
7045    // Limit forces for very close nodes; randomize direction if coincident.
7046    if (w * w / theta2 < l) {
7047      if (l < distanceMax2) {
7048        if (x === 0) x = jiggle(), l += x * x;
7049        if (y === 0) y = jiggle(), l += y * y;
7050        if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
7051        node.vx += x * quad.value * alpha / l;
7052        node.vy += y * quad.value * alpha / l;
7053      }
7054      return true;
7055    }
7056
7057    // Otherwise, process points directly.
7058    else if (quad.length || l >= distanceMax2) return;
7059
7060    // Limit forces for very close nodes; randomize direction if coincident.
7061    if (quad.data !== node || quad.next) {
7062      if (x === 0) x = jiggle(), l += x * x;
7063      if (y === 0) y = jiggle(), l += y * y;
7064      if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
7065    }
7066
7067    do if (quad.data !== node) {
7068      w = strengths[quad.data.index] * alpha / l;
7069      node.vx += x * w;
7070      node.vy += y * w;
7071    } while (quad = quad.next);
7072  }
7073
7074  force.initialize = function(_) {
7075    nodes = _;
7076    initialize();
7077  };
7078
7079  force.strength = function(_) {
7080    return arguments.length ? (strength = typeof _ === "function" ? _ : constant$7(+_), initialize(), force) : strength;
7081  };
7082
7083  force.distanceMin = function(_) {
7084    return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2);
7085  };
7086
7087  force.distanceMax = function(_) {
7088    return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2);
7089  };
7090
7091  force.theta = function(_) {
7092    return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2);
7093  };
7094
7095  return force;
7096}
7097
7098function radial(radius, x, y) {
7099  var nodes,
7100      strength = constant$7(0.1),
7101      strengths,
7102      radiuses;
7103
7104  if (typeof radius !== "function") radius = constant$7(+radius);
7105  if (x == null) x = 0;
7106  if (y == null) y = 0;
7107
7108  function force(alpha) {
7109    for (var i = 0, n = nodes.length; i < n; ++i) {
7110      var node = nodes[i],
7111          dx = node.x - x || 1e-6,
7112          dy = node.y - y || 1e-6,
7113          r = Math.sqrt(dx * dx + dy * dy),
7114          k = (radiuses[i] - r) * strengths[i] * alpha / r;
7115      node.vx += dx * k;
7116      node.vy += dy * k;
7117    }
7118  }
7119
7120  function initialize() {
7121    if (!nodes) return;
7122    var i, n = nodes.length;
7123    strengths = new Array(n);
7124    radiuses = new Array(n);
7125    for (i = 0; i < n; ++i) {
7126      radiuses[i] = +radius(nodes[i], i, nodes);
7127      strengths[i] = isNaN(radiuses[i]) ? 0 : +strength(nodes[i], i, nodes);
7128    }
7129  }
7130
7131  force.initialize = function(_) {
7132    nodes = _, initialize();
7133  };
7134
7135  force.strength = function(_) {
7136    return arguments.length ? (strength = typeof _ === "function" ? _ : constant$7(+_), initialize(), force) : strength;
7137  };
7138
7139  force.radius = function(_) {
7140    return arguments.length ? (radius = typeof _ === "function" ? _ : constant$7(+_), initialize(), force) : radius;
7141  };
7142
7143  force.x = function(_) {
7144    return arguments.length ? (x = +_, force) : x;
7145  };
7146
7147  force.y = function(_) {
7148    return arguments.length ? (y = +_, force) : y;
7149  };
7150
7151  return force;
7152}
7153
7154function x$2(x) {
7155  var strength = constant$7(0.1),
7156      nodes,
7157      strengths,
7158      xz;
7159
7160  if (typeof x !== "function") x = constant$7(x == null ? 0 : +x);
7161
7162  function force(alpha) {
7163    for (var i = 0, n = nodes.length, node; i < n; ++i) {
7164      node = nodes[i], node.vx += (xz[i] - node.x) * strengths[i] * alpha;
7165    }
7166  }
7167
7168  function initialize() {
7169    if (!nodes) return;
7170    var i, n = nodes.length;
7171    strengths = new Array(n);
7172    xz = new Array(n);
7173    for (i = 0; i < n; ++i) {
7174      strengths[i] = isNaN(xz[i] = +x(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
7175    }
7176  }
7177
7178  force.initialize = function(_) {
7179    nodes = _;
7180    initialize();
7181  };
7182
7183  force.strength = function(_) {
7184    return arguments.length ? (strength = typeof _ === "function" ? _ : constant$7(+_), initialize(), force) : strength;
7185  };
7186
7187  force.x = function(_) {
7188    return arguments.length ? (x = typeof _ === "function" ? _ : constant$7(+_), initialize(), force) : x;
7189  };
7190
7191  return force;
7192}
7193
7194function y$2(y) {
7195  var strength = constant$7(0.1),
7196      nodes,
7197      strengths,
7198      yz;
7199
7200  if (typeof y !== "function") y = constant$7(y == null ? 0 : +y);
7201
7202  function force(alpha) {
7203    for (var i = 0, n = nodes.length, node; i < n; ++i) {
7204      node = nodes[i], node.vy += (yz[i] - node.y) * strengths[i] * alpha;
7205    }
7206  }
7207
7208  function initialize() {
7209    if (!nodes) return;
7210    var i, n = nodes.length;
7211    strengths = new Array(n);
7212    yz = new Array(n);
7213    for (i = 0; i < n; ++i) {
7214      strengths[i] = isNaN(yz[i] = +y(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
7215    }
7216  }
7217
7218  force.initialize = function(_) {
7219    nodes = _;
7220    initialize();
7221  };
7222
7223  force.strength = function(_) {
7224    return arguments.length ? (strength = typeof _ === "function" ? _ : constant$7(+_), initialize(), force) : strength;
7225  };
7226
7227  force.y = function(_) {
7228    return arguments.length ? (y = typeof _ === "function" ? _ : constant$7(+_), initialize(), force) : y;
7229  };
7230
7231  return force;
7232}
7233
7234// Computes the decimal coefficient and exponent of the specified number x with
7235// significant digits p, where x is positive and p is in [1, 21] or undefined.
7236// For example, formatDecimal(1.23) returns ["123", 0].
7237function formatDecimal(x, p) {
vendor: 6,150 bytes, lines 7238-7408
7238  if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
7239  var i, coefficient = x.slice(0, i);
7240
7241  // The string returned by toExponential either has the form \d\.\d+e[-+]\d+
7242  // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
7243  return [
7244    coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
7245    +x.slice(i + 1)
7246  ];
7247}
7248
7249function exponent$1(x) {
7250  return x = formatDecimal(Math.abs(x)), x ? x[1] : NaN;
7251}
7252
7253function formatGroup(grouping, thousands) {
7254  return function(value, width) {
7255    var i = value.length,
7256        t = [],
7257        j = 0,
7258        g = grouping[0],
7259        length = 0;
7260
7261    while (i > 0 && g > 0) {
7262      if (length + g + 1 > width) g = Math.max(1, width - length);
7263      t.push(value.substring(i -= g, i + g));
7264      if ((length += g + 1) > width) break;
7265      g = grouping[j = (j + 1) % grouping.length];
7266    }
7267
7268    return t.reverse().join(thousands);
7269  };
7270}
7271
7272function formatNumerals(numerals) {
7273  return function(value) {
7274    return value.replace(/[0-9]/g, function(i) {
7275      return numerals[+i];
7276    });
7277  };
7278}
7279
7280// [[fill]align][sign][symbol][0][width][,][.precision][~][type]
7281var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
7282
7283function formatSpecifier(specifier) {
7284  if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
7285  var match;
7286  return new FormatSpecifier({
7287    fill: match[1],
7288    align: match[2],
7289    sign: match[3],
7290    symbol: match[4],
7291    zero: match[5],
7292    width: match[6],
7293    comma: match[7],
7294    precision: match[8] && match[8].slice(1),
7295    trim: match[9],
7296    type: match[10]
7297  });
7298}
7299
7300formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
7301
7302function FormatSpecifier(specifier) {
7303  this.fill = specifier.fill === undefined ? " " : specifier.fill + "";
7304  this.align = specifier.align === undefined ? ">" : specifier.align + "";
7305  this.sign = specifier.sign === undefined ? "-" : specifier.sign + "";
7306  this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + "";
7307  this.zero = !!specifier.zero;
7308  this.width = specifier.width === undefined ? undefined : +specifier.width;
7309  this.comma = !!specifier.comma;
7310  this.precision = specifier.precision === undefined ? undefined : +specifier.precision;
7311  this.trim = !!specifier.trim;
7312  this.type = specifier.type === undefined ? "" : specifier.type + "";
7313}
7314
7315FormatSpecifier.prototype.toString = function() {
7316  return this.fill
7317      + this.align
7318      + this.sign
7319      + this.symbol
7320      + (this.zero ? "0" : "")
7321      + (this.width === undefined ? "" : Math.max(1, this.width | 0))
7322      + (this.comma ? "," : "")
7323      + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0))
7324      + (this.trim ? "~" : "")
7325      + this.type;
7326};
7327
7328// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k.
7329function formatTrim(s) {
7330  out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
7331    switch (s[i]) {
7332      case ".": i0 = i1 = i; break;
7333      case "0": if (i0 === 0) i0 = i; i1 = i; break;
7334      default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break;
7335    }
7336  }
7337  return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
7338}
7339
7340var prefixExponent;
7341
7342function formatPrefixAuto(x, p) {
7343  var d = formatDecimal(x, p);
7344  if (!d) return x + "";
7345  var coefficient = d[0],
7346      exponent = d[1],
7347      i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
7348      n = coefficient.length;
7349  return i === n ? coefficient
7350      : i > n ? coefficient + new Array(i - n + 1).join("0")
7351      : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
7352      : "0." + new Array(1 - i).join("0") + formatDecimal(x, Math.max(0, p + i - 1))[0]; // less than 1y!
7353}
7354
7355function formatRounded(x, p) {
7356  var d = formatDecimal(x, p);
7357  if (!d) return x + "";
7358  var coefficient = d[0],
7359      exponent = d[1];
7360  return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
7361      : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
7362      : coefficient + new Array(exponent - coefficient.length + 2).join("0");
7363}
7364
7365var formatTypes = {
7366  "%": function(x, p) { return (x * 100).toFixed(p); },
7367  "b": function(x) { return Math.round(x).toString(2); },
7368  "c": function(x) { return x + ""; },
7369  "d": function(x) { return Math.round(x).toString(10); },
7370  "e": function(x, p) { return x.toExponential(p); },
7371  "f": function(x, p) { return x.toFixed(p); },
7372  "g": function(x, p) { return x.toPrecision(p); },
7373  "o": function(x) { return Math.round(x).toString(8); },
7374  "p": function(x, p) { return formatRounded(x * 100, p); },
7375  "r": formatRounded,
7376  "s": formatPrefixAuto,
7377  "X": function(x) { return Math.round(x).toString(16).toUpperCase(); },
7378  "x": function(x) { return Math.round(x).toString(16); }
7379};
7380
7381function identity$3(x) {
7382  return x;
7383}
7384
7385var map$2 = Array.prototype.map,
7386    prefixes = ["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"];
7387
7388function formatLocale(locale) {
7389  var group = locale.grouping === undefined || locale.thousands === undefined ? identity$3 : formatGroup(map$2.call(locale.grouping, Number), locale.thousands + ""),
7390      currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "",
7391      currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "",
7392      decimal = locale.decimal === undefined ? "." : locale.decimal + "",
7393      numerals = locale.numerals === undefined ? identity$3 : formatNumerals(map$2.call(locale.numerals, String)),
7394      percent = locale.percent === undefined ? "%" : locale.percent + "",
7395      minus = locale.minus === undefined ? "-" : locale.minus + "",
7396      nan = locale.nan === undefined ? "NaN" : locale.nan + "";
7397
7398  function newFormat(specifier) {
7399    specifier = formatSpecifier(specifier);
7400
7401    var fill = specifier.fill,
7402        align = specifier.align,
7403        sign = specifier.sign,
7404        symbol = specifier.symbol,
7405        zero = specifier.zero,
7406        width = specifier.width,
7407        comma = specifier.comma,
7408        precision = specifier.precision,
vendor: 4,618 bytes, lines 7409-7527
7409        trim = specifier.trim,
7410        type = specifier.type;
7411
7412    // The "n" type is an alias for ",g".
7413    if (type === "n") comma = true, type = "g";
7414
7415    // The "" type, and any invalid type, is an alias for ".12~g".
7416    else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g";
7417
7418    // If zero fill is specified, padding goes after sign and before digits.
7419    if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
7420
7421    // Compute the prefix and suffix.
7422    // For SI-prefix, the suffix is lazily computed.
7423    var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
7424        suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
7425
7426    // What format function should we use?
7427    // Is this an integer type?
7428    // Can this type generate exponential notation?
7429    var formatType = formatTypes[type],
7430        maybeSuffix = /[defgprs%]/.test(type);
7431
7432    // Set the default precision if not specified,
7433    // or clamp the specified precision to the supported range.
7434    // For significant precision, it must be in [1, 21].
7435    // For fixed precision, it must be in [0, 20].
7436    precision = precision === undefined ? 6
7437        : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
7438        : Math.max(0, Math.min(20, precision));
7439
7440    function format(value) {
7441      var valuePrefix = prefix,
7442          valueSuffix = suffix,
7443          i, n, c;
7444
7445      if (type === "c") {
7446        valueSuffix = formatType(value) + valueSuffix;
7447        value = "";
7448      } else {
7449        value = +value;
7450
7451        // Determine the sign. -0 is not less than 0, but 1 / -0 is!
7452        var valueNegative = value < 0 || 1 / value < 0;
7453
7454        // Perform the initial formatting.
7455        value = isNaN(value) ? nan : formatType(Math.abs(value), precision);
7456
7457        // Trim insignificant zeros.
7458        if (trim) value = formatTrim(value);
7459
7460        // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign.
7461        if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
7462
7463        // Compute the prefix and suffix.
7464        valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
7465        valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
7466
7467        // Break the formatted value into the integer “value” part that can be
7468        // grouped, and fractional or exponential “suffix” part that is not.
7469        if (maybeSuffix) {
7470          i = -1, n = value.length;
7471          while (++i < n) {
7472            if (c = value.charCodeAt(i), 48 > c || c > 57) {
7473              valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
7474              value = value.slice(0, i);
7475              break;
7476            }
7477          }
7478        }
7479      }
7480
7481      // If the fill character is not "0", grouping is applied before padding.
7482      if (comma && !zero) value = group(value, Infinity);
7483
7484      // Compute the padding.
7485      var length = valuePrefix.length + value.length + valueSuffix.length,
7486          padding = length < width ? new Array(width - length + 1).join(fill) : "";
7487
7488      // If the fill character is "0", grouping is applied after padding.
7489      if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
7490
7491      // Reconstruct the final output based on the desired alignment.
7492      switch (align) {
7493        case "<": value = valuePrefix + value + valueSuffix + padding; break;
7494        case "=": value = valuePrefix + padding + value + valueSuffix; break;
7495        case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
7496        default: value = padding + valuePrefix + value + valueSuffix; break;
7497      }
7498
7499      return numerals(value);
7500    }
7501
7502    format.toString = function() {
7503      return specifier + "";
7504    };
7505
7506    return format;
7507  }
7508
7509  function formatPrefix(specifier, value) {
7510    var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)),
7511        e = Math.max(-8, Math.min(8, Math.floor(exponent$1(value) / 3))) * 3,
7512        k = Math.pow(10, -e),
7513        prefix = prefixes[8 + e / 3];
7514    return function(value) {
7515      return f(k * value) + prefix;
7516    };
7517  }
7518
7519  return {
7520    format: newFormat,
7521    formatPrefix: formatPrefix
7522  };
7523}
7524
7525var locale;
7526
7527defaultLocale({
vendor: 12,526 bytes, lines 7528-7974
7528  decimal: ".",
7529  thousands: ",",
7530  grouping: [3],
7531  currency: ["$", ""],
7532  minus: "-"
7533});
7534
7535function defaultLocale(definition) {
7536  locale = formatLocale(definition);
7537  exports.format = locale.format;
7538  exports.formatPrefix = locale.formatPrefix;
7539  return locale;
7540}
7541
7542function precisionFixed(step) {
7543  return Math.max(0, -exponent$1(Math.abs(step)));
7544}
7545
7546function precisionPrefix(step, value) {
7547  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent$1(value) / 3))) * 3 - exponent$1(Math.abs(step)));
7548}
7549
7550function precisionRound(step, max) {
7551  step = Math.abs(step), max = Math.abs(max) - step;
7552  return Math.max(0, exponent$1(max) - exponent$1(step)) + 1;
7553}
7554
7555// Adds floating point numbers with twice the normal precision.
7556// Reference: J. R. Shewchuk, Adaptive Precision Floating-Point Arithmetic and
7557// Fast Robust Geometric Predicates, Discrete & Computational Geometry 18(3)
7558// 305–363 (1997).
7559// Code adapted from GeographicLib by Charles F. F. Karney,
7560// http://geographiclib.sourceforge.net/
7561
7562function adder() {
7563  return new Adder;
7564}
7565
7566function Adder() {
7567  this.reset();
7568}
7569
7570Adder.prototype = {
7571  constructor: Adder,
7572  reset: function() {
7573    this.s = // rounded value
7574    this.t = 0; // exact error
7575  },
7576  add: function(y) {
7577    add$1(temp, y, this.t);
7578    add$1(this, temp.s, this.s);
7579    if (this.s) this.t += temp.t;
7580    else this.s = temp.t;
7581  },
7582  valueOf: function() {
7583    return this.s;
7584  }
7585};
7586
7587var temp = new Adder;
7588
7589function add$1(adder, a, b) {
7590  var x = adder.s = a + b,
7591      bv = x - a,
7592      av = x - bv;
7593  adder.t = (a - av) + (b - bv);
7594}
7595
7596var epsilon$2 = 1e-6;
7597var epsilon2$1 = 1e-12;
7598var pi$3 = Math.PI;
7599var halfPi$2 = pi$3 / 2;
7600var quarterPi = pi$3 / 4;
7601var tau$3 = pi$3 * 2;
7602
7603var degrees$1 = 180 / pi$3;
7604var radians = pi$3 / 180;
7605
7606var abs = Math.abs;
7607var atan = Math.atan;
7608var atan2 = Math.atan2;
7609var cos$1 = Math.cos;
7610var ceil = Math.ceil;
7611var exp = Math.exp;
7612var log = Math.log;
7613var pow = Math.pow;
7614var sin$1 = Math.sin;
7615var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; };
7616var sqrt = Math.sqrt;
7617var tan = Math.tan;
7618
7619function acos(x) {
7620  return x > 1 ? 0 : x < -1 ? pi$3 : Math.acos(x);
7621}
7622
7623function asin(x) {
7624  return x > 1 ? halfPi$2 : x < -1 ? -halfPi$2 : Math.asin(x);
7625}
7626
7627function haversin(x) {
7628  return (x = sin$1(x / 2)) * x;
7629}
7630
7631function noop$2() {}
7632
7633function streamGeometry(geometry, stream) {
7634  if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
7635    streamGeometryType[geometry.type](geometry, stream);
7636  }
7637}
7638
7639var streamObjectType = {
7640  Feature: function(object, stream) {
7641    streamGeometry(object.geometry, stream);
7642  },
7643  FeatureCollection: function(object, stream) {
7644    var features = object.features, i = -1, n = features.length;
7645    while (++i < n) streamGeometry(features[i].geometry, stream);
7646  }
7647};
7648
7649var streamGeometryType = {
7650  Sphere: function(object, stream) {
7651    stream.sphere();
7652  },
7653  Point: function(object, stream) {
7654    object = object.coordinates;
7655    stream.point(object[0], object[1], object[2]);
7656  },
7657  MultiPoint: function(object, stream) {
7658    var coordinates = object.coordinates, i = -1, n = coordinates.length;
7659    while (++i < n) object = coordinates[i], stream.point(object[0], object[1], object[2]);
7660  },
7661  LineString: function(object, stream) {
7662    streamLine(object.coordinates, stream, 0);
7663  },
7664  MultiLineString: function(object, stream) {
7665    var coordinates = object.coordinates, i = -1, n = coordinates.length;
7666    while (++i < n) streamLine(coordinates[i], stream, 0);
7667  },
7668  Polygon: function(object, stream) {
7669    streamPolygon(object.coordinates, stream);
7670  },
7671  MultiPolygon: function(object, stream) {
7672    var coordinates = object.coordinates, i = -1, n = coordinates.length;
7673    while (++i < n) streamPolygon(coordinates[i], stream);
7674  },
7675  GeometryCollection: function(object, stream) {
7676    var geometries = object.geometries, i = -1, n = geometries.length;
7677    while (++i < n) streamGeometry(geometries[i], stream);
7678  }
7679};
7680
7681function streamLine(coordinates, stream, closed) {
7682  var i = -1, n = coordinates.length - closed, coordinate;
7683  stream.lineStart();
7684  while (++i < n) coordinate = coordinates[i], stream.point(coordinate[0], coordinate[1], coordinate[2]);
7685  stream.lineEnd();
7686}
7687
7688function streamPolygon(coordinates, stream) {
7689  var i = -1, n = coordinates.length;
7690  stream.polygonStart();
7691  while (++i < n) streamLine(coordinates[i], stream, 1);
7692  stream.polygonEnd();
7693}
7694
7695function geoStream(object, stream) {
7696  if (object && streamObjectType.hasOwnProperty(object.type)) {
7697    streamObjectType[object.type](object, stream);
7698  } else {
7699    streamGeometry(object, stream);
7700  }
7701}
7702
7703var areaRingSum = adder();
7704
7705var areaSum = adder(),
7706    lambda00,
7707    phi00,
7708    lambda0,
7709    cosPhi0,
7710    sinPhi0;
7711
7712var areaStream = {
7713  point: noop$2,
7714  lineStart: noop$2,
7715  lineEnd: noop$2,
7716  polygonStart: function() {
7717    areaRingSum.reset();
7718    areaStream.lineStart = areaRingStart;
7719    areaStream.lineEnd = areaRingEnd;
7720  },
7721  polygonEnd: function() {
7722    var areaRing = +areaRingSum;
7723    areaSum.add(areaRing < 0 ? tau$3 + areaRing : areaRing);
7724    this.lineStart = this.lineEnd = this.point = noop$2;
7725  },
7726  sphere: function() {
7727    areaSum.add(tau$3);
7728  }
7729};
7730
7731function areaRingStart() {
7732  areaStream.point = areaPointFirst;
7733}
7734
7735function areaRingEnd() {
7736  areaPoint(lambda00, phi00);
7737}
7738
7739function areaPointFirst(lambda, phi) {
7740  areaStream.point = areaPoint;
7741  lambda00 = lambda, phi00 = phi;
7742  lambda *= radians, phi *= radians;
7743  lambda0 = lambda, cosPhi0 = cos$1(phi = phi / 2 + quarterPi), sinPhi0 = sin$1(phi);
7744}
7745
7746function areaPoint(lambda, phi) {
7747  lambda *= radians, phi *= radians;
7748  phi = phi / 2 + quarterPi; // half the angular distance from south pole
7749
7750  // Spherical excess E for a spherical triangle with vertices: south pole,
7751  // previous point, current point.  Uses a formula derived from Cagnoli’s
7752  // theorem.  See Todhunter, Spherical Trig. (1871), Sec. 103, Eq. (2).
7753  var dLambda = lambda - lambda0,
7754      sdLambda = dLambda >= 0 ? 1 : -1,
7755      adLambda = sdLambda * dLambda,
7756      cosPhi = cos$1(phi),
7757      sinPhi = sin$1(phi),
7758      k = sinPhi0 * sinPhi,
7759      u = cosPhi0 * cosPhi + k * cos$1(adLambda),
7760      v = k * sdLambda * sin$1(adLambda);
7761  areaRingSum.add(atan2(v, u));
7762
7763  // Advance the previous points.
7764  lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
7765}
7766
7767function area$1(object) {
7768  areaSum.reset();
7769  geoStream(object, areaStream);
7770  return areaSum * 2;
7771}
7772
7773function spherical(cartesian) {
7774  return [atan2(cartesian[1], cartesian[0]), asin(cartesian[2])];
7775}
7776
7777function cartesian(spherical) {
7778  var lambda = spherical[0], phi = spherical[1], cosPhi = cos$1(phi);
7779  return [cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi)];
7780}
7781
7782function cartesianDot(a, b) {
7783  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
7784}
7785
7786function cartesianCross(a, b) {
7787  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]];
7788}
7789
7790// TODO return a
7791function cartesianAddInPlace(a, b) {
7792  a[0] += b[0], a[1] += b[1], a[2] += b[2];
7793}
7794
7795function cartesianScale(vector, k) {
7796  return [vector[0] * k, vector[1] * k, vector[2] * k];
7797}
7798
7799// TODO return d
7800function cartesianNormalizeInPlace(d) {
7801  var l = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
7802  d[0] /= l, d[1] /= l, d[2] /= l;
7803}
7804
7805var lambda0$1, phi0, lambda1, phi1, // bounds
7806    lambda2, // previous lambda-coordinate
7807    lambda00$1, phi00$1, // first point
7808    p0, // previous 3D point
7809    deltaSum = adder(),
7810    ranges,
7811    range;
7812
7813var boundsStream = {
7814  point: boundsPoint,
7815  lineStart: boundsLineStart,
7816  lineEnd: boundsLineEnd,
7817  polygonStart: function() {
7818    boundsStream.point = boundsRingPoint;
7819    boundsStream.lineStart = boundsRingStart;
7820    boundsStream.lineEnd = boundsRingEnd;
7821    deltaSum.reset();
7822    areaStream.polygonStart();
7823  },
7824  polygonEnd: function() {
7825    areaStream.polygonEnd();
7826    boundsStream.point = boundsPoint;
7827    boundsStream.lineStart = boundsLineStart;
7828    boundsStream.lineEnd = boundsLineEnd;
7829    if (areaRingSum < 0) lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90);
7830    else if (deltaSum > epsilon$2) phi1 = 90;
7831    else if (deltaSum < -epsilon$2) phi0 = -90;
7832    range[0] = lambda0$1, range[1] = lambda1;
7833  },
7834  sphere: function() {
7835    lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90);
7836  }
7837};
7838
7839function boundsPoint(lambda, phi) {
7840  ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]);
7841  if (phi < phi0) phi0 = phi;
7842  if (phi > phi1) phi1 = phi;
7843}
7844
7845function linePoint(lambda, phi) {
7846  var p = cartesian([lambda * radians, phi * radians]);
7847  if (p0) {
7848    var normal = cartesianCross(p0, p),
7849        equatorial = [normal[1], -normal[0], 0],
7850        inflection = cartesianCross(equatorial, normal);
7851    cartesianNormalizeInPlace(inflection);
7852    inflection = spherical(inflection);
7853    var delta = lambda - lambda2,
7854        sign = delta > 0 ? 1 : -1,
7855        lambdai = inflection[0] * degrees$1 * sign,
7856        phii,
7857        antimeridian = abs(delta) > 180;
7858    if (antimeridian ^ (sign * lambda2 < lambdai && lambdai < sign * lambda)) {
7859      phii = inflection[1] * degrees$1;
7860      if (phii > phi1) phi1 = phii;
7861    } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign * lambda2 < lambdai && lambdai < sign * lambda)) {
7862      phii = -inflection[1] * degrees$1;
7863      if (phii < phi0) phi0 = phii;
7864    } else {
7865      if (phi < phi0) phi0 = phi;
7866      if (phi > phi1) phi1 = phi;
7867    }
7868    if (antimeridian) {
7869      if (lambda < lambda2) {
7870        if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda;
7871      } else {
7872        if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda;
7873      }
7874    } else {
7875      if (lambda1 >= lambda0$1) {
7876        if (lambda < lambda0$1) lambda0$1 = lambda;
7877        if (lambda > lambda1) lambda1 = lambda;
7878      } else {
7879        if (lambda > lambda2) {
7880          if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda;
7881        } else {
7882          if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda;
7883        }
7884      }
7885    }
7886  } else {
7887    ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]);
7888  }
7889  if (phi < phi0) phi0 = phi;
7890  if (phi > phi1) phi1 = phi;
7891  p0 = p, lambda2 = lambda;
7892}
7893
7894function boundsLineStart() {
7895  boundsStream.point = linePoint;
7896}
7897
7898function boundsLineEnd() {
7899  range[0] = lambda0$1, range[1] = lambda1;
7900  boundsStream.point = boundsPoint;
7901  p0 = null;
7902}
7903
7904function boundsRingPoint(lambda, phi) {
7905  if (p0) {
7906    var delta = lambda - lambda2;
7907    deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
7908  } else {
7909    lambda00$1 = lambda, phi00$1 = phi;
7910  }
7911  areaStream.point(lambda, phi);
7912  linePoint(lambda, phi);
7913}
7914
7915function boundsRingStart() {
7916  areaStream.lineStart();
7917}
7918
7919function boundsRingEnd() {
7920  boundsRingPoint(lambda00$1, phi00$1);
7921  areaStream.lineEnd();
7922  if (abs(deltaSum) > epsilon$2) lambda0$1 = -(lambda1 = 180);
7923  range[0] = lambda0$1, range[1] = lambda1;
7924  p0 = null;
7925}
7926
7927// Finds the left-right distance between two longitudes.
7928// This is almost the same as (lambda1 - lambda0 + 360°) % 360°, except that we want
7929// the distance between ±180° to be 360°.
7930function angle(lambda0, lambda1) {
7931  return (lambda1 -= lambda0) < 0 ? lambda1 + 360 : lambda1;
7932}
7933
7934function rangeCompare(a, b) {
7935  return a[0] - b[0];
7936}
7937
7938function rangeContains(range, x) {
7939  return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;
7940}
7941
7942function bounds(feature) {
7943  var i, n, a, b, merged, deltaMax, delta;
7944
7945  phi1 = lambda1 = -(lambda0$1 = phi0 = Infinity);
7946  ranges = [];
7947  geoStream(feature, boundsStream);
7948
7949  // First, sort ranges by their minimum longitudes.
7950  if (n = ranges.length) {
7951    ranges.sort(rangeCompare);
7952
7953    // Then, merge any ranges that overlap.
7954    for (i = 1, a = ranges[0], merged = [a]; i < n; ++i) {
7955      b = ranges[i];
7956      if (rangeContains(a, b[0]) || rangeContains(a, b[1])) {
7957        if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];
7958        if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];
7959      } else {
7960        merged.push(a = b);
7961      }
7962    }
7963
7964    // Finally, find the largest gap between the merged ranges.
7965    // The final bounding box will be the inverse of this gap.
7966    for (deltaMax = -Infinity, n = merged.length - 1, i = 0, a = merged[n]; i <= n; a = b, ++i) {
7967      b = merged[i];
7968      if ((delta = angle(a[1], b[0])) > deltaMax) deltaMax = delta, lambda0$1 = b[0], lambda1 = a[1];
7969    }
7970  }
7971
7972  ranges = range = null;
7973
7974  return lambda0$1 === Infinity || phi0 === Infinity
vendor: 29,960 bytes, lines 7975-9006
7975      ? [[NaN, NaN], [NaN, NaN]]
7976      : [[lambda0$1, phi0], [lambda1, phi1]];
7977}
7978
7979var W0, W1,
7980    X0, Y0, Z0,
7981    X1, Y1, Z1,
7982    X2, Y2, Z2,
7983    lambda00$2, phi00$2, // first point
7984    x0, y0, z0; // previous point
7985
7986var centroidStream = {
7987  sphere: noop$2,
7988  point: centroidPoint,
7989  lineStart: centroidLineStart,
7990  lineEnd: centroidLineEnd,
7991  polygonStart: function() {
7992    centroidStream.lineStart = centroidRingStart;
7993    centroidStream.lineEnd = centroidRingEnd;
7994  },
7995  polygonEnd: function() {
7996    centroidStream.lineStart = centroidLineStart;
7997    centroidStream.lineEnd = centroidLineEnd;
7998  }
7999};
8000
8001// Arithmetic mean of Cartesian vectors.
8002function centroidPoint(lambda, phi) {
8003  lambda *= radians, phi *= radians;
8004  var cosPhi = cos$1(phi);
8005  centroidPointCartesian(cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi));
8006}
8007
8008function centroidPointCartesian(x, y, z) {
8009  ++W0;
8010  X0 += (x - X0) / W0;
8011  Y0 += (y - Y0) / W0;
8012  Z0 += (z - Z0) / W0;
8013}
8014
8015function centroidLineStart() {
8016  centroidStream.point = centroidLinePointFirst;
8017}
8018
8019function centroidLinePointFirst(lambda, phi) {
8020  lambda *= radians, phi *= radians;
8021  var cosPhi = cos$1(phi);
8022  x0 = cosPhi * cos$1(lambda);
8023  y0 = cosPhi * sin$1(lambda);
8024  z0 = sin$1(phi);
8025  centroidStream.point = centroidLinePoint;
8026  centroidPointCartesian(x0, y0, z0);
8027}
8028
8029function centroidLinePoint(lambda, phi) {
8030  lambda *= radians, phi *= radians;
8031  var cosPhi = cos$1(phi),
8032      x = cosPhi * cos$1(lambda),
8033      y = cosPhi * sin$1(lambda),
8034      z = sin$1(phi),
8035      w = atan2(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);
8036  W1 += w;
8037  X1 += w * (x0 + (x0 = x));
8038  Y1 += w * (y0 + (y0 = y));
8039  Z1 += w * (z0 + (z0 = z));
8040  centroidPointCartesian(x0, y0, z0);
8041}
8042
8043function centroidLineEnd() {
8044  centroidStream.point = centroidPoint;
8045}
8046
8047// See J. E. Brock, The Inertia Tensor for a Spherical Triangle,
8048// J. Applied Mechanics 42, 239 (1975).
8049function centroidRingStart() {
8050  centroidStream.point = centroidRingPointFirst;
8051}
8052
8053function centroidRingEnd() {
8054  centroidRingPoint(lambda00$2, phi00$2);
8055  centroidStream.point = centroidPoint;
8056}
8057
8058function centroidRingPointFirst(lambda, phi) {
8059  lambda00$2 = lambda, phi00$2 = phi;
8060  lambda *= radians, phi *= radians;
8061  centroidStream.point = centroidRingPoint;
8062  var cosPhi = cos$1(phi);
8063  x0 = cosPhi * cos$1(lambda);
8064  y0 = cosPhi * sin$1(lambda);
8065  z0 = sin$1(phi);
8066  centroidPointCartesian(x0, y0, z0);
8067}
8068
8069function centroidRingPoint(lambda, phi) {
8070  lambda *= radians, phi *= radians;
8071  var cosPhi = cos$1(phi),
8072      x = cosPhi * cos$1(lambda),
8073      y = cosPhi * sin$1(lambda),
8074      z = sin$1(phi),
8075      cx = y0 * z - z0 * y,
8076      cy = z0 * x - x0 * z,
8077      cz = x0 * y - y0 * x,
8078      m = sqrt(cx * cx + cy * cy + cz * cz),
8079      w = asin(m), // line weight = angle
8080      v = m && -w / m; // area weight multiplier
8081  X2 += v * cx;
8082  Y2 += v * cy;
8083  Z2 += v * cz;
8084  W1 += w;
8085  X1 += w * (x0 + (x0 = x));
8086  Y1 += w * (y0 + (y0 = y));
8087  Z1 += w * (z0 + (z0 = z));
8088  centroidPointCartesian(x0, y0, z0);
8089}
8090
8091function centroid(object) {
8092  W0 = W1 =
8093  X0 = Y0 = Z0 =
8094  X1 = Y1 = Z1 =
8095  X2 = Y2 = Z2 = 0;
8096  geoStream(object, centroidStream);
8097
8098  var x = X2,
8099      y = Y2,
8100      z = Z2,
8101      m = x * x + y * y + z * z;
8102
8103  // If the area-weighted ccentroid is undefined, fall back to length-weighted ccentroid.
8104  if (m < epsilon2$1) {
8105    x = X1, y = Y1, z = Z1;
8106    // If the feature has zero length, fall back to arithmetic mean of point vectors.
8107    if (W1 < epsilon$2) x = X0, y = Y0, z = Z0;
8108    m = x * x + y * y + z * z;
8109    // If the feature still has an undefined ccentroid, then return.
8110    if (m < epsilon2$1) return [NaN, NaN];
8111  }
8112
8113  return [atan2(y, x) * degrees$1, asin(z / sqrt(m)) * degrees$1];
8114}
8115
8116function constant$8(x) {
8117  return function() {
8118    return x;
8119  };
8120}
8121
8122function compose(a, b) {
8123
8124  function compose(x, y) {
8125    return x = a(x, y), b(x[0], x[1]);
8126  }
8127
8128  if (a.invert && b.invert) compose.invert = function(x, y) {
8129    return x = b.invert(x, y), x && a.invert(x[0], x[1]);
8130  };
8131
8132  return compose;
8133}
8134
8135function rotationIdentity(lambda, phi) {
8136  return [abs(lambda) > pi$3 ? lambda + Math.round(-lambda / tau$3) * tau$3 : lambda, phi];
8137}
8138
8139rotationIdentity.invert = rotationIdentity;
8140
8141function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
8142  return (deltaLambda %= tau$3) ? (deltaPhi || deltaGamma ? compose(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma))
8143    : rotationLambda(deltaLambda))
8144    : (deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma)
8145    : rotationIdentity);
8146}
8147
8148function forwardRotationLambda(deltaLambda) {
8149  return function(lambda, phi) {
8150    return lambda += deltaLambda, [lambda > pi$3 ? lambda - tau$3 : lambda < -pi$3 ? lambda + tau$3 : lambda, phi];
8151  };
8152}
8153
8154function rotationLambda(deltaLambda) {
8155  var rotation = forwardRotationLambda(deltaLambda);
8156  rotation.invert = forwardRotationLambda(-deltaLambda);
8157  return rotation;
8158}
8159
8160function rotationPhiGamma(deltaPhi, deltaGamma) {
8161  var cosDeltaPhi = cos$1(deltaPhi),
8162      sinDeltaPhi = sin$1(deltaPhi),
8163      cosDeltaGamma = cos$1(deltaGamma),
8164      sinDeltaGamma = sin$1(deltaGamma);
8165
8166  function rotation(lambda, phi) {
8167    var cosPhi = cos$1(phi),
8168        x = cos$1(lambda) * cosPhi,
8169        y = sin$1(lambda) * cosPhi,
8170        z = sin$1(phi),
8171        k = z * cosDeltaPhi + x * sinDeltaPhi;
8172    return [
8173      atan2(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi),
8174      asin(k * cosDeltaGamma + y * sinDeltaGamma)
8175    ];
8176  }
8177
8178  rotation.invert = function(lambda, phi) {
8179    var cosPhi = cos$1(phi),
8180        x = cos$1(lambda) * cosPhi,
8181        y = sin$1(lambda) * cosPhi,
8182        z = sin$1(phi),
8183        k = z * cosDeltaGamma - y * sinDeltaGamma;
8184    return [
8185      atan2(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi),
8186      asin(k * cosDeltaPhi - x * sinDeltaPhi)
8187    ];
8188  };
8189
8190  return rotation;
8191}
8192
8193function rotation(rotate) {
8194  rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);
8195
8196  function forward(coordinates) {
8197    coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);
8198    return coordinates[0] *= degrees$1, coordinates[1] *= degrees$1, coordinates;
8199  }
8200
8201  forward.invert = function(coordinates) {
8202    coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);
8203    return coordinates[0] *= degrees$1, coordinates[1] *= degrees$1, coordinates;
8204  };
8205
8206  return forward;
8207}
8208
8209// Generates a circle centered at [0°, 0°], with a given radius and precision.
8210function circleStream(stream, radius, delta, direction, t0, t1) {
8211  if (!delta) return;
8212  var cosRadius = cos$1(radius),
8213      sinRadius = sin$1(radius),
8214      step = direction * delta;
8215  if (t0 == null) {
8216    t0 = radius + direction * tau$3;
8217    t1 = radius - step / 2;
8218  } else {
8219    t0 = circleRadius(cosRadius, t0);
8220    t1 = circleRadius(cosRadius, t1);
8221    if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau$3;
8222  }
8223  for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) {
8224    point = spherical([cosRadius, -sinRadius * cos$1(t), -sinRadius * sin$1(t)]);
8225    stream.point(point[0], point[1]);
8226  }
8227}
8228
8229// Returns the signed angle of a cartesian point relative to [cosRadius, 0, 0].
8230function circleRadius(cosRadius, point) {
8231  point = cartesian(point), point[0] -= cosRadius;
8232  cartesianNormalizeInPlace(point);
8233  var radius = acos(-point[1]);
8234  return ((-point[2] < 0 ? -radius : radius) + tau$3 - epsilon$2) % tau$3;
8235}
8236
8237function circle() {
8238  var center = constant$8([0, 0]),
8239      radius = constant$8(90),
8240      precision = constant$8(6),
8241      ring,
8242      rotate,
8243      stream = {point: point};
8244
8245  function point(x, y) {
8246    ring.push(x = rotate(x, y));
8247    x[0] *= degrees$1, x[1] *= degrees$1;
8248  }
8249
8250  function circle() {
8251    var c = center.apply(this, arguments),
8252        r = radius.apply(this, arguments) * radians,
8253        p = precision.apply(this, arguments) * radians;
8254    ring = [];
8255    rotate = rotateRadians(-c[0] * radians, -c[1] * radians, 0).invert;
8256    circleStream(stream, r, p, 1);
8257    c = {type: "Polygon", coordinates: [ring]};
8258    ring = rotate = null;
8259    return c;
8260  }
8261
8262  circle.center = function(_) {
8263    return arguments.length ? (center = typeof _ === "function" ? _ : constant$8([+_[0], +_[1]]), circle) : center;
8264  };
8265
8266  circle.radius = function(_) {
8267    return arguments.length ? (radius = typeof _ === "function" ? _ : constant$8(+_), circle) : radius;
8268  };
8269
8270  circle.precision = function(_) {
8271    return arguments.length ? (precision = typeof _ === "function" ? _ : constant$8(+_), circle) : precision;
8272  };
8273
8274  return circle;
8275}
8276
8277function clipBuffer() {
8278  var lines = [],
8279      line;
8280  return {
8281    point: function(x, y) {
8282      line.push([x, y]);
8283    },
8284    lineStart: function() {
8285      lines.push(line = []);
8286    },
8287    lineEnd: noop$2,
8288    rejoin: function() {
8289      if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
8290    },
8291    result: function() {
8292      var result = lines;
8293      lines = [];
8294      line = null;
8295      return result;
8296    }
8297  };
8298}
8299
8300function pointEqual(a, b) {
8301  return abs(a[0] - b[0]) < epsilon$2 && abs(a[1] - b[1]) < epsilon$2;
8302}
8303
8304function Intersection(point, points, other, entry) {
8305  this.x = point;
8306  this.z = points;
8307  this.o = other; // another intersection
8308  this.e = entry; // is an entry?
8309  this.v = false; // visited
8310  this.n = this.p = null; // next & previous
8311}
8312
8313// A generalized polygon clipping algorithm: given a polygon that has been cut
8314// into its visible line segments, and rejoins the segments by interpolating
8315// along the clip edge.
8316function clipRejoin(segments, compareIntersection, startInside, interpolate, stream) {
8317  var subject = [],
8318      clip = [],
8319      i,
8320      n;
8321
8322  segments.forEach(function(segment) {
8323    if ((n = segment.length - 1) <= 0) return;
8324    var n, p0 = segment[0], p1 = segment[n], x;
8325
8326    // If the first and last points of a segment are coincident, then treat as a
8327    // closed ring. TODO if all rings are closed, then the winding order of the
8328    // exterior ring should be checked.
8329    if (pointEqual(p0, p1)) {
8330      stream.lineStart();
8331      for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]);
8332      stream.lineEnd();
8333      return;
8334    }
8335
8336    subject.push(x = new Intersection(p0, segment, null, true));
8337    clip.push(x.o = new Intersection(p0, null, x, false));
8338    subject.push(x = new Intersection(p1, segment, null, false));
8339    clip.push(x.o = new Intersection(p1, null, x, true));
8340  });
8341
8342  if (!subject.length) return;
8343
8344  clip.sort(compareIntersection);
8345  link$1(subject);
8346  link$1(clip);
8347
8348  for (i = 0, n = clip.length; i < n; ++i) {
8349    clip[i].e = startInside = !startInside;
8350  }
8351
8352  var start = subject[0],
8353      points,
8354      point;
8355
8356  while (1) {
8357    // Find first unvisited intersection.
8358    var current = start,
8359        isSubject = true;
8360    while (current.v) if ((current = current.n) === start) return;
8361    points = current.z;
8362    stream.lineStart();
8363    do {
8364      current.v = current.o.v = true;
8365      if (current.e) {
8366        if (isSubject) {
8367          for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]);
8368        } else {
8369          interpolate(current.x, current.n.x, 1, stream);
8370        }
8371        current = current.n;
8372      } else {
8373        if (isSubject) {
8374          points = current.p.z;
8375          for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]);
8376        } else {
8377          interpolate(current.x, current.p.x, -1, stream);
8378        }
8379        current = current.p;
8380      }
8381      current = current.o;
8382      points = current.z;
8383      isSubject = !isSubject;
8384    } while (!current.v);
8385    stream.lineEnd();
8386  }
8387}
8388
8389function link$1(array) {
8390  if (!(n = array.length)) return;
8391  var n,
8392      i = 0,
8393      a = array[0],
8394      b;
8395  while (++i < n) {
8396    a.n = b = array[i];
8397    b.p = a;
8398    a = b;
8399  }
8400  a.n = b = array[0];
8401  b.p = a;
8402}
8403
8404var sum$1 = adder();
8405
8406function longitude(point) {
8407  if (abs(point[0]) <= pi$3)
8408    return point[0];
8409  else
8410    return sign(point[0]) * ((abs(point[0]) + pi$3) % tau$3 - pi$3);
8411}
8412
8413function polygonContains(polygon, point) {
8414  var lambda = longitude(point),
8415      phi = point[1],
8416      sinPhi = sin$1(phi),
8417      normal = [sin$1(lambda), -cos$1(lambda), 0],
8418      angle = 0,
8419      winding = 0;
8420
8421  sum$1.reset();
8422
8423  if (sinPhi === 1) phi = halfPi$2 + epsilon$2;
8424  else if (sinPhi === -1) phi = -halfPi$2 - epsilon$2;
8425
8426  for (var i = 0, n = polygon.length; i < n; ++i) {
8427    if (!(m = (ring = polygon[i]).length)) continue;
8428    var ring,
8429        m,
8430        point0 = ring[m - 1],
8431        lambda0 = longitude(point0),
8432        phi0 = point0[1] / 2 + quarterPi,
8433        sinPhi0 = sin$1(phi0),
8434        cosPhi0 = cos$1(phi0);
8435
8436    for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
8437      var point1 = ring[j],
8438          lambda1 = longitude(point1),
8439          phi1 = point1[1] / 2 + quarterPi,
8440          sinPhi1 = sin$1(phi1),
8441          cosPhi1 = cos$1(phi1),
8442          delta = lambda1 - lambda0,
8443          sign = delta >= 0 ? 1 : -1,
8444          absDelta = sign * delta,
8445          antimeridian = absDelta > pi$3,
8446          k = sinPhi0 * sinPhi1;
8447
8448      sum$1.add(atan2(k * sign * sin$1(absDelta), cosPhi0 * cosPhi1 + k * cos$1(absDelta)));
8449      angle += antimeridian ? delta + sign * tau$3 : delta;
8450
8451      // Are the longitudes either side of the point’s meridian (lambda),
8452      // and are the latitudes smaller than the parallel (phi)?
8453      if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) {
8454        var arc = cartesianCross(cartesian(point0), cartesian(point1));
8455        cartesianNormalizeInPlace(arc);
8456        var intersection = cartesianCross(normal, arc);
8457        cartesianNormalizeInPlace(intersection);
8458        var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection[2]);
8459        if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
8460          winding += antimeridian ^ delta >= 0 ? 1 : -1;
8461        }
8462      }
8463    }
8464  }
8465
8466  // First, determine whether the South pole is inside or outside:
8467  //
8468  // It is inside if:
8469  // * the polygon winds around it in a clockwise direction.
8470  // * the polygon does not (cumulatively) wind around it, but has a negative
8471  //   (counter-clockwise) area.
8472  //
8473  // Second, count the (signed) number of times a segment crosses a lambda
8474  // from the point to the South pole.  If it is zero, then the point is the
8475  // same side as the South pole.
8476
8477  return (angle < -epsilon$2 || angle < epsilon$2 && sum$1 < -epsilon$2) ^ (winding & 1);
8478}
8479
8480function clip(pointVisible, clipLine, interpolate, start) {
8481  return function(sink) {
8482    var line = clipLine(sink),
8483        ringBuffer = clipBuffer(),
8484        ringSink = clipLine(ringBuffer),
8485        polygonStarted = false,
8486        polygon,
8487        segments,
8488        ring;
8489
8490    var clip = {
8491      point: point,
8492      lineStart: lineStart,
8493      lineEnd: lineEnd,
8494      polygonStart: function() {
8495        clip.point = pointRing;
8496        clip.lineStart = ringStart;
8497        clip.lineEnd = ringEnd;
8498        segments = [];
8499        polygon = [];
8500      },
8501      polygonEnd: function() {
8502        clip.point = point;
8503        clip.lineStart = lineStart;
8504        clip.lineEnd = lineEnd;
8505        segments = merge(segments);
8506        var startInside = polygonContains(polygon, start);
8507        if (segments.length) {
8508          if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
8509          clipRejoin(segments, compareIntersection, startInside, interpolate, sink);
8510        } else if (startInside) {
8511          if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
8512          sink.lineStart();
8513          interpolate(null, null, 1, sink);
8514          sink.lineEnd();
8515        }
8516        if (polygonStarted) sink.polygonEnd(), polygonStarted = false;
8517        segments = polygon = null;
8518      },
8519      sphere: function() {
8520        sink.polygonStart();
8521        sink.lineStart();
8522        interpolate(null, null, 1, sink);
8523        sink.lineEnd();
8524        sink.polygonEnd();
8525      }
8526    };
8527
8528    function point(lambda, phi) {
8529      if (pointVisible(lambda, phi)) sink.point(lambda, phi);
8530    }
8531
8532    function pointLine(lambda, phi) {
8533      line.point(lambda, phi);
8534    }
8535
8536    function lineStart() {
8537      clip.point = pointLine;
8538      line.lineStart();
8539    }
8540
8541    function lineEnd() {
8542      clip.point = point;
8543      line.lineEnd();
8544    }
8545
8546    function pointRing(lambda, phi) {
8547      ring.push([lambda, phi]);
8548      ringSink.point(lambda, phi);
8549    }
8550
8551    function ringStart() {
8552      ringSink.lineStart();
8553      ring = [];
8554    }
8555
8556    function ringEnd() {
8557      pointRing(ring[0][0], ring[0][1]);
8558      ringSink.lineEnd();
8559
8560      var clean = ringSink.clean(),
8561          ringSegments = ringBuffer.result(),
8562          i, n = ringSegments.length, m,
8563          segment,
8564          point;
8565
8566      ring.pop();
8567      polygon.push(ring);
8568      ring = null;
8569
8570      if (!n) return;
8571
8572      // No intersections.
8573      if (clean & 1) {
8574        segment = ringSegments[0];
8575        if ((m = segment.length - 1) > 0) {
8576          if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
8577          sink.lineStart();
8578          for (i = 0; i < m; ++i) sink.point((point = segment[i])[0], point[1]);
8579          sink.lineEnd();
8580        }
8581        return;
8582      }
8583
8584      // Rejoin connected segments.
8585      // TODO reuse ringBuffer.rejoin()?
8586      if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
8587
8588      segments.push(ringSegments.filter(validSegment));
8589    }
8590
8591    return clip;
8592  };
8593}
8594
8595function validSegment(segment) {
8596  return segment.length > 1;
8597}
8598
8599// Intersections are sorted along the clip edge. For both antimeridian cutting
8600// and circle clipping, the same comparison is used.
8601function compareIntersection(a, b) {
8602  return ((a = a.x)[0] < 0 ? a[1] - halfPi$2 - epsilon$2 : halfPi$2 - a[1])
8603       - ((b = b.x)[0] < 0 ? b[1] - halfPi$2 - epsilon$2 : halfPi$2 - b[1]);
8604}
8605
8606var clipAntimeridian = clip(
8607  function() { return true; },
8608  clipAntimeridianLine,
8609  clipAntimeridianInterpolate,
8610  [-pi$3, -halfPi$2]
8611);
8612
8613// Takes a line and cuts into visible segments. Return values: 0 - there were
8614// intersections or the line was empty; 1 - no intersections; 2 - there were
8615// intersections, and the first and last segments should be rejoined.
8616function clipAntimeridianLine(stream) {
8617  var lambda0 = NaN,
8618      phi0 = NaN,
8619      sign0 = NaN,
8620      clean; // no intersections
8621
8622  return {
8623    lineStart: function() {
8624      stream.lineStart();
8625      clean = 1;
8626    },
8627    point: function(lambda1, phi1) {
8628      var sign1 = lambda1 > 0 ? pi$3 : -pi$3,
8629          delta = abs(lambda1 - lambda0);
8630      if (abs(delta - pi$3) < epsilon$2) { // line crosses a pole
8631        stream.point(lambda0, phi0 = (phi0 + phi1) / 2 > 0 ? halfPi$2 : -halfPi$2);
8632        stream.point(sign0, phi0);
8633        stream.lineEnd();
8634        stream.lineStart();
8635        stream.point(sign1, phi0);
8636        stream.point(lambda1, phi0);
8637        clean = 0;
8638      } else if (sign0 !== sign1 && delta >= pi$3) { // line crosses antimeridian
8639        if (abs(lambda0 - sign0) < epsilon$2) lambda0 -= sign0 * epsilon$2; // handle degeneracies
8640        if (abs(lambda1 - sign1) < epsilon$2) lambda1 -= sign1 * epsilon$2;
8641        phi0 = clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1);
8642        stream.point(sign0, phi0);
8643        stream.lineEnd();
8644        stream.lineStart();
8645        stream.point(sign1, phi0);
8646        clean = 0;
8647      }
8648      stream.point(lambda0 = lambda1, phi0 = phi1);
8649      sign0 = sign1;
8650    },
8651    lineEnd: function() {
8652      stream.lineEnd();
8653      lambda0 = phi0 = NaN;
8654    },
8655    clean: function() {
8656      return 2 - clean; // if intersections, rejoin first and last segments
8657    }
8658  };
8659}
8660
8661function clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1) {
8662  var cosPhi0,
8663      cosPhi1,
8664      sinLambda0Lambda1 = sin$1(lambda0 - lambda1);
8665  return abs(sinLambda0Lambda1) > epsilon$2
8666      ? atan((sin$1(phi0) * (cosPhi1 = cos$1(phi1)) * sin$1(lambda1)
8667          - sin$1(phi1) * (cosPhi0 = cos$1(phi0)) * sin$1(lambda0))
8668          / (cosPhi0 * cosPhi1 * sinLambda0Lambda1))
8669      : (phi0 + phi1) / 2;
8670}
8671
8672function clipAntimeridianInterpolate(from, to, direction, stream) {
8673  var phi;
8674  if (from == null) {
8675    phi = direction * halfPi$2;
8676    stream.point(-pi$3, phi);
8677    stream.point(0, phi);
8678    stream.point(pi$3, phi);
8679    stream.point(pi$3, 0);
8680    stream.point(pi$3, -phi);
8681    stream.point(0, -phi);
8682    stream.point(-pi$3, -phi);
8683    stream.point(-pi$3, 0);
8684    stream.point(-pi$3, phi);
8685  } else if (abs(from[0] - to[0]) > epsilon$2) {
8686    var lambda = from[0] < to[0] ? pi$3 : -pi$3;
8687    phi = direction * lambda / 2;
8688    stream.point(-lambda, phi);
8689    stream.point(0, phi);
8690    stream.point(lambda, phi);
8691  } else {
8692    stream.point(to[0], to[1]);
8693  }
8694}
8695
8696function clipCircle(radius) {
8697  var cr = cos$1(radius),
8698      delta = 6 * radians,
8699      smallRadius = cr > 0,
8700      notHemisphere = abs(cr) > epsilon$2; // TODO optimise for this common case
8701
8702  function interpolate(from, to, direction, stream) {
8703    circleStream(stream, radius, delta, direction, from, to);
8704  }
8705
8706  function visible(lambda, phi) {
8707    return cos$1(lambda) * cos$1(phi) > cr;
8708  }
8709
8710  // Takes a line and cuts into visible segments. Return values used for polygon
8711  // clipping: 0 - there were intersections or the line was empty; 1 - no
8712  // intersections 2 - there were intersections, and the first and last segments
8713  // should be rejoined.
8714  function clipLine(stream) {
8715    var point0, // previous point
8716        c0, // code for previous point
8717        v0, // visibility of previous point
8718        v00, // visibility of first point
8719        clean; // no intersections
8720    return {
8721      lineStart: function() {
8722        v00 = v0 = false;
8723        clean = 1;
8724      },
8725      point: function(lambda, phi) {
8726        var point1 = [lambda, phi],
8727            point2,
8728            v = visible(lambda, phi),
8729            c = smallRadius
8730              ? v ? 0 : code(lambda, phi)
8731              : v ? code(lambda + (lambda < 0 ? pi$3 : -pi$3), phi) : 0;
8732        if (!point0 && (v00 = v0 = v)) stream.lineStart();
8733        // Handle degeneracies.
8734        // TODO ignore if not clipping polygons.
8735        if (v !== v0) {
8736          point2 = intersect(point0, point1);
8737          if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2)) {
8738            point1[0] += epsilon$2;
8739            point1[1] += epsilon$2;
8740            v = visible(point1[0], point1[1]);
8741          }
8742        }
8743        if (v !== v0) {
8744          clean = 0;
8745          if (v) {
8746            // outside going in
8747            stream.lineStart();
8748            point2 = intersect(point1, point0);
8749            stream.point(point2[0], point2[1]);
8750          } else {
8751            // inside going out
8752            point2 = intersect(point0, point1);
8753            stream.point(point2[0], point2[1]);
8754            stream.lineEnd();
8755          }
8756          point0 = point2;
8757        } else if (notHemisphere && point0 && smallRadius ^ v) {
8758          var t;
8759          // If the codes for two points are different, or are both zero,
8760          // and there this segment intersects with the small circle.
8761          if (!(c & c0) && (t = intersect(point1, point0, true))) {
8762            clean = 0;
8763            if (smallRadius) {
8764              stream.lineStart();
8765              stream.point(t[0][0], t[0][1]);
8766              stream.point(t[1][0], t[1][1]);
8767              stream.lineEnd();
8768            } else {
8769              stream.point(t[1][0], t[1][1]);
8770              stream.lineEnd();
8771              stream.lineStart();
8772              stream.point(t[0][0], t[0][1]);
8773            }
8774          }
8775        }
8776        if (v && (!point0 || !pointEqual(point0, point1))) {
8777          stream.point(point1[0], point1[1]);
8778        }
8779        point0 = point1, v0 = v, c0 = c;
8780      },
8781      lineEnd: function() {
8782        if (v0) stream.lineEnd();
8783        point0 = null;
8784      },
8785      // Rejoin first and last segments if there were intersections and the first
8786      // and last points were visible.
8787      clean: function() {
8788        return clean | ((v00 && v0) << 1);
8789      }
8790    };
8791  }
8792
8793  // Intersects the great circle between a and b with the clip circle.
8794  function intersect(a, b, two) {
8795    var pa = cartesian(a),
8796        pb = cartesian(b);
8797
8798    // We have two planes, n1.p = d1 and n2.p = d2.
8799    // Find intersection line p(t) = c1 n1 + c2 n2 + t (n1 ⨯ n2).
8800    var n1 = [1, 0, 0], // normal
8801        n2 = cartesianCross(pa, pb),
8802        n2n2 = cartesianDot(n2, n2),
8803        n1n2 = n2[0], // cartesianDot(n1, n2),
8804        determinant = n2n2 - n1n2 * n1n2;
8805
8806    // Two polar points.
8807    if (!determinant) return !two && a;
8808
8809    var c1 =  cr * n2n2 / determinant,
8810        c2 = -cr * n1n2 / determinant,
8811        n1xn2 = cartesianCross(n1, n2),
8812        A = cartesianScale(n1, c1),
8813        B = cartesianScale(n2, c2);
8814    cartesianAddInPlace(A, B);
8815
8816    // Solve |p(t)|^2 = 1.
8817    var u = n1xn2,
8818        w = cartesianDot(A, u),
8819        uu = cartesianDot(u, u),
8820        t2 = w * w - uu * (cartesianDot(A, A) - 1);
8821
8822    if (t2 < 0) return;
8823
8824    var t = sqrt(t2),
8825        q = cartesianScale(u, (-w - t) / uu);
8826    cartesianAddInPlace(q, A);
8827    q = spherical(q);
8828
8829    if (!two) return q;
8830
8831    // Two intersection points.
8832    var lambda0 = a[0],
8833        lambda1 = b[0],
8834        phi0 = a[1],
8835        phi1 = b[1],
8836        z;
8837
8838    if (lambda1 < lambda0) z = lambda0, lambda0 = lambda1, lambda1 = z;
8839
8840    var delta = lambda1 - lambda0,
8841        polar = abs(delta - pi$3) < epsilon$2,
8842        meridian = polar || delta < epsilon$2;
8843
8844    if (!polar && phi1 < phi0) z = phi0, phi0 = phi1, phi1 = z;
8845
8846    // Check that the first point is between a and b.
8847    if (meridian
8848        ? polar
8849          ? phi0 + phi1 > 0 ^ q[1] < (abs(q[0] - lambda0) < epsilon$2 ? phi0 : phi1)
8850          : phi0 <= q[1] && q[1] <= phi1
8851        : delta > pi$3 ^ (lambda0 <= q[0] && q[0] <= lambda1)) {
8852      var q1 = cartesianScale(u, (-w + t) / uu);
8853      cartesianAddInPlace(q1, A);
8854      return [q, spherical(q1)];
8855    }
8856  }
8857
8858  // Generates a 4-bit vector representing the location of a point relative to
8859  // the small circle's bounding box.
8860  function code(lambda, phi) {
8861    var r = smallRadius ? radius : pi$3 - radius,
8862        code = 0;
8863    if (lambda < -r) code |= 1; // left
8864    else if (lambda > r) code |= 2; // right
8865    if (phi < -r) code |= 4; // below
8866    else if (phi > r) code |= 8; // above
8867    return code;
8868  }
8869
8870  return clip(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi$3, radius - pi$3]);
8871}
8872
8873function clipLine(a, b, x0, y0, x1, y1) {
8874  var ax = a[0],
8875      ay = a[1],
8876      bx = b[0],
8877      by = b[1],
8878      t0 = 0,
8879      t1 = 1,
8880      dx = bx - ax,
8881      dy = by - ay,
8882      r;
8883
8884  r = x0 - ax;
8885  if (!dx && r > 0) return;
8886  r /= dx;
8887  if (dx < 0) {
8888    if (r < t0) return;
8889    if (r < t1) t1 = r;
8890  } else if (dx > 0) {
8891    if (r > t1) return;
8892    if (r > t0) t0 = r;
8893  }
8894
8895  r = x1 - ax;
8896  if (!dx && r < 0) return;
8897  r /= dx;
8898  if (dx < 0) {
8899    if (r > t1) return;
8900    if (r > t0) t0 = r;
8901  } else if (dx > 0) {
8902    if (r < t0) return;
8903    if (r < t1) t1 = r;
8904  }
8905
8906  r = y0 - ay;
8907  if (!dy && r > 0) return;
8908  r /= dy;
8909  if (dy < 0) {
8910    if (r < t0) return;
8911    if (r < t1) t1 = r;
8912  } else if (dy > 0) {
8913    if (r > t1) return;
8914    if (r > t0) t0 = r;
8915  }
8916
8917  r = y1 - ay;
8918  if (!dy && r < 0) return;
8919  r /= dy;
8920  if (dy < 0) {
8921    if (r > t1) return;
8922    if (r > t0) t0 = r;
8923  } else if (dy > 0) {
8924    if (r < t0) return;
8925    if (r < t1) t1 = r;
8926  }
8927
8928  if (t0 > 0) a[0] = ax + t0 * dx, a[1] = ay + t0 * dy;
8929  if (t1 < 1) b[0] = ax + t1 * dx, b[1] = ay + t1 * dy;
8930  return true;
8931}
8932
8933var clipMax = 1e9, clipMin = -clipMax;
8934
8935// TODO Use d3-polygon’s polygonContains here for the ring check?
8936// TODO Eliminate duplicate buffering in clipBuffer and polygon.push?
8937
8938function clipRectangle(x0, y0, x1, y1) {
8939
8940  function visible(x, y) {
8941    return x0 <= x && x <= x1 && y0 <= y && y <= y1;
8942  }
8943
8944  function interpolate(from, to, direction, stream) {
8945    var a = 0, a1 = 0;
8946    if (from == null
8947        || (a = corner(from, direction)) !== (a1 = corner(to, direction))
8948        || comparePoint(from, to) < 0 ^ direction > 0) {
8949      do stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
8950      while ((a = (a + direction + 4) % 4) !== a1);
8951    } else {
8952      stream.point(to[0], to[1]);
8953    }
8954  }
8955
8956  function corner(p, direction) {
8957    return abs(p[0] - x0) < epsilon$2 ? direction > 0 ? 0 : 3
8958        : abs(p[0] - x1) < epsilon$2 ? direction > 0 ? 2 : 1
8959        : abs(p[1] - y0) < epsilon$2 ? direction > 0 ? 1 : 0
8960        : direction > 0 ? 3 : 2; // abs(p[1] - y1) < epsilon
8961  }
8962
8963  function compareIntersection(a, b) {
8964    return comparePoint(a.x, b.x);
8965  }
8966
8967  function comparePoint(a, b) {
8968    var ca = corner(a, 1),
8969        cb = corner(b, 1);
8970    return ca !== cb ? ca - cb
8971        : ca === 0 ? b[1] - a[1]
8972        : ca === 1 ? a[0] - b[0]
8973        : ca === 2 ? a[1] - b[1]
8974        : b[0] - a[0];
8975  }
8976
8977  return function(stream) {
8978    var activeStream = stream,
8979        bufferStream = clipBuffer(),
8980        segments,
8981        polygon,
8982        ring,
8983        x__, y__, v__, // first point
8984        x_, y_, v_, // previous point
8985        first,
8986        clean;
8987
8988    var clipStream = {
8989      point: point,
8990      lineStart: lineStart,
8991      lineEnd: lineEnd,
8992      polygonStart: polygonStart,
8993      polygonEnd: polygonEnd
8994    };
8995
8996    function point(x, y) {
8997      if (visible(x, y)) activeStream.point(x, y);
8998    }
8999
9000    function polygonInside() {
9001      var winding = 0;
9002
9003      for (var i = 0, n = polygon.length; i < n; ++i) {
9004        for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) {
9005          a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1];
9006          if (a1 <= y1) { if (b1 > y1 && (b0 - a0) * (y1 - a1) >
vendor: 4,186 bytes, lines 9006-9154
9006 (b1 - a1) * (x0 - a0)) ++winding; }
9007          else { if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; }
9008        }
9009      }
9010
9011      return winding;
9012    }
9013
9014    // Buffer geometry within a polygon and then clip it en masse.
9015    function polygonStart() {
9016      activeStream = bufferStream, segments = [], polygon = [], clean = true;
9017    }
9018
9019    function polygonEnd() {
9020      var startInside = polygonInside(),
9021          cleanInside = clean && startInside,
9022          visible = (segments = merge(segments)).length;
9023      if (cleanInside || visible) {
9024        stream.polygonStart();
9025        if (cleanInside) {
9026          stream.lineStart();
9027          interpolate(null, null, 1, stream);
9028          stream.lineEnd();
9029        }
9030        if (visible) {
9031          clipRejoin(segments, compareIntersection, startInside, interpolate, stream);
9032        }
9033        stream.polygonEnd();
9034      }
9035      activeStream = stream, segments = polygon = ring = null;
9036    }
9037
9038    function lineStart() {
9039      clipStream.point = linePoint;
9040      if (polygon) polygon.push(ring = []);
9041      first = true;
9042      v_ = false;
9043      x_ = y_ = NaN;
9044    }
9045
9046    // TODO rather than special-case polygons, simply handle them separately.
9047    // Ideally, coincident intersection points should be jittered to avoid
9048    // clipping issues.
9049    function lineEnd() {
9050      if (segments) {
9051        linePoint(x__, y__);
9052        if (v__ && v_) bufferStream.rejoin();
9053        segments.push(bufferStream.result());
9054      }
9055      clipStream.point = point;
9056      if (v_) activeStream.lineEnd();
9057    }
9058
9059    function linePoint(x, y) {
9060      var v = visible(x, y);
9061      if (polygon) ring.push([x, y]);
9062      if (first) {
9063        x__ = x, y__ = y, v__ = v;
9064        first = false;
9065        if (v) {
9066          activeStream.lineStart();
9067          activeStream.point(x, y);
9068        }
9069      } else {
9070        if (v && v_) activeStream.point(x, y);
9071        else {
9072          var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))],
9073              b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))];
9074          if (clipLine(a, b, x0, y0, x1, y1)) {
9075            if (!v_) {
9076              activeStream.lineStart();
9077              activeStream.point(a[0], a[1]);
9078            }
9079            activeStream.point(b[0], b[1]);
9080            if (!v) activeStream.lineEnd();
9081            clean = false;
9082          } else if (v) {
9083            activeStream.lineStart();
9084            activeStream.point(x, y);
9085            clean = false;
9086          }
9087        }
9088      }
9089      x_ = x, y_ = y, v_ = v;
9090    }
9091
9092    return clipStream;
9093  };
9094}
9095
9096function extent$1() {
9097  var x0 = 0,
9098      y0 = 0,
9099      x1 = 960,
9100      y1 = 500,
9101      cache,
9102      cacheStream,
9103      clip;
9104
9105  return clip = {
9106    stream: function(stream) {
9107      return cache && cacheStream === stream ? cache : cache = clipRectangle(x0, y0, x1, y1)(cacheStream = stream);
9108    },
9109    extent: function(_) {
9110      return arguments.length ? (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1], cache = cacheStream = null, clip) : [[x0, y0], [x1, y1]];
9111    }
9112  };
9113}
9114
9115var lengthSum = adder(),
9116    lambda0$2,
9117    sinPhi0$1,
9118    cosPhi0$1;
9119
9120var lengthStream = {
9121  sphere: noop$2,
9122  point: noop$2,
9123  lineStart: lengthLineStart,
9124  lineEnd: noop$2,
9125  polygonStart: noop$2,
9126  polygonEnd: noop$2
9127};
9128
9129function lengthLineStart() {
9130  lengthStream.point = lengthPointFirst;
9131  lengthStream.lineEnd = lengthLineEnd;
9132}
9133
9134function lengthLineEnd() {
9135  lengthStream.point = lengthStream.lineEnd = noop$2;
9136}
9137
9138function lengthPointFirst(lambda, phi) {
9139  lambda *= radians, phi *= radians;
9140  lambda0$2 = lambda, sinPhi0$1 = sin$1(phi), cosPhi0$1 = cos$1(phi);
9141  lengthStream.point = lengthPoint;
9142}
9143
9144function lengthPoint(lambda, phi) {
9145  lambda *= radians, phi *= radians;
9146  var sinPhi = sin$1(phi),
9147      cosPhi = cos$1(phi),
9148      delta = abs(lambda - lambda0$2),
9149      cosDelta = cos$1(delta),
9150      sinDelta = sin$1(delta),
9151      x = cosPhi * sinDelta,
9152      y = cosPhi0$1 * sinPhi - sinPhi0$1 * cosPhi * cosDelta,
9153      z = sinPhi0$1 * sinPhi + cosPhi0$1 * cosPhi * cosDelta;
9154  lengthSum.add(atan2(sqrt(x * x + y * y), z));
vendor: 5,271 bytes, lines 9155-9333
9155  lambda0$2 = lambda, sinPhi0$1 = sinPhi, cosPhi0$1 = cosPhi;
9156}
9157
9158function length$1(object) {
9159  lengthSum.reset();
9160  geoStream(object, lengthStream);
9161  return +lengthSum;
9162}
9163
9164var coordinates = [null, null],
9165    object$1 = {type: "LineString", coordinates: coordinates};
9166
9167function distance(a, b) {
9168  coordinates[0] = a;
9169  coordinates[1] = b;
9170  return length$1(object$1);
9171}
9172
9173var containsObjectType = {
9174  Feature: function(object, point) {
9175    return containsGeometry(object.geometry, point);
9176  },
9177  FeatureCollection: function(object, point) {
9178    var features = object.features, i = -1, n = features.length;
9179    while (++i < n) if (containsGeometry(features[i].geometry, point)) return true;
9180    return false;
9181  }
9182};
9183
9184var containsGeometryType = {
9185  Sphere: function() {
9186    return true;
9187  },
9188  Point: function(object, point) {
9189    return containsPoint(object.coordinates, point);
9190  },
9191  MultiPoint: function(object, point) {
9192    var coordinates = object.coordinates, i = -1, n = coordinates.length;
9193    while (++i < n) if (containsPoint(coordinates[i], point)) return true;
9194    return false;
9195  },
9196  LineString: function(object, point) {
9197    return containsLine(object.coordinates, point);
9198  },
9199  MultiLineString: function(object, point) {
9200    var coordinates = object.coordinates, i = -1, n = coordinates.length;
9201    while (++i < n) if (containsLine(coordinates[i], point)) return true;
9202    return false;
9203  },
9204  Polygon: function(object, point) {
9205    return containsPolygon(object.coordinates, point);
9206  },
9207  MultiPolygon: function(object, point) {
9208    var coordinates = object.coordinates, i = -1, n = coordinates.length;
9209    while (++i < n) if (containsPolygon(coordinates[i], point)) return true;
9210    return false;
9211  },
9212  GeometryCollection: function(object, point) {
9213    var geometries = object.geometries, i = -1, n = geometries.length;
9214    while (++i < n) if (containsGeometry(geometries[i], point)) return true;
9215    return false;
9216  }
9217};
9218
9219function containsGeometry(geometry, point) {
9220  return geometry && containsGeometryType.hasOwnProperty(geometry.type)
9221      ? containsGeometryType[geometry.type](geometry, point)
9222      : false;
9223}
9224
9225function containsPoint(coordinates, point) {
9226  return distance(coordinates, point) === 0;
9227}
9228
9229function containsLine(coordinates, point) {
9230  var ao, bo, ab;
9231  for (var i = 0, n = coordinates.length; i < n; i++) {
9232    bo = distance(coordinates[i], point);
9233    if (bo === 0) return true;
9234    if (i > 0) {
9235      ab = distance(coordinates[i], coordinates[i - 1]);
9236      if (
9237        ab > 0 &&
9238        ao <= ab &&
9239        bo <= ab &&
9240        (ao + bo - ab) * (1 - Math.pow((ao - bo) / ab, 2)) < epsilon2$1 * ab
9241      )
9242        return true;
9243    }
9244    ao = bo;
9245  }
9246  return false;
9247}
9248
9249function containsPolygon(coordinates, point) {
9250  return !!polygonContains(coordinates.map(ringRadians), pointRadians(point));
9251}
9252
9253function ringRadians(ring) {
9254  return ring = ring.map(pointRadians), ring.pop(), ring;
9255}
9256
9257function pointRadians(point) {
9258  return [point[0] * radians, point[1] * radians];
9259}
9260
9261function contains$1(object, point) {
9262  return (object && containsObjectType.hasOwnProperty(object.type)
9263      ? containsObjectType[object.type]
9264      : containsGeometry)(object, point);
9265}
9266
9267function graticuleX(y0, y1, dy) {
9268  var y = sequence(y0, y1 - epsilon$2, dy).concat(y1);
9269  return function(x) { return y.map(function(y) { return [x, y]; }); };
9270}
9271
9272function graticuleY(x0, x1, dx) {
9273  var x = sequence(x0, x1 - epsilon$2, dx).concat(x1);
9274  return function(y) { return x.map(function(x) { return [x, y]; }); };
9275}
9276
9277function graticule() {
9278  var x1, x0, X1, X0,
9279      y1, y0, Y1, Y0,
9280      dx = 10, dy = dx, DX = 90, DY = 360,
9281      x, y, X, Y,
9282      precision = 2.5;
9283
9284  function graticule() {
9285    return {type: "MultiLineString", coordinates: lines()};
9286  }
9287
9288  function lines() {
9289    return sequence(ceil(X0 / DX) * DX, X1, DX).map(X)
9290        .concat(sequence(ceil(Y0 / DY) * DY, Y1, DY).map(Y))
9291        .concat(sequence(ceil(x0 / dx) * dx, x1, dx).filter(function(x) { return abs(x % DX) > epsilon$2; }).map(x))
9292        .concat(sequence(ceil(y0 / dy) * dy, y1, dy).filter(function(y) { return abs(y % DY) > epsilon$2; }).map(y));
9293  }
9294
9295  graticule.lines = function() {
9296    return lines().map(function(coordinates) { return {type: "LineString", coordinates: coordinates}; });
9297  };
9298
9299  graticule.outline = function() {
9300    return {
9301      type: "Polygon",
9302      coordinates: [
9303        X(X0).concat(
9304        Y(Y1).slice(1),
9305        X(X1).reverse().slice(1),
9306        Y(Y0).reverse().slice(1))
9307      ]
9308    };
9309  };
9310
9311  graticule.extent = function(_) {
9312    if (!arguments.length) return graticule.extentMinor();
9313    return graticule.extentMajor(_).extentMinor(_);
9314  };
9315
9316  graticule.extentMajor = function(_) {
9317    if (!arguments.length) return [[X0, Y0], [X1, Y1]];
9318    X0 = +_[0][0], X1 = +_[1][0];
9319    Y0 = +_[0][1], Y1 = +_[1][1];
9320    if (X0 > X1) _ = X0, X0 = X1, X1 = _;
9321    if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;
9322    return graticule.precision(precision);
9323  };
9324
9325  graticule.extentMinor = function(_) {
9326    if (!arguments.length) return [[x0, y0], [x1, y1]];
9327    x0 = +_[0][0], x1 = +_[1][0];
9328    y0 = +_[0][1], y1 = +_[1][1];
9329    if (x0 > x1) _ = x0, x0 = x1, x1 = _;
9330    if (y0 > y1) _ = y0, y0 = y1, y1 = _;
9331    return graticule.precision(precision);
9332  };
9333
vendor: 4,390 bytes, lines 9334-9531
9334  graticule.step = function(_) {
9335    if (!arguments.length) return graticule.stepMinor();
9336    return graticule.stepMajor(_).stepMinor(_);
9337  };
9338
9339  graticule.stepMajor = function(_) {
9340    if (!arguments.length) return [DX, DY];
9341    DX = +_[0], DY = +_[1];
9342    return graticule;
9343  };
9344
9345  graticule.stepMinor = function(_) {
9346    if (!arguments.length) return [dx, dy];
9347    dx = +_[0], dy = +_[1];
9348    return graticule;
9349  };
9350
9351  graticule.precision = function(_) {
9352    if (!arguments.length) return precision;
9353    precision = +_;
9354    x = graticuleX(y0, y1, 90);
9355    y = graticuleY(x0, x1, precision);
9356    X = graticuleX(Y0, Y1, 90);
9357    Y = graticuleY(X0, X1, precision);
9358    return graticule;
9359  };
9360
9361  return graticule
9362      .extentMajor([[-180, -90 + epsilon$2], [180, 90 - epsilon$2]])
9363      .extentMinor([[-180, -80 - epsilon$2], [180, 80 + epsilon$2]]);
9364}
9365
9366function graticule10() {
9367  return graticule()();
9368}
9369
9370function interpolate$1(a, b) {
9371  var x0 = a[0] * radians,
9372      y0 = a[1] * radians,
9373      x1 = b[0] * radians,
9374      y1 = b[1] * radians,
9375      cy0 = cos$1(y0),
9376      sy0 = sin$1(y0),
9377      cy1 = cos$1(y1),
9378      sy1 = sin$1(y1),
9379      kx0 = cy0 * cos$1(x0),
9380      ky0 = cy0 * sin$1(x0),
9381      kx1 = cy1 * cos$1(x1),
9382      ky1 = cy1 * sin$1(x1),
9383      d = 2 * asin(sqrt(haversin(y1 - y0) + cy0 * cy1 * haversin(x1 - x0))),
9384      k = sin$1(d);
9385
9386  var interpolate = d ? function(t) {
9387    var B = sin$1(t *= d) / k,
9388        A = sin$1(d - t) / k,
9389        x = A * kx0 + B * kx1,
9390        y = A * ky0 + B * ky1,
9391        z = A * sy0 + B * sy1;
9392    return [
9393      atan2(y, x) * degrees$1,
9394      atan2(z, sqrt(x * x + y * y)) * degrees$1
9395    ];
9396  } : function() {
9397    return [x0 * degrees$1, y0 * degrees$1];
9398  };
9399
9400  interpolate.distance = d;
9401
9402  return interpolate;
9403}
9404
9405function identity$4(x) {
9406  return x;
9407}
9408
9409var areaSum$1 = adder(),
9410    areaRingSum$1 = adder(),
9411    x00,
9412    y00,
9413    x0$1,
9414    y0$1;
9415
9416var areaStream$1 = {
9417  point: noop$2,
9418  lineStart: noop$2,
9419  lineEnd: noop$2,
9420  polygonStart: function() {
9421    areaStream$1.lineStart = areaRingStart$1;
9422    areaStream$1.lineEnd = areaRingEnd$1;
9423  },
9424  polygonEnd: function() {
9425    areaStream$1.lineStart = areaStream$1.lineEnd = areaStream$1.point = noop$2;
9426    areaSum$1.add(abs(areaRingSum$1));
9427    areaRingSum$1.reset();
9428  },
9429  result: function() {
9430    var area = areaSum$1 / 2;
9431    areaSum$1.reset();
9432    return area;
9433  }
9434};
9435
9436function areaRingStart$1() {
9437  areaStream$1.point = areaPointFirst$1;
9438}
9439
9440function areaPointFirst$1(x, y) {
9441  areaStream$1.point = areaPoint$1;
9442  x00 = x0$1 = x, y00 = y0$1 = y;
9443}
9444
9445function areaPoint$1(x, y) {
9446  areaRingSum$1.add(y0$1 * x - x0$1 * y);
9447  x0$1 = x, y0$1 = y;
9448}
9449
9450function areaRingEnd$1() {
9451  areaPoint$1(x00, y00);
9452}
9453
9454var x0$2 = Infinity,
9455    y0$2 = x0$2,
9456    x1 = -x0$2,
9457    y1 = x1;
9458
9459var boundsStream$1 = {
9460  point: boundsPoint$1,
9461  lineStart: noop$2,
9462  lineEnd: noop$2,
9463  polygonStart: noop$2,
9464  polygonEnd: noop$2,
9465  result: function() {
9466    var bounds = [[x0$2, y0$2], [x1, y1]];
9467    x1 = y1 = -(y0$2 = x0$2 = Infinity);
9468    return bounds;
9469  }
9470};
9471
9472function boundsPoint$1(x, y) {
9473  if (x < x0$2) x0$2 = x;
9474  if (x > x1) x1 = x;
9475  if (y < y0$2) y0$2 = y;
9476  if (y > y1) y1 = y;
9477}
9478
9479// TODO Enforce positive area for exterior, negative area for interior?
9480
9481var X0$1 = 0,
9482    Y0$1 = 0,
9483    Z0$1 = 0,
9484    X1$1 = 0,
9485    Y1$1 = 0,
9486    Z1$1 = 0,
9487    X2$1 = 0,
9488    Y2$1 = 0,
9489    Z2$1 = 0,
9490    x00$1,
9491    y00$1,
9492    x0$3,
9493    y0$3;
9494
9495var centroidStream$1 = {
9496  point: centroidPoint$1,
9497  lineStart: centroidLineStart$1,
9498  lineEnd: centroidLineEnd$1,
9499  polygonStart: function() {
9500    centroidStream$1.lineStart = centroidRingStart$1;
9501    centroidStream$1.lineEnd = centroidRingEnd$1;
9502  },
9503  polygonEnd: function() {
9504    centroidStream$1.point = centroidPoint$1;
9505    centroidStream$1.lineStart = centroidLineStart$1;
9506    centroidStream$1.lineEnd = centroidLineEnd$1;
9507  },
9508  result: function() {
9509    var centroid = Z2$1 ? [X2$1 / Z2$1, Y2$1 / Z2$1]
9510        : Z1$1 ? [X1$1 / Z1$1, Y1$1 / Z1$1]
9511        : Z0$1 ? [X0$1 / Z0$1, Y0$1 / Z0$1]
9512        : [NaN, NaN];
9513    X0$1 = Y0$1 = Z0$1 =
9514    X1$1 = Y1$1 = Z1$1 =
9515    X2$1 = Y2$1 = Z2$1 = 0;
9516    return centroid;
9517  }
9518};
9519
9520function centroidPoint$1(x, y) {
9521  X0$1 += x;
9522  Y0$1 += y;
9523  ++Z0$1;
9524}
9525
9526function centroidLineStart$1() {
9527  centroidStream$1.point = centroidPointFirstLine;
9528}
9529
9530function centroidPointFirstLine(x, y) {
9531  centroidStream$1.point = centroidPointLine;
vendor: 16,384 bytes, lines 9532-10116
9532  centroidPoint$1(x0$3 = x, y0$3 = y);
9533}
9534
9535function centroidPointLine(x, y) {
9536  var dx = x - x0$3, dy = y - y0$3, z = sqrt(dx * dx + dy * dy);
9537  X1$1 += z * (x0$3 + x) / 2;
9538  Y1$1 += z * (y0$3 + y) / 2;
9539  Z1$1 += z;
9540  centroidPoint$1(x0$3 = x, y0$3 = y);
9541}
9542
9543function centroidLineEnd$1() {
9544  centroidStream$1.point = centroidPoint$1;
9545}
9546
9547function centroidRingStart$1() {
9548  centroidStream$1.point = centroidPointFirstRing;
9549}
9550
9551function centroidRingEnd$1() {
9552  centroidPointRing(x00$1, y00$1);
9553}
9554
9555function centroidPointFirstRing(x, y) {
9556  centroidStream$1.point = centroidPointRing;
9557  centroidPoint$1(x00$1 = x0$3 = x, y00$1 = y0$3 = y);
9558}
9559
9560function centroidPointRing(x, y) {
9561  var dx = x - x0$3,
9562      dy = y - y0$3,
9563      z = sqrt(dx * dx + dy * dy);
9564
9565  X1$1 += z * (x0$3 + x) / 2;
9566  Y1$1 += z * (y0$3 + y) / 2;
9567  Z1$1 += z;
9568
9569  z = y0$3 * x - x0$3 * y;
9570  X2$1 += z * (x0$3 + x);
9571  Y2$1 += z * (y0$3 + y);
9572  Z2$1 += z * 3;
9573  centroidPoint$1(x0$3 = x, y0$3 = y);
9574}
9575
9576function PathContext(context) {
9577  this._context = context;
9578}
9579
9580PathContext.prototype = {
9581  _radius: 4.5,
9582  pointRadius: function(_) {
9583    return this._radius = _, this;
9584  },
9585  polygonStart: function() {
9586    this._line = 0;
9587  },
9588  polygonEnd: function() {
9589    this._line = NaN;
9590  },
9591  lineStart: function() {
9592    this._point = 0;
9593  },
9594  lineEnd: function() {
9595    if (this._line === 0) this._context.closePath();
9596    this._point = NaN;
9597  },
9598  point: function(x, y) {
9599    switch (this._point) {
9600      case 0: {
9601        this._context.moveTo(x, y);
9602        this._point = 1;
9603        break;
9604      }
9605      case 1: {
9606        this._context.lineTo(x, y);
9607        break;
9608      }
9609      default: {
9610        this._context.moveTo(x + this._radius, y);
9611        this._context.arc(x, y, this._radius, 0, tau$3);
9612        break;
9613      }
9614    }
9615  },
9616  result: noop$2
9617};
9618
9619var lengthSum$1 = adder(),
9620    lengthRing,
9621    x00$2,
9622    y00$2,
9623    x0$4,
9624    y0$4;
9625
9626var lengthStream$1 = {
9627  point: noop$2,
9628  lineStart: function() {
9629    lengthStream$1.point = lengthPointFirst$1;
9630  },
9631  lineEnd: function() {
9632    if (lengthRing) lengthPoint$1(x00$2, y00$2);
9633    lengthStream$1.point = noop$2;
9634  },
9635  polygonStart: function() {
9636    lengthRing = true;
9637  },
9638  polygonEnd: function() {
9639    lengthRing = null;
9640  },
9641  result: function() {
9642    var length = +lengthSum$1;
9643    lengthSum$1.reset();
9644    return length;
9645  }
9646};
9647
9648function lengthPointFirst$1(x, y) {
9649  lengthStream$1.point = lengthPoint$1;
9650  x00$2 = x0$4 = x, y00$2 = y0$4 = y;
9651}
9652
9653function lengthPoint$1(x, y) {
9654  x0$4 -= x, y0$4 -= y;
9655  lengthSum$1.add(sqrt(x0$4 * x0$4 + y0$4 * y0$4));
9656  x0$4 = x, y0$4 = y;
9657}
9658
9659function PathString() {
9660  this._string = [];
9661}
9662
9663PathString.prototype = {
9664  _radius: 4.5,
9665  _circle: circle$1(4.5),
9666  pointRadius: function(_) {
9667    if ((_ = +_) !== this._radius) this._radius = _, this._circle = null;
9668    return this;
9669  },
9670  polygonStart: function() {
9671    this._line = 0;
9672  },
9673  polygonEnd: function() {
9674    this._line = NaN;
9675  },
9676  lineStart: function() {
9677    this._point = 0;
9678  },
9679  lineEnd: function() {
9680    if (this._line === 0) this._string.push("Z");
9681    this._point = NaN;
9682  },
9683  point: function(x, y) {
9684    switch (this._point) {
9685      case 0: {
9686        this._string.push("M", x, ",", y);
9687        this._point = 1;
9688        break;
9689      }
9690      case 1: {
9691        this._string.push("L", x, ",", y);
9692        break;
9693      }
9694      default: {
9695        if (this._circle == null) this._circle = circle$1(this._radius);
9696        this._string.push("M", x, ",", y, this._circle);
9697        break;
9698      }
9699    }
9700  },
9701  result: function() {
9702    if (this._string.length) {
9703      var result = this._string.join("");
9704      this._string = [];
9705      return result;
9706    } else {
9707      return null;
9708    }
9709  }
9710};
9711
9712function circle$1(radius) {
9713  return "m0," + radius
9714      + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius
9715      + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius
9716      + "z";
9717}
9718
9719function index$1(projection, context) {
9720  var pointRadius = 4.5,
9721      projectionStream,
9722      contextStream;
9723
9724  function path(object) {
9725    if (object) {
9726      if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
9727      geoStream(object, projectionStream(contextStream));
9728    }
9729    return contextStream.result();
9730  }
9731
9732  path.area = function(object) {
9733    geoStream(object, projectionStream(areaStream$1));
9734    return areaStream$1.result();
9735  };
9736
9737  path.measure = function(object) {
9738    geoStream(object, projectionStream(lengthStream$1));
9739    return lengthStream$1.result();
9740  };
9741
9742  path.bounds = function(object) {
9743    geoStream(object, projectionStream(boundsStream$1));
9744    return boundsStream$1.result();
9745  };
9746
9747  path.centroid = function(object) {
9748    geoStream(object, projectionStream(centroidStream$1));
9749    return centroidStream$1.result();
9750  };
9751
9752  path.projection = function(_) {
9753    return arguments.length ? (projectionStream = _ == null ? (projection = null, identity$4) : (projection = _).stream, path) : projection;
9754  };
9755
9756  path.context = function(_) {
9757    if (!arguments.length) return context;
9758    contextStream = _ == null ? (context = null, new PathString) : new PathContext(context = _);
9759    if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
9760    return path;
9761  };
9762
9763  path.pointRadius = function(_) {
9764    if (!arguments.length) return pointRadius;
9765    pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_);
9766    return path;
9767  };
9768
9769  return path.projection(projection).context(context);
9770}
9771
9772function transform(methods) {
9773  return {
9774    stream: transformer(methods)
9775  };
9776}
9777
9778function transformer(methods) {
9779  return function(stream) {
9780    var s = new TransformStream;
9781    for (var key in methods) s[key] = methods[key];
9782    s.stream = stream;
9783    return s;
9784  };
9785}
9786
9787function TransformStream() {}
9788
9789TransformStream.prototype = {
9790  constructor: TransformStream,
9791  point: function(x, y) { this.stream.point(x, y); },
9792  sphere: function() { this.stream.sphere(); },
9793  lineStart: function() { this.stream.lineStart(); },
9794  lineEnd: function() { this.stream.lineEnd(); },
9795  polygonStart: function() { this.stream.polygonStart(); },
9796  polygonEnd: function() { this.stream.polygonEnd(); }
9797};
9798
9799function fit(projection, fitBounds, object) {
9800  var clip = projection.clipExtent && projection.clipExtent();
9801  projection.scale(150).translate([0, 0]);
9802  if (clip != null) projection.clipExtent(null);
9803  geoStream(object, projection.stream(boundsStream$1));
9804  fitBounds(boundsStream$1.result());
9805  if (clip != null) projection.clipExtent(clip);
9806  return projection;
9807}
9808
9809function fitExtent(projection, extent, object) {
9810  return fit(projection, function(b) {
9811    var w = extent[1][0] - extent[0][0],
9812        h = extent[1][1] - extent[0][1],
9813        k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])),
9814        x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2,
9815        y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
9816    projection.scale(150 * k).translate([x, y]);
9817  }, object);
9818}
9819
9820function fitSize(projection, size, object) {
9821  return fitExtent(projection, [[0, 0], size], object);
9822}
9823
9824function fitWidth(projection, width, object) {
9825  return fit(projection, function(b) {
9826    var w = +width,
9827        k = w / (b[1][0] - b[0][0]),
9828        x = (w - k * (b[1][0] + b[0][0])) / 2,
9829        y = -k * b[0][1];
9830    projection.scale(150 * k).translate([x, y]);
9831  }, object);
9832}
9833
9834function fitHeight(projection, height, object) {
9835  return fit(projection, function(b) {
9836    var h = +height,
9837        k = h / (b[1][1] - b[0][1]),
9838        x = -k * b[0][0],
9839        y = (h - k * (b[1][1] + b[0][1])) / 2;
9840    projection.scale(150 * k).translate([x, y]);
9841  }, object);
9842}
9843
9844var maxDepth = 16, // maximum depth of subdivision
9845    cosMinDistance = cos$1(30 * radians); // cos(minimum angular distance)
9846
9847function resample(project, delta2) {
9848  return +delta2 ? resample$1(project, delta2) : resampleNone(project);
9849}
9850
9851function resampleNone(project) {
9852  return transformer({
9853    point: function(x, y) {
9854      x = project(x, y);
9855      this.stream.point(x[0], x[1]);
9856    }
9857  });
9858}
9859
9860function resample$1(project, delta2) {
9861
9862  function resampleLineTo(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream) {
9863    var dx = x1 - x0,
9864        dy = y1 - y0,
9865        d2 = dx * dx + dy * dy;
9866    if (d2 > 4 * delta2 && depth--) {
9867      var a = a0 + a1,
9868          b = b0 + b1,
9869          c = c0 + c1,
9870          m = sqrt(a * a + b * b + c * c),
9871          phi2 = asin(c /= m),
9872          lambda2 = abs(abs(c) - 1) < epsilon$2 || abs(lambda0 - lambda1) < epsilon$2 ? (lambda0 + lambda1) / 2 : atan2(b, a),
9873          p = project(lambda2, phi2),
9874          x2 = p[0],
9875          y2 = p[1],
9876          dx2 = x2 - x0,
9877          dy2 = y2 - y0,
9878          dz = dy * dx2 - dx * dy2;
9879      if (dz * dz / d2 > delta2 // perpendicular projected distance
9880          || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 // midpoint close to an end
9881          || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { // angular distance
9882        resampleLineTo(x0, y0, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth, stream);
9883        stream.point(x2, y2);
9884        resampleLineTo(x2, y2, lambda2, a, b, c, x1, y1, lambda1, a1, b1, c1, depth, stream);
9885      }
9886    }
9887  }
9888  return function(stream) {
9889    var lambda00, x00, y00, a00, b00, c00, // first point
9890        lambda0, x0, y0, a0, b0, c0; // previous point
9891
9892    var resampleStream = {
9893      point: point,
9894      lineStart: lineStart,
9895      lineEnd: lineEnd,
9896      polygonStart: function() { stream.polygonStart(); resampleStream.lineStart = ringStart; },
9897      polygonEnd: function() { stream.polygonEnd(); resampleStream.lineStart = lineStart; }
9898    };
9899
9900    function point(x, y) {
9901      x = project(x, y);
9902      stream.point(x[0], x[1]);
9903    }
9904
9905    function lineStart() {
9906      x0 = NaN;
9907      resampleStream.point = linePoint;
9908      stream.lineStart();
9909    }
9910
9911    function linePoint(lambda, phi) {
9912      var c = cartesian([lambda, phi]), p = project(lambda, phi);
9913      resampleLineTo(x0, y0, lambda0, a0, b0, c0, x0 = p[0], y0 = p[1], lambda0 = lambda, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);
9914      stream.point(x0, y0);
9915    }
9916
9917    function lineEnd() {
9918      resampleStream.point = point;
9919      stream.lineEnd();
9920    }
9921
9922    function ringStart() {
9923      lineStart();
9924      resampleStream.point = ringPoint;
9925      resampleStream.lineEnd = ringEnd;
9926    }
9927
9928    function ringPoint(lambda, phi) {
9929      linePoint(lambda00 = lambda, phi), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;
9930      resampleStream.point = linePoint;
9931    }
9932
9933    function ringEnd() {
9934      resampleLineTo(x0, y0, lambda0, a0, b0, c0, x00, y00, lambda00, a00, b00, c00, maxDepth, stream);
9935      resampleStream.lineEnd = lineEnd;
9936      lineEnd();
9937    }
9938
9939    return resampleStream;
9940  };
9941}
9942
9943var transformRadians = transformer({
9944  point: function(x, y) {
9945    this.stream.point(x * radians, y * radians);
9946  }
9947});
9948
9949function transformRotate(rotate) {
9950  return transformer({
9951    point: function(x, y) {
9952      var r = rotate(x, y);
9953      return this.stream.point(r[0], r[1]);
9954    }
9955  });
9956}
9957
9958function scaleTranslate(k, dx, dy, sx, sy) {
9959  function transform(x, y) {
9960    x *= sx; y *= sy;
9961    return [dx + k * x, dy - k * y];
9962  }
9963  transform.invert = function(x, y) {
9964    return [(x - dx) / k * sx, (dy - y) / k * sy];
9965  };
9966  return transform;
9967}
9968
9969function scaleTranslateRotate(k, dx, dy, sx, sy, alpha) {
9970  var cosAlpha = cos$1(alpha),
9971      sinAlpha = sin$1(alpha),
9972      a = cosAlpha * k,
9973      b = sinAlpha * k,
9974      ai = cosAlpha / k,
9975      bi = sinAlpha / k,
9976      ci = (sinAlpha * dy - cosAlpha * dx) / k,
9977      fi = (sinAlpha * dx + cosAlpha * dy) / k;
9978  function transform(x, y) {
9979    x *= sx; y *= sy;
9980    return [a * x - b * y + dx, dy - b * x - a * y];
9981  }
9982  transform.invert = function(x, y) {
9983    return [sx * (ai * x - bi * y + ci), sy * (fi - bi * x - ai * y)];
9984  };
9985  return transform;
9986}
9987
9988function projection(project) {
9989  return projectionMutator(function() { return project; })();
9990}
9991
9992function projectionMutator(projectAt) {
9993  var project,
9994      k = 150, // scale
9995      x = 480, y = 250, // translate
9996      lambda = 0, phi = 0, // center
9997      deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, // pre-rotate
9998      alpha = 0, // post-rotate angle
9999      sx = 1, // reflectX
10000      sy = 1, // reflectX
10001      theta = null, preclip = clipAntimeridian, // pre-clip angle
10002      x0 = null, y0, x1, y1, postclip = identity$4, // post-clip extent
10003      delta2 = 0.5, // precision
10004      projectResample,
10005      projectTransform,
10006      projectRotateTransform,
10007      cache,
10008      cacheStream;
10009
10010  function projection(point) {
10011    return projectRotateTransform(point[0] * radians, point[1] * radians);
10012  }
10013
10014  function invert(point) {
10015    point = projectRotateTransform.invert(point[0], point[1]);
10016    return point && [point[0] * degrees$1, point[1] * degrees$1];
10017  }
10018
10019  projection.stream = function(stream) {
10020    return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
10021  };
10022
10023  projection.preclip = function(_) {
10024    return arguments.length ? (preclip = _, theta = undefined, reset()) : preclip;
10025  };
10026
10027  projection.postclip = function(_) {
10028    return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip;
10029  };
10030
10031  projection.clipAngle = function(_) {
10032    return arguments.length ? (preclip = +_ ? clipCircle(theta = _ * radians) : (theta = null, clipAntimeridian), reset()) : theta * degrees$1;
10033  };
10034
10035  projection.clipExtent = function(_) {
10036    return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity$4) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
10037  };
10038
10039  projection.scale = function(_) {
10040    return arguments.length ? (k = +_, recenter()) : k;
10041  };
10042
10043  projection.translate = function(_) {
10044    return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y];
10045  };
10046
10047  projection.center = function(_) {
10048    return arguments.length ? (lambda = _[0] % 360 * radians, phi = _[1] % 360 * radians, recenter()) : [lambda * degrees$1, phi * degrees$1];
10049  };
10050
10051  projection.rotate = function(_) {
10052    return arguments.length ? (deltaLambda = _[0] % 360 * radians, deltaPhi = _[1] % 360 * radians, deltaGamma = _.length > 2 ? _[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees$1, deltaPhi * degrees$1, deltaGamma * degrees$1];
10053  };
10054
10055  projection.angle = function(_) {
10056    return arguments.length ? (alpha = _ % 360 * radians, recenter()) : alpha * degrees$1;
10057  };
10058
10059  projection.reflectX = function(_) {
10060    return arguments.length ? (sx = _ ? -1 : 1, recenter()) : sx < 0;
10061  };
10062
10063  projection.reflectY = function(_) {
10064    return arguments.length ? (sy = _ ? -1 : 1, recenter()) : sy < 0;
10065  };
10066
10067  projection.precision = function(_) {
10068    return arguments.length ? (projectResample = resample(projectTransform, delta2 = _ * _), reset()) : sqrt(delta2);
10069  };
10070
10071  projection.fitExtent = function(extent, object) {
10072    return fitExtent(projection, extent, object);
10073  };
10074
10075  projection.fitSize = function(size, object) {
10076    return fitSize(projection, size, object);
10077  };
10078
10079  projection.fitWidth = function(width, object) {
10080    return fitWidth(projection, width, object);
10081  };
10082
10083  projection.fitHeight = function(height, object) {
10084    return fitHeight(projection, height, object);
10085  };
10086
10087  function recenter() {
10088    var center = scaleTranslateRotate(k, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi)),
10089        transform = (alpha ? scaleTranslateRotate : scaleTranslate)(k, x - center[0], y - center[1], sx, sy, alpha);
10090    rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
10091    projectTransform = compose(project, transform);
10092    projectRotateTransform = compose(rotate, projectTransform);
10093    projectResample = resample(projectTransform, delta2);
10094    return reset();
10095  }
10096
10097  function reset() {
10098    cache = cacheStream = null;
10099    return projection;
10100  }
10101
10102  return function() {
10103    project = projectAt.apply(this, arguments);
10104    projection.invert = project.invert && invert;
10105    return recenter();
10106  };
10107}
10108
10109function conicProjection(projectAt) {
10110  var phi0 = 0,
10111      phi1 = pi$3 / 3,
10112      m = projectionMutator(projectAt),
10113      p = m(phi0, phi1);
10114
10115  p.parallels = function(_) {
10116    return arguments.length ? m(phi0 = _[0] * radi
vendor: 13,497 bytes, lines 10116-10588
10116ans, phi1 = _[1] * radians) : [phi0 * degrees$1, phi1 * degrees$1];
10117  };
10118
10119  return p;
10120}
10121
10122function cylindricalEqualAreaRaw(phi0) {
10123  var cosPhi0 = cos$1(phi0);
10124
10125  function forward(lambda, phi) {
10126    return [lambda * cosPhi0, sin$1(phi) / cosPhi0];
10127  }
10128
10129  forward.invert = function(x, y) {
10130    return [x / cosPhi0, asin(y * cosPhi0)];
10131  };
10132
10133  return forward;
10134}
10135
10136function conicEqualAreaRaw(y0, y1) {
10137  var sy0 = sin$1(y0), n = (sy0 + sin$1(y1)) / 2;
10138
10139  // Are the parallels symmetrical around the Equator?
10140  if (abs(n) < epsilon$2) return cylindricalEqualAreaRaw(y0);
10141
10142  var c = 1 + sy0 * (2 * n - sy0), r0 = sqrt(c) / n;
10143
10144  function project(x, y) {
10145    var r = sqrt(c - 2 * n * sin$1(y)) / n;
10146    return [r * sin$1(x *= n), r0 - r * cos$1(x)];
10147  }
10148
10149  project.invert = function(x, y) {
10150    var r0y = r0 - y,
10151        l = atan2(x, abs(r0y)) * sign(r0y);
10152    if (r0y * n < 0)
10153      l -= pi$3 * sign(x) * sign(r0y);
10154    return [l / n, asin((c - (x * x + r0y * r0y) * n * n) / (2 * n))];
10155  };
10156
10157  return project;
10158}
10159
10160function conicEqualArea() {
10161  return conicProjection(conicEqualAreaRaw)
10162      .scale(155.424)
10163      .center([0, 33.6442]);
10164}
10165
10166function albers() {
10167  return conicEqualArea()
10168      .parallels([29.5, 45.5])
10169      .scale(1070)
10170      .translate([480, 250])
10171      .rotate([96, 0])
10172      .center([-0.6, 38.7]);
10173}
10174
10175// The projections must have mutually exclusive clip regions on the sphere,
10176// as this will avoid emitting interleaving lines and polygons.
10177function multiplex(streams) {
10178  var n = streams.length;
10179  return {
10180    point: function(x, y) { var i = -1; while (++i < n) streams[i].point(x, y); },
10181    sphere: function() { var i = -1; while (++i < n) streams[i].sphere(); },
10182    lineStart: function() { var i = -1; while (++i < n) streams[i].lineStart(); },
10183    lineEnd: function() { var i = -1; while (++i < n) streams[i].lineEnd(); },
10184    polygonStart: function() { var i = -1; while (++i < n) streams[i].polygonStart(); },
10185    polygonEnd: function() { var i = -1; while (++i < n) streams[i].polygonEnd(); }
10186  };
10187}
10188
10189// A composite projection for the United States, configured by default for
10190// 960×500. The projection also works quite well at 960×600 if you change the
10191// scale to 1285 and adjust the translate accordingly. The set of standard
10192// parallels for each region comes from USGS, which is published here:
10193// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers
10194function albersUsa() {
10195  var cache,
10196      cacheStream,
10197      lower48 = albers(), lower48Point,
10198      alaska = conicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), alaskaPoint, // EPSG:3338
10199      hawaii = conicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), hawaiiPoint, // ESRI:102007
10200      point, pointStream = {point: function(x, y) { point = [x, y]; }};
10201
10202  function albersUsa(coordinates) {
10203    var x = coordinates[0], y = coordinates[1];
10204    return point = null,
10205        (lower48Point.point(x, y), point)
10206        || (alaskaPoint.point(x, y), point)
10207        || (hawaiiPoint.point(x, y), point);
10208  }
10209
10210  albersUsa.invert = function(coordinates) {
10211    var k = lower48.scale(),
10212        t = lower48.translate(),
10213        x = (coordinates[0] - t[0]) / k,
10214        y = (coordinates[1] - t[1]) / k;
10215    return (y >= 0.120 && y < 0.234 && x >= -0.425 && x < -0.214 ? alaska
10216        : y >= 0.166 && y < 0.234 && x >= -0.214 && x < -0.115 ? hawaii
10217        : lower48).invert(coordinates);
10218  };
10219
10220  albersUsa.stream = function(stream) {
10221    return cache && cacheStream === stream ? cache : cache = multiplex([lower48.stream(cacheStream = stream), alaska.stream(stream), hawaii.stream(stream)]);
10222  };
10223
10224  albersUsa.precision = function(_) {
10225    if (!arguments.length) return lower48.precision();
10226    lower48.precision(_), alaska.precision(_), hawaii.precision(_);
10227    return reset();
10228  };
10229
10230  albersUsa.scale = function(_) {
10231    if (!arguments.length) return lower48.scale();
10232    lower48.scale(_), alaska.scale(_ * 0.35), hawaii.scale(_);
10233    return albersUsa.translate(lower48.translate());
10234  };
10235
10236  albersUsa.translate = function(_) {
10237    if (!arguments.length) return lower48.translate();
10238    var k = lower48.scale(), x = +_[0], y = +_[1];
10239
10240    lower48Point = lower48
10241        .translate(_)
10242        .clipExtent([[x - 0.455 * k, y - 0.238 * k], [x + 0.455 * k, y + 0.238 * k]])
10243        .stream(pointStream);
10244
10245    alaskaPoint = alaska
10246        .translate([x - 0.307 * k, y + 0.201 * k])
10247        .clipExtent([[x - 0.425 * k + epsilon$2, y + 0.120 * k + epsilon$2], [x - 0.214 * k - epsilon$2, y + 0.234 * k - epsilon$2]])
10248        .stream(pointStream);
10249
10250    hawaiiPoint = hawaii
10251        .translate([x - 0.205 * k, y + 0.212 * k])
10252        .clipExtent([[x - 0.214 * k + epsilon$2, y + 0.166 * k + epsilon$2], [x - 0.115 * k - epsilon$2, y + 0.234 * k - epsilon$2]])
10253        .stream(pointStream);
10254
10255    return reset();
10256  };
10257
10258  albersUsa.fitExtent = function(extent, object) {
10259    return fitExtent(albersUsa, extent, object);
10260  };
10261
10262  albersUsa.fitSize = function(size, object) {
10263    return fitSize(albersUsa, size, object);
10264  };
10265
10266  albersUsa.fitWidth = function(width, object) {
10267    return fitWidth(albersUsa, width, object);
10268  };
10269
10270  albersUsa.fitHeight = function(height, object) {
10271    return fitHeight(albersUsa, height, object);
10272  };
10273
10274  function reset() {
10275    cache = cacheStream = null;
10276    return albersUsa;
10277  }
10278
10279  return albersUsa.scale(1070);
10280}
10281
10282function azimuthalRaw(scale) {
10283  return function(x, y) {
10284    var cx = cos$1(x),
10285        cy = cos$1(y),
10286        k = scale(cx * cy);
10287    return [
10288      k * cy * sin$1(x),
10289      k * sin$1(y)
10290    ];
10291  }
10292}
10293
10294function azimuthalInvert(angle) {
10295  return function(x, y) {
10296    var z = sqrt(x * x + y * y),
10297        c = angle(z),
10298        sc = sin$1(c),
10299        cc = cos$1(c);
10300    return [
10301      atan2(x * sc, z * cc),
10302      asin(z && y * sc / z)
10303    ];
10304  }
10305}
10306
10307var azimuthalEqualAreaRaw = azimuthalRaw(function(cxcy) {
10308  return sqrt(2 / (1 + cxcy));
10309});
10310
10311azimuthalEqualAreaRaw.invert = azimuthalInvert(function(z) {
10312  return 2 * asin(z / 2);
10313});
10314
10315function azimuthalEqualArea() {
10316  return projection(azimuthalEqualAreaRaw)
10317      .scale(124.75)
10318      .clipAngle(180 - 1e-3);
10319}
10320
10321var azimuthalEquidistantRaw = azimuthalRaw(function(c) {
10322  return (c = acos(c)) && c / sin$1(c);
10323});
10324
10325azimuthalEquidistantRaw.invert = azimuthalInvert(function(z) {
10326  return z;
10327});
10328
10329function azimuthalEquidistant() {
10330  return projection(azimuthalEquidistantRaw)
10331      .scale(79.4188)
10332      .clipAngle(180 - 1e-3);
10333}
10334
10335function mercatorRaw(lambda, phi) {
10336  return [lambda, log(tan((halfPi$2 + phi) / 2))];
10337}
10338
10339mercatorRaw.invert = function(x, y) {
10340  return [x, 2 * atan(exp(y)) - halfPi$2];
10341};
10342
10343function mercator() {
10344  return mercatorProjection(mercatorRaw)
10345      .scale(961 / tau$3);
10346}
10347
10348function mercatorProjection(project) {
10349  var m = projection(project),
10350      center = m.center,
10351      scale = m.scale,
10352      translate = m.translate,
10353      clipExtent = m.clipExtent,
10354      x0 = null, y0, x1, y1; // clip extent
10355
10356  m.scale = function(_) {
10357    return arguments.length ? (scale(_), reclip()) : scale();
10358  };
10359
10360  m.translate = function(_) {
10361    return arguments.length ? (translate(_), reclip()) : translate();
10362  };
10363
10364  m.center = function(_) {
10365    return arguments.length ? (center(_), reclip()) : center();
10366  };
10367
10368  m.clipExtent = function(_) {
10369    return arguments.length ? ((_ == null ? x0 = y0 = x1 = y1 = null : (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1])), reclip()) : x0 == null ? null : [[x0, y0], [x1, y1]];
10370  };
10371
10372  function reclip() {
10373    var k = pi$3 * scale(),
10374        t = m(rotation(m.rotate()).invert([0, 0]));
10375    return clipExtent(x0 == null
10376        ? [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]] : project === mercatorRaw
10377        ? [[Math.max(t[0] - k, x0), y0], [Math.min(t[0] + k, x1), y1]]
10378        : [[x0, Math.max(t[1] - k, y0)], [x1, Math.min(t[1] + k, y1)]]);
10379  }
10380
10381  return reclip();
10382}
10383
10384function tany(y) {
10385  return tan((halfPi$2 + y) / 2);
10386}
10387
10388function conicConformalRaw(y0, y1) {
10389  var cy0 = cos$1(y0),
10390      n = y0 === y1 ? sin$1(y0) : log(cy0 / cos$1(y1)) / log(tany(y1) / tany(y0)),
10391      f = cy0 * pow(tany(y0), n) / n;
10392
10393  if (!n) return mercatorRaw;
10394
10395  function project(x, y) {
10396    if (f > 0) { if (y < -halfPi$2 + epsilon$2) y = -halfPi$2 + epsilon$2; }
10397    else { if (y > halfPi$2 - epsilon$2) y = halfPi$2 - epsilon$2; }
10398    var r = f / pow(tany(y), n);
10399    return [r * sin$1(n * x), f - r * cos$1(n * x)];
10400  }
10401
10402  project.invert = function(x, y) {
10403    var fy = f - y, r = sign(n) * sqrt(x * x + fy * fy),
10404      l = atan2(x, abs(fy)) * sign(fy);
10405    if (fy * n < 0)
10406      l -= pi$3 * sign(x) * sign(fy);
10407    return [l / n, 2 * atan(pow(f / r, 1 / n)) - halfPi$2];
10408  };
10409
10410  return project;
10411}
10412
10413function conicConformal() {
10414  return conicProjection(conicConformalRaw)
10415      .scale(109.5)
10416      .parallels([30, 30]);
10417}
10418
10419function equirectangularRaw(lambda, phi) {
10420  return [lambda, phi];
10421}
10422
10423equirectangularRaw.invert = equirectangularRaw;
10424
10425function equirectangular() {
10426  return projection(equirectangularRaw)
10427      .scale(152.63);
10428}
10429
10430function conicEquidistantRaw(y0, y1) {
10431  var cy0 = cos$1(y0),
10432      n = y0 === y1 ? sin$1(y0) : (cy0 - cos$1(y1)) / (y1 - y0),
10433      g = cy0 / n + y0;
10434
10435  if (abs(n) < epsilon$2) return equirectangularRaw;
10436
10437  function project(x, y) {
10438    var gy = g - y, nx = n * x;
10439    return [gy * sin$1(nx), g - gy * cos$1(nx)];
10440  }
10441
10442  project.invert = function(x, y) {
10443    var gy = g - y,
10444        l = atan2(x, abs(gy)) * sign(gy);
10445    if (gy * n < 0)
10446      l -= pi$3 * sign(x) * sign(gy);
10447    return [l / n, g - sign(n) * sqrt(x * x + gy * gy)];
10448  };
10449
10450  return project;
10451}
10452
10453function conicEquidistant() {
10454  return conicProjection(conicEquidistantRaw)
10455      .scale(131.154)
10456      .center([0, 13.9389]);
10457}
10458
10459var A1 = 1.340264,
10460    A2 = -0.081106,
10461    A3 = 0.000893,
10462    A4 = 0.003796,
10463    M = sqrt(3) / 2,
10464    iterations = 12;
10465
10466function equalEarthRaw(lambda, phi) {
10467  var l = asin(M * sin$1(phi)), l2 = l * l, l6 = l2 * l2 * l2;
10468  return [
10469    lambda * cos$1(l) / (M * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2))),
10470    l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2))
10471  ];
10472}
10473
10474equalEarthRaw.invert = function(x, y) {
10475  var l = y, l2 = l * l, l6 = l2 * l2 * l2;
10476  for (var i = 0, delta, fy, fpy; i < iterations; ++i) {
10477    fy = l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2)) - y;
10478    fpy = A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2);
10479    l -= delta = fy / fpy, l2 = l * l, l6 = l2 * l2 * l2;
10480    if (abs(delta) < epsilon2$1) break;
10481  }
10482  return [
10483    M * x * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2)) / cos$1(l),
10484    asin(sin$1(l) / M)
10485  ];
10486};
10487
10488function equalEarth() {
10489  return projection(equalEarthRaw)
10490      .scale(177.158);
10491}
10492
10493function gnomonicRaw(x, y) {
10494  var cy = cos$1(y), k = cos$1(x) * cy;
10495  return [cy * sin$1(x) / k, sin$1(y) / k];
10496}
10497
10498gnomonicRaw.invert = azimuthalInvert(atan);
10499
10500function gnomonic() {
10501  return projection(gnomonicRaw)
10502      .scale(144.049)
10503      .clipAngle(60);
10504}
10505
10506function identity$5() {
10507  var k = 1, tx = 0, ty = 0, sx = 1, sy = 1, // scale, translate and reflect
10508      alpha = 0, ca, sa, // angle
10509      x0 = null, y0, x1, y1, // clip extent
10510      kx = 1, ky = 1,
10511      transform = transformer({
10512        point: function(x, y) {
10513          var p = projection([x, y]);
10514          this.stream.point(p[0], p[1]);
10515        }
10516      }),
10517      postclip = identity$4,
10518      cache,
10519      cacheStream;
10520
10521  function reset() {
10522    kx = k * sx;
10523    ky = k * sy;
10524    cache = cacheStream = null;
10525    return projection;
10526  }
10527
10528  function projection (p) {
10529    var x = p[0] * kx, y = p[1] * ky;
10530    if (alpha) {
10531      var t = y * ca - x * sa;
10532      x = x * ca + y * sa;
10533      y = t;
10534    }    
10535    return [x + tx, y + ty];
10536  }
10537  projection.invert = function(p) {
10538    var x = p[0] - tx, y = p[1] - ty;
10539    if (alpha) {
10540      var t = y * ca + x * sa;
10541      x = x * ca - y * sa;
10542      y = t;
10543    }
10544    return [x / kx, y / ky];
10545  };
10546  projection.stream = function(stream) {
10547    return cache && cacheStream === stream ? cache : cache = transform(postclip(cacheStream = stream));
10548  };
10549  projection.postclip = function(_) {
10550    return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip;
10551  };
10552  projection.clipExtent = function(_) {
10553    return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity$4) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
10554  };
10555  projection.scale = function(_) {
10556    return arguments.length ? (k = +_, reset()) : k;
10557  };
10558  projection.translate = function(_) {
10559    return arguments.length ? (tx = +_[0], ty = +_[1], reset()) : [tx, ty];
10560  };
10561  projection.angle = function(_) {
10562    return arguments.length ? (alpha = _ % 360 * radians, sa = sin$1(alpha), ca = cos$1(alpha), reset()) : alpha * degrees$1;
10563  };
10564  projection.reflectX = function(_) {
10565    return arguments.length ? (sx = _ ? -1 : 1, reset()) : sx < 0;
10566  };
10567  projection.reflectY = function(_) {
10568    return arguments.length ? (sy = _ ? -1 : 1, reset()) : sy < 0;
10569  };
10570  projection.fitExtent = function(extent, object) {
10571    return fitExtent(projection, extent, object);
10572  };
10573  projection.fitSize = function(size, object) {
10574    return fitSize(projection, size, object);
10575  };
10576  projection.fitWidth = function(width, object) {
10577    return fitWidth(projection, width, object);
10578  };
10579  projection.fitHeight = function(height, object) {
10580    return fitHeight(projection, height, object);
10581  };
10582
10583  return projection;
10584}
10585
10586function naturalEarth1Raw(lambda, phi) {
10587  var phi2 = phi * phi, phi4 = phi2 * phi2;
10588  return [
vendor: 28,292 bytes, lines 10589-11715
10589    lambda * (0.8707 - 0.131979 * phi2 + phi4 * (-0.013791 + phi4 * (0.003971 * phi2 - 0.001529 * phi4))),
10590    phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4)))
10591  ];
10592}
10593
10594naturalEarth1Raw.invert = function(x, y) {
10595  var phi = y, i = 25, delta;
10596  do {
10597    var phi2 = phi * phi, phi4 = phi2 * phi2;
10598    phi -= delta = (phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4))) - y) /
10599        (1.007226 + phi2 * (0.015085 * 3 + phi4 * (-0.044475 * 7 + 0.028874 * 9 * phi2 - 0.005916 * 11 * phi4)));
10600  } while (abs(delta) > epsilon$2 && --i > 0);
10601  return [
10602    x / (0.8707 + (phi2 = phi * phi) * (-0.131979 + phi2 * (-0.013791 + phi2 * phi2 * phi2 * (0.003971 - 0.001529 * phi2)))),
10603    phi
10604  ];
10605};
10606
10607function naturalEarth1() {
10608  return projection(naturalEarth1Raw)
10609      .scale(175.295);
10610}
10611
10612function orthographicRaw(x, y) {
10613  return [cos$1(y) * sin$1(x), sin$1(y)];
10614}
10615
10616orthographicRaw.invert = azimuthalInvert(asin);
10617
10618function orthographic() {
10619  return projection(orthographicRaw)
10620      .scale(249.5)
10621      .clipAngle(90 + epsilon$2);
10622}
10623
10624function stereographicRaw(x, y) {
10625  var cy = cos$1(y), k = 1 + cos$1(x) * cy;
10626  return [cy * sin$1(x) / k, sin$1(y) / k];
10627}
10628
10629stereographicRaw.invert = azimuthalInvert(function(z) {
10630  return 2 * atan(z);
10631});
10632
10633function stereographic() {
10634  return projection(stereographicRaw)
10635      .scale(250)
10636      .clipAngle(142);
10637}
10638
10639function transverseMercatorRaw(lambda, phi) {
10640  return [log(tan((halfPi$2 + phi) / 2)), -lambda];
10641}
10642
10643transverseMercatorRaw.invert = function(x, y) {
10644  return [-y, 2 * atan(exp(x)) - halfPi$2];
10645};
10646
10647function transverseMercator() {
10648  var m = mercatorProjection(transverseMercatorRaw),
10649      center = m.center,
10650      rotate = m.rotate;
10651
10652  m.center = function(_) {
10653    return arguments.length ? center([-_[1], _[0]]) : (_ = center(), [_[1], -_[0]]);
10654  };
10655
10656  m.rotate = function(_) {
10657    return arguments.length ? rotate([_[0], _[1], _.length > 2 ? _[2] + 90 : 90]) : (_ = rotate(), [_[0], _[1], _[2] - 90]);
10658  };
10659
10660  return rotate([0, 0, 90])
10661      .scale(159.155);
10662}
10663
10664function defaultSeparation(a, b) {
10665  return a.parent === b.parent ? 1 : 2;
10666}
10667
10668function meanX(children) {
10669  return children.reduce(meanXReduce, 0) / children.length;
10670}
10671
10672function meanXReduce(x, c) {
10673  return x + c.x;
10674}
10675
10676function maxY(children) {
10677  return 1 + children.reduce(maxYReduce, 0);
10678}
10679
10680function maxYReduce(y, c) {
10681  return Math.max(y, c.y);
10682}
10683
10684function leafLeft(node) {
10685  var children;
10686  while (children = node.children) node = children[0];
10687  return node;
10688}
10689
10690function leafRight(node) {
10691  var children;
10692  while (children = node.children) node = children[children.length - 1];
10693  return node;
10694}
10695
10696function cluster() {
10697  var separation = defaultSeparation,
10698      dx = 1,
10699      dy = 1,
10700      nodeSize = false;
10701
10702  function cluster(root) {
10703    var previousNode,
10704        x = 0;
10705
10706    // First walk, computing the initial x & y values.
10707    root.eachAfter(function(node) {
10708      var children = node.children;
10709      if (children) {
10710        node.x = meanX(children);
10711        node.y = maxY(children);
10712      } else {
10713        node.x = previousNode ? x += separation(node, previousNode) : 0;
10714        node.y = 0;
10715        previousNode = node;
10716      }
10717    });
10718
10719    var left = leafLeft(root),
10720        right = leafRight(root),
10721        x0 = left.x - separation(left, right) / 2,
10722        x1 = right.x + separation(right, left) / 2;
10723
10724    // Second walk, normalizing x & y to the desired size.
10725    return root.eachAfter(nodeSize ? function(node) {
10726      node.x = (node.x - root.x) * dx;
10727      node.y = (root.y - node.y) * dy;
10728    } : function(node) {
10729      node.x = (node.x - x0) / (x1 - x0) * dx;
10730      node.y = (1 - (root.y ? node.y / root.y : 1)) * dy;
10731    });
10732  }
10733
10734  cluster.separation = function(x) {
10735    return arguments.length ? (separation = x, cluster) : separation;
10736  };
10737
10738  cluster.size = function(x) {
10739    return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? null : [dx, dy]);
10740  };
10741
10742  cluster.nodeSize = function(x) {
10743    return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? [dx, dy] : null);
10744  };
10745
10746  return cluster;
10747}
10748
10749function count(node) {
10750  var sum = 0,
10751      children = node.children,
10752      i = children && children.length;
10753  if (!i) sum = 1;
10754  else while (--i >= 0) sum += children[i].value;
10755  node.value = sum;
10756}
10757
10758function node_count() {
10759  return this.eachAfter(count);
10760}
10761
10762function node_each(callback) {
10763  var node = this, current, next = [node], children, i, n;
10764  do {
10765    current = next.reverse(), next = [];
10766    while (node = current.pop()) {
10767      callback(node), children = node.children;
10768      if (children) for (i = 0, n = children.length; i < n; ++i) {
10769        next.push(children[i]);
10770      }
10771    }
10772  } while (next.length);
10773  return this;
10774}
10775
10776function node_eachBefore(callback) {
10777  var node = this, nodes = [node], children, i;
10778  while (node = nodes.pop()) {
10779    callback(node), children = node.children;
10780    if (children) for (i = children.length - 1; i >= 0; --i) {
10781      nodes.push(children[i]);
10782    }
10783  }
10784  return this;
10785}
10786
10787function node_eachAfter(callback) {
10788  var node = this, nodes = [node], next = [], children, i, n;
10789  while (node = nodes.pop()) {
10790    next.push(node), children = node.children;
10791    if (children) for (i = 0, n = children.length; i < n; ++i) {
10792      nodes.push(children[i]);
10793    }
10794  }
10795  while (node = next.pop()) {
10796    callback(node);
10797  }
10798  return this;
10799}
10800
10801function node_sum(value) {
10802  return this.eachAfter(function(node) {
10803    var sum = +value(node.data) || 0,
10804        children = node.children,
10805        i = children && children.length;
10806    while (--i >= 0) sum += children[i].value;
10807    node.value = sum;
10808  });
10809}
10810
10811function node_sort(compare) {
10812  return this.eachBefore(function(node) {
10813    if (node.children) {
10814      node.children.sort(compare);
10815    }
10816  });
10817}
10818
10819function node_path(end) {
10820  var start = this,
10821      ancestor = leastCommonAncestor(start, end),
10822      nodes = [start];
10823  while (start !== ancestor) {
10824    start = start.parent;
10825    nodes.push(start);
10826  }
10827  var k = nodes.length;
10828  while (end !== ancestor) {
10829    nodes.splice(k, 0, end);
10830    end = end.parent;
10831  }
10832  return nodes;
10833}
10834
10835function leastCommonAncestor(a, b) {
10836  if (a === b) return a;
10837  var aNodes = a.ancestors(),
10838      bNodes = b.ancestors(),
10839      c = null;
10840  a = aNodes.pop();
10841  b = bNodes.pop();
10842  while (a === b) {
10843    c = a;
10844    a = aNodes.pop();
10845    b = bNodes.pop();
10846  }
10847  return c;
10848}
10849
10850function node_ancestors() {
10851  var node = this, nodes = [node];
10852  while (node = node.parent) {
10853    nodes.push(node);
10854  }
10855  return nodes;
10856}
10857
10858function node_descendants() {
10859  var nodes = [];
10860  this.each(function(node) {
10861    nodes.push(node);
10862  });
10863  return nodes;
10864}
10865
10866function node_leaves() {
10867  var leaves = [];
10868  this.eachBefore(function(node) {
10869    if (!node.children) {
10870      leaves.push(node);
10871    }
10872  });
10873  return leaves;
10874}
10875
10876function node_links() {
10877  var root = this, links = [];
10878  root.each(function(node) {
10879    if (node !== root) { // Don’t include the root’s parent, if any.
10880      links.push({source: node.parent, target: node});
10881    }
10882  });
10883  return links;
10884}
10885
10886function hierarchy(data, children) {
10887  var root = new Node(data),
10888      valued = +data.value && (root.value = data.value),
10889      node,
10890      nodes = [root],
10891      child,
10892      childs,
10893      i,
10894      n;
10895
10896  if (children == null) children = defaultChildren;
10897
10898  while (node = nodes.pop()) {
10899    if (valued) node.value = +node.data.value;
10900    if ((childs = children(node.data)) && (n = childs.length)) {
10901      node.children = new Array(n);
10902      for (i = n - 1; i >= 0; --i) {
10903        nodes.push(child = node.children[i] = new Node(childs[i]));
10904        child.parent = node;
10905        child.depth = node.depth + 1;
10906      }
10907    }
10908  }
10909
10910  return root.eachBefore(computeHeight);
10911}
10912
10913function node_copy() {
10914  return hierarchy(this).eachBefore(copyData);
10915}
10916
10917function defaultChildren(d) {
10918  return d.children;
10919}
10920
10921function copyData(node) {
10922  node.data = node.data.data;
10923}
10924
10925function computeHeight(node) {
10926  var height = 0;
10927  do node.height = height;
10928  while ((node = node.parent) && (node.height < ++height));
10929}
10930
10931function Node(data) {
10932  this.data = data;
10933  this.depth =
10934  this.height = 0;
10935  this.parent = null;
10936}
10937
10938Node.prototype = hierarchy.prototype = {
10939  constructor: Node,
10940  count: node_count,
10941  each: node_each,
10942  eachAfter: node_eachAfter,
10943  eachBefore: node_eachBefore,
10944  sum: node_sum,
10945  sort: node_sort,
10946  path: node_path,
10947  ancestors: node_ancestors,
10948  descendants: node_descendants,
10949  leaves: node_leaves,
10950  links: node_links,
10951  copy: node_copy
10952};
10953
10954var slice$4 = Array.prototype.slice;
10955
10956function shuffle$1(array) {
10957  var m = array.length,
10958      t,
10959      i;
10960
10961  while (m) {
10962    i = Math.random() * m-- | 0;
10963    t = array[m];
10964    array[m] = array[i];
10965    array[i] = t;
10966  }
10967
10968  return array;
10969}
10970
10971function enclose(circles) {
10972  var i = 0, n = (circles = shuffle$1(slice$4.call(circles))).length, B = [], p, e;
10973
10974  while (i < n) {
10975    p = circles[i];
10976    if (e && enclosesWeak(e, p)) ++i;
10977    else e = encloseBasis(B = extendBasis(B, p)), i = 0;
10978  }
10979
10980  return e;
10981}
10982
10983function extendBasis(B, p) {
10984  var i, j;
10985
10986  if (enclosesWeakAll(p, B)) return [p];
10987
10988  // If we get here then B must have at least one element.
10989  for (i = 0; i < B.length; ++i) {
10990    if (enclosesNot(p, B[i])
10991        && enclosesWeakAll(encloseBasis2(B[i], p), B)) {
10992      return [B[i], p];
10993    }
10994  }
10995
10996  // If we get here then B must have at least two elements.
10997  for (i = 0; i < B.length - 1; ++i) {
10998    for (j = i + 1; j < B.length; ++j) {
10999      if (enclosesNot(encloseBasis2(B[i], B[j]), p)
11000          && enclosesNot(encloseBasis2(B[i], p), B[j])
11001          && enclosesNot(encloseBasis2(B[j], p), B[i])
11002          && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
11003        return [B[i], B[j], p];
11004      }
11005    }
11006  }
11007
11008  // If we get here then something is very wrong.
11009  throw new Error;
11010}
11011
11012function enclosesNot(a, b) {
11013  var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
11014  return dr < 0 || dr * dr < dx * dx + dy * dy;
11015}
11016
11017function enclosesWeak(a, b) {
11018  var dr = a.r - b.r + 1e-6, dx = b.x - a.x, dy = b.y - a.y;
11019  return dr > 0 && dr * dr > dx * dx + dy * dy;
11020}
11021
11022function enclosesWeakAll(a, B) {
11023  for (var i = 0; i < B.length; ++i) {
11024    if (!enclosesWeak(a, B[i])) {
11025      return false;
11026    }
11027  }
11028  return true;
11029}
11030
11031function encloseBasis(B) {
11032  switch (B.length) {
11033    case 1: return encloseBasis1(B[0]);
11034    case 2: return encloseBasis2(B[0], B[1]);
11035    case 3: return encloseBasis3(B[0], B[1], B[2]);
11036  }
11037}
11038
11039function encloseBasis1(a) {
11040  return {
11041    x: a.x,
11042    y: a.y,
11043    r: a.r
11044  };
11045}
11046
11047function encloseBasis2(a, b) {
11048  var x1 = a.x, y1 = a.y, r1 = a.r,
11049      x2 = b.x, y2 = b.y, r2 = b.r,
11050      x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1,
11051      l = Math.sqrt(x21 * x21 + y21 * y21);
11052  return {
11053    x: (x1 + x2 + x21 / l * r21) / 2,
11054    y: (y1 + y2 + y21 / l * r21) / 2,
11055    r: (l + r1 + r2) / 2
11056  };
11057}
11058
11059function encloseBasis3(a, b, c) {
11060  var x1 = a.x, y1 = a.y, r1 = a.r,
11061      x2 = b.x, y2 = b.y, r2 = b.r,
11062      x3 = c.x, y3 = c.y, r3 = c.r,
11063      a2 = x1 - x2,
11064      a3 = x1 - x3,
11065      b2 = y1 - y2,
11066      b3 = y1 - y3,
11067      c2 = r2 - r1,
11068      c3 = r3 - r1,
11069      d1 = x1 * x1 + y1 * y1 - r1 * r1,
11070      d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2,
11071      d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3,
11072      ab = a3 * b2 - a2 * b3,
11073      xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1,
11074      xb = (b3 * c2 - b2 * c3) / ab,
11075      ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1,
11076      yb = (a2 * c3 - a3 * c2) / ab,
11077      A = xb * xb + yb * yb - 1,
11078      B = 2 * (r1 + xa * xb + ya * yb),
11079      C = xa * xa + ya * ya - r1 * r1,
11080      r = -(A ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
11081  return {
11082    x: x1 + xa + xb * r,
11083    y: y1 + ya + yb * r,
11084    r: r
11085  };
11086}
11087
11088function place(b, a, c) {
11089  var dx = b.x - a.x, x, a2,
11090      dy = b.y - a.y, y, b2,
11091      d2 = dx * dx + dy * dy;
11092  if (d2) {
11093    a2 = a.r + c.r, a2 *= a2;
11094    b2 = b.r + c.r, b2 *= b2;
11095    if (a2 > b2) {
11096      x = (d2 + b2 - a2) / (2 * d2);
11097      y = Math.sqrt(Math.max(0, b2 / d2 - x * x));
11098      c.x = b.x - x * dx - y * dy;
11099      c.y = b.y - x * dy + y * dx;
11100    } else {
11101      x = (d2 + a2 - b2) / (2 * d2);
11102      y = Math.sqrt(Math.max(0, a2 / d2 - x * x));
11103      c.x = a.x + x * dx - y * dy;
11104      c.y = a.y + x * dy + y * dx;
11105    }
11106  } else {
11107    c.x = a.x + c.r;
11108    c.y = a.y;
11109  }
11110}
11111
11112function intersects(a, b) {
11113  var dr = a.r + b.r - 1e-6, dx = b.x - a.x, dy = b.y - a.y;
11114  return dr > 0 && dr * dr > dx * dx + dy * dy;
11115}
11116
11117function score(node) {
11118  var a = node._,
11119      b = node.next._,
11120      ab = a.r + b.r,
11121      dx = (a.x * b.r + b.x * a.r) / ab,
11122      dy = (a.y * b.r + b.y * a.r) / ab;
11123  return dx * dx + dy * dy;
11124}
11125
11126function Node$1(circle) {
11127  this._ = circle;
11128  this.next = null;
11129  this.previous = null;
11130}
11131
11132function packEnclose(circles) {
11133  if (!(n = circles.length)) return 0;
11134
11135  var a, b, c, n, aa, ca, i, j, k, sj, sk;
11136
11137  // Place the first circle.
11138  a = circles[0], a.x = 0, a.y = 0;
11139  if (!(n > 1)) return a.r;
11140
11141  // Place the second circle.
11142  b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0;
11143  if (!(n > 2)) return a.r + b.r;
11144
11145  // Place the third circle.
11146  place(b, a, c = circles[2]);
11147
11148  // Initialize the front-chain using the first three circles a, b and c.
11149  a = new Node$1(a), b = new Node$1(b), c = new Node$1(c);
11150  a.next = c.previous = b;
11151  b.next = a.previous = c;
11152  c.next = b.previous = a;
11153
11154  // Attempt to place each remaining circle…
11155  pack: for (i = 3; i < n; ++i) {
11156    place(a._, b._, c = circles[i]), c = new Node$1(c);
11157
11158    // Find the closest intersecting circle on the front-chain, if any.
11159    // “Closeness” is determined by linear distance along the front-chain.
11160    // “Ahead” or “behind” is likewise determined by linear distance.
11161    j = b.next, k = a.previous, sj = b._.r, sk = a._.r;
11162    do {
11163      if (sj <= sk) {
11164        if (intersects(j._, c._)) {
11165          b = j, a.next = b, b.previous = a, --i;
11166          continue pack;
11167        }
11168        sj += j._.r, j = j.next;
11169      } else {
11170        if (intersects(k._, c._)) {
11171          a = k, a.next = b, b.previous = a, --i;
11172          continue pack;
11173        }
11174        sk += k._.r, k = k.previous;
11175      }
11176    } while (j !== k.next);
11177
11178    // Success! Insert the new circle c between a and b.
11179    c.previous = a, c.next = b, a.next = b.previous = b = c;
11180
11181    // Compute the new closest circle pair to the centroid.
11182    aa = score(a);
11183    while ((c = c.next) !== b) {
11184      if ((ca = score(c)) < aa) {
11185        a = c, aa = ca;
11186      }
11187    }
11188    b = a.next;
11189  }
11190
11191  // Compute the enclosing circle of the front chain.
11192  a = [b._], c = b; while ((c = c.next) !== b) a.push(c._); c = enclose(a);
11193
11194  // Translate the circles to put the enclosing circle around the origin.
11195  for (i = 0; i < n; ++i) a = circles[i], a.x -= c.x, a.y -= c.y;
11196
11197  return c.r;
11198}
11199
11200function siblings(circles) {
11201  packEnclose(circles);
11202  return circles;
11203}
11204
11205function optional(f) {
11206  return f == null ? null : required(f);
11207}
11208
11209function required(f) {
11210  if (typeof f !== "function") throw new Error;
11211  return f;
11212}
11213
11214function constantZero() {
11215  return 0;
11216}
11217
11218function constant$9(x) {
11219  return function() {
11220    return x;
11221  };
11222}
11223
11224function defaultRadius$1(d) {
11225  return Math.sqrt(d.value);
11226}
11227
11228function index$2() {
11229  var radius = null,
11230      dx = 1,
11231      dy = 1,
11232      padding = constantZero;
11233
11234  function pack(root) {
11235    root.x = dx / 2, root.y = dy / 2;
11236    if (radius) {
11237      root.eachBefore(radiusLeaf(radius))
11238          .eachAfter(packChildren(padding, 0.5))
11239          .eachBefore(translateChild(1));
11240    } else {
11241      root.eachBefore(radiusLeaf(defaultRadius$1))
11242          .eachAfter(packChildren(constantZero, 1))
11243          .eachAfter(packChildren(padding, root.r / Math.min(dx, dy)))
11244          .eachBefore(translateChild(Math.min(dx, dy) / (2 * root.r)));
11245    }
11246    return root;
11247  }
11248
11249  pack.radius = function(x) {
11250    return arguments.length ? (radius = optional(x), pack) : radius;
11251  };
11252
11253  pack.size = function(x) {
11254    return arguments.length ? (dx = +x[0], dy = +x[1], pack) : [dx, dy];
11255  };
11256
11257  pack.padding = function(x) {
11258    return arguments.length ? (padding = typeof x === "function" ? x : constant$9(+x), pack) : padding;
11259  };
11260
11261  return pack;
11262}
11263
11264function radiusLeaf(radius) {
11265  return function(node) {
11266    if (!node.children) {
11267      node.r = Math.max(0, +radius(node) || 0);
11268    }
11269  };
11270}
11271
11272function packChildren(padding, k) {
11273  return function(node) {
11274    if (children = node.children) {
11275      var children,
11276          i,
11277          n = children.length,
11278          r = padding(node) * k || 0,
11279          e;
11280
11281      if (r) for (i = 0; i < n; ++i) children[i].r += r;
11282      e = packEnclose(children);
11283      if (r) for (i = 0; i < n; ++i) children[i].r -= r;
11284      node.r = e + r;
11285    }
11286  };
11287}
11288
11289function translateChild(k) {
11290  return function(node) {
11291    var parent = node.parent;
11292    node.r *= k;
11293    if (parent) {
11294      node.x = parent.x + k * node.x;
11295      node.y = parent.y + k * node.y;
11296    }
11297  };
11298}
11299
11300function roundNode(node) {
11301  node.x0 = Math.round(node.x0);
11302  node.y0 = Math.round(node.y0);
11303  node.x1 = Math.round(node.x1);
11304  node.y1 = Math.round(node.y1);
11305}
11306
11307function treemapDice(parent, x0, y0, x1, y1) {
11308  var nodes = parent.children,
11309      node,
11310      i = -1,
11311      n = nodes.length,
11312      k = parent.value && (x1 - x0) / parent.value;
11313
11314  while (++i < n) {
11315    node = nodes[i], node.y0 = y0, node.y1 = y1;
11316    node.x0 = x0, node.x1 = x0 += node.value * k;
11317  }
11318}
11319
11320function partition() {
11321  var dx = 1,
11322      dy = 1,
11323      padding = 0,
11324      round = false;
11325
11326  function partition(root) {
11327    var n = root.height + 1;
11328    root.x0 =
11329    root.y0 = padding;
11330    root.x1 = dx;
11331    root.y1 = dy / n;
11332    root.eachBefore(positionNode(dy, n));
11333    if (round) root.eachBefore(roundNode);
11334    return root;
11335  }
11336
11337  function positionNode(dy, n) {
11338    return function(node) {
11339      if (node.children) {
11340        treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n);
11341      }
11342      var x0 = node.x0,
11343          y0 = node.y0,
11344          x1 = node.x1 - padding,
11345          y1 = node.y1 - padding;
11346      if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
11347      if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
11348      node.x0 = x0;
11349      node.y0 = y0;
11350      node.x1 = x1;
11351      node.y1 = y1;
11352    };
11353  }
11354
11355  partition.round = function(x) {
11356    return arguments.length ? (round = !!x, partition) : round;
11357  };
11358
11359  partition.size = function(x) {
11360    return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy];
11361  };
11362
11363  partition.padding = function(x) {
11364    return arguments.length ? (padding = +x, partition) : padding;
11365  };
11366
11367  return partition;
11368}
11369
11370var keyPrefix$1 = "$", // Protect against keys like “__proto__”.
11371    preroot = {depth: -1},
11372    ambiguous = {};
11373
11374function defaultId(d) {
11375  return d.id;
11376}
11377
11378function defaultParentId(d) {
11379  return d.parentId;
11380}
11381
11382function stratify() {
11383  var id = defaultId,
11384      parentId = defaultParentId;
11385
11386  function stratify(data) {
11387    var d,
11388        i,
11389        n = data.length,
11390        root,
11391        parent,
11392        node,
11393        nodes = new Array(n),
11394        nodeId,
11395        nodeKey,
11396        nodeByKey = {};
11397
11398    for (i = 0; i < n; ++i) {
11399      d = data[i], node = nodes[i] = new Node(d);
11400      if ((nodeId = id(d, i, data)) != null && (nodeId += "")) {
11401        nodeKey = keyPrefix$1 + (node.id = nodeId);
11402        nodeByKey[nodeKey] = nodeKey in nodeByKey ? ambiguous : node;
11403      }
11404    }
11405
11406    for (i = 0; i < n; ++i) {
11407      node = nodes[i], nodeId = parentId(data[i], i, data);
11408      if (nodeId == null || !(nodeId += "")) {
11409        if (root) throw new Error("multiple roots");
11410        root = node;
11411      } else {
11412        parent = nodeByKey[keyPrefix$1 + nodeId];
11413        if (!parent) throw new Error("missing: " + nodeId);
11414        if (parent === ambiguous) throw new Error("ambiguous: " + nodeId);
11415        if (parent.children) parent.children.push(node);
11416        else parent.children = [node];
11417        node.parent = parent;
11418      }
11419    }
11420
11421    if (!root) throw new Error("no root");
11422    root.parent = preroot;
11423    root.eachBefore(function(node) { node.depth = node.parent.depth + 1; --n; }).eachBefore(computeHeight);
11424    root.parent = null;
11425    if (n > 0) throw new Error("cycle");
11426
11427    return root;
11428  }
11429
11430  stratify.id = function(x) {
11431    return arguments.length ? (id = required(x), stratify) : id;
11432  };
11433
11434  stratify.parentId = function(x) {
11435    return arguments.length ? (parentId = required(x), stratify) : parentId;
11436  };
11437
11438  return stratify;
11439}
11440
11441function defaultSeparation$1(a, b) {
11442  return a.parent === b.parent ? 1 : 2;
11443}
11444
11445// function radialSeparation(a, b) {
11446//   return (a.parent === b.parent ? 1 : 2) / a.depth;
11447// }
11448
11449// This function is used to traverse the left contour of a subtree (or
11450// subforest). It returns the successor of v on this contour. This successor is
11451// either given by the leftmost child of v or by the thread of v. The function
11452// returns null if and only if v is on the highest level of its subtree.
11453function nextLeft(v) {
11454  var children = v.children;
11455  return children ? children[0] : v.t;
11456}
11457
11458// This function works analogously to nextLeft.
11459function nextRight(v) {
11460  var children = v.children;
11461  return children ? children[children.length - 1] : v.t;
11462}
11463
11464// Shifts the current subtree rooted at w+. This is done by increasing
11465// prelim(w+) and mod(w+) by shift.
11466function moveSubtree(wm, wp, shift) {
11467  var change = shift / (wp.i - wm.i);
11468  wp.c -= change;
11469  wp.s += shift;
11470  wm.c += change;
11471  wp.z += shift;
11472  wp.m += shift;
11473}
11474
11475// All other shifts, applied to the smaller subtrees between w- and w+, are
11476// performed by this function. To prepare the shifts, we have to adjust
11477// change(w+), shift(w+), and change(w-).
11478function executeShifts(v) {
11479  var shift = 0,
11480      change = 0,
11481      children = v.children,
11482      i = children.length,
11483      w;
11484  while (--i >= 0) {
11485    w = children[i];
11486    w.z += shift;
11487    w.m += shift;
11488    shift += w.s + (change += w.c);
11489  }
11490}
11491
11492// If vi-’s ancestor is a sibling of v, returns vi-’s ancestor. Otherwise,
11493// returns the specified (default) ancestor.
11494function nextAncestor(vim, v, ancestor) {
11495  return vim.a.parent === v.parent ? vim.a : ancestor;
11496}
11497
11498function TreeNode(node, i) {
11499  this._ = node;
11500  this.parent = null;
11501  this.children = null;
11502  this.A = null; // default ancestor
11503  this.a = this; // ancestor
11504  this.z = 0; // prelim
11505  this.m = 0; // mod
11506  this.c = 0; // change
11507  this.s = 0; // shift
11508  this.t = null; // thread
11509  this.i = i; // number
11510}
11511
11512TreeNode.prototype = Object.create(Node.prototype);
11513
11514function treeRoot(root) {
11515  var tree = new TreeNode(root, 0),
11516      node,
11517      nodes = [tree],
11518      child,
11519      children,
11520      i,
11521      n;
11522
11523  while (node = nodes.pop()) {
11524    if (children = node._.children) {
11525      node.children = new Array(n = children.length);
11526      for (i = n - 1; i >= 0; --i) {
11527        nodes.push(child = node.children[i] = new TreeNode(children[i], i));
11528        child.parent = node;
11529      }
11530    }
11531  }
11532
11533  (tree.parent = new TreeNode(null, 0)).children = [tree];
11534  return tree;
11535}
11536
11537// Node-link tree diagram using the Reingold-Tilford "tidy" algorithm
11538function tree() {
11539  var separation = defaultSeparation$1,
11540      dx = 1,
11541      dy = 1,
11542      nodeSize = null;
11543
11544  function tree(root) {
11545    var t = treeRoot(root);
11546
11547    // Compute the layout using Buchheim et al.’s algorithm.
11548    t.eachAfter(firstWalk), t.parent.m = -t.z;
11549    t.eachBefore(secondWalk);
11550
11551    // If a fixed node size is specified, scale x and y.
11552    if (nodeSize) root.eachBefore(sizeNode);
11553
11554    // If a fixed tree size is specified, scale x and y based on the extent.
11555    // Compute the left-most, right-most, and depth-most nodes for extents.
11556    else {
11557      var left = root,
11558          right = root,
11559          bottom = root;
11560      root.eachBefore(function(node) {
11561        if (node.x < left.x) left = node;
11562        if (node.x > right.x) right = node;
11563        if (node.depth > bottom.depth) bottom = node;
11564      });
11565      var s = left === right ? 1 : separation(left, right) / 2,
11566          tx = s - left.x,
11567          kx = dx / (right.x + s + tx),
11568          ky = dy / (bottom.depth || 1);
11569      root.eachBefore(function(node) {
11570        node.x = (node.x + tx) * kx;
11571        node.y = node.depth * ky;
11572      });
11573    }
11574
11575    return root;
11576  }
11577
11578  // Computes a preliminary x-coordinate for v. Before that, FIRST WALK is
11579  // applied recursively to the children of v, as well as the function
11580  // APPORTION. After spacing out the children by calling EXECUTE SHIFTS, the
11581  // node v is placed to the midpoint of its outermost children.
11582  function firstWalk(v) {
11583    var children = v.children,
11584        siblings = v.parent.children,
11585        w = v.i ? siblings[v.i - 1] : null;
11586    if (children) {
11587      executeShifts(v);
11588      var midpoint = (children[0].z + children[children.length - 1].z) / 2;
11589      if (w) {
11590        v.z = w.z + separation(v._, w._);
11591        v.m = v.z - midpoint;
11592      } else {
11593        v.z = midpoint;
11594      }
11595    } else if (w) {
11596      v.z = w.z + separation(v._, w._);
11597    }
11598    v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
11599  }
11600
11601  // Computes all real x-coordinates by summing up the modifiers recursively.
11602  function secondWalk(v) {
11603    v._.x = v.z + v.parent.m;
11604    v.m += v.parent.m;
11605  }
11606
11607  // The core of the algorithm. Here, a new subtree is combined with the
11608  // previous subtrees. Threads are used to traverse the inside and outside
11609  // contours of the left and right subtree up to the highest common level. The
11610  // vertices used for the traversals are vi+, vi-, vo-, and vo+, where the
11611  // superscript o means outside and i means inside, the subscript - means left
11612  // subtree and + means right subtree. For summing up the modifiers along the
11613  // contour, we use respective variables si+, si-, so-, and so+. Whenever two
11614  // nodes of the inside contours conflict, we compute the left one of the
11615  // greatest uncommon ancestors using the function ANCESTOR and call MOVE
11616  // SUBTREE to shift the subtree and prepare the shifts of smaller subtrees.
11617  // Finally, we add a new thread (if necessary).
11618  function apportion(v, w, ancestor) {
11619    if (w) {
11620      var vip = v,
11621          vop = v,
11622          vim = w,
11623          vom = vip.parent.children[0],
11624          sip = vip.m,
11625          sop = vop.m,
11626          sim = vim.m,
11627          som = vom.m,
11628          shift;
11629      while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {
11630        vom = nextLeft(vom);
11631        vop = nextRight(vop);
11632        vop.a = v;
11633        shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
11634        if (shift > 0) {
11635          moveSubtree(nextAncestor(vim, v, ancestor), v, shift);
11636          sip += shift;
11637          sop += shift;
11638        }
11639        sim += vim.m;
11640        sip += vip.m;
11641        som += vom.m;
11642        sop += vop.m;
11643      }
11644      if (vim && !nextRight(vop)) {
11645        vop.t = vim;
11646        vop.m += sim - sop;
11647      }
11648      if (vip && !nextLeft(vom)) {
11649        vom.t = vip;
11650        vom.m += sip - som;
11651        ancestor = v;
11652      }
11653    }
11654    return ancestor;
11655  }
11656
11657  function sizeNode(node) {
11658    node.x *= dx;
11659    node.y = node.depth * dy;
11660  }
11661
11662  tree.separation = function(x) {
11663    return arguments.length ? (separation = x, tree) : separation;
11664  };
11665
11666  tree.size = function(x) {
11667    return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]);
11668  };
11669
11670  tree.nodeSize = function(x) {
11671    return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null);
11672  };
11673
11674  return tree;
11675}
11676
11677function treemapSlice(parent, x0, y0, x1, y1) {
11678  var nodes = parent.children,
11679      node,
11680      i = -1,
11681      n = nodes.length,
11682      k = parent.value && (y1 - y0) / parent.value;
11683
11684  while (++i < n) {
11685    node = nodes[i], node.x0 = x0, node.x1 = x1;
11686    node.y0 = y0, node.y1 = y0 += node.value * k;
11687  }
11688}
11689
11690var phi = (1 + Math.sqrt(5)) / 2;
11691
11692function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
11693  var rows = [],
11694      nodes = parent.children,
11695      row,
11696      nodeValue,
11697      i0 = 0,
11698      i1 = 0,
11699      n = nodes.length,
11700      dx, dy,
11701      value = parent.value,
11702      sumValue,
11703      minValue,
11704      maxValue,
11705      newRatio,
11706      minRatio,
11707      alpha,
11708      beta;
11709
11710  while (i0 < n) {
11711    dx = x1 - x0, dy = y1 - y0;
11712
11713    // Find the next non-empty node.
11714    do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);
11715    minValue = maxValue = sumValue;
vendor: 18,070 bytes, lines 11716-12408
11716    alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
11717    beta = sumValue * sumValue * alpha;
11718    minRatio = Math.max(maxValue / beta, beta / minValue);
11719
11720    // Keep adding nodes while the aspect ratio maintains or improves.
11721    for (; i1 < n; ++i1) {
11722      sumValue += nodeValue = nodes[i1].value;
11723      if (nodeValue < minValue) minValue = nodeValue;
11724      if (nodeValue > maxValue) maxValue = nodeValue;
11725      beta = sumValue * sumValue * alpha;
11726      newRatio = Math.max(maxValue / beta, beta / minValue);
11727      if (newRatio > minRatio) { sumValue -= nodeValue; break; }
11728      minRatio = newRatio;
11729    }
11730
11731    // Position and record the row orientation.
11732    rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
11733    if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
11734    else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
11735    value -= sumValue, i0 = i1;
11736  }
11737
11738  return rows;
11739}
11740
11741var squarify = (function custom(ratio) {
11742
11743  function squarify(parent, x0, y0, x1, y1) {
11744    squarifyRatio(ratio, parent, x0, y0, x1, y1);
11745  }
11746
11747  squarify.ratio = function(x) {
11748    return custom((x = +x) > 1 ? x : 1);
11749  };
11750
11751  return squarify;
11752})(phi);
11753
11754function index$3() {
11755  var tile = squarify,
11756      round = false,
11757      dx = 1,
11758      dy = 1,
11759      paddingStack = [0],
11760      paddingInner = constantZero,
11761      paddingTop = constantZero,
11762      paddingRight = constantZero,
11763      paddingBottom = constantZero,
11764      paddingLeft = constantZero;
11765
11766  function treemap(root) {
11767    root.x0 =
11768    root.y0 = 0;
11769    root.x1 = dx;
11770    root.y1 = dy;
11771    root.eachBefore(positionNode);
11772    paddingStack = [0];
11773    if (round) root.eachBefore(roundNode);
11774    return root;
11775  }
11776
11777  function positionNode(node) {
11778    var p = paddingStack[node.depth],
11779        x0 = node.x0 + p,
11780        y0 = node.y0 + p,
11781        x1 = node.x1 - p,
11782        y1 = node.y1 - p;
11783    if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
11784    if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
11785    node.x0 = x0;
11786    node.y0 = y0;
11787    node.x1 = x1;
11788    node.y1 = y1;
11789    if (node.children) {
11790      p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
11791      x0 += paddingLeft(node) - p;
11792      y0 += paddingTop(node) - p;
11793      x1 -= paddingRight(node) - p;
11794      y1 -= paddingBottom(node) - p;
11795      if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
11796      if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
11797      tile(node, x0, y0, x1, y1);
11798    }
11799  }
11800
11801  treemap.round = function(x) {
11802    return arguments.length ? (round = !!x, treemap) : round;
11803  };
11804
11805  treemap.size = function(x) {
11806    return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
11807  };
11808
11809  treemap.tile = function(x) {
11810    return arguments.length ? (tile = required(x), treemap) : tile;
11811  };
11812
11813  treemap.padding = function(x) {
11814    return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
11815  };
11816
11817  treemap.paddingInner = function(x) {
11818    return arguments.length ? (paddingInner = typeof x === "function" ? x : constant$9(+x), treemap) : paddingInner;
11819  };
11820
11821  treemap.paddingOuter = function(x) {
11822    return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
11823  };
11824
11825  treemap.paddingTop = function(x) {
11826    return arguments.length ? (paddingTop = typeof x === "function" ? x : constant$9(+x), treemap) : paddingTop;
11827  };
11828
11829  treemap.paddingRight = function(x) {
11830    return arguments.length ? (paddingRight = typeof x === "function" ? x : constant$9(+x), treemap) : paddingRight;
11831  };
11832
11833  treemap.paddingBottom = function(x) {
11834    return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant$9(+x), treemap) : paddingBottom;
11835  };
11836
11837  treemap.paddingLeft = function(x) {
11838    return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant$9(+x), treemap) : paddingLeft;
11839  };
11840
11841  return treemap;
11842}
11843
11844function binary(parent, x0, y0, x1, y1) {
11845  var nodes = parent.children,
11846      i, n = nodes.length,
11847      sum, sums = new Array(n + 1);
11848
11849  for (sums[0] = sum = i = 0; i < n; ++i) {
11850    sums[i + 1] = sum += nodes[i].value;
11851  }
11852
11853  partition(0, n, parent.value, x0, y0, x1, y1);
11854
11855  function partition(i, j, value, x0, y0, x1, y1) {
11856    if (i >= j - 1) {
11857      var node = nodes[i];
11858      node.x0 = x0, node.y0 = y0;
11859      node.x1 = x1, node.y1 = y1;
11860      return;
11861    }
11862
11863    var valueOffset = sums[i],
11864        valueTarget = (value / 2) + valueOffset,
11865        k = i + 1,
11866        hi = j - 1;
11867
11868    while (k < hi) {
11869      var mid = k + hi >>> 1;
11870      if (sums[mid] < valueTarget) k = mid + 1;
11871      else hi = mid;
11872    }
11873
11874    if ((valueTarget - sums[k - 1]) < (sums[k] - valueTarget) && i + 1 < k) --k;
11875
11876    var valueLeft = sums[k] - valueOffset,
11877        valueRight = value - valueLeft;
11878
11879    if ((x1 - x0) > (y1 - y0)) {
11880      var xk = (x0 * valueRight + x1 * valueLeft) / value;
11881      partition(i, k, valueLeft, x0, y0, xk, y1);
11882      partition(k, j, valueRight, xk, y0, x1, y1);
11883    } else {
11884      var yk = (y0 * valueRight + y1 * valueLeft) / value;
11885      partition(i, k, valueLeft, x0, y0, x1, yk);
11886      partition(k, j, valueRight, x0, yk, x1, y1);
11887    }
11888  }
11889}
11890
11891function sliceDice(parent, x0, y0, x1, y1) {
11892  (parent.depth & 1 ? treemapSlice : treemapDice)(parent, x0, y0, x1, y1);
11893}
11894
11895var resquarify = (function custom(ratio) {
11896
11897  function resquarify(parent, x0, y0, x1, y1) {
11898    if ((rows = parent._squarify) && (rows.ratio === ratio)) {
11899      var rows,
11900          row,
11901          nodes,
11902          i,
11903          j = -1,
11904          n,
11905          m = rows.length,
11906          value = parent.value;
11907
11908      while (++j < m) {
11909        row = rows[j], nodes = row.children;
11910        for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
11911        if (row.dice) treemapDice(row, x0, y0, x1, y0 += (y1 - y0) * row.value / value);
11912        else treemapSlice(row, x0, y0, x0 += (x1 - x0) * row.value / value, y1);
11913        value -= row.value;
11914      }
11915    } else {
11916      parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
11917      rows.ratio = ratio;
11918    }
11919  }
11920
11921  resquarify.ratio = function(x) {
11922    return custom((x = +x) > 1 ? x : 1);
11923  };
11924
11925  return resquarify;
11926})(phi);
11927
11928function area$2(polygon) {
11929  var i = -1,
11930      n = polygon.length,
11931      a,
11932      b = polygon[n - 1],
11933      area = 0;
11934
11935  while (++i < n) {
11936    a = b;
11937    b = polygon[i];
11938    area += a[1] * b[0] - a[0] * b[1];
11939  }
11940
11941  return area / 2;
11942}
11943
11944function centroid$1(polygon) {
11945  var i = -1,
11946      n = polygon.length,
11947      x = 0,
11948      y = 0,
11949      a,
11950      b = polygon[n - 1],
11951      c,
11952      k = 0;
11953
11954  while (++i < n) {
11955    a = b;
11956    b = polygon[i];
11957    k += c = a[0] * b[1] - b[0] * a[1];
11958    x += (a[0] + b[0]) * c;
11959    y += (a[1] + b[1]) * c;
11960  }
11961
11962  return k *= 3, [x / k, y / k];
11963}
11964
11965// Returns the 2D cross product of AB and AC vectors, i.e., the z-component of
11966// the 3D cross product in a quadrant I Cartesian coordinate system (+x is
11967// right, +y is up). Returns a positive value if ABC is counter-clockwise,
11968// negative if clockwise, and zero if the points are collinear.
11969function cross$1(a, b, c) {
11970  return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
11971}
11972
11973function lexicographicOrder(a, b) {
11974  return a[0] - b[0] || a[1] - b[1];
11975}
11976
11977// Computes the upper convex hull per the monotone chain algorithm.
11978// Assumes points.length >= 3, is sorted by x, unique in y.
11979// Returns an array of indices into points in left-to-right order.
11980function computeUpperHullIndexes(points) {
11981  var n = points.length,
11982      indexes = [0, 1],
11983      size = 2;
11984
11985  for (var i = 2; i < n; ++i) {
11986    while (size > 1 && cross$1(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size;
11987    indexes[size++] = i;
11988  }
11989
11990  return indexes.slice(0, size); // remove popped points
11991}
11992
11993function hull(points) {
11994  if ((n = points.length) < 3) return null;
11995
11996  var i,
11997      n,
11998      sortedPoints = new Array(n),
11999      flippedPoints = new Array(n);
12000
12001  for (i = 0; i < n; ++i) sortedPoints[i] = [+points[i][0], +points[i][1], i];
12002  sortedPoints.sort(lexicographicOrder);
12003  for (i = 0; i < n; ++i) flippedPoints[i] = [sortedPoints[i][0], -sortedPoints[i][1]];
12004
12005  var upperIndexes = computeUpperHullIndexes(sortedPoints),
12006      lowerIndexes = computeUpperHullIndexes(flippedPoints);
12007
12008  // Construct the hull polygon, removing possible duplicate endpoints.
12009  var skipLeft = lowerIndexes[0] === upperIndexes[0],
12010      skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1],
12011      hull = [];
12012
12013  // Add upper hull in right-to-l order.
12014  // Then add lower hull in left-to-right order.
12015  for (i = upperIndexes.length - 1; i >= 0; --i) hull.push(points[sortedPoints[upperIndexes[i]][2]]);
12016  for (i = +skipLeft; i < lowerIndexes.length - skipRight; ++i) hull.push(points[sortedPoints[lowerIndexes[i]][2]]);
12017
12018  return hull;
12019}
12020
12021function contains$2(polygon, point) {
12022  var n = polygon.length,
12023      p = polygon[n - 1],
12024      x = point[0], y = point[1],
12025      x0 = p[0], y0 = p[1],
12026      x1, y1,
12027      inside = false;
12028
12029  for (var i = 0; i < n; ++i) {
12030    p = polygon[i], x1 = p[0], y1 = p[1];
12031    if (((y1 > y) !== (y0 > y)) && (x < (x0 - x1) * (y - y1) / (y0 - y1) + x1)) inside = !inside;
12032    x0 = x1, y0 = y1;
12033  }
12034
12035  return inside;
12036}
12037
12038function length$2(polygon) {
12039  var i = -1,
12040      n = polygon.length,
12041      b = polygon[n - 1],
12042      xa,
12043      ya,
12044      xb = b[0],
12045      yb = b[1],
12046      perimeter = 0;
12047
12048  while (++i < n) {
12049    xa = xb;
12050    ya = yb;
12051    b = polygon[i];
12052    xb = b[0];
12053    yb = b[1];
12054    xa -= xb;
12055    ya -= yb;
12056    perimeter += Math.sqrt(xa * xa + ya * ya);
12057  }
12058
12059  return perimeter;
12060}
12061
12062function defaultSource$1() {
12063  return Math.random();
12064}
12065
12066var uniform = (function sourceRandomUniform(source) {
12067  function randomUniform(min, max) {
12068    min = min == null ? 0 : +min;
12069    max = max == null ? 1 : +max;
12070    if (arguments.length === 1) max = min, min = 0;
12071    else max -= min;
12072    return function() {
12073      return source() * max + min;
12074    };
12075  }
12076
12077  randomUniform.source = sourceRandomUniform;
12078
12079  return randomUniform;
12080})(defaultSource$1);
12081
12082var normal = (function sourceRandomNormal(source) {
12083  function randomNormal(mu, sigma) {
12084    var x, r;
12085    mu = mu == null ? 0 : +mu;
12086    sigma = sigma == null ? 1 : +sigma;
12087    return function() {
12088      var y;
12089
12090      // If available, use the second previously-generated uniform random.
12091      if (x != null) y = x, x = null;
12092
12093      // Otherwise, generate a new x and y.
12094      else do {
12095        x = source() * 2 - 1;
12096        y = source() * 2 - 1;
12097        r = x * x + y * y;
12098      } while (!r || r > 1);
12099
12100      return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r);
12101    };
12102  }
12103
12104  randomNormal.source = sourceRandomNormal;
12105
12106  return randomNormal;
12107})(defaultSource$1);
12108
12109var logNormal = (function sourceRandomLogNormal(source) {
12110  function randomLogNormal() {
12111    var randomNormal = normal.source(source).apply(this, arguments);
12112    return function() {
12113      return Math.exp(randomNormal());
12114    };
12115  }
12116
12117  randomLogNormal.source = sourceRandomLogNormal;
12118
12119  return randomLogNormal;
12120})(defaultSource$1);
12121
12122var irwinHall = (function sourceRandomIrwinHall(source) {
12123  function randomIrwinHall(n) {
12124    return function() {
12125      for (var sum = 0, i = 0; i < n; ++i) sum += source();
12126      return sum;
12127    };
12128  }
12129
12130  randomIrwinHall.source = sourceRandomIrwinHall;
12131
12132  return randomIrwinHall;
12133})(defaultSource$1);
12134
12135var bates = (function sourceRandomBates(source) {
12136  function randomBates(n) {
12137    var randomIrwinHall = irwinHall.source(source)(n);
12138    return function() {
12139      return randomIrwinHall() / n;
12140    };
12141  }
12142
12143  randomBates.source = sourceRandomBates;
12144
12145  return randomBates;
12146})(defaultSource$1);
12147
12148var exponential$1 = (function sourceRandomExponential(source) {
12149  function randomExponential(lambda) {
12150    return function() {
12151      return -Math.log(1 - source()) / lambda;
12152    };
12153  }
12154
12155  randomExponential.source = sourceRandomExponential;
12156
12157  return randomExponential;
12158})(defaultSource$1);
12159
12160function initRange(domain, range) {
12161  switch (arguments.length) {
12162    case 0: break;
12163    case 1: this.range(domain); break;
12164    default: this.range(range).domain(domain); break;
12165  }
12166  return this;
12167}
12168
12169function initInterpolator(domain, interpolator) {
12170  switch (arguments.length) {
12171    case 0: break;
12172    case 1: this.interpolator(domain); break;
12173    default: this.interpolator(interpolator).domain(domain); break;
12174  }
12175  return this;
12176}
12177
12178var array$3 = Array.prototype;
12179
12180var map$3 = array$3.map;
12181var slice$5 = array$3.slice;
12182
12183var implicit = {name: "implicit"};
12184
12185function ordinal() {
12186  var index = map$1(),
12187      domain = [],
12188      range = [],
12189      unknown = implicit;
12190
12191  function scale(d) {
12192    var key = d + "", i = index.get(key);
12193    if (!i) {
12194      if (unknown !== implicit) return unknown;
12195      index.set(key, i = domain.push(d));
12196    }
12197    return range[(i - 1) % range.length];
12198  }
12199
12200  scale.domain = function(_) {
12201    if (!arguments.length) return domain.slice();
12202    domain = [], index = map$1();
12203    var i = -1, n = _.length, d, key;
12204    while (++i < n) if (!index.has(key = (d = _[i]) + "")) index.set(key, domain.push(d));
12205    return scale;
12206  };
12207
12208  scale.range = function(_) {
12209    return arguments.length ? (range = slice$5.call(_), scale) : range.slice();
12210  };
12211
12212  scale.unknown = function(_) {
12213    return arguments.length ? (unknown = _, scale) : unknown;
12214  };
12215
12216  scale.copy = function() {
12217    return ordinal(domain, range).unknown(unknown);
12218  };
12219
12220  initRange.apply(scale, arguments);
12221
12222  return scale;
12223}
12224
12225function band() {
12226  var scale = ordinal().unknown(undefined),
12227      domain = scale.domain,
12228      ordinalRange = scale.range,
12229      range = [0, 1],
12230      step,
12231      bandwidth,
12232      round = false,
12233      paddingInner = 0,
12234      paddingOuter = 0,
12235      align = 0.5;
12236
12237  delete scale.unknown;
12238
12239  function rescale() {
12240    var n = domain().length,
12241        reverse = range[1] < range[0],
12242        start = range[reverse - 0],
12243        stop = range[1 - reverse];
12244    step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
12245    if (round) step = Math.floor(step);
12246    start += (stop - start - step * (n - paddingInner)) * align;
12247    bandwidth = step * (1 - paddingInner);
12248    if (round) start = Math.round(start), bandwidth = Math.round(bandwidth);
12249    var values = sequence(n).map(function(i) { return start + step * i; });
12250    return ordinalRange(reverse ? values.reverse() : values);
12251  }
12252
12253  scale.domain = function(_) {
12254    return arguments.length ? (domain(_), rescale()) : domain();
12255  };
12256
12257  scale.range = function(_) {
12258    return arguments.length ? (range = [+_[0], +_[1]], rescale()) : range.slice();
12259  };
12260
12261  scale.rangeRound = function(_) {
12262    return range = [+_[0], +_[1]], round = true, rescale();
12263  };
12264
12265  scale.bandwidth = function() {
12266    return bandwidth;
12267  };
12268
12269  scale.step = function() {
12270    return step;
12271  };
12272
12273  scale.round = function(_) {
12274    return arguments.length ? (round = !!_, rescale()) : round;
12275  };
12276
12277  scale.padding = function(_) {
12278    return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner;
12279  };
12280
12281  scale.paddingInner = function(_) {
12282    return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner;
12283  };
12284
12285  scale.paddingOuter = function(_) {
12286    return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter;
12287  };
12288
12289  scale.align = function(_) {
12290    return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
12291  };
12292
12293  scale.copy = function() {
12294    return band(domain(), range)
12295        .round(round)
12296        .paddingInner(paddingInner)
12297        .paddingOuter(paddingOuter)
12298        .align(align);
12299  };
12300
12301  return initRange.apply(rescale(), arguments);
12302}
12303
12304function pointish(scale) {
12305  var copy = scale.copy;
12306
12307  scale.padding = scale.paddingOuter;
12308  delete scale.paddingInner;
12309  delete scale.paddingOuter;
12310
12311  scale.copy = function() {
12312    return pointish(copy());
12313  };
12314
12315  return scale;
12316}
12317
12318function point$1() {
12319  return pointish(band.apply(null, arguments).paddingInner(1));
12320}
12321
12322function constant$a(x) {
12323  return function() {
12324    return x;
12325  };
12326}
12327
12328function number$2(x) {
12329  return +x;
12330}
12331
12332var unit = [0, 1];
12333
12334function identity$6(x) {
12335  return x;
12336}
12337
12338function normalize(a, b) {
12339  return (b -= (a = +a))
12340      ? function(x) { return (x - a) / b; }
12341      : constant$a(isNaN(b) ? NaN : 0.5);
12342}
12343
12344function clamper(domain) {
12345  var a = domain[0], b = domain[domain.length - 1], t;
12346  if (a > b) t = a, a = b, b = t;
12347  return function(x) { return Math.max(a, Math.min(b, x)); };
12348}
12349
12350// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
12351// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].
12352function bimap(domain, range, interpolate) {
12353  var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
12354  if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
12355  else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
12356  return function(x) { return r0(d0(x)); };
12357}
12358
12359function polymap(domain, range, interpolate) {
12360  var j = Math.min(domain.length, range.length) - 1,
12361      d = new Array(j),
12362      r = new Array(j),
12363      i = -1;
12364
12365  // Reverse descending domains.
12366  if (domain[j] < domain[0]) {
12367    domain = domain.slice().reverse();
12368    range = range.slice().reverse();
12369  }
12370
12371  while (++i < j) {
12372    d[i] = normalize(domain[i], domain[i + 1]);
12373    r[i] = interpolate(range[i], range[i + 1]);
12374  }
12375
12376  return function(x) {
12377    var i = bisectRight(domain, x, 1, j) - 1;
12378    return r[i](d[i](x));
12379  };
12380}
12381
12382function copy(source, target) {
12383  return target
12384      .domain(source.domain())
12385      .range(source.range())
12386      .interpolate(source.interpolate())
12387      .clamp(source.clamp())
12388      .unknown(source.unknown());
12389}
12390
12391function transformer$1() {
12392  var domain = unit,
12393      range = unit,
12394      interpolate = interpolateValue,
12395      transform,
12396      untransform,
12397      unknown,
12398      clamp = identity$6,
12399      piecewise,
12400      output,
12401      input;
12402
12403  function rescale() {
12404    piecewise = Math.min(domain.length, range.length) > 2 ? polymap : bimap;
12405    output = input = null;
12406    return scale;
12407  }
12408
vendor: 9,954 bytes, lines 12409-12822
12409  function scale(x) {
12410    return isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate)))(transform(clamp(x)));
12411  }
12412
12413  scale.invert = function(y) {
12414    return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y)));
12415  };
12416
12417  scale.domain = function(_) {
12418    return arguments.length ? (domain = map$3.call(_, number$2), clamp === identity$6 || (clamp = clamper(domain)), rescale()) : domain.slice();
12419  };
12420
12421  scale.range = function(_) {
12422    return arguments.length ? (range = slice$5.call(_), rescale()) : range.slice();
12423  };
12424
12425  scale.rangeRound = function(_) {
12426    return range = slice$5.call(_), interpolate = interpolateRound, rescale();
12427  };
12428
12429  scale.clamp = function(_) {
12430    return arguments.length ? (clamp = _ ? clamper(domain) : identity$6, scale) : clamp !== identity$6;
12431  };
12432
12433  scale.interpolate = function(_) {
12434    return arguments.length ? (interpolate = _, rescale()) : interpolate;
12435  };
12436
12437  scale.unknown = function(_) {
12438    return arguments.length ? (unknown = _, scale) : unknown;
12439  };
12440
12441  return function(t, u) {
12442    transform = t, untransform = u;
12443    return rescale();
12444  };
12445}
12446
12447function continuous(transform, untransform) {
12448  return transformer$1()(transform, untransform);
12449}
12450
12451function tickFormat(start, stop, count, specifier) {
12452  var step = tickStep(start, stop, count),
12453      precision;
12454  specifier = formatSpecifier(specifier == null ? ",f" : specifier);
12455  switch (specifier.type) {
12456    case "s": {
12457      var value = Math.max(Math.abs(start), Math.abs(stop));
12458      if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
12459      return exports.formatPrefix(specifier, value);
12460    }
12461    case "":
12462    case "e":
12463    case "g":
12464    case "p":
12465    case "r": {
12466      if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
12467      break;
12468    }
12469    case "f":
12470    case "%": {
12471      if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
12472      break;
12473    }
12474  }
12475  return exports.format(specifier);
12476}
12477
12478function linearish(scale) {
12479  var domain = scale.domain;
12480
12481  scale.ticks = function(count) {
12482    var d = domain();
12483    return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
12484  };
12485
12486  scale.tickFormat = function(count, specifier) {
12487    var d = domain();
12488    return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier);
12489  };
12490
12491  scale.nice = function(count) {
12492    if (count == null) count = 10;
12493
12494    var d = domain(),
12495        i0 = 0,
12496        i1 = d.length - 1,
12497        start = d[i0],
12498        stop = d[i1],
12499        step;
12500
12501    if (stop < start) {
12502      step = start, start = stop, stop = step;
12503      step = i0, i0 = i1, i1 = step;
12504    }
12505
12506    step = tickIncrement(start, stop, count);
12507
12508    if (step > 0) {
12509      start = Math.floor(start / step) * step;
12510      stop = Math.ceil(stop / step) * step;
12511      step = tickIncrement(start, stop, count);
12512    } else if (step < 0) {
12513      start = Math.ceil(start * step) / step;
12514      stop = Math.floor(stop * step) / step;
12515      step = tickIncrement(start, stop, count);
12516    }
12517
12518    if (step > 0) {
12519      d[i0] = Math.floor(start / step) * step;
12520      d[i1] = Math.ceil(stop / step) * step;
12521      domain(d);
12522    } else if (step < 0) {
12523      d[i0] = Math.ceil(start * step) / step;
12524      d[i1] = Math.floor(stop * step) / step;
12525      domain(d);
12526    }
12527
12528    return scale;
12529  };
12530
12531  return scale;
12532}
12533
12534function linear$2() {
12535  var scale = continuous(identity$6, identity$6);
12536
12537  scale.copy = function() {
12538    return copy(scale, linear$2());
12539  };
12540
12541  initRange.apply(scale, arguments);
12542
12543  return linearish(scale);
12544}
12545
12546function identity$7(domain) {
12547  var unknown;
12548
12549  function scale(x) {
12550    return isNaN(x = +x) ? unknown : x;
12551  }
12552
12553  scale.invert = scale;
12554
12555  scale.domain = scale.range = function(_) {
12556    return arguments.length ? (domain = map$3.call(_, number$2), scale) : domain.slice();
12557  };
12558
12559  scale.unknown = function(_) {
12560    return arguments.length ? (unknown = _, scale) : unknown;
12561  };
12562
12563  scale.copy = function() {
12564    return identity$7(domain).unknown(unknown);
12565  };
12566
12567  domain = arguments.length ? map$3.call(domain, number$2) : [0, 1];
12568
12569  return linearish(scale);
12570}
12571
12572function nice(domain, interval) {
12573  domain = domain.slice();
12574
12575  var i0 = 0,
12576      i1 = domain.length - 1,
12577      x0 = domain[i0],
12578      x1 = domain[i1],
12579      t;
12580
12581  if (x1 < x0) {
12582    t = i0, i0 = i1, i1 = t;
12583    t = x0, x0 = x1, x1 = t;
12584  }
12585
12586  domain[i0] = interval.floor(x0);
12587  domain[i1] = interval.ceil(x1);
12588  return domain;
12589}
12590
12591function transformLog(x) {
12592  return Math.log(x);
12593}
12594
12595function transformExp(x) {
12596  return Math.exp(x);
12597}
12598
12599function transformLogn(x) {
12600  return -Math.log(-x);
12601}
12602
12603function transformExpn(x) {
12604  return -Math.exp(-x);
12605}
12606
12607function pow10(x) {
12608  return isFinite(x) ? +("1e" + x) : x < 0 ? 0 : x;
12609}
12610
12611function powp(base) {
12612  return base === 10 ? pow10
12613      : base === Math.E ? Math.exp
12614      : function(x) { return Math.pow(base, x); };
12615}
12616
12617function logp(base) {
12618  return base === Math.E ? Math.log
12619      : base === 10 && Math.log10
12620      || base === 2 && Math.log2
12621      || (base = Math.log(base), function(x) { return Math.log(x) / base; });
12622}
12623
12624function reflect(f) {
12625  return function(x) {
12626    return -f(-x);
12627  };
12628}
12629
12630function loggish(transform) {
12631  var scale = transform(transformLog, transformExp),
12632      domain = scale.domain,
12633      base = 10,
12634      logs,
12635      pows;
12636
12637  function rescale() {
12638    logs = logp(base), pows = powp(base);
12639    if (domain()[0] < 0) {
12640      logs = reflect(logs), pows = reflect(pows);
12641      transform(transformLogn, transformExpn);
12642    } else {
12643      transform(transformLog, transformExp);
12644    }
12645    return scale;
12646  }
12647
12648  scale.base = function(_) {
12649    return arguments.length ? (base = +_, rescale()) : base;
12650  };
12651
12652  scale.domain = function(_) {
12653    return arguments.length ? (domain(_), rescale()) : domain();
12654  };
12655
12656  scale.ticks = function(count) {
12657    var d = domain(),
12658        u = d[0],
12659        v = d[d.length - 1],
12660        r;
12661
12662    if (r = v < u) i = u, u = v, v = i;
12663
12664    var i = logs(u),
12665        j = logs(v),
12666        p,
12667        k,
12668        t,
12669        n = count == null ? 10 : +count,
12670        z = [];
12671
12672    if (!(base % 1) && j - i < n) {
12673      i = Math.round(i) - 1, j = Math.round(j) + 1;
12674      if (u > 0) for (; i < j; ++i) {
12675        for (k = 1, p = pows(i); k < base; ++k) {
12676          t = p * k;
12677          if (t < u) continue;
12678          if (t > v) break;
12679          z.push(t);
12680        }
12681      } else for (; i < j; ++i) {
12682        for (k = base - 1, p = pows(i); k >= 1; --k) {
12683          t = p * k;
12684          if (t < u) continue;
12685          if (t > v) break;
12686          z.push(t);
12687        }
12688      }
12689    } else {
12690      z = ticks(i, j, Math.min(j - i, n)).map(pows);
12691    }
12692
12693    return r ? z.reverse() : z;
12694  };
12695
12696  scale.tickFormat = function(count, specifier) {
12697    if (specifier == null) specifier = base === 10 ? ".0e" : ",";
12698    if (typeof specifier !== "function") specifier = exports.format(specifier);
12699    if (count === Infinity) return specifier;
12700    if (count == null) count = 10;
12701    var k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate?
12702    return function(d) {
12703      var i = d / pows(Math.round(logs(d)));
12704      if (i * base < base - 0.5) i *= base;
12705      return i <= k ? specifier(d) : "";
12706    };
12707  };
12708
12709  scale.nice = function() {
12710    return domain(nice(domain(), {
12711      floor: function(x) { return pows(Math.floor(logs(x))); },
12712      ceil: function(x) { return pows(Math.ceil(logs(x))); }
12713    }));
12714  };
12715
12716  return scale;
12717}
12718
12719function log$1() {
12720  var scale = loggish(transformer$1()).domain([1, 10]);
12721
12722  scale.copy = function() {
12723    return copy(scale, log$1()).base(scale.base());
12724  };
12725
12726  initRange.apply(scale, arguments);
12727
12728  return scale;
12729}
12730
12731function transformSymlog(c) {
12732  return function(x) {
12733    return Math.sign(x) * Math.log1p(Math.abs(x / c));
12734  };
12735}
12736
12737function transformSymexp(c) {
12738  return function(x) {
12739    return Math.sign(x) * Math.expm1(Math.abs(x)) * c;
12740  };
12741}
12742
12743function symlogish(transform) {
12744  var c = 1, scale = transform(transformSymlog(c), transformSymexp(c));
12745
12746  scale.constant = function(_) {
12747    return arguments.length ? transform(transformSymlog(c = +_), transformSymexp(c)) : c;
12748  };
12749
12750  return linearish(scale);
12751}
12752
12753function symlog() {
12754  var scale = symlogish(transformer$1());
12755
12756  scale.copy = function() {
12757    return copy(scale, symlog()).constant(scale.constant());
12758  };
12759
12760  return initRange.apply(scale, arguments);
12761}
12762
12763function transformPow(exponent) {
12764  return function(x) {
12765    return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
12766  };
12767}
12768
12769function transformSqrt(x) {
12770  return x < 0 ? -Math.sqrt(-x) : Math.sqrt(x);
12771}
12772
12773function transformSquare(x) {
12774  return x < 0 ? -x * x : x * x;
12775}
12776
12777function powish(transform) {
12778  var scale = transform(identity$6, identity$6),
12779      exponent = 1;
12780
12781  function rescale() {
12782    return exponent === 1 ? transform(identity$6, identity$6)
12783        : exponent === 0.5 ? transform(transformSqrt, transformSquare)
12784        : transform(transformPow(exponent), transformPow(1 / exponent));
12785  }
12786
12787  scale.exponent = function(_) {
12788    return arguments.length ? (exponent = +_, rescale()) : exponent;
12789  };
12790
12791  return linearish(scale);
12792}
12793
12794function pow$1() {
12795  var scale = powish(transformer$1());
12796
12797  scale.copy = function() {
12798    return copy(scale, pow$1()).exponent(scale.exponent());
12799  };
12800
12801  initRange.apply(scale, arguments);
12802
12803  return scale;
12804}
12805
12806function sqrt$1() {
12807  return pow$1.apply(null, arguments).exponent(0.5);
12808}
12809
12810function quantile() {
12811  var domain = [],
12812      range = [],
12813      thresholds = [],
12814      unknown;
12815
12816  function rescale() {
12817    var i = 0, n = Math.max(1, range.length);
12818    thresholds = new Array(n - 1);
12819    while (++i < n) thresholds[i - 1] = threshold(domain, i / n);
12820    return scale;
12821  }
12822
vendor: 4,382 bytes, lines 12823-12994
12823  function scale(x) {
12824    return isNaN(x = +x) ? unknown : range[bisectRight(thresholds, x)];
12825  }
12826
12827  scale.invertExtent = function(y) {
12828    var i = range.indexOf(y);
12829    return i < 0 ? [NaN, NaN] : [
12830      i > 0 ? thresholds[i - 1] : domain[0],
12831      i < thresholds.length ? thresholds[i] : domain[domain.length - 1]
12832    ];
12833  };
12834
12835  scale.domain = function(_) {
12836    if (!arguments.length) return domain.slice();
12837    domain = [];
12838    for (var i = 0, n = _.length, d; i < n; ++i) if (d = _[i], d != null && !isNaN(d = +d)) domain.push(d);
12839    domain.sort(ascending);
12840    return rescale();
12841  };
12842
12843  scale.range = function(_) {
12844    return arguments.length ? (range = slice$5.call(_), rescale()) : range.slice();
12845  };
12846
12847  scale.unknown = function(_) {
12848    return arguments.length ? (unknown = _, scale) : unknown;
12849  };
12850
12851  scale.quantiles = function() {
12852    return thresholds.slice();
12853  };
12854
12855  scale.copy = function() {
12856    return quantile()
12857        .domain(domain)
12858        .range(range)
12859        .unknown(unknown);
12860  };
12861
12862  return initRange.apply(scale, arguments);
12863}
12864
12865function quantize$1() {
12866  var x0 = 0,
12867      x1 = 1,
12868      n = 1,
12869      domain = [0.5],
12870      range = [0, 1],
12871      unknown;
12872
12873  function scale(x) {
12874    return x <= x ? range[bisectRight(domain, x, 0, n)] : unknown;
12875  }
12876
12877  function rescale() {
12878    var i = -1;
12879    domain = new Array(n);
12880    while (++i < n) domain[i] = ((i + 1) * x1 - (i - n) * x0) / (n + 1);
12881    return scale;
12882  }
12883
12884  scale.domain = function(_) {
12885    return arguments.length ? (x0 = +_[0], x1 = +_[1], rescale()) : [x0, x1];
12886  };
12887
12888  scale.range = function(_) {
12889    return arguments.length ? (n = (range = slice$5.call(_)).length - 1, rescale()) : range.slice();
12890  };
12891
12892  scale.invertExtent = function(y) {
12893    var i = range.indexOf(y);
12894    return i < 0 ? [NaN, NaN]
12895        : i < 1 ? [x0, domain[0]]
12896        : i >= n ? [domain[n - 1], x1]
12897        : [domain[i - 1], domain[i]];
12898  };
12899
12900  scale.unknown = function(_) {
12901    return arguments.length ? (unknown = _, scale) : scale;
12902  };
12903
12904  scale.thresholds = function() {
12905    return domain.slice();
12906  };
12907
12908  scale.copy = function() {
12909    return quantize$1()
12910        .domain([x0, x1])
12911        .range(range)
12912        .unknown(unknown);
12913  };
12914
12915  return initRange.apply(linearish(scale), arguments);
12916}
12917
12918function threshold$1() {
12919  var domain = [0.5],
12920      range = [0, 1],
12921      unknown,
12922      n = 1;
12923
12924  function scale(x) {
12925    return x <= x ? range[bisectRight(domain, x, 0, n)] : unknown;
12926  }
12927
12928  scale.domain = function(_) {
12929    return arguments.length ? (domain = slice$5.call(_), n = Math.min(domain.length, range.length - 1), scale) : domain.slice();
12930  };
12931
12932  scale.range = function(_) {
12933    return arguments.length ? (range = slice$5.call(_), n = Math.min(domain.length, range.length - 1), scale) : range.slice();
12934  };
12935
12936  scale.invertExtent = function(y) {
12937    var i = range.indexOf(y);
12938    return [domain[i - 1], domain[i]];
12939  };
12940
12941  scale.unknown = function(_) {
12942    return arguments.length ? (unknown = _, scale) : unknown;
12943  };
12944
12945  scale.copy = function() {
12946    return threshold$1()
12947        .domain(domain)
12948        .range(range)
12949        .unknown(unknown);
12950  };
12951
12952  return initRange.apply(scale, arguments);
12953}
12954
12955var t0$1 = new Date,
12956    t1$1 = new Date;
12957
12958function newInterval(floori, offseti, count, field) {
12959
12960  function interval(date) {
12961    return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date;
12962  }
12963
12964  interval.floor = function(date) {
12965    return floori(date = new Date(+date)), date;
12966  };
12967
12968  interval.ceil = function(date) {
12969    return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date;
12970  };
12971
12972  interval.round = function(date) {
12973    var d0 = interval(date),
12974        d1 = interval.ceil(date);
12975    return date - d0 < d1 - date ? d0 : d1;
12976  };
12977
12978  interval.offset = function(date, step) {
12979    return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date;
12980  };
12981
12982  interval.range = function(start, stop, step) {
12983    var range = [], previous;
12984    start = interval.ceil(start);
12985    step = step == null ? 1 : Math.floor(step);
12986    if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date
12987    do range.push(previous = new Date(+start)), offseti(start, step), floori(start);
12988    while (previous < start && start < stop);
12989    return range;
12990  };
12991
12992  interval.filter = function(test) {
12993    return newInterval(function(date) {
12994      if (date >
vendor: 9,500 bytes, lines 12994-13313
12994= date) while (floori(date), !test(date)) date.setTime(date - 1);
12995    }, function(date, step) {
12996      if (date >= date) {
12997        if (step < 0) while (++step <= 0) {
12998          while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty
12999        } else while (--step >= 0) {
13000          while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty
13001        }
13002      }
13003    });
13004  };
13005
13006  if (count) {
13007    interval.count = function(start, end) {
13008      t0$1.setTime(+start), t1$1.setTime(+end);
13009      floori(t0$1), floori(t1$1);
13010      return Math.floor(count(t0$1, t1$1));
13011    };
13012
13013    interval.every = function(step) {
13014      step = Math.floor(step);
13015      return !isFinite(step) || !(step > 0) ? null
13016          : !(step > 1) ? interval
13017          : interval.filter(field
13018              ? function(d) { return field(d) % step === 0; }
13019              : function(d) { return interval.count(0, d) % step === 0; });
13020    };
13021  }
13022
13023  return interval;
13024}
13025
13026var millisecond = newInterval(function() {
13027  // noop
13028}, function(date, step) {
13029  date.setTime(+date + step);
13030}, function(start, end) {
13031  return end - start;
13032});
13033
13034// An optimized implementation for this simple case.
13035millisecond.every = function(k) {
13036  k = Math.floor(k);
13037  if (!isFinite(k) || !(k > 0)) return null;
13038  if (!(k > 1)) return millisecond;
13039  return newInterval(function(date) {
13040    date.setTime(Math.floor(date / k) * k);
13041  }, function(date, step) {
13042    date.setTime(+date + step * k);
13043  }, function(start, end) {
13044    return (end - start) / k;
13045  });
13046};
13047var milliseconds = millisecond.range;
13048
13049var durationSecond = 1e3;
13050var durationMinute = 6e4;
13051var durationHour = 36e5;
13052var durationDay = 864e5;
13053var durationWeek = 6048e5;
13054
13055var second = newInterval(function(date) {
13056  date.setTime(date - date.getMilliseconds());
13057}, function(date, step) {
13058  date.setTime(+date + step * durationSecond);
13059}, function(start, end) {
13060  return (end - start) / durationSecond;
13061}, function(date) {
13062  return date.getUTCSeconds();
13063});
13064var seconds = second.range;
13065
13066var minute = newInterval(function(date) {
13067  date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond);
13068}, function(date, step) {
13069  date.setTime(+date + step * durationMinute);
13070}, function(start, end) {
13071  return (end - start) / durationMinute;
13072}, function(date) {
13073  return date.getMinutes();
13074});
13075var minutes = minute.range;
13076
13077var hour = newInterval(function(date) {
13078  date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute);
13079}, function(date, step) {
13080  date.setTime(+date + step * durationHour);
13081}, function(start, end) {
13082  return (end - start) / durationHour;
13083}, function(date) {
13084  return date.getHours();
13085});
13086var hours = hour.range;
13087
13088var day = newInterval(function(date) {
13089  date.setHours(0, 0, 0, 0);
13090}, function(date, step) {
13091  date.setDate(date.getDate() + step);
13092}, function(start, end) {
13093  return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay;
13094}, function(date) {
13095  return date.getDate() - 1;
13096});
13097var days = day.range;
13098
13099function weekday(i) {
13100  return newInterval(function(date) {
13101    date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
13102    date.setHours(0, 0, 0, 0);
13103  }, function(date, step) {
13104    date.setDate(date.getDate() + step * 7);
13105  }, function(start, end) {
13106    return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
13107  });
13108}
13109
13110var sunday = weekday(0);
13111var monday = weekday(1);
13112var tuesday = weekday(2);
13113var wednesday = weekday(3);
13114var thursday = weekday(4);
13115var friday = weekday(5);
13116var saturday = weekday(6);
13117
13118var sundays = sunday.range;
13119var mondays = monday.range;
13120var tuesdays = tuesday.range;
13121var wednesdays = wednesday.range;
13122var thursdays = thursday.range;
13123var fridays = friday.range;
13124var saturdays = saturday.range;
13125
13126var month = newInterval(function(date) {
13127  date.setDate(1);
13128  date.setHours(0, 0, 0, 0);
13129}, function(date, step) {
13130  date.setMonth(date.getMonth() + step);
13131}, function(start, end) {
13132  return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
13133}, function(date) {
13134  return date.getMonth();
13135});
13136var months = month.range;
13137
13138var year = newInterval(function(date) {
13139  date.setMonth(0, 1);
13140  date.setHours(0, 0, 0, 0);
13141}, function(date, step) {
13142  date.setFullYear(date.getFullYear() + step);
13143}, function(start, end) {
13144  return end.getFullYear() - start.getFullYear();
13145}, function(date) {
13146  return date.getFullYear();
13147});
13148
13149// An optimized implementation for this simple case.
13150year.every = function(k) {
13151  return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
13152    date.setFullYear(Math.floor(date.getFullYear() / k) * k);
13153    date.setMonth(0, 1);
13154    date.setHours(0, 0, 0, 0);
13155  }, function(date, step) {
13156    date.setFullYear(date.getFullYear() + step * k);
13157  });
13158};
13159var years = year.range;
13160
13161var utcMinute = newInterval(function(date) {
13162  date.setUTCSeconds(0, 0);
13163}, function(date, step) {
13164  date.setTime(+date + step * durationMinute);
13165}, function(start, end) {
13166  return (end - start) / durationMinute;
13167}, function(date) {
13168  return date.getUTCMinutes();
13169});
13170var utcMinutes = utcMinute.range;
13171
13172var utcHour = newInterval(function(date) {
13173  date.setUTCMinutes(0, 0, 0);
13174}, function(date, step) {
13175  date.setTime(+date + step * durationHour);
13176}, function(start, end) {
13177  return (end - start) / durationHour;
13178}, function(date) {
13179  return date.getUTCHours();
13180});
13181var utcHours = utcHour.range;
13182
13183var utcDay = newInterval(function(date) {
13184  date.setUTCHours(0, 0, 0, 0);
13185}, function(date, step) {
13186  date.setUTCDate(date.getUTCDate() + step);
13187}, function(start, end) {
13188  return (end - start) / durationDay;
13189}, function(date) {
13190  return date.getUTCDate() - 1;
13191});
13192var utcDays = utcDay.range;
13193
13194function utcWeekday(i) {
13195  return newInterval(function(date) {
13196    date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
13197    date.setUTCHours(0, 0, 0, 0);
13198  }, function(date, step) {
13199    date.setUTCDate(date.getUTCDate() + step * 7);
13200  }, function(start, end) {
13201    return (end - start) / durationWeek;
13202  });
13203}
13204
13205var utcSunday = utcWeekday(0);
13206var utcMonday = utcWeekday(1);
13207var utcTuesday = utcWeekday(2);
13208var utcWednesday = utcWeekday(3);
13209var utcThursday = utcWeekday(4);
13210var utcFriday = utcWeekday(5);
13211var utcSaturday = utcWeekday(6);
13212
13213var utcSundays = utcSunday.range;
13214var utcMondays = utcMonday.range;
13215var utcTuesdays = utcTuesday.range;
13216var utcWednesdays = utcWednesday.range;
13217var utcThursdays = utcThursday.range;
13218var utcFridays = utcFriday.range;
13219var utcSaturdays = utcSaturday.range;
13220
13221var utcMonth = newInterval(function(date) {
13222  date.setUTCDate(1);
13223  date.setUTCHours(0, 0, 0, 0);
13224}, function(date, step) {
13225  date.setUTCMonth(date.getUTCMonth() + step);
13226}, function(start, end) {
13227  return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
13228}, function(date) {
13229  return date.getUTCMonth();
13230});
13231var utcMonths = utcMonth.range;
13232
13233var utcYear = newInterval(function(date) {
13234  date.setUTCMonth(0, 1);
13235  date.setUTCHours(0, 0, 0, 0);
13236}, function(date, step) {
13237  date.setUTCFullYear(date.getUTCFullYear() + step);
13238}, function(start, end) {
13239  return end.getUTCFullYear() - start.getUTCFullYear();
13240}, function(date) {
13241  return date.getUTCFullYear();
13242});
13243
13244// An optimized implementation for this simple case.
13245utcYear.every = function(k) {
13246  return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
13247    date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
13248    date.setUTCMonth(0, 1);
13249    date.setUTCHours(0, 0, 0, 0);
13250  }, function(date, step) {
13251    date.setUTCFullYear(date.getUTCFullYear() + step * k);
13252  });
13253};
13254var utcYears = utcYear.range;
13255
13256function localDate(d) {
13257  if (0 <= d.y && d.y < 100) {
13258    var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
13259    date.setFullYear(d.y);
13260    return date;
13261  }
13262  return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
13263}
13264
13265function utcDate(d) {
13266  if (0 <= d.y && d.y < 100) {
13267    var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
13268    date.setUTCFullYear(d.y);
13269    return date;
13270  }
13271  return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
13272}
13273
13274function newDate(y, m, d) {
13275  return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0};
13276}
13277
13278function formatLocale$1(locale) {
13279  var locale_dateTime = locale.dateTime,
13280      locale_date = locale.date,
13281      locale_time = locale.time,
13282      locale_periods = locale.periods,
13283      locale_weekdays = locale.days,
13284      locale_shortWeekdays = locale.shortDays,
13285      locale_months = locale.months,
13286      locale_shortMonths = locale.shortMonths;
13287
13288  var periodRe = formatRe(locale_periods),
13289      periodLookup = formatLookup(locale_periods),
13290      weekdayRe = formatRe(locale_weekdays),
13291      weekdayLookup = formatLookup(locale_weekdays),
13292      shortWeekdayRe = formatRe(locale_shortWeekdays),
13293      shortWeekdayLookup = formatLookup(locale_shortWeekdays),
13294      monthRe = formatRe(locale_months),
13295      monthLookup = formatLookup(locale_months),
13296      shortMonthRe = formatRe(locale_shortMonths),
13297      shortMonthLookup = formatLookup(locale_shortMonths);
13298
13299  var formats = {
13300    "a": formatShortWeekday,
13301    "A": formatWeekday,
13302    "b": formatShortMonth,
13303    "B": formatMonth,
13304    "c": null,
13305    "d": formatDayOfMonth,
13306    "e": formatDayOfMonth,
13307    "f": formatMicroseconds,
13308    "H": formatHour24,
13309    "I": formatHour12,
13310    "j": formatDayOfYear,
13311    "L": formatMilliseconds,
13312    "m": formatMonthNumber,
13313    "M": formatMinutes,
vendor: 3,157 bytes, lines 13314-13428
13314    "p": formatPeriod,
13315    "q": formatQuarter,
13316    "Q": formatUnixTimestamp,
13317    "s": formatUnixTimestampSeconds,
13318    "S": formatSeconds,
13319    "u": formatWeekdayNumberMonday,
13320    "U": formatWeekNumberSunday,
13321    "V": formatWeekNumberISO,
13322    "w": formatWeekdayNumberSunday,
13323    "W": formatWeekNumberMonday,
13324    "x": null,
13325    "X": null,
13326    "y": formatYear$1,
13327    "Y": formatFullYear,
13328    "Z": formatZone,
13329    "%": formatLiteralPercent
13330  };
13331
13332  var utcFormats = {
13333    "a": formatUTCShortWeekday,
13334    "A": formatUTCWeekday,
13335    "b": formatUTCShortMonth,
13336    "B": formatUTCMonth,
13337    "c": null,
13338    "d": formatUTCDayOfMonth,
13339    "e": formatUTCDayOfMonth,
13340    "f": formatUTCMicroseconds,
13341    "H": formatUTCHour24,
13342    "I": formatUTCHour12,
13343    "j": formatUTCDayOfYear,
13344    "L": formatUTCMilliseconds,
13345    "m": formatUTCMonthNumber,
13346    "M": formatUTCMinutes,
13347    "p": formatUTCPeriod,
13348    "q": formatUTCQuarter,
13349    "Q": formatUnixTimestamp,
13350    "s": formatUnixTimestampSeconds,
13351    "S": formatUTCSeconds,
13352    "u": formatUTCWeekdayNumberMonday,
13353    "U": formatUTCWeekNumberSunday,
13354    "V": formatUTCWeekNumberISO,
13355    "w": formatUTCWeekdayNumberSunday,
13356    "W": formatUTCWeekNumberMonday,
13357    "x": null,
13358    "X": null,
13359    "y": formatUTCYear,
13360    "Y": formatUTCFullYear,
13361    "Z": formatUTCZone,
13362    "%": formatLiteralPercent
13363  };
13364
13365  var parses = {
13366    "a": parseShortWeekday,
13367    "A": parseWeekday,
13368    "b": parseShortMonth,
13369    "B": parseMonth,
13370    "c": parseLocaleDateTime,
13371    "d": parseDayOfMonth,
13372    "e": parseDayOfMonth,
13373    "f": parseMicroseconds,
13374    "H": parseHour24,
13375    "I": parseHour24,
13376    "j": parseDayOfYear,
13377    "L": parseMilliseconds,
13378    "m": parseMonthNumber,
13379    "M": parseMinutes,
13380    "p": parsePeriod,
13381    "q": parseQuarter,
13382    "Q": parseUnixTimestamp,
13383    "s": parseUnixTimestampSeconds,
13384    "S": parseSeconds,
13385    "u": parseWeekdayNumberMonday,
13386    "U": parseWeekNumberSunday,
13387    "V": parseWeekNumberISO,
13388    "w": parseWeekdayNumberSunday,
13389    "W": parseWeekNumberMonday,
13390    "x": parseLocaleDate,
13391    "X": parseLocaleTime,
13392    "y": parseYear,
13393    "Y": parseFullYear,
13394    "Z": parseZone,
13395    "%": parseLiteralPercent
13396  };
13397
13398  // These recursive directive definitions must be deferred.
13399  formats.x = newFormat(locale_date, formats);
13400  formats.X = newFormat(locale_time, formats);
13401  formats.c = newFormat(locale_dateTime, formats);
13402  utcFormats.x = newFormat(locale_date, utcFormats);
13403  utcFormats.X = newFormat(locale_time, utcFormats);
13404  utcFormats.c = newFormat(locale_dateTime, utcFormats);
13405
13406  function newFormat(specifier, formats) {
13407    return function(date) {
13408      var string = [],
13409          i = -1,
13410          j = 0,
13411          n = specifier.length,
13412          c,
13413          pad,
13414          format;
13415
13416      if (!(date instanceof Date)) date = new Date(+date);
13417
13418      while (++i < n) {
13419        if (specifier.charCodeAt(i) === 37) {
13420          string.push(specifier.slice(j, i));
13421          if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i);
13422          else pad = c === "e" ? " " : "0";
13423          if (format = formats[c]) c = format(date, pad);
13424          string.push(c);
13425          j = i + 1;
13426        }
13427      }
13428
vendor: 4,382 bytes, lines 13429-13567
13429      string.push(specifier.slice(j, i));
13430      return string.join("");
13431    };
13432  }
13433
13434  function newParse(specifier, Z) {
13435    return function(string) {
13436      var d = newDate(1900, undefined, 1),
13437          i = parseSpecifier(d, specifier, string += "", 0),
13438          week, day$1;
13439      if (i != string.length) return null;
13440
13441      // If a UNIX timestamp is specified, return it.
13442      if ("Q" in d) return new Date(d.Q);
13443      if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0));
13444
13445      // If this is utcParse, never use the local timezone.
13446      if (Z && !("Z" in d)) d.Z = 0;
13447
13448      // The am-pm flag is 0 for AM, and 1 for PM.
13449      if ("p" in d) d.H = d.H % 12 + d.p * 12;
13450
13451      // If the month was not specified, inherit from the quarter.
13452      if (d.m === undefined) d.m = "q" in d ? d.q : 0;
13453
13454      // Convert day-of-week and week-of-year to day-of-year.
13455      if ("V" in d) {
13456        if (d.V < 1 || d.V > 53) return null;
13457        if (!("w" in d)) d.w = 1;
13458        if ("Z" in d) {
13459          week = utcDate(newDate(d.y, 0, 1)), day$1 = week.getUTCDay();
13460          week = day$1 > 4 || day$1 === 0 ? utcMonday.ceil(week) : utcMonday(week);
13461          week = utcDay.offset(week, (d.V - 1) * 7);
13462          d.y = week.getUTCFullYear();
13463          d.m = week.getUTCMonth();
13464          d.d = week.getUTCDate() + (d.w + 6) % 7;
13465        } else {
13466          week = localDate(newDate(d.y, 0, 1)), day$1 = week.getDay();
13467          week = day$1 > 4 || day$1 === 0 ? monday.ceil(week) : monday(week);
13468          week = day.offset(week, (d.V - 1) * 7);
13469          d.y = week.getFullYear();
13470          d.m = week.getMonth();
13471          d.d = week.getDate() + (d.w + 6) % 7;
13472        }
13473      } else if ("W" in d || "U" in d) {
13474        if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
13475        day$1 = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay();
13476        d.m = 0;
13477        d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day$1 + 5) % 7 : d.w + d.U * 7 - (day$1 + 6) % 7;
13478      }
13479
13480      // If a time zone is specified, all fields are interpreted as UTC and then
13481      // offset according to the specified time zone.
13482      if ("Z" in d) {
13483        d.H += d.Z / 100 | 0;
13484        d.M += d.Z % 100;
13485        return utcDate(d);
13486      }
13487
13488      // Otherwise, all fields are in local time.
13489      return localDate(d);
13490    };
13491  }
13492
13493  function parseSpecifier(d, specifier, string, j) {
13494    var i = 0,
13495        n = specifier.length,
13496        m = string.length,
13497        c,
13498        parse;
13499
13500    while (i < n) {
13501      if (j >= m) return -1;
13502      c = specifier.charCodeAt(i++);
13503      if (c === 37) {
13504        c = specifier.charAt(i++);
13505        parse = parses[c in pads ? specifier.charAt(i++) : c];
13506        if (!parse || ((j = parse(d, string, j)) < 0)) return -1;
13507      } else if (c != string.charCodeAt(j++)) {
13508        return -1;
13509      }
13510    }
13511
13512    return j;
13513  }
13514
13515  function parsePeriod(d, string, i) {
13516    var n = periodRe.exec(string.slice(i));
13517    return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13518  }
13519
13520  function parseShortWeekday(d, string, i) {
13521    var n = shortWeekdayRe.exec(string.slice(i));
13522    return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13523  }
13524
13525  function parseWeekday(d, string, i) {
13526    var n = weekdayRe.exec(string.slice(i));
13527    return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13528  }
13529
13530  function parseShortMonth(d, string, i) {
13531    var n = shortMonthRe.exec(string.slice(i));
13532    return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13533  }
13534
13535  function parseMonth(d, string, i) {
13536    var n = monthRe.exec(string.slice(i));
13537    return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13538  }
13539
13540  function parseLocaleDateTime(d, string, i) {
13541    return parseSpecifier(d, locale_dateTime, string, i);
13542  }
13543
13544  function parseLocaleDate(d, string, i) {
13545    return parseSpecifier(d, locale_date, string, i);
13546  }
13547
13548  function parseLocaleTime(d, string, i) {
13549    return parseSpecifier(d, locale_time, string, i);
13550  }
13551
13552  function formatShortWeekday(d) {
13553    return locale_shortWeekdays[d.getDay()];
13554  }
13555
13556  function formatWeekday(d) {
13557    return locale_weekdays[d.getDay()];
13558  }
13559
13560  function formatShortMonth(d) {
13561    return locale_shortMonths[d.getMonth()];
13562  }
13563
13564  function formatMonth(d) {
13565    return locale_months[d.getMonth()];
13566  }
13567
vendor: 2,191 bytes, lines 13568-13654
13568  function formatPeriod(d) {
13569    return locale_periods[+(d.getHours() >= 12)];
13570  }
13571
13572  function formatQuarter(d) {
13573    return 1 + ~~(d.getMonth() / 3);
13574  }
13575
13576  function formatUTCShortWeekday(d) {
13577    return locale_shortWeekdays[d.getUTCDay()];
13578  }
13579
13580  function formatUTCWeekday(d) {
13581    return locale_weekdays[d.getUTCDay()];
13582  }
13583
13584  function formatUTCShortMonth(d) {
13585    return locale_shortMonths[d.getUTCMonth()];
13586  }
13587
13588  function formatUTCMonth(d) {
13589    return locale_months[d.getUTCMonth()];
13590  }
13591
13592  function formatUTCPeriod(d) {
13593    return locale_periods[+(d.getUTCHours() >= 12)];
13594  }
13595
13596  function formatUTCQuarter(d) {
13597    return 1 + ~~(d.getUTCMonth() / 3);
13598  }
13599
13600  return {
13601    format: function(specifier) {
13602      var f = newFormat(specifier += "", formats);
13603      f.toString = function() { return specifier; };
13604      return f;
13605    },
13606    parse: function(specifier) {
13607      var p = newParse(specifier += "", false);
13608      p.toString = function() { return specifier; };
13609      return p;
13610    },
13611    utcFormat: function(specifier) {
13612      var f = newFormat(specifier += "", utcFormats);
13613      f.toString = function() { return specifier; };
13614      return f;
13615    },
13616    utcParse: function(specifier) {
13617      var p = newParse(specifier += "", true);
13618      p.toString = function() { return specifier; };
13619      return p;
13620    }
13621  };
13622}
13623
13624var pads = {"-": "", "_": " ", "0": "0"},
13625    numberRe = /^\s*\d+/, // note: ignores next directive
13626    percentRe = /^%/,
13627    requoteRe = /[\\^$*+?|[\]().{}]/g;
13628
13629function pad$1(value, fill, width) {
13630  var sign = value < 0 ? "-" : "",
13631      string = (sign ? -value : value) + "",
13632      length = string.length;
13633  return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
13634}
13635
13636function requote(s) {
13637  return s.replace(requoteRe, "\\$&");
13638}
13639
13640function formatRe(names) {
13641  return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i");
13642}
13643
13644function formatLookup(names) {
13645  var map = {}, i = -1, n = names.length;
13646  while (++i < n) map[names[i].toLowerCase()] = i;
13647  return map;
13648}
13649
13650function parseWeekdayNumberSunday(d, string, i) {
13651  var n = numberRe.exec(string.slice(i, i + 1));
13652  return n ? (d.w = +n[0], i + n[0].length) : -1;
13653}
13654
vendor: 6,541 bytes, lines 13655-13916
13655function parseWeekdayNumberMonday(d, string, i) {
13656  var n = numberRe.exec(string.slice(i, i + 1));
13657  return n ? (d.u = +n[0], i + n[0].length) : -1;
13658}
13659
13660function parseWeekNumberSunday(d, string, i) {
13661  var n = numberRe.exec(string.slice(i, i + 2));
13662  return n ? (d.U = +n[0], i + n[0].length) : -1;
13663}
13664
13665function parseWeekNumberISO(d, string, i) {
13666  var n = numberRe.exec(string.slice(i, i + 2));
13667  return n ? (d.V = +n[0], i + n[0].length) : -1;
13668}
13669
13670function parseWeekNumberMonday(d, string, i) {
13671  var n = numberRe.exec(string.slice(i, i + 2));
13672  return n ? (d.W = +n[0], i + n[0].length) : -1;
13673}
13674
13675function parseFullYear(d, string, i) {
13676  var n = numberRe.exec(string.slice(i, i + 4));
13677  return n ? (d.y = +n[0], i + n[0].length) : -1;
13678}
13679
13680function parseYear(d, string, i) {
13681  var n = numberRe.exec(string.slice(i, i + 2));
13682  return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1;
13683}
13684
13685function parseZone(d, string, i) {
13686  var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6));
13687  return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1;
13688}
13689
13690function parseQuarter(d, string, i) {
13691  var n = numberRe.exec(string.slice(i, i + 1));
13692  return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1;
13693}
13694
13695function parseMonthNumber(d, string, i) {
13696  var n = numberRe.exec(string.slice(i, i + 2));
13697  return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
13698}
13699
13700function parseDayOfMonth(d, string, i) {
13701  var n = numberRe.exec(string.slice(i, i + 2));
13702  return n ? (d.d = +n[0], i + n[0].length) : -1;
13703}
13704
13705function parseDayOfYear(d, string, i) {
13706  var n = numberRe.exec(string.slice(i, i + 3));
13707  return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
13708}
13709
13710function parseHour24(d, string, i) {
13711  var n = numberRe.exec(string.slice(i, i + 2));
13712  return n ? (d.H = +n[0], i + n[0].length) : -1;
13713}
13714
13715function parseMinutes(d, string, i) {
13716  var n = numberRe.exec(string.slice(i, i + 2));
13717  return n ? (d.M = +n[0], i + n[0].length) : -1;
13718}
13719
13720function parseSeconds(d, string, i) {
13721  var n = numberRe.exec(string.slice(i, i + 2));
13722  return n ? (d.S = +n[0], i + n[0].length) : -1;
13723}
13724
13725function parseMilliseconds(d, string, i) {
13726  var n = numberRe.exec(string.slice(i, i + 3));
13727  return n ? (d.L = +n[0], i + n[0].length) : -1;
13728}
13729
13730function parseMicroseconds(d, string, i) {
13731  var n = numberRe.exec(string.slice(i, i + 6));
13732  return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1;
13733}
13734
13735function parseLiteralPercent(d, string, i) {
13736  var n = percentRe.exec(string.slice(i, i + 1));
13737  return n ? i + n[0].length : -1;
13738}
13739
13740function parseUnixTimestamp(d, string, i) {
13741  var n = numberRe.exec(string.slice(i));
13742  return n ? (d.Q = +n[0], i + n[0].length) : -1;
13743}
13744
13745function parseUnixTimestampSeconds(d, string, i) {
13746  var n = numberRe.exec(string.slice(i));
13747  return n ? (d.s = +n[0], i + n[0].length) : -1;
13748}
13749
13750function formatDayOfMonth(d, p) {
13751  return pad$1(d.getDate(), p, 2);
13752}
13753
13754function formatHour24(d, p) {
13755  return pad$1(d.getHours(), p, 2);
13756}
13757
13758function formatHour12(d, p) {
13759  return pad$1(d.getHours() % 12 || 12, p, 2);
13760}
13761
13762function formatDayOfYear(d, p) {
13763  return pad$1(1 + day.count(year(d), d), p, 3);
13764}
13765
13766function formatMilliseconds(d, p) {
13767  return pad$1(d.getMilliseconds(), p, 3);
13768}
13769
13770function formatMicroseconds(d, p) {
13771  return formatMilliseconds(d, p) + "000";
13772}
13773
13774function formatMonthNumber(d, p) {
13775  return pad$1(d.getMonth() + 1, p, 2);
13776}
13777
13778function formatMinutes(d, p) {
13779  return pad$1(d.getMinutes(), p, 2);
13780}
13781
13782function formatSeconds(d, p) {
13783  return pad$1(d.getSeconds(), p, 2);
13784}
13785
13786function formatWeekdayNumberMonday(d) {
13787  var day = d.getDay();
13788  return day === 0 ? 7 : day;
13789}
13790
13791function formatWeekNumberSunday(d, p) {
13792  return pad$1(sunday.count(year(d) - 1, d), p, 2);
13793}
13794
13795function formatWeekNumberISO(d, p) {
13796  var day = d.getDay();
13797  d = (day >= 4 || day === 0) ? thursday(d) : thursday.ceil(d);
13798  return pad$1(thursday.count(year(d), d) + (year(d).getDay() === 4), p, 2);
13799}
13800
13801function formatWeekdayNumberSunday(d) {
13802  return d.getDay();
13803}
13804
13805function formatWeekNumberMonday(d, p) {
13806  return pad$1(monday.count(year(d) - 1, d), p, 2);
13807}
13808
13809function formatYear$1(d, p) {
13810  return pad$1(d.getFullYear() % 100, p, 2);
13811}
13812
13813function formatFullYear(d, p) {
13814  return pad$1(d.getFullYear() % 10000, p, 4);
13815}
13816
13817function formatZone(d) {
13818  var z = d.getTimezoneOffset();
13819  return (z > 0 ? "-" : (z *= -1, "+"))
13820      + pad$1(z / 60 | 0, "0", 2)
13821      + pad$1(z % 60, "0", 2);
13822}
13823
13824function formatUTCDayOfMonth(d, p) {
13825  return pad$1(d.getUTCDate(), p, 2);
13826}
13827
13828function formatUTCHour24(d, p) {
13829  return pad$1(d.getUTCHours(), p, 2);
13830}
13831
13832function formatUTCHour12(d, p) {
13833  return pad$1(d.getUTCHours() % 12 || 12, p, 2);
13834}
13835
13836function formatUTCDayOfYear(d, p) {
13837  return pad$1(1 + utcDay.count(utcYear(d), d), p, 3);
13838}
13839
13840function formatUTCMilliseconds(d, p) {
13841  return pad$1(d.getUTCMilliseconds(), p, 3);
13842}
13843
13844function formatUTCMicroseconds(d, p) {
13845  return formatUTCMilliseconds(d, p) + "000";
13846}
13847
13848function formatUTCMonthNumber(d, p) {
13849  return pad$1(d.getUTCMonth() + 1, p, 2);
13850}
13851
13852function formatUTCMinutes(d, p) {
13853  return pad$1(d.getUTCMinutes(), p, 2);
13854}
13855
13856function formatUTCSeconds(d, p) {
13857  return pad$1(d.getUTCSeconds(), p, 2);
13858}
13859
13860function formatUTCWeekdayNumberMonday(d) {
13861  var dow = d.getUTCDay();
13862  return dow === 0 ? 7 : dow;
13863}
13864
13865function formatUTCWeekNumberSunday(d, p) {
13866  return pad$1(utcSunday.count(utcYear(d) - 1, d), p, 2);
13867}
13868
13869function formatUTCWeekNumberISO(d, p) {
13870  var day = d.getUTCDay();
13871  d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d);
13872  return pad$1(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2);
13873}
13874
13875function formatUTCWeekdayNumberSunday(d) {
13876  return d.getUTCDay();
13877}
13878
13879function formatUTCWeekNumberMonday(d, p) {
13880  return pad$1(utcMonday.count(utcYear(d) - 1, d), p, 2);
13881}
13882
13883function formatUTCYear(d, p) {
13884  return pad$1(d.getUTCFullYear() % 100, p, 2);
13885}
13886
13887function formatUTCFullYear(d, p) {
13888  return pad$1(d.getUTCFullYear() % 10000, p, 4);
13889}
13890
13891function formatUTCZone() {
13892  return "+0000";
13893}
13894
13895function formatLiteralPercent() {
13896  return "%";
13897}
13898
13899function formatUnixTimestamp(d) {
13900  return +d;
13901}
13902
13903function formatUnixTimestampSeconds(d) {
13904  return Math.floor(+d / 1000);
13905}
13906
13907var locale$1;
13908
13909defaultLocale$1({
13910  dateTime: "%x, %X",
13911  date: "%-m/%-d/%Y",
13912  time: "%-I:%M:%S %p",
13913  periods: ["AM", "PM"],
13914  days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
13915  shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
13916  months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
vendor: 5,419 bytes, lines 13916-14090
13916November", "December"],
13917  shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
13918});
13919
13920function defaultLocale$1(definition) {
13921  locale$1 = formatLocale$1(definition);
13922  exports.timeFormat = locale$1.format;
13923  exports.timeParse = locale$1.parse;
13924  exports.utcFormat = locale$1.utcFormat;
13925  exports.utcParse = locale$1.utcParse;
13926  return locale$1;
13927}
13928
13929var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ";
13930
13931function formatIsoNative(date) {
13932  return date.toISOString();
13933}
13934
13935var formatIso = Date.prototype.toISOString
13936    ? formatIsoNative
13937    : exports.utcFormat(isoSpecifier);
13938
13939function parseIsoNative(string) {
13940  var date = new Date(string);
13941  return isNaN(date) ? null : date;
13942}
13943
13944var parseIso = +new Date("2000-01-01T00:00:00.000Z")
13945    ? parseIsoNative
13946    : exports.utcParse(isoSpecifier);
13947
13948var durationSecond$1 = 1000,
13949    durationMinute$1 = durationSecond$1 * 60,
13950    durationHour$1 = durationMinute$1 * 60,
13951    durationDay$1 = durationHour$1 * 24,
13952    durationWeek$1 = durationDay$1 * 7,
13953    durationMonth = durationDay$1 * 30,
13954    durationYear = durationDay$1 * 365;
13955
13956function date$1(t) {
13957  return new Date(t);
13958}
13959
13960function number$3(t) {
13961  return t instanceof Date ? +t : +new Date(+t);
13962}
13963
13964function calendar(year, month, week, day, hour, minute, second, millisecond, format) {
13965  var scale = continuous(identity$6, identity$6),
13966      invert = scale.invert,
13967      domain = scale.domain;
13968
13969  var formatMillisecond = format(".%L"),
13970      formatSecond = format(":%S"),
13971      formatMinute = format("%I:%M"),
13972      formatHour = format("%I %p"),
13973      formatDay = format("%a %d"),
13974      formatWeek = format("%b %d"),
13975      formatMonth = format("%B"),
13976      formatYear = format("%Y");
13977
13978  var tickIntervals = [
13979    [second,  1,      durationSecond$1],
13980    [second,  5,  5 * durationSecond$1],
13981    [second, 15, 15 * durationSecond$1],
13982    [second, 30, 30 * durationSecond$1],
13983    [minute,  1,      durationMinute$1],
13984    [minute,  5,  5 * durationMinute$1],
13985    [minute, 15, 15 * durationMinute$1],
13986    [minute, 30, 30 * durationMinute$1],
13987    [  hour,  1,      durationHour$1  ],
13988    [  hour,  3,  3 * durationHour$1  ],
13989    [  hour,  6,  6 * durationHour$1  ],
13990    [  hour, 12, 12 * durationHour$1  ],
13991    [   day,  1,      durationDay$1   ],
13992    [   day,  2,  2 * durationDay$1   ],
13993    [  week,  1,      durationWeek$1  ],
13994    [ month,  1,      durationMonth ],
13995    [ month,  3,  3 * durationMonth ],
13996    [  year,  1,      durationYear  ]
13997  ];
13998
13999  function tickFormat(date) {
14000    return (second(date) < date ? formatMillisecond
14001        : minute(date) < date ? formatSecond
14002        : hour(date) < date ? formatMinute
14003        : day(date) < date ? formatHour
14004        : month(date) < date ? (week(date) < date ? formatDay : formatWeek)
14005        : year(date) < date ? formatMonth
14006        : formatYear)(date);
14007  }
14008
14009  function tickInterval(interval, start, stop, step) {
14010    if (interval == null) interval = 10;
14011
14012    // If a desired tick count is specified, pick a reasonable tick interval
14013    // based on the extent of the domain and a rough estimate of tick size.
14014    // Otherwise, assume interval is already a time interval and use it.
14015    if (typeof interval === "number") {
14016      var target = Math.abs(stop - start) / interval,
14017          i = bisector(function(i) { return i[2]; }).right(tickIntervals, target);
14018      if (i === tickIntervals.length) {
14019        step = tickStep(start / durationYear, stop / durationYear, interval);
14020        interval = year;
14021      } else if (i) {
14022        i = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];
14023        step = i[1];
14024        interval = i[0];
14025      } else {
14026        step = Math.max(tickStep(start, stop, interval), 1);
14027        interval = millisecond;
14028      }
14029    }
14030
14031    return step == null ? interval : interval.every(step);
14032  }
14033
14034  scale.invert = function(y) {
14035    return new Date(invert(y));
14036  };
14037
14038  scale.domain = function(_) {
14039    return arguments.length ? domain(map$3.call(_, number$3)) : domain().map(date$1);
14040  };
14041
14042  scale.ticks = function(interval, step) {
14043    var d = domain(),
14044        t0 = d[0],
14045        t1 = d[d.length - 1],
14046        r = t1 < t0,
14047        t;
14048    if (r) t = t0, t0 = t1, t1 = t;
14049    t = tickInterval(interval, t0, t1, step);
14050    t = t ? t.range(t0, t1 + 1) : []; // inclusive stop
14051    return r ? t.reverse() : t;
14052  };
14053
14054  scale.tickFormat = function(count, specifier) {
14055    return specifier == null ? tickFormat : format(specifier);
14056  };
14057
14058  scale.nice = function(interval, step) {
14059    var d = domain();
14060    return (interval = tickInterval(interval, d[0], d[d.length - 1], step))
14061        ? domain(nice(d, interval))
14062        : scale;
14063  };
14064
14065  scale.copy = function() {
14066    return copy(scale, calendar(year, month, week, day, hour, minute, second, millisecond, format));
14067  };
14068
14069  return scale;
14070}
14071
14072function time() {
14073  return initRange.apply(calendar(year, month, sunday, day, hour, minute, second, millisecond, exports.timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]), arguments);
14074}
14075
14076function utcTime() {
14077  return initRange.apply(calendar(utcYear, utcMonth, utcSunday, utcDay, utcHour, utcMinute, second, millisecond, exports.utcFormat).domain([Date.UTC(2000, 0, 1), Date.UTC(2000, 0, 2)]), arguments);
14078}
14079
14080function transformer$2() {
14081  var x0 = 0,
14082      x1 = 1,
14083      t0,
14084      t1,
14085      k10,
14086      transform,
14087      interpolator = identity$6,
14088      clamp = false,
14089      unknown;
14090
vendor: 22,038 bytes, lines 14091-14709
14091  function scale(x) {
14092    return isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x));
14093  }
14094
14095  scale.domain = function(_) {
14096    return arguments.length ? (t0 = transform(x0 = +_[0]), t1 = transform(x1 = +_[1]), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [x0, x1];
14097  };
14098
14099  scale.clamp = function(_) {
14100    return arguments.length ? (clamp = !!_, scale) : clamp;
14101  };
14102
14103  scale.interpolator = function(_) {
14104    return arguments.length ? (interpolator = _, scale) : interpolator;
14105  };
14106
14107  scale.unknown = function(_) {
14108    return arguments.length ? (unknown = _, scale) : unknown;
14109  };
14110
14111  return function(t) {
14112    transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0);
14113    return scale;
14114  };
14115}
14116
14117function copy$1(source, target) {
14118  return target
14119      .domain(source.domain())
14120      .interpolator(source.interpolator())
14121      .clamp(source.clamp())
14122      .unknown(source.unknown());
14123}
14124
14125function sequential() {
14126  var scale = linearish(transformer$2()(identity$6));
14127
14128  scale.copy = function() {
14129    return copy$1(scale, sequential());
14130  };
14131
14132  return initInterpolator.apply(scale, arguments);
14133}
14134
14135function sequentialLog() {
14136  var scale = loggish(transformer$2()).domain([1, 10]);
14137
14138  scale.copy = function() {
14139    return copy$1(scale, sequentialLog()).base(scale.base());
14140  };
14141
14142  return initInterpolator.apply(scale, arguments);
14143}
14144
14145function sequentialSymlog() {
14146  var scale = symlogish(transformer$2());
14147
14148  scale.copy = function() {
14149    return copy$1(scale, sequentialSymlog()).constant(scale.constant());
14150  };
14151
14152  return initInterpolator.apply(scale, arguments);
14153}
14154
14155function sequentialPow() {
14156  var scale = powish(transformer$2());
14157
14158  scale.copy = function() {
14159    return copy$1(scale, sequentialPow()).exponent(scale.exponent());
14160  };
14161
14162  return initInterpolator.apply(scale, arguments);
14163}
14164
14165function sequentialSqrt() {
14166  return sequentialPow.apply(null, arguments).exponent(0.5);
14167}
14168
14169function sequentialQuantile() {
14170  var domain = [],
14171      interpolator = identity$6;
14172
14173  function scale(x) {
14174    if (!isNaN(x = +x)) return interpolator((bisectRight(domain, x) - 1) / (domain.length - 1));
14175  }
14176
14177  scale.domain = function(_) {
14178    if (!arguments.length) return domain.slice();
14179    domain = [];
14180    for (var i = 0, n = _.length, d; i < n; ++i) if (d = _[i], d != null && !isNaN(d = +d)) domain.push(d);
14181    domain.sort(ascending);
14182    return scale;
14183  };
14184
14185  scale.interpolator = function(_) {
14186    return arguments.length ? (interpolator = _, scale) : interpolator;
14187  };
14188
14189  scale.copy = function() {
14190    return sequentialQuantile(interpolator).domain(domain);
14191  };
14192
14193  return initInterpolator.apply(scale, arguments);
14194}
14195
14196function transformer$3() {
14197  var x0 = 0,
14198      x1 = 0.5,
14199      x2 = 1,
14200      t0,
14201      t1,
14202      t2,
14203      k10,
14204      k21,
14205      interpolator = identity$6,
14206      transform,
14207      clamp = false,
14208      unknown;
14209
14210  function scale(x) {
14211    return isNaN(x = +x) ? unknown : (x = 0.5 + ((x = +transform(x)) - t1) * (x < t1 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x)) : x));
14212  }
14213
14214  scale.domain = function(_) {
14215    return arguments.length ? (t0 = transform(x0 = +_[0]), t1 = transform(x1 = +_[1]), t2 = transform(x2 = +_[2]), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), scale) : [x0, x1, x2];
14216  };
14217
14218  scale.clamp = function(_) {
14219    return arguments.length ? (clamp = !!_, scale) : clamp;
14220  };
14221
14222  scale.interpolator = function(_) {
14223    return arguments.length ? (interpolator = _, scale) : interpolator;
14224  };
14225
14226  scale.unknown = function(_) {
14227    return arguments.length ? (unknown = _, scale) : unknown;
14228  };
14229
14230  return function(t) {
14231    transform = t, t0 = t(x0), t1 = t(x1), t2 = t(x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1);
14232    return scale;
14233  };
14234}
14235
14236function diverging() {
14237  var scale = linearish(transformer$3()(identity$6));
14238
14239  scale.copy = function() {
14240    return copy$1(scale, diverging());
14241  };
14242
14243  return initInterpolator.apply(scale, arguments);
14244}
14245
14246function divergingLog() {
14247  var scale = loggish(transformer$3()).domain([0.1, 1, 10]);
14248
14249  scale.copy = function() {
14250    return copy$1(scale, divergingLog()).base(scale.base());
14251  };
14252
14253  return initInterpolator.apply(scale, arguments);
14254}
14255
14256function divergingSymlog() {
14257  var scale = symlogish(transformer$3());
14258
14259  scale.copy = function() {
14260    return copy$1(scale, divergingSymlog()).constant(scale.constant());
14261  };
14262
14263  return initInterpolator.apply(scale, arguments);
14264}
14265
14266function divergingPow() {
14267  var scale = powish(transformer$3());
14268
14269  scale.copy = function() {
14270    return copy$1(scale, divergingPow()).exponent(scale.exponent());
14271  };
14272
14273  return initInterpolator.apply(scale, arguments);
14274}
14275
14276function divergingSqrt() {
14277  return divergingPow.apply(null, arguments).exponent(0.5);
14278}
14279
14280function colors(specifier) {
14281  var n = specifier.length / 6 | 0, colors = new Array(n), i = 0;
14282  while (i < n) colors[i] = "#" + specifier.slice(i * 6, ++i * 6);
14283  return colors;
14284}
14285
14286var category10 = colors("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf");
14287
14288var Accent = colors("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666");
14289
14290var Dark2 = colors("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666");
14291
14292var Paired = colors("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");
14293
14294var Pastel1 = colors("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2");
14295
14296var Pastel2 = colors("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc");
14297
14298var Set1 = colors("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999");
14299
14300var Set2 = colors("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3");
14301
14302var Set3 = colors("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f");
14303
14304var Tableau10 = colors("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");
14305
14306function ramp(scheme) {
14307  return rgbBasis(scheme[scheme.length - 1]);
14308}
14309
14310var scheme = new Array(3).concat(
14311  "d8b365f5f5f55ab4ac",
14312  "a6611adfc27d80cdc1018571",
14313  "a6611adfc27df5f5f580cdc1018571",
14314  "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
14315  "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
14316  "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
14317  "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
14318  "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
14319  "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
14320).map(colors);
14321
14322var BrBG = ramp(scheme);
14323
14324var scheme$1 = new Array(3).concat(
14325  "af8dc3f7f7f77fbf7b",
14326  "7b3294c2a5cfa6dba0008837",
14327  "7b3294c2a5cff7f7f7a6dba0008837",
14328  "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
14329  "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
14330  "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
14331  "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
14332  "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
14333  "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
14334).map(colors);
14335
14336var PRGn = ramp(scheme$1);
14337
14338var scheme$2 = new Array(3).concat(
14339  "e9a3c9f7f7f7a1d76a",
14340  "d01c8bf1b6dab8e1864dac26",
14341  "d01c8bf1b6daf7f7f7b8e1864dac26",
14342  "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
14343  "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
14344  "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
14345  "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
14346  "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
14347  "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
14348).map(colors);
14349
14350var PiYG = ramp(scheme$2);
14351
14352var scheme$3 = new Array(3).concat(
14353  "998ec3f7f7f7f1a340",
14354  "5e3c99b2abd2fdb863e66101",
14355  "5e3c99b2abd2f7f7f7fdb863e66101",
14356  "542788998ec3d8daebfee0b6f1a340b35806",
14357  "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
14358  "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
14359  "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
14360  "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
14361  "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
14362).map(colors);
14363
14364var PuOr = ramp(scheme$3);
14365
14366var scheme$4 = new Array(3).concat(
14367  "ef8a62f7f7f767a9cf",
14368  "ca0020f4a58292c5de0571b0",
14369  "ca0020f4a582f7f7f792c5de0571b0",
14370  "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
14371  "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
14372  "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
14373  "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
14374  "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
14375  "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
14376).map(colors);
14377
14378var RdBu = ramp(scheme$4);
14379
14380var scheme$5 = new Array(3).concat(
14381  "ef8a62ffffff999999",
14382  "ca0020f4a582bababa404040",
14383  "ca0020f4a582ffffffbababa404040",
14384  "b2182bef8a62fddbc7e0e0e09999994d4d4d",
14385  "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
14386  "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
14387  "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
14388  "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
14389  "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
14390).map(colors);
14391
14392var RdGy = ramp(scheme$5);
14393
14394var scheme$6 = new Array(3).concat(
14395  "fc8d59ffffbf91bfdb",
14396  "d7191cfdae61abd9e92c7bb6",
14397  "d7191cfdae61ffffbfabd9e92c7bb6",
14398  "d73027fc8d59fee090e0f3f891bfdb4575b4",
14399  "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
14400  "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
14401  "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
14402  "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
14403  "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
14404).map(colors);
14405
14406var RdYlBu = ramp(scheme$6);
14407
14408var scheme$7 = new Array(3).concat(
14409  "fc8d59ffffbf91cf60",
14410  "d7191cfdae61a6d96a1a9641",
14411  "d7191cfdae61ffffbfa6d96a1a9641",
14412  "d73027fc8d59fee08bd9ef8b91cf601a9850",
14413  "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
14414  "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
14415  "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
14416  "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
14417  "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
14418).map(colors);
14419
14420var RdYlGn = ramp(scheme$7);
14421
14422var scheme$8 = new Array(3).concat(
14423  "fc8d59ffffbf99d594",
14424  "d7191cfdae61abdda42b83ba",
14425  "d7191cfdae61ffffbfabdda42b83ba",
14426  "d53e4ffc8d59fee08be6f59899d5943288bd",
14427  "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
14428  "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
14429  "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
14430  "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
14431  "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
14432).map(colors);
14433
14434var Spectral = ramp(scheme$8);
14435
14436var scheme$9 = new Array(3).concat(
14437  "e5f5f999d8c92ca25f",
14438  "edf8fbb2e2e266c2a4238b45",
14439  "edf8fbb2e2e266c2a42ca25f006d2c",
14440  "edf8fbccece699d8c966c2a42ca25f006d2c",
14441  "edf8fbccece699d8c966c2a441ae76238b45005824",
14442  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
14443  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
14444).map(colors);
14445
14446var BuGn = ramp(scheme$9);
14447
14448var scheme$a = new Array(3).concat(
14449  "e0ecf49ebcda8856a7",
14450  "edf8fbb3cde38c96c688419d",
14451  "edf8fbb3cde38c96c68856a7810f7c",
14452  "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
14453  "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
14454  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
14455  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
14456).map(colors);
14457
14458var BuPu = ramp(scheme$a);
14459
14460var scheme$b = new Array(3).concat(
14461  "e0f3dba8ddb543a2ca",
14462  "f0f9e8bae4bc7bccc42b8cbe",
14463  "f0f9e8bae4bc7bccc443a2ca0868ac",
14464  "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
14465  "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
14466  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
14467  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
14468).map(colors);
14469
14470var GnBu = ramp(scheme$b);
14471
14472var scheme$c = new Array(3).concat(
14473  "fee8c8fdbb84e34a33",
14474  "fef0d9fdcc8afc8d59d7301f",
14475  "fef0d9fdcc8afc8d59e34a33b30000",
14476  "fef0d9fdd49efdbb84fc8d59e34a33b30000",
14477  "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
14478  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
14479  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
14480).map(colors);
14481
14482var OrRd = ramp(scheme$c);
14483
14484var scheme$d = new Array(3).concat(
14485  "ece2f0a6bddb1c9099",
14486  "f6eff7bdc9e167a9cf02818a",
14487  "f6eff7bdc9e167a9cf1c9099016c59",
14488  "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
14489  "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
14490  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
14491  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
14492).map(colors);
14493
14494var PuBuGn = ramp(scheme$d);
14495
14496var scheme$e = new Array(3).concat(
14497  "ece7f2a6bddb2b8cbe",
14498  "f1eef6bdc9e174a9cf0570b0",
14499  "f1eef6bdc9e174a9cf2b8cbe045a8d",
14500  "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
14501  "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
14502  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
14503  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
14504).map(colors);
14505
14506var PuBu = ramp(scheme$e);
14507
14508var scheme$f = new Array(3).concat(
14509  "e7e1efc994c7dd1c77",
14510  "f1eef6d7b5d8df65b0ce1256",
14511  "f1eef6d7b5d8df65b0dd1c77980043",
14512  "f1eef6d4b9dac994c7df65b0dd1c77980043",
14513  "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
14514  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
14515  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
14516).map(colors);
14517
14518var PuRd = ramp(scheme$f);
14519
14520var scheme$g = new Array(3).concat(
14521  "fde0ddfa9fb5c51b8a",
14522  "feebe2fbb4b9f768a1ae017e",
14523  "feebe2fbb4b9f768a1c51b8a7a0177",
14524  "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
14525  "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
14526  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
14527  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
14528).map(colors);
14529
14530var RdPu = ramp(scheme$g);
14531
14532var scheme$h = new Array(3).concat(
14533  "edf8b17fcdbb2c7fb8",
14534  "ffffcca1dab441b6c4225ea8",
14535  "ffffcca1dab441b6c42c7fb8253494",
14536  "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
14537  "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
14538  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
14539  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
14540).map(colors);
14541
14542var YlGnBu = ramp(scheme$h);
14543
14544var scheme$i = new Array(3).concat(
14545  "f7fcb9addd8e31a354",
14546  "ffffccc2e69978c679238443",
14547  "ffffccc2e69978c67931a354006837",
14548  "ffffccd9f0a3addd8e78c67931a354006837",
14549  "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
14550  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
14551  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
14552).map(colors);
14553
14554var YlGn = ramp(scheme$i);
14555
14556var scheme$j = new Array(3).concat(
14557  "fff7bcfec44fd95f0e",
14558  "ffffd4fed98efe9929cc4c02",
14559  "ffffd4fed98efe9929d95f0e993404",
14560  "ffffd4fee391fec44ffe9929d95f0e993404",
14561  "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
14562  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
14563  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
14564).map(colors);
14565
14566var YlOrBr = ramp(scheme$j);
14567
14568var scheme$k = new Array(3).concat(
14569  "ffeda0feb24cf03b20",
14570  "ffffb2fecc5cfd8d3ce31a1c",
14571  "ffffb2fecc5cfd8d3cf03b20bd0026",
14572  "ffffb2fed976feb24cfd8d3cf03b20bd0026",
14573  "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
14574  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
14575  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
14576).map(colors);
14577
14578var YlOrRd = ramp(scheme$k);
14579
14580var scheme$l = new Array(3).concat(
14581  "deebf79ecae13182bd",
14582  "eff3ffbdd7e76baed62171b5",
14583  "eff3ffbdd7e76baed63182bd08519c",
14584  "eff3ffc6dbef9ecae16baed63182bd08519c",
14585  "eff3ffc6dbef9ecae16baed64292c62171b5084594",
14586  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
14587  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
14588).map(colors);
14589
14590var Blues = ramp(scheme$l);
14591
14592var scheme$m = new Array(3).concat(
14593  "e5f5e0a1d99b31a354",
14594  "edf8e9bae4b374c476238b45",
14595  "edf8e9bae4b374c47631a354006d2c",
14596  "edf8e9c7e9c0a1d99b74c47631a354006d2c",
14597  "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
14598  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
14599  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
14600).map(colors);
14601
14602var Greens = ramp(scheme$m);
14603
14604var scheme$n = new Array(3).concat(
14605  "f0f0f0bdbdbd636363",
14606  "f7f7f7cccccc969696525252",
14607  "f7f7f7cccccc969696636363252525",
14608  "f7f7f7d9d9d9bdbdbd969696636363252525",
14609  "f7f7f7d9d9d9bdbdbd969696737373525252252525",
14610  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
14611  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
14612).map(colors);
14613
14614var Greys = ramp(scheme$n);
14615
14616var scheme$o = new Array(3).concat(
14617  "efedf5bcbddc756bb1",
14618  "f2f0f7cbc9e29e9ac86a51a3",
14619  "f2f0f7cbc9e29e9ac8756bb154278f",
14620  "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
14621  "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
14622  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
14623  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
14624).map(colors);
14625
14626var Purples = ramp(scheme$o);
14627
14628var scheme$p = new Array(3).concat(
14629  "fee0d2fc9272de2d26",
14630  "fee5d9fcae91fb6a4acb181d",
14631  "fee5d9fcae91fb6a4ade2d26a50f15",
14632  "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
14633  "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
14634  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
14635  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
14636).map(colors);
14637
14638var Reds = ramp(scheme$p);
14639
14640var scheme$q = new Array(3).concat(
14641  "fee6cefdae6be6550d",
14642  "feeddefdbe85fd8d3cd94701",
14643  "feeddefdbe85fd8d3ce6550da63603",
14644  "feeddefdd0a2fdae6bfd8d3ce6550da63603",
14645  "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
14646  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
14647  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
14648).map(colors);
14649
14650var Oranges = ramp(scheme$q);
14651
14652function cividis(t) {
14653  t = Math.max(0, Math.min(1, t));
14654  return "rgb("
14655      + Math.max(0, Math.min(255, Math.round(-4.54 - t * (35.34 - t * (2381.73 - t * (6402.7 - t * (7024.72 - t * 2710.57))))))) + ", "
14656      + Math.max(0, Math.min(255, Math.round(32.49 + t * (170.73 + t * (52.82 - t * (131.46 - t * (176.58 - t * 67.37))))))) + ", "
14657      + Math.max(0, Math.min(255, Math.round(81.24 + t * (442.36 - t * (2482.43 - t * (6167.24 - t * (6614.94 - t * 2475.67)))))))
14658      + ")";
14659}
14660
14661var cubehelix$3 = cubehelixLong(cubehelix(300, 0.5, 0.0), cubehelix(-240, 0.5, 1.0));
14662
14663var warm = cubehelixLong(cubehelix(-100, 0.75, 0.35), cubehelix(80, 1.50, 0.8));
14664
14665var cool = cubehelixLong(cubehelix(260, 0.75, 0.35), cubehelix(80, 1.50, 0.8));
14666
14667var c = cubehelix();
14668
14669function rainbow(t) {
14670  if (t < 0 || t > 1) t -= Math.floor(t);
14671  var ts = Math.abs(t - 0.5);
14672  c.h = 360 * t - 100;
14673  c.s = 1.5 - 1.5 * ts;
14674  c.l = 0.8 - 0.9 * ts;
14675  return c + "";
14676}
14677
14678var c$1 = rgb(),
14679    pi_1_3 = Math.PI / 3,
14680    pi_2_3 = Math.PI * 2 / 3;
14681
14682function sinebow(t) {
14683  var x;
14684  t = (0.5 - t) * Math.PI;
14685  c$1.r = 255 * (x = Math.sin(t)) * x;
14686  c$1.g = 255 * (x = Math.sin(t + pi_1_3)) * x;
14687  c$1.b = 255 * (x = Math.sin(t + pi_2_3)) * x;
14688  return c$1 + "";
14689}
14690
14691function turbo(t) {
14692  t = Math.max(0, Math.min(1, t));
14693  return "rgb("
14694      + Math.max(0, Math.min(255, Math.round(34.61 + t * (1172.33 - t * (10793.56 - t * (33300.12 - t * (38394.49 - t * 14825.05))))))) + ", "
14695      + Math.max(0, Math.min(255, Math.round(23.31 + t * (557.33 + t * (1225.33 - t * (3574.96 - t * (1073.77 + t * 707.56))))))) + ", "
14696      + Math.max(0, Math.min(255, Math.round(27.2 + t * (3211.1 - t * (15327.97 - t * (27814 - t * (22569.18 - t * 6838.66)))))))
14697      + ")";
14698}
14699
14700function ramp$1(range) {
14701  var n = range.length;
14702  return function(t) {
14703    return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
14704  };
14705}
14706
14707var viridis = ramp$1(colors("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
14708
14709var magma = ramp$1(colors("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb8
vendor: 7,404 bytes, lines 14709-14870
147091febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));
14710
14711var inferno = ramp$1(colors("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4"));
14712
14713var plasma = ramp$1(colors("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
14714
14715function constant$b(x) {
14716  return function constant() {
14717    return x;
14718  };
14719}
14720
14721var abs$1 = Math.abs;
14722var atan2$1 = Math.atan2;
14723var cos$2 = Math.cos;
14724var max$2 = Math.max;
14725var min$1 = Math.min;
14726var sin$2 = Math.sin;
14727var sqrt$2 = Math.sqrt;
14728
14729var epsilon$3 = 1e-12;
14730var pi$4 = Math.PI;
14731var halfPi$3 = pi$4 / 2;
14732var tau$4 = 2 * pi$4;
14733
14734function acos$1(x) {
14735  return x > 1 ? 0 : x < -1 ? pi$4 : Math.acos(x);
14736}
14737
14738function asin$1(x) {
14739  return x >= 1 ? halfPi$3 : x <= -1 ? -halfPi$3 : Math.asin(x);
14740}
14741
14742function arcInnerRadius(d) {
14743  return d.innerRadius;
14744}
14745
14746function arcOuterRadius(d) {
14747  return d.outerRadius;
14748}
14749
14750function arcStartAngle(d) {
14751  return d.startAngle;
14752}
14753
14754function arcEndAngle(d) {
14755  return d.endAngle;
14756}
14757
14758function arcPadAngle(d) {
14759  return d && d.padAngle; // Note: optional!
14760}
14761
14762function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
14763  var x10 = x1 - x0, y10 = y1 - y0,
14764      x32 = x3 - x2, y32 = y3 - y2,
14765      t = y32 * x10 - x32 * y10;
14766  if (t * t < epsilon$3) return;
14767  t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
14768  return [x0 + t * x10, y0 + t * y10];
14769}
14770
14771// Compute perpendicular offset line of length rc.
14772// http://mathworld.wolfram.com/Circle-LineIntersection.html
14773function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
14774  var x01 = x0 - x1,
14775      y01 = y0 - y1,
14776      lo = (cw ? rc : -rc) / sqrt$2(x01 * x01 + y01 * y01),
14777      ox = lo * y01,
14778      oy = -lo * x01,
14779      x11 = x0 + ox,
14780      y11 = y0 + oy,
14781      x10 = x1 + ox,
14782      y10 = y1 + oy,
14783      x00 = (x11 + x10) / 2,
14784      y00 = (y11 + y10) / 2,
14785      dx = x10 - x11,
14786      dy = y10 - y11,
14787      d2 = dx * dx + dy * dy,
14788      r = r1 - rc,
14789      D = x11 * y10 - x10 * y11,
14790      d = (dy < 0 ? -1 : 1) * sqrt$2(max$2(0, r * r * d2 - D * D)),
14791      cx0 = (D * dy - dx * d) / d2,
14792      cy0 = (-D * dx - dy * d) / d2,
14793      cx1 = (D * dy + dx * d) / d2,
14794      cy1 = (-D * dx + dy * d) / d2,
14795      dx0 = cx0 - x00,
14796      dy0 = cy0 - y00,
14797      dx1 = cx1 - x00,
14798      dy1 = cy1 - y00;
14799
14800  // Pick the closer of the two intersection points.
14801  // TODO Is there a faster way to determine which intersection to use?
14802  if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
14803
14804  return {
14805    cx: cx0,
14806    cy: cy0,
14807    x01: -ox,
14808    y01: -oy,
14809    x11: cx0 * (r1 / r - 1),
14810    y11: cy0 * (r1 / r - 1)
14811  };
14812}
14813
14814function arc() {
14815  var innerRadius = arcInnerRadius,
14816      outerRadius = arcOuterRadius,
14817      cornerRadius = constant$b(0),
14818      padRadius = null,
14819      startAngle = arcStartAngle,
14820      endAngle = arcEndAngle,
14821      padAngle = arcPadAngle,
14822      context = null;
14823
14824  function arc() {
14825    var buffer,
14826        r,
14827        r0 = +innerRadius.apply(this, arguments),
14828        r1 = +outerRadius.apply(this, arguments),
14829        a0 = startAngle.apply(this, arguments) - halfPi$3,
14830        a1 = endAngle.apply(this, arguments) - halfPi$3,
14831        da = abs$1(a1 - a0),
14832        cw = a1 > a0;
14833
14834    if (!context) context = buffer = path();
14835
14836    // Ensure that the outer radius is always larger than the inner radius.
14837    if (r1 < r0) r = r1, r1 = r0, r0 = r;
14838
14839    // Is it a point?
14840    if (!(r1 > epsilon$3)) context.moveTo(0, 0);
14841
14842    // Or is it a circle or annulus?
14843    else if (da > tau$4 - epsilon$3) {
14844      context.moveTo(r1 * cos$2(a0), r1 * sin$2(a0));
14845      context.arc(0, 0, r1, a0, a1, !cw);
14846      if (r0 > epsilon$3) {
14847        context.moveTo(r0 * cos$2(a1), r0 * sin$2(a1));
14848        context.arc(0, 0, r0, a1, a0, cw);
14849      }
14850    }
14851
14852    // Or is it a circular or annular sector?
14853    else {
14854      var a01 = a0,
14855          a11 = a1,
14856          a00 = a0,
14857          a10 = a1,
14858          da0 = da,
14859          da1 = da,
14860          ap = padAngle.apply(this, arguments) / 2,
14861          rp = (ap > epsilon$3) && (padRadius ? +padRadius.apply(this, arguments) : sqrt$2(r0 * r0 + r1 * r1)),
14862          rc = min$1(abs$1(r1 - r0) / 2, +cornerRadius.apply(this, arguments)),
14863          rc0 = rc,
14864          rc1 = rc,
14865          t0,
14866          t1;
14867
14868      // Apply padding? Note that since r1 ≥ r0, da1 ≥ da0.
14869      if (rp > epsilon$3) {
14870        var p0 = asin$1(rp / r0 * sin$2(ap)),
vendor: 25,934 bytes, lines 14871-15831
14871            p1 = asin$1(rp / r1 * sin$2(ap));
14872        if ((da0 -= p0 * 2) > epsilon$3) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0;
14873        else da0 = 0, a00 = a10 = (a0 + a1) / 2;
14874        if ((da1 -= p1 * 2) > epsilon$3) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1;
14875        else da1 = 0, a01 = a11 = (a0 + a1) / 2;
14876      }
14877
14878      var x01 = r1 * cos$2(a01),
14879          y01 = r1 * sin$2(a01),
14880          x10 = r0 * cos$2(a10),
14881          y10 = r0 * sin$2(a10);
14882
14883      // Apply rounded corners?
14884      if (rc > epsilon$3) {
14885        var x11 = r1 * cos$2(a11),
14886            y11 = r1 * sin$2(a11),
14887            x00 = r0 * cos$2(a00),
14888            y00 = r0 * sin$2(a00),
14889            oc;
14890
14891        // Restrict the corner radius according to the sector angle.
14892        if (da < pi$4 && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) {
14893          var ax = x01 - oc[0],
14894              ay = y01 - oc[1],
14895              bx = x11 - oc[0],
14896              by = y11 - oc[1],
14897              kc = 1 / sin$2(acos$1((ax * bx + ay * by) / (sqrt$2(ax * ax + ay * ay) * sqrt$2(bx * bx + by * by))) / 2),
14898              lc = sqrt$2(oc[0] * oc[0] + oc[1] * oc[1]);
14899          rc0 = min$1(rc, (r0 - lc) / (kc - 1));
14900          rc1 = min$1(rc, (r1 - lc) / (kc + 1));
14901        }
14902      }
14903
14904      // Is the sector collapsed to a line?
14905      if (!(da1 > epsilon$3)) context.moveTo(x01, y01);
14906
14907      // Does the sector’s outer ring have rounded corners?
14908      else if (rc1 > epsilon$3) {
14909        t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
14910        t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
14911
14912        context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
14913
14914        // Have the corners merged?
14915        if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2$1(t0.y01, t0.x01), atan2$1(t1.y01, t1.x01), !cw);
14916
14917        // Otherwise, draw the two corners and the ring.
14918        else {
14919          context.arc(t0.cx, t0.cy, rc1, atan2$1(t0.y01, t0.x01), atan2$1(t0.y11, t0.x11), !cw);
14920          context.arc(0, 0, r1, atan2$1(t0.cy + t0.y11, t0.cx + t0.x11), atan2$1(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
14921          context.arc(t1.cx, t1.cy, rc1, atan2$1(t1.y11, t1.x11), atan2$1(t1.y01, t1.x01), !cw);
14922        }
14923      }
14924
14925      // Or is the outer ring just a circular arc?
14926      else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
14927
14928      // Is there no inner ring, and it’s a circular sector?
14929      // Or perhaps it’s an annular sector collapsed due to padding?
14930      if (!(r0 > epsilon$3) || !(da0 > epsilon$3)) context.lineTo(x10, y10);
14931
14932      // Does the sector’s inner ring (or point) have rounded corners?
14933      else if (rc0 > epsilon$3) {
14934        t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
14935        t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
14936
14937        context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
14938
14939        // Have the corners merged?
14940        if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2$1(t0.y01, t0.x01), atan2$1(t1.y01, t1.x01), !cw);
14941
14942        // Otherwise, draw the two corners and the ring.
14943        else {
14944          context.arc(t0.cx, t0.cy, rc0, atan2$1(t0.y01, t0.x01), atan2$1(t0.y11, t0.x11), !cw);
14945          context.arc(0, 0, r0, atan2$1(t0.cy + t0.y11, t0.cx + t0.x11), atan2$1(t1.cy + t1.y11, t1.cx + t1.x11), cw);
14946          context.arc(t1.cx, t1.cy, rc0, atan2$1(t1.y11, t1.x11), atan2$1(t1.y01, t1.x01), !cw);
14947        }
14948      }
14949
14950      // Or is the inner ring just a circular arc?
14951      else context.arc(0, 0, r0, a10, a00, cw);
14952    }
14953
14954    context.closePath();
14955
14956    if (buffer) return context = null, buffer + "" || null;
14957  }
14958
14959  arc.centroid = function() {
14960    var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2,
14961        a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi$4 / 2;
14962    return [cos$2(a) * r, sin$2(a) * r];
14963  };
14964
14965  arc.innerRadius = function(_) {
14966    return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant$b(+_), arc) : innerRadius;
14967  };
14968
14969  arc.outerRadius = function(_) {
14970    return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant$b(+_), arc) : outerRadius;
14971  };
14972
14973  arc.cornerRadius = function(_) {
14974    return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant$b(+_), arc) : cornerRadius;
14975  };
14976
14977  arc.padRadius = function(_) {
14978    return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant$b(+_), arc) : padRadius;
14979  };
14980
14981  arc.startAngle = function(_) {
14982    return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$b(+_), arc) : startAngle;
14983  };
14984
14985  arc.endAngle = function(_) {
14986    return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$b(+_), arc) : endAngle;
14987  };
14988
14989  arc.padAngle = function(_) {
14990    return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant$b(+_), arc) : padAngle;
14991  };
14992
14993  arc.context = function(_) {
14994    return arguments.length ? ((context = _ == null ? null : _), arc) : context;
14995  };
14996
14997  return arc;
14998}
14999
15000function Linear(context) {
15001  this._context = context;
15002}
15003
15004Linear.prototype = {
15005  areaStart: function() {
15006    this._line = 0;
15007  },
15008  areaEnd: function() {
15009    this._line = NaN;
15010  },
15011  lineStart: function() {
15012    this._point = 0;
15013  },
15014  lineEnd: function() {
15015    if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
15016    this._line = 1 - this._line;
15017  },
15018  point: function(x, y) {
15019    x = +x, y = +y;
15020    switch (this._point) {
15021      case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
15022      case 1: this._point = 2; // proceed
15023      default: this._context.lineTo(x, y); break;
15024    }
15025  }
15026};
15027
15028function curveLinear(context) {
15029  return new Linear(context);
15030}
15031
15032function x$3(p) {
15033  return p[0];
15034}
15035
15036function y$3(p) {
15037  return p[1];
15038}
15039
15040function line() {
15041  var x = x$3,
15042      y = y$3,
15043      defined = constant$b(true),
15044      context = null,
15045      curve = curveLinear,
15046      output = null;
15047
15048  function line(data) {
15049    var i,
15050        n = data.length,
15051        d,
15052        defined0 = false,
15053        buffer;
15054
15055    if (context == null) output = curve(buffer = path());
15056
15057    for (i = 0; i <= n; ++i) {
15058      if (!(i < n && defined(d = data[i], i, data)) === defined0) {
15059        if (defined0 = !defined0) output.lineStart();
15060        else output.lineEnd();
15061      }
15062      if (defined0) output.point(+x(d, i, data), +y(d, i, data));
15063    }
15064
15065    if (buffer) return output = null, buffer + "" || null;
15066  }
15067
15068  line.x = function(_) {
15069    return arguments.length ? (x = typeof _ === "function" ? _ : constant$b(+_), line) : x;
15070  };
15071
15072  line.y = function(_) {
15073    return arguments.length ? (y = typeof _ === "function" ? _ : constant$b(+_), line) : y;
15074  };
15075
15076  line.defined = function(_) {
15077    return arguments.length ? (defined = typeof _ === "function" ? _ : constant$b(!!_), line) : defined;
15078  };
15079
15080  line.curve = function(_) {
15081    return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve;
15082  };
15083
15084  line.context = function(_) {
15085    return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context;
15086  };
15087
15088  return line;
15089}
15090
15091function area$3() {
15092  var x0 = x$3,
15093      x1 = null,
15094      y0 = constant$b(0),
15095      y1 = y$3,
15096      defined = constant$b(true),
15097      context = null,
15098      curve = curveLinear,
15099      output = null;
15100
15101  function area(data) {
15102    var i,
15103        j,
15104        k,
15105        n = data.length,
15106        d,
15107        defined0 = false,
15108        buffer,
15109        x0z = new Array(n),
15110        y0z = new Array(n);
15111
15112    if (context == null) output = curve(buffer = path());
15113
15114    for (i = 0; i <= n; ++i) {
15115      if (!(i < n && defined(d = data[i], i, data)) === defined0) {
15116        if (defined0 = !defined0) {
15117          j = i;
15118          output.areaStart();
15119          output.lineStart();
15120        } else {
15121          output.lineEnd();
15122          output.lineStart();
15123          for (k = i - 1; k >= j; --k) {
15124            output.point(x0z[k], y0z[k]);
15125          }
15126          output.lineEnd();
15127          output.areaEnd();
15128        }
15129      }
15130      if (defined0) {
15131        x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data);
15132        output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]);
15133      }
15134    }
15135
15136    if (buffer) return output = null, buffer + "" || null;
15137  }
15138
15139  function arealine() {
15140    return line().defined(defined).curve(curve).context(context);
15141  }
15142
15143  area.x = function(_) {
15144    return arguments.length ? (x0 = typeof _ === "function" ? _ : constant$b(+_), x1 = null, area) : x0;
15145  };
15146
15147  area.x0 = function(_) {
15148    return arguments.length ? (x0 = typeof _ === "function" ? _ : constant$b(+_), area) : x0;
15149  };
15150
15151  area.x1 = function(_) {
15152    return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant$b(+_), area) : x1;
15153  };
15154
15155  area.y = function(_) {
15156    return arguments.length ? (y0 = typeof _ === "function" ? _ : constant$b(+_), y1 = null, area) : y0;
15157  };
15158
15159  area.y0 = function(_) {
15160    return arguments.length ? (y0 = typeof _ === "function" ? _ : constant$b(+_), area) : y0;
15161  };
15162
15163  area.y1 = function(_) {
15164    return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant$b(+_), area) : y1;
15165  };
15166
15167  area.lineX0 =
15168  area.lineY0 = function() {
15169    return arealine().x(x0).y(y0);
15170  };
15171
15172  area.lineY1 = function() {
15173    return arealine().x(x0).y(y1);
15174  };
15175
15176  area.lineX1 = function() {
15177    return arealine().x(x1).y(y0);
15178  };
15179
15180  area.defined = function(_) {
15181    return arguments.length ? (defined = typeof _ === "function" ? _ : constant$b(!!_), area) : defined;
15182  };
15183
15184  area.curve = function(_) {
15185    return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve;
15186  };
15187
15188  area.context = function(_) {
15189    return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context;
15190  };
15191
15192  return area;
15193}
15194
15195function descending$1(a, b) {
15196  return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
15197}
15198
15199function identity$8(d) {
15200  return d;
15201}
15202
15203function pie() {
15204  var value = identity$8,
15205      sortValues = descending$1,
15206      sort = null,
15207      startAngle = constant$b(0),
15208      endAngle = constant$b(tau$4),
15209      padAngle = constant$b(0);
15210
15211  function pie(data) {
15212    var i,
15213        n = data.length,
15214        j,
15215        k,
15216        sum = 0,
15217        index = new Array(n),
15218        arcs = new Array(n),
15219        a0 = +startAngle.apply(this, arguments),
15220        da = Math.min(tau$4, Math.max(-tau$4, endAngle.apply(this, arguments) - a0)),
15221        a1,
15222        p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)),
15223        pa = p * (da < 0 ? -1 : 1),
15224        v;
15225
15226    for (i = 0; i < n; ++i) {
15227      if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {
15228        sum += v;
15229      }
15230    }
15231
15232    // Optionally sort the arcs by previously-computed values or by data.
15233    if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); });
15234    else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); });
15235
15236    // Compute the arcs! They are stored in the original data's order.
15237    for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {
15238      j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
15239        data: data[j],
15240        index: i,
15241        value: v,
15242        startAngle: a0,
15243        endAngle: a1,
15244        padAngle: p
15245      };
15246    }
15247
15248    return arcs;
15249  }
15250
15251  pie.value = function(_) {
15252    return arguments.length ? (value = typeof _ === "function" ? _ : constant$b(+_), pie) : value;
15253  };
15254
15255  pie.sortValues = function(_) {
15256    return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
15257  };
15258
15259  pie.sort = function(_) {
15260    return arguments.length ? (sort = _, sortValues = null, pie) : sort;
15261  };
15262
15263  pie.startAngle = function(_) {
15264    return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$b(+_), pie) : startAngle;
15265  };
15266
15267  pie.endAngle = function(_) {
15268    return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$b(+_), pie) : endAngle;
15269  };
15270
15271  pie.padAngle = function(_) {
15272    return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant$b(+_), pie) : padAngle;
15273  };
15274
15275  return pie;
15276}
15277
15278var curveRadialLinear = curveRadial(curveLinear);
15279
15280function Radial(curve) {
15281  this._curve = curve;
15282}
15283
15284Radial.prototype = {
15285  areaStart: function() {
15286    this._curve.areaStart();
15287  },
15288  areaEnd: function() {
15289    this._curve.areaEnd();
15290  },
15291  lineStart: function() {
15292    this._curve.lineStart();
15293  },
15294  lineEnd: function() {
15295    this._curve.lineEnd();
15296  },
15297  point: function(a, r) {
15298    this._curve.point(r * Math.sin(a), r * -Math.cos(a));
15299  }
15300};
15301
15302function curveRadial(curve) {
15303
15304  function radial(context) {
15305    return new Radial(curve(context));
15306  }
15307
15308  radial._curve = curve;
15309
15310  return radial;
15311}
15312
15313function lineRadial(l) {
15314  var c = l.curve;
15315
15316  l.angle = l.x, delete l.x;
15317  l.radius = l.y, delete l.y;
15318
15319  l.curve = function(_) {
15320    return arguments.length ? c(curveRadial(_)) : c()._curve;
15321  };
15322
15323  return l;
15324}
15325
15326function lineRadial$1() {
15327  return lineRadial(line().curve(curveRadialLinear));
15328}
15329
15330function areaRadial() {
15331  var a = area$3().curve(curveRadialLinear),
15332      c = a.curve,
15333      x0 = a.lineX0,
15334      x1 = a.lineX1,
15335      y0 = a.lineY0,
15336      y1 = a.lineY1;
15337
15338  a.angle = a.x, delete a.x;
15339  a.startAngle = a.x0, delete a.x0;
15340  a.endAngle = a.x1, delete a.x1;
15341  a.radius = a.y, delete a.y;
15342  a.innerRadius = a.y0, delete a.y0;
15343  a.outerRadius = a.y1, delete a.y1;
15344  a.lineStartAngle = function() { return lineRadial(x0()); }, delete a.lineX0;
15345  a.lineEndAngle = function() { return lineRadial(x1()); }, delete a.lineX1;
15346  a.lineInnerRadius = function() { return lineRadial(y0()); }, delete a.lineY0;
15347  a.lineOuterRadius = function() { return lineRadial(y1()); }, delete a.lineY1;
15348
15349  a.curve = function(_) {
15350    return arguments.length ? c(curveRadial(_)) : c()._curve;
15351  };
15352
15353  return a;
15354}
15355
15356function pointRadial(x, y) {
15357  return [(y = +y) * Math.cos(x -= Math.PI / 2), y * Math.sin(x)];
15358}
15359
15360var slice$6 = Array.prototype.slice;
15361
15362function linkSource(d) {
15363  return d.source;
15364}
15365
15366function linkTarget(d) {
15367  return d.target;
15368}
15369
15370function link$2(curve) {
15371  var source = linkSource,
15372      target = linkTarget,
15373      x = x$3,
15374      y = y$3,
15375      context = null;
15376
15377  function link() {
15378    var buffer, argv = slice$6.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);
15379    if (!context) context = buffer = path();
15380    curve(context, +x.apply(this, (argv[0] = s, argv)), +y.apply(this, argv), +x.apply(this, (argv[0] = t, argv)), +y.apply(this, argv));
15381    if (buffer) return context = null, buffer + "" || null;
15382  }
15383
15384  link.source = function(_) {
15385    return arguments.length ? (source = _, link) : source;
15386  };
15387
15388  link.target = function(_) {
15389    return arguments.length ? (target = _, link) : target;
15390  };
15391
15392  link.x = function(_) {
15393    return arguments.length ? (x = typeof _ === "function" ? _ : constant$b(+_), link) : x;
15394  };
15395
15396  link.y = function(_) {
15397    return arguments.length ? (y = typeof _ === "function" ? _ : constant$b(+_), link) : y;
15398  };
15399
15400  link.context = function(_) {
15401    return arguments.length ? ((context = _ == null ? null : _), link) : context;
15402  };
15403
15404  return link;
15405}
15406
15407function curveHorizontal(context, x0, y0, x1, y1) {
15408  context.moveTo(x0, y0);
15409  context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
15410}
15411
15412function curveVertical(context, x0, y0, x1, y1) {
15413  context.moveTo(x0, y0);
15414  context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);
15415}
15416
15417function curveRadial$1(context, x0, y0, x1, y1) {
15418  var p0 = pointRadial(x0, y0),
15419      p1 = pointRadial(x0, y0 = (y0 + y1) / 2),
15420      p2 = pointRadial(x1, y0),
15421      p3 = pointRadial(x1, y1);
15422  context.moveTo(p0[0], p0[1]);
15423  context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);
15424}
15425
15426function linkHorizontal() {
15427  return link$2(curveHorizontal);
15428}
15429
15430function linkVertical() {
15431  return link$2(curveVertical);
15432}
15433
15434function linkRadial() {
15435  var l = link$2(curveRadial$1);
15436  l.angle = l.x, delete l.x;
15437  l.radius = l.y, delete l.y;
15438  return l;
15439}
15440
15441var circle$2 = {
15442  draw: function(context, size) {
15443    var r = Math.sqrt(size / pi$4);
15444    context.moveTo(r, 0);
15445    context.arc(0, 0, r, 0, tau$4);
15446  }
15447};
15448
15449var cross$2 = {
15450  draw: function(context, size) {
15451    var r = Math.sqrt(size / 5) / 2;
15452    context.moveTo(-3 * r, -r);
15453    context.lineTo(-r, -r);
15454    context.lineTo(-r, -3 * r);
15455    context.lineTo(r, -3 * r);
15456    context.lineTo(r, -r);
15457    context.lineTo(3 * r, -r);
15458    context.lineTo(3 * r, r);
15459    context.lineTo(r, r);
15460    context.lineTo(r, 3 * r);
15461    context.lineTo(-r, 3 * r);
15462    context.lineTo(-r, r);
15463    context.lineTo(-3 * r, r);
15464    context.closePath();
15465  }
15466};
15467
15468var tan30 = Math.sqrt(1 / 3),
15469    tan30_2 = tan30 * 2;
15470
15471var diamond = {
15472  draw: function(context, size) {
15473    var y = Math.sqrt(size / tan30_2),
15474        x = y * tan30;
15475    context.moveTo(0, -y);
15476    context.lineTo(x, 0);
15477    context.lineTo(0, y);
15478    context.lineTo(-x, 0);
15479    context.closePath();
15480  }
15481};
15482
15483var ka = 0.89081309152928522810,
15484    kr = Math.sin(pi$4 / 10) / Math.sin(7 * pi$4 / 10),
15485    kx = Math.sin(tau$4 / 10) * kr,
15486    ky = -Math.cos(tau$4 / 10) * kr;
15487
15488var star = {
15489  draw: function(context, size) {
15490    var r = Math.sqrt(size * ka),
15491        x = kx * r,
15492        y = ky * r;
15493    context.moveTo(0, -r);
15494    context.lineTo(x, y);
15495    for (var i = 1; i < 5; ++i) {
15496      var a = tau$4 * i / 5,
15497          c = Math.cos(a),
15498          s = Math.sin(a);
15499      context.lineTo(s * r, -c * r);
15500      context.lineTo(c * x - s * y, s * x + c * y);
15501    }
15502    context.closePath();
15503  }
15504};
15505
15506var square = {
15507  draw: function(context, size) {
15508    var w = Math.sqrt(size),
15509        x = -w / 2;
15510    context.rect(x, x, w, w);
15511  }
15512};
15513
15514var sqrt3 = Math.sqrt(3);
15515
15516var triangle = {
15517  draw: function(context, size) {
15518    var y = -Math.sqrt(size / (sqrt3 * 3));
15519    context.moveTo(0, y * 2);
15520    context.lineTo(-sqrt3 * y, -y);
15521    context.lineTo(sqrt3 * y, -y);
15522    context.closePath();
15523  }
15524};
15525
15526var c$2 = -0.5,
15527    s = Math.sqrt(3) / 2,
15528    k = 1 / Math.sqrt(12),
15529    a = (k / 2 + 1) * 3;
15530
15531var wye = {
15532  draw: function(context, size) {
15533    var r = Math.sqrt(size / a),
15534        x0 = r / 2,
15535        y0 = r * k,
15536        x1 = x0,
15537        y1 = r * k + r,
15538        x2 = -x1,
15539        y2 = y1;
15540    context.moveTo(x0, y0);
15541    context.lineTo(x1, y1);
15542    context.lineTo(x2, y2);
15543    context.lineTo(c$2 * x0 - s * y0, s * x0 + c$2 * y0);
15544    context.lineTo(c$2 * x1 - s * y1, s * x1 + c$2 * y1);
15545    context.lineTo(c$2 * x2 - s * y2, s * x2 + c$2 * y2);
15546    context.lineTo(c$2 * x0 + s * y0, c$2 * y0 - s * x0);
15547    context.lineTo(c$2 * x1 + s * y1, c$2 * y1 - s * x1);
15548    context.lineTo(c$2 * x2 + s * y2, c$2 * y2 - s * x2);
15549    context.closePath();
15550  }
15551};
15552
15553var symbols = [
15554  circle$2,
15555  cross$2,
15556  diamond,
15557  square,
15558  star,
15559  triangle,
15560  wye
15561];
15562
15563function symbol() {
15564  var type = constant$b(circle$2),
15565      size = constant$b(64),
15566      context = null;
15567
15568  function symbol() {
15569    var buffer;
15570    if (!context) context = buffer = path();
15571    type.apply(this, arguments).draw(context, +size.apply(this, arguments));
15572    if (buffer) return context = null, buffer + "" || null;
15573  }
15574
15575  symbol.type = function(_) {
15576    return arguments.length ? (type = typeof _ === "function" ? _ : constant$b(_), symbol) : type;
15577  };
15578
15579  symbol.size = function(_) {
15580    return arguments.length ? (size = typeof _ === "function" ? _ : constant$b(+_), symbol) : size;
15581  };
15582
15583  symbol.context = function(_) {
15584    return arguments.length ? (context = _ == null ? null : _, symbol) : context;
15585  };
15586
15587  return symbol;
15588}
15589
15590function noop$3() {}
15591
15592function point$2(that, x, y) {
15593  that._context.bezierCurveTo(
15594    (2 * that._x0 + that._x1) / 3,
15595    (2 * that._y0 + that._y1) / 3,
15596    (that._x0 + 2 * that._x1) / 3,
15597    (that._y0 + 2 * that._y1) / 3,
15598    (that._x0 + 4 * that._x1 + x) / 6,
15599    (that._y0 + 4 * that._y1 + y) / 6
15600  );
15601}
15602
15603function Basis(context) {
15604  this._context = context;
15605}
15606
15607Basis.prototype = {
15608  areaStart: function() {
15609    this._line = 0;
15610  },
15611  areaEnd: function() {
15612    this._line = NaN;
15613  },
15614  lineStart: function() {
15615    this._x0 = this._x1 =
15616    this._y0 = this._y1 = NaN;
15617    this._point = 0;
15618  },
15619  lineEnd: function() {
15620    switch (this._point) {
15621      case 3: point$2(this, this._x1, this._y1); // proceed
15622      case 2: this._context.lineTo(this._x1, this._y1); break;
15623    }
15624    if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
15625    this._line = 1 - this._line;
15626  },
15627  point: function(x, y) {
15628    x = +x, y = +y;
15629    switch (this._point) {
15630      case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
15631      case 1: this._point = 2; break;
15632      case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // proceed
15633      default: point$2(this, x, y); break;
15634    }
15635    this._x0 = this._x1, this._x1 = x;
15636    this._y0 = this._y1, this._y1 = y;
15637  }
15638};
15639
15640function basis$2(context) {
15641  return new Basis(context);
15642}
15643
15644function BasisClosed(context) {
15645  this._context = context;
15646}
15647
15648BasisClosed.prototype = {
15649  areaStart: noop$3,
15650  areaEnd: noop$3,
15651  lineStart: function() {
15652    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 =
15653    this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN;
15654    this._point = 0;
15655  },
15656  lineEnd: function() {
15657    switch (this._point) {
15658      case 1: {
15659        this._context.moveTo(this._x2, this._y2);
15660        this._context.closePath();
15661        break;
15662      }
15663      case 2: {
15664        this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3);
15665        this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3);
15666        this._context.closePath();
15667        break;
15668      }
15669      case 3: {
15670        this.point(this._x2, this._y2);
15671        this.point(this._x3, this._y3);
15672        this.point(this._x4, this._y4);
15673        break;
15674      }
15675    }
15676  },
15677  point: function(x, y) {
15678    x = +x, y = +y;
15679    switch (this._point) {
15680      case 0: this._point = 1; this._x2 = x, this._y2 = y; break;
15681      case 1: this._point = 2; this._x3 = x, this._y3 = y; break;
15682      case 2: this._point = 3; this._x4 = x, this._y4 = y; this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6); break;
15683      default: point$2(this, x, y); break;
15684    }
15685    this._x0 = this._x1, this._x1 = x;
15686    this._y0 = this._y1, this._y1 = y;
15687  }
15688};
15689
15690function basisClosed$1(context) {
15691  return new BasisClosed(context);
15692}
15693
15694function BasisOpen(context) {
15695  this._context = context;
15696}
15697
15698BasisOpen.prototype = {
15699  areaStart: function() {
15700    this._line = 0;
15701  },
15702  areaEnd: function() {
15703    this._line = NaN;
15704  },
15705  lineStart: function() {
15706    this._x0 = this._x1 =
15707    this._y0 = this._y1 = NaN;
15708    this._point = 0;
15709  },
15710  lineEnd: function() {
15711    if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath();
15712    this._line = 1 - this._line;
15713  },
15714  point: function(x, y) {
15715    x = +x, y = +y;
15716    switch (this._point) {
15717      case 0: this._point = 1; break;
15718      case 1: this._point = 2; break;
15719      case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0); break;
15720      case 3: this._point = 4; // proceed
15721      default: point$2(this, x, y); break;
15722    }
15723    this._x0 = this._x1, this._x1 = x;
15724    this._y0 = this._y1, this._y1 = y;
15725  }
15726};
15727
15728function basisOpen(context) {
15729  return new BasisOpen(context);
15730}
15731
15732function Bundle(context, beta) {
15733  this._basis = new Basis(context);
15734  this._beta = beta;
15735}
15736
15737Bundle.prototype = {
15738  lineStart: function() {
15739    this._x = [];
15740    this._y = [];
15741    this._basis.lineStart();
15742  },
15743  lineEnd: function() {
15744    var x = this._x,
15745        y = this._y,
15746        j = x.length - 1;
15747
15748    if (j > 0) {
15749      var x0 = x[0],
15750          y0 = y[0],
15751          dx = x[j] - x0,
15752          dy = y[j] - y0,
15753          i = -1,
15754          t;
15755
15756      while (++i <= j) {
15757        t = i / j;
15758        this._basis.point(
15759          this._beta * x[i] + (1 - this._beta) * (x0 + t * dx),
15760          this._beta * y[i] + (1 - this._beta) * (y0 + t * dy)
15761        );
15762      }
15763    }
15764
15765    this._x = this._y = null;
15766    this._basis.lineEnd();
15767  },
15768  point: function(x, y) {
15769    this._x.push(+x);
15770    this._y.push(+y);
15771  }
15772};
15773
15774var bundle = (function custom(beta) {
15775
15776  function bundle(context) {
15777    return beta === 1 ? new Basis(context) : new Bundle(context, beta);
15778  }
15779
15780  bundle.beta = function(beta) {
15781    return custom(+beta);
15782  };
15783
15784  return bundle;
15785})(0.85);
15786
15787function point$3(that, x, y) {
15788  that._context.bezierCurveTo(
15789    that._x1 + that._k * (that._x2 - that._x0),
15790    that._y1 + that._k * (that._y2 - that._y0),
15791    that._x2 + that._k * (that._x1 - x),
15792    that._y2 + that._k * (that._y1 - y),
15793    that._x2,
15794    that._y2
15795  );
15796}
15797
15798function Cardinal(context, tension) {
15799  this._context = context;
15800  this._k = (1 - tension) / 6;
15801}
15802
15803Cardinal.prototype = {
15804  areaStart: function() {
15805    this._line = 0;
15806  },
15807  areaEnd: function() {
15808    this._line = NaN;
15809  },
15810  lineStart: function() {
15811    this._x0 = this._x1 = this._x2 =
15812    this._y0 = this._y1 = this._y2 = NaN;
15813    this._point = 0;
15814  },
15815  lineEnd: function() {
15816    switch (this._point) {
15817      case 2: this._context.lineTo(this._x2, this._y2); break;
15818      case 3: point$3(this, this._x1, this._y1); break;
15819    }
15820    if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
15821    this._line = 1 - this._line;
15822  },
15823  point: function(x, y) {
15824    x = +x, y = +y;
15825    switch (this._point) {
15826      case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
15827      case 1: this._point = 2; this._x1 = x, this._y1 = y; break;
15828      case 2: this._point = 3; // proceed
15829      default: point$3(this, x, y); break;
15830    }
15831    this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
vendor: 14,565 bytes, lines 15832-16358
15832    this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15833  }
15834};
15835
15836var cardinal = (function custom(tension) {
15837
15838  function cardinal(context) {
15839    return new Cardinal(context, tension);
15840  }
15841
15842  cardinal.tension = function(tension) {
15843    return custom(+tension);
15844  };
15845
15846  return cardinal;
15847})(0);
15848
15849function CardinalClosed(context, tension) {
15850  this._context = context;
15851  this._k = (1 - tension) / 6;
15852}
15853
15854CardinalClosed.prototype = {
15855  areaStart: noop$3,
15856  areaEnd: noop$3,
15857  lineStart: function() {
15858    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 =
15859    this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
15860    this._point = 0;
15861  },
15862  lineEnd: function() {
15863    switch (this._point) {
15864      case 1: {
15865        this._context.moveTo(this._x3, this._y3);
15866        this._context.closePath();
15867        break;
15868      }
15869      case 2: {
15870        this._context.lineTo(this._x3, this._y3);
15871        this._context.closePath();
15872        break;
15873      }
15874      case 3: {
15875        this.point(this._x3, this._y3);
15876        this.point(this._x4, this._y4);
15877        this.point(this._x5, this._y5);
15878        break;
15879      }
15880    }
15881  },
15882  point: function(x, y) {
15883    x = +x, y = +y;
15884    switch (this._point) {
15885      case 0: this._point = 1; this._x3 = x, this._y3 = y; break;
15886      case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break;
15887      case 2: this._point = 3; this._x5 = x, this._y5 = y; break;
15888      default: point$3(this, x, y); break;
15889    }
15890    this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
15891    this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15892  }
15893};
15894
15895var cardinalClosed = (function custom(tension) {
15896
15897  function cardinal(context) {
15898    return new CardinalClosed(context, tension);
15899  }
15900
15901  cardinal.tension = function(tension) {
15902    return custom(+tension);
15903  };
15904
15905  return cardinal;
15906})(0);
15907
15908function CardinalOpen(context, tension) {
15909  this._context = context;
15910  this._k = (1 - tension) / 6;
15911}
15912
15913CardinalOpen.prototype = {
15914  areaStart: function() {
15915    this._line = 0;
15916  },
15917  areaEnd: function() {
15918    this._line = NaN;
15919  },
15920  lineStart: function() {
15921    this._x0 = this._x1 = this._x2 =
15922    this._y0 = this._y1 = this._y2 = NaN;
15923    this._point = 0;
15924  },
15925  lineEnd: function() {
15926    if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath();
15927    this._line = 1 - this._line;
15928  },
15929  point: function(x, y) {
15930    x = +x, y = +y;
15931    switch (this._point) {
15932      case 0: this._point = 1; break;
15933      case 1: this._point = 2; break;
15934      case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break;
15935      case 3: this._point = 4; // proceed
15936      default: point$3(this, x, y); break;
15937    }
15938    this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
15939    this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15940  }
15941};
15942
15943var cardinalOpen = (function custom(tension) {
15944
15945  function cardinal(context) {
15946    return new CardinalOpen(context, tension);
15947  }
15948
15949  cardinal.tension = function(tension) {
15950    return custom(+tension);
15951  };
15952
15953  return cardinal;
15954})(0);
15955
15956function point$4(that, x, y) {
15957  var x1 = that._x1,
15958      y1 = that._y1,
15959      x2 = that._x2,
15960      y2 = that._y2;
15961
15962  if (that._l01_a > epsilon$3) {
15963    var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a,
15964        n = 3 * that._l01_a * (that._l01_a + that._l12_a);
15965    x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n;
15966    y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n;
15967  }
15968
15969  if (that._l23_a > epsilon$3) {
15970    var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a,
15971        m = 3 * that._l23_a * (that._l23_a + that._l12_a);
15972    x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m;
15973    y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m;
15974  }
15975
15976  that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2);
15977}
15978
15979function CatmullRom(context, alpha) {
15980  this._context = context;
15981  this._alpha = alpha;
15982}
15983
15984CatmullRom.prototype = {
15985  areaStart: function() {
15986    this._line = 0;
15987  },
15988  areaEnd: function() {
15989    this._line = NaN;
15990  },
15991  lineStart: function() {
15992    this._x0 = this._x1 = this._x2 =
15993    this._y0 = this._y1 = this._y2 = NaN;
15994    this._l01_a = this._l12_a = this._l23_a =
15995    this._l01_2a = this._l12_2a = this._l23_2a =
15996    this._point = 0;
15997  },
15998  lineEnd: function() {
15999    switch (this._point) {
16000      case 2: this._context.lineTo(this._x2, this._y2); break;
16001      case 3: this.point(this._x2, this._y2); break;
16002    }
16003    if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
16004    this._line = 1 - this._line;
16005  },
16006  point: function(x, y) {
16007    x = +x, y = +y;
16008
16009    if (this._point) {
16010      var x23 = this._x2 - x,
16011          y23 = this._y2 - y;
16012      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
16013    }
16014
16015    switch (this._point) {
16016      case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
16017      case 1: this._point = 2; break;
16018      case 2: this._point = 3; // proceed
16019      default: point$4(this, x, y); break;
16020    }
16021
16022    this._l01_a = this._l12_a, this._l12_a = this._l23_a;
16023    this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
16024    this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
16025    this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
16026  }
16027};
16028
16029var catmullRom = (function custom(alpha) {
16030
16031  function catmullRom(context) {
16032    return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0);
16033  }
16034
16035  catmullRom.alpha = function(alpha) {
16036    return custom(+alpha);
16037  };
16038
16039  return catmullRom;
16040})(0.5);
16041
16042function CatmullRomClosed(context, alpha) {
16043  this._context = context;
16044  this._alpha = alpha;
16045}
16046
16047CatmullRomClosed.prototype = {
16048  areaStart: noop$3,
16049  areaEnd: noop$3,
16050  lineStart: function() {
16051    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 =
16052    this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
16053    this._l01_a = this._l12_a = this._l23_a =
16054    this._l01_2a = this._l12_2a = this._l23_2a =
16055    this._point = 0;
16056  },
16057  lineEnd: function() {
16058    switch (this._point) {
16059      case 1: {
16060        this._context.moveTo(this._x3, this._y3);
16061        this._context.closePath();
16062        break;
16063      }
16064      case 2: {
16065        this._context.lineTo(this._x3, this._y3);
16066        this._context.closePath();
16067        break;
16068      }
16069      case 3: {
16070        this.point(this._x3, this._y3);
16071        this.point(this._x4, this._y4);
16072        this.point(this._x5, this._y5);
16073        break;
16074      }
16075    }
16076  },
16077  point: function(x, y) {
16078    x = +x, y = +y;
16079
16080    if (this._point) {
16081      var x23 = this._x2 - x,
16082          y23 = this._y2 - y;
16083      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
16084    }
16085
16086    switch (this._point) {
16087      case 0: this._point = 1; this._x3 = x, this._y3 = y; break;
16088      case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break;
16089      case 2: this._point = 3; this._x5 = x, this._y5 = y; break;
16090      default: point$4(this, x, y); break;
16091    }
16092
16093    this._l01_a = this._l12_a, this._l12_a = this._l23_a;
16094    this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
16095    this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
16096    this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
16097  }
16098};
16099
16100var catmullRomClosed = (function custom(alpha) {
16101
16102  function catmullRom(context) {
16103    return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0);
16104  }
16105
16106  catmullRom.alpha = function(alpha) {
16107    return custom(+alpha);
16108  };
16109
16110  return catmullRom;
16111})(0.5);
16112
16113function CatmullRomOpen(context, alpha) {
16114  this._context = context;
16115  this._alpha = alpha;
16116}
16117
16118CatmullRomOpen.prototype = {
16119  areaStart: function() {
16120    this._line = 0;
16121  },
16122  areaEnd: function() {
16123    this._line = NaN;
16124  },
16125  lineStart: function() {
16126    this._x0 = this._x1 = this._x2 =
16127    this._y0 = this._y1 = this._y2 = NaN;
16128    this._l01_a = this._l12_a = this._l23_a =
16129    this._l01_2a = this._l12_2a = this._l23_2a =
16130    this._point = 0;
16131  },
16132  lineEnd: function() {
16133    if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath();
16134    this._line = 1 - this._line;
16135  },
16136  point: function(x, y) {
16137    x = +x, y = +y;
16138
16139    if (this._point) {
16140      var x23 = this._x2 - x,
16141          y23 = this._y2 - y;
16142      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
16143    }
16144
16145    switch (this._point) {
16146      case 0: this._point = 1; break;
16147      case 1: this._point = 2; break;
16148      case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break;
16149      case 3: this._point = 4; // proceed
16150      default: point$4(this, x, y); break;
16151    }
16152
16153    this._l01_a = this._l12_a, this._l12_a = this._l23_a;
16154    this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
16155    this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
16156    this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
16157  }
16158};
16159
16160var catmullRomOpen = (function custom(alpha) {
16161
16162  function catmullRom(context) {
16163    return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0);
16164  }
16165
16166  catmullRom.alpha = function(alpha) {
16167    return custom(+alpha);
16168  };
16169
16170  return catmullRom;
16171})(0.5);
16172
16173function LinearClosed(context) {
16174  this._context = context;
16175}
16176
16177LinearClosed.prototype = {
16178  areaStart: noop$3,
16179  areaEnd: noop$3,
16180  lineStart: function() {
16181    this._point = 0;
16182  },
16183  lineEnd: function() {
16184    if (this._point) this._context.closePath();
16185  },
16186  point: function(x, y) {
16187    x = +x, y = +y;
16188    if (this._point) this._context.lineTo(x, y);
16189    else this._point = 1, this._context.moveTo(x, y);
16190  }
16191};
16192
16193function linearClosed(context) {
16194  return new LinearClosed(context);
16195}
16196
16197function sign$1(x) {
16198  return x < 0 ? -1 : 1;
16199}
16200
16201// Calculate the slopes of the tangents (Hermite-type interpolation) based on
16202// the following paper: Steffen, M. 1990. A Simple Method for Monotonic
16203// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO.
16204// NOV(II), P. 443, 1990.
16205function slope3(that, x2, y2) {
16206  var h0 = that._x1 - that._x0,
16207      h1 = x2 - that._x1,
16208      s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0),
16209      s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0),
16210      p = (s0 * h1 + s1 * h0) / (h0 + h1);
16211  return (sign$1(s0) + sign$1(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;
16212}
16213
16214// Calculate a one-sided slope.
16215function slope2(that, t) {
16216  var h = that._x1 - that._x0;
16217  return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t;
16218}
16219
16220// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations
16221// "you can express cubic Hermite interpolation in terms of cubic Bézier curves
16222// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1".
16223function point$5(that, t0, t1) {
16224  var x0 = that._x0,
16225      y0 = that._y0,
16226      x1 = that._x1,
16227      y1 = that._y1,
16228      dx = (x1 - x0) / 3;
16229  that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1);
16230}
16231
16232function MonotoneX(context) {
16233  this._context = context;
16234}
16235
16236MonotoneX.prototype = {
16237  areaStart: function() {
16238    this._line = 0;
16239  },
16240  areaEnd: function() {
16241    this._line = NaN;
16242  },
16243  lineStart: function() {
16244    this._x0 = this._x1 =
16245    this._y0 = this._y1 =
16246    this._t0 = NaN;
16247    this._point = 0;
16248  },
16249  lineEnd: function() {
16250    switch (this._point) {
16251      case 2: this._context.lineTo(this._x1, this._y1); break;
16252      case 3: point$5(this, this._t0, slope2(this, this._t0)); break;
16253    }
16254    if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
16255    this._line = 1 - this._line;
16256  },
16257  point: function(x, y) {
16258    var t1 = NaN;
16259
16260    x = +x, y = +y;
16261    if (x === this._x1 && y === this._y1) return; // Ignore coincident points.
16262    switch (this._point) {
16263      case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
16264      case 1: this._point = 2; break;
16265      case 2: this._point = 3; point$5(this, slope2(this, t1 = slope3(this, x, y)), t1); break;
16266      default: point$5(this, this._t0, t1 = slope3(this, x, y)); break;
16267    }
16268
16269    this._x0 = this._x1, this._x1 = x;
16270    this._y0 = this._y1, this._y1 = y;
16271    this._t0 = t1;
16272  }
16273};
16274
16275function MonotoneY(context) {
16276  this._context = new ReflectContext(context);
16277}
16278
16279(MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x, y) {
16280  MonotoneX.prototype.point.call(this, y, x);
16281};
16282
16283function ReflectContext(context) {
16284  this._context = context;
16285}
16286
16287ReflectContext.prototype = {
16288  moveTo: function(x, y) { this._context.moveTo(y, x); },
16289  closePath: function() { this._context.closePath(); },
16290  lineTo: function(x, y) { this._context.lineTo(y, x); },
16291  bezierCurveTo: function(x1, y1, x2, y2, x, y) { this._context.bezierCurveTo(y1, x1, y2, x2, y, x); }
16292};
16293
16294function monotoneX(context) {
16295  return new MonotoneX(context);
16296}
16297
16298function monotoneY(context) {
16299  return new MonotoneY(context);
16300}
16301
16302function Natural(context) {
16303  this._context = context;
16304}
16305
16306Natural.prototype = {
16307  areaStart: function() {
16308    this._line = 0;
16309  },
16310  areaEnd: function() {
16311    this._line = NaN;
16312  },
16313  lineStart: function() {
16314    this._x = [];
16315    this._y = [];
16316  },
16317  lineEnd: function() {
16318    var x = this._x,
16319        y = this._y,
16320        n = x.length;
16321
16322    if (n) {
16323      this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]);
16324      if (n === 2) {
16325        this._context.lineTo(x[1], y[1]);
16326      } else {
16327        var px = controlPoints(x),
16328            py = controlPoints(y);
16329        for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) {
16330          this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]);
16331        }
16332      }
16333    }
16334
16335    if (this._line || (this._line !== 0 && n === 1)) this._context.closePath();
16336    this._line = 1 - this._line;
16337    this._x = this._y = null;
16338  },
16339  point: function(x, y) {
16340    this._x.push(+x);
16341    this._y.push(+y);
16342  }
16343};
16344
16345// See https://www.particleincell.com/2012/bezier-splines/ for derivation.
16346function controlPoints(x) {
16347  var i,
16348      n = x.length - 1,
16349      m,
16350      a = new Array(n),
16351      b = new Array(n),
16352      r = new Array(n);
16353  a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1];
16354  for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1];
16355  a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n];
16356  for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1];
16357  a[n - 1] = r[n - 1] / b[n - 1];
16358  for (i = n - 2; i >= 0;
vendor: 7,242 bytes, lines 16358-16659
16358 --i) a[i] = (r[i] - a[i + 1]) / b[i];
16359  b[n - 1] = (x[n] + a[n - 1]) / 2;
16360  for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1];
16361  return [a, b];
16362}
16363
16364function natural(context) {
16365  return new Natural(context);
16366}
16367
16368function Step(context, t) {
16369  this._context = context;
16370  this._t = t;
16371}
16372
16373Step.prototype = {
16374  areaStart: function() {
16375    this._line = 0;
16376  },
16377  areaEnd: function() {
16378    this._line = NaN;
16379  },
16380  lineStart: function() {
16381    this._x = this._y = NaN;
16382    this._point = 0;
16383  },
16384  lineEnd: function() {
16385    if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y);
16386    if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
16387    if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line;
16388  },
16389  point: function(x, y) {
16390    x = +x, y = +y;
16391    switch (this._point) {
16392      case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
16393      case 1: this._point = 2; // proceed
16394      default: {
16395        if (this._t <= 0) {
16396          this._context.lineTo(this._x, y);
16397          this._context.lineTo(x, y);
16398        } else {
16399          var x1 = this._x * (1 - this._t) + x * this._t;
16400          this._context.lineTo(x1, this._y);
16401          this._context.lineTo(x1, y);
16402        }
16403        break;
16404      }
16405    }
16406    this._x = x, this._y = y;
16407  }
16408};
16409
16410function step(context) {
16411  return new Step(context, 0.5);
16412}
16413
16414function stepBefore(context) {
16415  return new Step(context, 0);
16416}
16417
16418function stepAfter(context) {
16419  return new Step(context, 1);
16420}
16421
16422function none$1(series, order) {
16423  if (!((n = series.length) > 1)) return;
16424  for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
16425    s0 = s1, s1 = series[order[i]];
16426    for (j = 0; j < m; ++j) {
16427      s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
16428    }
16429  }
16430}
16431
16432function none$2(series) {
16433  var n = series.length, o = new Array(n);
16434  while (--n >= 0) o[n] = n;
16435  return o;
16436}
16437
16438function stackValue(d, key) {
16439  return d[key];
16440}
16441
16442function stack() {
16443  var keys = constant$b([]),
16444      order = none$2,
16445      offset = none$1,
16446      value = stackValue;
16447
16448  function stack(data) {
16449    var kz = keys.apply(this, arguments),
16450        i,
16451        m = data.length,
16452        n = kz.length,
16453        sz = new Array(n),
16454        oz;
16455
16456    for (i = 0; i < n; ++i) {
16457      for (var ki = kz[i], si = sz[i] = new Array(m), j = 0, sij; j < m; ++j) {
16458        si[j] = sij = [0, +value(data[j], ki, j, data)];
16459        sij.data = data[j];
16460      }
16461      si.key = ki;
16462    }
16463
16464    for (i = 0, oz = order(sz); i < n; ++i) {
16465      sz[oz[i]].index = i;
16466    }
16467
16468    offset(sz, oz);
16469    return sz;
16470  }
16471
16472  stack.keys = function(_) {
16473    return arguments.length ? (keys = typeof _ === "function" ? _ : constant$b(slice$6.call(_)), stack) : keys;
16474  };
16475
16476  stack.value = function(_) {
16477    return arguments.length ? (value = typeof _ === "function" ? _ : constant$b(+_), stack) : value;
16478  };
16479
16480  stack.order = function(_) {
16481    return arguments.length ? (order = _ == null ? none$2 : typeof _ === "function" ? _ : constant$b(slice$6.call(_)), stack) : order;
16482  };
16483
16484  stack.offset = function(_) {
16485    return arguments.length ? (offset = _ == null ? none$1 : _, stack) : offset;
16486  };
16487
16488  return stack;
16489}
16490
16491function expand(series, order) {
16492  if (!((n = series.length) > 0)) return;
16493  for (var i, n, j = 0, m = series[0].length, y; j < m; ++j) {
16494    for (y = i = 0; i < n; ++i) y += series[i][j][1] || 0;
16495    if (y) for (i = 0; i < n; ++i) series[i][j][1] /= y;
16496  }
16497  none$1(series, order);
16498}
16499
16500function diverging$1(series, order) {
16501  if (!((n = series.length) > 0)) return;
16502  for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) {
16503    for (yp = yn = 0, i = 0; i < n; ++i) {
16504      if ((dy = (d = series[order[i]][j])[1] - d[0]) > 0) {
16505        d[0] = yp, d[1] = yp += dy;
16506      } else if (dy < 0) {
16507        d[1] = yn, d[0] = yn += dy;
16508      } else {
16509        d[0] = 0, d[1] = dy;
16510      }
16511    }
16512  }
16513}
16514
16515function silhouette(series, order) {
16516  if (!((n = series.length) > 0)) return;
16517  for (var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j) {
16518    for (var i = 0, y = 0; i < n; ++i) y += series[i][j][1] || 0;
16519    s0[j][1] += s0[j][0] = -y / 2;
16520  }
16521  none$1(series, order);
16522}
16523
16524function wiggle(series, order) {
16525  if (!((n = series.length) > 0) || !((m = (s0 = series[order[0]]).length) > 0)) return;
16526  for (var y = 0, j = 1, s0, m, n; j < m; ++j) {
16527    for (var i = 0, s1 = 0, s2 = 0; i < n; ++i) {
16528      var si = series[order[i]],
16529          sij0 = si[j][1] || 0,
16530          sij1 = si[j - 1][1] || 0,
16531          s3 = (sij0 - sij1) / 2;
16532      for (var k = 0; k < i; ++k) {
16533        var sk = series[order[k]],
16534            skj0 = sk[j][1] || 0,
16535            skj1 = sk[j - 1][1] || 0;
16536        s3 += skj0 - skj1;
16537      }
16538      s1 += sij0, s2 += s3 * sij0;
16539    }
16540    s0[j - 1][1] += s0[j - 1][0] = y;
16541    if (s1) y -= s2 / s1;
16542  }
16543  s0[j - 1][1] += s0[j - 1][0] = y;
16544  none$1(series, order);
16545}
16546
16547function appearance(series) {
16548  var peaks = series.map(peak);
16549  return none$2(series).sort(function(a, b) { return peaks[a] - peaks[b]; });
16550}
16551
16552function peak(series) {
16553  var i = -1, j = 0, n = series.length, vi, vj = -Infinity;
16554  while (++i < n) if ((vi = +series[i][1]) > vj) vj = vi, j = i;
16555  return j;
16556}
16557
16558function ascending$3(series) {
16559  var sums = series.map(sum$2);
16560  return none$2(series).sort(function(a, b) { return sums[a] - sums[b]; });
16561}
16562
16563function sum$2(series) {
16564  var s = 0, i = -1, n = series.length, v;
16565  while (++i < n) if (v = +series[i][1]) s += v;
16566  return s;
16567}
16568
16569function descending$2(series) {
16570  return ascending$3(series).reverse();
16571}
16572
16573function insideOut(series) {
16574  var n = series.length,
16575      i,
16576      j,
16577      sums = series.map(sum$2),
16578      order = appearance(series),
16579      top = 0,
16580      bottom = 0,
16581      tops = [],
16582      bottoms = [];
16583
16584  for (i = 0; i < n; ++i) {
16585    j = order[i];
16586    if (top < bottom) {
16587      top += sums[j];
16588      tops.push(j);
16589    } else {
16590      bottom += sums[j];
16591      bottoms.push(j);
16592    }
16593  }
16594
16595  return bottoms.reverse().concat(tops);
16596}
16597
16598function reverse(series) {
16599  return none$2(series).reverse();
16600}
16601
16602function constant$c(x) {
16603  return function() {
16604    return x;
16605  };
16606}
16607
16608function x$4(d) {
16609  return d[0];
16610}
16611
16612function y$4(d) {
16613  return d[1];
16614}
16615
16616function RedBlackTree() {
16617  this._ = null; // root node
16618}
16619
16620function RedBlackNode(node) {
16621  node.U = // parent node
16622  node.C = // color - true for red, false for black
16623  node.L = // left node
16624  node.R = // right node
16625  node.P = // previous node
16626  node.N = null; // next node
16627}
16628
16629RedBlackTree.prototype = {
16630  constructor: RedBlackTree,
16631
16632  insert: function(after, node) {
16633    var parent, grandpa, uncle;
16634
16635    if (after) {
16636      node.P = after;
16637      node.N = after.N;
16638      if (after.N) after.N.P = node;
16639      after.N = node;
16640      if (after.R) {
16641        after = after.R;
16642        while (after.L) after = after.L;
16643        after.L = node;
16644      } else {
16645        after.R = node;
16646      }
16647      parent = after;
16648    } else if (this._) {
16649      after = RedBlackFirst(this._);
16650      node.P = null;
16651      node.N = after;
16652      after.P = after.L = node;
16653      parent = after;
16654    } else {
16655      node.P = node.N = null;
16656      this._ = node;
16657      parent = null;
16658    }
16659    node.L = node.R = null;
vendor: 17,553 bytes, lines 16660-17408
16660    node.U = parent;
16661    node.C = true;
16662
16663    after = node;
16664    while (parent && parent.C) {
16665      grandpa = parent.U;
16666      if (parent === grandpa.L) {
16667        uncle = grandpa.R;
16668        if (uncle && uncle.C) {
16669          parent.C = uncle.C = false;
16670          grandpa.C = true;
16671          after = grandpa;
16672        } else {
16673          if (after === parent.R) {
16674            RedBlackRotateLeft(this, parent);
16675            after = parent;
16676            parent = after.U;
16677          }
16678          parent.C = false;
16679          grandpa.C = true;
16680          RedBlackRotateRight(this, grandpa);
16681        }
16682      } else {
16683        uncle = grandpa.L;
16684        if (uncle && uncle.C) {
16685          parent.C = uncle.C = false;
16686          grandpa.C = true;
16687          after = grandpa;
16688        } else {
16689          if (after === parent.L) {
16690            RedBlackRotateRight(this, parent);
16691            after = parent;
16692            parent = after.U;
16693          }
16694          parent.C = false;
16695          grandpa.C = true;
16696          RedBlackRotateLeft(this, grandpa);
16697        }
16698      }
16699      parent = after.U;
16700    }
16701    this._.C = false;
16702  },
16703
16704  remove: function(node) {
16705    if (node.N) node.N.P = node.P;
16706    if (node.P) node.P.N = node.N;
16707    node.N = node.P = null;
16708
16709    var parent = node.U,
16710        sibling,
16711        left = node.L,
16712        right = node.R,
16713        next,
16714        red;
16715
16716    if (!left) next = right;
16717    else if (!right) next = left;
16718    else next = RedBlackFirst(right);
16719
16720    if (parent) {
16721      if (parent.L === node) parent.L = next;
16722      else parent.R = next;
16723    } else {
16724      this._ = next;
16725    }
16726
16727    if (left && right) {
16728      red = next.C;
16729      next.C = node.C;
16730      next.L = left;
16731      left.U = next;
16732      if (next !== right) {
16733        parent = next.U;
16734        next.U = node.U;
16735        node = next.R;
16736        parent.L = node;
16737        next.R = right;
16738        right.U = next;
16739      } else {
16740        next.U = parent;
16741        parent = next;
16742        node = next.R;
16743      }
16744    } else {
16745      red = node.C;
16746      node = next;
16747    }
16748
16749    if (node) node.U = parent;
16750    if (red) return;
16751    if (node && node.C) { node.C = false; return; }
16752
16753    do {
16754      if (node === this._) break;
16755      if (node === parent.L) {
16756        sibling = parent.R;
16757        if (sibling.C) {
16758          sibling.C = false;
16759          parent.C = true;
16760          RedBlackRotateLeft(this, parent);
16761          sibling = parent.R;
16762        }
16763        if ((sibling.L && sibling.L.C)
16764            || (sibling.R && sibling.R.C)) {
16765          if (!sibling.R || !sibling.R.C) {
16766            sibling.L.C = false;
16767            sibling.C = true;
16768            RedBlackRotateRight(this, sibling);
16769            sibling = parent.R;
16770          }
16771          sibling.C = parent.C;
16772          parent.C = sibling.R.C = false;
16773          RedBlackRotateLeft(this, parent);
16774          node = this._;
16775          break;
16776        }
16777      } else {
16778        sibling = parent.L;
16779        if (sibling.C) {
16780          sibling.C = false;
16781          parent.C = true;
16782          RedBlackRotateRight(this, parent);
16783          sibling = parent.L;
16784        }
16785        if ((sibling.L && sibling.L.C)
16786          || (sibling.R && sibling.R.C)) {
16787          if (!sibling.L || !sibling.L.C) {
16788            sibling.R.C = false;
16789            sibling.C = true;
16790            RedBlackRotateLeft(this, sibling);
16791            sibling = parent.L;
16792          }
16793          sibling.C = parent.C;
16794          parent.C = sibling.L.C = false;
16795          RedBlackRotateRight(this, parent);
16796          node = this._;
16797          break;
16798        }
16799      }
16800      sibling.C = true;
16801      node = parent;
16802      parent = parent.U;
16803    } while (!node.C);
16804
16805    if (node) node.C = false;
16806  }
16807};
16808
16809function RedBlackRotateLeft(tree, node) {
16810  var p = node,
16811      q = node.R,
16812      parent = p.U;
16813
16814  if (parent) {
16815    if (parent.L === p) parent.L = q;
16816    else parent.R = q;
16817  } else {
16818    tree._ = q;
16819  }
16820
16821  q.U = parent;
16822  p.U = q;
16823  p.R = q.L;
16824  if (p.R) p.R.U = p;
16825  q.L = p;
16826}
16827
16828function RedBlackRotateRight(tree, node) {
16829  var p = node,
16830      q = node.L,
16831      parent = p.U;
16832
16833  if (parent) {
16834    if (parent.L === p) parent.L = q;
16835    else parent.R = q;
16836  } else {
16837    tree._ = q;
16838  }
16839
16840  q.U = parent;
16841  p.U = q;
16842  p.L = q.R;
16843  if (p.L) p.L.U = p;
16844  q.R = p;
16845}
16846
16847function RedBlackFirst(node) {
16848  while (node.L) node = node.L;
16849  return node;
16850}
16851
16852function createEdge(left, right, v0, v1) {
16853  var edge = [null, null],
16854      index = edges.push(edge) - 1;
16855  edge.left = left;
16856  edge.right = right;
16857  if (v0) setEdgeEnd(edge, left, right, v0);
16858  if (v1) setEdgeEnd(edge, right, left, v1);
16859  cells[left.index].halfedges.push(index);
16860  cells[right.index].halfedges.push(index);
16861  return edge;
16862}
16863
16864function createBorderEdge(left, v0, v1) {
16865  var edge = [v0, v1];
16866  edge.left = left;
16867  return edge;
16868}
16869
16870function setEdgeEnd(edge, left, right, vertex) {
16871  if (!edge[0] && !edge[1]) {
16872    edge[0] = vertex;
16873    edge.left = left;
16874    edge.right = right;
16875  } else if (edge.left === right) {
16876    edge[1] = vertex;
16877  } else {
16878    edge[0] = vertex;
16879  }
16880}
16881
16882// Liang–Barsky line clipping.
16883function clipEdge(edge, x0, y0, x1, y1) {
16884  var a = edge[0],
16885      b = edge[1],
16886      ax = a[0],
16887      ay = a[1],
16888      bx = b[0],
16889      by = b[1],
16890      t0 = 0,
16891      t1 = 1,
16892      dx = bx - ax,
16893      dy = by - ay,
16894      r;
16895
16896  r = x0 - ax;
16897  if (!dx && r > 0) return;
16898  r /= dx;
16899  if (dx < 0) {
16900    if (r < t0) return;
16901    if (r < t1) t1 = r;
16902  } else if (dx > 0) {
16903    if (r > t1) return;
16904    if (r > t0) t0 = r;
16905  }
16906
16907  r = x1 - ax;
16908  if (!dx && r < 0) return;
16909  r /= dx;
16910  if (dx < 0) {
16911    if (r > t1) return;
16912    if (r > t0) t0 = r;
16913  } else if (dx > 0) {
16914    if (r < t0) return;
16915    if (r < t1) t1 = r;
16916  }
16917
16918  r = y0 - ay;
16919  if (!dy && r > 0) return;
16920  r /= dy;
16921  if (dy < 0) {
16922    if (r < t0) return;
16923    if (r < t1) t1 = r;
16924  } else if (dy > 0) {
16925    if (r > t1) return;
16926    if (r > t0) t0 = r;
16927  }
16928
16929  r = y1 - ay;
16930  if (!dy && r < 0) return;
16931  r /= dy;
16932  if (dy < 0) {
16933    if (r > t1) return;
16934    if (r > t0) t0 = r;
16935  } else if (dy > 0) {
16936    if (r < t0) return;
16937    if (r < t1) t1 = r;
16938  }
16939
16940  if (!(t0 > 0) && !(t1 < 1)) return true; // TODO Better check?
16941
16942  if (t0 > 0) edge[0] = [ax + t0 * dx, ay + t0 * dy];
16943  if (t1 < 1) edge[1] = [ax + t1 * dx, ay + t1 * dy];
16944  return true;
16945}
16946
16947function connectEdge(edge, x0, y0, x1, y1) {
16948  var v1 = edge[1];
16949  if (v1) return true;
16950
16951  var v0 = edge[0],
16952      left = edge.left,
16953      right = edge.right,
16954      lx = left[0],
16955      ly = left[1],
16956      rx = right[0],
16957      ry = right[1],
16958      fx = (lx + rx) / 2,
16959      fy = (ly + ry) / 2,
16960      fm,
16961      fb;
16962
16963  if (ry === ly) {
16964    if (fx < x0 || fx >= x1) return;
16965    if (lx > rx) {
16966      if (!v0) v0 = [fx, y0];
16967      else if (v0[1] >= y1) return;
16968      v1 = [fx, y1];
16969    } else {
16970      if (!v0) v0 = [fx, y1];
16971      else if (v0[1] < y0) return;
16972      v1 = [fx, y0];
16973    }
16974  } else {
16975    fm = (lx - rx) / (ry - ly);
16976    fb = fy - fm * fx;
16977    if (fm < -1 || fm > 1) {
16978      if (lx > rx) {
16979        if (!v0) v0 = [(y0 - fb) / fm, y0];
16980        else if (v0[1] >= y1) return;
16981        v1 = [(y1 - fb) / fm, y1];
16982      } else {
16983        if (!v0) v0 = [(y1 - fb) / fm, y1];
16984        else if (v0[1] < y0) return;
16985        v1 = [(y0 - fb) / fm, y0];
16986      }
16987    } else {
16988      if (ly < ry) {
16989        if (!v0) v0 = [x0, fm * x0 + fb];
16990        else if (v0[0] >= x1) return;
16991        v1 = [x1, fm * x1 + fb];
16992      } else {
16993        if (!v0) v0 = [x1, fm * x1 + fb];
16994        else if (v0[0] < x0) return;
16995        v1 = [x0, fm * x0 + fb];
16996      }
16997    }
16998  }
16999
17000  edge[0] = v0;
17001  edge[1] = v1;
17002  return true;
17003}
17004
17005function clipEdges(x0, y0, x1, y1) {
17006  var i = edges.length,
17007      edge;
17008
17009  while (i--) {
17010    if (!connectEdge(edge = edges[i], x0, y0, x1, y1)
17011        || !clipEdge(edge, x0, y0, x1, y1)
17012        || !(Math.abs(edge[0][0] - edge[1][0]) > epsilon$4
17013            || Math.abs(edge[0][1] - edge[1][1]) > epsilon$4)) {
17014      delete edges[i];
17015    }
17016  }
17017}
17018
17019function createCell(site) {
17020  return cells[site.index] = {
17021    site: site,
17022    halfedges: []
17023  };
17024}
17025
17026function cellHalfedgeAngle(cell, edge) {
17027  var site = cell.site,
17028      va = edge.left,
17029      vb = edge.right;
17030  if (site === vb) vb = va, va = site;
17031  if (vb) return Math.atan2(vb[1] - va[1], vb[0] - va[0]);
17032  if (site === va) va = edge[1], vb = edge[0];
17033  else va = edge[0], vb = edge[1];
17034  return Math.atan2(va[0] - vb[0], vb[1] - va[1]);
17035}
17036
17037function cellHalfedgeStart(cell, edge) {
17038  return edge[+(edge.left !== cell.site)];
17039}
17040
17041function cellHalfedgeEnd(cell, edge) {
17042  return edge[+(edge.left === cell.site)];
17043}
17044
17045function sortCellHalfedges() {
17046  for (var i = 0, n = cells.length, cell, halfedges, j, m; i < n; ++i) {
17047    if ((cell = cells[i]) && (m = (halfedges = cell.halfedges).length)) {
17048      var index = new Array(m),
17049          array = new Array(m);
17050      for (j = 0; j < m; ++j) index[j] = j, array[j] = cellHalfedgeAngle(cell, edges[halfedges[j]]);
17051      index.sort(function(i, j) { return array[j] - array[i]; });
17052      for (j = 0; j < m; ++j) array[j] = halfedges[index[j]];
17053      for (j = 0; j < m; ++j) halfedges[j] = array[j];
17054    }
17055  }
17056}
17057
17058function clipCells(x0, y0, x1, y1) {
17059  var nCells = cells.length,
17060      iCell,
17061      cell,
17062      site,
17063      iHalfedge,
17064      halfedges,
17065      nHalfedges,
17066      start,
17067      startX,
17068      startY,
17069      end,
17070      endX,
17071      endY,
17072      cover = true;
17073
17074  for (iCell = 0; iCell < nCells; ++iCell) {
17075    if (cell = cells[iCell]) {
17076      site = cell.site;
17077      halfedges = cell.halfedges;
17078      iHalfedge = halfedges.length;
17079
17080      // Remove any dangling clipped edges.
17081      while (iHalfedge--) {
17082        if (!edges[halfedges[iHalfedge]]) {
17083          halfedges.splice(iHalfedge, 1);
17084        }
17085      }
17086
17087      // Insert any border edges as necessary.
17088      iHalfedge = 0, nHalfedges = halfedges.length;
17089      while (iHalfedge < nHalfedges) {
17090        end = cellHalfedgeEnd(cell, edges[halfedges[iHalfedge]]), endX = end[0], endY = end[1];
17091        start = cellHalfedgeStart(cell, edges[halfedges[++iHalfedge % nHalfedges]]), startX = start[0], startY = start[1];
17092        if (Math.abs(endX - startX) > epsilon$4 || Math.abs(endY - startY) > epsilon$4) {
17093          halfedges.splice(iHalfedge, 0, edges.push(createBorderEdge(site, end,
17094              Math.abs(endX - x0) < epsilon$4 && y1 - endY > epsilon$4 ? [x0, Math.abs(startX - x0) < epsilon$4 ? startY : y1]
17095              : Math.abs(endY - y1) < epsilon$4 && x1 - endX > epsilon$4 ? [Math.abs(startY - y1) < epsilon$4 ? startX : x1, y1]
17096              : Math.abs(endX - x1) < epsilon$4 && endY - y0 > epsilon$4 ? [x1, Math.abs(startX - x1) < epsilon$4 ? startY : y0]
17097              : Math.abs(endY - y0) < epsilon$4 && endX - x0 > epsilon$4 ? [Math.abs(startY - y0) < epsilon$4 ? startX : x0, y0]
17098              : null)) - 1);
17099          ++nHalfedges;
17100        }
17101      }
17102
17103      if (nHalfedges) cover = false;
17104    }
17105  }
17106
17107  // If there weren’t any edges, have the closest site cover the extent.
17108  // It doesn’t matter which corner of the extent we measure!
17109  if (cover) {
17110    var dx, dy, d2, dc = Infinity;
17111
17112    for (iCell = 0, cover = null; iCell < nCells; ++iCell) {
17113      if (cell = cells[iCell]) {
17114        site = cell.site;
17115        dx = site[0] - x0;
17116        dy = site[1] - y0;
17117        d2 = dx * dx + dy * dy;
17118        if (d2 < dc) dc = d2, cover = cell;
17119      }
17120    }
17121
17122    if (cover) {
17123      var v00 = [x0, y0], v01 = [x0, y1], v11 = [x1, y1], v10 = [x1, y0];
17124      cover.halfedges.push(
17125        edges.push(createBorderEdge(site = cover.site, v00, v01)) - 1,
17126        edges.push(createBorderEdge(site, v01, v11)) - 1,
17127        edges.push(createBorderEdge(site, v11, v10)) - 1,
17128        edges.push(createBorderEdge(site, v10, v00)) - 1
17129      );
17130    }
17131  }
17132
17133  // Lastly delete any cells with no edges; these were entirely clipped.
17134  for (iCell = 0; iCell < nCells; ++iCell) {
17135    if (cell = cells[iCell]) {
17136      if (!cell.halfedges.length) {
17137        delete cells[iCell];
17138      }
17139    }
17140  }
17141}
17142
17143var circlePool = [];
17144
17145var firstCircle;
17146
17147function Circle() {
17148  RedBlackNode(this);
17149  this.x =
17150  this.y =
17151  this.arc =
17152  this.site =
17153  this.cy = null;
17154}
17155
17156function attachCircle(arc) {
17157  var lArc = arc.P,
17158      rArc = arc.N;
17159
17160  if (!lArc || !rArc) return;
17161
17162  var lSite = lArc.site,
17163      cSite = arc.site,
17164      rSite = rArc.site;
17165
17166  if (lSite === rSite) return;
17167
17168  var bx = cSite[0],
17169      by = cSite[1],
17170      ax = lSite[0] - bx,
17171      ay = lSite[1] - by,
17172      cx = rSite[0] - bx,
17173      cy = rSite[1] - by;
17174
17175  var d = 2 * (ax * cy - ay * cx);
17176  if (d >= -epsilon2$2) return;
17177
17178  var ha = ax * ax + ay * ay,
17179      hc = cx * cx + cy * cy,
17180      x = (cy * ha - ay * hc) / d,
17181      y = (ax * hc - cx * ha) / d;
17182
17183  var circle = circlePool.pop() || new Circle;
17184  circle.arc = arc;
17185  circle.site = cSite;
17186  circle.x = x + bx;
17187  circle.y = (circle.cy = y + by) + Math.sqrt(x * x + y * y); // y bottom
17188
17189  arc.circle = circle;
17190
17191  var before = null,
17192      node = circles._;
17193
17194  while (node) {
17195    if (circle.y < node.y || (circle.y === node.y && circle.x <= node.x)) {
17196      if (node.L) node = node.L;
17197      else { before = node.P; break; }
17198    } else {
17199      if (node.R) node = node.R;
17200      else { before = node; break; }
17201    }
17202  }
17203
17204  circles.insert(before, circle);
17205  if (!before) firstCircle = circle;
17206}
17207
17208function detachCircle(arc) {
17209  var circle = arc.circle;
17210  if (circle) {
17211    if (!circle.P) firstCircle = circle.N;
17212    circles.remove(circle);
17213    circlePool.push(circle);
17214    RedBlackNode(circle);
17215    arc.circle = null;
17216  }
17217}
17218
17219var beachPool = [];
17220
17221function Beach() {
17222  RedBlackNode(this);
17223  this.edge =
17224  this.site =
17225  this.circle = null;
17226}
17227
17228function createBeach(site) {
17229  var beach = beachPool.pop() || new Beach;
17230  beach.site = site;
17231  return beach;
17232}
17233
17234function detachBeach(beach) {
17235  detachCircle(beach);
17236  beaches.remove(beach);
17237  beachPool.push(beach);
17238  RedBlackNode(beach);
17239}
17240
17241function removeBeach(beach) {
17242  var circle = beach.circle,
17243      x = circle.x,
17244      y = circle.cy,
17245      vertex = [x, y],
17246      previous = beach.P,
17247      next = beach.N,
17248      disappearing = [beach];
17249
17250  detachBeach(beach);
17251
17252  var lArc = previous;
17253  while (lArc.circle
17254      && Math.abs(x - lArc.circle.x) < epsilon$4
17255      && Math.abs(y - lArc.circle.cy) < epsilon$4) {
17256    previous = lArc.P;
17257    disappearing.unshift(lArc);
17258    detachBeach(lArc);
17259    lArc = previous;
17260  }
17261
17262  disappearing.unshift(lArc);
17263  detachCircle(lArc);
17264
17265  var rArc = next;
17266  while (rArc.circle
17267      && Math.abs(x - rArc.circle.x) < epsilon$4
17268      && Math.abs(y - rArc.circle.cy) < epsilon$4) {
17269    next = rArc.N;
17270    disappearing.push(rArc);
17271    detachBeach(rArc);
17272    rArc = next;
17273  }
17274
17275  disappearing.push(rArc);
17276  detachCircle(rArc);
17277
17278  var nArcs = disappearing.length,
17279      iArc;
17280  for (iArc = 1; iArc < nArcs; ++iArc) {
17281    rArc = disappearing[iArc];
17282    lArc = disappearing[iArc - 1];
17283    setEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);
17284  }
17285
17286  lArc = disappearing[0];
17287  rArc = disappearing[nArcs - 1];
17288  rArc.edge = createEdge(lArc.site, rArc.site, null, vertex);
17289
17290  attachCircle(lArc);
17291  attachCircle(rArc);
17292}
17293
17294function addBeach(site) {
17295  var x = site[0],
17296      directrix = site[1],
17297      lArc,
17298      rArc,
17299      dxl,
17300      dxr,
17301      node = beaches._;
17302
17303  while (node) {
17304    dxl = leftBreakPoint(node, directrix) - x;
17305    if (dxl > epsilon$4) node = node.L; else {
17306      dxr = x - rightBreakPoint(node, directrix);
17307      if (dxr > epsilon$4) {
17308        if (!node.R) {
17309          lArc = node;
17310          break;
17311        }
17312        node = node.R;
17313      } else {
17314        if (dxl > -epsilon$4) {
17315          lArc = node.P;
17316          rArc = node;
17317        } else if (dxr > -epsilon$4) {
17318          lArc = node;
17319          rArc = node.N;
17320        } else {
17321          lArc = rArc = node;
17322        }
17323        break;
17324      }
17325    }
17326  }
17327
17328  createCell(site);
17329  var newArc = createBeach(site);
17330  beaches.insert(lArc, newArc);
17331
17332  if (!lArc && !rArc) return;
17333
17334  if (lArc === rArc) {
17335    detachCircle(lArc);
17336    rArc = createBeach(lArc.site);
17337    beaches.insert(newArc, rArc);
17338    newArc.edge = rArc.edge = createEdge(lArc.site, newArc.site);
17339    attachCircle(lArc);
17340    attachCircle(rArc);
17341    return;
17342  }
17343
17344  if (!rArc) { // && lArc
17345    newArc.edge = createEdge(lArc.site, newArc.site);
17346    return;
17347  }
17348
17349  // else lArc !== rArc
17350  detachCircle(lArc);
17351  detachCircle(rArc);
17352
17353  var lSite = lArc.site,
17354      ax = lSite[0],
17355      ay = lSite[1],
17356      bx = site[0] - ax,
17357      by = site[1] - ay,
17358      rSite = rArc.site,
17359      cx = rSite[0] - ax,
17360      cy = rSite[1] - ay,
17361      d = 2 * (bx * cy - by * cx),
17362      hb = bx * bx + by * by,
17363      hc = cx * cx + cy * cy,
17364      vertex = [(cy * hb - by * hc) / d + ax, (bx * hc - cx * hb) / d + ay];
17365
17366  setEdgeEnd(rArc.edge, lSite, rSite, vertex);
17367  newArc.edge = createEdge(lSite, site, null, vertex);
17368  rArc.edge = createEdge(site, rSite, null, vertex);
17369  attachCircle(lArc);
17370  attachCircle(rArc);
17371}
17372
17373function leftBreakPoint(arc, directrix) {
17374  var site = arc.site,
17375      rfocx = site[0],
17376      rfocy = site[1],
17377      pby2 = rfocy - directrix;
17378
17379  if (!pby2) return rfocx;
17380
17381  var lArc = arc.P;
17382  if (!lArc) return -Infinity;
17383
17384  site = lArc.site;
17385  var lfocx = site[0],
17386      lfocy = site[1],
17387      plby2 = lfocy - directrix;
17388
17389  if (!plby2) return lfocx;
17390
17391  var hl = lfocx - rfocx,
17392      aby2 = 1 / pby2 - 1 / plby2,
17393      b = hl / plby2;
17394
17395  if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;
17396
17397  return (rfocx + lfocx) / 2;
17398}
17399
17400function rightBreakPoint(arc, directrix) {
17401  var rArc = arc.N;
17402  if (rArc) return leftBreakPoint(rArc, directrix);
17403  var site = arc.site;
17404  return site[1] === directrix ? site[0] : Infinity;
17405}
17406
17407var epsilon$4 = 1e-6;
17408var epsilon2$
vendor: 3,274 bytes, lines 17408-17545
174082 = 1e-12;
17409var beaches;
17410var cells;
17411var circles;
17412var edges;
17413
17414function triangleArea(a, b, c) {
17415  return (a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1]);
17416}
17417
17418function lexicographic(a, b) {
17419  return b[1] - a[1]
17420      || b[0] - a[0];
17421}
17422
17423function Diagram(sites, extent) {
17424  var site = sites.sort(lexicographic).pop(),
17425      x,
17426      y,
17427      circle;
17428
17429  edges = [];
17430  cells = new Array(sites.length);
17431  beaches = new RedBlackTree;
17432  circles = new RedBlackTree;
17433
17434  while (true) {
17435    circle = firstCircle;
17436    if (site && (!circle || site[1] < circle.y || (site[1] === circle.y && site[0] < circle.x))) {
17437      if (site[0] !== x || site[1] !== y) {
17438        addBeach(site);
17439        x = site[0], y = site[1];
17440      }
17441      site = sites.pop();
17442    } else if (circle) {
17443      removeBeach(circle.arc);
17444    } else {
17445      break;
17446    }
17447  }
17448
17449  sortCellHalfedges();
17450
17451  if (extent) {
17452    var x0 = +extent[0][0],
17453        y0 = +extent[0][1],
17454        x1 = +extent[1][0],
17455        y1 = +extent[1][1];
17456    clipEdges(x0, y0, x1, y1);
17457    clipCells(x0, y0, x1, y1);
17458  }
17459
17460  this.edges = edges;
17461  this.cells = cells;
17462
17463  beaches =
17464  circles =
17465  edges =
17466  cells = null;
17467}
17468
17469Diagram.prototype = {
17470  constructor: Diagram,
17471
17472  polygons: function() {
17473    var edges = this.edges;
17474
17475    return this.cells.map(function(cell) {
17476      var polygon = cell.halfedges.map(function(i) { return cellHalfedgeStart(cell, edges[i]); });
17477      polygon.data = cell.site.data;
17478      return polygon;
17479    });
17480  },
17481
17482  triangles: function() {
17483    var triangles = [],
17484        edges = this.edges;
17485
17486    this.cells.forEach(function(cell, i) {
17487      if (!(m = (halfedges = cell.halfedges).length)) return;
17488      var site = cell.site,
17489          halfedges,
17490          j = -1,
17491          m,
17492          s0,
17493          e1 = edges[halfedges[m - 1]],
17494          s1 = e1.left === site ? e1.right : e1.left;
17495
17496      while (++j < m) {
17497        s0 = s1;
17498        e1 = edges[halfedges[j]];
17499        s1 = e1.left === site ? e1.right : e1.left;
17500        if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {
17501          triangles.push([site.data, s0.data, s1.data]);
17502        }
17503      }
17504    });
17505
17506    return triangles;
17507  },
17508
17509  links: function() {
17510    return this.edges.filter(function(edge) {
17511      return edge.right;
17512    }).map(function(edge) {
17513      return {
17514        source: edge.left.data,
17515        target: edge.right.data
17516      };
17517    });
17518  },
17519
17520  find: function(x, y, radius) {
17521    var that = this, i0, i1 = that._found || 0, n = that.cells.length, cell;
17522
17523    // Use the previously-found cell, or start with an arbitrary one.
17524    while (!(cell = that.cells[i1])) if (++i1 >= n) return null;
17525    var dx = x - cell.site[0], dy = y - cell.site[1], d2 = dx * dx + dy * dy;
17526
17527    // Traverse the half-edges to find a closer cell, if any.
17528    do {
17529      cell = that.cells[i0 = i1], i1 = null;
17530      cell.halfedges.forEach(function(e) {
17531        var edge = that.edges[e], v = edge.left;
17532        if ((v === cell.site || !v) && !(v = edge.right)) return;
17533        var vx = x - v[0], vy = y - v[1], v2 = vx * vx + vy * vy;
17534        if (v2 < d2) d2 = v2, i1 = v.index;
17535      });
17536    } while (i1 !== null);
17537
17538    that._found = i0;
17539
17540    return radius == null || d2 <= radius * radius ? cell.site : null;
17541  }
17542};
17543
17544function voronoi() {
17545  var x
vendor: 9,843 bytes, lines 17545-17849
17545 = x$4,
17546      y = y$4,
17547      extent = null;
17548
17549  function voronoi(data) {
17550    return new Diagram(data.map(function(d, i) {
17551      var s = [Math.round(x(d, i, data) / epsilon$4) * epsilon$4, Math.round(y(d, i, data) / epsilon$4) * epsilon$4];
17552      s.index = i;
17553      s.data = d;
17554      return s;
17555    }), extent);
17556  }
17557
17558  voronoi.polygons = function(data) {
17559    return voronoi(data).polygons();
17560  };
17561
17562  voronoi.links = function(data) {
17563    return voronoi(data).links();
17564  };
17565
17566  voronoi.triangles = function(data) {
17567    return voronoi(data).triangles();
17568  };
17569
17570  voronoi.x = function(_) {
17571    return arguments.length ? (x = typeof _ === "function" ? _ : constant$c(+_), voronoi) : x;
17572  };
17573
17574  voronoi.y = function(_) {
17575    return arguments.length ? (y = typeof _ === "function" ? _ : constant$c(+_), voronoi) : y;
17576  };
17577
17578  voronoi.extent = function(_) {
17579    return arguments.length ? (extent = _ == null ? null : [[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]], voronoi) : extent && [[extent[0][0], extent[0][1]], [extent[1][0], extent[1][1]]];
17580  };
17581
17582  voronoi.size = function(_) {
17583    return arguments.length ? (extent = _ == null ? null : [[0, 0], [+_[0], +_[1]]], voronoi) : extent && [extent[1][0] - extent[0][0], extent[1][1] - extent[0][1]];
17584  };
17585
17586  return voronoi;
17587}
17588
17589function constant$d(x) {
17590  return function() {
17591    return x;
17592  };
17593}
17594
17595function ZoomEvent(target, type, transform) {
17596  this.target = target;
17597  this.type = type;
17598  this.transform = transform;
17599}
17600
17601function Transform(k, x, y) {
17602  this.k = k;
17603  this.x = x;
17604  this.y = y;
17605}
17606
17607Transform.prototype = {
17608  constructor: Transform,
17609  scale: function(k) {
17610    return k === 1 ? this : new Transform(this.k * k, this.x, this.y);
17611  },
17612  translate: function(x, y) {
17613    return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y);
17614  },
17615  apply: function(point) {
17616    return [point[0] * this.k + this.x, point[1] * this.k + this.y];
17617  },
17618  applyX: function(x) {
17619    return x * this.k + this.x;
17620  },
17621  applyY: function(y) {
17622    return y * this.k + this.y;
17623  },
17624  invert: function(location) {
17625    return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
17626  },
17627  invertX: function(x) {
17628    return (x - this.x) / this.k;
17629  },
17630  invertY: function(y) {
17631    return (y - this.y) / this.k;
17632  },
17633  rescaleX: function(x) {
17634    return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x));
17635  },
17636  rescaleY: function(y) {
17637    return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y));
17638  },
17639  toString: function() {
17640    return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
17641  }
17642};
17643
17644var identity$9 = new Transform(1, 0, 0);
17645
17646transform$1.prototype = Transform.prototype;
17647
17648function transform$1(node) {
17649  while (!node.__zoom) if (!(node = node.parentNode)) return identity$9;
17650  return node.__zoom;
17651}
17652
17653function nopropagation$2() {
17654  exports.event.stopImmediatePropagation();
17655}
17656
17657function noevent$2() {
17658  exports.event.preventDefault();
17659  exports.event.stopImmediatePropagation();
17660}
17661
17662// Ignore right-click, since that should open the context menu.
17663function defaultFilter$2() {
17664  return !exports.event.ctrlKey && !exports.event.button;
17665}
17666
17667function defaultExtent$1() {
17668  var e = this;
17669  if (e instanceof SVGElement) {
17670    e = e.ownerSVGElement || e;
17671    if (e.hasAttribute("viewBox")) {
17672      e = e.viewBox.baseVal;
17673      return [[e.x, e.y], [e.x + e.width, e.y + e.height]];
17674    }
17675    return [[0, 0], [e.width.baseVal.value, e.height.baseVal.value]];
17676  }
17677  return [[0, 0], [e.clientWidth, e.clientHeight]];
17678}
17679
17680function defaultTransform() {
17681  return this.__zoom || identity$9;
17682}
17683
17684function defaultWheelDelta() {
17685  return -exports.event.deltaY * (exports.event.deltaMode === 1 ? 0.05 : exports.event.deltaMode ? 1 : 0.002);
17686}
17687
17688function defaultTouchable$2() {
17689  return navigator.maxTouchPoints || ("ontouchstart" in this);
17690}
17691
17692function defaultConstrain(transform, extent, translateExtent) {
17693  var dx0 = transform.invertX(extent[0][0]) - translateExtent[0][0],
17694      dx1 = transform.invertX(extent[1][0]) - translateExtent[1][0],
17695      dy0 = transform.invertY(extent[0][1]) - translateExtent[0][1],
17696      dy1 = transform.invertY(extent[1][1]) - translateExtent[1][1];
17697  return transform.translate(
17698    dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
17699    dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
17700  );
17701}
17702
17703function zoom() {
17704  var filter = defaultFilter$2,
17705      extent = defaultExtent$1,
17706      constrain = defaultConstrain,
17707      wheelDelta = defaultWheelDelta,
17708      touchable = defaultTouchable$2,
17709      scaleExtent = [0, Infinity],
17710      translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]],
17711      duration = 250,
17712      interpolate = interpolateZoom,
17713      listeners = dispatch("start", "zoom", "end"),
17714      touchstarting,
17715      touchending,
17716      touchDelay = 500,
17717      wheelDelay = 150,
17718      clickDistance2 = 0;
17719
17720  function zoom(selection) {
17721    selection
17722        .property("__zoom", defaultTransform)
17723        .on("wheel.zoom", wheeled)
17724        .on("mousedown.zoom", mousedowned)
17725        .on("dblclick.zoom", dblclicked)
17726      .filter(touchable)
17727        .on("touchstart.zoom", touchstarted)
17728        .on("touchmove.zoom", touchmoved)
17729        .on("touchend.zoom touchcancel.zoom", touchended)
17730        .style("touch-action", "none")
17731        .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
17732  }
17733
17734  zoom.transform = function(collection, transform, point) {
17735    var selection = collection.selection ? collection.selection() : collection;
17736    selection.property("__zoom", defaultTransform);
17737    if (collection !== selection) {
17738      schedule(collection, transform, point);
17739    } else {
17740      selection.interrupt().each(function() {
17741        gesture(this, arguments)
17742            .start()
17743            .zoom(null, typeof transform === "function" ? transform.apply(this, arguments) : transform)
17744            .end();
17745      });
17746    }
17747  };
17748
17749  zoom.scaleBy = function(selection, k, p) {
17750    zoom.scaleTo(selection, function() {
17751      var k0 = this.__zoom.k,
17752          k1 = typeof k === "function" ? k.apply(this, arguments) : k;
17753      return k0 * k1;
17754    }, p);
17755  };
17756
17757  zoom.scaleTo = function(selection, k, p) {
17758    zoom.transform(selection, function() {
17759      var e = extent.apply(this, arguments),
17760          t0 = this.__zoom,
17761          p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p,
17762          p1 = t0.invert(p0),
17763          k1 = typeof k === "function" ? k.apply(this, arguments) : k;
17764      return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent);
17765    }, p);
17766  };
17767
17768  zoom.translateBy = function(selection, x, y) {
17769    zoom.transform(selection, function() {
17770      return constrain(this.__zoom.translate(
17771        typeof x === "function" ? x.apply(this, arguments) : x,
17772        typeof y === "function" ? y.apply(this, arguments) : y
17773      ), extent.apply(this, arguments), translateExtent);
17774    });
17775  };
17776
17777  zoom.translateTo = function(selection, x, y, p) {
17778    zoom.transform(selection, function() {
17779      var e = extent.apply(this, arguments),
17780          t = this.__zoom,
17781          p0 = p == null ? centroid(e) : typeof p === "function" ? p.apply(this, arguments) : p;
17782      return constrain(identity$9.translate(p0[0], p0[1]).scale(t.k).translate(
17783        typeof x === "function" ? -x.apply(this, arguments) : -x,
17784        typeof y === "function" ? -y.apply(this, arguments) : -y
17785      ), e, translateExtent);
17786    }, p);
17787  };
17788
17789  function scale(transform, k) {
17790    k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k));
17791    return k === transform.k ? transform : new Transform(k, transform.x, transform.y);
17792  }
17793
17794  function translate(transform, p0, p1) {
17795    var x = p0[0] - p1[0] * transform.k, y = p0[1] - p1[1] * transform.k;
17796    return x === transform.x && y === transform.y ? transform : new Transform(transform.k, x, y);
17797  }
17798
17799  function centroid(extent) {
17800    return [(+extent[0][0] + +extent[1][0]) / 2, (+extent[0][1] + +extent[1][1]) / 2];
17801  }
17802
17803  function schedule(transition, transform, point) {
17804    transition
17805        .on("start.zoom", function() { gesture(this, arguments).start(); })
17806        .on("interrupt.zoom end.zoom", function() { gesture(this, arguments).end(); })
17807        .tween("zoom", function() {
17808          var that = this,
17809              args = arguments,
17810              g = gesture(that, args),
17811              e = extent.apply(that, args),
17812              p = point == null ? centroid(e) : typeof point === "function" ? point.apply(that, args) : point,
17813              w = Math.max(e[1][0] - e[0][0], e[1][1] - e[0][1]),
17814              a = that.__zoom,
17815              b = typeof transform === "function" ? transform.apply(that, args) : transform,
17816              i = interpolate(a.invert(p).concat(w / a.k), b.invert(p).concat(w / b.k));
17817          return function(t) {
17818            if (t === 1) t = b; // Avoid rounding error on end.
17819            else { var l = i(t), k = w / l[2]; t = new Transform(k, p[0] - l[0] * k, p[1] - l[1] * k); }
17820            g.zoom(null, t);
17821          };
17822        });
17823  }
17824
17825  function gesture(that, args, clean) {
17826    return (!clean && that.__zooming) || new Gesture(that, args);
17827  }
17828
17829  function Gesture(that, args) {
17830    this.that = that;
17831    this.args = args;
17832    this.active = 0;
17833    this.extent = extent.apply(that, args);
17834    this.taps = 0;
17835  }
17836
17837  Gesture.prototype = {
17838    start: function() {
17839      if (++this.active === 1) {
17840        this.that.__zooming = this;
17841        this.emit("start");
17842      }
17843      return this;
17844    },
17845    zoom: function(key, transform) {
17846      if (this.mouse && key !== "mouse") this.mouse[1] = transform.invert(this.mouse[0]);
17847      if (this.touch0 && key !== "touch") this.touch0[1] = transform.invert(this.touch0[0]);
17848      if (this.touch1 && key !== "touch") this.touch1[1] = transform.invert(this.touch1[0]);
17849      this.that.__zoom = transform;
17850      this.emit("zoom");
17851      return this;
17852    },
17853    end: function() {
17854      if (--this.active === 0) {
17855        delete this.that.__zooming;
17856        this.emit("end");
17857      }
17858      return this;
17859    },
17860    emit: function(type) {
17861      customEvent(new ZoomEvent(zoom, type, this.that.__zoom), listeners.apply, listeners, [type, this.that, this.args]);
17862    }
17863  };
17864
17865  function wheeled() {
17866    if (!filter.apply(this, arguments)) return;
17867    var g = gesture(this, arguments),
17868        t = this.__zoom,
17869        k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t.k * Math.pow(2, wheelDelta.apply(this, arguments)))),
17870        p = mouse(this);
17871
17872    // If the mouse is in the same location as before, reuse it.
17873    // If there were recent wheel events, reset the wheel idle timeout.
17874    if (g.wheel) {
17875      if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) {
17876        g.mouse[1] = t.invert(g.mouse[0] = p);
17877      }
17878      clearTimeout(g.wheel);
17879    }
17880
17881    // If this wheel event won’t trigger a transform change, ignore it.
17882    else if (t.k === k) return;
17883
17884    // Otherwise, capture the mouse point and location at the start.
17885    else {
17886      g.mouse = [p, t.invert(p)];
17887      interrupt(this);
17888      g.start();
17889    }
17890
17891    noevent$2();
17892    g.wheel = setTimeout(wheelidled, wheelDelay);
17893    g.zoom("mouse", constrain(translate(scale(t, k), g.mouse[0], g.mouse[1]), g.extent, translateExtent));
17894
17895    function wheelidled() {
17896      g.wheel = null;
17897      g.end();
17898    }
17899  }
17900
17901  function mousedowned() {
17902    if (touchending || !filter.apply(this, arguments)) return;
17903    var g = gesture(this, arguments, true),
17904        v = select(exports.event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true),
17905        p = mouse(this),
17906        x0 = exports.event.clientX,
17907        y0 = exports.event.clientY;
17908
17909    dragDisable(exports.event.view);
17910    nopropagation$2();
17911    g.mouse = [p, this.__zoom.invert(p)];
17912    interrupt(this);
17913    g.start();
17914
17915    function mousemoved() {
17916      noevent$2();
17917      if (!g.moved) {
17918        var dx = exports.event.clientX - x0, dy = exports.event.clientY - y0;
17919        g.moved = dx * dx + dy * dy > clickDistance2;
17920      }
17921      g.zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = mouse(g.that), g.mouse[1]), g.extent, translateExtent));
17922    }
17923
17924    function mouseupped() {
17925      v.on("mousemove.zoom mouseup.zoom", null);
17926      yesdrag(exports.event.view, g.moved);
17927      noevent$2();
17928      g.end();
17929    }
17930  }
17931
17932  function dblclicked() {
17933    if (!filter.apply(this, arguments)) return;
17934    var t0 = this.__zoom,
17935        p0 = mouse(this),
17936        p1 = t0.invert(p0),
17937        k1 = t0.k * (exports.event.shiftKey ? 0.5 : 2),
17938        t1 = constrain(translate(scale(t0, k1), p0, p1), extent.apply(this, arguments), translateExtent);
17939
17940    noevent$2();
17941    if (duration > 0) select(this).transition().duration(duration).call(schedule, t1, p0);
17942    else select(this).call(zoom.transform, t1);
17943  }
17944
17945  function touchstarted() {
17946    if (!filter.apply(this, arguments)) return;
17947    var touches = exports.event.touches,
17948        n = touches.length,
17949        g = gesture(this, arguments, exports.event.changedTouches.length === n),
17950        started, i, t, p;
17951
17952    nopropagation$2();
17953    for (i = 0; i < n; ++i) {
17954      t = touches[i], p = touch(this, touches, t.identifier);
17955      p = [p, this.__zoom.invert(p), t.identifier];
17956      if (!g.touch0) g.touch0 = p, started = true, g.taps = 1 + !!touchstarting;
17957      else if (!g.touch1 && g.touch0[2] !== p[2]) g.touch1 = p, g.taps = 0;
17958    }
17959
17960    if (touchstarting) touchstarting = clearTimeout(touchstarting);
17961
17962    if (started) {
17963      if (g.taps < 2) touchstarting = setTimeout(function() { touchstarting = null; }, touchDelay);
17964      interrupt(this);
17965      g.start();
17966    }
17967  }
17968
17969  function touchmoved() {
17970    if (!this.__zooming) return;
17971    var g = gesture(this, arguments),
17972        touches = exports.event.changedTouches,
17973        n = touches.length, i, t, p, l;
17974
17975    noevent$2();
17976    if (touchstarting) touchstarting = clearTimeout(touchstarting);
17977    g.taps = 0;
17978    for (i = 0; i < n; ++i) {
17979      t = touches[i], p = touch(this, touches, t.identifier);
17980      if (g.touch0 && g.touch0[2] === t.identifier) g.touch0[0] = p;
17981      else if (g.touch1 && g.touch1[2] === t.identifier) g.touch1[0] = p;
17982    }
17983    t = g.that.__zoom;
17984    if (g.touch1) {
17985      var p0 = g.touch0[0], l0 = g.touch0[1],
17986          p1 = g.touch1[0], l1 = g.touch1[1],
17987          dp = (dp = p1[0] - p0[0]) * dp + (dp = p1[1] - p0[1]) * dp,
17988          dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl;
17989      t = scale(t, Math.sqrt(dp / dl));
17990      p = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
17991      l = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
17992    }
17993    else if (g.touch0) p = g.touch0[0], l = g.touch0[1];
17994    else return;
17995    g.zoom("touch", constrain(translate(t, p, l), g.extent, translateExtent));
17996  }
17997
17998  function touchended() {
17999    if (!this.__zooming) return;
18000    var g = gesture(this, arguments),
18001        touches = exports.event.changedTouches,
18002        n = touches.length, i, t;
18003
18004    nopropagation$2();
18005    if (touchending) clearTimeout(touchending);
18006    touchending = setTimeout(function() { touchending = null; }, touchDelay);
18007    for (i = 0; i < n; ++i) {
18008      t = touches[i];
18009      if (g.touch0 && g.touch0[2] === t.identifier) delete g.touch0;
18010      else if (g.touch1 && g.touch1[2] === t.identifier) delete g.touch1;
18011    }
18012    if (g.touch1 && !g.touch0) g.touch0 = g.touch1, delete g.touch1;
18013    if (g.touch0) g.touch0[1] = this.__zoom.invert(g.touch0[0]);
18014    else {
18015      g.end();
18016      // If this was a dbltap, reroute to the (optional) dblclick.zoom handler.
vendor: 4,201 bytes, lines 18017-18145
18017      if (g.taps === 2) {
18018        var p = select(this).on("dblclick.zoom");
18019        if (p) p.apply(this, arguments);
18020      }
18021    }
18022  }
18023
18024  zoom.wheelDelta = function(_) {
18025    return arguments.length ? (wheelDelta = typeof _ === "function" ? _ : constant$d(+_), zoom) : wheelDelta;
18026  };
18027
18028  zoom.filter = function(_) {
18029    return arguments.length ? (filter = typeof _ === "function" ? _ : constant$d(!!_), zoom) : filter;
18030  };
18031
18032  zoom.touchable = function(_) {
18033    return arguments.length ? (touchable = typeof _ === "function" ? _ : constant$d(!!_), zoom) : touchable;
18034  };
18035
18036  zoom.extent = function(_) {
18037    return arguments.length ? (extent = typeof _ === "function" ? _ : constant$d([[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]]), zoom) : extent;
18038  };
18039
18040  zoom.scaleExtent = function(_) {
18041    return arguments.length ? (scaleExtent[0] = +_[0], scaleExtent[1] = +_[1], zoom) : [scaleExtent[0], scaleExtent[1]];
18042  };
18043
18044  zoom.translateExtent = function(_) {
18045    return arguments.length ? (translateExtent[0][0] = +_[0][0], translateExtent[1][0] = +_[1][0], translateExtent[0][1] = +_[0][1], translateExtent[1][1] = +_[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]];
18046  };
18047
18048  zoom.constrain = function(_) {
18049    return arguments.length ? (constrain = _, zoom) : constrain;
18050  };
18051
18052  zoom.duration = function(_) {
18053    return arguments.length ? (duration = +_, zoom) : duration;
18054  };
18055
18056  zoom.interpolate = function(_) {
18057    return arguments.length ? (interpolate = _, zoom) : interpolate;
18058  };
18059
18060  zoom.on = function() {
18061    var value = listeners.on.apply(listeners, arguments);
18062    return value === listeners ? zoom : value;
18063  };
18064
18065  zoom.clickDistance = function(_) {
18066    return arguments.length ? (clickDistance2 = (_ = +_) * _, zoom) : Math.sqrt(clickDistance2);
18067  };
18068
18069  return zoom;
18070}
18071
18072exports.FormatSpecifier = FormatSpecifier;
18073exports.active = active;
18074exports.arc = arc;
18075exports.area = area$3;
18076exports.areaRadial = areaRadial;
18077exports.ascending = ascending;
18078exports.autoType = autoType;
18079exports.axisBottom = axisBottom;
18080exports.axisLeft = axisLeft;
18081exports.axisRight = axisRight;
18082exports.axisTop = axisTop;
18083exports.bisect = bisectRight;
18084exports.bisectLeft = bisectLeft;
18085exports.bisectRight = bisectRight;
18086exports.bisector = bisector;
18087exports.blob = blob;
18088exports.brush = brush;
18089exports.brushSelection = brushSelection;
18090exports.brushX = brushX;
18091exports.brushY = brushY;
18092exports.buffer = buffer;
18093exports.chord = chord;
18094exports.clientPoint = point;
18095exports.cluster = cluster;
18096exports.color = color;
18097exports.contourDensity = density;
18098exports.contours = contours;
18099exports.create = create;
18100exports.creator = creator;
18101exports.cross = cross;
18102exports.csv = csv$1;
18103exports.csvFormat = csvFormat;
18104exports.csvFormatBody = csvFormatBody;
18105exports.csvFormatRow = csvFormatRow;
18106exports.csvFormatRows = csvFormatRows;
18107exports.csvFormatValue = csvFormatValue;
18108exports.csvParse = csvParse;
18109exports.csvParseRows = csvParseRows;
18110exports.cubehelix = cubehelix;
18111exports.curveBasis = basis$2;
18112exports.curveBasisClosed = basisClosed$1;
18113exports.curveBasisOpen = basisOpen;
18114exports.curveBundle = bundle;
18115exports.curveCardinal = cardinal;
18116exports.curveCardinalClosed = cardinalClosed;
18117exports.curveCardinalOpen = cardinalOpen;
18118exports.curveCatmullRom = catmullRom;
18119exports.curveCatmullRomClosed = catmullRomClosed;
18120exports.curveCatmullRomOpen = catmullRomOpen;
18121exports.curveLinear = curveLinear;
18122exports.curveLinearClosed = linearClosed;
18123exports.curveMonotoneX = monotoneX;
18124exports.curveMonotoneY = monotoneY;
18125exports.curveNatural = natural;
18126exports.curveStep = step;
18127exports.curveStepAfter = stepAfter;
18128exports.curveStepBefore = stepBefore;
18129exports.customEvent = customEvent;
18130exports.descending = descending;
18131exports.deviation = deviation;
18132exports.dispatch = dispatch;
18133exports.drag = drag;
18134exports.dragDisable = dragDisable;
18135exports.dragEnable = yesdrag;
18136exports.dsv = dsv;
18137exports.dsvFormat = dsvFormat;
18138exports.easeBack = backInOut;
18139exports.easeBackIn = backIn;
18140exports.easeBackInOut = backInOut;
18141exports.easeBackOut = backOut;
18142exports.easeBounce = bounceOut;
18143exports.easeBounceIn = bounceIn;
18144exports.easeBounceInOut = bounceInOut;
18145exports.easeBounceOut = bounceOut;
18146exports.easeCircle = circleInOut;
18147exports.easeCircleIn = circleIn;
18148exports.easeCircleInOut = circleInOut;
18149exports.easeCircleOut = circleOut;
18150exports.easeCubic = cubicInOut;
18151exports.easeCubicIn = cubicIn;
18152exports.easeCubicInOut = cubicInOut;
18153exports.easeCubicOut = cubicOut;
18154exports.easeElastic = elasticOut;
18155exports.easeElasticIn = elasticIn;
18156exports.easeElasticInOut = elasticInOut;
18157exports.easeElasticOut = elasticOut;
18158exports.easeExp = expInOut;
18159exports.easeExpIn = expIn;
18160exports.easeExpInOut = expInOut;
18161exports.easeExpOut = expOut;
18162exports.easeLinear = linear$1;
18163exports.easePoly = polyInOut;
18164exports.easePolyIn = polyIn;
18165exports.easePolyInOut = polyInOut;
18166exports.easePolyOut = polyOut;
18167exports.easeQuad = quadInOut;
18168exports.easeQuadIn = quadIn;
18169exports.easeQuadInOut = quadInOut;
18170exports.easeQuadOut = quadOut;
18171exports.easeSin = sinInOut;
18172exports.easeSinIn = sinIn;
18173exports.easeSinInOut = sinInOut;
18174exports.easeSinOut = sinOut;
18175exports.entries = entries;
18176exports.extent = extent;
18177exports.forceCenter = center$1;
18178exports.forceCollide = collide;
18179exports.forceLink = link;
18180exports.forceManyBody = manyBody;
18181exports.forceRadial = radial;
18182exports.forceSimulation = simulation;
18183exports.forceX = x$2;
18184exports.forceY = y$2;
18185exports.formatDefaultLocale = defaultLocale;
18186exports.formatLocale = formatLocale;
18187exports.formatSpecifier = formatSpecifier;
18188exports.geoAlbers = albers;
18189exports.geoAlbersUsa = albersUsa;
18190exports.geoArea = area$1;
18191exports.geoAzimuthalEqualArea = azimuthalEqualArea;
18192exports.geoAzimuthalEqualAreaRaw = azimuthalEqualAreaRaw;
18193exports.geoAzimuthalEquidistant = azimuthalEquidistant;
18194exports.geoAzimuthalEquidistantRaw = azimuthalEquidistantRaw;
18195exports.geoBounds = bounds;
18196exports.geoCentroid = centroid;
18197exports.geoCircle = circle;
18198exports.geoClipAntimeridian = clipAntimeridian;
18199exports.geoClipCircle = clipCircle;
18200exports.geoClipExtent = extent$1;
18201exports.geoClipRectangle = clipRectangle;
18202exports.geoConicConformal = conicConformal;
18203exports.geoConicConformalRaw = conicConformalRaw;
18204exports.geoConicEqualArea = conicEqualArea;
18205exports.geoConicEqualAreaRaw = conicEqualAreaRaw;
18206exports.geoConicEquidistant = conicEquidistant;
18207exports.geoConicEquidistantRaw = conicEquidistantRaw;
18208exports.geoContains = contains$1;
18209exports.geoDistance = distance;
18210exports.geoEqualEarth = equalEarth;
18211exports.geoEqualEarthRaw = equalEarthRaw;
18212exports.geoEquirectangular = equirectangular;
18213exports.geoEquirectangularRaw = equirectangularRaw;
18214exports.geoGnomonic = gnomonic;
18215exports.geoGnomonicRaw = gnomonicRaw;
18216exports.geoGraticule = graticule;
18217exports.geoGraticule10 = graticule10;
18218exports.geoIdentity = identity$5;
18219exports.geoInterpolate = interpolate$1;
18220exports.geoLength = length$1;
18221exports.geoMercator = mercator;
18222exports.geoMercatorRaw = mercatorRaw;
18223exports.geoNaturalEarth1 = naturalEarth1;
18224exports.geoNaturalEarth1Raw = naturalEarth1Raw;
18225exports.geoOrthographic = orthographic;
18226exports.geoOrthographicRaw = orthographicRaw;
18227exports.geoPath = index$1;
18228exports.geoProjection = projection;
18229exports.geoProjectionMutator = projectionMutator;
18230exports.geoRotation = rotation;
18231exports.geoStereographic = stereographic;
18232exports.geoStereographicRaw = stereographicRaw;
18233exports.geoStream = geoStream;
18234exports.geoTransform = transform;
18235exports.geoTransverseMercator = transverseMercator;
18236exports.geoTransverseMercatorRaw = transverseMercatorRaw;
18237exports.gray = gray;
18238exports.hcl = hcl;
18239exports.hierarchy = hierarchy;
18240exports.histogram = histogram;
18241exports.hsl = hsl;
18242exports.html = html;
18243exports.image = image;
18244exports.interpolate = interpolateValue;
18245exports.interpolateArray = array$1;
18246exports.interpolateBasis = basis$1;
18247exports.interpolateBasisClosed = basisClosed;
18248exports.interpolateBlues = Blues;
18249exports.interpolateBrBG = BrBG;
18250exports.interpolateBuGn = BuGn;
18251exports.interpolateBuPu = BuPu;
18252exports.interpolateCividis = cividis;
18253exports.interpolateCool = cool;
18254exports.interpolateCubehelix = cubehelix$2;
18255exports.interpolateCubehelixDefault = cubehelix$3;
18256exports.interpolateCubehelixLong = cubehelixLong;
18257exports.interpolateDate = date;
18258exports.interpolateDiscrete = discrete;
18259exports.interpolateGnBu = GnBu;
18260exports.interpolateGreens = Greens;
18261exports.interpolateGreys = Greys;
18262exports.interpolateHcl = hcl$2;
18263exports.interpolateHclLong = hclLong;
18264exports.interpolateHsl = hsl$2;
18265exports.interpolateHslLong = hslLong;
18266exports.interpolateHue = hue$1;
18267exports.interpolateInferno = inferno;
18268exports.interpolateLab = lab$1;
18269exports.interpolateMagma = magma;
18270exports.interpolateNumber = interpolateNumber;
18271exports.interpolateNumberArray = numberArray;
18272exports.interpolateObject = object;
18273exports.interpolateOrRd = OrRd;
18274exports.interpolateOranges = Oranges;
18275exports.interpolatePRGn = PRGn;
18276exports.interpolatePiYG = PiYG;
18277exports.interpolatePlasma = plasma;
18278exports.interpolatePuBu = PuBu;
18279exports.interpolatePuBuGn = PuBuGn;
18280exports.interpolatePuOr = PuOr;
18281exports.interpolatePuRd = PuRd;
18282exports.interpolatePurples = Purples;
18283exports.interpolateRainbow = rainbow;
18284exports.interpolateRdBu = RdBu;
18285exports.interpolateRdGy = RdGy;
18286exports.interpolateRdPu = RdPu;
18287exports.interpolateRdYlBu = RdYlBu;
18288exports.interpolateRdYlGn = RdYlGn;
18289exports.interpolateReds = Reds;
18290exports.interpolateRgb = interpolateRgb;
18291exports.interpolateRgbBasis = rgbBasis;
18292exports.interpolateRgbBasisClosed = rgbBasisClosed;
18293exports.interpolateRound = interpolateRound;
18294exports.interpolateSinebow = sinebow;
18295exports.interpolateSpectral = Spectral;
18296exports.interpolateString = interpolateString;
18297exports.interpolateTransformCss = interpolateTransformCss;
18298exports.interpolateTransformSvg = interpolateTransformSvg;
18299exports.interpolateTurbo = turbo;
18300exports.interpolateViridis = viridis;
18301exports.interpolateWarm = warm;
18302exports.interpolateYlGn = YlGn;
18303exports.interpolateYlGnBu = YlGnBu;
18304exports.interpolateYlOrBr = YlOrBr;
18305exports.interpolateYlOrRd = YlOrRd;
18306exports.interpolateZoom = interpolateZoom;
18307exports.interrupt = interrupt;
18308exports.interval = interval$1;
18309exports.isoFormat = formatIso;
18310exports.isoParse = parseIso;
18311exports.json = json;
18312exports.keys = keys;
18313exports.lab = lab;
18314exports.lch = lch;
18315exports.line = line;
18316exports.lineRadial = lineRadial$1;
18317exports.linkHorizontal = linkHorizontal;
18318exports.linkRadial = linkRadial;
18319exports.linkVertical = linkVertical;
18320exports.local = local;
18321exports.map = map$1;
18322exports.matcher = matcher;
18323exports.max = max;
18324exports.mean = mean;
18325exports.median = median;
18326exports.merge = merge;
18327exports.min = min;
18328exports.mouse = mouse;
18329exports.namespace = namespace;
18330exports.namespaces = namespaces;
18331exports.nest = nest;
18332exports.now = now;
18333exports.pack = index$2;
18334exports.packEnclose = enclose;
18335exports.packSiblings = siblings;
18336exports.pairs = pairs;
18337exports.partition = partition;
18338exports.path = path;
18339exports.permute = permute;
18340exports.pie = pie;
18341exports.piecewise = piecewise;
18342exports.pointRadial = pointRadial;
18343exports.polygonArea = area$2;
18344exports.polygonCentroid = centroid$1;
18345exports.polygonContains = contains$2;
18346exports.polygonHull = hull;
18347exports.polygonLength = length$2;
18348exports.precisionFixed = precisionFixed;
18349exports.precisionPrefix = precisionPrefix;
18350exports.precisionRound = precisionRound;
18351exports.quadtree = quadtree;
18352exports.quantile = threshold;
18353exports.quantize = quantize;
18354exports.radialArea = areaRadial;
18355exports.radialLine = lineRadial$1;
18356exports.randomBates = bates;
18357exports.randomExponential = exponential$1;
18358exports.randomIrwinHall = irwinHall;
18359exports.randomLogNormal = logNormal;
18360exports.randomNormal = normal;
18361exports.randomUniform = uniform;
18362exports.range = sequence;
18363exports.rgb = rgb;
18364exports.ribbon = ribbon;
18365exports.scaleBand = band;
18366exports.scaleDiverging = diverging;
18367exports.scaleDivergingLog = divergingLog;
18368exports.scaleDivergingPow = divergingPow;
18369exports.scaleDivergingSqrt = divergingSqrt;
18370exports.scaleDivergingSymlog = divergingSymlog;
18371exports.scaleIdentity = identity$7;
18372exports.scaleImplicit = implicit;
18373exports.scaleLinear = linear$2;
18374exports.scaleLog = log$1;
18375exports.scaleOrdinal = ordinal;
18376exports.scalePoint = point$1;
18377exports.scalePow = pow$1;
18378exports.scaleQuantile = quantile;
18379exports.scaleQuantize = quantize$1;
18380exports.scaleSequential = sequential;
18381exports.scaleSequentialLog = sequentialLog;
18382exports.scaleSequentialPow = sequentialPow;
18383exports.scaleSequentialQuantile = sequentialQuantile;
18384exports.scaleSequentialSqrt = sequentialSqrt;
18385exports.scaleSequentialSymlog = sequentialSymlog;
18386exports.scaleSqrt = sqrt$1;
18387exports.scaleSymlog = symlog;
18388exports.scaleThreshold = threshold$1;
18389exports.scaleTime = time;
18390exports.scaleUtc = utcTime;
18391exports.scan = scan;
18392exports.schemeAccent = Accent;
18393exports.schemeBlues = scheme$l;
18394exports.schemeBrBG = scheme;
18395exports.schemeBuGn = scheme$9;
18396exports.schemeBuPu = scheme$a;
18397exports.schemeCategory10 = category10;
18398exports.schemeDark2 = Dark2;
18399exports.schemeGnBu = scheme$b;
18400exports.schemeGreens = scheme$m;
18401exports.schemeGreys = scheme$n;
18402exports.schemeOrRd = scheme$c;
18403exports.schemeOranges = scheme$q;
18404exports.schemePRGn = scheme$1;
18405exports.schemePaired = Paired;
18406exports.schemePastel1 = Pastel1;
18407exports.schemePastel2 = Pastel2;
18408exports.schemePiYG = scheme$2;
18409exports.schemePuBu = scheme$e;
18410exports.schemePuBuGn = scheme$d;
18411exports.schemePuOr = scheme$3;
18412exports.schemePuRd = scheme$f;
18413exports.schemePurples = scheme$o;
18414exports.schemeRdBu = scheme$4;
18415exports.schemeRdGy = scheme$5;
18416exports.schemeRdPu = scheme$g;
18417exports.schemeRdYlBu = scheme$6;
18418exports.schemeRdYlGn = scheme$7;
18419exports.schemeReds = scheme$p;
18420exports.schemeSet1 = Set1;
18421exports.schemeSet2 = Set2;
18422exports.schemeSet3 = Set3;
18423exports.schemeSpectral = scheme$8;
18424exports.schemeTableau10 = Tableau10;
18425exports.schemeYlGn = scheme$i;
18426exports.schemeYlGnBu = scheme$h;
18427exports.schemeYlOrBr = scheme$j;
18428exports.schemeYlOrRd = scheme$k;
18429exports.select = select;
18430exports.selectAll = selectAll;
18431exports.selection = selection;
18432exports.selector = selector;
18433exports.selectorAll = selectorAll;
18434exports.set = set$2;
18435exports.shuffle = shuffle;
18436exports.stack = stack;
18437exports.stackOffsetDiverging = diverging$1;
18438exports.stackOffsetExpand = expand;
18439exports.stackOffsetNone = none$1;
18440exports.stackOffsetSilhouette = silhouette;
18441exports.stackOffsetWiggle = wiggle;
18442exports.stackOrderAppearance = appearance;
18443exports.stackOrderAscending = ascending$3;
18444exports.stackOrderDescending = descending$2;
18445exports.stackOrderInsideOut = insideOut;
18446exports.stackOrderNone = none$2;
18447exports.stackOrderReverse = reverse;
18448exports.stratify = stratify;
18449exports.style = styleValue;
18450exports.sum = sum;
18451exports.svg = svg;
18452exports.symbol = symbol;
18453exports.symbolCircle = circle$2;
18454exports.symbolCross = cross$2;
18455exports.symbolDiamond = diamond;
18456exports.symbolSquare = square;
18457exports.symbolStar = star;
18458exports.symbolTriangle = triangle;
18459exports.symbolWye = wye;
18460exports.symbols = symbols;
18461exports.text = text;
18462exports.thresholdFreedmanDiaconis = freedmanDiaconis;
18463exports.thresholdScott = scott;
18464exports.thresholdSturges = thresholdSturges;
18465exports.tickFormat = tickFormat;
18466exports.tickIncrement = tickIncrement;
18467exports.tickStep = tickStep;
18468exports.ticks = ticks;
18469exports.timeDay = day;
18470exports.timeDays = days;
18471exports.timeFormatDefaultLocale = defaultLocale$1;
18472exports.timeFormatLocale = formatLocale$1;
18473exports.timeFriday = friday;
18474exports.timeFridays = fridays;
18475exports.timeHour = hour;
18476exports.timeHours = hours;
18477exports.timeInterval = newInterval;
18478exports.timeMillisecond = millisecond;
18479exports.timeMilliseconds = milliseconds;
18480exports.timeMinute = minute;
18481exports.timeMinutes = minutes;
18482exports.timeMonday = monday;
18483exports.timeMondays = mondays;
18484exports.timeMonth = month;
18485exports.timeMonths = months;
18486exports.timeSaturday = saturday;
18487exports.timeSaturdays = saturdays;
18488exports.timeSecond = second;
18489exports.timeSeconds = seconds;
18490exports.timeSunday = sunday;
18491exports.timeSundays = sundays;
18492exports.timeThursday = thursday;
18493exports.timeThursdays = thursdays;
18494exports.timeTuesday = tuesday;
18495exports.timeTuesdays = tuesdays;
18496exports.timeWednesday = wednesday;
18497exports.timeWednesdays = wednesdays;
18498exports.timeWeek = sunday;
18499exports.timeWeeks = sundays;
18500exports.timeYear = year;
18501exports.timeYears = years;
18502exports.timeout = timeout$1;
18503exports.timer = timer;
18504exports.timerFlush = timerFlush;
18505exports.touch = touch;
18506exports.touches = touches;
18507exports.transition = transition;
18508exports.transpose = transpose;
18509exports.tree = tree;
18510exports.treemap = index$3;
18511exports.treemapBinary = binary;
18512exports.treemapDice = treemapDice;
18513exports.treemapResquarify = resquarify;
18514exports.treemapSlice = treemapSlice;
18515exports.treemapSliceDice = sliceDice;
18516exports.treemapSquarify = squarify;
18517exports.tsv = tsv$1;
18518exports.tsvFormat = tsvFormat;
18519exports.tsvFormatBody = tsvFormatBody;
18520exports.tsvFormatRow = tsvFormatRow;
18521exports.tsvFormatRows = tsvFormatRows;
18522exports.tsvFormatValue = tsvFormatValue;
18523exports.tsvParse = tsvParse;
18524exports.tsvParseRows = tsvParseRows;
18525exports.utcDay = utcDay;
18526exports.utcDays = utcDays;
18527exports.utcFriday = utcFriday;
18528exports.utcFridays = utcFridays;
18529exports.utcHour = utcHour;
18530exports.utcHours = utcHours;
18531exports.utcMillisecond = millisecond;
18532exports.utcMilliseconds = milliseconds;
18533exports.utcMinute = utcMinute;
18534exports.utcMinutes = utcMinutes;
18535exports.utcMonday = utcMonday;
18536exports.utcMondays = utcMondays;
18537exports.utcMonth = utcMonth;
18538exports.utcMonths = utcMonths;
18539exports.utcSaturday = utcSaturday;
18540exports.utcSaturdays = utcSaturdays;
18541exports.utcSecond = second;
18542exports.utcSeconds = seconds;
18543exports.utcSunday = utcSunday;
18544exports.utcSundays = utcSundays;
18545exports.utcThursday = utcThursday;
18546exports.utcThursdays = utcThursdays;
18547exports.utcTuesday = utcTuesday;
18548exports.utcTuesdays = utcTuesdays;
18549exports.utcWednesday = utcWednesday;
18550exports.utcWednesdays = utcWednesdays;
18551exports.utcWeek = utcSunday;
18552exports.utcWeeks = utcSundays;
18553exports.utcYear = utcYear;
18554exports.utcYears = utcYears;
18555exports.values = values;
18556exports.variance = variance;
18557exports.version = version;
18558exports.voronoi = voronoi;
18559exports.window = defaultView;
18560exports.xml = xml;
18561exports.zip = zip;
18562exports.zoom = zoom;
18563exports.zoomIdentity = identity$9;
18564exports.zoomTransform = transform$1;
18565
18566Object.defineProperty(exports, '__esModule', { value: true });
18567
18568}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.