@lilt-ui/charts 0.12.2 → 0.13.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 (72) hide show
  1. package/CHANGELOG.md +282 -270
  2. package/README.md +0 -45
  3. package/dist/cards/arc-bridges-card.d.ts +17 -0
  4. package/dist/cards/area-chart-card.d.ts +1 -10
  5. package/dist/cards/block-city-card.d.ts +21 -0
  6. package/dist/cards/calendar-heatmap-card.d.ts +31 -1
  7. package/dist/cards/cartesian-card.d.ts +8 -26
  8. package/dist/cards/chart-card.d.ts +1 -12
  9. package/dist/cards/chord-loom-card.d.ts +17 -0
  10. package/dist/cards/circle-archipelago-card.d.ts +9 -0
  11. package/dist/cards/cluster-constellation-card.d.ts +16 -0
  12. package/dist/cards/comparison-forms.d.ts +30 -0
  13. package/dist/cards/composition-forms.d.ts +10 -0
  14. package/dist/cards/contour-islands-card.d.ts +25 -0
  15. package/dist/cards/density-contours.d.ts +3 -0
  16. package/dist/cards/distribution-forms.d.ts +37 -0
  17. package/dist/cards/event-helix-card.d.ts +26 -0
  18. package/dist/cards/helix-ribbons-card.d.ts +14 -0
  19. package/dist/cards/hex-city-card.d.ts +25 -0
  20. package/dist/cards/hierarchy-layouts.d.ts +21 -0
  21. package/dist/cards/horizon-folds-card.d.ts +10 -0
  22. package/dist/cards/horizontal-bar-chart-card.d.ts +1 -1
  23. package/dist/cards/intersection-towers-card.d.ts +9 -0
  24. package/dist/cards/line-chart-card.d.ts +4 -11
  25. package/dist/cards/link-readings.d.ts +26 -0
  26. package/dist/cards/marimekko-blocks-card.d.ts +10 -0
  27. package/dist/cards/observations-card.d.ts +45 -2
  28. package/dist/cards/parallel-ribbons-card.d.ts +27 -0
  29. package/dist/cards/prism-grid.d.ts +58 -0
  30. package/dist/cards/prism.d.ts +42 -0
  31. package/dist/cards/progress-forms.d.ts +21 -0
  32. package/dist/cards/rank-ribbons-card.d.ts +22 -0
  33. package/dist/cards/ridgeline-card.d.ts +24 -0
  34. package/dist/cards/scatter-chart-card.d.ts +19 -1
  35. package/dist/cards/sculpted-geometry.d.ts +18 -0
  36. package/dist/cards/skyline-card.d.ts +12 -0
  37. package/dist/cards/spatial-composition-layouts.d.ts +14 -0
  38. package/dist/cards/spatial-geometry.d.ts +34 -0
  39. package/dist/cards/spatial-hierarchy.d.ts +10 -0
  40. package/dist/cards/spatial-point-layouts.d.ts +16 -0
  41. package/dist/cards/spatial-series-layouts.d.ts +12 -0
  42. package/dist/cards/spiral-year-card.d.ts +17 -0
  43. package/dist/cards/sunburst-terraces-card.d.ts +10 -0
  44. package/dist/cards/ternary-prism-card.d.ts +13 -0
  45. package/dist/cards/terrain-card.d.ts +21 -0
  46. package/dist/cards/treemap-chart-card.d.ts +3 -1
  47. package/dist/cards/trend-forms.d.ts +11 -0
  48. package/dist/cards/voxel-cloud-card.d.ts +16 -0
  49. package/dist/cards/voxel-waffle-card.d.ts +18 -0
  50. package/dist/cards/wind-rose-card.d.ts +11 -0
  51. package/dist/engine/domains.d.ts +0 -1
  52. package/dist/finance.js +310 -311
  53. package/dist/index.d.ts +39 -4
  54. package/dist/index.js +8919 -2948
  55. package/dist/{skeleton-block-DIgcA9t6.js → skeleton-block-BPoUJvcR.js} +3596 -2971
  56. package/dist/styles.css +1 -1
  57. package/package.json +80 -85
  58. package/dist/report-context-CIUa6iiD.js +0 -1101
  59. package/dist/watch/board/board-state.d.ts +0 -72
  60. package/dist/watch/board/board-toast.d.ts +0 -19
  61. package/dist/watch/board/chart-board.d.ts +0 -93
  62. package/dist/watch/board/report-context.d.ts +0 -3
  63. package/dist/watch/engine/describe.d.ts +0 -9
  64. package/dist/watch/engine/explain.d.ts +0 -48
  65. package/dist/watch/engine/normal.d.ts +0 -114
  66. package/dist/watch/engine/robust.d.ts +0 -7
  67. package/dist/watch/engine/rules.d.ts +0 -22
  68. package/dist/watch/engine/status.d.ts +0 -39
  69. package/dist/watch/index.d.ts +0 -14
  70. package/dist/watch/normal-layer.d.ts +0 -18
  71. package/dist/watch.d.ts +0 -2
  72. package/dist/watch.js +0 -636
@@ -1,1101 +0,0 @@
1
- import { createContext as e, useContext as t, useEffect as n, useId as r, useLayoutEffect as i, useMemo as a, useRef as o, useState as s } from "react";
2
- import { AnimatePresence as c, LazyMotion as l, animate as u, domAnimation as d, m as f, useMotionValue as p, useMotionValueEvent as m, useReducedMotion as h, useTransform as g } from "motion/react";
3
- import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
4
- import { extent as b, min as x } from "d3-array";
5
- import { animate as S } from "motion";
6
- import C from "@number-flow/react";
7
- //#region src/motion/motion-scope.tsx
8
- var w, T;
9
- function E() {
10
- return T ??= import("./motion-layout-features-CJq3xh5t.js").then((e) => (w = e.domMax, e.domMax)), T;
11
- }
12
- function D({ children: e, layout: t = !1 }) {
13
- let [r, i] = s(w);
14
- return n(() => {
15
- if (!t || r) return;
16
- let e = !0;
17
- return E().then((t) => {
18
- e && i(t);
19
- }), () => {
20
- e = !1;
21
- };
22
- }, [t, r]), /* @__PURE__ */ v(l, {
23
- features: t && r ? r : d,
24
- children: e
25
- });
26
- }
27
- //#endregion
28
- //#region src/motion/use-chart-motion.ts
29
- var O = [
30
- .22,
31
- 1,
32
- .36,
33
- 1
34
- ];
35
- function k(e) {
36
- let [t, r] = s(!1);
37
- return n(() => {
38
- if (typeof window > "u" || !window.matchMedia) return;
39
- let e = window.matchMedia("(prefers-reduced-motion: reduce)"), t = () => r(e.matches);
40
- return t(), e.addEventListener?.("change", t), () => e.removeEventListener?.("change", t);
41
- }, []), e === "none" || t;
42
- }
43
- function ee(e, t) {
44
- let [n, r] = s(e.active ? +!!t : 1), a = o(e.key), c = e.active && e.key !== a.current;
45
- return i(() => {
46
- if (a.current = e.key, !e.active || t) {
47
- r(1);
48
- return;
49
- }
50
- r(0);
51
- let n = S(0, 1, {
52
- ...e.spring ? {
53
- type: "spring",
54
- duration: e.duration / 1e3,
55
- bounce: .18
56
- } : {
57
- duration: e.duration / 1e3,
58
- ease: O
59
- },
60
- onUpdate: (e) => r(e),
61
- onComplete: () => r(1)
62
- });
63
- return () => n.stop();
64
- }, [
65
- t,
66
- e.active,
67
- e.duration,
68
- e.key,
69
- e.spring
70
- ]), t ? 1 : c ? 0 : Math.max(0, e.spring ? n : Math.min(1, n));
71
- }
72
- //#endregion
73
- //#region src/interaction/pin-glyphs.tsx
74
- var A = "M9 4.5h6l-1 5 3 3v2H7v-2l3-3-1-5ZM12 14.5v7";
75
- function j({ release: e }) {
76
- return /* @__PURE__ */ v("svg", {
77
- className: e ? "lilt-chart__pin-glyph lilt-chart__pin-glyph--release" : "lilt-chart__pin-glyph",
78
- viewBox: "0 0 24 24",
79
- fill: "none",
80
- "aria-hidden": "true",
81
- children: /* @__PURE__ */ v("path", {
82
- d: e ? `${A}M4.5 5.5l15 15` : A,
83
- stroke: "currentColor",
84
- strokeLinecap: "round",
85
- strokeLinejoin: "round",
86
- strokeWidth: "1.8"
87
- })
88
- });
89
- }
90
- function te({ release: e = !1 }) {
91
- return /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v(j, {}), e ? /* @__PURE__ */ v(j, { release: !0 }) : null] });
92
- }
93
- //#endregion
94
- //#region src/motion/number-format.ts
95
- var M = /* @__PURE__ */ new WeakMap();
96
- function ne(e) {
97
- let t = (t) => e.format(t);
98
- return M.set(t, e), t;
99
- }
100
- function re(e) {
101
- return e instanceof Intl.NumberFormat ? e : M.get(e);
102
- }
103
- //#endregion
104
- //#region src/motion/animated-number.tsx
105
- var N = /\p{Decimal_Number}/u, P = /* @__PURE__ */ new Set([
106
- "integer",
107
- "group",
108
- "decimal",
109
- "fraction",
110
- "nan",
111
- "infinity"
112
- ]);
113
- function ie(e, t) {
114
- let n = [];
115
- if (t?.length && t.map((e) => e.value).join("") === e) {
116
- let e = t.findIndex((e) => P.has(e.type)), r = t.length - 1 - [...t].reverse().findIndex((e) => P.has(e.type)), i = t.filter((e) => e.type === "integer").reduce((e, t) => e + Array.from(t.value).length, 0), a = 0, o = /* @__PURE__ */ new Map();
117
- t.forEach((t, s) => {
118
- let c = e < 0 || s < e ? "prefix" : s > r ? "suffix" : "number";
119
- for (let e of Array.from(t.value)) {
120
- let r;
121
- if (t.type === "integer") r = `i${--i}`;
122
- else if (t.type === "group") r = `g${i}`;
123
- else if (t.type === "decimal") r = "dec";
124
- else if (t.type === "fraction") r = `f${a++}`;
125
- else {
126
- let e = `${c}-${t.type}`, n = o.get(e) ?? 0;
127
- o.set(e, n + 1), r = `${e}-${n}`;
128
- }
129
- n.push({
130
- key: r,
131
- char: e,
132
- digit: N.test(e),
133
- role: c
134
- });
135
- }
136
- });
137
- } else {
138
- let t = Array.from(e), r = t.findIndex((e) => N.test(e)), i = t.length - 1 - [...t].reverse().findIndex((e) => N.test(e));
139
- t.forEach((e, a) => {
140
- let o = N.test(e);
141
- r < 0 || a < r ? n.push({
142
- key: `prefix-${a}`,
143
- char: e,
144
- digit: o,
145
- role: "prefix"
146
- }) : a > i ? n.push({
147
- key: `suffix-${t.length - 1 - a}`,
148
- char: e,
149
- digit: o,
150
- role: "suffix"
151
- }) : n.push({
152
- key: `n${i - a}${o ? "d" : "s"}`,
153
- char: e,
154
- digit: o,
155
- role: "number"
156
- });
157
- });
158
- }
159
- return n.map((e, t) => ({
160
- ...e,
161
- place: n.length - 1 - t
162
- }));
163
- }
164
- function ae(e, t) {
165
- let [n, r] = String(t).toLowerCase().split("e"), i = n.split(".")[1]?.length ?? 0, a = Number(r ?? 0), o = Math.min(10, Math.max(0, i - a)), s = Number(e.toFixed(o));
166
- return Object.is(s, -0) ? 0 : s;
167
- }
168
- function oe(e, t, n) {
169
- let r = ((t - e) % 10 + 10) % 10;
170
- return r === 0 ? e : n > 0 ? e + r : e - (10 - r);
171
- }
172
- var se = 240, F = .16, I = {
173
- duration: .1,
174
- ease: "easeOut"
175
- }, L = [
176
- .16,
177
- 1,
178
- .3,
179
- 1
180
- ], ce = {
181
- type: "spring",
182
- stiffness: 420,
183
- damping: 34,
184
- mass: .7
185
- }, R = (e) => Math.min(e, 6) * .024;
186
- function z({ cell: e, change: t, style: n }) {
187
- let r = n === "slide" ? .72 : 0;
188
- return /* @__PURE__ */ v("span", {
189
- className: "lilt-number__cell",
190
- "data-digit": e.digit || void 0,
191
- children: /* @__PURE__ */ v(c, {
192
- initial: !1,
193
- custom: t,
194
- children: /* @__PURE__ */ v(f.span, {
195
- className: "lilt-number__glyph",
196
- custom: t,
197
- variants: {
198
- enter: ({ direction: e, live: t }) => t ? {
199
- y: `${e * r * 55}%`,
200
- opacity: .35,
201
- scale: 1,
202
- filter: "blur(0px)"
203
- } : {
204
- y: `${e * r * 100}%`,
205
- opacity: 0,
206
- scale: n === "fade" ? 1.06 : .96,
207
- filter: `blur(${n === "fade" ? 1.5 : 2.5}px)`
208
- },
209
- rest: {
210
- y: "0%",
211
- opacity: 1,
212
- scale: 1,
213
- filter: "blur(0px)"
214
- },
215
- leave: ({ direction: e, live: t }) => t ? {
216
- y: `${-e * r * 55}%`,
217
- opacity: 0,
218
- transition: I
219
- } : {
220
- y: `${-e * r * 100}%`,
221
- opacity: 0,
222
- scale: n === "fade" ? .94 : .96,
223
- filter: `blur(${n === "fade" ? 1.5 : 2.5}px)`
224
- }
225
- },
226
- initial: "enter",
227
- animate: "rest",
228
- exit: "leave",
229
- transition: t.live ? {
230
- duration: F,
231
- ease: L
232
- } : {
233
- delay: R(e.place),
234
- y: ce,
235
- default: {
236
- duration: .26,
237
- ease: L
238
- }
239
- },
240
- children: e.char
241
- }, e.char)
242
- })
243
- });
244
- }
245
- var B = Array.from({ length: 30 }, (e, t) => String(t % 10));
246
- function le({ cell: e, change: t }) {
247
- let r = Number(e.char), i = p(10 + r), a = o(t);
248
- a.current = t, n(() => {
249
- let t = i.get();
250
- (t < 5 || t >= 25) && (t = 10 + (t % 10 + 10) % 10, i.jump(t));
251
- let { direction: n, live: o } = a.current, s = oe(t, r, n);
252
- if (s === t) return;
253
- let c = u(i, s, {
254
- type: "spring",
255
- stiffness: o ? 320 : 190,
256
- damping: o ? 32 : 26,
257
- mass: .9,
258
- delay: o ? 0 : R(e.place),
259
- onComplete: () => i.jump(10 + r)
260
- });
261
- return () => c.stop();
262
- }, [
263
- e.place,
264
- r,
265
- i
266
- ]);
267
- let s = g(i, (e) => `${-e / B.length * 100}%`);
268
- return /* @__PURE__ */ y("span", {
269
- className: "lilt-number__cell lilt-number__cell--reel",
270
- "data-digit": !0,
271
- children: [/* @__PURE__ */ v("span", {
272
- className: "lilt-number__glyph lilt-number__sizer",
273
- "aria-hidden": "true",
274
- children: e.char
275
- }), /* @__PURE__ */ v(f.span, {
276
- className: "lilt-number__reel",
277
- style: { y: s },
278
- children: B.map((e, t) => /* @__PURE__ */ v("span", { children: e }, t))
279
- })]
280
- });
281
- }
282
- var ue = "0123456789";
283
- function de({ cell: e, live: t }) {
284
- let [r, i] = s(null), a = o(e.char), c = o(t);
285
- return c.current = t, n(() => {
286
- if (a.current === e.char) return;
287
- a.current = e.char;
288
- let t = 0, n = c.current ? 2 : 5 + Math.min(e.place, 6), r = window.setInterval(() => {
289
- t += 1, i(t >= n ? null : ue[Math.floor(Math.random() * 10)]), t >= n && window.clearInterval(r);
290
- }, 36);
291
- return () => {
292
- window.clearInterval(r), i(null);
293
- };
294
- }, [e.char, e.place]), /* @__PURE__ */ v("span", {
295
- className: "lilt-number__cell",
296
- "data-digit": e.digit || void 0,
297
- "data-scrambling": r !== null || void 0,
298
- children: /* @__PURE__ */ v("span", {
299
- className: "lilt-number__glyph",
300
- children: r ?? e.char
301
- })
302
- });
303
- }
304
- function V({ cell: e }) {
305
- return /* @__PURE__ */ v("span", {
306
- className: "lilt-number__cell",
307
- "data-digit": e.digit || void 0,
308
- children: /* @__PURE__ */ v("span", {
309
- className: "lilt-number__glyph",
310
- children: e.char
311
- })
312
- });
313
- }
314
- var H = [
315
- .34,
316
- 1.45,
317
- .64,
318
- 1
319
- ], fe = {
320
- enter: (e) => e ? {
321
- y: "16%",
322
- opacity: .4,
323
- filter: "blur(0px)"
324
- } : {
325
- y: "32%",
326
- opacity: 0,
327
- filter: "blur(2px)"
328
- },
329
- visible: {
330
- y: "0%",
331
- opacity: 1,
332
- filter: "blur(0px)"
333
- }
334
- }, pe = { leave: (e) => e ? {
335
- y: "-16%",
336
- opacity: 0,
337
- transition: I
338
- } : {
339
- y: "-32%",
340
- opacity: 0,
341
- filter: "blur(2px)",
342
- transition: {
343
- duration: .3,
344
- ease: L
345
- }
346
- } };
347
- function me({ cells: e, live: t }) {
348
- let n = e.map((e) => e.char).join("");
349
- return /* @__PURE__ */ v("span", {
350
- className: "lilt-number__pop-host",
351
- children: /* @__PURE__ */ v(c, {
352
- mode: "popLayout",
353
- initial: !1,
354
- custom: t,
355
- children: /* @__PURE__ */ v(f.span, {
356
- className: "lilt-number__pop",
357
- variants: pe,
358
- initial: "enter",
359
- animate: "visible",
360
- exit: "leave",
361
- children: e.map((e, n) => /* @__PURE__ */ v(f.span, {
362
- className: "lilt-number__pop-char",
363
- custom: t,
364
- variants: fe,
365
- transition: t ? {
366
- duration: .22,
367
- ease: H
368
- } : {
369
- duration: .5,
370
- delay: Math.min(n, 2) * .07,
371
- ease: H
372
- },
373
- children: e.char
374
- }, n))
375
- }, n)
376
- })
377
- });
378
- }
379
- function he(e, t, r) {
380
- let i = p(e), a = o(r);
381
- a.current = r;
382
- let [c, l] = s(e);
383
- return m(i, "change", l), n(() => {
384
- if (!t) {
385
- i.jump(e);
386
- return;
387
- }
388
- let n = u(i, e, {
389
- duration: a.current ? .24 : .62,
390
- ease: L
391
- });
392
- return () => n.stop();
393
- }, [
394
- t,
395
- i,
396
- e
397
- ]), t ? ae(c, e) : e;
398
- }
399
- function ge(e) {
400
- let [t, n] = s({
401
- value: e,
402
- at: 0,
403
- direction: 1,
404
- live: !1
405
- });
406
- if (t.value !== e) {
407
- let r = Date.now();
408
- n({
409
- value: e,
410
- at: r,
411
- direction: e >= t.value ? 1 : -1,
412
- live: r - t.at < se
413
- });
414
- }
415
- return {
416
- direction: t.direction,
417
- live: t.live
418
- };
419
- }
420
- function _e({ value: e, format: t = String, className: n, motion: r = "auto", variant: i = "count" }) {
421
- let o = !h() && r !== "none", s = re(t), l = (e) => t instanceof Intl.NumberFormat ? t.format(e) : t(e), u = (e) => ie(l(e), s?.formatToParts(e)), d = i === "flow" && !s ? "slide" : i, p = a(() => {
422
- if (!s) return;
423
- let { locale: e, ...t } = s.resolvedOptions();
424
- return {
425
- locale: e,
426
- options: t
427
- };
428
- }, [s]), m = l(e), g = ge(e), b = he(e, o && d === "count", g.live), x = ["lilt-number", n].filter(Boolean).join(" ");
429
- if (d === "flow" && p) return /* @__PURE__ */ y("span", {
430
- className: x,
431
- "data-variant": "flow",
432
- children: [/* @__PURE__ */ v("span", {
433
- className: "lilt-chart__sr-only",
434
- children: m
435
- }), /* @__PURE__ */ v("span", {
436
- "aria-hidden": "true",
437
- className: "lilt-number__flow",
438
- children: /* @__PURE__ */ v(C, {
439
- value: e,
440
- locales: p.locale,
441
- format: p.options,
442
- animated: o,
443
- willChange: !0
444
- })
445
- })]
446
- });
447
- let S = u(d === "count" ? b : e), w = (e) => o ? e.role === "number" ? d === "count" ? /* @__PURE__ */ v(V, { cell: e }) : d === "roll" ? /[0-9]/.test(e.char) ? /* @__PURE__ */ v(le, {
448
- cell: e,
449
- change: g
450
- }) : /* @__PURE__ */ v(z, {
451
- cell: e,
452
- change: g,
453
- style: "fade"
454
- }) : d === "scramble" ? /[0-9]/.test(e.char) ? /* @__PURE__ */ v(de, {
455
- cell: e,
456
- live: g.live
457
- }) : /* @__PURE__ */ v(z, {
458
- cell: e,
459
- change: g,
460
- style: "fade"
461
- }) : /* @__PURE__ */ v(z, {
462
- cell: e,
463
- change: g,
464
- style: "slide"
465
- }) : /* @__PURE__ */ v(z, {
466
- cell: e,
467
- change: g,
468
- style: "fade"
469
- }) : /* @__PURE__ */ v(V, { cell: e }), T = (e) => /* @__PURE__ */ v(f.span, {
470
- className: "lilt-number__place",
471
- custom: g.live,
472
- initial: o ? {
473
- width: 0,
474
- opacity: 0
475
- } : !1,
476
- animate: {
477
- width: "auto",
478
- opacity: 1
479
- },
480
- exit: o ? {
481
- width: 0,
482
- opacity: 0
483
- } : void 0,
484
- transition: {
485
- duration: g.live ? F : .32,
486
- ease: L
487
- },
488
- children: w(e)
489
- }, e.key), E = d === "pop" && o, D = S.filter((e) => e.role === "prefix"), O = S.filter((e) => e.role === "number"), k = S.filter((e) => e.role === "suffix");
490
- return /* @__PURE__ */ y("span", {
491
- className: x,
492
- "data-variant": i,
493
- children: [/* @__PURE__ */ v("span", {
494
- className: "lilt-chart__sr-only",
495
- children: m
496
- }), /* @__PURE__ */ v("span", {
497
- "aria-hidden": "true",
498
- className: "lilt-number__characters",
499
- children: E ? /* @__PURE__ */ y(_, { children: [
500
- /* @__PURE__ */ v(c, {
501
- initial: !1,
502
- children: D.map(T)
503
- }),
504
- /* @__PURE__ */ v(me, {
505
- cells: O,
506
- live: g.live
507
- }),
508
- /* @__PURE__ */ v(c, {
509
- initial: !1,
510
- children: k.map(T)
511
- })
512
- ] }) : /* @__PURE__ */ v(c, {
513
- initial: !1,
514
- children: S.map(T)
515
- })
516
- })]
517
- });
518
- }
519
- function U(e) {
520
- return /* @__PURE__ */ v(D, { children: /* @__PURE__ */ v(_e, { ...e }) });
521
- }
522
- //#endregion
523
- //#region src/cards/range-select.tsx
524
- var W = e(null);
525
- function ve({ rangeSelect: e, children: t }) {
526
- return /* @__PURE__ */ v(W.Provider, {
527
- value: e ?? null,
528
- children: t
529
- });
530
- }
531
- function ye() {
532
- return t(W);
533
- }
534
- var G = [
535
- .23,
536
- 1,
537
- .32,
538
- 1
539
- ], be = 30;
540
- function xe({ value: e, options: t, onValueChange: i, "aria-label": a }) {
541
- let l = r(), u = h(), [d, p] = s(!1), m = Math.max(0, t.findIndex((t) => t.id === e)), [g, _] = s(m), b = o(null), x = o(null), S = o(null), C = t[m], w = (e = m) => {
542
- _(e), p(!0);
543
- }, T = (e = !0) => {
544
- p(!1), e && x.current?.focus();
545
- }, E = (n) => {
546
- let r = t[n];
547
- r && r.id !== e && i(r.id), T();
548
- };
549
- return n(() => {
550
- if (!d) return;
551
- S.current?.focus();
552
- let e = (e) => {
553
- b.current?.contains(e.target) || T(!1);
554
- };
555
- return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
556
- }, [d]), /* @__PURE__ */ y("span", {
557
- ref: b,
558
- className: "lilt-card__range lilt-card__range--select",
559
- "data-value": C?.id,
560
- "data-open": d || void 0,
561
- children: [/* @__PURE__ */ y("button", {
562
- ref: x,
563
- type: "button",
564
- className: "lilt-range-select__trigger",
565
- "aria-haspopup": "listbox",
566
- "aria-expanded": d,
567
- "aria-controls": d ? `${l}-list` : void 0,
568
- "aria-label": `${a}: ${C?.label ?? ""}`,
569
- onClick: () => d ? T() : w(),
570
- onKeyDown: (e) => {
571
- (e.key === "ArrowDown" || e.key === "ArrowUp") && (e.preventDefault(), w(e.key === "ArrowDown" ? Math.min(t.length - 1, m + 1) : Math.max(0, m - 1)));
572
- },
573
- children: [/* @__PURE__ */ v("span", {
574
- className: "lilt-range-select__value",
575
- children: /* @__PURE__ */ v(c, {
576
- mode: "popLayout",
577
- initial: !1,
578
- children: /* @__PURE__ */ v(f.span, {
579
- initial: u ? { opacity: 0 } : {
580
- opacity: 0,
581
- y: 4,
582
- filter: "blur(3px)"
583
- },
584
- animate: {
585
- opacity: 1,
586
- y: 0,
587
- filter: "blur(0px)"
588
- },
589
- exit: u ? { opacity: 0 } : {
590
- opacity: 0,
591
- y: -4,
592
- filter: "blur(3px)"
593
- },
594
- transition: {
595
- duration: .2,
596
- ease: G
597
- },
598
- children: C?.label
599
- }, C?.id)
600
- })
601
- }), /* @__PURE__ */ v("svg", {
602
- "aria-hidden": "true",
603
- viewBox: "0 0 12 12",
604
- width: "12",
605
- height: "12",
606
- children: /* @__PURE__ */ v("path", {
607
- d: "M3 4.5 6 7.5 9 4.5",
608
- fill: "none",
609
- stroke: "currentColor",
610
- strokeWidth: "1.5"
611
- })
612
- })]
613
- }), /* @__PURE__ */ v(c, { children: d ? /* @__PURE__ */ y(f.ul, {
614
- ref: S,
615
- id: `${l}-list`,
616
- role: "listbox",
617
- tabIndex: -1,
618
- "aria-label": a,
619
- "aria-activedescendant": `${l}-option-${g}`,
620
- className: "lilt-range-select__list",
621
- onKeyDown: (e) => {
622
- let n = (n) => {
623
- e.preventDefault(), _(Math.max(0, Math.min(t.length - 1, n)));
624
- };
625
- if (e.key === "ArrowDown") n(g + 1);
626
- else if (e.key === "ArrowUp") n(g - 1);
627
- else if (e.key === "Home") n(0);
628
- else if (e.key === "End") n(t.length - 1);
629
- else if (e.key === "Enter" || e.key === " ") e.preventDefault(), E(g);
630
- else if (e.key === "Escape") e.preventDefault(), T();
631
- else if (e.key === "Tab") T(!1);
632
- else if (e.key.length === 1) {
633
- let r = e.key.toLowerCase(), i = t.findIndex((e, t) => t > g && e.label.toLowerCase().startsWith(r)), a = i >= 0 ? i : t.findIndex((e) => e.label.toLowerCase().startsWith(r));
634
- a >= 0 && n(a);
635
- }
636
- },
637
- initial: u ? { opacity: 0 } : {
638
- opacity: 0,
639
- scale: .96,
640
- y: -4,
641
- filter: "blur(4px)"
642
- },
643
- animate: {
644
- opacity: 1,
645
- scale: 1,
646
- y: 0,
647
- filter: "blur(0px)"
648
- },
649
- exit: u ? {
650
- opacity: 0,
651
- transition: { duration: .1 }
652
- } : {
653
- opacity: 0,
654
- scale: .97,
655
- filter: "blur(3px)",
656
- transition: { duration: .12 }
657
- },
658
- transition: {
659
- duration: .18,
660
- ease: G
661
- },
662
- children: [/* @__PURE__ */ v(f.li, {
663
- role: "presentation",
664
- "aria-hidden": "true",
665
- className: "lilt-range-select__highlight",
666
- initial: !1,
667
- animate: { y: g * be },
668
- transition: u ? { duration: 0 } : {
669
- type: "spring",
670
- duration: .28,
671
- bounce: 0
672
- }
673
- }), t.map((e, t) => /* @__PURE__ */ y("li", {
674
- id: `${l}-option-${t}`,
675
- role: "option",
676
- "data-value": e.id,
677
- "aria-selected": t === m,
678
- className: "lilt-range-select__option",
679
- "data-active": t === g || void 0,
680
- onPointerMove: () => _(t),
681
- onClick: () => E(t),
682
- children: [/* @__PURE__ */ v("span", {
683
- className: "lilt-range-select__label",
684
- children: e.label
685
- }), t === m ? /* @__PURE__ */ v("svg", {
686
- "aria-hidden": "true",
687
- className: "lilt-range-select__check",
688
- viewBox: "0 0 12 12",
689
- width: "12",
690
- height: "12",
691
- children: /* @__PURE__ */ v("path", {
692
- d: "M2.5 6.5 5 9l4.5-6",
693
- fill: "none",
694
- stroke: "currentColor",
695
- strokeWidth: "1.6"
696
- })
697
- }) : null]
698
- }, e.id))]
699
- }) : null })]
700
- });
701
- }
702
- function Se(e) {
703
- return /* @__PURE__ */ v(D, { children: /* @__PURE__ */ v(xe, { ...e }) });
704
- }
705
- //#endregion
706
- //#region src/cards/chart-card.tsx
707
- var K = e("count");
708
- function q(...e) {
709
- return e.filter(Boolean).join(" ");
710
- }
711
- var J = e(null);
712
- function Ce({ children: e, surface: n = "elevated", palette: r, motion: i, numberStyle: a = "count", badge: o, className: s, style: c, "aria-label": l, onKeyDown: u }) {
713
- let d = t(J), f = d?.badge ?? o, p = f != null && f !== !1, m = p || d !== null, h = {
714
- "data-lilt-chart": "",
715
- "data-lilt-palette": r,
716
- "data-motion": i === "none" ? "none" : void 0,
717
- style: c
718
- }, g = /* @__PURE__ */ v("section", {
719
- ...m ? { "data-lilt-chart": "" } : h,
720
- "data-surface": n,
721
- "data-tone": d?.tone ?? void 0,
722
- className: q("lilt-card", !m && s),
723
- "aria-label": l,
724
- onKeyDown: u,
725
- children: /* @__PURE__ */ v(J.Provider, {
726
- value: null,
727
- children: e
728
- })
729
- });
730
- return /* @__PURE__ */ v(K.Provider, {
731
- value: a,
732
- children: /* @__PURE__ */ v(D, { children: m ? /* @__PURE__ */ y("div", {
733
- ...h,
734
- className: q("lilt-card-frame", s),
735
- "data-tabbed": p || void 0,
736
- "data-surface": n,
737
- children: [
738
- p ? /* @__PURE__ */ v(Y, { children: f }) : null,
739
- d?.handle,
740
- g
741
- ]
742
- }) : g })
743
- });
744
- }
745
- function Y({ children: e, className: t }) {
746
- return /* @__PURE__ */ v("div", {
747
- "data-lilt-chart": "",
748
- className: q("lilt-card-badge", t),
749
- children: e
750
- });
751
- }
752
- function we({ children: e, aside: t, className: n }) {
753
- return /* @__PURE__ */ y("header", {
754
- className: q("lilt-card__header", n),
755
- children: [/* @__PURE__ */ v("div", {
756
- className: "lilt-card__heading",
757
- children: e
758
- }), t ? /* @__PURE__ */ v("div", {
759
- className: "lilt-card__aside",
760
- children: t
761
- }) : null]
762
- });
763
- }
764
- function Te({ children: e }) {
765
- return /* @__PURE__ */ v("p", {
766
- className: "lilt-card__title",
767
- children: e
768
- });
769
- }
770
- function Ee({ value: e, format: n, children: r, loading: i = !1, motion: a }) {
771
- let o = t(K);
772
- return /* @__PURE__ */ y("div", {
773
- className: "lilt-card__value-row",
774
- children: [/* @__PURE__ */ v("strong", {
775
- className: "lilt-card__value",
776
- "data-loading": i || void 0,
777
- children: i ? /* @__PURE__ */ v("span", {
778
- className: "lilt-card__skeleton",
779
- "aria-label": "Loading"
780
- }) : e === null ? "—" : /* @__PURE__ */ v(U, {
781
- value: e,
782
- format: n,
783
- variant: o,
784
- motion: a
785
- })
786
- }), r]
787
- });
788
- }
789
- var De = (e) => `${e >= 0 ? "+" : ""}${(e * 100).toFixed(1)}%`;
790
- function Oe({ value: e, tone: t = "default", format: n = De }) {
791
- let r = e > 0 ? "up" : e < 0 ? "down" : "flat";
792
- return /* @__PURE__ */ v("span", {
793
- className: "lilt-card__delta",
794
- "data-tone": t === "neutral" || r === "flat" ? "neutral" : r === "up" == (t === "default") ? "positive" : "negative",
795
- children: n(e)
796
- });
797
- }
798
- function ke({ children: e }) {
799
- return /* @__PURE__ */ v("span", {
800
- className: "lilt-card__caption",
801
- children: e
802
- });
803
- }
804
- function Ae({ label: e, options: t, value: n, onValueChange: r }) {
805
- let i = ye();
806
- if (!t || t.length < 2) return /* @__PURE__ */ v("span", {
807
- className: "lilt-card__range",
808
- children: e ?? t?.[0]?.label
809
- });
810
- let a = {
811
- value: n ?? t[0].id,
812
- options: t,
813
- onValueChange: (e) => r?.(e),
814
- "aria-label": "Period"
815
- };
816
- return i ? /* @__PURE__ */ v("span", {
817
- className: "lilt-card__range-slot",
818
- children: /* @__PURE__ */ v(i, { ...a })
819
- }) : /* @__PURE__ */ v(Se, { ...a });
820
- }
821
- //#endregion
822
- //#region src/watch/engine/robust.ts
823
- function X(e) {
824
- if (e.length === 0) return null;
825
- let t = [...e].sort((e, t) => e - t), n = t.length >> 1;
826
- return t.length % 2 == 1 ? t[n] : (t[n - 1] + t[n]) / 2;
827
- }
828
- function je(e, t) {
829
- let n = X(e.map((e) => Math.abs(e - t)));
830
- return n === null ? 0 : n * 1.4826;
831
- }
832
- //#endregion
833
- //#region src/watch/engine/normal.ts
834
- var Z = 1440, Me = 256, Ne = 12;
835
- function Pe({ data: e, x: t, value: n, normal: r }) {
836
- let i = (e, t) => {
837
- let n = e[t];
838
- return typeof n == "number" && Number.isFinite(n) ? n : null;
839
- }, a = e.map((e) => i(e, n));
840
- if (r.around !== void 0 && r.tolerance === void 0) throw Error("Lilt Charts: `normal.around` needs a `tolerance`.");
841
- if (r.given !== void 0 && r.learn === void 0) throw Error("Lilt Charts: `normal.given` needs `learn`.");
842
- let o = r.learn === void 0 ? null : Be(r.learn), s = o ? Ve(e, t, o) : null, c = r.given === void 0 ? null : Ue(r.given, e, i), l = /* @__PURE__ */ new Map(), u = [], d = Object.entries(r.rules ?? {}).map(([e, t]) => typeof t == "function" ? {
843
- id: e,
844
- test: t
845
- } : {
846
- id: e,
847
- ...t
848
- });
849
- return e.map((t, n) => {
850
- let f = a[n] ?? null, p = !r.when || r.when(t, n), m = [], h = {
851
- lower: null,
852
- upper: null
853
- }, g = null, _ = null;
854
- if (r.limits) {
855
- let { min: e, max: t, severity: n = "critical" } = r.limits;
856
- h = {
857
- lower: e ?? null,
858
- upper: t ?? null
859
- }, p && f !== null && (t !== void 0 && f > t && m.push(Q("limit", "max", n, "above", t, f, Fe(t))), e !== void 0 && f < e && m.push(Q("limit", "min", n, "below", e, f, Fe(e))));
860
- }
861
- if (r.around !== void 0 && r.tolerance !== void 0) {
862
- let e = i(t, r.around);
863
- if (e !== null) {
864
- let t = Ie(r.tolerance, e), n = {
865
- lower: e - t,
866
- upper: e + t
867
- };
868
- if (h = Le(h, n), g = e, p && f !== null) {
869
- let e = r.aroundSeverity ?? "warning";
870
- f > n.upper ? m.push(Q("around", "around", e, "above", n.upper, f, t)) : f < n.lower && m.push(Q("around", "around", e, "below", n.lower, f, t));
871
- }
872
- }
873
- }
874
- if (o && s) {
875
- let e = We(s(t), c ? c(t) : ""), r = e === null ? void 0 : l.get(e), i = r?.values;
876
- if (r && i && i.length >= o.minSamples) {
877
- let e = X(i);
878
- _ = [...r.rows];
879
- let t = u.length >= Ne ? X(u) * 1.4826 : 0, n = Math.max(je(i, e), Math.abs(e) * Math.max(t, .02), 1e-9) * o.width, a = {
880
- lower: e - n,
881
- upper: e + n
882
- };
883
- h = Le(h, a), g = e, p && f !== null && (f > a.upper ? m.push(Q("learned", "learned", o.severity, "above", a.upper, f, n)) : f < a.lower && m.push(Q("learned", "learned", o.severity, "below", a.lower, f, n)));
884
- }
885
- if (e !== null && p && f !== null) {
886
- if (g !== null && i && i.length >= o.minSamples) {
887
- let e = X(i);
888
- e !== 0 && (u.push(Math.abs(f - e) / Math.abs(e)), u.length > Me && u.shift());
889
- }
890
- let t = l.get(e) ?? {
891
- values: [],
892
- rows: []
893
- };
894
- t.values.push(f), t.rows.push(n), t.values.length > o.history && (t.values.shift(), t.rows.shift()), l.set(e, t);
895
- }
896
- }
897
- if (p) for (let r of d) r.test(t, {
898
- index: n,
899
- rows: e,
900
- value: f,
901
- values: a
902
- }) && m.push({
903
- source: "rule",
904
- id: r.id,
905
- severity: r.severity ?? "critical",
906
- message: r.message ?? r.id,
907
- score: 1
908
- });
909
- let v = m.some((e) => e.severity === "critical") ? "critical" : m.length > 0 ? "warning" : null;
910
- return {
911
- index: n,
912
- value: f,
913
- judged: p,
914
- expected: g,
915
- lower: h.lower,
916
- upper: h.upper,
917
- flags: m,
918
- severity: v,
919
- score: m.reduce((e, t) => Math.max(e, t.score), 0),
920
- basis: _
921
- };
922
- });
923
- }
924
- function Q(e, t, n, r, i, a, o) {
925
- return {
926
- source: e,
927
- id: t,
928
- severity: n,
929
- direction: r,
930
- bound: i,
931
- score: 1 + Math.abs(a - i) / Math.max(o, 1e-9)
932
- };
933
- }
934
- var Fe = (e) => e === 0 ? 1 : Math.abs(e) * .1;
935
- function Ie(e, t) {
936
- return typeof e == "number" ? Math.abs(e) : Math.abs(t) * Math.abs(Number.parseFloat(e)) / 100;
937
- }
938
- function Le(e, t) {
939
- let n = Re(e.lower, t.lower), r = ze(e.upper, t.upper);
940
- return n !== null && r !== null && n > r ? e : {
941
- lower: n,
942
- upper: r
943
- };
944
- }
945
- var Re = (e, t) => e === null ? t : t === null ? e : Math.max(e, t), ze = (e, t) => e === null ? t : t === null ? e : Math.min(e, t);
946
- function Be(e) {
947
- return {
948
- width: 3,
949
- history: 8,
950
- minSamples: 3,
951
- utcOffsetMinutes: 0,
952
- severity: "warning",
953
- ...typeof e == "string" ? { period: e } : e
954
- };
955
- }
956
- function Ve(e, t, n) {
957
- if (n.period === "all") return () => "all";
958
- let r = (e) => {
959
- let r = e[t];
960
- if (r instanceof Date) return r.getTime();
961
- if (typeof r == "number" && Number.isFinite(r)) return r;
962
- if (r == null) return null;
963
- throw Error(`Lilt Charts: learning by '${n.period}' needs dates or epoch milliseconds in '${t}'.`);
964
- }, i = n.slotMinutes ?? He(e.map(r));
965
- return (e) => {
966
- let t = r(e);
967
- if (t === null) return null;
968
- let a = new Date(t + n.utcOffsetMinutes * 6e4), o = a.getUTCHours() * 60 + a.getUTCMinutes(), s = Math.floor(o / i);
969
- return n.period === "week" ? `${a.getUTCDay()}:${s}` : String(s);
970
- };
971
- }
972
- function He(e) {
973
- let t = e.filter((e) => e !== null), n = [];
974
- for (let e = 1; e < t.length; e += 1) {
975
- let r = t[e] - t[e - 1];
976
- r > 0 && n.push(r);
977
- }
978
- let r = X(n);
979
- return r === null ? Z : Math.min(Z, Math.max(1, Math.round(r / 6e4)));
980
- }
981
- function Ue(e, t, n) {
982
- let { key: r, step: i } = typeof e == "string" ? {
983
- key: e,
984
- step: void 0
985
- } : e, a = i;
986
- if (a === void 0) {
987
- let e = t.map((e) => n(e, r)).filter((e) => e !== null), [i, o] = b(e), s = i === void 0 || o === void 0 ? 0 : o - i;
988
- a = s > 0 ? s / 8 : 1;
989
- }
990
- return (e) => {
991
- let t = n(e, r);
992
- return t === null ? null : String(Math.floor(t / a));
993
- };
994
- }
995
- function We(e, t) {
996
- return e === null || t === null ? null : t === "" ? e : `${e}|${t}`;
997
- }
998
- //#endregion
999
- //#region src/watch/engine/status.ts
1000
- function Ge(e, { enter: t = 2, exit: n = 3 } = {}) {
1001
- let r = [], i = !1, a = null, o = null, s = [], c = 0, l = 0, u = 0, d = 0, f = [];
1002
- for (let p of e) {
1003
- let e = p.flags.length > 0;
1004
- p.judged && (e || p.value !== null) && (e ? (d = 0, l === 0 && (u = p.index, f = []), l += 1, f.push(p), !i && l >= t ? (i = !0, o = u, a = Ke(f), c = Math.max(...f.map((e) => e.score)), s = p.flags, r.push({
1005
- type: "activated",
1006
- index: p.index,
1007
- severity: a,
1008
- flags: s
1009
- })) : i && (s = p.flags, c = Math.max(c, p.score), a === "warning" && p.severity === "critical" && (a = "critical", r.push({
1010
- type: "escalated",
1011
- index: p.index,
1012
- severity: a,
1013
- flags: s
1014
- })))) : (l = 0, d += 1, i && d >= n && (i = !1, r.push({
1015
- type: "cleared",
1016
- index: p.index
1017
- }), a = null, o = null, s = [], c = 0)));
1018
- }
1019
- return {
1020
- active: i,
1021
- severity: a,
1022
- since: o,
1023
- flags: s,
1024
- score: c,
1025
- events: r
1026
- };
1027
- }
1028
- var Ke = (e) => e.some((e) => e.severity === "critical") ? "critical" : "warning";
1029
- //#endregion
1030
- //#region src/watch/engine/describe.ts
1031
- function qe(e, { formatValue: t = String, aroundLabel: n = "reference" } = {}) {
1032
- let r = e.direction === "above";
1033
- switch (e.source) {
1034
- case "limit": return `${r ? "Above max" : "Below min"} ${t(e.bound)}`;
1035
- case "around": return `${r ? "Above" : "Below"} ${n} range`;
1036
- case "learned": return r ? "Unusually high" : "Unusually low";
1037
- case "rule": return e.message ?? e.id;
1038
- }
1039
- }
1040
- //#endregion
1041
- //#region src/watch/engine/explain.ts
1042
- function Je(e, t) {
1043
- let n = [.../* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)])], r = [], i = [];
1044
- for (let a of n) {
1045
- let n = e[a], o = t[a];
1046
- if (!$(n) || !$(o)) {
1047
- r.push(a);
1048
- continue;
1049
- }
1050
- i.push({
1051
- segment: a,
1052
- actual: n,
1053
- expected: o,
1054
- delta: n - o
1055
- });
1056
- }
1057
- let a = i.reduce((e, t) => e + t.actual, 0), o = i.reduce((e, t) => e + t.expected, 0), s = a - o;
1058
- return {
1059
- actual: a,
1060
- expected: o,
1061
- delta: s,
1062
- parts: i.map((e) => ({
1063
- ...e,
1064
- share: s === 0 ? 0 : e.delta / s
1065
- })).sort((e, t) => t.share - e.share),
1066
- missing: r
1067
- };
1068
- }
1069
- var $ = (e) => typeof e == "number" && Number.isFinite(e);
1070
- function Ye({ data: e, points: t, indices: n, breakdown: r, fallback: i = 6 }) {
1071
- if (!n.length) return null;
1072
- let a = {}, o = {}, s = (e, t, n) => {
1073
- e[t] !== null && (e[t] = n === null ? null : (e[t] ?? 0) + n);
1074
- }, c = x(n) ?? Infinity, l = [];
1075
- for (let e = c - 1; e >= 0 && l.length < i; --e) {
1076
- let n = t[e];
1077
- n?.judged && n.value !== null && n.flags.length === 0 && l.push(e);
1078
- }
1079
- for (let i of n) {
1080
- let n = e[i];
1081
- if (n === void 0) continue;
1082
- let c = r(n), u = (t[i]?.basis?.length ? t[i].basis : l).map((t) => r(e[t])), d = /* @__PURE__ */ new Set([...Object.keys(c), ...u.flatMap(Object.keys)]);
1083
- for (let e of d) {
1084
- let t = c[e];
1085
- s(a, e, $(t) ? t : null), s(o, e, X(u.map((t) => t[e]).filter($)));
1086
- }
1087
- }
1088
- return Je(a, o);
1089
- }
1090
- function Xe(e, { lead: t = .5 } = {}) {
1091
- if (!e || e.delta === 0) return null;
1092
- let [n, r] = e.parts;
1093
- if (!n || n.share <= 0) return null;
1094
- let i = e.delta < 0 ? "drop" : "rise";
1095
- return n.share >= t ? `${Math.round(Math.min(n.share, 1) * 100)}% of the ${i} is ${n.segment}` : r && r.share > 0 ? `${n.segment} and ${r.segment} lead the ${i}` : `${n.segment} leads the ${i}`;
1096
- }
1097
- //#endregion
1098
- //#region src/watch/board/report-context.ts
1099
- var Ze = e(null);
1100
- //#endregion
1101
- export { k as C, ee as S, ve as _, qe as a, te as b, Y as c, ke as d, Oe as f, Ee as g, Te as h, Ye as i, J as l, Ae as m, Xe as n, Ge as o, we as p, Je as r, Pe as s, Ze as t, Ce as u, U as v, D as w, O as x, ne as y };