visiojs
Version:
Microsoft Visio javascript alternative for creating diagrams and schematics
1,680 lines (1,679 loc) • 410 kB
JavaScript
function hn(n, t) {
return n == null || t == null ? NaN : n < t ? -1 : n > t ? 1 : n >= t ? 0 : NaN;
}
function Vl(n, t) {
return n == null || t == null ? NaN : t < n ? -1 : t > n ? 1 : t >= n ? 0 : NaN;
}
function Oo(n) {
let t, e, r;
n.length !== 2 ? (t = hn, e = (u, c) => hn(n(u), c), r = (u, c) => n(u) - c) : (t = n === hn || n === Vl ? n : $g, e = n, r = n);
function i(u, c, f = 0, s = u.length) {
if (f < s) {
if (t(c, c) !== 0) return s;
do {
const h = f + s >>> 1;
e(u[h], c) < 0 ? f = h + 1 : s = h;
} while (f < s);
}
return f;
}
function o(u, c, f = 0, s = u.length) {
if (f < s) {
if (t(c, c) !== 0) return s;
do {
const h = f + s >>> 1;
e(u[h], c) <= 0 ? f = h + 1 : s = h;
} while (f < s);
}
return f;
}
function a(u, c, f = 0, s = u.length) {
const h = i(u, c, f, s - 1);
return h > f && r(u[h - 1], c) > -r(u[h], c) ? h - 1 : h;
}
return { left: i, center: a, right: o };
}
function $g() {
return 0;
}
function ji(n) {
return n === null ? NaN : +n;
}
function* Tg(n, t) {
if (t === void 0)
for (let e of n)
e != null && (e = +e) >= e && (yield e);
else {
let e = -1;
for (let r of n)
(r = t(r, ++e, n)) != null && (r = +r) >= r && (yield r);
}
}
const Gl = Oo(hn), Ft = Gl.right, Ag = Gl.left, Sg = Oo(ji).center;
function Eg(n, t) {
if (!((t = +t) >= 0)) throw new RangeError("invalid r");
let e = n.length;
if (!((e = Math.floor(e)) >= 0)) throw new RangeError("invalid length");
if (!e || !t) return n;
const r = lf(t), i = n.slice();
return r(n, i, 0, e, 1), r(i, n, 0, e, 1), r(n, i, 0, e, 1), n;
}
const Zl = Ql(lf), kg = Ql(Ng);
function Ql(n) {
return function(t, e, r = e) {
if (!((e = +e) >= 0)) throw new RangeError("invalid rx");
if (!((r = +r) >= 0)) throw new RangeError("invalid ry");
let { data: i, width: o, height: a } = t;
if (!((o = Math.floor(o)) >= 0)) throw new RangeError("invalid width");
if (!((a = Math.floor(a !== void 0 ? a : i.length / o)) >= 0)) throw new RangeError("invalid height");
if (!o || !a || !e && !r) return t;
const u = e && n(e), c = r && n(r), f = i.slice();
return u && c ? (we(u, f, i, o, a), we(u, i, f, o, a), we(u, f, i, o, a), xe(c, i, f, o, a), xe(c, f, i, o, a), xe(c, i, f, o, a)) : u ? (we(u, i, f, o, a), we(u, f, i, o, a), we(u, i, f, o, a)) : c && (xe(c, i, f, o, a), xe(c, f, i, o, a), xe(c, i, f, o, a)), t;
};
}
function we(n, t, e, r, i) {
for (let o = 0, a = r * i; o < a; )
n(t, e, o, o += r, 1);
}
function xe(n, t, e, r, i) {
for (let o = 0, a = r * i; o < r; ++o)
n(t, e, o, o + a, r);
}
function Ng(n) {
const t = lf(n);
return (e, r, i, o, a) => {
i <<= 2, o <<= 2, a <<= 2, t(e, r, i + 0, o + 0, a), t(e, r, i + 1, o + 1, a), t(e, r, i + 2, o + 2, a), t(e, r, i + 3, o + 3, a);
};
}
function lf(n) {
const t = Math.floor(n);
if (t === n) return Rg(n);
const e = n - t, r = 2 * n + 1;
return (i, o, a, u, c) => {
if (!((u -= c) >= a)) return;
let f = t * o[a];
const s = c * t, h = s + c;
for (let l = a, d = a + s; l < d; l += c)
f += o[Math.min(u, l)];
for (let l = a, d = u; l <= d; l += c)
f += o[Math.min(u, l + s)], i[l] = (f + e * (o[Math.max(a, l - h)] + o[Math.min(u, l + h)])) / r, f -= o[Math.max(a, l - s)];
};
}
function Rg(n) {
const t = 2 * n + 1;
return (e, r, i, o, a) => {
if (!((o -= a) >= i)) return;
let u = n * r[i];
const c = a * n;
for (let f = i, s = i + c; f < s; f += a)
u += r[Math.min(o, f)];
for (let f = i, s = o; f <= s; f += a)
u += r[Math.min(o, f + c)], e[f] = u / t, u -= r[Math.max(i, f - c)];
};
}
function Yo(n, t) {
let e = 0;
if (t === void 0)
for (let r of n)
r != null && (r = +r) >= r && ++e;
else {
let r = -1;
for (let i of n)
(i = t(i, ++r, n)) != null && (i = +i) >= i && ++e;
}
return e;
}
function Ig(n) {
return n.length | 0;
}
function Cg(n) {
return !(n > 0);
}
function Pg(n) {
return typeof n != "object" || "length" in n ? n : Array.from(n);
}
function Dg(n) {
return (t) => n(...t);
}
function zg(...n) {
const t = typeof n[n.length - 1] == "function" && Dg(n.pop());
n = n.map(Pg);
const e = n.map(Ig), r = n.length - 1, i = new Array(r + 1).fill(0), o = [];
if (r < 0 || e.some(Cg)) return o;
for (; ; ) {
o.push(i.map((u, c) => n[c][u]));
let a = r;
for (; ++i[a] === e[a]; ) {
if (a === 0) return t ? o.map(t) : o;
i[a--] = 0;
}
}
}
function Og(n, t) {
var e = 0, r = 0;
return Float64Array.from(n, t === void 0 ? (i) => e += +i || 0 : (i) => e += +t(i, r++, n) || 0);
}
function Kl(n, t) {
let e = 0, r, i = 0, o = 0;
if (t === void 0)
for (let a of n)
a != null && (a = +a) >= a && (r = a - i, i += r / ++e, o += r * (a - i));
else {
let a = -1;
for (let u of n)
(u = t(u, ++a, n)) != null && (u = +u) >= u && (r = u - i, i += r / ++e, o += r * (u - i));
}
if (e > 1) return o / (e - 1);
}
function Jl(n, t) {
const e = Kl(n, t);
return e && Math.sqrt(e);
}
function Er(n, t) {
let e, r;
if (t === void 0)
for (const i of n)
i != null && (e === void 0 ? i >= i && (e = r = i) : (e > i && (e = i), r < i && (r = i)));
else {
let i = -1;
for (let o of n)
(o = t(o, ++i, n)) != null && (e === void 0 ? o >= o && (e = r = o) : (e > o && (e = o), r < o && (r = o)));
}
return [e, r];
}
class bn {
constructor() {
this._partials = new Float64Array(32), this._n = 0;
}
add(t) {
const e = this._partials;
let r = 0;
for (let i = 0; i < this._n && i < 32; i++) {
const o = e[i], a = t + o, u = Math.abs(t) < Math.abs(o) ? t - (a - o) : o - (a - t);
u && (e[r++] = u), t = a;
}
return e[r] = t, this._n = r + 1, this;
}
valueOf() {
const t = this._partials;
let e = this._n, r, i, o, a = 0;
if (e > 0) {
for (a = t[--e]; e > 0 && (r = a, i = t[--e], a = r + i, o = i - (a - r), !o); )
;
e > 0 && (o < 0 && t[e - 1] < 0 || o > 0 && t[e - 1] > 0) && (i = o * 2, r = a + i, i == r - a && (a = r));
}
return a;
}
}
function Yg(n, t) {
const e = new bn();
if (t === void 0)
for (let r of n)
(r = +r) && e.add(r);
else {
let r = -1;
for (let i of n)
(i = +t(i, ++r, n)) && e.add(i);
}
return +e;
}
function Fg(n, t) {
const e = new bn();
let r = -1;
return Float64Array.from(
n,
t === void 0 ? (i) => e.add(+i || 0) : (i) => e.add(+t(i, ++r, n) || 0)
);
}
class Pr extends Map {
constructor(t, e = eh) {
if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: e } }), t != null) for (const [r, i] of t) this.set(r, i);
}
get(t) {
return super.get(hu(this, t));
}
has(t) {
return super.has(hu(this, t));
}
set(t, e) {
return super.set(nh(this, t), e);
}
delete(t) {
return super.delete(th(this, t));
}
}
class ie extends Set {
constructor(t, e = eh) {
if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: e } }), t != null) for (const r of t) this.add(r);
}
has(t) {
return super.has(hu(this, t));
}
add(t) {
return super.add(nh(this, t));
}
delete(t) {
return super.delete(th(this, t));
}
}
function hu({ _intern: n, _key: t }, e) {
const r = t(e);
return n.has(r) ? n.get(r) : e;
}
function nh({ _intern: n, _key: t }, e) {
const r = t(e);
return n.has(r) ? n.get(r) : (n.set(r, e), e);
}
function th({ _intern: n, _key: t }, e) {
const r = t(e);
return n.has(r) && (e = n.get(r), n.delete(r)), e;
}
function eh(n) {
return n !== null && typeof n == "object" ? n.valueOf() : n;
}
function qe(n) {
return n;
}
function rh(n, ...t) {
return er(n, qe, qe, t);
}
function ih(n, ...t) {
return er(n, Array.from, qe, t);
}
function oh(n, t) {
for (let e = 1, r = t.length; e < r; ++e)
n = n.flatMap((i) => i.pop().map(([o, a]) => [...i, o, a]));
return n;
}
function qg(n, ...t) {
return oh(ih(n, ...t), t);
}
function Lg(n, t, ...e) {
return oh(uh(n, t, ...e), e);
}
function ah(n, t, ...e) {
return er(n, qe, t, e);
}
function uh(n, t, ...e) {
return er(n, Array.from, t, e);
}
function Bg(n, ...t) {
return er(n, qe, fh, t);
}
function Ug(n, ...t) {
return er(n, Array.from, fh, t);
}
function fh(n) {
if (n.length !== 1) throw new Error("duplicate key");
return n[0];
}
function er(n, t, e, r) {
return (function i(o, a) {
if (a >= r.length) return e(o);
const u = new Pr(), c = r[a++];
let f = -1;
for (const s of o) {
const h = c(s, ++f, o), l = u.get(h);
l ? l.push(s) : u.set(h, [s]);
}
for (const [s, h] of u)
u.set(s, i(h, a));
return t(u);
})(n, 0);
}
function ch(n, t) {
return Array.from(t, (e) => n[e]);
}
function du(n, ...t) {
if (typeof n[Symbol.iterator] != "function") throw new TypeError("values is not iterable");
n = Array.from(n);
let [e] = t;
if (e && e.length !== 2 || t.length > 1) {
const r = Uint32Array.from(n, (i, o) => o);
return t.length > 1 ? (t = t.map((i) => n.map(i)), r.sort((i, o) => {
for (const a of t) {
const u = Le(a[i], a[o]);
if (u) return u;
}
})) : (e = n.map(e), r.sort((i, o) => Le(e[i], e[o]))), ch(n, r);
}
return n.sort(hf(e));
}
function hf(n = hn) {
if (n === hn) return Le;
if (typeof n != "function") throw new TypeError("compare is not a function");
return (t, e) => {
const r = n(t, e);
return r || r === 0 ? r : (n(e, e) === 0) - (n(t, t) === 0);
};
}
function Le(n, t) {
return (n == null || !(n >= n)) - (t == null || !(t >= t)) || (n < t ? -1 : n > t ? 1 : 0);
}
function Xg(n, t, e) {
return (t.length !== 2 ? du(ah(n, t, e), (([r, i], [o, a]) => hn(i, a) || hn(r, o))) : du(rh(n, e), (([r, i], [o, a]) => t(i, a) || hn(r, o)))).map(([r]) => r);
}
var Hg = Array.prototype, jg = Hg.slice;
function Aa(n) {
return () => n;
}
const Wg = Math.sqrt(50), Vg = Math.sqrt(10), Gg = Math.sqrt(2);
function Wi(n, t, e) {
const r = (t - n) / Math.max(0, e), i = Math.floor(Math.log10(r)), o = r / Math.pow(10, i), a = o >= Wg ? 10 : o >= Vg ? 5 : o >= Gg ? 2 : 1;
let u, c, f;
return i < 0 ? (f = Math.pow(10, -i) / a, u = Math.round(n * f), c = Math.round(t * f), u / f < n && ++u, c / f > t && --c, f = -f) : (f = Math.pow(10, i) * a, u = Math.round(n / f), c = Math.round(t / f), u * f < n && ++u, c * f > t && --c), c < u && 0.5 <= e && e < 2 ? Wi(n, t, e * 2) : [u, c, f];
}
function oe(n, t, e) {
if (t = +t, n = +n, e = +e, !(e > 0)) return [];
if (n === t) return [n];
const r = t < n, [i, o, a] = r ? Wi(t, n, e) : Wi(n, t, e);
if (!(o >= i)) return [];
const u = o - i + 1, c = new Array(u);
if (r)
if (a < 0) for (let f = 0; f < u; ++f) c[f] = (o - f) / -a;
else for (let f = 0; f < u; ++f) c[f] = (o - f) * a;
else if (a < 0) for (let f = 0; f < u; ++f) c[f] = (i + f) / -a;
else for (let f = 0; f < u; ++f) c[f] = (i + f) * a;
return c;
}
function ae(n, t, e) {
return t = +t, n = +n, e = +e, Wi(n, t, e)[2];
}
function Vi(n, t, e) {
t = +t, n = +n, e = +e;
const r = t < n, i = r ? ae(t, n, e) : ae(n, t, e);
return (r ? -1 : 1) * (i < 0 ? 1 / -i : i);
}
function df(n, t, e) {
let r;
for (; ; ) {
const i = ae(n, t, e);
if (i === r || i === 0 || !isFinite(i))
return [n, t];
i > 0 ? (n = Math.floor(n / i) * i, t = Math.ceil(t / i) * i) : i < 0 && (n = Math.ceil(n * i) / i, t = Math.floor(t * i) / i), r = i;
}
}
function gf(n) {
return Math.max(1, Math.ceil(Math.log(Yo(n)) / Math.LN2) + 1);
}
function Nc() {
var n = qe, t = Er, e = gf;
function r(i) {
Array.isArray(i) || (i = Array.from(i));
var o, a = i.length, u, c, f = new Array(a);
for (o = 0; o < a; ++o)
f[o] = n(i[o], o, i);
var s = t(f), h = s[0], l = s[1], d = e(f, h, l);
if (!Array.isArray(d)) {
const v = l, _ = +d;
if (t === Er && ([h, l] = df(h, l, _)), d = oe(h, l, _), d[0] <= h && (c = ae(h, l, _)), d[d.length - 1] >= l)
if (v >= l && t === Er) {
const w = ae(h, l, _);
isFinite(w) && (w > 0 ? l = (Math.floor(l / w) + 1) * w : w < 0 && (l = (Math.ceil(l * -w) + 1) / -w));
} else
d.pop();
}
for (var p = d.length, m = 0, g = p; d[m] <= h; ) ++m;
for (; d[g - 1] > l; ) --g;
(m || g < p) && (d = d.slice(m, g), p = g - m);
var y = new Array(p + 1), b;
for (o = 0; o <= p; ++o)
b = y[o] = [], b.x0 = o > 0 ? d[o - 1] : h, b.x1 = o < p ? d[o] : l;
if (isFinite(c)) {
if (c > 0)
for (o = 0; o < a; ++o)
(u = f[o]) != null && h <= u && u <= l && y[Math.min(p, Math.floor((u - h) / c))].push(i[o]);
else if (c < 0) {
for (o = 0; o < a; ++o)
if ((u = f[o]) != null && h <= u && u <= l) {
const v = Math.floor((h - u) * c);
y[Math.min(p, v + (d[v] <= u))].push(i[o]);
}
}
} else
for (o = 0; o < a; ++o)
(u = f[o]) != null && h <= u && u <= l && y[Ft(d, u, 0, p)].push(i[o]);
return y;
}
return r.value = function(i) {
return arguments.length ? (n = typeof i == "function" ? i : Aa(i), r) : n;
}, r.domain = function(i) {
return arguments.length ? (t = typeof i == "function" ? i : Aa([i[0], i[1]]), r) : t;
}, r.thresholds = function(i) {
return arguments.length ? (e = typeof i == "function" ? i : Aa(Array.isArray(i) ? jg.call(i) : i), r) : e;
}, r;
}
function Dr(n, t) {
let e;
if (t === void 0)
for (const r of n)
r != null && (e < r || e === void 0 && r >= r) && (e = r);
else {
let r = -1;
for (let i of n)
(i = t(i, ++r, n)) != null && (e < i || e === void 0 && i >= i) && (e = i);
}
return e;
}
function pf(n, t) {
let e, r = -1, i = -1;
if (t === void 0)
for (const o of n)
++i, o != null && (e < o || e === void 0 && o >= o) && (e = o, r = i);
else
for (let o of n)
(o = t(o, ++i, n)) != null && (e < o || e === void 0 && o >= o) && (e = o, r = i);
return r;
}
function Gi(n, t) {
let e;
if (t === void 0)
for (const r of n)
r != null && (e > r || e === void 0 && r >= r) && (e = r);
else {
let r = -1;
for (let i of n)
(i = t(i, ++r, n)) != null && (e > i || e === void 0 && i >= i) && (e = i);
}
return e;
}
function mf(n, t) {
let e, r = -1, i = -1;
if (t === void 0)
for (const o of n)
++i, o != null && (e > o || e === void 0 && o >= o) && (e = o, r = i);
else
for (let o of n)
(o = t(o, ++i, n)) != null && (e > o || e === void 0 && o >= o) && (e = o, r = i);
return r;
}
function Fo(n, t, e = 0, r = 1 / 0, i) {
if (t = Math.floor(t), e = Math.floor(Math.max(0, e)), r = Math.floor(Math.min(n.length - 1, r)), !(e <= t && t <= r)) return n;
for (i = i === void 0 ? Le : hf(i); r > e; ) {
if (r - e > 600) {
const c = r - e + 1, f = t - e + 1, s = Math.log(c), h = 0.5 * Math.exp(2 * s / 3), l = 0.5 * Math.sqrt(s * h * (c - h) / c) * (f - c / 2 < 0 ? -1 : 1), d = Math.max(e, Math.floor(t - f * h / c + l)), p = Math.min(r, Math.floor(t + (c - f) * h / c + l));
Fo(n, t, d, p, i);
}
const o = n[t];
let a = e, u = r;
for (ur(n, e, t), i(n[r], o) > 0 && ur(n, e, r); a < u; ) {
for (ur(n, a, u), ++a, --u; i(n[a], o) < 0; ) ++a;
for (; i(n[u], o) > 0; ) --u;
}
i(n[e], o) === 0 ? ur(n, e, u) : (++u, ur(n, u, r)), u <= t && (e = u + 1), t <= u && (r = u - 1);
}
return n;
}
function ur(n, t, e) {
const r = n[t];
n[t] = n[e], n[e] = r;
}
function sh(n, t = hn) {
let e, r = !1;
if (t.length === 1) {
let i;
for (const o of n) {
const a = t(o);
(r ? hn(a, i) > 0 : hn(a, a) === 0) && (e = o, i = a, r = !0);
}
} else
for (const i of n)
(r ? t(i, e) > 0 : t(i, i) === 0) && (e = i, r = !0);
return e;
}
function zr(n, t, e) {
if (n = Float64Array.from(Tg(n, e)), !(!(r = n.length) || isNaN(t = +t))) {
if (t <= 0 || r < 2) return Gi(n);
if (t >= 1) return Dr(n);
var r, i = (r - 1) * t, o = Math.floor(i), a = Dr(Fo(n, o).subarray(0, o + 1)), u = Gi(n.subarray(o + 1));
return a + (u - a) * (i - o);
}
}
function lh(n, t, e = ji) {
if (!(!(r = n.length) || isNaN(t = +t))) {
if (t <= 0 || r < 2) return +e(n[0], 0, n);
if (t >= 1) return +e(n[r - 1], r - 1, n);
var r, i = (r - 1) * t, o = Math.floor(i), a = +e(n[o], o, n), u = +e(n[o + 1], o + 1, n);
return a + (u - a) * (i - o);
}
}
function hh(n, t, e = ji) {
if (!isNaN(t = +t)) {
if (r = Float64Array.from(n, (u, c) => ji(e(n[c], c, n))), t <= 0) return mf(r);
if (t >= 1) return pf(r);
var r, i = Uint32Array.from(n, (u, c) => c), o = r.length - 1, a = Math.floor(o * t);
return Fo(i, a, 0, o, (u, c) => Le(r[u], r[c])), a = sh(i.subarray(0, a + 1), (u) => r[u]), a >= 0 ? a : -1;
}
}
function Zg(n, t, e) {
const r = Yo(n), i = zr(n, 0.75) - zr(n, 0.25);
return r && i ? Math.ceil((e - t) / (2 * i * Math.pow(r, -1 / 3))) : 1;
}
function Qg(n, t, e) {
const r = Yo(n), i = Jl(n);
return r && i ? Math.ceil((e - t) * Math.cbrt(r) / (3.49 * i)) : 1;
}
function Kg(n, t) {
let e = 0, r = 0;
if (t === void 0)
for (let i of n)
i != null && (i = +i) >= i && (++e, r += i);
else {
let i = -1;
for (let o of n)
(o = t(o, ++i, n)) != null && (o = +o) >= o && (++e, r += o);
}
if (e) return r / e;
}
function Jg(n, t) {
return zr(n, 0.5, t);
}
function np(n, t) {
return hh(n, 0.5, t);
}
function* tp(n) {
for (const t of n)
yield* t;
}
function yf(n) {
return Array.from(tp(n));
}
function ep(n, t) {
const e = new Pr();
if (t === void 0)
for (let o of n)
o != null && o >= o && e.set(o, (e.get(o) || 0) + 1);
else {
let o = -1;
for (let a of n)
(a = t(a, ++o, n)) != null && a >= a && e.set(a, (e.get(a) || 0) + 1);
}
let r, i = 0;
for (const [o, a] of e)
a > i && (i = a, r = o);
return r;
}
function rp(n, t = ip) {
const e = [];
let r, i = !1;
for (const o of n)
i && e.push(t(r, o)), r = o, i = !0;
return e;
}
function ip(n, t) {
return [n, t];
}
function zt(n, t, e) {
n = +n, t = +t, e = (i = arguments.length) < 2 ? (t = n, n = 0, 1) : i < 3 ? 1 : +e;
for (var r = -1, i = Math.max(0, Math.ceil((t - n) / e)) | 0, o = new Array(i); ++r < i; )
o[r] = n + r * e;
return o;
}
function op(n, t = hn) {
if (typeof n[Symbol.iterator] != "function") throw new TypeError("values is not iterable");
let e = Array.from(n);
const r = new Float64Array(e.length);
t.length !== 2 && (e = e.map(t), t = hn);
const i = (u, c) => t(e[u], e[c]);
let o, a;
return n = Uint32Array.from(e, (u, c) => c), n.sort(t === hn ? (u, c) => Le(e[u], e[c]) : hf(i)), n.forEach((u, c) => {
const f = i(u, o === void 0 ? u : o);
f >= 0 ? ((o === void 0 || f > 0) && (o = u, a = c), r[u] = a) : r[u] = NaN;
}), r;
}
function ap(n, t = hn) {
let e, r = !1;
if (t.length === 1) {
let i;
for (const o of n) {
const a = t(o);
(r ? hn(a, i) < 0 : hn(a, a) === 0) && (e = o, i = a, r = !0);
}
} else
for (const i of n)
(r ? t(i, e) < 0 : t(i, i) === 0) && (e = i, r = !0);
return e;
}
function dh(n, t = hn) {
if (t.length === 1) return mf(n, t);
let e, r = -1, i = -1;
for (const o of n)
++i, (r < 0 ? t(o, o) === 0 : t(o, e) < 0) && (e = o, r = i);
return r;
}
function up(n, t = hn) {
if (t.length === 1) return pf(n, t);
let e, r = -1, i = -1;
for (const o of n)
++i, (r < 0 ? t(o, o) === 0 : t(o, e) > 0) && (e = o, r = i);
return r;
}
function fp(n, t) {
const e = dh(n, t);
return e < 0 ? void 0 : e;
}
const cp = gh(Math.random);
function gh(n) {
return function(e, r = 0, i = e.length) {
let o = i - (r = +r);
for (; o; ) {
const a = n() * o-- | 0, u = e[o + r];
e[o + r] = e[a + r], e[a + r] = u;
}
return e;
};
}
function sp(n, t) {
let e = 0;
if (t === void 0)
for (let r of n)
(r = +r) && (e += r);
else {
let r = -1;
for (let i of n)
(i = +t(i, ++r, n)) && (e += i);
}
return e;
}
function ph(n) {
if (!(o = n.length)) return [];
for (var t = -1, e = Gi(n, lp), r = new Array(e); ++t < e; )
for (var i = -1, o, a = r[t] = new Array(o); ++i < o; )
a[i] = n[i][t];
return r;
}
function lp(n) {
return n.length;
}
function hp() {
return ph(arguments);
}
function dp(n, t) {
if (typeof t != "function") throw new TypeError("test is not a function");
let e = -1;
for (const r of n)
if (!t(r, ++e, n))
return !1;
return !0;
}
function gp(n, t) {
if (typeof t != "function") throw new TypeError("test is not a function");
let e = -1;
for (const r of n)
if (t(r, ++e, n))
return !0;
return !1;
}
function pp(n, t) {
if (typeof t != "function") throw new TypeError("test is not a function");
const e = [];
let r = -1;
for (const i of n)
t(i, ++r, n) && e.push(i);
return e;
}
function mp(n, t) {
if (typeof n[Symbol.iterator] != "function") throw new TypeError("values is not iterable");
if (typeof t != "function") throw new TypeError("mapper is not a function");
return Array.from(n, (e, r) => t(e, r, n));
}
function yp(n, t, e) {
if (typeof t != "function") throw new TypeError("reducer is not a function");
const r = n[Symbol.iterator]();
let i, o, a = -1;
if (arguments.length < 3) {
if ({ done: i, value: e } = r.next(), i) return;
++a;
}
for (; { done: i, value: o } = r.next(), !i; )
e = t(e, o, ++a, n);
return e;
}
function _p(n) {
if (typeof n[Symbol.iterator] != "function") throw new TypeError("values is not iterable");
return Array.from(n).reverse();
}
function vp(n, ...t) {
n = new ie(n);
for (const e of t)
for (const r of e)
n.delete(r);
return n;
}
function bp(n, t) {
const e = t[Symbol.iterator](), r = new ie();
for (const i of n) {
if (r.has(i)) return !1;
let o, a;
for (; ({ value: o, done: a } = e.next()) && !a; ) {
if (Object.is(i, o)) return !1;
r.add(o);
}
}
return !0;
}
function wp(n, ...t) {
n = new ie(n), t = t.map(xp);
n: for (const e of n)
for (const r of t)
if (!r.has(e)) {
n.delete(e);
continue n;
}
return n;
}
function xp(n) {
return n instanceof ie ? n : new ie(n);
}
function mh(n, t) {
const e = n[Symbol.iterator](), r = /* @__PURE__ */ new Set();
for (const i of t) {
const o = Rc(i);
if (r.has(o)) continue;
let a, u;
for (; { value: a, done: u } = e.next(); ) {
if (u) return !1;
const c = Rc(a);
if (r.add(c), Object.is(o, c)) break;
}
}
return !0;
}
function Rc(n) {
return n !== null && typeof n == "object" ? n.valueOf() : n;
}
function Mp(n, t) {
return mh(t, n);
}
function $p(...n) {
const t = new ie();
for (const e of n)
for (const r of e)
t.add(r);
return t;
}
function Tp(n) {
return n;
}
var Pi = 1, Di = 2, gu = 3, mr = 4, Ic = 1e-6;
function Ap(n) {
return "translate(" + n + ",0)";
}
function Sp(n) {
return "translate(0," + n + ")";
}
function Ep(n) {
return (t) => +n(t);
}
function kp(n, t) {
return t = Math.max(0, n.bandwidth() - t * 2) / 2, n.round() && (t = Math.round(t)), (e) => +n(e) + t;
}
function Np() {
return !this.__axis;
}
function qo(n, t) {
var e = [], r = null, i = null, o = 6, a = 6, u = 3, c = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, f = n === Pi || n === mr ? -1 : 1, s = n === mr || n === Di ? "x" : "y", h = n === Pi || n === gu ? Ap : Sp;
function l(d) {
var p = r ?? (t.ticks ? t.ticks.apply(t, e) : t.domain()), m = i ?? (t.tickFormat ? t.tickFormat.apply(t, e) : Tp), g = Math.max(o, 0) + u, y = t.range(), b = +y[0] + c, v = +y[y.length - 1] + c, _ = (t.bandwidth ? kp : Ep)(t.copy(), c), w = d.selection ? d.selection() : d, M = w.selectAll(".domain").data([null]), k = w.selectAll(".tick").data(p, t).order(), N = k.exit(), T = k.enter().append("g").attr("class", "tick"), A = k.select("line"), $ = k.select("text");
M = M.merge(M.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), k = k.merge(T), A = A.merge(T.append("line").attr("stroke", "currentColor").attr(s + "2", f * o)), $ = $.merge(T.append("text").attr("fill", "currentColor").attr(s, f * g).attr("dy", n === Pi ? "0em" : n === gu ? "0.71em" : "0.32em")), d !== w && (M = M.transition(d), k = k.transition(d), A = A.transition(d), $ = $.transition(d), N = N.transition(d).attr("opacity", Ic).attr("transform", function(C) {
return isFinite(C = _(C)) ? h(C + c) : this.getAttribute("transform");
}), T.attr("opacity", Ic).attr("transform", function(C) {
var R = this.parentNode.__axis;
return h((R && isFinite(R = R(C)) ? R : _(C)) + c);
})), N.remove(), M.attr("d", n === mr || n === Di ? a ? "M" + f * a + "," + b + "H" + c + "V" + v + "H" + f * a : "M" + c + "," + b + "V" + v : a ? "M" + b + "," + f * a + "V" + c + "H" + v + "V" + f * a : "M" + b + "," + c + "H" + v), k.attr("opacity", 1).attr("transform", function(C) {
return h(_(C) + c);
}), A.attr(s + "2", f * o), $.attr(s, f * g).text(m), w.filter(Np).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", n === Di ? "start" : n === mr ? "end" : "middle"), w.each(function() {
this.__axis = _;
});
}
return l.scale = function(d) {
return arguments.length ? (t = d, l) : t;
}, l.ticks = function() {
return e = Array.from(arguments), l;
}, l.tickArguments = function(d) {
return arguments.length ? (e = d == null ? [] : Array.from(d), l) : e.slice();
}, l.tickValues = function(d) {
return arguments.length ? (r = d == null ? null : Array.from(d), l) : r && r.slice();
}, l.tickFormat = function(d) {
return arguments.length ? (i = d, l) : i;
}, l.tickSize = function(d) {
return arguments.length ? (o = a = +d, l) : o;
}, l.tickSizeInner = function(d) {
return arguments.length ? (o = +d, l) : o;
}, l.tickSizeOuter = function(d) {
return arguments.length ? (a = +d, l) : a;
}, l.tickPadding = function(d) {
return arguments.length ? (u = +d, l) : u;
}, l.offset = function(d) {
return arguments.length ? (c = +d, l) : c;
}, l;
}
function Rp(n) {
return qo(Pi, n);
}
function Ip(n) {
return qo(Di, n);
}
function Cp(n) {
return qo(gu, n);
}
function Pp(n) {
return qo(mr, n);
}
var Dp = { value: () => {
} };
function pe() {
for (var n = 0, t = arguments.length, e = {}, r; n < t; ++n) {
if (!(r = arguments[n] + "") || r in e || /[\s.]/.test(r)) throw new Error("illegal type: " + r);
e[r] = [];
}
return new zi(e);
}
function zi(n) {
this._ = n;
}
function zp(n, t) {
return n.trim().split(/^|\s+/).map(function(e) {
var r = "", i = e.indexOf(".");
if (i >= 0 && (r = e.slice(i + 1), e = e.slice(0, i)), e && !t.hasOwnProperty(e)) throw new Error("unknown type: " + e);
return { type: e, name: r };
});
}
zi.prototype = pe.prototype = {
constructor: zi,
on: function(n, t) {
var e = this._, r = zp(n + "", e), i, o = -1, a = r.length;
if (arguments.length < 2) {
for (; ++o < a; ) if ((i = (n = r[o]).type) && (i = Op(e[i], n.name))) return i;
return;
}
if (t != null && typeof t != "function") throw new Error("invalid callback: " + t);
for (; ++o < a; )
if (i = (n = r[o]).type) e[i] = Cc(e[i], n.name, t);
else if (t == null) for (i in e) e[i] = Cc(e[i], n.name, null);
return this;
},
copy: function() {
var n = {}, t = this._;
for (var e in t) n[e] = t[e].slice();
return new zi(n);
},
call: function(n, t) {
if ((i = arguments.length - 2) > 0) for (var e = new Array(i), r = 0, i, o; r < i; ++r) e[r] = arguments[r + 2];
if (!this._.hasOwnProperty(n)) throw new Error("unknown type: " + n);
for (o = this._[n], r = 0, i = o.length; r < i; ++r) o[r].value.apply(t, e);
},
apply: function(n, t, e) {
if (!this._.hasOwnProperty(n)) throw new Error("unknown type: " + n);
for (var r = this._[n], i = 0, o = r.length; i < o; ++i) r[i].value.apply(t, e);
}
};
function Op(n, t) {
for (var e = 0, r = n.length, i; e < r; ++e)
if ((i = n[e]).name === t)
return i.value;
}
function Cc(n, t, e) {
for (var r = 0, i = n.length; r < i; ++r)
if (n[r].name === t) {
n[r] = Dp, n = n.slice(0, r).concat(n.slice(r + 1));
break;
}
return e != null && n.push({ name: t, value: e }), n;
}
var pu = "http://www.w3.org/1999/xhtml";
const mu = {
svg: "http://www.w3.org/2000/svg",
xhtml: pu,
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
function Kr(n) {
var t = n += "", e = t.indexOf(":");
return e >= 0 && (t = n.slice(0, e)) !== "xmlns" && (n = n.slice(e + 1)), mu.hasOwnProperty(t) ? { space: mu[t], local: n } : n;
}
function Yp(n) {
return function() {
var t = this.ownerDocument, e = this.namespaceURI;
return e === pu && t.documentElement.namespaceURI === pu ? t.createElement(n) : t.createElementNS(e, n);
};
}
function Fp(n) {
return function() {
return this.ownerDocument.createElementNS(n.space, n.local);
};
}
function Lo(n) {
var t = Kr(n);
return (t.local ? Fp : Yp)(t);
}
function qp() {
}
function Bo(n) {
return n == null ? qp : function() {
return this.querySelector(n);
};
}
function Lp(n) {
typeof n != "function" && (n = Bo(n));
for (var t = this._groups, e = t.length, r = new Array(e), i = 0; i < e; ++i)
for (var o = t[i], a = o.length, u = r[i] = new Array(a), c, f, s = 0; s < a; ++s)
(c = o[s]) && (f = n.call(c, c.__data__, s, o)) && ("__data__" in c && (f.__data__ = c.__data__), u[s] = f);
return new qn(r, this._parents);
}
function yh(n) {
return n == null ? [] : Array.isArray(n) ? n : Array.from(n);
}
function Bp() {
return [];
}
function _f(n) {
return n == null ? Bp : function() {
return this.querySelectorAll(n);
};
}
function Up(n) {
return function() {
return yh(n.apply(this, arguments));
};
}
function Xp(n) {
typeof n == "function" ? n = Up(n) : n = _f(n);
for (var t = this._groups, e = t.length, r = [], i = [], o = 0; o < e; ++o)
for (var a = t[o], u = a.length, c, f = 0; f < u; ++f)
(c = a[f]) && (r.push(n.call(c, c.__data__, f, a)), i.push(c));
return new qn(r, i);
}
function vf(n) {
return function() {
return this.matches(n);
};
}
function _h(n) {
return function(t) {
return t.matches(n);
};
}
var Hp = Array.prototype.find;
function jp(n) {
return function() {
return Hp.call(this.children, n);
};
}
function Wp() {
return this.firstElementChild;
}
function Vp(n) {
return this.select(n == null ? Wp : jp(typeof n == "function" ? n : _h(n)));
}
var Gp = Array.prototype.filter;
function Zp() {
return Array.from(this.children);
}
function Qp(n) {
return function() {
return Gp.call(this.children, n);
};
}
function Kp(n) {
return this.selectAll(n == null ? Zp : Qp(typeof n == "function" ? n : _h(n)));
}
function Jp(n) {
typeof n != "function" && (n = vf(n));
for (var t = this._groups, e = t.length, r = new Array(e), i = 0; i < e; ++i)
for (var o = t[i], a = o.length, u = r[i] = [], c, f = 0; f < a; ++f)
(c = o[f]) && n.call(c, c.__data__, f, o) && u.push(c);
return new qn(r, this._parents);
}
function vh(n) {
return new Array(n.length);
}
function n2() {
return new qn(this._enter || this._groups.map(vh), this._parents);
}
function Zi(n, t) {
this.ownerDocument = n.ownerDocument, this.namespaceURI = n.namespaceURI, this._next = null, this._parent = n, this.__data__ = t;
}
Zi.prototype = {
constructor: Zi,
appendChild: function(n) {
return this._parent.insertBefore(n, this._next);
},
insertBefore: function(n, t) {
return this._parent.insertBefore(n, t);
},
querySelector: function(n) {
return this._parent.querySelector(n);
},
querySelectorAll: function(n) {
return this._parent.querySelectorAll(n);
}
};
function t2(n) {
return function() {
return n;
};
}
function e2(n, t, e, r, i, o) {
for (var a = 0, u, c = t.length, f = o.length; a < f; ++a)
(u = t[a]) ? (u.__data__ = o[a], r[a] = u) : e[a] = new Zi(n, o[a]);
for (; a < c; ++a)
(u = t[a]) && (i[a] = u);
}
function r2(n, t, e, r, i, o, a) {
var u, c, f = /* @__PURE__ */ new Map(), s = t.length, h = o.length, l = new Array(s), d;
for (u = 0; u < s; ++u)
(c = t[u]) && (l[u] = d = a.call(c, c.__data__, u, t) + "", f.has(d) ? i[u] = c : f.set(d, c));
for (u = 0; u < h; ++u)
d = a.call(n, o[u], u, o) + "", (c = f.get(d)) ? (r[u] = c, c.__data__ = o[u], f.delete(d)) : e[u] = new Zi(n, o[u]);
for (u = 0; u < s; ++u)
(c = t[u]) && f.get(l[u]) === c && (i[u] = c);
}
function i2(n) {
return n.__data__;
}
function o2(n, t) {
if (!arguments.length) return Array.from(this, i2);
var e = t ? r2 : e2, r = this._parents, i = this._groups;
typeof n != "function" && (n = t2(n));
for (var o = i.length, a = new Array(o), u = new Array(o), c = new Array(o), f = 0; f < o; ++f) {
var s = r[f], h = i[f], l = h.length, d = a2(n.call(s, s && s.__data__, f, r)), p = d.length, m = u[f] = new Array(p), g = a[f] = new Array(p), y = c[f] = new Array(l);
e(s, h, m, g, y, d, t);
for (var b = 0, v = 0, _, w; b < p; ++b)
if (_ = m[b]) {
for (b >= v && (v = b + 1); !(w = g[v]) && ++v < p; ) ;
_._next = w || null;
}
}
return a = new qn(a, r), a._enter = u, a._exit = c, a;
}
function a2(n) {
return typeof n == "object" && "length" in n ? n : Array.from(n);
}
function u2() {
return new qn(this._exit || this._groups.map(vh), this._parents);
}
function f2(n, t, e) {
var r = this.enter(), i = this, o = this.exit();
return typeof n == "function" ? (r = n(r), r && (r = r.selection())) : r = r.append(n + ""), t != null && (i = t(i), i && (i = i.selection())), e == null ? o.remove() : e(o), r && i ? r.merge(i).order() : i;
}
function c2(n) {
for (var t = n.selection ? n.selection() : n, e = this._groups, r = t._groups, i = e.length, o = r.length, a = Math.min(i, o), u = new Array(i), c = 0; c < a; ++c)
for (var f = e[c], s = r[c], h = f.length, l = u[c] = new Array(h), d, p = 0; p < h; ++p)
(d = f[p] || s[p]) && (l[p] = d);
for (; c < i; ++c)
u[c] = e[c];
return new qn(u, this._parents);
}
function s2() {
for (var n = this._groups, t = -1, e = n.length; ++t < e; )
for (var r = n[t], i = r.length - 1, o = r[i], a; --i >= 0; )
(a = r[i]) && (o && a.compareDocumentPosition(o) ^ 4 && o.parentNode.insertBefore(a, o), o = a);
return this;
}
function l2(n) {
n || (n = h2);
function t(h, l) {
return h && l ? n(h.__data__, l.__data__) : !h - !l;
}
for (var e = this._groups, r = e.length, i = new Array(r), o = 0; o < r; ++o) {
for (var a = e[o], u = a.length, c = i[o] = new Array(u), f, s = 0; s < u; ++s)
(f = a[s]) && (c[s] = f);
c.sort(t);
}
return new qn(i, this._parents).order();
}
function h2(n, t) {
return n < t ? -1 : n > t ? 1 : n >= t ? 0 : NaN;
}
function d2() {
var n = arguments[0];
return arguments[0] = this, n.apply(null, arguments), this;
}
function g2() {
return Array.from(this);
}
function p2() {
for (var n = this._groups, t = 0, e = n.length; t < e; ++t)
for (var r = n[t], i = 0, o = r.length; i < o; ++i) {
var a = r[i];
if (a) return a;
}
return null;
}
function m2() {
let n = 0;
for (const t of this) ++n;
return n;
}
function y2() {
return !this.node();
}
function _2(n) {
for (var t = this._groups, e = 0, r = t.length; e < r; ++e)
for (var i = t[e], o = 0, a = i.length, u; o < a; ++o)
(u = i[o]) && n.call(u, u.__data__, o, i);
return this;
}
function v2(n) {
return function() {
this.removeAttribute(n);
};
}
function b2(n) {
return function() {
this.removeAttributeNS(n.space, n.local);
};
}
function w2(n, t) {
return function() {
this.setAttribute(n, t);
};
}
function x2(n, t) {
return function() {
this.setAttributeNS(n.space, n.local, t);
};
}
function M2(n, t) {
return function() {
var e = t.apply(this, arguments);
e == null ? this.removeAttribute(n) : this.setAttribute(n, e);
};
}
function $2(n, t) {
return function() {
var e = t.apply(this, arguments);
e == null ? this.removeAttributeNS(n.space, n.local) : this.setAttributeNS(n.space, n.local, e);
};
}
function T2(n, t) {
var e = Kr(n);
if (arguments.length < 2) {
var r = this.node();
return e.local ? r.getAttributeNS(e.space, e.local) : r.getAttribute(e);
}
return this.each((t == null ? e.local ? b2 : v2 : typeof t == "function" ? e.local ? $2 : M2 : e.local ? x2 : w2)(e, t));
}
function bf(n) {
return n.ownerDocument && n.ownerDocument.defaultView || n.document && n || n.defaultView;
}
function A2(n) {
return function() {
this.style.removeProperty(n);
};
}
function S2(n, t, e) {
return function() {
this.style.setProperty(n, t, e);
};
}
function E2(n, t, e) {
return function() {
var r = t.apply(this, arguments);
r == null ? this.style.removeProperty(n) : this.style.setProperty(n, r, e);
};
}
function k2(n, t, e) {
return arguments.length > 1 ? this.each((t == null ? A2 : typeof t == "function" ? E2 : S2)(n, t, e ?? "")) : ue(this.node(), n);
}
function ue(n, t) {
return n.style.getPropertyValue(t) || bf(n).getComputedStyle(n, null).getPropertyValue(t);
}
function N2(n) {
return function() {
delete this[n];
};
}
function R2(n, t) {
return function() {
this[n] = t;
};
}
function I2(n, t) {
return function() {
var e = t.apply(this, arguments);
e == null ? delete this[n] : this[n] = e;
};
}
function C2(n, t) {
return arguments.length > 1 ? this.each((t == null ? N2 : typeof t == "function" ? I2 : R2)(n, t)) : this.node()[n];
}
function bh(n) {
return n.trim().split(/^|\s+/);
}
function wf(n) {
return n.classList || new wh(n);
}
function wh(n) {
this._node = n, this._names = bh(n.getAttribute("class") || "");
}
wh.prototype = {
add: function(n) {
var t = this._names.indexOf(n);
t < 0 && (this._names.push(n), this._node.setAttribute("class", this._names.join(" ")));
},
remove: function(n) {
var t = this._names.indexOf(n);
t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" ")));
},
contains: function(n) {
return this._names.indexOf(n) >= 0;
}
};
function xh(n, t) {
for (var e = wf(n), r = -1, i = t.length; ++r < i; ) e.add(t[r]);
}
function Mh(n, t) {
for (var e = wf(n), r = -1, i = t.length; ++r < i; ) e.remove(t[r]);
}
function P2(n) {
return function() {
xh(this, n);
};
}
function D2(n) {
return function() {
Mh(this, n);
};
}
function z2(n, t) {
return function() {
(t.apply(this, arguments) ? xh : Mh)(this, n);
};
}
function O2(n, t) {
var e = bh(n + "");
if (arguments.length < 2) {
for (var r = wf(this.node()), i = -1, o = e.length; ++i < o; ) if (!r.contains(e[i])) return !1;
return !0;
}
return this.each((typeof t == "function" ? z2 : t ? P2 : D2)(e, t));
}
function Y2() {
this.textContent = "";
}
function F2(n) {
return function() {
this.textContent = n;
};
}
function q2(n) {
return function() {
var t = n.apply(this, arguments);
this.textContent = t ?? "";
};
}
function L2(n) {
return arguments.length ? this.each(n == null ? Y2 : (typeof n == "function" ? q2 : F2)(n)) : this.node().textContent;
}
function B2() {
this.innerHTML = "";
}
function U2(n) {
return function() {
this.innerHTML = n;
};
}
function X2(n) {
return function() {
var t = n.apply(this, arguments);
this.innerHTML = t ?? "";
};
}
function H2(n) {
return arguments.length ? this.each(n == null ? B2 : (typeof n == "function" ? X2 : U2)(n)) : this.node().innerHTML;
}
function j2() {
this.nextSibling && this.parentNode.appendChild(this);
}
function W2() {
return this.each(j2);
}
function V2() {
this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function G2() {
return this.each(V2);
}
function Z2(n) {
var t = typeof n == "function" ? n : Lo(n);
return this.select(function() {
return this.appendChild(t.apply(this, arguments));
});
}
function Q2() {
return null;
}
function K2(n, t) {
var e = typeof n == "function" ? n : Lo(n), r = t == null ? Q2 : typeof t == "function" ? t : Bo(t);
return this.select(function() {
return this.insertBefore(e.apply(this, arguments), r.apply(this, arguments) || null);
});
}
function J2() {
var n = this.parentNode;
n && n.removeChild(this);
}
function nm() {
return this.each(J2);
}
function tm() {
var n = this.cloneNode(!1), t = this.parentNode;
return t ? t.insertBefore(n, this.nextSibling) : n;
}
function em() {
var n = this.cloneNode(!0), t = this.parentNode;
return t ? t.insertBefore(n, this.nextSibling) : n;
}
function rm(n) {
return this.select(n ? em : tm);
}
function im(n) {
return arguments.length ? this.property("__data__", n) : this.node().__data__;
}
function om(n) {
return function(t) {
n.call(this, t, this.__data__);
};
}
function am(n) {
return n.trim().split(/^|\s+/).map(function(t) {
var e = "", r = t.indexOf(".");
return r >= 0 && (e = t.slice(r + 1), t = t.slice(0, r)), { type: t, name: e };
});
}
function um(n) {
return function() {
var t = this.__on;
if (t) {
for (var e = 0, r = -1, i = t.length, o; e < i; ++e)
o = t[e], (!n.type || o.type === n.type) && o.name === n.name ? this.removeEventListener(o.type, o.listener, o.options) : t[++r] = o;
++r ? t.length = r : delete this.__on;
}
};
}
function fm(n, t, e) {
return function() {
var r = this.__on, i, o = om(t);
if (r) {
for (var a = 0, u = r.length; a < u; ++a)
if ((i = r[a]).type === n.type && i.name === n.name) {
this.removeEventListener(i.type, i.listener, i.options), this.addEventListener(i.type, i.listener = o, i.options = e), i.value = t;
return;
}
}
this.addEventListener(n.type, o, e), i = { type: n.type, name: n.name, value: t, listener: o, options: e }, r ? r.push(i) : this.__on = [i];
};
}
function cm(n, t, e) {
var r = am(n + ""), i, o = r.length, a;
if (arguments.length < 2) {
var u = this.node().__on;
if (u) {
for (var c = 0, f = u.length, s; c < f; ++c)
for (i = 0, s = u[c]; i < o; ++i)
if ((a = r[i]).type === s.type && a.name === s.name)
return s.value;
}
return;
}
for (u = t ? fm : um, i = 0; i < o; ++i) this.each(u(r[i], t, e));
return this;
}
function $h(n, t, e) {
var r = bf(n), i = r.CustomEvent;
typeof i == "function" ? i = new i(t, e) : (i = r.document.createEvent("Event"), e ? (i.initEvent(t, e.bubbles, e.cancelable), i.detail = e.detail) : i.initEvent(t, !1, !1)), n.dispatchEvent(i);
}
function sm(n, t) {
return function() {
return $h(this, n, t);
};
}
function lm(n, t) {
return function() {
return $h(this, n, t.apply(this, arguments));
};
}
function hm(n, t) {
return this.each((typeof t == "function" ? lm : sm)(n, t));
}
function* dm() {
for (var n = this._groups, t = 0, e = n.length; t < e; ++t)
for (var r = n[t], i = 0, o = r.length, a; i < o; ++i)
(a = r[i]) && (yield a);
}
var xf = [null];
function qn(n, t) {
this._groups = n, this._parents = t;
}
function me() {
return new qn([[document.documentElement]], xf);
}
function gm() {
return this;
}
qn.prototype = me.prototype = {
constructor: qn,
select: Lp,
selectAll: Xp,
selectChild: Vp,
selectChildren: Kp,
filter: Jp,
data: o2,
enter: n2,
exit: u2,
join: f2,
merge: c2,
selection: gm,
order: s2,
sort: l2,
call: d2,
nodes: g2,
node: p2,
size: m2,
empty: y2,
each: _2,
attr: T2,
style: k2,
property: C2,
classed: O2,
text: L2,
html: H2,
raise: W2,
lower: G2,
append: Z2,
insert: K2,
remove: nm,
clone: rm,
datum: im,
on: cm,
dispatch: hm,
[Symbol.iterator]: dm
};
function X(n) {
return typeof n == "string" ? new qn([[document.querySelector(n)]], [document.documentElement]) : new qn([[n]], xf);
}
function pm(n) {
return X(Lo(n).call(document.documentElement));
}
var mm = 0;
function Th() {
return new yu();
}
function yu() {
this._ = "@" + (++mm).toString(36);
}
yu.prototype = Th.prototype = {
constructor: yu,
get: function(n) {
for (var t = this._; !(t in n); ) if (!(n = n.parentNode)) return;
return n[t];
},
set: function(n, t) {
return n[this._] = t;
},
remove: function(n) {
return this._ in n && delete n[this._];
},
toString: function() {
return this._;
}
};
function Ah(n) {
let t;
for (; t = n.sourceEvent; ) n = t;
return n;
}
function wn(n, t) {
if (n = Ah(n), t === void 0 && (t = n.currentTarget), t) {
var e = t.ownerSVGElement || t;
if (e.createSVGPoint) {
var r = e.createSVGPoint();
return r.x = n.clientX, r.y = n.clientY, r = r.matrixTransform(t.getScreenCTM().inverse()), [r.x, r.y];
}
if (t.getBoundingClientRect) {
var i = t.getBoundingClientRect();
return [n.clientX - i.left - t.clientLeft, n.clientY - i.top - t.clientTop];
}
}
return [n.pageX, n.pageY];
}
function ym(n, t) {
return n.target && (n = Ah(n), t === void 0 && (t = n.currentTarget), n = n.touches || [n]), Array.from(n, (e) => wn(e, t));
}
function _m(n) {
return typeof n == "string" ? new qn([document.querySelectorAll(n)], [document.documentElement]) : new qn([yh(n)], xf);
}
const vm = { passive: !1 }, Or = { capture: !0, passive: !1 };
function Sa(n) {
n.stopImmediatePropagation();
}
function De(n) {
n.preventDefault(), n.stopImmediatePropagation();
}
function Uo(n) {
var t = n.document.documentElement, e = X(n).on("dragstart.drag", De, Or);
"onselectstart" in t ? e.on("selectstart.drag", De, Or) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function Xo(n, t) {
var e = n.document.documentElement, r = X(n).on("dragstart.drag", null);
t && (r.on("click.drag", De, Or), setTimeout(function() {
r.on("click.drag", null);
}, 0)), "onselectstart" in e ? r.on("selectstart.drag", null) : (e.style.MozUserSelect = e.__noselect, delete e.__noselect);
}
const hi = (n) => () => n;
function _u(n, {
sourceEvent: t,
subject: e,
target: r,
identifier: i,
active: o,
x: a,
y: u,
dx: c,
dy: f,
dispatch: s
}) {
Object.defineProperties(this, {
type: { value: n, enumerable: !0, configurable: !0 },
sourceEvent: { value: t, enumerable: !0, configurable: !0 },
subject: { value: e, enumerable: !0, configurable: !0 },
target: { value: r, enumerable: !0, configurable: !0 },
identifier: { value: i, enumerable: !0, configurable: !0 },
active: { value: o, enumerable: !0, configurable: !0 },
x: { value: a, enumerable: !0, configurable: !0 },
y: { value: u, enumerable: !0, configurable: !0 },
dx: { value: c, enumerable: !0, configurable: !0 },
dy: { value: f, enumerable: !0, configurable: !0 },
_: { value: s }
});
}
_u.prototype.on = function() {
var n = this._.on.apply(this._, arguments);
return n === this._ ? this : n;
};
function bm(n) {
return !n.ctrlKey && !n.button;
}
function wm() {
return this.parentNode;
}
function xm(n, t) {
return t ?? { x: n.x, y: n.y };
}
function Mm() {
return navigator.maxTouchPoints || "ontouchstart" in this;
}
function Sh() {
var n = bm, t = wm, e = xm, r = Mm, i = {}, o = pe("start", "drag", "end"), a = 0, u, c, f, s, h = 0;
function l(_) {
_.on("mousedown.drag", d).filter(r).on("touchstart.drag", g).on("touchmove.drag", y, vm).on("touchend.drag touchcancel.drag", b).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
}
function d(_, w) {
if (!(s || !n.call(this, _, w))) {
var M = v(this, t.call(this, _, w), _, w, "mouse");
M && (X(_.view).on("mousemove.drag", p, Or).on("mouseup.drag", m, Or), Uo(_.view), Sa(_), f = !1, u = _.clientX, c = _.clientY, M("start", _));
}
}
function p(_) {
if (De(_), !f) {
var w = _.clientX - u, M = _.clientY - c;
f = w * w + M * M > h;
}
i.mouse("drag", _);
}
function m(_) {
X(_.view).on("mousemove.drag mouseup.drag", null), Xo(_.view, f), De(_), i.mouse("end", _);
}
function g(_, w) {
if (n.call(this, _, w)) {
var M = _.changedTouches, k = t.call(this, _, w), N = M.length, T, A;
for (T = 0; T < N; ++T)
(A = v(this, k, _, w, M[T].identifier, M[T])) && (Sa(_), A("start", _, M[T]));
}
}
function y(_) {
var w = _.changedTouches, M = w.length, k, N;
for (k = 0; k < M; ++k)
(N = i[w[k].identifier]) && (De(_), N("drag", _, w[k]));
}
function b(_) {
var w = _.changedTouches, M = w.length, k, N;
for (s && clearTimeout(s), s = setTimeout(function() {
s = null;
}, 500), k = 0; k < M; ++k)
(N = i[w[k].identifier]) && (Sa(_), N("end", _, w[k]));
}
function v(_, w, M, k, N, T) {
var A = o.copy(), $ = wn(T || M, w), C, R, x;
if ((x = e.call(_, new _u("beforestart", {
sourceEvent: M,
target: l,
identifier: N,
active: a,
x: $[0],
y: $[1],
dx: 0,
dy: 0,
dispatch: A
}), k)) != null)
return C = x.x - $[0] || 0, R = x.y - $[1] || 0, function E(S, I, D) {
var P = $, O;
switch (S) {
case "start":
i[N] = E, O = a++;
break;
case "end":
delete i[N], --a;
// falls through
case "drag":
$ = wn(D || I, w), O = a;
break;
}
A.call(
S,
_,
new _u(S, {
sourceEvent: I,