From 5251937285823fdbf0e2cd4018978bab02ba4a2d Mon Sep 17 00:00:00 2001 From: skaphan Date: Tue, 24 Feb 2026 13:32:27 -0500 Subject: [PATCH 01/13] Add pie chart visualization template Add embedded pie chart web component, templates, static assets, and pie_chart_no_cache setting. Store raw JSON on graph for pie chart data access. --- common/cloudflare.py | 5 +- common/viewUtils.py | 1 + rcvis/settings.py | 9 + static/pie/pie-chart.es.js | 5607 ++++++++++++++++++ static/pie/pie.css | 5 + static/share/share.js | 3 +- static/visualizer/tabicons/pie.png | Bin 0 -> 2319 bytes templates/pie/pie-nonblocking.html | 54 + templates/pie/pie.html | 9 + templates/visualizer/visualize-embedded.html | 4 + templates/visualizer/visualize.html | 29 +- visualizer/graph/readRCVRCJSON.py | 1 + visualizer/serializers.py | 2 + visualizer/tests/testLiveBrowserHeadless.py | 4 +- 14 files changed, 5721 insertions(+), 12 deletions(-) create mode 100644 static/pie/pie-chart.es.js create mode 100644 static/pie/pie.css create mode 100644 static/visualizer/tabicons/pie.png create mode 100644 templates/pie/pie-nonblocking.html create mode 100644 templates/pie/pie.html diff --git a/common/cloudflare.py b/common/cloudflare.py index 33c2a7f9..8fbba373 100644 --- a/common/cloudflare.py +++ b/common/cloudflare.py @@ -40,6 +40,7 @@ def purge_vis_cache(cls, slug): reverse('visualizeEmbedly', args=(slug, 'barchart-interactive')), reverse('visualizeEmbedly', args=(slug, 'sankey')), reverse('visualizeEmbedly', args=(slug, 'table')), + reverse('visualizeEmbedly', args=(slug, 'pie')), reverse('visualizeBallotpedia', args=(slug,)), reverse('visualizeEmbedded', args=(slug,)) + '?vistype=barchart-interactive', reverse('visualizeEmbedded', args=(slug,)) + '?vistype=barchart-fixed', @@ -47,7 +48,9 @@ def purge_vis_cache(cls, slug): reverse('visualizeEmbedded', args=(slug,)) + '?vistype=tabular-by-round', reverse('visualizeEmbedded', args=(slug,)) + '?vistype=tabular-by-round-interactive', reverse('visualizeEmbedded', args=(slug,)) + '?vistype=candidate-by-round', - reverse('visualizeEmbedded', args=(slug,)) + '?vistype=sankey' + reverse('visualizeEmbedded', args=(slug,)) + '?vistype=sankey', + reverse('visualizeEmbedded', args=(slug,)) + '?vistype=pie' + ] cls.purge_paths_cache(paths) diff --git a/common/viewUtils.py b/common/viewUtils.py index 8c5f48c7..49c13ce5 100644 --- a/common/viewUtils.py +++ b/common/viewUtils.py @@ -68,6 +68,7 @@ def get_data_for_graph(graph, config): 'tabularByRound': tabularByRound, 'tabularByRoundInteractive': tabularByRoundInteractive, 'graph': graph, + 'rawData': graph._raw_JSON, 'textForWinner': as_caption(config).lower(), } roundDescriberData = get_data_for_round_describer(graph, config) diff --git a/rcvis/settings.py b/rcvis/settings.py index b75da902..78c3d38a 100644 --- a/rcvis/settings.py +++ b/rcvis/settings.py @@ -191,6 +191,15 @@ } } + +def pie_chart_no_cache(headers, path, url): + """Ensure browsers revalidate the pie chart component on every load.""" + if url.endswith('pie-chart.es.js'): + headers['Cache-Control'] = 'no-cache' + + +WHITENOISE_ADD_HEADERS_FUNCTION = pie_chart_no_cache + NODE_PACKAGE_JSON = './package.json' NODE_MODULES_ROOT = './node_modules' NODE_PACKAGE_MANAGER_EXECUTABLE = os.environ.get('NODE_PACKAGE_MANAGER_EXECUTABLE', '/usr/bin/npm') diff --git a/static/pie/pie-chart.es.js b/static/pie/pie-chart.es.js new file mode 100644 index 00000000..a70b1317 --- /dev/null +++ b/static/pie/pie-chart.es.js @@ -0,0 +1,5607 @@ +var ol = Object.defineProperty; +var ks = (t) => { + throw TypeError(t); +}; +var ll = (t, e, n) => e in t ? ol(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; +var ot = (t, e, n) => ll(t, typeof e != "symbol" ? e + "" : e, n), Ti = (t, e, n) => e.has(t) || ks("Cannot " + n); +var d = (t, e, n) => (Ti(t, e, "read from private field"), n ? n.call(t) : e.get(t)), L = (t, e, n) => e.has(t) ? ks("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), O = (t, e, n, r) => (Ti(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n), pt = (t, e, n) => (Ti(t, e, "access private method"), n); +var ua; +typeof window < "u" && ((ua = window.__svelte ?? (window.__svelte = {})).v ?? (ua.v = /* @__PURE__ */ new Set())).add("5"); +const ul = 1, fl = 2, cl = 16, hl = 1, dl = 4, pl = 8, vl = 16, gl = 2, is = "[", fi = "[!", ss = "]", Bn = {}, _t = Symbol(), _l = "http://www.w3.org/1999/xhtml", Di = !1; +var ha = Array.isArray, ml = Array.prototype.indexOf, Un = Array.prototype.includes, ci = Array.from, Zr = Object.keys, Jr = Object.defineProperty, mn = Object.getOwnPropertyDescriptor, yl = Object.prototype, wl = Array.prototype, xl = Object.getPrototypeOf, Ms = Object.isExtensible; +const bl = () => { +}; +function $l(t) { + for (var e = 0; e < t.length; e++) + t[e](); +} +function da() { + var t, e, n = new Promise((r, i) => { + t = r, e = i; + }); + return { promise: n, resolve: t, reject: e }; +} +function Al(t, e) { + if (Array.isArray(t)) + return t; + if (!(Symbol.iterator in t)) + return Array.from(t); + const n = []; + for (const r of t) + if (n.push(r), n.length === e) break; + return n; +} +const wt = 2, vr = 4, hi = 8, pa = 1 << 24, Ue = 16, pe = 32, en = 64, va = 128, Jt = 512, vt = 1024, xt = 2048, de = 4096, Lt = 8192, He = 16384, Qn = 32768, Xn = 65536, Ps = 1 << 17, ga = 1 << 18, Nn = 1 << 19, El = 1 << 20, Ze = 1 << 25, $n = 65536, Ii = 1 << 21, as = 1 << 22, Je = 1 << 23, hr = Symbol("$state"), _a = Symbol("legacy props"), on = new class extends Error { + constructor() { + super(...arguments); + ot(this, "name", "StaleReactionError"); + ot(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed"); + } +}(), Rr = 3, tr = 8; +function Rl(t) { + throw new Error("https://svelte.dev/e/lifecycle_outside_component"); +} +function Tl() { + throw new Error("https://svelte.dev/e/async_derived_orphan"); +} +function Cl(t, e, n) { + throw new Error("https://svelte.dev/e/each_key_duplicate"); +} +function Nl(t) { + throw new Error("https://svelte.dev/e/effect_in_teardown"); +} +function Sl() { + throw new Error("https://svelte.dev/e/effect_in_unowned_derived"); +} +function kl(t) { + throw new Error("https://svelte.dev/e/effect_orphan"); +} +function Ml() { + throw new Error("https://svelte.dev/e/effect_update_depth_exceeded"); +} +function Pl() { + throw new Error("https://svelte.dev/e/hydration_failed"); +} +function Ol(t) { + throw new Error("https://svelte.dev/e/props_invalid_value"); +} +function Dl() { + throw new Error("https://svelte.dev/e/state_descriptors_fixed"); +} +function Il() { + throw new Error("https://svelte.dev/e/state_prototype_fixed"); +} +function Fl() { + throw new Error("https://svelte.dev/e/state_unsafe_mutation"); +} +function Ll() { + throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror"); +} +function di(t) { + console.warn("https://svelte.dev/e/hydration_mismatch"); +} +function ql() { + console.warn("https://svelte.dev/e/svelte_boundary_reset_noop"); +} +let Z = !1; +function ze(t) { + Z = t; +} +let H; +function Pt(t) { + if (t === null) + throw di(), Bn; + return H = t; +} +function pi() { + return Pt(/* @__PURE__ */ ke(H)); +} +function Ut(t) { + if (Z) { + if (/* @__PURE__ */ ke(H) !== null) + throw di(), Bn; + H = t; + } +} +function Fi(t = 1) { + if (Z) { + for (var e = t, n = H; e--; ) + n = /** @type {TemplateNode} */ + /* @__PURE__ */ ke(n); + H = n; + } +} +function Qr(t = !0) { + for (var e = 0, n = H; ; ) { + if (n.nodeType === tr) { + var r = ( + /** @type {Comment} */ + n.data + ); + if (r === ss) { + if (e === 0) return n; + e -= 1; + } else (r === is || r === fi || // "[1", "[2", etc. for if blocks + r[0] === "[" && !isNaN(Number(r.slice(1)))) && (e += 1); + } + var i = ( + /** @type {TemplateNode} */ + /* @__PURE__ */ ke(n) + ); + t && n.remove(), n = i; + } +} +function ma(t) { + if (!t || t.nodeType !== tr) + throw di(), Bn; + return ( + /** @type {Comment} */ + t.data + ); +} +function ya(t) { + return t === this.v; +} +function Vl(t, e) { + return t != t ? e == e : t !== e || t !== null && typeof t == "object" || typeof t == "function"; +} +function wa(t) { + return !Vl(t, this.v); +} +let zl = !1, qt = null; +function Gn(t) { + qt = t; +} +function os(t, e = !1, n) { + qt = { + p: qt, + i: !1, + c: null, + e: null, + s: t, + x: null, + l: null + }; +} +function ls(t) { + var e = ( + /** @type {ComponentContext} */ + qt + ), n = e.e; + if (n !== null) { + e.e = null; + for (var r of n) + Ua(r); + } + return t !== void 0 && (e.x = t), e.i = !0, qt = e.p, t ?? /** @type {T} */ + {}; +} +function xa() { + return !0; +} +let ln = []; +function ba() { + var t = ln; + ln = [], $l(t); +} +function yn(t) { + if (ln.length === 0 && !dr) { + var e = ln; + queueMicrotask(() => { + e === ln && ba(); + }); + } + ln.push(t); +} +function Hl() { + for (; ln.length > 0; ) + ba(); +} +function $a(t) { + var e = X; + if (e === null) + return z.f |= Je, t; + if ((e.f & Qn) === 0 && (e.f & vr) === 0) + throw t; + Kn(t, e); +} +function Kn(t, e) { + for (; e !== null; ) { + if ((e.f & va) !== 0) { + if ((e.f & Qn) === 0) + throw t; + try { + e.b.error(t); + return; + } catch (n) { + t = n; + } + } + e = e.parent; + } + throw t; +} +const Yl = -7169; +function lt(t, e) { + t.f = t.f & Yl | e; +} +function us(t) { + (t.f & Jt) !== 0 || t.deps === null ? lt(t, vt) : lt(t, de); +} +function Aa(t) { + if (t !== null) + for (const e of t) + (e.f & wt) === 0 || (e.f & $n) === 0 || (e.f ^= $n, Aa( + /** @type {Derived} */ + e.deps + )); +} +function Ea(t, e, n) { + (t.f & xt) !== 0 ? e.add(t) : (t.f & de) !== 0 && n.add(t), Aa(t.deps), lt(t, vt); +} +const Mr = /* @__PURE__ */ new Set(); +let Y = null, yt = null, St = [], vi = null, Li = !1, dr = !1; +var Fn, Ln, hn, qn, xr, br, dn, Ie, Vn, Se, qi, Vi, Ra; +const Es = class Es { + constructor() { + L(this, Se); + ot(this, "committed", !1); + /** + * The current values of any sources that are updated in this batch + * They keys of this map are identical to `this.#previous` + * @type {Map} + */ + ot(this, "current", /* @__PURE__ */ new Map()); + /** + * The values of any sources that are updated in this batch _before_ those updates took place. + * They keys of this map are identical to `this.#current` + * @type {Map} + */ + ot(this, "previous", /* @__PURE__ */ new Map()); + /** + * When the batch is committed (and the DOM is updated), we need to remove old branches + * and append new ones by calling the functions added inside (if/each/key/etc) blocks + * @type {Set<() => void>} + */ + L(this, Fn, /* @__PURE__ */ new Set()); + /** + * If a fork is discarded, we need to destroy any effects that are no longer needed + * @type {Set<(batch: Batch) => void>} + */ + L(this, Ln, /* @__PURE__ */ new Set()); + /** + * The number of async effects that are currently in flight + */ + L(this, hn, 0); + /** + * The number of async effects that are currently in flight, _not_ inside a pending boundary + */ + L(this, qn, 0); + /** + * A deferred that resolves when the batch is committed, used with `settled()` + * TODO replace with Promise.withResolvers once supported widely enough + * @type {{ promise: Promise, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null} + */ + L(this, xr, null); + /** + * Deferred effects (which run after async work has completed) that are DIRTY + * @type {Set} + */ + L(this, br, /* @__PURE__ */ new Set()); + /** + * Deferred effects that are MAYBE_DIRTY + * @type {Set} + */ + L(this, dn, /* @__PURE__ */ new Set()); + /** + * A map of branches that still exist, but will be destroyed when this batch + * is committed — we skip over these during `process`. + * The value contains child effects that were dirty/maybe_dirty before being reset, + * so they can be rescheduled if the branch survives. + * @type {Map} + */ + L(this, Ie, /* @__PURE__ */ new Map()); + ot(this, "is_fork", !1); + L(this, Vn, !1); + } + is_deferred() { + return this.is_fork || d(this, qn) > 0; + } + /** + * Add an effect to the #skipped_branches map and reset its children + * @param {Effect} effect + */ + skip_effect(e) { + d(this, Ie).has(e) || d(this, Ie).set(e, { d: [], m: [] }); + } + /** + * Remove an effect from the #skipped_branches map and reschedule + * any tracked dirty/maybe_dirty child effects + * @param {Effect} effect + */ + unskip_effect(e) { + var n = d(this, Ie).get(e); + if (n) { + d(this, Ie).delete(e); + for (var r of n.d) + lt(r, xt), ce(r); + for (r of n.m) + lt(r, de), ce(r); + } + } + /** + * + * @param {Effect[]} root_effects + */ + process(e) { + var i; + St = [], this.apply(); + var n = [], r = []; + for (const s of e) + pt(this, Se, qi).call(this, s, n, r); + if (this.is_deferred()) { + pt(this, Se, Vi).call(this, r), pt(this, Se, Vi).call(this, n); + for (const [s, a] of d(this, Ie)) + Sa(s, a); + } else { + for (const s of d(this, Fn)) s(); + d(this, Fn).clear(), d(this, hn) === 0 && pt(this, Se, Ra).call(this), Y = null, Os(r), Os(n), (i = d(this, xr)) == null || i.resolve(); + } + yt = null; + } + /** + * Associate a change to a given source with the current + * batch, noting its previous and current values + * @param {Source} source + * @param {any} value + */ + capture(e, n) { + n !== _t && !this.previous.has(e) && this.previous.set(e, n), (e.f & Je) === 0 && (this.current.set(e, e.v), yt == null || yt.set(e, e.v)); + } + activate() { + Y = this, this.apply(); + } + deactivate() { + Y === this && (Y = null, yt = null); + } + flush() { + if (this.activate(), St.length > 0) { + if (Ta(), Y !== null && Y !== this) + return; + } else d(this, hn) === 0 && this.process([]); + this.deactivate(); + } + discard() { + for (const e of d(this, Ln)) e(this); + d(this, Ln).clear(); + } + /** + * + * @param {boolean} blocking + */ + increment(e) { + O(this, hn, d(this, hn) + 1), e && O(this, qn, d(this, qn) + 1); + } + /** + * + * @param {boolean} blocking + */ + decrement(e) { + O(this, hn, d(this, hn) - 1), e && O(this, qn, d(this, qn) - 1), !d(this, Vn) && (O(this, Vn, !0), yn(() => { + O(this, Vn, !1), this.is_deferred() ? St.length > 0 && this.flush() : this.revive(); + })); + } + revive() { + for (const e of d(this, br)) + d(this, dn).delete(e), lt(e, xt), ce(e); + for (const e of d(this, dn)) + lt(e, de), ce(e); + this.flush(); + } + /** @param {() => void} fn */ + oncommit(e) { + d(this, Fn).add(e); + } + /** @param {(batch: Batch) => void} fn */ + ondiscard(e) { + d(this, Ln).add(e); + } + settled() { + return (d(this, xr) ?? O(this, xr, da())).promise; + } + static ensure() { + if (Y === null) { + const e = Y = new Es(); + Mr.add(Y), dr || yn(() => { + Y === e && e.flush(); + }); + } + return Y; + } + apply() { + } +}; +Fn = new WeakMap(), Ln = new WeakMap(), hn = new WeakMap(), qn = new WeakMap(), xr = new WeakMap(), br = new WeakMap(), dn = new WeakMap(), Ie = new WeakMap(), Vn = new WeakMap(), Se = new WeakSet(), /** + * Traverse the effect tree, executing effects or stashing + * them for later execution as appropriate + * @param {Effect} root + * @param {Effect[]} effects + * @param {Effect[]} render_effects + */ +qi = function(e, n, r) { + e.f ^= vt; + for (var i = e.first, s = null; i !== null; ) { + var a = i.f, o = (a & (pe | en)) !== 0, l = o && (a & vt) !== 0, u = l || (a & Lt) !== 0 || d(this, Ie).has(i); + if (!u && i.fn !== null) { + o ? i.f ^= vt : s !== null && (a & (vr | hi | pa)) !== 0 ? s.b.defer_effect(i) : (a & vr) !== 0 ? n.push(i) : Tr(i) && ((a & Ue) !== 0 && d(this, dn).add(i), jn(i)); + var f = i.first; + if (f !== null) { + i = f; + continue; + } + } + var h = i.parent; + for (i = i.next; i === null && h !== null; ) + h === s && (s = null), i = h.next, h = h.parent; + } +}, /** + * @param {Effect[]} effects + */ +Vi = function(e) { + for (var n = 0; n < e.length; n += 1) + Ea(e[n], d(this, br), d(this, dn)); +}, Ra = function() { + var i; + if (Mr.size > 1) { + this.previous.clear(); + var e = yt, n = !0; + for (const s of Mr) { + if (s === this) { + n = !1; + continue; + } + const a = []; + for (const [l, u] of this.current) { + if (s.current.has(l)) + if (n && u !== s.current.get(l)) + s.current.set(l, u); + else + continue; + a.push(l); + } + if (a.length === 0) + continue; + const o = [...s.current.keys()].filter((l) => !this.current.has(l)); + if (o.length > 0) { + var r = St; + St = []; + const l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(); + for (const f of a) + Ca(f, o, l, u); + if (St.length > 0) { + Y = s, s.apply(); + for (const f of St) + pt(i = s, Se, qi).call(i, f, [], []); + s.deactivate(); + } + St = r; + } + } + Y = null, yt = e; + } + this.committed = !0, Mr.delete(this); +}; +let Ye = Es; +function jt(t) { + var e = dr; + dr = !0; + try { + for (var n; ; ) { + if (Hl(), St.length === 0 && (Y == null || Y.flush(), St.length === 0)) + return vi = null, /** @type {T} */ + n; + Ta(); + } + } finally { + dr = e; + } +} +function Ta() { + Li = !0; + var t = null; + try { + for (var e = 0; St.length > 0; ) { + var n = Ye.ensure(); + if (e++ > 1e3) { + var r, i; + Bl(); + } + n.process(St), Qe.clear(); + } + } finally { + St = [], Li = !1, vi = null; + } +} +function Bl() { + try { + Ml(); + } catch (t) { + Kn(t, vi); + } +} +let oe = null; +function Os(t) { + var e = t.length; + if (e !== 0) { + for (var n = 0; n < e; ) { + var r = t[n++]; + if ((r.f & (He | Lt)) === 0 && Tr(r) && (oe = /* @__PURE__ */ new Set(), jn(r), r.deps === null && r.first === null && r.nodes === null && r.teardown === null && r.ac === null && Ka(r), (oe == null ? void 0 : oe.size) > 0)) { + Qe.clear(); + for (const i of oe) { + if ((i.f & (He | Lt)) !== 0) continue; + const s = [i]; + let a = i.parent; + for (; a !== null; ) + oe.has(a) && (oe.delete(a), s.push(a)), a = a.parent; + for (let o = s.length - 1; o >= 0; o--) { + const l = s[o]; + (l.f & (He | Lt)) === 0 && jn(l); + } + } + oe.clear(); + } + } + oe = null; + } +} +function Ca(t, e, n, r) { + if (!n.has(t) && (n.add(t), t.reactions !== null)) + for (const i of t.reactions) { + const s = i.f; + (s & wt) !== 0 ? Ca( + /** @type {Derived} */ + i, + e, + n, + r + ) : (s & (as | Ue)) !== 0 && (s & xt) === 0 && Na(i, e, r) && (lt(i, xt), ce( + /** @type {Effect} */ + i + )); + } +} +function Na(t, e, n) { + const r = n.get(t); + if (r !== void 0) return r; + if (t.deps !== null) + for (const i of t.deps) { + if (Un.call(e, i)) + return !0; + if ((i.f & wt) !== 0 && Na( + /** @type {Derived} */ + i, + e, + n + )) + return n.set( + /** @type {Derived} */ + i, + !0 + ), !0; + } + return n.set(t, !1), !1; +} +function ce(t) { + for (var e = vi = t; e.parent !== null; ) { + e = e.parent; + var n = e.f; + if (Li && e === X && (n & Ue) !== 0 && (n & ga) === 0) + return; + if ((n & (en | pe)) !== 0) { + if ((n & vt) === 0) return; + e.f ^= vt; + } + } + St.push(e); +} +function Sa(t, e) { + if (!((t.f & pe) !== 0 && (t.f & vt) !== 0)) { + (t.f & xt) !== 0 ? e.d.push(t) : (t.f & de) !== 0 && e.m.push(t), lt(t, vt); + for (var n = t.first; n !== null; ) + Sa(n, e), n = n.next; + } +} +function Ul(t) { + let e = 0, n = An(0), r; + return () => { + hs() && (w(n), ps(() => (e === 0 && (r = mi(() => t(() => pr(n)))), e += 1, () => { + yn(() => { + e -= 1, e === 0 && (r == null || r(), r = void 0, pr(n)); + }); + }))); + }; +} +var Xl = Xn | Nn | va; +function Gl(t, e, n) { + new Kl(t, e, n); +} +var It, $r, $e, pn, Ae, Kt, Nt, Ee, Fe, je, vn, Le, zn, gn, Hn, Yn, qe, li, ht, ka, Ma, zi, zr, Hr, Hi; +class Kl { + /** + * @param {TemplateNode} node + * @param {BoundaryProps} props + * @param {((anchor: Node) => void)} children + */ + constructor(e, n, r) { + L(this, ht); + /** @type {Boundary | null} */ + ot(this, "parent"); + ot(this, "is_pending", !1); + /** @type {TemplateNode} */ + L(this, It); + /** @type {TemplateNode | null} */ + L(this, $r, Z ? H : null); + /** @type {BoundaryProps} */ + L(this, $e); + /** @type {((anchor: Node) => void)} */ + L(this, pn); + /** @type {Effect} */ + L(this, Ae); + /** @type {Effect | null} */ + L(this, Kt, null); + /** @type {Effect | null} */ + L(this, Nt, null); + /** @type {Effect | null} */ + L(this, Ee, null); + /** @type {DocumentFragment | null} */ + L(this, Fe, null); + /** @type {TemplateNode | null} */ + L(this, je, null); + L(this, vn, 0); + L(this, Le, 0); + L(this, zn, !1); + L(this, gn, !1); + /** @type {Set} */ + L(this, Hn, /* @__PURE__ */ new Set()); + /** @type {Set} */ + L(this, Yn, /* @__PURE__ */ new Set()); + /** + * A source containing the number of pending async deriveds/expressions. + * Only created if `$effect.pending()` is used inside the boundary, + * otherwise updating the source results in needless `Batch.ensure()` + * calls followed by no-op flushes + * @type {Source | null} + */ + L(this, qe, null); + L(this, li, Ul(() => (O(this, qe, An(d(this, vn))), () => { + O(this, qe, null); + }))); + O(this, It, e), O(this, $e, n), O(this, pn, r), this.parent = /** @type {Effect} */ + X.b, this.is_pending = !!d(this, $e).pending, O(this, Ae, vs(() => { + if (X.b = this, Z) { + const s = d(this, $r); + pi(), /** @type {Comment} */ + s.nodeType === tr && /** @type {Comment} */ + s.data === fi ? pt(this, ht, Ma).call(this) : (pt(this, ht, ka).call(this), d(this, Le) === 0 && (this.is_pending = !1)); + } else { + var i = pt(this, ht, zi).call(this); + try { + O(this, Kt, Zt(() => r(i))); + } catch (s) { + this.error(s); + } + d(this, Le) > 0 ? pt(this, ht, Hr).call(this) : this.is_pending = !1; + } + return () => { + var s; + (s = d(this, je)) == null || s.remove(); + }; + }, Xl)), Z && O(this, It, H); + } + /** + * Defer an effect inside a pending boundary until the boundary resolves + * @param {Effect} effect + */ + defer_effect(e) { + Ea(e, d(this, Hn), d(this, Yn)); + } + /** + * Returns `false` if the effect exists inside a boundary whose pending snippet is shown + * @returns {boolean} + */ + is_rendered() { + return !this.is_pending && (!this.parent || this.parent.is_rendered()); + } + has_pending_snippet() { + return !!d(this, $e).pending; + } + /** + * Update the source that powers `$effect.pending()` inside this boundary, + * and controls when the current `pending` snippet (if any) is removed. + * Do not call from inside the class + * @param {1 | -1} d + */ + update_pending_count(e) { + pt(this, ht, Hi).call(this, e), O(this, vn, d(this, vn) + e), !(!d(this, qe) || d(this, zn)) && (O(this, zn, !0), yn(() => { + O(this, zn, !1), d(this, qe) && Wn(d(this, qe), d(this, vn)); + })); + } + get_effect_pending() { + return d(this, li).call(this), w( + /** @type {Source} */ + d(this, qe) + ); + } + /** @param {unknown} error */ + error(e) { + var n = d(this, $e).onerror; + let r = d(this, $e).failed; + if (d(this, gn) || !n && !r) + throw e; + d(this, Kt) && (Rt(d(this, Kt)), O(this, Kt, null)), d(this, Nt) && (Rt(d(this, Nt)), O(this, Nt, null)), d(this, Ee) && (Rt(d(this, Ee)), O(this, Ee, null)), Z && (Pt( + /** @type {TemplateNode} */ + d(this, $r) + ), Fi(), Pt(Qr())); + var i = !1, s = !1; + const a = () => { + if (i) { + ql(); + return; + } + i = !0, s && Ll(), Ye.ensure(), O(this, vn, 0), d(this, Ee) !== null && wn(d(this, Ee), () => { + O(this, Ee, null); + }), this.is_pending = this.has_pending_snippet(), O(this, Kt, pt(this, ht, zr).call(this, () => (O(this, gn, !1), Zt(() => d(this, pn).call(this, d(this, It)))))), d(this, Le) > 0 ? pt(this, ht, Hr).call(this) : this.is_pending = !1; + }; + yn(() => { + try { + s = !0, n == null || n(e, a), s = !1; + } catch (o) { + Kn(o, d(this, Ae) && d(this, Ae).parent); + } + r && O(this, Ee, pt(this, ht, zr).call(this, () => { + Ye.ensure(), O(this, gn, !0); + try { + return Zt(() => { + r( + d(this, It), + () => e, + () => a + ); + }); + } catch (o) { + return Kn( + o, + /** @type {Effect} */ + d(this, Ae).parent + ), null; + } finally { + O(this, gn, !1); + } + })); + }); + } +} +It = new WeakMap(), $r = new WeakMap(), $e = new WeakMap(), pn = new WeakMap(), Ae = new WeakMap(), Kt = new WeakMap(), Nt = new WeakMap(), Ee = new WeakMap(), Fe = new WeakMap(), je = new WeakMap(), vn = new WeakMap(), Le = new WeakMap(), zn = new WeakMap(), gn = new WeakMap(), Hn = new WeakMap(), Yn = new WeakMap(), qe = new WeakMap(), li = new WeakMap(), ht = new WeakSet(), ka = function() { + try { + O(this, Kt, Zt(() => d(this, pn).call(this, d(this, It)))); + } catch (e) { + this.error(e); + } +}, Ma = function() { + const e = d(this, $e).pending; + e && (O(this, Nt, Zt(() => e(d(this, It)))), yn(() => { + var n = pt(this, ht, zi).call(this); + O(this, Kt, pt(this, ht, zr).call(this, () => (Ye.ensure(), Zt(() => d(this, pn).call(this, n))))), d(this, Le) > 0 ? pt(this, ht, Hr).call(this) : (wn( + /** @type {Effect} */ + d(this, Nt), + () => { + O(this, Nt, null); + } + ), this.is_pending = !1); + })); +}, zi = function() { + var e = d(this, It); + return this.is_pending && (O(this, je, te()), d(this, It).before(d(this, je)), e = d(this, je)), e; +}, /** + * @param {() => Effect | null} fn + */ +zr = function(e) { + var n = X, r = z, i = qt; + Ne(d(this, Ae)), ee(d(this, Ae)), Gn(d(this, Ae).ctx); + try { + return e(); + } catch (s) { + return $a(s), null; + } finally { + Ne(n), ee(r), Gn(i); + } +}, Hr = function() { + const e = ( + /** @type {(anchor: Node) => void} */ + d(this, $e).pending + ); + d(this, Kt) !== null && (O(this, Fe, document.createDocumentFragment()), d(this, Fe).append( + /** @type {TemplateNode} */ + d(this, je) + ), Za(d(this, Kt), d(this, Fe))), d(this, Nt) === null && O(this, Nt, Zt(() => e(d(this, It)))); +}, /** + * Updates the pending count associated with the currently visible pending snippet, + * if any, such that we can replace the snippet with content once work is done + * @param {1 | -1} d + */ +Hi = function(e) { + var n; + if (!this.has_pending_snippet()) { + this.parent && pt(n = this.parent, ht, Hi).call(n, e); + return; + } + if (O(this, Le, d(this, Le) + e), d(this, Le) === 0) { + this.is_pending = !1; + for (const r of d(this, Hn)) + lt(r, xt), ce(r); + for (const r of d(this, Yn)) + lt(r, de), ce(r); + d(this, Hn).clear(), d(this, Yn).clear(), d(this, Nt) && wn(d(this, Nt), () => { + O(this, Nt, null); + }), d(this, Fe) && (d(this, It).before(d(this, Fe)), O(this, Fe, null)); + } +}; +function Wl(t, e, n, r) { + const i = gi; + var s = t.filter((c) => !c.settled); + if (n.length === 0 && s.length === 0) { + r(e.map(i)); + return; + } + var a = Y, o = ( + /** @type {Effect} */ + X + ), l = jl(), u = s.length === 1 ? s[0].promise : s.length > 1 ? Promise.all(s.map((c) => c.promise)) : null; + function f(c) { + l(); + try { + r(c); + } catch (v) { + (o.f & He) === 0 && Kn(v, o); + } + a == null || a.deactivate(), Yi(); + } + if (n.length === 0) { + u.then(() => f(e.map(i))); + return; + } + function h() { + l(), Promise.all(n.map((c) => /* @__PURE__ */ Zl(c))).then((c) => f([...e.map(i), ...c])).catch((c) => Kn(c, o)); + } + u ? u.then(h) : h(); +} +function jl() { + var t = X, e = z, n = qt, r = Y; + return function(s = !0) { + Ne(t), ee(e), Gn(n), s && (r == null || r.activate()); + }; +} +function Yi() { + Ne(null), ee(null), Gn(null); +} +// @__NO_SIDE_EFFECTS__ +function gi(t) { + var e = wt | xt, n = z !== null && (z.f & wt) !== 0 ? ( + /** @type {Derived} */ + z + ) : null; + return X !== null && (X.f |= Nn), { + ctx: qt, + deps: null, + effects: null, + equals: ya, + f: e, + fn: t, + reactions: null, + rv: 0, + v: ( + /** @type {V} */ + _t + ), + wv: 0, + parent: n ?? X, + ac: null + }; +} +// @__NO_SIDE_EFFECTS__ +function Zl(t, e, n) { + let r = ( + /** @type {Effect | null} */ + X + ); + r === null && Tl(); + var i = ( + /** @type {Boundary} */ + r.b + ), s = ( + /** @type {Promise} */ + /** @type {unknown} */ + void 0 + ), a = An( + /** @type {V} */ + _t + ), o = !z, l = /* @__PURE__ */ new Map(); + return ou(() => { + var v; + var u = da(); + s = u.promise; + try { + Promise.resolve(t()).then(u.resolve, u.reject).then(() => { + f === Y && f.committed && f.deactivate(), Yi(); + }); + } catch (g) { + u.reject(g), Yi(); + } + var f = ( + /** @type {Batch} */ + Y + ); + if (o) { + var h = i.is_rendered(); + i.update_pending_count(1), f.increment(h), (v = l.get(f)) == null || v.reject(on), l.delete(f), l.set(f, u); + } + const c = (g, m = void 0) => { + if (f.activate(), m) + m !== on && (a.f |= Je, Wn(a, m)); + else { + (a.f & Je) !== 0 && (a.f ^= Je), Wn(a, g); + for (const [b, A] of l) { + if (l.delete(b), b === f) break; + A.reject(on); + } + } + o && (i.update_pending_count(-1), f.decrement(h)); + }; + u.promise.then(c, (g) => c(null, g || "unknown")); + }), iu(() => { + for (const u of l.values()) + u.reject(on); + }), new Promise((u) => { + function f(h) { + function c() { + h === s ? u(a) : f(s); + } + h.then(c, c); + } + f(s); + }); +} +// @__NO_SIDE_EFFECTS__ +function sr(t) { + const e = /* @__PURE__ */ gi(t); + return Ja(e), e; +} +// @__NO_SIDE_EFFECTS__ +function Pa(t) { + const e = /* @__PURE__ */ gi(t); + return e.equals = wa, e; +} +function Jl(t) { + var e = t.effects; + if (e !== null) { + t.effects = null; + for (var n = 0; n < e.length; n += 1) + Rt( + /** @type {Effect} */ + e[n] + ); + } +} +function Ql(t) { + for (var e = t.parent; e !== null; ) { + if ((e.f & wt) === 0) + return (e.f & He) === 0 ? ( + /** @type {Effect} */ + e + ) : null; + e = e.parent; + } + return null; +} +function fs(t) { + var e, n = X; + Ne(Ql(t)); + try { + t.f &= ~$n, Jl(t), e = no(t); + } finally { + Ne(n); + } + return e; +} +function Oa(t) { + var e = fs(t); + if (!t.equals(e) && (t.wv = to(), (!(Y != null && Y.is_fork) || t.deps === null) && (t.v = e, t.deps === null))) { + lt(t, vt); + return; + } + tn || (yt !== null ? (hs() || Y != null && Y.is_fork) && yt.set(t, e) : us(t)); +} +function tu(t) { + var e, n; + if (t.effects !== null) + for (const r of t.effects) + (r.teardown || r.ac) && ((e = r.teardown) == null || e.call(r), (n = r.ac) == null || n.abort(on), r.teardown = bl, r.ac = null, gr(r, 0), gs(r)); +} +function Da(t) { + if (t.effects !== null) + for (const e of t.effects) + e.teardown && jn(e); +} +let Bi = /* @__PURE__ */ new Set(); +const Qe = /* @__PURE__ */ new Map(); +let Ia = !1; +function An(t, e) { + var n = { + f: 0, + // TODO ideally we could skip this altogether, but it causes type errors + v: t, + reactions: null, + equals: ya, + rv: 0, + wv: 0 + }; + return n; +} +// @__NO_SIDE_EFFECTS__ +function mt(t, e) { + const n = An(t); + return Ja(n), n; +} +// @__NO_SIDE_EFFECTS__ +function Fa(t, e = !1, n = !0) { + const r = An(t); + return e || (r.equals = wa), r; +} +function J(t, e, n = !1) { + z !== null && // since we are untracking the function inside `$inspect.with` we need to add this check + // to ensure we error if state is set inside an inspect effect + (!he || (z.f & Ps) !== 0) && xa() && (z.f & (wt | Ue | as | Ps)) !== 0 && (Qt === null || !Un.call(Qt, t)) && Fl(); + let r = n ? un(e) : e; + return Wn(t, r); +} +function Wn(t, e) { + if (!t.equals(e)) { + var n = t.v; + tn ? Qe.set(t, e) : Qe.set(t, n), t.v = e; + var r = Ye.ensure(); + if (r.capture(t, n), (t.f & wt) !== 0) { + const i = ( + /** @type {Derived} */ + t + ); + (t.f & xt) !== 0 && fs(i), us(i); + } + t.wv = to(), La(t, xt), X !== null && (X.f & vt) !== 0 && (X.f & (pe | en)) === 0 && (Gt === null ? fu([t]) : Gt.push(t)), !r.is_fork && Bi.size > 0 && !Ia && eu(); + } + return e; +} +function eu() { + Ia = !1; + for (const t of Bi) + (t.f & vt) !== 0 && lt(t, de), Tr(t) && jn(t); + Bi.clear(); +} +function pr(t) { + J(t, t.v + 1); +} +function La(t, e) { + var n = t.reactions; + if (n !== null) + for (var r = n.length, i = 0; i < r; i++) { + var s = n[i], a = s.f, o = (a & xt) === 0; + if (o && lt(s, e), (a & wt) !== 0) { + var l = ( + /** @type {Derived} */ + s + ); + yt == null || yt.delete(l), (a & $n) === 0 && (a & Jt && (s.f |= $n), La(l, de)); + } else o && ((a & Ue) !== 0 && oe !== null && oe.add( + /** @type {Effect} */ + s + ), ce( + /** @type {Effect} */ + s + )); + } +} +function un(t) { + if (typeof t != "object" || t === null || hr in t) + return t; + const e = xl(t); + if (e !== yl && e !== wl) + return t; + var n = /* @__PURE__ */ new Map(), r = ha(t), i = /* @__PURE__ */ mt(0), s = xn, a = (o) => { + if (xn === s) + return o(); + var l = z, u = xn; + ee(null), Fs(s); + var f = o(); + return ee(l), Fs(u), f; + }; + return r && n.set("length", /* @__PURE__ */ mt( + /** @type {any[]} */ + t.length + )), new Proxy( + /** @type {any} */ + t, + { + defineProperty(o, l, u) { + (!("value" in u) || u.configurable === !1 || u.enumerable === !1 || u.writable === !1) && Dl(); + var f = n.get(l); + return f === void 0 ? a(() => { + var h = /* @__PURE__ */ mt(u.value); + return n.set(l, h), h; + }) : J(f, u.value, !0), !0; + }, + deleteProperty(o, l) { + var u = n.get(l); + if (u === void 0) { + if (l in o) { + const f = a(() => /* @__PURE__ */ mt(_t)); + n.set(l, f), pr(i); + } + } else + J(u, _t), pr(i); + return !0; + }, + get(o, l, u) { + var v; + if (l === hr) + return t; + var f = n.get(l), h = l in o; + if (f === void 0 && (!h || (v = mn(o, l)) != null && v.writable) && (f = a(() => { + var g = un(h ? o[l] : _t), m = /* @__PURE__ */ mt(g); + return m; + }), n.set(l, f)), f !== void 0) { + var c = w(f); + return c === _t ? void 0 : c; + } + return Reflect.get(o, l, u); + }, + getOwnPropertyDescriptor(o, l) { + var u = Reflect.getOwnPropertyDescriptor(o, l); + if (u && "value" in u) { + var f = n.get(l); + f && (u.value = w(f)); + } else if (u === void 0) { + var h = n.get(l), c = h == null ? void 0 : h.v; + if (h !== void 0 && c !== _t) + return { + enumerable: !0, + configurable: !0, + value: c, + writable: !0 + }; + } + return u; + }, + has(o, l) { + var c; + if (l === hr) + return !0; + var u = n.get(l), f = u !== void 0 && u.v !== _t || Reflect.has(o, l); + if (u !== void 0 || X !== null && (!f || (c = mn(o, l)) != null && c.writable)) { + u === void 0 && (u = a(() => { + var v = f ? un(o[l]) : _t, g = /* @__PURE__ */ mt(v); + return g; + }), n.set(l, u)); + var h = w(u); + if (h === _t) + return !1; + } + return f; + }, + set(o, l, u, f) { + var T; + var h = n.get(l), c = l in o; + if (r && l === "length") + for (var v = u; v < /** @type {Source} */ + h.v; v += 1) { + var g = n.get(v + ""); + g !== void 0 ? J(g, _t) : v in o && (g = a(() => /* @__PURE__ */ mt(_t)), n.set(v + "", g)); + } + if (h === void 0) + (!c || (T = mn(o, l)) != null && T.writable) && (h = a(() => /* @__PURE__ */ mt(void 0)), J(h, un(u)), n.set(l, h)); + else { + c = h.v !== _t; + var m = a(() => un(u)); + J(h, m); + } + var b = Reflect.getOwnPropertyDescriptor(o, l); + if (b != null && b.set && b.set.call(f, u), !c) { + if (r && typeof l == "string") { + var A = ( + /** @type {Source} */ + n.get("length") + ), S = Number(l); + Number.isInteger(S) && S >= A.v && J(A, S + 1); + } + pr(i); + } + return !0; + }, + ownKeys(o) { + w(i); + var l = Reflect.ownKeys(o).filter((h) => { + var c = n.get(h); + return c === void 0 || c.v !== _t; + }); + for (var [u, f] of n) + f.v !== _t && !(u in o) && l.push(u); + return l; + }, + setPrototypeOf() { + Il(); + } + } + ); +} +var Ds, qa, Va, za; +function Ui() { + if (Ds === void 0) { + Ds = window, qa = /Firefox/.test(navigator.userAgent); + var t = Element.prototype, e = Node.prototype, n = Text.prototype; + Va = mn(e, "firstChild").get, za = mn(e, "nextSibling").get, Ms(t) && (t.__click = void 0, t.__className = void 0, t.__attributes = null, t.__style = void 0, t.__e = void 0), Ms(n) && (n.__t = void 0); + } +} +function te(t = "") { + return document.createTextNode(t); +} +// @__NO_SIDE_EFFECTS__ +function En(t) { + return ( + /** @type {TemplateNode | null} */ + Va.call(t) + ); +} +// @__NO_SIDE_EFFECTS__ +function ke(t) { + return ( + /** @type {TemplateNode | null} */ + za.call(t) + ); +} +function Xt(t, e) { + if (!Z) + return /* @__PURE__ */ En(t); + var n = /* @__PURE__ */ En(H); + if (n === null) + n = H.appendChild(te()); + else if (e && n.nodeType !== Rr) { + var r = te(); + return n == null || n.before(r), Pt(r), r; + } + return e && _i( + /** @type {Text} */ + n + ), Pt(n), n; +} +function Mn(t, e = !1) { + if (!Z) { + var n = /* @__PURE__ */ En(t); + return n instanceof Comment && n.data === "" ? /* @__PURE__ */ ke(n) : n; + } + if (e) { + if ((H == null ? void 0 : H.nodeType) !== Rr) { + var r = te(); + return H == null || H.before(r), Pt(r), r; + } + _i( + /** @type {Text} */ + H + ); + } + return H; +} +function ae(t, e = 1, n = !1) { + let r = Z ? H : t; + for (var i; e--; ) + i = r, r = /** @type {TemplateNode} */ + /* @__PURE__ */ ke(r); + if (!Z) + return r; + if (n) { + if ((r == null ? void 0 : r.nodeType) !== Rr) { + var s = te(); + return r === null ? i == null || i.after(s) : r.before(s), Pt(s), s; + } + _i( + /** @type {Text} */ + r + ); + } + return Pt(r), r; +} +function Ha(t) { + t.textContent = ""; +} +function Ya() { + return !1; +} +function cs(t, e, n) { + return ( + /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */ + document.createElementNS(_l, t, void 0) + ); +} +function _i(t) { + if ( + /** @type {string} */ + t.nodeValue.length < 65536 + ) + return; + let e = t.nextSibling; + for (; e !== null && e.nodeType === Rr; ) + e.remove(), t.nodeValue += /** @type {string} */ + e.nodeValue, e = t.nextSibling; +} +function Ba(t) { + var e = z, n = X; + ee(null), Ne(null); + try { + return t(); + } finally { + ee(e), Ne(n); + } +} +function nu(t) { + X === null && (z === null && kl(), Sl()), tn && Nl(); +} +function ru(t, e) { + var n = e.last; + n === null ? e.last = e.first = t : (n.next = t, t.prev = n, e.last = t); +} +function Me(t, e, n) { + var r = X; + r !== null && (r.f & Lt) !== 0 && (t |= Lt); + var i = { + ctx: qt, + deps: null, + nodes: null, + f: t | xt | Jt, + first: null, + fn: e, + last: null, + next: null, + parent: r, + b: r && r.b, + prev: null, + teardown: null, + wv: 0, + ac: null + }; + if (n) + try { + jn(i); + } catch (o) { + throw Rt(i), o; + } + else e !== null && ce(i); + var s = i; + if (n && s.deps === null && s.teardown === null && s.nodes === null && s.first === s.last && // either `null`, or a singular child + (s.f & Nn) === 0 && (s = s.first, (t & Ue) !== 0 && (t & Xn) !== 0 && s !== null && (s.f |= Xn)), s !== null && (s.parent = r, r !== null && ru(s, r), z !== null && (z.f & wt) !== 0 && (t & en) === 0)) { + var a = ( + /** @type {Derived} */ + z + ); + (a.effects ?? (a.effects = [])).push(s); + } + return i; +} +function hs() { + return z !== null && !he; +} +function iu(t) { + const e = Me(hi, null, !1); + return lt(e, vt), e.teardown = t, e; +} +function ds(t) { + nu(); + var e = ( + /** @type {Effect} */ + X.f + ), n = !z && (e & pe) !== 0 && (e & Qn) === 0; + if (n) { + var r = ( + /** @type {ComponentContext} */ + qt + ); + (r.e ?? (r.e = [])).push(t); + } else + return Ua(t); +} +function Ua(t) { + return Me(vr | El, t, !1); +} +function su(t) { + Ye.ensure(); + const e = Me(en | Nn, t, !0); + return () => { + Rt(e); + }; +} +function au(t) { + Ye.ensure(); + const e = Me(en | Nn, t, !0); + return (n = {}) => new Promise((r) => { + n.outro ? wn(e, () => { + Rt(e), r(void 0); + }) : (Rt(e), r(void 0)); + }); +} +function Xa(t) { + return Me(vr, t, !1); +} +function ou(t) { + return Me(as | Nn, t, !0); +} +function ps(t, e = 0) { + return Me(hi | e, t, !0); +} +function Pr(t, e = [], n = [], r = []) { + Wl(r, e, n, (i) => { + Me(hi, () => t(...i.map(w)), !0); + }); +} +function vs(t, e = 0) { + var n = Me(Ue | e, t, !0); + return n; +} +function Zt(t) { + return Me(pe | Nn, t, !0); +} +function Ga(t) { + var e = t.teardown; + if (e !== null) { + const n = tn, r = z; + Is(!0), ee(null); + try { + e.call(null); + } finally { + Is(n), ee(r); + } + } +} +function gs(t, e = !1) { + var n = t.first; + for (t.first = t.last = null; n !== null; ) { + const i = n.ac; + i !== null && Ba(() => { + i.abort(on); + }); + var r = n.next; + (n.f & en) !== 0 ? n.parent = null : Rt(n, e), n = r; + } +} +function lu(t) { + for (var e = t.first; e !== null; ) { + var n = e.next; + (e.f & pe) === 0 && Rt(e), e = n; + } +} +function Rt(t, e = !0) { + var n = !1; + (e || (t.f & ga) !== 0) && t.nodes !== null && t.nodes.end !== null && (uu( + t.nodes.start, + /** @type {TemplateNode} */ + t.nodes.end + ), n = !0), gs(t, e && !n), gr(t, 0), lt(t, He); + var r = t.nodes && t.nodes.t; + if (r !== null) + for (const s of r) + s.stop(); + Ga(t); + var i = t.parent; + i !== null && i.first !== null && Ka(t), t.next = t.prev = t.teardown = t.ctx = t.deps = t.fn = t.nodes = t.ac = null; +} +function uu(t, e) { + for (; t !== null; ) { + var n = t === e ? null : /* @__PURE__ */ ke(t); + t.remove(), t = n; + } +} +function Ka(t) { + var e = t.parent, n = t.prev, r = t.next; + n !== null && (n.next = r), r !== null && (r.prev = n), e !== null && (e.first === t && (e.first = r), e.last === t && (e.last = n)); +} +function wn(t, e, n = !0) { + var r = []; + Wa(t, r, !0); + var i = () => { + n && Rt(t), e && e(); + }, s = r.length; + if (s > 0) { + var a = () => --s || i(); + for (var o of r) + o.out(a); + } else + i(); +} +function Wa(t, e, n) { + if ((t.f & Lt) === 0) { + t.f ^= Lt; + var r = t.nodes && t.nodes.t; + if (r !== null) + for (const o of r) + (o.is_global || n) && e.push(o); + for (var i = t.first; i !== null; ) { + var s = i.next, a = (i.f & Xn) !== 0 || // If this is a branch effect without a block effect parent, + // it means the parent block effect was pruned. In that case, + // transparency information was transferred to the branch effect. + (i.f & pe) !== 0 && (t.f & Ue) !== 0; + Wa(i, e, a ? n : !1), i = s; + } + } +} +function _s(t) { + ja(t, !0); +} +function ja(t, e) { + if ((t.f & Lt) !== 0) { + t.f ^= Lt, (t.f & vt) === 0 && (lt(t, xt), ce(t)); + for (var n = t.first; n !== null; ) { + var r = n.next, i = (n.f & Xn) !== 0 || (n.f & pe) !== 0; + ja(n, i ? e : !1), n = r; + } + var s = t.nodes && t.nodes.t; + if (s !== null) + for (const a of s) + (a.is_global || e) && a.in(); + } +} +function Za(t, e) { + if (t.nodes) + for (var n = t.nodes.start, r = t.nodes.end; n !== null; ) { + var i = n === r ? null : /* @__PURE__ */ ke(n); + e.append(n), n = i; + } +} +let Yr = !1, tn = !1; +function Is(t) { + tn = t; +} +let z = null, he = !1; +function ee(t) { + z = t; +} +let X = null; +function Ne(t) { + X = t; +} +let Qt = null; +function Ja(t) { + z !== null && (Qt === null ? Qt = [t] : Qt.push(t)); +} +let kt = null, Dt = 0, Gt = null; +function fu(t) { + Gt = t; +} +let Qa = 1, fn = 0, xn = fn; +function Fs(t) { + xn = t; +} +function to() { + return ++Qa; +} +function Tr(t) { + var e = t.f; + if ((e & xt) !== 0) + return !0; + if (e & wt && (t.f &= ~$n), (e & de) !== 0) { + for (var n = ( + /** @type {Value[]} */ + t.deps + ), r = n.length, i = 0; i < r; i++) { + var s = n[i]; + if (Tr( + /** @type {Derived} */ + s + ) && Oa( + /** @type {Derived} */ + s + ), s.wv > t.wv) + return !0; + } + (e & Jt) !== 0 && // During time traveling we don't want to reset the status so that + // traversal of the graph in the other batches still happens + yt === null && lt(t, vt); + } + return !1; +} +function eo(t, e, n = !0) { + var r = t.reactions; + if (r !== null && !(Qt !== null && Un.call(Qt, t))) + for (var i = 0; i < r.length; i++) { + var s = r[i]; + (s.f & wt) !== 0 ? eo( + /** @type {Derived} */ + s, + e, + !1 + ) : e === s && (n ? lt(s, xt) : (s.f & vt) !== 0 && lt(s, de), ce( + /** @type {Effect} */ + s + )); + } +} +function no(t) { + var m; + var e = kt, n = Dt, r = Gt, i = z, s = Qt, a = qt, o = he, l = xn, u = t.f; + kt = /** @type {null | Value[]} */ + null, Dt = 0, Gt = null, z = (u & (pe | en)) === 0 ? t : null, Qt = null, Gn(t.ctx), he = !1, xn = ++fn, t.ac !== null && (Ba(() => { + t.ac.abort(on); + }), t.ac = null); + try { + t.f |= Ii; + var f = ( + /** @type {Function} */ + t.fn + ), h = f(); + t.f |= Qn; + var c = t.deps, v = Y == null ? void 0 : Y.is_fork; + if (kt !== null) { + var g; + if (v || gr(t, Dt), c !== null && Dt > 0) + for (c.length = Dt + kt.length, g = 0; g < kt.length; g++) + c[Dt + g] = kt[g]; + else + t.deps = c = kt; + if (hs() && (t.f & Jt) !== 0) + for (g = Dt; g < c.length; g++) + ((m = c[g]).reactions ?? (m.reactions = [])).push(t); + } else !v && c !== null && Dt < c.length && (gr(t, Dt), c.length = Dt); + if (xa() && Gt !== null && !he && c !== null && (t.f & (wt | de | xt)) === 0) + for (g = 0; g < /** @type {Source[]} */ + Gt.length; g++) + eo( + Gt[g], + /** @type {Effect} */ + t + ); + if (i !== null && i !== t) { + if (fn++, i.deps !== null) + for (let b = 0; b < n; b += 1) + i.deps[b].rv = fn; + if (e !== null) + for (const b of e) + b.rv = fn; + Gt !== null && (r === null ? r = Gt : r.push(.../** @type {Source[]} */ + Gt)); + } + return (t.f & Je) !== 0 && (t.f ^= Je), h; + } catch (b) { + return $a(b); + } finally { + t.f ^= Ii, kt = e, Dt = n, Gt = r, z = i, Qt = s, Gn(a), he = o, xn = l; + } +} +function cu(t, e) { + let n = e.reactions; + if (n !== null) { + var r = ml.call(n, t); + if (r !== -1) { + var i = n.length - 1; + i === 0 ? n = e.reactions = null : (n[r] = n[i], n.pop()); + } + } + if (n === null && (e.f & wt) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear + // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps` + // allows us to skip the expensive work of disconnecting and immediately reconnecting it + (kt === null || !Un.call(kt, e))) { + var s = ( + /** @type {Derived} */ + e + ); + (s.f & Jt) !== 0 && (s.f ^= Jt, s.f &= ~$n), us(s), tu(s), gr(s, 0); + } +} +function gr(t, e) { + var n = t.deps; + if (n !== null) + for (var r = e; r < n.length; r++) + cu(t, n[r]); +} +function jn(t) { + var e = t.f; + if ((e & He) === 0) { + lt(t, vt); + var n = X, r = Yr; + X = t, Yr = !0; + try { + (e & (Ue | pa)) !== 0 ? lu(t) : gs(t), Ga(t); + var i = no(t); + t.teardown = typeof i == "function" ? i : null, t.wv = Qa; + var s; + Di && zl && (t.f & xt) !== 0 && t.deps; + } finally { + Yr = r, X = n; + } + } +} +function w(t) { + var e = t.f, n = (e & wt) !== 0; + if (z !== null && !he) { + var r = X !== null && (X.f & He) !== 0; + if (!r && (Qt === null || !Un.call(Qt, t))) { + var i = z.deps; + if ((z.f & Ii) !== 0) + t.rv < fn && (t.rv = fn, kt === null && i !== null && i[Dt] === t ? Dt++ : kt === null ? kt = [t] : kt.push(t)); + else { + (z.deps ?? (z.deps = [])).push(t); + var s = t.reactions; + s === null ? t.reactions = [z] : Un.call(s, z) || s.push(z); + } + } + } + if (tn && Qe.has(t)) + return Qe.get(t); + if (n) { + var a = ( + /** @type {Derived} */ + t + ); + if (tn) { + var o = a.v; + return ((a.f & vt) === 0 && a.reactions !== null || io(a)) && (o = fs(a)), Qe.set(a, o), o; + } + var l = (a.f & Jt) === 0 && !he && z !== null && (Yr || (z.f & Jt) !== 0), u = (a.f & Qn) === 0; + Tr(a) && (l && (a.f |= Jt), Oa(a)), l && !u && (Da(a), ro(a)); + } + if (yt != null && yt.has(t)) + return yt.get(t); + if ((t.f & Je) !== 0) + throw t.v; + return t.v; +} +function ro(t) { + if (t.f |= Jt, t.deps !== null) + for (const e of t.deps) + (e.reactions ?? (e.reactions = [])).push(t), (e.f & wt) !== 0 && (e.f & Jt) === 0 && (Da( + /** @type {Derived} */ + e + ), ro( + /** @type {Derived} */ + e + )); +} +function io(t) { + if (t.v === _t) return !0; + if (t.deps === null) return !1; + for (const e of t.deps) + if (Qe.has(e) || (e.f & wt) !== 0 && io( + /** @type {Derived} */ + e + )) + return !0; + return !1; +} +function mi(t) { + var e = he; + try { + return he = !0, t(); + } finally { + he = e; + } +} +const so = /* @__PURE__ */ new Set(), Xi = /* @__PURE__ */ new Set(); +function hu(t) { + for (var e = 0; e < t.length; e++) + so.add(t[e]); + for (var n of Xi) + n(t); +} +let Ls = null; +function qs(t) { + var b; + var e = this, n = ( + /** @type {Node} */ + e.ownerDocument + ), r = t.type, i = ((b = t.composedPath) == null ? void 0 : b.call(t)) || [], s = ( + /** @type {null | Element} */ + i[0] || t.target + ); + Ls = t; + var a = 0, o = Ls === t && t.__root; + if (o) { + var l = i.indexOf(o); + if (l !== -1 && (e === document || e === /** @type {any} */ + window)) { + t.__root = e; + return; + } + var u = i.indexOf(e); + if (u === -1) + return; + l <= u && (a = l); + } + if (s = /** @type {Element} */ + i[a] || t.target, s !== e) { + Jr(t, "currentTarget", { + configurable: !0, + get() { + return s || n; + } + }); + var f = z, h = X; + ee(null), Ne(null); + try { + for (var c, v = []; s !== null; ) { + var g = s.assignedSlot || s.parentNode || /** @type {any} */ + s.host || null; + try { + var m = s["__" + r]; + m != null && (!/** @type {any} */ + s.disabled || // DOM could've been updated already by the time this is reached, so we check this as well + // -> the target could not have been disabled because it emits the event in the first place + t.target === s) && m.call(s, t); + } catch (A) { + c ? v.push(A) : c = A; + } + if (t.cancelBubble || g === e || g === null) + break; + s = g; + } + if (c) { + for (let A of v) + queueMicrotask(() => { + throw A; + }); + throw c; + } + } finally { + t.__root = e, delete t.currentTarget, ee(f), Ne(h); + } + } +} +var fa, ca; +const Ci = (ca = (fa = globalThis == null ? void 0 : globalThis.window) == null ? void 0 : fa.trustedTypes) == null ? void 0 : /* @__PURE__ */ ca.createPolicy( + "svelte-trusted-html", + { + /** @param {string} html */ + createHTML: (t) => t + } +); +function du(t) { + return ( + /** @type {string} */ + (Ci == null ? void 0 : Ci.createHTML(t)) ?? t + ); +} +function ao(t, e = !1) { + var n = cs("template"); + return t = t.replaceAll("", ""), n.innerHTML = e ? du(t) : t, n.content; +} +function Rn(t, e) { + var n = ( + /** @type {Effect} */ + X + ); + n.nodes === null && (n.nodes = { start: t, end: e, a: null, t: null }); +} +// @__NO_SIDE_EFFECTS__ +function er(t, e) { + var n = (e & gl) !== 0, r, i = !t.startsWith(""); + return () => { + if (Z) + return Rn(H, null), H; + r === void 0 && (r = ao(i ? t : "" + t, !0)); + var s = ( + /** @type {TemplateNode} */ + n || qa ? document.importNode(r, !0) : r.cloneNode(!0) + ); + { + var a = ( + /** @type {TemplateNode} */ + /* @__PURE__ */ En(s) + ), o = ( + /** @type {TemplateNode} */ + s.lastChild + ); + Rn(a, o); + } + return s; + }; +} +// @__NO_SIDE_EFFECTS__ +function pu(t, e, n = "svg") { + var r = !t.startsWith(""), i = `<${n}>${r ? t : "" + t}`, s; + return () => { + if (Z) + return Rn(H, null), H; + if (!s) { + var a = ( + /** @type {DocumentFragment} */ + ao(i, !0) + ), o = ( + /** @type {Element} */ + /* @__PURE__ */ En(a) + ); + s = /** @type {Element} */ + /* @__PURE__ */ En(o); + } + var l = ( + /** @type {TemplateNode} */ + s.cloneNode(!0) + ); + return Rn(l, l), l; + }; +} +// @__NO_SIDE_EFFECTS__ +function vu(t, e) { + return /* @__PURE__ */ pu(t, e, "svg"); +} +function Vs(t = "") { + if (!Z) { + var e = te(t + ""); + return Rn(e, e), e; + } + var n = H; + return n.nodeType !== Rr ? (n.before(n = te()), Pt(n)) : _i( + /** @type {Text} */ + n + ), Rn(n, n), n; +} +function be(t, e) { + if (Z) { + var n = ( + /** @type {Effect & { nodes: EffectNodes }} */ + X + ); + ((n.f & Qn) === 0 || n.nodes.end === null) && (n.nodes.end = H), pi(); + return; + } + t !== null && t.before( + /** @type {Node} */ + e + ); +} +const gu = ["touchstart", "touchmove"]; +function _u(t) { + return gu.includes(t); +} +function Pn(t, e) { + var n = e == null ? "" : typeof e == "object" ? e + "" : e; + n !== (t.__t ?? (t.__t = t.nodeValue)) && (t.__t = n, t.nodeValue = n + ""); +} +function oo(t, e) { + return lo(t, e); +} +function mu(t, e) { + Ui(), e.intro = e.intro ?? !1; + const n = e.target, r = Z, i = H; + try { + for (var s = /* @__PURE__ */ En(n); s && (s.nodeType !== tr || /** @type {Comment} */ + s.data !== is); ) + s = /* @__PURE__ */ ke(s); + if (!s) + throw Bn; + ze(!0), Pt( + /** @type {Comment} */ + s + ); + const a = lo(t, { ...e, anchor: s }); + return ze(!1), /** @type {Exports} */ + a; + } catch (a) { + if (a instanceof Error && a.message.split(` +`).some((o) => o.startsWith("https://svelte.dev/e/"))) + throw a; + return a !== Bn && console.warn("Failed to hydrate: ", a), e.recover === !1 && Pl(), Ui(), Ha(n), ze(!1), oo(t, e); + } finally { + ze(r), Pt(i); + } +} +const Or = /* @__PURE__ */ new Map(); +function lo(t, { target: e, anchor: n, props: r = {}, events: i, context: s, intro: a = !0 }) { + Ui(); + var o = /* @__PURE__ */ new Set(), l = (h) => { + for (var c = 0; c < h.length; c++) { + var v = h[c]; + if (!o.has(v)) { + o.add(v); + var g = _u(v); + for (const A of [e, document]) { + var m = Or.get(A); + m === void 0 && (m = /* @__PURE__ */ new Map(), Or.set(A, m)); + var b = m.get(v); + b === void 0 ? (A.addEventListener(v, qs, { passive: g }), m.set(v, 1)) : m.set(v, b + 1); + } + } + } + }; + l(ci(so)), Xi.add(l); + var u = void 0, f = au(() => { + var h = n ?? e.appendChild(te()); + return Gl( + /** @type {TemplateNode} */ + h, + { + pending: () => { + } + }, + (c) => { + os({}); + var v = ( + /** @type {ComponentContext} */ + qt + ); + if (s && (v.c = s), i && (r.$$events = i), Z && Rn( + /** @type {TemplateNode} */ + c, + null + ), u = t(c, r) || {}, Z && (X.nodes.end = H, H === null || H.nodeType !== tr || /** @type {Comment} */ + H.data !== ss)) + throw di(), Bn; + ls(); + } + ), () => { + var m; + for (var c of o) + for (const b of [e, document]) { + var v = ( + /** @type {Map} */ + Or.get(b) + ), g = ( + /** @type {number} */ + v.get(c) + ); + --g == 0 ? (b.removeEventListener(c, qs), v.delete(c), v.size === 0 && Or.delete(b)) : v.set(c, g); + } + Xi.delete(l), h !== n && ((m = h.parentNode) == null || m.removeChild(h)); + }; + }); + return Gi.set(u, f), u; +} +let Gi = /* @__PURE__ */ new WeakMap(); +function yu(t, e) { + const n = Gi.get(t); + return n ? (Gi.delete(t), n(e)) : Promise.resolve(); +} +var le, Re, Ft, _n, Ar, Er, ui; +class wu { + /** + * @param {TemplateNode} anchor + * @param {boolean} transition + */ + constructor(e, n = !0) { + /** @type {TemplateNode} */ + ot(this, "anchor"); + /** @type {Map} */ + L(this, le, /* @__PURE__ */ new Map()); + /** + * Map of keys to effects that are currently rendered in the DOM. + * These effects are visible and actively part of the document tree. + * Example: + * ``` + * {#if condition} + * foo + * {:else} + * bar + * {/if} + * ``` + * Can result in the entries `true->Effect` and `false->Effect` + * @type {Map} + */ + L(this, Re, /* @__PURE__ */ new Map()); + /** + * Similar to #onscreen with respect to the keys, but contains branches that are not yet + * in the DOM, because their insertion is deferred. + * @type {Map} + */ + L(this, Ft, /* @__PURE__ */ new Map()); + /** + * Keys of effects that are currently outroing + * @type {Set} + */ + L(this, _n, /* @__PURE__ */ new Set()); + /** + * Whether to pause (i.e. outro) on change, or destroy immediately. + * This is necessary for `` + */ + L(this, Ar, !0); + L(this, Er, () => { + var e = ( + /** @type {Batch} */ + Y + ); + if (d(this, le).has(e)) { + var n = ( + /** @type {Key} */ + d(this, le).get(e) + ), r = d(this, Re).get(n); + if (r) + _s(r), d(this, _n).delete(n); + else { + var i = d(this, Ft).get(n); + i && (d(this, Re).set(n, i.effect), d(this, Ft).delete(n), i.fragment.lastChild.remove(), this.anchor.before(i.fragment), r = i.effect); + } + for (const [s, a] of d(this, le)) { + if (d(this, le).delete(s), s === e) + break; + const o = d(this, Ft).get(a); + o && (Rt(o.effect), d(this, Ft).delete(a)); + } + for (const [s, a] of d(this, Re)) { + if (s === n || d(this, _n).has(s)) continue; + const o = () => { + if (Array.from(d(this, le).values()).includes(s)) { + var u = document.createDocumentFragment(); + Za(a, u), u.append(te()), d(this, Ft).set(s, { effect: a, fragment: u }); + } else + Rt(a); + d(this, _n).delete(s), d(this, Re).delete(s); + }; + d(this, Ar) || !r ? (d(this, _n).add(s), wn(a, o, !1)) : o(); + } + } + }); + /** + * @param {Batch} batch + */ + L(this, ui, (e) => { + d(this, le).delete(e); + const n = Array.from(d(this, le).values()); + for (const [r, i] of d(this, Ft)) + n.includes(r) || (Rt(i.effect), d(this, Ft).delete(r)); + }); + this.anchor = e, O(this, Ar, n); + } + /** + * + * @param {any} key + * @param {null | ((target: TemplateNode) => void)} fn + */ + ensure(e, n) { + var r = ( + /** @type {Batch} */ + Y + ), i = Ya(); + if (n && !d(this, Re).has(e) && !d(this, Ft).has(e)) + if (i) { + var s = document.createDocumentFragment(), a = te(); + s.append(a), d(this, Ft).set(e, { + effect: Zt(() => n(a)), + fragment: s + }); + } else + d(this, Re).set( + e, + Zt(() => n(this.anchor)) + ); + if (d(this, le).set(r, e), i) { + for (const [o, l] of d(this, Re)) + o === e ? r.unskip_effect(l) : r.skip_effect(l); + for (const [o, l] of d(this, Ft)) + o === e ? r.unskip_effect(l.effect) : r.skip_effect(l.effect); + r.oncommit(d(this, Er)), r.ondiscard(d(this, ui)); + } else + Z && (this.anchor = H), d(this, Er).call(this); + } +} +le = new WeakMap(), Re = new WeakMap(), Ft = new WeakMap(), _n = new WeakMap(), Ar = new WeakMap(), Er = new WeakMap(), ui = new WeakMap(); +function xu(t) { + qt === null && Rl(), ds(() => { + const e = mi(t); + if (typeof e == "function") return ( + /** @type {() => void} */ + e + ); + }); +} +function Dr(t, e, n = !1) { + Z && pi(); + var r = new wu(t), i = n ? Xn : 0; + function s(a, o) { + if (Z) { + const f = ma(t); + var l; + if (f === is ? l = 0 : f === fi ? l = !1 : l = parseInt(f.substring(1)), a !== l) { + var u = Qr(); + Pt(u), r.anchor = u, ze(!1), r.ensure(a, o), ze(!0); + return; + } + } + r.ensure(a, o); + } + vs(() => { + var a = !1; + e((o, l = 0) => { + a = !0, s(l, o); + }), a || s(!1, null); + }, i); +} +function Ni(t, e) { + return e; +} +function bu(t, e, n) { + for (var r = [], i = e.length, s, a = e.length, o = 0; o < i; o++) { + let h = e[o]; + wn( + h, + () => { + if (s) { + if (s.pending.delete(h), s.done.add(h), s.pending.size === 0) { + var c = ( + /** @type {Set} */ + t.outrogroups + ); + Ki(ci(s.done)), c.delete(s), c.size === 0 && (t.outrogroups = null); + } + } else + a -= 1; + }, + !1 + ); + } + if (a === 0) { + var l = r.length === 0 && n !== null; + if (l) { + var u = ( + /** @type {Element} */ + n + ), f = ( + /** @type {Element} */ + u.parentNode + ); + Ha(f), f.append(u), t.items.clear(); + } + Ki(e, !l); + } else + s = { + pending: new Set(e), + done: /* @__PURE__ */ new Set() + }, (t.outrogroups ?? (t.outrogroups = /* @__PURE__ */ new Set())).add(s); +} +function Ki(t, e = !0) { + for (var n = 0; n < t.length; n++) + Rt(t[n], e); +} +var zs; +function Si(t, e, n, r, i, s = null) { + var a = t, o = /* @__PURE__ */ new Map(); + Z && pi(); + var l = null, u = /* @__PURE__ */ Pa(() => { + var m = n(); + return ha(m) ? m : m == null ? [] : ci(m); + }), f, h = !0; + function c() { + g.fallback = l, $u(g, f, a, e, r), l !== null && (f.length === 0 ? (l.f & Ze) === 0 ? _s(l) : (l.f ^= Ze, lr(l, null, a)) : wn(l, () => { + l = null; + })); + } + var v = vs(() => { + f = /** @type {V[]} */ + w(u); + var m = f.length; + let b = !1; + if (Z) { + var A = ma(a) === fi; + A !== (m === 0) && (a = Qr(), Pt(a), ze(!1), b = !0); + } + for (var S = /* @__PURE__ */ new Set(), T = ( + /** @type {Batch} */ + Y + ), D = Ya(), E = 0; E < m; E += 1) { + Z && H.nodeType === tr && /** @type {Comment} */ + H.data === ss && (a = /** @type {Comment} */ + H, b = !0, ze(!1)); + var j = f[E], it = r(j, E), W = h ? null : o.get(it); + W ? (W.v && Wn(W.v, j), W.i && Wn(W.i, E), D && T.unskip_effect(W.e)) : (W = Au( + o, + h ? a : zs ?? (zs = te()), + j, + it, + E, + i, + e, + n + ), h || (W.e.f |= Ze), o.set(it, W)), S.add(it); + } + if (m === 0 && s && !l && (h ? l = Zt(() => s(a)) : (l = Zt(() => s(zs ?? (zs = te()))), l.f |= Ze)), m > S.size && Cl(), Z && m > 0 && Pt(Qr()), !h) + if (D) { + for (const [nt, ut] of o) + S.has(nt) || T.skip_effect(ut.e); + T.oncommit(c), T.ondiscard(() => { + }); + } else + c(); + b && ze(!0), w(u); + }), g = { effect: v, items: o, outrogroups: null, fallback: l }; + h = !1, Z && (a = H); +} +function ar(t) { + for (; t !== null && (t.f & pe) === 0; ) + t = t.next; + return t; +} +function $u(t, e, n, r, i) { + var W; + var s = e.length, a = t.items, o = ar(t.effect.first), l, u = null, f = [], h = [], c, v, g, m; + for (m = 0; m < s; m += 1) { + if (c = e[m], v = i(c, m), g = /** @type {EachItem} */ + a.get(v).e, t.outrogroups !== null) + for (const nt of t.outrogroups) + nt.pending.delete(g), nt.done.delete(g); + if ((g.f & Ze) !== 0) + if (g.f ^= Ze, g === o) + lr(g, null, n); + else { + var b = u ? u.next : o; + g === t.effect.last && (t.effect.last = g.prev), g.prev && (g.prev.next = g.next), g.next && (g.next.prev = g.prev), We(t, u, g), We(t, g, b), lr(g, b, n), u = g, f = [], h = [], o = ar(u.next); + continue; + } + if ((g.f & Lt) !== 0 && _s(g), g !== o) { + if (l !== void 0 && l.has(g)) { + if (f.length < h.length) { + var A = h[0], S; + u = A.prev; + var T = f[0], D = f[f.length - 1]; + for (S = 0; S < f.length; S += 1) + lr(f[S], A, n); + for (S = 0; S < h.length; S += 1) + l.delete(h[S]); + We(t, T.prev, D.next), We(t, u, T), We(t, D, A), o = A, u = D, m -= 1, f = [], h = []; + } else + l.delete(g), lr(g, o, n), We(t, g.prev, g.next), We(t, g, u === null ? t.effect.first : u.next), We(t, u, g), u = g; + continue; + } + for (f = [], h = []; o !== null && o !== g; ) + (l ?? (l = /* @__PURE__ */ new Set())).add(o), h.push(o), o = ar(o.next); + if (o === null) + continue; + } + (g.f & Ze) === 0 && f.push(g), u = g, o = ar(g.next); + } + if (t.outrogroups !== null) { + for (const nt of t.outrogroups) + nt.pending.size === 0 && (Ki(ci(nt.done)), (W = t.outrogroups) == null || W.delete(nt)); + t.outrogroups.size === 0 && (t.outrogroups = null); + } + if (o !== null || l !== void 0) { + var E = []; + if (l !== void 0) + for (g of l) + (g.f & Lt) === 0 && E.push(g); + for (; o !== null; ) + (o.f & Lt) === 0 && o !== t.fallback && E.push(o), o = ar(o.next); + var j = E.length; + if (j > 0) { + var it = null; + bu(t, E, it); + } + } +} +function Au(t, e, n, r, i, s, a, o) { + var l = (a & ul) !== 0 ? (a & cl) === 0 ? /* @__PURE__ */ Fa(n, !1, !1) : An(n) : null, u = (a & fl) !== 0 ? An(i) : null; + return { + v: l, + i: u, + e: Zt(() => (s(e, l ?? n, u ?? i, o), () => { + t.delete(r); + })) + }; +} +function lr(t, e, n) { + if (t.nodes) + for (var r = t.nodes.start, i = t.nodes.end, s = e && (e.f & Ze) === 0 ? ( + /** @type {EffectNodes} */ + e.nodes.start + ) : n; r !== null; ) { + var a = ( + /** @type {TemplateNode} */ + /* @__PURE__ */ ke(r) + ); + if (s.before(r), r === i) + return; + r = a; + } +} +function We(t, e, n) { + e === null ? t.effect.first = n : e.next = n, n === null ? t.effect.last = e : n.prev = e; +} +function uo(t, e) { + Xa(() => { + var n = t.getRootNode(), r = ( + /** @type {ShadowRoot} */ + n.host ? ( + /** @type {ShadowRoot} */ + n + ) : ( + /** @type {Document} */ + n.head ?? /** @type {Document} */ + n.ownerDocument.head + ) + ); + if (!r.querySelector("#" + e.hash)) { + const i = cs("style"); + i.id = e.hash, i.textContent = e.code, r.appendChild(i); + } + }); +} +function Hs(t, e = !1) { + var n = e ? " !important;" : ";", r = ""; + for (var i in t) { + var s = t[i]; + s != null && s !== "" && (r += " " + i + ": " + s + n); + } + return r; +} +function Eu(t, e) { + if (e) { + var n = "", r, i; + return Array.isArray(e) ? (r = e[0], i = e[1]) : r = e, r && (n += Hs(r)), i && (n += Hs(i, !0)), n = n.trim(), n === "" ? null : n; + } + return String(t); +} +function ki(t, e = {}, n, r) { + for (var i in n) { + var s = n[i]; + e[i] !== s && (n[i] == null ? t.style.removeProperty(i) : t.style.setProperty(i, s, r)); + } +} +function Ys(t, e, n, r) { + var i = t.__style; + if (Z || i !== e) { + var s = Eu(e, r); + (!Z || s !== t.getAttribute("style")) && (s == null ? t.removeAttribute("style") : t.style.cssText = s), t.__style = e; + } else r && (Array.isArray(r) ? (ki(t, n == null ? void 0 : n[0], r[0]), ki(t, n == null ? void 0 : n[1], r[1], "important")) : ki(t, n, r)); + return r; +} +function Bs(t, e) { + return t === e || (t == null ? void 0 : t[hr]) === e; +} +function Br(t = {}, e, n, r) { + return Xa(() => { + var i, s; + return ps(() => { + i = s, s = [], mi(() => { + t !== n(...s) && (e(t, ...s), i && Bs(n(...i), t) && e(null, ...i)); + }); + }), () => { + yn(() => { + s && Bs(n(...s), t) && e(null, ...s); + }); + }; + }), t; +} +let Ir = !1; +function Ru(t) { + var e = Ir; + try { + return Ir = !1, [t(), Ir]; + } finally { + Ir = e; + } +} +function ue(t, e, n, r) { + var S; + var i = (n & pl) !== 0, s = (n & vl) !== 0, a = ( + /** @type {V} */ + r + ), o = !0, l = () => (o && (o = !1, a = s ? mi( + /** @type {() => V} */ + r + ) : ( + /** @type {V} */ + r + )), a), u; + if (i) { + var f = hr in t || _a in t; + u = ((S = mn(t, e)) == null ? void 0 : S.set) ?? (f && e in t ? (T) => t[e] = T : void 0); + } + var h, c = !1; + i ? [h, c] = Ru(() => ( + /** @type {V} */ + t[e] + )) : h = /** @type {V} */ + t[e], h === void 0 && r !== void 0 && (h = l(), u && (Ol(), u(h))); + var v; + if (v = () => { + var T = ( + /** @type {V} */ + t[e] + ); + return T === void 0 ? l() : (o = !0, T); + }, (n & dl) === 0) + return v; + if (u) { + var g = t.$$legacy; + return ( + /** @type {() => V} */ + (function(T, D) { + return arguments.length > 0 ? ((!D || g || c) && u(D ? v() : T), T) : v(); + }) + ); + } + var m = !1, b = ((n & hl) !== 0 ? gi : Pa)(() => (m = !1, v())); + i && w(b); + var A = ( + /** @type {Effect} */ + X + ); + return ( + /** @type {() => V} */ + (function(T, D) { + if (arguments.length > 0) { + const E = D ? w(b) : i ? un(T) : T; + return J(b, E), m = !0, a !== void 0 && (a = E), T; + } + return tn && m || (A.f & He) !== 0 ? b.v : w(b); + }) + ); +} +function Tu(t) { + return new Cu(t); +} +var Ve, Wt; +class Cu { + /** + * @param {ComponentConstructorOptions & { + * component: any; + * }} options + */ + constructor(e) { + /** @type {any} */ + L(this, Ve); + /** @type {Record} */ + L(this, Wt); + var s; + var n = /* @__PURE__ */ new Map(), r = (a, o) => { + var l = /* @__PURE__ */ Fa(o, !1, !1); + return n.set(a, l), l; + }; + const i = new Proxy( + { ...e.props || {}, $$events: {} }, + { + get(a, o) { + return w(n.get(o) ?? r(o, Reflect.get(a, o))); + }, + has(a, o) { + return o === _a ? !0 : (w(n.get(o) ?? r(o, Reflect.get(a, o))), Reflect.has(a, o)); + }, + set(a, o, l) { + return J(n.get(o) ?? r(o, l), l), Reflect.set(a, o, l); + } + } + ); + O(this, Wt, (e.hydrate ? mu : oo)(e.component, { + target: e.target, + anchor: e.anchor, + props: i, + context: e.context, + intro: e.intro ?? !1, + recover: e.recover + })), (!((s = e == null ? void 0 : e.props) != null && s.$$host) || e.sync === !1) && jt(), O(this, Ve, i.$$events); + for (const a of Object.keys(d(this, Wt))) + a === "$set" || a === "$destroy" || a === "$on" || Jr(this, a, { + get() { + return d(this, Wt)[a]; + }, + /** @param {any} value */ + set(o) { + d(this, Wt)[a] = o; + }, + enumerable: !0 + }); + d(this, Wt).$set = /** @param {Record} next */ + (a) => { + Object.assign(i, a); + }, d(this, Wt).$destroy = () => { + yu(d(this, Wt)); + }; + } + /** @param {Record} props */ + $set(e) { + d(this, Wt).$set(e); + } + /** + * @param {string} event + * @param {(...args: any[]) => any} callback + * @returns {any} + */ + $on(e, n) { + d(this, Ve)[e] = d(this, Ve)[e] || []; + const r = (...i) => n.call(this, ...i); + return d(this, Ve)[e].push(r), () => { + d(this, Ve)[e] = d(this, Ve)[e].filter( + /** @param {any} fn */ + (i) => i !== r + ); + }; + } + $destroy() { + d(this, Wt).$destroy(); + } +} +Ve = new WeakMap(), Wt = new WeakMap(); +let fo; +typeof HTMLElement == "function" && (fo = class extends HTMLElement { + /** + * @param {*} $$componentCtor + * @param {*} $$slots + * @param {ShadowRootInit | undefined} shadow_root_init + */ + constructor(e, n, r) { + super(); + /** The Svelte component constructor */ + ot(this, "$$ctor"); + /** Slots */ + ot(this, "$$s"); + /** @type {any} The Svelte component instance */ + ot(this, "$$c"); + /** Whether or not the custom element is connected */ + ot(this, "$$cn", !1); + /** @type {Record} Component props data */ + ot(this, "$$d", {}); + /** `true` if currently in the process of reflecting component props back to attributes */ + ot(this, "$$r", !1); + /** @type {Record} Props definition (name, reflected, type etc) */ + ot(this, "$$p_d", {}); + /** @type {Record} Event listeners */ + ot(this, "$$l", {}); + /** @type {Map} Event listener unsubscribe functions */ + ot(this, "$$l_u", /* @__PURE__ */ new Map()); + /** @type {any} The managed render effect for reflecting attributes */ + ot(this, "$$me"); + /** @type {ShadowRoot | null} The ShadowRoot of the custom element */ + ot(this, "$$shadowRoot", null); + this.$$ctor = e, this.$$s = n, r && (this.$$shadowRoot = this.attachShadow(r)); + } + /** + * @param {string} type + * @param {EventListenerOrEventListenerObject} listener + * @param {boolean | AddEventListenerOptions} [options] + */ + addEventListener(e, n, r) { + if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(n), this.$$c) { + const i = this.$$c.$on(e, n); + this.$$l_u.set(n, i); + } + super.addEventListener(e, n, r); + } + /** + * @param {string} type + * @param {EventListenerOrEventListenerObject} listener + * @param {boolean | AddEventListenerOptions} [options] + */ + removeEventListener(e, n, r) { + if (super.removeEventListener(e, n, r), this.$$c) { + const i = this.$$l_u.get(n); + i && (i(), this.$$l_u.delete(n)); + } + } + async connectedCallback() { + if (this.$$cn = !0, !this.$$c) { + let n = function(s) { + return (a) => { + const o = cs("slot"); + s !== "default" && (o.name = s), be(a, o); + }; + }; + var e = n; + if (await Promise.resolve(), !this.$$cn || this.$$c) + return; + const r = {}, i = Nu(this); + for (const s of this.$$s) + s in i && (s === "default" && !this.$$d.children ? (this.$$d.children = n(s), r.default = !0) : r[s] = n(s)); + for (const s of this.attributes) { + const a = this.$$g_p(s.name); + a in this.$$d || (this.$$d[a] = Ur(a, s.value, this.$$p_d, "toProp")); + } + for (const s in this.$$p_d) + !(s in this.$$d) && this[s] !== void 0 && (this.$$d[s] = this[s], delete this[s]); + this.$$c = Tu({ + component: this.$$ctor, + target: this.$$shadowRoot || this, + props: { + ...this.$$d, + $$slots: r, + $$host: this + } + }), this.$$me = su(() => { + ps(() => { + var s; + this.$$r = !0; + for (const a of Zr(this.$$c)) { + if (!((s = this.$$p_d[a]) != null && s.reflect)) continue; + this.$$d[a] = this.$$c[a]; + const o = Ur( + a, + this.$$d[a], + this.$$p_d, + "toAttribute" + ); + o == null ? this.removeAttribute(this.$$p_d[a].attribute || a) : this.setAttribute(this.$$p_d[a].attribute || a, o); + } + this.$$r = !1; + }); + }); + for (const s in this.$$l) + for (const a of this.$$l[s]) { + const o = this.$$c.$on(s, a); + this.$$l_u.set(a, o); + } + this.$$l = {}; + } + } + // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte + // and setting attributes through setAttribute etc, this is helpful + /** + * @param {string} attr + * @param {string} _oldValue + * @param {string} newValue + */ + attributeChangedCallback(e, n, r) { + var i; + this.$$r || (e = this.$$g_p(e), this.$$d[e] = Ur(e, r, this.$$p_d, "toProp"), (i = this.$$c) == null || i.$set({ [e]: this.$$d[e] })); + } + disconnectedCallback() { + this.$$cn = !1, Promise.resolve().then(() => { + !this.$$cn && this.$$c && (this.$$c.$destroy(), this.$$me(), this.$$c = void 0); + }); + } + /** + * @param {string} attribute_name + */ + $$g_p(e) { + return Zr(this.$$p_d).find( + (n) => this.$$p_d[n].attribute === e || !this.$$p_d[n].attribute && n.toLowerCase() === e + ) || e; + } +}); +function Ur(t, e, n, r) { + var s; + const i = (s = n[t]) == null ? void 0 : s.type; + if (e = i === "Boolean" && typeof e != "boolean" ? e != null : e, !r || !n[t]) + return e; + if (r === "toAttribute") + switch (i) { + case "Object": + case "Array": + return e == null ? null : JSON.stringify(e); + case "Boolean": + return e ? "" : null; + case "Number": + return e ?? null; + default: + return e; + } + else + switch (i) { + case "Object": + case "Array": + return e && JSON.parse(e); + case "Boolean": + return e; + // conversion already handled above + case "Number": + return e != null ? +e : e; + default: + return e; + } +} +function Nu(t) { + const e = {}; + return t.childNodes.forEach((n) => { + e[ + /** @type {Element} node */ + n.slot || "default" + ] = !0; + }), e; +} +function co(t, e, n, r, i, s) { + let a = class extends fo { + constructor() { + super(t, n, i), this.$$p_d = e; + } + static get observedAttributes() { + return Zr(e).map( + (o) => (e[o].attribute || o).toLowerCase() + ); + } + }; + return Zr(e).forEach((o) => { + Jr(a.prototype, o, { + get() { + return this.$$c && o in this.$$c ? this.$$c[o] : this.$$d[o]; + }, + set(l) { + var h; + l = Ur(o, l, e), this.$$d[o] = l; + var u = this.$$c; + if (u) { + var f = (h = mn(u, o)) == null ? void 0 : h.get; + f ? u[o] = l : u.$set({ [o]: l }); + } + } + }); + }), r.forEach((o) => { + Jr(a.prototype, o, { + get() { + var l; + return (l = this.$$c) == null ? void 0 : l[o]; + } + }); + }), t.element = /** @type {any} */ + a, a; +} +var Su = { value: () => { +} }; +function ho() { + for (var t = 0, e = arguments.length, n = {}, r; t < e; ++t) { + if (!(r = arguments[t] + "") || r in n || /[\s.]/.test(r)) throw new Error("illegal type: " + r); + n[r] = []; + } + return new Xr(n); +} +function Xr(t) { + this._ = t; +} +function ku(t, e) { + return t.trim().split(/^|\s+/).map(function(n) { + var r = "", i = n.indexOf("."); + if (i >= 0 && (r = n.slice(i + 1), n = n.slice(0, i)), n && !e.hasOwnProperty(n)) throw new Error("unknown type: " + n); + return { type: n, name: r }; + }); +} +Xr.prototype = ho.prototype = { + constructor: Xr, + on: function(t, e) { + var n = this._, r = ku(t + "", n), i, s = -1, a = r.length; + if (arguments.length < 2) { + for (; ++s < a; ) if ((i = (t = r[s]).type) && (i = Mu(n[i], t.name))) return i; + return; + } + if (e != null && typeof e != "function") throw new Error("invalid callback: " + e); + for (; ++s < a; ) + if (i = (t = r[s]).type) n[i] = Us(n[i], t.name, e); + else if (e == null) for (i in n) n[i] = Us(n[i], t.name, null); + return this; + }, + copy: function() { + var t = {}, e = this._; + for (var n in e) t[n] = e[n].slice(); + return new Xr(t); + }, + call: function(t, e) { + if ((i = arguments.length - 2) > 0) for (var n = new Array(i), r = 0, i, s; r < i; ++r) n[r] = arguments[r + 2]; + if (!this._.hasOwnProperty(t)) throw new Error("unknown type: " + t); + for (s = this._[t], r = 0, i = s.length; r < i; ++r) s[r].value.apply(e, n); + }, + apply: function(t, e, n) { + if (!this._.hasOwnProperty(t)) throw new Error("unknown type: " + t); + for (var r = this._[t], i = 0, s = r.length; i < s; ++i) r[i].value.apply(e, n); + } +}; +function Mu(t, e) { + for (var n = 0, r = t.length, i; n < r; ++n) + if ((i = t[n]).name === e) + return i.value; +} +function Us(t, e, n) { + for (var r = 0, i = t.length; r < i; ++r) + if (t[r].name === e) { + t[r] = Su, t = t.slice(0, r).concat(t.slice(r + 1)); + break; + } + return n != null && t.push({ name: e, value: n }), t; +} +var Wi = "http://www.w3.org/1999/xhtml"; +const Xs = { + svg: "http://www.w3.org/2000/svg", + xhtml: Wi, + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" +}; +function yi(t) { + var e = t += "", n = e.indexOf(":"); + return n >= 0 && (e = t.slice(0, n)) !== "xmlns" && (t = t.slice(n + 1)), Xs.hasOwnProperty(e) ? { space: Xs[e], local: t } : t; +} +function Pu(t) { + return function() { + var e = this.ownerDocument, n = this.namespaceURI; + return n === Wi && e.documentElement.namespaceURI === Wi ? e.createElement(t) : e.createElementNS(n, t); + }; +} +function Ou(t) { + return function() { + return this.ownerDocument.createElementNS(t.space, t.local); + }; +} +function po(t) { + var e = yi(t); + return (e.local ? Ou : Pu)(e); +} +function Du() { +} +function ms(t) { + return t == null ? Du : function() { + return this.querySelector(t); + }; +} +function Iu(t) { + typeof t != "function" && (t = ms(t)); + for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i) + for (var s = e[i], a = s.length, o = r[i] = new Array(a), l, u, f = 0; f < a; ++f) + (l = s[f]) && (u = t.call(l, l.__data__, f, s)) && ("__data__" in l && (u.__data__ = l.__data__), o[f] = u); + return new Vt(r, this._parents); +} +function Fu(t) { + return t == null ? [] : Array.isArray(t) ? t : Array.from(t); +} +function Lu() { + return []; +} +function vo(t) { + return t == null ? Lu : function() { + return this.querySelectorAll(t); + }; +} +function qu(t) { + return function() { + return Fu(t.apply(this, arguments)); + }; +} +function Vu(t) { + typeof t == "function" ? t = qu(t) : t = vo(t); + for (var e = this._groups, n = e.length, r = [], i = [], s = 0; s < n; ++s) + for (var a = e[s], o = a.length, l, u = 0; u < o; ++u) + (l = a[u]) && (r.push(t.call(l, l.__data__, u, a)), i.push(l)); + return new Vt(r, i); +} +function go(t) { + return function() { + return this.matches(t); + }; +} +function _o(t) { + return function(e) { + return e.matches(t); + }; +} +var zu = Array.prototype.find; +function Hu(t) { + return function() { + return zu.call(this.children, t); + }; +} +function Yu() { + return this.firstElementChild; +} +function Bu(t) { + return this.select(t == null ? Yu : Hu(typeof t == "function" ? t : _o(t))); +} +var Uu = Array.prototype.filter; +function Xu() { + return Array.from(this.children); +} +function Gu(t) { + return function() { + return Uu.call(this.children, t); + }; +} +function Ku(t) { + return this.selectAll(t == null ? Xu : Gu(typeof t == "function" ? t : _o(t))); +} +function Wu(t) { + typeof t != "function" && (t = go(t)); + for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i) + for (var s = e[i], a = s.length, o = r[i] = [], l, u = 0; u < a; ++u) + (l = s[u]) && t.call(l, l.__data__, u, s) && o.push(l); + return new Vt(r, this._parents); +} +function mo(t) { + return new Array(t.length); +} +function ju() { + return new Vt(this._enter || this._groups.map(mo), this._parents); +} +function ti(t, e) { + this.ownerDocument = t.ownerDocument, this.namespaceURI = t.namespaceURI, this._next = null, this._parent = t, this.__data__ = e; +} +ti.prototype = { + constructor: ti, + appendChild: function(t) { + return this._parent.insertBefore(t, this._next); + }, + insertBefore: function(t, e) { + return this._parent.insertBefore(t, e); + }, + querySelector: function(t) { + return this._parent.querySelector(t); + }, + querySelectorAll: function(t) { + return this._parent.querySelectorAll(t); + } +}; +function Zu(t) { + return function() { + return t; + }; +} +function Ju(t, e, n, r, i, s) { + for (var a = 0, o, l = e.length, u = s.length; a < u; ++a) + (o = e[a]) ? (o.__data__ = s[a], r[a] = o) : n[a] = new ti(t, s[a]); + for (; a < l; ++a) + (o = e[a]) && (i[a] = o); +} +function Qu(t, e, n, r, i, s, a) { + var o, l, u = /* @__PURE__ */ new Map(), f = e.length, h = s.length, c = new Array(f), v; + for (o = 0; o < f; ++o) + (l = e[o]) && (c[o] = v = a.call(l, l.__data__, o, e) + "", u.has(v) ? i[o] = l : u.set(v, l)); + for (o = 0; o < h; ++o) + v = a.call(t, s[o], o, s) + "", (l = u.get(v)) ? (r[o] = l, l.__data__ = s[o], u.delete(v)) : n[o] = new ti(t, s[o]); + for (o = 0; o < f; ++o) + (l = e[o]) && u.get(c[o]) === l && (i[o] = l); +} +function tf(t) { + return t.__data__; +} +function ef(t, e) { + if (!arguments.length) return Array.from(this, tf); + var n = e ? Qu : Ju, r = this._parents, i = this._groups; + typeof t != "function" && (t = Zu(t)); + for (var s = i.length, a = new Array(s), o = new Array(s), l = new Array(s), u = 0; u < s; ++u) { + var f = r[u], h = i[u], c = h.length, v = nf(t.call(f, f && f.__data__, u, r)), g = v.length, m = o[u] = new Array(g), b = a[u] = new Array(g), A = l[u] = new Array(c); + n(f, h, m, b, A, v, e); + for (var S = 0, T = 0, D, E; S < g; ++S) + if (D = m[S]) { + for (S >= T && (T = S + 1); !(E = b[T]) && ++T < g; ) ; + D._next = E || null; + } + } + return a = new Vt(a, r), a._enter = o, a._exit = l, a; +} +function nf(t) { + return typeof t == "object" && "length" in t ? t : Array.from(t); +} +function rf() { + return new Vt(this._exit || this._groups.map(mo), this._parents); +} +function sf(t, e, n) { + var r = this.enter(), i = this, s = this.exit(); + return typeof t == "function" ? (r = t(r), r && (r = r.selection())) : r = r.append(t + ""), e != null && (i = e(i), i && (i = i.selection())), n == null ? s.remove() : n(s), r && i ? r.merge(i).order() : i; +} +function af(t) { + for (var e = t.selection ? t.selection() : t, n = this._groups, r = e._groups, i = n.length, s = r.length, a = Math.min(i, s), o = new Array(i), l = 0; l < a; ++l) + for (var u = n[l], f = r[l], h = u.length, c = o[l] = new Array(h), v, g = 0; g < h; ++g) + (v = u[g] || f[g]) && (c[g] = v); + for (; l < i; ++l) + o[l] = n[l]; + return new Vt(o, this._parents); +} +function of() { + for (var t = this._groups, e = -1, n = t.length; ++e < n; ) + for (var r = t[e], i = r.length - 1, s = r[i], a; --i >= 0; ) + (a = r[i]) && (s && a.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(a, s), s = a); + return this; +} +function lf(t) { + t || (t = uf); + function e(h, c) { + return h && c ? t(h.__data__, c.__data__) : !h - !c; + } + for (var n = this._groups, r = n.length, i = new Array(r), s = 0; s < r; ++s) { + for (var a = n[s], o = a.length, l = i[s] = new Array(o), u, f = 0; f < o; ++f) + (u = a[f]) && (l[f] = u); + l.sort(e); + } + return new Vt(i, this._parents).order(); +} +function uf(t, e) { + return t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN; +} +function ff() { + var t = arguments[0]; + return arguments[0] = this, t.apply(null, arguments), this; +} +function cf() { + return Array.from(this); +} +function hf() { + for (var t = this._groups, e = 0, n = t.length; e < n; ++e) + for (var r = t[e], i = 0, s = r.length; i < s; ++i) { + var a = r[i]; + if (a) return a; + } + return null; +} +function df() { + let t = 0; + for (const e of this) ++t; + return t; +} +function pf() { + return !this.node(); +} +function vf(t) { + for (var e = this._groups, n = 0, r = e.length; n < r; ++n) + for (var i = e[n], s = 0, a = i.length, o; s < a; ++s) + (o = i[s]) && t.call(o, o.__data__, s, i); + return this; +} +function gf(t) { + return function() { + this.removeAttribute(t); + }; +} +function _f(t) { + return function() { + this.removeAttributeNS(t.space, t.local); + }; +} +function mf(t, e) { + return function() { + this.setAttribute(t, e); + }; +} +function yf(t, e) { + return function() { + this.setAttributeNS(t.space, t.local, e); + }; +} +function wf(t, e) { + return function() { + var n = e.apply(this, arguments); + n == null ? this.removeAttribute(t) : this.setAttribute(t, n); + }; +} +function xf(t, e) { + return function() { + var n = e.apply(this, arguments); + n == null ? this.removeAttributeNS(t.space, t.local) : this.setAttributeNS(t.space, t.local, n); + }; +} +function bf(t, e) { + var n = yi(t); + if (arguments.length < 2) { + var r = this.node(); + return n.local ? r.getAttributeNS(n.space, n.local) : r.getAttribute(n); + } + return this.each((e == null ? n.local ? _f : gf : typeof e == "function" ? n.local ? xf : wf : n.local ? yf : mf)(n, e)); +} +function yo(t) { + return t.ownerDocument && t.ownerDocument.defaultView || t.document && t || t.defaultView; +} +function $f(t) { + return function() { + this.style.removeProperty(t); + }; +} +function Af(t, e, n) { + return function() { + this.style.setProperty(t, e, n); + }; +} +function Ef(t, e, n) { + return function() { + var r = e.apply(this, arguments); + r == null ? this.style.removeProperty(t) : this.style.setProperty(t, r, n); + }; +} +function Rf(t, e, n) { + return arguments.length > 1 ? this.each((e == null ? $f : typeof e == "function" ? Ef : Af)(t, e, n ?? "")) : Zn(this.node(), t); +} +function Zn(t, e) { + return t.style.getPropertyValue(e) || yo(t).getComputedStyle(t, null).getPropertyValue(e); +} +function Tf(t) { + return function() { + delete this[t]; + }; +} +function Cf(t, e) { + return function() { + this[t] = e; + }; +} +function Nf(t, e) { + return function() { + var n = e.apply(this, arguments); + n == null ? delete this[t] : this[t] = n; + }; +} +function Sf(t, e) { + return arguments.length > 1 ? this.each((e == null ? Tf : typeof e == "function" ? Nf : Cf)(t, e)) : this.node()[t]; +} +function wo(t) { + return t.trim().split(/^|\s+/); +} +function ys(t) { + return t.classList || new xo(t); +} +function xo(t) { + this._node = t, this._names = wo(t.getAttribute("class") || ""); +} +xo.prototype = { + add: function(t) { + var e = this._names.indexOf(t); + e < 0 && (this._names.push(t), this._node.setAttribute("class", this._names.join(" "))); + }, + remove: function(t) { + var e = this._names.indexOf(t); + e >= 0 && (this._names.splice(e, 1), this._node.setAttribute("class", this._names.join(" "))); + }, + contains: function(t) { + return this._names.indexOf(t) >= 0; + } +}; +function bo(t, e) { + for (var n = ys(t), r = -1, i = e.length; ++r < i; ) n.add(e[r]); +} +function $o(t, e) { + for (var n = ys(t), r = -1, i = e.length; ++r < i; ) n.remove(e[r]); +} +function kf(t) { + return function() { + bo(this, t); + }; +} +function Mf(t) { + return function() { + $o(this, t); + }; +} +function Pf(t, e) { + return function() { + (e.apply(this, arguments) ? bo : $o)(this, t); + }; +} +function Of(t, e) { + var n = wo(t + ""); + if (arguments.length < 2) { + for (var r = ys(this.node()), i = -1, s = n.length; ++i < s; ) if (!r.contains(n[i])) return !1; + return !0; + } + return this.each((typeof e == "function" ? Pf : e ? kf : Mf)(n, e)); +} +function Df() { + this.textContent = ""; +} +function If(t) { + return function() { + this.textContent = t; + }; +} +function Ff(t) { + return function() { + var e = t.apply(this, arguments); + this.textContent = e ?? ""; + }; +} +function Lf(t) { + return arguments.length ? this.each(t == null ? Df : (typeof t == "function" ? Ff : If)(t)) : this.node().textContent; +} +function qf() { + this.innerHTML = ""; +} +function Vf(t) { + return function() { + this.innerHTML = t; + }; +} +function zf(t) { + return function() { + var e = t.apply(this, arguments); + this.innerHTML = e ?? ""; + }; +} +function Hf(t) { + return arguments.length ? this.each(t == null ? qf : (typeof t == "function" ? zf : Vf)(t)) : this.node().innerHTML; +} +function Yf() { + this.nextSibling && this.parentNode.appendChild(this); +} +function Bf() { + return this.each(Yf); +} +function Uf() { + this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild); +} +function Xf() { + return this.each(Uf); +} +function Gf(t) { + var e = typeof t == "function" ? t : po(t); + return this.select(function() { + return this.appendChild(e.apply(this, arguments)); + }); +} +function Kf() { + return null; +} +function Wf(t, e) { + var n = typeof t == "function" ? t : po(t), r = e == null ? Kf : typeof e == "function" ? e : ms(e); + return this.select(function() { + return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null); + }); +} +function jf() { + var t = this.parentNode; + t && t.removeChild(this); +} +function Zf() { + return this.each(jf); +} +function Jf() { + var t = this.cloneNode(!1), e = this.parentNode; + return e ? e.insertBefore(t, this.nextSibling) : t; +} +function Qf() { + var t = this.cloneNode(!0), e = this.parentNode; + return e ? e.insertBefore(t, this.nextSibling) : t; +} +function tc(t) { + return this.select(t ? Qf : Jf); +} +function ec(t) { + return arguments.length ? this.property("__data__", t) : this.node().__data__; +} +function nc(t) { + return function(e) { + t.call(this, e, this.__data__); + }; +} +function rc(t) { + return t.trim().split(/^|\s+/).map(function(e) { + var n = "", r = e.indexOf("."); + return r >= 0 && (n = e.slice(r + 1), e = e.slice(0, r)), { type: e, name: n }; + }); +} +function ic(t) { + return function() { + var e = this.__on; + if (e) { + for (var n = 0, r = -1, i = e.length, s; n < i; ++n) + s = e[n], (!t.type || s.type === t.type) && s.name === t.name ? this.removeEventListener(s.type, s.listener, s.options) : e[++r] = s; + ++r ? e.length = r : delete this.__on; + } + }; +} +function sc(t, e, n) { + return function() { + var r = this.__on, i, s = nc(e); + if (r) { + for (var a = 0, o = r.length; a < o; ++a) + if ((i = r[a]).type === t.type && i.name === t.name) { + this.removeEventListener(i.type, i.listener, i.options), this.addEventListener(i.type, i.listener = s, i.options = n), i.value = e; + return; + } + } + this.addEventListener(t.type, s, n), i = { type: t.type, name: t.name, value: e, listener: s, options: n }, r ? r.push(i) : this.__on = [i]; + }; +} +function ac(t, e, n) { + var r = rc(t + ""), i, s = r.length, a; + if (arguments.length < 2) { + var o = this.node().__on; + if (o) { + for (var l = 0, u = o.length, f; l < u; ++l) + for (i = 0, f = o[l]; i < s; ++i) + if ((a = r[i]).type === f.type && a.name === f.name) + return f.value; + } + return; + } + for (o = e ? sc : ic, i = 0; i < s; ++i) this.each(o(r[i], e, n)); + return this; +} +function Ao(t, e, n) { + var r = yo(t), i = r.CustomEvent; + typeof i == "function" ? i = new i(e, n) : (i = r.document.createEvent("Event"), n ? (i.initEvent(e, n.bubbles, n.cancelable), i.detail = n.detail) : i.initEvent(e, !1, !1)), t.dispatchEvent(i); +} +function oc(t, e) { + return function() { + return Ao(this, t, e); + }; +} +function lc(t, e) { + return function() { + return Ao(this, t, e.apply(this, arguments)); + }; +} +function uc(t, e) { + return this.each((typeof e == "function" ? lc : oc)(t, e)); +} +function* fc() { + for (var t = this._groups, e = 0, n = t.length; e < n; ++e) + for (var r = t[e], i = 0, s = r.length, a; i < s; ++i) + (a = r[i]) && (yield a); +} +var Eo = [null]; +function Vt(t, e) { + this._groups = t, this._parents = e; +} +function nr() { + return new Vt([[document.documentElement]], Eo); +} +function cc() { + return this; +} +Vt.prototype = nr.prototype = { + constructor: Vt, + select: Iu, + selectAll: Vu, + selectChild: Bu, + selectChildren: Ku, + filter: Wu, + data: ef, + enter: ju, + exit: rf, + join: sf, + merge: af, + selection: cc, + order: of, + sort: lf, + call: ff, + nodes: cf, + node: hf, + size: df, + empty: pf, + each: vf, + attr: bf, + style: Rf, + property: Sf, + classed: Of, + text: Lf, + html: Hf, + raise: Bf, + lower: Xf, + append: Gf, + insert: Wf, + remove: Zf, + clone: tc, + datum: ec, + on: ac, + dispatch: uc, + [Symbol.iterator]: fc +}; +function gt(t) { + return typeof t == "string" ? new Vt([[document.querySelector(t)]], [document.documentElement]) : new Vt([[t]], Eo); +} +function ws(t, e, n) { + t.prototype = e.prototype = n, n.constructor = t; +} +function Ro(t, e) { + var n = Object.create(t.prototype); + for (var r in e) n[r] = e[r]; + return n; +} +function Cr() { +} +var _r = 0.7, ei = 1 / _r, In = "\\s*([+-]?\\d+)\\s*", mr = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", Ce = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", hc = /^#([0-9a-f]{3,8})$/, dc = new RegExp(`^rgb\\(${In},${In},${In}\\)$`), pc = new RegExp(`^rgb\\(${Ce},${Ce},${Ce}\\)$`), vc = new RegExp(`^rgba\\(${In},${In},${In},${mr}\\)$`), gc = new RegExp(`^rgba\\(${Ce},${Ce},${Ce},${mr}\\)$`), _c = new RegExp(`^hsl\\(${mr},${Ce},${Ce}\\)$`), mc = new RegExp(`^hsla\\(${mr},${Ce},${Ce},${mr}\\)$`), Gs = { + aliceblue: 15792383, + antiquewhite: 16444375, + aqua: 65535, + aquamarine: 8388564, + azure: 15794175, + beige: 16119260, + bisque: 16770244, + black: 0, + blanchedalmond: 16772045, + blue: 255, + blueviolet: 9055202, + brown: 10824234, + burlywood: 14596231, + cadetblue: 6266528, + chartreuse: 8388352, + chocolate: 13789470, + coral: 16744272, + cornflowerblue: 6591981, + cornsilk: 16775388, + crimson: 14423100, + cyan: 65535, + darkblue: 139, + darkcyan: 35723, + darkgoldenrod: 12092939, + darkgray: 11119017, + darkgreen: 25600, + darkgrey: 11119017, + darkkhaki: 12433259, + darkmagenta: 9109643, + darkolivegreen: 5597999, + darkorange: 16747520, + darkorchid: 10040012, + darkred: 9109504, + darksalmon: 15308410, + darkseagreen: 9419919, + darkslateblue: 4734347, + darkslategray: 3100495, + darkslategrey: 3100495, + darkturquoise: 52945, + darkviolet: 9699539, + deeppink: 16716947, + deepskyblue: 49151, + dimgray: 6908265, + dimgrey: 6908265, + dodgerblue: 2003199, + firebrick: 11674146, + floralwhite: 16775920, + forestgreen: 2263842, + fuchsia: 16711935, + gainsboro: 14474460, + ghostwhite: 16316671, + gold: 16766720, + goldenrod: 14329120, + gray: 8421504, + green: 32768, + greenyellow: 11403055, + grey: 8421504, + honeydew: 15794160, + hotpink: 16738740, + indianred: 13458524, + indigo: 4915330, + ivory: 16777200, + khaki: 15787660, + lavender: 15132410, + lavenderblush: 16773365, + lawngreen: 8190976, + lemonchiffon: 16775885, + lightblue: 11393254, + lightcoral: 15761536, + lightcyan: 14745599, + lightgoldenrodyellow: 16448210, + lightgray: 13882323, + lightgreen: 9498256, + lightgrey: 13882323, + lightpink: 16758465, + lightsalmon: 16752762, + lightseagreen: 2142890, + lightskyblue: 8900346, + lightslategray: 7833753, + lightslategrey: 7833753, + lightsteelblue: 11584734, + lightyellow: 16777184, + lime: 65280, + limegreen: 3329330, + linen: 16445670, + magenta: 16711935, + maroon: 8388608, + mediumaquamarine: 6737322, + mediumblue: 205, + mediumorchid: 12211667, + mediumpurple: 9662683, + mediumseagreen: 3978097, + mediumslateblue: 8087790, + mediumspringgreen: 64154, + mediumturquoise: 4772300, + mediumvioletred: 13047173, + midnightblue: 1644912, + mintcream: 16121850, + mistyrose: 16770273, + moccasin: 16770229, + navajowhite: 16768685, + navy: 128, + oldlace: 16643558, + olive: 8421376, + olivedrab: 7048739, + orange: 16753920, + orangered: 16729344, + orchid: 14315734, + palegoldenrod: 15657130, + palegreen: 10025880, + paleturquoise: 11529966, + palevioletred: 14381203, + papayawhip: 16773077, + peachpuff: 16767673, + peru: 13468991, + pink: 16761035, + plum: 14524637, + powderblue: 11591910, + purple: 8388736, + rebeccapurple: 6697881, + red: 16711680, + rosybrown: 12357519, + royalblue: 4286945, + saddlebrown: 9127187, + salmon: 16416882, + sandybrown: 16032864, + seagreen: 3050327, + seashell: 16774638, + sienna: 10506797, + silver: 12632256, + skyblue: 8900331, + slateblue: 6970061, + slategray: 7372944, + slategrey: 7372944, + snow: 16775930, + springgreen: 65407, + steelblue: 4620980, + tan: 13808780, + teal: 32896, + thistle: 14204888, + tomato: 16737095, + turquoise: 4251856, + violet: 15631086, + wheat: 16113331, + white: 16777215, + whitesmoke: 16119285, + yellow: 16776960, + yellowgreen: 10145074 +}; +ws(Cr, Tn, { + copy(t) { + return Object.assign(new this.constructor(), this, t); + }, + displayable() { + return this.rgb().displayable(); + }, + hex: Ks, + // Deprecated! Use color.formatHex. + formatHex: Ks, + formatHex8: yc, + formatHsl: wc, + formatRgb: Ws, + toString: Ws +}); +function Ks() { + return this.rgb().formatHex(); +} +function yc() { + return this.rgb().formatHex8(); +} +function wc() { + return To(this).formatHsl(); +} +function Ws() { + return this.rgb().formatRgb(); +} +function Tn(t) { + var e, n; + return t = (t + "").trim().toLowerCase(), (e = hc.exec(t)) ? (n = e[1].length, e = parseInt(e[1], 16), n === 6 ? js(e) : n === 3 ? new Mt(e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, (e & 15) << 4 | e & 15, 1) : n === 8 ? Fr(e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, (e & 255) / 255) : n === 4 ? Fr(e >> 12 & 15 | e >> 8 & 240, e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, ((e & 15) << 4 | e & 15) / 255) : null) : (e = dc.exec(t)) ? new Mt(e[1], e[2], e[3], 1) : (e = pc.exec(t)) ? new Mt(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, 1) : (e = vc.exec(t)) ? Fr(e[1], e[2], e[3], e[4]) : (e = gc.exec(t)) ? Fr(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, e[4]) : (e = _c.exec(t)) ? Qs(e[1], e[2] / 100, e[3] / 100, 1) : (e = mc.exec(t)) ? Qs(e[1], e[2] / 100, e[3] / 100, e[4]) : Gs.hasOwnProperty(t) ? js(Gs[t]) : t === "transparent" ? new Mt(NaN, NaN, NaN, 0) : null; +} +function js(t) { + return new Mt(t >> 16 & 255, t >> 8 & 255, t & 255, 1); +} +function Fr(t, e, n, r) { + return r <= 0 && (t = e = n = NaN), new Mt(t, e, n, r); +} +function xc(t) { + return t instanceof Cr || (t = Tn(t)), t ? (t = t.rgb(), new Mt(t.r, t.g, t.b, t.opacity)) : new Mt(); +} +function ji(t, e, n, r) { + return arguments.length === 1 ? xc(t) : new Mt(t, e, n, r ?? 1); +} +function Mt(t, e, n, r) { + this.r = +t, this.g = +e, this.b = +n, this.opacity = +r; +} +ws(Mt, ji, Ro(Cr, { + brighter(t) { + return t = t == null ? ei : Math.pow(ei, t), new Mt(this.r * t, this.g * t, this.b * t, this.opacity); + }, + darker(t) { + return t = t == null ? _r : Math.pow(_r, t), new Mt(this.r * t, this.g * t, this.b * t, this.opacity); + }, + rgb() { + return this; + }, + clamp() { + return new Mt(bn(this.r), bn(this.g), bn(this.b), ni(this.opacity)); + }, + displayable() { + return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1; + }, + hex: Zs, + // Deprecated! Use color.formatHex. + formatHex: Zs, + formatHex8: bc, + formatRgb: Js, + toString: Js +})); +function Zs() { + return `#${cn(this.r)}${cn(this.g)}${cn(this.b)}`; +} +function bc() { + return `#${cn(this.r)}${cn(this.g)}${cn(this.b)}${cn((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; +} +function Js() { + const t = ni(this.opacity); + return `${t === 1 ? "rgb(" : "rgba("}${bn(this.r)}, ${bn(this.g)}, ${bn(this.b)}${t === 1 ? ")" : `, ${t})`}`; +} +function ni(t) { + return isNaN(t) ? 1 : Math.max(0, Math.min(1, t)); +} +function bn(t) { + return Math.max(0, Math.min(255, Math.round(t) || 0)); +} +function cn(t) { + return t = bn(t), (t < 16 ? "0" : "") + t.toString(16); +} +function Qs(t, e, n, r) { + return r <= 0 ? t = e = n = NaN : n <= 0 || n >= 1 ? t = e = NaN : e <= 0 && (t = NaN), new fe(t, e, n, r); +} +function To(t) { + if (t instanceof fe) return new fe(t.h, t.s, t.l, t.opacity); + if (t instanceof Cr || (t = Tn(t)), !t) return new fe(); + if (t instanceof fe) return t; + t = t.rgb(); + var e = t.r / 255, n = t.g / 255, r = t.b / 255, i = Math.min(e, n, r), s = Math.max(e, n, r), a = NaN, o = s - i, l = (s + i) / 2; + return o ? (e === s ? a = (n - r) / o + (n < r) * 6 : n === s ? a = (r - e) / o + 2 : a = (e - n) / o + 4, o /= l < 0.5 ? s + i : 2 - s - i, a *= 60) : o = l > 0 && l < 1 ? 0 : a, new fe(a, o, l, t.opacity); +} +function $c(t, e, n, r) { + return arguments.length === 1 ? To(t) : new fe(t, e, n, r ?? 1); +} +function fe(t, e, n, r) { + this.h = +t, this.s = +e, this.l = +n, this.opacity = +r; +} +ws(fe, $c, Ro(Cr, { + brighter(t) { + return t = t == null ? ei : Math.pow(ei, t), new fe(this.h, this.s, this.l * t, this.opacity); + }, + darker(t) { + return t = t == null ? _r : Math.pow(_r, t), new fe(this.h, this.s, this.l * t, this.opacity); + }, + rgb() { + var t = this.h % 360 + (this.h < 0) * 360, e = isNaN(t) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < 0.5 ? n : 1 - n) * e, i = 2 * n - r; + return new Mt( + Mi(t >= 240 ? t - 240 : t + 120, i, r), + Mi(t, i, r), + Mi(t < 120 ? t + 240 : t - 120, i, r), + this.opacity + ); + }, + clamp() { + return new fe(ta(this.h), Lr(this.s), Lr(this.l), ni(this.opacity)); + }, + displayable() { + return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1; + }, + formatHsl() { + const t = ni(this.opacity); + return `${t === 1 ? "hsl(" : "hsla("}${ta(this.h)}, ${Lr(this.s) * 100}%, ${Lr(this.l) * 100}%${t === 1 ? ")" : `, ${t})`}`; + } +})); +function ta(t) { + return t = (t || 0) % 360, t < 0 ? t + 360 : t; +} +function Lr(t) { + return Math.max(0, Math.min(1, t || 0)); +} +function Mi(t, e, n) { + return (t < 60 ? e + (n - e) * t / 60 : t < 180 ? n : t < 240 ? e + (n - e) * (240 - t) / 60 : e) * 255; +} +const xs = (t) => () => t; +function Ac(t, e) { + return function(n) { + return t + n * e; + }; +} +function Ec(t, e, n) { + return t = Math.pow(t, n), e = Math.pow(e, n) - t, n = 1 / n, function(r) { + return Math.pow(t + r * e, n); + }; +} +function Rc(t) { + return (t = +t) == 1 ? Co : function(e, n) { + return n - e ? Ec(e, n, t) : xs(isNaN(e) ? n : e); + }; +} +function Co(t, e) { + var n = e - t; + return n ? Ac(t, n) : xs(isNaN(t) ? e : t); +} +const ri = (function t(e) { + var n = Rc(e); + function r(i, s) { + var a = n((i = ji(i)).r, (s = ji(s)).r), o = n(i.g, s.g), l = n(i.b, s.b), u = Co(i.opacity, s.opacity); + return function(f) { + return i.r = a(f), i.g = o(f), i.b = l(f), i.opacity = u(f), i + ""; + }; + } + return r.gamma = t, r; +})(1); +function Tc(t, e) { + e || (e = []); + var n = t ? Math.min(e.length, t.length) : 0, r = e.slice(), i; + return function(s) { + for (i = 0; i < n; ++i) r[i] = t[i] * (1 - s) + e[i] * s; + return r; + }; +} +function Cc(t) { + return ArrayBuffer.isView(t) && !(t instanceof DataView); +} +function Nc(t, e) { + var n = e ? e.length : 0, r = t ? Math.min(n, t.length) : 0, i = new Array(r), s = new Array(n), a; + for (a = 0; a < r; ++a) i[a] = On(t[a], e[a]); + for (; a < n; ++a) s[a] = e[a]; + return function(o) { + for (a = 0; a < r; ++a) s[a] = i[a](o); + return s; + }; +} +function Sc(t, e) { + var n = /* @__PURE__ */ new Date(); + return t = +t, e = +e, function(r) { + return n.setTime(t * (1 - r) + e * r), n; + }; +} +function Te(t, e) { + return t = +t, e = +e, function(n) { + return t * (1 - n) + e * n; + }; +} +function kc(t, e) { + var n = {}, r = {}, i; + (t === null || typeof t != "object") && (t = {}), (e === null || typeof e != "object") && (e = {}); + for (i in e) + i in t ? n[i] = On(t[i], e[i]) : r[i] = e[i]; + return function(s) { + for (i in n) r[i] = n[i](s); + return r; + }; +} +var Zi = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Pi = new RegExp(Zi.source, "g"); +function Mc(t) { + return function() { + return t; + }; +} +function Pc(t) { + return function(e) { + return t(e) + ""; + }; +} +function No(t, e) { + var n = Zi.lastIndex = Pi.lastIndex = 0, r, i, s, a = -1, o = [], l = []; + for (t = t + "", e = e + ""; (r = Zi.exec(t)) && (i = Pi.exec(e)); ) + (s = i.index) > n && (s = e.slice(n, s), o[a] ? o[a] += s : o[++a] = s), (r = r[0]) === (i = i[0]) ? o[a] ? o[a] += i : o[++a] = i : (o[++a] = null, l.push({ i: a, x: Te(r, i) })), n = Pi.lastIndex; + return n < e.length && (s = e.slice(n), o[a] ? o[a] += s : o[++a] = s), o.length < 2 ? l[0] ? Pc(l[0].x) : Mc(e) : (e = l.length, function(u) { + for (var f = 0, h; f < e; ++f) o[(h = l[f]).i] = h.x(u); + return o.join(""); + }); +} +function On(t, e) { + var n = typeof e, r; + return e == null || n === "boolean" ? xs(e) : (n === "number" ? Te : n === "string" ? (r = Tn(e)) ? (e = r, ri) : No : e instanceof Tn ? ri : e instanceof Date ? Sc : Cc(e) ? Tc : Array.isArray(e) ? Nc : typeof e.valueOf != "function" && typeof e.toString != "function" || isNaN(e) ? kc : Te)(t, e); +} +var ea = 180 / Math.PI, Ji = { + translateX: 0, + translateY: 0, + rotate: 0, + skewX: 0, + scaleX: 1, + scaleY: 1 +}; +function So(t, e, n, r, i, s) { + var a, o, l; + return (a = Math.sqrt(t * t + e * e)) && (t /= a, e /= a), (l = t * n + e * r) && (n -= t * l, r -= e * l), (o = Math.sqrt(n * n + r * r)) && (n /= o, r /= o, l /= o), t * r < e * n && (t = -t, e = -e, l = -l, a = -a), { + translateX: i, + translateY: s, + rotate: Math.atan2(e, t) * ea, + skewX: Math.atan(l) * ea, + scaleX: a, + scaleY: o + }; +} +var qr; +function Oc(t) { + const e = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(t + ""); + return e.isIdentity ? Ji : So(e.a, e.b, e.c, e.d, e.e, e.f); +} +function Dc(t) { + return t == null || (qr || (qr = document.createElementNS("http://www.w3.org/2000/svg", "g")), qr.setAttribute("transform", t), !(t = qr.transform.baseVal.consolidate())) ? Ji : (t = t.matrix, So(t.a, t.b, t.c, t.d, t.e, t.f)); +} +function ko(t, e, n, r) { + function i(u) { + return u.length ? u.pop() + " " : ""; + } + function s(u, f, h, c, v, g) { + if (u !== h || f !== c) { + var m = v.push("translate(", null, e, null, n); + g.push({ i: m - 4, x: Te(u, h) }, { i: m - 2, x: Te(f, c) }); + } else (h || c) && v.push("translate(" + h + e + c + n); + } + function a(u, f, h, c) { + u !== f ? (u - f > 180 ? f += 360 : f - u > 180 && (u += 360), c.push({ i: h.push(i(h) + "rotate(", null, r) - 2, x: Te(u, f) })) : f && h.push(i(h) + "rotate(" + f + r); + } + function o(u, f, h, c) { + u !== f ? c.push({ i: h.push(i(h) + "skewX(", null, r) - 2, x: Te(u, f) }) : f && h.push(i(h) + "skewX(" + f + r); + } + function l(u, f, h, c, v, g) { + if (u !== h || f !== c) { + var m = v.push(i(v) + "scale(", null, ",", null, ")"); + g.push({ i: m - 4, x: Te(u, h) }, { i: m - 2, x: Te(f, c) }); + } else (h !== 1 || c !== 1) && v.push(i(v) + "scale(" + h + "," + c + ")"); + } + return function(u, f) { + var h = [], c = []; + return u = t(u), f = t(f), s(u.translateX, u.translateY, f.translateX, f.translateY, h, c), a(u.rotate, f.rotate, h, c), o(u.skewX, f.skewX, h, c), l(u.scaleX, u.scaleY, f.scaleX, f.scaleY, h, c), u = f = null, function(v) { + for (var g = -1, m = c.length, b; ++g < m; ) h[(b = c[g]).i] = b.x(v); + return h.join(""); + }; + }; +} +var Ic = ko(Oc, "px, ", "px)", "deg)"), Fc = ko(Dc, ", ", ")", ")"), Jn = 0, ur = 0, or = 0, Mo = 1e3, ii, fr, si = 0, Cn = 0, wi = 0, yr = typeof performance == "object" && performance.now ? performance : Date, Po = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(t) { + setTimeout(t, 17); +}; +function bs() { + return Cn || (Po(Lc), Cn = yr.now() + wi); +} +function Lc() { + Cn = 0; +} +function ai() { + this._call = this._time = this._next = null; +} +ai.prototype = Oo.prototype = { + constructor: ai, + restart: function(t, e, n) { + if (typeof t != "function") throw new TypeError("callback is not a function"); + n = (n == null ? bs() : +n) + (e == null ? 0 : +e), !this._next && fr !== this && (fr ? fr._next = this : ii = this, fr = this), this._call = t, this._time = n, Qi(); + }, + stop: function() { + this._call && (this._call = null, this._time = 1 / 0, Qi()); + } +}; +function Oo(t, e, n) { + var r = new ai(); + return r.restart(t, e, n), r; +} +function qc() { + bs(), ++Jn; + for (var t = ii, e; t; ) + (e = Cn - t._time) >= 0 && t._call.call(void 0, e), t = t._next; + --Jn; +} +function na() { + Cn = (si = yr.now()) + wi, Jn = ur = 0; + try { + qc(); + } finally { + Jn = 0, zc(), Cn = 0; + } +} +function Vc() { + var t = yr.now(), e = t - si; + e > Mo && (wi -= e, si = t); +} +function zc() { + for (var t, e = ii, n, r = 1 / 0; e; ) + e._call ? (r > e._time && (r = e._time), t = e, e = e._next) : (n = e._next, e._next = null, e = t ? t._next = n : ii = n); + fr = t, Qi(r); +} +function Qi(t) { + if (!Jn) { + ur && (ur = clearTimeout(ur)); + var e = t - Cn; + e > 24 ? (t < 1 / 0 && (ur = setTimeout(na, t - yr.now() - wi)), or && (or = clearInterval(or))) : (or || (si = yr.now(), or = setInterval(Vc, Mo)), Jn = 1, Po(na)); + } +} +function ra(t, e, n) { + var r = new ai(); + return e = e == null ? 0 : +e, r.restart((i) => { + r.stop(), t(i + e); + }, e, n), r; +} +var Hc = ho("start", "end", "cancel", "interrupt"), Yc = [], Do = 0, ia = 1, ts = 2, Gr = 3, sa = 4, es = 5, Kr = 6; +function xi(t, e, n, r, i, s) { + var a = t.__transition; + if (!a) t.__transition = {}; + else if (n in a) return; + Bc(t, n, { + name: e, + index: r, + // For context during callback. + group: i, + // For context during callback. + on: Hc, + tween: Yc, + time: s.time, + delay: s.delay, + duration: s.duration, + ease: s.ease, + timer: null, + state: Do + }); +} +function $s(t, e) { + var n = ve(t, e); + if (n.state > Do) throw new Error("too late; already scheduled"); + return n; +} +function Pe(t, e) { + var n = ve(t, e); + if (n.state > Gr) throw new Error("too late; already running"); + return n; +} +function ve(t, e) { + var n = t.__transition; + if (!n || !(n = n[e])) throw new Error("transition not found"); + return n; +} +function Bc(t, e, n) { + var r = t.__transition, i; + r[e] = n, n.timer = Oo(s, 0, n.time); + function s(u) { + n.state = ia, n.timer.restart(a, n.delay, n.time), n.delay <= u && a(u - n.delay); + } + function a(u) { + var f, h, c, v; + if (n.state !== ia) return l(); + for (f in r) + if (v = r[f], v.name === n.name) { + if (v.state === Gr) return ra(a); + v.state === sa ? (v.state = Kr, v.timer.stop(), v.on.call("interrupt", t, t.__data__, v.index, v.group), delete r[f]) : +f < e && (v.state = Kr, v.timer.stop(), v.on.call("cancel", t, t.__data__, v.index, v.group), delete r[f]); + } + if (ra(function() { + n.state === Gr && (n.state = sa, n.timer.restart(o, n.delay, n.time), o(u)); + }), n.state = ts, n.on.call("start", t, t.__data__, n.index, n.group), n.state === ts) { + for (n.state = Gr, i = new Array(c = n.tween.length), f = 0, h = -1; f < c; ++f) + (v = n.tween[f].value.call(t, t.__data__, n.index, n.group)) && (i[++h] = v); + i.length = h + 1; + } + } + function o(u) { + for (var f = u < n.duration ? n.ease.call(null, u / n.duration) : (n.timer.restart(l), n.state = es, 1), h = -1, c = i.length; ++h < c; ) + i[h].call(t, f); + n.state === es && (n.on.call("end", t, t.__data__, n.index, n.group), l()); + } + function l() { + n.state = Kr, n.timer.stop(), delete r[e]; + for (var u in r) return; + delete t.__transition; + } +} +function Uc(t, e) { + var n = t.__transition, r, i, s = !0, a; + if (n) { + e = e == null ? null : e + ""; + for (a in n) { + if ((r = n[a]).name !== e) { + s = !1; + continue; + } + i = r.state > ts && r.state < es, r.state = Kr, r.timer.stop(), r.on.call(i ? "interrupt" : "cancel", t, t.__data__, r.index, r.group), delete n[a]; + } + s && delete t.__transition; + } +} +function Xc(t) { + return this.each(function() { + Uc(this, t); + }); +} +function Gc(t, e) { + var n, r; + return function() { + var i = Pe(this, t), s = i.tween; + if (s !== n) { + r = n = s; + for (var a = 0, o = r.length; a < o; ++a) + if (r[a].name === e) { + r = r.slice(), r.splice(a, 1); + break; + } + } + i.tween = r; + }; +} +function Kc(t, e, n) { + var r, i; + if (typeof n != "function") throw new Error(); + return function() { + var s = Pe(this, t), a = s.tween; + if (a !== r) { + i = (r = a).slice(); + for (var o = { name: e, value: n }, l = 0, u = i.length; l < u; ++l) + if (i[l].name === e) { + i[l] = o; + break; + } + l === u && i.push(o); + } + s.tween = i; + }; +} +function Wc(t, e) { + var n = this._id; + if (t += "", arguments.length < 2) { + for (var r = ve(this.node(), n).tween, i = 0, s = r.length, a; i < s; ++i) + if ((a = r[i]).name === t) + return a.value; + return null; + } + return this.each((e == null ? Gc : Kc)(n, t, e)); +} +function As(t, e, n) { + var r = t._id; + return t.each(function() { + var i = Pe(this, r); + (i.value || (i.value = {}))[e] = n.apply(this, arguments); + }), function(i) { + return ve(i, r).value[e]; + }; +} +function Io(t, e) { + var n; + return (typeof e == "number" ? Te : e instanceof Tn ? ri : (n = Tn(e)) ? (e = n, ri) : No)(t, e); +} +function jc(t) { + return function() { + this.removeAttribute(t); + }; +} +function Zc(t) { + return function() { + this.removeAttributeNS(t.space, t.local); + }; +} +function Jc(t, e, n) { + var r, i = n + "", s; + return function() { + var a = this.getAttribute(t); + return a === i ? null : a === r ? s : s = e(r = a, n); + }; +} +function Qc(t, e, n) { + var r, i = n + "", s; + return function() { + var a = this.getAttributeNS(t.space, t.local); + return a === i ? null : a === r ? s : s = e(r = a, n); + }; +} +function th(t, e, n) { + var r, i, s; + return function() { + var a, o = n(this), l; + return o == null ? void this.removeAttribute(t) : (a = this.getAttribute(t), l = o + "", a === l ? null : a === r && l === i ? s : (i = l, s = e(r = a, o))); + }; +} +function eh(t, e, n) { + var r, i, s; + return function() { + var a, o = n(this), l; + return o == null ? void this.removeAttributeNS(t.space, t.local) : (a = this.getAttributeNS(t.space, t.local), l = o + "", a === l ? null : a === r && l === i ? s : (i = l, s = e(r = a, o))); + }; +} +function nh(t, e) { + var n = yi(t), r = n === "transform" ? Fc : Io; + return this.attrTween(t, typeof e == "function" ? (n.local ? eh : th)(n, r, As(this, "attr." + t, e)) : e == null ? (n.local ? Zc : jc)(n) : (n.local ? Qc : Jc)(n, r, e)); +} +function rh(t, e) { + return function(n) { + this.setAttribute(t, e.call(this, n)); + }; +} +function ih(t, e) { + return function(n) { + this.setAttributeNS(t.space, t.local, e.call(this, n)); + }; +} +function sh(t, e) { + var n, r; + function i() { + var s = e.apply(this, arguments); + return s !== r && (n = (r = s) && ih(t, s)), n; + } + return i._value = e, i; +} +function ah(t, e) { + var n, r; + function i() { + var s = e.apply(this, arguments); + return s !== r && (n = (r = s) && rh(t, s)), n; + } + return i._value = e, i; +} +function oh(t, e) { + var n = "attr." + t; + if (arguments.length < 2) return (n = this.tween(n)) && n._value; + if (e == null) return this.tween(n, null); + if (typeof e != "function") throw new Error(); + var r = yi(t); + return this.tween(n, (r.local ? sh : ah)(r, e)); +} +function lh(t, e) { + return function() { + $s(this, t).delay = +e.apply(this, arguments); + }; +} +function uh(t, e) { + return e = +e, function() { + $s(this, t).delay = e; + }; +} +function fh(t) { + var e = this._id; + return arguments.length ? this.each((typeof t == "function" ? lh : uh)(e, t)) : ve(this.node(), e).delay; +} +function ch(t, e) { + return function() { + Pe(this, t).duration = +e.apply(this, arguments); + }; +} +function hh(t, e) { + return e = +e, function() { + Pe(this, t).duration = e; + }; +} +function dh(t) { + var e = this._id; + return arguments.length ? this.each((typeof t == "function" ? ch : hh)(e, t)) : ve(this.node(), e).duration; +} +function ph(t, e) { + if (typeof e != "function") throw new Error(); + return function() { + Pe(this, t).ease = e; + }; +} +function vh(t) { + var e = this._id; + return arguments.length ? this.each(ph(e, t)) : ve(this.node(), e).ease; +} +function gh(t, e) { + return function() { + var n = e.apply(this, arguments); + if (typeof n != "function") throw new Error(); + Pe(this, t).ease = n; + }; +} +function _h(t) { + if (typeof t != "function") throw new Error(); + return this.each(gh(this._id, t)); +} +function mh(t) { + typeof t != "function" && (t = go(t)); + for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i) + for (var s = e[i], a = s.length, o = r[i] = [], l, u = 0; u < a; ++u) + (l = s[u]) && t.call(l, l.__data__, u, s) && o.push(l); + return new Be(r, this._parents, this._name, this._id); +} +function yh(t) { + if (t._id !== this._id) throw new Error(); + for (var e = this._groups, n = t._groups, r = e.length, i = n.length, s = Math.min(r, i), a = new Array(r), o = 0; o < s; ++o) + for (var l = e[o], u = n[o], f = l.length, h = a[o] = new Array(f), c, v = 0; v < f; ++v) + (c = l[v] || u[v]) && (h[v] = c); + for (; o < r; ++o) + a[o] = e[o]; + return new Be(a, this._parents, this._name, this._id); +} +function wh(t) { + return (t + "").trim().split(/^|\s+/).every(function(e) { + var n = e.indexOf("."); + return n >= 0 && (e = e.slice(0, n)), !e || e === "start"; + }); +} +function xh(t, e, n) { + var r, i, s = wh(e) ? $s : Pe; + return function() { + var a = s(this, t), o = a.on; + o !== r && (i = (r = o).copy()).on(e, n), a.on = i; + }; +} +function bh(t, e) { + var n = this._id; + return arguments.length < 2 ? ve(this.node(), n).on.on(t) : this.each(xh(n, t, e)); +} +function $h(t) { + return function() { + var e = this.parentNode; + for (var n in this.__transition) if (+n !== t) return; + e && e.removeChild(this); + }; +} +function Ah() { + return this.on("end.remove", $h(this._id)); +} +function Eh(t) { + var e = this._name, n = this._id; + typeof t != "function" && (t = ms(t)); + for (var r = this._groups, i = r.length, s = new Array(i), a = 0; a < i; ++a) + for (var o = r[a], l = o.length, u = s[a] = new Array(l), f, h, c = 0; c < l; ++c) + (f = o[c]) && (h = t.call(f, f.__data__, c, o)) && ("__data__" in f && (h.__data__ = f.__data__), u[c] = h, xi(u[c], e, n, c, u, ve(f, n))); + return new Be(s, this._parents, e, n); +} +function Rh(t) { + var e = this._name, n = this._id; + typeof t != "function" && (t = vo(t)); + for (var r = this._groups, i = r.length, s = [], a = [], o = 0; o < i; ++o) + for (var l = r[o], u = l.length, f, h = 0; h < u; ++h) + if (f = l[h]) { + for (var c = t.call(f, f.__data__, h, l), v, g = ve(f, n), m = 0, b = c.length; m < b; ++m) + (v = c[m]) && xi(v, e, n, m, c, g); + s.push(c), a.push(f); + } + return new Be(s, a, e, n); +} +var Th = nr.prototype.constructor; +function Ch() { + return new Th(this._groups, this._parents); +} +function Nh(t, e) { + var n, r, i; + return function() { + var s = Zn(this, t), a = (this.style.removeProperty(t), Zn(this, t)); + return s === a ? null : s === n && a === r ? i : i = e(n = s, r = a); + }; +} +function Fo(t) { + return function() { + this.style.removeProperty(t); + }; +} +function Sh(t, e, n) { + var r, i = n + "", s; + return function() { + var a = Zn(this, t); + return a === i ? null : a === r ? s : s = e(r = a, n); + }; +} +function kh(t, e, n) { + var r, i, s; + return function() { + var a = Zn(this, t), o = n(this), l = o + ""; + return o == null && (l = o = (this.style.removeProperty(t), Zn(this, t))), a === l ? null : a === r && l === i ? s : (i = l, s = e(r = a, o)); + }; +} +function Mh(t, e) { + var n, r, i, s = "style." + e, a = "end." + s, o; + return function() { + var l = Pe(this, t), u = l.on, f = l.value[s] == null ? o || (o = Fo(e)) : void 0; + (u !== n || i !== f) && (r = (n = u).copy()).on(a, i = f), l.on = r; + }; +} +function Ph(t, e, n) { + var r = (t += "") == "transform" ? Ic : Io; + return e == null ? this.styleTween(t, Nh(t, r)).on("end.style." + t, Fo(t)) : typeof e == "function" ? this.styleTween(t, kh(t, r, As(this, "style." + t, e))).each(Mh(this._id, t)) : this.styleTween(t, Sh(t, r, e), n).on("end.style." + t, null); +} +function Oh(t, e, n) { + return function(r) { + this.style.setProperty(t, e.call(this, r), n); + }; +} +function Dh(t, e, n) { + var r, i; + function s() { + var a = e.apply(this, arguments); + return a !== i && (r = (i = a) && Oh(t, a, n)), r; + } + return s._value = e, s; +} +function Ih(t, e, n) { + var r = "style." + (t += ""); + if (arguments.length < 2) return (r = this.tween(r)) && r._value; + if (e == null) return this.tween(r, null); + if (typeof e != "function") throw new Error(); + return this.tween(r, Dh(t, e, n ?? "")); +} +function Fh(t) { + return function() { + this.textContent = t; + }; +} +function Lh(t) { + return function() { + var e = t(this); + this.textContent = e ?? ""; + }; +} +function qh(t) { + return this.tween("text", typeof t == "function" ? Lh(As(this, "text", t)) : Fh(t == null ? "" : t + "")); +} +function Vh(t) { + return function(e) { + this.textContent = t.call(this, e); + }; +} +function zh(t) { + var e, n; + function r() { + var i = t.apply(this, arguments); + return i !== n && (e = (n = i) && Vh(i)), e; + } + return r._value = t, r; +} +function Hh(t) { + var e = "text"; + if (arguments.length < 1) return (e = this.tween(e)) && e._value; + if (t == null) return this.tween(e, null); + if (typeof t != "function") throw new Error(); + return this.tween(e, zh(t)); +} +function Yh() { + for (var t = this._name, e = this._id, n = Lo(), r = this._groups, i = r.length, s = 0; s < i; ++s) + for (var a = r[s], o = a.length, l, u = 0; u < o; ++u) + if (l = a[u]) { + var f = ve(l, e); + xi(l, t, n, u, a, { + time: f.time + f.delay + f.duration, + delay: 0, + duration: f.duration, + ease: f.ease + }); + } + return new Be(r, this._parents, t, n); +} +function Bh() { + var t, e, n = this, r = n._id, i = n.size(); + return new Promise(function(s, a) { + var o = { value: a }, l = { value: function() { + --i === 0 && s(); + } }; + n.each(function() { + var u = Pe(this, r), f = u.on; + f !== t && (e = (t = f).copy(), e._.cancel.push(o), e._.interrupt.push(o), e._.end.push(l)), u.on = e; + }), i === 0 && s(); + }); +} +var Uh = 0; +function Be(t, e, n, r) { + this._groups = t, this._parents = e, this._name = n, this._id = r; +} +function Wr(t) { + return nr().transition(t); +} +function Lo() { + return ++Uh; +} +var Oe = nr.prototype; +Be.prototype = Wr.prototype = { + constructor: Be, + select: Eh, + selectAll: Rh, + selectChild: Oe.selectChild, + selectChildren: Oe.selectChildren, + filter: mh, + merge: yh, + selection: Ch, + transition: Yh, + call: Oe.call, + nodes: Oe.nodes, + node: Oe.node, + size: Oe.size, + empty: Oe.empty, + each: Oe.each, + on: bh, + attr: nh, + attrTween: oh, + style: Ph, + styleTween: Ih, + text: qh, + textTween: Hh, + remove: Ah, + tween: Wc, + delay: fh, + duration: dh, + ease: vh, + easeVarying: _h, + end: Bh, + [Symbol.iterator]: Oe[Symbol.iterator] +}; +function Xh(t) { + return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; +} +var Gh = { + time: null, + // Set on use. + delay: 0, + duration: 250, + ease: Xh +}; +function Kh(t, e) { + for (var n; !(n = t.__transition) || !(n = n[e]); ) + if (!(t = t.parentNode)) + throw new Error(`transition ${e} not found`); + return n; +} +function Wh(t) { + var e, n; + t instanceof Be ? (e = t._id, t = t._name) : (e = Lo(), (n = Gh).time = bs(), t = t == null ? null : t + ""); + for (var r = this._groups, i = r.length, s = 0; s < i; ++s) + for (var a = r[s], o = a.length, l, u = 0; u < o; ++u) + (l = a[u]) && xi(l, t, e, u, a, n || Kh(l, e)); + return new Be(r, this._parents, t, e); +} +nr.prototype.interrupt = Xc; +nr.prototype.transition = Wh; +const ns = Math.PI, rs = 2 * ns, an = 1e-6, jh = rs - an; +function qo(t) { + this._ += t[0]; + for (let e = 1, n = t.length; e < n; ++e) + this._ += arguments[e] + t[e]; +} +function Zh(t) { + let e = Math.floor(t); + if (!(e >= 0)) throw new Error(`invalid digits: ${t}`); + if (e > 15) return qo; + const n = 10 ** e; + return function(r) { + this._ += r[0]; + for (let i = 1, s = r.length; i < s; ++i) + this._ += Math.round(arguments[i] * n) / n + r[i]; + }; +} +class Jh { + constructor(e) { + this._x0 = this._y0 = // start of current subpath + this._x1 = this._y1 = null, this._ = "", this._append = e == null ? qo : Zh(e); + } + moveTo(e, n) { + this._append`M${this._x0 = this._x1 = +e},${this._y0 = this._y1 = +n}`; + } + closePath() { + this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`); + } + lineTo(e, n) { + this._append`L${this._x1 = +e},${this._y1 = +n}`; + } + quadraticCurveTo(e, n, r, i) { + this._append`Q${+e},${+n},${this._x1 = +r},${this._y1 = +i}`; + } + bezierCurveTo(e, n, r, i, s, a) { + this._append`C${+e},${+n},${+r},${+i},${this._x1 = +s},${this._y1 = +a}`; + } + arcTo(e, n, r, i, s) { + if (e = +e, n = +n, r = +r, i = +i, s = +s, s < 0) throw new Error(`negative radius: ${s}`); + let a = this._x1, o = this._y1, l = r - e, u = i - n, f = a - e, h = o - n, c = f * f + h * h; + if (this._x1 === null) + this._append`M${this._x1 = e},${this._y1 = n}`; + else if (c > an) if (!(Math.abs(h * l - u * f) > an) || !s) + this._append`L${this._x1 = e},${this._y1 = n}`; + else { + let v = r - a, g = i - o, m = l * l + u * u, b = v * v + g * g, A = Math.sqrt(m), S = Math.sqrt(c), T = s * Math.tan((ns - Math.acos((m + c - b) / (2 * A * S))) / 2), D = T / S, E = T / A; + Math.abs(D - 1) > an && this._append`L${e + D * f},${n + D * h}`, this._append`A${s},${s},0,0,${+(h * v > f * g)},${this._x1 = e + E * l},${this._y1 = n + E * u}`; + } + } + arc(e, n, r, i, s, a) { + if (e = +e, n = +n, r = +r, a = !!a, r < 0) throw new Error(`negative radius: ${r}`); + let o = r * Math.cos(i), l = r * Math.sin(i), u = e + o, f = n + l, h = 1 ^ a, c = a ? i - s : s - i; + this._x1 === null ? this._append`M${u},${f}` : (Math.abs(this._x1 - u) > an || Math.abs(this._y1 - f) > an) && this._append`L${u},${f}`, r && (c < 0 && (c = c % rs + rs), c > jh ? this._append`A${r},${r},0,1,${h},${e - o},${n - l}A${r},${r},0,1,${h},${this._x1 = u},${this._y1 = f}` : c > an && this._append`A${r},${r},0,${+(c >= ns)},${h},${this._x1 = e + r * Math.cos(s)},${this._y1 = n + r * Math.sin(s)}`); + } + rect(e, n, r, i) { + this._append`M${this._x0 = this._x1 = +e},${this._y0 = this._y1 = +n}h${r = +r}v${+i}h${-r}Z`; + } + toString() { + return this._; + } +} +function Qh(t) { + for (var e = t.length / 6 | 0, n = new Array(e), r = 0; r < e; ) n[r] = "#" + t.slice(r * 6, ++r * 6); + return n; +} +const td = Qh("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"); +function Et(t) { + return function() { + return t; + }; +} +const aa = Math.abs, $t = Math.atan2, sn = Math.cos, ed = Math.max, Oi = Math.min, xe = Math.sin, Dn = Math.sqrt, Ct = 1e-12, wr = Math.PI, oi = wr / 2, jr = 2 * wr; +function nd(t) { + return t > 1 ? 0 : t < -1 ? wr : Math.acos(t); +} +function oa(t) { + return t >= 1 ? oi : t <= -1 ? -oi : Math.asin(t); +} +function rd(t) { + let e = 3; + return t.digits = function(n) { + if (!arguments.length) return e; + if (n == null) + e = null; + else { + const r = Math.floor(n); + if (!(r >= 0)) throw new RangeError(`invalid digits: ${n}`); + e = r; + } + return t; + }, () => new Jh(e); +} +function id(t) { + return t.innerRadius; +} +function sd(t) { + return t.outerRadius; +} +function ad(t) { + return t.startAngle; +} +function od(t) { + return t.endAngle; +} +function ld(t) { + return t && t.padAngle; +} +function ud(t, e, n, r, i, s, a, o) { + var l = n - t, u = r - e, f = a - i, h = o - s, c = h * l - f * u; + if (!(c * c < Ct)) + return c = (f * (e - s) - h * (t - i)) / c, [t + c * l, e + c * u]; +} +function Vr(t, e, n, r, i, s, a) { + var o = t - n, l = e - r, u = (a ? s : -s) / Dn(o * o + l * l), f = u * l, h = -u * o, c = t + f, v = e + h, g = n + f, m = r + h, b = (c + g) / 2, A = (v + m) / 2, S = g - c, T = m - v, D = S * S + T * T, E = i - s, j = c * m - g * v, it = (T < 0 ? -1 : 1) * Dn(ed(0, E * E * D - j * j)), W = (j * T - S * it) / D, nt = (-j * S - T * it) / D, ut = (j * T + S * it) / D, ft = (-j * S + T * it) / D, G = W - b, x = nt - A, P = ut - b, zt = ft - A; + return G * G + x * x > P * P + zt * zt && (W = ut, nt = ft), { + cx: W, + cy: nt, + x01: -f, + y01: -h, + x11: W * (i / E - 1), + y11: nt * (i / E - 1) + }; +} +function De() { + var t = id, e = sd, n = Et(0), r = null, i = ad, s = od, a = ld, o = null, l = rd(u); + function u() { + var f, h, c = +t.apply(this, arguments), v = +e.apply(this, arguments), g = i.apply(this, arguments) - oi, m = s.apply(this, arguments) - oi, b = aa(m - g), A = m > g; + if (o || (o = f = l()), v < c && (h = v, v = c, c = h), !(v > Ct)) o.moveTo(0, 0); + else if (b > jr - Ct) + o.moveTo(v * sn(g), v * xe(g)), o.arc(0, 0, v, g, m, !A), c > Ct && (o.moveTo(c * sn(m), c * xe(m)), o.arc(0, 0, c, m, g, A)); + else { + var S = g, T = m, D = g, E = m, j = b, it = b, W = a.apply(this, arguments) / 2, nt = W > Ct && (r ? +r.apply(this, arguments) : Dn(c * c + v * v)), ut = Oi(aa(v - c) / 2, +n.apply(this, arguments)), ft = ut, G = ut, x, P; + if (nt > Ct) { + var zt = oa(nt / c * xe(W)), tt = oa(nt / v * xe(W)); + (j -= zt * 2) > Ct ? (zt *= A ? 1 : -1, D += zt, E -= zt) : (j = 0, D = E = (g + m) / 2), (it -= tt * 2) > Ct ? (tt *= A ? 1 : -1, S += tt, T -= tt) : (it = 0, S = T = (g + m) / 2); + } + var Ht = v * sn(S), Yt = v * xe(S), ne = c * sn(E), ge = c * xe(E); + if (ut > Ct) { + var Tt = v * sn(T), _e = v * xe(T), me = c * sn(D), Xe = c * xe(D), Ot; + if (b < wr) + if (Ot = ud(Ht, Yt, me, Xe, Tt, _e, ne, ge)) { + var nn = Ht - Ot[0], rn = Yt - Ot[1], Ge = Tt - Ot[0], Bt = _e - Ot[1], ye = 1 / xe(nd((nn * Ge + rn * Bt) / (Dn(nn * nn + rn * rn) * Dn(Ge * Ge + Bt * Bt))) / 2), Sn = Dn(Ot[0] * Ot[0] + Ot[1] * Ot[1]); + ft = Oi(ut, (c - Sn) / (ye - 1)), G = Oi(ut, (v - Sn) / (ye + 1)); + } else + ft = G = 0; + } + it > Ct ? G > Ct ? (x = Vr(me, Xe, Ht, Yt, v, G, A), P = Vr(Tt, _e, ne, ge, v, G, A), o.moveTo(x.cx + x.x01, x.cy + x.y01), G < ut ? o.arc(x.cx, x.cy, G, $t(x.y01, x.x01), $t(P.y01, P.x01), !A) : (o.arc(x.cx, x.cy, G, $t(x.y01, x.x01), $t(x.y11, x.x11), !A), o.arc(0, 0, v, $t(x.cy + x.y11, x.cx + x.x11), $t(P.cy + P.y11, P.cx + P.x11), !A), o.arc(P.cx, P.cy, G, $t(P.y11, P.x11), $t(P.y01, P.x01), !A))) : (o.moveTo(Ht, Yt), o.arc(0, 0, v, S, T, !A)) : o.moveTo(Ht, Yt), !(c > Ct) || !(j > Ct) ? o.lineTo(ne, ge) : ft > Ct ? (x = Vr(ne, ge, Tt, _e, c, -ft, A), P = Vr(Ht, Yt, me, Xe, c, -ft, A), o.lineTo(x.cx + x.x01, x.cy + x.y01), ft < ut ? o.arc(x.cx, x.cy, ft, $t(x.y01, x.x01), $t(P.y01, P.x01), !A) : (o.arc(x.cx, x.cy, ft, $t(x.y01, x.x01), $t(x.y11, x.x11), !A), o.arc(0, 0, c, $t(x.cy + x.y11, x.cx + x.x11), $t(P.cy + P.y11, P.cx + P.x11), A), o.arc(P.cx, P.cy, ft, $t(P.y11, P.x11), $t(P.y01, P.x01), !A))) : o.arc(0, 0, c, E, D, A); + } + if (o.closePath(), f) return o = null, f + "" || null; + } + return u.centroid = function() { + var f = (+t.apply(this, arguments) + +e.apply(this, arguments)) / 2, h = (+i.apply(this, arguments) + +s.apply(this, arguments)) / 2 - wr / 2; + return [sn(h) * f, xe(h) * f]; + }, u.innerRadius = function(f) { + return arguments.length ? (t = typeof f == "function" ? f : Et(+f), u) : t; + }, u.outerRadius = function(f) { + return arguments.length ? (e = typeof f == "function" ? f : Et(+f), u) : e; + }, u.cornerRadius = function(f) { + return arguments.length ? (n = typeof f == "function" ? f : Et(+f), u) : n; + }, u.padRadius = function(f) { + return arguments.length ? (r = f == null ? null : typeof f == "function" ? f : Et(+f), u) : r; + }, u.startAngle = function(f) { + return arguments.length ? (i = typeof f == "function" ? f : Et(+f), u) : i; + }, u.endAngle = function(f) { + return arguments.length ? (s = typeof f == "function" ? f : Et(+f), u) : s; + }, u.padAngle = function(f) { + return arguments.length ? (a = typeof f == "function" ? f : Et(+f), u) : a; + }, u.context = function(f) { + return arguments.length ? (o = f ?? null, u) : o; + }, u; +} +function fd(t) { + return typeof t == "object" && "length" in t ? t : Array.from(t); +} +function cd(t, e) { + return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN; +} +function hd(t) { + return t; +} +function la() { + var t = hd, e = cd, n = null, r = Et(0), i = Et(jr), s = Et(0); + function a(o) { + var l, u = (o = fd(o)).length, f, h, c = 0, v = new Array(u), g = new Array(u), m = +r.apply(this, arguments), b = Math.min(jr, Math.max(-jr, i.apply(this, arguments) - m)), A, S = Math.min(Math.abs(b) / u, s.apply(this, arguments)), T = S * (b < 0 ? -1 : 1), D; + for (l = 0; l < u; ++l) + (D = g[v[l] = l] = +t(o[l], l, o)) > 0 && (c += D); + for (e != null ? v.sort(function(E, j) { + return e(g[E], g[j]); + }) : n != null && v.sort(function(E, j) { + return n(o[E], o[j]); + }), l = 0, h = c ? (b - u * T) / c : 0; l < u; ++l, m = A) + f = v[l], D = g[f], A = m + (D > 0 ? D * h : 0) + T, g[f] = { + data: o[f], + index: l, + value: D, + startAngle: m, + endAngle: A, + padAngle: S + }; + return g; + } + return a.value = function(o) { + return arguments.length ? (t = typeof o == "function" ? o : Et(+o), a) : t; + }, a.sortValues = function(o) { + return arguments.length ? (e = o, n = null, a) : e; + }, a.sort = function(o) { + return arguments.length ? (n = o, e = null, a) : n; + }, a.startAngle = function(o) { + return arguments.length ? (r = typeof o == "function" ? o : Et(+o), a) : r; + }, a.endAngle = function(o) { + return arguments.length ? (i = typeof o == "function" ? o : Et(+o), a) : i; + }, a.padAngle = function(o) { + return arguments.length ? (s = typeof o == "function" ? o : Et(+o), a) : s; + }, a; +} +function cr(t, e, n) { + this.k = t, this.x = e, this.y = n; +} +cr.prototype = { + constructor: cr, + scale: function(t) { + return t === 1 ? this : new cr(this.k * t, this.x, this.y); + }, + translate: function(t, e) { + return t === 0 & e === 0 ? this : new cr(this.k, this.x + this.k * t, this.y + this.k * e); + }, + apply: function(t) { + return [t[0] * this.k + this.x, t[1] * this.k + this.y]; + }, + applyX: function(t) { + return t * this.k + this.x; + }, + applyY: function(t) { + return t * this.k + this.y; + }, + invert: function(t) { + return [(t[0] - this.x) / this.k, (t[1] - this.y) / this.k]; + }, + invertX: function(t) { + return (t - this.x) / this.k; + }, + invertY: function(t) { + return (t - this.y) / this.k; + }, + rescaleX: function(t) { + return t.copy().domain(t.range().map(this.invertX, this).map(t.invert, t)); + }, + rescaleY: function(t) { + return t.copy().domain(t.range().map(this.invertY, this).map(t.invert, t)); + }, + toString: function() { + return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; + } +}; +cr.prototype; +var dd = /* @__PURE__ */ vu(''); +const pd = { + hash: "svelte-80ulj4", + code: `.pie-chart-svg.svelte-80ulj4 {width:100%;height:100%;max-width:700px;max-height:60vh;aspect-ratio:1 / 1; /* For a perfect circle, use 1:1 ratio */margin:0 auto;display:block;} + +@media (max-width: 768px) {.pie-chart-svg.svelte-80ulj4 {max-height:60vh;} +}` +}; +function Vo(t, e) { + os(e, !0), uo(t, pd); + let n = ue(e, "jsonData", 7), r = ue(e, "currentRound", 7, 1), i = ue(e, "mouseEventType", 15), s = ue(e, "mouseData", 15), a = ue(e, "mouseY", 15), o = ue(e, "requestRoundChange", 7, (p) => { + }), l = ue(e, "candidateColors", 23, () => []); + function u(p) { + return p.isTransfer ? `${p.label}__transfer` : p.transferIndex != null ? `${p.label}__${p.transferIndex}` : p.label; + } + const f = 800, h = 800, c = Math.min(f, h) * 0.3, v = f / 2, g = h / 2, m = "Pie", b = "Donut", A = "TextLayer", S = "url(#cross-hatch)", T = 1.15, D = 0.1, E = 750, j = 800; + function it(p) { + return "hatch-" + p.replace(/[^a-zA-Z0-9]/g, "-"); + } + let W = [], nt = [], ut = [], ft = 0, G = /* @__PURE__ */ mt( + 0 + // $state just to make it inspectable + ), x = 0; + const P = {}, zt = "No Further Rankings"; + let tt = /* @__PURE__ */ mt(null); + function Ht() { + const p = gt(w(tt)); + p.select("#" + m).remove(), p.select("#" + b).remove(), p.select("#" + A).remove(); + } + function Yt(p) { + o() && (st = p, o()(p)); + } + function ne(p) { + Ht(), ut = ge(p), W = jo(p, m, ut, v, g, 0, Tt()); + } + xu(() => { + rr(), setTimeout( + () => { + ne(r()); + }, + 0 + ); + }); + function ge(p) { + const _ = Nr(p); + return ft = rn(p), _; + } + function Tt() { + return c; + } + function _e() { + return Tt() * 1.41; + } + function me(p) { + let _ = 0; + for (let y = 1; y < p; y++) { + const M = n().results[y - 1].tallyResults; + for (let R = 0; R < M.length; R++) { + const C = M[R].transfers; + if (C) { + const k = C.exhausted; + k && (_ += Number(k)); + } + } + } + return _; + } + function Xe(p, _) { + if (p === "exhausted") return me(_); + { + const y = n().results[_ - 1].tally; + return Number(y[p]); + } + } + function Ot(p, _) { + return Xe(p, _).toLocaleString("en-US"); + } + function nn(p, _) { + return (Xe(p, _) / ft).toLocaleString("en-US", { style: "percent", minimumFractionDigits: 1 }); + } + function rn(p) { + const _ = n().results[p - 1].tally; + let y = 0; + for (let [M, R] of Object.entries(_)) + y += Number(R); + return y; + } + function Ge(p, _) { + if (!p || p < 1 || p > n().results.length) + return console.warn("In chsoenCandidates: round ${round} is out of range."), []; + const y = n().results[p - 1].tallyResults, M = []; + for (let R = 0; R < y.length; R++) { + const C = y[R][_]; + C != null && M.push(C); + } + return M; + } + function Bt(p) { + return Ge(p, "eliminated"); + } + function ye(p) { + let _ = []; + for (let y = 1; y <= p; y++) _ = _.concat(Ge(y, "elected")); + return _; + } + function Sn(p, _) { + const y = n().results[_ - 1].tallyResults; + let M = 0; + const R = y.findIndex((C) => (C == null ? void 0 : C.elected) && p == C.elected); + if (R >= 0) { + const C = y[R].transfers; + if (C) + for (let [k, I] of Object.entries(C)) M += Number(I); + } else + return 0; + return M; + } + function Nr(p) { + const _ = n().results; + let y = _[Math.max(0, p - 2)].tally; + const M = [], R = []; + for (let [k, I] of Object.entries(y)) + M.push({ label: k, value: 0 }); + y = _[p - 1].tally; + for (let k of M) { + const I = Number(y[k.label]), q = Sn(k.label, p); + q > 0 ? (R.push({ + label: k.label, + value: q, + isTransfer: !0 + }), k.value = I - q, R.push(k)) : (k.value = I, R.push(k)); + } + const C = me(p); + return R.push({ label: "exhausted", value: C }), R; + } + function rr() { + const p = gt(w(tt)).select("defs").select("#cross-hatch"); + let _ = 0; + for (let [y, M] of Object.entries(n().results[0].tally)) { + !l() || l().length === 0 ? _ < 10 ? P[y] = td[_] : P[y] = "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0") : P[y] = l()[_ % l().length], _++; + { + const R = p.clone(!0); + R.attr("id", it(y)).select("rect").attr("fill", P[y]), R.selectAll("circle").attr("fill", "#383838"); + } + } + P.exhausted = S, P["Inactive Ballots"] = S; + } + function bi() { + gt(w(tt)).select("#" + b).remove(); + } + function $(p, _) { + const y = Wr("global").duration(j); + _ && y.on("end", _), bi(), Yo(p), Zo(), Qo(0, Tt()), kr(); + } + function V(p, _) { + const y = Wr("global").duration(j); + _ && y.on("end", _), Bo(p); + } + function et(p, _) { + const y = Wr("global").duration(j); + _ && y.on("end", _), zo(p), Ho(Tt()); + } + let K = !1, rt = []; + function Q() { + kr(), K = !1, At(); + } + function At() { + if (rt.length === 0) { + st !== r() && (r() === st + 1 && st > 0 && r() <= n().results.length ? (st = r(), dt(r())) : r() >= 1 && r() <= n().results.length && (st = r(), J(G, 0), ne(r()))); + return; + } + const p = rt.shift(); + switch (p.type) { + case "round": { + const _ = p.round; + _ === st + 1 && st > 0 && _ <= n().results.length ? (st = _, dt(_)) : (_ !== st && _ >= 1 && _ <= n().results.length && (st = _, J(G, 0), ne(_)), At()); + break; + } + case "step": + kn(); + break; + } + } + function dt(p) { + if (p <= 1 || p > n().results.length) { + At(); + return; + } + K = !0, x = p, J(G, 0), $(x - 1, () => { + V(x - 1, () => { + et(x, Q); + }); + }); + } + function re() { + K || (K = !0, x = r(), ie()); + } + function ie() { + if (J( + G, + 0 + // if in the middle of "one small step" animation, reset to 0. + ), rt.length > 0) { + Q(); + return; + } + const p = x < n().results.length - 1 ? ie : Q; + $(x, () => { + V(x, () => { + x++, Yt(x), et(x, p); + }); + }); + } + ds(() => { + Ke(); + }); + let st = 0; + function Ke() { + if (st != r()) { + if (K) { + rt.push({ type: "round", round: r() }); + return; + } + st == r() - 1 && st > 0 ? bt() : se(r()), st = r(); + } + } + function se(p) { + if (K) { + rt.push({ type: "round", round: p }); + return; + } + J(G, 0), ne(p); + } + function bt() { + if (K) { + rt.push({ type: "round", round: r() }); + return; + } + if (r() <= 1) { + console.warn(`animateOneRoundFn: can't animate to round ${r()}`); + return; + } + if (x = r(), x > n().results.length) { + kr(), K = !1; + return; + } + K = !0, w(G) === 0 ? $(x - 1, () => { + V(x - 1, () => { + et(x, Q); + }); + }) : w(G) === 1 ? V(x - 1, () => { + et(x, Q); + }) : w(G) === 2 && et(x, Q), J(G, 0); + } + function kn() { + if (r() > n().results.length) { + kr(), K = !1; + return; + } + if (K) { + rt.push({ type: "step" }); + return; + } + K = !0, J(G, (w(G) + 1) % 3), x = r(), w(G) === 1 ? $(x, Q) : w(G) === 2 ? V(x, Q) : w(G) === 0 ? (x++, Yt(x), et(x, Q)) : (K = !1, console.warn("displayPhase out of range at ", w(G))); + } + function zo(p) { + ut = Nr(p), W = tl(p, m, ut, 0, Tt(), !0); + } + function Ho(p, _) { + const y = gt(w(tt)).select("#" + b), M = De().outerRadius(p).innerRadius(p - 1), R = y.selectAll(".slice"); + let C = R.size(); + function k() { + C--, C === 0 && Jo(); + } + R.select("path").transition("global").duration(E).attr("d", (I) => M(I)).on("end", (I) => k()); + } + function Yo(p) { + const _ = Xo(p, W); + nt = Ts(p, b, _, v, g, Tt(), _e(), !1, !0); + } + function Bo(p) { + const _ = Ko(p, nt, W); + nt = Cs(p, b, _, Tt(), _e(), !1); + } + function Sr(p) { + return P[p.data.label]; + } + function Uo(p) { + const _ = {}, y = n().results[p - 1].tallyResults; + for (let M = 0; M < y.length; M++) { + let R = y[M].eliminated; + if (R === void 0 && (R = y[M].elected), R === void 0) { + console.warn("getTransferVotes: Eliminated and Elected undefined..."); + continue; + } + const C = y[M].transfers; + if (C === void 0) { + console.warn("getTransferVotes: transfers undefined..."); + continue; + } + for (let [k, I] of Object.entries(C)) + _[k] === void 0 ? _[k] = Number(I) : _[k] += Number(I); + } + return _; + } + function Xo(p, _) { + const y = [], M = ft, R = n().results[p - 1].tallyResults; + for (let C = 0; C < R.length; C++) { + let k = R[C].eliminated; + if (k === void 0 && (k = R[C].elected), k === void 0) { + console.warn("MakeDonutInfo: Eliminated and Elected undefined..."); + continue; + } + const I = R[C].transfers; + if (I === void 0) { + console.warn("makeDonutInfo: transfers undefined..."); + continue; + } + let q = _.find((F) => F.data.label == k && F.data.isTransfer); + q === void 0 && (q = _.find((F) => F.data.label == k && !F.data.isTransfer)); + let B = 0; + if (q) B = q.startAngle; + else { + console.warn("makeDonutInfo: No transfers"); + continue; + } + for (let [F, U] of Object.entries(I)) { + let at; + const we = _.find((ct) => ct.data.label == F); + if (we) + at = structuredClone(we); + else if (F == "exhausted") + at = { + data: { label: F, value: Number(U) }, + value: 0, + index: 0, + startAngle: 0, + endAngle: 0, + padAngle: 0 + }; + else if (F == "residual surplus") { + console.warn("makeDonutInfo: residual surplus = ", U); + continue; + } else { + console.warn("makeDonutInfo: unrecognized name in transfers ", F); + continue; + } + const N = Number(U) / M * 2 * Math.PI; + at.startAngle = B, B = at.endAngle = B + N, at.index = C, at.data.transferIndex = C, y.push(at); + } + } + return y; + } + function Go(p, _, y) { + const M = {}; + for (let [R, C] of Object.entries(p)) { + const k = y.find((B) => R == B.data.label); + if (k === void 0) { + console.warn("getTransferStartAngles: mainPieObj not found for ", R); + continue; + } + const I = (k.startAngle + k.endAngle) / 2, q = p[k.data.label] / _ * 2 * Math.PI; + M[k.data.label] = I - q / 2; + } + return M; + } + function Ko(p, _, y) { + const M = [], R = ft, C = Uo(p), k = Go(C, R, y); + for (let [I, q] of _.entries()) { + const B = structuredClone(q), F = q.endAngle - q.startAngle, U = y.find((at) => q.data.label === at.data.label && !at.data.isTransfer); + if (U) { + const at = U.data.label; + B.startAngle = k[at], k[at] += F, B.endAngle = B.startAngle + F; + } else if (q.data.label === "exhausted") + B.startAngle = q.startAngle, B.endAngle = q.endAngle; + else { + console.warn("updateDonutInfo: unrecognized slice name ", q.data.label); + continue; + } + B.index = I, M.push(B); + } + return M; + } + function Rs(p, _, y, M, R, C) { + const I = gt(w(tt)).append("g").attr("id", A).attr("transform", `translate(${y}, ${M})`), q = De().innerRadius(R * T).outerRadius(R * T); + I.selectAll("text").data(_).enter().each(function(B) { + B.endAngle - B.startAngle < D || B.data.isTransfer || gt(this).append("g").attr("id", (F) => u(F.data)).classed("eliminated", (F) => C.includes(F.data.label) || F.data.isTransfer === !0).each(function(F, U) { + F.data.label === "exhausted" && gt(this).on("mouseenter", (at, we) => el(at)).on("mouseleave", (at, we) => nl()); + }).append("text").attr("transform", (F) => `translate(${q.centroid(F)})`).attr("text-anchor", (F) => $i(F.startAngle, F.endAngle)).text((F) => F.data.label === "exhausted" ? zt : F.data.label).append("tspan").attr("x", 0).attr("dy", "1.2em").text((F) => Ot(F.data.label, p) + " (" + nn(F.data.label, p) + ")"); + }); + } + function Wo(p, _, y, M) { + const C = gt(w(tt)).select("#" + A), k = C.selectAll("tspan"), I = C.selectAll("g").data(_, (U) => u(U.data)).classed("eliminated", (U) => M.includes(U.data.label) || U.data.isTransfer === !0), q = De().innerRadius(y * T).outerRadius(y * T + 1); + k.transition("global").duration(E).attr("transform", (U) => `translate(${q.centroid(U)})`).attr("text-anchor", (U) => $i(U.startAngle, U.endAngle)), I.select("text").transition("global").duration(E).attr("transform", (U) => `translate(${q.centroid(U)})`).attr("text-anchor", (U) => $i(U.startAngle, U.endAngle)).on("end", (U) => F()); + let B = I.size(); + function F(U) { + B--, B === 0 && (C.remove(), Rs(p, _, v, g, y, M)); + } + } + function jo(p, _, y, M, R, C, k, I = !0, q = !1) { + const F = la().sort(null).value((U) => U.value)(y); + return Ts(p, _, F, M, R, C, k, I, q), F; + } + function kr() { + gt(w(tt)).select("#" + m).selectAll(".elected").style("stroke", "yellow").style("stroke-width", "2px"); + } + function Ts(p, _, y, M, R, C, k, I, q) { + const B = Bt(p), F = ye(p), we = gt(w(tt)).attr("viewBox", `0 0 ${f} ${h}`).attr("preserveAspectRatio", "xMidYMid meet").classed("pie-chart-svg", !0).append("g").attr("id", _).attr("transform", `translate(${M}, ${R})`).selectAll(".slice").data(y).enter().append("g").attr("class", "slice").classed("eliminated", (N) => B.includes(N.data.label) || N.data.isTransfer === !0).classed("elected", (N) => F.includes(N.data.label) && !N.data.isTransfer).attr("id", (N) => u(N.data)).on("mouseenter", (N, ct) => Ei(N, ct)).on("mouseleave", (N, ct) => Ri(N, ct)), ir = De().outerRadius(k).innerRadius(C); + if (q) { + const N = De().outerRadius(C + 1).innerRadius(C); + we.append("path").attr("d", N).transition("global").duration(E).attr("d", (ct) => ir(ct)).attr("fill", (ct) => Sr(ct)).on("end", (ct) => Ai()); + } else + we.append("path").attr("d", (N) => ir(N)).attr("fill", (N) => Sr(N)), Ai(); + return I && Rs(p, y, M, R, k, B), y; + } + function Zo() { + const y = gt(w(tt)).select("#" + A).selectAll(".eliminated"); + y.size() > 0 && y.classed("finished", !0); + } + function Jo() { + const y = gt(w(tt)).select("#" + A).selectAll(".finished"); + y.size() > 0 && y.remove(); + } + function Qo(p, _) { + const R = gt(w(tt)).select("#" + m).selectAll(".eliminated"), C = De().innerRadius(p), k = De().outerRadius(_); + R.classed("finished", !0).select("path").transition("global").duration(E).attrTween("d", function(I) { + const q = On(_, p); + return function(B) { + return k.innerRadius(q(B)), k(I); + }; + }).attr("fill", (I) => `url(#${it(I.data.label)})`), R.clone(!0).classed("finished", !0).select("path").transition("global").duration(E).attrTween("d", function(I) { + const q = On(_, p); + return function(B) { + return C.outerRadius(q(B)), C(I); + }; + }).attr("fill", (I) => Sr(I)); + } + function $i(p, _) { + const y = (p + _) / 2; + return y > Math.PI * 11 / 6 || y < Math.PI * 1 / 6 || y > Math.PI * 5 / 6 && y < Math.PI * 7 / 6 ? "middle" : y < Math.PI ? "start" : "end"; + } + function Ai() { + gt(w( + tt + // force redisplay of text labels + )).select("#" + A).raise().append("g").remove(); + } + function tl(p, _, y, M, R, C) { + const I = la().sort(null).value((q) => q.value)(y); + return Cs(p, _, I, M, R, C), I; + } + function Cs(p, _, y, M, R, C) { + const k = Bt(p), I = ye(p), q = De().outerRadius(R).innerRadius(M).startAngle((N) => N.startAngle).endAngle((N) => N.endAngle), B = De().outerRadius(R).innerRadius(M), U = gt(w(tt)).select("#" + _); + U.selectAll(".slice").attr("prevStart", (N) => N.startAngle).attr("prevEnd", (N) => N.endAngle); + const at = U.selectAll(".slice").data(y, (N) => u(N.data)); + at.enter().append("g").attr("class", "slice").attr("id", (N) => u(N.data)).classed("eliminated", !0).on("mouseenter", (N, ct) => Ei(N, ct)).on("mouseleave", (N, ct) => Ri(N, ct)).append("path").attr("d", (N) => B(N)).attr("fill", (N) => Sr(N)), at.classed("eliminated", (N) => k.includes(N.data.label)).classed("elected", (N) => I.includes(N.data.label)).on("mouseenter", (N, ct) => Ei(N, ct)).on("mouseleave", (N, ct) => Ri(N, ct)); + let we = at.size(); + function ir() { + we--, we <= 0 && (Ai(), U.selectAll(".finished").remove()); + } + return at.select("path").transition("global").duration(E).attrTween("d", function(N) { + const ct = Number(gt(this.parentNode).attr("prevStart")), il = Number(gt(this.parentNode).attr("prevEnd")), sl = On(ct, N.startAngle), al = On(il, N.endAngle); + return (Ss) => (q.startAngle(sl(Ss)).endAngle(al(Ss)), q(N)); + }).on("end", ir), C && Wo(p, y, R, k), y; + } + function Ei(p, _) { + s(_.data.label), i("enter"), a(p.clientY); + } + function Ri(p, _) { + s(_.data.label), i("leave"); + } + function el(p, _) { + i("show-exhausted"), a(p.clientY); + } + function nl(p, _) { + i("hide-exhausted"); + } + var rl = { + pieColors: P, + exhaustedLabel: zt, + countExhaustedVotes: me, + getEliminatedCandidates: Bt, + getElectedCandidates: ye, + runFullAnimationFn: re, + animateOnePhaseFn: kn, + get jsonData() { + return n(); + }, + set jsonData(p) { + n(p), jt(); + }, + get currentRound() { + return r(); + }, + set currentRound(p = 1) { + r(p), jt(); + }, + get mouseEventType() { + return i(); + }, + set mouseEventType(p) { + i(p), jt(); + }, + get mouseData() { + return s(); + }, + set mouseData(p) { + s(p), jt(); + }, + get mouseY() { + return a(); + }, + set mouseY(p) { + a(p), jt(); + }, + get requestRoundChange() { + return o(); + }, + set requestRoundChange(p = (_) => { + }) { + o(p), jt(); + }, + get candidateColors() { + return l(); + }, + set candidateColors(p = []) { + l(p), jt(); + } + }, Ns = dd(); + return Br(Ns, (p) => J(tt, p), () => w(tt)), be(t, Ns), ls(rl); +} +co( + Vo, + { + jsonData: {}, + currentRound: {}, + mouseEventType: {}, + mouseData: {}, + mouseY: {}, + requestRoundChange: {}, + candidateColors: {} + }, + [], + [ + "pieColors", + "exhaustedLabel", + "countExhaustedVotes", + "getEliminatedCandidates", + "getElectedCandidates", + "runFullAnimationFn", + "animateOnePhaseFn" + ], + { mode: "open" } +); +var vd = /* @__PURE__ */ er(" ", 1), gd = /* @__PURE__ */ er("About to eliminate: ", 1), _d = /* @__PURE__ */ er(" ", 1), md = /* @__PURE__ */ er("Elected: ", 1), yd = /* @__PURE__ */ er("
", 1), wd = /* @__PURE__ */ er('


these ballots have already been eliminated.
', 1); +const xd = { + hash: "svelte-1r6y5gl", + code: `.page-container.svelte-1r6y5gl {width:95%;max-width:1800px;margin:0 auto;padding:0 20px;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;}.common-header.svelte-1r6y5gl {width:100%;margin-bottom:1rem;text-align:center;}.tooltip.svelte-1r6y5gl {position:absolute;width:max-content;text-align:left;padding:.5rem;background:#FFFFFF;color:#313639;border:1px solid #313639;border-radius:8px;pointer-events:none;font-size:0.8rem;left:50%;transform:translate(-50%);font-weight:normal;opacity:0;}.tooltip.svelte-1r6y5gl h3:where(.svelte-1r6y5gl) {text-align:center;}.animation-button-container.svelte-1r6y5gl {display:flex;justify-content:center;gap:10px;margin:0.5rem;}.pie-chart-container.svelte-1r6y5gl { + /* width: 90%; */ + /* min-width: 800px; /* Larger minimum size */width:100%; /* Change from 90% to 100% */min-width:auto; /* Remove the 800px minimum */flex-grow:0; /* Don't grow beyond specified width */margin:0 auto;margin-right:40px; /* Add extra space on right */margin-top:-3vh;}.visualizations-container.svelte-1r6y5gl {display:flex;justify-content:space-between;width:100%;padding:0 20px; + /* gap: 80px; */gap:20px; /* Reduce from 80px */} + + +/*** It looks like it is always OK to use justify-content: space-between even with no bubble viz display + +.visualizations-container { + justify-content: space-between; +} + ***/ + + + +/* width: 25%; /* Smaller percentage */ +/* flex-grow: 0; /* Don't grow beyond specified width */ +/* margin-left: 40px; /* Add extra space on left */ + +/*** Omit this if we are not using the bubble-visualization +.bubble-visualization-container { + width: 25%; + flex-grow: 0; + align-self: center; + margin: 0 auto; + margin-top: 30px; + margin-left: 40px; +} +***/ + + +/* Media query for smaller screens */ +@media (max-width: 1300px) {.visualizations-container.svelte-1r6y5gl {flex-direction:column;align-items:center;} +} + +@media (max-width: 768px) {.page-container.svelte-1r6y5gl {padding:0 10px; /* Reduce padding on smaller screens */}.visualizations-container.svelte-1r6y5gl {padding:0; /* Remove padding on small screens */} +}h3.svelte-1r6y5gl, h4.svelte-1r6y5gl {margin:0.5rem;} + +@media (max-width: 768px) {.common-header.svelte-1r6y5gl {margin-bottom:0.5rem;}h3.svelte-1r6y5gl, h4.svelte-1r6y5gl {margin:0.3rem 0;font-size:0.9rem;} + +}` +}; +function bd(t, e) { + os(e, !0), uo(t, xd); + const n = 0.85; + let r = ue(e, "electionSummary", 7), i = ue(e, "currentRound", 7, 1), s = ue(e, "requestRoundChange", 7, ($) => { + }), a = ue(e, "candidateColors", 23, () => []), o = /* @__PURE__ */ mt(null), l = /* @__PURE__ */ mt(null), u = /* @__PURE__ */ mt(""), f = /* @__PURE__ */ mt(un([])), h = /* @__PURE__ */ mt(""), c = /* @__PURE__ */ mt(""), v = /* @__PURE__ */ mt(0), g = /* @__PURE__ */ sr(() => m(r())); + function m($) { + if (typeof $ == "string") + try { + $ = JSON.parse($); + } catch (V) { + return console.error("Failed to parse JSON string:", V), {}; + } + return $ || {}; + } + function b($) { + s() ? s()($) : console.warn("onRoundChange in PieChart: requestRoundChange is null"); + } + function A() { + switch (w(h)) { + case "enter": + (($) => { + var V = Al($, 2); + J(f, V[0], !0), J(u, V[1], !0); + })(T(w(c), i())), w(o) && (w(o).style.top = String(w(v) || 20) + "px", w(o).style.opacity = String(n)); + break; + case "leave": + w(o) && (w(o).style.opacity = "0"), J(f, [], !0), J(u, ""); + break; + case "show-exhausted": + w(l) && (w(l).style.top = String(w(v) || 20) + "px", w(l).style.opacity = String(n)); + break; + case "hide-exhausted": + w(l) && (w(l).style.opacity = "0"); + break; + default: + console.log("Unknown mouse event: ", w(h)); + break; + } + } + ds(() => A()); + function S($, V) { + return $ == 1 ? V ? "vote was" : "vote will be" : V ? "votes were" : "votes will be"; + } + function T($, V) { + const et = [], K = $ === "exhausted" ? ut() : $; + let rt; + $ == "exhausted" ? rt = W(1) : rt = w(g).results[0].tally[$], et.push(`${K} started with ${rt} votes.`); + for (let Q = 1; Q <= V; Q++) { + Q === V && ($ == "exhausted" ? rt = W(V) : rt = w(g).results[V - 1].tally[$], et.push(`${K} has ${rt} votes at round ${V}.`)); + const At = w(g).results[Q - 1].tallyResults; + for (let dt = 0; dt < At.length; dt++) { + const re = At[dt].transfers, ie = At[dt].eliminated, st = At[dt].elected; + if (ie) + ie === $ && et.push(`${K} will be eliminated on round ${Q}.`); + else if ($ === st && (et.push(`${K} was elected on round ${Q}.`), re)) + for (let [se, bt] of Object.entries(re)) + et.push(`${bt} ${S(Number(bt), Q < V)} transferred to ${se} on round ${Q}.`); + const Ke = ie || st; + if (Ke) { + const se = Number(re[$]); + se && et.push(`${se} ${S(se, Q < V)} transferred from ${Ke} on round ${Q}.`); + } + } + } + return [et, K]; + } + function D() { + let $ = 0; + for (let V = 1; V <= w(g).results.length; V++) { + const et = w(g).results[V - 1].tallyResults; + for (let K = 0; K < et.length; K++) + et[K].elected && $++; + } + return $; + } + let E; + function j($) { + return E ? E.getEliminatedCandidates($) : []; + } + function it($) { + return E ? E.getElectedCandidates($) : []; + } + function W($) { + return E ? E.countExhaustedVotes($) : 0; + } + function nt() { + E && E.animateOnePhaseFn && E.animateOnePhaseFn(); + } + function ut() { + return E ? E.exhaustedLabel : ""; + } + function ft() { + return E ? E.pieColors : {}; + } + var G = { + get electionSummary() { + return r(); + }, + set electionSummary($) { + r($), jt(); + }, + get currentRound() { + return i(); + }, + set currentRound($ = 1) { + i($), jt(); + }, + get requestRoundChange() { + return s(); + }, + set requestRoundChange($ = (V) => { + }) { + s($), jt(); + }, + get candidateColors() { + return a(); + }, + set candidateColors($ = []) { + a($), jt(); + } + }, x = wd(), P = Mn(x), zt = Xt(P); + zt.__click = nt, Ut(P); + var tt = ae(P, 4), Ht = Xt(tt), Yt = Xt(Ht), ne = Xt(Yt); + Br( + Vo(ne, { + get jsonData() { + return w(g); + }, + get currentRound() { + return i(); + }, + requestRoundChange: b, + get candidateColors() { + return a(); + }, + get mouseEventType() { + return w(h); + }, + set mouseEventType($) { + J(h, $, !0); + }, + get mouseData() { + return w(c); + }, + set mouseData($) { + J(c, $, !0); + }, + get mouseY() { + return w(v); + }, + set mouseY($) { + J(v, $, !0); + } + }), + ($) => E = $, + () => E + ), Ut(Yt), Ut(Ht); + var ge = ae(Ht, 2), Tt = Xt(ge); + Ut(ge); + var _e = ae(ge, 2), me = Xt(_e); + { + var Xe = ($) => { + var V = gd(), et = ae(Mn(V)); + Si(et, 17, () => j(i()), Ni, (K, rt, Q) => { + var At = vd(), dt = Mn(At); + let re; + var ie = Xt(dt, !0); + Ut(dt); + var st = ae(dt, 2); + { + var Ke = (bt) => { + var kn = Vs(", "); + be(bt, kn); + }, se = /* @__PURE__ */ sr(() => Q < j(i()).length - 1); + Dr(st, (bt) => { + w(se) && bt(Ke); + }); + } + Pr( + (bt) => { + re = Ys(dt, "", re, bt), Pn(ie, w(rt)); + }, + [() => ({ color: ft()[w(rt)] })] + ), be(K, At); + }), be($, V); + }, Ot = /* @__PURE__ */ sr(() => j(i()).length > 0); + Dr(me, ($) => { + w(Ot) && $(Xe); + }); + } + var nn = ae(me, 2); + { + var rn = ($) => { + var V = md(), et = ae(Mn(V)); + Si(et, 17, () => it(i()), Ni, (K, rt, Q) => { + var At = _d(), dt = Mn(At); + let re; + var ie = Xt(dt, !0); + Ut(dt); + var st = ae(dt, 2); + { + var Ke = (bt) => { + var kn = Vs(", "); + be(bt, kn); + }, se = /* @__PURE__ */ sr(() => Q < it(i()).length - 1); + Dr(st, (bt) => { + w(se) && bt(Ke); + }); + } + Pr( + (bt) => { + re = Ys(dt, "", re, bt), Pn(ie, w(rt)); + }, + [() => ({ color: ft()[w(rt)] })] + ), be(K, At); + }), be($, V); + }, Ge = /* @__PURE__ */ sr(() => it(i()).length > 0); + Dr(nn, ($) => { + w(Ge) && $(rn); + }); + } + Ut(_e), Ut(tt); + var Bt = ae(tt, 2), ye = Xt(Bt), Sn = Xt(ye, !0); + Ut(ye); + var Nr = ae(ye, 2); + Si(Nr, 17, () => w(f), Ni, ($, V) => { + var et = yd(), K = Mn(et), rt = Xt(K, !0); + Ut(K), Fi(2), Pr(() => Pn(rt, w(V))), be($, et); + }), Ut(Bt), Br(Bt, ($) => J(o, $), () => w(o)); + var rr = ae(Bt, 2), bi = Xt(rr); + return Fi(2), Ut(rr), Br(rr, ($) => J(l, $), () => w(l)), Pr( + ($, V) => { + Pn(Tt, `${w(g).config.contest ?? ""}, ${$ ?? ""} to be elected, Round ${i() ?? ""}.`), Pn(Sn, w(u)), Pn(bi, `"${V ?? ""}" means all the candidates ranked on `); + }, + [D, ut] + ), be(t, x), ls(G); +} +hu(["click"]); +customElements.define("pie-chart", co( + bd, + { + electionSummary: {}, + currentRound: {}, + requestRoundChange: {}, + candidateColors: {} + }, + [], + [], + { mode: "open" } +)); diff --git a/static/pie/pie.css b/static/pie/pie.css new file mode 100644 index 00000000..a767859d --- /dev/null +++ b/static/pie/pie.css @@ -0,0 +1,5 @@ +/* TODO -- SHEL -- Pie CSS here */ +#pie-body { + max-width: 800px; + width: 100%; +} diff --git a/static/share/share.js b/static/share/share.js index 7357ecc2..059bdf94 100644 --- a/static/share/share.js +++ b/static/share/share.js @@ -20,7 +20,8 @@ function initializeOptions() ["Single Table Summary", "table"], ["Table, By Round (Interactive)", "table-by-round"], ["Table, By Round (Static)", "table-by-round-static"], - ["Table, By Candidate", "table-by-candidate"] + ["Table, By Candidate", "table-by-candidate"], + ["Pie Chart", "pie"] ]; for (const selector of ["exportVistypeSelector", "embedlyVistypeSelector"]) diff --git a/static/visualizer/tabicons/pie.png b/static/visualizer/tabicons/pie.png new file mode 100644 index 0000000000000000000000000000000000000000..51d020cc6ad56c8fe6f3b68da1a694651779675f GIT binary patch literal 2319 zcmb_ed2AF_9G9pac=$Y}*A4U=!VBcHX@C-tYSz z-|xMt8J{~kE%m8X1VPe#UQZspKWAN!B*Xug$i|iM)+6GbY9Pp?8P=76ENRF@kmQw0 zV2U}#KbDuYuuYIP5!lMZ5r{^RVK0|Q1gR95s0f0J>cXyUZ^2MSc43pV{iHwQ2E~fE zQU?<&a|2Rksl>_H%Q@(LIF2JonxJVMB5E<^~*Mp{wDfU*?FMauM0j9iuo5CUPKng+yDacrbmGc}`F zdw}Wq>w5@bcK!Z1$9;VXhvO86IdT>Zqaz{rMH_*N2q5x+p_SFqwI`J8V_LaSKDxx*u|8T1pwWjEzn$ICip;2>gAqZPyRPVq zc#!{wFzeyoGXg2o994t^PITZbD*@ceFf8sM8QCGyA}oT~8GYRQd-ce~_1GovX}gU@ z2m1v{QLPq-&C$M0Di+irfO{x`{fBV6B+hoi2ZVE{z5dT|2y5qT7aH+T4aVNxwada{ z#-`xbZ4Kkc27HJgJV1q+(&4f4YagZ+K@u~3o)H1>SGyPcJ)Q}@tCriTmAe;sv)t2~ zGt+CbMs4wl_JQ>S7TRk(n38cRJ)G`a>fOF5T<^`ImwHb1Tj)Jq`fWu+uN(-> z`DELf8H+rZ^IX4zXKS;cY+^DRc{wB65k=-|~?@1kz zOA{VX9JF)kQ8N(Ywl*h+kZ~oK`ek}k)%vF9nzV+=Ez=$EqgPT7?w#FTPYLa=I`H=V zwbLsRdS>fJXY$AEa_hTYOz2*Ab(ynm+tH1(Cz7{mQ2(B71OA%SR(*7B$hVAb9omNF z{9=zJx9vVjW(5nX_pjc5%21LP=l4FFSM_Pt-X~n?{R_o2DSrfNgT3`0F5G)+#@HiG>$f~Tskx?GD@f}(=2*tzw*76dr(K@# z*3>yO*Q_tuwBx$?*tH)fZK%sXxOLCY-*#@Ou5*5|Ce+&Vdv{Z4Td=sP1bN~3tV`!6 zgg38xrpbMwxk4}8_2r4^yQ^yLkb;e6pM_JdpGhq^ot(Mh-0+`!4E62b`1S1kk3K9wjwu(SOA?nSEV+HN dWn#&##JRRL8akw~yY + + + diff --git a/templates/pie/pie.html b/templates/pie/pie.html new file mode 100644 index 00000000..0511dd44 --- /dev/null +++ b/templates/pie/pie.html @@ -0,0 +1,9 @@ + + +{{ rawData|json_script:"rawDataId" }} + + +
+
+
+
diff --git a/templates/visualizer/visualize-embedded.html b/templates/visualizer/visualize-embedded.html index 3e966b37..84c9260b 100644 --- a/templates/visualizer/visualize-embedded.html +++ b/templates/visualizer/visualize-embedded.html @@ -13,6 +13,8 @@
{% if vistype == "sankey" %} {% include "sankey/sankey.html" %} + {% elif vistype == "pie" %} + {% include "pie/pie.html" %} {% elif vistype == "barchart-fixed" %} {% include "bargraph/barchart-fixed.html" %} {% elif vistype == "barchart-interactive" %} @@ -45,6 +47,8 @@ {% include "visualizer/common-visualizer-nonblocking.html" %} {% if vistype == "sankey" %} {% include "sankey/sankey-nonblocking.html" %} + {% elif vistype == "pie" %} + {% include "pie/pie-nonblocking.html" %} {% elif vistype == "barchart-fixed" %} {% include "bargraph/barchart-common-nonblocking.html" %} {% include "bargraph/barchart-fixed-nonblocking.html" %} diff --git a/templates/visualizer/visualize.html b/templates/visualizer/visualize.html index c0b4a920..a647dcdc 100644 --- a/templates/visualizer/visualize.html +++ b/templates/visualizer/visualize.html @@ -35,7 +35,19 @@ + + -
+
+ {% include "pie/pie.html" %} +
+
{% include "tabular/tabular-by-candidate.html" %}
@@ -156,6 +166,7 @@
{% block afterMaincontent %} {% include "visualizer/common-visualizer-nonblocking.html" %} {% include "sankey/sankey-nonblocking.html" %} + {% include "pie/pie-nonblocking.html" %} {% include "bargraph/barchart-common-nonblocking.html" %} {% include "bargraph/barchart-fixed-nonblocking.html" %} {% include "bargraph/barchart-interactive-nonblocking.html" %} diff --git a/visualizer/graph/readRCVRCJSON.py b/visualizer/graph/readRCVRCJSON.py index e1f55c17..76146f41 100644 --- a/visualizer/graph/readRCVRCJSON.py +++ b/visualizer/graph/readRCVRCJSON.py @@ -274,6 +274,7 @@ def __init__(self, data): self.parse_data(data) self.graph.create_graph_from_rounds(self.rounds) self.set_elimination_order(self.rounds, self.graph.candidates) + self.graph._raw_JSON = data def parse_data(self, data): """ Parses the JSON data, or raises an exception on failure """ diff --git a/visualizer/serializers.py b/visualizer/serializers.py index 2300a68a..b960b693 100644 --- a/visualizer/serializers.py +++ b/visualizer/serializers.py @@ -45,12 +45,14 @@ def to_representation(self, instance): embedRelativeBarUrl = reverse('visualizeEmbedly', args=(instance.slug, 'bar')) embedRelativeSankeyUrl = reverse('visualizeEmbedly', args=(instance.slug, 'sankey')) embedRelativeTableUrl = reverse('visualizeEmbedly', args=(instance.slug, 'table')) + embedRelativePieUrl = reverse('visualizeEmbedly', args=(instance.slug, 'pie')) oembedRelativeUrl = reverse('oembed') + "?url=" + visAbsoluteUrl data['visualizeUrl'] = visAbsoluteUrl data['embedUrl'] = request.build_absolute_uri(embedRelativeBarUrl) data['embedSankeyUrl'] = request.build_absolute_uri(embedRelativeSankeyUrl) data['embedTableUrl'] = request.build_absolute_uri(embedRelativeTableUrl) + data['embedPieUrl'] = request.build_absolute_uri(embedRelativePieUrl) data['oembedEndpointUrl'] = request.build_absolute_uri(oembedRelativeUrl) return data diff --git a/visualizer/tests/testLiveBrowserHeadless.py b/visualizer/tests/testLiveBrowserHeadless.py index e4d290ec..2cb7d144 100644 --- a/visualizer/tests/testLiveBrowserHeadless.py +++ b/visualizer/tests/testLiveBrowserHeadless.py @@ -186,7 +186,9 @@ def test_legacy_embedded_urls(self): "tabular-by-candidate", "tabular-by-round", "tabular-by-round-interactive", - "tabular-candidate-by-round"] + "tabular-candidate-by-round", + "pie" + ] # None of the valid vistypes have errors for vistype in validVistypes: From cb9035e5c70f5e7d78ac63f9ec21ff185e72cce1 Mon Sep 17 00:00:00 2001 From: skaphan Date: Wed, 4 Mar 2026 16:17:59 -0500 Subject: [PATCH 02/13] Use election color theme for pie chart instead of hardcoded colors Co-Authored-By: Claude Opus 4.6 --- templates/pie/pie-nonblocking.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/templates/pie/pie-nonblocking.html b/templates/pie/pie-nonblocking.html index e839d68e..8624e60b 100644 --- a/templates/pie/pie-nonblocking.html +++ b/templates/pie/pie-nonblocking.html @@ -12,12 +12,10 @@ // client browser anyway, and the pie chart component can handle it in string form. const electionSummary = document.getElementById("rawDataId").textContent; - const candidateColors = [ - "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", - "#bcbd22", "#17becf", "#aec7e8", "#ffbb78", "#98df8a", "#ff9896", "#c5b0d5", "#c49c94", - "#f7b6d2", "#c7c7c7", "#dbdb8d", "#9edae5", "#3366cc", "#dc3912", "#ff9900", "#109618", - "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395" - ]; + // Generate candidate colors from the election's color theme, + // matching the palette used by the other visualizations. + const colorGenerator = getColorGenerator(config.colorTheme); + const candidateColors = Array.from(colorGenerator({{ config.numCandidates }})); // Create the pie-chart element const pieChart = document.createElement("pie-chart"); From a7b166eec675e94994cd6cb66fc873e583a243e1 Mon Sep 17 00:00:00 2001 From: skaphan Date: Wed, 4 Mar 2026 16:59:42 -0500 Subject: [PATCH 03/13] Build pie chart data from processed Graph instead of raw JSON The pie chart was the only visualization reading graph._raw_JSON directly, bypassing config filters like excludeFinalWinnerAndEliminatedCandidate. New converter in visualizer/pie/graphToRCtab.py builds RCTab-compatible JSON from the same processed Graph that bar chart and sankey use. Co-Authored-By: Claude Opus 4.6 --- common/viewUtils.py | 2 + templates/pie/pie.html | 4 +- visualizer/pie/__init__.py | 0 visualizer/pie/graphToRCtab.py | 117 +++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 visualizer/pie/__init__.py create mode 100644 visualizer/pie/graphToRCtab.py diff --git a/common/viewUtils.py b/common/viewUtils.py index 49c13ce5..b75e1ee5 100644 --- a/common/viewUtils.py +++ b/common/viewUtils.py @@ -10,6 +10,7 @@ from visualizer.descriptors.textForWinnerUtils import as_caption from visualizer.graph.graphCreator import make_graph_with_file from visualizer.models import TextForWinner +from visualizer.pie.graphToRCtab import graph_to_rctab_json from visualizer.sankey.graphToD3 import D3Sankey from visualizer.sidecar.reader import SidecarReader from visualizer.tabular.tabular import TabulateByRoundInteractive, \ @@ -69,6 +70,7 @@ def get_data_for_graph(graph, config): 'tabularByRoundInteractive': tabularByRoundInteractive, 'graph': graph, 'rawData': graph._raw_JSON, + 'pieData': graph_to_rctab_json(graph), 'textForWinner': as_caption(config).lower(), } roundDescriberData = get_data_for_round_describer(graph, config) diff --git a/templates/pie/pie.html b/templates/pie/pie.html index 0511dd44..edb4f589 100644 --- a/templates/pie/pie.html +++ b/templates/pie/pie.html @@ -1,6 +1,6 @@ - -{{ rawData|json_script:"rawDataId" }} + +{{ pieData|json_script:"rawDataId" }}
diff --git a/visualizer/pie/__init__.py b/visualizer/pie/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/visualizer/pie/graphToRCtab.py b/visualizer/pie/graphToRCtab.py new file mode 100644 index 00000000..54a37a2d --- /dev/null +++ b/visualizer/pie/graphToRCtab.py @@ -0,0 +1,117 @@ +""" +Convert a Graph object into an RCTab-compatible JSON dict for the pie chart. + +Other rcvis visualizations (bar chart, sankey, tabular) consume GraphSummary, +which respects config options like excludeFinalWinnerAndEliminatedCandidate. +The pie chart component expects RCTab's JSON format (results/tally/tallyResults). + +This module bridges the two: it reads from the processed Graph (which already +has config filters applied) and produces the JSON structure the pie chart needs. +""" + +from visualizer import common +from visualizer.graph.rcvResult import Elimination, WinTransfer + + +def _stringify(value): + """ Convert a number to string, matching RCTab JSON convention. + Integers are formatted without decimals. """ + if isinstance(value, float) and value == int(value): + return str(int(value)) + return str(value) + + +def graph_to_rctab_json(graph): + """ + Build an RCTab-compatible JSON dict from a processed Graph. + + The Graph has already been through config filters (e.g. + excludeFinalWinnerAndEliminatedCandidate) and migrations, + so the output respects those settings. + + All candidates present in the Graph are included in the tally, + including "Inactive Ballots" and "Residual Surplus" pseudo-candidates + (the pie chart handles these by name). + + Returns a dict matching the RCtabSummary TypeScript interface. + """ + summary = graph.summarize() + num_rounds = graph.numRounds + + # Count active (real) candidates for the summary + inactive_names = {common.INACTIVE_TEXT, common.RESIDUAL_SURPLUS_TEXT} + num_active_candidates = sum(1 for c in graph.candidates if c.name not in inactive_names) + + results = [] + for round_i in range(num_rounds): + nodes_this_round = graph.nodesPerRound[round_i] + + # Build tally: candidate name -> vote count (as string) + # Include all candidates present this round (including Inactive Ballots) + tally = {} + for candidate, node in nodes_this_round.items(): + tally[candidate.name] = _stringify(node.count) + + # Build tallyResults from transfersPerRound + tally_results = [] + for transfer in graph.transfersPerRound[round_i]: + tally_result = {} + + if isinstance(transfer, Elimination): + tally_result['eliminated'] = transfer.candidate.name + elif isinstance(transfer, WinTransfer): + tally_result['elected'] = transfer.candidate.name + else: + # Plain Transfer with no election/elimination action — skip + continue + + # Build transfers dict: target candidate name -> vote count + transfers = {} + for target_candidate, count in transfer.transfersByCandidate.items(): + if count != 0: + transfers[target_candidate.name] = _stringify(count) + tally_result['transfers'] = transfers + + tally_results.append(tally_result) + + # Compute inactive ballots (exhausted choices) for the inactiveBallots field + inactive_ballots = {} + for candidate in graph.candidates: + if candidate.name == common.INACTIVE_TEXT and candidate in nodes_this_round: + exhausted = nodes_this_round[candidate].count + if exhausted > 0: + inactive_ballots['exhaustedChoices'] = _stringify(exhausted) + break + + # Threshold: RCTab has per-round threshold, rcvis stores a single value + threshold = _stringify(graph.threshold) if graph.threshold is not None else "0" + + results.append({ + 'round': round_i + 1, + 'tally': tally, + 'tallyResults': tally_results, + 'inactiveBallots': inactive_ballots, + 'threshold': threshold, + }) + + # Build summary + first_round_total = summary.rounds[0].totalActiveVotes if summary.rounds else 0 + + rctab_json = { + 'config': { + 'contest': graph.title, + }, + 'jsonFormatVersion': '1', + 'results': results, + 'summary': { + 'finalThreshold': _stringify(graph.threshold) if graph.threshold is not None else "0", + 'numCandidates': num_active_candidates, + 'numWinners': summary.numWinners, + 'totalNumBallots': _stringify(first_round_total), + }, + } + + if graph.dateString: + rctab_json['config']['date'] = graph.dateString + + return rctab_json From e9a2dace279b5f3dd36d62ca7426c0801e2f329d Mon Sep 17 00:00:00 2001 From: skaphan Date: Wed, 4 Mar 2026 18:06:05 -0500 Subject: [PATCH 04/13] Pass config options to pie chart, initialize to final round - Pass textForWinner and excludeFinalWinnerAndEliminatedCandidate - Set currentRound to numRounds so pie loads on last round - Rebuilt standalone component with new props Co-Authored-By: Claude Opus 4.6 --- static/pie/pie-chart.es.js | 4222 ++++++++++++++-------------- templates/pie/pie-nonblocking.html | 3 + 2 files changed, 2151 insertions(+), 2074 deletions(-) diff --git a/static/pie/pie-chart.es.js b/static/pie/pie-chart.es.js index a70b1317..30e857a2 100644 --- a/static/pie/pie-chart.es.js +++ b/static/pie/pie-chart.es.js @@ -1,27 +1,27 @@ -var ol = Object.defineProperty; -var ks = (t) => { +var ll = Object.defineProperty; +var zs = (t) => { throw TypeError(t); }; -var ll = (t, e, n) => e in t ? ol(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; -var ot = (t, e, n) => ll(t, typeof e != "symbol" ? e + "" : e, n), Ti = (t, e, n) => e.has(t) || ks("Cannot " + n); -var d = (t, e, n) => (Ti(t, e, "read from private field"), n ? n.call(t) : e.get(t)), L = (t, e, n) => e.has(t) ? ks("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), O = (t, e, n, r) => (Ti(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n), pt = (t, e, n) => (Ti(t, e, "access private method"), n); -var ua; -typeof window < "u" && ((ua = window.__svelte ?? (window.__svelte = {})).v ?? (ua.v = /* @__PURE__ */ new Set())).add("5"); -const ul = 1, fl = 2, cl = 16, hl = 1, dl = 4, pl = 8, vl = 16, gl = 2, is = "[", fi = "[!", ss = "]", Bn = {}, _t = Symbol(), _l = "http://www.w3.org/1999/xhtml", Di = !1; -var ha = Array.isArray, ml = Array.prototype.indexOf, Un = Array.prototype.includes, ci = Array.from, Zr = Object.keys, Jr = Object.defineProperty, mn = Object.getOwnPropertyDescriptor, yl = Object.prototype, wl = Array.prototype, xl = Object.getPrototypeOf, Ms = Object.isExtensible; -const bl = () => { +var ul = (t, e, n) => e in t ? ll(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; +var lt = (t, e, n) => ul(t, typeof e != "symbol" ? e + "" : e, n), Li = (t, e, n) => e.has(t) || zs("Cannot " + n); +var d = (t, e, n) => (Li(t, e, "read from private field"), n ? n.call(t) : e.get(t)), L = (t, e, n) => e.has(t) ? zs("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), D = (t, e, n, r) => (Li(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n), pt = (t, e, n) => (Li(t, e, "access private method"), n); +var ya; +typeof window < "u" && ((ya = window.__svelte ?? (window.__svelte = {})).v ?? (ya.v = /* @__PURE__ */ new Set())).add("5"); +const fl = 1, cl = 2, hl = 16, dl = 1, pl = 4, vl = 8, gl = 16, _l = 2, vs = "[", yi = "[!", gs = "]", nr = {}, _t = Symbol(), ml = "http://www.w3.org/1999/xhtml", Wi = !1; +var ba = Array.isArray, yl = Array.prototype.indexOf, rr = Array.prototype.includes, wi = Array.from, ai = Object.keys, oi = Object.defineProperty, Tn = Object.getOwnPropertyDescriptor, wl = Object.prototype, xl = Array.prototype, bl = Object.getPrototypeOf, Hs = Object.isExtensible; +const $l = () => { }; -function $l(t) { +function Al(t) { for (var e = 0; e < t.length; e++) t[e](); } -function da() { +function $a() { var t, e, n = new Promise((r, i) => { t = r, e = i; }); return { promise: n, resolve: t, reject: e }; } -function Al(t, e) { +function El(t, e) { if (Array.isArray(t)) return t; if (!(Symbol.iterator in t)) @@ -31,130 +31,130 @@ function Al(t, e) { if (n.push(r), n.length === e) break; return n; } -const wt = 2, vr = 4, hi = 8, pa = 1 << 24, Ue = 16, pe = 32, en = 64, va = 128, Jt = 512, vt = 1024, xt = 2048, de = 4096, Lt = 8192, He = 16384, Qn = 32768, Xn = 65536, Ps = 1 << 17, ga = 1 << 18, Nn = 1 << 19, El = 1 << 20, Ze = 1 << 25, $n = 65536, Ii = 1 << 21, as = 1 << 22, Je = 1 << 23, hr = Symbol("$state"), _a = Symbol("legacy props"), on = new class extends Error { +const xt = 2, Tr = 4, xi = 8, Aa = 1 << 24, je = 16, he = 32, on = 64, Ea = 128, jt = 512, vt = 1024, bt = 2048, ce = 4096, qt = 8192, Xe = 16384, cr = 32768, ir = 65536, Ys = 1 << 17, Ra = 1 << 18, qn = 1 << 19, Rl = 1 << 20, nn = 1 << 25, Pn = 65536, Xi = 1 << 21, _s = 1 << 22, rn = 1 << 23, Er = Symbol("$state"), Ca = Symbol("legacy props"), _n = new class extends Error { constructor() { super(...arguments); - ot(this, "name", "StaleReactionError"); - ot(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed"); + lt(this, "name", "StaleReactionError"); + lt(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed"); } -}(), Rr = 3, tr = 8; -function Rl(t) { +}(), qr = 3, hr = 8; +function Cl(t) { throw new Error("https://svelte.dev/e/lifecycle_outside_component"); } function Tl() { throw new Error("https://svelte.dev/e/async_derived_orphan"); } -function Cl(t, e, n) { +function Nl(t, e, n) { throw new Error("https://svelte.dev/e/each_key_duplicate"); } -function Nl(t) { +function Sl(t) { throw new Error("https://svelte.dev/e/effect_in_teardown"); } -function Sl() { +function kl() { throw new Error("https://svelte.dev/e/effect_in_unowned_derived"); } -function kl(t) { +function Ml(t) { throw new Error("https://svelte.dev/e/effect_orphan"); } -function Ml() { +function Pl() { throw new Error("https://svelte.dev/e/effect_update_depth_exceeded"); } -function Pl() { +function Dl() { throw new Error("https://svelte.dev/e/hydration_failed"); } -function Ol(t) { +function Fl(t) { throw new Error("https://svelte.dev/e/props_invalid_value"); } -function Dl() { +function Ol() { throw new Error("https://svelte.dev/e/state_descriptors_fixed"); } function Il() { throw new Error("https://svelte.dev/e/state_prototype_fixed"); } -function Fl() { +function Ll() { throw new Error("https://svelte.dev/e/state_unsafe_mutation"); } -function Ll() { +function ql() { throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror"); } -function di(t) { +function bi(t) { console.warn("https://svelte.dev/e/hydration_mismatch"); } -function ql() { +function Vl() { console.warn("https://svelte.dev/e/svelte_boundary_reset_noop"); } -let Z = !1; -function ze(t) { - Z = t; +let j = !1; +function We(t) { + j = t; } -let H; -function Pt(t) { +let z; +function Ft(t) { if (t === null) - throw di(), Bn; - return H = t; + throw bi(), nr; + return z = t; } -function pi() { - return Pt(/* @__PURE__ */ ke(H)); +function $i() { + return Ft(/* @__PURE__ */ Ne(z)); } -function Ut(t) { - if (Z) { - if (/* @__PURE__ */ ke(H) !== null) - throw di(), Bn; - H = t; +function Bt(t) { + if (j) { + if (/* @__PURE__ */ Ne(z) !== null) + throw bi(), nr; + z = t; } } -function Fi(t = 1) { - if (Z) { - for (var e = t, n = H; e--; ) +function Gi(t = 1) { + if (j) { + for (var e = t, n = z; e--; ) n = /** @type {TemplateNode} */ - /* @__PURE__ */ ke(n); - H = n; + /* @__PURE__ */ Ne(n); + z = n; } } -function Qr(t = !0) { - for (var e = 0, n = H; ; ) { - if (n.nodeType === tr) { +function li(t = !0) { + for (var e = 0, n = z; ; ) { + if (n.nodeType === hr) { var r = ( /** @type {Comment} */ n.data ); - if (r === ss) { + if (r === gs) { if (e === 0) return n; e -= 1; - } else (r === is || r === fi || // "[1", "[2", etc. for if blocks + } else (r === vs || r === yi || // "[1", "[2", etc. for if blocks r[0] === "[" && !isNaN(Number(r.slice(1)))) && (e += 1); } var i = ( /** @type {TemplateNode} */ - /* @__PURE__ */ ke(n) + /* @__PURE__ */ Ne(n) ); t && n.remove(), n = i; } } -function ma(t) { - if (!t || t.nodeType !== tr) - throw di(), Bn; +function Ta(t) { + if (!t || t.nodeType !== hr) + throw bi(), nr; return ( /** @type {Comment} */ t.data ); } -function ya(t) { +function Na(t) { return t === this.v; } -function Vl(t, e) { +function zl(t, e) { return t != t ? e == e : t !== e || t !== null && typeof t == "object" || typeof t == "function"; } -function wa(t) { - return !Vl(t, this.v); +function Sa(t) { + return !zl(t, this.v); } -let zl = !1, qt = null; -function Gn(t) { - qt = t; +let Hl = !1, Vt = null; +function sr(t) { + Vt = t; } -function os(t, e = !1, n) { - qt = { - p: qt, +function ms(t, e = !1, n) { + Vt = { + p: Vt, i: !1, c: null, e: null, @@ -163,52 +163,52 @@ function os(t, e = !1, n) { l: null }; } -function ls(t) { +function ys(t) { var e = ( /** @type {ComponentContext} */ - qt + Vt ), n = e.e; if (n !== null) { e.e = null; for (var r of n) - Ua(r); + eo(r); } - return t !== void 0 && (e.x = t), e.i = !0, qt = e.p, t ?? /** @type {T} */ + return t !== void 0 && (e.x = t), e.i = !0, Vt = e.p, t ?? /** @type {T} */ {}; } -function xa() { +function ka() { return !0; } -let ln = []; -function ba() { - var t = ln; - ln = [], $l(t); +let mn = []; +function Ma() { + var t = mn; + mn = [], Al(t); } -function yn(t) { - if (ln.length === 0 && !dr) { - var e = ln; +function Nn(t) { + if (mn.length === 0 && !Rr) { + var e = mn; queueMicrotask(() => { - e === ln && ba(); + e === mn && Ma(); }); } - ln.push(t); + mn.push(t); } -function Hl() { - for (; ln.length > 0; ) - ba(); +function Yl() { + for (; mn.length > 0; ) + Ma(); } -function $a(t) { +function Pa(t) { var e = X; if (e === null) - return z.f |= Je, t; - if ((e.f & Qn) === 0 && (e.f & vr) === 0) + return V.f |= rn, t; + if ((e.f & cr) === 0 && (e.f & Tr) === 0) throw t; - Kn(t, e); + ar(t, e); } -function Kn(t, e) { +function ar(t, e) { for (; e !== null; ) { - if ((e.f & va) !== 0) { - if ((e.f & Qn) === 0) + if ((e.f & Ea) !== 0) { + if ((e.f & cr) === 0) throw t; try { e.b.error(t); @@ -221,78 +221,78 @@ function Kn(t, e) { } throw t; } -const Yl = -7169; -function lt(t, e) { - t.f = t.f & Yl | e; +const Bl = -7169; +function ut(t, e) { + t.f = t.f & Bl | e; } -function us(t) { - (t.f & Jt) !== 0 || t.deps === null ? lt(t, vt) : lt(t, de); +function ws(t) { + (t.f & jt) !== 0 || t.deps === null ? ut(t, vt) : ut(t, ce); } -function Aa(t) { +function Da(t) { if (t !== null) for (const e of t) - (e.f & wt) === 0 || (e.f & $n) === 0 || (e.f ^= $n, Aa( + (e.f & xt) === 0 || (e.f & Pn) === 0 || (e.f ^= Pn, Da( /** @type {Derived} */ e.deps )); } -function Ea(t, e, n) { - (t.f & xt) !== 0 ? e.add(t) : (t.f & de) !== 0 && n.add(t), Aa(t.deps), lt(t, vt); +function Fa(t, e, n) { + (t.f & bt) !== 0 ? e.add(t) : (t.f & ce) !== 0 && n.add(t), Da(t.deps), ut(t, vt); } -const Mr = /* @__PURE__ */ new Set(); -let Y = null, yt = null, St = [], vi = null, Li = !1, dr = !1; -var Fn, Ln, hn, qn, xr, br, dn, Ie, Vn, Se, qi, Vi, Ra; -const Es = class Es { +const Yr = /* @__PURE__ */ new Set(); +let Y = null, wt = null, Mt = [], Ai = null, Ki = !1, Rr = !1; +var Kn, jn, bn, Zn, Dr, Fr, $n, ze, Jn, Te, ji, Zi, Oa; +const Os = class Os { constructor() { - L(this, Se); - ot(this, "committed", !1); + L(this, Te); + lt(this, "committed", !1); /** * The current values of any sources that are updated in this batch * They keys of this map are identical to `this.#previous` * @type {Map} */ - ot(this, "current", /* @__PURE__ */ new Map()); + lt(this, "current", /* @__PURE__ */ new Map()); /** * The values of any sources that are updated in this batch _before_ those updates took place. * They keys of this map are identical to `this.#current` * @type {Map} */ - ot(this, "previous", /* @__PURE__ */ new Map()); + lt(this, "previous", /* @__PURE__ */ new Map()); /** * When the batch is committed (and the DOM is updated), we need to remove old branches * and append new ones by calling the functions added inside (if/each/key/etc) blocks * @type {Set<() => void>} */ - L(this, Fn, /* @__PURE__ */ new Set()); + L(this, Kn, /* @__PURE__ */ new Set()); /** * If a fork is discarded, we need to destroy any effects that are no longer needed * @type {Set<(batch: Batch) => void>} */ - L(this, Ln, /* @__PURE__ */ new Set()); + L(this, jn, /* @__PURE__ */ new Set()); /** * The number of async effects that are currently in flight */ - L(this, hn, 0); + L(this, bn, 0); /** * The number of async effects that are currently in flight, _not_ inside a pending boundary */ - L(this, qn, 0); + L(this, Zn, 0); /** * A deferred that resolves when the batch is committed, used with `settled()` * TODO replace with Promise.withResolvers once supported widely enough * @type {{ promise: Promise, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null} */ - L(this, xr, null); + L(this, Dr, null); /** * Deferred effects (which run after async work has completed) that are DIRTY * @type {Set} */ - L(this, br, /* @__PURE__ */ new Set()); + L(this, Fr, /* @__PURE__ */ new Set()); /** * Deferred effects that are MAYBE_DIRTY * @type {Set} */ - L(this, dn, /* @__PURE__ */ new Set()); + L(this, $n, /* @__PURE__ */ new Set()); /** * A map of branches that still exist, but will be destroyed when this batch * is committed — we skip over these during `process`. @@ -300,19 +300,19 @@ const Es = class Es { * so they can be rescheduled if the branch survives. * @type {Map} */ - L(this, Ie, /* @__PURE__ */ new Map()); - ot(this, "is_fork", !1); - L(this, Vn, !1); + L(this, ze, /* @__PURE__ */ new Map()); + lt(this, "is_fork", !1); + L(this, Jn, !1); } is_deferred() { - return this.is_fork || d(this, qn) > 0; + return this.is_fork || d(this, Zn) > 0; } /** * Add an effect to the #skipped_branches map and reset its children * @param {Effect} effect */ skip_effect(e) { - d(this, Ie).has(e) || d(this, Ie).set(e, { d: [], m: [] }); + d(this, ze).has(e) || d(this, ze).set(e, { d: [], m: [] }); } /** * Remove an effect from the #skipped_branches map and reschedule @@ -320,13 +320,13 @@ const Es = class Es { * @param {Effect} effect */ unskip_effect(e) { - var n = d(this, Ie).get(e); + var n = d(this, ze).get(e); if (n) { - d(this, Ie).delete(e); + d(this, ze).delete(e); for (var r of n.d) - lt(r, xt), ce(r); + ut(r, bt), ue(r); for (r of n.m) - lt(r, de), ce(r); + ut(r, ce), ue(r); } } /** @@ -335,19 +335,19 @@ const Es = class Es { */ process(e) { var i; - St = [], this.apply(); + Mt = [], this.apply(); var n = [], r = []; for (const s of e) - pt(this, Se, qi).call(this, s, n, r); + pt(this, Te, ji).call(this, s, n, r); if (this.is_deferred()) { - pt(this, Se, Vi).call(this, r), pt(this, Se, Vi).call(this, n); - for (const [s, a] of d(this, Ie)) - Sa(s, a); + pt(this, Te, Zi).call(this, r), pt(this, Te, Zi).call(this, n); + for (const [s, a] of d(this, ze)) + Va(s, a); } else { - for (const s of d(this, Fn)) s(); - d(this, Fn).clear(), d(this, hn) === 0 && pt(this, Se, Ra).call(this), Y = null, Os(r), Os(n), (i = d(this, xr)) == null || i.resolve(); + for (const s of d(this, Kn)) s(); + d(this, Kn).clear(), d(this, bn) === 0 && pt(this, Te, Oa).call(this), Y = null, Bs(r), Bs(n), (i = d(this, Dr)) == null || i.resolve(); } - yt = null; + wt = null; } /** * Associate a change to a given source with the current @@ -356,63 +356,63 @@ const Es = class Es { * @param {any} value */ capture(e, n) { - n !== _t && !this.previous.has(e) && this.previous.set(e, n), (e.f & Je) === 0 && (this.current.set(e, e.v), yt == null || yt.set(e, e.v)); + n !== _t && !this.previous.has(e) && this.previous.set(e, n), (e.f & rn) === 0 && (this.current.set(e, e.v), wt == null || wt.set(e, e.v)); } activate() { Y = this, this.apply(); } deactivate() { - Y === this && (Y = null, yt = null); + Y === this && (Y = null, wt = null); } flush() { - if (this.activate(), St.length > 0) { - if (Ta(), Y !== null && Y !== this) + if (this.activate(), Mt.length > 0) { + if (Ia(), Y !== null && Y !== this) return; - } else d(this, hn) === 0 && this.process([]); + } else d(this, bn) === 0 && this.process([]); this.deactivate(); } discard() { - for (const e of d(this, Ln)) e(this); - d(this, Ln).clear(); + for (const e of d(this, jn)) e(this); + d(this, jn).clear(); } /** * * @param {boolean} blocking */ increment(e) { - O(this, hn, d(this, hn) + 1), e && O(this, qn, d(this, qn) + 1); + D(this, bn, d(this, bn) + 1), e && D(this, Zn, d(this, Zn) + 1); } /** * * @param {boolean} blocking */ decrement(e) { - O(this, hn, d(this, hn) - 1), e && O(this, qn, d(this, qn) - 1), !d(this, Vn) && (O(this, Vn, !0), yn(() => { - O(this, Vn, !1), this.is_deferred() ? St.length > 0 && this.flush() : this.revive(); + D(this, bn, d(this, bn) - 1), e && D(this, Zn, d(this, Zn) - 1), !d(this, Jn) && (D(this, Jn, !0), Nn(() => { + D(this, Jn, !1), this.is_deferred() ? Mt.length > 0 && this.flush() : this.revive(); })); } revive() { - for (const e of d(this, br)) - d(this, dn).delete(e), lt(e, xt), ce(e); - for (const e of d(this, dn)) - lt(e, de), ce(e); + for (const e of d(this, Fr)) + d(this, $n).delete(e), ut(e, bt), ue(e); + for (const e of d(this, $n)) + ut(e, ce), ue(e); this.flush(); } /** @param {() => void} fn */ oncommit(e) { - d(this, Fn).add(e); + d(this, Kn).add(e); } /** @param {(batch: Batch) => void} fn */ ondiscard(e) { - d(this, Ln).add(e); + d(this, jn).add(e); } settled() { - return (d(this, xr) ?? O(this, xr, da())).promise; + return (d(this, Dr) ?? D(this, Dr, $a())).promise; } static ensure() { if (Y === null) { - const e = Y = new Es(); - Mr.add(Y), dr || yn(() => { + const e = Y = new Os(); + Yr.add(Y), Rr || Nn(() => { Y === e && e.flush(); }); } @@ -421,19 +421,19 @@ const Es = class Es { apply() { } }; -Fn = new WeakMap(), Ln = new WeakMap(), hn = new WeakMap(), qn = new WeakMap(), xr = new WeakMap(), br = new WeakMap(), dn = new WeakMap(), Ie = new WeakMap(), Vn = new WeakMap(), Se = new WeakSet(), /** +Kn = new WeakMap(), jn = new WeakMap(), bn = new WeakMap(), Zn = new WeakMap(), Dr = new WeakMap(), Fr = new WeakMap(), $n = new WeakMap(), ze = new WeakMap(), Jn = new WeakMap(), Te = new WeakSet(), /** * Traverse the effect tree, executing effects or stashing * them for later execution as appropriate * @param {Effect} root * @param {Effect[]} effects * @param {Effect[]} render_effects */ -qi = function(e, n, r) { +ji = function(e, n, r) { e.f ^= vt; for (var i = e.first, s = null; i !== null; ) { - var a = i.f, o = (a & (pe | en)) !== 0, l = o && (a & vt) !== 0, u = l || (a & Lt) !== 0 || d(this, Ie).has(i); + var a = i.f, o = (a & (he | on)) !== 0, l = o && (a & vt) !== 0, u = l || (a & qt) !== 0 || d(this, ze).has(i); if (!u && i.fn !== null) { - o ? i.f ^= vt : s !== null && (a & (vr | hi | pa)) !== 0 ? s.b.defer_effect(i) : (a & vr) !== 0 ? n.push(i) : Tr(i) && ((a & Ue) !== 0 && d(this, dn).add(i), jn(i)); + o ? i.f ^= vt : s !== null && (a & (Tr | xi | Aa)) !== 0 ? s.b.defer_effect(i) : (a & Tr) !== 0 ? n.push(i) : Vr(i) && ((a & je) !== 0 && d(this, $n).add(i), lr(i)); var f = i.first; if (f !== null) { i = f; @@ -447,15 +447,15 @@ qi = function(e, n, r) { }, /** * @param {Effect[]} effects */ -Vi = function(e) { +Zi = function(e) { for (var n = 0; n < e.length; n += 1) - Ea(e[n], d(this, br), d(this, dn)); -}, Ra = function() { + Fa(e[n], d(this, Fr), d(this, $n)); +}, Oa = function() { var i; - if (Mr.size > 1) { + if (Yr.size > 1) { this.previous.clear(); - var e = yt, n = !0; - for (const s of Mr) { + var e = wt, n = !0; + for (const s of Yr) { if (s === this) { n = !1; continue; @@ -473,111 +473,111 @@ Vi = function(e) { continue; const o = [...s.current.keys()].filter((l) => !this.current.has(l)); if (o.length > 0) { - var r = St; - St = []; + var r = Mt; + Mt = []; const l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(); for (const f of a) - Ca(f, o, l, u); - if (St.length > 0) { + La(f, o, l, u); + if (Mt.length > 0) { Y = s, s.apply(); - for (const f of St) - pt(i = s, Se, qi).call(i, f, [], []); + for (const f of Mt) + pt(i = s, Te, ji).call(i, f, [], []); s.deactivate(); } - St = r; + Mt = r; } } - Y = null, yt = e; + Y = null, wt = e; } - this.committed = !0, Mr.delete(this); + this.committed = !0, Yr.delete(this); }; -let Ye = Es; -function jt(t) { - var e = dr; - dr = !0; +let Ge = Os; +function mt(t) { + var e = Rr; + Rr = !0; try { for (var n; ; ) { - if (Hl(), St.length === 0 && (Y == null || Y.flush(), St.length === 0)) - return vi = null, /** @type {T} */ + if (Yl(), Mt.length === 0 && (Y == null || Y.flush(), Mt.length === 0)) + return Ai = null, /** @type {T} */ n; - Ta(); + Ia(); } } finally { - dr = e; + Rr = e; } } -function Ta() { - Li = !0; +function Ia() { + Ki = !0; var t = null; try { - for (var e = 0; St.length > 0; ) { - var n = Ye.ensure(); + for (var e = 0; Mt.length > 0; ) { + var n = Ge.ensure(); if (e++ > 1e3) { var r, i; - Bl(); + Ul(); } - n.process(St), Qe.clear(); + n.process(Mt), sn.clear(); } } finally { - St = [], Li = !1, vi = null; + Mt = [], Ki = !1, Ai = null; } } -function Bl() { +function Ul() { try { - Ml(); + Pl(); } catch (t) { - Kn(t, vi); + ar(t, Ai); } } -let oe = null; -function Os(t) { +let se = null; +function Bs(t) { var e = t.length; if (e !== 0) { for (var n = 0; n < e; ) { var r = t[n++]; - if ((r.f & (He | Lt)) === 0 && Tr(r) && (oe = /* @__PURE__ */ new Set(), jn(r), r.deps === null && r.first === null && r.nodes === null && r.teardown === null && r.ac === null && Ka(r), (oe == null ? void 0 : oe.size) > 0)) { - Qe.clear(); - for (const i of oe) { - if ((i.f & (He | Lt)) !== 0) continue; + if ((r.f & (Xe | qt)) === 0 && Vr(r) && (se = /* @__PURE__ */ new Set(), lr(r), r.deps === null && r.first === null && r.nodes === null && r.teardown === null && r.ac === null && io(r), (se == null ? void 0 : se.size) > 0)) { + sn.clear(); + for (const i of se) { + if ((i.f & (Xe | qt)) !== 0) continue; const s = [i]; let a = i.parent; for (; a !== null; ) - oe.has(a) && (oe.delete(a), s.push(a)), a = a.parent; + se.has(a) && (se.delete(a), s.push(a)), a = a.parent; for (let o = s.length - 1; o >= 0; o--) { const l = s[o]; - (l.f & (He | Lt)) === 0 && jn(l); + (l.f & (Xe | qt)) === 0 && lr(l); } } - oe.clear(); + se.clear(); } } - oe = null; + se = null; } } -function Ca(t, e, n, r) { +function La(t, e, n, r) { if (!n.has(t) && (n.add(t), t.reactions !== null)) for (const i of t.reactions) { const s = i.f; - (s & wt) !== 0 ? Ca( + (s & xt) !== 0 ? La( /** @type {Derived} */ i, e, n, r - ) : (s & (as | Ue)) !== 0 && (s & xt) === 0 && Na(i, e, r) && (lt(i, xt), ce( + ) : (s & (_s | je)) !== 0 && (s & bt) === 0 && qa(i, e, r) && (ut(i, bt), ue( /** @type {Effect} */ i )); } } -function Na(t, e, n) { +function qa(t, e, n) { const r = n.get(t); if (r !== void 0) return r; if (t.deps !== null) for (const i of t.deps) { - if (Un.call(e, i)) + if (rr.call(e, i)) return !0; - if ((i.f & wt) !== 0 && Na( + if ((i.f & xt) !== 0 && qa( /** @type {Derived} */ i, e, @@ -591,41 +591,41 @@ function Na(t, e, n) { } return n.set(t, !1), !1; } -function ce(t) { - for (var e = vi = t; e.parent !== null; ) { +function ue(t) { + for (var e = Ai = t; e.parent !== null; ) { e = e.parent; var n = e.f; - if (Li && e === X && (n & Ue) !== 0 && (n & ga) === 0) + if (Ki && e === X && (n & je) !== 0 && (n & Ra) === 0) return; - if ((n & (en | pe)) !== 0) { + if ((n & (on | he)) !== 0) { if ((n & vt) === 0) return; e.f ^= vt; } } - St.push(e); + Mt.push(e); } -function Sa(t, e) { - if (!((t.f & pe) !== 0 && (t.f & vt) !== 0)) { - (t.f & xt) !== 0 ? e.d.push(t) : (t.f & de) !== 0 && e.m.push(t), lt(t, vt); +function Va(t, e) { + if (!((t.f & he) !== 0 && (t.f & vt) !== 0)) { + (t.f & bt) !== 0 ? e.d.push(t) : (t.f & ce) !== 0 && e.m.push(t), ut(t, vt); for (var n = t.first; n !== null; ) - Sa(n, e), n = n.next; + Va(n, e), n = n.next; } } -function Ul(t) { - let e = 0, n = An(0), r; +function Wl(t) { + let e = 0, n = Dn(0), r; return () => { - hs() && (w(n), ps(() => (e === 0 && (r = mi(() => t(() => pr(n)))), e += 1, () => { - yn(() => { - e -= 1, e === 0 && (r == null || r(), r = void 0, pr(n)); + $s() && (w(n), Es(() => (e === 0 && (r = Ci(() => t(() => Cr(n)))), e += 1, () => { + Nn(() => { + e -= 1, e === 0 && (r == null || r(), r = void 0, Cr(n)); }); }))); }; } -var Xl = Xn | Nn | va; +var Xl = ir | qn | Ea; function Gl(t, e, n) { new Kl(t, e, n); } -var It, $r, $e, pn, Ae, Kt, Nt, Ee, Fe, je, vn, Le, zn, gn, Hn, Yn, qe, li, ht, ka, Ma, zi, zr, Hr, Hi; +var It, Or, xe, An, be, Xt, kt, $e, He, en, En, Ye, Qn, Rn, tr, er, Be, _i, ct, za, Ha, Ji, jr, Zr, Qi; class Kl { /** * @param {TemplateNode} node @@ -633,38 +633,38 @@ class Kl { * @param {((anchor: Node) => void)} children */ constructor(e, n, r) { - L(this, ht); + L(this, ct); /** @type {Boundary | null} */ - ot(this, "parent"); - ot(this, "is_pending", !1); + lt(this, "parent"); + lt(this, "is_pending", !1); /** @type {TemplateNode} */ L(this, It); /** @type {TemplateNode | null} */ - L(this, $r, Z ? H : null); + L(this, Or, j ? z : null); /** @type {BoundaryProps} */ - L(this, $e); + L(this, xe); /** @type {((anchor: Node) => void)} */ - L(this, pn); + L(this, An); /** @type {Effect} */ - L(this, Ae); + L(this, be); /** @type {Effect | null} */ - L(this, Kt, null); + L(this, Xt, null); /** @type {Effect | null} */ - L(this, Nt, null); + L(this, kt, null); /** @type {Effect | null} */ - L(this, Ee, null); + L(this, $e, null); /** @type {DocumentFragment | null} */ - L(this, Fe, null); + L(this, He, null); /** @type {TemplateNode | null} */ - L(this, je, null); - L(this, vn, 0); - L(this, Le, 0); - L(this, zn, !1); - L(this, gn, !1); + L(this, en, null); + L(this, En, 0); + L(this, Ye, 0); + L(this, Qn, !1); + L(this, Rn, !1); /** @type {Set} */ - L(this, Hn, /* @__PURE__ */ new Set()); + L(this, tr, /* @__PURE__ */ new Set()); /** @type {Set} */ - L(this, Yn, /* @__PURE__ */ new Set()); + L(this, er, /* @__PURE__ */ new Set()); /** * A source containing the number of pending async deriveds/expressions. * Only created if `$effect.pending()` is used inside the boundary, @@ -672,38 +672,38 @@ class Kl { * calls followed by no-op flushes * @type {Source | null} */ - L(this, qe, null); - L(this, li, Ul(() => (O(this, qe, An(d(this, vn))), () => { - O(this, qe, null); + L(this, Be, null); + L(this, _i, Wl(() => (D(this, Be, Dn(d(this, En))), () => { + D(this, Be, null); }))); - O(this, It, e), O(this, $e, n), O(this, pn, r), this.parent = /** @type {Effect} */ - X.b, this.is_pending = !!d(this, $e).pending, O(this, Ae, vs(() => { - if (X.b = this, Z) { - const s = d(this, $r); - pi(), /** @type {Comment} */ - s.nodeType === tr && /** @type {Comment} */ - s.data === fi ? pt(this, ht, Ma).call(this) : (pt(this, ht, ka).call(this), d(this, Le) === 0 && (this.is_pending = !1)); + D(this, It, e), D(this, xe, n), D(this, An, r), this.parent = /** @type {Effect} */ + X.b, this.is_pending = !!d(this, xe).pending, D(this, be, Rs(() => { + if (X.b = this, j) { + const s = d(this, Or); + $i(), /** @type {Comment} */ + s.nodeType === hr && /** @type {Comment} */ + s.data === yi ? pt(this, ct, Ha).call(this) : (pt(this, ct, za).call(this), d(this, Ye) === 0 && (this.is_pending = !1)); } else { - var i = pt(this, ht, zi).call(this); + var i = pt(this, ct, Ji).call(this); try { - O(this, Kt, Zt(() => r(i))); + D(this, Xt, Kt(() => r(i))); } catch (s) { this.error(s); } - d(this, Le) > 0 ? pt(this, ht, Hr).call(this) : this.is_pending = !1; + d(this, Ye) > 0 ? pt(this, ct, Zr).call(this) : this.is_pending = !1; } return () => { var s; - (s = d(this, je)) == null || s.remove(); + (s = d(this, en)) == null || s.remove(); }; - }, Xl)), Z && O(this, It, H); + }, Xl)), j && D(this, It, z); } /** * Defer an effect inside a pending boundary until the boundary resolves * @param {Effect} effect */ defer_effect(e) { - Ea(e, d(this, Hn), d(this, Yn)); + Fa(e, d(this, tr), d(this, er)); } /** * Returns `false` if the effect exists inside a boundary whose pending snippet is shown @@ -713,7 +713,7 @@ class Kl { return !this.is_pending && (!this.parent || this.parent.is_rendered()); } has_pending_snippet() { - return !!d(this, $e).pending; + return !!d(this, xe).pending; } /** * Update the source that powers `$effect.pending()` inside this boundary, @@ -722,46 +722,46 @@ class Kl { * @param {1 | -1} d */ update_pending_count(e) { - pt(this, ht, Hi).call(this, e), O(this, vn, d(this, vn) + e), !(!d(this, qe) || d(this, zn)) && (O(this, zn, !0), yn(() => { - O(this, zn, !1), d(this, qe) && Wn(d(this, qe), d(this, vn)); + pt(this, ct, Qi).call(this, e), D(this, En, d(this, En) + e), !(!d(this, Be) || d(this, Qn)) && (D(this, Qn, !0), Nn(() => { + D(this, Qn, !1), d(this, Be) && or(d(this, Be), d(this, En)); })); } get_effect_pending() { - return d(this, li).call(this), w( + return d(this, _i).call(this), w( /** @type {Source} */ - d(this, qe) + d(this, Be) ); } /** @param {unknown} error */ error(e) { - var n = d(this, $e).onerror; - let r = d(this, $e).failed; - if (d(this, gn) || !n && !r) + var n = d(this, xe).onerror; + let r = d(this, xe).failed; + if (d(this, Rn) || !n && !r) throw e; - d(this, Kt) && (Rt(d(this, Kt)), O(this, Kt, null)), d(this, Nt) && (Rt(d(this, Nt)), O(this, Nt, null)), d(this, Ee) && (Rt(d(this, Ee)), O(this, Ee, null)), Z && (Pt( + d(this, Xt) && (Tt(d(this, Xt)), D(this, Xt, null)), d(this, kt) && (Tt(d(this, kt)), D(this, kt, null)), d(this, $e) && (Tt(d(this, $e)), D(this, $e, null)), j && (Ft( /** @type {TemplateNode} */ - d(this, $r) - ), Fi(), Pt(Qr())); + d(this, Or) + ), Gi(), Ft(li())); var i = !1, s = !1; const a = () => { if (i) { - ql(); + Vl(); return; } - i = !0, s && Ll(), Ye.ensure(), O(this, vn, 0), d(this, Ee) !== null && wn(d(this, Ee), () => { - O(this, Ee, null); - }), this.is_pending = this.has_pending_snippet(), O(this, Kt, pt(this, ht, zr).call(this, () => (O(this, gn, !1), Zt(() => d(this, pn).call(this, d(this, It)))))), d(this, Le) > 0 ? pt(this, ht, Hr).call(this) : this.is_pending = !1; + i = !0, s && ql(), Ge.ensure(), D(this, En, 0), d(this, $e) !== null && Sn(d(this, $e), () => { + D(this, $e, null); + }), this.is_pending = this.has_pending_snippet(), D(this, Xt, pt(this, ct, jr).call(this, () => (D(this, Rn, !1), Kt(() => d(this, An).call(this, d(this, It)))))), d(this, Ye) > 0 ? pt(this, ct, Zr).call(this) : this.is_pending = !1; }; - yn(() => { + Nn(() => { try { s = !0, n == null || n(e, a), s = !1; } catch (o) { - Kn(o, d(this, Ae) && d(this, Ae).parent); + ar(o, d(this, be) && d(this, be).parent); } - r && O(this, Ee, pt(this, ht, zr).call(this, () => { - Ye.ensure(), O(this, gn, !0); + r && D(this, $e, pt(this, ct, jr).call(this, () => { + Ge.ensure(), D(this, Rn, !0); try { - return Zt(() => { + return Kt(() => { r( d(this, It), () => e, @@ -769,85 +769,85 @@ class Kl { ); }); } catch (o) { - return Kn( + return ar( o, /** @type {Effect} */ - d(this, Ae).parent + d(this, be).parent ), null; } finally { - O(this, gn, !1); + D(this, Rn, !1); } })); }); } } -It = new WeakMap(), $r = new WeakMap(), $e = new WeakMap(), pn = new WeakMap(), Ae = new WeakMap(), Kt = new WeakMap(), Nt = new WeakMap(), Ee = new WeakMap(), Fe = new WeakMap(), je = new WeakMap(), vn = new WeakMap(), Le = new WeakMap(), zn = new WeakMap(), gn = new WeakMap(), Hn = new WeakMap(), Yn = new WeakMap(), qe = new WeakMap(), li = new WeakMap(), ht = new WeakSet(), ka = function() { +It = new WeakMap(), Or = new WeakMap(), xe = new WeakMap(), An = new WeakMap(), be = new WeakMap(), Xt = new WeakMap(), kt = new WeakMap(), $e = new WeakMap(), He = new WeakMap(), en = new WeakMap(), En = new WeakMap(), Ye = new WeakMap(), Qn = new WeakMap(), Rn = new WeakMap(), tr = new WeakMap(), er = new WeakMap(), Be = new WeakMap(), _i = new WeakMap(), ct = new WeakSet(), za = function() { try { - O(this, Kt, Zt(() => d(this, pn).call(this, d(this, It)))); + D(this, Xt, Kt(() => d(this, An).call(this, d(this, It)))); } catch (e) { this.error(e); } -}, Ma = function() { - const e = d(this, $e).pending; - e && (O(this, Nt, Zt(() => e(d(this, It)))), yn(() => { - var n = pt(this, ht, zi).call(this); - O(this, Kt, pt(this, ht, zr).call(this, () => (Ye.ensure(), Zt(() => d(this, pn).call(this, n))))), d(this, Le) > 0 ? pt(this, ht, Hr).call(this) : (wn( +}, Ha = function() { + const e = d(this, xe).pending; + e && (D(this, kt, Kt(() => e(d(this, It)))), Nn(() => { + var n = pt(this, ct, Ji).call(this); + D(this, Xt, pt(this, ct, jr).call(this, () => (Ge.ensure(), Kt(() => d(this, An).call(this, n))))), d(this, Ye) > 0 ? pt(this, ct, Zr).call(this) : (Sn( /** @type {Effect} */ - d(this, Nt), + d(this, kt), () => { - O(this, Nt, null); + D(this, kt, null); } ), this.is_pending = !1); })); -}, zi = function() { +}, Ji = function() { var e = d(this, It); - return this.is_pending && (O(this, je, te()), d(this, It).before(d(this, je)), e = d(this, je)), e; + return this.is_pending && (D(this, en, Jt()), d(this, It).before(d(this, en)), e = d(this, en)), e; }, /** * @param {() => Effect | null} fn */ -zr = function(e) { - var n = X, r = z, i = qt; - Ne(d(this, Ae)), ee(d(this, Ae)), Gn(d(this, Ae).ctx); +jr = function(e) { + var n = X, r = V, i = Vt; + Ce(d(this, be)), Qt(d(this, be)), sr(d(this, be).ctx); try { return e(); } catch (s) { - return $a(s), null; + return Pa(s), null; } finally { - Ne(n), ee(r), Gn(i); + Ce(n), Qt(r), sr(i); } -}, Hr = function() { +}, Zr = function() { const e = ( /** @type {(anchor: Node) => void} */ - d(this, $e).pending + d(this, xe).pending ); - d(this, Kt) !== null && (O(this, Fe, document.createDocumentFragment()), d(this, Fe).append( + d(this, Xt) !== null && (D(this, He, document.createDocumentFragment()), d(this, He).append( /** @type {TemplateNode} */ - d(this, je) - ), Za(d(this, Kt), d(this, Fe))), d(this, Nt) === null && O(this, Nt, Zt(() => e(d(this, It)))); + d(this, en) + ), oo(d(this, Xt), d(this, He))), d(this, kt) === null && D(this, kt, Kt(() => e(d(this, It)))); }, /** * Updates the pending count associated with the currently visible pending snippet, * if any, such that we can replace the snippet with content once work is done * @param {1 | -1} d */ -Hi = function(e) { +Qi = function(e) { var n; if (!this.has_pending_snippet()) { - this.parent && pt(n = this.parent, ht, Hi).call(n, e); + this.parent && pt(n = this.parent, ct, Qi).call(n, e); return; } - if (O(this, Le, d(this, Le) + e), d(this, Le) === 0) { + if (D(this, Ye, d(this, Ye) + e), d(this, Ye) === 0) { this.is_pending = !1; - for (const r of d(this, Hn)) - lt(r, xt), ce(r); - for (const r of d(this, Yn)) - lt(r, de), ce(r); - d(this, Hn).clear(), d(this, Yn).clear(), d(this, Nt) && wn(d(this, Nt), () => { - O(this, Nt, null); - }), d(this, Fe) && (d(this, It).before(d(this, Fe)), O(this, Fe, null)); + for (const r of d(this, tr)) + ut(r, bt), ue(r); + for (const r of d(this, er)) + ut(r, ce), ue(r); + d(this, tr).clear(), d(this, er).clear(), d(this, kt) && Sn(d(this, kt), () => { + D(this, kt, null); + }), d(this, He) && (d(this, It).before(d(this, He)), D(this, He, null)); } }; -function Wl(t, e, n, r) { - const i = gi; +function jl(t, e, n, r) { + const i = Ei; var s = t.filter((c) => !c.settled); if (n.length === 0 && s.length === 0) { r(e.map(i)); @@ -856,45 +856,45 @@ function Wl(t, e, n, r) { var a = Y, o = ( /** @type {Effect} */ X - ), l = jl(), u = s.length === 1 ? s[0].promise : s.length > 1 ? Promise.all(s.map((c) => c.promise)) : null; + ), l = Zl(), u = s.length === 1 ? s[0].promise : s.length > 1 ? Promise.all(s.map((c) => c.promise)) : null; function f(c) { l(); try { r(c); } catch (v) { - (o.f & He) === 0 && Kn(v, o); + (o.f & Xe) === 0 && ar(v, o); } - a == null || a.deactivate(), Yi(); + a == null || a.deactivate(), ts(); } if (n.length === 0) { u.then(() => f(e.map(i))); return; } function h() { - l(), Promise.all(n.map((c) => /* @__PURE__ */ Zl(c))).then((c) => f([...e.map(i), ...c])).catch((c) => Kn(c, o)); + l(), Promise.all(n.map((c) => /* @__PURE__ */ Jl(c))).then((c) => f([...e.map(i), ...c])).catch((c) => ar(c, o)); } u ? u.then(h) : h(); } -function jl() { - var t = X, e = z, n = qt, r = Y; +function Zl() { + var t = X, e = V, n = Vt, r = Y; return function(s = !0) { - Ne(t), ee(e), Gn(n), s && (r == null || r.activate()); + Ce(t), Qt(e), sr(n), s && (r == null || r.activate()); }; } -function Yi() { - Ne(null), ee(null), Gn(null); +function ts() { + Ce(null), Qt(null), sr(null); } // @__NO_SIDE_EFFECTS__ -function gi(t) { - var e = wt | xt, n = z !== null && (z.f & wt) !== 0 ? ( +function Ei(t) { + var e = xt | bt, n = V !== null && (V.f & xt) !== 0 ? ( /** @type {Derived} */ - z + V ) : null; - return X !== null && (X.f |= Nn), { - ctx: qt, + return X !== null && (X.f |= qn), { + ctx: Vt, deps: null, effects: null, - equals: ya, + equals: Na, f: e, fn: t, reactions: null, @@ -909,7 +909,7 @@ function gi(t) { }; } // @__NO_SIDE_EFFECTS__ -function Zl(t, e, n) { +function Jl(t, e, n) { let r = ( /** @type {Effect | null} */ X @@ -922,20 +922,20 @@ function Zl(t, e, n) { /** @type {Promise} */ /** @type {unknown} */ void 0 - ), a = An( + ), a = Dn( /** @type {V} */ _t - ), o = !z, l = /* @__PURE__ */ new Map(); - return ou(() => { + ), o = !V, l = /* @__PURE__ */ new Map(); + return lu(() => { var v; - var u = da(); + var u = $a(); s = u.promise; try { Promise.resolve(t()).then(u.resolve, u.reject).then(() => { - f === Y && f.committed && f.deactivate(), Yi(); + f === Y && f.committed && f.deactivate(), ts(); }); } catch (g) { - u.reject(g), Yi(); + u.reject(g), ts(); } var f = ( /** @type {Batch} */ @@ -943,24 +943,24 @@ function Zl(t, e, n) { ); if (o) { var h = i.is_rendered(); - i.update_pending_count(1), f.increment(h), (v = l.get(f)) == null || v.reject(on), l.delete(f), l.set(f, u); + i.update_pending_count(1), f.increment(h), (v = l.get(f)) == null || v.reject(_n), l.delete(f), l.set(f, u); } const c = (g, m = void 0) => { if (f.activate(), m) - m !== on && (a.f |= Je, Wn(a, m)); + m !== _n && (a.f |= rn, or(a, m)); else { - (a.f & Je) !== 0 && (a.f ^= Je), Wn(a, g); - for (const [b, A] of l) { + (a.f & rn) !== 0 && (a.f ^= rn), or(a, g); + for (const [b, $] of l) { if (l.delete(b), b === f) break; - A.reject(on); + $.reject(_n); } } o && (i.update_pending_count(-1), f.decrement(h)); }; u.promise.then(c, (g) => c(null, g || "unknown")); - }), iu(() => { + }), su(() => { for (const u of l.values()) - u.reject(on); + u.reject(_n); }), new Promise((u) => { function f(h) { function c() { @@ -972,30 +972,30 @@ function Zl(t, e, n) { }); } // @__NO_SIDE_EFFECTS__ -function sr(t) { - const e = /* @__PURE__ */ gi(t); - return Ja(e), e; +function Bn(t) { + const e = /* @__PURE__ */ Ei(t); + return lo(e), e; } // @__NO_SIDE_EFFECTS__ -function Pa(t) { - const e = /* @__PURE__ */ gi(t); - return e.equals = wa, e; +function Ya(t) { + const e = /* @__PURE__ */ Ei(t); + return e.equals = Sa, e; } -function Jl(t) { +function Ql(t) { var e = t.effects; if (e !== null) { t.effects = null; for (var n = 0; n < e.length; n += 1) - Rt( + Tt( /** @type {Effect} */ e[n] ); } } -function Ql(t) { +function tu(t) { for (var e = t.parent; e !== null; ) { - if ((e.f & wt) === 0) - return (e.f & He) === 0 ? ( + if ((e.f & xt) === 0) + return (e.f & Xe) === 0 ? ( /** @type {Effect} */ e ) : null; @@ -1003,127 +1003,127 @@ function Ql(t) { } return null; } -function fs(t) { +function xs(t) { var e, n = X; - Ne(Ql(t)); + Ce(tu(t)); try { - t.f &= ~$n, Jl(t), e = no(t); + t.f &= ~Pn, Ql(t), e = ho(t); } finally { - Ne(n); + Ce(n); } return e; } -function Oa(t) { - var e = fs(t); - if (!t.equals(e) && (t.wv = to(), (!(Y != null && Y.is_fork) || t.deps === null) && (t.v = e, t.deps === null))) { - lt(t, vt); +function Ba(t) { + var e = xs(t); + if (!t.equals(e) && (t.wv = fo(), (!(Y != null && Y.is_fork) || t.deps === null) && (t.v = e, t.deps === null))) { + ut(t, vt); return; } - tn || (yt !== null ? (hs() || Y != null && Y.is_fork) && yt.set(t, e) : us(t)); + an || (wt !== null ? ($s() || Y != null && Y.is_fork) && wt.set(t, e) : ws(t)); } -function tu(t) { +function eu(t) { var e, n; if (t.effects !== null) for (const r of t.effects) - (r.teardown || r.ac) && ((e = r.teardown) == null || e.call(r), (n = r.ac) == null || n.abort(on), r.teardown = bl, r.ac = null, gr(r, 0), gs(r)); + (r.teardown || r.ac) && ((e = r.teardown) == null || e.call(r), (n = r.ac) == null || n.abort(_n), r.teardown = $l, r.ac = null, Nr(r, 0), Cs(r)); } -function Da(t) { +function Ua(t) { if (t.effects !== null) for (const e of t.effects) - e.teardown && jn(e); + e.teardown && lr(e); } -let Bi = /* @__PURE__ */ new Set(); -const Qe = /* @__PURE__ */ new Map(); -let Ia = !1; -function An(t, e) { +let es = /* @__PURE__ */ new Set(); +const sn = /* @__PURE__ */ new Map(); +let Wa = !1; +function Dn(t, e) { var n = { f: 0, // TODO ideally we could skip this altogether, but it causes type errors v: t, reactions: null, - equals: ya, + equals: Na, rv: 0, wv: 0 }; return n; } // @__NO_SIDE_EFFECTS__ -function mt(t, e) { - const n = An(t); - return Ja(n), n; +function yt(t, e) { + const n = Dn(t); + return lo(n), n; } // @__NO_SIDE_EFFECTS__ -function Fa(t, e = !1, n = !0) { - const r = An(t); - return e || (r.equals = wa), r; +function Xa(t, e = !1, n = !0) { + const r = Dn(t); + return e || (r.equals = Sa), r; } -function J(t, e, n = !1) { - z !== null && // since we are untracking the function inside `$inspect.with` we need to add this check +function Q(t, e, n = !1) { + V !== null && // since we are untracking the function inside `$inspect.with` we need to add this check // to ensure we error if state is set inside an inspect effect - (!he || (z.f & Ps) !== 0) && xa() && (z.f & (wt | Ue | as | Ps)) !== 0 && (Qt === null || !Un.call(Qt, t)) && Fl(); - let r = n ? un(e) : e; - return Wn(t, r); + (!fe || (V.f & Ys) !== 0) && ka() && (V.f & (xt | je | _s | Ys)) !== 0 && (Zt === null || !rr.call(Zt, t)) && Ll(); + let r = n ? yn(e) : e; + return or(t, r); } -function Wn(t, e) { +function or(t, e) { if (!t.equals(e)) { var n = t.v; - tn ? Qe.set(t, e) : Qe.set(t, n), t.v = e; - var r = Ye.ensure(); - if (r.capture(t, n), (t.f & wt) !== 0) { + an ? sn.set(t, e) : sn.set(t, n), t.v = e; + var r = Ge.ensure(); + if (r.capture(t, n), (t.f & xt) !== 0) { const i = ( /** @type {Derived} */ t ); - (t.f & xt) !== 0 && fs(i), us(i); + (t.f & bt) !== 0 && xs(i), ws(i); } - t.wv = to(), La(t, xt), X !== null && (X.f & vt) !== 0 && (X.f & (pe | en)) === 0 && (Gt === null ? fu([t]) : Gt.push(t)), !r.is_fork && Bi.size > 0 && !Ia && eu(); + t.wv = fo(), Ga(t, bt), X !== null && (X.f & vt) !== 0 && (X.f & (he | on)) === 0 && (Wt === null ? cu([t]) : Wt.push(t)), !r.is_fork && es.size > 0 && !Wa && nu(); } return e; } -function eu() { - Ia = !1; - for (const t of Bi) - (t.f & vt) !== 0 && lt(t, de), Tr(t) && jn(t); - Bi.clear(); +function nu() { + Wa = !1; + for (const t of es) + (t.f & vt) !== 0 && ut(t, ce), Vr(t) && lr(t); + es.clear(); } -function pr(t) { - J(t, t.v + 1); +function Cr(t) { + Q(t, t.v + 1); } -function La(t, e) { +function Ga(t, e) { var n = t.reactions; if (n !== null) for (var r = n.length, i = 0; i < r; i++) { - var s = n[i], a = s.f, o = (a & xt) === 0; - if (o && lt(s, e), (a & wt) !== 0) { + var s = n[i], a = s.f, o = (a & bt) === 0; + if (o && ut(s, e), (a & xt) !== 0) { var l = ( /** @type {Derived} */ s ); - yt == null || yt.delete(l), (a & $n) === 0 && (a & Jt && (s.f |= $n), La(l, de)); - } else o && ((a & Ue) !== 0 && oe !== null && oe.add( + wt == null || wt.delete(l), (a & Pn) === 0 && (a & jt && (s.f |= Pn), Ga(l, ce)); + } else o && ((a & je) !== 0 && se !== null && se.add( /** @type {Effect} */ s - ), ce( + ), ue( /** @type {Effect} */ s )); } } -function un(t) { - if (typeof t != "object" || t === null || hr in t) +function yn(t) { + if (typeof t != "object" || t === null || Er in t) return t; - const e = xl(t); - if (e !== yl && e !== wl) + const e = bl(t); + if (e !== wl && e !== xl) return t; - var n = /* @__PURE__ */ new Map(), r = ha(t), i = /* @__PURE__ */ mt(0), s = xn, a = (o) => { - if (xn === s) + var n = /* @__PURE__ */ new Map(), r = ba(t), i = /* @__PURE__ */ yt(0), s = kn, a = (o) => { + if (kn === s) return o(); - var l = z, u = xn; - ee(null), Fs(s); + var l = V, u = kn; + Qt(null), Xs(s); var f = o(); - return ee(l), Fs(u), f; + return Qt(l), Xs(u), f; }; - return r && n.set("length", /* @__PURE__ */ mt( + return r && n.set("length", /* @__PURE__ */ yt( /** @type {any[]} */ t.length )), new Proxy( @@ -1131,31 +1131,31 @@ function un(t) { t, { defineProperty(o, l, u) { - (!("value" in u) || u.configurable === !1 || u.enumerable === !1 || u.writable === !1) && Dl(); + (!("value" in u) || u.configurable === !1 || u.enumerable === !1 || u.writable === !1) && Ol(); var f = n.get(l); return f === void 0 ? a(() => { - var h = /* @__PURE__ */ mt(u.value); + var h = /* @__PURE__ */ yt(u.value); return n.set(l, h), h; - }) : J(f, u.value, !0), !0; + }) : Q(f, u.value, !0), !0; }, deleteProperty(o, l) { var u = n.get(l); if (u === void 0) { if (l in o) { - const f = a(() => /* @__PURE__ */ mt(_t)); - n.set(l, f), pr(i); + const f = a(() => /* @__PURE__ */ yt(_t)); + n.set(l, f), Cr(i); } } else - J(u, _t), pr(i); + Q(u, _t), Cr(i); return !0; }, get(o, l, u) { var v; - if (l === hr) + if (l === Er) return t; var f = n.get(l), h = l in o; - if (f === void 0 && (!h || (v = mn(o, l)) != null && v.writable) && (f = a(() => { - var g = un(h ? o[l] : _t), m = /* @__PURE__ */ mt(g); + if (f === void 0 && (!h || (v = Tn(o, l)) != null && v.writable) && (f = a(() => { + var g = yn(h ? o[l] : _t), m = /* @__PURE__ */ yt(g); return m; }), n.set(l, f)), f !== void 0) { var c = w(f); @@ -1182,12 +1182,12 @@ function un(t) { }, has(o, l) { var c; - if (l === hr) + if (l === Er) return !0; var u = n.get(l), f = u !== void 0 && u.v !== _t || Reflect.has(o, l); - if (u !== void 0 || X !== null && (!f || (c = mn(o, l)) != null && c.writable)) { + if (u !== void 0 || X !== null && (!f || (c = Tn(o, l)) != null && c.writable)) { u === void 0 && (u = a(() => { - var v = f ? un(o[l]) : _t, g = /* @__PURE__ */ mt(v); + var v = f ? yn(o[l]) : _t, g = /* @__PURE__ */ yt(v); return g; }), n.set(l, u)); var h = w(u); @@ -1203,25 +1203,25 @@ function un(t) { for (var v = u; v < /** @type {Source} */ h.v; v += 1) { var g = n.get(v + ""); - g !== void 0 ? J(g, _t) : v in o && (g = a(() => /* @__PURE__ */ mt(_t)), n.set(v + "", g)); + g !== void 0 ? Q(g, _t) : v in o && (g = a(() => /* @__PURE__ */ yt(_t)), n.set(v + "", g)); } if (h === void 0) - (!c || (T = mn(o, l)) != null && T.writable) && (h = a(() => /* @__PURE__ */ mt(void 0)), J(h, un(u)), n.set(l, h)); + (!c || (T = Tn(o, l)) != null && T.writable) && (h = a(() => /* @__PURE__ */ yt(void 0)), Q(h, yn(u)), n.set(l, h)); else { c = h.v !== _t; - var m = a(() => un(u)); - J(h, m); + var m = a(() => yn(u)); + Q(h, m); } var b = Reflect.getOwnPropertyDescriptor(o, l); if (b != null && b.set && b.set.call(f, u), !c) { if (r && typeof l == "string") { - var A = ( + var $ = ( /** @type {Source} */ n.get("length") - ), S = Number(l); - Number.isInteger(S) && S >= A.v && J(A, S + 1); + ), C = Number(l); + Number.isInteger(C) && C >= $.v && Q($, C + 1); } - pr(i); + Cr(i); } return !0; }, @@ -1241,129 +1241,129 @@ function un(t) { } ); } -var Ds, qa, Va, za; -function Ui() { - if (Ds === void 0) { - Ds = window, qa = /Firefox/.test(navigator.userAgent); +var Us, Ka, ja, Za; +function ns() { + if (Us === void 0) { + Us = window, Ka = /Firefox/.test(navigator.userAgent); var t = Element.prototype, e = Node.prototype, n = Text.prototype; - Va = mn(e, "firstChild").get, za = mn(e, "nextSibling").get, Ms(t) && (t.__click = void 0, t.__className = void 0, t.__attributes = null, t.__style = void 0, t.__e = void 0), Ms(n) && (n.__t = void 0); + ja = Tn(e, "firstChild").get, Za = Tn(e, "nextSibling").get, Hs(t) && (t.__click = void 0, t.__className = void 0, t.__attributes = null, t.__style = void 0, t.__e = void 0), Hs(n) && (n.__t = void 0); } } -function te(t = "") { +function Jt(t = "") { return document.createTextNode(t); } // @__NO_SIDE_EFFECTS__ -function En(t) { +function Fn(t) { return ( /** @type {TemplateNode | null} */ - Va.call(t) + ja.call(t) ); } // @__NO_SIDE_EFFECTS__ -function ke(t) { +function Ne(t) { return ( /** @type {TemplateNode | null} */ - za.call(t) + Za.call(t) ); } -function Xt(t, e) { - if (!Z) - return /* @__PURE__ */ En(t); - var n = /* @__PURE__ */ En(H); +function Ut(t, e) { + if (!j) + return /* @__PURE__ */ Fn(t); + var n = /* @__PURE__ */ Fn(z); if (n === null) - n = H.appendChild(te()); - else if (e && n.nodeType !== Rr) { - var r = te(); - return n == null || n.before(r), Pt(r), r; + n = z.appendChild(Jt()); + else if (e && n.nodeType !== qr) { + var r = Jt(); + return n == null || n.before(r), Ft(r), r; } - return e && _i( + return e && Ri( /** @type {Text} */ n - ), Pt(n), n; + ), Ft(n), n; } -function Mn(t, e = !1) { - if (!Z) { - var n = /* @__PURE__ */ En(t); - return n instanceof Comment && n.data === "" ? /* @__PURE__ */ ke(n) : n; +function dn(t, e = !1) { + if (!j) { + var n = /* @__PURE__ */ Fn(t); + return n instanceof Comment && n.data === "" ? /* @__PURE__ */ Ne(n) : n; } if (e) { - if ((H == null ? void 0 : H.nodeType) !== Rr) { - var r = te(); - return H == null || H.before(r), Pt(r), r; + if ((z == null ? void 0 : z.nodeType) !== qr) { + var r = Jt(); + return z == null || z.before(r), Ft(r), r; } - _i( + Ri( /** @type {Text} */ - H + z ); } - return H; + return z; } -function ae(t, e = 1, n = !1) { - let r = Z ? H : t; +function ie(t, e = 1, n = !1) { + let r = j ? z : t; for (var i; e--; ) i = r, r = /** @type {TemplateNode} */ - /* @__PURE__ */ ke(r); - if (!Z) + /* @__PURE__ */ Ne(r); + if (!j) return r; if (n) { - if ((r == null ? void 0 : r.nodeType) !== Rr) { - var s = te(); - return r === null ? i == null || i.after(s) : r.before(s), Pt(s), s; + if ((r == null ? void 0 : r.nodeType) !== qr) { + var s = Jt(); + return r === null ? i == null || i.after(s) : r.before(s), Ft(s), s; } - _i( + Ri( /** @type {Text} */ r ); } - return Pt(r), r; + return Ft(r), r; } -function Ha(t) { +function Ja(t) { t.textContent = ""; } -function Ya() { +function Qa() { return !1; } -function cs(t, e, n) { +function bs(t, e, n) { return ( /** @type {T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] : Element} */ - document.createElementNS(_l, t, void 0) + document.createElementNS(ml, t, void 0) ); } -function _i(t) { +function Ri(t) { if ( /** @type {string} */ t.nodeValue.length < 65536 ) return; let e = t.nextSibling; - for (; e !== null && e.nodeType === Rr; ) + for (; e !== null && e.nodeType === qr; ) e.remove(), t.nodeValue += /** @type {string} */ e.nodeValue, e = t.nextSibling; } -function Ba(t) { - var e = z, n = X; - ee(null), Ne(null); +function to(t) { + var e = V, n = X; + Qt(null), Ce(null); try { return t(); } finally { - ee(e), Ne(n); + Qt(e), Ce(n); } } -function nu(t) { - X === null && (z === null && kl(), Sl()), tn && Nl(); +function ru(t) { + X === null && (V === null && Ml(), kl()), an && Sl(); } -function ru(t, e) { +function iu(t, e) { var n = e.last; n === null ? e.last = e.first = t : (n.next = t, t.prev = n, e.last = t); } -function Me(t, e, n) { +function Se(t, e, n) { var r = X; - r !== null && (r.f & Lt) !== 0 && (t |= Lt); + r !== null && (r.f & qt) !== 0 && (t |= qt); var i = { - ctx: qt, + ctx: Vt, deps: null, nodes: null, - f: t | xt | Jt, + f: t | bt | jt, first: null, fn: e, last: null, @@ -1377,143 +1377,143 @@ function Me(t, e, n) { }; if (n) try { - jn(i); + lr(i); } catch (o) { - throw Rt(i), o; + throw Tt(i), o; } - else e !== null && ce(i); + else e !== null && ue(i); var s = i; if (n && s.deps === null && s.teardown === null && s.nodes === null && s.first === s.last && // either `null`, or a singular child - (s.f & Nn) === 0 && (s = s.first, (t & Ue) !== 0 && (t & Xn) !== 0 && s !== null && (s.f |= Xn)), s !== null && (s.parent = r, r !== null && ru(s, r), z !== null && (z.f & wt) !== 0 && (t & en) === 0)) { + (s.f & qn) === 0 && (s = s.first, (t & je) !== 0 && (t & ir) !== 0 && s !== null && (s.f |= ir)), s !== null && (s.parent = r, r !== null && iu(s, r), V !== null && (V.f & xt) !== 0 && (t & on) === 0)) { var a = ( /** @type {Derived} */ - z + V ); (a.effects ?? (a.effects = [])).push(s); } return i; } -function hs() { - return z !== null && !he; +function $s() { + return V !== null && !fe; } -function iu(t) { - const e = Me(hi, null, !1); - return lt(e, vt), e.teardown = t, e; +function su(t) { + const e = Se(xi, null, !1); + return ut(e, vt), e.teardown = t, e; } -function ds(t) { - nu(); +function As(t) { + ru(); var e = ( /** @type {Effect} */ X.f - ), n = !z && (e & pe) !== 0 && (e & Qn) === 0; + ), n = !V && (e & he) !== 0 && (e & cr) === 0; if (n) { var r = ( /** @type {ComponentContext} */ - qt + Vt ); (r.e ?? (r.e = [])).push(t); } else - return Ua(t); + return eo(t); } -function Ua(t) { - return Me(vr | El, t, !1); +function eo(t) { + return Se(Tr | Rl, t, !1); } -function su(t) { - Ye.ensure(); - const e = Me(en | Nn, t, !0); +function au(t) { + Ge.ensure(); + const e = Se(on | qn, t, !0); return () => { - Rt(e); + Tt(e); }; } -function au(t) { - Ye.ensure(); - const e = Me(en | Nn, t, !0); +function ou(t) { + Ge.ensure(); + const e = Se(on | qn, t, !0); return (n = {}) => new Promise((r) => { - n.outro ? wn(e, () => { - Rt(e), r(void 0); - }) : (Rt(e), r(void 0)); + n.outro ? Sn(e, () => { + Tt(e), r(void 0); + }) : (Tt(e), r(void 0)); }); } -function Xa(t) { - return Me(vr, t, !1); +function no(t) { + return Se(Tr, t, !1); } -function ou(t) { - return Me(as | Nn, t, !0); +function lu(t) { + return Se(_s | qn, t, !0); } -function ps(t, e = 0) { - return Me(hi | e, t, !0); +function Es(t, e = 0) { + return Se(xi | e, t, !0); } -function Pr(t, e = [], n = [], r = []) { - Wl(r, e, n, (i) => { - Me(hi, () => t(...i.map(w)), !0); +function Un(t, e = [], n = [], r = []) { + jl(r, e, n, (i) => { + Se(xi, () => t(...i.map(w)), !0); }); } -function vs(t, e = 0) { - var n = Me(Ue | e, t, !0); +function Rs(t, e = 0) { + var n = Se(je | e, t, !0); return n; } -function Zt(t) { - return Me(pe | Nn, t, !0); +function Kt(t) { + return Se(he | qn, t, !0); } -function Ga(t) { +function ro(t) { var e = t.teardown; if (e !== null) { - const n = tn, r = z; - Is(!0), ee(null); + const n = an, r = V; + Ws(!0), Qt(null); try { e.call(null); } finally { - Is(n), ee(r); + Ws(n), Qt(r); } } } -function gs(t, e = !1) { +function Cs(t, e = !1) { var n = t.first; for (t.first = t.last = null; n !== null; ) { const i = n.ac; - i !== null && Ba(() => { - i.abort(on); + i !== null && to(() => { + i.abort(_n); }); var r = n.next; - (n.f & en) !== 0 ? n.parent = null : Rt(n, e), n = r; + (n.f & on) !== 0 ? n.parent = null : Tt(n, e), n = r; } } -function lu(t) { +function uu(t) { for (var e = t.first; e !== null; ) { var n = e.next; - (e.f & pe) === 0 && Rt(e), e = n; + (e.f & he) === 0 && Tt(e), e = n; } } -function Rt(t, e = !0) { +function Tt(t, e = !0) { var n = !1; - (e || (t.f & ga) !== 0) && t.nodes !== null && t.nodes.end !== null && (uu( + (e || (t.f & Ra) !== 0) && t.nodes !== null && t.nodes.end !== null && (fu( t.nodes.start, /** @type {TemplateNode} */ t.nodes.end - ), n = !0), gs(t, e && !n), gr(t, 0), lt(t, He); + ), n = !0), Cs(t, e && !n), Nr(t, 0), ut(t, Xe); var r = t.nodes && t.nodes.t; if (r !== null) for (const s of r) s.stop(); - Ga(t); + ro(t); var i = t.parent; - i !== null && i.first !== null && Ka(t), t.next = t.prev = t.teardown = t.ctx = t.deps = t.fn = t.nodes = t.ac = null; + i !== null && i.first !== null && io(t), t.next = t.prev = t.teardown = t.ctx = t.deps = t.fn = t.nodes = t.ac = null; } -function uu(t, e) { +function fu(t, e) { for (; t !== null; ) { - var n = t === e ? null : /* @__PURE__ */ ke(t); + var n = t === e ? null : /* @__PURE__ */ Ne(t); t.remove(), t = n; } } -function Ka(t) { +function io(t) { var e = t.parent, n = t.prev, r = t.next; n !== null && (n.next = r), r !== null && (r.prev = n), e !== null && (e.first === t && (e.first = r), e.last === t && (e.last = n)); } -function wn(t, e, n = !0) { +function Sn(t, e, n = !0) { var r = []; - Wa(t, r, !0); + so(t, r, !0); var i = () => { - n && Rt(t), e && e(); + n && Tt(t), e && e(); }, s = r.length; if (s > 0) { var a = () => --s || i(); @@ -1522,31 +1522,31 @@ function wn(t, e, n = !0) { } else i(); } -function Wa(t, e, n) { - if ((t.f & Lt) === 0) { - t.f ^= Lt; +function so(t, e, n) { + if ((t.f & qt) === 0) { + t.f ^= qt; var r = t.nodes && t.nodes.t; if (r !== null) for (const o of r) (o.is_global || n) && e.push(o); for (var i = t.first; i !== null; ) { - var s = i.next, a = (i.f & Xn) !== 0 || // If this is a branch effect without a block effect parent, + var s = i.next, a = (i.f & ir) !== 0 || // If this is a branch effect without a block effect parent, // it means the parent block effect was pruned. In that case, // transparency information was transferred to the branch effect. - (i.f & pe) !== 0 && (t.f & Ue) !== 0; - Wa(i, e, a ? n : !1), i = s; + (i.f & he) !== 0 && (t.f & je) !== 0; + so(i, e, a ? n : !1), i = s; } } } -function _s(t) { - ja(t, !0); +function Ts(t) { + ao(t, !0); } -function ja(t, e) { - if ((t.f & Lt) !== 0) { - t.f ^= Lt, (t.f & vt) === 0 && (lt(t, xt), ce(t)); +function ao(t, e) { + if ((t.f & qt) !== 0) { + t.f ^= qt, (t.f & vt) === 0 && (ut(t, bt), ue(t)); for (var n = t.first; n !== null; ) { - var r = n.next, i = (n.f & Xn) !== 0 || (n.f & pe) !== 0; - ja(n, i ? e : !1), n = r; + var r = n.next, i = (n.f & ir) !== 0 || (n.f & he) !== 0; + ao(n, i ? e : !1), n = r; } var s = t.nodes && t.nodes.t; if (s !== null) @@ -1554,249 +1554,249 @@ function ja(t, e) { (a.is_global || e) && a.in(); } } -function Za(t, e) { +function oo(t, e) { if (t.nodes) for (var n = t.nodes.start, r = t.nodes.end; n !== null; ) { - var i = n === r ? null : /* @__PURE__ */ ke(n); + var i = n === r ? null : /* @__PURE__ */ Ne(n); e.append(n), n = i; } } -let Yr = !1, tn = !1; -function Is(t) { - tn = t; +let Jr = !1, an = !1; +function Ws(t) { + an = t; } -let z = null, he = !1; -function ee(t) { - z = t; +let V = null, fe = !1; +function Qt(t) { + V = t; } let X = null; -function Ne(t) { +function Ce(t) { X = t; } -let Qt = null; -function Ja(t) { - z !== null && (Qt === null ? Qt = [t] : Qt.push(t)); +let Zt = null; +function lo(t) { + V !== null && (Zt === null ? Zt = [t] : Zt.push(t)); } -let kt = null, Dt = 0, Gt = null; -function fu(t) { - Gt = t; +let Pt = null, Ot = 0, Wt = null; +function cu(t) { + Wt = t; } -let Qa = 1, fn = 0, xn = fn; -function Fs(t) { - xn = t; +let uo = 1, wn = 0, kn = wn; +function Xs(t) { + kn = t; } -function to() { - return ++Qa; +function fo() { + return ++uo; } -function Tr(t) { +function Vr(t) { var e = t.f; - if ((e & xt) !== 0) + if ((e & bt) !== 0) return !0; - if (e & wt && (t.f &= ~$n), (e & de) !== 0) { + if (e & xt && (t.f &= ~Pn), (e & ce) !== 0) { for (var n = ( /** @type {Value[]} */ t.deps ), r = n.length, i = 0; i < r; i++) { var s = n[i]; - if (Tr( + if (Vr( /** @type {Derived} */ s - ) && Oa( + ) && Ba( /** @type {Derived} */ s ), s.wv > t.wv) return !0; } - (e & Jt) !== 0 && // During time traveling we don't want to reset the status so that + (e & jt) !== 0 && // During time traveling we don't want to reset the status so that // traversal of the graph in the other batches still happens - yt === null && lt(t, vt); + wt === null && ut(t, vt); } return !1; } -function eo(t, e, n = !0) { +function co(t, e, n = !0) { var r = t.reactions; - if (r !== null && !(Qt !== null && Un.call(Qt, t))) + if (r !== null && !(Zt !== null && rr.call(Zt, t))) for (var i = 0; i < r.length; i++) { var s = r[i]; - (s.f & wt) !== 0 ? eo( + (s.f & xt) !== 0 ? co( /** @type {Derived} */ s, e, !1 - ) : e === s && (n ? lt(s, xt) : (s.f & vt) !== 0 && lt(s, de), ce( + ) : e === s && (n ? ut(s, bt) : (s.f & vt) !== 0 && ut(s, ce), ue( /** @type {Effect} */ s )); } } -function no(t) { +function ho(t) { var m; - var e = kt, n = Dt, r = Gt, i = z, s = Qt, a = qt, o = he, l = xn, u = t.f; - kt = /** @type {null | Value[]} */ - null, Dt = 0, Gt = null, z = (u & (pe | en)) === 0 ? t : null, Qt = null, Gn(t.ctx), he = !1, xn = ++fn, t.ac !== null && (Ba(() => { - t.ac.abort(on); + var e = Pt, n = Ot, r = Wt, i = V, s = Zt, a = Vt, o = fe, l = kn, u = t.f; + Pt = /** @type {null | Value[]} */ + null, Ot = 0, Wt = null, V = (u & (he | on)) === 0 ? t : null, Zt = null, sr(t.ctx), fe = !1, kn = ++wn, t.ac !== null && (to(() => { + t.ac.abort(_n); }), t.ac = null); try { - t.f |= Ii; + t.f |= Xi; var f = ( /** @type {Function} */ t.fn ), h = f(); - t.f |= Qn; + t.f |= cr; var c = t.deps, v = Y == null ? void 0 : Y.is_fork; - if (kt !== null) { + if (Pt !== null) { var g; - if (v || gr(t, Dt), c !== null && Dt > 0) - for (c.length = Dt + kt.length, g = 0; g < kt.length; g++) - c[Dt + g] = kt[g]; + if (v || Nr(t, Ot), c !== null && Ot > 0) + for (c.length = Ot + Pt.length, g = 0; g < Pt.length; g++) + c[Ot + g] = Pt[g]; else - t.deps = c = kt; - if (hs() && (t.f & Jt) !== 0) - for (g = Dt; g < c.length; g++) + t.deps = c = Pt; + if ($s() && (t.f & jt) !== 0) + for (g = Ot; g < c.length; g++) ((m = c[g]).reactions ?? (m.reactions = [])).push(t); - } else !v && c !== null && Dt < c.length && (gr(t, Dt), c.length = Dt); - if (xa() && Gt !== null && !he && c !== null && (t.f & (wt | de | xt)) === 0) + } else !v && c !== null && Ot < c.length && (Nr(t, Ot), c.length = Ot); + if (ka() && Wt !== null && !fe && c !== null && (t.f & (xt | ce | bt)) === 0) for (g = 0; g < /** @type {Source[]} */ - Gt.length; g++) - eo( - Gt[g], + Wt.length; g++) + co( + Wt[g], /** @type {Effect} */ t ); if (i !== null && i !== t) { - if (fn++, i.deps !== null) + if (wn++, i.deps !== null) for (let b = 0; b < n; b += 1) - i.deps[b].rv = fn; + i.deps[b].rv = wn; if (e !== null) for (const b of e) - b.rv = fn; - Gt !== null && (r === null ? r = Gt : r.push(.../** @type {Source[]} */ - Gt)); + b.rv = wn; + Wt !== null && (r === null ? r = Wt : r.push(.../** @type {Source[]} */ + Wt)); } - return (t.f & Je) !== 0 && (t.f ^= Je), h; + return (t.f & rn) !== 0 && (t.f ^= rn), h; } catch (b) { - return $a(b); + return Pa(b); } finally { - t.f ^= Ii, kt = e, Dt = n, Gt = r, z = i, Qt = s, Gn(a), he = o, xn = l; + t.f ^= Xi, Pt = e, Ot = n, Wt = r, V = i, Zt = s, sr(a), fe = o, kn = l; } } -function cu(t, e) { +function hu(t, e) { let n = e.reactions; if (n !== null) { - var r = ml.call(n, t); + var r = yl.call(n, t); if (r !== -1) { var i = n.length - 1; i === 0 ? n = e.reactions = null : (n[r] = n[i], n.pop()); } } - if (n === null && (e.f & wt) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear + if (n === null && (e.f & xt) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps` // allows us to skip the expensive work of disconnecting and immediately reconnecting it - (kt === null || !Un.call(kt, e))) { + (Pt === null || !rr.call(Pt, e))) { var s = ( /** @type {Derived} */ e ); - (s.f & Jt) !== 0 && (s.f ^= Jt, s.f &= ~$n), us(s), tu(s), gr(s, 0); + (s.f & jt) !== 0 && (s.f ^= jt, s.f &= ~Pn), ws(s), eu(s), Nr(s, 0); } } -function gr(t, e) { +function Nr(t, e) { var n = t.deps; if (n !== null) for (var r = e; r < n.length; r++) - cu(t, n[r]); + hu(t, n[r]); } -function jn(t) { +function lr(t) { var e = t.f; - if ((e & He) === 0) { - lt(t, vt); - var n = X, r = Yr; - X = t, Yr = !0; + if ((e & Xe) === 0) { + ut(t, vt); + var n = X, r = Jr; + X = t, Jr = !0; try { - (e & (Ue | pa)) !== 0 ? lu(t) : gs(t), Ga(t); - var i = no(t); - t.teardown = typeof i == "function" ? i : null, t.wv = Qa; + (e & (je | Aa)) !== 0 ? uu(t) : Cs(t), ro(t); + var i = ho(t); + t.teardown = typeof i == "function" ? i : null, t.wv = uo; var s; - Di && zl && (t.f & xt) !== 0 && t.deps; + Wi && Hl && (t.f & bt) !== 0 && t.deps; } finally { - Yr = r, X = n; + Jr = r, X = n; } } } function w(t) { - var e = t.f, n = (e & wt) !== 0; - if (z !== null && !he) { - var r = X !== null && (X.f & He) !== 0; - if (!r && (Qt === null || !Un.call(Qt, t))) { - var i = z.deps; - if ((z.f & Ii) !== 0) - t.rv < fn && (t.rv = fn, kt === null && i !== null && i[Dt] === t ? Dt++ : kt === null ? kt = [t] : kt.push(t)); + var e = t.f, n = (e & xt) !== 0; + if (V !== null && !fe) { + var r = X !== null && (X.f & Xe) !== 0; + if (!r && (Zt === null || !rr.call(Zt, t))) { + var i = V.deps; + if ((V.f & Xi) !== 0) + t.rv < wn && (t.rv = wn, Pt === null && i !== null && i[Ot] === t ? Ot++ : Pt === null ? Pt = [t] : Pt.push(t)); else { - (z.deps ?? (z.deps = [])).push(t); + (V.deps ?? (V.deps = [])).push(t); var s = t.reactions; - s === null ? t.reactions = [z] : Un.call(s, z) || s.push(z); + s === null ? t.reactions = [V] : rr.call(s, V) || s.push(V); } } } - if (tn && Qe.has(t)) - return Qe.get(t); + if (an && sn.has(t)) + return sn.get(t); if (n) { var a = ( /** @type {Derived} */ t ); - if (tn) { + if (an) { var o = a.v; - return ((a.f & vt) === 0 && a.reactions !== null || io(a)) && (o = fs(a)), Qe.set(a, o), o; + return ((a.f & vt) === 0 && a.reactions !== null || vo(a)) && (o = xs(a)), sn.set(a, o), o; } - var l = (a.f & Jt) === 0 && !he && z !== null && (Yr || (z.f & Jt) !== 0), u = (a.f & Qn) === 0; - Tr(a) && (l && (a.f |= Jt), Oa(a)), l && !u && (Da(a), ro(a)); + var l = (a.f & jt) === 0 && !fe && V !== null && (Jr || (V.f & jt) !== 0), u = (a.f & cr) === 0; + Vr(a) && (l && (a.f |= jt), Ba(a)), l && !u && (Ua(a), po(a)); } - if (yt != null && yt.has(t)) - return yt.get(t); - if ((t.f & Je) !== 0) + if (wt != null && wt.has(t)) + return wt.get(t); + if ((t.f & rn) !== 0) throw t.v; return t.v; } -function ro(t) { - if (t.f |= Jt, t.deps !== null) +function po(t) { + if (t.f |= jt, t.deps !== null) for (const e of t.deps) - (e.reactions ?? (e.reactions = [])).push(t), (e.f & wt) !== 0 && (e.f & Jt) === 0 && (Da( + (e.reactions ?? (e.reactions = [])).push(t), (e.f & xt) !== 0 && (e.f & jt) === 0 && (Ua( /** @type {Derived} */ e - ), ro( + ), po( /** @type {Derived} */ e )); } -function io(t) { +function vo(t) { if (t.v === _t) return !0; if (t.deps === null) return !1; for (const e of t.deps) - if (Qe.has(e) || (e.f & wt) !== 0 && io( + if (sn.has(e) || (e.f & xt) !== 0 && vo( /** @type {Derived} */ e )) return !0; return !1; } -function mi(t) { - var e = he; +function Ci(t) { + var e = fe; try { - return he = !0, t(); + return fe = !0, t(); } finally { - he = e; + fe = e; } } -const so = /* @__PURE__ */ new Set(), Xi = /* @__PURE__ */ new Set(); -function hu(t) { +const go = /* @__PURE__ */ new Set(), rs = /* @__PURE__ */ new Set(); +function du(t) { for (var e = 0; e < t.length; e++) - so.add(t[e]); - for (var n of Xi) + go.add(t[e]); + for (var n of rs) n(t); } -let Ls = null; -function qs(t) { +let Gs = null; +function Ks(t) { var b; var e = this, n = ( /** @type {Node} */ @@ -1805,8 +1805,8 @@ function qs(t) { /** @type {null | Element} */ i[0] || t.target ); - Ls = t; - var a = 0, o = Ls === t && t.__root; + Gs = t; + var a = 0, o = Gs === t && t.__root; if (o) { var l = i.indexOf(o); if (l !== -1 && (e === document || e === /** @type {any} */ @@ -1821,14 +1821,14 @@ function qs(t) { } if (s = /** @type {Element} */ i[a] || t.target, s !== e) { - Jr(t, "currentTarget", { + oi(t, "currentTarget", { configurable: !0, get() { return s || n; } }); - var f = z, h = X; - ee(null), Ne(null); + var f = V, h = X; + Qt(null), Ce(null); try { for (var c, v = []; s !== null; ) { var g = s.assignedSlot || s.parentNode || /** @type {any} */ @@ -1839,44 +1839,44 @@ function qs(t) { s.disabled || // DOM could've been updated already by the time this is reached, so we check this as well // -> the target could not have been disabled because it emits the event in the first place t.target === s) && m.call(s, t); - } catch (A) { - c ? v.push(A) : c = A; + } catch ($) { + c ? v.push($) : c = $; } if (t.cancelBubble || g === e || g === null) break; s = g; } if (c) { - for (let A of v) + for (let $ of v) queueMicrotask(() => { - throw A; + throw $; }); throw c; } } finally { - t.__root = e, delete t.currentTarget, ee(f), Ne(h); + t.__root = e, delete t.currentTarget, Qt(f), Ce(h); } } } -var fa, ca; -const Ci = (ca = (fa = globalThis == null ? void 0 : globalThis.window) == null ? void 0 : fa.trustedTypes) == null ? void 0 : /* @__PURE__ */ ca.createPolicy( +var wa, xa; +const qi = (xa = (wa = globalThis == null ? void 0 : globalThis.window) == null ? void 0 : wa.trustedTypes) == null ? void 0 : /* @__PURE__ */ xa.createPolicy( "svelte-trusted-html", { /** @param {string} html */ createHTML: (t) => t } ); -function du(t) { +function pu(t) { return ( /** @type {string} */ - (Ci == null ? void 0 : Ci.createHTML(t)) ?? t + (qi == null ? void 0 : qi.createHTML(t)) ?? t ); } -function ao(t, e = !1) { - var n = cs("template"); - return t = t.replaceAll("", ""), n.innerHTML = e ? du(t) : t, n.content; +function _o(t, e = !1) { + var n = bs("template"); + return t = t.replaceAll("", ""), n.innerHTML = e ? pu(t) : t, n.content; } -function Rn(t, e) { +function On(t, e) { var n = ( /** @type {Effect} */ X @@ -1884,75 +1884,75 @@ function Rn(t, e) { n.nodes === null && (n.nodes = { start: t, end: e, a: null, t: null }); } // @__NO_SIDE_EFFECTS__ -function er(t, e) { - var n = (e & gl) !== 0, r, i = !t.startsWith(""); +function Vn(t, e) { + var n = (e & _l) !== 0, r, i = !t.startsWith(""); return () => { - if (Z) - return Rn(H, null), H; - r === void 0 && (r = ao(i ? t : "" + t, !0)); + if (j) + return On(z, null), z; + r === void 0 && (r = _o(i ? t : "" + t, !0)); var s = ( /** @type {TemplateNode} */ - n || qa ? document.importNode(r, !0) : r.cloneNode(!0) + n || Ka ? document.importNode(r, !0) : r.cloneNode(!0) ); { var a = ( /** @type {TemplateNode} */ - /* @__PURE__ */ En(s) + /* @__PURE__ */ Fn(s) ), o = ( /** @type {TemplateNode} */ s.lastChild ); - Rn(a, o); + On(a, o); } return s; }; } // @__NO_SIDE_EFFECTS__ -function pu(t, e, n = "svg") { +function vu(t, e, n = "svg") { var r = !t.startsWith(""), i = `<${n}>${r ? t : "" + t}`, s; return () => { - if (Z) - return Rn(H, null), H; + if (j) + return On(z, null), z; if (!s) { var a = ( /** @type {DocumentFragment} */ - ao(i, !0) + _o(i, !0) ), o = ( /** @type {Element} */ - /* @__PURE__ */ En(a) + /* @__PURE__ */ Fn(a) ); s = /** @type {Element} */ - /* @__PURE__ */ En(o); + /* @__PURE__ */ Fn(o); } var l = ( /** @type {TemplateNode} */ s.cloneNode(!0) ); - return Rn(l, l), l; + return On(l, l), l; }; } // @__NO_SIDE_EFFECTS__ -function vu(t, e) { - return /* @__PURE__ */ pu(t, e, "svg"); +function gu(t, e) { + return /* @__PURE__ */ vu(t, e, "svg"); } -function Vs(t = "") { - if (!Z) { - var e = te(t + ""); - return Rn(e, e), e; +function js(t = "") { + if (!j) { + var e = Jt(t + ""); + return On(e, e), e; } - var n = H; - return n.nodeType !== Rr ? (n.before(n = te()), Pt(n)) : _i( + var n = z; + return n.nodeType !== qr ? (n.before(n = Jt()), Ft(n)) : Ri( /** @type {Text} */ n - ), Rn(n, n), n; + ), On(n, n), n; } -function be(t, e) { - if (Z) { +function ae(t, e) { + if (j) { var n = ( /** @type {Effect & { nodes: EffectNodes }} */ X ); - ((n.f & Qn) === 0 || n.nodes.end === null) && (n.nodes.end = H), pi(); + ((n.f & cr) === 0 || n.nodes.end === null) && (n.nodes.end = z), $i(); return; } t !== null && t.before( @@ -1960,63 +1960,63 @@ function be(t, e) { e ); } -const gu = ["touchstart", "touchmove"]; -function _u(t) { - return gu.includes(t); +const _u = ["touchstart", "touchmove"]; +function mu(t) { + return _u.includes(t); } -function Pn(t, e) { +function pn(t, e) { var n = e == null ? "" : typeof e == "object" ? e + "" : e; n !== (t.__t ?? (t.__t = t.nodeValue)) && (t.__t = n, t.nodeValue = n + ""); } -function oo(t, e) { - return lo(t, e); +function mo(t, e) { + return yo(t, e); } -function mu(t, e) { - Ui(), e.intro = e.intro ?? !1; - const n = e.target, r = Z, i = H; +function yu(t, e) { + ns(), e.intro = e.intro ?? !1; + const n = e.target, r = j, i = z; try { - for (var s = /* @__PURE__ */ En(n); s && (s.nodeType !== tr || /** @type {Comment} */ - s.data !== is); ) - s = /* @__PURE__ */ ke(s); + for (var s = /* @__PURE__ */ Fn(n); s && (s.nodeType !== hr || /** @type {Comment} */ + s.data !== vs); ) + s = /* @__PURE__ */ Ne(s); if (!s) - throw Bn; - ze(!0), Pt( + throw nr; + We(!0), Ft( /** @type {Comment} */ s ); - const a = lo(t, { ...e, anchor: s }); - return ze(!1), /** @type {Exports} */ + const a = yo(t, { ...e, anchor: s }); + return We(!1), /** @type {Exports} */ a; } catch (a) { if (a instanceof Error && a.message.split(` `).some((o) => o.startsWith("https://svelte.dev/e/"))) throw a; - return a !== Bn && console.warn("Failed to hydrate: ", a), e.recover === !1 && Pl(), Ui(), Ha(n), ze(!1), oo(t, e); + return a !== nr && console.warn("Failed to hydrate: ", a), e.recover === !1 && Dl(), ns(), Ja(n), We(!1), mo(t, e); } finally { - ze(r), Pt(i); + We(r), Ft(i); } } -const Or = /* @__PURE__ */ new Map(); -function lo(t, { target: e, anchor: n, props: r = {}, events: i, context: s, intro: a = !0 }) { - Ui(); +const Br = /* @__PURE__ */ new Map(); +function yo(t, { target: e, anchor: n, props: r = {}, events: i, context: s, intro: a = !0 }) { + ns(); var o = /* @__PURE__ */ new Set(), l = (h) => { for (var c = 0; c < h.length; c++) { var v = h[c]; if (!o.has(v)) { o.add(v); - var g = _u(v); - for (const A of [e, document]) { - var m = Or.get(A); - m === void 0 && (m = /* @__PURE__ */ new Map(), Or.set(A, m)); + var g = mu(v); + for (const $ of [e, document]) { + var m = Br.get($); + m === void 0 && (m = /* @__PURE__ */ new Map(), Br.set($, m)); var b = m.get(v); - b === void 0 ? (A.addEventListener(v, qs, { passive: g }), m.set(v, 1)) : m.set(v, b + 1); + b === void 0 ? ($.addEventListener(v, Ks, { passive: g }), m.set(v, 1)) : m.set(v, b + 1); } } } }; - l(ci(so)), Xi.add(l); - var u = void 0, f = au(() => { - var h = n ?? e.appendChild(te()); + l(wi(go)), rs.add(l); + var u = void 0, f = ou(() => { + var h = n ?? e.appendChild(Jt()); return Gl( /** @type {TemplateNode} */ h, @@ -2025,19 +2025,19 @@ function lo(t, { target: e, anchor: n, props: r = {}, events: i, context: s, int } }, (c) => { - os({}); + ms({}); var v = ( /** @type {ComponentContext} */ - qt + Vt ); - if (s && (v.c = s), i && (r.$$events = i), Z && Rn( + if (s && (v.c = s), i && (r.$$events = i), j && On( /** @type {TemplateNode} */ c, null - ), u = t(c, r) || {}, Z && (X.nodes.end = H, H === null || H.nodeType !== tr || /** @type {Comment} */ - H.data !== ss)) - throw di(), Bn; - ls(); + ), u = t(c, r) || {}, j && (X.nodes.end = z, z === null || z.nodeType !== hr || /** @type {Comment} */ + z.data !== gs)) + throw bi(), nr; + ys(); } ), () => { var m; @@ -2045,34 +2045,34 @@ function lo(t, { target: e, anchor: n, props: r = {}, events: i, context: s, int for (const b of [e, document]) { var v = ( /** @type {Map} */ - Or.get(b) + Br.get(b) ), g = ( /** @type {number} */ v.get(c) ); - --g == 0 ? (b.removeEventListener(c, qs), v.delete(c), v.size === 0 && Or.delete(b)) : v.set(c, g); + --g == 0 ? (b.removeEventListener(c, Ks), v.delete(c), v.size === 0 && Br.delete(b)) : v.set(c, g); } - Xi.delete(l), h !== n && ((m = h.parentNode) == null || m.removeChild(h)); + rs.delete(l), h !== n && ((m = h.parentNode) == null || m.removeChild(h)); }; }); - return Gi.set(u, f), u; + return is.set(u, f), u; } -let Gi = /* @__PURE__ */ new WeakMap(); -function yu(t, e) { - const n = Gi.get(t); - return n ? (Gi.delete(t), n(e)) : Promise.resolve(); +let is = /* @__PURE__ */ new WeakMap(); +function wu(t, e) { + const n = is.get(t); + return n ? (is.delete(t), n(e)) : Promise.resolve(); } -var le, Re, Ft, _n, Ar, Er, ui; -class wu { +var oe, Ae, Lt, Cn, Ir, Lr, mi; +class xu { /** * @param {TemplateNode} anchor * @param {boolean} transition */ constructor(e, n = !0) { /** @type {TemplateNode} */ - ot(this, "anchor"); + lt(this, "anchor"); /** @type {Map} */ - L(this, le, /* @__PURE__ */ new Map()); + L(this, oe, /* @__PURE__ */ new Map()); /** * Map of keys to effects that are currently rendered in the DOM. * These effects are visible and actively part of the document tree. @@ -2087,69 +2087,69 @@ class wu { * Can result in the entries `true->Effect` and `false->Effect` * @type {Map} */ - L(this, Re, /* @__PURE__ */ new Map()); + L(this, Ae, /* @__PURE__ */ new Map()); /** * Similar to #onscreen with respect to the keys, but contains branches that are not yet * in the DOM, because their insertion is deferred. * @type {Map} */ - L(this, Ft, /* @__PURE__ */ new Map()); + L(this, Lt, /* @__PURE__ */ new Map()); /** * Keys of effects that are currently outroing * @type {Set} */ - L(this, _n, /* @__PURE__ */ new Set()); + L(this, Cn, /* @__PURE__ */ new Set()); /** * Whether to pause (i.e. outro) on change, or destroy immediately. * This is necessary for `` */ - L(this, Ar, !0); - L(this, Er, () => { + L(this, Ir, !0); + L(this, Lr, () => { var e = ( /** @type {Batch} */ Y ); - if (d(this, le).has(e)) { + if (d(this, oe).has(e)) { var n = ( /** @type {Key} */ - d(this, le).get(e) - ), r = d(this, Re).get(n); + d(this, oe).get(e) + ), r = d(this, Ae).get(n); if (r) - _s(r), d(this, _n).delete(n); + Ts(r), d(this, Cn).delete(n); else { - var i = d(this, Ft).get(n); - i && (d(this, Re).set(n, i.effect), d(this, Ft).delete(n), i.fragment.lastChild.remove(), this.anchor.before(i.fragment), r = i.effect); + var i = d(this, Lt).get(n); + i && (d(this, Ae).set(n, i.effect), d(this, Lt).delete(n), i.fragment.lastChild.remove(), this.anchor.before(i.fragment), r = i.effect); } - for (const [s, a] of d(this, le)) { - if (d(this, le).delete(s), s === e) + for (const [s, a] of d(this, oe)) { + if (d(this, oe).delete(s), s === e) break; - const o = d(this, Ft).get(a); - o && (Rt(o.effect), d(this, Ft).delete(a)); + const o = d(this, Lt).get(a); + o && (Tt(o.effect), d(this, Lt).delete(a)); } - for (const [s, a] of d(this, Re)) { - if (s === n || d(this, _n).has(s)) continue; + for (const [s, a] of d(this, Ae)) { + if (s === n || d(this, Cn).has(s)) continue; const o = () => { - if (Array.from(d(this, le).values()).includes(s)) { + if (Array.from(d(this, oe).values()).includes(s)) { var u = document.createDocumentFragment(); - Za(a, u), u.append(te()), d(this, Ft).set(s, { effect: a, fragment: u }); + oo(a, u), u.append(Jt()), d(this, Lt).set(s, { effect: a, fragment: u }); } else - Rt(a); - d(this, _n).delete(s), d(this, Re).delete(s); + Tt(a); + d(this, Cn).delete(s), d(this, Ae).delete(s); }; - d(this, Ar) || !r ? (d(this, _n).add(s), wn(a, o, !1)) : o(); + d(this, Ir) || !r ? (d(this, Cn).add(s), Sn(a, o, !1)) : o(); } } }); /** * @param {Batch} batch */ - L(this, ui, (e) => { - d(this, le).delete(e); - const n = Array.from(d(this, le).values()); - for (const [r, i] of d(this, Ft)) - n.includes(r) || (Rt(i.effect), d(this, Ft).delete(r)); + L(this, mi, (e) => { + d(this, oe).delete(e); + const n = Array.from(d(this, oe).values()); + for (const [r, i] of d(this, Lt)) + n.includes(r) || (Tt(i.effect), d(this, Lt).delete(r)); }); - this.anchor = e, O(this, Ar, n); + this.anchor = e, D(this, Ir, n); } /** * @@ -2160,68 +2160,68 @@ class wu { var r = ( /** @type {Batch} */ Y - ), i = Ya(); - if (n && !d(this, Re).has(e) && !d(this, Ft).has(e)) + ), i = Qa(); + if (n && !d(this, Ae).has(e) && !d(this, Lt).has(e)) if (i) { - var s = document.createDocumentFragment(), a = te(); - s.append(a), d(this, Ft).set(e, { - effect: Zt(() => n(a)), + var s = document.createDocumentFragment(), a = Jt(); + s.append(a), d(this, Lt).set(e, { + effect: Kt(() => n(a)), fragment: s }); } else - d(this, Re).set( + d(this, Ae).set( e, - Zt(() => n(this.anchor)) + Kt(() => n(this.anchor)) ); - if (d(this, le).set(r, e), i) { - for (const [o, l] of d(this, Re)) + if (d(this, oe).set(r, e), i) { + for (const [o, l] of d(this, Ae)) o === e ? r.unskip_effect(l) : r.skip_effect(l); - for (const [o, l] of d(this, Ft)) + for (const [o, l] of d(this, Lt)) o === e ? r.unskip_effect(l.effect) : r.skip_effect(l.effect); - r.oncommit(d(this, Er)), r.ondiscard(d(this, ui)); + r.oncommit(d(this, Lr)), r.ondiscard(d(this, mi)); } else - Z && (this.anchor = H), d(this, Er).call(this); + j && (this.anchor = z), d(this, Lr).call(this); } } -le = new WeakMap(), Re = new WeakMap(), Ft = new WeakMap(), _n = new WeakMap(), Ar = new WeakMap(), Er = new WeakMap(), ui = new WeakMap(); -function xu(t) { - qt === null && Rl(), ds(() => { - const e = mi(t); +oe = new WeakMap(), Ae = new WeakMap(), Lt = new WeakMap(), Cn = new WeakMap(), Ir = new WeakMap(), Lr = new WeakMap(), mi = new WeakMap(); +function bu(t) { + Vt === null && Cl(), As(() => { + const e = Ci(t); if (typeof e == "function") return ( /** @type {() => void} */ e ); }); } -function Dr(t, e, n = !1) { - Z && pi(); - var r = new wu(t), i = n ? Xn : 0; +function mr(t, e, n = !1) { + j && $i(); + var r = new xu(t), i = n ? ir : 0; function s(a, o) { - if (Z) { - const f = ma(t); + if (j) { + const f = Ta(t); var l; - if (f === is ? l = 0 : f === fi ? l = !1 : l = parseInt(f.substring(1)), a !== l) { - var u = Qr(); - Pt(u), r.anchor = u, ze(!1), r.ensure(a, o), ze(!0); + if (f === vs ? l = 0 : f === yi ? l = !1 : l = parseInt(f.substring(1)), a !== l) { + var u = li(); + Ft(u), r.anchor = u, We(!1), r.ensure(a, o), We(!0); return; } } r.ensure(a, o); } - vs(() => { + Rs(() => { var a = !1; e((o, l = 0) => { a = !0, s(l, o); }), a || s(!1, null); }, i); } -function Ni(t, e) { +function Vi(t, e) { return e; } -function bu(t, e, n) { +function $u(t, e, n) { for (var r = [], i = e.length, s, a = e.length, o = 0; o < i; o++) { let h = e[o]; - wn( + Sn( h, () => { if (s) { @@ -2230,7 +2230,7 @@ function bu(t, e, n) { /** @type {Set} */ t.outrogroups ); - Ki(ci(s.done)), c.delete(s), c.size === 0 && (t.outrogroups = null); + ss(wi(s.done)), c.delete(s), c.size === 0 && (t.outrogroups = null); } } else a -= 1; @@ -2248,164 +2248,164 @@ function bu(t, e, n) { /** @type {Element} */ u.parentNode ); - Ha(f), f.append(u), t.items.clear(); + Ja(f), f.append(u), t.items.clear(); } - Ki(e, !l); + ss(e, !l); } else s = { pending: new Set(e), done: /* @__PURE__ */ new Set() }, (t.outrogroups ?? (t.outrogroups = /* @__PURE__ */ new Set())).add(s); } -function Ki(t, e = !0) { +function ss(t, e = !0) { for (var n = 0; n < t.length; n++) - Rt(t[n], e); + Tt(t[n], e); } -var zs; -function Si(t, e, n, r, i, s = null) { +var Zs; +function zi(t, e, n, r, i, s = null) { var a = t, o = /* @__PURE__ */ new Map(); - Z && pi(); - var l = null, u = /* @__PURE__ */ Pa(() => { + j && $i(); + var l = null, u = /* @__PURE__ */ Ya(() => { var m = n(); - return ha(m) ? m : m == null ? [] : ci(m); + return ba(m) ? m : m == null ? [] : wi(m); }), f, h = !0; function c() { - g.fallback = l, $u(g, f, a, e, r), l !== null && (f.length === 0 ? (l.f & Ze) === 0 ? _s(l) : (l.f ^= Ze, lr(l, null, a)) : wn(l, () => { + g.fallback = l, Au(g, f, a, e, r), l !== null && (f.length === 0 ? (l.f & nn) === 0 ? Ts(l) : (l.f ^= nn, xr(l, null, a)) : Sn(l, () => { l = null; })); } - var v = vs(() => { + var v = Rs(() => { f = /** @type {V[]} */ w(u); var m = f.length; let b = !1; - if (Z) { - var A = ma(a) === fi; - A !== (m === 0) && (a = Qr(), Pt(a), ze(!1), b = !0); + if (j) { + var $ = Ta(a) === yi; + $ !== (m === 0) && (a = li(), Ft(a), We(!1), b = !0); } - for (var S = /* @__PURE__ */ new Set(), T = ( + for (var C = /* @__PURE__ */ new Set(), T = ( /** @type {Batch} */ Y - ), D = Ya(), E = 0; E < m; E += 1) { - Z && H.nodeType === tr && /** @type {Comment} */ - H.data === ss && (a = /** @type {Comment} */ - H, b = !0, ze(!1)); - var j = f[E], it = r(j, E), W = h ? null : o.get(it); - W ? (W.v && Wn(W.v, j), W.i && Wn(W.i, E), D && T.unskip_effect(W.e)) : (W = Au( + ), N = Qa(), I = 0; I < m; I += 1) { + j && z.nodeType === hr && /** @type {Comment} */ + z.data === gs && (a = /** @type {Comment} */ + z, b = !0, We(!1)); + var G = f[I], at = r(G, I), Z = h ? null : o.get(at); + Z ? (Z.v && or(Z.v, G), Z.i && or(Z.i, I), N && T.unskip_effect(Z.e)) : (Z = Eu( o, - h ? a : zs ?? (zs = te()), - j, - it, - E, + h ? a : Zs ?? (Zs = Jt()), + G, + at, + I, i, e, n - ), h || (W.e.f |= Ze), o.set(it, W)), S.add(it); + ), h || (Z.e.f |= nn), o.set(at, Z)), C.add(at); } - if (m === 0 && s && !l && (h ? l = Zt(() => s(a)) : (l = Zt(() => s(zs ?? (zs = te()))), l.f |= Ze)), m > S.size && Cl(), Z && m > 0 && Pt(Qr()), !h) - if (D) { - for (const [nt, ut] of o) - S.has(nt) || T.skip_effect(ut.e); + if (m === 0 && s && !l && (h ? l = Kt(() => s(a)) : (l = Kt(() => s(Zs ?? (Zs = Jt()))), l.f |= nn)), m > C.size && Nl(), j && m > 0 && Ft(li()), !h) + if (N) { + for (const [et, dt] of o) + C.has(et) || T.skip_effect(dt.e); T.oncommit(c), T.ondiscard(() => { }); } else c(); - b && ze(!0), w(u); + b && We(!0), w(u); }), g = { effect: v, items: o, outrogroups: null, fallback: l }; - h = !1, Z && (a = H); + h = !1, j && (a = z); } -function ar(t) { - for (; t !== null && (t.f & pe) === 0; ) +function yr(t) { + for (; t !== null && (t.f & he) === 0; ) t = t.next; return t; } -function $u(t, e, n, r, i) { - var W; - var s = e.length, a = t.items, o = ar(t.effect.first), l, u = null, f = [], h = [], c, v, g, m; +function Au(t, e, n, r, i) { + var Z; + var s = e.length, a = t.items, o = yr(t.effect.first), l, u = null, f = [], h = [], c, v, g, m; for (m = 0; m < s; m += 1) { if (c = e[m], v = i(c, m), g = /** @type {EachItem} */ a.get(v).e, t.outrogroups !== null) - for (const nt of t.outrogroups) - nt.pending.delete(g), nt.done.delete(g); - if ((g.f & Ze) !== 0) - if (g.f ^= Ze, g === o) - lr(g, null, n); + for (const et of t.outrogroups) + et.pending.delete(g), et.done.delete(g); + if ((g.f & nn) !== 0) + if (g.f ^= nn, g === o) + xr(g, null, n); else { var b = u ? u.next : o; - g === t.effect.last && (t.effect.last = g.prev), g.prev && (g.prev.next = g.next), g.next && (g.next.prev = g.prev), We(t, u, g), We(t, g, b), lr(g, b, n), u = g, f = [], h = [], o = ar(u.next); + g === t.effect.last && (t.effect.last = g.prev), g.prev && (g.prev.next = g.next), g.next && (g.next.prev = g.prev), tn(t, u, g), tn(t, g, b), xr(g, b, n), u = g, f = [], h = [], o = yr(u.next); continue; } - if ((g.f & Lt) !== 0 && _s(g), g !== o) { + if ((g.f & qt) !== 0 && Ts(g), g !== o) { if (l !== void 0 && l.has(g)) { if (f.length < h.length) { - var A = h[0], S; - u = A.prev; - var T = f[0], D = f[f.length - 1]; - for (S = 0; S < f.length; S += 1) - lr(f[S], A, n); - for (S = 0; S < h.length; S += 1) - l.delete(h[S]); - We(t, T.prev, D.next), We(t, u, T), We(t, D, A), o = A, u = D, m -= 1, f = [], h = []; + var $ = h[0], C; + u = $.prev; + var T = f[0], N = f[f.length - 1]; + for (C = 0; C < f.length; C += 1) + xr(f[C], $, n); + for (C = 0; C < h.length; C += 1) + l.delete(h[C]); + tn(t, T.prev, N.next), tn(t, u, T), tn(t, N, $), o = $, u = N, m -= 1, f = [], h = []; } else - l.delete(g), lr(g, o, n), We(t, g.prev, g.next), We(t, g, u === null ? t.effect.first : u.next), We(t, u, g), u = g; + l.delete(g), xr(g, o, n), tn(t, g.prev, g.next), tn(t, g, u === null ? t.effect.first : u.next), tn(t, u, g), u = g; continue; } for (f = [], h = []; o !== null && o !== g; ) - (l ?? (l = /* @__PURE__ */ new Set())).add(o), h.push(o), o = ar(o.next); + (l ?? (l = /* @__PURE__ */ new Set())).add(o), h.push(o), o = yr(o.next); if (o === null) continue; } - (g.f & Ze) === 0 && f.push(g), u = g, o = ar(g.next); + (g.f & nn) === 0 && f.push(g), u = g, o = yr(g.next); } if (t.outrogroups !== null) { - for (const nt of t.outrogroups) - nt.pending.size === 0 && (Ki(ci(nt.done)), (W = t.outrogroups) == null || W.delete(nt)); + for (const et of t.outrogroups) + et.pending.size === 0 && (ss(wi(et.done)), (Z = t.outrogroups) == null || Z.delete(et)); t.outrogroups.size === 0 && (t.outrogroups = null); } if (o !== null || l !== void 0) { - var E = []; + var I = []; if (l !== void 0) for (g of l) - (g.f & Lt) === 0 && E.push(g); + (g.f & qt) === 0 && I.push(g); for (; o !== null; ) - (o.f & Lt) === 0 && o !== t.fallback && E.push(o), o = ar(o.next); - var j = E.length; - if (j > 0) { - var it = null; - bu(t, E, it); + (o.f & qt) === 0 && o !== t.fallback && I.push(o), o = yr(o.next); + var G = I.length; + if (G > 0) { + var at = null; + $u(t, I, at); } } } -function Au(t, e, n, r, i, s, a, o) { - var l = (a & ul) !== 0 ? (a & cl) === 0 ? /* @__PURE__ */ Fa(n, !1, !1) : An(n) : null, u = (a & fl) !== 0 ? An(i) : null; +function Eu(t, e, n, r, i, s, a, o) { + var l = (a & fl) !== 0 ? (a & hl) === 0 ? /* @__PURE__ */ Xa(n, !1, !1) : Dn(n) : null, u = (a & cl) !== 0 ? Dn(i) : null; return { v: l, i: u, - e: Zt(() => (s(e, l ?? n, u ?? i, o), () => { + e: Kt(() => (s(e, l ?? n, u ?? i, o), () => { t.delete(r); })) }; } -function lr(t, e, n) { +function xr(t, e, n) { if (t.nodes) - for (var r = t.nodes.start, i = t.nodes.end, s = e && (e.f & Ze) === 0 ? ( + for (var r = t.nodes.start, i = t.nodes.end, s = e && (e.f & nn) === 0 ? ( /** @type {EffectNodes} */ e.nodes.start ) : n; r !== null; ) { var a = ( /** @type {TemplateNode} */ - /* @__PURE__ */ ke(r) + /* @__PURE__ */ Ne(r) ); if (s.before(r), r === i) return; r = a; } } -function We(t, e, n) { +function tn(t, e, n) { e === null ? t.effect.first = n : e.next = n, n === null ? t.effect.last = e : n.prev = e; } -function uo(t, e) { - Xa(() => { +function wo(t, e) { + no(() => { var n = t.getRootNode(), r = ( /** @type {ShadowRoot} */ n.host ? ( @@ -2418,12 +2418,12 @@ function uo(t, e) { ) ); if (!r.querySelector("#" + e.hash)) { - const i = cs("style"); + const i = bs("style"); i.id = e.hash, i.textContent = e.code, r.appendChild(i); } }); } -function Hs(t, e = !1) { +function Js(t, e = !1) { var n = e ? " !important;" : ";", r = ""; for (var i in t) { var s = t[i]; @@ -2431,59 +2431,59 @@ function Hs(t, e = !1) { } return r; } -function Eu(t, e) { +function Ru(t, e) { if (e) { var n = "", r, i; - return Array.isArray(e) ? (r = e[0], i = e[1]) : r = e, r && (n += Hs(r)), i && (n += Hs(i, !0)), n = n.trim(), n === "" ? null : n; + return Array.isArray(e) ? (r = e[0], i = e[1]) : r = e, r && (n += Js(r)), i && (n += Js(i, !0)), n = n.trim(), n === "" ? null : n; } return String(t); } -function ki(t, e = {}, n, r) { +function Hi(t, e = {}, n, r) { for (var i in n) { var s = n[i]; e[i] !== s && (n[i] == null ? t.style.removeProperty(i) : t.style.setProperty(i, s, r)); } } -function Ys(t, e, n, r) { +function Qs(t, e, n, r) { var i = t.__style; - if (Z || i !== e) { - var s = Eu(e, r); - (!Z || s !== t.getAttribute("style")) && (s == null ? t.removeAttribute("style") : t.style.cssText = s), t.__style = e; - } else r && (Array.isArray(r) ? (ki(t, n == null ? void 0 : n[0], r[0]), ki(t, n == null ? void 0 : n[1], r[1], "important")) : ki(t, n, r)); + if (j || i !== e) { + var s = Ru(e, r); + (!j || s !== t.getAttribute("style")) && (s == null ? t.removeAttribute("style") : t.style.cssText = s), t.__style = e; + } else r && (Array.isArray(r) ? (Hi(t, n == null ? void 0 : n[0], r[0]), Hi(t, n == null ? void 0 : n[1], r[1], "important")) : Hi(t, n, r)); return r; } -function Bs(t, e) { - return t === e || (t == null ? void 0 : t[hr]) === e; +function ta(t, e) { + return t === e || (t == null ? void 0 : t[Er]) === e; } -function Br(t = {}, e, n, r) { - return Xa(() => { +function Qr(t = {}, e, n, r) { + return no(() => { var i, s; - return ps(() => { - i = s, s = [], mi(() => { - t !== n(...s) && (e(t, ...s), i && Bs(n(...i), t) && e(null, ...i)); + return Es(() => { + i = s, s = [], Ci(() => { + t !== n(...s) && (e(t, ...s), i && ta(n(...i), t) && e(null, ...i)); }); }), () => { - yn(() => { - s && Bs(n(...s), t) && e(null, ...s); + Nn(() => { + s && ta(n(...s), t) && e(null, ...s); }); }; }), t; } -let Ir = !1; -function Ru(t) { - var e = Ir; +let Ur = !1; +function Cu(t) { + var e = Ur; try { - return Ir = !1, [t(), Ir]; + return Ur = !1, [t(), Ur]; } finally { - Ir = e; + Ur = e; } } -function ue(t, e, n, r) { - var S; - var i = (n & pl) !== 0, s = (n & vl) !== 0, a = ( +function Et(t, e, n, r) { + var C; + var i = (n & vl) !== 0, s = (n & gl) !== 0, a = ( /** @type {V} */ r - ), o = !0, l = () => (o && (o = !1, a = s ? mi( + ), o = !0, l = () => (o && (o = !1, a = s ? Ci( /** @type {() => V} */ r ) : ( @@ -2491,15 +2491,15 @@ function ue(t, e, n, r) { r )), a), u; if (i) { - var f = hr in t || _a in t; - u = ((S = mn(t, e)) == null ? void 0 : S.set) ?? (f && e in t ? (T) => t[e] = T : void 0); + var f = Er in t || Ca in t; + u = ((C = Tn(t, e)) == null ? void 0 : C.set) ?? (f && e in t ? (T) => t[e] = T : void 0); } var h, c = !1; - i ? [h, c] = Ru(() => ( + i ? [h, c] = Cu(() => ( /** @type {V} */ t[e] )) : h = /** @type {V} */ - t[e], h === void 0 && r !== void 0 && (h = l(), u && (Ol(), u(h))); + t[e], h === void 0 && r !== void 0 && (h = l(), u && (Fl(), u(h))); var v; if (v = () => { var T = ( @@ -2507,39 +2507,39 @@ function ue(t, e, n, r) { t[e] ); return T === void 0 ? l() : (o = !0, T); - }, (n & dl) === 0) + }, (n & pl) === 0) return v; if (u) { var g = t.$$legacy; return ( /** @type {() => V} */ - (function(T, D) { - return arguments.length > 0 ? ((!D || g || c) && u(D ? v() : T), T) : v(); + (function(T, N) { + return arguments.length > 0 ? ((!N || g || c) && u(N ? v() : T), T) : v(); }) ); } - var m = !1, b = ((n & hl) !== 0 ? gi : Pa)(() => (m = !1, v())); + var m = !1, b = ((n & dl) !== 0 ? Ei : Ya)(() => (m = !1, v())); i && w(b); - var A = ( + var $ = ( /** @type {Effect} */ X ); return ( /** @type {() => V} */ - (function(T, D) { + (function(T, N) { if (arguments.length > 0) { - const E = D ? w(b) : i ? un(T) : T; - return J(b, E), m = !0, a !== void 0 && (a = E), T; + const I = N ? w(b) : i ? yn(T) : T; + return Q(b, I), m = !0, a !== void 0 && (a = I), T; } - return tn && m || (A.f & He) !== 0 ? b.v : w(b); + return an && m || ($.f & Xe) !== 0 ? b.v : w(b); }) ); } function Tu(t) { - return new Cu(t); + return new Nu(t); } -var Ve, Wt; -class Cu { +var Ue, Gt; +class Nu { /** * @param {ComponentConstructorOptions & { * component: any; @@ -2547,12 +2547,12 @@ class Cu { */ constructor(e) { /** @type {any} */ - L(this, Ve); + L(this, Ue); /** @type {Record} */ - L(this, Wt); + L(this, Gt); var s; var n = /* @__PURE__ */ new Map(), r = (a, o) => { - var l = /* @__PURE__ */ Fa(o, !1, !1); + var l = /* @__PURE__ */ Xa(o, !1, !1); return n.set(a, l), l; }; const i = new Proxy( @@ -2562,42 +2562,42 @@ class Cu { return w(n.get(o) ?? r(o, Reflect.get(a, o))); }, has(a, o) { - return o === _a ? !0 : (w(n.get(o) ?? r(o, Reflect.get(a, o))), Reflect.has(a, o)); + return o === Ca ? !0 : (w(n.get(o) ?? r(o, Reflect.get(a, o))), Reflect.has(a, o)); }, set(a, o, l) { - return J(n.get(o) ?? r(o, l), l), Reflect.set(a, o, l); + return Q(n.get(o) ?? r(o, l), l), Reflect.set(a, o, l); } } ); - O(this, Wt, (e.hydrate ? mu : oo)(e.component, { + D(this, Gt, (e.hydrate ? yu : mo)(e.component, { target: e.target, anchor: e.anchor, props: i, context: e.context, intro: e.intro ?? !1, recover: e.recover - })), (!((s = e == null ? void 0 : e.props) != null && s.$$host) || e.sync === !1) && jt(), O(this, Ve, i.$$events); - for (const a of Object.keys(d(this, Wt))) - a === "$set" || a === "$destroy" || a === "$on" || Jr(this, a, { + })), (!((s = e == null ? void 0 : e.props) != null && s.$$host) || e.sync === !1) && mt(), D(this, Ue, i.$$events); + for (const a of Object.keys(d(this, Gt))) + a === "$set" || a === "$destroy" || a === "$on" || oi(this, a, { get() { - return d(this, Wt)[a]; + return d(this, Gt)[a]; }, /** @param {any} value */ set(o) { - d(this, Wt)[a] = o; + d(this, Gt)[a] = o; }, enumerable: !0 }); - d(this, Wt).$set = /** @param {Record} next */ + d(this, Gt).$set = /** @param {Record} next */ (a) => { Object.assign(i, a); - }, d(this, Wt).$destroy = () => { - yu(d(this, Wt)); + }, d(this, Gt).$destroy = () => { + wu(d(this, Gt)); }; } /** @param {Record} props */ $set(e) { - d(this, Wt).$set(e); + d(this, Gt).$set(e); } /** * @param {string} event @@ -2605,22 +2605,22 @@ class Cu { * @returns {any} */ $on(e, n) { - d(this, Ve)[e] = d(this, Ve)[e] || []; + d(this, Ue)[e] = d(this, Ue)[e] || []; const r = (...i) => n.call(this, ...i); - return d(this, Ve)[e].push(r), () => { - d(this, Ve)[e] = d(this, Ve)[e].filter( + return d(this, Ue)[e].push(r), () => { + d(this, Ue)[e] = d(this, Ue)[e].filter( /** @param {any} fn */ (i) => i !== r ); }; } $destroy() { - d(this, Wt).$destroy(); + d(this, Gt).$destroy(); } } -Ve = new WeakMap(), Wt = new WeakMap(); -let fo; -typeof HTMLElement == "function" && (fo = class extends HTMLElement { +Ue = new WeakMap(), Gt = new WeakMap(); +let xo; +typeof HTMLElement == "function" && (xo = class extends HTMLElement { /** * @param {*} $$componentCtor * @param {*} $$slots @@ -2629,27 +2629,27 @@ typeof HTMLElement == "function" && (fo = class extends HTMLElement { constructor(e, n, r) { super(); /** The Svelte component constructor */ - ot(this, "$$ctor"); + lt(this, "$$ctor"); /** Slots */ - ot(this, "$$s"); + lt(this, "$$s"); /** @type {any} The Svelte component instance */ - ot(this, "$$c"); + lt(this, "$$c"); /** Whether or not the custom element is connected */ - ot(this, "$$cn", !1); + lt(this, "$$cn", !1); /** @type {Record} Component props data */ - ot(this, "$$d", {}); + lt(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - ot(this, "$$r", !1); + lt(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - ot(this, "$$p_d", {}); + lt(this, "$$p_d", {}); /** @type {Record} Event listeners */ - ot(this, "$$l", {}); + lt(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - ot(this, "$$l_u", /* @__PURE__ */ new Map()); + lt(this, "$$l_u", /* @__PURE__ */ new Map()); /** @type {any} The managed render effect for reflecting attributes */ - ot(this, "$$me"); + lt(this, "$$me"); /** @type {ShadowRoot | null} The ShadowRoot of the custom element */ - ot(this, "$$shadowRoot", null); + lt(this, "$$shadowRoot", null); this.$$ctor = e, this.$$s = n, r && (this.$$shadowRoot = this.attachShadow(r)); } /** @@ -2679,19 +2679,19 @@ typeof HTMLElement == "function" && (fo = class extends HTMLElement { if (this.$$cn = !0, !this.$$c) { let n = function(s) { return (a) => { - const o = cs("slot"); - s !== "default" && (o.name = s), be(a, o); + const o = bs("slot"); + s !== "default" && (o.name = s), ae(a, o); }; }; var e = n; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const r = {}, i = Nu(this); + const r = {}, i = Su(this); for (const s of this.$$s) s in i && (s === "default" && !this.$$d.children ? (this.$$d.children = n(s), r.default = !0) : r[s] = n(s)); for (const s of this.attributes) { const a = this.$$g_p(s.name); - a in this.$$d || (this.$$d[a] = Ur(a, s.value, this.$$p_d, "toProp")); + a in this.$$d || (this.$$d[a] = ti(a, s.value, this.$$p_d, "toProp")); } for (const s in this.$$p_d) !(s in this.$$d) && this[s] !== void 0 && (this.$$d[s] = this[s], delete this[s]); @@ -2703,14 +2703,14 @@ typeof HTMLElement == "function" && (fo = class extends HTMLElement { $$slots: r, $$host: this } - }), this.$$me = su(() => { - ps(() => { + }), this.$$me = au(() => { + Es(() => { var s; this.$$r = !0; - for (const a of Zr(this.$$c)) { + for (const a of ai(this.$$c)) { if (!((s = this.$$p_d[a]) != null && s.reflect)) continue; this.$$d[a] = this.$$c[a]; - const o = Ur( + const o = ti( a, this.$$d[a], this.$$p_d, @@ -2738,7 +2738,7 @@ typeof HTMLElement == "function" && (fo = class extends HTMLElement { */ attributeChangedCallback(e, n, r) { var i; - this.$$r || (e = this.$$g_p(e), this.$$d[e] = Ur(e, r, this.$$p_d, "toProp"), (i = this.$$c) == null || i.$set({ [e]: this.$$d[e] })); + this.$$r || (e = this.$$g_p(e), this.$$d[e] = ti(e, r, this.$$p_d, "toProp"), (i = this.$$c) == null || i.$set({ [e]: this.$$d[e] })); } disconnectedCallback() { this.$$cn = !1, Promise.resolve().then(() => { @@ -2749,12 +2749,12 @@ typeof HTMLElement == "function" && (fo = class extends HTMLElement { * @param {string} attribute_name */ $$g_p(e) { - return Zr(this.$$p_d).find( + return ai(this.$$p_d).find( (n) => this.$$p_d[n].attribute === e || !this.$$p_d[n].attribute && n.toLowerCase() === e ) || e; } }); -function Ur(t, e, n, r) { +function ti(t, e, n, r) { var s; const i = (s = n[t]) == null ? void 0 : s.type; if (e = i === "Boolean" && typeof e != "boolean" ? e != null : e, !r || !n[t]) @@ -2785,7 +2785,7 @@ function Ur(t, e, n, r) { return e; } } -function Nu(t) { +function Su(t) { const e = {}; return t.childNodes.forEach((n) => { e[ @@ -2794,34 +2794,34 @@ function Nu(t) { ] = !0; }), e; } -function co(t, e, n, r, i, s) { - let a = class extends fo { +function bo(t, e, n, r, i, s) { + let a = class extends xo { constructor() { super(t, n, i), this.$$p_d = e; } static get observedAttributes() { - return Zr(e).map( + return ai(e).map( (o) => (e[o].attribute || o).toLowerCase() ); } }; - return Zr(e).forEach((o) => { - Jr(a.prototype, o, { + return ai(e).forEach((o) => { + oi(a.prototype, o, { get() { return this.$$c && o in this.$$c ? this.$$c[o] : this.$$d[o]; }, set(l) { var h; - l = Ur(o, l, e), this.$$d[o] = l; + l = ti(o, l, e), this.$$d[o] = l; var u = this.$$c; if (u) { - var f = (h = mn(u, o)) == null ? void 0 : h.get; + var f = (h = Tn(u, o)) == null ? void 0 : h.get; f ? u[o] = l : u.$set({ [o]: l }); } } }); }), r.forEach((o) => { - Jr(a.prototype, o, { + oi(a.prototype, o, { get() { var l; return (l = this.$$c) == null ? void 0 : l[o]; @@ -2830,43 +2830,43 @@ function co(t, e, n, r, i, s) { }), t.element = /** @type {any} */ a, a; } -var Su = { value: () => { +var ku = { value: () => { } }; -function ho() { +function $o() { for (var t = 0, e = arguments.length, n = {}, r; t < e; ++t) { if (!(r = arguments[t] + "") || r in n || /[\s.]/.test(r)) throw new Error("illegal type: " + r); n[r] = []; } - return new Xr(n); + return new ei(n); } -function Xr(t) { +function ei(t) { this._ = t; } -function ku(t, e) { +function Mu(t, e) { return t.trim().split(/^|\s+/).map(function(n) { var r = "", i = n.indexOf("."); if (i >= 0 && (r = n.slice(i + 1), n = n.slice(0, i)), n && !e.hasOwnProperty(n)) throw new Error("unknown type: " + n); return { type: n, name: r }; }); } -Xr.prototype = ho.prototype = { - constructor: Xr, +ei.prototype = $o.prototype = { + constructor: ei, on: function(t, e) { - var n = this._, r = ku(t + "", n), i, s = -1, a = r.length; + var n = this._, r = Mu(t + "", n), i, s = -1, a = r.length; if (arguments.length < 2) { - for (; ++s < a; ) if ((i = (t = r[s]).type) && (i = Mu(n[i], t.name))) return i; + for (; ++s < a; ) if ((i = (t = r[s]).type) && (i = Pu(n[i], t.name))) return i; return; } if (e != null && typeof e != "function") throw new Error("invalid callback: " + e); for (; ++s < a; ) - if (i = (t = r[s]).type) n[i] = Us(n[i], t.name, e); - else if (e == null) for (i in n) n[i] = Us(n[i], t.name, null); + if (i = (t = r[s]).type) n[i] = ea(n[i], t.name, e); + else if (e == null) for (i in n) n[i] = ea(n[i], t.name, null); return this; }, copy: function() { var t = {}, e = this._; for (var n in e) t[n] = e[n].slice(); - return new Xr(t); + return new ei(t); }, call: function(t, e) { if ((i = arguments.length - 2) > 0) for (var n = new Array(i), r = 0, i, s; r < i; ++r) n[r] = arguments[r + 2]; @@ -2878,135 +2878,135 @@ Xr.prototype = ho.prototype = { for (var r = this._[t], i = 0, s = r.length; i < s; ++i) r[i].value.apply(e, n); } }; -function Mu(t, e) { +function Pu(t, e) { for (var n = 0, r = t.length, i; n < r; ++n) if ((i = t[n]).name === e) return i.value; } -function Us(t, e, n) { +function ea(t, e, n) { for (var r = 0, i = t.length; r < i; ++r) if (t[r].name === e) { - t[r] = Su, t = t.slice(0, r).concat(t.slice(r + 1)); + t[r] = ku, t = t.slice(0, r).concat(t.slice(r + 1)); break; } return n != null && t.push({ name: e, value: n }), t; } -var Wi = "http://www.w3.org/1999/xhtml"; -const Xs = { +var as = "http://www.w3.org/1999/xhtml"; +const na = { svg: "http://www.w3.org/2000/svg", - xhtml: Wi, + xhtml: as, xlink: "http://www.w3.org/1999/xlink", xml: "http://www.w3.org/XML/1998/namespace", xmlns: "http://www.w3.org/2000/xmlns/" }; -function yi(t) { +function Ti(t) { var e = t += "", n = e.indexOf(":"); - return n >= 0 && (e = t.slice(0, n)) !== "xmlns" && (t = t.slice(n + 1)), Xs.hasOwnProperty(e) ? { space: Xs[e], local: t } : t; + return n >= 0 && (e = t.slice(0, n)) !== "xmlns" && (t = t.slice(n + 1)), na.hasOwnProperty(e) ? { space: na[e], local: t } : t; } -function Pu(t) { +function Du(t) { return function() { var e = this.ownerDocument, n = this.namespaceURI; - return n === Wi && e.documentElement.namespaceURI === Wi ? e.createElement(t) : e.createElementNS(n, t); + return n === as && e.documentElement.namespaceURI === as ? e.createElement(t) : e.createElementNS(n, t); }; } -function Ou(t) { +function Fu(t) { return function() { return this.ownerDocument.createElementNS(t.space, t.local); }; } -function po(t) { - var e = yi(t); - return (e.local ? Ou : Pu)(e); +function Ao(t) { + var e = Ti(t); + return (e.local ? Fu : Du)(e); } -function Du() { +function Ou() { } -function ms(t) { - return t == null ? Du : function() { +function Ns(t) { + return t == null ? Ou : function() { return this.querySelector(t); }; } function Iu(t) { - typeof t != "function" && (t = ms(t)); + typeof t != "function" && (t = Ns(t)); for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i) for (var s = e[i], a = s.length, o = r[i] = new Array(a), l, u, f = 0; f < a; ++f) (l = s[f]) && (u = t.call(l, l.__data__, f, s)) && ("__data__" in l && (u.__data__ = l.__data__), o[f] = u); - return new Vt(r, this._parents); + return new zt(r, this._parents); } -function Fu(t) { +function Lu(t) { return t == null ? [] : Array.isArray(t) ? t : Array.from(t); } -function Lu() { +function qu() { return []; } -function vo(t) { - return t == null ? Lu : function() { +function Eo(t) { + return t == null ? qu : function() { return this.querySelectorAll(t); }; } -function qu(t) { +function Vu(t) { return function() { - return Fu(t.apply(this, arguments)); + return Lu(t.apply(this, arguments)); }; } -function Vu(t) { - typeof t == "function" ? t = qu(t) : t = vo(t); +function zu(t) { + typeof t == "function" ? t = Vu(t) : t = Eo(t); for (var e = this._groups, n = e.length, r = [], i = [], s = 0; s < n; ++s) for (var a = e[s], o = a.length, l, u = 0; u < o; ++u) (l = a[u]) && (r.push(t.call(l, l.__data__, u, a)), i.push(l)); - return new Vt(r, i); + return new zt(r, i); } -function go(t) { +function Ro(t) { return function() { return this.matches(t); }; } -function _o(t) { +function Co(t) { return function(e) { return e.matches(t); }; } -var zu = Array.prototype.find; -function Hu(t) { +var Hu = Array.prototype.find; +function Yu(t) { return function() { - return zu.call(this.children, t); + return Hu.call(this.children, t); }; } -function Yu() { +function Bu() { return this.firstElementChild; } -function Bu(t) { - return this.select(t == null ? Yu : Hu(typeof t == "function" ? t : _o(t))); +function Uu(t) { + return this.select(t == null ? Bu : Yu(typeof t == "function" ? t : Co(t))); } -var Uu = Array.prototype.filter; +var Wu = Array.prototype.filter; function Xu() { return Array.from(this.children); } function Gu(t) { return function() { - return Uu.call(this.children, t); + return Wu.call(this.children, t); }; } function Ku(t) { - return this.selectAll(t == null ? Xu : Gu(typeof t == "function" ? t : _o(t))); + return this.selectAll(t == null ? Xu : Gu(typeof t == "function" ? t : Co(t))); } -function Wu(t) { - typeof t != "function" && (t = go(t)); +function ju(t) { + typeof t != "function" && (t = Ro(t)); for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i) for (var s = e[i], a = s.length, o = r[i] = [], l, u = 0; u < a; ++u) (l = s[u]) && t.call(l, l.__data__, u, s) && o.push(l); - return new Vt(r, this._parents); + return new zt(r, this._parents); } -function mo(t) { +function To(t) { return new Array(t.length); } -function ju() { - return new Vt(this._enter || this._groups.map(mo), this._parents); +function Zu() { + return new zt(this._enter || this._groups.map(To), this._parents); } -function ti(t, e) { +function ui(t, e) { this.ownerDocument = t.ownerDocument, this.namespaceURI = t.namespaceURI, this._next = null, this._parent = t, this.__data__ = e; } -ti.prototype = { - constructor: ti, +ui.prototype = { + constructor: ui, appendChild: function(t) { return this._parent.insertBefore(t, this._next); }, @@ -3020,70 +3020,70 @@ ti.prototype = { return this._parent.querySelectorAll(t); } }; -function Zu(t) { +function Ju(t) { return function() { return t; }; } -function Ju(t, e, n, r, i, s) { +function Qu(t, e, n, r, i, s) { for (var a = 0, o, l = e.length, u = s.length; a < u; ++a) - (o = e[a]) ? (o.__data__ = s[a], r[a] = o) : n[a] = new ti(t, s[a]); + (o = e[a]) ? (o.__data__ = s[a], r[a] = o) : n[a] = new ui(t, s[a]); for (; a < l; ++a) (o = e[a]) && (i[a] = o); } -function Qu(t, e, n, r, i, s, a) { +function tf(t, e, n, r, i, s, a) { var o, l, u = /* @__PURE__ */ new Map(), f = e.length, h = s.length, c = new Array(f), v; for (o = 0; o < f; ++o) (l = e[o]) && (c[o] = v = a.call(l, l.__data__, o, e) + "", u.has(v) ? i[o] = l : u.set(v, l)); for (o = 0; o < h; ++o) - v = a.call(t, s[o], o, s) + "", (l = u.get(v)) ? (r[o] = l, l.__data__ = s[o], u.delete(v)) : n[o] = new ti(t, s[o]); + v = a.call(t, s[o], o, s) + "", (l = u.get(v)) ? (r[o] = l, l.__data__ = s[o], u.delete(v)) : n[o] = new ui(t, s[o]); for (o = 0; o < f; ++o) (l = e[o]) && u.get(c[o]) === l && (i[o] = l); } -function tf(t) { +function ef(t) { return t.__data__; } -function ef(t, e) { - if (!arguments.length) return Array.from(this, tf); - var n = e ? Qu : Ju, r = this._parents, i = this._groups; - typeof t != "function" && (t = Zu(t)); +function nf(t, e) { + if (!arguments.length) return Array.from(this, ef); + var n = e ? tf : Qu, r = this._parents, i = this._groups; + typeof t != "function" && (t = Ju(t)); for (var s = i.length, a = new Array(s), o = new Array(s), l = new Array(s), u = 0; u < s; ++u) { - var f = r[u], h = i[u], c = h.length, v = nf(t.call(f, f && f.__data__, u, r)), g = v.length, m = o[u] = new Array(g), b = a[u] = new Array(g), A = l[u] = new Array(c); - n(f, h, m, b, A, v, e); - for (var S = 0, T = 0, D, E; S < g; ++S) - if (D = m[S]) { - for (S >= T && (T = S + 1); !(E = b[T]) && ++T < g; ) ; - D._next = E || null; + var f = r[u], h = i[u], c = h.length, v = rf(t.call(f, f && f.__data__, u, r)), g = v.length, m = o[u] = new Array(g), b = a[u] = new Array(g), $ = l[u] = new Array(c); + n(f, h, m, b, $, v, e); + for (var C = 0, T = 0, N, I; C < g; ++C) + if (N = m[C]) { + for (C >= T && (T = C + 1); !(I = b[T]) && ++T < g; ) ; + N._next = I || null; } } - return a = new Vt(a, r), a._enter = o, a._exit = l, a; + return a = new zt(a, r), a._enter = o, a._exit = l, a; } -function nf(t) { +function rf(t) { return typeof t == "object" && "length" in t ? t : Array.from(t); } -function rf() { - return new Vt(this._exit || this._groups.map(mo), this._parents); +function sf() { + return new zt(this._exit || this._groups.map(To), this._parents); } -function sf(t, e, n) { +function af(t, e, n) { var r = this.enter(), i = this, s = this.exit(); return typeof t == "function" ? (r = t(r), r && (r = r.selection())) : r = r.append(t + ""), e != null && (i = e(i), i && (i = i.selection())), n == null ? s.remove() : n(s), r && i ? r.merge(i).order() : i; } -function af(t) { +function of(t) { for (var e = t.selection ? t.selection() : t, n = this._groups, r = e._groups, i = n.length, s = r.length, a = Math.min(i, s), o = new Array(i), l = 0; l < a; ++l) for (var u = n[l], f = r[l], h = u.length, c = o[l] = new Array(h), v, g = 0; g < h; ++g) (v = u[g] || f[g]) && (c[g] = v); for (; l < i; ++l) o[l] = n[l]; - return new Vt(o, this._parents); + return new zt(o, this._parents); } -function of() { +function lf() { for (var t = this._groups, e = -1, n = t.length; ++e < n; ) for (var r = t[e], i = r.length - 1, s = r[i], a; --i >= 0; ) (a = r[i]) && (s && a.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(a, s), s = a); return this; } -function lf(t) { - t || (t = uf); +function uf(t) { + t || (t = ff); function e(h, c) { return h && c ? t(h.__data__, c.__data__) : !h - !c; } @@ -3092,19 +3092,19 @@ function lf(t) { (u = a[f]) && (l[f] = u); l.sort(e); } - return new Vt(i, this._parents).order(); + return new zt(i, this._parents).order(); } -function uf(t, e) { +function ff(t, e) { return t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN; } -function ff() { +function cf() { var t = arguments[0]; return arguments[0] = this, t.apply(null, arguments), this; } -function cf() { +function hf() { return Array.from(this); } -function hf() { +function df() { for (var t = this._groups, e = 0, n = t.length; e < n; ++e) for (var r = t[e], i = 0, s = r.length; i < s; ++i) { var a = r[i]; @@ -3112,114 +3112,114 @@ function hf() { } return null; } -function df() { +function pf() { let t = 0; for (const e of this) ++t; return t; } -function pf() { +function vf() { return !this.node(); } -function vf(t) { +function gf(t) { for (var e = this._groups, n = 0, r = e.length; n < r; ++n) for (var i = e[n], s = 0, a = i.length, o; s < a; ++s) (o = i[s]) && t.call(o, o.__data__, s, i); return this; } -function gf(t) { +function _f(t) { return function() { this.removeAttribute(t); }; } -function _f(t) { +function mf(t) { return function() { this.removeAttributeNS(t.space, t.local); }; } -function mf(t, e) { +function yf(t, e) { return function() { this.setAttribute(t, e); }; } -function yf(t, e) { +function wf(t, e) { return function() { this.setAttributeNS(t.space, t.local, e); }; } -function wf(t, e) { +function xf(t, e) { return function() { var n = e.apply(this, arguments); n == null ? this.removeAttribute(t) : this.setAttribute(t, n); }; } -function xf(t, e) { +function bf(t, e) { return function() { var n = e.apply(this, arguments); n == null ? this.removeAttributeNS(t.space, t.local) : this.setAttributeNS(t.space, t.local, n); }; } -function bf(t, e) { - var n = yi(t); +function $f(t, e) { + var n = Ti(t); if (arguments.length < 2) { var r = this.node(); return n.local ? r.getAttributeNS(n.space, n.local) : r.getAttribute(n); } - return this.each((e == null ? n.local ? _f : gf : typeof e == "function" ? n.local ? xf : wf : n.local ? yf : mf)(n, e)); + return this.each((e == null ? n.local ? mf : _f : typeof e == "function" ? n.local ? bf : xf : n.local ? wf : yf)(n, e)); } -function yo(t) { +function No(t) { return t.ownerDocument && t.ownerDocument.defaultView || t.document && t || t.defaultView; } -function $f(t) { +function Af(t) { return function() { this.style.removeProperty(t); }; } -function Af(t, e, n) { +function Ef(t, e, n) { return function() { this.style.setProperty(t, e, n); }; } -function Ef(t, e, n) { +function Rf(t, e, n) { return function() { var r = e.apply(this, arguments); r == null ? this.style.removeProperty(t) : this.style.setProperty(t, r, n); }; } -function Rf(t, e, n) { - return arguments.length > 1 ? this.each((e == null ? $f : typeof e == "function" ? Ef : Af)(t, e, n ?? "")) : Zn(this.node(), t); +function Cf(t, e, n) { + return arguments.length > 1 ? this.each((e == null ? Af : typeof e == "function" ? Rf : Ef)(t, e, n ?? "")) : ur(this.node(), t); } -function Zn(t, e) { - return t.style.getPropertyValue(e) || yo(t).getComputedStyle(t, null).getPropertyValue(e); +function ur(t, e) { + return t.style.getPropertyValue(e) || No(t).getComputedStyle(t, null).getPropertyValue(e); } function Tf(t) { return function() { delete this[t]; }; } -function Cf(t, e) { +function Nf(t, e) { return function() { this[t] = e; }; } -function Nf(t, e) { +function Sf(t, e) { return function() { var n = e.apply(this, arguments); n == null ? delete this[t] : this[t] = n; }; } -function Sf(t, e) { - return arguments.length > 1 ? this.each((e == null ? Tf : typeof e == "function" ? Nf : Cf)(t, e)) : this.node()[t]; +function kf(t, e) { + return arguments.length > 1 ? this.each((e == null ? Tf : typeof e == "function" ? Sf : Nf)(t, e)) : this.node()[t]; } -function wo(t) { +function So(t) { return t.trim().split(/^|\s+/); } -function ys(t) { - return t.classList || new xo(t); +function Ss(t) { + return t.classList || new ko(t); } -function xo(t) { - this._node = t, this._names = wo(t.getAttribute("class") || ""); +function ko(t) { + this._node = t, this._names = So(t.getAttribute("class") || ""); } -xo.prototype = { +ko.prototype = { add: function(t) { var e = this._names.indexOf(t); e < 0 && (this._names.push(t), this._node.setAttribute("class", this._names.join(" "))); @@ -3232,36 +3232,36 @@ xo.prototype = { return this._names.indexOf(t) >= 0; } }; -function bo(t, e) { - for (var n = ys(t), r = -1, i = e.length; ++r < i; ) n.add(e[r]); +function Mo(t, e) { + for (var n = Ss(t), r = -1, i = e.length; ++r < i; ) n.add(e[r]); } -function $o(t, e) { - for (var n = ys(t), r = -1, i = e.length; ++r < i; ) n.remove(e[r]); +function Po(t, e) { + for (var n = Ss(t), r = -1, i = e.length; ++r < i; ) n.remove(e[r]); } -function kf(t) { +function Mf(t) { return function() { - bo(this, t); + Mo(this, t); }; } -function Mf(t) { +function Pf(t) { return function() { - $o(this, t); + Po(this, t); }; } -function Pf(t, e) { +function Df(t, e) { return function() { - (e.apply(this, arguments) ? bo : $o)(this, t); + (e.apply(this, arguments) ? Mo : Po)(this, t); }; } -function Of(t, e) { - var n = wo(t + ""); +function Ff(t, e) { + var n = So(t + ""); if (arguments.length < 2) { - for (var r = ys(this.node()), i = -1, s = n.length; ++i < s; ) if (!r.contains(n[i])) return !1; + for (var r = Ss(this.node()), i = -1, s = n.length; ++i < s; ) if (!r.contains(n[i])) return !1; return !0; } - return this.each((typeof e == "function" ? Pf : e ? kf : Mf)(n, e)); + return this.each((typeof e == "function" ? Df : e ? Mf : Pf)(n, e)); } -function Df() { +function Of() { this.textContent = ""; } function If(t) { @@ -3269,46 +3269,46 @@ function If(t) { this.textContent = t; }; } -function Ff(t) { +function Lf(t) { return function() { var e = t.apply(this, arguments); this.textContent = e ?? ""; }; } -function Lf(t) { - return arguments.length ? this.each(t == null ? Df : (typeof t == "function" ? Ff : If)(t)) : this.node().textContent; +function qf(t) { + return arguments.length ? this.each(t == null ? Of : (typeof t == "function" ? Lf : If)(t)) : this.node().textContent; } -function qf() { +function Vf() { this.innerHTML = ""; } -function Vf(t) { +function zf(t) { return function() { this.innerHTML = t; }; } -function zf(t) { +function Hf(t) { return function() { var e = t.apply(this, arguments); this.innerHTML = e ?? ""; }; } -function Hf(t) { - return arguments.length ? this.each(t == null ? qf : (typeof t == "function" ? zf : Vf)(t)) : this.node().innerHTML; -} -function Yf() { - this.nextSibling && this.parentNode.appendChild(this); +function Yf(t) { + return arguments.length ? this.each(t == null ? Vf : (typeof t == "function" ? Hf : zf)(t)) : this.node().innerHTML; } function Bf() { - return this.each(Yf); + this.nextSibling && this.parentNode.appendChild(this); } function Uf() { + return this.each(Bf); +} +function Wf() { this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild); } function Xf() { - return this.each(Uf); + return this.each(Wf); } function Gf(t) { - var e = typeof t == "function" ? t : po(t); + var e = typeof t == "function" ? t : Ao(t); return this.select(function() { return this.appendChild(e.apply(this, arguments)); }); @@ -3316,45 +3316,45 @@ function Gf(t) { function Kf() { return null; } -function Wf(t, e) { - var n = typeof t == "function" ? t : po(t), r = e == null ? Kf : typeof e == "function" ? e : ms(e); +function jf(t, e) { + var n = typeof t == "function" ? t : Ao(t), r = e == null ? Kf : typeof e == "function" ? e : Ns(e); return this.select(function() { return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null); }); } -function jf() { +function Zf() { var t = this.parentNode; t && t.removeChild(this); } -function Zf() { - return this.each(jf); -} function Jf() { + return this.each(Zf); +} +function Qf() { var t = this.cloneNode(!1), e = this.parentNode; return e ? e.insertBefore(t, this.nextSibling) : t; } -function Qf() { +function tc() { var t = this.cloneNode(!0), e = this.parentNode; return e ? e.insertBefore(t, this.nextSibling) : t; } -function tc(t) { - return this.select(t ? Qf : Jf); -} function ec(t) { - return arguments.length ? this.property("__data__", t) : this.node().__data__; + return this.select(t ? tc : Qf); } function nc(t) { + return arguments.length ? this.property("__data__", t) : this.node().__data__; +} +function rc(t) { return function(e) { t.call(this, e, this.__data__); }; } -function rc(t) { +function ic(t) { return t.trim().split(/^|\s+/).map(function(e) { var n = "", r = e.indexOf("."); return r >= 0 && (n = e.slice(r + 1), e = e.slice(0, r)), { type: e, name: n }; }); } -function ic(t) { +function sc(t) { return function() { var e = this.__on; if (e) { @@ -3364,9 +3364,9 @@ function ic(t) { } }; } -function sc(t, e, n) { +function ac(t, e, n) { return function() { - var r = this.__on, i, s = nc(e); + var r = this.__on, i, s = rc(e); if (r) { for (var a = 0, o = r.length; a < o; ++a) if ((i = r[a]).type === t.type && i.name === t.name) { @@ -3377,8 +3377,8 @@ function sc(t, e, n) { this.addEventListener(t.type, s, n), i = { type: t.type, name: t.name, value: e, listener: s, options: n }, r ? r.push(i) : this.__on = [i]; }; } -function ac(t, e, n) { - var r = rc(t + ""), i, s = r.length, a; +function oc(t, e, n) { + var r = ic(t + ""), i, s = r.length, a; if (arguments.length < 2) { var o = this.node().__on; if (o) { @@ -3389,93 +3389,93 @@ function ac(t, e, n) { } return; } - for (o = e ? sc : ic, i = 0; i < s; ++i) this.each(o(r[i], e, n)); + for (o = e ? ac : sc, i = 0; i < s; ++i) this.each(o(r[i], e, n)); return this; } -function Ao(t, e, n) { - var r = yo(t), i = r.CustomEvent; +function Do(t, e, n) { + var r = No(t), i = r.CustomEvent; typeof i == "function" ? i = new i(e, n) : (i = r.document.createEvent("Event"), n ? (i.initEvent(e, n.bubbles, n.cancelable), i.detail = n.detail) : i.initEvent(e, !1, !1)), t.dispatchEvent(i); } -function oc(t, e) { +function lc(t, e) { return function() { - return Ao(this, t, e); + return Do(this, t, e); }; } -function lc(t, e) { +function uc(t, e) { return function() { - return Ao(this, t, e.apply(this, arguments)); + return Do(this, t, e.apply(this, arguments)); }; } -function uc(t, e) { - return this.each((typeof e == "function" ? lc : oc)(t, e)); +function fc(t, e) { + return this.each((typeof e == "function" ? uc : lc)(t, e)); } -function* fc() { +function* cc() { for (var t = this._groups, e = 0, n = t.length; e < n; ++e) for (var r = t[e], i = 0, s = r.length, a; i < s; ++i) (a = r[i]) && (yield a); } -var Eo = [null]; -function Vt(t, e) { +var Fo = [null]; +function zt(t, e) { this._groups = t, this._parents = e; } -function nr() { - return new Vt([[document.documentElement]], Eo); +function dr() { + return new zt([[document.documentElement]], Fo); } -function cc() { +function hc() { return this; } -Vt.prototype = nr.prototype = { - constructor: Vt, +zt.prototype = dr.prototype = { + constructor: zt, select: Iu, - selectAll: Vu, - selectChild: Bu, + selectAll: zu, + selectChild: Uu, selectChildren: Ku, - filter: Wu, - data: ef, - enter: ju, - exit: rf, - join: sf, - merge: af, - selection: cc, - order: of, - sort: lf, - call: ff, - nodes: cf, - node: hf, - size: df, - empty: pf, - each: vf, - attr: bf, - style: Rf, - property: Sf, - classed: Of, - text: Lf, - html: Hf, - raise: Bf, + filter: ju, + data: nf, + enter: Zu, + exit: sf, + join: af, + merge: of, + selection: hc, + order: lf, + sort: uf, + call: cf, + nodes: hf, + node: df, + size: pf, + empty: vf, + each: gf, + attr: $f, + style: Cf, + property: kf, + classed: Ff, + text: qf, + html: Yf, + raise: Uf, lower: Xf, append: Gf, - insert: Wf, - remove: Zf, - clone: tc, - datum: ec, - on: ac, - dispatch: uc, - [Symbol.iterator]: fc + insert: jf, + remove: Jf, + clone: ec, + datum: nc, + on: oc, + dispatch: fc, + [Symbol.iterator]: cc }; function gt(t) { - return typeof t == "string" ? new Vt([[document.querySelector(t)]], [document.documentElement]) : new Vt([[t]], Eo); + return typeof t == "string" ? new zt([[document.querySelector(t)]], [document.documentElement]) : new zt([[t]], Fo); } -function ws(t, e, n) { +function ks(t, e, n) { t.prototype = e.prototype = n, n.constructor = t; } -function Ro(t, e) { +function Oo(t, e) { var n = Object.create(t.prototype); for (var r in e) n[r] = e[r]; return n; } -function Cr() { +function zr() { } -var _r = 0.7, ei = 1 / _r, In = "\\s*([+-]?\\d+)\\s*", mr = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", Ce = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", hc = /^#([0-9a-f]{3,8})$/, dc = new RegExp(`^rgb\\(${In},${In},${In}\\)$`), pc = new RegExp(`^rgb\\(${Ce},${Ce},${Ce}\\)$`), vc = new RegExp(`^rgba\\(${In},${In},${In},${mr}\\)$`), gc = new RegExp(`^rgba\\(${Ce},${Ce},${Ce},${mr}\\)$`), _c = new RegExp(`^hsl\\(${mr},${Ce},${Ce}\\)$`), mc = new RegExp(`^hsla\\(${mr},${Ce},${Ce},${mr}\\)$`), Gs = { +var Sr = 0.7, fi = 1 / Sr, Gn = "\\s*([+-]?\\d+)\\s*", kr = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", Re = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", dc = /^#([0-9a-f]{3,8})$/, pc = new RegExp(`^rgb\\(${Gn},${Gn},${Gn}\\)$`), vc = new RegExp(`^rgb\\(${Re},${Re},${Re}\\)$`), gc = new RegExp(`^rgba\\(${Gn},${Gn},${Gn},${kr}\\)$`), _c = new RegExp(`^rgba\\(${Re},${Re},${Re},${kr}\\)$`), mc = new RegExp(`^hsl\\(${kr},${Re},${Re}\\)$`), yc = new RegExp(`^hsla\\(${kr},${Re},${Re},${kr}\\)$`), ra = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, @@ -3625,171 +3625,171 @@ var _r = 0.7, ei = 1 / _r, In = "\\s*([+-]?\\d+)\\s*", mr = "\\s*([+-]?(?:\\d*\\ yellow: 16776960, yellowgreen: 10145074 }; -ws(Cr, Tn, { +ks(zr, In, { copy(t) { return Object.assign(new this.constructor(), this, t); }, displayable() { return this.rgb().displayable(); }, - hex: Ks, + hex: ia, // Deprecated! Use color.formatHex. - formatHex: Ks, - formatHex8: yc, - formatHsl: wc, - formatRgb: Ws, - toString: Ws + formatHex: ia, + formatHex8: wc, + formatHsl: xc, + formatRgb: sa, + toString: sa }); -function Ks() { +function ia() { return this.rgb().formatHex(); } -function yc() { +function wc() { return this.rgb().formatHex8(); } -function wc() { - return To(this).formatHsl(); +function xc() { + return Io(this).formatHsl(); } -function Ws() { +function sa() { return this.rgb().formatRgb(); } -function Tn(t) { +function In(t) { var e, n; - return t = (t + "").trim().toLowerCase(), (e = hc.exec(t)) ? (n = e[1].length, e = parseInt(e[1], 16), n === 6 ? js(e) : n === 3 ? new Mt(e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, (e & 15) << 4 | e & 15, 1) : n === 8 ? Fr(e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, (e & 255) / 255) : n === 4 ? Fr(e >> 12 & 15 | e >> 8 & 240, e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, ((e & 15) << 4 | e & 15) / 255) : null) : (e = dc.exec(t)) ? new Mt(e[1], e[2], e[3], 1) : (e = pc.exec(t)) ? new Mt(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, 1) : (e = vc.exec(t)) ? Fr(e[1], e[2], e[3], e[4]) : (e = gc.exec(t)) ? Fr(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, e[4]) : (e = _c.exec(t)) ? Qs(e[1], e[2] / 100, e[3] / 100, 1) : (e = mc.exec(t)) ? Qs(e[1], e[2] / 100, e[3] / 100, e[4]) : Gs.hasOwnProperty(t) ? js(Gs[t]) : t === "transparent" ? new Mt(NaN, NaN, NaN, 0) : null; + return t = (t + "").trim().toLowerCase(), (e = dc.exec(t)) ? (n = e[1].length, e = parseInt(e[1], 16), n === 6 ? aa(e) : n === 3 ? new Dt(e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, (e & 15) << 4 | e & 15, 1) : n === 8 ? Wr(e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, (e & 255) / 255) : n === 4 ? Wr(e >> 12 & 15 | e >> 8 & 240, e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, ((e & 15) << 4 | e & 15) / 255) : null) : (e = pc.exec(t)) ? new Dt(e[1], e[2], e[3], 1) : (e = vc.exec(t)) ? new Dt(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, 1) : (e = gc.exec(t)) ? Wr(e[1], e[2], e[3], e[4]) : (e = _c.exec(t)) ? Wr(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, e[4]) : (e = mc.exec(t)) ? ua(e[1], e[2] / 100, e[3] / 100, 1) : (e = yc.exec(t)) ? ua(e[1], e[2] / 100, e[3] / 100, e[4]) : ra.hasOwnProperty(t) ? aa(ra[t]) : t === "transparent" ? new Dt(NaN, NaN, NaN, 0) : null; } -function js(t) { - return new Mt(t >> 16 & 255, t >> 8 & 255, t & 255, 1); +function aa(t) { + return new Dt(t >> 16 & 255, t >> 8 & 255, t & 255, 1); } -function Fr(t, e, n, r) { - return r <= 0 && (t = e = n = NaN), new Mt(t, e, n, r); +function Wr(t, e, n, r) { + return r <= 0 && (t = e = n = NaN), new Dt(t, e, n, r); } -function xc(t) { - return t instanceof Cr || (t = Tn(t)), t ? (t = t.rgb(), new Mt(t.r, t.g, t.b, t.opacity)) : new Mt(); +function bc(t) { + return t instanceof zr || (t = In(t)), t ? (t = t.rgb(), new Dt(t.r, t.g, t.b, t.opacity)) : new Dt(); } -function ji(t, e, n, r) { - return arguments.length === 1 ? xc(t) : new Mt(t, e, n, r ?? 1); +function os(t, e, n, r) { + return arguments.length === 1 ? bc(t) : new Dt(t, e, n, r ?? 1); } -function Mt(t, e, n, r) { +function Dt(t, e, n, r) { this.r = +t, this.g = +e, this.b = +n, this.opacity = +r; } -ws(Mt, ji, Ro(Cr, { +ks(Dt, os, Oo(zr, { brighter(t) { - return t = t == null ? ei : Math.pow(ei, t), new Mt(this.r * t, this.g * t, this.b * t, this.opacity); + return t = t == null ? fi : Math.pow(fi, t), new Dt(this.r * t, this.g * t, this.b * t, this.opacity); }, darker(t) { - return t = t == null ? _r : Math.pow(_r, t), new Mt(this.r * t, this.g * t, this.b * t, this.opacity); + return t = t == null ? Sr : Math.pow(Sr, t), new Dt(this.r * t, this.g * t, this.b * t, this.opacity); }, rgb() { return this; }, clamp() { - return new Mt(bn(this.r), bn(this.g), bn(this.b), ni(this.opacity)); + return new Dt(Mn(this.r), Mn(this.g), Mn(this.b), ci(this.opacity)); }, displayable() { return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1; }, - hex: Zs, + hex: oa, // Deprecated! Use color.formatHex. - formatHex: Zs, - formatHex8: bc, - formatRgb: Js, - toString: Js + formatHex: oa, + formatHex8: $c, + formatRgb: la, + toString: la })); -function Zs() { - return `#${cn(this.r)}${cn(this.g)}${cn(this.b)}`; +function oa() { + return `#${xn(this.r)}${xn(this.g)}${xn(this.b)}`; } -function bc() { - return `#${cn(this.r)}${cn(this.g)}${cn(this.b)}${cn((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; +function $c() { + return `#${xn(this.r)}${xn(this.g)}${xn(this.b)}${xn((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; } -function Js() { - const t = ni(this.opacity); - return `${t === 1 ? "rgb(" : "rgba("}${bn(this.r)}, ${bn(this.g)}, ${bn(this.b)}${t === 1 ? ")" : `, ${t})`}`; +function la() { + const t = ci(this.opacity); + return `${t === 1 ? "rgb(" : "rgba("}${Mn(this.r)}, ${Mn(this.g)}, ${Mn(this.b)}${t === 1 ? ")" : `, ${t})`}`; } -function ni(t) { +function ci(t) { return isNaN(t) ? 1 : Math.max(0, Math.min(1, t)); } -function bn(t) { +function Mn(t) { return Math.max(0, Math.min(255, Math.round(t) || 0)); } -function cn(t) { - return t = bn(t), (t < 16 ? "0" : "") + t.toString(16); +function xn(t) { + return t = Mn(t), (t < 16 ? "0" : "") + t.toString(16); } -function Qs(t, e, n, r) { - return r <= 0 ? t = e = n = NaN : n <= 0 || n >= 1 ? t = e = NaN : e <= 0 && (t = NaN), new fe(t, e, n, r); +function ua(t, e, n, r) { + return r <= 0 ? t = e = n = NaN : n <= 0 || n >= 1 ? t = e = NaN : e <= 0 && (t = NaN), new le(t, e, n, r); } -function To(t) { - if (t instanceof fe) return new fe(t.h, t.s, t.l, t.opacity); - if (t instanceof Cr || (t = Tn(t)), !t) return new fe(); - if (t instanceof fe) return t; +function Io(t) { + if (t instanceof le) return new le(t.h, t.s, t.l, t.opacity); + if (t instanceof zr || (t = In(t)), !t) return new le(); + if (t instanceof le) return t; t = t.rgb(); var e = t.r / 255, n = t.g / 255, r = t.b / 255, i = Math.min(e, n, r), s = Math.max(e, n, r), a = NaN, o = s - i, l = (s + i) / 2; - return o ? (e === s ? a = (n - r) / o + (n < r) * 6 : n === s ? a = (r - e) / o + 2 : a = (e - n) / o + 4, o /= l < 0.5 ? s + i : 2 - s - i, a *= 60) : o = l > 0 && l < 1 ? 0 : a, new fe(a, o, l, t.opacity); + return o ? (e === s ? a = (n - r) / o + (n < r) * 6 : n === s ? a = (r - e) / o + 2 : a = (e - n) / o + 4, o /= l < 0.5 ? s + i : 2 - s - i, a *= 60) : o = l > 0 && l < 1 ? 0 : a, new le(a, o, l, t.opacity); } -function $c(t, e, n, r) { - return arguments.length === 1 ? To(t) : new fe(t, e, n, r ?? 1); +function Ac(t, e, n, r) { + return arguments.length === 1 ? Io(t) : new le(t, e, n, r ?? 1); } -function fe(t, e, n, r) { +function le(t, e, n, r) { this.h = +t, this.s = +e, this.l = +n, this.opacity = +r; } -ws(fe, $c, Ro(Cr, { +ks(le, Ac, Oo(zr, { brighter(t) { - return t = t == null ? ei : Math.pow(ei, t), new fe(this.h, this.s, this.l * t, this.opacity); + return t = t == null ? fi : Math.pow(fi, t), new le(this.h, this.s, this.l * t, this.opacity); }, darker(t) { - return t = t == null ? _r : Math.pow(_r, t), new fe(this.h, this.s, this.l * t, this.opacity); + return t = t == null ? Sr : Math.pow(Sr, t), new le(this.h, this.s, this.l * t, this.opacity); }, rgb() { var t = this.h % 360 + (this.h < 0) * 360, e = isNaN(t) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < 0.5 ? n : 1 - n) * e, i = 2 * n - r; - return new Mt( - Mi(t >= 240 ? t - 240 : t + 120, i, r), - Mi(t, i, r), - Mi(t < 120 ? t + 240 : t - 120, i, r), + return new Dt( + Yi(t >= 240 ? t - 240 : t + 120, i, r), + Yi(t, i, r), + Yi(t < 120 ? t + 240 : t - 120, i, r), this.opacity ); }, clamp() { - return new fe(ta(this.h), Lr(this.s), Lr(this.l), ni(this.opacity)); + return new le(fa(this.h), Xr(this.s), Xr(this.l), ci(this.opacity)); }, displayable() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1; }, formatHsl() { - const t = ni(this.opacity); - return `${t === 1 ? "hsl(" : "hsla("}${ta(this.h)}, ${Lr(this.s) * 100}%, ${Lr(this.l) * 100}%${t === 1 ? ")" : `, ${t})`}`; + const t = ci(this.opacity); + return `${t === 1 ? "hsl(" : "hsla("}${fa(this.h)}, ${Xr(this.s) * 100}%, ${Xr(this.l) * 100}%${t === 1 ? ")" : `, ${t})`}`; } })); -function ta(t) { +function fa(t) { return t = (t || 0) % 360, t < 0 ? t + 360 : t; } -function Lr(t) { +function Xr(t) { return Math.max(0, Math.min(1, t || 0)); } -function Mi(t, e, n) { +function Yi(t, e, n) { return (t < 60 ? e + (n - e) * t / 60 : t < 180 ? n : t < 240 ? e + (n - e) * (240 - t) / 60 : e) * 255; } -const xs = (t) => () => t; -function Ac(t, e) { +const Ms = (t) => () => t; +function Ec(t, e) { return function(n) { return t + n * e; }; } -function Ec(t, e, n) { +function Rc(t, e, n) { return t = Math.pow(t, n), e = Math.pow(e, n) - t, n = 1 / n, function(r) { return Math.pow(t + r * e, n); }; } -function Rc(t) { - return (t = +t) == 1 ? Co : function(e, n) { - return n - e ? Ec(e, n, t) : xs(isNaN(e) ? n : e); +function Cc(t) { + return (t = +t) == 1 ? Lo : function(e, n) { + return n - e ? Rc(e, n, t) : Ms(isNaN(e) ? n : e); }; } -function Co(t, e) { +function Lo(t, e) { var n = e - t; - return n ? Ac(t, n) : xs(isNaN(t) ? e : t); + return n ? Ec(t, n) : Ms(isNaN(t) ? e : t); } -const ri = (function t(e) { - var n = Rc(e); +const hi = (function t(e) { + var n = Cc(e); function r(i, s) { - var a = n((i = ji(i)).r, (s = ji(s)).r), o = n(i.g, s.g), l = n(i.b, s.b), u = Co(i.opacity, s.opacity); + var a = n((i = os(i)).r, (s = os(s)).r), o = n(i.g, s.g), l = n(i.b, s.b), u = Lo(i.opacity, s.opacity); return function(f) { return i.r = a(f), i.g = o(f), i.b = l(f), i.opacity = u(f), i + ""; }; @@ -3804,64 +3804,64 @@ function Tc(t, e) { return r; }; } -function Cc(t) { +function Nc(t) { return ArrayBuffer.isView(t) && !(t instanceof DataView); } -function Nc(t, e) { +function Sc(t, e) { var n = e ? e.length : 0, r = t ? Math.min(n, t.length) : 0, i = new Array(r), s = new Array(n), a; - for (a = 0; a < r; ++a) i[a] = On(t[a], e[a]); + for (a = 0; a < r; ++a) i[a] = Wn(t[a], e[a]); for (; a < n; ++a) s[a] = e[a]; return function(o) { for (a = 0; a < r; ++a) s[a] = i[a](o); return s; }; } -function Sc(t, e) { +function kc(t, e) { var n = /* @__PURE__ */ new Date(); return t = +t, e = +e, function(r) { return n.setTime(t * (1 - r) + e * r), n; }; } -function Te(t, e) { +function Ee(t, e) { return t = +t, e = +e, function(n) { return t * (1 - n) + e * n; }; } -function kc(t, e) { +function Mc(t, e) { var n = {}, r = {}, i; (t === null || typeof t != "object") && (t = {}), (e === null || typeof e != "object") && (e = {}); for (i in e) - i in t ? n[i] = On(t[i], e[i]) : r[i] = e[i]; + i in t ? n[i] = Wn(t[i], e[i]) : r[i] = e[i]; return function(s) { for (i in n) r[i] = n[i](s); return r; }; } -var Zi = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Pi = new RegExp(Zi.source, "g"); -function Mc(t) { +var ls = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Bi = new RegExp(ls.source, "g"); +function Pc(t) { return function() { return t; }; } -function Pc(t) { +function Dc(t) { return function(e) { return t(e) + ""; }; } -function No(t, e) { - var n = Zi.lastIndex = Pi.lastIndex = 0, r, i, s, a = -1, o = [], l = []; - for (t = t + "", e = e + ""; (r = Zi.exec(t)) && (i = Pi.exec(e)); ) - (s = i.index) > n && (s = e.slice(n, s), o[a] ? o[a] += s : o[++a] = s), (r = r[0]) === (i = i[0]) ? o[a] ? o[a] += i : o[++a] = i : (o[++a] = null, l.push({ i: a, x: Te(r, i) })), n = Pi.lastIndex; - return n < e.length && (s = e.slice(n), o[a] ? o[a] += s : o[++a] = s), o.length < 2 ? l[0] ? Pc(l[0].x) : Mc(e) : (e = l.length, function(u) { +function qo(t, e) { + var n = ls.lastIndex = Bi.lastIndex = 0, r, i, s, a = -1, o = [], l = []; + for (t = t + "", e = e + ""; (r = ls.exec(t)) && (i = Bi.exec(e)); ) + (s = i.index) > n && (s = e.slice(n, s), o[a] ? o[a] += s : o[++a] = s), (r = r[0]) === (i = i[0]) ? o[a] ? o[a] += i : o[++a] = i : (o[++a] = null, l.push({ i: a, x: Ee(r, i) })), n = Bi.lastIndex; + return n < e.length && (s = e.slice(n), o[a] ? o[a] += s : o[++a] = s), o.length < 2 ? l[0] ? Dc(l[0].x) : Pc(e) : (e = l.length, function(u) { for (var f = 0, h; f < e; ++f) o[(h = l[f]).i] = h.x(u); return o.join(""); }); } -function On(t, e) { +function Wn(t, e) { var n = typeof e, r; - return e == null || n === "boolean" ? xs(e) : (n === "number" ? Te : n === "string" ? (r = Tn(e)) ? (e = r, ri) : No : e instanceof Tn ? ri : e instanceof Date ? Sc : Cc(e) ? Tc : Array.isArray(e) ? Nc : typeof e.valueOf != "function" && typeof e.toString != "function" || isNaN(e) ? kc : Te)(t, e); + return e == null || n === "boolean" ? Ms(e) : (n === "number" ? Ee : n === "string" ? (r = In(e)) ? (e = r, hi) : qo : e instanceof In ? hi : e instanceof Date ? kc : Nc(e) ? Tc : Array.isArray(e) ? Sc : typeof e.valueOf != "function" && typeof e.toString != "function" || isNaN(e) ? Mc : Ee)(t, e); } -var ea = 180 / Math.PI, Ji = { +var ca = 180 / Math.PI, us = { translateX: 0, translateY: 0, rotate: 0, @@ -3869,45 +3869,45 @@ var ea = 180 / Math.PI, Ji = { scaleX: 1, scaleY: 1 }; -function So(t, e, n, r, i, s) { +function Vo(t, e, n, r, i, s) { var a, o, l; return (a = Math.sqrt(t * t + e * e)) && (t /= a, e /= a), (l = t * n + e * r) && (n -= t * l, r -= e * l), (o = Math.sqrt(n * n + r * r)) && (n /= o, r /= o, l /= o), t * r < e * n && (t = -t, e = -e, l = -l, a = -a), { translateX: i, translateY: s, - rotate: Math.atan2(e, t) * ea, - skewX: Math.atan(l) * ea, + rotate: Math.atan2(e, t) * ca, + skewX: Math.atan(l) * ca, scaleX: a, scaleY: o }; } -var qr; -function Oc(t) { +var Gr; +function Fc(t) { const e = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(t + ""); - return e.isIdentity ? Ji : So(e.a, e.b, e.c, e.d, e.e, e.f); + return e.isIdentity ? us : Vo(e.a, e.b, e.c, e.d, e.e, e.f); } -function Dc(t) { - return t == null || (qr || (qr = document.createElementNS("http://www.w3.org/2000/svg", "g")), qr.setAttribute("transform", t), !(t = qr.transform.baseVal.consolidate())) ? Ji : (t = t.matrix, So(t.a, t.b, t.c, t.d, t.e, t.f)); +function Oc(t) { + return t == null || (Gr || (Gr = document.createElementNS("http://www.w3.org/2000/svg", "g")), Gr.setAttribute("transform", t), !(t = Gr.transform.baseVal.consolidate())) ? us : (t = t.matrix, Vo(t.a, t.b, t.c, t.d, t.e, t.f)); } -function ko(t, e, n, r) { +function zo(t, e, n, r) { function i(u) { return u.length ? u.pop() + " " : ""; } function s(u, f, h, c, v, g) { if (u !== h || f !== c) { var m = v.push("translate(", null, e, null, n); - g.push({ i: m - 4, x: Te(u, h) }, { i: m - 2, x: Te(f, c) }); + g.push({ i: m - 4, x: Ee(u, h) }, { i: m - 2, x: Ee(f, c) }); } else (h || c) && v.push("translate(" + h + e + c + n); } function a(u, f, h, c) { - u !== f ? (u - f > 180 ? f += 360 : f - u > 180 && (u += 360), c.push({ i: h.push(i(h) + "rotate(", null, r) - 2, x: Te(u, f) })) : f && h.push(i(h) + "rotate(" + f + r); + u !== f ? (u - f > 180 ? f += 360 : f - u > 180 && (u += 360), c.push({ i: h.push(i(h) + "rotate(", null, r) - 2, x: Ee(u, f) })) : f && h.push(i(h) + "rotate(" + f + r); } function o(u, f, h, c) { - u !== f ? c.push({ i: h.push(i(h) + "skewX(", null, r) - 2, x: Te(u, f) }) : f && h.push(i(h) + "skewX(" + f + r); + u !== f ? c.push({ i: h.push(i(h) + "skewX(", null, r) - 2, x: Ee(u, f) }) : f && h.push(i(h) + "skewX(" + f + r); } function l(u, f, h, c, v, g) { if (u !== h || f !== c) { var m = v.push(i(v) + "scale(", null, ",", null, ")"); - g.push({ i: m - 4, x: Te(u, h) }, { i: m - 2, x: Te(f, c) }); + g.push({ i: m - 4, x: Ee(u, h) }, { i: m - 2, x: Ee(f, c) }); } else (h !== 1 || c !== 1) && v.push(i(v) + "scale(" + h + "," + c + ")"); } return function(u, f) { @@ -3918,138 +3918,138 @@ function ko(t, e, n, r) { }; }; } -var Ic = ko(Oc, "px, ", "px)", "deg)"), Fc = ko(Dc, ", ", ")", ")"), Jn = 0, ur = 0, or = 0, Mo = 1e3, ii, fr, si = 0, Cn = 0, wi = 0, yr = typeof performance == "object" && performance.now ? performance : Date, Po = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(t) { +var Ic = zo(Fc, "px, ", "px)", "deg)"), Lc = zo(Oc, ", ", ")", ")"), fr = 0, br = 0, wr = 0, Ho = 1e3, di, $r, pi = 0, Ln = 0, Ni = 0, Mr = typeof performance == "object" && performance.now ? performance : Date, Yo = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(t) { setTimeout(t, 17); }; -function bs() { - return Cn || (Po(Lc), Cn = yr.now() + wi); +function Ps() { + return Ln || (Yo(qc), Ln = Mr.now() + Ni); } -function Lc() { - Cn = 0; +function qc() { + Ln = 0; } -function ai() { +function vi() { this._call = this._time = this._next = null; } -ai.prototype = Oo.prototype = { - constructor: ai, +vi.prototype = Bo.prototype = { + constructor: vi, restart: function(t, e, n) { if (typeof t != "function") throw new TypeError("callback is not a function"); - n = (n == null ? bs() : +n) + (e == null ? 0 : +e), !this._next && fr !== this && (fr ? fr._next = this : ii = this, fr = this), this._call = t, this._time = n, Qi(); + n = (n == null ? Ps() : +n) + (e == null ? 0 : +e), !this._next && $r !== this && ($r ? $r._next = this : di = this, $r = this), this._call = t, this._time = n, fs(); }, stop: function() { - this._call && (this._call = null, this._time = 1 / 0, Qi()); + this._call && (this._call = null, this._time = 1 / 0, fs()); } }; -function Oo(t, e, n) { - var r = new ai(); +function Bo(t, e, n) { + var r = new vi(); return r.restart(t, e, n), r; } -function qc() { - bs(), ++Jn; - for (var t = ii, e; t; ) - (e = Cn - t._time) >= 0 && t._call.call(void 0, e), t = t._next; - --Jn; +function Vc() { + Ps(), ++fr; + for (var t = di, e; t; ) + (e = Ln - t._time) >= 0 && t._call.call(void 0, e), t = t._next; + --fr; } -function na() { - Cn = (si = yr.now()) + wi, Jn = ur = 0; +function ha() { + Ln = (pi = Mr.now()) + Ni, fr = br = 0; try { - qc(); + Vc(); } finally { - Jn = 0, zc(), Cn = 0; + fr = 0, Hc(), Ln = 0; } } -function Vc() { - var t = yr.now(), e = t - si; - e > Mo && (wi -= e, si = t); -} function zc() { - for (var t, e = ii, n, r = 1 / 0; e; ) - e._call ? (r > e._time && (r = e._time), t = e, e = e._next) : (n = e._next, e._next = null, e = t ? t._next = n : ii = n); - fr = t, Qi(r); + var t = Mr.now(), e = t - pi; + e > Ho && (Ni -= e, pi = t); } -function Qi(t) { - if (!Jn) { - ur && (ur = clearTimeout(ur)); - var e = t - Cn; - e > 24 ? (t < 1 / 0 && (ur = setTimeout(na, t - yr.now() - wi)), or && (or = clearInterval(or))) : (or || (si = yr.now(), or = setInterval(Vc, Mo)), Jn = 1, Po(na)); +function Hc() { + for (var t, e = di, n, r = 1 / 0; e; ) + e._call ? (r > e._time && (r = e._time), t = e, e = e._next) : (n = e._next, e._next = null, e = t ? t._next = n : di = n); + $r = t, fs(r); +} +function fs(t) { + if (!fr) { + br && (br = clearTimeout(br)); + var e = t - Ln; + e > 24 ? (t < 1 / 0 && (br = setTimeout(ha, t - Mr.now() - Ni)), wr && (wr = clearInterval(wr))) : (wr || (pi = Mr.now(), wr = setInterval(zc, Ho)), fr = 1, Yo(ha)); } } -function ra(t, e, n) { - var r = new ai(); +function da(t, e, n) { + var r = new vi(); return e = e == null ? 0 : +e, r.restart((i) => { r.stop(), t(i + e); }, e, n), r; } -var Hc = ho("start", "end", "cancel", "interrupt"), Yc = [], Do = 0, ia = 1, ts = 2, Gr = 3, sa = 4, es = 5, Kr = 6; -function xi(t, e, n, r, i, s) { +var Yc = $o("start", "end", "cancel", "interrupt"), Bc = [], Uo = 0, pa = 1, cs = 2, ni = 3, va = 4, hs = 5, ri = 6; +function Si(t, e, n, r, i, s) { var a = t.__transition; if (!a) t.__transition = {}; else if (n in a) return; - Bc(t, n, { + Uc(t, n, { name: e, index: r, // For context during callback. group: i, // For context during callback. - on: Hc, - tween: Yc, + on: Yc, + tween: Bc, time: s.time, delay: s.delay, duration: s.duration, ease: s.ease, timer: null, - state: Do + state: Uo }); } -function $s(t, e) { - var n = ve(t, e); - if (n.state > Do) throw new Error("too late; already scheduled"); +function Ds(t, e) { + var n = de(t, e); + if (n.state > Uo) throw new Error("too late; already scheduled"); return n; } -function Pe(t, e) { - var n = ve(t, e); - if (n.state > Gr) throw new Error("too late; already running"); +function ke(t, e) { + var n = de(t, e); + if (n.state > ni) throw new Error("too late; already running"); return n; } -function ve(t, e) { +function de(t, e) { var n = t.__transition; if (!n || !(n = n[e])) throw new Error("transition not found"); return n; } -function Bc(t, e, n) { +function Uc(t, e, n) { var r = t.__transition, i; - r[e] = n, n.timer = Oo(s, 0, n.time); + r[e] = n, n.timer = Bo(s, 0, n.time); function s(u) { - n.state = ia, n.timer.restart(a, n.delay, n.time), n.delay <= u && a(u - n.delay); + n.state = pa, n.timer.restart(a, n.delay, n.time), n.delay <= u && a(u - n.delay); } function a(u) { var f, h, c, v; - if (n.state !== ia) return l(); + if (n.state !== pa) return l(); for (f in r) if (v = r[f], v.name === n.name) { - if (v.state === Gr) return ra(a); - v.state === sa ? (v.state = Kr, v.timer.stop(), v.on.call("interrupt", t, t.__data__, v.index, v.group), delete r[f]) : +f < e && (v.state = Kr, v.timer.stop(), v.on.call("cancel", t, t.__data__, v.index, v.group), delete r[f]); + if (v.state === ni) return da(a); + v.state === va ? (v.state = ri, v.timer.stop(), v.on.call("interrupt", t, t.__data__, v.index, v.group), delete r[f]) : +f < e && (v.state = ri, v.timer.stop(), v.on.call("cancel", t, t.__data__, v.index, v.group), delete r[f]); } - if (ra(function() { - n.state === Gr && (n.state = sa, n.timer.restart(o, n.delay, n.time), o(u)); - }), n.state = ts, n.on.call("start", t, t.__data__, n.index, n.group), n.state === ts) { - for (n.state = Gr, i = new Array(c = n.tween.length), f = 0, h = -1; f < c; ++f) + if (da(function() { + n.state === ni && (n.state = va, n.timer.restart(o, n.delay, n.time), o(u)); + }), n.state = cs, n.on.call("start", t, t.__data__, n.index, n.group), n.state === cs) { + for (n.state = ni, i = new Array(c = n.tween.length), f = 0, h = -1; f < c; ++f) (v = n.tween[f].value.call(t, t.__data__, n.index, n.group)) && (i[++h] = v); i.length = h + 1; } } function o(u) { - for (var f = u < n.duration ? n.ease.call(null, u / n.duration) : (n.timer.restart(l), n.state = es, 1), h = -1, c = i.length; ++h < c; ) + for (var f = u < n.duration ? n.ease.call(null, u / n.duration) : (n.timer.restart(l), n.state = hs, 1), h = -1, c = i.length; ++h < c; ) i[h].call(t, f); - n.state === es && (n.on.call("end", t, t.__data__, n.index, n.group), l()); + n.state === hs && (n.on.call("end", t, t.__data__, n.index, n.group), l()); } function l() { - n.state = Kr, n.timer.stop(), delete r[e]; + n.state = ri, n.timer.stop(), delete r[e]; for (var u in r) return; delete t.__transition; } } -function Uc(t, e) { +function Wc(t, e) { var n = t.__transition, r, i, s = !0, a; if (n) { e = e == null ? null : e + ""; @@ -4058,20 +4058,20 @@ function Uc(t, e) { s = !1; continue; } - i = r.state > ts && r.state < es, r.state = Kr, r.timer.stop(), r.on.call(i ? "interrupt" : "cancel", t, t.__data__, r.index, r.group), delete n[a]; + i = r.state > cs && r.state < hs, r.state = ri, r.timer.stop(), r.on.call(i ? "interrupt" : "cancel", t, t.__data__, r.index, r.group), delete n[a]; } s && delete t.__transition; } } function Xc(t) { return this.each(function() { - Uc(this, t); + Wc(this, t); }); } function Gc(t, e) { var n, r; return function() { - var i = Pe(this, t), s = i.tween; + var i = ke(this, t), s = i.tween; if (s !== n) { r = n = s; for (var a = 0, o = r.length; a < o; ++a) @@ -4087,7 +4087,7 @@ function Kc(t, e, n) { var r, i; if (typeof n != "function") throw new Error(); return function() { - var s = Pe(this, t), a = s.tween; + var s = ke(this, t), a = s.tween; if (a !== r) { i = (r = a).slice(); for (var o = { name: e, value: n }, l = 0, u = i.length; l < u; ++l) @@ -4100,268 +4100,268 @@ function Kc(t, e, n) { s.tween = i; }; } -function Wc(t, e) { +function jc(t, e) { var n = this._id; if (t += "", arguments.length < 2) { - for (var r = ve(this.node(), n).tween, i = 0, s = r.length, a; i < s; ++i) + for (var r = de(this.node(), n).tween, i = 0, s = r.length, a; i < s; ++i) if ((a = r[i]).name === t) return a.value; return null; } return this.each((e == null ? Gc : Kc)(n, t, e)); } -function As(t, e, n) { +function Fs(t, e, n) { var r = t._id; return t.each(function() { - var i = Pe(this, r); + var i = ke(this, r); (i.value || (i.value = {}))[e] = n.apply(this, arguments); }), function(i) { - return ve(i, r).value[e]; + return de(i, r).value[e]; }; } -function Io(t, e) { +function Wo(t, e) { var n; - return (typeof e == "number" ? Te : e instanceof Tn ? ri : (n = Tn(e)) ? (e = n, ri) : No)(t, e); + return (typeof e == "number" ? Ee : e instanceof In ? hi : (n = In(e)) ? (e = n, hi) : qo)(t, e); } -function jc(t) { +function Zc(t) { return function() { this.removeAttribute(t); }; } -function Zc(t) { +function Jc(t) { return function() { this.removeAttributeNS(t.space, t.local); }; } -function Jc(t, e, n) { +function Qc(t, e, n) { var r, i = n + "", s; return function() { var a = this.getAttribute(t); return a === i ? null : a === r ? s : s = e(r = a, n); }; } -function Qc(t, e, n) { +function th(t, e, n) { var r, i = n + "", s; return function() { var a = this.getAttributeNS(t.space, t.local); return a === i ? null : a === r ? s : s = e(r = a, n); }; } -function th(t, e, n) { +function eh(t, e, n) { var r, i, s; return function() { var a, o = n(this), l; return o == null ? void this.removeAttribute(t) : (a = this.getAttribute(t), l = o + "", a === l ? null : a === r && l === i ? s : (i = l, s = e(r = a, o))); }; } -function eh(t, e, n) { +function nh(t, e, n) { var r, i, s; return function() { var a, o = n(this), l; return o == null ? void this.removeAttributeNS(t.space, t.local) : (a = this.getAttributeNS(t.space, t.local), l = o + "", a === l ? null : a === r && l === i ? s : (i = l, s = e(r = a, o))); }; } -function nh(t, e) { - var n = yi(t), r = n === "transform" ? Fc : Io; - return this.attrTween(t, typeof e == "function" ? (n.local ? eh : th)(n, r, As(this, "attr." + t, e)) : e == null ? (n.local ? Zc : jc)(n) : (n.local ? Qc : Jc)(n, r, e)); -} function rh(t, e) { + var n = Ti(t), r = n === "transform" ? Lc : Wo; + return this.attrTween(t, typeof e == "function" ? (n.local ? nh : eh)(n, r, Fs(this, "attr." + t, e)) : e == null ? (n.local ? Jc : Zc)(n) : (n.local ? th : Qc)(n, r, e)); +} +function ih(t, e) { return function(n) { this.setAttribute(t, e.call(this, n)); }; } -function ih(t, e) { +function sh(t, e) { return function(n) { this.setAttributeNS(t.space, t.local, e.call(this, n)); }; } -function sh(t, e) { +function ah(t, e) { var n, r; function i() { var s = e.apply(this, arguments); - return s !== r && (n = (r = s) && ih(t, s)), n; + return s !== r && (n = (r = s) && sh(t, s)), n; } return i._value = e, i; } -function ah(t, e) { +function oh(t, e) { var n, r; function i() { var s = e.apply(this, arguments); - return s !== r && (n = (r = s) && rh(t, s)), n; + return s !== r && (n = (r = s) && ih(t, s)), n; } return i._value = e, i; } -function oh(t, e) { +function lh(t, e) { var n = "attr." + t; if (arguments.length < 2) return (n = this.tween(n)) && n._value; if (e == null) return this.tween(n, null); if (typeof e != "function") throw new Error(); - var r = yi(t); - return this.tween(n, (r.local ? sh : ah)(r, e)); + var r = Ti(t); + return this.tween(n, (r.local ? ah : oh)(r, e)); } -function lh(t, e) { +function uh(t, e) { return function() { - $s(this, t).delay = +e.apply(this, arguments); + Ds(this, t).delay = +e.apply(this, arguments); }; } -function uh(t, e) { +function fh(t, e) { return e = +e, function() { - $s(this, t).delay = e; + Ds(this, t).delay = e; }; } -function fh(t) { +function ch(t) { var e = this._id; - return arguments.length ? this.each((typeof t == "function" ? lh : uh)(e, t)) : ve(this.node(), e).delay; + return arguments.length ? this.each((typeof t == "function" ? uh : fh)(e, t)) : de(this.node(), e).delay; } -function ch(t, e) { +function hh(t, e) { return function() { - Pe(this, t).duration = +e.apply(this, arguments); + ke(this, t).duration = +e.apply(this, arguments); }; } -function hh(t, e) { +function dh(t, e) { return e = +e, function() { - Pe(this, t).duration = e; + ke(this, t).duration = e; }; } -function dh(t) { +function ph(t) { var e = this._id; - return arguments.length ? this.each((typeof t == "function" ? ch : hh)(e, t)) : ve(this.node(), e).duration; + return arguments.length ? this.each((typeof t == "function" ? hh : dh)(e, t)) : de(this.node(), e).duration; } -function ph(t, e) { +function vh(t, e) { if (typeof e != "function") throw new Error(); return function() { - Pe(this, t).ease = e; + ke(this, t).ease = e; }; } -function vh(t) { +function gh(t) { var e = this._id; - return arguments.length ? this.each(ph(e, t)) : ve(this.node(), e).ease; + return arguments.length ? this.each(vh(e, t)) : de(this.node(), e).ease; } -function gh(t, e) { +function _h(t, e) { return function() { var n = e.apply(this, arguments); if (typeof n != "function") throw new Error(); - Pe(this, t).ease = n; + ke(this, t).ease = n; }; } -function _h(t) { +function mh(t) { if (typeof t != "function") throw new Error(); - return this.each(gh(this._id, t)); + return this.each(_h(this._id, t)); } -function mh(t) { - typeof t != "function" && (t = go(t)); +function yh(t) { + typeof t != "function" && (t = Ro(t)); for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i) for (var s = e[i], a = s.length, o = r[i] = [], l, u = 0; u < a; ++u) (l = s[u]) && t.call(l, l.__data__, u, s) && o.push(l); - return new Be(r, this._parents, this._name, this._id); + return new Ke(r, this._parents, this._name, this._id); } -function yh(t) { +function wh(t) { if (t._id !== this._id) throw new Error(); for (var e = this._groups, n = t._groups, r = e.length, i = n.length, s = Math.min(r, i), a = new Array(r), o = 0; o < s; ++o) for (var l = e[o], u = n[o], f = l.length, h = a[o] = new Array(f), c, v = 0; v < f; ++v) (c = l[v] || u[v]) && (h[v] = c); for (; o < r; ++o) a[o] = e[o]; - return new Be(a, this._parents, this._name, this._id); + return new Ke(a, this._parents, this._name, this._id); } -function wh(t) { +function xh(t) { return (t + "").trim().split(/^|\s+/).every(function(e) { var n = e.indexOf("."); return n >= 0 && (e = e.slice(0, n)), !e || e === "start"; }); } -function xh(t, e, n) { - var r, i, s = wh(e) ? $s : Pe; +function bh(t, e, n) { + var r, i, s = xh(e) ? Ds : ke; return function() { var a = s(this, t), o = a.on; o !== r && (i = (r = o).copy()).on(e, n), a.on = i; }; } -function bh(t, e) { +function $h(t, e) { var n = this._id; - return arguments.length < 2 ? ve(this.node(), n).on.on(t) : this.each(xh(n, t, e)); + return arguments.length < 2 ? de(this.node(), n).on.on(t) : this.each(bh(n, t, e)); } -function $h(t) { +function Ah(t) { return function() { var e = this.parentNode; for (var n in this.__transition) if (+n !== t) return; e && e.removeChild(this); }; } -function Ah() { - return this.on("end.remove", $h(this._id)); +function Eh() { + return this.on("end.remove", Ah(this._id)); } -function Eh(t) { +function Rh(t) { var e = this._name, n = this._id; - typeof t != "function" && (t = ms(t)); + typeof t != "function" && (t = Ns(t)); for (var r = this._groups, i = r.length, s = new Array(i), a = 0; a < i; ++a) for (var o = r[a], l = o.length, u = s[a] = new Array(l), f, h, c = 0; c < l; ++c) - (f = o[c]) && (h = t.call(f, f.__data__, c, o)) && ("__data__" in f && (h.__data__ = f.__data__), u[c] = h, xi(u[c], e, n, c, u, ve(f, n))); - return new Be(s, this._parents, e, n); + (f = o[c]) && (h = t.call(f, f.__data__, c, o)) && ("__data__" in f && (h.__data__ = f.__data__), u[c] = h, Si(u[c], e, n, c, u, de(f, n))); + return new Ke(s, this._parents, e, n); } -function Rh(t) { +function Ch(t) { var e = this._name, n = this._id; - typeof t != "function" && (t = vo(t)); + typeof t != "function" && (t = Eo(t)); for (var r = this._groups, i = r.length, s = [], a = [], o = 0; o < i; ++o) for (var l = r[o], u = l.length, f, h = 0; h < u; ++h) if (f = l[h]) { - for (var c = t.call(f, f.__data__, h, l), v, g = ve(f, n), m = 0, b = c.length; m < b; ++m) - (v = c[m]) && xi(v, e, n, m, c, g); + for (var c = t.call(f, f.__data__, h, l), v, g = de(f, n), m = 0, b = c.length; m < b; ++m) + (v = c[m]) && Si(v, e, n, m, c, g); s.push(c), a.push(f); } - return new Be(s, a, e, n); + return new Ke(s, a, e, n); } -var Th = nr.prototype.constructor; -function Ch() { +var Th = dr.prototype.constructor; +function Nh() { return new Th(this._groups, this._parents); } -function Nh(t, e) { +function Sh(t, e) { var n, r, i; return function() { - var s = Zn(this, t), a = (this.style.removeProperty(t), Zn(this, t)); + var s = ur(this, t), a = (this.style.removeProperty(t), ur(this, t)); return s === a ? null : s === n && a === r ? i : i = e(n = s, r = a); }; } -function Fo(t) { +function Xo(t) { return function() { this.style.removeProperty(t); }; } -function Sh(t, e, n) { +function kh(t, e, n) { var r, i = n + "", s; return function() { - var a = Zn(this, t); + var a = ur(this, t); return a === i ? null : a === r ? s : s = e(r = a, n); }; } -function kh(t, e, n) { +function Mh(t, e, n) { var r, i, s; return function() { - var a = Zn(this, t), o = n(this), l = o + ""; - return o == null && (l = o = (this.style.removeProperty(t), Zn(this, t))), a === l ? null : a === r && l === i ? s : (i = l, s = e(r = a, o)); + var a = ur(this, t), o = n(this), l = o + ""; + return o == null && (l = o = (this.style.removeProperty(t), ur(this, t))), a === l ? null : a === r && l === i ? s : (i = l, s = e(r = a, o)); }; } -function Mh(t, e) { +function Ph(t, e) { var n, r, i, s = "style." + e, a = "end." + s, o; return function() { - var l = Pe(this, t), u = l.on, f = l.value[s] == null ? o || (o = Fo(e)) : void 0; + var l = ke(this, t), u = l.on, f = l.value[s] == null ? o || (o = Xo(e)) : void 0; (u !== n || i !== f) && (r = (n = u).copy()).on(a, i = f), l.on = r; }; } -function Ph(t, e, n) { - var r = (t += "") == "transform" ? Ic : Io; - return e == null ? this.styleTween(t, Nh(t, r)).on("end.style." + t, Fo(t)) : typeof e == "function" ? this.styleTween(t, kh(t, r, As(this, "style." + t, e))).each(Mh(this._id, t)) : this.styleTween(t, Sh(t, r, e), n).on("end.style." + t, null); +function Dh(t, e, n) { + var r = (t += "") == "transform" ? Ic : Wo; + return e == null ? this.styleTween(t, Sh(t, r)).on("end.style." + t, Xo(t)) : typeof e == "function" ? this.styleTween(t, Mh(t, r, Fs(this, "style." + t, e))).each(Ph(this._id, t)) : this.styleTween(t, kh(t, r, e), n).on("end.style." + t, null); } -function Oh(t, e, n) { +function Fh(t, e, n) { return function(r) { this.style.setProperty(t, e.call(this, r), n); }; } -function Dh(t, e, n) { +function Oh(t, e, n) { var r, i; function s() { var a = e.apply(this, arguments); - return a !== i && (r = (i = a) && Oh(t, a, n)), r; + return a !== i && (r = (i = a) && Fh(t, a, n)), r; } return s._value = e, s; } @@ -4370,110 +4370,110 @@ function Ih(t, e, n) { if (arguments.length < 2) return (r = this.tween(r)) && r._value; if (e == null) return this.tween(r, null); if (typeof e != "function") throw new Error(); - return this.tween(r, Dh(t, e, n ?? "")); + return this.tween(r, Oh(t, e, n ?? "")); } -function Fh(t) { +function Lh(t) { return function() { this.textContent = t; }; } -function Lh(t) { +function qh(t) { return function() { var e = t(this); this.textContent = e ?? ""; }; } -function qh(t) { - return this.tween("text", typeof t == "function" ? Lh(As(this, "text", t)) : Fh(t == null ? "" : t + "")); -} function Vh(t) { + return this.tween("text", typeof t == "function" ? qh(Fs(this, "text", t)) : Lh(t == null ? "" : t + "")); +} +function zh(t) { return function(e) { this.textContent = t.call(this, e); }; } -function zh(t) { +function Hh(t) { var e, n; function r() { var i = t.apply(this, arguments); - return i !== n && (e = (n = i) && Vh(i)), e; + return i !== n && (e = (n = i) && zh(i)), e; } return r._value = t, r; } -function Hh(t) { +function Yh(t) { var e = "text"; if (arguments.length < 1) return (e = this.tween(e)) && e._value; if (t == null) return this.tween(e, null); if (typeof t != "function") throw new Error(); - return this.tween(e, zh(t)); + return this.tween(e, Hh(t)); } -function Yh() { - for (var t = this._name, e = this._id, n = Lo(), r = this._groups, i = r.length, s = 0; s < i; ++s) +function Bh() { + for (var t = this._name, e = this._id, n = Go(), r = this._groups, i = r.length, s = 0; s < i; ++s) for (var a = r[s], o = a.length, l, u = 0; u < o; ++u) if (l = a[u]) { - var f = ve(l, e); - xi(l, t, n, u, a, { + var f = de(l, e); + Si(l, t, n, u, a, { time: f.time + f.delay + f.duration, delay: 0, duration: f.duration, ease: f.ease }); } - return new Be(r, this._parents, t, n); + return new Ke(r, this._parents, t, n); } -function Bh() { +function Uh() { var t, e, n = this, r = n._id, i = n.size(); return new Promise(function(s, a) { var o = { value: a }, l = { value: function() { --i === 0 && s(); } }; n.each(function() { - var u = Pe(this, r), f = u.on; + var u = ke(this, r), f = u.on; f !== t && (e = (t = f).copy(), e._.cancel.push(o), e._.interrupt.push(o), e._.end.push(l)), u.on = e; }), i === 0 && s(); }); } -var Uh = 0; -function Be(t, e, n, r) { +var Wh = 0; +function Ke(t, e, n, r) { this._groups = t, this._parents = e, this._name = n, this._id = r; } -function Wr(t) { - return nr().transition(t); -} -function Lo() { - return ++Uh; -} -var Oe = nr.prototype; -Be.prototype = Wr.prototype = { - constructor: Be, - select: Eh, - selectAll: Rh, - selectChild: Oe.selectChild, - selectChildren: Oe.selectChildren, - filter: mh, - merge: yh, - selection: Ch, - transition: Yh, - call: Oe.call, - nodes: Oe.nodes, - node: Oe.node, - size: Oe.size, - empty: Oe.empty, - each: Oe.each, - on: bh, - attr: nh, - attrTween: oh, - style: Ph, +function ii(t) { + return dr().transition(t); +} +function Go() { + return ++Wh; +} +var qe = dr.prototype; +Ke.prototype = ii.prototype = { + constructor: Ke, + select: Rh, + selectAll: Ch, + selectChild: qe.selectChild, + selectChildren: qe.selectChildren, + filter: yh, + merge: wh, + selection: Nh, + transition: Bh, + call: qe.call, + nodes: qe.nodes, + node: qe.node, + size: qe.size, + empty: qe.empty, + each: qe.each, + on: $h, + attr: rh, + attrTween: lh, + style: Dh, styleTween: Ih, - text: qh, - textTween: Hh, - remove: Ah, - tween: Wc, - delay: fh, - duration: dh, - ease: vh, - easeVarying: _h, - end: Bh, - [Symbol.iterator]: Oe[Symbol.iterator] + text: Vh, + textTween: Yh, + remove: Eh, + tween: jc, + delay: ch, + duration: ph, + ease: gh, + easeVarying: mh, + end: Uh, + [Symbol.iterator]: qe[Symbol.iterator] }; function Xh(t) { return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; @@ -4491,26 +4491,26 @@ function Kh(t, e) { throw new Error(`transition ${e} not found`); return n; } -function Wh(t) { +function jh(t) { var e, n; - t instanceof Be ? (e = t._id, t = t._name) : (e = Lo(), (n = Gh).time = bs(), t = t == null ? null : t + ""); + t instanceof Ke ? (e = t._id, t = t._name) : (e = Go(), (n = Gh).time = Ps(), t = t == null ? null : t + ""); for (var r = this._groups, i = r.length, s = 0; s < i; ++s) for (var a = r[s], o = a.length, l, u = 0; u < o; ++u) - (l = a[u]) && xi(l, t, e, u, a, n || Kh(l, e)); - return new Be(r, this._parents, t, e); + (l = a[u]) && Si(l, t, e, u, a, n || Kh(l, e)); + return new Ke(r, this._parents, t, e); } -nr.prototype.interrupt = Xc; -nr.prototype.transition = Wh; -const ns = Math.PI, rs = 2 * ns, an = 1e-6, jh = rs - an; -function qo(t) { +dr.prototype.interrupt = Xc; +dr.prototype.transition = jh; +const ds = Math.PI, ps = 2 * ds, gn = 1e-6, Zh = ps - gn; +function Ko(t) { this._ += t[0]; for (let e = 1, n = t.length; e < n; ++e) this._ += arguments[e] + t[e]; } -function Zh(t) { +function Jh(t) { let e = Math.floor(t); if (!(e >= 0)) throw new Error(`invalid digits: ${t}`); - if (e > 15) return qo; + if (e > 15) return Ko; const n = 10 ** e; return function(r) { this._ += r[0]; @@ -4518,10 +4518,10 @@ function Zh(t) { this._ += Math.round(arguments[i] * n) / n + r[i]; }; } -class Jh { +class Qh { constructor(e) { this._x0 = this._y0 = // start of current subpath - this._x1 = this._y1 = null, this._ = "", this._append = e == null ? qo : Zh(e); + this._x1 = this._y1 = null, this._ = "", this._append = e == null ? Ko : Jh(e); } moveTo(e, n) { this._append`M${this._x0 = this._x1 = +e},${this._y0 = this._y1 = +n}`; @@ -4543,17 +4543,17 @@ class Jh { let a = this._x1, o = this._y1, l = r - e, u = i - n, f = a - e, h = o - n, c = f * f + h * h; if (this._x1 === null) this._append`M${this._x1 = e},${this._y1 = n}`; - else if (c > an) if (!(Math.abs(h * l - u * f) > an) || !s) + else if (c > gn) if (!(Math.abs(h * l - u * f) > gn) || !s) this._append`L${this._x1 = e},${this._y1 = n}`; else { - let v = r - a, g = i - o, m = l * l + u * u, b = v * v + g * g, A = Math.sqrt(m), S = Math.sqrt(c), T = s * Math.tan((ns - Math.acos((m + c - b) / (2 * A * S))) / 2), D = T / S, E = T / A; - Math.abs(D - 1) > an && this._append`L${e + D * f},${n + D * h}`, this._append`A${s},${s},0,0,${+(h * v > f * g)},${this._x1 = e + E * l},${this._y1 = n + E * u}`; + let v = r - a, g = i - o, m = l * l + u * u, b = v * v + g * g, $ = Math.sqrt(m), C = Math.sqrt(c), T = s * Math.tan((ds - Math.acos((m + c - b) / (2 * $ * C))) / 2), N = T / C, I = T / $; + Math.abs(N - 1) > gn && this._append`L${e + N * f},${n + N * h}`, this._append`A${s},${s},0,0,${+(h * v > f * g)},${this._x1 = e + I * l},${this._y1 = n + I * u}`; } } arc(e, n, r, i, s, a) { if (e = +e, n = +n, r = +r, a = !!a, r < 0) throw new Error(`negative radius: ${r}`); let o = r * Math.cos(i), l = r * Math.sin(i), u = e + o, f = n + l, h = 1 ^ a, c = a ? i - s : s - i; - this._x1 === null ? this._append`M${u},${f}` : (Math.abs(this._x1 - u) > an || Math.abs(this._y1 - f) > an) && this._append`L${u},${f}`, r && (c < 0 && (c = c % rs + rs), c > jh ? this._append`A${r},${r},0,1,${h},${e - o},${n - l}A${r},${r},0,1,${h},${this._x1 = u},${this._y1 = f}` : c > an && this._append`A${r},${r},0,${+(c >= ns)},${h},${this._x1 = e + r * Math.cos(s)},${this._y1 = n + r * Math.sin(s)}`); + this._x1 === null ? this._append`M${u},${f}` : (Math.abs(this._x1 - u) > gn || Math.abs(this._y1 - f) > gn) && this._append`L${u},${f}`, r && (c < 0 && (c = c % ps + ps), c > Zh ? this._append`A${r},${r},0,1,${h},${e - o},${n - l}A${r},${r},0,1,${h},${this._x1 = u},${this._y1 = f}` : c > gn && this._append`A${r},${r},0,${+(c >= ds)},${h},${this._x1 = e + r * Math.cos(s)},${this._y1 = n + r * Math.sin(s)}`); } rect(e, n, r, i) { this._append`M${this._x0 = this._x1 = +e},${this._y0 = this._y1 = +n}h${r = +r}v${+i}h${-r}Z`; @@ -4562,24 +4562,24 @@ class Jh { return this._; } } -function Qh(t) { +function td(t) { for (var e = t.length / 6 | 0, n = new Array(e), r = 0; r < e; ) n[r] = "#" + t.slice(r * 6, ++r * 6); return n; } -const td = Qh("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"); -function Et(t) { +const ed = td("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"); +function Ct(t) { return function() { return t; }; } -const aa = Math.abs, $t = Math.atan2, sn = Math.cos, ed = Math.max, Oi = Math.min, xe = Math.sin, Dn = Math.sqrt, Ct = 1e-12, wr = Math.PI, oi = wr / 2, jr = 2 * wr; -function nd(t) { - return t > 1 ? 0 : t < -1 ? wr : Math.acos(t); +const ga = Math.abs, At = Math.atan2, vn = Math.cos, nd = Math.max, Ui = Math.min, we = Math.sin, Xn = Math.sqrt, St = 1e-12, Pr = Math.PI, gi = Pr / 2, si = 2 * Pr; +function rd(t) { + return t > 1 ? 0 : t < -1 ? Pr : Math.acos(t); } -function oa(t) { - return t >= 1 ? oi : t <= -1 ? -oi : Math.asin(t); +function _a(t) { + return t >= 1 ? gi : t <= -1 ? -gi : Math.asin(t); } -function rd(t) { +function id(t) { let e = 3; return t.digits = function(n) { if (!arguments.length) return e; @@ -4591,141 +4591,141 @@ function rd(t) { e = r; } return t; - }, () => new Jh(e); + }, () => new Qh(e); } -function id(t) { +function sd(t) { return t.innerRadius; } -function sd(t) { +function ad(t) { return t.outerRadius; } -function ad(t) { +function od(t) { return t.startAngle; } -function od(t) { +function ld(t) { return t.endAngle; } -function ld(t) { +function ud(t) { return t && t.padAngle; } -function ud(t, e, n, r, i, s, a, o) { +function fd(t, e, n, r, i, s, a, o) { var l = n - t, u = r - e, f = a - i, h = o - s, c = h * l - f * u; - if (!(c * c < Ct)) + if (!(c * c < St)) return c = (f * (e - s) - h * (t - i)) / c, [t + c * l, e + c * u]; } -function Vr(t, e, n, r, i, s, a) { - var o = t - n, l = e - r, u = (a ? s : -s) / Dn(o * o + l * l), f = u * l, h = -u * o, c = t + f, v = e + h, g = n + f, m = r + h, b = (c + g) / 2, A = (v + m) / 2, S = g - c, T = m - v, D = S * S + T * T, E = i - s, j = c * m - g * v, it = (T < 0 ? -1 : 1) * Dn(ed(0, E * E * D - j * j)), W = (j * T - S * it) / D, nt = (-j * S - T * it) / D, ut = (j * T + S * it) / D, ft = (-j * S + T * it) / D, G = W - b, x = nt - A, P = ut - b, zt = ft - A; - return G * G + x * x > P * P + zt * zt && (W = ut, nt = ft), { - cx: W, - cy: nt, +function Kr(t, e, n, r, i, s, a) { + var o = t - n, l = e - r, u = (a ? s : -s) / Xn(o * o + l * l), f = u * l, h = -u * o, c = t + f, v = e + h, g = n + f, m = r + h, b = (c + g) / 2, $ = (v + m) / 2, C = g - c, T = m - v, N = C * C + T * T, I = i - s, G = c * m - g * v, at = (T < 0 ? -1 : 1) * Xn(nd(0, I * I * N - G * G)), Z = (G * T - C * at) / N, et = (-G * C - T * at) / N, dt = (G * T + C * at) / N, H = (-G * C + T * at) / N, it = Z - b, A = et - $, E = dt - b, ht = H - $; + return it * it + A * A > E * E + ht * ht && (Z = dt, et = H), { + cx: Z, + cy: et, x01: -f, y01: -h, - x11: W * (i / E - 1), - y11: nt * (i / E - 1) + x11: Z * (i / I - 1), + y11: et * (i / I - 1) }; } -function De() { - var t = id, e = sd, n = Et(0), r = null, i = ad, s = od, a = ld, o = null, l = rd(u); +function Ve() { + var t = sd, e = ad, n = Ct(0), r = null, i = od, s = ld, a = ud, o = null, l = id(u); function u() { - var f, h, c = +t.apply(this, arguments), v = +e.apply(this, arguments), g = i.apply(this, arguments) - oi, m = s.apply(this, arguments) - oi, b = aa(m - g), A = m > g; - if (o || (o = f = l()), v < c && (h = v, v = c, c = h), !(v > Ct)) o.moveTo(0, 0); - else if (b > jr - Ct) - o.moveTo(v * sn(g), v * xe(g)), o.arc(0, 0, v, g, m, !A), c > Ct && (o.moveTo(c * sn(m), c * xe(m)), o.arc(0, 0, c, m, g, A)); + var f, h, c = +t.apply(this, arguments), v = +e.apply(this, arguments), g = i.apply(this, arguments) - gi, m = s.apply(this, arguments) - gi, b = ga(m - g), $ = m > g; + if (o || (o = f = l()), v < c && (h = v, v = c, c = h), !(v > St)) o.moveTo(0, 0); + else if (b > si - St) + o.moveTo(v * vn(g), v * we(g)), o.arc(0, 0, v, g, m, !$), c > St && (o.moveTo(c * vn(m), c * we(m)), o.arc(0, 0, c, m, g, $)); else { - var S = g, T = m, D = g, E = m, j = b, it = b, W = a.apply(this, arguments) / 2, nt = W > Ct && (r ? +r.apply(this, arguments) : Dn(c * c + v * v)), ut = Oi(aa(v - c) / 2, +n.apply(this, arguments)), ft = ut, G = ut, x, P; - if (nt > Ct) { - var zt = oa(nt / c * xe(W)), tt = oa(nt / v * xe(W)); - (j -= zt * 2) > Ct ? (zt *= A ? 1 : -1, D += zt, E -= zt) : (j = 0, D = E = (g + m) / 2), (it -= tt * 2) > Ct ? (tt *= A ? 1 : -1, S += tt, T -= tt) : (it = 0, S = T = (g + m) / 2); + var C = g, T = m, N = g, I = m, G = b, at = b, Z = a.apply(this, arguments) / 2, et = Z > St && (r ? +r.apply(this, arguments) : Xn(c * c + v * v)), dt = Ui(ga(v - c) / 2, +n.apply(this, arguments)), H = dt, it = dt, A, E; + if (et > St) { + var ht = _a(et / c * we(Z)), Me = _a(et / v * we(Z)); + (G -= ht * 2) > St ? (ht *= $ ? 1 : -1, N += ht, I -= ht) : (G = 0, N = I = (g + m) / 2), (at -= Me * 2) > St ? (Me *= $ ? 1 : -1, C += Me, T -= Me) : (at = 0, C = T = (g + m) / 2); } - var Ht = v * sn(S), Yt = v * xe(S), ne = c * sn(E), ge = c * xe(E); - if (ut > Ct) { - var Tt = v * sn(T), _e = v * xe(T), me = c * sn(D), Xe = c * xe(D), Ot; - if (b < wr) - if (Ot = ud(Ht, Yt, me, Xe, Tt, _e, ne, ge)) { - var nn = Ht - Ot[0], rn = Yt - Ot[1], Ge = Tt - Ot[0], Bt = _e - Ot[1], ye = 1 / xe(nd((nn * Ge + rn * Bt) / (Dn(nn * nn + rn * rn) * Dn(Ge * Ge + Bt * Bt))) / 2), Sn = Dn(Ot[0] * Ot[0] + Ot[1] * Ot[1]); - ft = Oi(ut, (c - Sn) / (ye - 1)), G = Oi(ut, (v - Sn) / (ye + 1)); + var tt = v * vn(C), te = v * we(C), Pe = c * vn(I), Ht = c * we(I); + if (dt > St) { + var pe = v * vn(T), Nt = v * we(T), ve = c * vn(N), ee = c * we(N), Rt; + if (b < Pr) + if (Rt = fd(tt, te, ve, ee, pe, Nt, Pe, Ht)) { + var ln = tt - Rt[0], un = te - Rt[1], fn = pe - Rt[0], ne = Nt - Rt[1], ge = 1 / we(rd((ln * fn + un * ne) / (Xn(ln * ln + un * un) * Xn(fn * fn + ne * ne))) / 2), Ze = Xn(Rt[0] * Rt[0] + Rt[1] * Rt[1]); + H = Ui(dt, (c - Ze) / (ge - 1)), it = Ui(dt, (v - Ze) / (ge + 1)); } else - ft = G = 0; + H = it = 0; } - it > Ct ? G > Ct ? (x = Vr(me, Xe, Ht, Yt, v, G, A), P = Vr(Tt, _e, ne, ge, v, G, A), o.moveTo(x.cx + x.x01, x.cy + x.y01), G < ut ? o.arc(x.cx, x.cy, G, $t(x.y01, x.x01), $t(P.y01, P.x01), !A) : (o.arc(x.cx, x.cy, G, $t(x.y01, x.x01), $t(x.y11, x.x11), !A), o.arc(0, 0, v, $t(x.cy + x.y11, x.cx + x.x11), $t(P.cy + P.y11, P.cx + P.x11), !A), o.arc(P.cx, P.cy, G, $t(P.y11, P.x11), $t(P.y01, P.x01), !A))) : (o.moveTo(Ht, Yt), o.arc(0, 0, v, S, T, !A)) : o.moveTo(Ht, Yt), !(c > Ct) || !(j > Ct) ? o.lineTo(ne, ge) : ft > Ct ? (x = Vr(ne, ge, Tt, _e, c, -ft, A), P = Vr(Ht, Yt, me, Xe, c, -ft, A), o.lineTo(x.cx + x.x01, x.cy + x.y01), ft < ut ? o.arc(x.cx, x.cy, ft, $t(x.y01, x.x01), $t(P.y01, P.x01), !A) : (o.arc(x.cx, x.cy, ft, $t(x.y01, x.x01), $t(x.y11, x.x11), !A), o.arc(0, 0, c, $t(x.cy + x.y11, x.cx + x.x11), $t(P.cy + P.y11, P.cx + P.x11), A), o.arc(P.cx, P.cy, ft, $t(P.y11, P.x11), $t(P.y01, P.x01), !A))) : o.arc(0, 0, c, E, D, A); + at > St ? it > St ? (A = Kr(ve, ee, tt, te, v, it, $), E = Kr(pe, Nt, Pe, Ht, v, it, $), o.moveTo(A.cx + A.x01, A.cy + A.y01), it < dt ? o.arc(A.cx, A.cy, it, At(A.y01, A.x01), At(E.y01, E.x01), !$) : (o.arc(A.cx, A.cy, it, At(A.y01, A.x01), At(A.y11, A.x11), !$), o.arc(0, 0, v, At(A.cy + A.y11, A.cx + A.x11), At(E.cy + E.y11, E.cx + E.x11), !$), o.arc(E.cx, E.cy, it, At(E.y11, E.x11), At(E.y01, E.x01), !$))) : (o.moveTo(tt, te), o.arc(0, 0, v, C, T, !$)) : o.moveTo(tt, te), !(c > St) || !(G > St) ? o.lineTo(Pe, Ht) : H > St ? (A = Kr(Pe, Ht, pe, Nt, c, -H, $), E = Kr(tt, te, ve, ee, c, -H, $), o.lineTo(A.cx + A.x01, A.cy + A.y01), H < dt ? o.arc(A.cx, A.cy, H, At(A.y01, A.x01), At(E.y01, E.x01), !$) : (o.arc(A.cx, A.cy, H, At(A.y01, A.x01), At(A.y11, A.x11), !$), o.arc(0, 0, c, At(A.cy + A.y11, A.cx + A.x11), At(E.cy + E.y11, E.cx + E.x11), $), o.arc(E.cx, E.cy, H, At(E.y11, E.x11), At(E.y01, E.x01), !$))) : o.arc(0, 0, c, I, N, $); } if (o.closePath(), f) return o = null, f + "" || null; } return u.centroid = function() { - var f = (+t.apply(this, arguments) + +e.apply(this, arguments)) / 2, h = (+i.apply(this, arguments) + +s.apply(this, arguments)) / 2 - wr / 2; - return [sn(h) * f, xe(h) * f]; + var f = (+t.apply(this, arguments) + +e.apply(this, arguments)) / 2, h = (+i.apply(this, arguments) + +s.apply(this, arguments)) / 2 - Pr / 2; + return [vn(h) * f, we(h) * f]; }, u.innerRadius = function(f) { - return arguments.length ? (t = typeof f == "function" ? f : Et(+f), u) : t; + return arguments.length ? (t = typeof f == "function" ? f : Ct(+f), u) : t; }, u.outerRadius = function(f) { - return arguments.length ? (e = typeof f == "function" ? f : Et(+f), u) : e; + return arguments.length ? (e = typeof f == "function" ? f : Ct(+f), u) : e; }, u.cornerRadius = function(f) { - return arguments.length ? (n = typeof f == "function" ? f : Et(+f), u) : n; + return arguments.length ? (n = typeof f == "function" ? f : Ct(+f), u) : n; }, u.padRadius = function(f) { - return arguments.length ? (r = f == null ? null : typeof f == "function" ? f : Et(+f), u) : r; + return arguments.length ? (r = f == null ? null : typeof f == "function" ? f : Ct(+f), u) : r; }, u.startAngle = function(f) { - return arguments.length ? (i = typeof f == "function" ? f : Et(+f), u) : i; + return arguments.length ? (i = typeof f == "function" ? f : Ct(+f), u) : i; }, u.endAngle = function(f) { - return arguments.length ? (s = typeof f == "function" ? f : Et(+f), u) : s; + return arguments.length ? (s = typeof f == "function" ? f : Ct(+f), u) : s; }, u.padAngle = function(f) { - return arguments.length ? (a = typeof f == "function" ? f : Et(+f), u) : a; + return arguments.length ? (a = typeof f == "function" ? f : Ct(+f), u) : a; }, u.context = function(f) { return arguments.length ? (o = f ?? null, u) : o; }, u; } -function fd(t) { +function cd(t) { return typeof t == "object" && "length" in t ? t : Array.from(t); } -function cd(t, e) { +function hd(t, e) { return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN; } -function hd(t) { +function dd(t) { return t; } -function la() { - var t = hd, e = cd, n = null, r = Et(0), i = Et(jr), s = Et(0); +function ma() { + var t = dd, e = hd, n = null, r = Ct(0), i = Ct(si), s = Ct(0); function a(o) { - var l, u = (o = fd(o)).length, f, h, c = 0, v = new Array(u), g = new Array(u), m = +r.apply(this, arguments), b = Math.min(jr, Math.max(-jr, i.apply(this, arguments) - m)), A, S = Math.min(Math.abs(b) / u, s.apply(this, arguments)), T = S * (b < 0 ? -1 : 1), D; + var l, u = (o = cd(o)).length, f, h, c = 0, v = new Array(u), g = new Array(u), m = +r.apply(this, arguments), b = Math.min(si, Math.max(-si, i.apply(this, arguments) - m)), $, C = Math.min(Math.abs(b) / u, s.apply(this, arguments)), T = C * (b < 0 ? -1 : 1), N; for (l = 0; l < u; ++l) - (D = g[v[l] = l] = +t(o[l], l, o)) > 0 && (c += D); - for (e != null ? v.sort(function(E, j) { - return e(g[E], g[j]); - }) : n != null && v.sort(function(E, j) { - return n(o[E], o[j]); - }), l = 0, h = c ? (b - u * T) / c : 0; l < u; ++l, m = A) - f = v[l], D = g[f], A = m + (D > 0 ? D * h : 0) + T, g[f] = { + (N = g[v[l] = l] = +t(o[l], l, o)) > 0 && (c += N); + for (e != null ? v.sort(function(I, G) { + return e(g[I], g[G]); + }) : n != null && v.sort(function(I, G) { + return n(o[I], o[G]); + }), l = 0, h = c ? (b - u * T) / c : 0; l < u; ++l, m = $) + f = v[l], N = g[f], $ = m + (N > 0 ? N * h : 0) + T, g[f] = { data: o[f], index: l, - value: D, + value: N, startAngle: m, - endAngle: A, - padAngle: S + endAngle: $, + padAngle: C }; return g; } return a.value = function(o) { - return arguments.length ? (t = typeof o == "function" ? o : Et(+o), a) : t; + return arguments.length ? (t = typeof o == "function" ? o : Ct(+o), a) : t; }, a.sortValues = function(o) { return arguments.length ? (e = o, n = null, a) : e; }, a.sort = function(o) { return arguments.length ? (n = o, e = null, a) : n; }, a.startAngle = function(o) { - return arguments.length ? (r = typeof o == "function" ? o : Et(+o), a) : r; + return arguments.length ? (r = typeof o == "function" ? o : Ct(+o), a) : r; }, a.endAngle = function(o) { - return arguments.length ? (i = typeof o == "function" ? o : Et(+o), a) : i; + return arguments.length ? (i = typeof o == "function" ? o : Ct(+o), a) : i; }, a.padAngle = function(o) { - return arguments.length ? (s = typeof o == "function" ? o : Et(+o), a) : s; + return arguments.length ? (s = typeof o == "function" ? o : Ct(+o), a) : s; }, a; } -function cr(t, e, n) { +function Ar(t, e, n) { this.k = t, this.x = e, this.y = n; } -cr.prototype = { - constructor: cr, +Ar.prototype = { + constructor: Ar, scale: function(t) { - return t === 1 ? this : new cr(this.k * t, this.x, this.y); + return t === 1 ? this : new Ar(this.k * t, this.x, this.y); }, translate: function(t, e) { - return t === 0 & e === 0 ? this : new cr(this.k, this.x + this.k * t, this.y + this.k * e); + return t === 0 & e === 0 ? this : new Ar(this.k, this.x + this.k * t, this.y + this.k * e); }, apply: function(t) { return [t[0] * this.k + this.x, t[1] * this.k + this.y]; @@ -4755,242 +4755,244 @@ cr.prototype = { return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; } }; -cr.prototype; -var dd = /* @__PURE__ */ vu(''); -const pd = { +Ar.prototype; +var pd = /* @__PURE__ */ gu(''); +const vd = { hash: "svelte-80ulj4", code: `.pie-chart-svg.svelte-80ulj4 {width:100%;height:100%;max-width:700px;max-height:60vh;aspect-ratio:1 / 1; /* For a perfect circle, use 1:1 ratio */margin:0 auto;display:block;} @media (max-width: 768px) {.pie-chart-svg.svelte-80ulj4 {max-height:60vh;} }` }; -function Vo(t, e) { - os(e, !0), uo(t, pd); - let n = ue(e, "jsonData", 7), r = ue(e, "currentRound", 7, 1), i = ue(e, "mouseEventType", 15), s = ue(e, "mouseData", 15), a = ue(e, "mouseY", 15), o = ue(e, "requestRoundChange", 7, (p) => { - }), l = ue(e, "candidateColors", 23, () => []); - function u(p) { +function jo(t, e) { + ms(e, !0), wo(t, vd); + let n = Et(e, "jsonData", 7), r = Et(e, "currentRound", 7, 1), i = Et(e, "mouseEventType", 15), s = Et(e, "mouseData", 15), a = Et(e, "mouseY", 15), o = Et(e, "requestRoundChange", 7, (p) => { + }), l = Et(e, "candidateColors", 23, () => []), u = Et(e, "excludeFinalWinnerAndEliminatedCandidate", 7, !1); + function f(p) { return p.isTransfer ? `${p.label}__transfer` : p.transferIndex != null ? `${p.label}__${p.transferIndex}` : p.label; } - const f = 800, h = 800, c = Math.min(f, h) * 0.3, v = f / 2, g = h / 2, m = "Pie", b = "Donut", A = "TextLayer", S = "url(#cross-hatch)", T = 1.15, D = 0.1, E = 750, j = 800; - function it(p) { + const h = 800, c = 800, v = Math.min(h, c) * 0.3, g = h / 2, m = c / 2, b = "Pie", $ = "Donut", C = "TextLayer", T = "url(#cross-hatch)", N = 1.15, I = 0.1, G = 750, at = 800; + function Z(p) { return "hatch-" + p.replace(/[^a-zA-Z0-9]/g, "-"); } - let W = [], nt = [], ut = [], ft = 0, G = /* @__PURE__ */ mt( + let et = [], dt = [], H = [], it = 0, A = /* @__PURE__ */ yt( 0 // $state just to make it inspectable - ), x = 0; - const P = {}, zt = "No Further Rankings"; - let tt = /* @__PURE__ */ mt(null); - function Ht() { + ), E = 0; + const ht = {}, Me = "No Further Rankings"; + let tt = /* @__PURE__ */ yt(null); + function te() { const p = gt(w(tt)); - p.select("#" + m).remove(), p.select("#" + b).remove(), p.select("#" + A).remove(); + p.select("#" + b).remove(), p.select("#" + $).remove(), p.select("#" + C).remove(); } - function Yt(p) { - o() && (st = p, o()(p)); + function Pe(p) { + o() && (K = p, o()(p)); } - function ne(p) { - Ht(), ut = ge(p), W = jo(p, m, ut, v, g, 0, Tt()); + function Ht(p) { + te(), H = pe(p), et = Zo(p, b, H, g, m, 0, Nt()); } - xu(() => { - rr(), setTimeout( + bu(() => { + Mi(), setTimeout( () => { - ne(r()); + Ht(r()); }, 0 ); }); - function ge(p) { - const _ = Nr(p); - return ft = rn(p), _; + function pe(p) { + const _ = zn(p); + return it = fn(p), _; } - function Tt() { - return c; + function Nt() { + return v; } - function _e() { - return Tt() * 1.41; + function ve() { + return Nt() * 1.41; } - function me(p) { + function ee(p) { let _ = 0; for (let y = 1; y < p; y++) { - const M = n().results[y - 1].tallyResults; - for (let R = 0; R < M.length; R++) { - const C = M[R].transfers; - if (C) { - const k = C.exhausted; - k && (_ += Number(k)); + const P = n().results[y - 1].tallyResults; + for (let R = 0; R < P.length; R++) { + const S = P[R].transfers; + if (S) { + const M = S.exhausted; + M && (_ += Number(M)); } } } return _; } - function Xe(p, _) { - if (p === "exhausted") return me(_); + function Rt(p, _) { + if (p === "exhausted") return ee(_); { const y = n().results[_ - 1].tally; return Number(y[p]); } } - function Ot(p, _) { - return Xe(p, _).toLocaleString("en-US"); + function ln(p, _) { + return Rt(p, _).toLocaleString("en-US"); } - function nn(p, _) { - return (Xe(p, _) / ft).toLocaleString("en-US", { style: "percent", minimumFractionDigits: 1 }); + function un(p, _) { + return (Rt(p, _) / it).toLocaleString("en-US", { style: "percent", minimumFractionDigits: 1 }); } - function rn(p) { + function fn(p) { const _ = n().results[p - 1].tally; let y = 0; - for (let [M, R] of Object.entries(_)) + for (let [P, R] of Object.entries(_)) y += Number(R); return y; } - function Ge(p, _) { + function ne(p, _) { if (!p || p < 1 || p > n().results.length) return console.warn("In chsoenCandidates: round ${round} is out of range."), []; - const y = n().results[p - 1].tallyResults, M = []; + if (u() && p === n().results.length) + return []; + const y = n().results[p - 1].tallyResults, P = []; for (let R = 0; R < y.length; R++) { - const C = y[R][_]; - C != null && M.push(C); + const S = y[R][_]; + S != null && P.push(S); } - return M; + return P; } - function Bt(p) { - return Ge(p, "eliminated"); + function ge(p) { + return ne(p, "eliminated"); } - function ye(p) { + function Ze(p) { let _ = []; - for (let y = 1; y <= p; y++) _ = _.concat(Ge(y, "elected")); + for (let y = 1; y <= p; y++) _ = _.concat(ne(y, "elected")); return _; } - function Sn(p, _) { + function ki(p, _) { const y = n().results[_ - 1].tallyResults; - let M = 0; - const R = y.findIndex((C) => (C == null ? void 0 : C.elected) && p == C.elected); + let P = 0; + const R = y.findIndex((S) => (S == null ? void 0 : S.elected) && p == S.elected); if (R >= 0) { - const C = y[R].transfers; - if (C) - for (let [k, I] of Object.entries(C)) M += Number(I); + const S = y[R].transfers; + if (S) + for (let [M, F] of Object.entries(S)) P += Number(F); } else return 0; - return M; + return P; } - function Nr(p) { + function zn(p) { const _ = n().results; let y = _[Math.max(0, p - 2)].tally; - const M = [], R = []; - for (let [k, I] of Object.entries(y)) - M.push({ label: k, value: 0 }); + const P = [], R = []; + for (let [M, F] of Object.entries(y)) + P.push({ label: M, value: 0 }); y = _[p - 1].tally; - for (let k of M) { - const I = Number(y[k.label]), q = Sn(k.label, p); + for (let M of P) { + const F = Number(y[M.label]), q = ki(M.label, p); q > 0 ? (R.push({ - label: k.label, + label: M.label, value: q, isTransfer: !0 - }), k.value = I - q, R.push(k)) : (k.value = I, R.push(k)); + }), M.value = F - q, R.push(M)) : (M.value = F, R.push(M)); } - const C = me(p); - return R.push({ label: "exhausted", value: C }), R; + const S = ee(p); + return R.push({ label: "exhausted", value: S }), R; } - function rr() { + function Mi() { const p = gt(w(tt)).select("defs").select("#cross-hatch"); let _ = 0; - for (let [y, M] of Object.entries(n().results[0].tally)) { - !l() || l().length === 0 ? _ < 10 ? P[y] = td[_] : P[y] = "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0") : P[y] = l()[_ % l().length], _++; + for (let [y, P] of Object.entries(n().results[0].tally)) { + !l() || l().length === 0 ? _ < 10 ? ht[y] = ed[_] : ht[y] = "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0") : ht[y] = l()[_ % l().length], _++; { const R = p.clone(!0); - R.attr("id", it(y)).select("rect").attr("fill", P[y]), R.selectAll("circle").attr("fill", "#383838"); + R.attr("id", Z(y)).select("rect").attr("fill", ht[y]), R.selectAll("circle").attr("fill", "#383838"); } } - P.exhausted = S, P["Inactive Ballots"] = S; + ht.exhausted = T, ht["Inactive Ballots"] = T; } - function bi() { - gt(w(tt)).select("#" + b).remove(); + function x() { + gt(w(tt)).select("#" + $).remove(); } - function $(p, _) { - const y = Wr("global").duration(j); - _ && y.on("end", _), bi(), Yo(p), Zo(), Qo(0, Tt()), kr(); + function B(p, _) { + const y = ii("global").duration(at); + _ && y.on("end", _), x(), Fe(p), Jo(), tl(0, Nt()), Hr(); } - function V(p, _) { - const y = Wr("global").duration(j); - _ && y.on("end", _), Bo(p); + function nt(p, _) { + const y = ii("global").duration(at); + _ && y.on("end", _), Oe(p); } - function et(p, _) { - const y = Wr("global").duration(j); - _ && y.on("end", _), zo(p), Ho(Tt()); + function ot(p, _) { + const y = ii("global").duration(at); + _ && y.on("end", _), Hn(p), Yn(Nt()); } - let K = !1, rt = []; - function Q() { - kr(), K = !1, At(); + let J = !1, rt = []; + function $t() { + Hr(), J = !1, Je(); } - function At() { + function Je() { if (rt.length === 0) { - st !== r() && (r() === st + 1 && st > 0 && r() <= n().results.length ? (st = r(), dt(r())) : r() >= 1 && r() <= n().results.length && (st = r(), J(G, 0), ne(r()))); + K !== r() && (r() === K + 1 && K > 0 && r() <= n().results.length ? (K = r(), re(r())) : r() >= 1 && r() <= n().results.length && (K = r(), Q(A, 0), Ht(r()))); return; } const p = rt.shift(); switch (p.type) { case "round": { const _ = p.round; - _ === st + 1 && st > 0 && _ <= n().results.length ? (st = _, dt(_)) : (_ !== st && _ >= 1 && _ <= n().results.length && (st = _, J(G, 0), ne(_)), At()); + _ === K + 1 && K > 0 && _ <= n().results.length ? (K = _, re(_)) : (_ !== K && _ >= 1 && _ <= n().results.length && (K = _, Q(A, 0), Ht(_)), Je()); break; } case "step": - kn(); + hn(); break; } } - function dt(p) { + function re(p) { if (p <= 1 || p > n().results.length) { - At(); + Je(); return; } - K = !0, x = p, J(G, 0), $(x - 1, () => { - V(x - 1, () => { - et(x, Q); + J = !0, E = p, Q(A, 0), B(E - 1, () => { + nt(E - 1, () => { + ot(E, $t); }); }); } - function re() { - K || (K = !0, x = r(), ie()); + function cn() { + J || (J = !0, E = r(), De()); } - function ie() { - if (J( - G, + function De() { + if (Q( + A, 0 // if in the middle of "one small step" animation, reset to 0. ), rt.length > 0) { - Q(); + $t(); return; } - const p = x < n().results.length - 1 ? ie : Q; - $(x, () => { - V(x, () => { - x++, Yt(x), et(x, p); + const p = E < n().results.length - 1 ? De : $t; + B(E, () => { + nt(E, () => { + E++, Pe(E), ot(E, p); }); }); } - ds(() => { - Ke(); + As(() => { + _e(); }); - let st = 0; - function Ke() { - if (st != r()) { - if (K) { + let K = 0; + function _e() { + if (K != r()) { + if (J) { rt.push({ type: "round", round: r() }); return; } - st == r() - 1 && st > 0 ? bt() : se(r()), st = r(); + K == r() - 1 && K > 0 ? Qe() : Yt(r()), K = r(); } } - function se(p) { - if (K) { + function Yt(p) { + if (J) { rt.push({ type: "round", round: p }); return; } - J(G, 0), ne(p); + Q(A, 0), Ht(p); } - function bt() { - if (K) { + function Qe() { + if (J) { rt.push({ type: "round", round: r() }); return; } @@ -4998,297 +5000,303 @@ function Vo(t, e) { console.warn(`animateOneRoundFn: can't animate to round ${r()}`); return; } - if (x = r(), x > n().results.length) { - kr(), K = !1; + if (E = r(), E > n().results.length) { + Hr(), J = !1; return; } - K = !0, w(G) === 0 ? $(x - 1, () => { - V(x - 1, () => { - et(x, Q); + J = !0, w(A) === 0 ? B(E - 1, () => { + nt(E - 1, () => { + ot(E, $t); }); - }) : w(G) === 1 ? V(x - 1, () => { - et(x, Q); - }) : w(G) === 2 && et(x, Q), J(G, 0); + }) : w(A) === 1 ? nt(E - 1, () => { + ot(E, $t); + }) : w(A) === 2 && ot(E, $t), Q(A, 0); } - function kn() { + function hn() { if (r() > n().results.length) { - kr(), K = !1; + Hr(), J = !1; return; } - if (K) { + if (J) { rt.push({ type: "step" }); return; } - K = !0, J(G, (w(G) + 1) % 3), x = r(), w(G) === 1 ? $(x, Q) : w(G) === 2 ? V(x, Q) : w(G) === 0 ? (x++, Yt(x), et(x, Q)) : (K = !1, console.warn("displayPhase out of range at ", w(G))); + J = !0, Q(A, (w(A) + 1) % 3), E = r(), w(A) === 1 ? B(E, $t) : w(A) === 2 ? nt(E, $t) : w(A) === 0 ? (E++, Pe(E), ot(E, $t)) : (J = !1, console.warn("displayPhase out of range at ", w(A))); } - function zo(p) { - ut = Nr(p), W = tl(p, m, ut, 0, Tt(), !0); + function Hn(p) { + H = zn(p), et = el(p, b, H, 0, Nt(), !0); } - function Ho(p, _) { - const y = gt(w(tt)).select("#" + b), M = De().outerRadius(p).innerRadius(p - 1), R = y.selectAll(".slice"); - let C = R.size(); - function k() { - C--, C === 0 && Jo(); + function Yn(p, _) { + const y = gt(w(tt)).select("#" + $), P = Ve().outerRadius(p).innerRadius(p - 1), R = y.selectAll(".slice"); + let S = R.size(); + function M() { + S--, S === 0 && Qo(); } - R.select("path").transition("global").duration(E).attr("d", (I) => M(I)).on("end", (I) => k()); + R.select("path").transition("global").duration(G).attr("d", (F) => P(F)).on("end", (F) => M()); } - function Yo(p) { - const _ = Xo(p, W); - nt = Ts(p, b, _, v, g, Tt(), _e(), !1, !0); + function Fe(p) { + const _ = vr(p, et); + dt = Is(p, $, _, g, m, Nt(), ve(), !1, !0); } - function Bo(p) { - const _ = Ko(p, nt, W); - nt = Cs(p, b, _, Tt(), _e(), !1); + function Oe(p) { + const _ = Le(p, dt, et); + dt = Ls(p, $, _, Nt(), ve(), !1); } - function Sr(p) { - return P[p.data.label]; + function Ie(p) { + return ht[p.data.label]; } - function Uo(p) { + function pr(p) { const _ = {}, y = n().results[p - 1].tallyResults; - for (let M = 0; M < y.length; M++) { - let R = y[M].eliminated; - if (R === void 0 && (R = y[M].elected), R === void 0) { + for (let P = 0; P < y.length; P++) { + let R = y[P].eliminated; + if (R === void 0 && (R = y[P].elected), R === void 0) { console.warn("getTransferVotes: Eliminated and Elected undefined..."); continue; } - const C = y[M].transfers; - if (C === void 0) { + const S = y[P].transfers; + if (S === void 0) { console.warn("getTransferVotes: transfers undefined..."); continue; } - for (let [k, I] of Object.entries(C)) - _[k] === void 0 ? _[k] = Number(I) : _[k] += Number(I); + for (let [M, F] of Object.entries(S)) + _[M] === void 0 ? _[M] = Number(F) : _[M] += Number(F); } return _; } - function Xo(p, _) { - const y = [], M = ft, R = n().results[p - 1].tallyResults; - for (let C = 0; C < R.length; C++) { - let k = R[C].eliminated; - if (k === void 0 && (k = R[C].elected), k === void 0) { + function vr(p, _) { + const y = [], P = it, R = n().results[p - 1].tallyResults; + for (let S = 0; S < R.length; S++) { + let M = R[S].eliminated; + if (M === void 0 && (M = R[S].elected), M === void 0) { console.warn("MakeDonutInfo: Eliminated and Elected undefined..."); continue; } - const I = R[C].transfers; - if (I === void 0) { + const F = R[S].transfers; + if (F === void 0) { console.warn("makeDonutInfo: transfers undefined..."); continue; } - let q = _.find((F) => F.data.label == k && F.data.isTransfer); - q === void 0 && (q = _.find((F) => F.data.label == k && !F.data.isTransfer)); - let B = 0; - if (q) B = q.startAngle; + let q = _.find((O) => O.data.label == M && O.data.isTransfer); + q === void 0 && (q = _.find((O) => O.data.label == M && !O.data.isTransfer)); + let U = 0; + if (q) U = q.startAngle; else { console.warn("makeDonutInfo: No transfers"); continue; } - for (let [F, U] of Object.entries(I)) { - let at; - const we = _.find((ct) => ct.data.label == F); - if (we) - at = structuredClone(we); - else if (F == "exhausted") - at = { - data: { label: F, value: Number(U) }, + for (let [O, W] of Object.entries(F)) { + let st; + const ye = _.find((ft) => ft.data.label == O); + if (ye) + st = structuredClone(ye); + else if (O == "exhausted") + st = { + data: { label: O, value: Number(W) }, value: 0, index: 0, startAngle: 0, endAngle: 0, padAngle: 0 }; - else if (F == "residual surplus") { - console.warn("makeDonutInfo: residual surplus = ", U); + else if (O == "residual surplus") { + console.warn("makeDonutInfo: residual surplus = ", W); continue; } else { - console.warn("makeDonutInfo: unrecognized name in transfers ", F); + console.warn("makeDonutInfo: unrecognized name in transfers ", O); continue; } - const N = Number(U) / M * 2 * Math.PI; - at.startAngle = B, B = at.endAngle = B + N, at.index = C, at.data.transferIndex = C, y.push(at); + const k = Number(W) / P * 2 * Math.PI; + st.startAngle = U, U = st.endAngle = U + k, st.index = S, st.data.transferIndex = S, y.push(st); } } return y; } - function Go(p, _, y) { - const M = {}; - for (let [R, C] of Object.entries(p)) { - const k = y.find((B) => R == B.data.label); - if (k === void 0) { + function gr(p, _, y) { + const P = {}; + for (let [R, S] of Object.entries(p)) { + const M = y.find((U) => R == U.data.label); + if (M === void 0) { console.warn("getTransferStartAngles: mainPieObj not found for ", R); continue; } - const I = (k.startAngle + k.endAngle) / 2, q = p[k.data.label] / _ * 2 * Math.PI; - M[k.data.label] = I - q / 2; + const F = (M.startAngle + M.endAngle) / 2, q = p[M.data.label] / _ * 2 * Math.PI; + P[M.data.label] = F - q / 2; } - return M; - } - function Ko(p, _, y) { - const M = [], R = ft, C = Uo(p), k = Go(C, R, y); - for (let [I, q] of _.entries()) { - const B = structuredClone(q), F = q.endAngle - q.startAngle, U = y.find((at) => q.data.label === at.data.label && !at.data.isTransfer); - if (U) { - const at = U.data.label; - B.startAngle = k[at], k[at] += F, B.endAngle = B.startAngle + F; + return P; + } + function Le(p, _, y) { + const P = [], R = it, S = pr(p), M = gr(S, R, y); + for (let [F, q] of _.entries()) { + const U = structuredClone(q), O = q.endAngle - q.startAngle, W = y.find((st) => q.data.label === st.data.label && !st.data.isTransfer); + if (W) { + const st = W.data.label; + U.startAngle = M[st], M[st] += O, U.endAngle = U.startAngle + O; } else if (q.data.label === "exhausted") - B.startAngle = q.startAngle, B.endAngle = q.endAngle; + U.startAngle = q.startAngle, U.endAngle = q.endAngle; else { console.warn("updateDonutInfo: unrecognized slice name ", q.data.label); continue; } - B.index = I, M.push(B); + U.index = F, P.push(U); } - return M; - } - function Rs(p, _, y, M, R, C) { - const I = gt(w(tt)).append("g").attr("id", A).attr("transform", `translate(${y}, ${M})`), q = De().innerRadius(R * T).outerRadius(R * T); - I.selectAll("text").data(_).enter().each(function(B) { - B.endAngle - B.startAngle < D || B.data.isTransfer || gt(this).append("g").attr("id", (F) => u(F.data)).classed("eliminated", (F) => C.includes(F.data.label) || F.data.isTransfer === !0).each(function(F, U) { - F.data.label === "exhausted" && gt(this).on("mouseenter", (at, we) => el(at)).on("mouseleave", (at, we) => nl()); - }).append("text").attr("transform", (F) => `translate(${q.centroid(F)})`).attr("text-anchor", (F) => $i(F.startAngle, F.endAngle)).text((F) => F.data.label === "exhausted" ? zt : F.data.label).append("tspan").attr("x", 0).attr("dy", "1.2em").text((F) => Ot(F.data.label, p) + " (" + nn(F.data.label, p) + ")"); + return P; + } + function me(p, _, y, P, R, S) { + const F = gt(w(tt)).append("g").attr("id", C).attr("transform", `translate(${y}, ${P})`), q = Ve().innerRadius(R * N).outerRadius(R * N); + F.selectAll("text").data(_).enter().each(function(U) { + U.endAngle - U.startAngle < I || U.data.isTransfer || gt(this).append("g").attr("id", (O) => f(O.data)).classed("eliminated", (O) => S.includes(O.data.label) || O.data.isTransfer === !0).each(function(O, W) { + O.data.label === "exhausted" && gt(this).on("mouseenter", (st, ye) => nl(st)).on("mouseleave", (st, ye) => rl()); + }).append("text").attr("transform", (O) => `translate(${q.centroid(O)})`).attr("text-anchor", (O) => Di(O.startAngle, O.endAngle)).text((O) => O.data.label === "exhausted" ? Me : O.data.label).append("tspan").attr("x", 0).attr("dy", "1.2em").text((O) => ln(O.data.label, p) + " (" + un(O.data.label, p) + ")"); }); } - function Wo(p, _, y, M) { - const C = gt(w(tt)).select("#" + A), k = C.selectAll("tspan"), I = C.selectAll("g").data(_, (U) => u(U.data)).classed("eliminated", (U) => M.includes(U.data.label) || U.data.isTransfer === !0), q = De().innerRadius(y * T).outerRadius(y * T + 1); - k.transition("global").duration(E).attr("transform", (U) => `translate(${q.centroid(U)})`).attr("text-anchor", (U) => $i(U.startAngle, U.endAngle)), I.select("text").transition("global").duration(E).attr("transform", (U) => `translate(${q.centroid(U)})`).attr("text-anchor", (U) => $i(U.startAngle, U.endAngle)).on("end", (U) => F()); - let B = I.size(); - function F(U) { - B--, B === 0 && (C.remove(), Rs(p, _, v, g, y, M)); + function Pi(p, _, y, P) { + const S = gt(w(tt)).select("#" + C), M = S.selectAll("tspan"), F = S.selectAll("g").data(_, (W) => f(W.data)).classed("eliminated", (W) => P.includes(W.data.label) || W.data.isTransfer === !0), q = Ve().innerRadius(y * N).outerRadius(y * N + 1); + M.transition("global").duration(G).attr("transform", (W) => `translate(${q.centroid(W)})`).attr("text-anchor", (W) => Di(W.startAngle, W.endAngle)), F.select("text").transition("global").duration(G).attr("transform", (W) => `translate(${q.centroid(W)})`).attr("text-anchor", (W) => Di(W.startAngle, W.endAngle)).on("end", (W) => O()); + let U = F.size(); + function O(W) { + U--, U === 0 && (S.remove(), me(p, _, g, m, y, P)); } } - function jo(p, _, y, M, R, C, k, I = !0, q = !1) { - const F = la().sort(null).value((U) => U.value)(y); - return Ts(p, _, F, M, R, C, k, I, q), F; + function Zo(p, _, y, P, R, S, M, F = !0, q = !1) { + const O = ma().sort(null).value((W) => W.value)(y); + return Is(p, _, O, P, R, S, M, F, q), O; } - function kr() { - gt(w(tt)).select("#" + m).selectAll(".elected").style("stroke", "yellow").style("stroke-width", "2px"); + function Hr() { + gt(w(tt)).select("#" + b).selectAll(".elected").style("stroke", "yellow").style("stroke-width", "2px"); } - function Ts(p, _, y, M, R, C, k, I, q) { - const B = Bt(p), F = ye(p), we = gt(w(tt)).attr("viewBox", `0 0 ${f} ${h}`).attr("preserveAspectRatio", "xMidYMid meet").classed("pie-chart-svg", !0).append("g").attr("id", _).attr("transform", `translate(${M}, ${R})`).selectAll(".slice").data(y).enter().append("g").attr("class", "slice").classed("eliminated", (N) => B.includes(N.data.label) || N.data.isTransfer === !0).classed("elected", (N) => F.includes(N.data.label) && !N.data.isTransfer).attr("id", (N) => u(N.data)).on("mouseenter", (N, ct) => Ei(N, ct)).on("mouseleave", (N, ct) => Ri(N, ct)), ir = De().outerRadius(k).innerRadius(C); + function Is(p, _, y, P, R, S, M, F, q) { + const U = ge(p), O = Ze(p), ye = gt(w(tt)).attr("viewBox", `0 0 ${h} ${c}`).attr("preserveAspectRatio", "xMidYMid meet").classed("pie-chart-svg", !0).append("g").attr("id", _).attr("transform", `translate(${P}, ${R})`).selectAll(".slice").data(y).enter().append("g").attr("class", "slice").classed("eliminated", (k) => U.includes(k.data.label) || k.data.isTransfer === !0).classed("elected", (k) => O.includes(k.data.label) && !k.data.isTransfer).attr("id", (k) => f(k.data)).on("mouseenter", (k, ft) => Oi(k, ft)).on("mouseleave", (k, ft) => Ii(k, ft)), _r = Ve().outerRadius(M).innerRadius(S); if (q) { - const N = De().outerRadius(C + 1).innerRadius(C); - we.append("path").attr("d", N).transition("global").duration(E).attr("d", (ct) => ir(ct)).attr("fill", (ct) => Sr(ct)).on("end", (ct) => Ai()); + const k = Ve().outerRadius(S + 1).innerRadius(S); + ye.append("path").attr("d", k).transition("global").duration(G).attr("d", (ft) => _r(ft)).attr("fill", (ft) => Ie(ft)).on("end", (ft) => Fi()); } else - we.append("path").attr("d", (N) => ir(N)).attr("fill", (N) => Sr(N)), Ai(); - return I && Rs(p, y, M, R, k, B), y; + ye.append("path").attr("d", (k) => _r(k)).attr("fill", (k) => Ie(k)), Fi(); + return F && me(p, y, P, R, M, U), y; } - function Zo() { - const y = gt(w(tt)).select("#" + A).selectAll(".eliminated"); + function Jo() { + const y = gt(w(tt)).select("#" + C).selectAll(".eliminated"); y.size() > 0 && y.classed("finished", !0); } - function Jo() { - const y = gt(w(tt)).select("#" + A).selectAll(".finished"); + function Qo() { + const y = gt(w(tt)).select("#" + C).selectAll(".finished"); y.size() > 0 && y.remove(); } - function Qo(p, _) { - const R = gt(w(tt)).select("#" + m).selectAll(".eliminated"), C = De().innerRadius(p), k = De().outerRadius(_); - R.classed("finished", !0).select("path").transition("global").duration(E).attrTween("d", function(I) { - const q = On(_, p); - return function(B) { - return k.innerRadius(q(B)), k(I); + function tl(p, _) { + const R = gt(w(tt)).select("#" + b).selectAll(".eliminated"), S = Ve().innerRadius(p), M = Ve().outerRadius(_); + R.classed("finished", !0).select("path").transition("global").duration(G).attrTween("d", function(F) { + const q = Wn(_, p); + return function(U) { + return M.innerRadius(q(U)), M(F); }; - }).attr("fill", (I) => `url(#${it(I.data.label)})`), R.clone(!0).classed("finished", !0).select("path").transition("global").duration(E).attrTween("d", function(I) { - const q = On(_, p); - return function(B) { - return C.outerRadius(q(B)), C(I); + }).attr("fill", (F) => `url(#${Z(F.data.label)})`), R.clone(!0).classed("finished", !0).select("path").transition("global").duration(G).attrTween("d", function(F) { + const q = Wn(_, p); + return function(U) { + return S.outerRadius(q(U)), S(F); }; - }).attr("fill", (I) => Sr(I)); + }).attr("fill", (F) => Ie(F)); } - function $i(p, _) { + function Di(p, _) { const y = (p + _) / 2; return y > Math.PI * 11 / 6 || y < Math.PI * 1 / 6 || y > Math.PI * 5 / 6 && y < Math.PI * 7 / 6 ? "middle" : y < Math.PI ? "start" : "end"; } - function Ai() { + function Fi() { gt(w( tt // force redisplay of text labels - )).select("#" + A).raise().append("g").remove(); - } - function tl(p, _, y, M, R, C) { - const I = la().sort(null).value((q) => q.value)(y); - return Cs(p, _, I, M, R, C), I; - } - function Cs(p, _, y, M, R, C) { - const k = Bt(p), I = ye(p), q = De().outerRadius(R).innerRadius(M).startAngle((N) => N.startAngle).endAngle((N) => N.endAngle), B = De().outerRadius(R).innerRadius(M), U = gt(w(tt)).select("#" + _); - U.selectAll(".slice").attr("prevStart", (N) => N.startAngle).attr("prevEnd", (N) => N.endAngle); - const at = U.selectAll(".slice").data(y, (N) => u(N.data)); - at.enter().append("g").attr("class", "slice").attr("id", (N) => u(N.data)).classed("eliminated", !0).on("mouseenter", (N, ct) => Ei(N, ct)).on("mouseleave", (N, ct) => Ri(N, ct)).append("path").attr("d", (N) => B(N)).attr("fill", (N) => Sr(N)), at.classed("eliminated", (N) => k.includes(N.data.label)).classed("elected", (N) => I.includes(N.data.label)).on("mouseenter", (N, ct) => Ei(N, ct)).on("mouseleave", (N, ct) => Ri(N, ct)); - let we = at.size(); - function ir() { - we--, we <= 0 && (Ai(), U.selectAll(".finished").remove()); + )).select("#" + C).raise().append("g").remove(); + } + function el(p, _, y, P, R, S) { + const F = ma().sort(null).value((q) => q.value)(y); + return Ls(p, _, F, P, R, S), F; + } + function Ls(p, _, y, P, R, S) { + const M = ge(p), F = Ze(p), q = Ve().outerRadius(R).innerRadius(P).startAngle((k) => k.startAngle).endAngle((k) => k.endAngle), U = Ve().outerRadius(R).innerRadius(P), W = gt(w(tt)).select("#" + _); + W.selectAll(".slice").attr("prevStart", (k) => k.startAngle).attr("prevEnd", (k) => k.endAngle); + const st = W.selectAll(".slice").data(y, (k) => f(k.data)); + st.enter().append("g").attr("class", "slice").attr("id", (k) => f(k.data)).classed("eliminated", !0).on("mouseenter", (k, ft) => Oi(k, ft)).on("mouseleave", (k, ft) => Ii(k, ft)).append("path").attr("d", (k) => U(k)).attr("fill", (k) => Ie(k)), st.classed("eliminated", (k) => M.includes(k.data.label)).classed("elected", (k) => F.includes(k.data.label)).on("mouseenter", (k, ft) => Oi(k, ft)).on("mouseleave", (k, ft) => Ii(k, ft)); + let ye = st.size(); + function _r() { + ye--, ye <= 0 && (Fi(), W.selectAll(".finished").remove()); } - return at.select("path").transition("global").duration(E).attrTween("d", function(N) { - const ct = Number(gt(this.parentNode).attr("prevStart")), il = Number(gt(this.parentNode).attr("prevEnd")), sl = On(ct, N.startAngle), al = On(il, N.endAngle); - return (Ss) => (q.startAngle(sl(Ss)).endAngle(al(Ss)), q(N)); - }).on("end", ir), C && Wo(p, y, R, k), y; + return st.select("path").transition("global").duration(G).attrTween("d", function(k) { + const ft = Number(gt(this.parentNode).attr("prevStart")), sl = Number(gt(this.parentNode).attr("prevEnd")), al = Wn(ft, k.startAngle), ol = Wn(sl, k.endAngle); + return (Vs) => (q.startAngle(al(Vs)).endAngle(ol(Vs)), q(k)); + }).on("end", _r), S && Pi(p, y, R, M), y; } - function Ei(p, _) { + function Oi(p, _) { s(_.data.label), i("enter"), a(p.clientY); } - function Ri(p, _) { + function Ii(p, _) { s(_.data.label), i("leave"); } - function el(p, _) { + function nl(p, _) { i("show-exhausted"), a(p.clientY); } - function nl(p, _) { + function rl(p, _) { i("hide-exhausted"); } - var rl = { - pieColors: P, - exhaustedLabel: zt, - countExhaustedVotes: me, - getEliminatedCandidates: Bt, - getElectedCandidates: ye, - runFullAnimationFn: re, - animateOnePhaseFn: kn, + var il = { + pieColors: ht, + exhaustedLabel: Me, + countExhaustedVotes: ee, + getEliminatedCandidates: ge, + getElectedCandidates: Ze, + runFullAnimationFn: cn, + animateOnePhaseFn: hn, get jsonData() { return n(); }, set jsonData(p) { - n(p), jt(); + n(p), mt(); }, get currentRound() { return r(); }, set currentRound(p = 1) { - r(p), jt(); + r(p), mt(); }, get mouseEventType() { return i(); }, set mouseEventType(p) { - i(p), jt(); + i(p), mt(); }, get mouseData() { return s(); }, set mouseData(p) { - s(p), jt(); + s(p), mt(); }, get mouseY() { return a(); }, set mouseY(p) { - a(p), jt(); + a(p), mt(); }, get requestRoundChange() { return o(); }, set requestRoundChange(p = (_) => { }) { - o(p), jt(); + o(p), mt(); }, get candidateColors() { return l(); }, set candidateColors(p = []) { - l(p), jt(); + l(p), mt(); + }, + get excludeFinalWinnerAndEliminatedCandidate() { + return u(); + }, + set excludeFinalWinnerAndEliminatedCandidate(p = !1) { + u(p), mt(); } - }, Ns = dd(); - return Br(Ns, (p) => J(tt, p), () => w(tt)), be(t, Ns), ls(rl); + }, qs = pd(); + return Qr(qs, (p) => Q(tt, p), () => w(tt)), ae(t, qs), ys(il); } -co( - Vo, +bo( + jo, { jsonData: {}, currentRound: {}, @@ -5296,7 +5304,8 @@ co( mouseData: {}, mouseY: {}, requestRoundChange: {}, - candidateColors: {} + candidateColors: {}, + excludeFinalWinnerAndEliminatedCandidate: {} }, [], [ @@ -5310,8 +5319,8 @@ co( ], { mode: "open" } ); -var vd = /* @__PURE__ */ er(" ", 1), gd = /* @__PURE__ */ er("About to eliminate: ", 1), _d = /* @__PURE__ */ er(" ", 1), md = /* @__PURE__ */ er("Elected: ", 1), yd = /* @__PURE__ */ er("
", 1), wd = /* @__PURE__ */ er('


these ballots have already been eliminated.
', 1); -const xd = { +var gd = /* @__PURE__ */ Vn(" ", 1), _d = /* @__PURE__ */ Vn("About to eliminate: ", 1), md = /* @__PURE__ */ Vn(" ", 1), yd = /* @__PURE__ */ Vn(" ", 1), wd = /* @__PURE__ */ Vn('

', 1), xd = /* @__PURE__ */ Vn("
", 1), bd = /* @__PURE__ */ Vn('


these ballots have already been eliminated.
', 1); +const $d = { hash: "svelte-1r6y5gl", code: `.page-container.svelte-1r6y5gl {width:95%;max-width:1800px;margin:0 auto;padding:0 20px;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;}.common-header.svelte-1r6y5gl {width:100%;margin-bottom:1rem;text-align:center;}.tooltip.svelte-1r6y5gl {position:absolute;width:max-content;text-align:left;padding:.5rem;background:#FFFFFF;color:#313639;border:1px solid #313639;border-radius:8px;pointer-events:none;font-size:0.8rem;left:50%;transform:translate(-50%);font-weight:normal;opacity:0;}.tooltip.svelte-1r6y5gl h3:where(.svelte-1r6y5gl) {text-align:center;}.animation-button-container.svelte-1r6y5gl {display:flex;justify-content:center;gap:10px;margin:0.5rem;}.pie-chart-container.svelte-1r6y5gl { /* width: 90%; */ @@ -5355,251 +5364,316 @@ const xd = { }` }; -function bd(t, e) { - os(e, !0), uo(t, xd); +function Ad(t, e) { + ms(e, !0), wo(t, $d); const n = 0.85; - let r = ue(e, "electionSummary", 7), i = ue(e, "currentRound", 7, 1), s = ue(e, "requestRoundChange", 7, ($) => { - }), a = ue(e, "candidateColors", 23, () => []), o = /* @__PURE__ */ mt(null), l = /* @__PURE__ */ mt(null), u = /* @__PURE__ */ mt(""), f = /* @__PURE__ */ mt(un([])), h = /* @__PURE__ */ mt(""), c = /* @__PURE__ */ mt(""), v = /* @__PURE__ */ mt(0), g = /* @__PURE__ */ sr(() => m(r())); - function m($) { - if (typeof $ == "string") + let r = Et(e, "electionSummary", 7), i = Et(e, "currentRound", 7, 1), s = Et(e, "requestRoundChange", 7, (x) => { + }), a = Et(e, "candidateColors", 23, () => []), o = Et(e, "textForWinner", 7, "elected"), l = Et(e, "excludeFinalWinnerAndEliminatedCandidate", 7, !1), u = Et(e, "firstRoundDeterminesPercentages", 7, !0), f = Et(e, "showCaptions", 7, !1); + const h = { + elected: { + caption: "Elected", + event: "was elected", + infinitive: "to be elected" + }, + won: { caption: "Won", event: "won", infinitive: "to win" }, + advanced: { + caption: "Advanced", + event: "advanced to the general", + infinitive: "to advance to the general" + }, + leading: { + caption: "Leading", + event: "is in the lead", + infinitive: "to take the lead" + } + }; + let c = /* @__PURE__ */ Bn(() => h[o()] ?? h.elected), v = /* @__PURE__ */ yt(null), g = /* @__PURE__ */ yt(null), m = /* @__PURE__ */ yt(""), b = /* @__PURE__ */ yt(yn([])), $ = /* @__PURE__ */ yt(""), C = /* @__PURE__ */ yt(""), T = /* @__PURE__ */ yt(0), N = /* @__PURE__ */ Bn(() => I(r())); + function I(x) { + if (typeof x == "string") try { - $ = JSON.parse($); - } catch (V) { - return console.error("Failed to parse JSON string:", V), {}; + x = JSON.parse(x); + } catch (B) { + return console.error("Failed to parse JSON string:", B), {}; } - return $ || {}; + return x || {}; } - function b($) { - s() ? s()($) : console.warn("onRoundChange in PieChart: requestRoundChange is null"); + function G(x) { + s() ? s()(x) : console.warn("onRoundChange in PieChart: requestRoundChange is null"); } - function A() { - switch (w(h)) { + function at() { + switch (w($)) { case "enter": - (($) => { - var V = Al($, 2); - J(f, V[0], !0), J(u, V[1], !0); - })(T(w(c), i())), w(o) && (w(o).style.top = String(w(v) || 20) + "px", w(o).style.opacity = String(n)); + ((x) => { + var B = El(x, 2); + Q(b, B[0], !0), Q(m, B[1], !0); + })(et(w(C), i())), w(v) && (w(v).style.top = String(w(T) || 20) + "px", w(v).style.opacity = String(n)); break; case "leave": - w(o) && (w(o).style.opacity = "0"), J(f, [], !0), J(u, ""); + w(v) && (w(v).style.opacity = "0"), Q(b, [], !0), Q(m, ""); break; case "show-exhausted": - w(l) && (w(l).style.top = String(w(v) || 20) + "px", w(l).style.opacity = String(n)); + w(g) && (w(g).style.top = String(w(T) || 20) + "px", w(g).style.opacity = String(n)); break; case "hide-exhausted": - w(l) && (w(l).style.opacity = "0"); + w(g) && (w(g).style.opacity = "0"); break; default: - console.log("Unknown mouse event: ", w(h)); + console.log("Unknown mouse event: ", w($)); break; } } - ds(() => A()); - function S($, V) { - return $ == 1 ? V ? "vote was" : "vote will be" : V ? "votes were" : "votes will be"; - } - function T($, V) { - const et = [], K = $ === "exhausted" ? ut() : $; - let rt; - $ == "exhausted" ? rt = W(1) : rt = w(g).results[0].tally[$], et.push(`${K} started with ${rt} votes.`); - for (let Q = 1; Q <= V; Q++) { - Q === V && ($ == "exhausted" ? rt = W(V) : rt = w(g).results[V - 1].tally[$], et.push(`${K} has ${rt} votes at round ${V}.`)); - const At = w(g).results[Q - 1].tallyResults; - for (let dt = 0; dt < At.length; dt++) { - const re = At[dt].transfers, ie = At[dt].eliminated, st = At[dt].elected; - if (ie) - ie === $ && et.push(`${K} will be eliminated on round ${Q}.`); - else if ($ === st && (et.push(`${K} was elected on round ${Q}.`), re)) - for (let [se, bt] of Object.entries(re)) - et.push(`${bt} ${S(Number(bt), Q < V)} transferred to ${se} on round ${Q}.`); - const Ke = ie || st; - if (Ke) { - const se = Number(re[$]); - se && et.push(`${se} ${S(se, Q < V)} transferred from ${Ke} on round ${Q}.`); + As(() => at()); + function Z(x, B) { + return x == 1 ? B ? "vote was" : "vote will be" : B ? "votes were" : "votes will be"; + } + function et(x, B) { + const nt = [], ot = x === "exhausted" ? tt() : x; + let J; + x == "exhausted" ? J = ht(1) : J = w(N).results[0].tally[x], nt.push(`${ot} started with ${J} votes.`); + for (let rt = 1; rt <= B; rt++) { + rt === B && (x == "exhausted" ? J = ht(B) : J = w(N).results[B - 1].tally[x], nt.push(`${ot} has ${J} votes at round ${B}.`)); + const $t = w(N).results[rt - 1].tallyResults, Je = it(rt); + for (let re = 0; re < $t.length; re++) { + const cn = $t[re].transfers, De = $t[re].eliminated, K = $t[re].elected; + if (!Je) { + if (De) + De === x && nt.push(`${ot} will be eliminated on round ${rt}.`); + else if (x === K && (nt.push(`${ot} ${w(c).event} on round ${rt}.`), cn)) + for (let [Yt, Qe] of Object.entries(cn)) + nt.push(`${Qe} ${Z(Number(Qe), rt < B)} transferred to ${Yt} on round ${rt}.`); + } + const _e = De || K; + if (_e) { + const Yt = Number(cn[x]); + Yt && nt.push(`${Yt} ${Z(Yt, rt < B)} transferred from ${_e} on round ${rt}.`); } } } - return [et, K]; - } - function D() { - let $ = 0; - for (let V = 1; V <= w(g).results.length; V++) { - const et = w(g).results[V - 1].tallyResults; - for (let K = 0; K < et.length; K++) - et[K].elected && $++; + return [nt, ot]; + } + function dt() { + let x = 0; + for (let B = 1; B <= w(N).results.length; B++) { + if (it(B)) continue; + const nt = w(N).results[B - 1].tallyResults; + for (let ot = 0; ot < nt.length; ot++) + nt[ot].elected && x++; } - return $; + return x; } - let E; - function j($) { - return E ? E.getEliminatedCandidates($) : []; + let H; + function it(x) { + return l() && w(N).results && x === w(N).results.length; } - function it($) { - return E ? E.getElectedCandidates($) : []; + function A(x) { + return it(x) ? [] : H ? H.getEliminatedCandidates(x) : []; } - function W($) { - return E ? E.countExhaustedVotes($) : 0; + function E(x) { + return it(x) ? [] : H ? H.getElectedCandidates(x) : []; } - function nt() { - E && E.animateOnePhaseFn && E.animateOnePhaseFn(); + function ht(x) { + return H ? H.countExhaustedVotes(x) : 0; } - function ut() { - return E ? E.exhaustedLabel : ""; + function Me() { + H && H.animateOnePhaseFn && H.animateOnePhaseFn(); } - function ft() { - return E ? E.pieColors : {}; + function tt() { + return H ? H.exhaustedLabel : ""; } - var G = { + function te() { + return H ? H.pieColors : {}; + } + var Pe = { get electionSummary() { return r(); }, - set electionSummary($) { - r($), jt(); + set electionSummary(x) { + r(x), mt(); }, get currentRound() { return i(); }, - set currentRound($ = 1) { - i($), jt(); + set currentRound(x = 1) { + i(x), mt(); }, get requestRoundChange() { return s(); }, - set requestRoundChange($ = (V) => { + set requestRoundChange(x = (B) => { }) { - s($), jt(); + s(x), mt(); }, get candidateColors() { return a(); }, - set candidateColors($ = []) { - a($), jt(); + set candidateColors(x = []) { + a(x), mt(); + }, + get textForWinner() { + return o(); + }, + set textForWinner(x = "elected") { + o(x), mt(); + }, + get excludeFinalWinnerAndEliminatedCandidate() { + return l(); + }, + set excludeFinalWinnerAndEliminatedCandidate(x = !1) { + l(x), mt(); + }, + get firstRoundDeterminesPercentages() { + return u(); + }, + set firstRoundDeterminesPercentages(x = !0) { + u(x), mt(); + }, + get showCaptions() { + return f(); + }, + set showCaptions(x = !1) { + f(x), mt(); } - }, x = wd(), P = Mn(x), zt = Xt(P); - zt.__click = nt, Ut(P); - var tt = ae(P, 4), Ht = Xt(tt), Yt = Xt(Ht), ne = Xt(Yt); - Br( - Vo(ne, { + }, Ht = bd(), pe = dn(Ht), Nt = Ut(pe); + Nt.__click = Me, Bt(pe); + var ve = ie(pe, 4), ee = Ut(ve), Rt = Ut(ee), ln = Ut(Rt); + Qr( + jo(ln, { get jsonData() { - return w(g); + return w(N); }, get currentRound() { return i(); }, - requestRoundChange: b, + requestRoundChange: G, get candidateColors() { return a(); }, + get excludeFinalWinnerAndEliminatedCandidate() { + return l(); + }, get mouseEventType() { - return w(h); + return w($); }, - set mouseEventType($) { - J(h, $, !0); + set mouseEventType(x) { + Q($, x, !0); }, get mouseData() { - return w(c); + return w(C); }, - set mouseData($) { - J(c, $, !0); + set mouseData(x) { + Q(C, x, !0); }, get mouseY() { - return w(v); + return w(T); }, - set mouseY($) { - J(v, $, !0); + set mouseY(x) { + Q(T, x, !0); } }), - ($) => E = $, - () => E - ), Ut(Yt), Ut(Ht); - var ge = ae(Ht, 2), Tt = Xt(ge); - Ut(ge); - var _e = ae(ge, 2), me = Xt(_e); - { - var Xe = ($) => { - var V = gd(), et = ae(Mn(V)); - Si(et, 17, () => j(i()), Ni, (K, rt, Q) => { - var At = vd(), dt = Mn(At); - let re; - var ie = Xt(dt, !0); - Ut(dt); - var st = ae(dt, 2); - { - var Ke = (bt) => { - var kn = Vs(", "); - be(bt, kn); - }, se = /* @__PURE__ */ sr(() => Q < j(i()).length - 1); - Dr(st, (bt) => { - w(se) && bt(Ke); - }); - } - Pr( - (bt) => { - re = Ys(dt, "", re, bt), Pn(ie, w(rt)); - }, - [() => ({ color: ft()[w(rt)] })] - ), be(K, At); - }), be($, V); - }, Ot = /* @__PURE__ */ sr(() => j(i()).length > 0); - Dr(me, ($) => { - w(Ot) && $(Xe); - }); - } - var nn = ae(me, 2); + (x) => H = x, + () => H + ), Bt(Rt), Bt(ee); + var un = ie(ee, 2); { - var rn = ($) => { - var V = md(), et = ae(Mn(V)); - Si(et, 17, () => it(i()), Ni, (K, rt, Q) => { - var At = _d(), dt = Mn(At); - let re; - var ie = Xt(dt, !0); - Ut(dt); - var st = ae(dt, 2); - { - var Ke = (bt) => { - var kn = Vs(", "); - be(bt, kn); - }, se = /* @__PURE__ */ sr(() => Q < it(i()).length - 1); - Dr(st, (bt) => { - w(se) && bt(Ke); - }); - } - Pr( - (bt) => { - re = Ys(dt, "", re, bt), Pn(ie, w(rt)); - }, - [() => ({ color: ft()[w(rt)] })] - ), be(K, At); - }), be($, V); - }, Ge = /* @__PURE__ */ sr(() => it(i()).length > 0); - Dr(nn, ($) => { - w(Ge) && $(rn); + var fn = (x) => { + var B = wd(), nt = dn(B), ot = Ut(nt); + Bt(nt); + var J = ie(nt, 2), rt = Ut(J); + { + var $t = (K) => { + var _e = _d(), Yt = ie(dn(_e)); + zi(Yt, 17, () => A(i()), Vi, (Qe, hn, Hn) => { + var Yn = gd(), Fe = dn(Yn); + let Oe; + var Ie = Ut(Fe, !0); + Bt(Fe); + var pr = ie(Fe, 2); + { + var vr = (Le) => { + var me = js(", "); + ae(Le, me); + }, gr = /* @__PURE__ */ Bn(() => Hn < A(i()).length - 1); + mr(pr, (Le) => { + w(gr) && Le(vr); + }); + } + Un( + (Le) => { + Oe = Qs(Fe, "", Oe, Le), pn(Ie, w(hn)); + }, + [() => ({ color: te()[w(hn)] })] + ), ae(Qe, Yn); + }), ae(K, _e); + }, Je = /* @__PURE__ */ Bn(() => A(i()).length > 0); + mr(rt, (K) => { + w(Je) && K($t); + }); + } + var re = ie(rt, 2); + { + var cn = (K) => { + var _e = yd(), Yt = dn(_e), Qe = ie(Yt); + zi(Qe, 17, () => E(i()), Vi, (hn, Hn, Yn) => { + var Fe = md(), Oe = dn(Fe); + let Ie; + var pr = Ut(Oe, !0); + Bt(Oe); + var vr = ie(Oe, 2); + { + var gr = (me) => { + var Pi = js(", "); + ae(me, Pi); + }, Le = /* @__PURE__ */ Bn(() => Yn < E(i()).length - 1); + mr(vr, (me) => { + w(Le) && me(gr); + }); + } + Un( + (me) => { + Ie = Qs(Oe, "", Ie, me), pn(pr, w(Hn)); + }, + [() => ({ color: te()[w(Hn)] })] + ), ae(hn, Fe); + }), Un(() => pn(Yt, `${w(c).caption ?? ""}: `)), ae(K, _e); + }, De = /* @__PURE__ */ Bn(() => E(i()).length > 0); + mr(re, (K) => { + w(De) && K(cn); + }); + } + Bt(J), Un((K) => pn(ot, `${w(N).config.contest ?? ""}, ${K ?? ""} ${w(c).infinitive ?? ""}, Round ${i() ?? ""}.`), [dt]), ae(x, B); + }; + mr(un, (x) => { + f() && x(fn); }); } - Ut(_e), Ut(tt); - var Bt = ae(tt, 2), ye = Xt(Bt), Sn = Xt(ye, !0); - Ut(ye); - var Nr = ae(ye, 2); - Si(Nr, 17, () => w(f), Ni, ($, V) => { - var et = yd(), K = Mn(et), rt = Xt(K, !0); - Ut(K), Fi(2), Pr(() => Pn(rt, w(V))), be($, et); - }), Ut(Bt), Br(Bt, ($) => J(o, $), () => w(o)); - var rr = ae(Bt, 2), bi = Xt(rr); - return Fi(2), Ut(rr), Br(rr, ($) => J(l, $), () => w(l)), Pr( - ($, V) => { - Pn(Tt, `${w(g).config.contest ?? ""}, ${$ ?? ""} to be elected, Round ${i() ?? ""}.`), Pn(Sn, w(u)), Pn(bi, `"${V ?? ""}" means all the candidates ranked on `); + Bt(ve); + var ne = ie(ve, 2), ge = Ut(ne), Ze = Ut(ge, !0); + Bt(ge); + var ki = ie(ge, 2); + zi(ki, 17, () => w(b), Vi, (x, B) => { + var nt = xd(), ot = dn(nt), J = Ut(ot, !0); + Bt(ot), Gi(2), Un(() => pn(J, w(B))), ae(x, nt); + }), Bt(ne), Qr(ne, (x) => Q(v, x), () => w(v)); + var zn = ie(ne, 2), Mi = Ut(zn); + return Gi(2), Bt(zn), Qr(zn, (x) => Q(g, x), () => w(g)), Un( + (x) => { + pn(Ze, w(m)), pn(Mi, `"${x ?? ""}" means all the candidates ranked on `); }, - [D, ut] - ), be(t, x), ls(G); + [tt] + ), ae(t, Ht), ys(Pe); } -hu(["click"]); -customElements.define("pie-chart", co( - bd, +du(["click"]); +customElements.define("pie-chart", bo( + Ad, { electionSummary: {}, currentRound: {}, requestRoundChange: {}, - candidateColors: {} + candidateColors: {}, + textForWinner: {}, + excludeFinalWinnerAndEliminatedCandidate: {}, + firstRoundDeterminesPercentages: {}, + showCaptions: {} }, [], [], diff --git a/templates/pie/pie-nonblocking.html b/templates/pie/pie-nonblocking.html index 8624e60b..faf0a731 100644 --- a/templates/pie/pie-nonblocking.html +++ b/templates/pie/pie-nonblocking.html @@ -26,6 +26,9 @@ pieChart.requestRoundChange = updateRound; pieChart.electionSummary = electionSummary; pieChart.candidateColors = candidateColors; + pieChart.textForWinner = "{{ textForWinner }}"; + pieChart.excludeFinalWinnerAndEliminatedCandidate = {{ config.excludeFinalWinnerAndEliminatedCandidate|yesno:"true,false" }}; + pieChart.currentRound = {{ config.numRounds }}; // Append it to the div document.getElementById("pie-body").appendChild(pieChart); From da794a6ce63053f2fcf72565c4f9943674f678e3 Mon Sep 17 00:00:00 2001 From: skaphan Date: Wed, 4 Mar 2026 18:06:12 -0500 Subject: [PATCH 05/13] Add hidePie setting to hide pie chart tab per election Following the hideSankey/hideTabular pattern: model field, config JS variable, settings checkbox, and tab hiding in hideTabsBasedOnConfig(). Co-Authored-By: Claude Opus 4.6 --- static/visualizer/tabs-nonblocking.js | 4 ++++ templates/settings/base.html | 8 ++++++++ .../visualizer/common-visualizer-header.html | 1 + .../migrations/0033_jsonconfig_hidepie.py | 18 ++++++++++++++++++ visualizer/models.py | 2 ++ 5 files changed, 33 insertions(+) create mode 100644 visualizer/migrations/0033_jsonconfig_hidepie.py diff --git a/static/visualizer/tabs-nonblocking.js b/static/visualizer/tabs-nonblocking.js index 25277dcb..ca44626e 100644 --- a/static/visualizer/tabs-nonblocking.js +++ b/static/visualizer/tabs-nonblocking.js @@ -59,6 +59,10 @@ function hideTabsBasedOnConfig() { { $("li[name='li_hideable_tabular']").css("display","none"); } + if (config.hidePie) + { + $("li[name='li_hideable_pie']").css("display","none"); + } if (config.hideSankey) { $("li[name='li_hideable_sankey']").css("display","none"); diff --git a/templates/settings/base.html b/templates/settings/base.html index 0ed3a719..59957868 100644 --- a/templates/settings/base.html +++ b/templates/settings/base.html @@ -48,6 +48,14 @@

+ +
+

+ + +

+
+

diff --git a/templates/visualizer/common-visualizer-header.html b/templates/visualizer/common-visualizer-header.html index 79613737..5bd9868f 100644 --- a/templates/visualizer/common-visualizer-header.html +++ b/templates/visualizer/common-visualizer-header.html @@ -26,6 +26,7 @@ // 1. Load from django (happens once on baking) config.onlyShowWinnersTabular = {% if config.onlyShowWinnersTabular %} true {% else %} false {% endif %}; config.hideSankey = {% if config.hideSankey %} true {% else %} false {% endif %}; + config.hidePie = {% if config.hidePie %} true {% else %} false {% endif %}; config.showRoundNumbersOnSankey = {% if config.showRoundNumbersOnSankey %} true {% else %} false {% endif %}; config.hideTabular = {% if config.hideTabular %} true {% else %} false {% endif %}; config.doDimPrevRoundColors = {% if config.doDimPrevRoundColors %} true {% else %} false {% endif %}; diff --git a/visualizer/migrations/0033_jsonconfig_hidepie.py b/visualizer/migrations/0033_jsonconfig_hidepie.py new file mode 100644 index 00000000..9beb3559 --- /dev/null +++ b/visualizer/migrations/0033_jsonconfig_hidepie.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('visualizer', '0032_jsonconfig_forcefirstrounddeterminespercentages'), + ] + + operations = [ + migrations.AddField( + model_name='jsonconfig', + name='hidePie', + field=models.BooleanField(default=False), + ), + ] diff --git a/visualizer/models.py b/visualizer/models.py index 789dba60..6dfd37fd 100644 --- a/visualizer/models.py +++ b/visualizer/models.py @@ -87,6 +87,7 @@ class JsonConfig(models.Model): showRoundNumbersOnSankey = models.BooleanField(default=True) onlyShowWinnersTabular = models.BooleanField(default=True) hideSankey = models.BooleanField(default=False) + hidePie = models.BooleanField(default=False) hideTabular = models.BooleanField(default=False) doDimPrevRoundColors = models.BooleanField(default=True) isPreferentialBlock = models.BooleanField(default=False) @@ -109,6 +110,7 @@ def get_all_non_auto_fields(cls): 'isPreferentialBlock', 'forceFirstRoundDeterminesPercentages', 'hideSankey', + 'hidePie', 'hideTabular', 'doDimPrevRoundColors', 'excludeFinalWinnerAndEliminatedCandidate', From 546a880d2841ae56f88bd52d9771977cc480db77 Mon Sep 17 00:00:00 2001 From: skaphan Date: Wed, 4 Mar 2026 18:15:11 -0500 Subject: [PATCH 06/13] Add tests for graphToRCtab converter (32 tests) Covers structure validation, tally correctness, eliminations, multi-winner surplus, inactive ballots, no-threshold elections, excludeFinalWinner flag, and the _stringify helper. Co-Authored-By: Claude Opus 4.6 --- visualizer/tests/testGraphToRCtab.py | 263 +++++++++++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 visualizer/tests/testGraphToRCtab.py diff --git a/visualizer/tests/testGraphToRCtab.py b/visualizer/tests/testGraphToRCtab.py new file mode 100644 index 00000000..a177558f --- /dev/null +++ b/visualizer/tests/testGraphToRCtab.py @@ -0,0 +1,263 @@ +""" +Tests for the graphToRCtab converter that builds RCTab-compatible JSON +from processed Graph objects for the pie chart component. +""" + +from django.test import TestCase + +from visualizer import common +from visualizer.graph.graphCreator import make_graph_with_file +from visualizer.pie.graphToRCtab import graph_to_rctab_json, _stringify +from visualizer.tests import filenames + + +class StringifyTests(TestCase): + """ Tests for the _stringify helper """ + + def test_integer_unchanged(self): + self.assertEqual(_stringify(42), "42") + + def test_integer_float_drops_decimal(self): + self.assertEqual(_stringify(42.0), "42") + + def test_actual_float_kept(self): + self.assertEqual(_stringify(42.5), "42.5") + + def test_zero(self): + self.assertEqual(_stringify(0), "0") + + def test_zero_float(self): + self.assertEqual(_stringify(0.0), "0") + + def test_string_passthrough(self): + """ RCTab JSON sometimes has string values already """ + self.assertEqual(_stringify("100"), "100") + + +class OneRoundTests(TestCase): + """ Tests with a single-round election """ + + def setUp(self): + with open(filenames.ONE_ROUND, 'r', encoding='utf-8') as f: + self.graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=False) + self.result = graph_to_rctab_json(self.graph) + + def test_top_level_structure(self): + self.assertIn('config', self.result) + self.assertIn('results', self.result) + self.assertIn('summary', self.result) + self.assertIn('jsonFormatVersion', self.result) + + def test_single_round(self): + self.assertEqual(len(self.result['results']), 1) + + def test_round_has_required_fields(self): + rnd = self.result['results'][0] + self.assertIn('round', rnd) + self.assertIn('tally', rnd) + self.assertIn('tallyResults', rnd) + self.assertIn('inactiveBallots', rnd) + self.assertIn('threshold', rnd) + self.assertEqual(rnd['round'], 1) + + def test_tally_has_candidates(self): + tally = self.result['results'][0]['tally'] + self.assertGreater(len(tally), 0) + # All tally values should be strings (RCTab convention) + for val in tally.values(): + self.assertIsInstance(val, str) + + def test_winner_elected(self): + """ The single-round election should have an elected candidate """ + tally_results = self.result['results'][0]['tallyResults'] + elected = [tr for tr in tally_results if 'elected' in tr] + self.assertGreater(len(elected), 0) + + def test_config_has_contest(self): + self.assertIn('contest', self.result['config']) + self.assertIsInstance(self.result['config']['contest'], str) + self.assertGreater(len(self.result['config']['contest']), 0) + + +class ThreeRoundTests(TestCase): + """ Tests with a three-round single-winner election (medium-rcvis.json) """ + + def setUp(self): + with open(filenames.THREE_ROUND, 'r', encoding='utf-8') as f: + self.graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=False) + self.result = graph_to_rctab_json(self.graph) + + def test_round_count(self): + self.assertEqual(len(self.result['results']), 3) + + def test_rounds_numbered_sequentially(self): + for i, rnd in enumerate(self.result['results']): + self.assertEqual(rnd['round'], i + 1) + + def test_first_round_has_all_candidates(self): + """ The first round's tally should include all candidates from the graph """ + graph_candidates = {c.name for c in self.graph.candidates} + first_tally = set(self.result['results'][0]['tally'].keys()) + self.assertTrue(graph_candidates.issubset(first_tally), + f"Missing candidates: {graph_candidates - first_tally}") + + def test_eliminated_candidates_removed_in_later_rounds(self): + """ Eliminated candidates should not appear in subsequent rounds' tallies """ + # Banana is eliminated in round 1, so it should not be in round 2 or 3 + round_2_tally = set(self.result['results'][1]['tally'].keys()) + round_3_tally = set(self.result['results'][2]['tally'].keys()) + self.assertNotIn('Banana', round_2_tally) + self.assertNotIn('Banana', round_3_tally) + + def test_eliminations_present(self): + """ Earlier rounds should have eliminations """ + all_eliminated = [] + for rnd in self.result['results']: + for tr in rnd['tallyResults']: + if 'eliminated' in tr: + all_eliminated.append(tr['eliminated']) + self.assertGreater(len(all_eliminated), 0) + + def test_final_round_has_winner(self): + last_round = self.result['results'][-1] + elected = [tr for tr in last_round['tallyResults'] if 'elected' in tr] + self.assertEqual(len(elected), 1) + + def test_transfers_have_string_values(self): + """ All transfer values should be strings (RCTab convention) """ + for rnd in self.result['results']: + for tr in rnd['tallyResults']: + if 'transfers' in tr: + for val in tr['transfers'].values(): + self.assertIsInstance(val, str) + + def test_threshold_is_string(self): + for rnd in self.result['results']: + self.assertIsInstance(rnd['threshold'], str) + + def test_summary_fields(self): + summary = self.result['summary'] + self.assertIn('numCandidates', summary) + self.assertIn('numWinners', summary) + self.assertIn('totalNumBallots', summary) + self.assertIn('finalThreshold', summary) + + +class MultwinnerTests(TestCase): + """ Tests with a multi-winner surplus election (macomb-multiwinner-surplus.json) """ + + def setUp(self): + with open(filenames.MULTIWINNER, 'r', encoding='utf-8') as f: + self.graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=False) + self.result = graph_to_rctab_json(self.graph) + + def test_round_count(self): + self.assertEqual(len(self.result['results']), 5) + + def test_multiple_winners(self): + """ Multi-winner election should have multiple elected candidates """ + all_elected = [] + for rnd in self.result['results']: + for tr in rnd['tallyResults']: + if 'elected' in tr: + all_elected.append(tr['elected']) + self.assertGreater(len(all_elected), 1) + + def test_elected_have_transfers(self): + """ Elected candidates with surplus should have transfer entries """ + for rnd in self.result['results']: + for tr in rnd['tallyResults']: + if 'elected' in tr: + self.assertIn('transfers', tr) + + def test_num_candidates_excludes_pseudocandidates(self): + """ numCandidates in summary should not count Inactive Ballots or Residual Surplus """ + num = self.result['summary']['numCandidates'] + inactive_names = {common.INACTIVE_TEXT, common.RESIDUAL_SURPLUS_TEXT} + real_count = sum(1 for c in self.graph.candidates if c.name not in inactive_names) + self.assertEqual(num, real_count) + + +class InactiveBallotTests(TestCase): + """ Tests with a multiwinner election that has nonzero exhausted votes """ + + def setUp(self): + # Multiwinner election has Inactive Ballots count > 0 in round 5 + with open(filenames.MULTIWINNER, 'r', encoding='utf-8') as f: + self.graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=False) + self.result = graph_to_rctab_json(self.graph) + + def test_inactive_ballots_absent_when_zero(self): + """ Early rounds with zero exhausted votes should have empty inactiveBallots """ + first_round = self.result['results'][0] + inactive = first_round['inactiveBallots'] + self.assertNotIn('exhaustedChoices', inactive) + + def test_inactive_ballots_present_when_nonzero(self): + """ Round 5 has nonzero exhausted votes and should populate exhaustedChoices """ + last_round = self.result['results'][-1] + inactive = last_round['inactiveBallots'] + self.assertIn('exhaustedChoices', inactive) + self.assertGreater(float(inactive['exhaustedChoices']), 0) + + +class NoThresholdTests(TestCase): + """ Tests with an election that has no threshold in its config """ + + def setUp(self): + with open(filenames.NO_THRESHOLD, 'r', encoding='utf-8') as f: + self.graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=False) + self.result = graph_to_rctab_json(self.graph) + + def test_threshold_defaults_to_zero(self): + """ When no threshold, converter should output "0" rather than crash """ + for rnd in self.result['results']: + self.assertIsInstance(rnd['threshold'], str) + + def test_final_threshold_in_summary(self): + self.assertIn('finalThreshold', self.result['summary']) + + +class ExcludeFinalWinnerTests(TestCase): + """ Tests that excludeFinalWinnerAndEliminatedCandidate affects the output. + + The flag removes isWinner/isEliminated flags from the Graph's nodes, + but the WinTransfer/Elimination objects remain in transfersPerRound. + The converter still produces tallyResults entries — the flag's effect + is on visual markers (gold rings, etc.), not on transfer data. + The pie chart component handles suppression separately via its own + excludeFinalWinnerAndEliminatedCandidate prop. """ + + def test_with_exclude_flag_nodes_not_marked(self): + """ With the flag, the final round's nodes should have no winner/eliminated flags """ + with open(filenames.THREE_ROUND, 'r', encoding='utf-8') as f: + graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=True) + + last_round_nodes = graph.nodesPerRound[-1] + for candidate, node in last_round_nodes.items(): + self.assertFalse(node.isWinner, + f"{candidate.name} should not be marked as winner") + self.assertFalse(node.isEliminated, + f"{candidate.name} should not be marked as eliminated") + + def test_with_exclude_flag_transfers_preserved(self): + """ The converter still outputs tallyResults even with the flag, + because transfersPerRound is not affected by the flag """ + with open(filenames.THREE_ROUND, 'r', encoding='utf-8') as f: + graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=True) + result = graph_to_rctab_json(graph) + + last_round = result['results'][-1] + # WinTransfer is still present, so elected entry still appears + elected = [tr for tr in last_round['tallyResults'] if 'elected' in tr] + self.assertEqual(len(elected), 1) + + def test_without_exclude_flag(self): + """ Without the flag, the final round should have an elected candidate """ + with open(filenames.THREE_ROUND, 'r', encoding='utf-8') as f: + graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=False) + result = graph_to_rctab_json(graph) + + last_round = result['results'][-1] + elected = [tr for tr in last_round['tallyResults'] if 'elected' in tr] + self.assertEqual(len(elected), 1) From b250c98de186c48824a2c705d151fa9b30b19db4 Mon Sep 17 00:00:00 2001 From: skaphan Date: Wed, 4 Mar 2026 19:04:22 -0500 Subject: [PATCH 07/13] Rebuild standalone component with tooltip fix Co-Authored-By: Claude Opus 4.6 --- static/pie/pie-chart.es.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/pie/pie-chart.es.js b/static/pie/pie-chart.es.js index 30e857a2..b0241777 100644 --- a/static/pie/pie-chart.es.js +++ b/static/pie/pie-chart.es.js @@ -5322,7 +5322,7 @@ bo( var gd = /* @__PURE__ */ Vn(" ", 1), _d = /* @__PURE__ */ Vn("About to eliminate: ", 1), md = /* @__PURE__ */ Vn(" ", 1), yd = /* @__PURE__ */ Vn(" ", 1), wd = /* @__PURE__ */ Vn('

', 1), xd = /* @__PURE__ */ Vn("
", 1), bd = /* @__PURE__ */ Vn('


these ballots have already been eliminated.
', 1); const $d = { hash: "svelte-1r6y5gl", - code: `.page-container.svelte-1r6y5gl {width:95%;max-width:1800px;margin:0 auto;padding:0 20px;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;}.common-header.svelte-1r6y5gl {width:100%;margin-bottom:1rem;text-align:center;}.tooltip.svelte-1r6y5gl {position:absolute;width:max-content;text-align:left;padding:.5rem;background:#FFFFFF;color:#313639;border:1px solid #313639;border-radius:8px;pointer-events:none;font-size:0.8rem;left:50%;transform:translate(-50%);font-weight:normal;opacity:0;}.tooltip.svelte-1r6y5gl h3:where(.svelte-1r6y5gl) {text-align:center;}.animation-button-container.svelte-1r6y5gl {display:flex;justify-content:center;gap:10px;margin:0.5rem;}.pie-chart-container.svelte-1r6y5gl { + code: `.page-container.svelte-1r6y5gl {width:95%;max-width:1800px;margin:0 auto;padding:0 20px;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;}.common-header.svelte-1r6y5gl {width:100%;margin-bottom:1rem;text-align:center;}.tooltip.svelte-1r6y5gl {position:fixed;width:max-content;text-align:left;padding:.5rem;background:#FFFFFF;color:#313639;border:1px solid #313639;border-radius:8px;pointer-events:none;font-size:0.8rem;left:50%;transform:translate(-50%);font-weight:normal;opacity:0;z-index:100;}.tooltip.svelte-1r6y5gl h3:where(.svelte-1r6y5gl) {text-align:center;}.animation-button-container.svelte-1r6y5gl {display:flex;justify-content:center;gap:10px;margin:0.5rem;}.pie-chart-container.svelte-1r6y5gl { /* width: 90%; */ /* min-width: 800px; /* Larger minimum size */width:100%; /* Change from 90% to 100% */min-width:auto; /* Remove the 800px minimum */flex-grow:0; /* Don't grow beyond specified width */margin:0 auto;margin-right:40px; /* Add extra space on right */margin-top:-3vh;}.visualizations-container.svelte-1r6y5gl {display:flex;justify-content:space-between;width:100%;padding:0 20px; /* gap: 80px; */gap:20px; /* Reduce from 80px */} @@ -5406,13 +5406,13 @@ function Ad(t, e) { ((x) => { var B = El(x, 2); Q(b, B[0], !0), Q(m, B[1], !0); - })(et(w(C), i())), w(v) && (w(v).style.top = String(w(T) || 20) + "px", w(v).style.opacity = String(n)); + })(et(w(C), i())), w(v) && (w(v).style.top = String((w(T) || 0) + 20) + "px", w(v).style.opacity = String(n)); break; case "leave": w(v) && (w(v).style.opacity = "0"), Q(b, [], !0), Q(m, ""); break; case "show-exhausted": - w(g) && (w(g).style.top = String(w(T) || 20) + "px", w(g).style.opacity = String(n)); + w(g) && (w(g).style.top = String((w(T) || 0) + 20) + "px", w(g).style.opacity = String(n)); break; case "hide-exhausted": w(g) && (w(g).style.opacity = "0"); From 40508dcee6165a0098f12d6442d93dc6f0bfa76a Mon Sep 17 00:00:00 2001 From: skaphan Date: Thu, 5 Mar 2026 05:27:03 -0500 Subject: [PATCH 08/13] Scramble pie chart colors for better adjacent-slice contrast Use a coprime stride near N/2 to reorder the color palette so that visually similar colors are spread apart around the pie chart. Co-Authored-By: Claude Opus 4.6 --- templates/pie/pie-nonblocking.html | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/templates/pie/pie-nonblocking.html b/templates/pie/pie-nonblocking.html index faf0a731..1c5dbbc4 100644 --- a/templates/pie/pie-nonblocking.html +++ b/templates/pie/pie-nonblocking.html @@ -15,7 +15,14 @@ // Generate candidate colors from the election's color theme, // matching the palette used by the other visualizations. const colorGenerator = getColorGenerator(config.colorTheme); - const candidateColors = Array.from(colorGenerator({{ config.numCandidates }})); + const candidateColors = Array.from(colorGenerator({{ config.numCandidates }})); + // Scramble colors so adjacent pie slices have more visual contrast. + // Pick a stride near N/2 that is coprime to N, so every index is visited exactly once. + function gcd(a, b) { while (b) { [a, b] = [b, a % b]; } return a; } + const _n = candidateColors.length; + let _stride = Math.floor(_n / 2) || 1; + while (_stride < _n && gcd(_stride, _n) !== 1) _stride++; + const scrambledColors = candidateColors.map((_, i) => candidateColors[(i * _stride) % _n]); // Create the pie-chart element const pieChart = document.createElement("pie-chart"); @@ -25,7 +32,7 @@ // we can just bind it in object form here. pieChart.requestRoundChange = updateRound; pieChart.electionSummary = electionSummary; - pieChart.candidateColors = candidateColors; + pieChart.candidateColors = scrambledColors; pieChart.textForWinner = "{{ textForWinner }}"; pieChart.excludeFinalWinnerAndEliminatedCandidate = {{ config.excludeFinalWinnerAndEliminatedCandidate|yesno:"true,false" }}; pieChart.currentRound = {{ config.numRounds }}; From 20b9b038a7b20207a2c5f9f6a2961df60c4b9b2d Mon Sep 17 00:00:00 2001 From: skaphan Date: Thu, 5 Mar 2026 06:01:47 -0500 Subject: [PATCH 09/13] Interleave pie slices by vote count, fix color count Replace color scramble with tally interleaving: alternate largest and smallest candidates so small slices always have a large neighbor, reducing label overlap. Inactive Ballots always last. Fix color generation to use actual tally entry count instead of config.numCandidates, which excluded Inactive Ballots and caused color wrapping on large elections. Co-Authored-By: Claude Opus 4.6 --- templates/pie/pie-nonblocking.html | 15 ++++++--------- visualizer/pie/graphToRCtab.py | 24 ++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/templates/pie/pie-nonblocking.html b/templates/pie/pie-nonblocking.html index 1c5dbbc4..cf69e834 100644 --- a/templates/pie/pie-nonblocking.html +++ b/templates/pie/pie-nonblocking.html @@ -14,15 +14,12 @@ // Generate candidate colors from the election's color theme, // matching the palette used by the other visualizations. + // Generate enough colors for all tally entries (including Inactive Ballots) + // rather than config.numCandidates, to avoid color wrapping. + const _parsedSummary = JSON.parse(electionSummary); + const _numTallyEntries = Object.keys(_parsedSummary.results[0].tally).length; const colorGenerator = getColorGenerator(config.colorTheme); - const candidateColors = Array.from(colorGenerator({{ config.numCandidates }})); - // Scramble colors so adjacent pie slices have more visual contrast. - // Pick a stride near N/2 that is coprime to N, so every index is visited exactly once. - function gcd(a, b) { while (b) { [a, b] = [b, a % b]; } return a; } - const _n = candidateColors.length; - let _stride = Math.floor(_n / 2) || 1; - while (_stride < _n && gcd(_stride, _n) !== 1) _stride++; - const scrambledColors = candidateColors.map((_, i) => candidateColors[(i * _stride) % _n]); + const candidateColors = Array.from(colorGenerator(_numTallyEntries)); // Create the pie-chart element const pieChart = document.createElement("pie-chart"); @@ -32,7 +29,7 @@ // we can just bind it in object form here. pieChart.requestRoundChange = updateRound; pieChart.electionSummary = electionSummary; - pieChart.candidateColors = scrambledColors; + pieChart.candidateColors = candidateColors; pieChart.textForWinner = "{{ textForWinner }}"; pieChart.excludeFinalWinnerAndEliminatedCandidate = {{ config.excludeFinalWinnerAndEliminatedCandidate|yesno:"true,false" }}; pieChart.currentRound = {{ config.numRounds }}; diff --git a/visualizer/pie/graphToRCtab.py b/visualizer/pie/graphToRCtab.py index 54a37a2d..509c0a0b 100644 --- a/visualizer/pie/graphToRCtab.py +++ b/visualizer/pie/graphToRCtab.py @@ -47,9 +47,29 @@ def graph_to_rctab_json(graph): nodes_this_round = graph.nodesPerRound[round_i] # Build tally: candidate name -> vote count (as string) - # Include all candidates present this round (including Inactive Ballots) - tally = {} + # Include all candidates present this round (including Inactive Ballots). + # Interleave by vote count (largest, smallest, 2nd largest, 2nd smallest, ...) + # so that small slices always have a large neighbor, reducing label overlap. + # Inactive/residual entries always go last. + active_items = [] + inactive_items = [] for candidate, node in nodes_this_round.items(): + if candidate.name in inactive_names: + inactive_items.append((candidate, node)) + else: + active_items.append((candidate, node)) + active_items.sort(key=lambda item: item[1].count, reverse=True) + interleaved = [] + lo, hi = 0, len(active_items) - 1 + while lo <= hi: + interleaved.append(active_items[lo]) + if lo != hi: + interleaved.append(active_items[hi]) + lo += 1 + hi -= 1 + interleaved.extend(inactive_items) + tally = {} + for candidate, node in interleaved: tally[candidate.name] = _stringify(node.count) # Build tallyResults from transfersPerRound From 5d761f6073cca7526289c9530a832c0e0aa12c06 Mon Sep 17 00:00:00 2001 From: skaphan Date: Thu, 5 Mar 2026 06:13:26 -0500 Subject: [PATCH 10/13] Add reset-db.sh for easy database reset after branch switching Co-Authored-By: Claude Opus 4.6 --- scripts/reset-db.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/reset-db.sh diff --git a/scripts/reset-db.sh b/scripts/reset-db.sh new file mode 100755 index 00000000..24f378fa --- /dev/null +++ b/scripts/reset-db.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Reset the SQLite database and re-run all migrations. +# Use after switching branches with incompatible migration history. +set -e + +source venv/bin/activate +source .env + +rm -f db.sqlite3 +python manage.py migrate + +# Create API-enabled admin user (matches docker-entrypoint.sh) +python manage.py shell -c " +from django.contrib.auth import get_user_model +User = get_user_model() +if not User.objects.filter(username='skaphan').exists(): + user = User.objects.create_superuser('skaphan', 'sjk@kaphan.org', 'rcvisacc0unt') + user.userprofile.canUseApi = True + user.userprofile.save() + print('Created API user skaphan with API access') +else: + print('API user skaphan already exists') +" + +echo "Database reset complete." From 0c61b0e014041aef8ef8d952e129fef6604c7aaf Mon Sep 17 00:00:00 2001 From: skaphan Date: Thu, 5 Mar 2026 06:36:22 -0500 Subject: [PATCH 11/13] Fix interleave: compute order once from round 1, reuse for all rounds Per-round reordering broke D3 pie animation because candidate positions shifted between rounds. Now the interleave order is stable across all rounds, just dropping eliminated candidates. Co-Authored-By: Claude Opus 4.6 --- visualizer/pie/graphToRCtab.py | 54 +++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/visualizer/pie/graphToRCtab.py b/visualizer/pie/graphToRCtab.py index 509c0a0b..174931a7 100644 --- a/visualizer/pie/graphToRCtab.py +++ b/visualizer/pie/graphToRCtab.py @@ -42,35 +42,41 @@ def graph_to_rctab_json(graph): inactive_names = {common.INACTIVE_TEXT, common.RESIDUAL_SURPLUS_TEXT} num_active_candidates = sum(1 for c in graph.candidates if c.name not in inactive_names) + # Compute interleave order once from round 1, reuse for all rounds. + # Alternates largest/smallest so small slices have large neighbors, + # reducing label overlap. Inactive/residual entries always last. + # Order must be stable across rounds for D3 pie animation to work. + round1_nodes = graph.nodesPerRound[0] + active_items = [] + inactive_order = [] + for candidate, node in round1_nodes.items(): + if candidate.name in inactive_names: + inactive_order.append(candidate.name) + else: + active_items.append((candidate.name, node.count)) + active_items.sort(key=lambda item: item[1], reverse=True) + interleaved_order = [] + lo, hi = 0, len(active_items) - 1 + while lo <= hi: + interleaved_order.append(active_items[lo][0]) + if lo != hi: + interleaved_order.append(active_items[hi][0]) + lo += 1 + hi -= 1 + interleaved_order.extend(inactive_order) + results = [] for round_i in range(num_rounds): nodes_this_round = graph.nodesPerRound[round_i] + names_this_round = {c.name: (c, node) for c, node in nodes_this_round.items()} - # Build tally: candidate name -> vote count (as string) - # Include all candidates present this round (including Inactive Ballots). - # Interleave by vote count (largest, smallest, 2nd largest, 2nd smallest, ...) - # so that small slices always have a large neighbor, reducing label overlap. - # Inactive/residual entries always go last. - active_items = [] - inactive_items = [] - for candidate, node in nodes_this_round.items(): - if candidate.name in inactive_names: - inactive_items.append((candidate, node)) - else: - active_items.append((candidate, node)) - active_items.sort(key=lambda item: item[1].count, reverse=True) - interleaved = [] - lo, hi = 0, len(active_items) - 1 - while lo <= hi: - interleaved.append(active_items[lo]) - if lo != hi: - interleaved.append(active_items[hi]) - lo += 1 - hi -= 1 - interleaved.extend(inactive_items) + # Build tally using the stable interleaved order from round 1, + # including only candidates still present this round. tally = {} - for candidate, node in interleaved: - tally[candidate.name] = _stringify(node.count) + for name in interleaved_order: + if name in names_this_round: + candidate, node = names_this_round[name] + tally[name] = _stringify(node.count) # Build tallyResults from transfersPerRound tally_results = [] From 3db35e26c5ea14f509e5e4a0628fc8835262b9f2 Mon Sep 17 00:00:00 2001 From: skaphan Date: Fri, 6 Mar 2026 17:39:37 -0500 Subject: [PATCH 12/13] Add pie chart and special character tests Tests pie vistype rendering, embedly redirect, hidePie config toggle, and cloudflare cache purge including pie URLs. Tests graphToRCtab with candidate names containing HTML, quotes, and other special characters. Co-Authored-By: Claude Opus 4.6 --- visualizer/tests/testGraphToRCtab.py | 33 ++++++++++++++++++ visualizer/tests/testSimple.py | 52 ++++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/visualizer/tests/testGraphToRCtab.py b/visualizer/tests/testGraphToRCtab.py index a177558f..cddfa37a 100644 --- a/visualizer/tests/testGraphToRCtab.py +++ b/visualizer/tests/testGraphToRCtab.py @@ -261,3 +261,36 @@ def test_without_exclude_flag(self): last_round = result['results'][-1] elected = [tr for tr in last_round['tallyResults'] if 'elected' in tr] self.assertEqual(len(elected), 1) + + +class SpecialCharacterTests(TestCase): + """ Tests that candidate names with special characters survive the conversion """ + + def setUp(self): + with open(filenames.CRAZY_NAMES, 'r', encoding='utf-8') as f: + self.graph = make_graph_with_file(f, excludeFinalWinnerAndEliminatedCandidate=False) + self.result = graph_to_rctab_json(self.graph) + + def test_conversion_succeeds(self): + """ graphToRCtab should not crash on names with HTML, quotes, commas, etc. """ + self.assertIn('results', self.result) + self.assertGreater(len(self.result['results']), 0) + + def test_html_name_preserved(self): + """ A candidate name containing HTML tags should appear verbatim in the tally """ + first_tally = self.result['results'][0]['tally'] + html_names = [n for n in first_tally if '' in n] + self.assertEqual(len(html_names), 1) + self.assertIn('A malicious name with html', first_tally) + + def test_quotes_preserved(self): + """ A candidate name with quotes and ticks should appear verbatim """ + first_tally = self.result['results'][0]['tally'] + self.assertIn('A malicious name with "quotes" and \'ticks\'', first_tally) + + def test_all_candidates_present_in_first_round(self): + """ All graph candidates should appear in the first round's tally """ + graph_candidates = {c.name for c in self.graph.candidates} + first_tally_names = set(self.result['results'][0]['tally'].keys()) + self.assertTrue(graph_candidates.issubset(first_tally_names), + f"Missing candidates: {graph_candidates - first_tally_names}") diff --git a/visualizer/tests/testSimple.py b/visualizer/tests/testSimple.py index f5df1319..948524ce 100644 --- a/visualizer/tests/testSimple.py +++ b/visualizer/tests/testSimple.py @@ -293,6 +293,50 @@ def test_embedly_translation(self): response = self.client.get(visualizeUrl) self.assertRedirects(response, expectedBaseURL + 'barchart-interactive', status_code=301) + def test_pie_vistype_renders(self): + """ + Ensure the pie chart vistype renders without error when accessed + via the embedded visualization URL with ?vistype=pie. + """ + TestHelpers.get_multiwinner_upload_response(self.client) + slug = TestHelpers.get_latest_upload().slug + path = reverse('visualizeEmbedded', args=(slug,)) + '?vistype=pie' + response = self.client.get(path) + self.assertEqual(response.status_code, 200) + + def test_pie_embedly_redirect(self): + """ + Ensure the embedly-friendly pie URL /vo/{slug}/pie redirects + to the embedded URL /ve/{slug}?vistype=pie with a 301. + """ + TestHelpers.get_multiwinner_upload_response(self.client) + slug = TestHelpers.get_latest_upload().slug + visualizeUrl = reverse('visualizeEmbedly', args=(slug, 'pie')) + response = self.client.get(visualizeUrl) + expectedUrl = f'/ve/{slug}?vistype=pie' + self.assertRedirects(response, expectedUrl, status_code=301) + + def test_hide_pie_config(self): + """ + When hidePie is True on a JsonConfig, the rendered visualization page + should pass hidePie = true to the JavaScript config. + """ + TestHelpers.get_multiwinner_upload_response(self.client) + config = TestHelpers.get_latest_upload() + + # Default: hidePie is False + path = reverse('visualize', args=(config.slug,)) + response = self.client.get(path) + self.assertContains(response, 'config.hidePie = false') + + # Set hidePie to True; disable cache so we get a fresh response + config.hidePie = True + config.save() + with self.settings(CACHES={'default': { + 'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}): + response = self.client.get(path) + self.assertContains(response, 'config.hidePie = true') + @patch('visualizer.wikipedia.wikipedia.WikipediaExport._get_todays_date_string') def test_wikicode(self, mockGetDateString): """ Validate that the wikicode can be generated and hasn't inadvertently changed """ @@ -380,7 +424,7 @@ def test_cloudflare_purge(self, requestPostResponse): slug = TestHelpers.get_latest_upload().slug requestPostResponse.side_effect = TestHelpers.create_request_mock({'a': 0}, 200) - expectedLogString = "INFO:common.cloudflare:Cleared cloudflare cache for 15 starting with "\ + expectedLogString = "INFO:common.cloudflare:Cleared cloudflare cache for 17 starting with "\ "/v/one-round: {'a': 0}" with self.settings( @@ -404,6 +448,7 @@ def test_cloudflare_purge(self, requestPostResponse): "https://example.com/vo/one-round/barchart-interactive", "https://example.com/vo/one-round/sankey", "https://example.com/vo/one-round/table", + "https://example.com/vo/one-round/pie", "https://example.com/vb/one-round", "https://example.com/ve/one-round?vistype=barchart-interactive", "https://example.com/ve/one-round?vistype=barchart-fixed", @@ -412,6 +457,7 @@ def test_cloudflare_purge(self, requestPostResponse): "https://example.com/ve/one-round?vistype=tabular-by-round-interactive", "https://example.com/ve/one-round?vistype=candidate-by-round", "https://example.com/ve/one-round?vistype=sankey", + "https://example.com/ve/one-round?vistype=pie", "https://www.example.com/v/one-round", "https://www.example.com/ve/one-round", "https://www.example.com/vo/one-round", @@ -419,6 +465,7 @@ def test_cloudflare_purge(self, requestPostResponse): "https://www.example.com/vo/one-round/barchart-interactive", "https://www.example.com/vo/one-round/sankey", "https://www.example.com/vo/one-round/table", + "https://www.example.com/vo/one-round/pie", "https://www.example.com/vb/one-round", "https://www.example.com/ve/one-round?vistype=barchart-interactive", "https://www.example.com/ve/one-round?vistype=barchart-fixed", @@ -426,7 +473,8 @@ def test_cloudflare_purge(self, requestPostResponse): "https://www.example.com/ve/one-round?vistype=tabular-by-round", "https://www.example.com/ve/one-round?vistype=tabular-by-round-interactive", "https://www.example.com/ve/one-round?vistype=candidate-by-round", - "https://www.example.com/ve/one-round?vistype=sankey"]} + "https://www.example.com/ve/one-round?vistype=sankey", + "https://www.example.com/ve/one-round?vistype=pie"]} requestPostResponse.assert_called_with(expectedUrl, headers=expectedHeaders, data=json.dumps(expectedData), From de5205a8ca388bd491b6b9cacc84c4296ff73d5d Mon Sep 17 00:00:00 2001 From: skaphan Date: Fri, 6 Mar 2026 18:00:22 -0500 Subject: [PATCH 13/13] Remove reset-db.sh from branch (local-only script) Co-Authored-By: Claude Opus 4.6 --- scripts/reset-db.sh | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100755 scripts/reset-db.sh diff --git a/scripts/reset-db.sh b/scripts/reset-db.sh deleted file mode 100755 index 24f378fa..00000000 --- a/scripts/reset-db.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# Reset the SQLite database and re-run all migrations. -# Use after switching branches with incompatible migration history. -set -e - -source venv/bin/activate -source .env - -rm -f db.sqlite3 -python manage.py migrate - -# Create API-enabled admin user (matches docker-entrypoint.sh) -python manage.py shell -c " -from django.contrib.auth import get_user_model -User = get_user_model() -if not User.objects.filter(username='skaphan').exists(): - user = User.objects.create_superuser('skaphan', 'sjk@kaphan.org', 'rcvisacc0unt') - user.userprofile.canUseApi = True - user.userprofile.save() - print('Created API user skaphan with API access') -else: - print('API user skaphan already exists') -" - -echo "Database reset complete."