@wick-charts/react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3807 @@
1
+ import { createContext as ye, useContext as Gt, useRef as et, useLayoutEffect as it, useEffect as j, useState as Rt, Children as Ye, isValidElement as _e, useMemo as dt, useSyncExternalStore as Tt } from "react";
2
+ import { jsx as S, jsxs as F, Fragment as Dt } from "react/jsx-runtime";
3
+ var Ue = Object.defineProperty, xe = (r) => {
4
+ throw TypeError(r);
5
+ }, Ee = (r, t, i) => t in r ? Ue(r, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[t] = i, w = (r, t, i) => Ee(r, typeof t != "symbol" ? t + "" : t, i), Nt = (r, t, i) => t.has(r) || xe("Cannot " + i), c = (r, t, i) => (Nt(r, t, "read from private field"), i ? i.call(r) : t.get(r)), L = (r, t, i) => t.has(r) ? xe("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, i), R = (r, t, i, e) => (Nt(r, t, "write to private field"), t.set(r, i), i), Ft = (r, t, i) => (Nt(r, t, "access private method"), i), ne = (r, t, i, e) => ({
6
+ set _(a) {
7
+ R(r, t, a);
8
+ },
9
+ get _() {
10
+ return c(r, t, e);
11
+ }
12
+ });
13
+ class Bt {
14
+ constructor() {
15
+ w(this, "listeners", /* @__PURE__ */ new Map());
16
+ }
17
+ on(t, i) {
18
+ let e = this.listeners.get(t);
19
+ e || (e = /* @__PURE__ */ new Set(), this.listeners.set(t, e)), e.add(i);
20
+ }
21
+ off(t, i) {
22
+ var e;
23
+ (e = this.listeners.get(t)) == null || e.delete(i);
24
+ }
25
+ emit(t, ...i) {
26
+ var e;
27
+ (e = this.listeners.get(t)) == null || e.forEach((a) => a(...i));
28
+ }
29
+ removeAllListeners() {
30
+ this.listeners.clear();
31
+ }
32
+ }
33
+ function le(r, t, i) {
34
+ const e = document.createElement("canvas");
35
+ return e.style.position = "absolute", e.style.inset = "0", e.style.width = "100%", e.style.height = "100%", e.style.display = "block", e.style.zIndex = String(t), r.appendChild(e), e;
36
+ }
37
+ class Oe extends Bt {
38
+ constructor(t) {
39
+ super(), w(this, "mainCanvas"), w(this, "mainCtx"), w(this, "overlayCanvas"), w(this, "overlayCtx"), w(this, "resizeObserver"), w(this, "_size"), w(this, "supportsDevicePixelContentBox", !1), this.mainCanvas = le(t, 0), this.overlayCanvas = le(t, 1), this.mainCtx = this.mainCanvas.getContext("2d", { alpha: !0 }), this.overlayCtx = this.overlayCanvas.getContext("2d", { alpha: !0 });
40
+ const i = window.devicePixelRatio || 1;
41
+ this._size = {
42
+ media: { width: 0, height: 0 },
43
+ bitmap: { width: 0, height: 0 },
44
+ horizontalPixelRatio: i,
45
+ verticalPixelRatio: i
46
+ }, this.resizeObserver = new ResizeObserver((a) => {
47
+ this.handleResize(a[0]);
48
+ });
49
+ try {
50
+ this.resizeObserver.observe(t, { box: "device-pixel-content-box" }), this.supportsDevicePixelContentBox = !0;
51
+ } catch {
52
+ this.resizeObserver.observe(t, { box: "content-box" });
53
+ }
54
+ const e = t.getBoundingClientRect();
55
+ if (e.width > 0 && e.height > 0) {
56
+ const a = window.devicePixelRatio || 1, o = a, s = Math.round(e.width * a), n = Math.round(e.height * o);
57
+ this.mainCanvas.width = s, this.mainCanvas.height = n, this.overlayCanvas.width = s, this.overlayCanvas.height = n, this._size = {
58
+ media: { width: e.width, height: e.height },
59
+ bitmap: { width: s, height: n },
60
+ horizontalPixelRatio: s / e.width,
61
+ verticalPixelRatio: n / e.height
62
+ };
63
+ }
64
+ }
65
+ handleResize(t) {
66
+ var i, e;
67
+ let a, o, s, n;
68
+ if (this.supportsDevicePixelContentBox && (i = t.devicePixelContentBoxSize) != null && i[0]) {
69
+ const d = t.devicePixelContentBoxSize[0];
70
+ a = d.inlineSize, o = d.blockSize;
71
+ const g = t.contentBoxSize[0];
72
+ s = g.inlineSize, n = g.blockSize;
73
+ } else {
74
+ const d = (e = t.contentBoxSize) == null ? void 0 : e[0];
75
+ if (d)
76
+ s = d.inlineSize, n = d.blockSize;
77
+ else {
78
+ const f = t.contentRect;
79
+ s = f.width, n = f.height;
80
+ }
81
+ const g = window.devicePixelRatio || 1;
82
+ a = Math.round(s * g), o = Math.round(n * g);
83
+ }
84
+ if (a === 0 || o === 0) return;
85
+ this.mainCanvas.width = a, this.mainCanvas.height = o, this.overlayCanvas.width = a, this.overlayCanvas.height = o;
86
+ const l = a / s, h = o / n;
87
+ this._size = {
88
+ media: { width: s, height: n },
89
+ bitmap: { width: a, height: o },
90
+ horizontalPixelRatio: l,
91
+ verticalPixelRatio: h
92
+ }, this.emit("resize", this._size);
93
+ }
94
+ get size() {
95
+ return this._size;
96
+ }
97
+ /** Draw on the main (bottom) layer — series, grid, background */
98
+ useMainLayer(t) {
99
+ this.mainCtx.save(), t({
100
+ context: this.mainCtx,
101
+ bitmapSize: this._size.bitmap,
102
+ mediaSize: this._size.media,
103
+ horizontalPixelRatio: this._size.horizontalPixelRatio,
104
+ verticalPixelRatio: this._size.verticalPixelRatio
105
+ }), this.mainCtx.restore();
106
+ }
107
+ /** Draw on the overlay (top) layer — crosshair */
108
+ useOverlayLayer(t) {
109
+ const { width: i, height: e } = this._size.bitmap;
110
+ this.overlayCtx.clearRect(0, 0, i, e), this.overlayCtx.save(), t({
111
+ context: this.overlayCtx,
112
+ bitmapSize: this._size.bitmap,
113
+ mediaSize: this._size.media,
114
+ horizontalPixelRatio: this._size.horizontalPixelRatio,
115
+ verticalPixelRatio: this._size.verticalPixelRatio
116
+ }), this.overlayCtx.restore();
117
+ }
118
+ // Keep backward compat for now
119
+ get canvas() {
120
+ return this.overlayCanvas;
121
+ }
122
+ destroy() {
123
+ this.resizeObserver.disconnect(), this.mainCanvas.remove(), this.overlayCanvas.remove(), this.removeAllListeners();
124
+ }
125
+ }
126
+ function $e(r, t, i, e) {
127
+ const { context: a, bitmapSize: o, horizontalPixelRatio: s } = r;
128
+ a.strokeStyle = e.crosshair.color, a.lineWidth = 1, a.setLineDash([4 * s, 4 * s]);
129
+ const n = Math.round(t) + 0.5, l = Math.round(i) + 0.5;
130
+ a.beginPath(), a.moveTo(n, 0), a.lineTo(n, o.height), a.moveTo(0, l), a.lineTo(o.width, l), a.stroke(), a.setLineDash([]);
131
+ }
132
+ function Xe(r, t, i, e, a) {
133
+ const { context: o, bitmapSize: s, horizontalPixelRatio: n, verticalPixelRatio: l } = r;
134
+ o.strokeStyle = e.grid.color, o.lineWidth = 1, e.grid.style === "dashed" ? o.setLineDash([4 * n, 4 * n]) : e.grid.style === "dotted" && o.setLineDash([1 * n, 3 * n]);
135
+ const h = i.niceTickValues();
136
+ o.beginPath();
137
+ for (const g of h) {
138
+ const f = Math.round(i.valueToBitmapY(g)) + 0.5;
139
+ o.moveTo(0, f), o.lineTo(s.width, f);
140
+ }
141
+ o.stroke();
142
+ const { ticks: d } = t.niceTickValues(a);
143
+ o.beginPath();
144
+ for (const g of d) {
145
+ const f = Math.round(t.timeToBitmapX(g)) + 0.5;
146
+ o.moveTo(f, 0), o.lineTo(f, s.height);
147
+ }
148
+ o.stroke(), o.setLineDash([]);
149
+ }
150
+ function ce(r, t, i) {
151
+ return r + (t - r) * i;
152
+ }
153
+ function Et(r, t, i) {
154
+ let e = 0, a = r.length - 1;
155
+ for (; e <= a; ) {
156
+ const o = e + a >>> 1, s = i(r[o]);
157
+ if (s < t) e = o + 1;
158
+ else if (s > t) a = o - 1;
159
+ else return o;
160
+ }
161
+ return e;
162
+ }
163
+ class jt extends Bt {
164
+ constructor() {
165
+ super(...arguments), w(this, "data", []), w(this, "_visible", !0), w(this, "cachedRange", null), w(this, "cachedResult", []);
166
+ }
167
+ setVisible(t) {
168
+ this._visible = t;
169
+ }
170
+ isVisible() {
171
+ return this._visible;
172
+ }
173
+ setData(t) {
174
+ let i = !0;
175
+ for (let e = 1; e < t.length; e++)
176
+ if (t[e].time < t[e - 1].time) {
177
+ i = !1;
178
+ break;
179
+ }
180
+ this.data = i ? t.slice() : [...t].sort((e, a) => e.time - a.time), this.cachedRange = null, this.emit("update");
181
+ }
182
+ append(t) {
183
+ if (this.data.length > 0 && t.time <= this.data[this.data.length - 1].time) {
184
+ this.updateLast(t);
185
+ return;
186
+ }
187
+ this.data.push(t), this.cachedRange = null, this.emit("update");
188
+ }
189
+ updateLast(t) {
190
+ this.data.length !== 0 && (this.data[this.data.length - 1] = t, this.cachedRange = null, this.emit("update"));
191
+ }
192
+ getAll() {
193
+ return this.data;
194
+ }
195
+ getVisibleData(t, i) {
196
+ if (this.data.length === 0) return [];
197
+ if (this.cachedRange && this.cachedRange.from === t && this.cachedRange.to === i) return this.cachedResult;
198
+ const e = Math.max(0, Et(this.data, t, (o) => o.time) - 1), a = Math.min(this.data.length, Et(this.data, i, (o) => o.time) + 1);
199
+ return this.cachedResult = this.data.slice(e, a), this.cachedRange = { from: t, to: i }, this.cachedResult;
200
+ }
201
+ first() {
202
+ return this.data[0];
203
+ }
204
+ last() {
205
+ return this.data[this.data.length - 1];
206
+ }
207
+ get length() {
208
+ return this.data.length;
209
+ }
210
+ isEmpty() {
211
+ return this.data.length === 0;
212
+ }
213
+ findNearest(t, i) {
214
+ if (this.data.length === 0) return null;
215
+ const e = Et(this.data, t, (s) => s.time);
216
+ let a = null, o = i;
217
+ for (let s = Math.max(0, e - 1); s <= Math.min(this.data.length - 1, e + 1); s++) {
218
+ const n = Math.abs(this.data[s].time - t);
219
+ n <= o && (o = n, a = this.data[s]);
220
+ }
221
+ return a;
222
+ }
223
+ }
224
+ class He {
225
+ constructor(t, i, e) {
226
+ w(this, "dragging", !1), w(this, "lastX", 0), this.viewport = t, this.timeScale = i, this.canvas = e;
227
+ }
228
+ handleMouseDown(t) {
229
+ t.button === 0 && (this.dragging = !0, this.lastX = t.clientX, this.canvas.style.cursor = "grabbing");
230
+ }
231
+ handleMouseMove(t) {
232
+ if (!this.dragging) return;
233
+ const i = t.clientX - this.lastX;
234
+ this.lastX = t.clientX;
235
+ const e = this.timeScale.pixelDeltaToTimeDelta(-i);
236
+ this.viewport.pan(e);
237
+ }
238
+ handleMouseUp() {
239
+ this.dragging && (this.dragging = !1, this.canvas.style.cursor = "crosshair");
240
+ }
241
+ isDragging() {
242
+ return this.dragging;
243
+ }
244
+ }
245
+ class Ge {
246
+ constructor(t, i) {
247
+ this.viewport = t, this.timeScale = i;
248
+ }
249
+ handleWheel(t) {
250
+ t.preventDefault();
251
+ const i = Ne(t.deltaY, t.deltaMode), e = Math.exp(i * 5e-3), a = this.timeScale.getMediaWidth(), o = Math.min(t.offsetX, a), s = this.timeScale.xToTime(o);
252
+ this.viewport.zoomAt(s, e);
253
+ }
254
+ }
255
+ function Ne(r, t) {
256
+ return t === WheelEvent.DOM_DELTA_LINE ? r * 8 : t === WheelEvent.DOM_DELTA_PAGE ? r * 24 : r;
257
+ }
258
+ class je extends Bt {
259
+ constructor(t, i, e, a) {
260
+ super(), w(this, "zoom"), w(this, "pan"), w(this, "canvas"), w(this, "timeScale"), w(this, "yScale"), w(this, "viewport"), w(this, "onWheel", (o) => {
261
+ this.zoom.handleWheel(o);
262
+ }), w(this, "onMouseDown", (o) => {
263
+ this.pan.handleMouseDown(o);
264
+ }), w(this, "onMouseMove", (o) => {
265
+ this.pan.isDragging() && this.pan.handleMouseMove(o), this.emitCrosshair(o.offsetX, o.offsetY);
266
+ }), w(this, "onMouseUp", () => {
267
+ this.pan.handleMouseUp();
268
+ }), w(this, "onMouseLeave", () => {
269
+ this.pan.handleMouseUp(), this.emit("crosshairMove", null);
270
+ }), w(this, "onDblClick", () => {
271
+ }), w(this, "lastTouchDist", 0), w(this, "lastTouchCenter", 0), w(this, "touchCount", 0), w(this, "onTouchStart", (o) => {
272
+ o.preventDefault(), this.touchCount = o.touches.length, o.touches.length === 1 ? this.pan.handleMouseDown({
273
+ button: 0,
274
+ clientX: o.touches[0].clientX
275
+ }) : o.touches.length === 2 && (this.lastTouchDist = Math.abs(o.touches[0].clientX - o.touches[1].clientX), this.lastTouchCenter = (o.touches[0].clientX + o.touches[1].clientX) / 2);
276
+ }), w(this, "onTouchMove", (o) => {
277
+ if (o.preventDefault(), o.touches.length === 1 && this.touchCount === 1) {
278
+ this.pan.handleMouseMove({
279
+ clientX: o.touches[0].clientX
280
+ });
281
+ const s = this.canvas.getBoundingClientRect();
282
+ this.emitCrosshair(o.touches[0].clientX - s.left, o.touches[0].clientY - s.top);
283
+ } else if (o.touches.length === 2) {
284
+ const s = Math.abs(o.touches[0].clientX - o.touches[1].clientX), n = (o.touches[0].clientX + o.touches[1].clientX) / 2, l = this.canvas.getBoundingClientRect();
285
+ if (this.lastTouchDist > 0) {
286
+ const h = this.lastTouchDist / s, d = this.timeScale.xToTime(n - l.left);
287
+ this.viewport.zoomAt(d, h);
288
+ }
289
+ this.lastTouchDist = s, this.lastTouchCenter = n;
290
+ }
291
+ }), w(this, "onTouchEnd", (o) => {
292
+ o.touches.length === 0 && (this.pan.handleMouseUp(), this.touchCount = 0, this.lastTouchDist = 0);
293
+ }), this.canvas = t, this.viewport = i, this.timeScale = e, this.yScale = a, this.zoom = new Ge(i, e), this.pan = new He(i, e, t), t.style.cursor = "crosshair", t.style.touchAction = "none", t.addEventListener("wheel", this.onWheel, { passive: !1 }), t.addEventListener("mousedown", this.onMouseDown), t.addEventListener("mousemove", this.onMouseMove), t.addEventListener("mouseup", this.onMouseUp), t.addEventListener("mouseleave", this.onMouseLeave), t.addEventListener("dblclick", this.onDblClick), t.addEventListener("touchstart", this.onTouchStart, { passive: !1 }), t.addEventListener("touchmove", this.onTouchMove, { passive: !1 }), t.addEventListener("touchend", this.onTouchEnd);
294
+ }
295
+ emitCrosshair(t, i) {
296
+ const e = this.timeScale.xToTime(t), a = this.yScale.yToValue(i);
297
+ this.emit("crosshairMove", {
298
+ mediaX: t,
299
+ mediaY: i,
300
+ time: e,
301
+ y: a
302
+ });
303
+ }
304
+ destroy() {
305
+ this.canvas.removeEventListener("wheel", this.onWheel), this.canvas.removeEventListener("mousedown", this.onMouseDown), this.canvas.removeEventListener("mousemove", this.onMouseMove), this.canvas.removeEventListener("mouseup", this.onMouseUp), this.canvas.removeEventListener("mouseleave", this.onMouseLeave), this.canvas.removeEventListener("dblclick", this.onDblClick), this.canvas.removeEventListener("touchstart", this.onTouchStart), this.canvas.removeEventListener("touchmove", this.onTouchMove), this.canvas.removeEventListener("touchend", this.onTouchEnd), this.removeAllListeners();
306
+ }
307
+ }
308
+ class he {
309
+ constructor(t) {
310
+ w(this, "dirty", !1), w(this, "rafId", null), w(this, "callback"), w(this, "render", (i) => {
311
+ this.dirty = !1, this.rafId = null, this.callback(i);
312
+ }), this.callback = t;
313
+ }
314
+ markDirty() {
315
+ this.dirty || (this.dirty = !0, this.rafId = requestAnimationFrame(this.render));
316
+ }
317
+ destroy() {
318
+ this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.dirty = !1;
319
+ }
320
+ }
321
+ const ut = 6e4, ct = 36e5, st = 864e5;
322
+ function de(r) {
323
+ return r instanceof Date ? r.getTime() : r;
324
+ }
325
+ function Je(r) {
326
+ return r.length === 0 || typeof r[0].time == "number" ? r : r.map((t) => ({ ...t, time: t.time.getTime() }));
327
+ }
328
+ function Ke(r) {
329
+ return r.length === 0 || typeof r[0].time == "number" ? r : r.map((t) => ({ ...t, time: t.time.getTime() }));
330
+ }
331
+ function qe(r) {
332
+ if (r.length < 2) return st;
333
+ const t = [];
334
+ for (let i = 1; i < Math.min(r.length, 20); i++)
335
+ t.push(r[i] - r[i - 1]);
336
+ return t.sort((i, e) => i - e), t[Math.floor(t.length / 2)];
337
+ }
338
+ function At(r, t) {
339
+ const i = new Date(r);
340
+ return t >= st ? i.toLocaleDateString("en-US", { month: "short", day: "numeric" }) : t >= ct ? i.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: !1 }) : i.toLocaleTimeString("en-US", {
341
+ hour: "2-digit",
342
+ minute: "2-digit",
343
+ second: "2-digit",
344
+ hour12: !1
345
+ });
346
+ }
347
+ function Qe(r) {
348
+ return new Date(r).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
349
+ }
350
+ function Ze(r) {
351
+ const t = [1e3, 5e3, 1e4, 15e3, 3e4], i = [ut, 5 * ut, 10 * ut, 15 * ut, 30 * ut], e = [ct, 2 * ct, 4 * ct, 6 * ct, 12 * ct], a = [st, 7 * st, 30 * st, 90 * st, 365 * st];
352
+ return r < ut ? [...t, ...i, ...e, ...a] : r < ct ? [...i, ...e, ...a] : r < st ? [...e, ...a] : a;
353
+ }
354
+ class ti {
355
+ constructor() {
356
+ w(this, "from", 0), w(this, "to", 0), w(this, "width", 1), w(this, "pixelRatio", 1);
357
+ }
358
+ update(t, i, e) {
359
+ this.from = t.from, this.to = t.to, this.width = i, this.pixelRatio = e;
360
+ }
361
+ timeToX(t) {
362
+ return this.to <= this.from ? 0 : (t - this.from) / (this.to - this.from) * this.width;
363
+ }
364
+ timeToBitmapX(t) {
365
+ return Math.round(this.timeToX(t) * this.pixelRatio);
366
+ }
367
+ xToTime(t) {
368
+ return this.to <= this.from ? this.from : this.from + t / this.width * (this.to - this.from);
369
+ }
370
+ pixelDeltaToTimeDelta(t) {
371
+ return this.to <= this.from ? 0 : t / this.width * (this.to - this.from);
372
+ }
373
+ barWidthMedia(t) {
374
+ return this.to <= this.from ? 0 : t / (this.to - this.from) * this.width;
375
+ }
376
+ barWidthBitmap(t) {
377
+ return Math.max(1, Math.round(this.barWidthMedia(t) * this.pixelRatio));
378
+ }
379
+ niceTickValues(t) {
380
+ if (this.to <= this.from) return { ticks: [], tickInterval: 0 };
381
+ const i = Ze(t), e = (this.to - this.from) / this.width * 80;
382
+ let a = i[i.length - 1];
383
+ for (const n of i)
384
+ if (n >= e) {
385
+ a = n;
386
+ break;
387
+ }
388
+ const o = [], s = Math.ceil(this.from / a) * a;
389
+ for (let n = s; n <= this.to; n += a)
390
+ o.push(n);
391
+ return { ticks: o, tickInterval: a };
392
+ }
393
+ getRange() {
394
+ return { from: this.from, to: this.to };
395
+ }
396
+ getMediaWidth() {
397
+ return this.width;
398
+ }
399
+ }
400
+ const Ot = [
401
+ 1e-4,
402
+ 2e-4,
403
+ 5e-4,
404
+ 1e-3,
405
+ 2e-3,
406
+ 5e-3,
407
+ 0.01,
408
+ 0.02,
409
+ 0.05,
410
+ 0.1,
411
+ 0.2,
412
+ 0.5,
413
+ 1,
414
+ 2,
415
+ 5,
416
+ 10,
417
+ 20,
418
+ 50,
419
+ 100,
420
+ 200,
421
+ 500,
422
+ 1e3,
423
+ 2e3,
424
+ 5e3,
425
+ 1e4,
426
+ 2e4,
427
+ 5e4
428
+ ];
429
+ class ei {
430
+ constructor() {
431
+ w(this, "min", 0), w(this, "max", 0), w(this, "height", 1), w(this, "pixelRatio", 1);
432
+ }
433
+ /** Recalculate the scale with a new Y range, chart height, and device pixel ratio. */
434
+ update(t, i, e) {
435
+ this.min = t.min, this.max = t.max, this.height = i, this.pixelRatio = e;
436
+ }
437
+ /** Convert a value to a Y position in CSS (media) pixels. */
438
+ valueToY(t) {
439
+ return (1 - (t - this.min) / (this.max - this.min)) * this.height;
440
+ }
441
+ /** Convert a value to a Y position in physical (bitmap) pixels. */
442
+ valueToBitmapY(t) {
443
+ return Math.round(this.valueToY(t) * this.pixelRatio);
444
+ }
445
+ /** Convert a Y position in CSS pixels back to a value. */
446
+ yToValue(t) {
447
+ return this.max - t / this.height * (this.max - this.min);
448
+ }
449
+ /** Generate evenly spaced "nice" tick values that fit the current range and chart height. */
450
+ niceTickValues() {
451
+ if (this.max <= this.min) return [];
452
+ const t = (this.max - this.min) / this.height * 50;
453
+ let i = Ot[Ot.length - 1];
454
+ for (const o of Ot)
455
+ if (o >= t) {
456
+ i = o;
457
+ break;
458
+ }
459
+ const e = [], a = Math.ceil(this.min / i) * i;
460
+ for (let o = a; o <= this.max; o += i)
461
+ e.push(o);
462
+ return e;
463
+ }
464
+ getRange() {
465
+ return { min: this.min, max: this.max };
466
+ }
467
+ getMediaHeight() {
468
+ return this.height;
469
+ }
470
+ /** Format a value for display, adapting decimal places to the visible range magnitude. */
471
+ formatY(t) {
472
+ const i = this.max - this.min;
473
+ return i < 0.01 ? t.toFixed(6) : i < 0.1 ? t.toFixed(4) : i < 10 ? t.toFixed(2) : i < 1e3 ? t.toFixed(1) : t.toFixed(0);
474
+ }
475
+ }
476
+ const ii = {
477
+ colors: ["#26a69a", "#ef5350"],
478
+ barWidthRatio: 0.6,
479
+ stacking: "off"
480
+ };
481
+ class Z {
482
+ constructor(t, i) {
483
+ w(this, "stores"), w(this, "options"), this.stores = Array.from({ length: t }, () => new jt()), this.options = { ...ii, ...i };
484
+ }
485
+ /** For chart compatibility — returns first store */
486
+ get store() {
487
+ return this.stores[0];
488
+ }
489
+ updateOptions(t) {
490
+ this.options = { ...this.options, ...t };
491
+ }
492
+ getColor() {
493
+ return this.options.colors[0];
494
+ }
495
+ getColors() {
496
+ return this.options.colors;
497
+ }
498
+ getValueRange(t, i) {
499
+ if (this.options.stacking === "percent")
500
+ return { min: 0, max: 100 };
501
+ if (this.stores.length <= 1)
502
+ return null;
503
+ const e = this.stores.map((n) => n.isVisible() ? n.getVisibleData(t, i) : []);
504
+ if (this.options.stacking === "off") {
505
+ let n = 1 / 0, l = -1 / 0;
506
+ for (const h of e)
507
+ for (const d of h)
508
+ d.value < n && (n = d.value), d.value > l && (l = d.value);
509
+ return n < 1 / 0 ? { min: n, max: l } : null;
510
+ }
511
+ const a = /* @__PURE__ */ new Map();
512
+ for (let n = 0; n < e.length; n++)
513
+ for (const l of e[n])
514
+ a.has(l.time) || a.set(l.time, new Array(e.length).fill(0)), a.get(l.time)[n] = l.value;
515
+ let o = 0, s = 0;
516
+ for (const n of a.values()) {
517
+ let l = 0, h = 0;
518
+ for (const d of n)
519
+ d > 0 ? l += d : h += d;
520
+ l > s && (s = l), h < o && (o = h);
521
+ }
522
+ return s > o ? { min: o, max: s } : null;
523
+ }
524
+ render(t) {
525
+ switch (this.options.stacking) {
526
+ case "normal":
527
+ this.renderStacked(t, !1);
528
+ break;
529
+ case "percent":
530
+ this.renderStacked(t, !0);
531
+ break;
532
+ default:
533
+ this.renderOff(t);
534
+ break;
535
+ }
536
+ }
537
+ /** Stacking off — each layer drawn independently from zero, overlapping */
538
+ renderOff(t) {
539
+ const { scope: i, timeScale: e, yScale: a, dataInterval: o } = t, { context: s } = i, n = e.getRange(), l = e.barWidthBitmap(o), h = Math.max(1, Math.round(l * this.options.barWidthRatio) - 2), d = Math.floor(h / 2), g = a.getRange().min < 0, f = g ? a.valueToBitmapY(0) : i.bitmapSize.height;
540
+ if (this.stores.length === 1) {
541
+ if (!this.stores[0].isVisible()) return;
542
+ const p = this.options.colors[0], m = this.options.colors.length > 1 ? this.options.colors[1] : p, b = this.stores[0].getVisibleData(n.from, n.to);
543
+ for (const u of b) {
544
+ const v = e.timeToBitmapX(u.time);
545
+ if (u.value >= 0) {
546
+ const y = a.valueToBitmapY(u.value), x = Math.max(1, f - y);
547
+ this.fillBar(s, v - d, y, h, x, p);
548
+ } else {
549
+ const y = a.valueToBitmapY(u.value), x = Math.max(1, y - f);
550
+ this.fillBar(s, v - d, f, h, x, m);
551
+ }
552
+ }
553
+ } else {
554
+ const p = this.stores.map((b) => b.isVisible() ? b.getVisibleData(n.from, n.to) : []), m = /* @__PURE__ */ new Map();
555
+ for (let b = 0; b < p.length; b++)
556
+ for (const u of p[b]) {
557
+ let v = m.get(u.time);
558
+ v || (v = [], m.set(u.time, v)), v.push({ layer: b, value: u.value });
559
+ }
560
+ for (const [b, u] of m) {
561
+ u.sort((y, x) => Math.abs(x.value) - Math.abs(y.value));
562
+ const v = e.timeToBitmapX(b);
563
+ for (const { layer: y, value: x } of u) {
564
+ const C = this.options.colors[y % this.options.colors.length];
565
+ if (x >= 0) {
566
+ const T = a.valueToBitmapY(x), k = Math.max(1, f - T);
567
+ this.fillBar(s, v - d, T, h, k, C);
568
+ } else {
569
+ const T = a.valueToBitmapY(x), k = Math.max(1, T - f);
570
+ this.fillBar(s, v - d, f, h, k, C);
571
+ }
572
+ }
573
+ }
574
+ }
575
+ if (g) {
576
+ s.strokeStyle = t.theme.grid.color, s.lineWidth = 1;
577
+ const p = Math.round(f) + 0.5;
578
+ s.beginPath(), s.moveTo(0, p), s.lineTo(i.bitmapSize.width, p), s.stroke();
579
+ }
580
+ }
581
+ /** Stacked (normal or percent) rendering */
582
+ renderStacked(t, i) {
583
+ const { scope: e, timeScale: a, yScale: o, dataInterval: s } = t, { context: n } = e, l = a.getRange(), h = a.barWidthBitmap(s), d = Math.max(1, Math.round(h * this.options.barWidthRatio) - 2), g = Math.floor(d / 2), f = this.stores.map(
584
+ (m) => m.isVisible() ? m.getVisibleData(l.from, l.to) : []
585
+ );
586
+ if (f.every((m) => m.length === 0)) return;
587
+ const p = /* @__PURE__ */ new Map();
588
+ for (let m = 0; m < f.length; m++)
589
+ for (const b of f[m])
590
+ p.has(b.time) || p.set(b.time, new Array(f.length).fill(0)), p.get(b.time)[m] = this.stores[m].isVisible() ? b.value : 0;
591
+ for (let m = 0; m < f.length; m++) {
592
+ const b = this.options.colors[m % this.options.colors.length];
593
+ for (const [u, v] of p) {
594
+ const y = v[m];
595
+ if (y === 0) continue;
596
+ const x = a.timeToBitmapX(u);
597
+ let C = 0, T = 0;
598
+ for (let k = 0; k < m; k++) {
599
+ const D = v[k];
600
+ D > 0 ? C += D : T += D;
601
+ }
602
+ if (i) {
603
+ let k = 0, D = 0;
604
+ for (const z of v)
605
+ z > 0 ? k += z : D += z;
606
+ if (y > 0 && k > 0) {
607
+ const z = C / k * 100, _ = (C + y) / k * 100, P = o.valueToBitmapY(_), X = o.valueToBitmapY(z), H = Math.max(1, X - P);
608
+ this.fillBar(n, x - g, P, d, H, b);
609
+ } else if (y < 0 && D < 0) {
610
+ const z = T / D * -100, _ = (T + y) / D * -100, P = o.valueToBitmapY(z), X = o.valueToBitmapY(_), H = Math.max(1, X - P);
611
+ n.fillStyle = b, n.fillRect(x - g, P, d, H);
612
+ }
613
+ } else if (y > 0) {
614
+ const k = o.valueToBitmapY(C + y), D = o.valueToBitmapY(C), z = Math.max(1, D - k);
615
+ this.fillBar(n, x - g, k, d, z, b);
616
+ } else {
617
+ const k = o.valueToBitmapY(T), D = o.valueToBitmapY(T + y), z = Math.max(1, D - k);
618
+ n.fillStyle = b, n.fillRect(x - g, k, d, z);
619
+ }
620
+ }
621
+ }
622
+ }
623
+ fillBar(t, i, e, a, o, s) {
624
+ t.fillStyle = s, t.fillRect(i, e, a, o);
625
+ }
626
+ }
627
+ function ue(r, t) {
628
+ return r.length <= t ? r : ri(
629
+ r,
630
+ t,
631
+ (i) => i.time,
632
+ (i) => i.value
633
+ );
634
+ }
635
+ function oi(r, t) {
636
+ if (r.length <= t) return r;
637
+ const i = Math.ceil(r.length / t), e = [];
638
+ for (let a = 0; a < r.length; a += i) {
639
+ const o = Math.min(a + i, r.length);
640
+ let s = -1 / 0, n = 1 / 0, l = 0;
641
+ for (let h = a; h < o; h++)
642
+ r[h].high > s && (s = r[h].high), r[h].low < n && (n = r[h].low), l += r[h].volume ?? 0;
643
+ e.push({
644
+ time: r[a].time,
645
+ open: r[a].open,
646
+ high: s,
647
+ low: n,
648
+ close: r[o - 1].close,
649
+ volume: l
650
+ });
651
+ }
652
+ return e;
653
+ }
654
+ function ri(r, t, i, e) {
655
+ if (t >= r.length || t < 3) return r;
656
+ const a = [r[0]], o = (r.length - 2) / (t - 2);
657
+ let s = 0;
658
+ for (let n = 0; n < t - 2; n++) {
659
+ const l = Math.floor((n + 1) * o) + 1, h = Math.min(Math.floor((n + 2) * o) + 1, r.length - 1);
660
+ let d = 0, g = 0;
661
+ const f = h, p = Math.min(Math.floor((n + 3) * o) + 1, r.length), m = p - f;
662
+ if (m > 0) {
663
+ for (let x = f; x < p; x++)
664
+ d += i(r[x]), g += e(r[x]);
665
+ d /= m, g /= m;
666
+ }
667
+ let b = -1, u = l;
668
+ const v = i(r[s]), y = e(r[s]);
669
+ for (let x = l; x < h; x++) {
670
+ const C = Math.abs((v - d) * (e(r[x]) - y) - (v - i(r[x])) * (g - y));
671
+ C > b && (b = C, u = x);
672
+ }
673
+ a.push(r[u]), s = u;
674
+ }
675
+ return a.push(r[r.length - 1]), a;
676
+ }
677
+ const fe = /* @__PURE__ */ new Map(), ge = /* @__PURE__ */ new Map(), pe = /* @__PURE__ */ new Map();
678
+ function Jt(r) {
679
+ return [parseInt(r.slice(1, 3), 16), parseInt(r.slice(3, 5), 16), parseInt(r.slice(5, 7), 16)];
680
+ }
681
+ function Ce(r, t, i) {
682
+ return `#${r.toString(16).padStart(2, "0")}${t.toString(16).padStart(2, "0")}${i.toString(16).padStart(2, "0")}`;
683
+ }
684
+ function bt(r, t) {
685
+ if (r.startsWith("rgba")) return r.replace(/[\d.]+\)\s*$/, `${t})`);
686
+ if (r.startsWith("rgb(")) return r.replace(/^rgb\((.*)\)$/i, `rgba($1, ${t})`);
687
+ const i = r + t;
688
+ let e = fe.get(i);
689
+ if (e) return e;
690
+ const [a, o, s] = Jt(r);
691
+ return e = `rgba(${a}, ${o}, ${s}, ${t})`, fe.set(i, e), e;
692
+ }
693
+ function ai(r, t) {
694
+ const i = r + t;
695
+ let e = ge.get(i);
696
+ if (e) return e;
697
+ const [a, o, s] = Jt(r);
698
+ return e = Ce(
699
+ Math.min(255, Math.round(a + (255 - a) * t)),
700
+ Math.min(255, Math.round(o + (255 - o) * t)),
701
+ Math.min(255, Math.round(s + (255 - s) * t))
702
+ ), ge.set(i, e), e;
703
+ }
704
+ function si(r, t) {
705
+ const i = r + t;
706
+ let e = pe.get(i);
707
+ if (e) return e;
708
+ const [a, o, s] = Jt(r);
709
+ return e = Ce(
710
+ Math.max(0, Math.round(a * (1 - t))),
711
+ Math.max(0, Math.round(o * (1 - t))),
712
+ Math.max(0, Math.round(s * (1 - t)))
713
+ ), pe.set(i, e), e;
714
+ }
715
+ const ni = {
716
+ upColor: "#26a69a",
717
+ downColor: "#ef5350",
718
+ wickUpColor: "#26a69a",
719
+ wickDownColor: "#ef5350",
720
+ bodyWidthRatio: 0.6
721
+ };
722
+ class $t {
723
+ constructor(t, i) {
724
+ w(this, "store"), w(this, "options"), this.store = t, this.options = { ...ni, ...i };
725
+ }
726
+ updateOptions(t) {
727
+ this.options = { ...this.options, ...t };
728
+ }
729
+ getColor() {
730
+ return this.options.upColor;
731
+ }
732
+ render(t) {
733
+ const { scope: i, timeScale: e, yScale: a, dataInterval: o } = t, { context: s, horizontalPixelRatio: n } = i, l = e.getRange();
734
+ let h = this.store.getVisibleData(l.from, l.to);
735
+ const d = i.mediaSize.width;
736
+ if (h.length > d * 2 && (h = oi(h, Math.round(d * 1.5))), h.length === 0) return;
737
+ const g = e.barWidthBitmap(o), f = Math.max(1, Math.round(g * this.options.bodyWidthRatio) - 2), p = Math.floor(f / 2), m = Math.max(1, Math.round(n)), b = Math.round(a.getMediaHeight() * i.verticalPixelRatio);
738
+ this.drawVolume(s, h, e, b, g, o);
739
+ const u = [], v = [];
740
+ for (const y of h)
741
+ y.close >= y.open ? u.push(y) : v.push(y);
742
+ this.drawCandles(
743
+ s,
744
+ u,
745
+ e,
746
+ a,
747
+ p,
748
+ f,
749
+ m,
750
+ this.options.upColor,
751
+ this.options.wickUpColor
752
+ ), this.drawCandles(
753
+ s,
754
+ v,
755
+ e,
756
+ a,
757
+ p,
758
+ f,
759
+ m,
760
+ this.options.downColor,
761
+ this.options.wickDownColor
762
+ );
763
+ }
764
+ drawVolume(t, i, e, a, o, s) {
765
+ let n = 0;
766
+ for (const p of i)
767
+ p.volume !== void 0 && p.volume > n && (n = p.volume);
768
+ if (n === 0) return;
769
+ const l = a * 0.2, h = Math.max(1, o - 2), d = Math.floor(h / 2), g = bt(this.options.upColor, 0.2), f = bt(this.options.downColor, 0.2);
770
+ for (const p of i) {
771
+ if (p.volume === void 0 || p.volume === 0) continue;
772
+ const m = e.timeToBitmapX(p.time), b = Math.max(1, p.volume / n * l), u = p.close >= p.open;
773
+ t.fillStyle = u ? g : f, t.fillRect(m - d, a - b, h, b);
774
+ }
775
+ }
776
+ drawCandles(t, i, e, a, o, s, n, l, h) {
777
+ if (i.length === 0) return;
778
+ t.fillStyle = h;
779
+ for (const p of i) {
780
+ const m = e.timeToBitmapX(p.time), b = a.valueToBitmapY(p.high), u = a.valueToBitmapY(p.low), v = m - Math.floor(n / 2);
781
+ t.fillRect(v, b, n, u - b);
782
+ }
783
+ const d = this.options.candleGradient !== !1, g = d ? ai(l, 0.2) : l, f = d ? si(l, 0.15) : l;
784
+ d || (t.fillStyle = l);
785
+ for (const p of i) {
786
+ const m = e.timeToBitmapX(p.time), b = a.valueToBitmapY(p.open), u = a.valueToBitmapY(p.close), v = Math.min(b, u), y = Math.max(1, Math.abs(u - b));
787
+ if (d && y > 2) {
788
+ const x = t.createLinearGradient(0, v, 0, v + y);
789
+ x.addColorStop(0, g), x.addColorStop(0.5, l), x.addColorStop(1, f), t.fillStyle = x;
790
+ }
791
+ t.fillRect(m - o, v, s, y);
792
+ }
793
+ }
794
+ }
795
+ const li = {
796
+ colors: ["#2962FF"],
797
+ lineWidth: 1,
798
+ areaFill: !0,
799
+ pulse: !0,
800
+ stacking: "off"
801
+ };
802
+ class G {
803
+ constructor(t, i) {
804
+ w(this, "stores"), w(this, "options"), w(this, "areaGradientCache", /* @__PURE__ */ new Map()), this.stores = Array.from({ length: t }, () => new jt()), this.options = { ...li, ...i };
805
+ }
806
+ get store() {
807
+ return this.stores[0];
808
+ }
809
+ updateOptions(t) {
810
+ this.options = { ...this.options, ...t };
811
+ }
812
+ getColor() {
813
+ return this.options.colors[0];
814
+ }
815
+ getColors() {
816
+ return this.options.colors;
817
+ }
818
+ getStacking() {
819
+ return this.options.stacking;
820
+ }
821
+ get needsAnimation() {
822
+ return !1;
823
+ }
824
+ get hasPulse() {
825
+ return this.options.pulse && this.stores.some((t) => t.isVisible() && t.length > 0);
826
+ }
827
+ getValueRange(t, i) {
828
+ if (this.options.stacking === "percent")
829
+ return { min: 0, max: 100 };
830
+ if (this.stores.length <= 1)
831
+ return null;
832
+ const e = this.stores.map((n) => n.isVisible() ? n.getVisibleData(t, i) : []);
833
+ if (this.options.stacking === "off") {
834
+ let n = 1 / 0, l = -1 / 0;
835
+ for (const h of e)
836
+ for (const d of h)
837
+ d.value < n && (n = d.value), d.value > l && (l = d.value);
838
+ return n < 1 / 0 ? { min: n, max: l } : null;
839
+ }
840
+ const a = /* @__PURE__ */ new Map();
841
+ for (let n = 0; n < e.length; n++)
842
+ for (const l of e[n])
843
+ a.has(l.time) || a.set(l.time, new Array(e.length).fill(0)), a.get(l.time)[n] = l.value;
844
+ let o = 0, s = 0;
845
+ for (const n of a.values()) {
846
+ let l = 0, h = 0;
847
+ for (const d of n)
848
+ d > 0 ? l += d : h += d;
849
+ l > s && (s = l), h < o && (o = h);
850
+ }
851
+ return s > o ? { min: o, max: s } : null;
852
+ }
853
+ render(t) {
854
+ this.options.stacking === "off" ? this.renderOff(t) : this.renderStacked(t, this.options.stacking === "percent");
855
+ }
856
+ /** Each layer drawn independently */
857
+ renderOff(t) {
858
+ const { scope: i, timeScale: e, yScale: a } = t, { context: o } = i, s = e.getRange(), { verticalPixelRatio: n, horizontalPixelRatio: l } = i, h = Math.max(1, Math.round(this.options.lineWidth * n));
859
+ for (let d = 0; d < this.stores.length; d++) {
860
+ if (!this.stores[d].isVisible()) continue;
861
+ let g = this.stores[d].getVisibleData(s.from, s.to);
862
+ const f = i.mediaSize.width;
863
+ if (g.length > f * 2 && (g = ue(g, Math.round(f * 1.5))), g.length < 2) continue;
864
+ const p = this.options.colors[d % this.options.colors.length];
865
+ o.beginPath(), o.moveTo(e.timeToBitmapX(g[0].time), a.valueToBitmapY(g[0].value));
866
+ for (let m = 1; m < g.length; m++)
867
+ o.lineTo(e.timeToBitmapX(g[m].time), a.valueToBitmapY(g[m].value));
868
+ if (o.strokeStyle = p, o.lineWidth = h, o.lineJoin = "round", o.lineCap = "round", o.stroke(), this.options.areaFill) {
869
+ const m = e.timeToBitmapX(g[0].time), b = e.timeToBitmapX(g[g.length - 1].time), u = i.bitmapSize.height;
870
+ o.lineTo(b, u), o.lineTo(m, u), o.closePath();
871
+ const v = String(d), y = this.areaGradientCache.get(v);
872
+ let x;
873
+ y && y.bottomY === u && y.color === p ? x = y.gradient : (x = o.createLinearGradient(0, 0, 0, u), x.addColorStop(0, bt(p, 0.12)), x.addColorStop(1, bt(p, 0.01)), this.areaGradientCache.set(v, { gradient: x, bottomY: u, color: p })), o.fillStyle = x, o.fill();
874
+ }
875
+ }
876
+ }
877
+ /** Stacked area rendering */
878
+ renderStacked(t, i) {
879
+ const { scope: e, timeScale: a, yScale: o } = t, { context: s } = e, n = a.getRange(), { verticalPixelRatio: l } = e, h = Math.max(1, Math.round(this.options.lineWidth * l)), d = e.mediaSize.width, g = this.stores.map((u) => {
880
+ let v = u.getVisibleData(n.from, n.to);
881
+ return v.length > d * 2 && (v = ue(v, Math.round(d * 1.5))), v;
882
+ }), f = /* @__PURE__ */ new Set();
883
+ for (const u of g)
884
+ for (const v of u) f.add(v.time);
885
+ const p = Array.from(f).sort((u, v) => u - v);
886
+ if (p.length < 2) return;
887
+ const m = g.map((u) => {
888
+ const v = /* @__PURE__ */ new Map();
889
+ for (const y of u) v.set(y.time, y.value);
890
+ return v;
891
+ }), b = Array.from({ length: this.stores.length }, () => new Array(p.length).fill(0));
892
+ for (let u = 0; u < p.length; u++) {
893
+ const v = p[u];
894
+ let y = 0;
895
+ if (i)
896
+ for (let C = 0; C < this.stores.length; C++)
897
+ this.stores[C].isVisible() && (y += m[C].get(v) ?? 0);
898
+ let x = 0;
899
+ for (let C = 0; C < this.stores.length; C++) {
900
+ const T = this.stores[C].isVisible() ? m[C].get(v) ?? 0 : 0;
901
+ x += i && y > 0 ? T / y * 100 : T, b[C][u] = x;
902
+ }
903
+ }
904
+ for (let u = this.stores.length - 1; u >= 0; u--) {
905
+ if (!this.stores[u].isVisible()) continue;
906
+ const v = this.options.colors[u % this.options.colors.length], y = [];
907
+ for (let C = 0; C < p.length; C++)
908
+ y.push([a.timeToBitmapX(p[C]), o.valueToBitmapY(b[u][C])]);
909
+ const x = [];
910
+ for (let C = 0; C < p.length; C++) {
911
+ const T = u > 0 ? b[u - 1][C] : 0;
912
+ x.push([a.timeToBitmapX(p[C]), o.valueToBitmapY(T)]);
913
+ }
914
+ if (this.options.areaFill) {
915
+ s.beginPath(), s.moveTo(y[0][0], y[0][1]);
916
+ for (let C = 1; C < y.length; C++)
917
+ s.lineTo(y[C][0], y[C][1]);
918
+ for (let C = x.length - 1; C >= 0; C--)
919
+ s.lineTo(x[C][0], x[C][1]);
920
+ s.closePath(), s.fillStyle = bt(v, 0.25), s.fill();
921
+ }
922
+ s.beginPath(), s.moveTo(y[0][0], y[0][1]);
923
+ for (let C = 1; C < y.length; C++)
924
+ s.lineTo(y[C][0], y[C][1]);
925
+ s.strokeStyle = v, s.lineWidth = h, s.lineJoin = "round", s.lineCap = "round", s.stroke();
926
+ }
927
+ }
928
+ drawPulseOverlay(t, i, e, a) {
929
+ if (this.options.pulse)
930
+ for (let o = 0; o < this.stores.length; o++) {
931
+ if (!this.stores[o].isVisible()) continue;
932
+ const s = this.stores[o].last();
933
+ if (!s) continue;
934
+ const n = this.options.colors[o % this.options.colors.length];
935
+ this.drawPulse(
936
+ t,
937
+ i.timeToBitmapX(s.time),
938
+ e.valueToBitmapY(s.value),
939
+ n,
940
+ a
941
+ );
942
+ }
943
+ }
944
+ drawPulse(t, i, e, a, o) {
945
+ const s = 3 * o, n = 0.4 + 0.6 * Math.abs(Math.sin(performance.now() / 600)), l = s + 4 * o * n;
946
+ t.beginPath(), t.arc(i, e, l, 0, Math.PI * 2), t.fillStyle = bt(a, n * 0.3), t.fill(), t.beginPath(), t.arc(i, e, s, 0, Math.PI * 2), t.fillStyle = a, t.fill();
947
+ }
948
+ }
949
+ const ci = {
950
+ innerRadiusRatio: 0,
951
+ padAngle: 0.02,
952
+ strokeColor: "transparent",
953
+ strokeWidth: 0
954
+ }, Pt = Math.PI * 2;
955
+ function hi(r) {
956
+ if (!r.startsWith("#")) return !1;
957
+ const t = parseInt(r.slice(1, 3), 16), i = parseInt(r.slice(3, 5), 16), e = parseInt(r.slice(5, 7), 16);
958
+ return t * 0.299 + i * 0.587 + e * 0.114 > 150;
959
+ }
960
+ function di(r, t) {
961
+ if (!r.startsWith("#")) return r;
962
+ const i = Math.min(255, parseInt(r.slice(1, 3), 16) + Math.round(255 * t)), e = Math.min(255, parseInt(r.slice(3, 5), 16) + Math.round(255 * t)), a = Math.min(255, parseInt(r.slice(5, 7), 16) + Math.round(255 * t));
963
+ return `#${i.toString(16).padStart(2, "0")}${e.toString(16).padStart(2, "0")}${a.toString(16).padStart(2, "0")}`;
964
+ }
965
+ function ui(r, t, i) {
966
+ return r + (t - r) * Math.min(1, i);
967
+ }
968
+ class lt {
969
+ constructor(t) {
970
+ w(this, "data", []), w(this, "options"), w(this, "hoverIndex", -1), w(this, "sliceOffsets", []), w(this, "lastRenderTime", 0), this.options = { ...ci, ...t };
971
+ }
972
+ getData() {
973
+ return this.data;
974
+ }
975
+ setData(t) {
976
+ this.data = t, this.sliceOffsets = new Array(t.length).fill(0);
977
+ }
978
+ updateOptions(t) {
979
+ this.options = { ...this.options, ...t };
980
+ }
981
+ getColor() {
982
+ var t, i;
983
+ return ((t = this.data[0]) == null ? void 0 : t.color) ?? ((i = this.options.colors) == null ? void 0 : i[0]) ?? "#888";
984
+ }
985
+ /** Hit-test: which slice is at this bitmap coordinate? Returns index or -1. */
986
+ hitTest(t, i, e, a) {
987
+ if (this.data.length === 0) return -1;
988
+ const o = this.data.reduce((b, u) => b + u.value, 0);
989
+ if (o <= 0) return -1;
990
+ const s = e / 2, n = a / 2, l = Math.min(e, a) / 2 * 0.85, h = l * this.options.innerRadiusRatio, d = t - s, g = i - n, f = Math.sqrt(d * d + g * g);
991
+ if (f > l || f < h) return -1;
992
+ let p = Math.atan2(g, d) + Math.PI / 2;
993
+ p < 0 && (p += Pt);
994
+ let m = 0;
995
+ for (let b = 0; b < this.data.length; b++) {
996
+ const u = this.data[b].value / o * Pt;
997
+ if (p >= m && p < m + u) return b;
998
+ m += u;
999
+ }
1000
+ return -1;
1001
+ }
1002
+ /** Returns true if animation is still in progress. */
1003
+ get needsAnimation() {
1004
+ for (let t = 0; t < this.sliceOffsets.length; t++) {
1005
+ const i = t === this.hoverIndex ? 1 : 0;
1006
+ if (Math.abs(this.sliceOffsets[t] - i) > 0.01) return !0;
1007
+ }
1008
+ return !1;
1009
+ }
1010
+ render(t) {
1011
+ if (this.data.length === 0) return;
1012
+ const { scope: i, theme: e } = t, { context: a, bitmapSize: o, horizontalPixelRatio: s } = i, n = performance.now(), l = this.lastRenderTime ? (n - this.lastRenderTime) / 1e3 : 0;
1013
+ this.lastRenderTime = n;
1014
+ const h = this.data.reduce((k, D) => k + D.value, 0);
1015
+ if (h <= 0) return;
1016
+ const d = 10;
1017
+ for (; this.sliceOffsets.length < this.data.length; ) this.sliceOffsets.push(0);
1018
+ for (let k = 0; k < this.data.length; k++) {
1019
+ const D = k === this.hoverIndex ? 1 : 0;
1020
+ this.sliceOffsets[k] = ui(this.sliceOffsets[k], D, d * l);
1021
+ }
1022
+ const g = this.options.colors ?? e.seriesColors, f = o.width / 2, p = o.height / 2, m = Math.min(o.width, o.height) / 2 * 0.85, b = m * this.options.innerRadiusRatio, u = this.options.padAngle, { strokeColor: v, strokeWidth: y } = this.options, x = 8 * s;
1023
+ let C = -Math.PI / 2;
1024
+ for (let k = 0; k < this.data.length; k++) {
1025
+ const D = this.data[k], z = D.value / h * Pt, _ = C + u / 2, P = C + z - u / 2, X = C + z / 2, H = D.color ?? g[k % g.length], Q = this.sliceOffsets[k] * x, U = Math.cos(X) * Q, nt = Math.sin(X) * Q, E = f + U, O = p + nt;
1026
+ a.beginPath(), a.arc(E, O, m, _, P), b > 0 ? a.arc(E, O, b, P, _, !0) : a.lineTo(E, O), a.closePath();
1027
+ const A = a.createRadialGradient(E, O, b || 0, E, O, m);
1028
+ A.addColorStop(0, di(H, 0.15)), A.addColorStop(1, H), a.fillStyle = A, this.sliceOffsets[k] > 0.01 && (a.shadowColor = "rgba(0,0,0,0.25)", a.shadowBlur = 12 * s * this.sliceOffsets[k], a.shadowOffsetX = U * 0.3, a.shadowOffsetY = nt * 0.3), a.fill(), a.shadowColor = "transparent", a.shadowBlur = 0, a.shadowOffsetX = 0, a.shadowOffsetY = 0, y > 0 && v !== "transparent" && (a.strokeStyle = v, a.lineWidth = y, a.stroke()), C += z;
1029
+ }
1030
+ C = -Math.PI / 2;
1031
+ const T = b > 0 ? (m + b) / 2 : m * 0.65;
1032
+ a.textAlign = "center", a.textBaseline = "middle", a.font = `${11 * s}px ${e.typography.fontFamily}`;
1033
+ for (let k = 0; k < this.data.length; k++) {
1034
+ const D = this.data[k], z = D.value / h * Pt;
1035
+ if (z > 0.3) {
1036
+ const _ = C + z / 2, P = this.sliceOffsets[k] * x, X = f + Math.cos(_) * (T + P), H = p + Math.sin(_) * (T + P), Q = D.color ?? g[k % g.length];
1037
+ a.fillStyle = hi(Q) ? "#000000" : "#ffffff", a.fillText(D.label, X, H);
1038
+ }
1039
+ C += z;
1040
+ }
1041
+ }
1042
+ }
1043
+ const fi = {
1044
+ background: "#131722",
1045
+ chartGradient: ["#1a1f2e", "#101318"],
1046
+ typography: {
1047
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
1048
+ fontSize: 12,
1049
+ axisFontSize: 10,
1050
+ yFontSize: 11,
1051
+ tooltipFontSize: 12
1052
+ },
1053
+ grid: {
1054
+ color: "rgba(42, 46, 57, 0.6)",
1055
+ style: "dashed"
1056
+ },
1057
+ candlestick: {
1058
+ upColor: "#26a69a",
1059
+ downColor: "#ef5350",
1060
+ wickUpColor: "#26a69a",
1061
+ wickDownColor: "#ef5350"
1062
+ },
1063
+ line: {
1064
+ color: "#2962FF",
1065
+ width: 1,
1066
+ areaTopColor: "rgba(41, 98, 255, 0.08)",
1067
+ areaBottomColor: "rgba(41, 98, 255, 0.01)"
1068
+ },
1069
+ seriesColors: [
1070
+ "#2962FF",
1071
+ "#FF6D00",
1072
+ "#26a69a",
1073
+ "#AB47BC",
1074
+ "#ef5350",
1075
+ "#FFCA28",
1076
+ "#66BB6A",
1077
+ "#EC407A",
1078
+ "#42A5F5",
1079
+ "#B388FF"
1080
+ ],
1081
+ bands: {
1082
+ upper: "#42A5F5",
1083
+ lower: "#EC407A"
1084
+ },
1085
+ crosshair: {
1086
+ color: "rgba(150, 150, 150, 0.5)",
1087
+ labelBackground: "#363a45",
1088
+ labelTextColor: "#d1d4dc"
1089
+ },
1090
+ axis: { textColor: "#787b86" },
1091
+ yLabel: {
1092
+ upBackground: "#26a69a",
1093
+ downBackground: "#ef5350",
1094
+ neutralBackground: "#363a45",
1095
+ textColor: "#ffffff"
1096
+ },
1097
+ tooltip: {
1098
+ background: "rgba(19, 23, 34, 0.9)",
1099
+ textColor: "#d1d4dc",
1100
+ borderColor: "rgba(42, 46, 57, 0.8)"
1101
+ }
1102
+ }, rt = {
1103
+ top: 20,
1104
+ bottom: 20,
1105
+ right: { intervals: 3 },
1106
+ left: { intervals: 0 }
1107
+ };
1108
+ class gi extends Bt {
1109
+ constructor({ padding: t } = {}) {
1110
+ super(), w(this, "_visibleRange", { from: 0, to: 0 }), w(this, "_yRange", { min: 0, max: 0 }), w(this, "_autoScroll", !0), w(this, "padding"), w(this, "dataInterval", 6e4), w(this, "_dataStart", null), w(this, "_dataEnd", null), w(this, "_animating", !1), w(this, "animStartTime", 0), w(this, "animDuration", 0), w(this, "animFrom", { from: 0, to: 0 }), w(this, "animTo", { from: 0, to: 0 }), this.padding = {
1111
+ top: (t == null ? void 0 : t.top) ?? rt.top,
1112
+ bottom: (t == null ? void 0 : t.bottom) ?? rt.bottom,
1113
+ right: (t == null ? void 0 : t.right) ?? rt.right,
1114
+ left: (t == null ? void 0 : t.left) ?? rt.left
1115
+ };
1116
+ }
1117
+ /**
1118
+ * Resolve a HorizontalPadding value to a time offset.
1119
+ * - `{ intervals: N }` → N * dataInterval (zoom-independent bar count)
1120
+ * - `number` (pixels) → (px / chartWidth) * visibleRange (zoom-dependent)
1121
+ */
1122
+ resolveHPad(t, i, e) {
1123
+ return typeof t == "object" ? t.intervals * this.dataInterval : e <= 0 ? 0 : t / e * i;
1124
+ }
1125
+ get visibleRange() {
1126
+ return this._visibleRange;
1127
+ }
1128
+ get yRange() {
1129
+ return this._yRange;
1130
+ }
1131
+ get autoScroll() {
1132
+ return this._autoScroll;
1133
+ }
1134
+ get animating() {
1135
+ return this._animating;
1136
+ }
1137
+ setDataInterval(t) {
1138
+ this.dataInterval = t;
1139
+ }
1140
+ /** Replace padding configuration. Only updates fields that are provided; others keep defaults. */
1141
+ setPadding(t) {
1142
+ this.padding = {
1143
+ top: (t == null ? void 0 : t.top) ?? rt.top,
1144
+ bottom: (t == null ? void 0 : t.bottom) ?? rt.bottom,
1145
+ right: (t == null ? void 0 : t.right) ?? rt.right,
1146
+ left: (t == null ? void 0 : t.left) ?? rt.left
1147
+ };
1148
+ }
1149
+ setDataStart(t) {
1150
+ this._dataStart = t;
1151
+ }
1152
+ setDataEnd(t) {
1153
+ this._dataEnd = t;
1154
+ }
1155
+ cancelAnimation() {
1156
+ this._animating = !1;
1157
+ }
1158
+ /** Validate and apply a new visible range. When clampToData is true, reject zoom beyond data extent. */
1159
+ applyRange(t, i, e = !1) {
1160
+ if (i <= t) return;
1161
+ const a = i - t;
1162
+ if (!(a / this.dataInterval < 2)) {
1163
+ if (e && this._dataStart !== null && this._dataEnd !== null) {
1164
+ const o = this._dataEnd - this._dataStart + this.dataInterval * 5;
1165
+ if (a > o && o > 0) return;
1166
+ }
1167
+ this._visibleRange = { from: t, to: i }, this.emit("change");
1168
+ }
1169
+ }
1170
+ /** Start animation — will be advanced by tick() calls from the render loop */
1171
+ animateTo(t, i, e = 400) {
1172
+ this.animFrom = { ...this._visibleRange }, this.animTo = { from: t, to: i }, this.animDuration = e, this.animStartTime = performance.now(), this._animating = !0;
1173
+ }
1174
+ /** Called by the render loop before each frame. Returns true if still animating. */
1175
+ tick(t) {
1176
+ if (!this._animating) return !1;
1177
+ const i = t - this.animStartTime, e = Math.min(1, i / this.animDuration), a = 1 - (1 - e) ** 3, o = ce(this.animFrom.from, this.animTo.from, a), s = ce(this.animFrom.to, this.animTo.to, a);
1178
+ return s > o && this.applyRange(o, s), e >= 1 && (this._animating = !1), this._animating;
1179
+ }
1180
+ /** Set the Y-axis range. Adds pixel-based padding unless a side has a fixed (explicit) bound. */
1181
+ setYRange(t, i, e, a = !1, o = !1) {
1182
+ const s = i - t, n = e > 0 ? this.padding.top / e * s : 0, l = e > 0 ? this.padding.bottom / e * s : 0;
1183
+ this._yRange = {
1184
+ min: a ? t : t - l,
1185
+ max: o ? i : i + n
1186
+ };
1187
+ }
1188
+ /** Zoom in/out around a time anchor point. Factor < 1 zooms in, > 1 zooms out. */
1189
+ zoomAt(t, i) {
1190
+ this.cancelAnimation();
1191
+ const { from: e, to: a } = this._visibleRange, o = a - e, s = o * i, n = (t - e) / o, l = t - n * s, h = l + s;
1192
+ if (!(s / this.dataInterval < 10)) {
1193
+ if (i > 1 && this._dataStart !== null && this._dataEnd !== null && l <= this._dataStart && h >= this._dataEnd) {
1194
+ this._autoScroll = !0, this.applyRange(l, h, !0);
1195
+ return;
1196
+ }
1197
+ this._autoScroll = !1, this.applyRange(l, h, !0);
1198
+ }
1199
+ }
1200
+ /** Shift the visible range by a time delta. Disables auto-scroll. */
1201
+ pan(t) {
1202
+ this.cancelAnimation();
1203
+ const { from: i, to: e } = this._visibleRange, a = i + t, o = e + t;
1204
+ this._autoScroll = !1, this.applyRange(a, o);
1205
+ }
1206
+ /** Fit the viewport to show data from first to last timestamp, with optional animation. */
1207
+ fitToData(t, i, e = 0, a = !1) {
1208
+ this._autoScroll = !0;
1209
+ const o = 400 * this.dataInterval, s = i - t, n = s > 0 ? s : this.dataInterval * 10, l = this.resolveHPad(this.padding.right, n, e), h = this.resolveHPad(this.padding.left, n, e);
1210
+ let d = i + l, g = t - h;
1211
+ d - g > o && (d = i + l, g = d - o), a && this._visibleRange.from !== 0 && this._visibleRange.to !== 0 ? this.animateTo(g, d, 450) : this.applyRange(g, d);
1212
+ }
1213
+ /** Keep the right edge pinned to the latest data (real-time auto-scroll). */
1214
+ scrollToEnd(t, i = 0) {
1215
+ const e = this._visibleRange.to - this._visibleRange.from, a = this.resolveHPad(this.padding.right, e, i), o = t + a, s = o - e;
1216
+ this._autoScroll = !0, this._animating ? (this.animFrom = { ...this._visibleRange }, this.animTo = { from: s, to: o }, this.animDuration = 150, this.animStartTime = performance.now()) : this.animateTo(s, o, 150);
1217
+ }
1218
+ /** Return the number of data bars (candles/points) currently visible. */
1219
+ getVisibleBarsCount() {
1220
+ return (this._visibleRange.to - this._visibleRange.from) / this.dataInterval;
1221
+ }
1222
+ destroy() {
1223
+ this.cancelAnimation(), this.removeAllListeners();
1224
+ }
1225
+ }
1226
+ let pi = 0;
1227
+ var Y, B, V, ft, wt, M, W, St, N, ot, $, tt, Xt, gt, at, kt, ht, pt, Mt, Wt, K, q, mt;
1228
+ class mi extends Bt {
1229
+ constructor(t, i) {
1230
+ var e, a, o;
1231
+ super(), L(this, pt), L(this, Y), L(this, B), L(this, V), L(this, ft), w(this, "timeScale"), w(this, "yScale"), L(this, wt), L(this, M, []), L(this, W), L(this, St), L(this, N, 6e4), L(this, ot, null), L(this, $, {}), L(this, tt, null), L(this, Xt, !1), L(this, gt, {}), L(this, at, 0), L(this, kt, !1), L(this, ht, !1), L(this, Wt, 0), L(this, K, 0), L(this, q, 0), L(this, mt, !1), i != null && i.axis && (R(this, gt, i.axis), R(this, $, { min: (e = i.axis.y) == null ? void 0 : e.min, max: (a = i.axis.y) == null ? void 0 : a.max })), R(this, W, (i == null ? void 0 : i.theme) ?? fi), R(this, St, (i == null ? void 0 : i.grid) !== !1), R(this, Y, new Oe(t)), R(this, B, new gi({ padding: i == null ? void 0 : i.padding })), this.timeScale = new ti(), this.yScale = new ei(), R(this, V, new he(() => this.renderMain())), R(this, ft, new he(() => this.renderOverlay()));
1232
+ const s = (i == null ? void 0 : i.interactive) !== !1;
1233
+ R(this, wt, s ? new je(c(this, Y).canvas, c(this, B), this.timeScale, this.yScale) : null), c(this, B).on("change", () => {
1234
+ this.syncScales(), c(this, V).markDirty(), this.emit("viewportChange");
1235
+ }), c(this, Y).on("resize", () => {
1236
+ this.updateScales(!0), this.renderMain(), this.emit("viewportChange");
1237
+ }), (o = c(this, wt)) == null || o.on("crosshairMove", (n) => {
1238
+ R(this, ot, n), c(this, ft).markDirty(), this.emit("crosshairMove", n), this.updatePieHover(n);
1239
+ });
1240
+ }
1241
+ get yAxisWidth() {
1242
+ const t = c(this, gt).y;
1243
+ return (t == null ? void 0 : t.visible) === !1 ? 0 : (t == null ? void 0 : t.width) ?? 55;
1244
+ }
1245
+ get xAxisHeight() {
1246
+ const t = c(this, gt).x;
1247
+ return (t == null ? void 0 : t.visible) === !1 ? 0 : (t == null ? void 0 : t.height) ?? 30;
1248
+ }
1249
+ /** Add a candlestick (OHLC) series and return its unique ID. */
1250
+ addCandlestickSeries(t) {
1251
+ const i = new jt(), e = new $t(i, {
1252
+ upColor: c(this, W).candlestick.upColor,
1253
+ downColor: c(this, W).candlestick.downColor,
1254
+ wickUpColor: c(this, W).candlestick.wickUpColor,
1255
+ wickDownColor: c(this, W).candlestick.wickDownColor,
1256
+ bodyWidthRatio: 0.6,
1257
+ ...t
1258
+ }), a = Ft(this, pt, Mt).call(this, t == null ? void 0 : t.id);
1259
+ return i.on("update", () => {
1260
+ this.onDataChanged();
1261
+ }), c(this, M).push({ id: a, renderer: e, store: i, visible: !0 }), R(this, tt, null), this.updateViewportPadding(), this.emit("seriesChange"), a;
1262
+ }
1263
+ addLineSeries(t, i) {
1264
+ let e, a;
1265
+ if (typeof t == "number")
1266
+ e = t, a = i;
1267
+ else {
1268
+ const { layers: n, ...l } = t ?? {};
1269
+ e = n ?? 1, a = l;
1270
+ }
1271
+ const o = new G(e, {
1272
+ colors: e === 1 ? [c(this, W).line.color] : c(this, W).seriesColors.slice(0, e),
1273
+ lineWidth: c(this, W).line.width,
1274
+ areaFill: !0,
1275
+ ...a
1276
+ }), s = Ft(this, pt, Mt).call(this, a == null ? void 0 : a.id);
1277
+ for (const n of o.stores)
1278
+ n.on("update", () => this.onDataChanged());
1279
+ return c(this, M).push({ id: s, label: a == null ? void 0 : a.label, renderer: o, store: o.stores[0], visible: !0 }), R(this, tt, null), this.updateViewportPadding(), this.emit("seriesChange"), s;
1280
+ }
1281
+ /** Set data for a specific layer within a line series. */
1282
+ setLineLayerData(t, i, e) {
1283
+ const a = c(this, M).find((s) => s.id === t);
1284
+ if (!a || !(a.renderer instanceof G)) return;
1285
+ const o = a.renderer.stores[i];
1286
+ o && o.setData(e);
1287
+ }
1288
+ addBarSeries(t, i) {
1289
+ let e, a;
1290
+ if (typeof t == "number")
1291
+ e = t, a = i;
1292
+ else {
1293
+ const { layers: n, ...l } = t ?? {};
1294
+ e = n ?? 1, a = l;
1295
+ }
1296
+ const o = new Z(e, {
1297
+ colors: c(this, W).seriesColors.slice(0, e),
1298
+ barWidthRatio: 0.6,
1299
+ ...a
1300
+ }), s = Ft(this, pt, Mt).call(this, a == null ? void 0 : a.id);
1301
+ for (const n of o.stores)
1302
+ n.on("update", () => this.onDataChanged());
1303
+ return c(this, M).push({ id: s, label: a == null ? void 0 : a.label, renderer: o, store: o.stores[0], visible: !0 }), R(this, tt, null), this.updateViewportPadding(), this.emit("seriesChange"), s;
1304
+ }
1305
+ /** Set data for a specific layer within a bar series. */
1306
+ setBarLayerData(t, i, e) {
1307
+ const a = c(this, M).find((s) => s.id === t);
1308
+ if (!a || !(a.renderer instanceof Z)) return;
1309
+ const o = a.renderer.stores[i];
1310
+ o && o.setData(e);
1311
+ }
1312
+ /** Add a pie/donut series. Set `innerRadiusRatio > 0` for donut. */
1313
+ addPieSeries(t) {
1314
+ const i = new lt(t), e = Ft(this, pt, Mt).call(this, t == null ? void 0 : t.id);
1315
+ return c(this, M).push({ id: e, label: t == null ? void 0 : t.label, renderer: i, store: null, visible: !0 }), R(this, tt, null), this.updateViewportPadding(), this.emit("seriesChange"), e;
1316
+ }
1317
+ /** Set data for a pie/donut series. */
1318
+ setPieData(t, i) {
1319
+ const e = c(this, M).find((a) => a.id === t);
1320
+ !e || !(e.renderer instanceof lt) || (e.renderer.setData(i), c(this, V).markDirty(), this.emit("dataUpdate"));
1321
+ }
1322
+ /** Remove a series by ID and clean up its resources. */
1323
+ removeSeries(t) {
1324
+ const i = c(this, M).findIndex((e) => e.id === t);
1325
+ if (i >= 0) {
1326
+ const { renderer: e, store: a } = c(this, M)[i];
1327
+ if (e instanceof G || e instanceof Z)
1328
+ for (const o of e.stores) o.removeAllListeners();
1329
+ else
1330
+ a == null || a.removeAllListeners();
1331
+ c(this, M).splice(i, 1), R(this, tt, null), this.updateViewportPadding(), c(this, V).markDirty(), this.emit("seriesChange");
1332
+ }
1333
+ }
1334
+ /** Replace all data for a series (batch load). Accepts `Date` objects for time fields. */
1335
+ setSeriesData(t, i) {
1336
+ const e = c(this, M).find((o) => o.id === t);
1337
+ if (!(e != null && e.store)) return;
1338
+ const a = i.length > 0 && "open" in i[0] ? Je(i) : Ke(i);
1339
+ e.store.setData(a);
1340
+ }
1341
+ /** Append a new data point to the end of a series (real-time tick). */
1342
+ appendData(t, i) {
1343
+ const e = c(this, M).find((o) => o.id === t);
1344
+ if (!(e != null && e.store)) return;
1345
+ const a = { ...i, time: de(i.time) };
1346
+ e.store.append(a);
1347
+ }
1348
+ /** Update the last data point of a series in place (e.g. live candle update). */
1349
+ updateData(t, i) {
1350
+ const e = c(this, M).find((o) => o.id === t);
1351
+ if (!(e != null && e.store)) return;
1352
+ const a = { ...i, time: de(i.time) };
1353
+ e.store.updateLast(a);
1354
+ }
1355
+ /** Update visual options (color, width, etc.) for an existing series. */
1356
+ updateSeriesOptions(t, i) {
1357
+ const e = c(this, M).find((a) => a.id === t);
1358
+ e && ((e.renderer instanceof $t || e.renderer instanceof G || e.renderer instanceof Z || e.renderer instanceof lt) && e.renderer.updateOptions(i), "label" in i && typeof i.label == "string" && (e.label = i.label), c(this, V).markDirty());
1359
+ }
1360
+ /**
1361
+ * Batch multiple updates: suppress recomputes until `fn` returns.
1362
+ * Equivalent to `beginUpdate()` / `endUpdate()` but safer (always calls endUpdate even on throw).
1363
+ */
1364
+ batch(t) {
1365
+ this.beginUpdate();
1366
+ try {
1367
+ t();
1368
+ } finally {
1369
+ this.endUpdate();
1370
+ }
1371
+ }
1372
+ /** @deprecated Use {@link batch} instead. */
1373
+ beginUpdate() {
1374
+ ne(this, at)._++;
1375
+ }
1376
+ /** @deprecated Use {@link batch} instead. */
1377
+ endUpdate() {
1378
+ --ne(this, at)._ <= 0 && (R(this, at, 0), c(this, kt) ? (R(this, kt, !1), R(this, ht, !1), this.onDataChanged()) : c(this, ht) && (R(this, ht, !1), this.updateYRange(!0), c(this, V).markDirty()));
1379
+ }
1380
+ /** Show or hide a series. Hidden series are not rendered and excluded from Y-range. */
1381
+ setSeriesVisible(t, i) {
1382
+ const e = c(this, M).find((a) => a.id === t);
1383
+ if (!(!e || e.visible === i)) {
1384
+ if (e.visible = i, c(this, at) > 0) {
1385
+ R(this, ht, !0);
1386
+ return;
1387
+ }
1388
+ this.updateYRange(!0), c(this, V).markDirty();
1389
+ }
1390
+ }
1391
+ isSeriesVisible(t) {
1392
+ var i;
1393
+ return ((i = c(this, M).find((e) => e.id === t)) == null ? void 0 : i.visible) ?? !0;
1394
+ }
1395
+ /** Show or hide a specific layer within a multi-layer series. */
1396
+ setLayerVisible(t, i, e) {
1397
+ const a = c(this, M).find((s) => s.id === t);
1398
+ if (!a) return;
1399
+ const o = a.renderer;
1400
+ if (o instanceof Z || o instanceof G) {
1401
+ const s = o.stores[i];
1402
+ if (s) {
1403
+ if (s.isVisible() === e) return;
1404
+ if (s.setVisible(e), c(this, at) > 0) {
1405
+ R(this, ht, !0);
1406
+ return;
1407
+ }
1408
+ this.updateYRange(!0), c(this, V).markDirty();
1409
+ }
1410
+ }
1411
+ }
1412
+ isLayerVisible(t, i) {
1413
+ var e;
1414
+ const a = c(this, M).find((s) => s.id === t);
1415
+ if (!a) return !0;
1416
+ const o = a.renderer;
1417
+ return o instanceof Z || o instanceof G ? ((e = o.stores[i]) == null ? void 0 : e.isVisible()) ?? !0 : !0;
1418
+ }
1419
+ /** Auto-fit the viewport to show all data across every series. */
1420
+ fitContent() {
1421
+ const { first: t, last: i } = this.getDataBounds();
1422
+ if (t === void 0 || i === void 0) return;
1423
+ const e = c(this, Y).size.media.width - this.yAxisWidth;
1424
+ c(this, B).fitToData(t, i, e, !0);
1425
+ }
1426
+ getVisibleRange() {
1427
+ return c(this, B).visibleRange;
1428
+ }
1429
+ getYRange() {
1430
+ return c(this, B).yRange;
1431
+ }
1432
+ getCrosshairPosition() {
1433
+ return c(this, ot);
1434
+ }
1435
+ /** Get the last visible value and whether the absolute last point is on screen. */
1436
+ getLastValue(t) {
1437
+ const i = c(this, M).find((l) => l.id === t);
1438
+ if (!(i != null && i.store)) return null;
1439
+ const e = i.store.last();
1440
+ if (!e) return null;
1441
+ const a = (l) => "close" in l ? l.close : l.value, { from: o, to: s } = c(this, B).visibleRange;
1442
+ if (e.time >= o && e.time <= s)
1443
+ return { value: a(e), isLive: !0 };
1444
+ const n = i.store.getVisibleData(o, s);
1445
+ return n.length === 0 ? null : { value: a(n[n.length - 1]), isLive: !1 };
1446
+ }
1447
+ /** Get the second-to-last value, useful for computing change. */
1448
+ getPreviousClose(t) {
1449
+ const i = c(this, M).find((o) => o.id === t);
1450
+ if (!(i != null && i.store)) return null;
1451
+ const e = i.store.getAll();
1452
+ if (e.length < 2) return null;
1453
+ const a = e[e.length - 2];
1454
+ return "close" in a ? a.close : a.value;
1455
+ }
1456
+ getLastData(t) {
1457
+ const i = c(this, M).find((e) => e.id === t);
1458
+ return i != null && i.store ? i.store.last() ?? null : null;
1459
+ }
1460
+ /** Find the data point closest to the given timestamp within one data interval. */
1461
+ getDataAtTime(t, i) {
1462
+ const e = c(this, M).find((n) => n.id === t);
1463
+ if (!(e != null && e.store)) return null;
1464
+ const a = e.store.getVisibleData(i - c(this, N), i + c(this, N));
1465
+ if (a.length === 0) return null;
1466
+ let o = a[0], s = Math.abs(a[0].time - i);
1467
+ for (let n = 1; n < a.length; n++) {
1468
+ const l = Math.abs(a[n].time - i);
1469
+ l < s && (s = l, o = a[n]);
1470
+ }
1471
+ return o;
1472
+ }
1473
+ /** Get all layers' data at a given time for multi-layer series (Bar/Line with stacking). */
1474
+ getLayerSnapshots(t, i) {
1475
+ const e = c(this, M).find((n) => n.id === t);
1476
+ if (!e || !e.visible) return null;
1477
+ const a = e.renderer;
1478
+ if (!(a instanceof Z) && !(a instanceof G) || a.stores.length <= 1) return null;
1479
+ const o = a.getColors(), s = [];
1480
+ for (let n = 0; n < a.stores.length; n++) {
1481
+ if (!a.stores[n].isVisible()) continue;
1482
+ const l = a.stores[n].getVisibleData(i - c(this, N), i + c(this, N));
1483
+ if (l.length === 0) continue;
1484
+ let h = l[0], d = Math.abs(l[0].time - i);
1485
+ for (let g = 1; g < l.length; g++) {
1486
+ const f = Math.abs(l[g].time - i);
1487
+ f < d && (d = f, h = l[g]);
1488
+ }
1489
+ s.push({
1490
+ value: h.value,
1491
+ color: (o == null ? void 0 : o[n % ((o == null ? void 0 : o.length) ?? 1)]) ?? c(this, W).seriesColors[n % c(this, W).seriesColors.length]
1492
+ });
1493
+ }
1494
+ return s.length > 0 ? s : null;
1495
+ }
1496
+ getSeriesIds() {
1497
+ return c(this, tt) || R(this, tt, c(this, M).map((t) => t.id)), c(this, tt).slice();
1498
+ }
1499
+ /** Get the primary display color for a series. */
1500
+ getSeriesColor(t) {
1501
+ const i = c(this, M).find((e) => e.id === t);
1502
+ return i ? "getColor" in i.renderer && typeof i.renderer.getColor == "function" ? i.renderer.getColor() : c(this, W).line.color : null;
1503
+ }
1504
+ getSeriesLabel(t) {
1505
+ var i;
1506
+ return (i = c(this, M).find((e) => e.id === t)) == null ? void 0 : i.label;
1507
+ }
1508
+ /** Get per-layer colors for a series. Returns null for non-bar/line series (e.g. candlestick, pie). */
1509
+ getSeriesLayers(t) {
1510
+ const i = c(this, M).find((o) => o.id === t);
1511
+ if (!i) return null;
1512
+ const e = i.renderer;
1513
+ if (!(e instanceof Z) && !(e instanceof G)) return null;
1514
+ const a = e.getColors();
1515
+ return e.stores.map((o, s) => ({
1516
+ color: a[s % a.length]
1517
+ }));
1518
+ }
1519
+ /** Get all pie slices with computed colors and percentages. Returns null for non-pie series. */
1520
+ getPieSlices(t) {
1521
+ const i = c(this, M).find((s) => s.id === t);
1522
+ if (!i || !(i.renderer instanceof lt)) return null;
1523
+ const e = i.renderer.getData();
1524
+ if (e.length === 0) return null;
1525
+ const a = e.reduce((s, n) => s + n.value, 0), o = c(this, W).seriesColors;
1526
+ return e.map((s, n) => ({
1527
+ label: s.label,
1528
+ value: s.value,
1529
+ percent: a > 0 ? s.value / a * 100 : 0,
1530
+ color: s.color ?? o[n % o.length]
1531
+ }));
1532
+ }
1533
+ /** Get the hovered pie slice info (label, value, percentage, color). Returns null if no hover. */
1534
+ getPieHoverInfo(t) {
1535
+ const i = c(this, M).find((l) => l.id === t);
1536
+ if (!i || !(i.renderer instanceof lt)) return null;
1537
+ const e = i.renderer;
1538
+ if (e.hoverIndex < 0) return null;
1539
+ const a = e.getData(), o = a[e.hoverIndex];
1540
+ if (!o) return null;
1541
+ const s = a.reduce((l, h) => l + h.value, 0), n = c(this, W).seriesColors;
1542
+ return {
1543
+ label: o.label,
1544
+ value: o.value,
1545
+ percent: s > 0 ? o.value / s * 100 : 0,
1546
+ color: o.color ?? n[e.hoverIndex % n.length]
1547
+ };
1548
+ }
1549
+ /** Apply a new theme and update candlestick series colors. Line series keep their individual colors. */
1550
+ setTheme(t) {
1551
+ const i = c(this, W).line.color;
1552
+ R(this, W, t);
1553
+ for (const e of c(this, M))
1554
+ e.renderer instanceof $t ? e.renderer.updateOptions({
1555
+ upColor: t.candlestick.upColor,
1556
+ downColor: t.candlestick.downColor,
1557
+ wickUpColor: t.candlestick.wickUpColor,
1558
+ wickDownColor: t.candlestick.wickDownColor
1559
+ }) : e.renderer instanceof Z ? e.renderer.updateOptions({
1560
+ colors: t.seriesColors.slice(0, e.renderer.stores.length)
1561
+ }) : e.renderer instanceof G && (e.renderer.stores.length === 1 ? e.renderer.getColor() === i && e.renderer.updateOptions({ colors: [t.line.color] }) : e.renderer.updateOptions({
1562
+ colors: t.seriesColors.slice(0, e.renderer.stores.length)
1563
+ }));
1564
+ c(this, V).markDirty();
1565
+ }
1566
+ getTheme() {
1567
+ return c(this, W);
1568
+ }
1569
+ /** Update axis configuration and re-render. */
1570
+ setAxis(t) {
1571
+ var i, e;
1572
+ const a = this.yAxisWidth, o = this.xAxisHeight;
1573
+ R(this, gt, t);
1574
+ const s = { min: (i = t.y) == null ? void 0 : i.min, max: (e = t.y) == null ? void 0 : e.max };
1575
+ R(this, $, s), R(this, mt, !1), this.updateYRange(!0), (this.yAxisWidth !== a || this.xAxisHeight !== o) && this.updateScales(!0), c(this, V).markDirty();
1576
+ }
1577
+ getMediaSize() {
1578
+ return c(this, Y).size.media;
1579
+ }
1580
+ /** Returns layout metrics for the chart area, Y axis, and time axis. */
1581
+ getLayout() {
1582
+ const t = c(this, Y).size.media, i = this.yAxisWidth, e = this.xAxisHeight;
1583
+ return {
1584
+ chartArea: { x: 0, y: 0, width: t.width - i, height: t.height - e },
1585
+ yAxisWidth: i,
1586
+ xAxisHeight: e
1587
+ };
1588
+ }
1589
+ getDataInterval() {
1590
+ return c(this, N);
1591
+ }
1592
+ /** Update viewport padding at runtime. Refits the visible range to current data bounds. */
1593
+ setPadding(t) {
1594
+ c(this, B).setPadding(t);
1595
+ const { first: i, last: e } = this.getDataBounds();
1596
+ if (i !== void 0 && e !== void 0) {
1597
+ const a = c(this, Y).size.media.width - this.yAxisWidth;
1598
+ c(this, B).fitToData(i, e, a, !1);
1599
+ }
1600
+ this.syncScales(), c(this, V).markDirty();
1601
+ }
1602
+ /** Show or hide the background grid. Takes effect on the next render frame. */
1603
+ setGrid(t) {
1604
+ R(this, St, t), c(this, V).markDirty();
1605
+ }
1606
+ /** Notify chart that a YLabel is present (affects right padding). */
1607
+ setYLabel(t) {
1608
+ R(this, Xt, t), this.updateViewportPadding();
1609
+ }
1610
+ updatePieHover(t) {
1611
+ const i = c(this, Y).size;
1612
+ for (const e of c(this, M))
1613
+ if (e.renderer instanceof lt) {
1614
+ const a = e.renderer.hoverIndex;
1615
+ if (t) {
1616
+ const o = t.mediaX * i.horizontalPixelRatio, s = t.mediaY * i.verticalPixelRatio;
1617
+ e.renderer.hoverIndex = e.renderer.hitTest(o, s, i.bitmap.width, i.bitmap.height);
1618
+ } else
1619
+ e.renderer.hoverIndex = -1;
1620
+ e.renderer.hoverIndex !== a && c(this, V).markDirty();
1621
+ }
1622
+ }
1623
+ updateViewportPadding() {
1624
+ }
1625
+ /** Tear down the chart: cancel animations, remove listeners, and detach the canvas. */
1626
+ destroy() {
1627
+ var t;
1628
+ c(this, B).destroy(), c(this, V).destroy(), c(this, ft).destroy(), (t = c(this, wt)) == null || t.destroy(), c(this, Y).destroy(), this.removeAllListeners();
1629
+ }
1630
+ /** Compute the earliest and latest timestamps across all series. */
1631
+ getDataBounds() {
1632
+ let t, i;
1633
+ for (const e of c(this, M)) {
1634
+ if (!e.visible || !e.store) continue;
1635
+ const a = e.store.first(), o = e.store.last();
1636
+ a && (t === void 0 || a.time < t) && (t = a.time), o && (i === void 0 || o.time > i) && (i = o.time);
1637
+ }
1638
+ return { first: t, last: i };
1639
+ }
1640
+ onDataChanged() {
1641
+ if (c(this, at) > 0) {
1642
+ R(this, kt, !0);
1643
+ return;
1644
+ }
1645
+ this.updateDataInterval();
1646
+ const { first: t, last: i } = this.getDataBounds();
1647
+ t !== void 0 && c(this, B).setDataStart(t), i !== void 0 && c(this, B).setDataEnd(i);
1648
+ let e = 0;
1649
+ for (const o of c(this, M))
1650
+ if (o.renderer instanceof G || o.renderer instanceof Z)
1651
+ for (const s of o.renderer.stores) e += s.length;
1652
+ else o.store && (e += o.store.length);
1653
+ const a = e - c(this, Wt) > 5;
1654
+ if (R(this, Wt, e), t !== void 0 && i !== void 0) {
1655
+ const { from: o, to: s } = c(this, B).visibleRange, n = o === 0 && s === 0, l = c(this, Y).size.media.width - this.yAxisWidth;
1656
+ n ? c(this, B).fitToData(t, i, l, !1) : a && c(this, B).autoScroll ? c(this, B).fitToData(t, i, l, !0) : !a && this.isLastPointVisible() && c(this, B).scrollToEnd(i, l);
1657
+ }
1658
+ this.updateYRange(a), this.syncScales(), c(this, V).markDirty(), this.emit("dataUpdate");
1659
+ }
1660
+ /** Check whether the last data point of any series falls within the visible time range. */
1661
+ isLastPointVisible() {
1662
+ const { from: t, to: i } = c(this, B).visibleRange;
1663
+ for (const e of c(this, M)) {
1664
+ if (!e.visible || !e.store) continue;
1665
+ const a = e.store.last();
1666
+ if (a && a.time >= t && a.time <= i) return !0;
1667
+ }
1668
+ return !1;
1669
+ }
1670
+ updateDataInterval() {
1671
+ for (const t of c(this, M)) {
1672
+ if (!t.store) continue;
1673
+ const i = t.store.getAll();
1674
+ if (i.length >= 2) {
1675
+ const e = i.slice(0, 20).map((a) => a.time);
1676
+ R(this, N, qe(e)), c(this, B).setDataInterval(c(this, N));
1677
+ break;
1678
+ }
1679
+ }
1680
+ }
1681
+ updateYRange(t = !1) {
1682
+ let i = 1 / 0, e = -1 / 0;
1683
+ const a = c(this, B).visibleRange;
1684
+ let o = c(this, $).min !== void 0 && c(this, $).min !== "auto" && typeof c(this, $).min != "number" || c(this, $).max !== void 0 && c(this, $).max !== "auto" && typeof c(this, $).max != "number" ? [] : null;
1685
+ for (const h of c(this, M)) {
1686
+ if (!h.visible) continue;
1687
+ if (h.renderer.getValueRange) {
1688
+ const g = h.renderer.getValueRange(a.from, a.to);
1689
+ if (g) {
1690
+ g.max > e && (e = g.max), g.min < i && (i = g.min), o == null || o.push(g.min, g.max);
1691
+ continue;
1692
+ }
1693
+ }
1694
+ if (!h.store) continue;
1695
+ const d = h.store.getVisibleData(a.from, a.to);
1696
+ for (const g of d)
1697
+ if ("high" in g) {
1698
+ const f = g;
1699
+ f.high > e && (e = f.high), f.low < i && (i = f.low), o == null || o.push(f.high, f.low);
1700
+ } else {
1701
+ const f = g;
1702
+ f.value > e && (e = f.value), f.value < i && (i = f.value), o == null || o.push(f.value);
1703
+ }
1704
+ }
1705
+ if (i === 1 / 0 || e === -1 / 0) {
1706
+ R(this, mt, !1);
1707
+ return;
1708
+ }
1709
+ if (i = this.resolveBound(c(this, $).min, i, e, o ?? [], "min"), e = this.resolveBound(c(this, $).max, e, i, o ?? [], "max"), !c(this, mt) || t)
1710
+ R(this, K, i), R(this, q, e), R(this, mt, !0);
1711
+ else {
1712
+ R(this, K, c(this, K) + (i - c(this, K)) * 0.2), R(this, q, c(this, q) + (e - c(this, q)) * 0.2), i < c(this, K) && R(this, K, i), e > c(this, q) && R(this, q, e);
1713
+ const h = Math.max(Math.abs(c(this, q) - c(this, K)) * 1e-4, 1e-3);
1714
+ (Math.abs(c(this, K) - i) > h || Math.abs(c(this, q) - e) > h) && c(this, V).markDirty();
1715
+ }
1716
+ const s = c(this, $).min !== void 0 && c(this, $).min !== "auto", n = c(this, $).max !== void 0 && c(this, $).max !== "auto", l = c(this, Y).size.media.height - this.xAxisHeight;
1717
+ c(this, B).setYRange(c(this, K), c(this, q), l, s, n);
1718
+ }
1719
+ /** Resolve an {@link AxisBound} to a concrete numeric value. */
1720
+ resolveBound(t, i, e, a, o) {
1721
+ if (t === void 0 || t === "auto") return i;
1722
+ if (typeof t == "number") return t;
1723
+ if (typeof t == "function") return t(a);
1724
+ const s = String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);
1725
+ if (s) {
1726
+ const n = s[1] === "-" ? -1 : 1, l = parseFloat(s[2]) / 100, h = Math.abs(e - i) || Math.abs(i) || 1;
1727
+ return i + n * l * h * (o === "max" ? 1 : -1);
1728
+ }
1729
+ return i;
1730
+ }
1731
+ /**
1732
+ * Lightweight scale sync: updates timeScale/yScale from current viewport state
1733
+ * without advancing the Y smoothing animation. Called from the viewport 'change'
1734
+ * handler so DOM axis components always read fresh coordinates on re-render.
1735
+ */
1736
+ syncScales() {
1737
+ const t = c(this, Y).size;
1738
+ if (t.media.width === 0 || t.media.height === 0) return;
1739
+ const i = t.media.width - this.yAxisWidth, e = t.media.height - this.xAxisHeight;
1740
+ this.timeScale.update(c(this, B).visibleRange, i, t.horizontalPixelRatio), this.yScale.update(c(this, B).yRange, e, t.verticalPixelRatio);
1741
+ }
1742
+ updateScales(t = !1) {
1743
+ const i = c(this, Y).size;
1744
+ if (i.media.width === 0 || i.media.height === 0) return;
1745
+ const e = i.media.width - this.yAxisWidth, a = i.media.height - this.xAxisHeight;
1746
+ this.timeScale.update(c(this, B).visibleRange, e, i.horizontalPixelRatio), this.yScale.update(c(this, B).yRange, a, i.verticalPixelRatio), this.updateYRange(t), this.yScale.update(c(this, B).yRange, a, i.verticalPixelRatio);
1747
+ }
1748
+ /** Expensive: background, grid, all series. Only on data/viewport/resize change. */
1749
+ renderMain() {
1750
+ const t = c(this, Y).size;
1751
+ if (!(t.media.width === 0 || t.media.height === 0)) {
1752
+ c(this, B).tick(performance.now()) && c(this, V).markDirty(), this.updateScales(), c(this, Y).useMainLayer((i) => {
1753
+ const { context: e, bitmapSize: a } = i, o = (t.media.width - this.yAxisWidth) * t.horizontalPixelRatio, s = (t.media.height - this.xAxisHeight) * t.verticalPixelRatio;
1754
+ e.clearRect(0, 0, a.width, a.height), e.save(), e.beginPath(), e.rect(0, 0, o, s), e.clip(), c(this, St) && Xe(i, this.timeScale, this.yScale, c(this, W), c(this, N));
1755
+ for (const n of c(this, M))
1756
+ n.visible && n.renderer.render({
1757
+ scope: i,
1758
+ timeScale: this.timeScale,
1759
+ yScale: this.yScale,
1760
+ theme: c(this, W),
1761
+ dataInterval: c(this, N)
1762
+ });
1763
+ e.restore();
1764
+ });
1765
+ for (const i of c(this, M))
1766
+ if (i.renderer instanceof lt && i.renderer.needsAnimation) {
1767
+ c(this, V).markDirty();
1768
+ break;
1769
+ }
1770
+ this.renderOverlay();
1771
+ }
1772
+ }
1773
+ /** Cheap overlay: crosshair, nearest-point dots, pulse animation. */
1774
+ renderOverlay() {
1775
+ const t = c(this, Y).size;
1776
+ if (t.media.width === 0 || t.media.height === 0) return;
1777
+ let i = !1;
1778
+ for (const e of c(this, M))
1779
+ if (e.visible && e.renderer instanceof G && e.renderer.hasPulse) {
1780
+ i = !0;
1781
+ break;
1782
+ }
1783
+ if (c(this, Y).useOverlayLayer((e) => {
1784
+ if (!c(this, ot) && !i) return;
1785
+ const a = (t.media.width - this.yAxisWidth) * t.horizontalPixelRatio, o = (t.media.height - this.xAxisHeight) * t.verticalPixelRatio;
1786
+ if (e.context.save(), e.context.beginPath(), e.context.rect(0, 0, a, o), e.context.clip(), c(this, ot)) {
1787
+ const s = c(this, ot).mediaX * t.horizontalPixelRatio, n = c(this, ot).mediaY * t.verticalPixelRatio;
1788
+ $e(e, s, n, c(this, W));
1789
+ for (const l of c(this, M))
1790
+ if (l.visible && l.renderer instanceof G) {
1791
+ const h = l.renderer, d = h.getColors(), g = h.getStacking(), f = 4 * t.horizontalPixelRatio, p = [], m = [];
1792
+ for (let u = 0; u < h.stores.length; u++) {
1793
+ const v = h.stores[u].findNearest(c(this, ot).time, c(this, N));
1794
+ v ? (p.push(v.value), m.push(v.time)) : (p.push(0), m.push(0));
1795
+ }
1796
+ const b = [];
1797
+ if (g === "off")
1798
+ for (const u of p) b.push(u);
1799
+ else {
1800
+ let u = 0;
1801
+ if (g === "percent")
1802
+ for (const y of p) u += y;
1803
+ let v = 0;
1804
+ for (const y of p)
1805
+ v += g === "percent" && u > 0 ? y / u * 100 : y, b.push(v);
1806
+ }
1807
+ for (let u = 0; u < h.stores.length; u++) {
1808
+ if (m[u] === 0 || !h.stores[u].isVisible()) continue;
1809
+ const v = d[u % d.length], y = this.timeScale.timeToBitmapX(m[u]), x = this.yScale.valueToBitmapY(b[u]);
1810
+ e.context.beginPath(), e.context.arc(y, x, f + 3 * t.horizontalPixelRatio, 0, Math.PI * 2);
1811
+ const C = v.startsWith("#") ? v + "40" : /^rgb\(/i.test(v) ? v.replace(/^rgb\((.*)\)$/i, "rgba($1, 0.25)") : v.replace(/[\d.]+\)\s*$/, "0.25)");
1812
+ e.context.fillStyle = C, e.context.fill(), e.context.beginPath(), e.context.arc(y, x, f, 0, Math.PI * 2), e.context.fillStyle = v, e.context.fill();
1813
+ }
1814
+ }
1815
+ }
1816
+ for (const s of c(this, M))
1817
+ s.visible && s.renderer instanceof G && s.renderer.hasPulse && s.renderer.drawPulseOverlay(
1818
+ e.context,
1819
+ this.timeScale,
1820
+ this.yScale,
1821
+ t.horizontalPixelRatio
1822
+ );
1823
+ e.context.restore();
1824
+ }), i) {
1825
+ const { from: e, to: a } = this.timeScale.getRange();
1826
+ let o = !1;
1827
+ for (const s of c(this, M))
1828
+ if (!(!s.visible || !(s.renderer instanceof G) || !s.renderer.hasPulse)) {
1829
+ for (const n of s.renderer.stores) {
1830
+ const l = n.last();
1831
+ if (l && l.time >= e && l.time <= a) {
1832
+ o = !0;
1833
+ break;
1834
+ }
1835
+ }
1836
+ if (o) break;
1837
+ }
1838
+ o && c(this, ft).markDirty();
1839
+ }
1840
+ }
1841
+ }
1842
+ Y = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), ft = /* @__PURE__ */ new WeakMap(), wt = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), St = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), ot = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakMap(), tt = /* @__PURE__ */ new WeakMap(), Xt = /* @__PURE__ */ new WeakMap(), gt = /* @__PURE__ */ new WeakMap(), at = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakMap(), pt = /* @__PURE__ */ new WeakSet(), /**
1843
+ * Return a series ID: use the provided hint if it's non-empty and not already taken,
1844
+ * otherwise generate a new auto ID. Auto-generated IDs never collide with each other
1845
+ * or with user-provided IDs because they use a monotonically increasing counter.
1846
+ */
1847
+ Mt = function(r) {
1848
+ if (r && !c(this, M).some((i) => i.id === r))
1849
+ return r;
1850
+ let t;
1851
+ do
1852
+ t = `series_${++pi}`;
1853
+ while (c(this, M).some((i) => i.id === t));
1854
+ return t;
1855
+ }, Wt = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), mt = /* @__PURE__ */ new WeakMap();
1856
+ const yo = {
1857
+ background: "#ffffff",
1858
+ chartGradient: ["#ffffff", "#f5f6f8"],
1859
+ typography: {
1860
+ fontFamily: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
1861
+ fontSize: 12,
1862
+ axisFontSize: 10,
1863
+ yFontSize: 11,
1864
+ tooltipFontSize: 12
1865
+ },
1866
+ grid: {
1867
+ color: "rgba(0, 0, 0, 0.06)",
1868
+ style: "solid"
1869
+ },
1870
+ candlestick: {
1871
+ upColor: "#089981",
1872
+ downColor: "#f23645",
1873
+ wickUpColor: "#089981",
1874
+ wickDownColor: "#f23645"
1875
+ },
1876
+ line: {
1877
+ color: "#2962FF",
1878
+ width: 1,
1879
+ areaTopColor: "rgba(41, 98, 255, 0.08)",
1880
+ areaBottomColor: "rgba(41, 98, 255, 0.01)"
1881
+ },
1882
+ seriesColors: [
1883
+ "#2962FF",
1884
+ "#FF6D00",
1885
+ "#089981",
1886
+ "#AB47BC",
1887
+ "#f23645",
1888
+ "#E6A700",
1889
+ "#43A047",
1890
+ "#D81B60",
1891
+ "#1E88E5",
1892
+ "#7E57C2"
1893
+ ],
1894
+ bands: { upper: "#1E88E5", lower: "#D81B60" },
1895
+ crosshair: {
1896
+ color: "rgba(0, 0, 0, 0.2)",
1897
+ labelBackground: "#4c525e",
1898
+ labelTextColor: "#ffffff"
1899
+ },
1900
+ axis: { textColor: "#787b86" },
1901
+ yLabel: {
1902
+ upBackground: "#089981",
1903
+ downBackground: "#f23645",
1904
+ neutralBackground: "#4c525e",
1905
+ textColor: "#ffffff"
1906
+ },
1907
+ tooltip: {
1908
+ background: "rgba(255, 255, 255, 0.95)",
1909
+ textColor: "#131722",
1910
+ borderColor: "rgba(0, 0, 0, 0.1)"
1911
+ }
1912
+ };
1913
+ function bi(r) {
1914
+ return parseInt(r.slice(1, 3), 16) * 0.299 + parseInt(r.slice(3, 5), 16) * 0.587 + parseInt(r.slice(5, 7), 16) * 0.114 < 128;
1915
+ }
1916
+ function I(r) {
1917
+ var t, i, e, a, o, s, n, l, h, d, g, f, p, m, b, u, v, y, x, C, T, k, D, z, _, P, X, H, Q;
1918
+ const { background: U, name: nt = "Custom", description: E, fontUrl: O = null } = r, A = bi(U), Te = A ? "#d1d4dc" : "#24292f", De = A ? "#787b86" : "#8b949e", oe = A ? "#26a69a" : "#2da44e", re = A ? "#ef5350" : "#cf222e", Be = A ? "#2962ff" : "#0969da", ze = A ? "rgba(42,46,57,0.6)" : "rgba(200,200,200,0.5)", Fe = A ? "rgba(150,150,150,0.5)" : "rgba(170,170,170,0.3)", ae = A ? Lt(U, 0.1) : me(U, 0.05), Pe = A ? yt(U, 0.92) : yt(U, 0.95), Le = A ? yt(Lt(U, 0.15), 0.6) : "rgba(200,200,200,0.5)", We = Yt, Ut = ((t = r.candlestick) == null ? void 0 : t.upColor) ?? oe, zt = ((i = r.candlestick) == null ? void 0 : i.downColor) ?? re, vt = ((e = r.line) == null ? void 0 : e.color) ?? Be, se = ((a = r.tooltip) == null ? void 0 : a.textColor) ?? Te, Ae = ((o = r.axis) == null ? void 0 : o.textColor) ?? De, Ie = ((s = r.typography) == null ? void 0 : s.fontFamily) ?? We, Ve = {
1919
+ background: U,
1920
+ chartGradient: r.chartGradient ?? (A ? [Lt(U, 0.04), me(U, 0.06)] : [Lt(U, 0.06), U]),
1921
+ typography: {
1922
+ fontFamily: Ie,
1923
+ fontSize: ((n = r.typography) == null ? void 0 : n.fontSize) ?? 12,
1924
+ axisFontSize: ((l = r.typography) == null ? void 0 : l.axisFontSize) ?? 10,
1925
+ yFontSize: ((h = r.typography) == null ? void 0 : h.yFontSize) ?? 11,
1926
+ tooltipFontSize: ((d = r.typography) == null ? void 0 : d.tooltipFontSize) ?? ((g = r.typography) == null ? void 0 : g.fontSize) ?? 12
1927
+ },
1928
+ grid: {
1929
+ color: ((f = r.grid) == null ? void 0 : f.color) ?? ze,
1930
+ style: ((p = r.grid) == null ? void 0 : p.style) ?? "dashed"
1931
+ },
1932
+ candlestick: {
1933
+ upColor: Ut,
1934
+ downColor: zt,
1935
+ wickUpColor: ((m = r.candlestick) == null ? void 0 : m.wickUpColor) ?? Ut,
1936
+ wickDownColor: ((b = r.candlestick) == null ? void 0 : b.wickDownColor) ?? zt
1937
+ },
1938
+ line: {
1939
+ color: vt,
1940
+ width: ((u = r.line) == null ? void 0 : u.width) ?? 1,
1941
+ areaTopColor: ((v = r.line) == null ? void 0 : v.areaTopColor) ?? yt(vt, 0.08),
1942
+ areaBottomColor: ((y = r.line) == null ? void 0 : y.areaBottomColor) ?? yt(vt, 0.01)
1943
+ },
1944
+ seriesColors: r.seriesColors ?? [vt, oe, re],
1945
+ bands: {
1946
+ upper: ((x = r.bands) == null ? void 0 : x.upper) ?? vt,
1947
+ lower: ((C = r.bands) == null ? void 0 : C.lower) ?? zt
1948
+ },
1949
+ crosshair: {
1950
+ color: ((T = r.crosshair) == null ? void 0 : T.color) ?? Fe,
1951
+ labelBackground: ((k = r.crosshair) == null ? void 0 : k.labelBackground) ?? ae,
1952
+ labelTextColor: ((D = r.crosshair) == null ? void 0 : D.labelTextColor) ?? se
1953
+ },
1954
+ axis: { textColor: Ae },
1955
+ yLabel: {
1956
+ upBackground: ((z = r.yLabel) == null ? void 0 : z.upBackground) ?? Ut,
1957
+ downBackground: ((_ = r.yLabel) == null ? void 0 : _.downBackground) ?? zt,
1958
+ neutralBackground: ((P = r.yLabel) == null ? void 0 : P.neutralBackground) ?? ae,
1959
+ textColor: ((X = r.yLabel) == null ? void 0 : X.textColor) ?? "#ffffff"
1960
+ },
1961
+ tooltip: {
1962
+ background: ((H = r.tooltip) == null ? void 0 : H.background) ?? Pe,
1963
+ textColor: se,
1964
+ borderColor: ((Q = r.tooltip) == null ? void 0 : Q.borderColor) ?? Le
1965
+ }
1966
+ };
1967
+ return { name: nt, description: E, fontUrl: O, dark: A, theme: Ve };
1968
+ }
1969
+ function yt(r, t) {
1970
+ const i = parseInt(r.slice(1, 3), 16), e = parseInt(r.slice(3, 5), 16), a = parseInt(r.slice(5, 7), 16);
1971
+ return `rgba(${i}, ${e}, ${a}, ${t})`;
1972
+ }
1973
+ function Lt(r, t) {
1974
+ if (!r.startsWith("#")) return r;
1975
+ const i = Math.min(255, Math.round(parseInt(r.slice(1, 3), 16) + 255 * t)), e = Math.min(255, Math.round(parseInt(r.slice(3, 5), 16) + 255 * t)), a = Math.min(255, Math.round(parseInt(r.slice(5, 7), 16) + 255 * t));
1976
+ return `#${i.toString(16).padStart(2, "0")}${e.toString(16).padStart(2, "0")}${a.toString(16).padStart(2, "0")}`;
1977
+ }
1978
+ function me(r, t) {
1979
+ if (!r.startsWith("#")) return r;
1980
+ const i = Math.max(0, Math.round(parseInt(r.slice(1, 3), 16) * (1 - t))), e = Math.max(0, Math.round(parseInt(r.slice(3, 5), 16) * (1 - t))), a = Math.max(0, Math.round(parseInt(r.slice(5, 7), 16) * (1 - t)));
1981
+ return `#${i.toString(16).padStart(2, "0")}${e.toString(16).padStart(2, "0")}${a.toString(16).padStart(2, "0")}`;
1982
+ }
1983
+ const It = "'JetBrains Mono', 'Fira Code', monospace", Vt = "https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap", Yt = "'Outfit', -apple-system, BlinkMacSystemFont, sans-serif", Kt = "https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap", we = "'Roboto Mono', monospace", Se = "https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap", vi = "'IBM Plex Mono', monospace", yi = "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap", qt = "'Fira Code', monospace", Qt = "https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap", ke = "'Source Code Pro', monospace", Me = "https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap", xi = "'Space Mono', monospace", Ci = "https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap", Zt = "'Plus Jakarta Sans', sans-serif", te = "https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap", wi = "'Caveat', 'Comic Sans MS', cursive", Si = "https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap", ki = I({
1984
+ name: "Andromeda",
1985
+ description: "Deep space purples and cosmic blues",
1986
+ background: "#23262e",
1987
+ grid: { color: "rgba(50,48,56,0.8)" },
1988
+ candlestick: { upColor: "#96e072", downColor: "#ee5d43" },
1989
+ line: { color: "#00e8c6" },
1990
+ seriesColors: [
1991
+ "#00e8c6",
1992
+ "#f39c12",
1993
+ "#96e072",
1994
+ "#c74ded",
1995
+ "#ee5d43",
1996
+ "#ffe66d",
1997
+ "#00e8c6",
1998
+ "#ee5d43",
1999
+ "#7cb7ff",
2000
+ "#c74ded"
2001
+ ],
2002
+ bands: { upper: "#7cb7ff", lower: "#c74ded" },
2003
+ crosshair: { color: "rgba(102,94,110,0.4)", labelBackground: "#2e3038" },
2004
+ axis: { textColor: "#665e6e" },
2005
+ tooltip: { background: "rgba(35,38,46,0.92)", textColor: "#d5ced9", borderColor: "rgba(50,48,56,0.6)" },
2006
+ typography: { fontFamily: we },
2007
+ fontUrl: Se
2008
+ }), Mi = I({
2009
+ name: "Ayu Mirage",
2010
+ description: "Warm dark with amber accents",
2011
+ background: "#1f2430",
2012
+ grid: { color: "rgba(42,48,60,0.8)" },
2013
+ candlestick: { upColor: "#bae67e", downColor: "#f27983" },
2014
+ line: { color: "#73d0ff" },
2015
+ seriesColors: [
2016
+ "#73d0ff",
2017
+ "#ffad66",
2018
+ "#bae67e",
2019
+ "#d4bfff",
2020
+ "#f27983",
2021
+ "#ffd580",
2022
+ "#95e6cb",
2023
+ "#f28779",
2024
+ "#5ccfe6",
2025
+ "#d4bfff"
2026
+ ],
2027
+ bands: { upper: "#5ccfe6", lower: "#f28779" },
2028
+ crosshair: { color: "rgba(92,103,115,0.4)", labelBackground: "#2a3040" },
2029
+ axis: { textColor: "#5c6773" },
2030
+ tooltip: { background: "rgba(31,36,48,0.92)", textColor: "#cbccc6", borderColor: "rgba(42,48,60,0.6)" },
2031
+ typography: { fontFamily: Yt },
2032
+ fontUrl: Kt
2033
+ }), Ri = I({
2034
+ name: "Catppuccin",
2035
+ description: "Pastel tones on a mocha base",
2036
+ background: "#1e1e2e",
2037
+ grid: { color: "rgba(49,50,68,0.8)" },
2038
+ candlestick: { upColor: "#a6e3a1", downColor: "#f38ba8" },
2039
+ line: { color: "#89b4fa" },
2040
+ seriesColors: [
2041
+ "#89b4fa",
2042
+ "#fab387",
2043
+ "#a6e3a1",
2044
+ "#cba6f7",
2045
+ "#f38ba8",
2046
+ "#f9e2af",
2047
+ "#94e2d5",
2048
+ "#eba0ac",
2049
+ "#74c7ec",
2050
+ "#cba6f7"
2051
+ ],
2052
+ bands: { upper: "#74c7ec", lower: "#f38ba8" },
2053
+ crosshair: { color: "rgba(108,112,134,0.4)", labelBackground: "#313244" },
2054
+ axis: { textColor: "#6c7086" },
2055
+ tooltip: { background: "rgba(30,30,46,0.92)", textColor: "#cdd6f4", borderColor: "rgba(49,50,68,0.6)" },
2056
+ typography: { fontFamily: Yt },
2057
+ fontUrl: Kt
2058
+ }), Ti = I({
2059
+ name: "Dracula",
2060
+ description: "Classic dark with vibrant highlights",
2061
+ background: "#282a36",
2062
+ grid: { color: "rgba(68,71,90,0.8)" },
2063
+ candlestick: { upColor: "#45c868", downColor: "#d04848" },
2064
+ line: { color: "#a080d8" },
2065
+ seriesColors: [
2066
+ "#a080d8",
2067
+ "#d49858",
2068
+ "#45c868",
2069
+ "#d068a0",
2070
+ "#d04848",
2071
+ "#c8d070",
2072
+ "#70c0d8",
2073
+ "#d04848",
2074
+ "#6272a4",
2075
+ "#d068a0"
2076
+ ],
2077
+ bands: { upper: "#70c0d8", lower: "#d068a0" },
2078
+ crosshair: { color: "rgba(98,114,164,0.4)", labelBackground: "#44475a" },
2079
+ axis: { textColor: "#6272a4" },
2080
+ tooltip: { background: "rgba(40,42,54,0.92)", textColor: "#f8f8f2", borderColor: "rgba(68,71,90,0.6)" },
2081
+ typography: { fontFamily: qt },
2082
+ fontUrl: Qt
2083
+ }), Di = I({
2084
+ name: "GitHub Light",
2085
+ description: "Clean and familiar, GitHub-inspired",
2086
+ background: "#fafbfc",
2087
+ chartGradient: ["#ffffff", "#fafbfc"],
2088
+ grid: { color: "rgba(208,215,222,0.4)" },
2089
+ candlestick: { upColor: "#2da44e", downColor: "#cf222e" },
2090
+ line: { color: "#0969da", areaTopColor: "rgba(9,105,218,0.05)", areaBottomColor: "rgba(9,105,218,0.005)" },
2091
+ seriesColors: [
2092
+ "#0969da",
2093
+ "#c4820e",
2094
+ "#2da44e",
2095
+ "#8250df",
2096
+ "#cf222e",
2097
+ "#c4820e",
2098
+ "#0550ae",
2099
+ "#cf222e",
2100
+ "#2da44e",
2101
+ "#8250df"
2102
+ ],
2103
+ bands: { upper: "#0550ae", lower: "#cf222e" },
2104
+ crosshair: { color: "rgba(208,215,222,0.3)", labelBackground: "#f0f3f6" },
2105
+ axis: { textColor: "#8b949e" },
2106
+ tooltip: { background: "rgba(250,251,252,0.95)", textColor: "#24292f", borderColor: "rgba(216,222,228,0.5)" },
2107
+ typography: { fontFamily: vi },
2108
+ fontUrl: yi
2109
+ }), Bi = I({
2110
+ name: "Gruvbox",
2111
+ description: "Retro warm with earthy tones",
2112
+ background: "#282828",
2113
+ grid: { color: "rgba(60,56,54,0.8)" },
2114
+ candlestick: { upColor: "#b8bb26", downColor: "#fb4934" },
2115
+ line: { color: "#83a598" },
2116
+ seriesColors: [
2117
+ "#83a598",
2118
+ "#fe8019",
2119
+ "#b8bb26",
2120
+ "#d3869b",
2121
+ "#fb4934",
2122
+ "#fabd2f",
2123
+ "#8ec07c",
2124
+ "#fb4934",
2125
+ "#458588",
2126
+ "#d3869b"
2127
+ ],
2128
+ bands: { upper: "#83a598", lower: "#d3869b" },
2129
+ crosshair: { color: "rgba(146,131,116,0.4)", labelBackground: "#3c3836" },
2130
+ axis: { textColor: "#928374" },
2131
+ tooltip: { background: "rgba(40,40,40,0.92)", textColor: "#ebdbb2", borderColor: "rgba(60,56,54,0.6)" },
2132
+ typography: { fontFamily: It },
2133
+ fontUrl: Vt
2134
+ }), zi = {
2135
+ name: "Handwritten",
2136
+ description: "Sketch-style with a personal touch",
2137
+ fontUrl: Si,
2138
+ dark: !1,
2139
+ theme: {
2140
+ background: "#fdf5e6",
2141
+ chartGradient: ["#fef6e3", "#fdf5e6"],
2142
+ typography: {
2143
+ fontFamily: wi,
2144
+ fontSize: 18,
2145
+ axisFontSize: 13,
2146
+ yFontSize: 15,
2147
+ tooltipFontSize: 14
2148
+ },
2149
+ grid: {
2150
+ color: "rgba(180,170,150,0.3)",
2151
+ style: "dashed"
2152
+ },
2153
+ candlestick: {
2154
+ upColor: "#7a9a5e",
2155
+ downColor: "#b07060",
2156
+ wickUpColor: "#7a9a5e",
2157
+ wickDownColor: "#b07060"
2158
+ },
2159
+ line: {
2160
+ color: "#6a8fa0",
2161
+ width: 1,
2162
+ areaTopColor: "rgba(106,143,160,0.08)",
2163
+ areaBottomColor: "rgba(106,143,160,0.01)"
2164
+ },
2165
+ seriesColors: [
2166
+ "#6a8fa0",
2167
+ "#c09050",
2168
+ "#7a9a5e",
2169
+ "#8a7098",
2170
+ "#b07060",
2171
+ "#a09030",
2172
+ "#508878",
2173
+ "#a06878",
2174
+ "#6888a0",
2175
+ "#8870a0"
2176
+ ],
2177
+ bands: {
2178
+ upper: "#6888a0",
2179
+ lower: "#a06878"
2180
+ },
2181
+ crosshair: {
2182
+ color: "rgba(160,152,128,0.3)",
2183
+ labelBackground: "#f5edd8",
2184
+ labelTextColor: "#5c5040"
2185
+ },
2186
+ axis: { textColor: "#a09880" },
2187
+ yLabel: {
2188
+ upBackground: "#7a9a5e",
2189
+ downBackground: "#b07060",
2190
+ neutralBackground: "#e8dcc8",
2191
+ textColor: "#fdf5e6"
2192
+ },
2193
+ tooltip: {
2194
+ background: "rgba(253,245,230,0.95)",
2195
+ textColor: "#5c5040",
2196
+ borderColor: "rgba(180,170,150,0.4)"
2197
+ }
2198
+ }
2199
+ }, Fi = "'Silkscreen', cursive", Pi = "https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap", Li = I({
2200
+ name: "Matrix",
2201
+ background: "#000000",
2202
+ candlestick: { upColor: "#00ff41", downColor: "#00802a" },
2203
+ line: { color: "#00ff41" },
2204
+ seriesColors: [
2205
+ "#00ff41",
2206
+ "#00cc33",
2207
+ "#00992a",
2208
+ "#33ff66",
2209
+ "#66ff88",
2210
+ "#00e639",
2211
+ "#00b830",
2212
+ "#4dff78",
2213
+ "#00ff41",
2214
+ "#00cc33"
2215
+ ],
2216
+ bands: { upper: "#33ff66", lower: "#00802a" },
2217
+ grid: { color: "rgba(0,255,65,0.06)" },
2218
+ axis: { textColor: "#00cc33" },
2219
+ crosshair: { color: "rgba(0,255,65,0.3)", labelBackground: "#0a1a0a" },
2220
+ tooltip: { background: "rgba(0,10,0,0.95)", textColor: "#00ff41", borderColor: "rgba(0,255,65,0.2)" },
2221
+ typography: { fontFamily: Fi },
2222
+ fontUrl: Pi,
2223
+ chartGradient: ["#010a01", "#000000"]
2224
+ }), Wi = I({
2225
+ name: "Lavender Mist",
2226
+ background: "#f5f0f4",
2227
+ candlestick: { upColor: "#6b8e5e", downColor: "#b85468" },
2228
+ line: { color: "#7c6bc4" },
2229
+ seriesColors: [
2230
+ "#7c6bc4",
2231
+ "#d4885a",
2232
+ "#6b8e5e",
2233
+ "#c46b8e",
2234
+ "#b85468",
2235
+ "#8e7a4e",
2236
+ "#4e8e8a",
2237
+ "#b85468",
2238
+ "#7c6bc4",
2239
+ "#c46b8e"
2240
+ ],
2241
+ bands: { upper: "#4e8e8a", lower: "#b85468" },
2242
+ grid: { color: "rgba(150,130,155,0.12)" },
2243
+ axis: { textColor: "#9a88a0" },
2244
+ crosshair: { color: "rgba(150,130,155,0.2)", labelBackground: "#ebe4e8" },
2245
+ tooltip: { background: "rgba(245,240,244,0.95)", textColor: "#3a3050", borderColor: "rgba(150,130,155,0.25)" },
2246
+ typography: { fontFamily: Zt },
2247
+ fontUrl: te,
2248
+ chartGradient: ["#f8f4f7", "#f5f0f4"]
2249
+ }), Ai = I({
2250
+ name: "Love",
2251
+ description: "Soft romantic pinks and roses",
2252
+ background: "#fef7f8",
2253
+ chartGradient: ["#fffafb", "#fef7f8"],
2254
+ grid: { color: "rgba(200,160,175,0.25)" },
2255
+ candlestick: { upColor: "#6a9a6e", downColor: "#c45070" },
2256
+ line: { color: "#a05080" },
2257
+ seriesColors: [
2258
+ "#a05080",
2259
+ "#d08850",
2260
+ "#6a9a6e",
2261
+ "#7868a8",
2262
+ "#c45070",
2263
+ "#c89040",
2264
+ "#508890",
2265
+ "#c45070",
2266
+ "#a05080",
2267
+ "#7868a8"
2268
+ ],
2269
+ bands: { upper: "#508890", lower: "#c45070" },
2270
+ crosshair: { color: "rgba(180,140,155,0.3)", labelBackground: "#f0dce2" },
2271
+ axis: { textColor: "#b08898" },
2272
+ tooltip: { background: "rgba(253,242,244,0.95)", textColor: "#4a3040", borderColor: "rgba(200,160,175,0.35)" },
2273
+ typography: { fontFamily: Yt },
2274
+ fontUrl: Kt
2275
+ }), Ii = I({
2276
+ name: "Material Palenight",
2277
+ description: "Material Design in moonlit hues",
2278
+ background: "#292d3e",
2279
+ grid: { color: "rgba(55,59,75,0.8)" },
2280
+ candlestick: { upColor: "#c3e88d", downColor: "#f07178" },
2281
+ line: { color: "#82aaff" },
2282
+ seriesColors: [
2283
+ "#82aaff",
2284
+ "#f78c6c",
2285
+ "#c3e88d",
2286
+ "#c792ea",
2287
+ "#f07178",
2288
+ "#ffcb6b",
2289
+ "#89ddff",
2290
+ "#ff5370",
2291
+ "#82aaff",
2292
+ "#c792ea"
2293
+ ],
2294
+ bands: { upper: "#89ddff", lower: "#f07178" },
2295
+ crosshair: { color: "rgba(103,110,149,0.4)", labelBackground: "#34324a" },
2296
+ axis: { textColor: "#676e95" },
2297
+ tooltip: { background: "rgba(41,45,62,0.92)", textColor: "#a6accd", borderColor: "rgba(55,59,75,0.6)" },
2298
+ typography: { fontFamily: we },
2299
+ fontUrl: Se
2300
+ }), Vi = "'Silkscreen', cursive", Yi = "https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap", _i = I({
2301
+ name: "Monochrome",
2302
+ description: "Pure black and white, pixel font",
2303
+ background: "#ffffff",
2304
+ chartGradient: ["#ffffff", "#fafafa"],
2305
+ grid: { color: "rgba(0,0,0,0.06)", style: "solid" },
2306
+ candlestick: { upColor: "#111111", downColor: "#bbbbbb" },
2307
+ line: { color: "#111111" },
2308
+ seriesColors: [
2309
+ "#111111",
2310
+ "#888888",
2311
+ "#bbbbbb",
2312
+ "#555555",
2313
+ "#999999",
2314
+ "#333333",
2315
+ "#aaaaaa",
2316
+ "#666666",
2317
+ "#cccccc",
2318
+ "#444444"
2319
+ ],
2320
+ bands: { upper: "#555555", lower: "#bbbbbb" },
2321
+ crosshair: { color: "rgba(0,0,0,0.08)", labelBackground: "#f0f0f0" },
2322
+ axis: { textColor: "#b0b0b0" },
2323
+ tooltip: { background: "rgba(255,255,255,0.97)", textColor: "#222222", borderColor: "rgba(0,0,0,0.08)" },
2324
+ typography: { fontFamily: Vi, tooltipFontSize: 9 },
2325
+ fontUrl: Yi
2326
+ }), Ui = I({
2327
+ name: "Mint Breeze",
2328
+ background: "#f6f5ee",
2329
+ candlestick: { upColor: "#2e9070", downColor: "#d04848" },
2330
+ line: { color: "#2a8a80" },
2331
+ seriesColors: [
2332
+ "#2a8a80",
2333
+ "#d0884a",
2334
+ "#2e9070",
2335
+ "#7a68b0",
2336
+ "#d04848",
2337
+ "#a09040",
2338
+ "#3a7a9a",
2339
+ "#d04848",
2340
+ "#2a8a80",
2341
+ "#7a68b0"
2342
+ ],
2343
+ bands: { upper: "#3a7a9a", lower: "#d04848" },
2344
+ grid: { color: "rgba(100,150,140,0.1)" },
2345
+ axis: { textColor: "#80a098" },
2346
+ crosshair: { color: "rgba(120,140,120,0.18)", labelBackground: "#ece8de" },
2347
+ tooltip: { background: "rgba(246,245,238,0.95)", textColor: "#2a3530", borderColor: "rgba(130,140,115,0.2)" },
2348
+ typography: { fontFamily: xi },
2349
+ fontUrl: Ci,
2350
+ chartGradient: ["#f8f7f0", "#f6f5ee"]
2351
+ }), Ei = I({
2352
+ name: "Monokai Pro",
2353
+ description: "Bold syntax colors on dark gray",
2354
+ background: "#2d2a2e",
2355
+ grid: { color: "rgba(64,60,62,0.8)" },
2356
+ candlestick: { upColor: "#8ab862", downColor: "#d05470" },
2357
+ line: { color: "#62b8c8" },
2358
+ seriesColors: [
2359
+ "#62b8c8",
2360
+ "#d08050",
2361
+ "#8ab862",
2362
+ "#9080c8",
2363
+ "#d05470",
2364
+ "#d0b850",
2365
+ "#62b8c8",
2366
+ "#d05470",
2367
+ "#8ab862",
2368
+ "#9080c8"
2369
+ ],
2370
+ bands: { upper: "#62b8c8", lower: "#d05470" },
2371
+ crosshair: { color: "rgba(114,112,114,0.4)", labelBackground: "#403e42" },
2372
+ axis: { textColor: "#727072" },
2373
+ tooltip: { background: "rgba(45,42,46,0.92)", textColor: "#fcfcfa", borderColor: "rgba(64,60,62,0.6)" },
2374
+ typography: { fontFamily: qt },
2375
+ fontUrl: Qt
2376
+ }), Oi = I({
2377
+ name: "Night Owl",
2378
+ description: "Crafted for late-night coding",
2379
+ background: "#011627",
2380
+ grid: { color: "rgba(31,52,72,0.8)" },
2381
+ candlestick: { upColor: "#7ec699", downColor: "#e06c75" },
2382
+ line: { color: "#82aaff" },
2383
+ seriesColors: [
2384
+ "#82aaff",
2385
+ "#d49a6a",
2386
+ "#7ec699",
2387
+ "#b48ead",
2388
+ "#e06c75",
2389
+ "#d4b568",
2390
+ "#5fb3a1",
2391
+ "#d47084",
2392
+ "#6bc5e0",
2393
+ "#b48ead"
2394
+ ],
2395
+ bands: { upper: "#6bc5e0", lower: "#d47084" },
2396
+ crosshair: { color: "rgba(99,119,119,0.4)", labelBackground: "#1d3b53" },
2397
+ axis: { textColor: "#495a5a" },
2398
+ tooltip: { background: "rgba(1,22,39,0.92)", textColor: "#d6deeb", borderColor: "rgba(31,52,72,0.6)" },
2399
+ typography: { fontFamily: It },
2400
+ fontUrl: Vt
2401
+ }), $i = I({
2402
+ name: "One Dark Pro",
2403
+ description: "Atom editor's iconic dark palette",
2404
+ background: "#282c34",
2405
+ grid: { color: "rgba(59,64,72,0.8)" },
2406
+ candlestick: { upColor: "#98c379", downColor: "#e06c75" },
2407
+ line: { color: "#61afef" },
2408
+ seriesColors: [
2409
+ "#61afef",
2410
+ "#e5c07b",
2411
+ "#98c379",
2412
+ "#c678dd",
2413
+ "#e06c75",
2414
+ "#56b6c2",
2415
+ "#d19a66",
2416
+ "#be5046",
2417
+ "#61afef",
2418
+ "#c678dd"
2419
+ ],
2420
+ bands: { upper: "#56b6c2", lower: "#c678dd" },
2421
+ crosshair: { color: "rgba(99,110,123,0.4)", labelBackground: "#3e4451" },
2422
+ axis: { textColor: "#5c6370" },
2423
+ tooltip: { background: "rgba(40,44,52,0.92)", textColor: "#abb2bf", borderColor: "rgba(59,64,72,0.6)" },
2424
+ typography: { fontFamily: It },
2425
+ fontUrl: Vt
2426
+ }), Xi = I({
2427
+ name: "Panda",
2428
+ description: "Playful neons on charcoal",
2429
+ background: "#292a2b",
2430
+ grid: { color: "rgba(58,58,60,0.8)" },
2431
+ candlestick: { upColor: "#19f9d8", downColor: "#ff75b5" },
2432
+ line: { color: "#6fc1ff" },
2433
+ seriesColors: [
2434
+ "#6fc1ff",
2435
+ "#ffb86c",
2436
+ "#19f9d8",
2437
+ "#b084eb",
2438
+ "#ff75b5",
2439
+ "#ffcc95",
2440
+ "#19f9d8",
2441
+ "#ff4b82",
2442
+ "#45a9f9",
2443
+ "#b084eb"
2444
+ ],
2445
+ bands: { upper: "#45a9f9", lower: "#ff75b5" },
2446
+ crosshair: { color: "rgba(117,117,117,0.4)", labelBackground: "#3a3a3c" },
2447
+ axis: { textColor: "#757575" },
2448
+ tooltip: { background: "rgba(41,42,43,0.92)", textColor: "#e6e6e6", borderColor: "rgba(58,58,60,0.6)" },
2449
+ typography: { fontFamily: qt },
2450
+ fontUrl: Qt
2451
+ }), Hi = I({
2452
+ name: "Peach Cream",
2453
+ background: "#fef6f0",
2454
+ candlestick: { upColor: "#5a9a68", downColor: "#d06848" },
2455
+ line: { color: "#d07040" },
2456
+ seriesColors: [
2457
+ "#d07040",
2458
+ "#5a9a68",
2459
+ "#8a6aaa",
2460
+ "#c0884a",
2461
+ "#d06848",
2462
+ "#4a8a9a",
2463
+ "#9a7a4a",
2464
+ "#d06848",
2465
+ "#d07040",
2466
+ "#8a6aaa"
2467
+ ],
2468
+ bands: { upper: "#4a8a9a", lower: "#d06848" },
2469
+ grid: { color: "rgba(180,140,120,0.12)" },
2470
+ axis: { textColor: "#b09080" },
2471
+ crosshair: { color: "rgba(180,140,120,0.2)", labelBackground: "#f0e4d8" },
2472
+ tooltip: { background: "rgba(254,246,240,0.95)", textColor: "#4a3028", borderColor: "rgba(180,140,120,0.25)" },
2473
+ typography: { fontFamily: Zt },
2474
+ fontUrl: te,
2475
+ chartGradient: ["#fff8f2", "#fef6f0"]
2476
+ }), Gi = I({
2477
+ name: "Quiet Light",
2478
+ description: "Subdued and easy on the eyes",
2479
+ background: "#f5f5f5",
2480
+ grid: { color: "rgba(200,200,200,0.5)" },
2481
+ candlestick: { upColor: "#448c27", downColor: "#aa3731" },
2482
+ line: { color: "#4b69c6" },
2483
+ seriesColors: [
2484
+ "#4b69c6",
2485
+ "#c47820",
2486
+ "#448c27",
2487
+ "#7a3e9d",
2488
+ "#aa3731",
2489
+ "#c47820",
2490
+ "#2d8fa1",
2491
+ "#aa3731",
2492
+ "#448c27",
2493
+ "#7a3e9d"
2494
+ ],
2495
+ bands: { upper: "#2d8fa1", lower: "#aa3731" },
2496
+ crosshair: { color: "rgba(170,170,170,0.3)", labelBackground: "#e8e8e8" },
2497
+ axis: { textColor: "#aaaaaa" },
2498
+ tooltip: { background: "rgba(245,245,245,0.95)", textColor: "#333333", borderColor: "rgba(200,200,200,0.5)" },
2499
+ typography: { fontFamily: Zt },
2500
+ fontUrl: te
2501
+ }), Ni = I({
2502
+ name: "Rosé Pine Dawn",
2503
+ description: "Dawn-inspired warm neutrals",
2504
+ background: "#faf4ed",
2505
+ grid: { color: "rgba(152,147,165,0.2)" },
2506
+ candlestick: { upColor: "#56949f", downColor: "#b4637a" },
2507
+ line: { color: "#907aa9" },
2508
+ seriesColors: [
2509
+ "#907aa9",
2510
+ "#ea9d34",
2511
+ "#56949f",
2512
+ "#d7827e",
2513
+ "#b4637a",
2514
+ "#ea9d34",
2515
+ "#286983",
2516
+ "#b4637a",
2517
+ "#907aa9",
2518
+ "#d7827e"
2519
+ ],
2520
+ bands: { upper: "#286983", lower: "#b4637a" },
2521
+ crosshair: { color: "rgba(152,147,165,0.3)", labelBackground: "#f2e9e1" },
2522
+ axis: { textColor: "#9893a5" },
2523
+ tooltip: { background: "rgba(250,244,237,0.95)", textColor: "#575279", borderColor: "rgba(152,147,165,0.3)" },
2524
+ typography: { fontFamily: ke },
2525
+ fontUrl: Me
2526
+ }), ji = I({
2527
+ name: "Sand Dune",
2528
+ background: "#f4f0e8",
2529
+ candlestick: { upColor: "#5a8a50", downColor: "#b85040" },
2530
+ line: { color: "#8a6a3a" },
2531
+ seriesColors: [
2532
+ "#8a6a3a",
2533
+ "#b87a40",
2534
+ "#5a8a50",
2535
+ "#7a5a70",
2536
+ "#b85040",
2537
+ "#a09030",
2538
+ "#4a7a7a",
2539
+ "#b85040",
2540
+ "#8a6a3a",
2541
+ "#7a5a70"
2542
+ ],
2543
+ bands: { upper: "#4a7a7a", lower: "#b85040" },
2544
+ grid: { color: "rgba(150,130,100,0.15)" },
2545
+ axis: { textColor: "#9a8a70" },
2546
+ crosshair: { color: "rgba(150,130,100,0.2)", labelBackground: "#e8e0d0" },
2547
+ tooltip: { background: "rgba(244,240,232,0.95)", textColor: "#3a3020", borderColor: "rgba(150,130,100,0.3)" },
2548
+ typography: { fontFamily: ke },
2549
+ fontUrl: Me,
2550
+ chartGradient: ["#f8f4ec", "#f4f0e8"]
2551
+ }), Ji = I({
2552
+ name: "Solarized Light",
2553
+ description: "Ethan Schoonover's precision palette",
2554
+ background: "#fdf6e3",
2555
+ chartGradient: ["#fef8e8", "#fdf6e3"],
2556
+ grid: { color: "rgba(238,232,213,0.8)" },
2557
+ candlestick: { upColor: "#859900", downColor: "#dc322f" },
2558
+ line: { color: "#268bd2" },
2559
+ seriesColors: [
2560
+ "#268bd2",
2561
+ "#cb4b16",
2562
+ "#859900",
2563
+ "#6c71c4",
2564
+ "#dc322f",
2565
+ "#b58900",
2566
+ "#2aa198",
2567
+ "#d33682",
2568
+ "#268bd2",
2569
+ "#6c71c4"
2570
+ ],
2571
+ bands: { upper: "#2aa198", lower: "#d33682" },
2572
+ crosshair: { color: "rgba(147,161,161,0.3)", labelBackground: "#eee8d5" },
2573
+ axis: { textColor: "#93a1a1" },
2574
+ tooltip: { background: "rgba(253,246,227,0.95)", textColor: "#586e75", borderColor: "rgba(238,232,213,0.6)" },
2575
+ typography: { fontFamily: It },
2576
+ fontUrl: Vt
2577
+ }), be = {
2578
+ Dracula: Ti,
2579
+ "One Dark Pro": $i,
2580
+ "Monokai Pro": Ei,
2581
+ "Night Owl": Oi,
2582
+ "Material Palenight": Ii,
2583
+ Gruvbox: Bi,
2584
+ Catppuccin: Ri,
2585
+ "Ayu Mirage": Mi,
2586
+ Panda: Xi,
2587
+ Andromeda: ki,
2588
+ Matrix: Li,
2589
+ Handwritten: zi,
2590
+ "GitHub Light": Di,
2591
+ "Solarized Light": Ji,
2592
+ "Rosé Pine Dawn": Ni,
2593
+ "Quiet Light": Gi,
2594
+ "Lavender Mist": Wi,
2595
+ "Mint Breeze": Ui,
2596
+ "Sand Dune": ji,
2597
+ "Peach Cream": Hi,
2598
+ Monochrome: _i,
2599
+ Love: Ai
2600
+ };
2601
+ function xo(r) {
2602
+ return (be[r] ?? be["One Dark Pro"]).theme;
2603
+ }
2604
+ const Ht = ye(null);
2605
+ function J() {
2606
+ const r = Gt(Ht);
2607
+ if (!r)
2608
+ throw new Error("useChartInstance must be used within <ChartContainer>");
2609
+ return r;
2610
+ }
2611
+ function Ki({ data: r, options: t, label: i, id: e, onSeriesId: a }) {
2612
+ var n;
2613
+ const o = J(), s = et(null);
2614
+ return it(() => {
2615
+ const l = o.addBarSeries({ ...t, label: i ?? (t == null ? void 0 : t.label), layers: r.length, id: e });
2616
+ return s.current = l, a == null || a(l), () => {
2617
+ o.removeSeries(l), s.current = null;
2618
+ };
2619
+ }, [o, r.length, e]), it(() => {
2620
+ const l = s.current;
2621
+ l && o.batch(() => {
2622
+ for (let h = 0; h < r.length; h++)
2623
+ o.setBarLayerData(l, h, r[h]);
2624
+ });
2625
+ }, [o, r]), j(() => {
2626
+ s.current && t && o.updateSeriesOptions(s.current, t);
2627
+ }, [o, (n = t == null ? void 0 : t.colors) == null ? void 0 : n.join(","), t == null ? void 0 : t.barWidthRatio, t == null ? void 0 : t.stacking]), null;
2628
+ }
2629
+ function Co({ data: r, options: t, id: i, onSeriesId: e }) {
2630
+ const a = J(), o = et(null), s = et(0);
2631
+ return it(() => {
2632
+ const n = a.addCandlestickSeries({ ...t, id: i });
2633
+ return o.current = n, e == null || e(n), () => {
2634
+ a.removeSeries(n), o.current = null, s.current = 0;
2635
+ };
2636
+ }, [a, i]), it(() => {
2637
+ const n = o.current;
2638
+ if (!n) return;
2639
+ if (r.length === 0) {
2640
+ a.setSeriesData(n, []), s.current = 0;
2641
+ return;
2642
+ }
2643
+ const l = s.current;
2644
+ if (l === 0 || r.length < l || r.length - l > 5)
2645
+ a.setSeriesData(n, r);
2646
+ else if (r.length === l)
2647
+ a.updateData(n, r[r.length - 1]);
2648
+ else
2649
+ for (let h = l; h < r.length; h++)
2650
+ a.appendData(n, r[h]);
2651
+ s.current = r.length;
2652
+ }, [a, r]), j(() => {
2653
+ o.current && t && a.updateSeriesOptions(o.current, t);
2654
+ }, [
2655
+ a,
2656
+ t == null ? void 0 : t.upColor,
2657
+ t == null ? void 0 : t.downColor,
2658
+ t == null ? void 0 : t.wickUpColor,
2659
+ t == null ? void 0 : t.wickDownColor,
2660
+ t == null ? void 0 : t.bodyWidthRatio,
2661
+ t == null ? void 0 : t.candleGradient
2662
+ ]), null;
2663
+ }
2664
+ const ee = ye(null), ve = ee.Provider;
2665
+ function qi() {
2666
+ const r = Gt(ee);
2667
+ if (!r)
2668
+ throw new Error("useTheme must be used within <ThemeProvider>");
2669
+ return r;
2670
+ }
2671
+ function Qi() {
2672
+ return Gt(ee);
2673
+ }
2674
+ function Zi({ items: r, position: t = "bottom", mode: i = "toggle" }) {
2675
+ const e = J(), a = qi(), [o, s] = Rt(/* @__PURE__ */ new Set()), [, n] = Rt(0);
2676
+ it(() => {
2677
+ const f = () => {
2678
+ n((m) => m + 1), s(/* @__PURE__ */ new Set());
2679
+ }, p = () => n((m) => m + 1);
2680
+ return e.on("seriesChange", f), e.on("dataUpdate", p), e.getSeriesIds().length > 0 && n((m) => m + 1), () => {
2681
+ e.off("seriesChange", f), e.off("dataUpdate", p);
2682
+ };
2683
+ }, [e]);
2684
+ const l = (r == null ? void 0 : r.map((f, p) => ({ ...f, seriesId: "", layerIndex: p, isLayer: !1 }))) ?? (() => {
2685
+ const f = [];
2686
+ for (const p of e.getSeriesIds()) {
2687
+ const m = e.getSeriesLayers(p);
2688
+ if (m) {
2689
+ const b = e.getSeriesLabel(p);
2690
+ for (let u = 0; u < m.length; u++)
2691
+ f.push({
2692
+ label: b ? `${b} ${u + 1}` : `Series ${u + 1}`,
2693
+ color: m[u].color,
2694
+ seriesId: p,
2695
+ layerIndex: u,
2696
+ isLayer: !0
2697
+ });
2698
+ } else {
2699
+ const b = e.getSeriesColor(p), u = e.getSeriesLabel(p);
2700
+ b && f.push({ label: u ?? "Series", color: b, seriesId: p, layerIndex: 0, isLayer: !1 });
2701
+ }
2702
+ }
2703
+ return f;
2704
+ })();
2705
+ if (l.length === 0) return null;
2706
+ const h = (f) => {
2707
+ s(f), e.beginUpdate();
2708
+ for (let p = 0; p < l.length; p++) {
2709
+ const m = l[p];
2710
+ m.seriesId && (m.isLayer ? e.setLayerVisible(m.seriesId, m.layerIndex, !f.has(p)) : e.setSeriesVisible(m.seriesId, !f.has(p)));
2711
+ }
2712
+ e.endUpdate();
2713
+ }, d = (f) => {
2714
+ if (i === "solo")
2715
+ if (l.every((m, b) => b === f || o.has(b)))
2716
+ h(/* @__PURE__ */ new Set());
2717
+ else {
2718
+ const m = new Set(l.map((b, u) => u));
2719
+ m.delete(f), h(m);
2720
+ }
2721
+ else {
2722
+ const p = new Set(o);
2723
+ p.has(f) ? p.delete(f) : p.add(f), h(p);
2724
+ }
2725
+ }, g = t === "right";
2726
+ return /* @__PURE__ */ S(
2727
+ "div",
2728
+ {
2729
+ "data-legend": t,
2730
+ style: {
2731
+ display: "flex",
2732
+ flexDirection: g ? "column" : "row",
2733
+ flexWrap: "wrap",
2734
+ gap: g ? 6 : 14,
2735
+ padding: g ? "8px 6px" : "6px 8px",
2736
+ alignItems: g ? "flex-start" : "center",
2737
+ justifyContent: g ? "flex-start" : "center",
2738
+ fontFamily: a.typography.fontFamily,
2739
+ fontSize: a.typography.axisFontSize,
2740
+ color: a.axis.textColor,
2741
+ pointerEvents: "auto",
2742
+ flexShrink: 0
2743
+ },
2744
+ children: l.map((f, p) => {
2745
+ const m = o.has(p), b = !!f.seriesId;
2746
+ return /* @__PURE__ */ F(
2747
+ "div",
2748
+ {
2749
+ onClick: b ? () => d(p) : void 0,
2750
+ style: {
2751
+ display: "flex",
2752
+ alignItems: "center",
2753
+ gap: 4,
2754
+ cursor: b ? "pointer" : "default",
2755
+ opacity: m ? 0.35 : 1,
2756
+ transition: "opacity 0.15s ease",
2757
+ userSelect: "none"
2758
+ },
2759
+ children: [
2760
+ /* @__PURE__ */ S(
2761
+ "span",
2762
+ {
2763
+ style: {
2764
+ width: 8,
2765
+ height: 8,
2766
+ borderRadius: 2,
2767
+ background: f.color,
2768
+ flexShrink: 0
2769
+ }
2770
+ }
2771
+ ),
2772
+ /* @__PURE__ */ S("span", { style: { whiteSpace: "nowrap" }, children: f.label })
2773
+ ]
2774
+ },
2775
+ p
2776
+ );
2777
+ })
2778
+ }
2779
+ );
2780
+ }
2781
+ function to({ children: r, theme: t, axis: i, padding: e, gradient: a = !0, interactive: o, grid: s, style: n, className: l }) {
2782
+ var _, P, X, H, Q, U, nt;
2783
+ const h = Qi(), d = t ?? h ?? void 0, g = et(null), f = et(null), [p, m] = Rt(0);
2784
+ it(() => {
2785
+ if (!g.current || f.current) return;
2786
+ const E = {};
2787
+ return i && (E.axis = i), d && (E.theme = d), e && (E.padding = e), o !== void 0 && (E.interactive = o), s !== void 0 && (E.grid = s), f.current = new mi(g.current, E), m((O) => O + 1), () => {
2788
+ const O = f.current;
2789
+ f.current = null, setTimeout(() => {
2790
+ f.current || O == null || O.destroy();
2791
+ }, 0);
2792
+ };
2793
+ }, []), j(() => {
2794
+ f.current && d && f.current.setTheme(d);
2795
+ }, [d]), j(() => {
2796
+ f.current && i && f.current.setAxis(i);
2797
+ }, [(_ = i == null ? void 0 : i.y) == null ? void 0 : _.width, (P = i == null ? void 0 : i.y) == null ? void 0 : P.min, (X = i == null ? void 0 : i.y) == null ? void 0 : X.max, (H = i == null ? void 0 : i.y) == null ? void 0 : H.visible, (Q = i == null ? void 0 : i.x) == null ? void 0 : Q.height, (U = i == null ? void 0 : i.x) == null ? void 0 : U.visible]), j(() => {
2798
+ f.current && e && f.current.setPadding(e);
2799
+ }, [
2800
+ e == null ? void 0 : e.top,
2801
+ e == null ? void 0 : e.bottom,
2802
+ typeof (e == null ? void 0 : e.right) == "object" ? e.right.intervals : e == null ? void 0 : e.right,
2803
+ typeof (e == null ? void 0 : e.left) == "object" ? e.left.intervals : e == null ? void 0 : e.left
2804
+ ]), j(() => {
2805
+ f.current && s !== void 0 && f.current.setGrid(s);
2806
+ }, [s]);
2807
+ const b = f.current, { legendEl: u, overlay: v } = (() => {
2808
+ let E = null;
2809
+ const O = [];
2810
+ return Ye.forEach(r, (A) => {
2811
+ _e(A) && A.type === Zi ? E = A : O.push(A);
2812
+ }), { legendEl: E, overlay: O };
2813
+ })(), x = (((nt = u == null ? void 0 : u.props) == null ? void 0 : nt.position) ?? "bottom") === "right", C = d ?? (b == null ? void 0 : b.getTheme()), [T, k] = (C == null ? void 0 : C.chartGradient) ?? ["transparent", "transparent"], D = (C == null ? void 0 : C.background) ?? "transparent", z = a ? `linear-gradient(to bottom, ${T} 0%, ${D} 70%, ${k} 100%)` : D;
2814
+ return /* @__PURE__ */ F(
2815
+ "div",
2816
+ {
2817
+ className: l,
2818
+ style: {
2819
+ display: "flex",
2820
+ flexDirection: x ? "row" : "column",
2821
+ width: "100%",
2822
+ height: "100%",
2823
+ overflow: "hidden",
2824
+ background: z,
2825
+ ...n
2826
+ },
2827
+ children: [
2828
+ /* @__PURE__ */ S(
2829
+ "div",
2830
+ {
2831
+ ref: g,
2832
+ style: {
2833
+ position: "relative",
2834
+ flex: 1,
2835
+ minWidth: 0,
2836
+ minHeight: 0,
2837
+ overflow: "hidden"
2838
+ },
2839
+ children: b && /* @__PURE__ */ S(Ht.Provider, { value: b, children: /* @__PURE__ */ S(ve, { value: d ?? b.getTheme(), children: /* @__PURE__ */ S(
2840
+ "div",
2841
+ {
2842
+ style: {
2843
+ position: "absolute",
2844
+ inset: 0,
2845
+ pointerEvents: "none",
2846
+ zIndex: 2
2847
+ },
2848
+ children: v
2849
+ }
2850
+ ) }) })
2851
+ }
2852
+ ),
2853
+ b && u && /* @__PURE__ */ S(Ht.Provider, { value: b, children: /* @__PURE__ */ S(ve, { value: d ?? b.getTheme(), children: u }) })
2854
+ ]
2855
+ }
2856
+ );
2857
+ }
2858
+ function eo({ data: r, options: t, label: i, id: e, onSeriesId: a }) {
2859
+ var n;
2860
+ const o = J(), s = et(null);
2861
+ return it(() => {
2862
+ const l = o.addLineSeries({ ...t, label: i ?? (t == null ? void 0 : t.label), layers: r.length, id: e });
2863
+ return s.current = l, a == null || a(l), () => {
2864
+ o.removeSeries(l), s.current = null;
2865
+ };
2866
+ }, [o, r.length, e]), it(() => {
2867
+ const l = s.current;
2868
+ l && o.batch(() => {
2869
+ for (let h = 0; h < r.length; h++)
2870
+ o.setLineLayerData(l, h, r[h]);
2871
+ });
2872
+ }, [o, r]), j(() => {
2873
+ s.current && t && o.updateSeriesOptions(s.current, t);
2874
+ }, [o, (n = t == null ? void 0 : t.colors) == null ? void 0 : n.join(","), t == null ? void 0 : t.lineWidth, t == null ? void 0 : t.areaFill, t == null ? void 0 : t.pulse, t == null ? void 0 : t.stacking]), null;
2875
+ }
2876
+ function wo({ data: r, options: t, id: i, onSeriesId: e }) {
2877
+ const a = J(), o = et(null);
2878
+ return it(() => {
2879
+ const s = a.addPieSeries({ ...t, id: i });
2880
+ return o.current = s, e == null || e(s), () => {
2881
+ a.removeSeries(s), o.current = null;
2882
+ };
2883
+ }, [a, i]), j(() => {
2884
+ o.current && t && a.updateSeriesOptions(o.current, t);
2885
+ }, [
2886
+ a,
2887
+ t == null ? void 0 : t.innerRadiusRatio,
2888
+ t == null ? void 0 : t.padAngle,
2889
+ t == null ? void 0 : t.strokeColor,
2890
+ t == null ? void 0 : t.strokeWidth,
2891
+ t == null ? void 0 : t.colors
2892
+ ]), it(() => {
2893
+ o.current && a.setPieData(o.current, r);
2894
+ }, [a, r]), null;
2895
+ }
2896
+ function _t(r, t, i) {
2897
+ const e = Array.isArray(t) ? t : [t];
2898
+ return {
2899
+ subscribe: (a) => {
2900
+ for (const o of e) r.on(o, a);
2901
+ return () => {
2902
+ for (const o of e) r.off(o, a);
2903
+ };
2904
+ },
2905
+ getSnapshot: i
2906
+ };
2907
+ }
2908
+ function io(r) {
2909
+ const t = dt(() => _t(r, ["viewportChange", "dataUpdate", "seriesChange"], () => r.getVisibleRange()), [r]);
2910
+ return Tt(t.subscribe, t.getSnapshot);
2911
+ }
2912
+ function oo(r) {
2913
+ const t = dt(() => _t(r, ["viewportChange", "dataUpdate", "seriesChange"], () => r.getYRange()), [r]);
2914
+ return Tt(t.subscribe, t.getSnapshot);
2915
+ }
2916
+ function ro(r, t) {
2917
+ const i = dt(() => {
2918
+ let e = r.getLastValue(t);
2919
+ return {
2920
+ subscribe: (o) => {
2921
+ const s = () => {
2922
+ const l = r.getLastValue(t);
2923
+ (e == null ? void 0 : e.value) === (l == null ? void 0 : l.value) && (e == null ? void 0 : e.isLive) === (l == null ? void 0 : l.isLive) || (e = l, o());
2924
+ }, n = () => {
2925
+ const l = r.getLastValue(t), h = l ? r.yScale.valueToY(l.value) : null, d = e ? r.yScale.valueToY(e.value) : null;
2926
+ h === d && (e == null ? void 0 : e.value) === (l == null ? void 0 : l.value) && (e == null ? void 0 : e.isLive) === (l == null ? void 0 : l.isLive) || (e = l, o());
2927
+ };
2928
+ return r.on("dataUpdate", s), r.on("viewportChange", n), () => {
2929
+ r.off("dataUpdate", s), r.off("viewportChange", n);
2930
+ };
2931
+ },
2932
+ getSnapshot: () => e
2933
+ };
2934
+ }, [r, t]);
2935
+ return Tt(i.subscribe, i.getSnapshot);
2936
+ }
2937
+ function ao(r, t) {
2938
+ const i = dt(
2939
+ () => _t(r, "dataUpdate", () => r.getPreviousClose(t)),
2940
+ [r, t]
2941
+ );
2942
+ return Tt(i.subscribe, i.getSnapshot);
2943
+ }
2944
+ function ie(r) {
2945
+ const t = dt(() => _t(r, "crosshairMove", () => r.getCrosshairPosition()), [r]);
2946
+ return Tt(t.subscribe, t.getSnapshot);
2947
+ }
2948
+ function So() {
2949
+ const r = J(), t = ie(r);
2950
+ if (!t) return null;
2951
+ const i = r.getTheme(), e = r.getDataInterval(), a = {
2952
+ background: i.crosshair.labelBackground,
2953
+ color: i.crosshair.labelTextColor,
2954
+ fontSize: i.typography.axisFontSize,
2955
+ fontFamily: i.typography.fontFamily,
2956
+ padding: "2px 6px",
2957
+ borderRadius: 2,
2958
+ whiteSpace: "nowrap",
2959
+ pointerEvents: "none"
2960
+ };
2961
+ return /* @__PURE__ */ F(Dt, { children: [
2962
+ /* @__PURE__ */ S(
2963
+ "div",
2964
+ {
2965
+ style: {
2966
+ position: "absolute",
2967
+ right: 0,
2968
+ top: t.mediaY,
2969
+ transform: "translateY(-50%)",
2970
+ ...a
2971
+ },
2972
+ children: r.yScale.formatY(t.y)
2973
+ }
2974
+ ),
2975
+ /* @__PURE__ */ S(
2976
+ "div",
2977
+ {
2978
+ style: {
2979
+ position: "absolute",
2980
+ bottom: 0,
2981
+ left: t.mediaX,
2982
+ transform: "translateX(-50%)",
2983
+ ...a
2984
+ },
2985
+ children: At(t.time, e)
2986
+ }
2987
+ )
2988
+ ] });
2989
+ }
2990
+ const so = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
2991
+ function no(r) {
2992
+ const t = [];
2993
+ for (const i of r)
2994
+ i >= "0" && i <= "9" ? t.push({ type: "digit", value: i }) : t.push({ type: "symbol", value: i });
2995
+ return t;
2996
+ }
2997
+ function lo({ value: r, format: t, locale: i = "en-US", spinDuration: e = 350, className: a, style: o }) {
2998
+ const n = dt(() => new Intl.NumberFormat(i, t), [i, t]).format(r), l = no(n);
2999
+ return /* @__PURE__ */ S(
3000
+ "span",
3001
+ {
3002
+ className: a,
3003
+ style: {
3004
+ display: "inline-flex",
3005
+ fontVariantNumeric: "tabular-nums",
3006
+ lineHeight: 1.2,
3007
+ ...o
3008
+ },
3009
+ children: l.map(
3010
+ (h, d) => h.type === "digit" ? /* @__PURE__ */ S(co, { digit: parseInt(h.value), duration: e }, `d${d}`) : /* @__PURE__ */ S("span", { style: { display: "inline-block" }, children: h.value }, `s${d}`)
3011
+ )
3012
+ }
3013
+ );
3014
+ }
3015
+ function co({ digit: r, duration: t }) {
3016
+ const i = et(!1);
3017
+ return j(() => {
3018
+ i.current = !0;
3019
+ }, []), /* @__PURE__ */ S(
3020
+ "span",
3021
+ {
3022
+ style: {
3023
+ display: "inline-block",
3024
+ height: "1.2em",
3025
+ overflow: "hidden",
3026
+ position: "relative"
3027
+ },
3028
+ children: /* @__PURE__ */ S(
3029
+ "span",
3030
+ {
3031
+ style: {
3032
+ display: "flex",
3033
+ flexDirection: "column",
3034
+ transform: `translateY(${-r * 1.2}em)`,
3035
+ transition: i.current ? `transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)` : "none"
3036
+ },
3037
+ children: so.map((e) => /* @__PURE__ */ S(
3038
+ "span",
3039
+ {
3040
+ style: {
3041
+ display: "flex",
3042
+ alignItems: "center",
3043
+ justifyContent: "center",
3044
+ height: "1.2em"
3045
+ },
3046
+ children: e
3047
+ },
3048
+ e
3049
+ ))
3050
+ }
3051
+ )
3052
+ }
3053
+ );
3054
+ }
3055
+ function ho(r) {
3056
+ return r >= 1e9 ? (r / 1e9).toFixed(1) + "B" : r >= 1e6 ? (r / 1e6).toFixed(1) + "M" : r >= 1e3 ? (r / 1e3).toFixed(1) + "K" : r.toLocaleString();
3057
+ }
3058
+ function ko({ seriesId: r, format: t = "value" }) {
3059
+ const i = J(), e = i.getTheme(), [, a] = Rt(0);
3060
+ j(() => {
3061
+ const s = () => a((n) => n + 1);
3062
+ return i.on("dataUpdate", s), () => {
3063
+ i.off("dataUpdate", s);
3064
+ };
3065
+ }, [i]);
3066
+ const o = i.getPieSlices(r);
3067
+ return !o || o.length === 0 ? null : /* @__PURE__ */ S(
3068
+ "div",
3069
+ {
3070
+ style: {
3071
+ display: "flex",
3072
+ flexDirection: "column",
3073
+ gap: 6,
3074
+ padding: "8px 12px",
3075
+ fontFamily: e.typography.fontFamily,
3076
+ fontSize: e.typography.fontSize,
3077
+ color: e.tooltip.textColor,
3078
+ pointerEvents: "auto"
3079
+ },
3080
+ children: o.map((s, n) => /* @__PURE__ */ F(
3081
+ "div",
3082
+ {
3083
+ style: {
3084
+ display: "flex",
3085
+ alignItems: "center",
3086
+ gap: 10
3087
+ },
3088
+ children: [
3089
+ /* @__PURE__ */ S(
3090
+ "span",
3091
+ {
3092
+ style: {
3093
+ width: 10,
3094
+ height: 10,
3095
+ borderRadius: "50%",
3096
+ background: s.color,
3097
+ flexShrink: 0
3098
+ }
3099
+ }
3100
+ ),
3101
+ /* @__PURE__ */ S("span", { style: { flex: 1, opacity: 0.8 }, children: s.label }),
3102
+ t === "value" && /* @__PURE__ */ S("span", { style: { fontWeight: 600, fontVariantNumeric: "tabular-nums" }, children: ho(s.value) }),
3103
+ /* @__PURE__ */ F(
3104
+ "span",
3105
+ {
3106
+ style: {
3107
+ opacity: t === "percent" ? 1 : 0.5,
3108
+ fontWeight: t === "percent" ? 600 : 400,
3109
+ fontSize: t === "percent" ? e.typography.fontSize : e.typography.axisFontSize,
3110
+ fontVariantNumeric: "tabular-nums",
3111
+ minWidth: 40,
3112
+ textAlign: "right"
3113
+ },
3114
+ children: [
3115
+ s.percent.toFixed(1),
3116
+ "%"
3117
+ ]
3118
+ }
3119
+ )
3120
+ ]
3121
+ },
3122
+ n
3123
+ ))
3124
+ }
3125
+ );
3126
+ }
3127
+ function Mo({ seriesId: r }) {
3128
+ const t = J(), i = ie(t), e = t.getPieHoverInfo(r);
3129
+ if (!e || !i) return null;
3130
+ const a = t.getTheme(), o = t.getMediaSize(), s = 160, n = 70, l = 16, h = 16, d = i.mediaX + l + s > o.width ? i.mediaX - l - s : i.mediaX + l, g = i.mediaY + h + n > o.height ? i.mediaY - h - n : i.mediaY + h;
3131
+ return /* @__PURE__ */ F(
3132
+ "div",
3133
+ {
3134
+ style: {
3135
+ position: "absolute",
3136
+ left: d,
3137
+ top: g,
3138
+ pointerEvents: "none",
3139
+ background: a.tooltip.background,
3140
+ backdropFilter: "blur(12px)",
3141
+ WebkitBackdropFilter: "blur(12px)",
3142
+ border: `1px solid ${a.tooltip.borderColor}`,
3143
+ borderRadius: 8,
3144
+ padding: "10px 14px",
3145
+ boxShadow: "0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",
3146
+ fontSize: a.typography.fontSize,
3147
+ fontFamily: a.typography.fontFamily,
3148
+ color: a.tooltip.textColor,
3149
+ zIndex: 10,
3150
+ display: "flex",
3151
+ flexDirection: "column",
3152
+ gap: 6
3153
+ },
3154
+ children: [
3155
+ /* @__PURE__ */ F("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
3156
+ /* @__PURE__ */ S(
3157
+ "span",
3158
+ {
3159
+ style: {
3160
+ width: 10,
3161
+ height: 10,
3162
+ borderRadius: "50%",
3163
+ background: e.color,
3164
+ flexShrink: 0
3165
+ }
3166
+ }
3167
+ ),
3168
+ /* @__PURE__ */ S("span", { style: { fontWeight: 600 }, children: e.label })
3169
+ ] }),
3170
+ /* @__PURE__ */ F("div", { style: { display: "flex", justifyContent: "space-between", gap: 16 }, children: [
3171
+ /* @__PURE__ */ S("span", { style: { opacity: 0.6 }, children: e.value.toLocaleString() }),
3172
+ /* @__PURE__ */ F("span", { style: { fontWeight: 600 }, children: [
3173
+ e.percent.toFixed(1),
3174
+ "%"
3175
+ ] })
3176
+ ] })
3177
+ ]
3178
+ }
3179
+ );
3180
+ }
3181
+ function uo(r, t) {
3182
+ if (r.startsWith("rgba") || !r.startsWith("#")) return r;
3183
+ const i = parseInt(r.slice(1, 3), 16), e = parseInt(r.slice(3, 5), 16), a = parseInt(r.slice(5, 7), 16);
3184
+ return `rgba(${i}, ${e}, ${a}, ${t})`;
3185
+ }
3186
+ function fo(r) {
3187
+ return Math.abs(r) >= 1e6 ? `${(r / 1e6).toFixed(1)}M` : Math.abs(r) >= 1e4 ? `${(r / 1e3).toFixed(1)}K` : Math.abs(r) >= 1e3 ? `${(r / 1e3).toFixed(2)}K` : Math.abs(r) < 1 ? r.toFixed(4) : Math.abs(r) < 10 ? r.toFixed(2) : r.toFixed(1);
3188
+ }
3189
+ function go(r) {
3190
+ if (r.length < 2) return { value: 0, pct: 0, positive: !0 };
3191
+ const t = r[0].value, e = r[r.length - 1].value - t, a = t !== 0 ? e / t * 100 : 0;
3192
+ return { value: e, pct: a, positive: e >= 0 };
3193
+ }
3194
+ function Ro({
3195
+ data: r,
3196
+ theme: t,
3197
+ variant: i = "line",
3198
+ valuePosition: e = "right",
3199
+ formatValue: a = fo,
3200
+ label: o,
3201
+ sublabel: s,
3202
+ color: n,
3203
+ negativeColor: l,
3204
+ areaFill: h = !0,
3205
+ width: d = 140,
3206
+ height: g = 48,
3207
+ lineWidth: f = 1.5,
3208
+ gradient: p = !0,
3209
+ style: m
3210
+ }) {
3211
+ const b = r.length > 0 ? r[r.length - 1].value : 0, u = dt(() => go(r), [r]), v = n ?? t.seriesColors[0], y = l ?? t.candlestick.downColor, x = u.positive ? t.candlestick.upColor : t.candlestick.downColor, C = e !== "none" && /* @__PURE__ */ F(
3212
+ "div",
3213
+ {
3214
+ style: {
3215
+ display: "flex",
3216
+ flexDirection: "column",
3217
+ justifyContent: "center",
3218
+ gap: 1,
3219
+ minWidth: 0,
3220
+ flexShrink: 0
3221
+ },
3222
+ children: [
3223
+ o && /* @__PURE__ */ S(
3224
+ "div",
3225
+ {
3226
+ style: {
3227
+ fontSize: t.typography.axisFontSize,
3228
+ color: t.axis.textColor,
3229
+ lineHeight: 1.2,
3230
+ whiteSpace: "nowrap",
3231
+ overflow: "hidden",
3232
+ textOverflow: "ellipsis"
3233
+ },
3234
+ children: o
3235
+ }
3236
+ ),
3237
+ /* @__PURE__ */ S(
3238
+ "div",
3239
+ {
3240
+ style: {
3241
+ fontSize: t.typography.fontSize + 3,
3242
+ fontWeight: 700,
3243
+ color: t.tooltip.textColor,
3244
+ lineHeight: 1.1,
3245
+ whiteSpace: "nowrap",
3246
+ fontVariantNumeric: "tabular-nums"
3247
+ },
3248
+ children: a(b)
3249
+ }
3250
+ ),
3251
+ s !== void 0 ? /* @__PURE__ */ S(
3252
+ "div",
3253
+ {
3254
+ style: {
3255
+ fontSize: t.typography.axisFontSize - 1,
3256
+ color: t.axis.textColor,
3257
+ lineHeight: 1.2,
3258
+ whiteSpace: "nowrap"
3259
+ },
3260
+ children: s
3261
+ }
3262
+ ) : /* @__PURE__ */ F(
3263
+ "div",
3264
+ {
3265
+ style: {
3266
+ fontSize: t.typography.axisFontSize - 1,
3267
+ fontWeight: 500,
3268
+ color: x,
3269
+ lineHeight: 1.2,
3270
+ whiteSpace: "nowrap",
3271
+ fontVariantNumeric: "tabular-nums"
3272
+ },
3273
+ children: [
3274
+ u.positive ? "+" : "",
3275
+ u.pct.toFixed(1),
3276
+ "%"
3277
+ ]
3278
+ }
3279
+ )
3280
+ ]
3281
+ }
3282
+ ), T = /* @__PURE__ */ S("div", { style: { width: d, height: g, flexShrink: 0, borderRadius: 4, overflow: "hidden" }, children: /* @__PURE__ */ S(
3283
+ to,
3284
+ {
3285
+ theme: t,
3286
+ axis: {
3287
+ y: { visible: !1, width: 0 },
3288
+ x: { visible: !1, height: 0 }
3289
+ },
3290
+ padding: { top: 5, right: 0, bottom: 0, left: 0 },
3291
+ gradient: p,
3292
+ interactive: !1,
3293
+ grid: !1,
3294
+ children: i === "line" ? /* @__PURE__ */ S(
3295
+ eo,
3296
+ {
3297
+ data: [r],
3298
+ options: {
3299
+ colors: [v],
3300
+ lineWidth: f,
3301
+ areaFill: h,
3302
+ pulse: !1,
3303
+ stacking: "off"
3304
+ }
3305
+ }
3306
+ ) : /* @__PURE__ */ S(
3307
+ Ki,
3308
+ {
3309
+ data: [r],
3310
+ options: {
3311
+ colors: [v, y],
3312
+ barWidthRatio: 0.7,
3313
+ stacking: "off"
3314
+ }
3315
+ }
3316
+ )
3317
+ }
3318
+ ) });
3319
+ return /* @__PURE__ */ F(
3320
+ "div",
3321
+ {
3322
+ style: {
3323
+ display: "inline-flex",
3324
+ alignItems: "center",
3325
+ gap: 12,
3326
+ padding: "8px 12px",
3327
+ borderRadius: 8,
3328
+ background: uo(t.tooltip.background, 0.7),
3329
+ border: `1px solid ${t.tooltip.borderColor}`,
3330
+ fontFamily: t.typography.fontFamily,
3331
+ ...m
3332
+ },
3333
+ children: [
3334
+ e === "left" && C,
3335
+ T,
3336
+ e === "right" && C
3337
+ ]
3338
+ }
3339
+ );
3340
+ }
3341
+ function To() {
3342
+ const r = J();
3343
+ io(r);
3344
+ const t = r.getTheme(), i = r.getDataInterval(), { ticks: e, tickInterval: a } = r.timeScale.niceTickValues(i), o = new Set(e), n = et(/* @__PURE__ */ new Map()).current, l = performance.now();
3345
+ for (const d of e)
3346
+ n.has(d) ? n.get(d).opacity = 1 : n.set(d, { opacity: 1, addedAt: l });
3347
+ for (const [d, g] of n)
3348
+ o.has(d) || g.opacity !== 0 && (g.opacity = 0, g.fadedAt = l);
3349
+ for (const [d, g] of n)
3350
+ g.opacity === 0 && g.fadedAt !== void 0 && l - g.fadedAt > 600 && n.delete(d);
3351
+ const h = Array.from(n.entries());
3352
+ return /* @__PURE__ */ S(
3353
+ "div",
3354
+ {
3355
+ style: {
3356
+ position: "absolute",
3357
+ left: 0,
3358
+ bottom: 0,
3359
+ right: r.yAxisWidth,
3360
+ height: r.xAxisHeight,
3361
+ pointerEvents: "none",
3362
+ display: "flex",
3363
+ alignItems: "center"
3364
+ },
3365
+ children: h.map(([d, g]) => {
3366
+ const f = r.timeScale.timeToX(d);
3367
+ return /* @__PURE__ */ S(
3368
+ "span",
3369
+ {
3370
+ style: {
3371
+ position: "absolute",
3372
+ left: f,
3373
+ transform: "translateX(-50%)",
3374
+ color: t.axis.textColor,
3375
+ fontSize: t.typography.axisFontSize,
3376
+ fontFamily: t.typography.fontFamily,
3377
+ userSelect: "none",
3378
+ whiteSpace: "nowrap",
3379
+ opacity: g.opacity,
3380
+ transition: "opacity 0.3s ease",
3381
+ willChange: "opacity"
3382
+ },
3383
+ children: At(d, a)
3384
+ },
3385
+ d
3386
+ );
3387
+ })
3388
+ }
3389
+ );
3390
+ }
3391
+ function po(r, t) {
3392
+ return t === "none" || r.length <= 1 ? r : [...r].sort((i, e) => {
3393
+ const a = "value" in i.data ? i.data.value : i.data.close, o = "value" in e.data ? e.data.value : e.data.close;
3394
+ return t === "asc" ? a - o : o - a;
3395
+ });
3396
+ }
3397
+ function Do({ seriesId: r, sort: t = "none", showLegend: i, legend: e }) {
3398
+ const a = i ?? e ?? !0, o = J(), s = ie(o), n = r ? [r] : o.getSeriesIds(), [, l] = Rt(0);
3399
+ j(() => {
3400
+ const u = () => l((v) => v + 1);
3401
+ return o.on("dataUpdate", u), () => o.off("dataUpdate", u);
3402
+ }, [o]);
3403
+ const h = [];
3404
+ if (s)
3405
+ for (const u of n) {
3406
+ const v = o.getLayerSnapshots(u, s.time);
3407
+ if (v)
3408
+ for (let y = 0; y < v.length; y++)
3409
+ h.push({
3410
+ id: `${u}_layer${y}`,
3411
+ label: o.getSeriesLabel(u),
3412
+ data: { time: s.time, value: v[y].value },
3413
+ color: v[y].color
3414
+ });
3415
+ else {
3416
+ const y = o.getDataAtTime(u, s.time);
3417
+ y && h.push({
3418
+ id: u,
3419
+ label: o.getSeriesLabel(u),
3420
+ data: y,
3421
+ color: o.getSeriesColor(u) ?? "#888"
3422
+ });
3423
+ }
3424
+ }
3425
+ let d;
3426
+ if (h.length > 0)
3427
+ d = h;
3428
+ else {
3429
+ const u = [];
3430
+ for (const v of n) {
3431
+ const y = o.getLastData(v);
3432
+ if (!y) continue;
3433
+ const x = o.getLayerSnapshots(v, y.time);
3434
+ if (x)
3435
+ for (let C = 0; C < x.length; C++)
3436
+ u.push({
3437
+ id: `${v}_layer${C}`,
3438
+ label: o.getSeriesLabel(v),
3439
+ data: { time: y.time, value: x[C].value },
3440
+ color: x[C].color
3441
+ });
3442
+ else
3443
+ u.push({ id: v, label: o.getSeriesLabel(v), data: y, color: o.getSeriesColor(v) ?? "#888" });
3444
+ }
3445
+ d = u;
3446
+ }
3447
+ const g = po(d, t), f = o.getTheme();
3448
+ if (g.length === 0) return null;
3449
+ const p = o.getDataInterval(), m = o.getMediaSize(), b = g[0].data.time;
3450
+ return /* @__PURE__ */ F(Dt, { children: [
3451
+ a && /* @__PURE__ */ F(
3452
+ "div",
3453
+ {
3454
+ style: {
3455
+ position: "absolute",
3456
+ top: 24,
3457
+ left: 8,
3458
+ pointerEvents: "none",
3459
+ display: "flex",
3460
+ alignItems: "center",
3461
+ gap: 4,
3462
+ flexWrap: "wrap",
3463
+ maxWidth: "70%",
3464
+ fontSize: f.typography.fontSize,
3465
+ fontFamily: f.typography.fontFamily,
3466
+ fontVariantNumeric: "tabular-nums",
3467
+ opacity: s ? 1 : 0.6,
3468
+ transition: "opacity 0.2s ease"
3469
+ },
3470
+ children: [
3471
+ /* @__PURE__ */ S("span", { style: { color: f.axis.textColor, marginRight: 2 }, children: At(b, p) }),
3472
+ g.map((u) => {
3473
+ if ("open" in u.data) {
3474
+ const x = u.data, T = x.close >= x.open ? f.candlestick.upColor : f.candlestick.downColor;
3475
+ return /* @__PURE__ */ F("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 }, children: [
3476
+ /* @__PURE__ */ S(xt, { label: "O", value: x.open, color: T, dim: f.axis.textColor }),
3477
+ /* @__PURE__ */ S(xt, { label: "H", value: x.high, color: T, dim: f.axis.textColor }),
3478
+ /* @__PURE__ */ S(xt, { label: "L", value: x.low, color: T, dim: f.axis.textColor }),
3479
+ /* @__PURE__ */ S(xt, { label: "C", value: x.close, color: T, dim: f.axis.textColor }),
3480
+ x.volume != null && /* @__PURE__ */ S(
3481
+ xt,
3482
+ {
3483
+ label: "V",
3484
+ value: x.volume,
3485
+ color: f.axis.textColor,
3486
+ dim: f.axis.textColor,
3487
+ volume: !0
3488
+ }
3489
+ )
3490
+ ] }, u.id);
3491
+ }
3492
+ const y = u.data;
3493
+ return /* @__PURE__ */ F("span", { style: { display: "inline-flex", alignItems: "center", gap: 3 }, children: [
3494
+ /* @__PURE__ */ S(
3495
+ "span",
3496
+ {
3497
+ style: {
3498
+ width: 6,
3499
+ height: 6,
3500
+ borderRadius: "50%",
3501
+ background: u.color,
3502
+ flexShrink: 0
3503
+ }
3504
+ }
3505
+ ),
3506
+ /* @__PURE__ */ S("span", { style: { color: u.color, fontWeight: 500 }, children: y.value.toFixed(2) })
3507
+ ] }, u.id);
3508
+ })
3509
+ ]
3510
+ }
3511
+ ),
3512
+ s && h.length > 0 && /* @__PURE__ */ S(
3513
+ mo,
3514
+ {
3515
+ snapshots: g,
3516
+ x: s.mediaX,
3517
+ y: s.mediaY,
3518
+ chartWidth: m.width - o.yAxisWidth,
3519
+ chartHeight: m.height - o.xAxisHeight,
3520
+ theme: f,
3521
+ dataInterval: p
3522
+ }
3523
+ )
3524
+ ] });
3525
+ }
3526
+ function xt({
3527
+ label: r,
3528
+ value: t,
3529
+ color: i,
3530
+ dim: e,
3531
+ volume: a
3532
+ }) {
3533
+ return /* @__PURE__ */ F(Dt, { children: [
3534
+ /* @__PURE__ */ S("span", { style: { color: e, opacity: 0.5, marginLeft: 5 }, children: r }),
3535
+ /* @__PURE__ */ S("span", { style: { color: i, fontWeight: 500, marginLeft: 2 }, children: a ? Re(t) : t.toFixed(2) })
3536
+ ] });
3537
+ }
3538
+ function mo({
3539
+ snapshots: r,
3540
+ x: t,
3541
+ y: i,
3542
+ chartWidth: e,
3543
+ chartHeight: a,
3544
+ theme: o,
3545
+ dataInterval: s
3546
+ }) {
3547
+ const n = r.some((x) => "open" in x.data), l = r.filter((x) => !("open" in x.data)).length, h = 160, d = n ? 140 : 40 + l * 22, g = 16, f = 16, p = t + g + h > e ? t - g - h : t + g, m = i + f + d > a ? i - f - d : i + f, b = o.tooltip.background, u = o.tooltip.borderColor, v = "0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)", y = r[0].data.time;
3548
+ return /* @__PURE__ */ F(
3549
+ "div",
3550
+ {
3551
+ style: {
3552
+ position: "absolute",
3553
+ left: p,
3554
+ top: m,
3555
+ pointerEvents: "none",
3556
+ background: b,
3557
+ backdropFilter: "blur(12px)",
3558
+ WebkitBackdropFilter: "blur(12px)",
3559
+ border: `1px solid ${u}`,
3560
+ borderRadius: 8,
3561
+ padding: "10px 14px",
3562
+ boxShadow: v,
3563
+ fontSize: o.typography.tooltipFontSize,
3564
+ fontFamily: o.typography.fontFamily,
3565
+ fontVariantNumeric: "tabular-nums",
3566
+ color: o.tooltip.textColor,
3567
+ minWidth: 140,
3568
+ zIndex: 10,
3569
+ transition: "opacity 0.15s ease"
3570
+ },
3571
+ children: [
3572
+ /* @__PURE__ */ F(
3573
+ "div",
3574
+ {
3575
+ style: {
3576
+ fontSize: o.typography.axisFontSize,
3577
+ color: o.axis.textColor,
3578
+ marginBottom: 8,
3579
+ paddingBottom: 6,
3580
+ borderBottom: `1px solid ${u}`,
3581
+ letterSpacing: "0.02em"
3582
+ },
3583
+ children: [
3584
+ Qe(y),
3585
+ " ",
3586
+ At(y, s)
3587
+ ]
3588
+ }
3589
+ ),
3590
+ r.map((x) => {
3591
+ if ("open" in x.data) {
3592
+ const k = x.data, D = k.close >= k.open, z = o.candlestick.upColor, _ = o.candlestick.downColor, P = D ? z : _;
3593
+ return /* @__PURE__ */ F("div", { style: { display: "grid", gridTemplateColumns: "auto 1fr", gap: "4px 12px" }, children: [
3594
+ /* @__PURE__ */ S(Ct, { label: "Open", value: k.open, color: P }),
3595
+ /* @__PURE__ */ S(Ct, { label: "High", value: k.high, color: P }),
3596
+ /* @__PURE__ */ S(Ct, { label: "Low", value: k.low, color: P }),
3597
+ /* @__PURE__ */ S(Ct, { label: "Close", value: k.close, color: P }),
3598
+ k.volume != null && /* @__PURE__ */ S(Ct, { label: "Volume", value: k.volume, color: o.tooltip.textColor, volume: !0 })
3599
+ ] }, x.id);
3600
+ }
3601
+ const T = x.data;
3602
+ return /* @__PURE__ */ F("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "2px 0" }, children: [
3603
+ /* @__PURE__ */ S(
3604
+ "span",
3605
+ {
3606
+ style: {
3607
+ width: 8,
3608
+ height: 8,
3609
+ borderRadius: "50%",
3610
+ background: x.color,
3611
+ flexShrink: 0
3612
+ }
3613
+ }
3614
+ ),
3615
+ /* @__PURE__ */ S("span", { style: { opacity: 0.6, flex: 1 }, children: x.label ?? "Value" }),
3616
+ /* @__PURE__ */ S("span", { style: { fontWeight: 600, color: x.color }, children: T.value.toFixed(2) })
3617
+ ] }, x.id);
3618
+ })
3619
+ ]
3620
+ }
3621
+ );
3622
+ }
3623
+ function Ct({
3624
+ label: r,
3625
+ value: t,
3626
+ color: i,
3627
+ volume: e
3628
+ }) {
3629
+ return /* @__PURE__ */ F(Dt, { children: [
3630
+ /* @__PURE__ */ S("span", { style: { opacity: 0.5 }, children: r }),
3631
+ /* @__PURE__ */ S("span", { style: { fontWeight: 600, color: i, textAlign: "right" }, children: e ? Re(t) : t.toFixed(2) })
3632
+ ] });
3633
+ }
3634
+ function Re(r) {
3635
+ return r >= 1e9 ? (r / 1e9).toFixed(2) + "B" : r >= 1e6 ? (r / 1e6).toFixed(2) + "M" : r >= 1e3 ? (r / 1e3).toFixed(1) + "K" : r.toFixed(0);
3636
+ }
3637
+ function Bo() {
3638
+ const r = J();
3639
+ oo(r);
3640
+ const t = r.getTheme(), i = r.yScale.niceTickValues(), e = new Set(i), o = et(/* @__PURE__ */ new Map()).current, s = performance.now();
3641
+ for (const l of i)
3642
+ o.has(l) ? o.get(l).opacity = 1 : o.set(l, { opacity: 1, addedAt: s });
3643
+ for (const [l, h] of o)
3644
+ e.has(l) || h.opacity !== 0 && (h.opacity = 0, h.fadedAt = s);
3645
+ for (const [l, h] of o)
3646
+ h.opacity === 0 && h.fadedAt !== void 0 && s - h.fadedAt > 600 && o.delete(l);
3647
+ const n = Array.from(o.entries());
3648
+ return /* @__PURE__ */ S(
3649
+ "div",
3650
+ {
3651
+ style: {
3652
+ position: "absolute",
3653
+ right: 0,
3654
+ top: 0,
3655
+ bottom: r.xAxisHeight,
3656
+ width: r.yAxisWidth,
3657
+ pointerEvents: "none"
3658
+ },
3659
+ children: n.map(([l, h]) => {
3660
+ const d = r.yScale.valueToY(l);
3661
+ return /* @__PURE__ */ S(
3662
+ "span",
3663
+ {
3664
+ style: {
3665
+ position: "absolute",
3666
+ right: 8,
3667
+ top: d,
3668
+ transform: "translateY(-50%)",
3669
+ color: t.axis.textColor,
3670
+ fontSize: t.typography.axisFontSize,
3671
+ fontFamily: t.typography.fontFamily,
3672
+ fontVariantNumeric: "tabular-nums",
3673
+ userSelect: "none",
3674
+ opacity: h.opacity,
3675
+ transition: "opacity 0.3s ease",
3676
+ willChange: "opacity"
3677
+ },
3678
+ children: r.yScale.formatY(l)
3679
+ },
3680
+ l
3681
+ );
3682
+ })
3683
+ }
3684
+ );
3685
+ }
3686
+ function zo({ seriesId: r, color: t }) {
3687
+ const i = J();
3688
+ j(() => (i.setYLabel(!0), () => i.setYLabel(!1)), [i]);
3689
+ const e = ro(i, r), a = ao(i, r);
3690
+ if (!e) return null;
3691
+ const { value: o, isLive: s } = e, n = i.getTheme(), l = i.yScale.valueToY(o);
3692
+ let h;
3693
+ if (!s)
3694
+ h = n.axis.textColor;
3695
+ else if (t)
3696
+ h = t;
3697
+ else {
3698
+ const p = a === null ? "neutral" : o > a ? "up" : o < a ? "down" : "neutral";
3699
+ h = p === "up" ? n.yLabel.upBackground : p === "down" ? n.yLabel.downBackground : n.yLabel.neutralBackground;
3700
+ }
3701
+ const d = i.yScale.getRange(), g = d.max - d.min, f = g < 0.1 ? 6 : g < 10 ? 4 : g < 1e3 ? 2 : 0;
3702
+ return /* @__PURE__ */ F(Dt, { children: [
3703
+ /* @__PURE__ */ S(
3704
+ "div",
3705
+ {
3706
+ style: {
3707
+ position: "absolute",
3708
+ left: 0,
3709
+ right: i.yAxisWidth,
3710
+ top: l,
3711
+ height: 0,
3712
+ borderTop: `1px dashed ${h}`,
3713
+ opacity: 0.5,
3714
+ pointerEvents: "none",
3715
+ zIndex: 2
3716
+ }
3717
+ }
3718
+ ),
3719
+ /* @__PURE__ */ S(
3720
+ "div",
3721
+ {
3722
+ style: {
3723
+ position: "absolute",
3724
+ right: 4,
3725
+ top: l,
3726
+ transform: "translateY(-50%)",
3727
+ pointerEvents: "auto",
3728
+ zIndex: 3,
3729
+ background: h,
3730
+ color: n.yLabel.textColor,
3731
+ fontSize: n.typography.yFontSize,
3732
+ fontFamily: n.typography.fontFamily,
3733
+ padding: "3px 8px",
3734
+ borderRadius: 3,
3735
+ whiteSpace: "nowrap",
3736
+ transition: "background-color 0.3s ease"
3737
+ },
3738
+ children: /* @__PURE__ */ S(
3739
+ lo,
3740
+ {
3741
+ value: o,
3742
+ format: { minimumFractionDigits: f, maximumFractionDigits: f, useGrouping: !1 },
3743
+ spinDuration: 350
3744
+ }
3745
+ )
3746
+ }
3747
+ )
3748
+ ] });
3749
+ }
3750
+ export {
3751
+ Ki as BarSeries,
3752
+ Co as CandlestickSeries,
3753
+ to as ChartContainer,
3754
+ mi as ChartInstance,
3755
+ So as Crosshair,
3756
+ Zi as Legend,
3757
+ eo as LineSeries,
3758
+ lo as NumberFlow,
3759
+ ko as PieLegend,
3760
+ wo as PieSeries,
3761
+ Mo as PieTooltip,
3762
+ Ro as Sparkline,
3763
+ ve as ThemeProvider,
3764
+ To as TimeAxis,
3765
+ Do as Tooltip,
3766
+ To as XAxis,
3767
+ Bo as YAxis,
3768
+ zo as YLabel,
3769
+ ki as andromeda,
3770
+ Mi as ayuMirage,
3771
+ xo as buildTheme,
3772
+ Ri as catppuccin,
3773
+ I as createTheme,
3774
+ fi as darkTheme,
3775
+ qe as detectInterval,
3776
+ Ti as dracula,
3777
+ Qe as formatDate,
3778
+ At as formatTime,
3779
+ Di as githubLight,
3780
+ Bi as gruvbox,
3781
+ zi as handwritten,
3782
+ Li as highContrast,
3783
+ Wi as lavenderMist,
3784
+ Ai as lightPink,
3785
+ yo as lightTheme,
3786
+ Ii as materialPalenight,
3787
+ _i as minimalLight,
3788
+ Ui as mintBreeze,
3789
+ Ei as monokaiPro,
3790
+ Oi as nightOwl,
3791
+ de as normalizeTime,
3792
+ $i as oneDarkPro,
3793
+ Xi as panda,
3794
+ Hi as peachCream,
3795
+ Gi as quietLight,
3796
+ Ni as rosePineDawn,
3797
+ ji as sandDune,
3798
+ Ji as solarizedLight,
3799
+ be as themes,
3800
+ J as useChartInstance,
3801
+ ie as useCrosshairPosition,
3802
+ ro as useLastYValue,
3803
+ ao as usePreviousClose,
3804
+ qi as useTheme,
3805
+ io as useVisibleRange,
3806
+ oo as useYRange
3807
+ };