@lilt-ui/charts 0.2.0 → 0.4.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.
- package/CHANGELOG.md +44 -0
- package/README.md +45 -0
- package/dist/cards/area-chart-card.d.ts +10 -1
- package/dist/cards/cartesian-card.d.ts +35 -6
- package/dist/cards/chart-card.d.ts +12 -1
- package/dist/cards/line-chart-card.d.ts +10 -1
- package/dist/{cartesian-card-BDZs0v6E.js → cartesian-card-Cj1o38DC.js} +2771 -2987
- package/dist/chart.d.ts +1 -1
- package/dist/finance/cards/depth-chart-card.d.ts +2 -2
- package/dist/finance.js +220 -219
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1792 -1628
- package/dist/interaction/axis-cursor.d.ts +12 -2
- package/dist/interaction/chart-sync.d.ts +11 -1
- package/dist/interaction/inspection-layer.d.ts +6 -0
- package/dist/interaction/pin-glyphs.d.ts +8 -0
- package/dist/interaction/pin-marker.d.ts +9 -1
- package/dist/interaction/use-category-state.d.ts +2 -0
- package/dist/interaction/use-touch-glide.d.ts +26 -0
- package/dist/model/cartesian-model.d.ts +3 -3
- package/dist/motion/use-glide.d.ts +7 -3
- package/dist/primitives/axis-segments.d.ts +23 -0
- package/dist/report-context-Cz0AYdV2.js +895 -0
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +34 -3
- package/dist/watch/board/board-state.d.ts +74 -0
- package/dist/watch/board/board-toast.d.ts +19 -0
- package/dist/watch/board/chart-board.d.ts +97 -0
- package/dist/watch/board/report-context.d.ts +3 -0
- package/dist/watch/engine/describe.d.ts +9 -0
- package/dist/watch/engine/explain.d.ts +48 -0
- package/dist/watch/engine/normal.d.ts +114 -0
- package/dist/watch/engine/robust.d.ts +7 -0
- package/dist/watch/engine/rules.d.ts +22 -0
- package/dist/watch/engine/status.d.ts +39 -0
- package/dist/watch/index.d.ts +14 -0
- package/dist/watch/normal-layer.d.ts +18 -0
- package/dist/watch.d.ts +2 -0
- package/dist/watch.js +628 -0
- package/package.json +6 -1
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
import { createContext as e, useContext as t, useEffect as n, useLayoutEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
3
|
+
import { AnimatePresence as u, animate as d, motion as f, useMotionValue as p, useMotionValueEvent as m, useReducedMotion as h, useTransform as g } from "motion/react";
|
|
4
|
+
import { animate as _ } from "motion";
|
|
5
|
+
import v from "@number-flow/react";
|
|
6
|
+
//#region src/motion/use-chart-motion.ts
|
|
7
|
+
var y = [
|
|
8
|
+
.22,
|
|
9
|
+
1,
|
|
10
|
+
.36,
|
|
11
|
+
1
|
|
12
|
+
];
|
|
13
|
+
function b(e) {
|
|
14
|
+
let [t, r] = o(!1);
|
|
15
|
+
return n(() => {
|
|
16
|
+
if (typeof window > "u" || !window.matchMedia) return;
|
|
17
|
+
let e = window.matchMedia("(prefers-reduced-motion: reduce)"), t = () => r(e.matches);
|
|
18
|
+
return t(), e.addEventListener?.("change", t), () => e.removeEventListener?.("change", t);
|
|
19
|
+
}, []), e === "none" || t;
|
|
20
|
+
}
|
|
21
|
+
function x(e, t) {
|
|
22
|
+
let [n, i] = o(e.active ? +!!t : 1), s = a(e.key), c = e.active && e.key !== s.current;
|
|
23
|
+
return r(() => {
|
|
24
|
+
if (s.current = e.key, !e.active || t) {
|
|
25
|
+
i(1);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
i(0);
|
|
29
|
+
let n = _(0, 1, {
|
|
30
|
+
duration: e.duration / 1e3,
|
|
31
|
+
ease: y,
|
|
32
|
+
onUpdate: (e) => i(e),
|
|
33
|
+
onComplete: () => i(1)
|
|
34
|
+
});
|
|
35
|
+
return () => n.stop();
|
|
36
|
+
}, [
|
|
37
|
+
t,
|
|
38
|
+
e.active,
|
|
39
|
+
e.duration,
|
|
40
|
+
e.key
|
|
41
|
+
]), t ? 1 : c ? 0 : Math.max(0, Math.min(1, n));
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/interaction/pin-glyphs.tsx
|
|
45
|
+
var S = "M9 4.5h6l-1 5 3 3v2H7v-2l3-3-1-5ZM12 14.5v7";
|
|
46
|
+
function C({ release: e }) {
|
|
47
|
+
return /* @__PURE__ */ c("svg", {
|
|
48
|
+
className: e ? "lilt-chart__pin-glyph lilt-chart__pin-glyph--release" : "lilt-chart__pin-glyph",
|
|
49
|
+
viewBox: "0 0 24 24",
|
|
50
|
+
fill: "none",
|
|
51
|
+
"aria-hidden": "true",
|
|
52
|
+
children: /* @__PURE__ */ c("path", {
|
|
53
|
+
d: e ? `${S}M4.5 5.5l15 15` : S,
|
|
54
|
+
stroke: "currentColor",
|
|
55
|
+
strokeLinecap: "round",
|
|
56
|
+
strokeLinejoin: "round",
|
|
57
|
+
strokeWidth: "1.8"
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function w({ release: e = !1 }) {
|
|
62
|
+
return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(C, {}), e ? /* @__PURE__ */ c(C, { release: !0 }) : null] });
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/motion/number-format.ts
|
|
66
|
+
var T = /* @__PURE__ */ new WeakMap();
|
|
67
|
+
function E(e) {
|
|
68
|
+
let t = (t) => e.format(t);
|
|
69
|
+
return T.set(t, e), t;
|
|
70
|
+
}
|
|
71
|
+
function D(e) {
|
|
72
|
+
return e instanceof Intl.NumberFormat ? e : T.get(e);
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/motion/animated-number.tsx
|
|
76
|
+
var O = /\p{Decimal_Number}/u, k = /* @__PURE__ */ new Set([
|
|
77
|
+
"integer",
|
|
78
|
+
"group",
|
|
79
|
+
"decimal",
|
|
80
|
+
"fraction",
|
|
81
|
+
"nan",
|
|
82
|
+
"infinity"
|
|
83
|
+
]);
|
|
84
|
+
function ee(e, t) {
|
|
85
|
+
let n = [];
|
|
86
|
+
if (t?.length && t.map((e) => e.value).join("") === e) {
|
|
87
|
+
let e = t.findIndex((e) => k.has(e.type)), r = t.length - 1 - [...t].reverse().findIndex((e) => k.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();
|
|
88
|
+
t.forEach((t, s) => {
|
|
89
|
+
let c = e < 0 || s < e ? "prefix" : s > r ? "suffix" : "number";
|
|
90
|
+
for (let e of Array.from(t.value)) {
|
|
91
|
+
let r;
|
|
92
|
+
if (t.type === "integer") r = `i${--i}`;
|
|
93
|
+
else if (t.type === "group") r = `g${i}`;
|
|
94
|
+
else if (t.type === "decimal") r = "dec";
|
|
95
|
+
else if (t.type === "fraction") r = `f${a++}`;
|
|
96
|
+
else {
|
|
97
|
+
let e = `${c}-${t.type}`, n = o.get(e) ?? 0;
|
|
98
|
+
o.set(e, n + 1), r = `${e}-${n}`;
|
|
99
|
+
}
|
|
100
|
+
n.push({
|
|
101
|
+
key: r,
|
|
102
|
+
char: e,
|
|
103
|
+
digit: O.test(e),
|
|
104
|
+
role: c
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
let t = Array.from(e), r = t.findIndex((e) => O.test(e)), i = t.length - 1 - [...t].reverse().findIndex((e) => O.test(e));
|
|
110
|
+
t.forEach((e, a) => {
|
|
111
|
+
let o = O.test(e);
|
|
112
|
+
r < 0 || a < r ? n.push({
|
|
113
|
+
key: `prefix-${a}`,
|
|
114
|
+
char: e,
|
|
115
|
+
digit: o,
|
|
116
|
+
role: "prefix"
|
|
117
|
+
}) : a > i ? n.push({
|
|
118
|
+
key: `suffix-${t.length - 1 - a}`,
|
|
119
|
+
char: e,
|
|
120
|
+
digit: o,
|
|
121
|
+
role: "suffix"
|
|
122
|
+
}) : n.push({
|
|
123
|
+
key: `n${i - a}${o ? "d" : "s"}`,
|
|
124
|
+
char: e,
|
|
125
|
+
digit: o,
|
|
126
|
+
role: "number"
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return n.map((e, t) => ({
|
|
131
|
+
...e,
|
|
132
|
+
place: n.length - 1 - t
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
function A(e, t) {
|
|
136
|
+
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));
|
|
137
|
+
return Object.is(s, -0) ? 0 : s;
|
|
138
|
+
}
|
|
139
|
+
function te(e, t, n) {
|
|
140
|
+
let r = ((t - e) % 10 + 10) % 10;
|
|
141
|
+
return r === 0 ? e : n > 0 ? e + r : e - (10 - r);
|
|
142
|
+
}
|
|
143
|
+
var ne = 240, j = .16, M = {
|
|
144
|
+
duration: .1,
|
|
145
|
+
ease: "easeOut"
|
|
146
|
+
}, N = [
|
|
147
|
+
.16,
|
|
148
|
+
1,
|
|
149
|
+
.3,
|
|
150
|
+
1
|
|
151
|
+
], re = {
|
|
152
|
+
type: "spring",
|
|
153
|
+
stiffness: 420,
|
|
154
|
+
damping: 34,
|
|
155
|
+
mass: .7
|
|
156
|
+
}, P = (e) => Math.min(e, 6) * .024;
|
|
157
|
+
function F({ cell: e, change: t, style: n }) {
|
|
158
|
+
let r = n === "slide" ? .72 : 0;
|
|
159
|
+
return /* @__PURE__ */ c("span", {
|
|
160
|
+
className: "lilt-number__cell",
|
|
161
|
+
"data-digit": e.digit || void 0,
|
|
162
|
+
children: /* @__PURE__ */ c(u, {
|
|
163
|
+
initial: !1,
|
|
164
|
+
custom: t,
|
|
165
|
+
children: /* @__PURE__ */ c(f.span, {
|
|
166
|
+
className: "lilt-number__glyph",
|
|
167
|
+
custom: t,
|
|
168
|
+
variants: {
|
|
169
|
+
enter: ({ direction: e, live: t }) => t ? {
|
|
170
|
+
y: `${e * r * 55}%`,
|
|
171
|
+
opacity: .35,
|
|
172
|
+
scale: 1,
|
|
173
|
+
filter: "blur(0px)"
|
|
174
|
+
} : {
|
|
175
|
+
y: `${e * r * 100}%`,
|
|
176
|
+
opacity: 0,
|
|
177
|
+
scale: n === "fade" ? 1.06 : .96,
|
|
178
|
+
filter: `blur(${n === "fade" ? 1.5 : 2.5}px)`
|
|
179
|
+
},
|
|
180
|
+
rest: {
|
|
181
|
+
y: "0%",
|
|
182
|
+
opacity: 1,
|
|
183
|
+
scale: 1,
|
|
184
|
+
filter: "blur(0px)"
|
|
185
|
+
},
|
|
186
|
+
leave: ({ direction: e, live: t }) => t ? {
|
|
187
|
+
y: `${-e * r * 55}%`,
|
|
188
|
+
opacity: 0,
|
|
189
|
+
transition: M
|
|
190
|
+
} : {
|
|
191
|
+
y: `${-e * r * 100}%`,
|
|
192
|
+
opacity: 0,
|
|
193
|
+
scale: n === "fade" ? .94 : .96,
|
|
194
|
+
filter: `blur(${n === "fade" ? 1.5 : 2.5}px)`
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
initial: "enter",
|
|
198
|
+
animate: "rest",
|
|
199
|
+
exit: "leave",
|
|
200
|
+
transition: t.live ? {
|
|
201
|
+
duration: j,
|
|
202
|
+
ease: N
|
|
203
|
+
} : {
|
|
204
|
+
delay: P(e.place),
|
|
205
|
+
y: re,
|
|
206
|
+
default: {
|
|
207
|
+
duration: .26,
|
|
208
|
+
ease: N
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
children: e.char
|
|
212
|
+
}, e.char)
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
var I = Array.from({ length: 30 }, (e, t) => String(t % 10));
|
|
217
|
+
function ie({ cell: e, change: t }) {
|
|
218
|
+
let r = Number(e.char), i = p(10 + r), o = a(t);
|
|
219
|
+
o.current = t, n(() => {
|
|
220
|
+
let t = i.get();
|
|
221
|
+
(t < 5 || t >= 25) && (t = 10 + (t % 10 + 10) % 10, i.jump(t));
|
|
222
|
+
let { direction: n, live: a } = o.current, s = te(t, r, n);
|
|
223
|
+
if (s === t) return;
|
|
224
|
+
let c = d(i, s, {
|
|
225
|
+
type: "spring",
|
|
226
|
+
stiffness: a ? 320 : 190,
|
|
227
|
+
damping: a ? 32 : 26,
|
|
228
|
+
mass: .9,
|
|
229
|
+
delay: a ? 0 : P(e.place),
|
|
230
|
+
onComplete: () => i.jump(10 + r)
|
|
231
|
+
});
|
|
232
|
+
return () => c.stop();
|
|
233
|
+
}, [
|
|
234
|
+
e.place,
|
|
235
|
+
r,
|
|
236
|
+
i
|
|
237
|
+
]);
|
|
238
|
+
let s = g(i, (e) => `${-e / I.length * 100}%`);
|
|
239
|
+
return /* @__PURE__ */ l("span", {
|
|
240
|
+
className: "lilt-number__cell lilt-number__cell--reel",
|
|
241
|
+
"data-digit": !0,
|
|
242
|
+
children: [/* @__PURE__ */ c("span", {
|
|
243
|
+
className: "lilt-number__glyph lilt-number__sizer",
|
|
244
|
+
"aria-hidden": "true",
|
|
245
|
+
children: e.char
|
|
246
|
+
}), /* @__PURE__ */ c(f.span, {
|
|
247
|
+
className: "lilt-number__reel",
|
|
248
|
+
style: { y: s },
|
|
249
|
+
children: I.map((e, t) => /* @__PURE__ */ c("span", { children: e }, t))
|
|
250
|
+
})]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
var L = "0123456789";
|
|
254
|
+
function R({ cell: e, live: t }) {
|
|
255
|
+
let [r, i] = o(null), s = a(e.char), l = a(t);
|
|
256
|
+
return l.current = t, n(() => {
|
|
257
|
+
if (s.current === e.char) return;
|
|
258
|
+
s.current = e.char;
|
|
259
|
+
let t = 0, n = l.current ? 2 : 5 + Math.min(e.place, 6), r = window.setInterval(() => {
|
|
260
|
+
t += 1, i(t >= n ? null : L[Math.floor(Math.random() * 10)]), t >= n && window.clearInterval(r);
|
|
261
|
+
}, 36);
|
|
262
|
+
return () => {
|
|
263
|
+
window.clearInterval(r), i(null);
|
|
264
|
+
};
|
|
265
|
+
}, [e.char, e.place]), /* @__PURE__ */ c("span", {
|
|
266
|
+
className: "lilt-number__cell",
|
|
267
|
+
"data-digit": e.digit || void 0,
|
|
268
|
+
"data-scrambling": r !== null || void 0,
|
|
269
|
+
children: /* @__PURE__ */ c("span", {
|
|
270
|
+
className: "lilt-number__glyph",
|
|
271
|
+
children: r ?? e.char
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function z({ cell: e }) {
|
|
276
|
+
return /* @__PURE__ */ c("span", {
|
|
277
|
+
className: "lilt-number__cell",
|
|
278
|
+
"data-digit": e.digit || void 0,
|
|
279
|
+
children: /* @__PURE__ */ c("span", {
|
|
280
|
+
className: "lilt-number__glyph",
|
|
281
|
+
children: e.char
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
var B = [
|
|
286
|
+
.34,
|
|
287
|
+
1.45,
|
|
288
|
+
.64,
|
|
289
|
+
1
|
|
290
|
+
], ae = {
|
|
291
|
+
enter: (e) => e ? {
|
|
292
|
+
y: "16%",
|
|
293
|
+
opacity: .4,
|
|
294
|
+
filter: "blur(0px)"
|
|
295
|
+
} : {
|
|
296
|
+
y: "32%",
|
|
297
|
+
opacity: 0,
|
|
298
|
+
filter: "blur(2px)"
|
|
299
|
+
},
|
|
300
|
+
visible: {
|
|
301
|
+
y: "0%",
|
|
302
|
+
opacity: 1,
|
|
303
|
+
filter: "blur(0px)"
|
|
304
|
+
}
|
|
305
|
+
}, oe = { leave: (e) => e ? {
|
|
306
|
+
y: "-16%",
|
|
307
|
+
opacity: 0,
|
|
308
|
+
transition: M
|
|
309
|
+
} : {
|
|
310
|
+
y: "-32%",
|
|
311
|
+
opacity: 0,
|
|
312
|
+
filter: "blur(2px)",
|
|
313
|
+
transition: {
|
|
314
|
+
duration: .3,
|
|
315
|
+
ease: N
|
|
316
|
+
}
|
|
317
|
+
} };
|
|
318
|
+
function se({ cells: e, live: t }) {
|
|
319
|
+
let n = e.map((e) => e.char).join("");
|
|
320
|
+
return /* @__PURE__ */ c("span", {
|
|
321
|
+
className: "lilt-number__pop-host",
|
|
322
|
+
children: /* @__PURE__ */ c(u, {
|
|
323
|
+
mode: "popLayout",
|
|
324
|
+
initial: !1,
|
|
325
|
+
custom: t,
|
|
326
|
+
children: /* @__PURE__ */ c(f.span, {
|
|
327
|
+
className: "lilt-number__pop",
|
|
328
|
+
variants: oe,
|
|
329
|
+
initial: "enter",
|
|
330
|
+
animate: "visible",
|
|
331
|
+
exit: "leave",
|
|
332
|
+
children: e.map((e, n) => /* @__PURE__ */ c(f.span, {
|
|
333
|
+
className: "lilt-number__pop-char",
|
|
334
|
+
custom: t,
|
|
335
|
+
variants: ae,
|
|
336
|
+
transition: t ? {
|
|
337
|
+
duration: .22,
|
|
338
|
+
ease: B
|
|
339
|
+
} : {
|
|
340
|
+
duration: .5,
|
|
341
|
+
delay: Math.min(n, 2) * .07,
|
|
342
|
+
ease: B
|
|
343
|
+
},
|
|
344
|
+
children: e.char
|
|
345
|
+
}, n))
|
|
346
|
+
}, n)
|
|
347
|
+
})
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
function ce(e, t, r) {
|
|
351
|
+
let i = p(e), s = a(r);
|
|
352
|
+
s.current = r;
|
|
353
|
+
let [c, l] = o(e);
|
|
354
|
+
return m(i, "change", l), n(() => {
|
|
355
|
+
if (!t) {
|
|
356
|
+
i.jump(e);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
let n = d(i, e, {
|
|
360
|
+
duration: s.current ? .24 : .62,
|
|
361
|
+
ease: N
|
|
362
|
+
});
|
|
363
|
+
return () => n.stop();
|
|
364
|
+
}, [
|
|
365
|
+
t,
|
|
366
|
+
i,
|
|
367
|
+
e
|
|
368
|
+
]), t ? A(c, e) : e;
|
|
369
|
+
}
|
|
370
|
+
function le(e) {
|
|
371
|
+
let [t, n] = o({
|
|
372
|
+
value: e,
|
|
373
|
+
at: 0,
|
|
374
|
+
direction: 1,
|
|
375
|
+
live: !1
|
|
376
|
+
});
|
|
377
|
+
if (t.value !== e) {
|
|
378
|
+
let r = Date.now();
|
|
379
|
+
n({
|
|
380
|
+
value: e,
|
|
381
|
+
at: r,
|
|
382
|
+
direction: e >= t.value ? 1 : -1,
|
|
383
|
+
live: r - t.at < ne
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
direction: t.direction,
|
|
388
|
+
live: t.live
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function V({ value: e, format: t = String, className: n, motion: r = "auto", variant: a = "count" }) {
|
|
392
|
+
let o = !h() && r !== "none", d = D(t), p = (e) => t instanceof Intl.NumberFormat ? t.format(e) : t(e), m = (e) => ee(p(e), d?.formatToParts(e)), g = a === "flow" && !d ? "slide" : a, _ = i(() => {
|
|
393
|
+
if (!d) return;
|
|
394
|
+
let { locale: e, ...t } = d.resolvedOptions();
|
|
395
|
+
return {
|
|
396
|
+
locale: e,
|
|
397
|
+
options: t
|
|
398
|
+
};
|
|
399
|
+
}, [d]), y = p(e), b = le(e), x = ce(e, o && g === "count", b.live), S = ["lilt-number", n].filter(Boolean).join(" ");
|
|
400
|
+
if (g === "flow" && _) return /* @__PURE__ */ l("span", {
|
|
401
|
+
className: S,
|
|
402
|
+
"data-variant": "flow",
|
|
403
|
+
children: [/* @__PURE__ */ c("span", {
|
|
404
|
+
className: "lilt-chart__sr-only",
|
|
405
|
+
children: y
|
|
406
|
+
}), /* @__PURE__ */ c("span", {
|
|
407
|
+
"aria-hidden": "true",
|
|
408
|
+
className: "lilt-number__flow",
|
|
409
|
+
children: /* @__PURE__ */ c(v, {
|
|
410
|
+
value: e,
|
|
411
|
+
locales: _.locale,
|
|
412
|
+
format: _.options,
|
|
413
|
+
animated: o,
|
|
414
|
+
willChange: !0
|
|
415
|
+
})
|
|
416
|
+
})]
|
|
417
|
+
});
|
|
418
|
+
let C = m(g === "count" ? x : e), w = (e) => o ? e.role === "number" ? g === "count" ? /* @__PURE__ */ c(z, { cell: e }) : g === "roll" ? /[0-9]/.test(e.char) ? /* @__PURE__ */ c(ie, {
|
|
419
|
+
cell: e,
|
|
420
|
+
change: b
|
|
421
|
+
}) : /* @__PURE__ */ c(F, {
|
|
422
|
+
cell: e,
|
|
423
|
+
change: b,
|
|
424
|
+
style: "fade"
|
|
425
|
+
}) : g === "scramble" ? /[0-9]/.test(e.char) ? /* @__PURE__ */ c(R, {
|
|
426
|
+
cell: e,
|
|
427
|
+
live: b.live
|
|
428
|
+
}) : /* @__PURE__ */ c(F, {
|
|
429
|
+
cell: e,
|
|
430
|
+
change: b,
|
|
431
|
+
style: "fade"
|
|
432
|
+
}) : /* @__PURE__ */ c(F, {
|
|
433
|
+
cell: e,
|
|
434
|
+
change: b,
|
|
435
|
+
style: "slide"
|
|
436
|
+
}) : /* @__PURE__ */ c(F, {
|
|
437
|
+
cell: e,
|
|
438
|
+
change: b,
|
|
439
|
+
style: "fade"
|
|
440
|
+
}) : /* @__PURE__ */ c(z, { cell: e }), T = (e) => /* @__PURE__ */ c(f.span, {
|
|
441
|
+
className: "lilt-number__place",
|
|
442
|
+
custom: b.live,
|
|
443
|
+
initial: o ? {
|
|
444
|
+
width: 0,
|
|
445
|
+
opacity: 0
|
|
446
|
+
} : !1,
|
|
447
|
+
animate: {
|
|
448
|
+
width: "auto",
|
|
449
|
+
opacity: 1
|
|
450
|
+
},
|
|
451
|
+
exit: o ? {
|
|
452
|
+
width: 0,
|
|
453
|
+
opacity: 0
|
|
454
|
+
} : void 0,
|
|
455
|
+
transition: {
|
|
456
|
+
duration: b.live ? j : .32,
|
|
457
|
+
ease: N
|
|
458
|
+
},
|
|
459
|
+
children: w(e)
|
|
460
|
+
}, e.key), E = g === "pop" && o, O = C.filter((e) => e.role === "prefix"), k = C.filter((e) => e.role === "number"), A = C.filter((e) => e.role === "suffix");
|
|
461
|
+
return /* @__PURE__ */ l("span", {
|
|
462
|
+
className: S,
|
|
463
|
+
"data-variant": a,
|
|
464
|
+
children: [/* @__PURE__ */ c("span", {
|
|
465
|
+
className: "lilt-chart__sr-only",
|
|
466
|
+
children: y
|
|
467
|
+
}), /* @__PURE__ */ c("span", {
|
|
468
|
+
"aria-hidden": "true",
|
|
469
|
+
className: "lilt-number__characters",
|
|
470
|
+
children: E ? /* @__PURE__ */ l(s, { children: [
|
|
471
|
+
/* @__PURE__ */ c(u, {
|
|
472
|
+
initial: !1,
|
|
473
|
+
children: O.map(T)
|
|
474
|
+
}),
|
|
475
|
+
/* @__PURE__ */ c(se, {
|
|
476
|
+
cells: k,
|
|
477
|
+
live: b.live
|
|
478
|
+
}),
|
|
479
|
+
/* @__PURE__ */ c(u, {
|
|
480
|
+
initial: !1,
|
|
481
|
+
children: A.map(T)
|
|
482
|
+
})
|
|
483
|
+
] }) : /* @__PURE__ */ c(u, {
|
|
484
|
+
initial: !1,
|
|
485
|
+
children: C.map(T)
|
|
486
|
+
})
|
|
487
|
+
})]
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/cards/chart-card.tsx
|
|
492
|
+
var H = e("count");
|
|
493
|
+
function U(...e) {
|
|
494
|
+
return e.filter(Boolean).join(" ");
|
|
495
|
+
}
|
|
496
|
+
var W = e(null);
|
|
497
|
+
function ue({ children: e, surface: n = "elevated", palette: r, motion: i, numberStyle: a = "count", badge: o, className: s, style: u, "aria-label": d }) {
|
|
498
|
+
let f = t(W), p = f?.badge ?? o, m = p != null && p !== !1, h = m || f !== null, g = {
|
|
499
|
+
"data-lilt-chart": "",
|
|
500
|
+
"data-lilt-palette": r,
|
|
501
|
+
"data-motion": i === "none" ? "none" : void 0,
|
|
502
|
+
style: u
|
|
503
|
+
}, _ = /* @__PURE__ */ c("section", {
|
|
504
|
+
...h ? { "data-lilt-chart": "" } : g,
|
|
505
|
+
"data-surface": n,
|
|
506
|
+
"data-tone": f?.tone ?? void 0,
|
|
507
|
+
className: U("lilt-card", !h && s),
|
|
508
|
+
"aria-label": d,
|
|
509
|
+
children: /* @__PURE__ */ c(W.Provider, {
|
|
510
|
+
value: null,
|
|
511
|
+
children: e
|
|
512
|
+
})
|
|
513
|
+
});
|
|
514
|
+
return /* @__PURE__ */ c(H.Provider, {
|
|
515
|
+
value: a,
|
|
516
|
+
children: h ? /* @__PURE__ */ l("div", {
|
|
517
|
+
...g,
|
|
518
|
+
className: U("lilt-card-frame", s),
|
|
519
|
+
"data-tabbed": m || void 0,
|
|
520
|
+
children: [
|
|
521
|
+
m ? /* @__PURE__ */ c(G, { children: p }) : null,
|
|
522
|
+
f?.handle,
|
|
523
|
+
_
|
|
524
|
+
]
|
|
525
|
+
}) : _
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
function G({ children: e, className: t }) {
|
|
529
|
+
return /* @__PURE__ */ c("div", {
|
|
530
|
+
"data-lilt-chart": "",
|
|
531
|
+
className: U("lilt-card-badge", t),
|
|
532
|
+
children: e
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
function de({ children: e, aside: t, className: n }) {
|
|
536
|
+
return /* @__PURE__ */ l("header", {
|
|
537
|
+
className: U("lilt-card__header", n),
|
|
538
|
+
children: [/* @__PURE__ */ c("div", {
|
|
539
|
+
className: "lilt-card__heading",
|
|
540
|
+
children: e
|
|
541
|
+
}), t ? /* @__PURE__ */ c("div", {
|
|
542
|
+
className: "lilt-card__aside",
|
|
543
|
+
children: t
|
|
544
|
+
}) : null]
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
function fe({ children: e }) {
|
|
548
|
+
return /* @__PURE__ */ c("p", {
|
|
549
|
+
className: "lilt-card__title",
|
|
550
|
+
children: e
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
function pe({ value: e, format: n, children: r, loading: i = !1, motion: a }) {
|
|
554
|
+
let o = t(H);
|
|
555
|
+
return /* @__PURE__ */ l("div", {
|
|
556
|
+
className: "lilt-card__value-row",
|
|
557
|
+
children: [/* @__PURE__ */ c("strong", {
|
|
558
|
+
className: "lilt-card__value",
|
|
559
|
+
"data-loading": i || void 0,
|
|
560
|
+
children: i ? /* @__PURE__ */ c("span", {
|
|
561
|
+
className: "lilt-card__skeleton",
|
|
562
|
+
"aria-label": "Loading"
|
|
563
|
+
}) : e === null ? "—" : /* @__PURE__ */ c(V, {
|
|
564
|
+
value: e,
|
|
565
|
+
format: n,
|
|
566
|
+
variant: o,
|
|
567
|
+
motion: a
|
|
568
|
+
})
|
|
569
|
+
}), r]
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
var me = (e) => `${e >= 0 ? "+" : ""}${(e * 100).toFixed(1)}%`;
|
|
573
|
+
function K({ value: e, tone: t = "default", format: n = me }) {
|
|
574
|
+
let r = e > 0 ? "up" : e < 0 ? "down" : "flat";
|
|
575
|
+
return /* @__PURE__ */ c("span", {
|
|
576
|
+
className: "lilt-card__delta",
|
|
577
|
+
"data-tone": t === "neutral" || r === "flat" ? "neutral" : r === "up" == (t === "default") ? "positive" : "negative",
|
|
578
|
+
children: n(e)
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
function he({ children: e }) {
|
|
582
|
+
return /* @__PURE__ */ c("span", {
|
|
583
|
+
className: "lilt-card__caption",
|
|
584
|
+
children: e
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
function ge({ label: e, options: t, value: n, onValueChange: r }) {
|
|
588
|
+
return !t || t.length < 2 ? /* @__PURE__ */ c("span", {
|
|
589
|
+
className: "lilt-card__range",
|
|
590
|
+
children: e ?? t?.[0]?.label
|
|
591
|
+
}) : /* @__PURE__ */ l("span", {
|
|
592
|
+
className: "lilt-card__range lilt-card__range--select",
|
|
593
|
+
children: [/* @__PURE__ */ c("select", {
|
|
594
|
+
"aria-label": "Period",
|
|
595
|
+
value: n,
|
|
596
|
+
onChange: (e) => r?.(e.target.value),
|
|
597
|
+
children: t.map((e) => /* @__PURE__ */ c("option", {
|
|
598
|
+
value: e.id,
|
|
599
|
+
children: e.label
|
|
600
|
+
}, e.id))
|
|
601
|
+
}), /* @__PURE__ */ c("svg", {
|
|
602
|
+
"aria-hidden": "true",
|
|
603
|
+
viewBox: "0 0 12 12",
|
|
604
|
+
width: "12",
|
|
605
|
+
height: "12",
|
|
606
|
+
children: /* @__PURE__ */ c("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
|
+
});
|
|
614
|
+
}
|
|
615
|
+
//#endregion
|
|
616
|
+
//#region src/watch/engine/robust.ts
|
|
617
|
+
function q(e) {
|
|
618
|
+
if (e.length === 0) return null;
|
|
619
|
+
let t = [...e].sort((e, t) => e - t), n = t.length >> 1;
|
|
620
|
+
return t.length % 2 == 1 ? t[n] : (t[n - 1] + t[n]) / 2;
|
|
621
|
+
}
|
|
622
|
+
function _e(e, t) {
|
|
623
|
+
let n = q(e.map((e) => Math.abs(e - t)));
|
|
624
|
+
return n === null ? 0 : n * 1.4826;
|
|
625
|
+
}
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region src/watch/engine/normal.ts
|
|
628
|
+
var J = 1440, ve = 256, ye = 12;
|
|
629
|
+
function be({ data: e, x: t, value: n, normal: r }) {
|
|
630
|
+
let i = (e, t) => {
|
|
631
|
+
let n = e[t];
|
|
632
|
+
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
633
|
+
}, a = e.map((e) => i(e, n));
|
|
634
|
+
if (r.around !== void 0 && r.tolerance === void 0) throw Error("Lilt Charts: `normal.around` needs a `tolerance`.");
|
|
635
|
+
if (r.given !== void 0 && r.learn === void 0) throw Error("Lilt Charts: `normal.given` needs `learn`.");
|
|
636
|
+
let o = r.learn === void 0 ? null : we(r.learn), s = o ? Te(e, t, o) : null, c = r.given === void 0 ? null : De(r.given, e, i), l = /* @__PURE__ */ new Map(), u = [], d = Object.entries(r.rules ?? {}).map(([e, t]) => typeof t == "function" ? {
|
|
637
|
+
id: e,
|
|
638
|
+
test: t
|
|
639
|
+
} : {
|
|
640
|
+
id: e,
|
|
641
|
+
...t
|
|
642
|
+
});
|
|
643
|
+
return e.map((t, n) => {
|
|
644
|
+
let f = a[n] ?? null, p = !r.when || r.when(t, n), m = [], h = {
|
|
645
|
+
lower: null,
|
|
646
|
+
upper: null
|
|
647
|
+
}, g = null, _ = null;
|
|
648
|
+
if (r.limits) {
|
|
649
|
+
let { min: e, max: t, severity: n = "critical" } = r.limits;
|
|
650
|
+
h = {
|
|
651
|
+
lower: e ?? null,
|
|
652
|
+
upper: t ?? null
|
|
653
|
+
}, p && f !== null && (t !== void 0 && f > t && m.push(Y("limit", "max", n, "above", t, f, X(t))), e !== void 0 && f < e && m.push(Y("limit", "min", n, "below", e, f, X(e))));
|
|
654
|
+
}
|
|
655
|
+
if (r.around !== void 0 && r.tolerance !== void 0) {
|
|
656
|
+
let e = i(t, r.around);
|
|
657
|
+
if (e !== null) {
|
|
658
|
+
let t = xe(r.tolerance, e), n = {
|
|
659
|
+
lower: e - t,
|
|
660
|
+
upper: e + t
|
|
661
|
+
};
|
|
662
|
+
if (h = Z(h, n), g = e, p && f !== null) {
|
|
663
|
+
let e = r.aroundSeverity ?? "warning";
|
|
664
|
+
f > n.upper ? m.push(Y("around", "around", e, "above", n.upper, f, t)) : f < n.lower && m.push(Y("around", "around", e, "below", n.lower, f, t));
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (o && s) {
|
|
669
|
+
let e = Oe(s(t), c ? c(t) : ""), r = e === null ? void 0 : l.get(e), i = r?.values;
|
|
670
|
+
if (r && i && i.length >= o.minSamples) {
|
|
671
|
+
let e = q(i);
|
|
672
|
+
_ = [...r.rows];
|
|
673
|
+
let t = u.length >= ye ? q(u) * 1.4826 : 0, n = Math.max(_e(i, e), Math.abs(e) * Math.max(t, .02), 1e-9) * o.width, a = {
|
|
674
|
+
lower: e - n,
|
|
675
|
+
upper: e + n
|
|
676
|
+
};
|
|
677
|
+
h = Z(h, a), g = e, p && f !== null && (f > a.upper ? m.push(Y("learned", "learned", o.severity, "above", a.upper, f, n)) : f < a.lower && m.push(Y("learned", "learned", o.severity, "below", a.lower, f, n)));
|
|
678
|
+
}
|
|
679
|
+
if (e !== null && p && f !== null) {
|
|
680
|
+
if (g !== null && i && i.length >= o.minSamples) {
|
|
681
|
+
let e = q(i);
|
|
682
|
+
e !== 0 && (u.push(Math.abs(f - e) / Math.abs(e)), u.length > ve && u.shift());
|
|
683
|
+
}
|
|
684
|
+
let t = l.get(e) ?? {
|
|
685
|
+
values: [],
|
|
686
|
+
rows: []
|
|
687
|
+
};
|
|
688
|
+
t.values.push(f), t.rows.push(n), t.values.length > o.history && (t.values.shift(), t.rows.shift()), l.set(e, t);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
if (p) for (let r of d) r.test(t, {
|
|
692
|
+
index: n,
|
|
693
|
+
rows: e,
|
|
694
|
+
value: f,
|
|
695
|
+
values: a
|
|
696
|
+
}) && m.push({
|
|
697
|
+
source: "rule",
|
|
698
|
+
id: r.id,
|
|
699
|
+
severity: r.severity ?? "critical",
|
|
700
|
+
message: r.message ?? r.id,
|
|
701
|
+
score: 1
|
|
702
|
+
});
|
|
703
|
+
let v = m.some((e) => e.severity === "critical") ? "critical" : m.length > 0 ? "warning" : null;
|
|
704
|
+
return {
|
|
705
|
+
index: n,
|
|
706
|
+
value: f,
|
|
707
|
+
judged: p,
|
|
708
|
+
expected: g,
|
|
709
|
+
lower: h.lower,
|
|
710
|
+
upper: h.upper,
|
|
711
|
+
flags: m,
|
|
712
|
+
severity: v,
|
|
713
|
+
score: m.reduce((e, t) => Math.max(e, t.score), 0),
|
|
714
|
+
basis: _
|
|
715
|
+
};
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
function Y(e, t, n, r, i, a, o) {
|
|
719
|
+
return {
|
|
720
|
+
source: e,
|
|
721
|
+
id: t,
|
|
722
|
+
severity: n,
|
|
723
|
+
direction: r,
|
|
724
|
+
bound: i,
|
|
725
|
+
score: 1 + Math.abs(a - i) / Math.max(o, 1e-9)
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
var X = (e) => e === 0 ? 1 : Math.abs(e) * .1;
|
|
729
|
+
function xe(e, t) {
|
|
730
|
+
return typeof e == "number" ? Math.abs(e) : Math.abs(t) * Math.abs(Number.parseFloat(e)) / 100;
|
|
731
|
+
}
|
|
732
|
+
function Z(e, t) {
|
|
733
|
+
let n = Se(e.lower, t.lower), r = Ce(e.upper, t.upper);
|
|
734
|
+
return n !== null && r !== null && n > r ? e : {
|
|
735
|
+
lower: n,
|
|
736
|
+
upper: r
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
var Se = (e, t) => e === null ? t : t === null ? e : Math.max(e, t), Ce = (e, t) => e === null ? t : t === null ? e : Math.min(e, t);
|
|
740
|
+
function we(e) {
|
|
741
|
+
return {
|
|
742
|
+
width: 3,
|
|
743
|
+
history: 8,
|
|
744
|
+
minSamples: 3,
|
|
745
|
+
utcOffsetMinutes: 0,
|
|
746
|
+
severity: "warning",
|
|
747
|
+
...typeof e == "string" ? { period: e } : e
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
function Te(e, t, n) {
|
|
751
|
+
if (n.period === "all") return () => "all";
|
|
752
|
+
let r = (e) => {
|
|
753
|
+
let r = e[t];
|
|
754
|
+
if (r instanceof Date) return r.getTime();
|
|
755
|
+
if (typeof r == "number" && Number.isFinite(r)) return r;
|
|
756
|
+
if (r == null) return null;
|
|
757
|
+
throw Error(`Lilt Charts: learning by '${n.period}' needs dates or epoch milliseconds in '${t}'.`);
|
|
758
|
+
}, i = n.slotMinutes ?? Ee(e.map(r));
|
|
759
|
+
return (e) => {
|
|
760
|
+
let t = r(e);
|
|
761
|
+
if (t === null) return null;
|
|
762
|
+
let a = new Date(t + n.utcOffsetMinutes * 6e4), o = a.getUTCHours() * 60 + a.getUTCMinutes(), s = Math.floor(o / i);
|
|
763
|
+
return n.period === "week" ? `${a.getUTCDay()}:${s}` : String(s);
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
function Ee(e) {
|
|
767
|
+
let t = e.filter((e) => e !== null), n = [];
|
|
768
|
+
for (let e = 1; e < t.length; e += 1) {
|
|
769
|
+
let r = t[e] - t[e - 1];
|
|
770
|
+
r > 0 && n.push(r);
|
|
771
|
+
}
|
|
772
|
+
let r = q(n);
|
|
773
|
+
return r === null ? J : Math.min(J, Math.max(1, Math.round(r / 6e4)));
|
|
774
|
+
}
|
|
775
|
+
function De(e, t, n) {
|
|
776
|
+
let { key: r, step: i } = typeof e == "string" ? {
|
|
777
|
+
key: e,
|
|
778
|
+
step: void 0
|
|
779
|
+
} : e, a = i;
|
|
780
|
+
if (a === void 0) {
|
|
781
|
+
let e = t.map((e) => n(e, r)).filter((e) => e !== null), i = e.length > 0 ? Math.max(...e) - Math.min(...e) : 0;
|
|
782
|
+
a = i > 0 ? i / 8 : 1;
|
|
783
|
+
}
|
|
784
|
+
return (e) => {
|
|
785
|
+
let t = n(e, r);
|
|
786
|
+
return t === null ? null : String(Math.floor(t / a));
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function Oe(e, t) {
|
|
790
|
+
return e === null || t === null ? null : t === "" ? e : `${e}|${t}`;
|
|
791
|
+
}
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region src/watch/engine/status.ts
|
|
794
|
+
function ke(e, { enter: t = 2, exit: n = 3 } = {}) {
|
|
795
|
+
let r = [], i = !1, a = null, o = null, s = [], c = 0, l = 0, u = 0, d = 0, f = [];
|
|
796
|
+
for (let p of e) {
|
|
797
|
+
let e = p.flags.length > 0;
|
|
798
|
+
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 = Ae(f), c = Math.max(...f.map((e) => e.score)), s = p.flags, r.push({
|
|
799
|
+
type: "activated",
|
|
800
|
+
index: p.index,
|
|
801
|
+
severity: a,
|
|
802
|
+
flags: s
|
|
803
|
+
})) : i && (s = p.flags, c = Math.max(c, p.score), a === "warning" && p.severity === "critical" && (a = "critical", r.push({
|
|
804
|
+
type: "escalated",
|
|
805
|
+
index: p.index,
|
|
806
|
+
severity: a,
|
|
807
|
+
flags: s
|
|
808
|
+
})))) : (l = 0, d += 1, i && d >= n && (i = !1, r.push({
|
|
809
|
+
type: "cleared",
|
|
810
|
+
index: p.index
|
|
811
|
+
}), a = null, o = null, s = [], c = 0)));
|
|
812
|
+
}
|
|
813
|
+
return {
|
|
814
|
+
active: i,
|
|
815
|
+
severity: a,
|
|
816
|
+
since: o,
|
|
817
|
+
flags: s,
|
|
818
|
+
score: c,
|
|
819
|
+
events: r
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
var Ae = (e) => e.some((e) => e.severity === "critical") ? "critical" : "warning";
|
|
823
|
+
//#endregion
|
|
824
|
+
//#region src/watch/engine/describe.ts
|
|
825
|
+
function je(e, { formatValue: t = String, aroundLabel: n = "reference" } = {}) {
|
|
826
|
+
let r = e.direction === "above";
|
|
827
|
+
switch (e.source) {
|
|
828
|
+
case "limit": return `${r ? "Above max" : "Below min"} ${t(e.bound)}`;
|
|
829
|
+
case "around": return `${r ? "Above" : "Below"} ${n} range`;
|
|
830
|
+
case "learned": return r ? "Unusually high" : "Unusually low";
|
|
831
|
+
case "rule": return e.message ?? e.id;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region src/watch/engine/explain.ts
|
|
836
|
+
function Q(e, t) {
|
|
837
|
+
let n = [.../* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)])], r = [], i = [];
|
|
838
|
+
for (let a of n) {
|
|
839
|
+
let n = e[a], o = t[a];
|
|
840
|
+
if (!$(n) || !$(o)) {
|
|
841
|
+
r.push(a);
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
i.push({
|
|
845
|
+
segment: a,
|
|
846
|
+
actual: n,
|
|
847
|
+
expected: o,
|
|
848
|
+
delta: n - o
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
let a = i.reduce((e, t) => e + t.actual, 0), o = i.reduce((e, t) => e + t.expected, 0), s = a - o;
|
|
852
|
+
return {
|
|
853
|
+
actual: a,
|
|
854
|
+
expected: o,
|
|
855
|
+
delta: s,
|
|
856
|
+
parts: i.map((e) => ({
|
|
857
|
+
...e,
|
|
858
|
+
share: s === 0 ? 0 : e.delta / s
|
|
859
|
+
})).sort((e, t) => t.share - e.share),
|
|
860
|
+
missing: r
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
var $ = (e) => typeof e == "number" && Number.isFinite(e);
|
|
864
|
+
function Me({ data: e, points: t, indices: n, breakdown: r, fallback: i = 6 }) {
|
|
865
|
+
if (!n.length) return null;
|
|
866
|
+
let a = {}, o = {}, s = (e, t, n) => {
|
|
867
|
+
e[t] !== null && (e[t] = n === null ? null : (e[t] ?? 0) + n);
|
|
868
|
+
}, c = Math.min(...n), l = [];
|
|
869
|
+
for (let e = c - 1; e >= 0 && l.length < i; --e) {
|
|
870
|
+
let n = t[e];
|
|
871
|
+
n?.judged && n.value !== null && n.flags.length === 0 && l.push(e);
|
|
872
|
+
}
|
|
873
|
+
for (let i of n) {
|
|
874
|
+
let n = e[i];
|
|
875
|
+
if (n === void 0) continue;
|
|
876
|
+
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)]);
|
|
877
|
+
for (let e of d) {
|
|
878
|
+
let t = c[e];
|
|
879
|
+
s(a, e, $(t) ? t : null), s(o, e, q(u.map((t) => t[e]).filter($)));
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return Q(a, o);
|
|
883
|
+
}
|
|
884
|
+
function Ne(e, { lead: t = .5 } = {}) {
|
|
885
|
+
if (!e || e.delta === 0) return null;
|
|
886
|
+
let [n, r] = e.parts;
|
|
887
|
+
if (!n || n.share <= 0) return null;
|
|
888
|
+
let i = e.delta < 0 ? "drop" : "rise";
|
|
889
|
+
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}`;
|
|
890
|
+
}
|
|
891
|
+
//#endregion
|
|
892
|
+
//#region src/watch/board/report-context.ts
|
|
893
|
+
var Pe = e(null);
|
|
894
|
+
//#endregion
|
|
895
|
+
export { b as S, V as _, je as a, y as b, G as c, he as d, K as f, pe as g, fe as h, Me as i, W as l, ge as m, Ne as n, ke as o, de as p, Q as r, be as s, Pe as t, ue as u, E as v, x, w as y };
|