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