@lilt-ui/charts 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/finance.js CHANGED
@@ -1,14 +1,15 @@
1
1
  "use client";
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-Uf1lywJi.js";
3
- import { S as D, d as O, g as k, h as A, p as j, u as ee } from "./report-context-Cz0AYdV2.js";
2
+ import { A as e, C as t, I as n, J as r, L as i, P as a, Q as o, R as s, S as c, T as l, _ as u, a as d, b as f, f as p, ht as m, i as h, n as g, nt as _, ot as v, q 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-DvtzSsgP.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
4
  import { useEffect as M, useMemo as N, useRef as P, useState as F } from "react";
5
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 z = "var(--lilt-candle-up)", B = "var(--lilt-candle-down)";
8
- function V(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 H(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,22 +19,22 @@ function H(e, t, n) {
18
19
  up: s >= i
19
20
  };
20
21
  }
21
- function U(e, t, n) {
22
+ function W(e, t, n) {
22
23
  for (let r of e) {
23
- let e = H(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 W(e, t, n, r, i = !1) {
30
- let a = Math.max(1, n.columnWidth), s = a / 2, c = V(e), l = V(n.y(t.high)), u = V(n.y(t.low));
30
+ function G(e, t, n, r, i = !1) {
31
+ let o = Math.max(1, n.columnWidth), s = o / 2, c = H(e), l = H(n.y(t.high)), u = H(n.y(t.low));
31
32
  if (r === "ohlc") {
32
- let r = V(n.y(t.open)), i = V(n.y(t.close)), a = V(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${c},${l}V${u}M${V(e - a)},${r}H${c}M${c},${i}H${V(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
  };
@@ -43,21 +44,21 @@ function W(e, t, n, r, i = !1) {
43
44
  let e = (d + f) / 2;
44
45
  d = e - .5, f = e + .5;
45
46
  }
46
- 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${V(d)}` : "") + (u > f ? `M${c},${V(f)}V${u}` : "");
47
+ let p = r === "hollow" && t.up && o >= 3, m = p ? .5 : 0, h = i ? _(e, d, o, f - d) : null, g = h ? e - h.frontWidth / 2 : e - s, v = a(g + m, d + m, Math.max(1, (h ? h.frontWidth : o) - m * 2), Math.max(1, f - d - m * 2), !h && o >= 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
49
  body: p ? null : v,
49
50
  hollow: p ? v : null,
50
51
  stroke: y,
51
- side: g?.side ?? null,
52
- top: g?.top ?? null
52
+ side: h?.side ?? null,
53
+ top: h?.top ?? null
53
54
  };
54
55
  }
55
- function te(t, n, r, i, a, o, s = !1) {
56
+ function K(t, n, r, i, a, o, s = !1) {
56
57
  let c = new l(), u = new l(), d = new l(), f = new l(), p = new l();
57
58
  for (let { row: l, cx: m } of e(t, i)) {
58
- let e = H(l, n, r);
59
+ let e = U(l, n, r);
59
60
  if (!e) continue;
60
- let t = o(l, e), h = W(m, e, i, a, s);
61
+ let t = o(l, e), h = G(m, e, i, a, s);
61
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 {
@@ -70,8 +71,8 @@ function te(t, n, r, i, a, o, s = !1) {
70
71
  }
71
72
  //#endregion
72
73
  //#region src/finance/candles.tsx
73
- function G(e, t, n) {
74
- return E(e, t, n.up ? z : B);
74
+ function te(e, t, n) {
75
+ return E(e, t, n.up ? B : V);
75
76
  }
76
77
  function ne({ paths: e, display: t }) {
77
78
  let n = t === "ohlc" ? 1.5 : 1;
@@ -85,11 +86,11 @@ function ne({ paths: e, display: t }) {
85
86
  }, `stroke-${e}`)),
86
87
  e.sides.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
87
88
  d: t,
88
- style: { fill: u(e).side }
89
+ style: { fill: o(e).side }
89
90
  }, `side-${e}`)),
90
91
  e.tops.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
91
92
  d: t,
92
- style: { fill: u(e).top }
93
+ style: { fill: o(e).top }
93
94
  }, `top-${e}`)),
94
95
  e.bodies.map(({ color: e, d: t }) => /* @__PURE__ */ L("path", {
95
96
  d: t,
@@ -105,24 +106,24 @@ function ne({ paths: e, display: t }) {
105
106
  }, `hollow-${e}`))
106
107
  ] });
107
108
  }
108
- var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle", depth: o = !1, className: s }) {
109
+ var re = s(function({ series: e, open: t, high: n, low: i, display: a = "candle", depth: o = !1, className: s }) {
109
110
  let c = C("Candles", e, [
110
111
  t,
111
112
  n,
112
- r
113
+ i
113
114
  ], "column"), { snapshot: l, descriptor: u, scales: d } = c, f = N(() => {
114
- let i = {
115
+ let r = {
115
116
  open: t,
116
117
  high: n,
117
- low: r
118
+ low: i
118
119
  };
119
- return U(l.data.rows, e, i), te(l.data.rows, e, i, d, a, (e, t) => G(u, e, t), o);
120
+ return W(l.data.rows, e, r), K(l.data.rows, e, r, d, a, (e, t) => te(u, e, t), o);
120
121
  }, [
121
122
  l,
122
123
  e,
123
124
  t,
124
125
  n,
125
- r,
126
+ i,
126
127
  d,
127
128
  a,
128
129
  u,
@@ -139,7 +140,7 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
139
140
  opacity: c.opacity,
140
141
  transition: c.reducedMotion ? void 0 : "opacity 160ms ease-out"
141
142
  },
142
- children: [o ? /* @__PURE__ */ L(i, { clip: c.depthClip }) : null, /* @__PURE__ */ L(ne, {
143
+ children: [o ? /* @__PURE__ */ L(r, { clip: c.depthClip }) : null, /* @__PURE__ */ L(ne, {
143
144
  paths: f,
144
145
  display: a
145
146
  })]
@@ -150,36 +151,36 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
150
151
  kind: e.display === "ohlc" ? "ohlc" : "candle",
151
152
  depth: e.depth && e.display !== "ohlc",
152
153
  render: ({ cx: t, low: n, high: r, scales: i, mask: a }) => {
153
- let o = a ? "white" : "color-mix(in srgb, var(--lilt-skeleton) 64%, var(--lilt-surface))", s = W(t, {
154
+ let s = a ? "white" : "color-mix(in srgb, var(--lilt-skeleton) 64%, var(--lilt-surface))", c = G(t, {
154
155
  low: n,
155
156
  high: r,
156
157
  open: n + (r - n) * .28,
157
158
  close: r - (r - n) * .23,
158
159
  up: !0
159
- }, i, e.display ?? "candle", e.depth), c = u(o);
160
+ }, i, e.display ?? "candle", e.depth), l = o(s);
160
161
  return /* @__PURE__ */ R(I, { children: [
161
- s.stroke ? /* @__PURE__ */ L("path", {
162
- d: s.stroke,
162
+ c.stroke ? /* @__PURE__ */ L("path", {
163
+ d: c.stroke,
163
164
  fill: "none",
164
- stroke: o,
165
+ stroke: s,
165
166
  strokeWidth: 1.5
166
167
  }) : null,
167
- s.side ? /* @__PURE__ */ L("path", {
168
- d: s.side,
169
- fill: a ? o : c.side
168
+ c.side ? /* @__PURE__ */ L("path", {
169
+ d: c.side,
170
+ fill: a ? s : l.side
170
171
  }) : null,
171
- s.top ? /* @__PURE__ */ L("path", {
172
- d: s.top,
173
- fill: a ? o : c.top
172
+ c.top ? /* @__PURE__ */ L("path", {
173
+ d: c.top,
174
+ fill: a ? s : l.top
174
175
  }) : null,
175
- s.body ? /* @__PURE__ */ L("path", {
176
- d: s.body,
177
- fill: o
176
+ c.body ? /* @__PURE__ */ L("path", {
177
+ d: c.body,
178
+ fill: s
178
179
  }) : null,
179
- s.hollow ? /* @__PURE__ */ L("path", {
180
- d: s.hollow,
180
+ c.hollow ? /* @__PURE__ */ L("path", {
181
+ d: c.hollow,
181
182
  fill: a ? "black" : "var(--lilt-surface)",
182
- stroke: o
183
+ stroke: s
183
184
  }) : null
184
185
  ] });
185
186
  }
@@ -191,9 +192,9 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
191
192
  e.low
192
193
  ],
193
194
  highlight: (e, { row: n, snapshot: r, descriptor: i }) => {
194
- let a = H(n, e.series, e);
195
+ let a = U(n, e.series, e);
195
196
  if (!a) return null;
196
- let o = e.display ?? "candle", s = t(r, e.series), c = W(s.x(n.x), a, s, o, e.depth), l = G(i, n, a);
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);
197
198
  return /* @__PURE__ */ L("g", {
198
199
  className: "lilt-chart__candle-highlight",
199
200
  children: /* @__PURE__ */ L(ne, {
@@ -226,8 +227,8 @@ var re = s(function({ series: e, open: t, high: n, low: r, display: a = "candle"
226
227
  });
227
228
  //#endregion
228
229
  //#region src/finance/cards/pane.tsx
229
- function K({ context: e, label: t, caption: n, readout: r, series: i, height: o, y: s, bars: c, xAxis: l = !1, children: u }) {
230
- let [f, p] = F(null), m = f ?? e.data.at(-1) ?? null;
230
+ function q({ context: e, label: t, caption: n, readout: r, series: a, height: o, y: s, bars: c, xAxis: l = !1, children: d }) {
231
+ let [f, p] = F(null), h = f ?? e.data.at(-1) ?? null;
231
232
  return /* @__PURE__ */ R("div", {
232
233
  className: "lilt-card__pane",
233
234
  children: [n ? /* @__PURE__ */ R("span", {
@@ -236,20 +237,20 @@ function K({ context: e, label: t, caption: n, readout: r, series: i, height: o,
236
237
  children: [/* @__PURE__ */ L("span", {
237
238
  className: "lilt-card__pane-name",
238
239
  children: n
239
- }), r && m && !e.loading ? r(m) : null]
240
- }) : null, /* @__PURE__ */ L(y, {
240
+ }), r && h && !e.loading ? r(h) : null]
241
+ }) : null, /* @__PURE__ */ L(m, {
241
242
  className: "lilt-card__chart",
242
243
  "aria-label": t,
243
244
  data: e.data,
244
245
  x: e.x,
245
246
  y: s,
246
- series: i,
247
+ series: a,
247
248
  controller: e.controller,
248
249
  onSelectionChange: r ? (e) => p(e?.row ?? null) : void 0,
249
250
  motion: e.motion,
250
251
  status: e.loading ? "loading" : "ready",
251
252
  loadingStyle: e.loadingStyle,
252
- children: /* @__PURE__ */ R(a, {
253
+ children: /* @__PURE__ */ R(i, {
253
254
  height: o,
254
255
  margins: {
255
256
  ...e.margins,
@@ -262,19 +263,19 @@ function K({ context: e, label: t, caption: n, readout: r, series: i, height: o,
262
263
  slots: e.slots || !!c,
263
264
  bars: c,
264
265
  background: "none",
265
- children: [u, l ? /* @__PURE__ */ L(d, { labels: "fit" }) : null]
266
+ children: [d, l ? /* @__PURE__ */ L(u, { labels: "fit" }) : null]
266
267
  })
267
268
  })]
268
269
  });
269
270
  }
270
271
  //#endregion
271
272
  //#region src/finance/cards/candlestick-chart-card.tsx
272
- function q(e, t) {
273
+ function J(e, t) {
273
274
  let n = e[t];
274
275
  return typeof n == "number" && Number.isFinite(n) ? n : null;
275
276
  }
276
- function J(e, t, n) {
277
- 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;
278
279
  return r && i !== null ? i / r - 1 : void 0;
279
280
  }
280
281
  function ie(e) {
@@ -287,47 +288,47 @@ var ae = {
287
288
  minimumFractionDigits: 2,
288
289
  maximumFractionDigits: 2
289
290
  };
290
- 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 }) {
291
- let x = N(() => g(_, h).full, [_, JSON.stringify(h)]), S = N(() => g(_).compact, [_]), C = N(() => f?.map((t) => ({
291
+ function oe({ open: e, high: t, low: r, close: i, volume: a, display: o = "candle", depth: s = !1, scale: c = "linear", label: l = "Price", live: u = !1, data: d, ranges: p, delta: m, valueFormat: _ = ae, locale: v = "en-US", volumeHeight: y = 64, ...b }) {
292
+ let x = N(() => h(v, _).full, [v, JSON.stringify(_)]), S = N(() => h(v).compact, [v]), C = N(() => p?.map((t) => ({
292
293
  ...t,
293
- delta: t.delta ?? J(t.data, e, i)
294
+ delta: t.delta ?? Y(t.data, e, i)
294
295
  })), [
295
- f,
296
+ p,
296
297
  e,
297
298
  i
298
- ]), T = (J(d ?? f?.[0]?.data ?? [], e, i) ?? 0) >= 0, E = (t) => (q(t, i) ?? 0) >= (q(t, e) ?? 0), D = o === "area", O = {
299
+ ]), T = (Y(d ?? p?.[0]?.data ?? [], e, i) ?? 0) >= 0, E = (t) => (J(t, i) ?? 0) >= (J(t, e) ?? 0), D = o === "area", O = {
299
300
  open: {
300
301
  label: "Open",
301
- accessor: (t) => q(t, e)
302
+ accessor: (t) => J(t, e)
302
303
  },
303
304
  high: {
304
305
  label: "High",
305
- accessor: (e) => q(e, t)
306
+ accessor: (e) => J(e, t)
306
307
  },
307
308
  low: {
308
309
  label: "Low",
309
- accessor: (e) => q(e, n)
310
+ accessor: (e) => J(e, r)
310
311
  }
311
312
  };
312
- return /* @__PURE__ */ L(v, {
313
+ return /* @__PURE__ */ L(g, {
313
314
  ...b,
314
315
  depth: s,
315
316
  data: d,
316
317
  ranges: C,
317
- delta: m ?? (d ? J(d, e, i) : void 0),
318
- valueFormat: h,
319
- locale: _,
318
+ delta: m ?? (d ? Y(d, e, i) : void 0),
319
+ valueFormat: _,
320
+ locale: v,
320
321
  aggregate: "last",
321
322
  tiles: !1,
322
323
  live: u,
323
324
  series: [{
324
325
  key: i,
325
326
  label: l,
326
- color: D ? T ? z : B : void 0
327
+ color: D ? T ? B : V : void 0
327
328
  }],
328
329
  shape: {
329
330
  kind: "marks",
330
- id: `candles:${o}:${s}:${c}:${e}:${t}:${n}:${!!a}`,
331
+ id: `candles:${o}:${s}:${c}:${e}:${t}:${r}:${!!a}`,
331
332
  includeZero: !1,
332
333
  scale: c,
333
334
  slots: !0,
@@ -341,7 +342,7 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
341
342
  line: { showInspectionPoint: !1 }
342
343
  },
343
344
  describe: ie(x),
344
- draw: (e) => e.map((e) => D ? [/* @__PURE__ */ L(r, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, `line-${e}`)] : /* @__PURE__ */ L(re, {
345
+ draw: (e) => e.map((e) => D ? [/* @__PURE__ */ L(n, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, `line-${e}`)] : /* @__PURE__ */ L(re, {
345
346
  series: e,
346
347
  open: "open",
347
348
  high: "high",
@@ -350,7 +351,7 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
350
351
  depth: s
351
352
  }, e))
352
353
  },
353
- panes: a ? (e) => /* @__PURE__ */ L(K, {
354
+ panes: a ? (e) => /* @__PURE__ */ L(q, {
354
355
  context: e,
355
356
  label: `${b.title} volume`,
356
357
  caption: "Volume",
@@ -365,18 +366,18 @@ function oe({ open: e, high: t, low: n, close: i, volume: a, display: o = "candl
365
366
  series: [{
366
367
  id: "volume",
367
368
  label: "Volume",
368
- accessor: (e) => q(e, a),
369
+ accessor: (e) => J(e, a),
369
370
  formatValue: S,
370
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)",
371
372
  bar: { radius: 1 }
372
373
  }],
373
- children: /* @__PURE__ */ L(p, { series: "volume" })
374
+ children: /* @__PURE__ */ L(f, { series: "volume" })
374
375
  }) : void 0
375
376
  });
376
377
  }
377
378
  //#endregion
378
379
  //#region src/finance/indicators.ts
379
- function Y(e) {
380
+ function X(e) {
380
381
  return typeof e == "number" && Number.isFinite(e);
381
382
  }
382
383
  function se(e, t) {
@@ -387,17 +388,17 @@ function ce(e, t) {
387
388
  let n = [], r = 0, i = 0;
388
389
  for (let a = 0; a < e.length; a += 1) {
389
390
  let o = e[a];
390
- Y(o) && (r += o, i += 1);
391
+ X(o) && (r += o, i += 1);
391
392
  let s = a - t >= 0 ? e[a - t] : void 0;
392
- 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);
393
394
  }
394
395
  return n;
395
396
  }
396
- function X(e, t) {
397
+ function Z(e, t) {
397
398
  se("ema", t);
398
399
  let n = 2 / (t + 1), r = [], i = null, a = [];
399
400
  for (let o of e) {
400
- if (!Y(o)) {
401
+ if (!X(o)) {
401
402
  r.push(null);
402
403
  continue;
403
404
  }
@@ -413,7 +414,7 @@ function le(e, t = 14) {
413
414
  se("rsi", t);
414
415
  let n = e.map(() => null), r = null, i = 0, a = 0, o = 0, s = 0, c = 0;
415
416
  return e.forEach((e, l) => {
416
- if (!Y(e)) return;
417
+ if (!X(e)) return;
417
418
  if (r === null) {
418
419
  r = e;
419
420
  return;
@@ -430,10 +431,10 @@ function le(e, t = 14) {
430
431
  }
431
432
  function ue(e, t = 12, n = 26, r = 9) {
432
433
  if (t >= n) throw Error("Lilt macd needs a fast period shorter than the slow period.");
433
- 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) => {
434
435
  let n = i[t], r = a[t];
435
436
  return n === null || r === null ? null : n - r;
436
- }), s = X(o, r);
437
+ }), s = Z(o, r);
437
438
  return {
438
439
  macd: o,
439
440
  signal: s,
@@ -462,14 +463,14 @@ function de(e, t = 20, n = 2) {
462
463
  }
463
464
  function fe(e) {
464
465
  let t = -Infinity;
465
- 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);
466
467
  }
467
468
  function pe(e) {
468
- let t = e.find(Y);
469
- return e.map((e) => Y(e) && t !== void 0 && t !== 0 ? e / t - 1 : null);
469
+ let t = e.find(X);
470
+ return e.map((e) => X(e) && t !== void 0 && t !== 0 ? e / t - 1 : null);
470
471
  }
471
472
  function me(e, t) {
472
- 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}.`);
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}.`);
473
474
  }
474
475
  function he(e, t) {
475
476
  me("bids", e), me("asks", t);
@@ -532,17 +533,17 @@ function _e(e) {
532
533
  };
533
534
  });
534
535
  }
535
- function Z(e, t) {
536
+ function Q(e, t) {
536
537
  if (!t) return null;
537
538
  let n = e[t];
538
539
  return typeof n == "number" && Number.isFinite(n) ? n : null;
539
540
  }
540
541
  function ve(e, t, n, r) {
541
- let i = e.map((e) => Z(e, t)), a = e.map((e) => ({ ...e })), o = (e, t) => t.forEach((t, n) => a[n][e] = t);
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);
542
543
  for (let e of n) if (e.kind === "bollinger") {
543
544
  let t = de(i, e.period, e.deviations);
544
545
  o(e.id, t.middle), o(`${e.id}Upper`, t.upper), o(`${e.id}Lower`, t.lower);
545
- } else o(e.id, (e.kind === "sma" ? ce : X)(i, e.period));
546
+ } else o(e.id, (e.kind === "sma" ? ce : Z)(i, e.period));
546
547
  for (let e of r) if (e.kind === "rsi" && o(e.id, le(i, e.period)), e.kind === "macd") {
547
548
  let t = ue(i, e.fast, e.slow, e.signal);
548
549
  o(`${e.id}Macd`, t.macd), o(`${e.id}Signal`, t.signal), o(`${e.id}Histogram`, t.histogram);
@@ -557,54 +558,54 @@ var ye = {
557
558
  "var(--lilt-series-3)",
558
559
  "var(--lilt-series-5)"
559
560
  ];
560
- 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 }) {
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: m, ranges: _, delta: v, valueFormat: y = ye, locale: b = "en-US", paneHeight: S = 72, ...C }) {
561
562
  let T = !!(t && n && r), E = a ?? (T ? "candle" : "line");
562
563
  if (E !== "line" && !T) throw Error("Lilt IndicatorChartCard candles need open, high and low fields.");
563
564
  let D = JSON.stringify(o), O = JSON.stringify(s), k = N(() => ge(o), [D]), A = N(() => _e(s), [O]);
564
565
  if (A.some((e) => e.kind === "volume") && !i) throw Error("Lilt IndicatorChartCard needs a `volume` field for a volume pane.");
565
- let j = N(() => f ? ve(f, e, k, A) : void 0, [
566
- f,
566
+ let j = N(() => m ? ve(m, e, k, A) : void 0, [
567
+ m,
567
568
  e,
568
569
  k,
569
570
  A
570
- ]), ee = N(() => m?.map((n) => ({
571
+ ]), ee = N(() => _?.map((n) => ({
571
572
  ...n,
572
573
  data: ve(n.data, e, k, A),
573
- delta: n.delta ?? (t ? J(n.data, t, e) : void 0)
574
+ delta: n.delta ?? (t ? Y(n.data, t, e) : void 0)
574
575
  })), [
575
- m,
576
+ _,
576
577
  e,
577
578
  t,
578
579
  k,
579
580
  A
580
- ]), M = N(() => g(b, y).full, [b, JSON.stringify(y)]), P = N(() => g(b, { maximumFractionDigits: 2 }).full, [b]), F = N(() => g(b).compact, [b]), V = T ? {
581
+ ]), M = N(() => h(b, y).full, [b, JSON.stringify(y)]), P = N(() => h(b, { maximumFractionDigits: 2 }).full, [b]), F = N(() => h(b).compact, [b]), z = T ? {
581
582
  open: {
582
583
  label: "Open",
583
- accessor: (e) => Z(e, t)
584
+ accessor: (e) => Q(e, t)
584
585
  },
585
586
  high: {
586
587
  label: "High",
587
- accessor: (e) => Z(e, n)
588
+ accessor: (e) => Q(e, n)
588
589
  },
589
590
  low: {
590
591
  label: "Low",
591
- accessor: (e) => Z(e, r)
592
+ accessor: (e) => Q(e, r)
592
593
  }
593
- } : void 0, H = new Map(k.map((e) => [e.id, e])), U = f?.length ? Z(f[0], e) : null, W = f?.length ? Z(f.at(-1), e) : null, te = U === null || W === null || W >= U, G = A.at(-1)?.id, ne = (n, r) => {
594
- let a = n.id === G, o = (e) => (t) => Z(t, e), s = (e, t, n) => {
595
- let r = Z(e, t);
594
+ } : void 0, H = new Map(k.map((e) => [e.id, e])), U = m?.length ? Q(m[0], e) : null, W = m?.length ? Q(m.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);
596
597
  return /* @__PURE__ */ R("span", {
597
598
  className: "lilt-card__pane-value",
598
599
  children: [n ? `${n} ` : "", r === null ? "—" : P(r)]
599
600
  }, t);
600
601
  };
601
- if (n.kind === "volume") return /* @__PURE__ */ L(K, {
602
+ if (n.kind === "volume") return /* @__PURE__ */ L(q, {
602
603
  context: r,
603
604
  label: `${C.title} volume`,
604
605
  caption: "Volume",
605
606
  readout: (e) => /* @__PURE__ */ L("span", {
606
607
  className: "lilt-card__pane-value",
607
- children: Z(e, i) === null ? "—" : F(Z(e, i))
608
+ children: Q(e, i) === null ? "—" : F(Q(e, i))
608
609
  }),
609
610
  height: S,
610
611
  xAxis: a,
@@ -619,12 +620,12 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
619
620
  label: "Volume",
620
621
  accessor: o(i),
621
622
  formatValue: F,
622
- 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)",
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)",
623
624
  bar: { radius: 1 }
624
625
  }],
625
- children: /* @__PURE__ */ L(p, { series: "volume" })
626
+ children: /* @__PURE__ */ L(f, { series: "volume" })
626
627
  }, n.id);
627
- if (n.kind === "rsi") return /* @__PURE__ */ R(K, {
628
+ if (n.kind === "rsi") return /* @__PURE__ */ R(q, {
628
629
  context: r,
629
630
  label: `${C.title} RSI ${n.period}`,
630
631
  caption: `RSI ${n.period}`,
@@ -648,7 +649,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
648
649
  }
649
650
  }],
650
651
  children: [
651
- /* @__PURE__ */ L(h, {
652
+ /* @__PURE__ */ L(p, {
652
653
  axis: "y",
653
654
  from: 30,
654
655
  to: 70,
@@ -666,7 +667,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
666
667
  ]
667
668
  }, n.id);
668
669
  let c = `${n.id}Macd`, l = `${n.id}Signal`, u = `${n.id}Histogram`;
669
- return /* @__PURE__ */ R(K, {
670
+ return /* @__PURE__ */ R(q, {
670
671
  context: r,
671
672
  label: `${C.title} MACD`,
672
673
  caption: `MACD ${n.fast} · ${n.slow} · ${n.signal}`,
@@ -685,7 +686,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
685
686
  label: "Histogram",
686
687
  accessor: o(u),
687
688
  formatValue: P,
688
- colorAt: (e) => (Z(e, u) ?? 0) >= 0 ? "color-mix(in srgb, var(--lilt-candle-up) 55%, transparent)" : "color-mix(in srgb, var(--lilt-candle-down) 55%, transparent)",
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)",
689
690
  bar: { radius: 1 }
690
691
  },
691
692
  {
@@ -712,17 +713,17 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
712
713
  }
713
714
  ],
714
715
  children: [
715
- /* @__PURE__ */ L(p, { series: u }),
716
+ /* @__PURE__ */ L(f, { series: u }),
716
717
  /* @__PURE__ */ L(w, { series: c }),
717
718
  /* @__PURE__ */ L(w, { series: l })
718
719
  ]
719
720
  }, n.id);
720
721
  };
721
- return /* @__PURE__ */ L(v, {
722
+ return /* @__PURE__ */ L(g, {
722
723
  ...C,
723
724
  data: j,
724
725
  ranges: ee,
725
- delta: _ ?? (f && t ? J(f, t, e) : void 0),
726
+ delta: v ?? (m && t ? Y(m, t, e) : void 0),
726
727
  valueFormat: y,
727
728
  locale: b,
728
729
  aggregate: "last",
@@ -733,7 +734,7 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
733
734
  series: [{
734
735
  key: e,
735
736
  label: l,
736
- color: E === "line" ? te ? z : B : void 0
737
+ color: E === "line" ? G ? B : V : void 0
737
738
  }, ...k.map((e, t) => ({
738
739
  key: e.id,
739
740
  label: e.label,
@@ -758,21 +759,21 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
758
759
  ...t.kind === "bollinger" ? { fields: {
759
760
  upper: {
760
761
  label: "Upper",
761
- accessor: (e) => Z(e, `${t.id}Upper`)
762
+ accessor: (e) => Q(e, `${t.id}Upper`)
762
763
  },
763
764
  lower: {
764
765
  label: "Lower",
765
- accessor: (e) => Z(e, `${t.id}Lower`)
766
+ accessor: (e) => Q(e, `${t.id}Lower`)
766
767
  }
767
768
  } } : {}
768
769
  } : E === "line" ? {
769
- fields: V,
770
+ fields: z,
770
771
  curve: "linear",
771
772
  line: {
772
773
  width: 2,
773
774
  depth: C.depth
774
775
  }
775
- } : { fields: V };
776
+ } : { fields: z };
776
777
  },
777
778
  describe: T ? ie(M) : void 0,
778
779
  draw: (e) => e.map((e) => {
@@ -791,13 +792,13 @@ function xe({ close: e, open: t, high: n, low: r, volume: i, display: a, overlay
791
792
  }, e);
792
793
  })
793
794
  },
794
- panes: A.length ? (e) => /* @__PURE__ */ L(I, { children: A.map((t) => ne(t, e)) }) : void 0
795
+ panes: A.length ? (e) => /* @__PURE__ */ L(I, { children: A.map((t) => te(t, e)) }) : void 0
795
796
  });
796
797
  }
797
798
  //#endregion
798
799
  //#region src/finance/cards/depth-chart-card.tsx
799
800
  function Se({ price: e, label: t }) {
800
- let { snapshot: n } = _();
801
+ let { snapshot: n } = v();
801
802
  if (e < n.xDomain[0] || e > n.xDomain[1]) return null;
802
803
  let r = n.xToPixel(e);
803
804
  return /* @__PURE__ */ R("g", {
@@ -824,15 +825,15 @@ var Ce = {
824
825
  minimumFractionDigits: 2,
825
826
  maximumFractionDigits: 2
826
827
  };
827
- 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 }) {
828
- 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]), V = N(() => g(s, {
828
+ function we({ title: e, bids: t, asks: r, valueFormat: a = Ce, sizeFormat: o, locale: s = "en-US", height: c = 220, axis: l = "minimal", background: d = "dots", hoverStyle: f = "soft", surface: p, numberStyle: g, loading: _ = !1, loadingStyle: v = "shimmer", motion: y, className: b, style: x, depth: C = !1 }) {
829
+ let E = N(() => he(t, r), [t, r]), D = JSON.stringify(a), M = JSON.stringify(o ?? null), P = N(() => h(s, a), [s, D]), I = N(() => h(s, o), [s, M]), z = N(() => h(s, {
829
830
  style: "percent",
830
831
  maximumFractionDigits: 3
831
832
  }).full, [s]), [H, U] = F(null), W = N(() => [{
832
833
  id: "bid",
833
834
  label: "Bids",
834
835
  accessor: (e) => e.bid,
835
- color: z,
836
+ color: B,
836
837
  curve: "step-before",
837
838
  area: { treatment: "fade" },
838
839
  line: {
@@ -844,7 +845,7 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
844
845
  id: "ask",
845
846
  label: "Asks",
846
847
  accessor: (e) => e.ask,
847
- color: B,
848
+ color: V,
848
849
  curve: "step-after",
849
850
  area: { treatment: "fade" },
850
851
  line: {
@@ -852,22 +853,22 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
852
853
  depth: C
853
854
  },
854
855
  formatValue: I.full
855
- }], [I, C]), te = E.spread !== null && E.mid ? `${P.full(E.spread)} (${V(E.spread / E.mid)})` : "—", G = H ? H.bid ?? H.ask : null;
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;
856
857
  return /* @__PURE__ */ R(ee, {
857
858
  "aria-label": e,
858
859
  surface: p,
859
- numberStyle: m,
860
- motion: v,
860
+ numberStyle: g,
861
+ motion: y,
861
862
  className: ["lilt-card--depth", b].filter(Boolean).join(" "),
862
863
  style: x,
863
864
  children: [
864
865
  /* @__PURE__ */ R(j, { children: [/* @__PURE__ */ L(A, { children: e }), /* @__PURE__ */ L(k, {
865
866
  value: E.mid,
866
867
  format: P.full,
867
- loading: h,
868
- motion: v,
869
- children: h ? null : H && G !== null ? /* @__PURE__ */ R(O, { children: [
870
- I.full(G),
868
+ loading: _,
869
+ motion: y,
870
+ children: _ ? null : H && K !== null ? /* @__PURE__ */ R(O, { children: [
871
+ I.full(K),
871
872
  " ",
872
873
  H.side === "bid" ? "bid" : "ask",
873
874
  " depth at",
@@ -878,18 +879,18 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
878
879
  /* @__PURE__ */ R("dl", {
879
880
  className: "lilt-card__stats",
880
881
  children: [
881
- /* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("dt", { children: "Spread" }), /* @__PURE__ */ L("dd", { children: h ? "—" : te })] }),
882
+ /* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("dt", { children: "Spread" }), /* @__PURE__ */ L("dd", { children: _ ? "—" : G })] }),
882
883
  /* @__PURE__ */ R("div", {
883
884
  "data-side": "bid",
884
- children: [/* @__PURE__ */ L("dt", { children: "Bid depth" }), /* @__PURE__ */ L("dd", { children: h ? "—" : I.compact(E.bidDepth) })]
885
+ children: [/* @__PURE__ */ L("dt", { children: "Bid depth" }), /* @__PURE__ */ L("dd", { children: _ ? "—" : I.compact(E.bidDepth) })]
885
886
  }),
886
887
  /* @__PURE__ */ R("div", {
887
888
  "data-side": "ask",
888
- children: [/* @__PURE__ */ L("dt", { children: "Ask depth" }), /* @__PURE__ */ L("dd", { children: h ? "—" : I.compact(E.askDepth) })]
889
+ children: [/* @__PURE__ */ L("dt", { children: "Ask depth" }), /* @__PURE__ */ L("dd", { children: _ ? "—" : I.compact(E.askDepth) })]
889
890
  })
890
891
  ]
891
892
  }),
892
- /* @__PURE__ */ L(y, {
893
+ /* @__PURE__ */ L(m, {
893
894
  className: "lilt-card__chart",
894
895
  "aria-label": `${e} depth by price`,
895
896
  data: E.levels,
@@ -905,13 +906,13 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
905
906
  },
906
907
  series: W,
907
908
  onSelectionChange: (e) => U(e?.row ?? null),
908
- motion: v,
909
- status: h ? "loading" : "ready",
910
- loadingStyle: _,
911
- children: /* @__PURE__ */ R(a, {
909
+ motion: y,
910
+ status: _ ? "loading" : "ready",
911
+ loadingStyle: v,
912
+ children: /* @__PURE__ */ R(i, {
912
913
  height: c,
913
914
  axis: l,
914
- background: u,
915
+ background: d,
915
916
  pill: f,
916
917
  margins: {
917
918
  top: 8,
@@ -921,15 +922,15 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
921
922
  },
922
923
  children: [
923
924
  /* @__PURE__ */ L(T, { pattern: "lines" }),
924
- /* @__PURE__ */ L(r, { series: "bid" }),
925
- /* @__PURE__ */ L(r, { series: "ask" }),
925
+ /* @__PURE__ */ L(n, { series: "bid" }),
926
+ /* @__PURE__ */ L(n, { series: "ask" }),
926
927
  /* @__PURE__ */ L(w, { series: "bid" }),
927
928
  /* @__PURE__ */ L(w, { series: "ask" }),
928
929
  E.mid === null ? null : /* @__PURE__ */ L(Se, {
929
930
  price: E.mid,
930
931
  label: `Mid ${P.full(E.mid)}`
931
932
  }),
932
- /* @__PURE__ */ L(d, { labels: "fit" }),
933
+ /* @__PURE__ */ L(u, { labels: "fit" }),
933
934
  /* @__PURE__ */ L(S, {})
934
935
  ]
935
936
  })
@@ -939,16 +940,16 @@ function we({ title: e, bids: t, asks: n, valueFormat: i = Ce, sizeFormat: o, lo
939
940
  }
940
941
  //#endregion
941
942
  //#region src/finance/cards/portfolio-chart-card.tsx
942
- function Q(e, t) {
943
+ function $(e, t) {
943
944
  if (!t) return null;
944
945
  let n = e[t];
945
946
  return typeof n == "number" && Number.isFinite(n) ? n : null;
946
947
  }
947
948
  function Te(e, t, n) {
948
- let r = e.at(-1), i = Q(r, t), a = Q(r, n);
949
+ let r = e.at(-1), i = $(r, t), a = $(r, n);
949
950
  return i !== null && a ? i / a - 1 : void 0;
950
951
  }
951
- 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 }) {
952
+ function Ee({ value: e, basis: t, label: r = "Value", drawdown: i = !0, drawdownHeight: a = 64, data: o, ranges: s, delta: c, locale: l = "en-US", ...u }) {
952
953
  let d = o ?? s?.[0]?.data ?? [], f = N(() => s?.map((n) => ({
953
954
  ...n,
954
955
  delta: n.delta ?? Te(n.data, e, t)
@@ -956,15 +957,15 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
956
957
  s,
957
958
  e,
958
959
  t
959
- ]), p = N(() => g(l, {
960
+ ]), p = N(() => h(l, {
960
961
  style: "percent",
961
962
  minimumFractionDigits: 1,
962
963
  maximumFractionDigits: 1
963
964
  }).full, [l]), m = N(() => {
964
- let t = fe(d.map((t) => Q(t, e))).filter((e) => e !== null);
965
- return t.length ? Math.min(...t) : null;
965
+ let t = fe(d.map((t) => $(t, e))).filter((e) => e !== null);
966
+ return z(t) ?? null;
966
967
  }, [d, e]);
967
- return /* @__PURE__ */ L(v, {
968
+ return /* @__PURE__ */ L(g, {
968
969
  ...u,
969
970
  data: o,
970
971
  ranges: f,
@@ -977,7 +978,7 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
977
978
  restCaption: t ? () => "over basis" : void 0,
978
979
  series: [{
979
980
  key: e,
980
- label: n
981
+ label: r
981
982
  }, ...t ? [{
982
983
  key: t,
983
984
  label: "Basis",
@@ -995,11 +996,11 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
995
996
  area: { treatment: "fade" },
996
997
  curve: "monotone"
997
998
  },
998
- draw: (e) => e.map((e) => [/* @__PURE__ */ L(r, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, e)])
999
+ draw: (e) => e.map((e) => [/* @__PURE__ */ L(n, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, e)])
999
1000
  },
1000
1001
  panes: i ? (t) => {
1001
- let n = fe(t.data.map((t) => Q(t, e))), i = new Map(t.data.map((e, t) => [e, n[t] ?? null]));
1002
- return /* @__PURE__ */ R(K, {
1002
+ let r = fe(t.data.map((t) => $(t, e))), i = new Map(t.data.map((e, t) => [e, r[t] ?? null]));
1003
+ return /* @__PURE__ */ R(q, {
1003
1004
  context: t,
1004
1005
  label: `${u.title} drawdown`,
1005
1006
  caption: "Drawdown",
@@ -1027,7 +1028,7 @@ function Ee({ value: e, basis: t, label: n = "Value", drawdown: i = !0, drawdown
1027
1028
  line: { width: 1.5 },
1028
1029
  curve: "monotone"
1029
1030
  }],
1030
- children: [/* @__PURE__ */ L(r, { series: "drawdown" }), /* @__PURE__ */ L(w, { series: "drawdown" })]
1031
+ children: [/* @__PURE__ */ L(n, { series: "drawdown" }), /* @__PURE__ */ L(w, { series: "drawdown" })]
1031
1032
  });
1032
1033
  } : void 0
1033
1034
  });
@@ -1038,46 +1039,46 @@ function De(e, t) {
1038
1039
  let n = e[t];
1039
1040
  return typeof n == "number" && Number.isFinite(n) ? n : null;
1040
1041
  }
1041
- function $(e, t) {
1042
+ function Oe(e, t) {
1042
1043
  let n = e.map((e) => De(e, t)).filter((e) => e !== null);
1043
1044
  return n.length > 1 ? {
1044
1045
  first: n[0],
1045
1046
  last: n.at(-1)
1046
1047
  } : null;
1047
1048
  }
1048
- function Oe(e, t) {
1049
+ function ke(e, t) {
1049
1050
  let n = e.map((e) => ({ ...e }));
1050
1051
  for (let r of t) pe(e.map((e) => De(e, r))).forEach((e, t) => n[t][`__rebased${r}`] = e);
1051
1052
  return n;
1052
1053
  }
1053
- var ke = {
1054
+ var Ae = {
1054
1055
  style: "currency",
1055
1056
  currency: "USD",
1056
1057
  minimumFractionDigits: 2,
1057
1058
  maximumFractionDigits: 2
1058
1059
  };
1059
- function Ae({ price: e, symbol: t, name: n, icon: i, display: a = "area", versus: o, data: s, ranges: c, delta: l, valueFormat: u = ke, locale: d = "en-US", title: p, ...m }) {
1060
- let h = !!o?.length, _ = N(() => [e, ...(o ?? []).map((e) => e.key)], [e, o]), y = N(() => s ? h ? Oe(s, _) : s : void 0, [
1060
+ function je({ price: e, symbol: t, name: r, icon: i, display: a = "area", versus: o, data: s, ranges: c, delta: l, valueFormat: u = Ae, locale: f = "en-US", title: p, ...m }) {
1061
+ let _ = !!o?.length, v = N(() => [e, ...(o ?? []).map((e) => e.key)], [e, o]), y = N(() => s ? _ ? ke(s, v) : s : void 0, [
1061
1062
  s,
1062
- h,
1063
- _
1063
+ _,
1064
+ v
1064
1065
  ]), b = N(() => c?.map((t) => {
1065
- let n = $(t.data, e);
1066
+ let n = Oe(t.data, e);
1066
1067
  return {
1067
1068
  ...t,
1068
- data: h ? Oe(t.data, _) : t.data,
1069
+ data: _ ? ke(t.data, v) : t.data,
1069
1070
  delta: t.delta ?? (n && n.first ? n.last / n.first - 1 : void 0)
1070
1071
  };
1071
1072
  }), [
1072
1073
  c,
1073
- h,
1074
1074
  _,
1075
+ v,
1075
1076
  e
1076
- ]), x = $(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, {
1077
+ ]), x = Oe(s ?? c?.[0]?.data ?? [], e), S = !x || x.last >= x.first, C = N(() => h(f, u).full, [f, JSON.stringify(u)]), T = N(() => h(f, {
1077
1078
  style: "percent",
1078
1079
  minimumFractionDigits: 1,
1079
1080
  maximumFractionDigits: 1
1080
- }).full, [d]), E = (e) => h ? `__rebased${e}` : e, D = /* @__PURE__ */ R("span", {
1081
+ }).full, [f]), E = (e) => _ ? `__rebased${e}` : e, D = /* @__PURE__ */ R("span", {
1081
1082
  className: "lilt-card__ticker",
1082
1083
  children: [
1083
1084
  i ? /* @__PURE__ */ L("span", {
@@ -1088,57 +1089,57 @@ function Ae({ price: e, symbol: t, name: n, icon: i, display: a = "area", versus
1088
1089
  className: "lilt-card__ticker-symbol",
1089
1090
  children: t ?? p
1090
1091
  }),
1091
- n ? /* @__PURE__ */ L("span", {
1092
+ r ? /* @__PURE__ */ L("span", {
1092
1093
  className: "lilt-card__ticker-name",
1093
- children: n
1094
+ children: r
1094
1095
  }) : null
1095
1096
  ]
1096
1097
  });
1097
- return /* @__PURE__ */ L(v, {
1098
+ return /* @__PURE__ */ L(g, {
1098
1099
  ...m,
1099
1100
  title: p,
1100
1101
  heading: D,
1101
1102
  data: y,
1102
1103
  ranges: b,
1103
- delta: h ? void 0 : l ?? (s && x && x.first ? x.last / x.first - 1 : void 0),
1104
- valueFormat: h ? {
1104
+ delta: _ ? void 0 : l ?? (s && x && x.first ? x.last / x.first - 1 : void 0),
1105
+ valueFormat: _ ? {
1105
1106
  style: "percent",
1106
1107
  maximumFractionDigits: 1
1107
1108
  } : u,
1108
- formatValue: h ? (e) => f(T)(e) : void 0,
1109
- locale: d,
1109
+ formatValue: _ ? (e) => d(T)(e) : void 0,
1110
+ locale: f,
1110
1111
  aggregate: "last",
1111
1112
  headlineSeries: E(e),
1112
- pillSeries: h ? "nearest" : E(e),
1113
- tiles: h,
1114
- restCaption: h ? void 0 : (t) => {
1115
- let n = $(t, e);
1116
- return n ? f(C)(n.last - n.first) : null;
1113
+ pillSeries: _ ? "nearest" : E(e),
1114
+ tiles: _,
1115
+ restCaption: _ ? void 0 : (t) => {
1116
+ let n = Oe(t, e);
1117
+ return n ? d(C)(n.last - n.first) : null;
1117
1118
  },
1118
1119
  series: [{
1119
1120
  key: E(e),
1120
1121
  label: t ?? p,
1121
- color: h ? void 0 : S ? z : B
1122
+ color: _ ? void 0 : S ? B : V
1122
1123
  }, ...(o ?? []).map((e) => ({
1123
1124
  ...e,
1124
1125
  key: E(e.key)
1125
1126
  }))],
1126
1127
  shape: {
1127
1128
  kind: "marks",
1128
- id: `price:${a}:${_.join()}:${h}`,
1129
- includeZero: h,
1130
- series: () => a === "area" && !h ? {
1129
+ id: `price:${a}:${v.join()}:${_}`,
1130
+ includeZero: _,
1131
+ series: () => a === "area" && !_ ? {
1131
1132
  area: { treatment: "fade" },
1132
1133
  curve: "monotone"
1133
1134
  } : { curve: "monotone" },
1134
- 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))
1135
+ draw: (e) => e.map((e) => a === "area" && !_ ? [/* @__PURE__ */ L(n, { series: e }, `area-${e}`), /* @__PURE__ */ L(w, { series: e }, e)] : /* @__PURE__ */ L(w, { series: e }, e))
1135
1136
  },
1136
1137
  bleed: m.bleed ?? !0
1137
1138
  });
1138
1139
  }
1139
1140
  //#endregion
1140
1141
  //#region src/finance/order-book.tsx
1141
- function je(e, t, n) {
1142
+ function Me(e, t, n) {
1142
1143
  let r = /* @__PURE__ */ new Map();
1143
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);
1144
1145
  let i = [...r].map(([e, t]) => ({
@@ -1151,7 +1152,7 @@ function je(e, t, n) {
1151
1152
  side: t
1152
1153
  }));
1153
1154
  }
1154
- function Me(e, t) {
1155
+ function Ne(e, t) {
1155
1156
  let n = P(null), [r, i] = F(/* @__PURE__ */ new Set());
1156
1157
  return M(() => {
1157
1158
  let r = new Map(e.map((e) => [`${e.side}:${e.price}`, e.size])), a = n.current;
@@ -1163,14 +1164,14 @@ function Me(e, t) {
1163
1164
  return () => window.clearTimeout(s);
1164
1165
  }, [e, t]), r;
1165
1166
  }
1166
- function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFormat: o = {
1167
+ function Pe({ title: e, bids: t, asks: n, levels: r = 8, depth: i = !1, valueFormat: a = {
1167
1168
  minimumFractionDigits: 2,
1168
1169
  maximumFractionDigits: 2
1169
- }, sizeFormat: s, locale: c = "en-US", flash: l = !0, surface: u, loading: d = !1, loadingStyle: f = "shimmer", motion: p, className: m, style: h }) {
1170
- 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, {
1170
+ }, sizeFormat: o, locale: s = "en-US", flash: c = !0, surface: l, loading: u = !1, loadingStyle: d = "shimmer", motion: f, className: p, style: m }) {
1171
+ let g = D(f ?? "auto"), _ = y(u, d), v = JSON.stringify(a), x = JSON.stringify(o ?? null), S = N(() => h(s, a).full, [s, v]), C = N(() => h(s, o).compact, [s, x]), w = N(() => h(s, {
1171
1172
  style: "percent",
1172
1173
  maximumFractionDigits: 3
1173
- }).full, [c]), T = N(() => je(t, "bid", i), [t, i]), E = N(() => je(r, "ask", i), [r, i]), O = Me(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 ? {
1174
+ }).full, [s]), T = N(() => Me(t, "bid", r), [t, r]), E = N(() => Me(n, "ask", r), [n, r]), O = Ne(N(() => [...E, ...T], [E, T]), c && !g && !u), 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 ? {
1174
1175
  value: j - A,
1175
1176
  mid: (j + A) / 2
1176
1177
  } : null, P = (e) => /* @__PURE__ */ R("tr", {
@@ -1181,7 +1182,7 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
1181
1182
  children: [
1182
1183
  /* @__PURE__ */ R("th", {
1183
1184
  scope: "row",
1184
- children: [a ? /* @__PURE__ */ L("span", {
1185
+ children: [i ? /* @__PURE__ */ L("span", {
1185
1186
  className: "lilt-order-book__bar",
1186
1187
  "aria-hidden": "true"
1187
1188
  }) : null, S(e.price)]
@@ -1189,7 +1190,7 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
1189
1190
  /* @__PURE__ */ L("td", { children: C(e.size) }),
1190
1191
  /* @__PURE__ */ L("td", { children: C(e.total) })
1191
1192
  ]
1192
- }, `${e.side}:${e.price}`), F = (e) => Array.from({ length: Math.max(1, Math.min(50, i)) }, (t, n) => /* @__PURE__ */ R("tr", {
1193
+ }, `${e.side}:${e.price}`), F = (e) => Array.from({ length: Math.max(1, Math.min(50, r)) }, (t, n) => /* @__PURE__ */ R("tr", {
1193
1194
  className: "lilt-order-book__placeholder",
1194
1195
  "aria-hidden": "true",
1195
1196
  children: [
@@ -1209,17 +1210,17 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
1209
1210
  }, `${e}-${n}`));
1210
1211
  return /* @__PURE__ */ L(ee, {
1211
1212
  "aria-label": e,
1212
- surface: u,
1213
- motion: p,
1214
- className: ["lilt-card--order-book", m].filter(Boolean).join(" "),
1215
- style: h,
1213
+ surface: l,
1214
+ motion: f,
1215
+ className: ["lilt-card--order-book", p].filter(Boolean).join(" "),
1216
+ style: m,
1216
1217
  children: /* @__PURE__ */ R("table", {
1217
- ref: v,
1218
- className: d ? "lilt-order-book lilt-skeleton" : "lilt-order-book",
1219
- "data-depth": a || void 0,
1220
- "data-style": d ? f : void 0,
1221
- "data-reduced-motion": _ || void 0,
1222
- "aria-busy": d,
1218
+ ref: _,
1219
+ className: u ? "lilt-order-book lilt-skeleton" : "lilt-order-book",
1220
+ "data-depth": i || void 0,
1221
+ "data-style": u ? d : void 0,
1222
+ "data-reduced-motion": g || void 0,
1223
+ "aria-busy": u,
1223
1224
  children: [
1224
1225
  /* @__PURE__ */ L("caption", { children: e }),
1225
1226
  /* @__PURE__ */ L("thead", { children: /* @__PURE__ */ R("tr", { children: [
@@ -1238,7 +1239,7 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
1238
1239
  ] }) }),
1239
1240
  /* @__PURE__ */ L("tbody", {
1240
1241
  "aria-label": "Asks",
1241
- children: d ? F("ask") : [...E].reverse().map(P)
1242
+ children: u ? F("ask") : [...E].reverse().map(P)
1242
1243
  }),
1243
1244
  /* @__PURE__ */ L("tbody", {
1244
1245
  "aria-label": "Spread",
@@ -1246,20 +1247,20 @@ function Ne({ title: e, bids: t, asks: r, levels: i = 8, depth: a = !1, valueFor
1246
1247
  className: "lilt-order-book__spread",
1247
1248
  children: [/* @__PURE__ */ L("th", {
1248
1249
  scope: "row",
1249
- children: d ? "—" : M ? S(M.mid) : "—"
1250
+ children: u ? "—" : M ? S(M.mid) : "—"
1250
1251
  }), /* @__PURE__ */ L("td", {
1251
1252
  colSpan: 2,
1252
- children: d ? "Loading order book" : M ? `Spread ${S(M.value)} · ${w(M.value / M.mid)}` : "No spread"
1253
+ children: u ? "Loading order book" : M ? `Spread ${S(M.value)} · ${w(M.value / M.mid)}` : "No spread"
1253
1254
  })]
1254
1255
  })
1255
1256
  }),
1256
1257
  /* @__PURE__ */ L("tbody", {
1257
1258
  "aria-label": "Bids",
1258
- children: d ? F("bid") : T.map(P)
1259
+ children: u ? F("bid") : T.map(P)
1259
1260
  })
1260
1261
  ]
1261
1262
  })
1262
1263
  });
1263
1264
  }
1264
1265
  //#endregion
1265
- export { re as Candles, oe as CandlestickChartCard, we as DepthChartCard, xe as IndicatorChartCard, Ne as OrderBook, Ee as PortfolioChartCard, Ae as PriceChartCard, de as bollinger, he as depthLevels, fe as drawdown, X as ema, ue as macd, pe as rebase, le as rsi, ce 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 };