phoria2 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +71 -13
  2. package/dist/bloom.js +4 -4
  3. package/dist/bloom.js.map +1 -1
  4. package/dist/charts.js +358 -345
  5. package/dist/charts.js.map +1 -1
  6. package/dist/core.js +3989 -3600
  7. package/dist/core.js.map +1 -1
  8. package/dist/edit.js +43 -43
  9. package/dist/edit.js.map +1 -1
  10. package/dist/explain.js +5 -1
  11. package/dist/explain.js.map +1 -1
  12. package/dist/gltf.js +96 -96
  13. package/dist/gltf.js.map +1 -1
  14. package/dist/motion.js +3 -3
  15. package/dist/motion.js.map +1 -1
  16. package/dist/particles.js +16 -16
  17. package/dist/particles.js.map +1 -1
  18. package/dist/passes.js +26 -26
  19. package/dist/passes.js.map +1 -1
  20. package/dist/phoria2.js +1 -1
  21. package/dist/picking.js +16 -16
  22. package/dist/picking.js.map +1 -1
  23. package/dist/types/OrbitControl.d.ts +6 -2
  24. package/dist/types/Raycaster.d.ts +10 -0
  25. package/dist/types/View.d.ts +59 -1
  26. package/dist/types/charts/Chart.d.ts +7 -0
  27. package/dist/types/explain.d.ts +3 -0
  28. package/dist/types/frame.d.ts +7 -0
  29. package/dist/types/geometry/Geometry.d.ts +8 -2
  30. package/dist/types/keyboard.d.ts +48 -0
  31. package/dist/types/labels.d.ts +4 -0
  32. package/dist/types/scene/Node.d.ts +19 -14
  33. package/dist/types/scene/drawables.d.ts +32 -14
  34. package/dist/types/scene/lights.d.ts +16 -2
  35. package/dist/types/shadow.d.ts +2 -1
  36. package/dist/types/types.d.ts +14 -0
  37. package/dist/types/value/Color.d.ts +0 -4
  38. package/dist/types/value/Quat.d.ts +4 -2
  39. package/llms-full.txt +58 -9
  40. package/package.json +4 -1
  41. package/schema/scene.schema.json +19 -1
  42. package/src/OrbitControl.js +7 -3
  43. package/src/Raycaster.js +58 -0
  44. package/src/View.js +204 -41
  45. package/src/charts/Chart.js +20 -2
  46. package/src/explain.js +6 -2
  47. package/src/frame.js +29 -9
  48. package/src/geometry/Geometry.js +16 -3
  49. package/src/keyboard.js +298 -0
  50. package/src/labels.js +4 -1
  51. package/src/scene/Node.js +20 -9
  52. package/src/scene/Scene.js +2 -0
  53. package/src/scene/cameras.js +4 -1
  54. package/src/scene/drawables.js +48 -12
  55. package/src/scene/lights.js +40 -6
  56. package/src/shadow.js +27 -4
  57. package/src/types.js +6 -0
  58. package/src/value/Color.js +21 -0
  59. package/src/value/Quat.js +15 -6
  60. package/src/watch.js +6 -1
package/dist/charts.js CHANGED
@@ -1,4 +1,4 @@
1
- import { At as e, C as t, Ft as n, Ot as r, R as i, S as a, Tt as o, Z as s, _t as c, b as l, it as u, kt as d, l as f, m as p, n as m, rt as h, w as g, x as _ } from "./core.js";
1
+ import { $ as e, At as t, Ft as n, Ot as r, Q as i, Tt as a, V as o, Z as s, _t as c, ct as l, et as u, kt as d, l as f, m as p, n as m, nt as h, rt as g, tt as _ } from "./core.js";
2
2
  // src/charts/axes.js
3
3
  var v = .97, y = .08, b = /* @__PURE__ */ new Float32Array(16);
4
4
  function x(e, t, r) {
@@ -11,22 +11,22 @@ function x(e, t, r) {
11
11
  s / c
12
12
  ];
13
13
  }
14
- function S({ box: e, axes: t, theme: n, overlap: r }) {
15
- let [o, s, c] = e, l = new h({
14
+ function S({ box: t, axes: n, theme: r, overlap: a }) {
15
+ let [o, s, c] = t, u = new h({
16
16
  name: "axes",
17
17
  pickable: !1
18
- }), u = (e) => x(l, e, s / 2), d = n === "light" ? "#c3c8d2" : "#3a3d47", f = (e) => {
18
+ }), d = (e) => x(u, e, s / 2), f = r === "light" ? "#c3c8d2" : "#3a3d47", p = (e) => {
19
19
  let t = e.channel?.axis?.ticks;
20
20
  if (!Array.isArray(t)) return e.scale.kind === "band" ? e.scale.ticks() : e.scale.ticks(t ?? 5);
21
21
  let [n, r] = e.scale.range, i = Math.min(n, r), a = Math.max(n, r);
22
22
  return t.filter((t) => e.scale(t) >= i - 1e-9 && e.scale(t) <= a + 1e-9);
23
- }, p = (e) => e && e.scale.kind !== "band" && e.channel?.axis !== !1 ? f(e) : [], m = p(t.x), g = p(t.y), b = p(t.z), S = (e, n) => {
24
- let r = [], f = (e, t) => r.push(...e, ...t), p = (e) => n < 0 ? -e / 2 : e / 2;
25
- if (e === "y") {
26
- let e = n < 0 ? 0 : s;
27
- for (let n of m) {
28
- let r = t.x.scale(n);
29
- f([
23
+ }, m = (e) => e && e.scale.kind !== "band" && e.channel?.axis !== !1 ? p(e) : [], g = m(n.x), _ = m(n.y), b = m(n.z), S = (t, r) => {
24
+ let i = [], a = (e, t) => i.push(...e, ...t), p = (e) => r < 0 ? -e / 2 : e / 2;
25
+ if (t === "y") {
26
+ let e = r < 0 ? 0 : s;
27
+ for (let t of g) {
28
+ let r = n.x.scale(t);
29
+ a([
30
30
  r,
31
31
  e,
32
32
  -c / 2
@@ -36,9 +36,9 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
36
36
  c / 2
37
37
  ]);
38
38
  }
39
- for (let n of b) {
40
- let r = t.z.scale(n);
41
- f([
39
+ for (let t of b) {
40
+ let r = n.z.scale(t);
41
+ a([
42
42
  -o / 2,
43
43
  e,
44
44
  r
@@ -48,7 +48,7 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
48
48
  r
49
49
  ]);
50
50
  }
51
- C(f, [
51
+ C(a, [
52
52
  -o / 2,
53
53
  e,
54
54
  -c / 2
@@ -65,11 +65,11 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
65
65
  e,
66
66
  c / 2
67
67
  ]);
68
- } else if (e === "x") {
68
+ } else if (t === "x") {
69
69
  let e = p(o);
70
- for (let n of g) {
71
- let r = t.y.scale(n);
72
- f([
70
+ for (let t of _) {
71
+ let r = n.y.scale(t);
72
+ a([
73
73
  e,
74
74
  r,
75
75
  -c / 2
@@ -79,9 +79,9 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
79
79
  c / 2
80
80
  ]);
81
81
  }
82
- for (let n of b) {
83
- let r = t.z.scale(n);
84
- f([
82
+ for (let t of b) {
83
+ let r = n.z.scale(t);
84
+ a([
85
85
  e,
86
86
  0,
87
87
  r
@@ -91,7 +91,7 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
91
91
  r
92
92
  ]);
93
93
  }
94
- C(f, [
94
+ C(a, [
95
95
  e,
96
96
  0,
97
97
  -c / 2
@@ -110,9 +110,9 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
110
110
  ]);
111
111
  } else {
112
112
  let e = p(c);
113
- for (let n of g) {
114
- let r = t.y.scale(n);
115
- f([
113
+ for (let t of _) {
114
+ let r = n.y.scale(t);
115
+ a([
116
116
  -o / 2,
117
117
  r,
118
118
  e
@@ -122,9 +122,9 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
122
122
  e
123
123
  ]);
124
124
  }
125
- for (let n of m) {
126
- let r = t.x.scale(n);
127
- f([
125
+ for (let t of g) {
126
+ let r = n.x.scale(t);
127
+ a([
128
128
  r,
129
129
  0,
130
130
  e
@@ -134,7 +134,7 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
134
134
  e
135
135
  ]);
136
136
  }
137
- C(f, [
137
+ C(a, [
138
138
  -o / 2,
139
139
  0,
140
140
  e
@@ -152,12 +152,12 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
152
152
  e
153
153
  ]);
154
154
  }
155
- let h = "xyz".indexOf(e);
156
- l.add(new a({
157
- geometry: new i({ positions: r }),
158
- material: { color: d },
155
+ let m = "xyz".indexOf(t);
156
+ u.add(new e({
157
+ geometry: new l({ positions: i }),
158
+ material: { color: f },
159
159
  pickable: !1,
160
- showFrom: (e) => -n * u(e)[h] > y
160
+ showFrom: (e) => -r * d(e)[m] > y
161
161
  }));
162
162
  };
163
163
  for (let e of [
@@ -165,30 +165,30 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
165
165
  "y",
166
166
  "z"
167
167
  ]) for (let t of [-1, 1]) S(e, t);
168
- let w = Math.max(o, s, c) * .04, T = (e) => `phoria-axis-${e} phoria-${n}`, E = (e, n, i) => {
169
- let a = t[e];
170
- if (!a || a.channel?.axis === !1) return;
171
- let o = "xyz".indexOf(e), s = f(a);
172
- for (let e of n) {
173
- let t = l.add(new h({ showFrom: (t) => {
174
- let n = u(t);
175
- return Math.abs(n[o]) < v && e.when(n);
168
+ let w = Math.max(o, s, c) * .04, T = (e) => `phoria-axis-${e} phoria-${r}`, E = (e, t, r) => {
169
+ let o = n[e];
170
+ if (!o || o.channel?.axis === !1) return;
171
+ let s = "xyz".indexOf(e), c = p(o);
172
+ for (let e of t) {
173
+ let t = u.add(new h({ showFrom: (t) => {
174
+ let n = d(t);
175
+ return Math.abs(n[s]) < v && e.when(n);
176
176
  } }));
177
- for (let n of s) t.add(new _({
178
- text: a.scale.format(n),
179
- position: e.at(a.scale(n), w),
180
- place: i,
177
+ for (let n of c) t.add(new i({
178
+ text: o.scale.format(n),
179
+ position: e.at(o.scale(n), w),
180
+ place: r,
181
181
  className: T("tick"),
182
182
  priority: 1,
183
- overlap: r
183
+ overlap: a
184
184
  }));
185
- a.title && t.add(new _({
186
- text: a.title,
185
+ o.title && t.add(new i({
186
+ text: o.title,
187
187
  position: e.title(w),
188
- place: i,
188
+ place: r,
189
189
  className: T("title"),
190
190
  priority: 2,
191
- overlap: r
191
+ overlap: a
192
192
  }));
193
193
  }
194
194
  }, D = (e) => e[1] >= -.08, O = (e) => e >= -.1 ? 1 : -1;
@@ -228,7 +228,7 @@ function S({ box: e, axes: t, theme: n, overlap: r }) {
228
228
  s + n * 2,
229
229
  t * c / 2
230
230
  ]
231
- }))), "left"), l;
231
+ }))), "left"), u;
232
232
  }
233
233
  function C(e, t, n, r, i) {
234
234
  e(t, n), e(n, r), e(r, i), e(i, t);
@@ -239,13 +239,13 @@ function T(e, t) {
239
239
  let n = e / Math.max(1, t), r = 10 ** Math.floor(Math.log(n) / w), i = n / r;
240
240
  return r * (i >= 7.07 ? 10 : i >= 3.16 ? 5 : i >= 1.41 ? 2 : 1);
241
241
  }
242
- function E(t, n, i = !1) {
243
- if (typeof t == "function") return t;
244
- if (t && typeof t == "object") {
245
- let e = i ? new Intl.DateTimeFormat(void 0, t) : new Intl.NumberFormat(void 0, t);
246
- return (t) => e.format(t);
242
+ function E(e, n, i = !1) {
243
+ if (typeof e == "function") return e;
244
+ if (e && typeof e == "object") {
245
+ let t = i ? new Intl.DateTimeFormat(void 0, e) : new Intl.NumberFormat(void 0, e);
246
+ return (e) => t.format(e);
247
247
  }
248
- return t !== void 0 && e("charts", `'format' must be Intl format options or a function, got ${r(t)}`), n;
248
+ return e !== void 0 && t("charts", `'format' must be Intl format options or a function, got ${r(e)}`), n;
249
249
  }
250
250
  function D(e, t) {
251
251
  let n = Math.max(0, Math.min(6, -Math.floor(Math.log(e || 1) / w))), r = new Intl.NumberFormat(void 0, { maximumFractionDigits: n }), i = new Intl.NumberFormat(void 0, {
@@ -254,8 +254,8 @@ function D(e, t) {
254
254
  }), a = Math.abs(t) >= 1e4 && e >= Math.abs(t) / 100;
255
255
  return (e) => (a ? i : r).format(e);
256
256
  }
257
- function O(t, n) {
258
- return Array.isArray(t) && t.length === 2 && t.every((e) => typeof e == "number" && Number.isFinite(e)) || e("charts", `'${n}' must be [min, max] numbers, got ${r(t)}`), [t[0], t[1]];
257
+ function O(e, n) {
258
+ return Array.isArray(e) && e.length === 2 && e.every((e) => typeof e == "number" && Number.isFinite(e)) || t("charts", `'${n}' must be [min, max] numbers, got ${r(e)}`), [e[0], e[1]];
259
259
  }
260
260
  function k({ domain: e, range: t = [0, 1], nice: n = !1, zero: r = !1, clamp: i = !1, format: a }) {
261
261
  let [o, s] = O(e, "domain"), [c, l] = O(t, "range");
@@ -273,9 +273,9 @@ function k({ domain: e, range: t = [0, 1], nice: n = !1, zero: r = !1, clamp: i
273
273
  return n;
274
274
  }, d.format = E(a, D(T(s - o, 5), Math.max(Math.abs(o), Math.abs(s)))), d;
275
275
  }
276
- function A({ domain: t, range: n = [0, 1], format: r }) {
277
- let [i, a] = O(t, "domain");
278
- (i <= 0 || a <= 0) && e("charts", `a log scale needs a domain above 0, got [${i}, ${a}] - use a linear scale for zero or negative values`);
276
+ function A({ domain: e, range: n = [0, 1], format: r }) {
277
+ let [i, a] = O(e, "domain");
278
+ (i <= 0 || a <= 0) && t("charts", `a log scale needs a domain above 0, got [${i}, ${a}] - use a linear scale for zero or negative values`);
279
279
  let o = k({
280
280
  domain: [Math.log10(i), Math.log10(a)],
281
281
  range: n
@@ -388,9 +388,9 @@ var j = 1e3, M = 60 * j, N = 60 * M, P = 24 * N, F = [
388
388
  },
389
389
  Y: { year: "numeric" }
390
390
  };
391
- function I(t) {
392
- let n = t instanceof Date ? t : new Date(t);
393
- return Number.isNaN(n.getTime()) && e("charts", `${r(t)} isn't a date - use Date objects, timestamps or ISO strings like '2026-10-25'`), n;
391
+ function I(e) {
392
+ let n = e instanceof Date ? e : new Date(e);
393
+ return Number.isNaN(n.getTime()) && t("charts", `${r(e)} isn't a date - use Date objects, timestamps or ISO strings like '2026-10-25'`), n;
394
394
  }
395
395
  function ne({ domain: e, range: t = [0, 1], format: n }) {
396
396
  let r = I(e[0]).getTime(), i = I(e[1]).getTime(), a = k({
@@ -419,13 +419,13 @@ function ne({ domain: e, range: t = [0, 1], format: n }) {
419
419
  let l = new Intl.DateTimeFormat(void 0, te[s(6)[1]]);
420
420
  return c.format = E(n, (e) => l.format(I(e)), !0), c;
421
421
  }
422
- function re({ domain: t, range: n = [0, 1], padding: i = .2, format: a }) {
423
- Array.isArray(t) || e("charts", `a band scale's domain is a list of categories, got ${r(t)}`);
424
- let [o, s] = O(n, "range"), c = new Map(t.map((e, t) => [String(e), t])), l = (s - o) / Math.max(1, t.length), u = ((e) => {
422
+ function re({ domain: e, range: n = [0, 1], padding: i = .2, format: a }) {
423
+ Array.isArray(e) || t("charts", `a band scale's domain is a list of categories, got ${r(e)}`);
424
+ let [o, s] = O(n, "range"), c = new Map(e.map((e, t) => [String(e), t])), l = (s - o) / Math.max(1, e.length), u = ((e) => {
425
425
  let t = c.get(String(e));
426
426
  return t === void 0 ? NaN : o + l * (t + .5);
427
427
  });
428
- return u.kind = "band", u.domain = t, u.range = [o, s], u.step = l, u.bandwidth = Math.abs(l) * (1 - i), u.ticks = () => t, u.format = E(a, (e) => String(e)), u;
428
+ return u.kind = "band", u.domain = e, u.range = [o, s], u.step = l, u.bandwidth = Math.abs(l) * (1 - i), u.ticks = () => e, u.format = E(a, (e) => String(e)), u;
429
429
  }
430
430
  var L = {
431
431
  category: [
@@ -476,31 +476,31 @@ var L = {
476
476
  "#2166ac"
477
477
  ]
478
478
  };
479
- function R({ domain: t, scheme: n, range: i, kind: a }) {
480
- n !== void 0 && !(n in L) && e("charts", `colour scheme '${n}' isn't one we have - use ${Object.keys(L).map((e) => `'${e}'`).join(", ")}, or a range of colours`);
481
- let o = a ? a === "sequential" : t.length === 2 && t.every((e) => typeof e == "number");
482
- o && (t.length < 2 || t.some((e) => typeof e != "number")) && e("charts", `a sequential colour scale needs two or more numbers in its domain, got ${r(t)}`);
479
+ function R({ domain: e, scheme: n, range: i, kind: a }) {
480
+ n !== void 0 && !(n in L) && t("charts", `colour scheme '${n}' isn't one we have - use ${Object.keys(L).map((e) => `'${e}'`).join(", ")}, or a range of colours`);
481
+ let o = a ? a === "sequential" : e.length === 2 && e.every((e) => typeof e == "number");
482
+ o && (e.length < 2 || e.some((e) => typeof e != "number")) && t("charts", `a sequential colour scale needs two or more numbers in its domain, got ${r(e)}`);
483
483
  let s = (i ?? L[n ?? (o ? "viridis" : "category")]).map((e) => c.fromInput(e, "charts")), l;
484
484
  if (o) {
485
- let e = (e) => {
486
- let n = t.length - 1, r = 0;
487
- for (; r < n - 1 && e > t[r + 1];) r++;
488
- let i = (e - t[r]) / (t[r + 1] - t[r] || 1);
485
+ let t = (t) => {
486
+ let n = e.length - 1, r = 0;
487
+ for (; r < n - 1 && t > e[r + 1];) r++;
488
+ let i = (t - e[r]) / (e[r + 1] - e[r] || 1);
489
489
  return Math.min(1, Math.max(0, (r + i) / n));
490
490
  };
491
- l = ((t) => {
491
+ l = ((e) => {
492
492
  if (s.length < 2) return s[0].clone();
493
- let n = e(t) * (s.length - 1), r = Math.min(s.length - 2, Math.floor(n));
493
+ let n = t(e) * (s.length - 1), r = Math.min(s.length - 2, Math.floor(n));
494
494
  return s[r].clone().lerp(s[r + 1], n - r);
495
495
  }), l.kind = "sequential", l.colors = () => [];
496
496
  } else {
497
- let e = new Map(t.map((e, t) => [String(e), t]));
498
- l = ((t) => s[(e.get(String(t)) ?? 0) % s.length].clone()), l.kind = "categorical", l.colors = () => t.map((e) => ({
497
+ let t = new Map(e.map((e, t) => [String(e), t]));
498
+ l = ((e) => s[(t.get(String(e)) ?? 0) % s.length].clone()), l.kind = "categorical", l.colors = () => e.map((e) => ({
499
499
  value: e,
500
500
  color: l(e)
501
501
  }));
502
502
  }
503
- return l.domain = t, l.range = s.map((e) => e.getStyle()), l;
503
+ return l.domain = e, l.range = s.map((e) => e.getStyle()), l;
504
504
  }
505
505
  function z(e) {
506
506
  let t = [...new Map(e.map((e) => [e instanceof Date ? e.getTime() : e, e])).values()];
@@ -624,7 +624,7 @@ function oe(e) {
624
624
  return n;
625
625
  }
626
626
  function U(e, t) {
627
- let n = new l({
627
+ let n = new s({
628
628
  geometry: f(1),
629
629
  material: { roughness: .55 },
630
630
  count: e,
@@ -640,7 +640,7 @@ function se(e) {
640
640
  let t = !!e.spec.channels.size?.field, n = Math.min(...e.box) / 40, r = e.spec.channels.opacity?.value, i = {
641
641
  roughness: .4,
642
642
  ...r === void 0 ? {} : { opacity: r }
643
- }, a = t ? new l({
643
+ }, a = t ? new s({
644
644
  geometry: p({
645
645
  radius: 1,
646
646
  detail: 1
@@ -648,7 +648,7 @@ function se(e) {
648
648
  material: i,
649
649
  count: 64,
650
650
  labels: V(e, "above")
651
- }) : new g({
651
+ }) : new _({
652
652
  geometry: G(64),
653
653
  material: {
654
654
  size: e.spec.channels.size?.value ?? n * 1.4,
@@ -684,7 +684,7 @@ function se(e) {
684
684
  let r = e.length / n.stride;
685
685
  if (a.data = n.rows, t) {
686
686
  if (r > a.instanceMatrices.length / 16) {
687
- let e = new l({
687
+ let e = new s({
688
688
  geometry: a.geometry,
689
689
  material: a.material,
690
690
  count: r * 2,
@@ -713,8 +713,8 @@ function se(e) {
713
713
  }
714
714
  let i = a.geometry;
715
715
  r > i.vertexCount && (a.geometry = G(r * 2));
716
- let s = a.geometry.positions, c = a.geometry.colors;
717
- for (let t = 0; t < r; t++) s.set(e.subarray(t * 6, t * 6 + 3), t * 3), c.set(e.subarray(t * 6 + 3, t * 6 + 6), t * 3);
716
+ let c = a.geometry.positions, l = a.geometry.colors;
717
+ for (let t = 0; t < r; t++) c.set(e.subarray(t * 6, t * 6 + 3), t * 3), l.set(e.subarray(t * 6 + 3, t * 6 + 6), t * 3);
718
718
  a.geometry.drawCount = r, a.geometry.needsUpdate(), a.geometry !== i && i.dispose();
719
719
  },
720
720
  enter(e) {
@@ -724,15 +724,15 @@ function se(e) {
724
724
  return o;
725
725
  }
726
726
  function G(e) {
727
- let t = new i({
727
+ let t = new l({
728
728
  positions: new Float32Array(e * 3),
729
729
  colors: new Float32Array(e * 3)
730
730
  });
731
731
  return t.drawCount = 0, t;
732
732
  }
733
- function ce(e, n) {
734
- let r = new a({
735
- geometry: new i({ positions: [
733
+ function ce(t, n) {
734
+ let r = new e({
735
+ geometry: new l({ positions: [
736
736
  0,
737
737
  0,
738
738
  0,
@@ -745,16 +745,16 @@ function ce(e, n) {
745
745
  vertexColors: !0
746
746
  },
747
747
  pickable: !1
748
- }), o = new g({
748
+ }), i = new _({
749
749
  geometry: G(8),
750
750
  material: {
751
751
  size: 7,
752
752
  sizeAttenuation: !1,
753
753
  vertexColors: !0
754
754
  },
755
- labels: V(e, "above")
756
- }), s = n ? new t({
757
- geometry: new i({ positions: [
755
+ labels: V(t, "above")
756
+ }), a = n ? new u({
757
+ geometry: new l({ positions: [
758
758
  0,
759
759
  0,
760
760
  0,
@@ -774,22 +774,22 @@ function ce(e, n) {
774
774
  pickable: !1
775
775
  }) : null;
776
776
  return {
777
- nodes: s ? [
778
- s,
777
+ nodes: a ? [
778
+ a,
779
779
  r,
780
- o
781
- ] : [r, o],
782
- layout(t) {
783
- let { x: n, y: r, z: i } = e.scales, a = e.spec.channels, o = a.color?.field ? a.color : a.detail ?? (a.z?.field ? a.z : null), s = /* @__PURE__ */ new Map();
784
- for (let e of t) {
785
- let t = o ? String(o.get(e)) : "";
786
- s.has(t) || s.set(t, []), s.get(t).push(e);
780
+ i
781
+ ] : [r, i],
782
+ layout(e) {
783
+ let { x: n, y: r, z: i } = t.scales, a = t.spec.channels, o = a.color?.field ? a.color : a.detail ?? (a.z?.field ? a.z : null), s = /* @__PURE__ */ new Map();
784
+ for (let t of e) {
785
+ let e = o ? String(o.get(t)) : "";
786
+ s.has(e) || s.set(e, []), s.get(e).push(t);
787
787
  }
788
788
  let c = [...s.values()].map((e) => e.sort((e, t) => n(a.x.get(e)) - n(a.x.get(t)))), l = /* @__PURE__ */ new Map(), u = c.flat(), d = new Float32Array(u.length * 4), f = 0;
789
- for (let t of c) for (let o of t) {
790
- let t = a.x.get(o), s = Number(a.y.get(o)) || 0, c = B(a, o, s), u = e.spec.options.stack ? l.get(c) ?? 0 : 0;
791
- e.spec.options.stack && l.set(c, u + s), d.set([
792
- n(t),
789
+ for (let e of c) for (let o of e) {
790
+ let e = a.x.get(o), s = Number(a.y.get(o)) || 0, c = B(a, o, s), u = t.spec.options.stack ? l.get(c) ?? 0 : 0;
791
+ t.spec.options.stack && l.set(c, u + s), d.set([
792
+ n(e),
793
793
  r(u + s),
794
794
  H(i, a.z, o),
795
795
  r(u)
@@ -802,23 +802,23 @@ function ce(e, n) {
802
802
  stride: 4,
803
803
  shape: {
804
804
  lengths: c.map((e) => e.length),
805
- colors: c.map((t) => e.rgb(t[0]))
805
+ colors: c.map((e) => t.rgb(e[0]))
806
806
  }
807
807
  };
808
808
  },
809
809
  apply(e, t) {
810
- let { lengths: n, colors: i } = t.shape, a = [], c = [], l = [], u = [], d = [], f = [], p = [], m = 0;
810
+ let { lengths: n, colors: o } = t.shape, s = [], c = [], l = [], u = [], d = [], f = [], p = [], m = 0;
811
811
  n.forEach((t, n) => {
812
- let r = i[n];
812
+ let r = o[n];
813
813
  for (let n = 0; n < t; n++, m++) {
814
814
  let [t, i, o, h] = e.subarray(m * 4, m * 4 + 4);
815
- if (l.push(t, i, o), u.push(...r), n > 0 && (a.push(...e.subarray((m - 1) * 4, (m - 1) * 4 + 3), t, i, o), c.push(...r, ...r)), s) {
815
+ if (l.push(t, i, o), u.push(...r), n > 0 && (s.push(...e.subarray((m - 1) * 4, (m - 1) * 4 + 3), t, i, o), c.push(...r, ...r)), a) {
816
816
  let e = f.length / 3;
817
817
  d.push(t, i, o, t, h, o), f.push(...r, ...r), n > 0 && p.push(e - 2, e - 1, e, e - 1, e + 1, e);
818
818
  }
819
819
  }
820
- }), r.geometry = K(r.geometry, a.length ? {
821
- positions: a,
820
+ }), r.geometry = K(r.geometry, s.length ? {
821
+ positions: s,
822
822
  colors: c
823
823
  } : { positions: [
824
824
  0,
@@ -827,7 +827,7 @@ function ce(e, n) {
827
827
  0,
828
828
  0,
829
829
  0
830
- ] }), o.geometry = K(o.geometry, {
830
+ ] }), i.geometry = K(i.geometry, {
831
831
  positions: l.length ? l : [
832
832
  0,
833
833
  0,
@@ -838,7 +838,7 @@ function ce(e, n) {
838
838
  0,
839
839
  0
840
840
  ]
841
- }), o.geometry.drawCount = l.length / 3, o.material.size = Math.max(...n, 0) > 40 ? 4 : 7, o.data = t.rows, s && (s.geometry = K(s.geometry, p.length ? {
841
+ }), i.geometry.drawCount = l.length / 3, i.material.size = Math.max(...n, 0) > 40 ? 4 : 7, i.data = t.rows, a && (a.geometry = K(a.geometry, p.length ? {
842
842
  positions: d,
843
843
  colors: f,
844
844
  indices: p
@@ -857,11 +857,11 @@ function ce(e, n) {
857
857
  };
858
858
  }
859
859
  function K(e, t) {
860
- return e.dispose(), new i(t);
860
+ return e.dispose(), new l(t);
861
861
  }
862
- function le(n) {
863
- let r = new t({
864
- geometry: new i({ positions: [
862
+ function le(e) {
863
+ let n = new u({
864
+ geometry: new l({ positions: [
865
865
  0,
866
866
  0,
867
867
  0,
@@ -879,21 +879,21 @@ function le(n) {
879
879
  }
880
880
  });
881
881
  return {
882
- nodes: [r],
883
- layout(t) {
884
- let { x: r, y: i, z: a } = n.scales, o = n.spec.channels, s = z(t.map((e) => o.x.get(e))), c = z(t.map((e) => o.z.get(e))), l = new Map(t.map((e) => [`${+o.x.get(e)}|${+o.z.get(e)}|${o.x.get(e)}|${o.z.get(e)}`, e])), u = (e, t) => l.get(`${+e}|${+t}|${e}|${t}`), d = s.length * c.length - l.size;
882
+ nodes: [n],
883
+ layout(n) {
884
+ let { x: r, y: i, z: a } = e.scales, o = e.spec.channels, s = z(n.map((e) => o.x.get(e))), c = z(n.map((e) => o.z.get(e))), l = new Map(n.map((e) => [`${+o.x.get(e)}|${+o.z.get(e)}|${o.x.get(e)}|${o.z.get(e)}`, e])), u = (e, t) => l.get(`${+e}|${+t}|${e}|${t}`), d = s.length * c.length - l.size;
885
885
  if (d > 0) {
886
- let t = s.flatMap((e) => c.map((t) => [e, t])).find(([e, t]) => !u(e, t));
887
- e("chart()", `a surface needs a value for every x and z pair - ${d} of ${s.length * c.length} are missing (first: x ${t[0]}, z ${t[1]})`);
886
+ let e = s.flatMap((e) => c.map((t) => [e, t])).find(([e, t]) => !u(e, t));
887
+ t("chart()", `a surface needs a value for every x and z pair - ${d} of ${s.length * c.length} are missing (first: x ${e[0]}, z ${e[1]})`);
888
888
  }
889
889
  let f = [], p = new Float32Array(s.length * c.length * 6), m = 0;
890
- for (let e of c) for (let t of s) {
891
- let s = u(t, e);
890
+ for (let t of c) for (let n of s) {
891
+ let s = u(n, t);
892
892
  f.push(s), p.set([
893
- r(t),
893
+ r(n),
894
894
  i(Number(o.y.get(s)) || 0),
895
- a(e),
896
- ...n.rgb(s)
895
+ a(t),
896
+ ...e.rgb(s)
897
897
  ], m++ * 6);
898
898
  }
899
899
  return {
@@ -908,17 +908,17 @@ function le(n) {
908
908
  };
909
909
  },
910
910
  apply(e, t) {
911
- let { nx: n, nz: i } = t.shape, a = [], o = [], s = [];
912
- for (let t = 0; t < n * i; t++) a.push(...e.subarray(t * 6, t * 6 + 3)), o.push(...e.subarray(t * 6 + 3, t * 6 + 6));
913
- for (let e = 0; e < i - 1; e++) for (let t = 0; t < n - 1; t++) {
914
- let r = e * n + t, i = r + 1, a = r + n, o = a + 1;
915
- s.push(r, a, i, i, a, o);
911
+ let { nx: r, nz: i } = t.shape, a = [], o = [], s = [];
912
+ for (let t = 0; t < r * i; t++) a.push(...e.subarray(t * 6, t * 6 + 3)), o.push(...e.subarray(t * 6 + 3, t * 6 + 6));
913
+ for (let e = 0; e < i - 1; e++) for (let t = 0; t < r - 1; t++) {
914
+ let n = e * r + t, i = n + 1, a = n + r, o = a + 1;
915
+ s.push(n, a, i, i, a, o);
916
916
  }
917
- r.geometry = K(r.geometry, {
917
+ n.geometry = K(n.geometry, {
918
918
  positions: a,
919
919
  colors: o,
920
920
  indices: s
921
- }), r.data = t.rows;
921
+ }), n.data = t.rows;
922
922
  }
923
923
  };
924
924
  }
@@ -935,19 +935,19 @@ var de = [
935
935
  2.5,
936
936
  4.5
937
937
  ];
938
- function fe(t) {
939
- let n = t.spec.options, o = me(t), s = t.spec.link, u = n.source ?? "source", d = n.target ?? "target", f = /* @__PURE__ */ new Map(), m = (e) => new l({
938
+ function fe(n) {
939
+ let i = n.spec.options, a = me(n), o = n.spec.link, u = i.source ?? "source", d = i.target ?? "target", f = /* @__PURE__ */ new Map(), m = (e) => new s({
940
940
  geometry: p({
941
941
  radius: 1,
942
942
  detail: 2
943
943
  }),
944
944
  material: { roughness: .35 },
945
945
  count: e,
946
- labels: V(t, "above")
947
- }), h = m(Math.max(8, t.spec.rows.length * 2));
946
+ labels: V(n, "above")
947
+ }), h = m(Math.max(8, n.spec.rows.length * 2));
948
948
  h.count = 0;
949
- let _ = de.map((e) => new a({
950
- geometry: new i({ positions: [
949
+ let g = de.map((t) => new e({
950
+ geometry: new l({ positions: [
951
951
  0,
952
952
  0,
953
953
  0,
@@ -956,45 +956,45 @@ function fe(t) {
956
956
  0
957
957
  ] }),
958
958
  material: {
959
- width: e,
959
+ width: t,
960
960
  vertexColors: !0
961
961
  },
962
962
  data: []
963
- })), v = new a({
964
- geometry: new i({ positions: [] }),
963
+ })), v = new e({
964
+ geometry: new l({ positions: [] }),
965
965
  material: {
966
966
  width: 4,
967
967
  color: "#7fd3ff"
968
968
  },
969
969
  pickable: !1,
970
970
  visible: !1
971
- }), y = s.flow ? new g({
972
- geometry: new i({ positions: [] }),
971
+ }), y = o.flow ? new _({
972
+ geometry: new l({ positions: [] }),
973
973
  material: {
974
- size: .012 * Math.min(...t.box),
974
+ size: .012 * Math.min(...n.box),
975
975
  color: "#bff0ff"
976
976
  },
977
977
  pickable: !1
978
978
  }) : null, b = [], x = [], S = [], C = [], w = null, T = {
979
979
  nodes: [
980
- ..._,
980
+ ...g,
981
981
  v,
982
982
  h,
983
983
  ...y ? [y] : []
984
984
  ],
985
- layout(n) {
986
- let i = n.map(o), a = new Map(i.map((e, t) => [e, t]));
987
- S = t.spec.links.filter((n, i) => {
988
- let s = n[u], c = n[d];
989
- return (s === void 0 || c === void 0) && e("chart()", `link ${i} has no '${s === void 0 ? u : d}' - links name their ends with source: '${u}', target: '${d}' (set 'source' and 'target' to your field names)`), t.spec.rows.some((e) => o(e) === s) || e("chart()", `link ${i}: ${u} ${r(s)} names no node`), t.spec.rows.some((e) => o(e) === c) || e("chart()", `link ${i}: ${d} ${r(c)} names no node`), a.has(s) && a.has(c);
985
+ layout(e) {
986
+ let i = e.map(a), o = new Map(i.map((e, t) => [e, t]));
987
+ S = n.spec.links.filter((e, i) => {
988
+ let s = e[u], c = e[d];
989
+ return (s === void 0 || c === void 0) && t("chart()", `link ${i} has no '${s === void 0 ? u : d}' - links name their ends with source: '${u}', target: '${d}' (set 'source' and 'target' to your field names)`), n.spec.rows.some((e) => a(e) === s) || t("chart()", `link ${i}: ${u} ${r(s)} names no node`), n.spec.rows.some((e) => a(e) === c) || t("chart()", `link ${i}: ${d} ${r(c)} names no node`), o.has(s) && o.has(c);
990
990
  });
991
- let s = N(n, i, S.map((e) => [a.get(e[u]), a.get(e[d])])), c = new Float32Array(n.length * 7);
992
- return n.forEach((e, n) => c.set([
993
- ...s[n],
994
- t.size ? t.size(t.spec.channels.size.get(e)) : .06 * Math.min(...t.box),
995
- ...t.rgb(e)
996
- ], n * 7)), {
997
- rows: n,
991
+ let s = N(e, i, S.map((e) => [o.get(e[u]), o.get(e[d])])), c = new Float32Array(e.length * 7);
992
+ return e.forEach((e, t) => c.set([
993
+ ...s[t],
994
+ n.size ? n.size(n.spec.channels.size.get(e)) : .06 * Math.min(...n.box),
995
+ ...n.rgb(e)
996
+ ], t * 7)), {
997
+ rows: e,
998
998
  keys: i,
999
999
  state: c,
1000
1000
  stride: 7,
@@ -1003,12 +1003,12 @@ function fe(t) {
1003
1003
  },
1004
1004
  apply(e, t) {
1005
1005
  let n = e.length / t.stride;
1006
- if (C = t.rows, w !== null && !C.some((e) => o(e) === w) && (w = null, v.visible = !1), n > h.instanceMatrices.length / 16) {
1006
+ if (C = t.rows, w !== null && !C.some((e) => a(e) === w) && (w = null, v.visible = !1), n > h.instanceMatrices.length / 16) {
1007
1007
  let e = m(n * 2);
1008
1008
  E && e.on("hover", D), h.parent?.add(e), h.parent?.remove(h), h.dispose(), T.nodes[T.nodes.indexOf(h)] = e, h = e;
1009
1009
  }
1010
1010
  h.count = n, h.data = t.rows;
1011
- let r = t.rows.map(o), a = new Map(r.map((e, t) => [e, t]));
1011
+ let r = t.rows.map(a), i = new Map(r.map((e, t) => [e, t]));
1012
1012
  x = [];
1013
1013
  for (let t = 0; t < n; t++) {
1014
1014
  let [n, r, i, a, o, s, c] = e.subarray(t * 7, t * 7 + 7);
@@ -1030,24 +1030,24 @@ function fe(t) {
1030
1030
  ])
1031
1031
  });
1032
1032
  }
1033
- let c = de.map(() => ({
1033
+ let s = de.map(() => ({
1034
1034
  positions: [],
1035
1035
  colors: [],
1036
1036
  rows: []
1037
1037
  }));
1038
1038
  b = [], S.forEach((e, t) => {
1039
- let n = a.get(e[u]), r = a.get(e[d]);
1039
+ let n = i.get(e[u]), r = i.get(e[d]);
1040
1040
  if (n === void 0 || r === void 0) return;
1041
- let i = c[A(e)], o = j(e);
1042
- i.positions.push(...x[n], ...x[r]), i.colors.push(...o, ...o), i.rows.push(e), s.flow && b.push({
1041
+ let a = s[A(e)], c = j(e);
1042
+ a.positions.push(...x[n], ...x[r]), a.colors.push(...c, ...c), a.rows.push(e), o.flow && b.push({
1043
1043
  a: n,
1044
1044
  b: r,
1045
1045
  speed: M(e),
1046
1046
  phase: t * .618 % 1
1047
1047
  });
1048
- }), _.forEach((e, t) => {
1049
- let n = c[t];
1050
- e.geometry.dispose(), e.geometry = new i(n.positions.length ? {
1048
+ }), g.forEach((e, t) => {
1049
+ let n = s[t];
1050
+ e.geometry.dispose(), e.geometry = new l(n.positions.length ? {
1051
1051
  positions: n.positions,
1052
1052
  colors: n.colors
1053
1053
  } : { positions: [
@@ -1070,67 +1070,67 @@ function fe(t) {
1070
1070
  n.phase = (n.phase + e * n.speed) % 1;
1071
1071
  let i = x[n.a], a = x[n.b];
1072
1072
  for (let e = 0; e < 3; e++) t[r * 3 + e] = i[e] + (a[e] - i[e]) * n.phase;
1073
- }), y.geometry.vertexCount === b.length ? (y.geometry.positions.set(t), y.geometry.needsUpdate()) : (y.geometry.dispose(), y.geometry = new i({ positions: t }));
1073
+ }), y.geometry.vertexCount === b.length ? (y.geometry.positions.set(t), y.geometry.needsUpdate()) : (y.geometry.dispose(), y.geometry = new l({ positions: t }));
1074
1074
  },
1075
1075
  tooltipRows(e) {
1076
- return _.includes(e.node) ? "link" : "node";
1076
+ return g.includes(e.node) ? "link" : "node";
1077
1077
  }
1078
- }, E = (n.highlight ?? "neighbours") === "neighbours";
1078
+ }, E = (i.highlight ?? "neighbours") === "neighbours";
1079
1079
  E && h.on("hover", D);
1080
1080
  function D(e) {
1081
- let n = e && e.node === h && e.instance !== null ? o(C[e.instance]) : null;
1082
- if (n !== w) {
1083
- w = n, v.visible = n !== null, n !== null && O(n);
1084
- for (let e = 0; e < h.count; e++) h.setColor(e, k(e, t.rgb(C[e])));
1081
+ let t = e && e.node === h && e.instance !== null ? a(C[e.instance]) : null;
1082
+ if (t !== w) {
1083
+ w = t, v.visible = t !== null, t !== null && O(t);
1084
+ for (let e = 0; e < h.count; e++) h.setColor(e, k(e, n.rgb(C[e])));
1085
1085
  }
1086
1086
  }
1087
1087
  function O(e) {
1088
1088
  let t = [];
1089
1089
  for (let n of S) {
1090
1090
  if (n[u] !== e && n[d] !== e) continue;
1091
- let r = C.findIndex((e) => o(e) === n[u]), i = C.findIndex((e) => o(e) === n[d]);
1091
+ let r = C.findIndex((e) => a(e) === n[u]), i = C.findIndex((e) => a(e) === n[d]);
1092
1092
  r >= 0 && i >= 0 && t.push(...x[r], ...x[i]);
1093
1093
  }
1094
- v.geometry.dispose(), v.geometry = new i({ positions: t });
1094
+ v.geometry.dispose(), v.geometry = new l({ positions: t });
1095
1095
  }
1096
- function k(e, n) {
1097
- if (w === null || !E) return n;
1098
- let r = o(C[e]);
1099
- return r === w || S.some((e) => e[u] === w && e[d] === r || e[d] === w && e[u] === r) ? n : new c().setSRGB(n[0], n[1], n[2]).lerp(t.theme === "light" ? "#ffffff" : "#202024", .65).toSRGB();
1096
+ function k(e, t) {
1097
+ if (w === null || !E) return t;
1098
+ let r = a(C[e]);
1099
+ return r === w || S.some((e) => e[u] === w && e[d] === r || e[d] === w && e[u] === r) ? t : new c().setSRGB(t[0], t[1], t[2]).lerp(n.theme === "light" ? "#ffffff" : "#202024", .65).toSRGB();
1100
1100
  }
1101
1101
  function A(e) {
1102
- let n = s.width;
1103
- if (!n) return 0;
1104
- if (n.field === null) return n.value >= 3.5 ? 2 : +(n.value >= 2);
1105
- let r = t.spec.links.map((e) => Number(n.get(e)) || 0), i = Math.max(...r) || 1;
1106
- return Math.min(2, Math.floor((Number(n.get(e)) || 0) / i * 2.999));
1102
+ let t = o.width;
1103
+ if (!t) return 0;
1104
+ if (t.field === null) return t.value >= 3.5 ? 2 : +(t.value >= 2);
1105
+ let r = n.spec.links.map((e) => Number(t.get(e)) || 0), i = Math.max(...r) || 1;
1106
+ return Math.min(2, Math.floor((Number(t.get(e)) || 0) / i * 2.999));
1107
1107
  }
1108
1108
  function j(e) {
1109
- let n = s.color, r = t.theme === "light" ? "#9aa3b2" : "#4a5266";
1110
- return n ? n.field === null ? c.fromInput(n.value).toSRGB() : t.linkColor(n.get(e)).toSRGB() : c.fromInput(r).toSRGB();
1109
+ let t = o.color, r = n.theme === "light" ? "#9aa3b2" : "#4a5266";
1110
+ return t ? t.field === null ? c.fromInput(t.value).toSRGB() : n.linkColor(t.get(e)).toSRGB() : c.fromInput(r).toSRGB();
1111
1111
  }
1112
1112
  function M(e) {
1113
- let n = s.flow;
1114
- if (n.field === null) return .4;
1115
- let r = Math.max(...t.spec.links.map((e) => Number(n.get(e)) || 0)) || 1;
1116
- return .15 + .6 * (Number(n.get(e)) || 0) / r;
1113
+ let t = o.flow;
1114
+ if (t.field === null) return .4;
1115
+ let r = Math.max(...n.spec.links.map((e) => Number(t.get(e)) || 0)) || 1;
1116
+ return .15 + .6 * (Number(t.get(e)) || 0) / r;
1117
1117
  }
1118
- function N(i, a, o) {
1119
- let [s, c, l] = t.box, u = n.layout ?? "force";
1118
+ function N(e, a, o) {
1119
+ let [s, c, l] = n.box, u = i.layout ?? "force";
1120
1120
  if (u === "given") {
1121
- let { x: e, y: n, z: r } = t.scales, a = t.spec.channels;
1122
- return i.map((t) => [
1123
- e && a.x ? e(a.x.get(t)) : 0,
1124
- n && a.y ? n(a.y.get(t)) : c / 2,
1125
- r && a.z ? r(a.z.get(t)) : 0
1121
+ let { x: t, y: r, z: i } = n.scales, a = n.spec.channels;
1122
+ return e.map((e) => [
1123
+ t && a.x ? t(a.x.get(e)) : 0,
1124
+ r && a.y ? r(a.y.get(e)) : c / 2,
1125
+ i && a.z ? i(a.z.get(e)) : 0
1126
1126
  ]);
1127
1127
  }
1128
- if (u && typeof u == "object" && "tiers" in u) return pe(i, a, o, u, [
1128
+ if (u && typeof u == "object" && "tiers" in u) return pe(e, a, o, u, [
1129
1129
  s,
1130
1130
  c,
1131
1131
  l
1132
1132
  ]);
1133
- u !== "force" && e("chart()", `layout ${r(u)} - expected 'force', 'given' or { tiers: 'field' }`);
1133
+ u !== "force" && t("chart()", `layout ${r(u)} - expected 'force', 'given' or { tiers: 'field' }`);
1134
1134
  let d = P(a, o), f = [
1135
1135
  Infinity,
1136
1136
  Infinity,
@@ -1141,27 +1141,27 @@ function fe(t) {
1141
1141
  -Infinity
1142
1142
  ];
1143
1143
  for (let e of d) for (let t = 0; t < 3; t++) f[t] = Math.min(f[t], e[t]), p[t] = Math.max(p[t], e[t]);
1144
- let m = Math.max(...p.map((e, t) => e - f[t]), 1e-6), h = Math.min(s, n.flat ? l : Math.min(c, l)) * .9 / m, g = p.map((e, t) => (e + f[t]) / 2);
1144
+ let m = Math.max(...p.map((e, t) => e - f[t]), 1e-6), h = Math.min(s, i.flat ? l : Math.min(c, l)) * .9 / m, g = p.map((e, t) => (e + f[t]) / 2);
1145
1145
  return d.map((e) => [
1146
1146
  (e[0] - g[0]) * h,
1147
- n.flat ? 0 : (e[1] - g[1]) * h + c / 2,
1147
+ i.flat ? 0 : (e[1] - g[1]) * h + c / 2,
1148
1148
  (e[2] - g[2]) * h
1149
1149
  ]);
1150
1150
  }
1151
1151
  function P(e, t) {
1152
- let r = e.length, i = ue(n.seed ?? 1), a = n.flat ? [0, 2] : [
1152
+ let n = e.length, r = ue(i.seed ?? 1), a = i.flat ? [0, 2] : [
1153
1153
  0,
1154
1154
  1,
1155
1155
  2
1156
- ], o = e.some((e) => f.has(e)), s = n.steps ?? (o ? 60 : 300), c = e.map(() => []);
1156
+ ], o = e.some((e) => f.has(e)), s = i.steps ?? (o ? 60 : 300), c = e.map(() => []);
1157
1157
  for (let [e, n] of t) c[e].push(n), c[n].push(e);
1158
- let l = new Float32Array(r * r).fill(Infinity), u = 1;
1159
- for (let e = 0; e < r; e++) {
1158
+ let l = new Float32Array(n * n).fill(Infinity), u = 1;
1159
+ for (let e = 0; e < n; e++) {
1160
1160
  let t = [e];
1161
- l[e * r + e] = 0;
1162
- for (let n = 0; n < t.length; n++) {
1163
- let i = t[n], a = l[e * r + i] + 1;
1164
- for (let n of c[i]) l[e * r + n] === Infinity && (l[e * r + n] = a, u = Math.max(u, a), t.push(n));
1161
+ l[e * n + e] = 0;
1162
+ for (let r = 0; r < t.length; r++) {
1163
+ let i = t[r], a = l[e * n + i] + 1;
1164
+ for (let r of c[i]) l[e * n + r] === Infinity && (l[e * n + r] = a, u = Math.max(u, a), t.push(r));
1165
1165
  }
1166
1166
  }
1167
1167
  let d = e.map((t, a) => {
@@ -1170,24 +1170,24 @@ function fe(t) {
1170
1170
  0,
1171
1171
  0,
1172
1172
  0
1173
- ] : f.get(e[o]), l = o === void 0 ? Math.sqrt(r) : .5;
1173
+ ] : f.get(e[o]), l = o === void 0 ? Math.sqrt(n) : .5;
1174
1174
  return [
1175
- s[0] + (i() - .5) * l,
1176
- n.flat ? 0 : s[1] + (i() - .5) * l,
1177
- s[2] + (i() - .5) * l
1175
+ s[0] + (r() - .5) * l,
1176
+ i.flat ? 0 : s[1] + (r() - .5) * l,
1177
+ s[2] + (r() - .5) * l
1178
1178
  ];
1179
1179
  }), p = [
1180
1180
  0,
1181
1181
  0,
1182
1182
  0
1183
1183
  ];
1184
- for (let e = 0; e < s; e++) for (let e = 0; e < r; e++) {
1184
+ for (let e = 0; e < s; e++) for (let e = 0; e < n; e++) {
1185
1185
  p.fill(0);
1186
1186
  let t = 0;
1187
- for (let n = 0; n < r; n++) {
1188
- if (e === n) continue;
1189
- let i = l[e * r + n], a = i === Infinity ? u + 1 : i, o = 1 / (a * a), s = d[e][0] - d[n][0], c = d[e][1] - d[n][1], f = d[e][2] - d[n][2], m = Math.hypot(s, c, f) || 1e-6;
1190
- p[0] += o * (d[n][0] + a * s / m), p[1] += o * (d[n][1] + a * c / m), p[2] += o * (d[n][2] + a * f / m), t += o;
1187
+ for (let r = 0; r < n; r++) {
1188
+ if (e === r) continue;
1189
+ let i = l[e * n + r], a = i === Infinity ? u + 1 : i, o = 1 / (a * a), s = d[e][0] - d[r][0], c = d[e][1] - d[r][1], f = d[e][2] - d[r][2], m = Math.hypot(s, c, f) || 1e-6;
1190
+ p[0] += o * (d[r][0] + a * s / m), p[1] += o * (d[r][1] + a * c / m), p[2] += o * (d[r][2] + a * f / m), t += o;
1191
1191
  }
1192
1192
  if (t) for (let n of a) d[e][n] = p[n] / t;
1193
1193
  }
@@ -1195,31 +1195,31 @@ function fe(t) {
1195
1195
  }
1196
1196
  return T;
1197
1197
  }
1198
- function pe(t, n, r, i, [a, o, s]) {
1198
+ function pe(e, n, r, i, [a, o, s]) {
1199
1199
  let c = i.tiers;
1200
- if (!t.length) return [];
1201
- c in t[0] || e("chart()", `layout: { tiers: '${c}' } - '${c}' isn't a node field`);
1202
- let l = i.order ?? [...new Set(t.map((e) => e[c]))], u = t.map((e) => Math.max(0, l.indexOf(e[c]))), d = Math.max(...u) + 1, f = Array(t.length).fill(0), p = Array(t.length), m = Math.min(a, s) / 2 * .92;
1203
- for (let e = 0; e < d; e++) {
1204
- let n = t.map((e, t) => t).filter((t) => u[t] === e), i = (t) => {
1205
- let i = r.filter(([e, n]) => e === t || n === t).map(([e, n]) => e === t ? n : e).filter((t) => u[t] < e);
1206
- return i.length ? i.reduce((e, t) => e + f[t], 0) / i.length : n.indexOf(t);
1200
+ if (!e.length) return [];
1201
+ c in e[0] || t("chart()", `layout: { tiers: '${c}' } - '${c}' isn't a node field`);
1202
+ let l = i.order ?? [...new Set(e.map((e) => e[c]))], u = e.map((e) => Math.max(0, l.indexOf(e[c]))), d = Math.max(...u) + 1, f = Array(e.length).fill(0), p = Array(e.length), m = Math.min(a, s) / 2 * .92;
1203
+ for (let t = 0; t < d; t++) {
1204
+ let n = e.map((e, t) => t).filter((e) => u[e] === t), i = (e) => {
1205
+ let i = r.filter(([t, n]) => t === e || n === e).map(([t, n]) => t === e ? n : t).filter((e) => u[e] < t);
1206
+ return i.length ? i.reduce((e, t) => e + f[t], 0) / i.length : n.indexOf(e);
1207
1207
  };
1208
- e > 0 && n.sort((e, t) => i(e) - i(t));
1209
- let a = n.length === 1 ? 0 : e === 0 ? m * .25 : m * (.35 + .65 * e / Math.max(1, d - 1));
1210
- n.forEach((t, r) => {
1211
- f[t] = (r + .5) / n.length * Math.PI * 2, p[t] = [
1212
- Math.cos(f[t]) * a,
1213
- o * (1 - e / Math.max(1, d - 1)),
1214
- Math.sin(f[t]) * a
1208
+ t > 0 && n.sort((e, t) => i(e) - i(t));
1209
+ let a = n.length === 1 ? 0 : t === 0 ? m * .25 : m * (.35 + .65 * t / Math.max(1, d - 1));
1210
+ n.forEach((e, r) => {
1211
+ f[e] = (r + .5) / n.length * Math.PI * 2, p[e] = [
1212
+ Math.cos(f[e]) * a,
1213
+ o * (1 - t / Math.max(1, d - 1)),
1214
+ Math.sin(f[e]) * a
1215
1215
  ];
1216
1216
  });
1217
1217
  }
1218
1218
  return p;
1219
1219
  }
1220
- function me(t) {
1221
- let n = t.spec.channels.key;
1222
- return n ? (e) => n.get(e) : (t.spec.rows.length && !("id" in t.spec.rows[0]) && e("chart()", "network nodes need an 'id' field, or key: 'yourIdField' - links name nodes by it"), (e) => e.id);
1220
+ function me(e) {
1221
+ let n = e.spec.channels.key;
1222
+ return n ? (e) => n.get(e) : (e.spec.rows.length && !("id" in e.spec.rows[0]) && t("chart()", "network nodes need an 'id' field, or key: 'yourIdField' - links name nodes by it"), (e) => e.id);
1223
1223
  }
1224
1224
  // src/charts/spec.js
1225
1225
  var q = [
@@ -1316,52 +1316,52 @@ var q = [
1316
1316
  sort: "sort with scale: { domain: [...] } in the order you want",
1317
1317
  stack: "stacking is the chart's option: stack: true"
1318
1318
  };
1319
- function ye(t) {
1320
- (!t || typeof t != "object" || Array.isArray(t)) && e("chart()", `expected a spec such as { mark: 'bar', data, x, y }, got ${r(t)}`);
1321
- for (let n of Object.keys(t)) Y.includes(n) || e("chart()", `unknown option '${n}' - ${ge[n] ?? `expected ${Y.filter((e) => e[0] !== "$").join(", ")}${d(n, Y)}`}`);
1322
- typeof t.width == "number" && t.width > 1 && e("chart()", "'width' is a bar's share of its band (0-1); in Vega-Lite it is pixels - here the canvas sets the size");
1323
- let n = be(t.mark), { rows: i, links: a } = xe(t.data, n), s = Se(i), c = { ...t.encoding ?? {} };
1324
- for (let t of Object.keys(c)) !J.includes(t) && t !== "tooltip" && e("chart()", `encoding '${t}' isn't a channel we have - channels are ${J.join(", ")}, tooltip`);
1319
+ function ye(e) {
1320
+ (!e || typeof e != "object" || Array.isArray(e)) && t("chart()", `expected a spec such as { mark: 'bar', data, x, y }, got ${r(e)}`);
1321
+ for (let n of Object.keys(e)) Y.includes(n) || t("chart()", `unknown option '${n}' - ${ge[n] ?? `expected ${Y.filter((e) => e[0] !== "$").join(", ")}${d(n, Y)}`}`);
1322
+ typeof e.width == "number" && e.width > 1 && t("chart()", "'width' is a bar's share of its band (0-1); in Vega-Lite it is pixels - here the canvas sets the size");
1323
+ let n = be(e.mark), { rows: i, links: o } = xe(e.data, n), s = Se(i), c = { ...e.encoding ?? {} };
1324
+ for (let e of Object.keys(c)) !J.includes(e) && e !== "tooltip" && t("chart()", `encoding '${e}' isn't a channel we have - channels are ${J.join(", ")}, tooltip`);
1325
1325
  let l = {};
1326
- for (let e of J) {
1327
- let n = t[e] ?? c[e];
1328
- n != null && (l[e] = X(e, n, i, s));
1326
+ for (let t of J) {
1327
+ let n = e[t] ?? c[t];
1328
+ n != null && (l[t] = X(t, n, i, s));
1329
1329
  }
1330
1330
  if (n === "network") for (let n of [
1331
1331
  "x",
1332
1332
  "y",
1333
1333
  "z"
1334
- ]) l[n] && t.layout !== "given" && e("chart()", `${n} on a 'network' places its nodes - add layout: 'given' to use positions from the data`);
1335
- else for (let t of n === "surface" ? [
1334
+ ]) l[n] && e.layout !== "given" && t("chart()", `${n} on a 'network' places its nodes - add layout: 'given' to use positions from the data`);
1335
+ else for (let e of n === "surface" ? [
1336
1336
  "x",
1337
1337
  "z",
1338
1338
  "y"
1339
- ] : ["x", "y"]) l[t] || e("chart()", `a '${n}' chart needs ${t} - e.g. ${t}: '${s[0] ?? "field"}'`), n !== "point" && l[t].field === null && e("chart()", `${t} on a '${n}' chart lays its marks out along a scale - it needs a field, not a constant value - e.g. ${t}: '${s[0] ?? "field"}'`);
1340
- let u = t.tooltip ?? c.tooltip, f = typeof t.mark == "object" ? t.mark.tooltip : void 0, p = Ee(u ?? (f !== !1 && void 0), l, i, s), m = {};
1341
- if (t.link !== void 0) {
1342
- n !== "network" && e("chart()", "'link' sets a network's link channels - it needs mark: 'network'");
1343
- let r = Se(a);
1344
- for (let [n, i] of Object.entries(t.link)) [
1339
+ ] : ["x", "y"]) l[e] || t("chart()", `a '${n}' chart needs ${e} - e.g. ${e}: '${s[0] ?? "field"}'`), n !== "point" && l[e].field === null && t("chart()", `${e} on a '${n}' chart lays its marks out along a scale - it needs a field, not a constant value - e.g. ${e}: '${s[0] ?? "field"}'`);
1340
+ let u = e.tooltip ?? c.tooltip, f = typeof e.mark == "object" ? e.mark.tooltip : void 0, p = Ee(u ?? (f !== !1 && void 0), l, i, s), m = {};
1341
+ if (e.link !== void 0) {
1342
+ n !== "network" && t("chart()", "'link' sets a network's link channels - it needs mark: 'network'");
1343
+ let r = Se(o);
1344
+ for (let [n, i] of Object.entries(e.link)) [
1345
1345
  "width",
1346
1346
  "color",
1347
1347
  "opacity",
1348
1348
  "flow",
1349
1349
  "tooltip"
1350
- ].includes(n) || e("chart()", `link has no '${n}' - link channels are width, color, opacity, flow, tooltip`), n !== "tooltip" && (m[n] = X(`link.${n}`, i, a, r));
1351
- t.link.tooltip !== void 0 && (m.tooltip = Ee(t.link.tooltip, {}, a, r));
1350
+ ].includes(n) || t("chart()", `link has no '${n}' - link channels are width, color, opacity, flow, tooltip`), n !== "tooltip" && (m[n] = X(`link.${n}`, i, o, r));
1351
+ e.link.tooltip !== void 0 && (m.tooltip = Ee(e.link.tooltip, {}, o, r));
1352
1352
  }
1353
1353
  let h = {};
1354
- for (let e of Y) !J.includes(e) && ![
1354
+ for (let t of Y) !J.includes(t) && ![
1355
1355
  "mark",
1356
1356
  "data",
1357
1357
  "encoding",
1358
1358
  "tooltip",
1359
1359
  "link"
1360
- ].includes(e) && t[e] !== void 0 && (h[e] = t[e]);
1361
- return h.steps !== void 0 && (!Number.isInteger(h.steps) || h.steps < 1) && e("chart()", `'steps' is how many steps the force layout takes, a whole number of 1 or more, got ${r(h.steps)}`), h.seed !== void 0 && o("chart()", "seed", h.seed), h.legend?.ticks !== void 0 && we("legend", h.legend.ticks), h.box === void 0 || Array.isArray(h.box) && h.box.length === 3 && h.box.every((e) => e > 0) || e("chart()", `'box' is the chart's size in the scene, [x, y, z] above 0, got ${r(h.box)}`), {
1360
+ ].includes(t) && e[t] !== void 0 && (h[t] = e[t]);
1361
+ return h.steps !== void 0 && (!Number.isInteger(h.steps) || h.steps < 1) && t("chart()", `'steps' is how many steps the force layout takes, a whole number of 1 or more, got ${r(h.steps)}`), h.seed !== void 0 && a("chart()", "seed", h.seed), h.legend?.ticks !== void 0 && we("legend", h.legend.ticks), h.box === void 0 || Array.isArray(h.box) && h.box.length === 3 && h.box.every((e) => e > 0) || t("chart()", `'box' is the chart's size in the scene, [x, y, z] above 0, got ${r(h.box)}`), {
1362
1362
  mark: n,
1363
1363
  rows: i,
1364
- links: a,
1364
+ links: o,
1365
1365
  fields: s,
1366
1366
  channels: l,
1367
1367
  tooltip: p,
@@ -1369,25 +1369,25 @@ function ye(t) {
1369
1369
  options: h
1370
1370
  };
1371
1371
  }
1372
- function be(t) {
1373
- let n = t;
1372
+ function be(e) {
1373
+ let n = e;
1374
1374
  if (n && typeof n == "object") {
1375
- for (let t of Object.keys(n)) t !== "type" && t !== "tooltip" && e("chart()", `mark option '${t}' isn't supported - use the chart's options (width, stack, ...) or style the chart's nodes`);
1375
+ for (let e of Object.keys(n)) e !== "type" && e !== "tooltip" && t("chart()", `mark option '${e}' isn't supported - use the chart's options (width, stack, ...) or style the chart's nodes`);
1376
1376
  n = n.type;
1377
1377
  }
1378
- if (typeof n != "string" && e("chart()", `'mark' is required: one of ${q.map((e) => `'${e}'`).join(", ")}`), !q.includes(n)) {
1379
- let t = _e[n];
1380
- (n === "pie" || n === "arc" || n === "donut") && e("chart()", "pie and donut charts aren't supported - in 3D they distort values; use mark: 'bar'"), e("chart()", `mark '${n}' - ${t ? `use '${t}'` : `expected one of ${q.map((e) => `'${e}'`).join(", ")}${d(n, q)}`}`);
1378
+ if (typeof n != "string" && t("chart()", `'mark' is required: one of ${q.map((e) => `'${e}'`).join(", ")}`), !q.includes(n)) {
1379
+ let e = _e[n];
1380
+ (n === "pie" || n === "arc" || n === "donut") && t("chart()", "pie and donut charts aren't supported - in 3D they distort values; use mark: 'bar'"), t("chart()", `mark '${n}' - ${e ? `use '${e}'` : `expected one of ${q.map((e) => `'${e}'`).join(", ")}${d(n, q)}`}`);
1381
1381
  }
1382
1382
  return n;
1383
1383
  }
1384
- function xe(t, n) {
1385
- if (t && typeof t == "object" && !Array.isArray(t) && "url" in t && e("chart()", "data: { url } isn't loaded for you - fetch the rows and pass data: rows"), n === "network") return t && Array.isArray(t.nodes) && Array.isArray(t.links) || e("chart()", `a network's data is { nodes: [...], links: [...] }, got ${r(t)}`), {
1386
- rows: t.nodes,
1387
- links: t.links
1384
+ function xe(e, n) {
1385
+ if (e && typeof e == "object" && !Array.isArray(e) && "url" in e && t("chart()", "data: { url } isn't loaded for you - fetch the rows and pass data: rows"), n === "network") return e && Array.isArray(e.nodes) && Array.isArray(e.links) || t("chart()", `a network's data is { nodes: [...], links: [...] }, got ${r(e)}`), {
1386
+ rows: e.nodes,
1387
+ links: e.links
1388
1388
  };
1389
- let i = Array.isArray(t) ? t : t && Array.isArray(t.values) ? t.values : null;
1390
- return i || e("chart()", `'data' must be an array of rows (objects), or { values: [...] }, got ${r(t)}`), i.some((e) => !e || typeof e != "object") && e("chart()", "every row in 'data' must be an object, such as { month: 'Jan', sales: 41 }"), {
1389
+ let i = Array.isArray(e) ? e : e && Array.isArray(e.values) ? e.values : null;
1390
+ return i || t("chart()", `'data' must be an array of rows (objects), or { values: [...] }, got ${r(e)}`), i.some((e) => !e || typeof e != "object") && t("chart()", "every row in 'data' must be an object, such as { month: 'Jan', sales: 41 }"), {
1391
1391
  rows: i,
1392
1392
  links: []
1393
1393
  };
@@ -1401,29 +1401,29 @@ function Ce(e, t) {
1401
1401
  let n = e.find((e) => e[t] !== null && e[t] !== void 0)?.[t];
1402
1402
  return typeof n == "number" ? "quantitative" : n instanceof Date || typeof n == "string" && /^\d{4}-\d{2}(-\d{2})?([T ][\d:.]+Z?)?$/.test(n) ? "temporal" : "nominal";
1403
1403
  }
1404
- function X(t, n, i, a) {
1404
+ function X(e, n, i, a) {
1405
1405
  let o = "chart()", s;
1406
- if (typeof n == "string") a.includes(n) ? s = { field: n } : /color|colour/.test(t) && Te(n) ? s = { value: n } : e(o, `${t}: field '${n}' isn't in the data - fields are ${a.join(", ") || "(none)"}${d(n, a)}`);
1406
+ if (typeof n == "string") a.includes(n) ? s = { field: n } : /color|colour/.test(e) && Te(n) ? s = { value: n } : t(o, `${e}: field '${n}' isn't in the data - fields are ${a.join(", ") || "(none)"}${d(n, a)}`);
1407
1407
  else if (typeof n == "number" && [
1408
1408
  "size",
1409
1409
  "opacity",
1410
1410
  "link.width",
1411
1411
  "link.opacity",
1412
1412
  "link.flow"
1413
- ].includes(t)) s = { value: n };
1413
+ ].includes(e)) s = { value: n };
1414
1414
  else if (n && typeof n == "object" && !Array.isArray(n)) {
1415
1415
  s = n;
1416
- for (let n of Object.keys(s)) he.includes(n) || e(o, `${t}: '${n}' - ${ve[n] ?? `unknown; a channel takes ${he.join(", ")}`}`);
1417
- s.field !== void 0 && !a.includes(s.field) && e(o, `${t}: field '${s.field}' isn't in the data - fields are ${a.join(", ") || "(none)"}${d(String(s.field), a)}`), s.field === void 0 && s.value === void 0 && e(o, `${t} needs a field (or a constant value)`);
1418
- } else return t === "size" && Array.isArray(n) && e(o, "'size' is a channel - the chart's size in the scene is 'box: [x, y, z]'"), e(o, `${t} must be a field name or { field, ... }, got ${r(n)}`);
1419
- s.axis?.ticks !== void 0 && we(`${t}: axis`, s.axis.ticks);
1416
+ for (let n of Object.keys(s)) he.includes(n) || t(o, `${e}: '${n}' - ${ve[n] ?? `unknown; a channel takes ${he.join(", ")}`}`);
1417
+ s.field !== void 0 && !a.includes(s.field) && t(o, `${e}: field '${s.field}' isn't in the data - fields are ${a.join(", ") || "(none)"}${d(String(s.field), a)}`), s.field === void 0 && s.value === void 0 && t(o, `${e} needs a field (or a constant value)`);
1418
+ } else return e === "size" && Array.isArray(n) && t(o, "'size' is a channel - the chart's size in the scene is 'box: [x, y, z]'"), t(o, `${e} must be a field name or { field, ... }, got ${r(n)}`);
1419
+ s.axis?.ticks !== void 0 && we(`${e}: axis`, s.axis.ticks);
1420
1420
  let c = s.field ?? null, l = s.type ?? (c ? Ce(i, c) : "nominal");
1421
1421
  [
1422
1422
  "quantitative",
1423
1423
  "nominal",
1424
1424
  "ordinal",
1425
1425
  "temporal"
1426
- ].includes(l) || e(o, `${t}: type '${l}' - expected 'quantitative', 'nominal', 'ordinal' or 'temporal'${d(String(l), [
1426
+ ].includes(l) || t(o, `${e}: type '${l}' - expected 'quantitative', 'nominal', 'ordinal' or 'temporal'${d(String(l), [
1427
1427
  "quantitative",
1428
1428
  "nominal",
1429
1429
  "ordinal",
@@ -1434,7 +1434,7 @@ function X(t, n, i, a) {
1434
1434
  field: c,
1435
1435
  value: s.value,
1436
1436
  type: l,
1437
- title: s.title ?? c ?? t,
1437
+ title: s.title ?? c ?? e,
1438
1438
  format: s.format,
1439
1439
  scale: s.scale ?? {},
1440
1440
  axis: s.axis ?? {},
@@ -1442,8 +1442,8 @@ function X(t, n, i, a) {
1442
1442
  priority: s.priority
1443
1443
  };
1444
1444
  }
1445
- function we(t, n) {
1446
- Array.isArray(n) || Number.isInteger(n) && n > 0 || e("chart()", `${t} ticks are a list of the values to mark, such as [0, 25, 50, 75, 100], or about how many, got ${r(n)}`);
1445
+ function we(e, n) {
1446
+ Array.isArray(n) || Number.isInteger(n) && n > 0 || t("chart()", `${e} ticks are a list of the values to mark, such as [0, 25, 50, 75, 100], or about how many, got ${r(n)}`);
1447
1447
  }
1448
1448
  function Te(e) {
1449
1449
  try {
@@ -1470,7 +1470,7 @@ function Oe() {
1470
1470
  e.id = "phoria-chart-style", e.textContent = De, document.head.prepend(e);
1471
1471
  }
1472
1472
  // src/charts/Chart.js
1473
- var ke = u.filter((e) => ![
1473
+ var ke = g.filter((e) => ![
1474
1474
  "children",
1475
1475
  "tooltip",
1476
1476
  "highlight"
@@ -1478,10 +1478,10 @@ var ke = u.filter((e) => ![
1478
1478
  function Ae(e) {
1479
1479
  return new Z(e);
1480
1480
  }
1481
- var Z = class t extends h {
1481
+ var Z = class e extends h {
1482
1482
  static type = "chart";
1483
1483
  static get OPTIONS() {
1484
- return u;
1484
+ return g;
1485
1485
  }
1486
1486
  scales = {};
1487
1487
  #e;
@@ -1496,11 +1496,11 @@ var Z = class t extends h {
1496
1496
  #l = null;
1497
1497
  #u = null;
1498
1498
  #d = null;
1499
- constructor(t) {
1500
- (!t || typeof t != "object" || Array.isArray(t)) && e("chart()", `expected a spec such as { mark: 'bar', data, x, y }, got ${r(t)}`);
1499
+ constructor(e) {
1500
+ (!e || typeof e != "object" || Array.isArray(e)) && t("chart()", `expected a spec such as { mark: 'bar', data, x, y }, got ${r(e)}`);
1501
1501
  let n = {}, i = {};
1502
- for (let [e, r] of Object.entries(t)) (ke.includes(e) ? n : i)[e] = r;
1503
- t.children && e("chart()", "a chart makes its own children - add other nodes to a Group beside it"), super(n), Oe(), this.#e = i, this.#i = {}, this.#f(!0), this.onUpdate((e, t) => this.#_(t));
1502
+ for (let [t, r] of Object.entries(e)) (ke.includes(t) ? n : i)[t] = r;
1503
+ e.children && t("chart()", "a chart makes its own children - add other nodes to a Group beside it"), super(n), Oe(), this.#e = i, this.#i = {}, this.#f(!0), this.onUpdate((e, t) => this.#_(t));
1504
1504
  }
1505
1505
  get spec() {
1506
1506
  let e = this.#t;
@@ -1526,8 +1526,8 @@ var Z = class t extends h {
1526
1526
  ...e
1527
1527
  }, this.#f(!0), this;
1528
1528
  }
1529
- filter(t) {
1530
- return t !== null && typeof t != "function" && e("Chart", `filter() takes (row) => boolean, or null, got ${r(t)}`), this.#c = t, this.#f(!0), this;
1529
+ filter(e) {
1530
+ return e !== null && typeof e != "function" && t("Chart", `filter() takes (row) => boolean, or null, got ${r(e)}`), this.#c = e, this.#f(!0), this;
1531
1531
  }
1532
1532
  explain() {
1533
1533
  let e = this.#t, t = [
@@ -1540,6 +1540,18 @@ var Z = class t extends h {
1540
1540
  }), n = this.#u?.rows.length ?? 0;
1541
1541
  return `Chart (${e.mark}): ${n} of ${e.rows.length} rows shown${t.length ? `; ${t.join(", ")}` : ""}${e.links.length ? `; ${e.links.length} links` : ""}`;
1542
1542
  }
1543
+ summary() {
1544
+ let e = this.#t, t = e.options;
1545
+ if (t.description) return String(t.description);
1546
+ let n = [...new Set([
1547
+ "x",
1548
+ "y",
1549
+ "z",
1550
+ "color",
1551
+ "size"
1552
+ ].map((t) => e.channels[t]).filter((e) => e?.field).map((e) => e.title))], r = (e, t) => `${e} ${e === 1 ? t : `${t}s`}`, i = `${e.mark} chart of ${r(e.rows.length, "row")}${n.length ? ` by ${n.join(", ")}` : ""}${e.links.length ? ` and ${r(e.links.length, "link")}` : ""}`;
1553
+ return t.title ? `${t.title}: ${i}` : i;
1554
+ }
1543
1555
  jsonOptions() {
1544
1556
  return { ...this.#e };
1545
1557
  }
@@ -1548,9 +1560,9 @@ var Z = class t extends h {
1548
1560
  return delete e.children, this.#e.highlight === void 0 && delete e.highlight, e;
1549
1561
  }
1550
1562
  clone() {
1551
- let { name: e, position: n, quaternion: r, scale: i, visible: a, pickable: o, highlightWhole: s, onHover: c, onClick: l, showFrom: u, clip: d, onDrag: f, outline: p } = super.cloneOptions(), m = new t({
1563
+ let { name: t, position: n, quaternion: r, scale: i, visible: a, pickable: o, highlightWhole: s, onHover: c, onClick: l, showFrom: u, clip: d, onDrag: f, outline: p } = super.cloneOptions(), m = new e({
1552
1564
  ...this.#e,
1553
- name: e,
1565
+ name: t,
1554
1566
  position: n,
1555
1567
  quaternion: r,
1556
1568
  scale: i,
@@ -1566,72 +1578,72 @@ var Z = class t extends h {
1566
1578
  });
1567
1579
  return m.userData = structuredClone(this.userData), m.matrixAutoUpdate = this.matrixAutoUpdate, m.matrixAutoUpdate || m.matrix.copy(this.matrix), m;
1568
1580
  }
1569
- #f(t) {
1570
- let n = ye(this.#e), r = n.options, i = n.channels;
1581
+ #f(e) {
1582
+ let n = ye(this.#e), r = n.options, a = n.channels;
1571
1583
  this.#t = n;
1572
- let a = r.box ?? Ne(n), o = r.theme ?? "dark";
1573
- o !== "dark" && o !== "light" && e("chart()", `theme '${o}' - expected 'dark' or 'light'`);
1574
- let s = r.overlap ?? "dim";
1584
+ let o = r.box ?? Ne(n), s = r.theme ?? "dark";
1585
+ s !== "dark" && s !== "light" && t("chart()", `theme '${s}' - expected 'dark' or 'light'`);
1586
+ let l = r.overlap ?? "dim";
1575
1587
  [
1576
1588
  "dim",
1577
1589
  "hide",
1578
1590
  "show"
1579
- ].includes(s) || e("chart()", `overlap '${s}' - expected 'dim', 'hide' or 'show'`);
1580
- let l = n.rows.filter((e) => (!this.#c || this.#c(e)) && (!i.color?.field || !this.#s.has(String(i.color.get(e)))));
1581
- this.scales = Le(n, a);
1582
- let u = this.scales.color, d = c.fromInput(i.color?.field ? L.category[0] : i.color?.value ?? L.category[0], "chart()").toSRGB(), f = n.link.color?.field ? Fe(n.link.color, n.links.map((e) => n.link.color.get(e))) : null;
1591
+ ].includes(l) || t("chart()", `overlap '${l}' - expected 'dim', 'hide' or 'show'`);
1592
+ let u = n.rows.filter((e) => (!this.#c || this.#c(e)) && (!a.color?.field || !this.#s.has(String(a.color.get(e)))));
1593
+ this.scales = Le(n, o);
1594
+ let d = this.scales.color, f = c.fromInput(a.color?.field ? L.category[0] : a.color?.value ?? L.category[0], "chart()").toSRGB(), p = n.link.color?.field ? Fe(n.link.color, n.links.map((e) => n.link.color.get(e))) : null;
1583
1595
  Object.assign(this.#i, {
1584
1596
  spec: n,
1585
- box: a,
1586
- theme: o,
1587
- overlap: s,
1597
+ box: o,
1598
+ theme: s,
1599
+ overlap: l,
1588
1600
  scales: this.scales,
1589
1601
  size: this.scales.size ?? null,
1590
- rgb: (e) => u ? u(Ie(n, e)).toSRGB() : d,
1602
+ rgb: (e) => d ? d(Ie(n, e)).toSRGB() : f,
1591
1603
  format: $,
1592
- linkColor: (e) => f(e)
1604
+ linkColor: (e) => p(e)
1593
1605
  });
1594
- let p = JSON.stringify([
1606
+ let m = JSON.stringify([
1595
1607
  n.mark,
1596
- Object.entries(i).map(([e, t]) => [
1608
+ Object.entries(a).map(([e, t]) => [
1597
1609
  e,
1598
1610
  t.field,
1599
1611
  t.type
1600
1612
  ]),
1601
- a,
1602
1613
  o,
1603
1614
  s,
1615
+ l,
1604
1616
  r.stack,
1605
1617
  r.layout,
1606
1618
  r.flat,
1607
1619
  Object.keys(n.link)
1608
1620
  ]);
1609
- if (p !== this.#r) {
1610
- this.#r = p, this.#n && this.remove(...this.#n.nodes), this.#n = Me(n.mark, this.#i);
1621
+ if (m !== this.#r) {
1622
+ this.#r = m, this.#n && this.remove(...this.#n.nodes), this.#n = Me(n.mark, this.#i);
1611
1623
  for (let e of this.#n.nodes) this.add(e);
1612
1624
  this.#l = this.#u = null, this.#d = null;
1613
1625
  }
1614
1626
  this.#a && this.remove(this.#a), this.#a = n.mark === "network" && r.layout !== "given" ? null : this.add(S({
1615
- box: a,
1616
- theme: o,
1617
- overlap: s,
1627
+ box: o,
1628
+ theme: s,
1629
+ overlap: l,
1618
1630
  axes: ze(n, this.scales)
1619
- })), this.#o && this.remove(this.#o), this.#o = r.title ? this.add(new _({
1631
+ })), this.#o && this.remove(this.#o), this.#o = r.title ? this.add(new i({
1620
1632
  text: String(r.title),
1621
1633
  position: [
1622
1634
  0,
1623
- a[1] * 1.12,
1624
- -a[2] / 2
1635
+ o[1] * 1.12,
1636
+ -o[2] / 2
1625
1637
  ],
1626
- className: `phoria-axis-title phoria-${o}`,
1638
+ className: `phoria-axis-title phoria-${s}`,
1627
1639
  overlap: "show"
1628
- })) : null, this.#p(n, o), this.tooltip = n.tooltip === null && !n.link.tooltip ? null : (e) => this.#m(e);
1629
- let m = r.highlight;
1630
- this.highlight = m === !1 ? null : c.fromInput(m === void 0 || m === "neighbours" || m === "node" ? "#ffffff" : m, "chart()"), this.#h(this.#n.layout(l), t && r.transition !== !1);
1640
+ })) : null, this.#p(n, s), this.tooltip = n.tooltip === null && !n.link.tooltip ? null : (e) => this.#m(e);
1641
+ let h = r.highlight;
1642
+ this.highlight = h === !1 ? null : c.fromInput(h === void 0 || h === "neighbours" || h === "node" ? "#ffffff" : h, "chart()"), this.#h(this.#n.layout(u), e && r.transition !== !1);
1631
1643
  }
1632
- #p(t, n) {
1644
+ #p(e, n) {
1633
1645
  this.overlay?.remove(), this.overlay = null;
1634
- let i = t.channels.color, a = t.options.legend;
1646
+ let i = e.channels.color, a = e.options.legend;
1635
1647
  if (!i?.field || a === !1 || !this.scales.color || typeof document > "u") return;
1636
1648
  let o = ie(this.scales.color, {
1637
1649
  title: i.title,
@@ -1648,8 +1660,8 @@ var Z = class t extends h {
1648
1660
  });
1649
1661
  let s = a?.container;
1650
1662
  if (s) {
1651
- let t = typeof s == "string" ? document.querySelector(s) : s;
1652
- t || e("chart()", `legend container ${r(s)} not found`), o.classList.remove(`phoria-legend-${a?.position ?? "top-right"}`), Object.assign(o.style, {
1663
+ let e = typeof s == "string" ? document.querySelector(s) : s;
1664
+ e || t("chart()", `legend container ${r(s)} not found`), o.classList.remove(`phoria-legend-${a?.position ?? "top-right"}`), Object.assign(o.style, {
1653
1665
  position: "static",
1654
1666
  flexDirection: "row",
1655
1667
  flexWrap: "wrap",
@@ -1657,7 +1669,7 @@ var Z = class t extends h {
1657
1669
  columnGap: "12px",
1658
1670
  maxHeight: "none",
1659
1671
  overflow: "visible"
1660
- }), t.replaceChildren(o);
1672
+ }), e.replaceChildren(o);
1661
1673
  } else this.overlay = o;
1662
1674
  }
1663
1675
  #m(e) {
@@ -1713,16 +1725,17 @@ var Z = class t extends h {
1713
1725
  #g(e, t, n) {
1714
1726
  this.#n.apply(e, t), this.#l = e.slice(), this.#u = n;
1715
1727
  }
1716
- #_(t) {
1717
- this.#n?.tick?.(t);
1718
- let n = this.#d;
1719
- if (!n) return;
1720
- let r = this.#e.transition ?? {}, i = r.duration ?? .5, a = s[r.ease ?? "out"];
1721
- a || e("chart()", `transition ease '${r.ease}' - expected ${Object.keys(s).map((e) => `'${e}'`).join(", ")}`), n.t = Math.min(1, n.t + t / i);
1722
- let o = a(n.t), c = new Float32Array(n.from.length);
1723
- for (let e = 0; e < c.length; e++) c[e] = n.from[e] + (n.to[e] - n.from[e]) * o;
1724
- if (n.t < 1) return this.#g(c, n.frame, n.frame);
1725
- this.#d = null, this.#g(n.final.state, n.final, n.final);
1728
+ #_(e) {
1729
+ let n = this.root.motionReduced === !0;
1730
+ n || this.#n?.tick?.(e);
1731
+ let r = this.#d;
1732
+ if (!r) return;
1733
+ let i = this.#e.transition ?? {}, a = i.duration ?? .5, s = o[i.ease ?? "out"];
1734
+ s || t("chart()", `transition ease '${i.ease}' - expected ${Object.keys(o).map((e) => `'${e}'`).join(", ")}`), r.t = n ? 1 : Math.min(1, r.t + e / a);
1735
+ let c = s(r.t), l = new Float32Array(r.from.length);
1736
+ for (let e = 0; e < l.length; e++) l[e] = r.from[e] + (r.to[e] - r.from[e]) * c;
1737
+ if (r.t < 1) return this.#g(l, r.frame, r.frame);
1738
+ this.#d = null, this.#g(r.final.state, r.final, r.final);
1726
1739
  }
1727
1740
  };
1728
1741
  m(Z);