phoria2 1.0.0-rc.7 → 1.0.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 (82) hide show
  1. package/README.md +26 -6
  2. package/dist/bloom.js +1 -1
  3. package/dist/charts.js +408 -408
  4. package/dist/charts.js.map +1 -1
  5. package/dist/core.js +1069 -1208
  6. package/dist/core.js.map +1 -1
  7. package/dist/edit.js +43 -43
  8. package/dist/edit.js.map +1 -1
  9. package/dist/explain.js +1 -1
  10. package/dist/gltf.js +168 -162
  11. package/dist/gltf.js.map +1 -1
  12. package/dist/motion.js +30 -30
  13. package/dist/motion.js.map +1 -1
  14. package/dist/particles.js +46 -46
  15. package/dist/particles.js.map +1 -1
  16. package/dist/passes.js +33 -33
  17. package/dist/passes.js.map +1 -1
  18. package/dist/phoria2.js +1 -1
  19. package/dist/picking.js +14 -14
  20. package/dist/picking.js.map +1 -1
  21. package/dist/snapshot.js +1 -1
  22. package/dist/tooltip.js +3 -3
  23. package/dist/tooltip.js.map +1 -1
  24. package/dist/types/OrbitControl.d.ts +0 -10
  25. package/dist/types/Raycaster.d.ts +0 -16
  26. package/dist/types/View.d.ts +0 -8
  27. package/dist/types/charts/Chart.d.ts +0 -2
  28. package/dist/types/charts/scales.d.ts +0 -5
  29. package/dist/types/clip.d.ts +0 -6
  30. package/dist/types/fog.d.ts +0 -6
  31. package/dist/types/frame.d.ts +0 -2
  32. package/dist/types/geometry/Geometry.d.ts +0 -4
  33. package/dist/types/geometry/generators.d.ts +10 -4
  34. package/dist/types/gltf/Animation.d.ts +0 -4
  35. package/dist/types/gltf/load.d.ts +6 -0
  36. package/dist/types/index.d.ts +1 -2
  37. package/dist/types/material/Material.d.ts +5 -22
  38. package/dist/types/material/Texture.d.ts +0 -6
  39. package/dist/types/particles/Emitter.d.ts +0 -4
  40. package/dist/types/registry.d.ts +0 -2
  41. package/dist/types/scene/Node.d.ts +13 -40
  42. package/dist/types/scene/Scene.d.ts +0 -4
  43. package/dist/types/scene/cameras.d.ts +0 -12
  44. package/dist/types/scene/drawables.d.ts +0 -42
  45. package/dist/types/scene/lights.d.ts +0 -38
  46. package/dist/types/value/Color.d.ts +0 -2
  47. package/dist/types/value/Euler.d.ts +0 -2
  48. package/dist/types/value/Quat.d.ts +0 -4
  49. package/dist/types/value/Vec3.d.ts +0 -7
  50. package/dist/types/webgl/WebGLRenderer.d.ts +0 -19
  51. package/dist/types/webgl/shaders.d.ts +1 -1
  52. package/llms-full.txt +120 -8
  53. package/llms.txt +2 -1
  54. package/package.json +3 -1
  55. package/schema/chart.schema.json +1 -1
  56. package/schema/scene.schema.json +1149 -0
  57. package/src/Raycaster.js +2 -2
  58. package/src/View.js +2 -2
  59. package/src/charts/Chart.js +1 -1
  60. package/src/clip.js +1 -1
  61. package/src/fog.js +1 -1
  62. package/src/frame.js +1 -1
  63. package/src/geometry/Geometry.js +4 -3
  64. package/src/geometry/generators.js +12 -7
  65. package/src/gltf/Animation.js +1 -1
  66. package/src/gltf/load.js +9 -0
  67. package/src/index.js +1 -2
  68. package/src/material/Material.js +10 -9
  69. package/src/material/Texture.js +2 -2
  70. package/src/particles/Emitter.js +2 -2
  71. package/src/scene/Node.js +20 -5
  72. package/src/scene/Scene.js +2 -2
  73. package/src/scene/cameras.js +6 -6
  74. package/src/scene/drawables.js +14 -12
  75. package/src/scene/lights.js +19 -19
  76. package/src/value/Color.js +1 -1
  77. package/src/value/Euler.js +1 -1
  78. package/src/value/Quat.js +2 -2
  79. package/src/value/Vec3.js +1 -1
  80. package/src/watch.js +1 -1
  81. package/src/webgl/WebGLRenderer.js +11 -3
  82. package/src/webgl/shaders.js +3 -0
package/dist/charts.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Ct as e, D as t, E as n, Ft as r, Ht as i, It as a, O as o, Pt as s, T as c, V as l, et as u, jt as d, n as f, ot as p, p as m, st as h, v as g, w as _ } from "./core.js";
1
+ import { C as e, Dt as t, L as n, Ot as r, Pt as i, S as a, X as o, b as s, gt as c, kt as l, l as u, m as d, n as f, nt as p, rt as m, w as h, wt as g, x 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, n) {
@@ -12,152 +12,152 @@ function x(e, t, n) {
12
12
  ];
13
13
  }
14
14
  function S({ box: e, axes: t, theme: r, overlap: i }) {
15
- let [a, o, s] = e, u = new p({
15
+ let [o, s, c] = e, l = new p({
16
16
  name: "axes",
17
17
  pickable: !1
18
- }), d = (e) => x(u, e, o / 2), f = r === "light" ? "#c3c8d2" : "#3a3d47", m = (e) => {
18
+ }), u = (e) => x(l, e, s / 2), d = r === "light" ? "#c3c8d2" : "#3a3d47", f = (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
- }, h = (e) => e && e.scale.kind !== "band" && e.channel?.axis !== !1 ? m(e) : [], g = h(t.x), _ = h(t.y), b = h(t.z), S = (e, r) => {
24
- let i = [], c = (e, t) => i.push(...e, ...t), p = (e) => r < 0 ? -e / 2 : e / 2;
23
+ }, m = (e) => e && e.scale.kind !== "band" && e.channel?.axis !== !1 ? f(e) : [], h = m(t.x), g = m(t.y), b = m(t.z), S = (e, r) => {
24
+ let i = [], f = (e, t) => i.push(...e, ...t), p = (e) => r < 0 ? -e / 2 : e / 2;
25
25
  if (e === "y") {
26
- let e = r < 0 ? 0 : o;
27
- for (let n of g) {
26
+ let e = r < 0 ? 0 : s;
27
+ for (let n of h) {
28
28
  let r = t.x.scale(n);
29
- c([
29
+ f([
30
30
  r,
31
31
  e,
32
- -s / 2
32
+ -c / 2
33
33
  ], [
34
34
  r,
35
35
  e,
36
- s / 2
36
+ c / 2
37
37
  ]);
38
38
  }
39
39
  for (let n of b) {
40
40
  let r = t.z.scale(n);
41
- c([
42
- -a / 2,
41
+ f([
42
+ -o / 2,
43
43
  e,
44
44
  r
45
45
  ], [
46
- a / 2,
46
+ o / 2,
47
47
  e,
48
48
  r
49
49
  ]);
50
50
  }
51
- C(c, [
52
- -a / 2,
51
+ C(f, [
52
+ -o / 2,
53
53
  e,
54
- -s / 2
54
+ -c / 2
55
55
  ], [
56
- a / 2,
56
+ o / 2,
57
57
  e,
58
- -s / 2
58
+ -c / 2
59
59
  ], [
60
- a / 2,
60
+ o / 2,
61
61
  e,
62
- s / 2
62
+ c / 2
63
63
  ], [
64
- -a / 2,
64
+ -o / 2,
65
65
  e,
66
- s / 2
66
+ c / 2
67
67
  ]);
68
68
  } else if (e === "x") {
69
- let e = p(a);
70
- for (let n of _) {
69
+ let e = p(o);
70
+ for (let n of g) {
71
71
  let r = t.y.scale(n);
72
- c([
72
+ f([
73
73
  e,
74
74
  r,
75
- -s / 2
75
+ -c / 2
76
76
  ], [
77
77
  e,
78
78
  r,
79
- s / 2
79
+ c / 2
80
80
  ]);
81
81
  }
82
82
  for (let n of b) {
83
83
  let r = t.z.scale(n);
84
- c([
84
+ f([
85
85
  e,
86
86
  0,
87
87
  r
88
88
  ], [
89
89
  e,
90
- o,
90
+ s,
91
91
  r
92
92
  ]);
93
93
  }
94
- C(c, [
94
+ C(f, [
95
95
  e,
96
96
  0,
97
- -s / 2
97
+ -c / 2
98
98
  ], [
99
99
  e,
100
- o,
101
- -s / 2
100
+ s,
101
+ -c / 2
102
102
  ], [
103
103
  e,
104
- o,
105
- s / 2
104
+ s,
105
+ c / 2
106
106
  ], [
107
107
  e,
108
108
  0,
109
- s / 2
109
+ c / 2
110
110
  ]);
111
111
  } else {
112
- let e = p(s);
113
- for (let n of _) {
112
+ let e = p(c);
113
+ for (let n of g) {
114
114
  let r = t.y.scale(n);
115
- c([
116
- -a / 2,
115
+ f([
116
+ -o / 2,
117
117
  r,
118
118
  e
119
119
  ], [
120
- a / 2,
120
+ o / 2,
121
121
  r,
122
122
  e
123
123
  ]);
124
124
  }
125
- for (let n of g) {
125
+ for (let n of h) {
126
126
  let r = t.x.scale(n);
127
- c([
127
+ f([
128
128
  r,
129
129
  0,
130
130
  e
131
131
  ], [
132
132
  r,
133
- o,
133
+ s,
134
134
  e
135
135
  ]);
136
136
  }
137
- C(c, [
138
- -a / 2,
137
+ C(f, [
138
+ -o / 2,
139
139
  0,
140
140
  e
141
141
  ], [
142
- a / 2,
142
+ o / 2,
143
143
  0,
144
144
  e
145
145
  ], [
146
- a / 2,
147
- o,
146
+ o / 2,
147
+ s,
148
148
  e
149
149
  ], [
150
- -a / 2,
151
- o,
150
+ -o / 2,
151
+ s,
152
152
  e
153
153
  ]);
154
154
  }
155
155
  let m = "xyz".indexOf(e);
156
- u.add(new n({
157
- geometry: new l({ positions: i }),
158
- material: { color: f },
156
+ l.add(new a({
157
+ geometry: new n({ positions: i }),
158
+ material: { color: d },
159
159
  pickable: !1,
160
- showFrom: (e) => -r * d(e)[m] > y
160
+ showFrom: (e) => -r * u(e)[m] > y
161
161
  }));
162
162
  };
163
163
  for (let e of [
@@ -165,16 +165,16 @@ function S({ box: e, axes: t, theme: r, overlap: i }) {
165
165
  "y",
166
166
  "z"
167
167
  ]) for (let t of [-1, 1]) S(e, t);
168
- let w = Math.max(a, o, s) * .04, T = (e) => `phoria-axis-${e} phoria-${r}`, E = (e, n, r) => {
168
+ let w = Math.max(o, s, c) * .04, T = (e) => `phoria-axis-${e} phoria-${r}`, E = (e, n, r) => {
169
169
  let a = t[e];
170
170
  if (!a || a.channel?.axis === !1) return;
171
- let o = "xyz".indexOf(e), s = m(a);
171
+ let o = "xyz".indexOf(e), s = f(a);
172
172
  for (let e of n) {
173
- let t = u.add(new p({ showFrom: (t) => {
174
- let n = d(t);
173
+ let t = l.add(new p({ showFrom: (t) => {
174
+ let n = u(t);
175
175
  return Math.abs(n[o]) < v && e.when(n);
176
176
  } }));
177
- for (let n of s) t.add(new c({
177
+ for (let n of s) t.add(new _({
178
178
  text: a.scale.format(n),
179
179
  position: e.at(a.scale(n), w),
180
180
  place: r,
@@ -182,7 +182,7 @@ function S({ box: e, axes: t, theme: r, overlap: i }) {
182
182
  priority: 1,
183
183
  overlap: i
184
184
  }));
185
- a.title && t.add(new c({
185
+ a.title && t.add(new _({
186
186
  text: a.title,
187
187
  position: e.title(w),
188
188
  place: r,
@@ -192,43 +192,43 @@ function S({ box: e, axes: t, theme: r, overlap: i }) {
192
192
  }));
193
193
  }
194
194
  }, D = (e) => e[1] >= -.08, O = (e) => e >= -.1 ? 1 : -1;
195
- return E("x", [-1, 1].flatMap((e) => [0, o].map((t) => ({
195
+ return E("x", [-1, 1].flatMap((e) => [0, s].map((t) => ({
196
196
  when: (n) => t === 0 === D(n) && O(n[2]) === e,
197
197
  at: (n, r) => [
198
198
  n,
199
199
  t,
200
- e * (s / 2 + r)
200
+ e * (c / 2 + r)
201
201
  ],
202
202
  title: (n) => [
203
203
  0,
204
204
  t,
205
- e * (s / 2 + n * 3.5)
205
+ e * (c / 2 + n * 3.5)
206
206
  ]
207
- }))), "below"), E("z", [-1, 1].flatMap((e) => [0, o].map((t) => ({
207
+ }))), "below"), E("z", [-1, 1].flatMap((e) => [0, s].map((t) => ({
208
208
  when: (n) => t === 0 === D(n) && O(n[0]) === e,
209
209
  at: (n, r) => [
210
- e * (a / 2 + r),
210
+ e * (o / 2 + r),
211
211
  t,
212
212
  n
213
213
  ],
214
214
  title: (n) => [
215
- e * (a / 2 + n * 4),
215
+ e * (o / 2 + n * 4),
216
216
  t,
217
217
  0
218
218
  ]
219
219
  }))), "below"), E("y", [-1, 1].flatMap((e) => [-1, 1].map((t) => ({
220
220
  when: (n) => O(n[0]) === -e && O(n[2]) === t,
221
221
  at: (n, r) => [
222
- e * (a / 2 + r),
222
+ e * (o / 2 + r),
223
223
  n,
224
- t * s / 2
224
+ t * c / 2
225
225
  ],
226
226
  title: (n) => [
227
- e * (a / 2 + n),
228
- o + n * 2,
229
- t * s / 2
227
+ e * (o / 2 + n),
228
+ s + n * 2,
229
+ t * c / 2
230
230
  ]
231
- }))), "left"), u;
231
+ }))), "left"), l;
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(e, t, n = !1) {
242
+ function E(e, n, r = !1) {
243
243
  if (typeof e == "function") return e;
244
244
  if (e && typeof e == "object") {
245
- let t = n ? new Intl.DateTimeFormat(void 0, e) : new Intl.NumberFormat(void 0, e);
245
+ let t = r ? new Intl.DateTimeFormat(void 0, e) : new Intl.NumberFormat(void 0, e);
246
246
  return (e) => t.format(e);
247
247
  }
248
- return e !== void 0 && a("charts", `'format' must be Intl format options or a function, got ${s(e)}`), t;
248
+ return e !== void 0 && l("charts", `'format' must be Intl format options or a function, got ${t(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(e, t) {
258
- return Array.isArray(e) && e.length === 2 && e.every((e) => typeof e == "number" && Number.isFinite(e)) || a("charts", `'${t}' must be [min, max] numbers, got ${s(e)}`), [e[0], e[1]];
257
+ function O(e, n) {
258
+ return Array.isArray(e) && e.length === 2 && e.every((e) => typeof e == "number" && Number.isFinite(e)) || l("charts", `'${n}' must be [min, max] numbers, got ${t(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");
@@ -275,12 +275,12 @@ function k({ domain: e, range: t = [0, 1], nice: n = !1, zero: r = !1, clamp: i
275
275
  }
276
276
  function A({ domain: e, range: t = [0, 1], format: n }) {
277
277
  let [r, i] = O(e, "domain");
278
- (r <= 0 || i <= 0) && a("charts", `a log scale needs a domain above 0, got [${r}, ${i}] - use a linear scale for zero or negative values`);
279
- let o = k({
278
+ (r <= 0 || i <= 0) && l("charts", `a log scale needs a domain above 0, got [${r}, ${i}] - use a linear scale for zero or negative values`);
279
+ let a = k({
280
280
  domain: [Math.log10(r), Math.log10(i)],
281
281
  range: t
282
- }), s = ((e) => o(Math.log10(e)));
283
- return s.kind = "log", s.domain = [r, i], s.range = o.range, s.invert = (e) => 10 ** o.invert?.(e), s.ticks = () => {
282
+ }), o = ((e) => a(Math.log10(e)));
283
+ return o.kind = "log", o.domain = [r, i], o.range = a.range, o.invert = (e) => 10 ** a.invert?.(e), o.ticks = () => {
284
284
  let e = [];
285
285
  for (let t = Math.floor(Math.log10(r)); t <= Math.ceil(Math.log10(i)); t++) for (let n of [
286
286
  1,
@@ -291,10 +291,10 @@ function A({ domain: e, range: t = [0, 1], format: n }) {
291
291
  a >= r * .999 && a <= i * 1.001 && e.push(a);
292
292
  }
293
293
  return e;
294
- }, s.format = E(n, (e) => new Intl.NumberFormat(void 0, {
294
+ }, o.format = E(n, (e) => new Intl.NumberFormat(void 0, {
295
295
  notation: "compact",
296
296
  maximumFractionDigits: 1
297
- }).format(e)), s;
297
+ }).format(e)), o;
298
298
  }
299
299
  var j = 1e3, M = 60 * j, N = 60 * M, P = 24 * N, F = [
300
300
  [j, "s"],
@@ -389,8 +389,8 @@ var j = 1e3, M = 60 * j, N = 60 * M, P = 24 * N, F = [
389
389
  Y: { year: "numeric" }
390
390
  };
391
391
  function I(e) {
392
- let t = e instanceof Date ? e : new Date(e);
393
- return Number.isNaN(t.getTime()) && a("charts", `${s(e)} isn't a date - use Date objects, timestamps or ISO strings like '2026-10-25'`), t;
392
+ let n = e instanceof Date ? e : new Date(e);
393
+ return Number.isNaN(n.getTime()) && l("charts", `${t(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: e, range: t = [0, 1], padding: n = .2, format: r }) {
423
- Array.isArray(e) || a("charts", `a band scale's domain is a list of categories, got ${s(e)}`);
424
- let [i, o] = O(t, "range"), c = new Map(e.map((e, t) => [String(e), t])), l = (o - i) / Math.max(1, e.length), u = ((e) => {
425
- let t = c.get(String(e));
426
- return t === void 0 ? NaN : i + l * (t + .5);
422
+ function re({ domain: e, range: n = [0, 1], padding: r = .2, format: i }) {
423
+ Array.isArray(e) || l("charts", `a band scale's domain is a list of categories, got ${t(e)}`);
424
+ let [a, o] = O(n, "range"), s = new Map(e.map((e, t) => [String(e), t])), c = (o - a) / Math.max(1, e.length), u = ((e) => {
425
+ let t = s.get(String(e));
426
+ return t === void 0 ? NaN : a + c * (t + .5);
427
427
  });
428
- return u.kind = "band", u.domain = e, u.range = [i, o], u.step = l, u.bandwidth = Math.abs(l) * (1 - n), u.ticks = () => e, u.format = E(r, (e) => String(e)), u;
428
+ return u.kind = "band", u.domain = e, u.range = [a, o], u.step = c, u.bandwidth = Math.abs(c) * (1 - r), u.ticks = () => e, u.format = E(i, (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: r, kind: i }) {
480
- n !== void 0 && !(n in L) && a("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 = i ? i === "sequential" : t.length === 2 && t.every((e) => typeof e == "number");
482
- o && (t.length < 2 || t.some((e) => typeof e != "number")) && a("charts", `a sequential colour scale needs two or more numbers in its domain, got ${s(t)}`);
483
- let c = (r ?? L[n ?? (o ? "viridis" : "category")]).map((t) => e.fromInput(t, "charts")), l;
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);
479
+ function R({ domain: e, scheme: n, range: r, kind: i }) {
480
+ n !== void 0 && !(n in L) && l("charts", `colour scheme '${n}' isn't one we have - use ${Object.keys(L).map((e) => `'${e}'`).join(", ")}, or a range of colours`);
481
+ let a = i ? i === "sequential" : e.length === 2 && e.every((e) => typeof e == "number");
482
+ a && (e.length < 2 || e.some((e) => typeof e != "number")) && l("charts", `a sequential colour scale needs two or more numbers in its domain, got ${t(e)}`);
483
+ let o = (r ?? L[n ?? (a ? "viridis" : "category")]).map((e) => c.fromInput(e, "charts")), s;
484
+ if (a) {
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) => {
492
- if (c.length < 2) return c[0].clone();
493
- let n = e(t) * (c.length - 1), r = Math.min(c.length - 2, Math.floor(n));
494
- return c[r].clone().lerp(c[r + 1], n - r);
495
- }), l.kind = "sequential", l.colors = () => [];
491
+ s = ((e) => {
492
+ if (o.length < 2) return o[0].clone();
493
+ let n = t(e) * (o.length - 1), r = Math.min(o.length - 2, Math.floor(n));
494
+ return o[r].clone().lerp(o[r + 1], n - r);
495
+ }), s.kind = "sequential", s.colors = () => [];
496
496
  } else {
497
- let e = new Map(t.map((e, t) => [String(e), t]));
498
- l = ((t) => c[(e.get(String(t)) ?? 0) % c.length].clone()), l.kind = "categorical", l.colors = () => t.map((e) => ({
497
+ let t = new Map(e.map((e, t) => [String(e), t]));
498
+ s = ((e) => o[(t.get(String(e)) ?? 0) % o.length].clone()), s.kind = "categorical", s.colors = () => e.map((e) => ({
499
499
  value: e,
500
- color: l(e)
500
+ color: s(e)
501
501
  }));
502
502
  }
503
- return l.domain = t, l.range = c.map((e) => e.getStyle()), l;
503
+ return s.domain = e, s.range = o.map((e) => e.getStyle()), s;
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,8 +624,8 @@ function oe(e) {
624
624
  return n;
625
625
  }
626
626
  function U(e, t) {
627
- let n = new _({
628
- geometry: m(1),
627
+ let n = new s({
628
+ geometry: u(1),
629
629
  material: { roughness: .55 },
630
630
  count: e,
631
631
  labels: V(t, "above")
@@ -640,15 +640,15 @@ 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 _({
644
- geometry: g({
643
+ }, a = t ? new s({
644
+ geometry: d({
645
645
  radius: 1,
646
646
  detail: 1
647
647
  }),
648
648
  material: i,
649
649
  count: 64,
650
650
  labels: V(e, "above")
651
- }) : new o({
651
+ }) : new h({
652
652
  geometry: G(64),
653
653
  material: {
654
654
  size: e.spec.channels.size?.value ?? n * 1.4,
@@ -658,7 +658,7 @@ function se(e) {
658
658
  labels: V(e, "above")
659
659
  });
660
660
  t && (a.count = 0);
661
- let s = {
661
+ let o = {
662
662
  nodes: [a],
663
663
  layout(n) {
664
664
  let { x: r, y: i, z: a } = e.scales, o = e.spec.channels, s = t ? 7 : 6, c = new Float32Array(n.length * s);
@@ -684,13 +684,13 @@ 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 _({
687
+ let e = new s({
688
688
  geometry: a.geometry,
689
689
  material: a.material,
690
690
  count: r * 2,
691
691
  labels: a.labels
692
692
  });
693
- a.parent?.add(e), a.parent?.remove(a), s.nodes[0] = a = e;
693
+ a.parent?.add(e), a.parent?.remove(a), o.nodes[0] = a = e;
694
694
  }
695
695
  a.count = r;
696
696
  for (let t = 0; t < r; t++) {
@@ -713,26 +713,26 @@ function se(e) {
713
713
  }
714
714
  let i = a.geometry;
715
715
  r > i.vertexCount && (a.geometry = G(r * 2));
716
- let o = a.geometry.positions, c = a.geometry.colors;
717
- for (let t = 0; t < r; t++) o.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) {
721
721
  t ? e[3] = 0 : e[1] = 0;
722
722
  }
723
723
  };
724
- return s;
724
+ return o;
725
725
  }
726
726
  function G(e) {
727
- let t = new l({
727
+ let t = new n({
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, r) {
734
- let i = new n({
735
- geometry: new l({ positions: [
733
+ function ce(t, r) {
734
+ let i = new a({
735
+ geometry: new n({ positions: [
736
736
  0,
737
737
  0,
738
738
  0,
@@ -745,16 +745,16 @@ function ce(e, r) {
745
745
  vertexColors: !0
746
746
  },
747
747
  pickable: !1
748
- }), a = new o({
748
+ }), o = new h({
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 = r ? new t({
757
- geometry: new l({ positions: [
755
+ labels: V(t, "above")
756
+ }), s = r ? new e({
757
+ geometry: new n({ positions: [
758
758
  0,
759
759
  0,
760
760
  0,
@@ -777,19 +777,19 @@ function ce(e, r) {
777
777
  nodes: s ? [
778
778
  s,
779
779
  i,
780
- a
781
- ] : [i, a],
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
+ o
781
+ ] : [i, o],
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, r) {
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: r } = t.shape, o = [], c = [], l = [], u = [], d = [], f = [], p = [], m = 0;
810
+ let { lengths: n, colors: r } = t.shape, a = [], c = [], l = [], u = [], d = [], f = [], p = [], m = 0;
811
811
  n.forEach((t, n) => {
812
812
  let i = r[n];
813
813
  for (let n = 0; n < t; n++, m++) {
814
- let [t, r, a, h] = e.subarray(m * 4, m * 4 + 4);
815
- if (l.push(t, r, a), u.push(...i), n > 0 && (o.push(...e.subarray((m - 1) * 4, (m - 1) * 4 + 3), t, r, a), c.push(...i, ...i)), s) {
814
+ let [t, r, o, h] = e.subarray(m * 4, m * 4 + 4);
815
+ if (l.push(t, r, o), u.push(...i), n > 0 && (a.push(...e.subarray((m - 1) * 4, (m - 1) * 4 + 3), t, r, o), c.push(...i, ...i)), s) {
816
816
  let e = f.length / 3;
817
- d.push(t, r, a, t, h, a), f.push(...i, ...i), n > 0 && p.push(e - 2, e - 1, e, e - 1, e + 1, e);
817
+ d.push(t, r, o, t, h, o), f.push(...i, ...i), n > 0 && p.push(e - 2, e - 1, e, e - 1, e + 1, e);
818
818
  }
819
819
  }
820
- }), i.geometry = K(i.geometry, o.length ? {
821
- positions: o,
820
+ }), i.geometry = K(i.geometry, a.length ? {
821
+ positions: a,
822
822
  colors: c
823
823
  } : { positions: [
824
824
  0,
@@ -827,7 +827,7 @@ function ce(e, r) {
827
827
  0,
828
828
  0,
829
829
  0
830
- ] }), a.geometry = K(a.geometry, {
830
+ ] }), o.geometry = K(o.geometry, {
831
831
  positions: l.length ? l : [
832
832
  0,
833
833
  0,
@@ -838,7 +838,7 @@ function ce(e, r) {
838
838
  0,
839
839
  0
840
840
  ]
841
- }), a.geometry.drawCount = l.length / 3, a.material.size = Math.max(...n, 0) > 40 ? 4 : 7, a.data = t.rows, s && (s.geometry = K(s.geometry, p.length ? {
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 ? {
842
842
  positions: d,
843
843
  colors: f,
844
844
  indices: p
@@ -857,11 +857,11 @@ function ce(e, r) {
857
857
  };
858
858
  }
859
859
  function K(e, t) {
860
- return e.dispose(), new l(t);
860
+ return e.dispose(), new n(t);
861
861
  }
862
- function le(e) {
863
- let n = new t({
864
- geometry: new l({ positions: [
862
+ function le(t) {
863
+ let r = new e({
864
+ geometry: new n({ positions: [
865
865
  0,
866
866
  0,
867
867
  0,
@@ -879,21 +879,21 @@ function le(e) {
879
879
  }
880
880
  });
881
881
  return {
882
- nodes: [n],
883
- layout(t) {
884
- let { x: n, y: r, z: i } = e.scales, o = e.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: [r],
883
+ layout(e) {
884
+ let { x: n, y: r, z: i } = t.scales, a = t.spec.channels, o = z(e.map((e) => a.x.get(e))), s = z(e.map((e) => a.z.get(e))), c = new Map(e.map((e) => [`${+a.x.get(e)}|${+a.z.get(e)}|${a.x.get(e)}|${a.z.get(e)}`, e])), u = (e, t) => c.get(`${+e}|${+t}|${e}|${t}`), d = o.length * s.length - c.size;
885
885
  if (d > 0) {
886
- let e = s.flatMap((e) => c.map((t) => [e, t])).find(([e, t]) => !u(e, t));
887
- a("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]})`);
886
+ let e = o.flatMap((e) => s.map((t) => [e, t])).find(([e, t]) => !u(e, t));
887
+ l("chart()", `a surface needs a value for every x and z pair - ${d} of ${o.length * s.length} are missing (first: x ${e[0]}, z ${e[1]})`);
888
888
  }
889
- let f = [], p = new Float32Array(s.length * c.length * 6), m = 0;
890
- for (let t of c) for (let a of s) {
891
- let s = u(a, t);
892
- f.push(s), p.set([
893
- n(a),
894
- r(Number(o.y.get(s)) || 0),
895
- i(t),
896
- ...e.rgb(s)
889
+ let f = [], p = new Float32Array(o.length * s.length * 6), m = 0;
890
+ for (let e of s) for (let s of o) {
891
+ let o = u(s, e);
892
+ f.push(o), p.set([
893
+ n(s),
894
+ r(Number(a.y.get(o)) || 0),
895
+ i(e),
896
+ ...t.rgb(o)
897
897
  ], m++ * 6);
898
898
  }
899
899
  return {
@@ -902,23 +902,23 @@ function le(e) {
902
902
  state: p,
903
903
  stride: 6,
904
904
  shape: {
905
- nx: s.length,
906
- nz: c.length
905
+ nx: o.length,
906
+ nz: s.length
907
907
  }
908
908
  };
909
909
  },
910
910
  apply(e, t) {
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);
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);
916
916
  }
917
- n.geometry = K(n.geometry, {
917
+ r.geometry = K(r.geometry, {
918
918
  positions: a,
919
919
  colors: o,
920
920
  indices: s
921
- }), n.data = t.rows;
921
+ }), r.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 r = t.spec.options, i = me(t), c = t.spec.link, u = r.source ?? "source", d = r.target ?? "target", f = /* @__PURE__ */ new Map(), p = (e) => new _({
940
- geometry: g({
938
+ function fe(e) {
939
+ let r = e.spec.options, i = me(e), o = e.spec.link, u = r.source ?? "source", f = r.target ?? "target", p = /* @__PURE__ */ new Map(), m = (t) => new s({
940
+ geometry: d({
941
941
  radius: 1,
942
942
  detail: 2
943
943
  }),
944
944
  material: { roughness: .35 },
945
- count: e,
946
- labels: V(t, "above")
947
- }), m = p(Math.max(8, t.spec.rows.length * 2));
948
- m.count = 0;
949
- let h = de.map((e) => new n({
950
- geometry: new l({ positions: [
945
+ count: t,
946
+ labels: V(e, "above")
947
+ }), g = m(Math.max(8, e.spec.rows.length * 2));
948
+ g.count = 0;
949
+ let _ = de.map((e) => new a({
950
+ geometry: new n({ positions: [
951
951
  0,
952
952
  0,
953
953
  0,
@@ -960,63 +960,63 @@ function fe(t) {
960
960
  vertexColors: !0
961
961
  },
962
962
  data: []
963
- })), v = new n({
964
- geometry: new l({ positions: [] }),
963
+ })), v = new a({
964
+ geometry: new n({ positions: [] }),
965
965
  material: {
966
966
  width: 4,
967
967
  color: "#7fd3ff"
968
968
  },
969
969
  pickable: !1,
970
970
  visible: !1
971
- }), y = c.flow ? new o({
972
- geometry: new l({ positions: [] }),
971
+ }), y = o.flow ? new h({
972
+ geometry: new n({ positions: [] }),
973
973
  material: {
974
- size: .012 * Math.min(...t.box),
974
+ size: .012 * Math.min(...e.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
- ...h,
980
+ ..._,
981
981
  v,
982
- m,
982
+ g,
983
983
  ...y ? [y] : []
984
984
  ],
985
- layout(e) {
986
- let n = e.map(i), r = new Map(n.map((e, t) => [e, t]));
987
- S = t.spec.links.filter((e, n) => {
988
- let o = e[u], c = e[d];
989
- return (o === void 0 || c === void 0) && a("chart()", `link ${n} has no '${o === 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) => i(e) === o) || a("chart()", `link ${n}: ${u} ${s(o)} names no node`), t.spec.rows.some((e) => i(e) === c) || a("chart()", `link ${n}: ${d} ${s(c)} names no node`), r.has(o) && r.has(c);
985
+ layout(n) {
986
+ let r = n.map(i), a = new Map(r.map((e, t) => [e, t]));
987
+ S = e.spec.links.filter((n, r) => {
988
+ let o = n[u], s = n[f];
989
+ return (o === void 0 || s === void 0) && l("chart()", `link ${r} has no '${o === void 0 ? u : f}' - links name their ends with source: '${u}', target: '${f}' (set 'source' and 'target' to your field names)`), e.spec.rows.some((e) => i(e) === o) || l("chart()", `link ${r}: ${u} ${t(o)} names no node`), e.spec.rows.some((e) => i(e) === s) || l("chart()", `link ${r}: ${f} ${t(s)} names no node`), a.has(o) && a.has(s);
990
990
  });
991
- let o = N(e, n, S.map((e) => [r.get(e[u]), r.get(e[d])])), c = new Float32Array(e.length * 7);
992
- return e.forEach((e, n) => c.set([
991
+ let o = N(n, r, S.map((e) => [a.get(e[u]), a.get(e[f])])), s = new Float32Array(n.length * 7);
992
+ return n.forEach((t, n) => s.set([
993
993
  ...o[n],
994
- t.size ? t.size(t.spec.channels.size.get(e)) : .06 * Math.min(...t.box),
995
- ...t.rgb(e)
994
+ e.size ? e.size(e.spec.channels.size.get(t)) : .06 * Math.min(...e.box),
995
+ ...e.rgb(t)
996
996
  ], n * 7)), {
997
- rows: e,
998
- keys: n,
999
- state: c,
997
+ rows: n,
998
+ keys: r,
999
+ state: s,
1000
1000
  stride: 7,
1001
- shape: { pairs: S.map((e) => [e[u], e[d]]) }
1001
+ shape: { pairs: S.map((e) => [e[u], e[f]]) }
1002
1002
  };
1003
1003
  },
1004
1004
  apply(e, t) {
1005
- let n = e.length / t.stride;
1006
- if (C = t.rows, w !== null && !C.some((e) => i(e) === w) && (w = null, v.visible = !1), n > m.instanceMatrices.length / 16) {
1007
- let e = p(n * 2);
1008
- E && e.on("hover", D), m.parent?.add(e), m.parent?.remove(m), m.dispose(), T.nodes[T.nodes.indexOf(m)] = e, m = e;
1005
+ let r = e.length / t.stride;
1006
+ if (C = t.rows, w !== null && !C.some((e) => i(e) === w) && (w = null, v.visible = !1), r > g.instanceMatrices.length / 16) {
1007
+ let e = m(r * 2);
1008
+ E && e.on("hover", D), g.parent?.add(e), g.parent?.remove(g), g.dispose(), T.nodes[T.nodes.indexOf(g)] = e, g = e;
1009
1009
  }
1010
- m.count = n, m.data = t.rows;
1011
- let r = t.rows.map(i), a = new Map(r.map((e, t) => [e, t]));
1010
+ g.count = r, g.data = t.rows;
1011
+ let a = t.rows.map(i), s = new Map(a.map((e, t) => [e, t]));
1012
1012
  x = [];
1013
- for (let t = 0; t < n; t++) {
1013
+ for (let t = 0; t < r; t++) {
1014
1014
  let [n, r, i, a, o, s, c] = e.subarray(t * 7, t * 7 + 7);
1015
1015
  x.push([
1016
1016
  n,
1017
1017
  r,
1018
1018
  i
1019
- ]), m.setInstance(t, {
1019
+ ]), g.setInstance(t, {
1020
1020
  position: [
1021
1021
  n,
1022
1022
  r,
@@ -1030,26 +1030,26 @@ function fe(t) {
1030
1030
  ])
1031
1031
  });
1032
1032
  }
1033
- let o = de.map(() => ({
1033
+ let c = 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 = s.get(e[u]), r = s.get(e[f]);
1040
1040
  if (n === void 0 || r === void 0) return;
1041
- let i = o[A(e)], s = j(e);
1042
- i.positions.push(...x[n], ...x[r]), i.colors.push(...s, ...s), i.rows.push(e), c.flow && b.push({
1041
+ let i = c[A(e)], a = j(e);
1042
+ i.positions.push(...x[n], ...x[r]), i.colors.push(...a, ...a), i.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
- }), h.forEach((e, t) => {
1049
- let n = o[t];
1050
- e.geometry.dispose(), e.geometry = new l(n.positions.length ? {
1051
- positions: n.positions,
1052
- colors: n.colors
1048
+ }), _.forEach((e, t) => {
1049
+ let r = c[t];
1050
+ e.geometry.dispose(), e.geometry = new n(r.positions.length ? {
1051
+ positions: r.positions,
1052
+ colors: r.colors
1053
1053
  } : { positions: [
1054
1054
  0,
1055
1055
  0,
@@ -1057,7 +1057,7 @@ function fe(t) {
1057
1057
  0,
1058
1058
  0,
1059
1059
  0
1060
- ] }), e.visible = n.positions.length > 0, e.data = n.rows;
1060
+ ] }), e.visible = r.positions.length > 0, e.data = r.rows;
1061
1061
  }), w !== null && O(w);
1062
1062
  },
1063
1063
  enter(e) {
@@ -1070,68 +1070,68 @@ 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 l({ positions: t }));
1073
+ }), y.geometry.vertexCount === b.length ? (y.geometry.positions.set(t), y.geometry.needsUpdate()) : (y.geometry.dispose(), y.geometry = new n({ positions: t }));
1074
1074
  },
1075
1075
  tooltipRows(e) {
1076
- return h.includes(e.node) ? "link" : "node";
1076
+ return _.includes(e.node) ? "link" : "node";
1077
1077
  }
1078
1078
  }, E = (r.highlight ?? "neighbours") === "neighbours";
1079
- E && m.on("hover", D);
1080
- function D(e) {
1081
- let n = e && e.node === m && e.instance !== null ? i(C[e.instance]) : null;
1079
+ E && g.on("hover", D);
1080
+ function D(t) {
1081
+ let n = t && t.node === g && t.instance !== null ? i(C[t.instance]) : null;
1082
1082
  if (n !== w) {
1083
1083
  w = n, v.visible = n !== null, n !== null && O(n);
1084
- for (let e = 0; e < m.count; e++) m.setColor(e, k(e, t.rgb(C[e])));
1084
+ for (let t = 0; t < g.count; t++) g.setColor(t, k(t, e.rgb(C[t])));
1085
1085
  }
1086
1086
  }
1087
1087
  function O(e) {
1088
1088
  let t = [];
1089
1089
  for (let n of S) {
1090
- if (n[u] !== e && n[d] !== e) continue;
1091
- let r = C.findIndex((e) => i(e) === n[u]), a = C.findIndex((e) => i(e) === n[d]);
1090
+ if (n[u] !== e && n[f] !== e) continue;
1091
+ let r = C.findIndex((e) => i(e) === n[u]), a = C.findIndex((e) => i(e) === n[f]);
1092
1092
  r >= 0 && a >= 0 && t.push(...x[r], ...x[a]);
1093
1093
  }
1094
- v.geometry.dispose(), v.geometry = new l({ positions: t });
1094
+ v.geometry.dispose(), v.geometry = new n({ positions: t });
1095
1095
  }
1096
- function k(n, r) {
1097
- if (w === null || !E) return r;
1098
- let a = i(C[n]);
1099
- return a === w || S.some((e) => e[u] === w && e[d] === a || e[d] === w && e[u] === a) ? r : new e().setSRGB(r[0], r[1], r[2]).lerp(t.theme === "light" ? "#ffffff" : "#202024", .65).toSRGB();
1096
+ function k(t, n) {
1097
+ if (w === null || !E) return n;
1098
+ let r = i(C[t]);
1099
+ return r === w || S.some((e) => e[u] === w && e[f] === r || e[f] === w && e[u] === r) ? n : new c().setSRGB(n[0], n[1], n[2]).lerp(e.theme === "light" ? "#ffffff" : "#202024", .65).toSRGB();
1100
1100
  }
1101
- function A(e) {
1102
- let n = c.width;
1101
+ function A(t) {
1102
+ let n = o.width;
1103
1103
  if (!n) return 0;
1104
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));
1105
+ let r = e.spec.links.map((e) => Number(n.get(e)) || 0), i = Math.max(...r) || 1;
1106
+ return Math.min(2, Math.floor((Number(n.get(t)) || 0) / i * 2.999));
1107
1107
  }
1108
- function j(n) {
1109
- let r = c.color, i = t.theme === "light" ? "#9aa3b2" : "#4a5266";
1110
- return r ? r.field === null ? e.fromInput(r.value).toSRGB() : t.linkColor(r.get(n)).toSRGB() : e.fromInput(i).toSRGB();
1108
+ function j(t) {
1109
+ let n = o.color, r = e.theme === "light" ? "#9aa3b2" : "#4a5266";
1110
+ return n ? n.field === null ? c.fromInput(n.value).toSRGB() : e.linkColor(n.get(t)).toSRGB() : c.fromInput(r).toSRGB();
1111
1111
  }
1112
- function M(e) {
1113
- let n = c.flow;
1112
+ function M(t) {
1113
+ let n = o.flow;
1114
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;
1115
+ let r = Math.max(...e.spec.links.map((e) => Number(n.get(e)) || 0)) || 1;
1116
+ return .15 + .6 * (Number(n.get(t)) || 0) / r;
1117
1117
  }
1118
- function N(e, n, i) {
1119
- let [o, c, l] = t.box, u = r.layout ?? "force";
1118
+ function N(n, i, a) {
1119
+ let [o, s, c] = e.box, u = r.layout ?? "force";
1120
1120
  if (u === "given") {
1121
- let { x: n, y: r, z: i } = t.scales, a = t.spec.channels;
1122
- return e.map((e) => [
1123
- n && a.x ? n(a.x.get(e)) : 0,
1124
- r && a.y ? r(a.y.get(e)) : c / 2,
1121
+ let { x: t, y: r, z: i } = e.scales, a = e.spec.channels;
1122
+ return n.map((e) => [
1123
+ t && a.x ? t(a.x.get(e)) : 0,
1124
+ r && a.y ? r(a.y.get(e)) : s / 2,
1125
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(e, n, i, u, [
1128
+ if (u && typeof u == "object" && "tiers" in u) return pe(n, i, a, u, [
1129
1129
  o,
1130
- c,
1131
- l
1130
+ s,
1131
+ c
1132
1132
  ]);
1133
- u !== "force" && a("chart()", `layout ${s(u)} - expected 'force', 'given' or { tiers: 'field' }`);
1134
- let d = P(n, i), f = [
1133
+ u !== "force" && l("chart()", `layout ${t(u)} - expected 'force', 'given' or { tiers: 'field' }`);
1134
+ let d = P(i, a), f = [
1135
1135
  Infinity,
1136
1136
  Infinity,
1137
1137
  Infinity
@@ -1141,10 +1141,10 @@ 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(o, r.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(o, r.flat ? c : Math.min(s, c)) * .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
- r.flat ? 0 : (e[1] - g[1]) * h + c / 2,
1147
+ r.flat ? 0 : (e[1] - g[1]) * h + s / 2,
1148
1148
  (e[2] - g[2]) * h
1149
1149
  ]);
1150
1150
  }
@@ -1153,7 +1153,7 @@ function fe(t) {
1153
1153
  0,
1154
1154
  1,
1155
1155
  2
1156
- ], o = e.some((e) => f.has(e)), s = r.steps ?? (o ? 60 : 300), c = e.map(() => []);
1156
+ ], o = e.some((e) => p.has(e)), s = r.steps ?? (o ? 60 : 300), c = e.map(() => []);
1157
1157
  for (let [e, n] of t) c[e].push(n), c[n].push(e);
1158
1158
  let l = new Float32Array(n * n).fill(Infinity), u = 1;
1159
1159
  for (let e = 0; e < n; e++) {
@@ -1165,53 +1165,53 @@ function fe(t) {
1165
1165
  }
1166
1166
  }
1167
1167
  let d = e.map((t, a) => {
1168
- if (f.has(t)) return [...f.get(t)];
1169
- let o = c[a].find((t) => f.has(e[t])), s = o === void 0 ? [
1168
+ if (p.has(t)) return [...p.get(t)];
1169
+ let o = c[a].find((t) => p.has(e[t])), s = o === void 0 ? [
1170
1170
  0,
1171
1171
  0,
1172
1172
  0
1173
- ] : f.get(e[o]), l = o === void 0 ? Math.sqrt(n) : .5;
1173
+ ] : p.get(e[o]), l = o === void 0 ? Math.sqrt(n) : .5;
1174
1174
  return [
1175
1175
  s[0] + (i() - .5) * l,
1176
1176
  r.flat ? 0 : s[1] + (i() - .5) * l,
1177
1177
  s[2] + (i() - .5) * l
1178
1178
  ];
1179
- }), p = [
1179
+ }), f = [
1180
1180
  0,
1181
1181
  0,
1182
1182
  0
1183
1183
  ];
1184
1184
  for (let e = 0; e < s; e++) for (let e = 0; e < n; e++) {
1185
- p.fill(0);
1185
+ f.fill(0);
1186
1186
  let t = 0;
1187
1187
  for (let r = 0; r < n; r++) {
1188
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;
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], p = d[e][2] - d[r][2], m = Math.hypot(s, c, p) || 1e-6;
1190
+ f[0] += o * (d[r][0] + a * s / m), f[1] += o * (d[r][1] + a * c / m), f[2] += o * (d[r][2] + a * p / m), t += o;
1191
1191
  }
1192
- if (t) for (let n of a) d[e][n] = p[n] / t;
1192
+ if (t) for (let n of a) d[e][n] = f[n] / t;
1193
1193
  }
1194
- return f = new Map(e.map((e, t) => [e, d[t]])), d;
1194
+ return p = new Map(e.map((e, t) => [e, d[t]])), d;
1195
1195
  }
1196
1196
  return T;
1197
1197
  }
1198
- function pe(e, t, n, r, [i, o, s]) {
1199
- let c = r.tiers;
1198
+ function pe(e, t, n, r, [i, a, o]) {
1199
+ let s = r.tiers;
1200
1200
  if (!e.length) return [];
1201
- c in e[0] || a("chart()", `layout: { tiers: '${c}' } - '${c}' isn't a node field`);
1202
- let l = r.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(i, s) / 2 * .92;
1201
+ s in e[0] || l("chart()", `layout: { tiers: '${s}' } - '${s}' isn't a node field`);
1202
+ let c = r.order ?? [...new Set(e.map((e) => e[s]))], u = e.map((e) => Math.max(0, c.indexOf(e[s]))), d = Math.max(...u) + 1, f = Array(e.length).fill(0), p = Array(e.length), m = Math.min(i, o) / 2 * .92;
1203
1203
  for (let t = 0; t < d; t++) {
1204
1204
  let r = e.map((e, t) => t).filter((e) => u[e] === t), i = (e) => {
1205
1205
  let i = n.filter(([t, n]) => t === e || n === e).map(([t, n]) => t === e ? n : t).filter((e) => u[e] < t);
1206
1206
  return i.length ? i.reduce((e, t) => e + f[t], 0) / i.length : r.indexOf(e);
1207
1207
  };
1208
1208
  t > 0 && r.sort((e, t) => i(e) - i(t));
1209
- let a = r.length === 1 ? 0 : t === 0 ? m * .25 : m * (.35 + .65 * t / Math.max(1, d - 1));
1209
+ let o = r.length === 1 ? 0 : t === 0 ? m * .25 : m * (.35 + .65 * t / Math.max(1, d - 1));
1210
1210
  r.forEach((e, n) => {
1211
1211
  f[e] = (n + .5) / r.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
1212
+ Math.cos(f[e]) * o,
1213
+ a * (1 - t / Math.max(1, d - 1)),
1214
+ Math.sin(f[e]) * o
1215
1215
  ];
1216
1216
  });
1217
1217
  }
@@ -1219,7 +1219,7 @@ function pe(e, t, n, r, [i, o, s]) {
1219
1219
  }
1220
1220
  function me(e) {
1221
1221
  let t = e.spec.channels.key;
1222
- return t ? (e) => t.get(e) : (e.spec.rows.length && !("id" in e.spec.rows[0]) && a("chart()", "network nodes need an 'id' field, or key: 'yourIdField' - links name nodes by it"), (e) => e.id);
1222
+ return t ? (e) => t.get(e) : (e.spec.rows.length && !("id" in e.spec.rows[0]) && l("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 = [
@@ -1317,78 +1317,78 @@ var q = [
1317
1317
  stack: "stacking is the chart's option: stack: true"
1318
1318
  };
1319
1319
  function ye(e) {
1320
- (!e || typeof e != "object" || Array.isArray(e)) && a("chart()", `expected a spec such as { mark: 'bar', data, x, y }, got ${s(e)}`);
1321
- for (let t of Object.keys(e)) Y.includes(t) || a("chart()", `unknown option '${t}' - ${ge[t] ?? `expected ${Y.filter((e) => e[0] !== "$").join(", ")}${r(t, Y)}`}`);
1322
- typeof e.width == "number" && e.width > 1 && a("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 t = be(e.mark), { rows: n, links: i } = xe(e.data, t), o = Se(n), c = { ...e.encoding ?? {} };
1324
- for (let e of Object.keys(c)) !J.includes(e) && e !== "tooltip" && a("chart()", `encoding '${e}' isn't a channel we have - channels are ${J.join(", ")}, tooltip`);
1325
- let l = {};
1320
+ (!e || typeof e != "object" || Array.isArray(e)) && l("chart()", `expected a spec such as { mark: 'bar', data, x, y }, got ${t(e)}`);
1321
+ for (let t of Object.keys(e)) Y.includes(t) || l("chart()", `unknown option '${t}' - ${ge[t] ?? `expected ${Y.filter((e) => e[0] !== "$").join(", ")}${r(t, Y)}`}`);
1322
+ typeof e.width == "number" && e.width > 1 && l("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: a } = xe(e.data, n), o = Se(i), s = { ...e.encoding ?? {} };
1324
+ for (let e of Object.keys(s)) !J.includes(e) && e !== "tooltip" && l("chart()", `encoding '${e}' isn't a channel we have - channels are ${J.join(", ")}, tooltip`);
1325
+ let c = {};
1326
1326
  for (let t of J) {
1327
- let r = e[t] ?? c[t];
1328
- r != null && (l[t] = X(t, r, n, o));
1327
+ let n = e[t] ?? s[t];
1328
+ n != null && (c[t] = X(t, n, i, o));
1329
1329
  }
1330
- if (t === "network") for (let t of [
1330
+ if (n === "network") for (let t of [
1331
1331
  "x",
1332
1332
  "y",
1333
1333
  "z"
1334
- ]) l[t] && e.layout !== "given" && a("chart()", `${t} on a 'network' places its nodes - add layout: 'given' to use positions from the data`);
1335
- else for (let e of t === "surface" ? [
1334
+ ]) c[t] && e.layout !== "given" && l("chart()", `${t} 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[e] || a("chart()", `a '${t}' chart needs ${e} - e.g. ${e}: '${o[0] ?? "field"}'`), t !== "point" && l[e].field === null && a("chart()", `${e} on a '${t}' chart lays its marks out along a scale - it needs a field, not a constant value - e.g. ${e}: '${o[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, n, o), m = {};
1339
+ ] : ["x", "y"]) c[e] || l("chart()", `a '${n}' chart needs ${e} - e.g. ${e}: '${o[0] ?? "field"}'`), n !== "point" && c[e].field === null && l("chart()", `${e} on a '${n}' chart lays its marks out along a scale - it needs a field, not a constant value - e.g. ${e}: '${o[0] ?? "field"}'`);
1340
+ let u = e.tooltip ?? s.tooltip, d = typeof e.mark == "object" ? e.mark.tooltip : void 0, f = Ee(u ?? (d !== !1 && void 0), c, i, o), p = {};
1341
1341
  if (e.link !== void 0) {
1342
- t !== "network" && a("chart()", "'link' sets a network's link channels - it needs mark: 'network'");
1343
- let n = Se(i);
1344
- for (let [t, r] of Object.entries(e.link)) [
1342
+ n !== "network" && l("chart()", "'link' sets a network's link channels - it needs mark: 'network'");
1343
+ let t = Se(a);
1344
+ for (let [n, r] of Object.entries(e.link)) [
1345
1345
  "width",
1346
1346
  "color",
1347
1347
  "opacity",
1348
1348
  "flow",
1349
1349
  "tooltip"
1350
- ].includes(t) || a("chart()", `link has no '${t}' - link channels are width, color, opacity, flow, tooltip`), t !== "tooltip" && (m[t] = X(`link.${t}`, r, i, n));
1351
- e.link.tooltip !== void 0 && (m.tooltip = Ee(e.link.tooltip, {}, i, n));
1350
+ ].includes(n) || l("chart()", `link has no '${n}' - link channels are width, color, opacity, flow, tooltip`), n !== "tooltip" && (p[n] = X(`link.${n}`, r, a, t));
1351
+ e.link.tooltip !== void 0 && (p.tooltip = Ee(e.link.tooltip, {}, a, t));
1352
1352
  }
1353
- let h = {};
1353
+ let m = {};
1354
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(t) && e[t] !== void 0 && (h[t] = e[t]);
1361
- return h.steps !== void 0 && (!Number.isInteger(h.steps) || h.steps < 1) && a("chart()", `'steps' is how many steps the force layout takes, a whole number of 1 or more, got ${s(h.steps)}`), h.seed !== void 0 && d("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) || a("chart()", `'box' is the chart's size in the scene, [x, y, z] above 0, got ${s(h.box)}`), {
1362
- mark: t,
1363
- rows: n,
1364
- links: i,
1360
+ ].includes(t) && e[t] !== void 0 && (m[t] = e[t]);
1361
+ return m.steps !== void 0 && (!Number.isInteger(m.steps) || m.steps < 1) && l("chart()", `'steps' is how many steps the force layout takes, a whole number of 1 or more, got ${t(m.steps)}`), m.seed !== void 0 && g("chart()", "seed", m.seed), m.legend?.ticks !== void 0 && we("legend", m.legend.ticks), m.box === void 0 || Array.isArray(m.box) && m.box.length === 3 && m.box.every((e) => e > 0) || l("chart()", `'box' is the chart's size in the scene, [x, y, z] above 0, got ${t(m.box)}`), {
1362
+ mark: n,
1363
+ rows: i,
1364
+ links: a,
1365
1365
  fields: o,
1366
- channels: l,
1367
- tooltip: p,
1368
- link: m,
1369
- options: h
1366
+ channels: c,
1367
+ tooltip: f,
1368
+ link: p,
1369
+ options: m
1370
1370
  };
1371
1371
  }
1372
1372
  function be(e) {
1373
1373
  let t = e;
1374
1374
  if (t && typeof t == "object") {
1375
- for (let e of Object.keys(t)) e !== "type" && e !== "tooltip" && a("chart()", `mark option '${e}' isn't supported - use the chart's options (width, stack, ...) or style the chart's nodes`);
1375
+ for (let e of Object.keys(t)) e !== "type" && e !== "tooltip" && l("chart()", `mark option '${e}' isn't supported - use the chart's options (width, stack, ...) or style the chart's nodes`);
1376
1376
  t = t.type;
1377
1377
  }
1378
- if (typeof t != "string" && a("chart()", `'mark' is required: one of ${q.map((e) => `'${e}'`).join(", ")}`), !q.includes(t)) {
1378
+ if (typeof t != "string" && l("chart()", `'mark' is required: one of ${q.map((e) => `'${e}'`).join(", ")}`), !q.includes(t)) {
1379
1379
  let e = _e[t];
1380
- (t === "pie" || t === "arc" || t === "donut") && a("chart()", "pie and donut charts aren't supported - in 3D they distort values; use mark: 'bar'"), a("chart()", `mark '${t}' - ${e ? `use '${e}'` : `expected one of ${q.map((e) => `'${e}'`).join(", ")}${r(t, q)}`}`);
1380
+ (t === "pie" || t === "arc" || t === "donut") && l("chart()", "pie and donut charts aren't supported - in 3D they distort values; use mark: 'bar'"), l("chart()", `mark '${t}' - ${e ? `use '${e}'` : `expected one of ${q.map((e) => `'${e}'`).join(", ")}${r(t, q)}`}`);
1381
1381
  }
1382
1382
  return t;
1383
1383
  }
1384
- function xe(e, t) {
1385
- if (e && typeof e == "object" && !Array.isArray(e) && "url" in e && a("chart()", "data: { url } isn't loaded for you - fetch the rows and pass data: rows"), t === "network") return e && Array.isArray(e.nodes) && Array.isArray(e.links) || a("chart()", `a network's data is { nodes: [...], links: [...] }, got ${s(e)}`), {
1384
+ function xe(e, n) {
1385
+ if (e && typeof e == "object" && !Array.isArray(e) && "url" in e && l("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) || l("chart()", `a network's data is { nodes: [...], links: [...] }, got ${t(e)}`), {
1386
1386
  rows: e.nodes,
1387
1387
  links: e.links
1388
1388
  };
1389
- let n = Array.isArray(e) ? e : e && Array.isArray(e.values) ? e.values : null;
1390
- return n || a("chart()", `'data' must be an array of rows (objects), or { values: [...] }, got ${s(e)}`), n.some((e) => !e || typeof e != "object") && a("chart()", "every row in 'data' must be an object, such as { month: 'Jan', sales: 41 }"), {
1391
- rows: n,
1389
+ let r = Array.isArray(e) ? e : e && Array.isArray(e.values) ? e.values : null;
1390
+ return r || l("chart()", `'data' must be an array of rows (objects), or { values: [...] }, got ${t(e)}`), r.some((e) => !e || typeof e != "object") && l("chart()", "every row in 'data' must be an object, such as { month: 'Jan', sales: 41 }"), {
1391
+ rows: r,
1392
1392
  links: []
1393
1393
  };
1394
1394
  }
@@ -1401,53 +1401,53 @@ 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(e, t, n, i) {
1405
- let o = "chart()", c;
1406
- if (typeof t == "string") i.includes(t) ? c = { field: t } : /color|colour/.test(e) && Te(t) ? c = { value: t } : a(o, `${e}: field '${t}' isn't in the data - fields are ${i.join(", ") || "(none)"}${r(t, i)}`);
1407
- else if (typeof t == "number" && [
1404
+ function X(e, n, i, a) {
1405
+ let o = "chart()", s;
1406
+ if (typeof n == "string") a.includes(n) ? s = { field: n } : /color|colour/.test(e) && Te(n) ? s = { value: n } : l(o, `${e}: field '${n}' isn't in the data - fields are ${a.join(", ") || "(none)"}${r(n, a)}`);
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(e)) c = { value: t };
1414
- else if (t && typeof t == "object" && !Array.isArray(t)) {
1415
- c = t;
1416
- for (let t of Object.keys(c)) he.includes(t) || a(o, `${e}: '${t}' - ${ve[t] ?? `unknown; a channel takes ${he.join(", ")}`}`);
1417
- c.field !== void 0 && !i.includes(c.field) && a(o, `${e}: field '${c.field}' isn't in the data - fields are ${i.join(", ") || "(none)"}${r(String(c.field), i)}`), c.field === void 0 && c.value === void 0 && a(o, `${e} needs a field (or a constant value)`);
1418
- } else return e === "size" && Array.isArray(t) && a(o, "'size' is a channel - the chart's size in the scene is 'box: [x, y, z]'"), a(o, `${e} must be a field name or { field, ... }, got ${s(t)}`);
1419
- c.axis?.ticks !== void 0 && we(`${e}: axis`, c.axis.ticks);
1420
- let l = c.field ?? null, u = c.type ?? (l ? Ce(n, l) : "nominal");
1413
+ ].includes(e)) s = { value: n };
1414
+ else if (n && typeof n == "object" && !Array.isArray(n)) {
1415
+ s = n;
1416
+ for (let t of Object.keys(s)) he.includes(t) || l(o, `${e}: '${t}' - ${ve[t] ?? `unknown; a channel takes ${he.join(", ")}`}`);
1417
+ s.field !== void 0 && !a.includes(s.field) && l(o, `${e}: field '${s.field}' isn't in the data - fields are ${a.join(", ") || "(none)"}${r(String(s.field), a)}`), s.field === void 0 && s.value === void 0 && l(o, `${e} needs a field (or a constant value)`);
1418
+ } else return e === "size" && Array.isArray(n) && l(o, "'size' is a channel - the chart's size in the scene is 'box: [x, y, z]'"), l(o, `${e} must be a field name or { field, ... }, got ${t(n)}`);
1419
+ s.axis?.ticks !== void 0 && we(`${e}: axis`, s.axis.ticks);
1420
+ let c = s.field ?? null, u = s.type ?? (c ? Ce(i, c) : "nominal");
1421
1421
  [
1422
1422
  "quantitative",
1423
1423
  "nominal",
1424
1424
  "ordinal",
1425
1425
  "temporal"
1426
- ].includes(u) || a(o, `${e}: type '${u}' - expected 'quantitative', 'nominal', 'ordinal' or 'temporal'${r(String(u), [
1426
+ ].includes(u) || l(o, `${e}: type '${u}' - expected 'quantitative', 'nominal', 'ordinal' or 'temporal'${r(String(u), [
1427
1427
  "quantitative",
1428
1428
  "nominal",
1429
1429
  "ordinal",
1430
1430
  "temporal"
1431
1431
  ])}`);
1432
- let d = l === null ? () => c.value : u === "temporal" ? (e) => I(e[l]) : (e) => e[l];
1432
+ let d = c === null ? () => s.value : u === "temporal" ? (e) => I(e[c]) : (e) => e[c];
1433
1433
  return {
1434
- field: l,
1435
- value: c.value,
1434
+ field: c,
1435
+ value: s.value,
1436
1436
  type: u,
1437
- title: c.title ?? l ?? e,
1438
- format: c.format,
1439
- scale: c.scale ?? {},
1440
- axis: c.axis ?? {},
1437
+ title: s.title ?? c ?? e,
1438
+ format: s.format,
1439
+ scale: s.scale ?? {},
1440
+ axis: s.axis ?? {},
1441
1441
  get: d,
1442
- priority: c.priority
1442
+ priority: s.priority
1443
1443
  };
1444
1444
  }
1445
- function we(e, t) {
1446
- Array.isArray(t) || Number.isInteger(t) && t > 0 || a("chart()", `${e} ticks are a list of the values to mark, such as [0, 25, 50, 75, 100], or about how many, got ${s(t)}`);
1445
+ function we(e, n) {
1446
+ Array.isArray(n) || Number.isInteger(n) && n > 0 || l("chart()", `${e} ticks are a list of the values to mark, such as [0, 25, 50, 75, 100], or about how many, got ${t(n)}`);
1447
1447
  }
1448
- function Te(t) {
1448
+ function Te(e) {
1449
1449
  try {
1450
- return e.fromInput(t), !0;
1450
+ return c.fromInput(e), !0;
1451
1451
  } catch {
1452
1452
  return !1;
1453
1453
  }
@@ -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 = h.filter((e) => ![
1473
+ var ke = m.filter((e) => ![
1474
1474
  "children",
1475
1475
  "tooltip",
1476
1476
  "highlight"
@@ -1478,10 +1478,10 @@ var ke = h.filter((e) => ![
1478
1478
  function Ae(e) {
1479
1479
  return new Z(e);
1480
1480
  }
1481
- var Z = class t extends p {
1481
+ var Z = class e extends p {
1482
1482
  static type = "chart";
1483
1483
  static get OPTIONS() {
1484
- return h;
1484
+ return m;
1485
1485
  }
1486
1486
  scales = {};
1487
1487
  #e;
@@ -1497,10 +1497,10 @@ var Z = class t extends p {
1497
1497
  #u = null;
1498
1498
  #d = null;
1499
1499
  constructor(e) {
1500
- (!e || typeof e != "object" || Array.isArray(e)) && a("chart()", `expected a spec such as { mark: 'bar', data, x, y }, got ${s(e)}`);
1501
- let t = {}, n = {};
1502
- for (let [r, i] of Object.entries(e)) (ke.includes(r) ? t : n)[r] = i;
1503
- e.children && a("chart()", "a chart makes its own children - add other nodes to a Group beside it"), super(t), Oe(), this.#e = n, this.#i = {}, this.#f(!0), this.onUpdate((e, t) => this.#_(t));
1500
+ (!e || typeof e != "object" || Array.isArray(e)) && l("chart()", `expected a spec such as { mark: 'bar', data, x, y }, got ${t(e)}`);
1501
+ let n = {}, r = {};
1502
+ for (let [t, i] of Object.entries(e)) (ke.includes(t) ? n : r)[t] = i;
1503
+ e.children && l("chart()", "a chart makes its own children - add other nodes to a Group beside it"), super(n), Oe(), this.#e = r, this.#i = {}, this.#f(!0), this.onUpdate((e, t) => this.#_(t));
1504
1504
  }
1505
1505
  get spec() {
1506
1506
  let e = this.#t;
@@ -1527,7 +1527,7 @@ var Z = class t extends p {
1527
1527
  }, this.#f(!0), this;
1528
1528
  }
1529
1529
  filter(e) {
1530
- return e !== null && typeof e != "function" && a("Chart", `filter() takes (row) => boolean, or null, got ${s(e)}`), this.#c = e, this.#f(!0), this;
1530
+ return e !== null && typeof e != "function" && l("Chart", `filter() takes (row) => boolean, or null, got ${t(e)}`), this.#c = e, this.#f(!0), this;
1531
1531
  }
1532
1532
  explain() {
1533
1533
  let e = this.#t, t = [
@@ -1548,9 +1548,9 @@ var Z = class t extends p {
1548
1548
  return delete e.children, this.#e.highlight === void 0 && delete e.highlight, e;
1549
1549
  }
1550
1550
  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({
1551
+ 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
1552
  ...this.#e,
1553
- name: e,
1553
+ name: t,
1554
1554
  position: n,
1555
1555
  quaternion: r,
1556
1556
  scale: i,
@@ -1566,90 +1566,90 @@ var Z = class t extends p {
1566
1566
  });
1567
1567
  return m.userData = structuredClone(this.userData), m.matrixAutoUpdate = this.matrixAutoUpdate, m.matrixAutoUpdate || m.matrix.copy(this.matrix), m;
1568
1568
  }
1569
- #f(t) {
1570
- let n = ye(this.#e), r = n.options, i = n.channels;
1571
- this.#t = n;
1572
- let o = r.box ?? Ne(n), s = r.theme ?? "dark";
1573
- s !== "dark" && s !== "light" && a("chart()", `theme '${s}' - expected 'dark' or 'light'`);
1574
- let l = r.overlap ?? "dim";
1569
+ #f(e) {
1570
+ let t = ye(this.#e), n = t.options, r = t.channels;
1571
+ this.#t = t;
1572
+ let i = n.box ?? Ne(t), a = n.theme ?? "dark";
1573
+ a !== "dark" && a !== "light" && l("chart()", `theme '${a}' - expected 'dark' or 'light'`);
1574
+ let o = n.overlap ?? "dim";
1575
1575
  [
1576
1576
  "dim",
1577
1577
  "hide",
1578
1578
  "show"
1579
- ].includes(l) || a("chart()", `overlap '${l}' - expected 'dim', 'hide' or 'show'`);
1580
- let u = 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, o);
1582
- let d = this.scales.color, f = e.fromInput(i.color?.field ? L.category[0] : i.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;
1579
+ ].includes(o) || l("chart()", `overlap '${o}' - expected 'dim', 'hide' or 'show'`);
1580
+ let s = t.rows.filter((e) => (!this.#c || this.#c(e)) && (!r.color?.field || !this.#s.has(String(r.color.get(e)))));
1581
+ this.scales = Le(t, i);
1582
+ let u = this.scales.color, d = c.fromInput(r.color?.field ? L.category[0] : r.color?.value ?? L.category[0], "chart()").toSRGB(), f = t.link.color?.field ? Fe(t.link.color, t.links.map((e) => t.link.color.get(e))) : null;
1583
1583
  Object.assign(this.#i, {
1584
- spec: n,
1585
- box: o,
1586
- theme: s,
1587
- overlap: l,
1584
+ spec: t,
1585
+ box: i,
1586
+ theme: a,
1587
+ overlap: o,
1588
1588
  scales: this.scales,
1589
1589
  size: this.scales.size ?? null,
1590
- rgb: (e) => d ? d(Ie(n, e)).toSRGB() : f,
1590
+ rgb: (e) => u ? u(Ie(t, e)).toSRGB() : d,
1591
1591
  format: $,
1592
- linkColor: (e) => p(e)
1592
+ linkColor: (e) => f(e)
1593
1593
  });
1594
- let m = JSON.stringify([
1595
- n.mark,
1596
- Object.entries(i).map(([e, t]) => [
1594
+ let p = JSON.stringify([
1595
+ t.mark,
1596
+ Object.entries(r).map(([e, t]) => [
1597
1597
  e,
1598
1598
  t.field,
1599
1599
  t.type
1600
1600
  ]),
1601
+ i,
1602
+ a,
1601
1603
  o,
1602
- s,
1603
- l,
1604
- r.stack,
1605
- r.layout,
1606
- r.flat,
1607
- Object.keys(n.link)
1604
+ n.stack,
1605
+ n.layout,
1606
+ n.flat,
1607
+ Object.keys(t.link)
1608
1608
  ]);
1609
- if (m !== this.#r) {
1610
- this.#r = m, this.#n && this.remove(...this.#n.nodes), this.#n = Me(n.mark, this.#i);
1609
+ if (p !== this.#r) {
1610
+ this.#r = p, this.#n && this.remove(...this.#n.nodes), this.#n = Me(t.mark, this.#i);
1611
1611
  for (let e of this.#n.nodes) this.add(e);
1612
1612
  this.#l = this.#u = null, this.#d = null;
1613
1613
  }
1614
- this.#a && this.remove(this.#a), this.#a = n.mark === "network" && r.layout !== "given" ? null : this.add(S({
1615
- box: o,
1616
- theme: s,
1617
- overlap: l,
1618
- axes: ze(n, this.scales)
1619
- })), this.#o && this.remove(this.#o), this.#o = r.title ? this.add(new c({
1620
- text: String(r.title),
1614
+ this.#a && this.remove(this.#a), this.#a = t.mark === "network" && n.layout !== "given" ? null : this.add(S({
1615
+ box: i,
1616
+ theme: a,
1617
+ overlap: o,
1618
+ axes: ze(t, this.scales)
1619
+ })), this.#o && this.remove(this.#o), this.#o = n.title ? this.add(new _({
1620
+ text: String(n.title),
1621
1621
  position: [
1622
1622
  0,
1623
- o[1] * 1.12,
1624
- -o[2] / 2
1623
+ i[1] * 1.12,
1624
+ -i[2] / 2
1625
1625
  ],
1626
- className: `phoria-axis-title phoria-${s}`,
1626
+ className: `phoria-axis-title phoria-${a}`,
1627
1627
  overlap: "show"
1628
- })) : null, this.#p(n, s), this.tooltip = n.tooltip === null && !n.link.tooltip ? null : (e) => this.#m(e);
1629
- let h = r.highlight;
1630
- this.highlight = h === !1 ? null : e.fromInput(h === void 0 || h === "neighbours" || h === "node" ? "#ffffff" : h, "chart()"), this.#h(this.#n.layout(u), t && r.transition !== !1);
1628
+ })) : null, this.#p(t, a), this.tooltip = t.tooltip === null && !t.link.tooltip ? null : (e) => this.#m(e);
1629
+ let m = n.highlight;
1630
+ this.highlight = m === !1 ? null : c.fromInput(m === void 0 || m === "neighbours" || m === "node" ? "#ffffff" : m, "chart()"), this.#h(this.#n.layout(s), e && n.transition !== !1);
1631
1631
  }
1632
- #p(e, t) {
1632
+ #p(e, n) {
1633
1633
  this.overlay?.remove(), this.overlay = null;
1634
- let n = e.channels.color, r = e.options.legend;
1635
- if (!n?.field || r === !1 || !this.scales.color || typeof document > "u") return;
1636
- let i = ie(this.scales.color, {
1637
- title: n.title,
1638
- theme: t,
1639
- position: r?.position,
1640
- ticks: r?.ticks,
1641
- format: (e) => $(n, e),
1634
+ let r = e.channels.color, i = e.options.legend;
1635
+ if (!r?.field || i === !1 || !this.scales.color || typeof document > "u") return;
1636
+ let a = ie(this.scales.color, {
1637
+ title: r.title,
1638
+ theme: n,
1639
+ position: i?.position,
1640
+ ticks: i?.ticks,
1641
+ format: (e) => $(r, e),
1642
1642
  onToggle: (e, t) => {
1643
1643
  t ? this.#s.delete(String(e)) : this.#s.add(String(e)), this.#f(!0);
1644
1644
  }
1645
1645
  });
1646
- i.querySelectorAll(".phoria-legend-item").forEach((e, t) => {
1646
+ a.querySelectorAll(".phoria-legend-item").forEach((e, t) => {
1647
1647
  this.#s.has(String(this.scales.color?.domain[t])) && e.classList.add("off");
1648
1648
  });
1649
- let o = r?.container;
1649
+ let o = i?.container;
1650
1650
  if (o) {
1651
1651
  let e = typeof o == "string" ? document.querySelector(o) : o;
1652
- e || a("chart()", `legend container ${s(o)} not found`), i.classList.remove(`phoria-legend-${r?.position ?? "top-right"}`), Object.assign(i.style, {
1652
+ e || l("chart()", `legend container ${t(o)} not found`), a.classList.remove(`phoria-legend-${i?.position ?? "top-right"}`), Object.assign(a.style, {
1653
1653
  position: "static",
1654
1654
  flexDirection: "row",
1655
1655
  flexWrap: "wrap",
@@ -1657,8 +1657,8 @@ var Z = class t extends p {
1657
1657
  columnGap: "12px",
1658
1658
  maxHeight: "none",
1659
1659
  overflow: "visible"
1660
- }), e.replaceChildren(i);
1661
- } else this.overlay = i;
1660
+ }), e.replaceChildren(a);
1661
+ } else this.overlay = a;
1662
1662
  }
1663
1663
  #m(e) {
1664
1664
  let t = this.#t, n = e.datum;
@@ -1717,10 +1717,10 @@ var Z = class t extends p {
1717
1717
  this.#n?.tick?.(e);
1718
1718
  let t = this.#d;
1719
1719
  if (!t) return;
1720
- let n = this.#e.transition ?? {}, r = n.duration ?? .5, i = u[n.ease ?? "out"];
1721
- i || a("chart()", `transition ease '${n.ease}' - expected ${Object.keys(u).map((e) => `'${e}'`).join(", ")}`), t.t = Math.min(1, t.t + e / r);
1722
- let o = i(t.t), s = new Float32Array(t.from.length);
1723
- for (let e = 0; e < s.length; e++) s[e] = t.from[e] + (t.to[e] - t.from[e]) * o;
1720
+ let n = this.#e.transition ?? {}, r = n.duration ?? .5, i = o[n.ease ?? "out"];
1721
+ i || l("chart()", `transition ease '${n.ease}' - expected ${Object.keys(o).map((e) => `'${e}'`).join(", ")}`), t.t = Math.min(1, t.t + e / r);
1722
+ let a = i(t.t), s = new Float32Array(t.from.length);
1723
+ for (let e = 0; e < s.length; e++) s[e] = t.from[e] + (t.to[e] - t.from[e]) * a;
1724
1724
  if (t.t < 1) return this.#g(s, t.frame, t.frame);
1725
1725
  this.#d = null, this.#g(t.final.state, t.final, t.final);
1726
1726
  }