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