@lilt-ui/charts 0.1.0 → 0.3.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 (68) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +120 -0
  3. package/dist/analysis-BJRmXHOB.js +62 -0
  4. package/dist/cards/area-chart-card.d.ts +10 -1
  5. package/dist/cards/box-plot-card.d.ts +30 -0
  6. package/dist/cards/cartesian-card.d.ts +86 -6
  7. package/dist/cards/chart-card.d.ts +12 -1
  8. package/dist/cards/line-chart-card.d.ts +10 -1
  9. package/dist/cards/range-chart-card.d.ts +28 -0
  10. package/dist/cartesian-card-Dcd0ZnQL.js +7004 -0
  11. package/dist/chart-context.d.ts +18 -0
  12. package/dist/chart-data-CCwLQeXa.js +44 -0
  13. package/dist/chart.d.ts +3 -1
  14. package/dist/data.js +3 -2
  15. package/dist/engine/box.d.ts +18 -0
  16. package/dist/engine/domains.d.ts +2 -0
  17. package/dist/engine/geometry.d.ts +2 -1
  18. package/dist/engine/normalize.d.ts +2 -4
  19. package/dist/engine/ranges.d.ts +59 -0
  20. package/dist/finance/candle-geometry.d.ts +55 -0
  21. package/dist/finance/candles.d.ts +18 -0
  22. package/dist/finance/cards/candlestick-chart-card.d.ts +41 -0
  23. package/dist/finance/cards/depth-chart-card.d.ts +32 -0
  24. package/dist/finance/cards/indicator-chart-card.d.ts +52 -0
  25. package/dist/finance/cards/pane.d.ts +24 -0
  26. package/dist/finance/cards/portfolio-chart-card.d.ts +22 -0
  27. package/dist/finance/cards/price-chart-card.d.ts +27 -0
  28. package/dist/finance/index.d.ts +17 -0
  29. package/dist/finance/indicators.d.ts +65 -0
  30. package/dist/finance/order-book.d.ts +26 -0
  31. package/dist/finance.d.ts +2 -0
  32. package/dist/finance.js +1158 -0
  33. package/dist/index.d.ts +14 -4
  34. package/dist/index.js +2239 -8793
  35. package/dist/interaction/axis-cursor.d.ts +12 -2
  36. package/dist/interaction/chart-sync.d.ts +11 -1
  37. package/dist/interaction/field-values.d.ts +12 -0
  38. package/dist/interaction/inspection-layer.d.ts +10 -1
  39. package/dist/interaction/pin-glyphs.d.ts +8 -0
  40. package/dist/interaction/pin-marker.d.ts +9 -1
  41. package/dist/marks/contract.d.ts +49 -0
  42. package/dist/marks/use-range-mark.d.ts +19 -0
  43. package/dist/model/cartesian-model.d.ts +3 -3
  44. package/dist/primitives/annotations.d.ts +1 -1
  45. package/dist/primitives/axis-segments.d.ts +23 -0
  46. package/dist/primitives/box-plot.d.ts +4 -0
  47. package/dist/primitives/error-bar.d.ts +4 -0
  48. package/dist/primitives/interval-band.d.ts +2 -2
  49. package/dist/primitives/range-bar.d.ts +4 -0
  50. package/dist/report-context-Cz0AYdV2.js +895 -0
  51. package/dist/styles.css +1 -1
  52. package/dist/types.d.ts +114 -16
  53. package/dist/watch/board/board-state.d.ts +74 -0
  54. package/dist/watch/board/board-toast.d.ts +19 -0
  55. package/dist/watch/board/chart-board.d.ts +97 -0
  56. package/dist/watch/board/report-context.d.ts +3 -0
  57. package/dist/watch/engine/describe.d.ts +9 -0
  58. package/dist/watch/engine/explain.d.ts +48 -0
  59. package/dist/watch/engine/normal.d.ts +114 -0
  60. package/dist/watch/engine/robust.d.ts +7 -0
  61. package/dist/watch/engine/rules.d.ts +22 -0
  62. package/dist/watch/engine/status.d.ts +39 -0
  63. package/dist/watch/index.d.ts +14 -0
  64. package/dist/watch/normal-layer.d.ts +18 -0
  65. package/dist/watch.d.ts +2 -0
  66. package/dist/watch.js +628 -0
  67. package/package.json +16 -2
  68. package/dist/analysis-BLLWEKBw.js +0 -105
@@ -0,0 +1,1158 @@
1
+ "use client";
2
+ import { A as e, D as t, J as n, M as r, _ as i, b as a, d as o, g as s, h as c, i as l, j as u, k as d, l as f, m as p, p as m, r as h, t as g, v as _, w as v, x as y, y as b, z as x } from "./cartesian-card-Dcd0ZnQL.js";
3
+ import { S, d as C, g as w, h as T, p as E, u as D } from "./report-context-Cz0AYdV2.js";
4
+ import { useEffect as O, useMemo as k, useRef as A, useState as j } from "react";
5
+ import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
6
+ //#region src/finance/candle-geometry.ts
7
+ var F = "var(--lilt-candle-up)", I = "var(--lilt-candle-down)";
8
+ function L(e) {
9
+ return Math.round(e * 100) / 100;
10
+ }
11
+ function R(e, t, n) {
12
+ let r = e.fields[t], i = r?.[n.open], a = r?.[n.high], o = r?.[n.low], s = e.values[t];
13
+ return i == null || a == null || o == null || s == null ? null : {
14
+ open: i,
15
+ high: a,
16
+ low: o,
17
+ close: s,
18
+ up: s >= i
19
+ };
20
+ }
21
+ function z(e, t, n) {
22
+ for (let r of e) {
23
+ let e = R(r, t, n);
24
+ if (!e) continue;
25
+ let i = Math.max(e.open, e.close), a = Math.min(e.open, e.close);
26
+ if (e.high < i || e.low > a) throw Error(`Lilt Candles on series "${t}" expects low ≤ open, close ≤ high at row ${r.sourceIndex + 1}.`);
27
+ }
28
+ }
29
+ function B(e, n, r, i) {
30
+ let a = Math.max(1, r.columnWidth), o = a / 2, s = L(e), c = L(r.y(n.high)), l = L(r.y(n.low));
31
+ if (i === "ohlc") {
32
+ let t = L(r.y(n.open)), i = L(r.y(n.close)), a = L(Math.max(2, o));
33
+ return {
34
+ body: null,
35
+ hollow: null,
36
+ stroke: `M${s},${c}V${l}M${L(e - a)},${t}H${s}M${s},${i}H${L(e + a)}`
37
+ };
38
+ }
39
+ let u = r.y(Math.max(n.open, n.close)), d = r.y(Math.min(n.open, n.close));
40
+ if (d - u < 1) {
41
+ let e = (u + d) / 2;
42
+ u = e - .5, d = e + .5;
43
+ }
44
+ let f = i === "hollow" && n.up && a >= 3, p = f ? .5 : 0, m = t(e - o + p, u + p, Math.max(1, a - p * 2), Math.max(1, d - u - p * 2), a >= 6 ? 1.5 : 0), h = (c < u ? `M${s},${c}V${L(u)}` : "") + (l > d ? `M${s},${L(d)}V${l}` : "");
45
+ return {
46
+ body: f ? null : m,
47
+ hollow: f ? m : null,
48
+ stroke: h
49
+ };
50
+ }
51
+ function V(e, t, n, r, i, a) {
52
+ let o = new y(), s = new y(), c = new y();
53
+ for (let { row: l, cx: u } of v(e, r)) {
54
+ let e = R(l, t, n);
55
+ if (!e) continue;
56
+ let d = a(l, e), f = B(u, e, r, i);
57
+ f.body && o.add(d, f.body), f.hollow && s.add(d, f.hollow), f.stroke && c.add(d, f.stroke);
58
+ }
59
+ return {
60
+ bodies: o.entries(),
61
+ hollow: s.entries(),
62
+ strokes: c.entries()
63
+ };
64
+ }
65
+ //#endregion
66
+ //#region src/finance/candles.tsx
67
+ function H(e, t, n) {
68
+ return r(e, t, n.up ? F : I);
69
+ }
70
+ function U({ paths: e, display: t }) {
71
+ let n = t === "ohlc" ? 1.5 : 1;
72
+ return /* @__PURE__ */ P(M, { children: [
73
+ e.strokes.map(({ color: e, d: r }) => /* @__PURE__ */ N("path", {
74
+ d: r,
75
+ fill: "none",
76
+ strokeWidth: n,
77
+ strokeLinecap: t === "ohlc" ? "round" : "butt",
78
+ style: { stroke: e }
79
+ }, `stroke-${e}`)),
80
+ e.bodies.map(({ color: e, d: t }) => /* @__PURE__ */ N("path", {
81
+ d: t,
82
+ style: { fill: e }
83
+ }, `body-${e}`)),
84
+ e.hollow.map(({ color: e, d: t }) => /* @__PURE__ */ N("path", {
85
+ d: t,
86
+ strokeWidth: 1,
87
+ style: {
88
+ fill: "var(--lilt-surface)",
89
+ stroke: e
90
+ }
91
+ }, `hollow-${e}`))
92
+ ] });
93
+ }
94
+ var W = u(function({ series: e, open: t, high: n, low: r, display: i = "candle", className: o }) {
95
+ let s = a("Candles", e, [
96
+ t,
97
+ n,
98
+ r
99
+ ], "column"), { snapshot: c, descriptor: l, scales: u } = s, d = k(() => {
100
+ let a = {
101
+ open: t,
102
+ high: n,
103
+ low: r
104
+ };
105
+ return z(c.data.rows, e, a), V(c.data.rows, e, a, u, i, (e, t) => H(l, e, t));
106
+ }, [
107
+ c,
108
+ e,
109
+ t,
110
+ n,
111
+ r,
112
+ u,
113
+ i,
114
+ l
115
+ ]);
116
+ return /* @__PURE__ */ N("g", {
117
+ "aria-hidden": "true",
118
+ className: ["lilt-chart__candles", o].filter(Boolean).join(" "),
119
+ "data-series": e,
120
+ "data-display": i,
121
+ clipPath: s.clipPath,
122
+ mask: s.mask,
123
+ style: {
124
+ opacity: s.opacity,
125
+ transition: s.reducedMotion ? void 0 : "opacity 160ms ease-out"
126
+ },
127
+ children: /* @__PURE__ */ N(U, {
128
+ paths: d,
129
+ display: i
130
+ })
131
+ });
132
+ }, {
133
+ layout: "column",
134
+ series: (e) => e.series,
135
+ fields: (e) => [
136
+ e.open,
137
+ e.high,
138
+ e.low
139
+ ],
140
+ highlight: (e, { row: t, snapshot: n, descriptor: r }) => {
141
+ let i = R(t, e.series, e);
142
+ if (!i) return null;
143
+ let a = e.display ?? "candle", o = b(n, e.series), s = B(o.x(t.x), i, o, a), c = H(r, t, i);
144
+ return /* @__PURE__ */ N("g", {
145
+ className: "lilt-chart__candle-highlight",
146
+ children: /* @__PURE__ */ N(U, {
147
+ display: a,
148
+ paths: {
149
+ bodies: s.body ? [{
150
+ color: c,
151
+ d: s.body
152
+ }] : [],
153
+ hollow: s.hollow ? [{
154
+ color: c,
155
+ d: s.hollow
156
+ }] : [],
157
+ strokes: s.stroke ? [{
158
+ color: c,
159
+ d: s.stroke
160
+ }] : []
161
+ }
162
+ })
163
+ });
164
+ }
165
+ });
166
+ //#endregion
167
+ //#region src/finance/cards/pane.tsx
168
+ function G({ context: t, label: r, caption: i, readout: a, series: o, height: s, y: c, bars: l, xAxis: u = !1, children: d }) {
169
+ let [f, p] = j(null), h = f ?? t.data.at(-1) ?? null;
170
+ return /* @__PURE__ */ P("div", {
171
+ className: "lilt-card__pane",
172
+ children: [i ? /* @__PURE__ */ P("span", {
173
+ className: "lilt-card__pane-caption",
174
+ "aria-hidden": "true",
175
+ children: [/* @__PURE__ */ N("span", {
176
+ className: "lilt-card__pane-name",
177
+ children: i
178
+ }), a && h && !t.loading ? a(h) : null]
179
+ }) : null, /* @__PURE__ */ N(n, {
180
+ className: "lilt-card__chart",
181
+ "aria-label": r,
182
+ data: t.data,
183
+ x: t.x,
184
+ y: c,
185
+ series: o,
186
+ controller: t.controller,
187
+ onSelectionChange: a ? (e) => p(e?.row ?? null) : void 0,
188
+ motion: t.motion,
189
+ status: t.loading ? "loading" : "ready",
190
+ children: /* @__PURE__ */ P(e, {
191
+ height: s,
192
+ margins: {
193
+ ...t.margins,
194
+ top: 6,
195
+ bottom: u ? 28 : 4
196
+ },
197
+ axis: t.axis,
198
+ pill: t.hoverStyle,
199
+ axisInset: t.axisInset,
200
+ slots: t.slots || !!l,
201
+ bars: l,
202
+ background: "none",
203
+ children: [d, u ? /* @__PURE__ */ N(m, { labels: "fit" }) : null]
204
+ })
205
+ })]
206
+ });
207
+ }
208
+ //#endregion
209
+ //#region src/finance/cards/candlestick-chart-card.tsx
210
+ function K(e, t) {
211
+ let n = e[t];
212
+ return typeof n == "number" && Number.isFinite(n) ? n : null;
213
+ }
214
+ function q(e, t, n) {
215
+ let r = e.length ? K(e[0], t) : null, i = e.length ? K(e.at(-1), n) : null;
216
+ return r && i !== null ? i / r - 1 : void 0;
217
+ }
218
+ function ee(e) {
219
+ return (t) => {
220
+ let n = t.series[0]?.fields;
221
+ return !n?.length || n.some((e) => e.value === null) ? null : n.map((t) => `${t.label[0]} ${e(t.value)}`).join(" ");
222
+ };
223
+ }
224
+ var te = {
225
+ minimumFractionDigits: 2,
226
+ maximumFractionDigits: 2
227
+ };
228
+ function ne({ open: e, high: t, low: n, close: r, volume: a, display: o = "candle", scale: c = "linear", label: l = "Price", live: u = !1, data: f, ranges: p, delta: m, valueFormat: _ = te, locale: v = "en-US", volumeHeight: y = 64, ...b }) {
229
+ let x = k(() => h(v, _).full, [v, JSON.stringify(_)]), S = k(() => h(v).compact, [v]), C = k(() => p?.map((t) => ({
230
+ ...t,
231
+ delta: t.delta ?? q(t.data, e, r)
232
+ })), [
233
+ p,
234
+ e,
235
+ r
236
+ ]), w = (q(f ?? p?.[0]?.data ?? [], e, r) ?? 0) >= 0, T = (t) => (K(t, r) ?? 0) >= (K(t, e) ?? 0), E = o === "area", D = {
237
+ open: {
238
+ label: "Open",
239
+ accessor: (t) => K(t, e)
240
+ },
241
+ high: {
242
+ label: "High",
243
+ accessor: (e) => K(e, t)
244
+ },
245
+ low: {
246
+ label: "Low",
247
+ accessor: (e) => K(e, n)
248
+ }
249
+ };
250
+ return /* @__PURE__ */ N(g, {
251
+ ...b,
252
+ data: f,
253
+ ranges: C,
254
+ delta: m ?? (f ? q(f, e, r) : void 0),
255
+ valueFormat: _,
256
+ locale: v,
257
+ aggregate: "last",
258
+ tiles: !1,
259
+ live: u,
260
+ series: [{
261
+ key: r,
262
+ label: l,
263
+ color: E ? w ? F : I : void 0
264
+ }],
265
+ shape: {
266
+ kind: "marks",
267
+ id: `candles:${o}:${c}:${e}:${t}:${n}:${!!a}`,
268
+ includeZero: !1,
269
+ scale: c,
270
+ slots: !0,
271
+ xAxis: !a,
272
+ series: () => E ? {
273
+ fields: D,
274
+ area: { treatment: "fade" },
275
+ curve: "linear"
276
+ } : {
277
+ fields: D,
278
+ line: { showInspectionPoint: !1 }
279
+ },
280
+ describe: ee(x),
281
+ draw: (e) => e.map((e) => E ? [/* @__PURE__ */ N(d, { series: e }, `area-${e}`), /* @__PURE__ */ N(i, { series: e }, `line-${e}`)] : /* @__PURE__ */ N(W, {
282
+ series: e,
283
+ open: "open",
284
+ high: "high",
285
+ low: "low",
286
+ display: o
287
+ }, e))
288
+ },
289
+ panes: a ? (e) => /* @__PURE__ */ N(G, {
290
+ context: e,
291
+ label: `${b.title} volume`,
292
+ caption: "Volume",
293
+ height: y,
294
+ xAxis: !0,
295
+ y: {
296
+ includeZero: !0,
297
+ ticks: 2,
298
+ format: S
299
+ },
300
+ bars: { series: ["volume"] },
301
+ series: [{
302
+ id: "volume",
303
+ label: "Volume",
304
+ accessor: (e) => K(e, a),
305
+ formatValue: S,
306
+ colorAt: (e) => T(e) ? "color-mix(in srgb, var(--lilt-candle-up) 42%, transparent)" : "color-mix(in srgb, var(--lilt-candle-down) 42%, transparent)",
307
+ bar: { radius: 1 }
308
+ }],
309
+ children: /* @__PURE__ */ N(s, { series: "volume" })
310
+ }) : void 0
311
+ });
312
+ }
313
+ //#endregion
314
+ //#region src/finance/indicators.ts
315
+ function J(e) {
316
+ return typeof e == "number" && Number.isFinite(e);
317
+ }
318
+ function Y(e, t) {
319
+ if (!Number.isInteger(t) || t < 1) throw Error(`Lilt ${e} period must be a positive integer; received ${t}.`);
320
+ }
321
+ function X(e, t) {
322
+ Y("sma", t);
323
+ let n = [], r = 0, i = 0;
324
+ for (let a = 0; a < e.length; a += 1) {
325
+ let o = e[a];
326
+ J(o) && (r += o, i += 1);
327
+ let s = a - t >= 0 ? e[a - t] : void 0;
328
+ a - t >= 0 && J(s) && (r -= s, --i), n.push(a >= t - 1 && i === t ? r / t : null);
329
+ }
330
+ return n;
331
+ }
332
+ function Z(e, t) {
333
+ Y("ema", t);
334
+ let n = 2 / (t + 1), r = [], i = null, a = [];
335
+ for (let o of e) {
336
+ if (!J(o)) {
337
+ r.push(null);
338
+ continue;
339
+ }
340
+ if (i === null) {
341
+ a.push(o), a.length === t && (i = a.reduce((e, t) => e + t, 0) / t), r.push(i);
342
+ continue;
343
+ }
344
+ i = o * n + i * (1 - n), r.push(i);
345
+ }
346
+ return r;
347
+ }
348
+ function re(e, t = 14) {
349
+ Y("rsi", t);
350
+ let n = e.map(() => null), r = null, i = 0, a = 0, o = 0, s = 0, c = 0;
351
+ return e.forEach((e, l) => {
352
+ if (!J(e)) return;
353
+ if (r === null) {
354
+ r = e;
355
+ return;
356
+ }
357
+ let u = e - r;
358
+ r = e;
359
+ let d = Math.max(0, u), f = Math.max(0, -u);
360
+ if (o += 1, o <= t) {
361
+ if (i += d, a += f, o < t) return;
362
+ s = i / t, c = a / t;
363
+ } else s = (s * (t - 1) + d) / t, c = (c * (t - 1) + f) / t;
364
+ n[l] = c === 0 ? s === 0 ? 50 : 100 : 100 - 100 / (1 + s / c);
365
+ }), n;
366
+ }
367
+ function ie(e, t = 12, n = 26, r = 9) {
368
+ if (t >= n) throw Error("Lilt macd needs a fast period shorter than the slow period.");
369
+ let i = Z(e, t), a = Z(e, n), o = e.map((e, t) => {
370
+ let n = i[t], r = a[t];
371
+ return n === null || r === null ? null : n - r;
372
+ }), s = Z(o, r);
373
+ return {
374
+ macd: o,
375
+ signal: s,
376
+ histogram: o.map((e, t) => {
377
+ let n = s[t];
378
+ return e === null || n === null ? null : e - n;
379
+ })
380
+ };
381
+ }
382
+ function ae(e, t = 20, n = 2) {
383
+ let r = X(e, t), i = [], a = [];
384
+ return r.forEach((r, o) => {
385
+ if (r === null) {
386
+ i.push(null), a.push(null);
387
+ return;
388
+ }
389
+ let s = 0;
390
+ for (let n = o - t + 1; n <= o; n += 1) s += (e[n] - r) ** 2;
391
+ let c = Math.sqrt(s / t) * n;
392
+ i.push(r + c), a.push(r - c);
393
+ }), {
394
+ middle: r,
395
+ upper: i,
396
+ lower: a
397
+ };
398
+ }
399
+ function oe(e) {
400
+ let t = -Infinity;
401
+ return e.map((e) => J(e) ? (t = Math.max(t, e), t > 0 ? e / t - 1 : 0) : null);
402
+ }
403
+ function se(e) {
404
+ let t = e.find(J);
405
+ return e.map((e) => J(e) && t !== void 0 && t !== 0 ? e / t - 1 : null);
406
+ }
407
+ function ce(e, t) {
408
+ for (let n of t) if (!J(n.price) || !J(n.size) || n.size < 0) throw Error(`Lilt order book ${e} need finite prices and non-negative sizes; received ${n.price} × ${n.size}.`);
409
+ }
410
+ function le(e, t) {
411
+ ce("bids", e), ce("asks", t);
412
+ let n = (e) => {
413
+ let t = /* @__PURE__ */ new Map();
414
+ for (let n of e) t.set(n.price, (t.get(n.price) ?? 0) + n.size);
415
+ return [...t].map(([e, t]) => ({
416
+ price: e,
417
+ size: t
418
+ }));
419
+ }, r = n(e).sort((e, t) => t.price - e.price), i = n(t).sort((e, t) => e.price - t.price), a = r[0]?.price ?? null, o = i[0]?.price ?? null;
420
+ if (a !== null && o !== null && a >= o) throw Error(`Lilt order book is crossed: best bid ${a} ≥ best ask ${o}.`);
421
+ let s = 0, c = r.map((e) => (s += e.size, {
422
+ price: e.price,
423
+ bid: s,
424
+ ask: null,
425
+ size: e.size,
426
+ side: "bid"
427
+ })), l = 0, u = i.map((e) => (l += e.size, {
428
+ price: e.price,
429
+ bid: null,
430
+ ask: l,
431
+ size: e.size,
432
+ side: "ask"
433
+ }));
434
+ return {
435
+ levels: [...c.reverse(), ...u],
436
+ bestBid: a,
437
+ bestAsk: o,
438
+ mid: a !== null && o !== null ? (a + o) / 2 : null,
439
+ spread: a !== null && o !== null ? o - a : null,
440
+ bidDepth: s,
441
+ askDepth: l
442
+ };
443
+ }
444
+ //#endregion
445
+ //#region src/finance/cards/indicator-chart-card.tsx
446
+ function ue(e) {
447
+ return e.map((e, t) => {
448
+ let n = typeof e == "string" ? { kind: e } : e, r = "period" in n && n.period !== void 0 ? n.period : (n.kind, 20), i = "deviations" in n && n.deviations !== void 0 ? n.deviations : 2, a = n.kind === "bollinger" ? "BB" : n.kind.toUpperCase();
449
+ return {
450
+ id: `__overlay${t}`,
451
+ label: `${a} ${r}`,
452
+ kind: n.kind,
453
+ period: r,
454
+ deviations: i
455
+ };
456
+ });
457
+ }
458
+ function de(e) {
459
+ return e.map((e, t) => {
460
+ let n = typeof e == "string" ? { kind: e } : e;
461
+ return {
462
+ kind: n.kind,
463
+ id: `__pane${t}`,
464
+ period: "period" in n && n.period !== void 0 ? n.period : 14,
465
+ fast: "fast" in n && n.fast !== void 0 ? n.fast : 12,
466
+ slow: "slow" in n && n.slow !== void 0 ? n.slow : 26,
467
+ signal: "signal" in n && n.signal !== void 0 ? n.signal : 9
468
+ };
469
+ });
470
+ }
471
+ function Q(e, t) {
472
+ if (!t) return null;
473
+ let n = e[t];
474
+ return typeof n == "number" && Number.isFinite(n) ? n : null;
475
+ }
476
+ function fe(e, t, n, r) {
477
+ let i = e.map((e) => Q(e, t)), a = e.map((e) => ({ ...e })), o = (e, t) => t.forEach((t, n) => a[n][e] = t);
478
+ for (let e of n) if (e.kind === "bollinger") {
479
+ let t = ae(i, e.period, e.deviations);
480
+ o(e.id, t.middle), o(`${e.id}Upper`, t.upper), o(`${e.id}Lower`, t.lower);
481
+ } else o(e.id, (e.kind === "sma" ? X : Z)(i, e.period));
482
+ for (let e of r) if (e.kind === "rsi" && o(e.id, re(i, e.period)), e.kind === "macd") {
483
+ let t = ie(i, e.fast, e.slow, e.signal);
484
+ o(`${e.id}Macd`, t.macd), o(`${e.id}Signal`, t.signal), o(`${e.id}Histogram`, t.histogram);
485
+ }
486
+ return a;
487
+ }
488
+ var pe = {
489
+ minimumFractionDigits: 2,
490
+ maximumFractionDigits: 2
491
+ }, me = [
492
+ "var(--lilt-series-4)",
493
+ "var(--lilt-series-3)",
494
+ "var(--lilt-series-5)"
495
+ ];
496
+ function he({ close: e, open: t, high: n, low: r, volume: a, display: c, overlays: l = [], panes: u = ["rsi", "macd"], label: d = "Price", scale: p = "linear", live: m = !1, data: v, ranges: y, delta: b, valueFormat: x = pe, locale: S = "en-US", paneHeight: C = 72, ...w }) {
497
+ let T = !!(t && n && r), E = c ?? (T ? "candle" : "line");
498
+ if (E !== "line" && !T) throw Error("Lilt IndicatorChartCard candles need open, high and low fields.");
499
+ let D = JSON.stringify(l), O = JSON.stringify(u), A = k(() => ue(l), [D]), j = k(() => de(u), [O]);
500
+ if (j.some((e) => e.kind === "volume") && !a) throw Error("Lilt IndicatorChartCard needs a `volume` field for a volume pane.");
501
+ let L = k(() => v ? fe(v, e, A, j) : void 0, [
502
+ v,
503
+ e,
504
+ A,
505
+ j
506
+ ]), R = k(() => y?.map((n) => ({
507
+ ...n,
508
+ data: fe(n.data, e, A, j),
509
+ delta: n.delta ?? (t ? q(n.data, t, e) : void 0)
510
+ })), [
511
+ y,
512
+ e,
513
+ t,
514
+ A,
515
+ j
516
+ ]), z = k(() => h(S, x).full, [S, JSON.stringify(x)]), B = k(() => h(S, { maximumFractionDigits: 2 }).full, [S]), V = k(() => h(S).compact, [S]), H = T ? {
517
+ open: {
518
+ label: "Open",
519
+ accessor: (e) => Q(e, t)
520
+ },
521
+ high: {
522
+ label: "High",
523
+ accessor: (e) => Q(e, n)
524
+ },
525
+ low: {
526
+ label: "Low",
527
+ accessor: (e) => Q(e, r)
528
+ }
529
+ } : void 0, U = new Map(A.map((e) => [e.id, e])), K = v?.length ? Q(v[0], e) : null, te = v?.length ? Q(v.at(-1), e) : null, ne = K === null || te === null || te >= K, J = j.at(-1)?.id, Y = (n, r) => {
530
+ let c = n.id === J, l = (e) => (t) => Q(t, e), u = (e, t, n) => {
531
+ let r = Q(e, t);
532
+ return /* @__PURE__ */ P("span", {
533
+ className: "lilt-card__pane-value",
534
+ children: [n ? `${n} ` : "", r === null ? "—" : B(r)]
535
+ }, t);
536
+ };
537
+ if (n.kind === "volume") return /* @__PURE__ */ N(G, {
538
+ context: r,
539
+ label: `${w.title} volume`,
540
+ caption: "Volume",
541
+ readout: (e) => /* @__PURE__ */ N("span", {
542
+ className: "lilt-card__pane-value",
543
+ children: Q(e, a) === null ? "—" : V(Q(e, a))
544
+ }),
545
+ height: C,
546
+ xAxis: c,
547
+ y: {
548
+ includeZero: !0,
549
+ ticks: 2,
550
+ format: V
551
+ },
552
+ bars: { series: ["volume"] },
553
+ series: [{
554
+ id: "volume",
555
+ label: "Volume",
556
+ accessor: l(a),
557
+ formatValue: V,
558
+ colorAt: (n) => (Q(n, e) ?? 0) >= (Q(n, t) ?? Q(n, e) ?? 0) ? "color-mix(in srgb, var(--lilt-candle-up) 42%, transparent)" : "color-mix(in srgb, var(--lilt-candle-down) 42%, transparent)",
559
+ bar: { radius: 1 }
560
+ }],
561
+ children: /* @__PURE__ */ N(s, { series: "volume" })
562
+ }, n.id);
563
+ if (n.kind === "rsi") return /* @__PURE__ */ P(G, {
564
+ context: r,
565
+ label: `${w.title} RSI ${n.period}`,
566
+ caption: `RSI ${n.period}`,
567
+ readout: (e) => u(e, n.id),
568
+ height: C,
569
+ xAxis: c,
570
+ y: {
571
+ domain: [0, 100],
572
+ ticks: 2,
573
+ format: (e) => String(Math.round(e))
574
+ },
575
+ series: [{
576
+ id: n.id,
577
+ label: `RSI ${n.period}`,
578
+ accessor: l(n.id),
579
+ color: "var(--lilt-series-1)",
580
+ formatValue: B,
581
+ line: { width: 1.5 }
582
+ }],
583
+ children: [
584
+ /* @__PURE__ */ N(o, {
585
+ axis: "y",
586
+ from: 30,
587
+ to: 70,
588
+ color: "var(--lilt-series-1)"
589
+ }),
590
+ /* @__PURE__ */ N(f, {
591
+ value: 70,
592
+ color: "var(--lilt-muted)"
593
+ }),
594
+ /* @__PURE__ */ N(f, {
595
+ value: 30,
596
+ color: "var(--lilt-muted)"
597
+ }),
598
+ /* @__PURE__ */ N(i, { series: n.id })
599
+ ]
600
+ }, n.id);
601
+ let d = `${n.id}Macd`, p = `${n.id}Signal`, m = `${n.id}Histogram`;
602
+ return /* @__PURE__ */ P(G, {
603
+ context: r,
604
+ label: `${w.title} MACD`,
605
+ caption: `MACD ${n.fast} · ${n.slow} · ${n.signal}`,
606
+ readout: (e) => [u(e, d), u(e, p, "Signal")],
607
+ height: C,
608
+ xAxis: c,
609
+ y: {
610
+ includeZero: !0,
611
+ ticks: 2,
612
+ format: B
613
+ },
614
+ bars: { series: [m] },
615
+ series: [
616
+ {
617
+ id: m,
618
+ label: "Histogram",
619
+ accessor: l(m),
620
+ formatValue: B,
621
+ colorAt: (e) => (Q(e, m) ?? 0) >= 0 ? "color-mix(in srgb, var(--lilt-candle-up) 55%, transparent)" : "color-mix(in srgb, var(--lilt-candle-down) 55%, transparent)",
622
+ bar: { radius: 1 }
623
+ },
624
+ {
625
+ id: d,
626
+ label: "MACD",
627
+ accessor: l(d),
628
+ color: "var(--lilt-series-4)",
629
+ formatValue: B,
630
+ line: { width: 1.5 }
631
+ },
632
+ {
633
+ id: p,
634
+ label: "Signal",
635
+ accessor: l(p),
636
+ color: "var(--lilt-series-3)",
637
+ formatValue: B,
638
+ line: {
639
+ width: 1.5,
640
+ dasharray: "3 3"
641
+ }
642
+ }
643
+ ],
644
+ children: [
645
+ /* @__PURE__ */ N(s, { series: m }),
646
+ /* @__PURE__ */ N(i, { series: d }),
647
+ /* @__PURE__ */ N(i, { series: p })
648
+ ]
649
+ }, n.id);
650
+ };
651
+ return /* @__PURE__ */ N(g, {
652
+ ...w,
653
+ data: L,
654
+ ranges: R,
655
+ delta: b ?? (v && t ? q(v, t, e) : void 0),
656
+ valueFormat: x,
657
+ locale: S,
658
+ aggregate: "last",
659
+ headlineSeries: e,
660
+ pillSeries: e,
661
+ tiles: !1,
662
+ live: m,
663
+ series: [{
664
+ key: e,
665
+ label: d,
666
+ color: E === "line" ? ne ? F : I : void 0
667
+ }, ...A.map((e, t) => ({
668
+ key: e.id,
669
+ label: e.label,
670
+ color: me[t % me.length]
671
+ }))],
672
+ shape: {
673
+ kind: "marks",
674
+ id: `indicator:${E}:${p}:${t}:${n}:${r}:${D}:${O}`,
675
+ includeZero: !1,
676
+ scale: p,
677
+ slots: !0,
678
+ xAxis: j.length === 0,
679
+ series: (e) => {
680
+ let t = U.get(e);
681
+ return t ? {
682
+ curve: "monotone",
683
+ line: {
684
+ width: 1.5,
685
+ showInspectionPoint: !1
686
+ },
687
+ ...t.kind === "bollinger" ? { fields: {
688
+ upper: {
689
+ label: "Upper",
690
+ accessor: (e) => Q(e, `${t.id}Upper`)
691
+ },
692
+ lower: {
693
+ label: "Lower",
694
+ accessor: (e) => Q(e, `${t.id}Lower`)
695
+ }
696
+ } } : {}
697
+ } : E === "line" ? {
698
+ fields: H,
699
+ curve: "linear",
700
+ line: { width: 2 }
701
+ } : { fields: H };
702
+ },
703
+ describe: T ? ee(z) : void 0,
704
+ draw: (e) => e.map((e) => {
705
+ let t = U.get(e);
706
+ return t ? t.kind === "bollinger" ? [/* @__PURE__ */ N(_, {
707
+ series: e,
708
+ lower: "lower",
709
+ upper: "upper"
710
+ }, `band-${e}`), /* @__PURE__ */ N(i, { series: e }, `line-${e}`)] : /* @__PURE__ */ N(i, { series: e }, e) : E === "line" ? /* @__PURE__ */ N(i, { series: e }, e) : /* @__PURE__ */ N(W, {
711
+ series: e,
712
+ open: "open",
713
+ high: "high",
714
+ low: "low",
715
+ display: E
716
+ }, e);
717
+ })
718
+ },
719
+ panes: j.length ? (e) => /* @__PURE__ */ N(M, { children: j.map((t) => Y(t, e)) }) : void 0
720
+ });
721
+ }
722
+ //#endregion
723
+ //#region src/finance/cards/depth-chart-card.tsx
724
+ function ge({ price: e, label: t }) {
725
+ let { snapshot: n } = x();
726
+ if (e < n.xDomain[0] || e > n.xDomain[1]) return null;
727
+ let r = n.xToPixel(e);
728
+ return /* @__PURE__ */ P("g", {
729
+ className: "lilt-card__depth-mid",
730
+ "aria-hidden": "true",
731
+ children: [/* @__PURE__ */ N("line", {
732
+ x1: r,
733
+ x2: r,
734
+ y1: n.plot.top + 18,
735
+ y2: n.plot.bottom,
736
+ strokeDasharray: "2 4",
737
+ vectorEffect: "non-scaling-stroke"
738
+ }), /* @__PURE__ */ N("text", {
739
+ x: r,
740
+ y: n.plot.top + 10,
741
+ textAnchor: "middle",
742
+ children: t
743
+ })]
744
+ });
745
+ }
746
+ var _e = {
747
+ style: "currency",
748
+ currency: "USD",
749
+ minimumFractionDigits: 2,
750
+ maximumFractionDigits: 2
751
+ };
752
+ function ve({ title: t, bids: r, asks: a, valueFormat: o = _e, sizeFormat: s, locale: l = "en-US", height: u = 220, axis: f = "minimal", background: g = "dots", hoverStyle: _ = "soft", surface: v, numberStyle: y, loading: b = !1, motion: x, className: S, style: O }) {
753
+ let A = k(() => le(r, a), [r, a]), M = JSON.stringify(o), L = JSON.stringify(s ?? null), R = k(() => h(l, o), [l, M]), z = k(() => h(l, s), [l, L]), B = k(() => h(l, {
754
+ style: "percent",
755
+ maximumFractionDigits: 3
756
+ }).full, [l]), [V, H] = j(null), U = k(() => [{
757
+ id: "bid",
758
+ label: "Bids",
759
+ accessor: (e) => e.bid,
760
+ color: F,
761
+ curve: "step-before",
762
+ area: { treatment: "fade" },
763
+ line: { width: 1.5 },
764
+ formatValue: z.full
765
+ }, {
766
+ id: "ask",
767
+ label: "Asks",
768
+ accessor: (e) => e.ask,
769
+ color: I,
770
+ curve: "step-after",
771
+ area: { treatment: "fade" },
772
+ line: { width: 1.5 },
773
+ formatValue: z.full
774
+ }], [z]), W = A.spread !== null && A.mid ? `${R.full(A.spread)} (${B(A.spread / A.mid)})` : "—", G = V ? V.bid ?? V.ask : null;
775
+ return /* @__PURE__ */ P(D, {
776
+ "aria-label": t,
777
+ surface: v,
778
+ numberStyle: y,
779
+ motion: x,
780
+ className: ["lilt-card--depth", S].filter(Boolean).join(" "),
781
+ style: O,
782
+ children: [
783
+ /* @__PURE__ */ P(E, { children: [/* @__PURE__ */ N(T, { children: t }), /* @__PURE__ */ N(w, {
784
+ value: A.mid,
785
+ format: R.full,
786
+ loading: b,
787
+ motion: x,
788
+ children: b ? null : V && G !== null ? /* @__PURE__ */ P(C, { children: [
789
+ z.full(G),
790
+ " ",
791
+ V.side === "bid" ? "bid" : "ask",
792
+ " depth at",
793
+ " ",
794
+ R.full(V.price)
795
+ ] }) : /* @__PURE__ */ N(C, { children: "Mid price" })
796
+ })] }),
797
+ /* @__PURE__ */ P("dl", {
798
+ className: "lilt-card__stats",
799
+ children: [
800
+ /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("dt", { children: "Spread" }), /* @__PURE__ */ N("dd", { children: b ? "—" : W })] }),
801
+ /* @__PURE__ */ P("div", {
802
+ "data-side": "bid",
803
+ children: [/* @__PURE__ */ N("dt", { children: "Bid depth" }), /* @__PURE__ */ N("dd", { children: b ? "—" : z.compact(A.bidDepth) })]
804
+ }),
805
+ /* @__PURE__ */ P("div", {
806
+ "data-side": "ask",
807
+ children: [/* @__PURE__ */ N("dt", { children: "Ask depth" }), /* @__PURE__ */ N("dd", { children: b ? "—" : z.compact(A.askDepth) })]
808
+ })
809
+ ]
810
+ }),
811
+ /* @__PURE__ */ N(n, {
812
+ className: "lilt-card__chart",
813
+ "aria-label": `${t} depth by price`,
814
+ data: A.levels,
815
+ x: {
816
+ type: "number",
817
+ accessor: (e) => e.price,
818
+ format: R.full
819
+ },
820
+ y: {
821
+ includeZero: !0,
822
+ ticks: 3,
823
+ format: z.compact
824
+ },
825
+ series: U,
826
+ onSelectionChange: (e) => H(e?.row ?? null),
827
+ motion: x,
828
+ status: b ? "loading" : "ready",
829
+ children: /* @__PURE__ */ P(e, {
830
+ height: u,
831
+ axis: f,
832
+ background: g,
833
+ pill: _,
834
+ margins: {
835
+ top: 8,
836
+ right: 4,
837
+ bottom: 28,
838
+ left: 4
839
+ },
840
+ children: [
841
+ /* @__PURE__ */ N(c, { pattern: "lines" }),
842
+ /* @__PURE__ */ N(d, { series: "bid" }),
843
+ /* @__PURE__ */ N(d, { series: "ask" }),
844
+ /* @__PURE__ */ N(i, { series: "bid" }),
845
+ /* @__PURE__ */ N(i, { series: "ask" }),
846
+ A.mid === null ? null : /* @__PURE__ */ N(ge, {
847
+ price: A.mid,
848
+ label: `Mid ${R.full(A.mid)}`
849
+ }),
850
+ /* @__PURE__ */ N(m, { labels: "fit" }),
851
+ /* @__PURE__ */ N(p, {})
852
+ ]
853
+ })
854
+ })
855
+ ]
856
+ });
857
+ }
858
+ //#endregion
859
+ //#region src/finance/cards/portfolio-chart-card.tsx
860
+ function $(e, t) {
861
+ if (!t) return null;
862
+ let n = e[t];
863
+ return typeof n == "number" && Number.isFinite(n) ? n : null;
864
+ }
865
+ function ye(e, t, n) {
866
+ let r = e.at(-1), i = $(r, t), a = $(r, n);
867
+ return i !== null && a ? i / a - 1 : void 0;
868
+ }
869
+ function be({ value: e, basis: t, label: n = "Value", drawdown: r = !0, drawdownHeight: a = 64, data: o, ranges: s, delta: c, locale: l = "en-US", ...u }) {
870
+ let f = o ?? s?.[0]?.data ?? [], p = k(() => s?.map((n) => ({
871
+ ...n,
872
+ delta: n.delta ?? ye(n.data, e, t)
873
+ })), [
874
+ s,
875
+ e,
876
+ t
877
+ ]), m = k(() => h(l, {
878
+ style: "percent",
879
+ minimumFractionDigits: 1,
880
+ maximumFractionDigits: 1
881
+ }).full, [l]), _ = k(() => {
882
+ let t = oe(f.map((t) => $(t, e))).filter((e) => e !== null);
883
+ return t.length ? Math.min(...t) : null;
884
+ }, [f, e]);
885
+ return /* @__PURE__ */ N(g, {
886
+ ...u,
887
+ data: o,
888
+ ranges: p,
889
+ delta: c ?? (o ? ye(o, e, t) : void 0),
890
+ locale: l,
891
+ aggregate: "last",
892
+ headlineSeries: e,
893
+ pillSeries: e,
894
+ tiles: !1,
895
+ restCaption: t ? () => "over basis" : void 0,
896
+ series: [{
897
+ key: e,
898
+ label: n
899
+ }, ...t ? [{
900
+ key: t,
901
+ label: "Basis",
902
+ dashed: !0
903
+ }] : []],
904
+ shape: {
905
+ kind: "marks",
906
+ id: `portfolio:${e}:${t}:${r}`,
907
+ includeZero: !1,
908
+ xAxis: !r,
909
+ series: (e) => e === t ? {
910
+ curve: "step-after",
911
+ color: "var(--lilt-muted)"
912
+ } : {
913
+ area: { treatment: "fade" },
914
+ curve: "monotone"
915
+ },
916
+ draw: (e) => e.map((e) => [/* @__PURE__ */ N(d, { series: e }, `area-${e}`), /* @__PURE__ */ N(i, { series: e }, e)])
917
+ },
918
+ panes: r ? (t) => {
919
+ let n = oe(t.data.map((t) => $(t, e))), r = new Map(t.data.map((e, t) => [e, n[t] ?? null]));
920
+ return /* @__PURE__ */ P(G, {
921
+ context: t,
922
+ label: `${u.title} drawdown`,
923
+ caption: "Drawdown",
924
+ readout: (e) => /* @__PURE__ */ P(M, { children: [/* @__PURE__ */ N("span", {
925
+ className: "lilt-card__pane-value",
926
+ children: r.get(e) == null ? "—" : m(r.get(e))
927
+ }), _ === null ? null : /* @__PURE__ */ P("span", {
928
+ className: "lilt-card__pane-value",
929
+ children: ["Max ", m(_)]
930
+ })] }),
931
+ height: a,
932
+ xAxis: !0,
933
+ y: {
934
+ includeZero: !0,
935
+ ticks: 2,
936
+ format: m
937
+ },
938
+ series: [{
939
+ id: "drawdown",
940
+ label: "Drawdown",
941
+ accessor: (e) => r.get(e) ?? null,
942
+ color: "var(--lilt-candle-down)",
943
+ formatValue: m,
944
+ area: { treatment: "fade" },
945
+ line: { width: 1.5 },
946
+ curve: "monotone"
947
+ }],
948
+ children: [/* @__PURE__ */ N(d, { series: "drawdown" }), /* @__PURE__ */ N(i, { series: "drawdown" })]
949
+ });
950
+ } : void 0
951
+ });
952
+ }
953
+ //#endregion
954
+ //#region src/finance/cards/price-chart-card.tsx
955
+ function xe(e, t) {
956
+ let n = e[t];
957
+ return typeof n == "number" && Number.isFinite(n) ? n : null;
958
+ }
959
+ function Se(e, t) {
960
+ let n = e.map((e) => xe(e, t)).filter((e) => e !== null);
961
+ return n.length > 1 ? {
962
+ first: n[0],
963
+ last: n.at(-1)
964
+ } : null;
965
+ }
966
+ function Ce(e, t) {
967
+ let n = e.map((e) => ({ ...e }));
968
+ for (let r of t) se(e.map((e) => xe(e, r))).forEach((e, t) => n[t][`__rebased${r}`] = e);
969
+ return n;
970
+ }
971
+ var we = {
972
+ style: "currency",
973
+ currency: "USD",
974
+ minimumFractionDigits: 2,
975
+ maximumFractionDigits: 2
976
+ };
977
+ function Te({ price: e, symbol: t, name: n, icon: r, display: a = "area", versus: o, data: s, ranges: c, delta: u, valueFormat: f = we, locale: p = "en-US", title: m, ..._ }) {
978
+ let v = !!o?.length, y = k(() => [e, ...(o ?? []).map((e) => e.key)], [e, o]), b = k(() => s ? v ? Ce(s, y) : s : void 0, [
979
+ s,
980
+ v,
981
+ y
982
+ ]), x = k(() => c?.map((t) => {
983
+ let n = Se(t.data, e);
984
+ return {
985
+ ...t,
986
+ data: v ? Ce(t.data, y) : t.data,
987
+ delta: t.delta ?? (n && n.first ? n.last / n.first - 1 : void 0)
988
+ };
989
+ }), [
990
+ c,
991
+ v,
992
+ y,
993
+ e
994
+ ]), S = Se(s ?? c?.[0]?.data ?? [], e), C = !S || S.last >= S.first, w = k(() => h(p, f).full, [p, JSON.stringify(f)]), T = k(() => h(p, {
995
+ style: "percent",
996
+ minimumFractionDigits: 1,
997
+ maximumFractionDigits: 1
998
+ }).full, [p]), E = (e) => v ? `__rebased${e}` : e, D = /* @__PURE__ */ P("span", {
999
+ className: "lilt-card__ticker",
1000
+ children: [
1001
+ r ? /* @__PURE__ */ N("span", {
1002
+ className: "lilt-card__ticker-icon",
1003
+ children: r
1004
+ }) : null,
1005
+ /* @__PURE__ */ N("span", {
1006
+ className: "lilt-card__ticker-symbol",
1007
+ children: t ?? m
1008
+ }),
1009
+ n ? /* @__PURE__ */ N("span", {
1010
+ className: "lilt-card__ticker-name",
1011
+ children: n
1012
+ }) : null
1013
+ ]
1014
+ });
1015
+ return /* @__PURE__ */ N(g, {
1016
+ ..._,
1017
+ title: m,
1018
+ heading: D,
1019
+ data: b,
1020
+ ranges: x,
1021
+ delta: v ? void 0 : u ?? (s && S && S.first ? S.last / S.first - 1 : void 0),
1022
+ valueFormat: v ? {
1023
+ style: "percent",
1024
+ maximumFractionDigits: 1
1025
+ } : f,
1026
+ formatValue: v ? (e) => l(T)(e) : void 0,
1027
+ locale: p,
1028
+ aggregate: "last",
1029
+ headlineSeries: E(e),
1030
+ pillSeries: v ? "nearest" : E(e),
1031
+ tiles: v,
1032
+ restCaption: v ? void 0 : (t) => {
1033
+ let n = Se(t, e);
1034
+ return n ? l(w)(n.last - n.first) : null;
1035
+ },
1036
+ series: [{
1037
+ key: E(e),
1038
+ label: t ?? m,
1039
+ color: v ? void 0 : C ? F : I
1040
+ }, ...(o ?? []).map((e) => ({
1041
+ ...e,
1042
+ key: E(e.key)
1043
+ }))],
1044
+ shape: {
1045
+ kind: "marks",
1046
+ id: `price:${a}:${y.join()}:${v}`,
1047
+ includeZero: v,
1048
+ series: () => a === "area" && !v ? {
1049
+ area: { treatment: "fade" },
1050
+ curve: "monotone"
1051
+ } : { curve: "monotone" },
1052
+ draw: (e) => e.map((e) => a === "area" && !v ? [/* @__PURE__ */ N(d, { series: e }, `area-${e}`), /* @__PURE__ */ N(i, { series: e }, e)] : /* @__PURE__ */ N(i, { series: e }, e))
1053
+ },
1054
+ bleed: _.bleed ?? !0
1055
+ });
1056
+ }
1057
+ //#endregion
1058
+ //#region src/finance/order-book.tsx
1059
+ function Ee(e, t, n) {
1060
+ let r = /* @__PURE__ */ new Map();
1061
+ for (let t of e) Number.isFinite(t.price) && Number.isFinite(t.size) && t.size > 0 && r.set(t.price, (r.get(t.price) ?? 0) + t.size);
1062
+ let i = [...r].map(([e, t]) => ({
1063
+ price: e,
1064
+ size: t
1065
+ })).sort((e, n) => t === "bid" ? n.price - e.price : e.price - n.price).slice(0, n), a = 0;
1066
+ return i.map((e) => (a += e.size, {
1067
+ ...e,
1068
+ total: a,
1069
+ side: t
1070
+ }));
1071
+ }
1072
+ function De(e, t) {
1073
+ let n = A(null), [r, i] = j(/* @__PURE__ */ new Set());
1074
+ return O(() => {
1075
+ let r = new Map(e.map((e) => [`${e.side}:${e.price}`, e.size])), a = n.current;
1076
+ if (n.current = r, !t || !a) return;
1077
+ let o = new Set([...r].filter(([e, t]) => a.get(e) !== t).map(([e]) => e));
1078
+ if (!o.size) return;
1079
+ i(o);
1080
+ let s = window.setTimeout(() => i(/* @__PURE__ */ new Set()), 600);
1081
+ return () => window.clearTimeout(s);
1082
+ }, [e, t]), r;
1083
+ }
1084
+ function Oe({ title: e, bids: t, asks: n, depth: r = 8, valueFormat: i = {
1085
+ minimumFractionDigits: 2,
1086
+ maximumFractionDigits: 2
1087
+ }, sizeFormat: a, locale: o = "en-US", flash: s = !0, surface: c, motion: l, className: u, style: d }) {
1088
+ let f = S(l ?? "auto"), p = JSON.stringify(i), m = JSON.stringify(a ?? null), g = k(() => h(o, i).full, [o, p]), _ = k(() => h(o, a).compact, [o, m]), v = k(() => h(o, {
1089
+ style: "percent",
1090
+ maximumFractionDigits: 3
1091
+ }).full, [o]), y = k(() => Ee(t, "bid", r), [t, r]), b = k(() => Ee(n, "ask", r), [n, r]), x = De(k(() => [...b, ...y], [b, y]), s && !f), C = Math.max(1, b.at(-1)?.total ?? 0, y.at(-1)?.total ?? 0), w = y[0]?.price, T = b[0]?.price, E = w !== void 0 && T !== void 0 ? {
1092
+ value: T - w,
1093
+ mid: (T + w) / 2
1094
+ } : null, O = (e) => /* @__PURE__ */ P("tr", {
1095
+ className: "lilt-order-book__level",
1096
+ "data-side": e.side,
1097
+ "data-flash": x.has(`${e.side}:${e.price}`) || void 0,
1098
+ style: { "--lilt-depth": `${e.total / C * 100}%` },
1099
+ children: [
1100
+ /* @__PURE__ */ N("th", {
1101
+ scope: "row",
1102
+ children: g(e.price)
1103
+ }),
1104
+ /* @__PURE__ */ N("td", { children: _(e.size) }),
1105
+ /* @__PURE__ */ N("td", { children: _(e.total) })
1106
+ ]
1107
+ }, `${e.side}:${e.price}`);
1108
+ return /* @__PURE__ */ N(D, {
1109
+ "aria-label": e,
1110
+ surface: c,
1111
+ motion: l,
1112
+ className: ["lilt-card--order-book", u].filter(Boolean).join(" "),
1113
+ style: d,
1114
+ children: /* @__PURE__ */ P("table", {
1115
+ className: "lilt-order-book",
1116
+ children: [
1117
+ /* @__PURE__ */ N("caption", { children: e }),
1118
+ /* @__PURE__ */ N("thead", { children: /* @__PURE__ */ P("tr", { children: [
1119
+ /* @__PURE__ */ N("th", {
1120
+ scope: "col",
1121
+ children: "Price"
1122
+ }),
1123
+ /* @__PURE__ */ N("th", {
1124
+ scope: "col",
1125
+ children: "Size"
1126
+ }),
1127
+ /* @__PURE__ */ N("th", {
1128
+ scope: "col",
1129
+ children: "Total"
1130
+ })
1131
+ ] }) }),
1132
+ /* @__PURE__ */ N("tbody", {
1133
+ "aria-label": "Asks",
1134
+ children: [...b].reverse().map(O)
1135
+ }),
1136
+ /* @__PURE__ */ N("tbody", {
1137
+ "aria-label": "Spread",
1138
+ children: /* @__PURE__ */ P("tr", {
1139
+ className: "lilt-order-book__spread",
1140
+ children: [/* @__PURE__ */ N("th", {
1141
+ scope: "row",
1142
+ children: E ? g(E.mid) : "—"
1143
+ }), /* @__PURE__ */ N("td", {
1144
+ colSpan: 2,
1145
+ children: E ? `Spread ${g(E.value)} · ${v(E.value / E.mid)}` : "No spread"
1146
+ })]
1147
+ })
1148
+ }),
1149
+ /* @__PURE__ */ N("tbody", {
1150
+ "aria-label": "Bids",
1151
+ children: y.map(O)
1152
+ })
1153
+ ]
1154
+ })
1155
+ });
1156
+ }
1157
+ //#endregion
1158
+ export { W as Candles, ne as CandlestickChartCard, ve as DepthChartCard, he as IndicatorChartCard, Oe as OrderBook, be as PortfolioChartCard, Te as PriceChartCard, ae as bollinger, le as depthLevels, oe as drawdown, Z as ema, ie as macd, se as rebase, re as rsi, X as sma };