UNPKG

@carbon/charts

Version:
1,568 lines 435 kB
import { t as Hr, $ as il, i as al, a0 as rl, a1 as Br, a2 as zr, a3 as ol, a4 as ll, a5 as cl, a6 as ul, a7 as Ur, a8 as va, a9 as nn, g as O, p as Kt, a as en, C as ya, aa as xt, w as At, ab as wn, E as Ea, H as jt, ac as Fr, ad as Os, c as hl, ae as Ee, I as ui, K as hi, e as se, af as vn, ag as ge, f as ve, x as me, ah as dl, h as je, O as pl, ai as Re, z as Et, l as qt, aj as Gt, ak as fl, M as gl, al as Wr, y as _t, q as un, n as Hn, am as Ns, an as ml, ao as vl, ap as di, aq as xa, A as Le, ar as Sa, as as Xr, at as yl } from "./color-scale-utils-ycwO-Ibq.mjs"; import { y as at, $ as T, N as Tt, r as Te, q as Be, L as El, A as te, m as nt, s as Ae, W as Ke, S as kt, e as J, Z as ze, i as Xt, f as Ta, J as Ps, d as xl, F as Bn, n as $s, H as Vs, C as Gs, p as zn, b as ba, D as Hs, U as Sl, x as Me, a0 as Un, O as Bs } from "./axis-scales-CPuwbFQf.mjs"; import { R as lt } from "./a11y-ePqvrObQ.mjs"; import { t as ns, s as D, h as Oa, e as Ut, c as ss, f as we, g as le, m as zs, i as La, j as Aa, k as Je, l as Rt, n as Ma, o as Tl, q as bl, u as Hi, D as I, v as Ol, w as pi, G as wa, x as Bi, y as Ll, a as Al, p as bt, r as Ca, b as Ml } from "./angle-utils-CqlSifly.mjs"; import { b as Yr, c as pt, a as zi, s as wl } from "./array-j65rN_vo.mjs"; function Cl(i, t, e, n) { for (var s = -1, a = i == null ? 0 : i.length; ++s < a; ) e = t(e, i[s], s, i); return e; } function kl(i) { return function(t) { return i == null ? void 0 : i[t]; }; } var _l = { // Latin-1 Supplement block. À: "A", Á: "A", Â: "A", Ã: "A", Ä: "A", Å: "A", à: "a", á: "a", â: "a", ã: "a", ä: "a", å: "a", Ç: "C", ç: "c", Ð: "D", ð: "d", È: "E", É: "E", Ê: "E", Ë: "E", è: "e", é: "e", ê: "e", ë: "e", Ì: "I", Í: "I", Î: "I", Ï: "I", ì: "i", í: "i", î: "i", ï: "i", Ñ: "N", ñ: "n", Ò: "O", Ó: "O", Ô: "O", Õ: "O", Ö: "O", Ø: "O", ò: "o", ó: "o", ô: "o", õ: "o", ö: "o", ø: "o", Ù: "U", Ú: "U", Û: "U", Ü: "U", ù: "u", ú: "u", û: "u", ü: "u", Ý: "Y", ý: "y", ÿ: "y", Æ: "Ae", æ: "ae", Þ: "Th", þ: "th", ß: "ss", // Latin Extended-A block. Ā: "A", Ă: "A", Ą: "A", ā: "a", ă: "a", ą: "a", Ć: "C", Ĉ: "C", Ċ: "C", Č: "C", ć: "c", ĉ: "c", ċ: "c", č: "c", Ď: "D", Đ: "D", ď: "d", đ: "d", Ē: "E", Ĕ: "E", Ė: "E", Ę: "E", Ě: "E", ē: "e", ĕ: "e", ė: "e", ę: "e", ě: "e", Ĝ: "G", Ğ: "G", Ġ: "G", Ģ: "G", ĝ: "g", ğ: "g", ġ: "g", ģ: "g", Ĥ: "H", Ħ: "H", ĥ: "h", ħ: "h", Ĩ: "I", Ī: "I", Ĭ: "I", Į: "I", İ: "I", ĩ: "i", ī: "i", ĭ: "i", į: "i", ı: "i", Ĵ: "J", ĵ: "j", Ķ: "K", ķ: "k", ĸ: "k", Ĺ: "L", Ļ: "L", Ľ: "L", Ŀ: "L", Ł: "L", ĺ: "l", ļ: "l", ľ: "l", ŀ: "l", ł: "l", Ń: "N", Ņ: "N", Ň: "N", Ŋ: "N", ń: "n", ņ: "n", ň: "n", ŋ: "n", Ō: "O", Ŏ: "O", Ő: "O", ō: "o", ŏ: "o", ő: "o", Ŕ: "R", Ŗ: "R", Ř: "R", ŕ: "r", ŗ: "r", ř: "r", Ś: "S", Ŝ: "S", Ş: "S", Š: "S", ś: "s", ŝ: "s", ş: "s", š: "s", Ţ: "T", Ť: "T", Ŧ: "T", ţ: "t", ť: "t", ŧ: "t", Ũ: "U", Ū: "U", Ŭ: "U", Ů: "U", Ű: "U", Ų: "U", ũ: "u", ū: "u", ŭ: "u", ů: "u", ű: "u", ų: "u", Ŵ: "W", ŵ: "w", Ŷ: "Y", ŷ: "y", Ÿ: "Y", Ź: "Z", Ż: "Z", Ž: "Z", ź: "z", ż: "z", ž: "z", IJ: "IJ", ij: "ij", Œ: "Oe", œ: "oe", ʼn: "'n", ſ: "s" }, Il = kl(_l), Rl = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Dl = "\\u0300-\\u036f", Nl = "\\ufe20-\\ufe2f", Pl = "\\u20d0-\\u20ff", $l = Dl + Nl + Pl, Vl = "[" + $l + "]", Gl = RegExp(Vl, "g"); function Hl(i) { return i = Hr(i), i && i.replace(Rl, Il).replace(Gl, ""); } var Bl = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; function zl(i) { return i.match(Bl) || []; } var Ul = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; function Fl(i) { return Ul.test(i); } var Zr = "\\ud800-\\udfff", Wl = "\\u0300-\\u036f", Xl = "\\ufe20-\\ufe2f", Yl = "\\u20d0-\\u20ff", Zl = Wl + Xl + Yl, qr = "\\u2700-\\u27bf", jr = "a-z\\xdf-\\xf6\\xf8-\\xff", ql = "\\xac\\xb1\\xd7\\xf7", jl = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Kl = "\\u2000-\\u206f", Jl = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", Kr = "A-Z\\xc0-\\xd6\\xd8-\\xde", Ql = "\\ufe0e\\ufe0f", Jr = ql + jl + Kl + Jl, Qr = "['’]", ka = "[" + Jr + "]", tc = "[" + Zl + "]", to = "\\d+", ec = "[" + qr + "]", eo = "[" + jr + "]", no = "[^" + Zr + Jr + to + qr + jr + Kr + "]", nc = "\\ud83c[\\udffb-\\udfff]", sc = "(?:" + tc + "|" + nc + ")", ic = "[^" + Zr + "]", so = "(?:\\ud83c[\\udde6-\\uddff]){2}", io = "[\\ud800-\\udbff][\\udc00-\\udfff]", Ye = "[" + Kr + "]", ac = "\\u200d", _a = "(?:" + eo + "|" + no + ")", rc = "(?:" + Ye + "|" + no + ")", Ia = "(?:" + Qr + "(?:d|ll|m|re|s|t|ve))?", Ra = "(?:" + Qr + "(?:D|LL|M|RE|S|T|VE))?", ao = sc + "?", ro = "[" + Ql + "]?", oc = "(?:" + ac + "(?:" + [ic, so, io].join("|") + ")" + ro + ao + ")*", lc = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", cc = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", uc = ro + ao + oc, hc = "(?:" + [ec, so, io].join("|") + ")" + uc, dc = RegExp([ Ye + "?" + eo + "+" + Ia + "(?=" + [ka, Ye, "$"].join("|") + ")", rc + "+" + Ra + "(?=" + [ka, Ye + _a, "$"].join("|") + ")", Ye + "?" + _a + "+" + Ia, Ye + "+" + Ra, cc, lc, to, hc ].join("|"), "g"); function pc(i) { return i.match(dc) || []; } function fc(i, t, e) { return i = Hr(i), t = t, t === void 0 ? Fl(i) ? pc(i) : zl(i) : i.match(t) || []; } var gc = "['’]", mc = RegExp(gc, "g"); function vc(i) { return function(t) { return Cl(fc(Hl(t).replace(mc, "")), i, ""); }; } function yc(i, t, e) { return i === i && (e !== void 0 && (i = i <= e ? i : e), t !== void 0 && (i = i >= t ? i : t)), i; } function oo(i, t, e) { return e === void 0 && (e = t, t = void 0), e !== void 0 && (e = ns(e), e = e === e ? e : 0), t !== void 0 && (t = ns(t), t = t === t ? t : 0), yc(ns(i), t, e); } var Ec = "Expected a function"; function xc(i, t, e) { if (typeof i != "function") throw new TypeError(Ec); return setTimeout(function() { i.apply(void 0, e); }, t); } var Sc = il(function(i, t, e) { return xc(i, ns(t) || 0, e); }); function Tc(i, t) { var e = -1, n = al(i) ? Array(i.length) : []; return Yr(i, function(s, a, r) { n[++e] = t(s, a, r); }), n; } function bc(i, t) { var e = zr(i) ? rl : Tc; return e(i, Br(t)); } var Oc = 1 / 0; function Lc(i, t) { return ol(bc(i, t), Oc); } function lo(i, t) { return ll(i, t); } var Ue = vc(function(i, t, e) { return i + (e ? "-" : "") + t.toLowerCase(); }); function Ac(i, t) { var e; return Yr(i, function(n, s, a) { return e = t(n, s, a), !e; }), !!e; } function Mc(i, t, e) { var n = zr(i) ? cl : Ac; return n(i, Br(t)); } class De { constructor() { this._partials = new Float64Array(32), this._n = 0; } add(t) { const e = this._partials; let n = 0; for (let s = 0; s < this._n && s < 32; s++) { const a = e[s], r = t + a, o = Math.abs(t) < Math.abs(a) ? t - (r - a) : a - (r - t); o && (e[n++] = o), t = r; } return e[n] = t, this._n = n + 1, this; } valueOf() { const t = this._partials; let e = this._n, n, s, a, r = 0; if (e > 0) { for (r = t[--e]; e > 0 && (n = r, s = t[--e], r = n + s, a = s - (r - n), !a); ) ; e > 0 && (a < 0 && t[e - 1] < 0 || a > 0 && t[e - 1] > 0) && (s = a * 2, n = r + s, s == n - r && (r = n)); } return r; } } function* wc(i) { for (const t of i) yield* t; } function co(i) { return Array.from(wc(i)); } function Cc(i) { return i; } var is = 1, as = 2, fi = 3, yn = 4, Da = 1e-6; function kc(i) { return "translate(" + i + ",0)"; } function _c(i) { return "translate(0," + i + ")"; } function Ic(i) { return (t) => +i(t); } function Rc(i, t) { return t = Math.max(0, i.bandwidth() - t * 2) / 2, i.round() && (t = Math.round(t)), (e) => +i(e) + t; } function Dc() { return !this.__axis; } function Ls(i, t) { var e = [], n = null, s = null, a = 6, r = 6, o = 3, c = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, l = i === is || i === yn ? -1 : 1, h = i === yn || i === as ? "x" : "y", d = i === is || i === fi ? kc : _c; function u(p) { var f = n ?? (t.ticks ? t.ticks.apply(t, e) : t.domain()), g = s ?? (t.tickFormat ? t.tickFormat.apply(t, e) : Cc), m = Math.max(a, 0) + o, y = t.range(), S = +y[0] + c, v = +y[y.length - 1] + c, E = (t.bandwidth ? Rc : Ic)(t.copy(), c), x = p.selection ? p.selection() : p, b = x.selectAll(".domain").data([null]), _ = x.selectAll(".tick").data(f, t).order(), k = _.exit(), G = _.enter().append("g").attr("class", "tick"), R = _.select("line"), A = _.select("text"); b = b.merge(b.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), _ = _.merge(G), R = R.merge(G.append("line").attr("stroke", "currentColor").attr(h + "2", l * a)), A = A.merge(G.append("text").attr("fill", "currentColor").attr(h, l * m).attr("dy", i === is ? "0em" : i === fi ? "0.71em" : "0.32em")), p !== x && (b = b.transition(p), _ = _.transition(p), R = R.transition(p), A = A.transition(p), k = k.transition(p).attr("opacity", Da).attr("transform", function(H) { return isFinite(H = E(H)) ? d(H + c) : this.getAttribute("transform"); }), G.attr("opacity", Da).attr("transform", function(H) { var N = this.parentNode.__axis; return d((N && isFinite(N = N(H)) ? N : E(H)) + c); })), k.remove(), b.attr("d", i === yn || i === as ? r ? "M" + l * r + "," + S + "H" + c + "V" + v + "H" + l * r : "M" + c + "," + S + "V" + v : r ? "M" + S + "," + l * r + "V" + c + "H" + v + "V" + l * r : "M" + S + "," + c + "H" + v), _.attr("opacity", 1).attr("transform", function(H) { return d(E(H) + c); }), R.attr(h + "2", l * a), A.attr(h, l * m).text(g), x.filter(Dc).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", i === as ? "start" : i === yn ? "end" : "middle"), x.each(function() { this.__axis = E; }); } return u.scale = function(p) { return arguments.length ? (t = p, u) : t; }, u.ticks = function() { return e = Array.from(arguments), u; }, u.tickArguments = function(p) { return arguments.length ? (e = p == null ? [] : Array.from(p), u) : e.slice(); }, u.tickValues = function(p) { return arguments.length ? (n = p == null ? null : Array.from(p), u) : n && n.slice(); }, u.tickFormat = function(p) { return arguments.length ? (s = p, u) : s; }, u.tickSize = function(p) { return arguments.length ? (a = r = +p, u) : a; }, u.tickSizeInner = function(p) { return arguments.length ? (a = +p, u) : a; }, u.tickSizeOuter = function(p) { return arguments.length ? (r = +p, u) : r; }, u.tickPadding = function(p) { return arguments.length ? (o = +p, u) : o; }, u.offset = function(p) { return arguments.length ? (c = +p, u) : c; }, u; } function Nc(i) { return Ls(is, i); } function Pc(i) { return Ls(as, i); } function Ui(i) { return Ls(fi, i); } function uo(i) { return Ls(yn, i); } const gi = { capture: !0, passive: !1 }; function mi(i) { i.preventDefault(), i.stopImmediatePropagation(); } function $c(i) { var t = i.document.documentElement, e = D(i).on("dragstart.drag", mi, gi); "onselectstart" in t ? e.on("selectstart.drag", mi, gi) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none"); } function Vc(i, t) { var e = i.document.documentElement, n = D(i).on("dragstart.drag", null); t && (n.on("click.drag", mi, gi), setTimeout(function() { n.on("click.drag", null); }, 0)), "onselectstart" in e ? n.on("selectstart.drag", null) : (e.style.MozUserSelect = e.__noselect, delete e.__noselect); } function Gc(i, t) { for (var e = new Array(t), n = 0; n < t; ++n) e[n] = i(n / (t - 1)); return e; } const Hc = (i) => +i, Us = (i) => () => i; function Bc(i, { sourceEvent: t, target: e, selection: n, mode: s, dispatch: a }) { Object.defineProperties(this, { type: { value: i, enumerable: !0, configurable: !0 }, sourceEvent: { value: t, enumerable: !0, configurable: !0 }, target: { value: e, enumerable: !0, configurable: !0 }, selection: { value: n, enumerable: !0, configurable: !0 }, mode: { value: s, enumerable: !0, configurable: !0 }, _: { value: a } }); } function zc(i) { i.stopImmediatePropagation(); } function Fs(i) { i.preventDefault(), i.stopImmediatePropagation(); } var Na = { name: "drag" }, Ws = { name: "space" }, Fe = { name: "handle" }, We = { name: "center" }; const { abs: Pa, max: Dt, min: Nt } = Math; function $a(i) { return [+i[0], +i[1]]; } function Va(i) { return [$a(i[0]), $a(i[1])]; } var rs = { name: "x", handles: ["w", "e"].map(vi), input: function(i, t) { return i == null ? null : [[+i[0], t[0][1]], [+i[1], t[1][1]]]; }, output: function(i) { return i && [i[0][0], i[1][0]]; } }, Xs = {}, fe = { overlay: "crosshair", selection: "move", n: "ns-resize", e: "ew-resize", s: "ns-resize", w: "ew-resize", nw: "nwse-resize", ne: "nesw-resize", se: "nwse-resize", sw: "nesw-resize" }, Ga = { e: "w", w: "e", nw: "ne", ne: "nw", se: "sw", sw: "se" }, Ha = { n: "s", s: "n", nw: "sw", ne: "se", se: "ne", sw: "nw" }, Uc = { overlay: 1, selection: 1, n: null, e: 1, s: null, w: -1, nw: -1, ne: 1, se: 1, sw: -1 }, Fc = { overlay: 1, selection: 1, n: -1, e: null, s: 1, w: null, nw: -1, ne: -1, se: 1, sw: 1 }; function vi(i) { return { type: i }; } function Wc(i) { return !i.ctrlKey && !i.button; } function Xc() { var i = this.ownerSVGElement || this; return i.hasAttribute("viewBox") ? (i = i.viewBox.baseVal, [[i.x, i.y], [i.x + i.width, i.y + i.height]]) : [[0, 0], [i.width.baseVal.value, i.height.baseVal.value]]; } function Yc() { return navigator.maxTouchPoints || "ontouchstart" in this; } function Ys(i) { for (; !i.__brush; ) if (!(i = i.parentNode)) return; return i.__brush; } function Zc(i) { return i[0][0] === i[1][0] || i[0][1] === i[1][1]; } function ho() { return qc(rs); } function qc(i) { var t = Xc, e = Wc, n = Yc, s = !0, a = ul("start", "brush", "end"), r = 6, o; function c(m) { var y = m.property("__brush", g).selectAll(".overlay").data([vi("overlay")]); y.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", fe.overlay).merge(y).each(function() { var v = Ys(this).extent; D(this).attr("x", v[0][0]).attr("y", v[0][1]).attr("width", v[1][0] - v[0][0]).attr("height", v[1][1] - v[0][1]); }), m.selectAll(".selection").data([vi("selection")]).enter().append("rect").attr("class", "selection").attr("cursor", fe.selection).attr("fill", "#777").attr("fill-opacity", 0.3).attr("stroke", "#fff").attr("shape-rendering", "crispEdges"); var S = m.selectAll(".handle").data(i.handles, function(v) { return v.type; }); S.exit().remove(), S.enter().append("rect").attr("class", function(v) { return "handle handle--" + v.type; }).attr("cursor", function(v) { return fe[v.type]; }), m.each(l).attr("fill", "none").attr("pointer-events", "all").on("mousedown.brush", u).filter(n).on("touchstart.brush", u).on("touchmove.brush", p).on("touchend.brush touchcancel.brush", f).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); } c.move = function(m, y, S) { m.tween ? m.on("start.brush", function(v) { h(this, arguments).beforestart().start(v); }).on("interrupt.brush end.brush", function(v) { h(this, arguments).end(v); }).tween("brush", function() { var v = this, E = v.__brush, x = h(v, arguments), b = E.selection, _ = i.input(typeof y == "function" ? y.apply(this, arguments) : y, E.extent), k = Ur(b, _); function G(R) { E.selection = R === 1 && _ === null ? null : k(R), l.call(v), x.brush(); } return b !== null && _ !== null ? G : G(1); }) : m.each(function() { var v = this, E = arguments, x = v.__brush, b = i.input(typeof y == "function" ? y.apply(v, E) : y, x.extent), _ = h(v, E).beforestart(); va(v), x.selection = b === null ? null : b, l.call(v), _.start(S).brush(S).end(S); }); }, c.clear = function(m, y) { c.move(m, null, y); }; function l() { var m = D(this), y = Ys(this).selection; y ? (m.selectAll(".selection").style("display", null).attr("x", y[0][0]).attr("y", y[0][1]).attr("width", y[1][0] - y[0][0]).attr("height", y[1][1] - y[0][1]), m.selectAll(".handle").style("display", null).attr("x", function(S) { return S.type[S.type.length - 1] === "e" ? y[1][0] - r / 2 : y[0][0] - r / 2; }).attr("y", function(S) { return S.type[0] === "s" ? y[1][1] - r / 2 : y[0][1] - r / 2; }).attr("width", function(S) { return S.type === "n" || S.type === "s" ? y[1][0] - y[0][0] + r : r; }).attr("height", function(S) { return S.type === "e" || S.type === "w" ? y[1][1] - y[0][1] + r : r; })) : m.selectAll(".selection,.handle").style("display", "none").attr("x", null).attr("y", null).attr("width", null).attr("height", null); } function h(m, y, S) { var v = m.__brush.emitter; return v && (!S || !v.clean) ? v : new d(m, y, S); } function d(m, y, S) { this.that = m, this.args = y, this.state = m.__brush, this.active = 0, this.clean = S; } d.prototype = { beforestart: function() { return ++this.active === 1 && (this.state.emitter = this, this.starting = !0), this; }, start: function(m, y) { return this.starting ? (this.starting = !1, this.emit("start", m, y)) : this.emit("brush", m), this; }, brush: function(m, y) { return this.emit("brush", m, y), this; }, end: function(m, y) { return --this.active === 0 && (delete this.state.emitter, this.emit("end", m, y)), this; }, emit: function(m, y, S) { var v = D(this.that).datum(); a.call( m, this.that, new Bc(m, { sourceEvent: y, target: c, selection: i.output(this.state.selection), mode: S, dispatch: a }), v ); } }; function u(m) { if (o && !m.touches || !e.apply(this, arguments)) return; var y = this, S = m.target.__data__.type, v = (s && m.metaKey ? S = "overlay" : S) === "selection" ? Na : s && m.altKey ? We : Fe, E = i === Xs ? null : Uc[S], x = i === rs ? null : Fc[S], b = Ys(y), _ = b.extent, k = b.selection, G = _[0][0], R, A, H = _[0][1], N, M, L = _[1][0], P, $, C = _[1][1], V, q, X = 0, F = 0, Z, rt = E && x && s && m.shiftKey, j, Y, K = Array.from(m.touches || [m], (et) => { const yt = et.identifier; return et = nn(et, y), et.point0 = et.slice(), et.identifier = yt, et; }); va(y); var ot = h(y, arguments, !0).beforestart(); if (S === "overlay") { k && (Z = !0); const et = [K[0], K[1] || K[0]]; b.selection = k = [[ R = i === Xs ? G : Nt(et[0][0], et[1][0]), N = i === rs ? H : Nt(et[0][1], et[1][1]) ], [ P = i === Xs ? L : Dt(et[0][0], et[1][0]), V = i === rs ? C : Dt(et[0][1], et[1][1]) ]], K.length > 1 && z(m); } else R = k[0][0], N = k[0][1], P = k[1][0], V = k[1][1]; A = R, M = N, $ = P, q = V; var ct = D(y).attr("pointer-events", "none"), st = ct.selectAll(".overlay").attr("cursor", fe[S]); if (m.touches) ot.moved = B, ot.ended = U; else { var it = D(m.view).on("mousemove.brush", B, !0).on("mouseup.brush", U, !0); s && it.on("keydown.brush", Mt, !0).on("keyup.brush", Se, !0), $c(m.view); } l.call(y), ot.start(m, v.name); function B(et) { for (const yt of et.changedTouches || [et]) for (const Zt of K) Zt.identifier === yt.identifier && (Zt.cur = nn(yt, y)); if (rt && !j && !Y && K.length === 1) { const yt = K[0]; Pa(yt.cur[0] - yt[0]) > Pa(yt.cur[1] - yt[1]) ? Y = !0 : j = !0; } for (const yt of K) yt.cur && (yt[0] = yt.cur[0], yt[1] = yt.cur[1]); Z = !0, Fs(et), z(et); } function z(et) { const yt = K[0], Zt = yt.point0; var Wt; switch (X = yt[0] - Zt[0], F = yt[1] - Zt[1], v) { case Ws: case Na: { E && (X = Dt(G - R, Nt(L - P, X)), A = R + X, $ = P + X), x && (F = Dt(H - N, Nt(C - V, F)), M = N + F, q = V + F); break; } case Fe: { K[1] ? (E && (A = Dt(G, Nt(L, K[0][0])), $ = Dt(G, Nt(L, K[1][0])), E = 1), x && (M = Dt(H, Nt(C, K[0][1])), q = Dt(H, Nt(C, K[1][1])), x = 1)) : (E < 0 ? (X = Dt(G - R, Nt(L - R, X)), A = R + X, $ = P) : E > 0 && (X = Dt(G - P, Nt(L - P, X)), A = R, $ = P + X), x < 0 ? (F = Dt(H - N, Nt(C - N, F)), M = N + F, q = V) : x > 0 && (F = Dt(H - V, Nt(C - V, F)), M = N, q = V + F)); break; } case We: { E && (A = Dt(G, Nt(L, R - X * E)), $ = Dt(G, Nt(L, P + X * E))), x && (M = Dt(H, Nt(C, N - F * x)), q = Dt(H, Nt(C, V + F * x))); break; } } $ < A && (E *= -1, Wt = R, R = P, P = Wt, Wt = A, A = $, $ = Wt, S in Ga && st.attr("cursor", fe[S = Ga[S]])), q < M && (x *= -1, Wt = N, N = V, V = Wt, Wt = M, M = q, q = Wt, S in Ha && st.attr("cursor", fe[S = Ha[S]])), b.selection && (k = b.selection), j && (A = k[0][0], $ = k[1][0]), Y && (M = k[0][1], q = k[1][1]), (k[0][0] !== A || k[0][1] !== M || k[1][0] !== $ || k[1][1] !== q) && (b.selection = [[A, M], [$, q]], l.call(y), ot.brush(et, v.name)); } function U(et) { if (zc(et), et.touches) { if (et.touches.length) return; o && clearTimeout(o), o = setTimeout(function() { o = null; }, 500); } else Vc(et.view, Z), it.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null); ct.attr("pointer-events", "all"), st.attr("cursor", fe.overlay), b.selection && (k = b.selection), Zc(k) && (b.selection = null, l.call(y)), ot.end(et, v.name); } function Mt(et) { switch (et.keyCode) { case 16: { rt = E && x; break; } case 18: { v === Fe && (E && (P = $ - X * E, R = A + X * E), x && (V = q - F * x, N = M + F * x), v = We, z(et)); break; } case 32: { (v === Fe || v === We) && (E < 0 ? P = $ - X : E > 0 && (R = A - X), x < 0 ? V = q - F : x > 0 && (N = M - F), v = Ws, st.attr("cursor", fe.selection), z(et)); break; } default: return; } Fs(et); } function Se(et) { switch (et.keyCode) { case 16: { rt && (j = Y = rt = !1, z(et)); break; } case 18: { v === We && (E < 0 ? P = $ : E > 0 && (R = A), x < 0 ? V = q : x > 0 && (N = M), v = Fe, z(et)); break; } case 32: { v === Ws && (et.altKey ? (E && (P = $ - X * E, R = A + X * E), x && (V = q - F * x, N = M + F * x), v = We) : (E < 0 ? P = $ : E > 0 && (R = A), x < 0 ? V = q : x > 0 && (N = M), v = Fe), st.attr("cursor", fe[S]), z(et)); break; } default: return; } Fs(et); } } function p(m) { h(this, arguments).moved(m); } function f(m) { h(this, arguments).ended(m); } function g() { var m = this.__brush || { selection: null }; return m.extent = Va(t.apply(this, arguments)), m.dim = i, m; } return c.extent = function(m) { return arguments.length ? (t = typeof m == "function" ? m : Us(Va(m)), c) : t; }, c.filter = function(m) { return arguments.length ? (e = typeof m == "function" ? m : Us(!!m), c) : e; }, c.touchable = function(m) { return arguments.length ? (n = typeof m == "function" ? m : Us(!!m), c) : n; }, c.handleSize = function(m) { return arguments.length ? (r = +m, c) : r; }, c.keyModifiers = function(m) { return arguments.length ? (s = !!m, c) : s; }, c.on = function() { var m = a.on.apply(a, arguments); return m === a ? c : m; }, c; } const yi = Math.PI, Ei = 2 * yi, Ce = 1e-6, jc = Ei - Ce; function po(i) { this._ += i[0]; for (let t = 1, e = i.length; t < e; ++t) this._ += arguments[t] + i[t]; } function Kc(i) { let t = Math.floor(i); if (!(t >= 0)) throw new Error(`invalid digits: ${i}`); if (t > 15) return po; const e = 10 ** t; return function(n) { this._ += n[0]; for (let s = 1, a = n.length; s < a; ++s) this._ += Math.round(arguments[s] * e) / e + n[s]; }; } let Fi = class { constructor(t) { this._x0 = this._y0 = // start of current subpath this._x1 = this._y1 = null, this._ = "", this._append = t == null ? po : Kc(t); } moveTo(t, e) { this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +e}`; } closePath() { this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`); } lineTo(t, e) { this._append`L${this._x1 = +t},${this._y1 = +e}`; } quadraticCurveTo(t, e, n, s) { this._append`Q${+t},${+e},${this._x1 = +n},${this._y1 = +s}`; } bezierCurveTo(t, e, n, s, a, r) { this._append`C${+t},${+e},${+n},${+s},${this._x1 = +a},${this._y1 = +r}`; } arcTo(t, e, n, s, a) { if (t = +t, e = +e, n = +n, s = +s, a = +a, a < 0) throw new Error(`negative radius: ${a}`); let r = this._x1, o = this._y1, c = n - t, l = s - e, h = r - t, d = o - e, u = h * h + d * d; if (this._x1 === null) this._append`M${this._x1 = t},${this._y1 = e}`; else if (u > Ce) if (!(Math.abs(d * c - l * h) > Ce) || !a) this._append`L${this._x1 = t},${this._y1 = e}`; else { let p = n - r, f = s - o, g = c * c + l * l, m = p * p + f * f, y = Math.sqrt(g), S = Math.sqrt(u), v = a * Math.tan((yi - Math.acos((g + u - m) / (2 * y * S))) / 2), E = v / S, x = v / y; Math.abs(E - 1) > Ce && this._append`L${t + E * h},${e + E * d}`, this._append`A${a},${a},0,0,${+(d * p > h * f)},${this._x1 = t + x * c},${this._y1 = e + x * l}`; } } arc(t, e, n, s, a, r) { if (t = +t, e = +e, n = +n, r = !!r, n < 0) throw new Error(`negative radius: ${n}`); let o = n * Math.cos(s), c = n * Math.sin(s), l = t + o, h = e + c, d = 1 ^ r, u = r ? s - a : a - s; this._x1 === null ? this._append`M${l},${h}` : (Math.abs(this._x1 - l) > Ce || Math.abs(this._y1 - h) > Ce) && this._append`L${l},${h}`, n && (u < 0 && (u = u % Ei + Ei), u > jc ? this._append`A${n},${n},0,1,${d},${t - o},${e - c}A${n},${n},0,1,${d},${this._x1 = l},${this._y1 = h}` : u > Ce && this._append`A${n},${n},0,${+(u >= yi)},${d},${this._x1 = t + n * Math.cos(a)},${this._y1 = e + n * Math.sin(a)}`); } rect(t, e, n, s) { this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +e}h${n = +n}v${+s}h${-n}Z`; } toString() { return this._; } }; function As() { return new Fi(); } As.prototype = Fi.prototype; var vt = 1e-6, Jc = 1e-12, ht = Math.PI, Ft = ht / 2, Ba = ht / 4, Yt = ht * 2, Vt = 180 / ht, Ot = ht / 180, gt = Math.abs, fo = Math.atan, Ne = Math.atan2, mt = Math.cos, Qc = Math.exp, tu = Math.log, ft = Math.sin, be = Math.sign || function(i) { return i > 0 ? 1 : i < 0 ? -1 : 0; }, ae = Math.sqrt, eu = Math.tan; function nu(i) { return i > 1 ? 0 : i < -1 ? ht : Math.acos(i); } function xe(i) { return i > 1 ? Ft : i < -1 ? -Ft : Math.asin(i); } function Qt() { } function hs(i, t) { i && Ua.hasOwnProperty(i.type) && Ua[i.type](i, t); } var za = { Feature: function(i, t) { hs(i.geometry, t); }, FeatureCollection: function(i, t) { for (var e = i.features, n = -1, s = e.length; ++n < s; ) hs(e[n].geometry, t); } }, Ua = { Sphere: function(i, t) { t.sphere(); }, Point: function(i, t) { i = i.coordinates, t.point(i[0], i[1], i[2]); }, MultiPoint: function(i, t) { for (var e = i.coordinates, n = -1, s = e.length; ++n < s; ) i = e[n], t.point(i[0], i[1], i[2]); }, LineString: function(i, t) { xi(i.coordinates, t, 0); }, MultiLineString: function(i, t) { for (var e = i.coordinates, n = -1, s = e.length; ++n < s; ) xi(e[n], t, 0); }, Polygon: function(i, t) { Fa(i.coordinates, t); }, MultiPolygon: function(i, t) { for (var e = i.coordinates, n = -1, s = e.length; ++n < s; ) Fa(e[n], t); }, GeometryCollection: function(i, t) { for (var e = i.geometries, n = -1, s = e.length; ++n < s; ) hs(e[n], t); } }; function xi(i, t, e) { var n = -1, s = i.length - e, a; for (t.lineStart(); ++n < s; ) a = i[n], t.point(a[0], a[1], a[2]); t.lineEnd(); } function Fa(i, t) { var e = -1, n = i.length; for (t.polygonStart(); ++e < n; ) xi(i[e], t, 1); t.polygonEnd(); } function Ze(i, t) { i && za.hasOwnProperty(i.type) ? za[i.type](i, t) : hs(i, t); } function Si(i) { return [Ne(i[1], i[0]), xe(i[2])]; } function sn(i) { var t = i[0], e = i[1], n = mt(e); return [n * mt(t), n * ft(t), ft(e)]; } function Fn(i, t) { return i[0] * t[0] + i[1] * t[1] + i[2] * t[2]; } function ds(i, t) { return [i[1] * t[2] - i[2] * t[1], i[2] * t[0] - i[0] * t[2], i[0] * t[1] - i[1] * t[0]]; } function Zs(i, t) { i[0] += t[0], i[1] += t[1], i[2] += t[2]; } function Wn(i, t) { return [i[0] * t, i[1] * t, i[2] * t]; } function Ti(i) { var t = ae(i[0] * i[0] + i[1] * i[1] + i[2] * i[2]); i[0] /= t, i[1] /= t, i[2] /= t; } function bi(i, t) { function e(n, s) { return n = i(n, s), t(n[0], n[1]); } return i.invert && t.invert && (e.invert = function(n, s) { return n = t.invert(n, s), n && i.invert(n[0], n[1]); }), e; } function Oi(i, t) { return gt(i) > ht && (i -= Math.round(i / Yt) * Yt), [i, t]; } Oi.invert = Oi; function go(i, t, e) { return (i %= Yt) ? t || e ? bi(Xa(i), Ya(t, e)) : Xa(i) : t || e ? Ya(t, e) : Oi; } function Wa(i) { return function(t, e) { return t += i, gt(t) > ht && (t -= Math.round(t / Yt) * Yt), [t, e]; }; } function Xa(i) { var t = Wa(i); return t.invert = Wa(-i), t; } function Ya(i, t) { var e = mt(i), n = ft(i), s = mt(t), a = ft(t); function r(o, c) { var l = mt(c), h = mt(o) * l, d = ft(o) * l, u = ft(c), p = u * e + h * n; return [ Ne(d * s - p * a, h * e - u * n), xe(p * s + d * a) ]; } return r.invert = function(o, c) { var l = mt(c), h = mt(o) * l, d = ft(o) * l, u = ft(c), p = u * s - d * a; return [ Ne(d * s + u * a, h * e + p * n), xe(p * e - h * n) ]; }, r; } function su(i) { i = go(i[0] * Ot, i[1] * Ot, i.length > 2 ? i[2] * Ot : 0); function t(e) { return e = i(e[0] * Ot, e[1] * Ot), e[0] *= Vt, e[1] *= Vt, e; } return t.invert = function(e) { return e = i.invert(e[0] * Ot, e[1] * Ot), e[0] *= Vt, e[1] *= Vt, e; }, t; } function iu(i, t, e, n, s, a) { if (e) { var r = mt(t), o = ft(t), c = n * e; s == null ? (s = t + n * Yt, a = t - c / 2) : (s = Za(r, s), a = Za(r, a), (n > 0 ? s < a : s > a) && (s += n * Yt)); for (var l, h = s; n > 0 ? h > a : h < a; h -= c) l = Si([r, -o * mt(h), -o * ft(h)]), i.point(l[0], l[1]); } } function Za(i, t) { t = sn(t), t[0] -= i, Ti(t); var e = nu(-t[1]); return ((-t[2] < 0 ? -e : e) + Yt - vt) % Yt; } function mo() { var i = [], t; return { point: function(e, n, s) { t.push([e, n, s]); }, lineStart: function() { i.push(t = []); }, lineEnd: Qt, rejoin: function() { i.length > 1 && i.push(i.pop().concat(i.shift())); }, result: function() { var e = i; return i = [], t = null, e; } }; } function os(i, t) { return gt(i[0] - t[0]) < vt && gt(i[1] - t[1]) < vt; } function Xn(i, t, e, n) { this.x = i, this.z = t, this.o = e, this.e = n, this.v = !1, this.n = this.p = null; } function vo(i, t, e, n, s) { var a = [], r = [], o, c; if (i.forEach(function(f) { if (!((g = f.length - 1) <= 0)) { var g, m = f[0], y = f[g], S; if (os(m, y)) { if (!m[2] && !y[2]) { for (s.lineStart(), o = 0; o < g; ++o) s.point((m = f[o])[0], m[1]); s.lineEnd(); return; } y[0] += 2 * vt; } a.push(S = new Xn(m, f, null, !0)), r.push(S.o = new Xn(m, null, S, !1)), a.push(S = new Xn(y, f, null, !1)), r.push(S.o = new Xn(y, null, S, !0)); } }), !!a.length) { for (r.sort(t), qa(a), qa(r), o = 0, c = r.length; o < c; ++o) r[o].e = e = !e; for (var l = a[0], h, d; ; ) { for (var u = l, p = !0; u.v; ) if ((u = u.n) === l) return; h = u.z, s.lineStart(); do { if (u.v = u.o.v = !0, u.e) { if (p) for (o = 0, c = h.length; o < c; ++o) s.point((d = h[o])[0], d[1]); else n(u.x, u.n.x, 1, s); u = u.n; } else { if (p) for (h = u.p.z, o = h.length - 1; o >= 0; --o) s.point((d = h[o])[0], d[1]); else n(u.x, u.p.x, -1, s); u = u.p; } u = u.o, h = u.z, p = !p; } while (!u.v); s.lineEnd(); } } } function qa(i) { if (t = i.length) { for (var t, e = 0, n = i[0], s; ++e < t; ) n.n = s = i[e], s.p = n, n = s; n.n = s = i[0], s.p = n; } } function qs(i) { return gt(i[0]) <= ht ? i[0] : be(i[0]) * ((gt(i[0]) + ht) % Yt - ht); } function au(i, t) { var e = qs(t), n = t[1], s = ft(n), a = [ft(e), -mt(e), 0], r = 0, o = 0, c = new De(); s === 1 ? n = Ft + vt : s === -1 && (n = -Ft - vt); for (var l = 0, h = i.length; l < h; ++l) if (u = (d = i[l]).length) for (var d, u, p = d[u - 1], f = qs(p), g = p[1] / 2 + Ba, m = ft(g), y = mt(g), S = 0; S < u; ++S, f = E, m = b, y = _, p = v) { var v = d[S], E = qs(v), x = v[1] / 2 + Ba, b = ft(x), _ = mt(x), k = E - f, G = k >= 0 ? 1 : -1, R = G * k, A = R > ht, H = m * b; if (c.add(Ne(H * G * ft(R), y * _ + H * mt(R))), r += A ? k + G * Yt : k, A ^ f >= e ^ E >= e) { var N = ds(sn(p), sn(v)); Ti(N); var M = ds(a, N); Ti(M); var L = (A ^ k >= 0 ? -1 : 1) * xe(M[2]); (n > L || n === L && (N[0] || N[1])) && (o += A ^ k >= 0 ? 1 : -1); } } return (r < -1e-6 || r < vt && c < -1e-12) ^ o & 1; } function yo(i, t, e, n) { return function(s) { var a = t(s), r = mo(), o = t(r), c = !1, l, h, d, u = { point: p, lineStart: g, lineEnd: m, polygonStart: function() { u.point = y, u.lineStart = S, u.lineEnd = v, h = [], l = []; }, polygonEnd: function() { u.point = p, u.lineStart = g, u.lineEnd = m, h = co(h); var E = au(l, n); h.length ? (c || (s.polygonStart(), c = !0), vo(h, ou, E, e, s)) : E && (c || (s.polygonStart(), c = !0), s.lineStart(), e(null, null, 1, s), s.lineEnd()), c && (s.polygonEnd(), c = !1), h = l = null; }, sphere: function() { s.polygonStart(), s.lineStart(), e(null, null, 1, s), s.lineEnd(), s.polygonEnd(); } }; function p(E, x) { i(E, x) && s.point(E, x); } function f(E, x) { a.point(E, x); } function g() { u.point = f, a.lineStart(); } function m() { u.point = p, a.lineEnd(); } function y(E, x) { d.push([E, x]), o.point(E, x); } function S() { o.lineStart(), d = []; } function v() { y(d[0][0], d[0][1]), o.lineEnd(); var E = o.clean(), x = r.result(), b, _ = x.length, k, G, R; if (d.pop(), l.push(d), d = null, !!_) { if (E & 1) { if (G = x[0], (k = G.length - 1) > 0) { for (c || (s.polygonStart(), c = !0), s.lineStart(), b = 0; b < k; ++b) s.point((R = G[b])[0], R[1]); s.lineEnd(); } return; } _ > 1 && E & 2 && x.push(x.pop().concat(x.shift())), h.push(x.filter(ru)); } } return u; }; } function ru(i) { return i.length > 1; } function ou(i, t) { return ((i = i.x)[0] < 0 ? i[1] - Ft - vt : Ft - i[1]) - ((t = t.x)[0] < 0 ? t[1] - Ft - vt : Ft - t[1]); } const ja = yo( function() { return !0; }, lu, uu, [-ht, -Ft] ); function lu(i) { var t = NaN, e = NaN, n = NaN, s; return { lineStart: function() { i.lineStart(), s = 1; }, point: function(a, r) { var o = a > 0 ? ht : -ht, c = gt(a - t); gt(c - ht) < vt ? (i.point(t, e = (e + r) / 2 > 0 ? Ft : -Ft), i.point(n, e), i.lineEnd(), i.lineStart(), i.point(o, e), i.point(a, e), s = 0) : n !== o && c >= ht && (gt(t - n) < vt && (t -= n * vt), gt(a - o) < vt && (a -= o * vt), e = cu(t, e, a, r), i.point(n, e), i.lineEnd(), i.lineStart(), i.point(o, e), s = 0), i.point(t = a, e = r), n = o; }, lineEnd: function() { i.lineEnd(), t = e = NaN; }, clean: function() { return 2 - s; } }; } function cu(i, t, e, n) { var s, a, r = ft(i - e); return gt(r) > vt ? fo((ft(t) * (a = mt(n)) * ft(e) - ft(n) * (s = mt(t)) * ft(i)) / (s * a * r)) : (t + n) / 2; } function uu(i, t, e, n) { var s; if (i == null) s = e * Ft, n.point(-ht, s), n.point(0, s), n.point(ht, s), n.point(ht, 0), n.point(ht, -s), n.point(0, -s), n.point(-ht, -s), n.point(-ht, 0), n.point(-ht, s); else if (gt(i[0] - t[0]) > vt) { var a = i[0] < t[0] ? ht : -ht; s = e * a / 2, n.point(-a, s), n.point(0, s), n.point(a, s); } else n.point(t[0], t[1]); } function hu(i) { var t = mt(i), e = 2 * Ot, n = t > 0, s = gt(t) > vt; function a(h, d, u, p) { iu(p, i, e, u, h, d); } function r(h, d) { return mt(h) * mt(d) > t; } function o(h) { var d, u, p, f, g; return { lineStart: function() { f = p = !1, g = 1; }, point: function(m, y) { var S = [m, y], v, E = r(m, y), x = n ? E ? 0 : l(m, y) : E ? l(m + (m < 0 ? ht : -ht), y) : 0; if (!d && (f = p = E) && h.lineStart(), E !== p && (v = c(d, S), (!v || os(d, v) || os(S, v)) && (S[2] = 1)), E !== p) g = 0, E ? (h.lineStart(), v = c(S, d), h.point(v[0], v[1])) : (v = c(d, S), h.point(v[0], v[1], 2), h.lineEnd()), d = v; else if (s && d && n ^ E) { var b; !(x & u) && (b = c(S, d, !0)) && (g = 0, n ? (h.lineStart(), h.point(b[0][0], b[0][1]), h.point(b[1][0], b[1][1]), h.lineEnd()) : (h.point(b[1][0], b[1][1]), h.lineEnd(), h.lineStart(), h.point(b[0][0], b[0][1], 3))); } E && (!d || !os(d, S)) && h.point(S[0], S[1]), d = S, p = E, u = x; }, lineEnd: function() { p && h.lineEnd(), d = null; }, // Rejoin first and last segments if there were intersections and the first // and last points were visible. clean: function() { return g | (f && p) << 1; } }; } function c(h, d, u) { var p = sn(h), f = sn(d), g = [1, 0, 0], m = ds(p, f), y = Fn(m, m), S = m[0], v = y - S * S; if (!v) return !u && h; var E = t * y / v, x = -t * S / v, b = ds(g, m), _ = Wn(g, E), k = Wn(m, x); Zs(_, k); var G = b, R = Fn(_, G), A = Fn(G, G), H = R * R - A * (Fn(_, _) - 1); if (!(H < 0)) { var N = ae(H), M = Wn(G, (-R - N) / A); if (Zs(M, _), M = Si(M), !u) return M; var L = h[0], P = d[0], $ = h[1], C = d[1], V; P < L && (V = L, L = P, P = V); var q = P - L, X = gt(q - ht) < vt, F = X || q < vt; if (!X && C < $ && (V = $, $ = C, C = V), F ? X ? $ + C > 0 ^ M[1] < (gt(M[0] - L) < vt ? $ : C) : $ <= M[1] && M[1] <= C : q > ht ^ (L <= M[0] && M[0] <= P)) { var Z = Wn(G, (-R + N) / A); return Zs(Z, _), [M, Si(Z)]; } } } function l(h, d) { var u = n ? i : ht - i, p = 0; return h < -u ? p |= 1 : h > u && (p |= 2), d < -u ? p |= 4 : d > u && (p |= 8), p; } return yo(r, o, a, n ? [0, -i] : [-ht, i - ht]); } function du(i, t, e, n, s, a) { var r = i[0], o = i[1], c = t[0], l = t[1], h = 0, d = 1, u = c - r, p = l - o, f; if (f = e - r, !(!u && f > 0)) { if (f /= u, u < 0) { if (f < h) return; f < d && (d = f); } else if (u > 0) { if (f > d) return; f > h && (h = f); } if (f = s - r, !(!u && f < 0)) { if (f /= u, u < 0) { if (f > d) return; f > h && (h = f); } else if (u > 0) { if (f < h) return; f < d && (d = f); } if (f = n - o, !(!p && f > 0)) { if (f /= p, p < 0) { if (f < h) return; f < d && (d = f); } else if (p > 0) { if (f > d) return; f > h && (h = f); } if (f = a - o, !(!p && f < 0)) { if (f /= p, p < 0) { if (f > d) return; f > h && (h = f); } else if (p > 0) { if (f < h) return; f < d && (d = f); } return h > 0 && (i[0] = r + h * u, i[1] = o + h * p), d < 1 && (t[0] = r + d * u, t[1] = o + d * p), !0; } } } } } var Yn = 1e9, Zn = -1e9; function pu(i, t, e, n) { function s(l, h) { return i <= l && l <= e && t <= h && h <= n; } function a(l, h, d, u) { var p = 0, f = 0; if (l == null || (p = r(l, d)) !== (f = r(h, d)) || c(l, h) < 0 ^ d > 0) do u.point(p === 0 || p === 3 ? i : e, p > 1 ? n : t); while ((p = (p + d + 4) % 4) !== f); else u.point(h[0], h[1]); } function r(l, h) { return gt(l[0] - i) < vt ? h > 0 ? 0 : 3 : gt(l[0] - e) < vt ? h > 0 ? 2 : 1 : gt(l[1] - t) < vt ? h > 0 ? 1 : 0 : h > 0 ? 3 : 2; } function o(l, h) { return c(l.x, h.x); } function c(l, h) { var d = r(l, 1), u = r(h, 1); return d !== u ? d - u : d === 0 ? h[1] - l[1] : d === 1 ? l[0] - h[0] : d === 2 ? l[1] - h[1] : h[0] - l[0]; } return function(l) { var h = l, d = mo(), u, p, f, g, m, y, S, v, E, x, b, _ = { point: k, lineStart: H, lineEnd: N, polygonStart: R, polygonEnd: A }; function k(L, P) { s(L, P) && h.point(L, P); } function G() { for (var L = 0, P = 0, $ = p.length; P < $; ++P) for (var C = p[P], V = 1, q = C.length, X = C[0], F, Z, rt = X[0], j = X[1]; V < q; ++V) F = rt, Z = j, X = C[V], rt = X[0], j = X[1], Z <= n ? j > n && (rt - F) * (n - Z) > (j - Z) * (i - F) && ++L : j <= n && (rt - F) * (n - Z) < (j - Z) * (i - F) && --L; return L; } function R() { h = d, u = [], p = [], b = !0; } function A() { var L = G(), P = b && L, $ = (u = co(u)).length; (P || $) && (l.polygonStart(), P && (l.lineStart(), a(null, null, 1, l), l.lineEnd()), $ && vo(u, o, L, a, l), l.polygonEnd()), h = l, u = p = f = null; } function H() { _.point = M, p && p.push(f = []), x = !0, E = !1, S = v = NaN; } function N() { u && (M(g, m), y && E && d.rejoin(), u.push(d.result())), _.point = k, E && h.lineEnd(); } function M(L, P) { var $ = s(L, P); if (p && f.push([L, P]), x) g = L, m = P, y = $, x = !1, $ && (h.lineStart(), h.point(L, P)); else if ($ && E) h.point(L, P); else { var C = [S = Math.max(Zn, Math.min(Yn, S)), v = Math.max(Zn, Math.min(Yn, v))], V = [L = Math.max(Zn, Math.min(Yn, L)), P = Math.max(Zn, Math.min(Yn, P))]; du(C, V, i, t, e, n) ? (E || (h.lineStart(), h.point(C[0], C[1])), h.point(V[0], V[1]), $ || h.lineEnd(), b = !1) : $ && (h.lineStart(), h.point(L, P), b = !1); } S = L, v = P, E = $; } return _; }; } const Li = (i) => i; var js = new De(), Ai = new De(), Eo, xo, Mi, wi, ye = { point: Qt, lineStart: Qt, lineEnd: Qt, polygonStart: function() { ye.lineStart = fu, ye.lineEnd = mu; }, polygonEnd: function() { ye.lineStart = ye.lineEnd = ye.point = Qt, js.add(gt(Ai)), Ai = new De(); }, result: function() { var i = js / 2; return js = new De(), i; } }; function fu() { ye.point = gu; } function gu(i, t) { ye.point = So, Eo = Mi = i, xo = wi = t; } function So(i, t) { Ai.add(wi * i - Mi * t), Mi = i, wi = t; } function mu() { So(Eo, xo); } var an = 1 / 0, ps = an, Cn = -an, fs = Cn, gs = { point: vu, lineStart: Qt, lineEnd: Qt, polygonStart: Qt, polygonEnd: Qt, result: function() { var i = [[an, ps], [Cn, fs]]; return Cn = fs = -(ps = an = 1 / 0), i; } }; function vu(i, t) { i < an && (an = i), i > Cn && (Cn = i), t < ps && (ps = t), t > fs && (fs = t); } var Ci = 0, ki = 0, En = 0, ms = 0, vs = 0, Qe = 0, _i = 0, Ii = 0, xn = 0, To, bo, ce, ue, Jt = { point: Pe, lineStart: Ka, lineEnd: Ja, polygonStart: function() { Jt.lineStart = xu, Jt.lineEnd = Su; }, polygonEnd: function() { Jt.point = Pe, Jt.lineStart = Ka, Jt.lineEnd = Ja; }, result: function() { var i = xn ? [_i / xn, Ii / xn] : Qe ? [ms / Qe, vs / Qe] : En ? [Ci / En, ki / En] : [NaN, NaN]; return Ci = ki = En = ms = vs = Qe = _i = Ii = xn = 0, i; } }; function Pe(i, t) { Ci += i, ki += t, ++En; } function Ka() { Jt.point = yu; } function yu(i, t) { Jt.point = Eu, Pe(ce = i, ue = t); } function Eu(i, t) { var e = i - ce, n = t - ue, s = ae(e * e + n * n); ms += s * (ce + i) / 2, vs += s * (ue + t) / 2, Qe += s, Pe(ce = i, ue = t); } function Ja() { Jt.point = Pe; } function xu() { Jt.point = Tu; } function Su() { Oo(To, bo); } function Tu(i, t) { Jt.point = Oo, Pe(To = ce = i, bo = ue = t); } function Oo(i, t) { var e = i - ce, n = t - ue, s = ae(e * e + n * n); ms += s * (ce + i) / 2, vs += s * (ue + t) / 2, Qe += s, s = ue * i - ce * t, _i += s * (ce + i), Ii += s * (ue + t), xn += s * 3, Pe(ce = i, ue = t); } function Lo(i) { this._context = i; } Lo.prototype = { _radius: 4.5, pointRadius: function(i) { return this._radius = i, this; }, polygonStart: function() { this._line = 0; }, polygonEnd: function() { this._line = NaN; }, lineStart: function() { this._point = 0; }, lineEnd: function() { this._line === 0 && this._context.closePath(), this._point = NaN; }, point: function(i, t) { switch (this._point) { case 0: { this._context.moveTo(i, t), this._point = 1; break; } case 1: { this._context.lineTo(i, t); break; } default: { this._context.moveTo(i + this._radius, t), this._context.arc(i, t, this._radius, 0, Yt); break; } } }, result: Qt }; var Ri = new De(), Ks, Ao, Mo, Sn, Tn, kn = { point: Qt, lineStart: function() { kn.point = bu; }, lineEnd: function() { Ks && wo(Ao, Mo), kn.point = Qt; }, polygonStart: function() { Ks = !0; }, polygonEnd: function() { Ks = null; }, result: function() { var i = +Ri; return Ri = new De(), i; } }; function bu(i, t) { kn.point = wo, Ao = Sn = i, Mo = Tn = t; } function wo(i, t) { Sn -= i, Tn -= t, Ri.add(ae(Sn * Sn + Tn * Tn)), Sn = i, Tn = t; } let Qa, ys, tr, er; class nr { constructor(t) { this._append = t == null ? Co : Ou(t), this._radius = 4.5, this._ = ""; } pointRadius(t) { return this._radius = +t, this; } polygonStart() { this._line = 0; } polygonEnd() { this._line = NaN; } lineStart() { this._point = 0; } lineEnd() { this._line === 0 && (this._ += "Z"), this._point = NaN; } point(t, e) { switch (this._point) { case 0: { this._append`M${t},${e}`, this._point = 1; break; } case 1: { this._append`L${t},${e}`; break; } default: { if (this._append`M${t},${e}`, this._radius !== tr || this._append !== ys) { const n = this._radius, s = this._; this._ = "", this._append`m0,${n}a${n},${n} 0 1,1 0,${-2 * n}a${n},${n} 0 1,1 0,${2 * n}z`, tr = n, ys = this._append, er = this._, this._ = s; } this._ += er; break; } } } result() { const t = this._; return this._ = "", t.length ? t : null; } } function Co(i) { let t = 1; this._ += i[0]; for (const e = i.length; t < e; ++t) this._ += arguments[t] + i[t]; } function Ou(i) { const t = Math.floor(i); if (!(t >= 0)) throw new RangeError(`invalid digits: ${i}`); if (t > 15) return Co; if (t !== Qa) { const e = 10 ** t; Qa = t, ys = function(s) { let a = 1; this._ += s[0]; for (const r = s.length; a < r; ++a) this._ += Math.round(arguments[a] * e) / e + s[a]; }; } return ys; } function Lu(i, t) { let e = 3, n = 4.5, s, a; function r(o) { return o && (typeof n == "function" && a.pointRadius(+n.apply(this, arguments)), Ze(o, s(a))), a.result(); } return r.area = function(o) { return Ze(o, s(ye)), ye.result(); }, r.measure = function(o) { return Ze(o, s(kn)), kn.result(); }, r.bounds = function(o) { return Ze(o, s(gs)), gs.result(); }, r.centroid = function(o) { return Ze(o, s(Jt)), Jt.result(); }, r.projection = function(o) { return arguments.length ? (s = o == null ? (i = null, Li) : (i = o).stream, r) : i; }, r.context = function(o) { return arguments.length ? (a = o == null ? (t = null, new nr(e)) : new Lo(t = o), typeof n != "function" && a.pointRadius(n), r) : t; }, r.pointRadius = function(o) { return arguments.length ? (n = typeof o == "function" ? o : (a.pointRadius(+o), +o), r) : n; }, r.digits = function(o) { if (!arguments.length) return e; if (o == null) e = null; else { const c = Math.floor(o); if (!(c >= 0)) throw new RangeError(`invalid digits: ${o}`); e = c; } return t === null && (a = new nr(e)), r; }, r.projection(i).digits(e).context(t); } function Wi(i) { return function(t) { var e = new Di(); for (var n in i) e[n] = i[n]; return e.stream = t, e; }; } function Di() { } Di.prototype = { constructor: Di, point: function(i, t) { this.stream.point(i, t); }, sphere: function() { this.stream.sphere(); }, lin