@canplot/react 0.5.8 → 0.5.10

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/canplot.mjs CHANGED
@@ -1,30 +1,30 @@
1
1
  var Be = Object.defineProperty;
2
2
  var ze = (e, t, n) => t in e ? Be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var O = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
3
+ var K = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsxs as pe, jsx as R, Fragment as Ne } from "react/jsx-runtime";
5
- import D, { version as $e, createContext as ye, forwardRef as je, useRef as k, useState as B, useMemo as Z, useLayoutEffect as $, useCallback as Ve, useContext as q, useEffect as ke, useId as He } from "react";
6
- const ie = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n) => t + (n ?? 0), 0), Rt = (e, t) => {
5
+ import D, { version as $e, createContext as ye, forwardRef as je, useRef as k, useState as B, useMemo as Q, useLayoutEffect as $, useCallback as He, useContext as G, useEffect as ke, useId as Ve } from "react";
6
+ const re = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n) => t + (n ?? 0), 0), Rt = (e, t) => {
7
7
  let n = 0;
8
8
  for (let s = 0; s < e.length; s++)
9
9
  Math.abs(e[s] - t) < Math.abs(e[n] - t) && (n = s);
10
10
  return n;
11
11
  }, We = (e, t, n, s) => {
12
- const o = X(e, n);
12
+ const o = F(e, n);
13
13
  if (!o)
14
14
  return null;
15
15
  const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = (o.origin === "x" ? i.width : i.height) / (o.max - o.min);
16
16
  return t / r;
17
- }, X = (e, t) => e.scales.find((n) => n.id === t) ?? null, U = (e, t) => {
17
+ }, F = (e, t) => e.scales.find((n) => n.id === t) ?? null, U = (e, t) => {
18
18
  const n = window.devicePixelRatio || 1;
19
19
  e.lineCap = t?.lineCap ?? "butt", e.lineDashOffset = n * (t?.lineDashOffset ?? 0), e.lineJoin = t?.lineJoin ?? "miter", e.lineWidth = n * (t?.lineWidth ?? 1), e.miterLimit = n * (t?.miterLimit ?? 10), e.strokeStyle = t?.strokeStyle ?? "black", e.fillStyle = t?.fillStyle ?? e.strokeStyle, e.font = t?.font ?? `${10 * n}px sans-serif`, e.textAlign = t?.textAlign ?? "start", e.direction = t?.direction ?? "inherit", e.textBaseline = t?.textBaseline ?? "alphabetic", e.fontKerning = t?.fontKerning ?? "auto";
20
20
  }, ge = (e, t, n, s) => {
21
- const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = X(e, n);
21
+ const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = F(e, n);
22
22
  if (!i)
23
23
  return null;
24
24
  const r = (i.origin === "x" ? o.width : o.height) / (i.max - i.min);
25
25
  return t * r;
26
- }, G = (e, t, n, s) => {
27
- const o = X(e, n);
26
+ }, Z = (e, t, n, s) => {
27
+ const o = F(e, n);
28
28
  if (!o)
29
29
  return null;
30
30
  const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = ge(
@@ -33,11 +33,11 @@ const ie = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n)
33
33
  n,
34
34
  s
35
35
  );
36
- return r === null ? null : o.origin === "x" ? ie(
36
+ return r === null ? null : o.origin === "x" ? re(
37
37
  i.x + r,
38
38
  i.x - 10 * i.width,
39
39
  i.x + 11 * i.width
40
- ) : ie(
40
+ ) : re(
41
41
  i.y + i.height - r,
42
42
  i.y - 10 * i.height,
43
43
  i.y + 11 * i.height
@@ -46,36 +46,36 @@ const ie = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n)
46
46
  if (t === null)
47
47
  return null;
48
48
  const s = n === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS;
49
- return ie(t, s.x, s.x + s.width);
50
- }, H = (e, t, n) => {
49
+ return re(t, s.x, s.x + s.width);
50
+ }, W = (e, t, n) => {
51
51
  if (t === null)
52
52
  return null;
53
53
  const s = n === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS;
54
- return ie(t, s.y, s.y + s.height);
55
- }, fe = (e, t, n) => {
54
+ return re(t, s.y, s.y + s.height);
55
+ }, de = (e, t, n) => {
56
56
  if (t === null)
57
57
  return !1;
58
- const s = X(e, n);
58
+ const s = F(e, n);
59
59
  return s ? t >= s.min && t <= s.max : !1;
60
- }, _ = (e, t, n, s) => {
61
- const o = X(e, n);
60
+ }, X = (e, t, n, s) => {
61
+ const o = F(e, n);
62
62
  if (!o)
63
63
  return null;
64
64
  const i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, r = o.origin === "x" ? (t - i.x) / i.width : (i.height - t + i.y) / i.height;
65
65
  return o.min + r * (o.max - o.min);
66
- }, F = (e, t) => {
66
+ }, O = (e, t) => {
67
67
  if (e === t) return !0;
68
68
  if (e == null || t == null || typeof e != typeof t || typeof e != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
69
69
  if (Array.isArray(e) && Array.isArray(t)) {
70
70
  if (e.length !== t.length) return !1;
71
71
  for (let o = 0; o < e.length; o++)
72
- if (!F(e[o], t[o])) return !1;
72
+ if (!O(e[o], t[o])) return !1;
73
73
  return !0;
74
74
  }
75
75
  const n = Object.keys(e), s = Object.keys(t);
76
76
  if (n.length !== s.length) return !1;
77
77
  for (const o of n)
78
- if (!Object.prototype.hasOwnProperty.call(t, o) || !F(e[o], t[o])) return !1;
78
+ if (!Object.prototype.hasOwnProperty.call(t, o) || !O(e[o], t[o])) return !1;
79
79
  return !0;
80
80
  }, qe = (e) => {
81
81
  const { ctx: t, scales: n } = e;
@@ -107,7 +107,7 @@ function Ge(e) {
107
107
  for (const n of e) me(n, t);
108
108
  };
109
109
  }
110
- function Ze(e) {
110
+ function Je(e) {
111
111
  return (t) => {
112
112
  const n = [];
113
113
  for (const s of e) {
@@ -124,7 +124,7 @@ function me(e, t) {
124
124
  return e(t);
125
125
  e && (e.current = t);
126
126
  }
127
- var Je = parseInt($e.split(".")[0], 10) >= 19 ? Ze : Ge;
127
+ var Ze = parseInt($e.split(".")[0], 10) >= 19 ? Je : Ge;
128
128
  const Re = ye({
129
129
  listeners: [],
130
130
  subscribe: () => () => {
@@ -149,13 +149,13 @@ const Re = ye({
149
149
  };
150
150
  class Le {
151
151
  constructor() {
152
- O(this, "_frame", null);
153
- O(this, "clampXPosToChartArea", (t, n = "canvas") => V(this.frame, t, n));
154
- O(this, "clampYPosToChartArea", (t, n = "canvas") => H(this.frame, t, n));
155
- O(this, "valToPos", (t, n, s = "canvas") => G(this.frame, t, n, s));
156
- O(this, "valToPxDistance", (t, n, s = "canvas") => ge(this.frame, t, n, s));
157
- O(this, "valFits", (t, n) => fe(this.frame, t, n));
158
- O(this, "getScale", (t) => X(this.frame, t));
152
+ K(this, "_frame", null);
153
+ K(this, "clampXPosToChartArea", (t, n = "canvas") => V(this.frame, t, n));
154
+ K(this, "clampYPosToChartArea", (t, n = "canvas") => W(this.frame, t, n));
155
+ K(this, "valToPos", (t, n, s = "canvas") => Z(this.frame, t, n, s));
156
+ K(this, "valToPxDistance", (t, n, s = "canvas") => ge(this.frame, t, n, s));
157
+ K(this, "valFits", (t, n) => de(this.frame, t, n));
158
+ K(this, "getScale", (t) => F(this.frame, t));
159
159
  }
160
160
  _updateFrame(t) {
161
161
  this._frame = t;
@@ -170,18 +170,18 @@ class Le {
170
170
  }
171
171
  }
172
172
  const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
173
- const i = k(null), r = k(null), c = tt(r), [u, l] = B(null), p = Z(
173
+ const i = k(null), r = k(null), c = tt(r), [u, l] = B(null), p = Q(
174
174
  () => nt(e, c, u),
175
175
  [e, c, u]
176
176
  );
177
177
  $(() => {
178
178
  l(i.current?.getContext("2d") || null);
179
179
  }, [i]);
180
- const d = window.devicePixelRatio || 1;
180
+ const f = window.devicePixelRatio || 1;
181
181
  return /* @__PURE__ */ pe(
182
182
  "div",
183
183
  {
184
- ref: Je([o, r]),
184
+ ref: Ze([o, r]),
185
185
  style: {
186
186
  position: "relative",
187
187
  overflow: "hidden",
@@ -194,8 +194,8 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
194
194
  "canvas",
195
195
  {
196
196
  ref: i,
197
- width: c.width * d,
198
- height: c.height * d,
197
+ width: c.width * f,
198
+ height: c.height * f,
199
199
  style: {
200
200
  inset: 0,
201
201
  position: "absolute",
@@ -212,7 +212,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
212
212
  frame: e,
213
213
  children: t
214
214
  }) => {
215
- const n = Z(Qe, []), [s, o] = B(0);
215
+ const n = Q(Qe, []), [s, o] = B(0);
216
216
  $(() => {
217
217
  e?.ctx.clearRect(0, 0, e.ctx.canvas.width, e.ctx.canvas.height);
218
218
  }, [e, s]);
@@ -229,7 +229,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
229
229
  c && cancelAnimationFrame(c);
230
230
  };
231
231
  }, [s, e, n]);
232
- const r = Ve(() => {
232
+ const r = He(() => {
233
233
  o((c) => c + 1);
234
234
  }, [o]);
235
235
  return /* @__PURE__ */ R(Re.Provider, { value: n, children: /* @__PURE__ */ R(De.Provider, { value: r, children: /* @__PURE__ */ R(ve.Provider, { value: e, children: t }) }) });
@@ -326,7 +326,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
326
326
  case "bottom":
327
327
  throw new Error("Invalid axis position for y origin");
328
328
  }
329
- const f = {
329
+ const d = {
330
330
  x: g.x * s,
331
331
  y: g.y * s,
332
332
  width: g.width * s,
@@ -337,7 +337,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
337
337
  axis: {
338
338
  ...a.axis,
339
339
  cssRect: g,
340
- canvasRect: f
340
+ canvasRect: d
341
341
  }
342
342
  });
343
343
  }
@@ -350,7 +350,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
350
350
  chartAreaCanvasPX: i
351
351
  };
352
352
  }, j = (e, t, n) => {
353
- const s = q(ve), o = q(De), i = q(Re);
353
+ const s = G(ve), o = G(De), i = G(Re);
354
354
  if (!s || !o)
355
355
  throw new Error("useFrame must be used within a CanPlot component");
356
356
  const [r] = B(() => new Le());
@@ -374,10 +374,10 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
374
374
  o();
375
375
  }, [o]);
376
376
  }, Ue = () => {
377
- const e = q(ve);
377
+ const e = G(ve);
378
378
  if (!e)
379
379
  throw new Error("useFrame must be used within a CanPlot component");
380
- return Z(() => {
380
+ return Q(() => {
381
381
  const t = new Le();
382
382
  return t._updateFrame(e), t;
383
383
  }, [e]);
@@ -386,13 +386,13 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
386
386
  ({ ctx: r, clampXPosToChartArea: c, clampYPosToChartArea: u, valToPos: l }) => {
387
387
  r.save(), r.beginPath(), U(r, o), i !== void 0 && (r.globalAlpha = i);
388
388
  for (const p of t) {
389
- const d = c(l(p.x, n, "canvas")), a = u(l(p.y, s, "canvas"));
390
- d === null || a === null || r.lineTo(d, a);
389
+ const f = c(l(p.x, n, "canvas")), a = u(l(p.y, s, "canvas"));
390
+ f === null || a === null || r.lineTo(f, a);
391
391
  }
392
392
  r.stroke(), r.restore();
393
393
  },
394
394
  [t, n, s, o, i]
395
- ), null), It = D.memo(st, F), ot = ({
395
+ ), null), It = D.memo(st, O), ot = ({
396
396
  layer: e = "MIDDLE",
397
397
  data: t,
398
398
  xScaleId: n,
@@ -407,44 +407,44 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
407
407
  ({
408
408
  ctx: l,
409
409
  valToPos: p,
410
- valFits: d,
410
+ valFits: f,
411
411
  clampXPosToChartArea: a,
412
412
  clampYPosToChartArea: g
413
413
  }) => {
414
414
  l.save(), U(l, c), u !== void 0 && (l.globalAlpha = u);
415
- const f = [];
415
+ const d = [];
416
416
  for (const y of t) {
417
417
  let h = null, m = null;
418
- const w = p(y.x, n);
419
- if (w === null) continue;
418
+ const v = p(y.x, n);
419
+ if (v === null) continue;
420
420
  if (o === "clip") {
421
- if (!d(y.x, n)) continue;
422
- h = w;
421
+ if (!f(y.x, n)) continue;
422
+ h = v;
423
423
  } else
424
- h = a(w, "canvas");
424
+ h = a(v, "canvas");
425
425
  const x = p(y.y, s);
426
426
  if (x !== null) {
427
427
  if (i === "clip") {
428
- if (!d(y.y, s)) continue;
428
+ if (!f(y.y, s)) continue;
429
429
  m = x;
430
430
  } else
431
431
  m = g(x, "canvas");
432
- h === null || m === null || f.push({ x: h, y: m });
432
+ h === null || m === null || d.push({ x: h, y: m });
433
433
  }
434
434
  }
435
435
  if (c?.fillStyle)
436
- for (const y of f)
436
+ for (const y of d)
437
437
  l.beginPath(), l.arc(y.x, y.y, r, 0, Math.PI * 2), l.fill();
438
438
  if (c?.strokeStyle) {
439
439
  l.beginPath();
440
- for (const y of f)
440
+ for (const y of d)
441
441
  l.moveTo(y.x + r, y.y), l.arc(y.x, y.y, r, 0, Math.PI * 2);
442
442
  l.stroke();
443
443
  }
444
444
  l.restore();
445
445
  },
446
446
  [t, n, s, r, c, u]
447
- ), null), Lt = D.memo(ot, F), it = ({
447
+ ), null), Lt = D.memo(ot, O), it = ({
448
448
  data: e,
449
449
  xScaleId: t,
450
450
  yScaleId: n,
@@ -459,34 +459,34 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
459
459
  ({
460
460
  ctx: l,
461
461
  valToPxDistance: p,
462
- valToPos: d,
462
+ valToPos: f,
463
463
  clampXPosToChartArea: a,
464
464
  clampYPosToChartArea: g
465
465
  }) => {
466
466
  if (e.length === 0) return;
467
- const f = g(
468
- d(0, n, "canvas"),
467
+ const d = g(
468
+ f(0, n, "canvas"),
469
469
  "canvas"
470
470
  );
471
- if (f === null)
471
+ if (d === null)
472
472
  return;
473
473
  const y = p(o, t, "canvas") ?? 0, h = [];
474
474
  for (const m of e) {
475
- const w = d(m.x, t, "canvas");
476
- if (w === null)
475
+ const v = f(m.x, t, "canvas");
476
+ if (v === null)
477
477
  continue;
478
- const x = w - y / 2 + i * y, T = g(
479
- d(m.y, n, "canvas"),
478
+ const x = v - y / 2 + i * y, T = g(
479
+ f(m.y, n, "canvas"),
480
480
  "canvas"
481
481
  );
482
482
  if (T === null)
483
483
  continue;
484
- const v = f - T, b = a(x, "canvas"), S = a(x + y, "canvas") - b;
484
+ const w = d - T, b = a(x, "canvas"), S = a(x + y, "canvas") - b;
485
485
  h.push({
486
486
  x: b,
487
487
  y: T,
488
488
  width: S,
489
- height: v
489
+ height: w
490
490
  });
491
491
  }
492
492
  if (l.save(), U(l, s), r !== void 0 && (l.globalAlpha = r), s?.fillStyle)
@@ -500,57 +500,57 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
500
500
  }
501
501
  l.restore();
502
502
  },
503
- [e, t, n, s, o, i, c]
504
- ), null), Ut = D.memo(it, F), rt = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
503
+ [e, t, n, s, o, i, c, r]
504
+ ), null), Ut = D.memo(it, O), rt = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
505
505
  e,
506
506
  ({ ctx: i, clampXPosToChartArea: r, clampYPosToChartArea: c, valToPos: u }) => {
507
507
  const l = [];
508
- for (const d of t) {
509
- const a = r(u(d.x, n));
508
+ for (const f of t) {
509
+ const a = r(u(f.x, n));
510
510
  if (a === null)
511
511
  continue;
512
- const g = c(u(d.y[0], s));
512
+ const g = c(u(f.y[0], s));
513
513
  if (g === null)
514
514
  continue;
515
- const f = c(u(d.y[1], s));
516
- f !== null && (l.push({ x: a, y: g }), l.unshift({ x: a, y: f }));
515
+ const d = c(u(f.y[1], s));
516
+ d !== null && (l.push({ x: a, y: g }), l.unshift({ x: a, y: d }));
517
517
  }
518
518
  const p = l[0];
519
519
  if (p) {
520
520
  i.save(), i.beginPath(), U(i, o), i.moveTo(p.x, p.y);
521
- for (const d of l)
522
- i.lineTo(d.x, d.y);
521
+ for (const f of l)
522
+ i.lineTo(f.x, f.y);
523
523
  i.closePath(), i.fill(), i.restore();
524
524
  }
525
525
  },
526
526
  [t, n, s, o]
527
- ), null), _t = D.memo(rt, F), ct = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: i }) => (j(
527
+ ), null), _t = D.memo(rt, O), ct = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: i }) => (j(
528
528
  e,
529
529
  ({ ctx: r, clampXPosToChartArea: c, clampYPosToChartArea: u, valToPos: l }) => {
530
530
  const p = [];
531
- for (const f of t) {
532
- const y = c(l(f.x, s)), h = u(l(f.y, o));
531
+ for (const d of t) {
532
+ const y = c(l(d.x, s)), h = u(l(d.y, o));
533
533
  y === null || h === null || p.push({ x: y, y: h });
534
534
  }
535
- const d = p.at(0), a = p.at(-1);
536
- if (!d || !a)
535
+ const f = p.at(0), a = p.at(-1);
536
+ if (!f || !a)
537
537
  return;
538
538
  const g = u(l(0, o));
539
539
  if (g !== null) {
540
- r.save(), r.beginPath(), U(r, i), r.moveTo(d.x, g);
541
- for (const f of p)
542
- r.lineTo(f.x, f.y);
540
+ r.save(), r.beginPath(), U(r, i), r.moveTo(f.x, g);
541
+ for (const d of p)
542
+ r.lineTo(d.x, d.y);
543
543
  if (r.lineTo(a.x, g), r.closePath(), r.fill(), n) {
544
- r.beginPath(), r.moveTo(d.x, d.y);
545
- for (const f of p)
546
- r.lineTo(f.x, f.y);
544
+ r.beginPath(), r.moveTo(f.x, f.y);
545
+ for (const d of p)
546
+ r.lineTo(d.x, d.y);
547
547
  r.stroke();
548
548
  }
549
549
  r.restore();
550
550
  }
551
551
  },
552
552
  [t, n, s, o, i]
553
- ), null), Xt = D.memo(ct, F), at = ({
553
+ ), null), Xt = D.memo(ct, O), at = ({
554
554
  layer: e = "BOTTOM",
555
555
  scaleId: t,
556
556
  tickStyle: n,
@@ -561,16 +561,16 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
561
561
  }) => (j(
562
562
  e,
563
563
  ({ ctx: c, valToPos: u, getScale: l, frame: p }) => {
564
- const d = l(t);
565
- if (!d || !d.axis || d.origin !== "x") return;
566
- const a = d.axis, g = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, f = window.devicePixelRatio || 1, y = g, h = (i ?? 6) * f, m = a.position === "top" ? g - h : g + h, w = (o ?? 12) * f;
564
+ const f = l(t);
565
+ if (!f || !f.axis || f.origin !== "x") return;
566
+ const a = f.axis, g = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, d = window.devicePixelRatio || 1, y = g, h = (i ?? 6) * d, m = a.position === "top" ? g - h : g + h, v = (o ?? 12) * d;
567
567
  c.save(), c.fontKerning = "auto", U(c, {
568
568
  ...n
569
569
  }), c.beginPath();
570
- const x = Array.isArray(r) ? r : r({ ...d, axis: a }, p);
570
+ const x = Array.isArray(r) ? r : r({ ...f, axis: a }, p);
571
571
  for (const { value: T } of x) {
572
- const v = u(T, t, "canvas");
573
- v !== null && (c.moveTo(v, y), c.lineTo(v, m));
572
+ const w = u(T, t, "canvas");
573
+ w !== null && (c.moveTo(w, y), c.lineTo(w, m));
574
574
  }
575
575
  c.stroke(), c.restore(), c.save(), U(c, {
576
576
  textBaseline: a.position === "top" ? "bottom" : "top",
@@ -580,19 +580,19 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
580
580
  // alter font size for DPR
581
581
  font: _e(s?.font ?? n?.font)
582
582
  });
583
- for (const { value: T, label: v } of x) {
583
+ for (const { value: T, label: w } of x) {
584
584
  const b = u(T, t, "canvas");
585
585
  if (b === null)
586
586
  continue;
587
- const S = v.split(`
587
+ const S = w.split(`
588
588
  `);
589
589
  for (let E = 0; E < S.length; E++)
590
- c.fillText(S[E], b, m + f * 2 + E * w);
590
+ c.fillText(S[E], b, m + d * 2 + E * v);
591
591
  }
592
592
  c.restore();
593
593
  },
594
594
  [r, t, n, s]
595
- ), null), Ft = D.memo(at, F), lt = ({
595
+ ), null), Ft = D.memo(at, O), lt = ({
596
596
  layer: e = "BOTTOM",
597
597
  scaleId: t,
598
598
  tickStyle: n,
@@ -603,13 +603,13 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
603
603
  }) => (j(
604
604
  e,
605
605
  ({ ctx: c, valToPos: u, getScale: l, frame: p }) => {
606
- const d = l(t);
607
- if (!d || !d.axis || d.origin !== "y") return;
608
- const a = d.axis, g = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, f = g, y = i ?? 6, h = a.position === "left" ? g - y : g + y, m = o ?? 12, w = Array.isArray(r) ? r : r({ ...d, axis: a }, p);
606
+ const f = l(t);
607
+ if (!f || !f.axis || f.origin !== "y") return;
608
+ const a = f.axis, g = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, d = g, y = i ?? 6, h = a.position === "left" ? g - y : g + y, m = o ?? 12, v = Array.isArray(r) ? r : r({ ...f, axis: a }, p);
609
609
  c.save(), c.fontKerning = "auto", U(c, { ...n }), c.beginPath();
610
- for (const { value: x } of w) {
610
+ for (const { value: x } of v) {
611
611
  const T = u(x, t, "canvas");
612
- T !== null && (c.moveTo(f, T), c.lineTo(h, T));
612
+ T !== null && (c.moveTo(d, T), c.lineTo(h, T));
613
613
  }
614
614
  c.stroke(), c.restore(), c.save(), U(c, {
615
615
  textBaseline: "middle",
@@ -619,19 +619,19 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
619
619
  // alter font size for DPR
620
620
  font: _e(s?.font ?? n?.font)
621
621
  });
622
- for (const { value: x, label: T } of w) {
623
- const v = u(x, t, "canvas");
624
- if (v === null)
622
+ for (const { value: x, label: T } of v) {
623
+ const w = u(x, t, "canvas");
624
+ if (w === null)
625
625
  continue;
626
626
  const b = T.split(`
627
627
  `);
628
628
  for (let S = 0; S < b.length; S++)
629
- c.fillText(` ${b[S]} `, h, v + S * m);
629
+ c.fillText(` ${b[S]} `, h, w + S * m);
630
630
  }
631
631
  c.restore();
632
632
  },
633
633
  [r, t, n, s]
634
- ), null), Ot = D.memo(lt, F), _e = (e) => {
634
+ ), null), Ot = D.memo(lt, O), _e = (e) => {
635
635
  if (e)
636
636
  try {
637
637
  return e.replace(/(\d+)px/, (t, n) => `${parseInt(n) * window.devicePixelRatio || 1}px`);
@@ -677,33 +677,33 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
677
677
  return L(e, n, t);
678
678
  }, ut = (e, t, n, s, o) => {
679
679
  if (!t) return;
680
- const i = s ?? n.scales.find((d) => d.origin === "x")?.id, r = o ?? n.scales.find((d) => d.origin === "y")?.id, c = e.clientX - t.left, u = i ? {
680
+ const i = s ?? n.scales.find((f) => f.origin === "x")?.id, r = o ?? n.scales.find((f) => f.origin === "y")?.id, c = e.clientX - t.left, u = i ? {
681
681
  scaleId: i,
682
- value: _(n, c, i, "css")
682
+ value: X(n, c, i, "css")
683
683
  } : null, l = e.clientY - t.top, p = r ? {
684
684
  scaleId: r,
685
- value: _(n, l, r, "css")
685
+ value: X(n, l, r, "css")
686
686
  } : null;
687
687
  return { pointerSyncPosition: { x: u, y: p }, cssX: c, cssY: l };
688
688
  }, N = (e, t) => {
689
- const { x: n, y: s } = e, o = n && t.scales.some((r) => r.id === n.scaleId) ? G(t, n.value, n.scaleId, "css") : null, i = s && t.scales.some((r) => r.id === s.scaleId) ? G(t, s.value, s.scaleId, "css") : null;
689
+ const { x: n, y: s } = e, o = n && t.scales.some((r) => r.id === n.scaleId) ? Z(t, n.value, n.scaleId, "css") : null, i = s && t.scales.some((r) => r.id === s.scaleId) ? Z(t, s.value, s.scaleId, "css") : null;
690
690
  return {
691
691
  cssX: o,
692
692
  cssY: i,
693
693
  scaled: Object.fromEntries(
694
694
  t.scales.flatMap((r) => {
695
695
  const c = r.origin === "y" ? i : o;
696
- return c === null ? [] : [[r.id, _(t, c, r.id, "css")]];
696
+ return c === null ? [] : [[r.id, X(t, c, r.id, "css")]];
697
697
  })
698
698
  )
699
699
  };
700
700
  }, Ee = (e, t, n) => {
701
- const s = G(
701
+ const s = Z(
702
702
  n,
703
703
  t.from,
704
704
  t.scaleId,
705
705
  "css"
706
- ), o = G(
706
+ ), o = Z(
707
707
  n,
708
708
  t.to,
709
709
  t.scaleId,
@@ -715,7 +715,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
715
715
  (r) => {
716
716
  if (r.origin !== e)
717
717
  return [];
718
- const c = _(n, s, r.id, "css"), u = _(n, o, r.id, "css");
718
+ const c = X(n, s, r.id, "css"), u = X(n, o, r.id, "css");
719
719
  return c === null || u === null ? [] : [
720
720
  {
721
721
  scaleId: r.id,
@@ -742,35 +742,35 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
742
742
  onContextMenu: u,
743
743
  className: l,
744
744
  style: p,
745
- sync: d,
745
+ sync: f,
746
746
  innerChildren: a,
747
747
  children: g
748
748
  }) => {
749
- const f = He();
750
- return L("dblclick", f, (y) => {
749
+ const d = Ve();
750
+ return L("dblclick", d, (y) => {
751
751
  n?.(y);
752
- }), L("click", f, (y) => {
752
+ }), L("click", d, (y) => {
753
753
  t?.(y);
754
- }), L("move", f, (y) => {
754
+ }), L("move", d, (y) => {
755
755
  s?.(y);
756
- }), L("mousedown", f, (y) => {
756
+ }), L("mousedown", d, (y) => {
757
757
  o?.(y);
758
- }), L("mouseup", f, (y) => {
758
+ }), L("mouseup", d, (y) => {
759
759
  i?.(y);
760
- }), L("documentmouseup", f, (y) => {
760
+ }), L("documentmouseup", d, (y) => {
761
761
  r?.(y);
762
- }), L("spanselect", f, (y) => {
762
+ }), L("spanselect", d, (y) => {
763
763
  c?.(y);
764
- }), L("contextmenu", f, (y) => {
764
+ }), L("contextmenu", d, (y) => {
765
765
  u?.(y);
766
- }), /* @__PURE__ */ pe(we.Provider, { value: f, children: [
766
+ }), /* @__PURE__ */ pe(we.Provider, { value: d, children: [
767
767
  /* @__PURE__ */ R(
768
768
  ht,
769
769
  {
770
770
  id: e,
771
771
  className: l,
772
772
  style: p,
773
- sync: d,
773
+ sync: f,
774
774
  children: a
775
775
  }
776
776
  ),
@@ -779,7 +779,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
779
779
  }, ht = ({ id: e, className: t, style: n, sync: s, children: o }) => {
780
780
  const i = k(null), r = Ue().frame, c = k(r);
781
781
  c.current = r;
782
- const u = q(we), l = s?.key || u, p = k(null), d = k(null), a = k(null), g = () => {
782
+ const u = G(we), l = s?.key || u, p = k(null), f = k(null), a = k(null), g = () => {
783
783
  const h = i.current?.parentElement;
784
784
  if (h) {
785
785
  if (h.dataset.canplotroot === void 0)
@@ -788,17 +788,17 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
788
788
  );
789
789
  return h.getBoundingClientRect();
790
790
  }
791
- }, f = (h, m) => {
792
- const w = ut(
791
+ }, d = (h, m) => {
792
+ const v = ut(
793
793
  h,
794
794
  g(),
795
795
  c.current,
796
796
  s?.xViaScaleId,
797
797
  s?.yViaScaleId
798
798
  );
799
- w && m(
800
- w.pointerSyncPosition,
801
- { cssX: w.cssX, cssY: w.cssY },
799
+ v && m(
800
+ v.pointerSyncPosition,
801
+ { cssX: v.cssX, cssY: v.cssY },
802
802
  {
803
803
  ctrlKey: h.ctrlKey,
804
804
  altKey: h.altKey,
@@ -806,28 +806,28 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
806
806
  metaKey: h.metaKey
807
807
  }
808
808
  );
809
- }, y = k(f);
810
- return y.current = f, ke(() => {
811
- const h = (v) => {
812
- const b = d.current;
809
+ }, y = k(d);
810
+ return y.current = d, ke(() => {
811
+ const h = (w) => {
812
+ const b = f.current;
813
813
  b && M.spanselect.dispatchEvent(u, {
814
814
  ...b,
815
815
  completed: !0
816
816
  }), M.documentmouseup.dispatchEvent(u, {
817
817
  frame: c.current,
818
818
  keys: {
819
- ctrlKey: v.ctrlKey,
820
- altKey: v.altKey,
821
- shiftKey: v.shiftKey,
822
- metaKey: v.metaKey
819
+ ctrlKey: w.ctrlKey,
820
+ altKey: w.altKey,
821
+ shiftKey: w.shiftKey,
822
+ metaKey: w.metaKey
823
823
  }
824
824
  });
825
- }, m = (v) => {
825
+ }, m = (w) => {
826
826
  const b = {
827
- ctrlKey: v.ctrlKey,
828
- altKey: v.altKey,
829
- shiftKey: v.shiftKey,
830
- metaKey: v.metaKey
827
+ ctrlKey: w.ctrlKey,
828
+ altKey: w.altKey,
829
+ shiftKey: w.shiftKey,
830
+ metaKey: w.metaKey
831
831
  }, S = a.current;
832
832
  if (S && Object.entries(b).some(
833
833
  ([C, P]) => S.keys[C] !== P
@@ -835,120 +835,120 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
835
835
  const C = { ...S, keys: b };
836
836
  a.current = C, M.sync_move.dispatchEvent(l, C);
837
837
  }
838
- const E = d.current;
838
+ const E = f.current;
839
839
  if (E && Object.entries(b).some(
840
840
  ([C, P]) => E.keys[C] !== P
841
841
  )) {
842
- v.stopPropagation(), v.preventDefault();
842
+ w.stopPropagation(), w.preventDefault();
843
843
  const C = { ...E, keys: b };
844
- d.current = C, M.spanselect.dispatchEvent(u, C);
844
+ f.current = C, M.spanselect.dispatchEvent(u, C);
845
845
  }
846
- }, w = (v) => {
846
+ }, v = (w) => {
847
847
  y.current(
848
- v,
848
+ w,
849
849
  (b, { cssX: S, cssY: E }, C) => {
850
850
  const P = p.current;
851
851
  if (!P || !b.x || !b.y) return;
852
- const A = c.current, z = P.xRangeCss.start, ae = S, le = P.yRangeCss.start, ue = E, J = X(A, b.x.scaleId);
853
- if (!J) return;
854
- const Q = X(A, b.y.scaleId);
855
- if (!Q) return;
852
+ const A = c.current, z = P.xRangeCss.start, ae = S, le = P.yRangeCss.start, ue = E, ee = F(A, b.x.scaleId);
853
+ if (!ee) return;
854
+ const te = F(A, b.y.scaleId);
855
+ if (!te) return;
856
856
  p.current = {
857
857
  xRangeCss: { start: z, end: ae },
858
858
  yRangeCss: { start: le, end: ue }
859
859
  };
860
- let W = "below_threshold";
861
- const he = Math.abs(le - ue), de = Math.abs(z - ae);
862
- he < 10 && de < 10 ? W = "below_threshold" : he > 30 && de > 30 ? W = "box" : he > de ? W = "y" : W = "x";
863
- const Te = _(
860
+ let q = "below_threshold";
861
+ const he = Math.abs(le - ue), fe = Math.abs(z - ae);
862
+ he < 10 && fe < 10 ? q = "below_threshold" : he > 30 && fe > 30 ? q = "box" : he > fe ? q = "y" : q = "x";
863
+ const Te = X(
864
864
  A,
865
865
  V(c.current, z, "css"),
866
- J.id,
866
+ ee.id,
867
867
  "css"
868
868
  );
869
869
  if (Te === null) return;
870
- const Se = _(
870
+ const Se = X(
871
871
  A,
872
872
  V(c.current, ae, "css"),
873
- J.id,
873
+ ee.id,
874
874
  "css"
875
875
  );
876
876
  if (Se === null) return;
877
- const Ce = _(
877
+ const Ce = X(
878
878
  A,
879
- H(c.current, le, "css"),
880
- Q.id,
879
+ W(c.current, le, "css"),
880
+ te.id,
881
881
  "css"
882
882
  );
883
883
  if (Ce === null) return;
884
- const Pe = _(
884
+ const Pe = X(
885
885
  A,
886
- H(c.current, ue, "css"),
887
- Q.id,
886
+ W(c.current, ue, "css"),
887
+ te.id,
888
888
  "css"
889
889
  );
890
890
  if (Pe === null) return;
891
- const ee = Ee(
891
+ const ne = Ee(
892
892
  "x",
893
- { scaleId: J.id, from: Te, to: Se },
893
+ { scaleId: ee.id, from: Te, to: Se },
894
894
  c.current
895
- ), te = Ee(
895
+ ), se = Ee(
896
896
  "y",
897
- { scaleId: Q.id, from: Ce, to: Pe },
897
+ { scaleId: te.id, from: Ce, to: Pe },
898
898
  c.current
899
- ), Ke = ee?.scaled, Ye = te?.scaled, Me = {
900
- mode: W,
899
+ ), Ke = ne?.scaled, Ye = se?.scaled, Me = {
900
+ mode: q,
901
901
  frame: c.current,
902
902
  completed: !1,
903
903
  x: {
904
- css: ee ? {
905
- from: ee.fromCSS,
906
- to: ee.toCSS
904
+ css: ne ? {
905
+ from: ne.fromCSS,
906
+ to: ne.toCSS
907
907
  } : void 0,
908
908
  scaled: Ke ?? []
909
909
  },
910
910
  y: {
911
- css: te ? {
912
- from: te.fromCSS,
913
- to: te.toCSS
911
+ css: se ? {
912
+ from: se.fromCSS,
913
+ to: se.toCSS
914
914
  } : void 0,
915
915
  scaled: Ye ?? []
916
916
  },
917
917
  keys: C
918
918
  };
919
- d.current = Me, M.spanselect.dispatchEvent(
919
+ f.current = Me, M.spanselect.dispatchEvent(
920
920
  u,
921
921
  Me
922
922
  );
923
923
  }
924
924
  );
925
- }, x = (v) => {
926
- y.current(v, (b, S, E) => {
925
+ }, x = (w) => {
926
+ y.current(w, (b, S, E) => {
927
927
  const C = N(
928
928
  b,
929
929
  c.current
930
930
  );
931
931
  if (!C) return;
932
932
  if (Object.values(E).some((A) => A)) {
933
- v.preventDefault();
934
- const A = Math.abs(v.deltaY) > Math.abs(v.deltaX) ? v.deltaY : v.deltaX;
933
+ w.preventDefault();
934
+ const A = Math.abs(w.deltaY) > Math.abs(w.deltaX) ? w.deltaY : w.deltaX;
935
935
  M.pressandwheel.dispatchEvent(u, {
936
936
  pointer: C,
937
937
  frame: c.current,
938
938
  keys: E,
939
- deltaX: v.deltaX,
940
- deltaY: v.deltaY,
939
+ deltaX: w.deltaX,
940
+ deltaY: w.deltaY,
941
941
  deltaAbs: A
942
942
  });
943
943
  }
944
944
  });
945
945
  };
946
- document.addEventListener("mouseup", h), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", w);
946
+ document.addEventListener("mouseup", h), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", v);
947
947
  const T = i.current;
948
948
  return T?.addEventListener("wheel", x, {
949
949
  passive: !1
950
950
  }), () => {
951
- document.removeEventListener("mouseup", h), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", w), T?.removeEventListener("wheel", x);
951
+ document.removeEventListener("mouseup", h), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", v), T?.removeEventListener("wheel", x);
952
952
  };
953
953
  }, [c, u, l, y]), L("sync_move", l, (h) => {
954
954
  const m = h.positions ? N(
@@ -980,7 +980,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
980
980
  h.preventDefault();
981
981
  },
982
982
  onClick: (h) => {
983
- f(h, (m, w, x) => {
983
+ d(h, (m, v, x) => {
984
984
  const T = N(
985
985
  m,
986
986
  c.current
@@ -993,7 +993,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
993
993
  });
994
994
  },
995
995
  onMouseLeave: (h) => {
996
- f(h, (m, w, x) => {
996
+ d(h, (m, v, x) => {
997
997
  M.sync_move.dispatchEvent(l, {
998
998
  positions: null,
999
999
  keys: x,
@@ -1002,7 +1002,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1002
1002
  });
1003
1003
  },
1004
1004
  onMouseMove: (h) => {
1005
- f(h, (m, w, x) => {
1005
+ d(h, (m, v, x) => {
1006
1006
  M.sync_move.dispatchEvent(l, {
1007
1007
  positions: m,
1008
1008
  keys: x,
@@ -1011,23 +1011,23 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1011
1011
  });
1012
1012
  },
1013
1013
  onMouseDown: (h) => {
1014
- f(h, (m, { cssX: w, cssY: x }, T) => {
1015
- const v = N(
1014
+ d(h, (m, { cssX: v, cssY: x }, T) => {
1015
+ const w = N(
1016
1016
  m,
1017
1017
  c.current
1018
1018
  );
1019
- v && (M.mousedown.dispatchEvent(u, {
1020
- pointer: v,
1019
+ w && (M.mousedown.dispatchEvent(u, {
1020
+ pointer: w,
1021
1021
  frame: c.current,
1022
1022
  keys: T
1023
1023
  }), p.current = {
1024
- xRangeCss: { start: w, end: w },
1024
+ xRangeCss: { start: v, end: v },
1025
1025
  yRangeCss: { start: x, end: x }
1026
1026
  });
1027
1027
  });
1028
1028
  },
1029
1029
  onMouseUp: (h) => {
1030
- f(h, (m, w, x) => {
1030
+ d(h, (m, v, x) => {
1031
1031
  const T = N(
1032
1032
  m,
1033
1033
  c.current
@@ -1038,16 +1038,16 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1038
1038
  pointer: T,
1039
1039
  keys: x
1040
1040
  });
1041
- const v = d.current;
1042
- d.current = null;
1041
+ const w = f.current;
1042
+ f.current = null;
1043
1043
  const b = p.current;
1044
- if (p.current = null, b && v) {
1044
+ if (p.current = null, b && w) {
1045
1045
  const S = {
1046
- ...v,
1046
+ ...w,
1047
1047
  keys: x,
1048
1048
  completed: !0
1049
1049
  };
1050
- d.current = null, M.spanselect.dispatchEvent(
1050
+ f.current = null, M.spanselect.dispatchEvent(
1051
1051
  u,
1052
1052
  S
1053
1053
  );
@@ -1055,7 +1055,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1055
1055
  });
1056
1056
  },
1057
1057
  onContextMenu: (h) => {
1058
- h.preventDefault(), f(h, (m, w, x) => {
1058
+ h.preventDefault(), d(h, (m, v, x) => {
1059
1059
  const T = N(
1060
1060
  m,
1061
1061
  c.current
@@ -1068,7 +1068,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1068
1068
  });
1069
1069
  },
1070
1070
  onDoubleClick: (h) => {
1071
- f(h, (m, w, x) => {
1071
+ d(h, (m, v, x) => {
1072
1072
  const T = N(
1073
1073
  m,
1074
1074
  c.current
@@ -1088,35 +1088,35 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1088
1088
  xe("move", (r) => {
1089
1089
  o(r);
1090
1090
  });
1091
- const i = Z(() => {
1091
+ const i = Q(() => {
1092
1092
  if (!s)
1093
1093
  return null;
1094
1094
  const { frame: r, pointer: c } = s, u = c?.scaled[n];
1095
- if (u === void 0 || !X(r, n))
1095
+ if (u === void 0 || !F(r, n))
1096
1096
  return null;
1097
1097
  const p = [];
1098
- let d = u;
1098
+ let f = u;
1099
1099
  for (const a of e) {
1100
- let g = null, f = 1 / 0;
1101
- for (const [m, w] of a.points.entries()) {
1102
- if (!fe(r, w.x, n) || !fe(r, w.y, a.yScaleId))
1100
+ let g = null, d = 1 / 0;
1101
+ for (const [m, v] of a.points.entries()) {
1102
+ if (!de(r, v.x, n) || !de(r, v.y, a.yScaleId))
1103
1103
  continue;
1104
- const x = Math.abs(w.x - u);
1105
- x < f && (f = x, g = m);
1104
+ const x = Math.abs(v.x - u);
1105
+ x < d && (d = x, g = m);
1106
1106
  }
1107
- const y = a.points[g ?? -1], h = ge(r, f, n, "css");
1107
+ const y = a.points[g ?? -1], h = ge(r, d, n, "css");
1108
1108
  if (!y || h === null || h > 30) {
1109
1109
  p.push({ seriesId: a.seriesId, y: null });
1110
1110
  continue;
1111
1111
  }
1112
- d = y.x, p.push({
1112
+ f = y.x, p.push({
1113
1113
  seriesId: a.seriesId,
1114
1114
  y: y.y
1115
1115
  });
1116
1116
  }
1117
1117
  return {
1118
1118
  frame: r,
1119
- x: d,
1119
+ x: f,
1120
1120
  points: p
1121
1121
  };
1122
1122
  }, [e, s, n]);
@@ -1127,7 +1127,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1127
1127
  i(a);
1128
1128
  }), !o)
1129
1129
  return null;
1130
- const { frame: r, pointer: c } = o, u = c?.cssX ?? null, l = c?.cssY ?? null, p = u ? V(r, u, "css") : 0, d = l ? H(r, l, "css") : 0;
1130
+ const { frame: r, pointer: c } = o, u = c?.cssX ?? null, l = c?.cssY ?? null, p = u ? V(r, u, "css") : 0, f = l ? W(r, l, "css") : 0;
1131
1131
  return /* @__PURE__ */ pe(Ne, { children: [
1132
1132
  /* @__PURE__ */ R(
1133
1133
  "div",
@@ -1165,7 +1165,7 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1165
1165
  width: r.chartAreaCSS.width,
1166
1166
  pointerEvents: "none",
1167
1167
  opacity: c ? 1 : 0,
1168
- transform: `translateY(${d}px)`,
1168
+ transform: `translateY(${f}px)`,
1169
1169
  ...n?.(o)
1170
1170
  }
1171
1171
  }
@@ -1178,11 +1178,11 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1178
1178
  i.mode === "below_threshold" || i.completed ? null : i
1179
1179
  );
1180
1180
  });
1181
- const o = Z(() => {
1181
+ const o = Q(() => {
1182
1182
  if (!n || n.mode === "below_threshold")
1183
1183
  return null;
1184
- const i = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, r = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, c = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, u = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, l = V(n.frame, i, "css"), p = V(n.frame, r, "css"), d = H(n.frame, c, "css"), a = H(n.frame, u, "css"), g = Math.min(l, p), f = Math.min(d, a), y = Math.abs(p - l), h = Math.abs(a - d);
1185
- return { leftPx: g, topPx: f, widthPx: y, heightPx: h };
1184
+ const i = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, r = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, c = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, u = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, l = V(n.frame, i, "css"), p = V(n.frame, r, "css"), f = W(n.frame, c, "css"), a = W(n.frame, u, "css"), g = Math.min(l, p), d = Math.min(f, a), y = Math.abs(p - l), h = Math.abs(a - f);
1185
+ return { leftPx: g, topPx: d, widthPx: y, heightPx: h };
1186
1186
  }, [n]);
1187
1187
  return /* @__PURE__ */ R(
1188
1188
  "div",
@@ -1218,12 +1218,12 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1218
1218
  children: t
1219
1219
  }
1220
1220
  ) : null;
1221
- }, Xe = 60, dt = 30, Fe = "UTC", ft = "en-GB", $t = ({
1221
+ }, Xe = 60, ft = 30, Fe = "UTC", dt = "en-GB", $t = ({
1222
1222
  space: e,
1223
1223
  formatter: t,
1224
1224
  acceptableIncrements: n
1225
1225
  } = {}) => (s, o) => {
1226
- const { min: i, max: r } = s, c = [], u = window.devicePixelRatio || 1, l = (e ?? (s.origin === "x" ? Xe : dt)) * u, p = We(
1226
+ const { min: i, max: r } = s, c = [], u = window.devicePixelRatio || 1, l = (e ?? (s.origin === "x" ? Xe : ft)) * u, p = We(
1227
1227
  o,
1228
1228
  l,
1229
1229
  s.id,
@@ -1231,11 +1231,11 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1231
1231
  );
1232
1232
  if (p === null)
1233
1233
  return [];
1234
- const d = n ?? ne, a = d.find((f) => f > p) ?? d.at(-1) ?? 1;
1234
+ const f = n ?? oe, a = f.find((d) => d > p) ?? f.at(-1) ?? 1;
1235
1235
  let g = i;
1236
1236
  if (Math.abs(g % a) > Number.EPSILON) {
1237
- const f = (a - g % a) % a;
1238
- g += f;
1237
+ const d = (a - g % a) % a;
1238
+ g += d;
1239
1239
  }
1240
1240
  for (; g <= r && c.length < 1e3; )
1241
1241
  c.push(g), g += a;
@@ -1243,10 +1243,10 @@ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
1243
1243
  }, mt = (e) => {
1244
1244
  const t = Math.max(0, Math.ceil(-Math.log10(e[1] - e[0])));
1245
1245
  return e.map((n) => ({ value: n, label: n.toFixed(t) }));
1246
- }, ne = [];
1246
+ }, oe = [];
1247
1247
  for (let e = -12; e <= 12; e++)
1248
- ne.push(1 * 10 ** e), ne.push(2 * 10 ** e), ne.push(5 * 10 ** e);
1249
- const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, re = 60 * be, ce = 24 * re, yt = 30 * ce, gt = 365 * ce, vt = [
1248
+ oe.push(1 * 10 ** e), oe.push(2 * 10 ** e), oe.push(5 * 10 ** e);
1249
+ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, J = 60 * be, ce = 24 * J, yt = 30 * ce, gt = 365 * ce, vt = [
1250
1250
  // second divisors
1251
1251
  [1, "milliseconds"],
1252
1252
  [2, "milliseconds"],
@@ -1298,7 +1298,7 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, re = 60 * be, ce = 24 * re, yt = 30 *
1298
1298
  [25, "years"],
1299
1299
  [50, "years"],
1300
1300
  [100, "years"]
1301
- ], se = (e) => {
1301
+ ], ie = (e) => {
1302
1302
  const [t, n] = e;
1303
1303
  switch (n) {
1304
1304
  case "milliseconds":
@@ -1308,7 +1308,7 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, re = 60 * be, ce = 24 * re, yt = 30 *
1308
1308
  case "minutes":
1309
1309
  return t * be;
1310
1310
  case "hours":
1311
- return t * re;
1311
+ return t * J;
1312
1312
  case "days":
1313
1313
  return t * ce;
1314
1314
  case "months":
@@ -1334,7 +1334,7 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, re = 60 * be, ce = 24 * re, yt = 30 *
1334
1334
  }, Ae = (e, t) => {
1335
1335
  const n = new Date(e);
1336
1336
  return n.setUTCMonth(n.getUTCMonth() + t), n.getTime();
1337
- }, Y = (e, t) => {
1337
+ }, _ = (e, t) => {
1338
1338
  const [n, s] = t;
1339
1339
  switch (s) {
1340
1340
  case "milliseconds":
@@ -1353,7 +1353,7 @@ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, re = 60 * be, ce = 24 * re, yt = 30 *
1353
1353
  return Ae(e, n * 12);
1354
1354
  }
1355
1355
  };
1356
- function oe(e, t) {
1356
+ function H(e, t) {
1357
1357
  const n = new Date(e), s = new Date(n.toLocaleString("en-US", { timeZone: t })), o = new Date(n.toLocaleString("en-US", { timeZone: "UTC" }));
1358
1358
  return (s.getTime() - o.getTime()) / (3600 * 1e3);
1359
1359
  }
@@ -1361,7 +1361,7 @@ const Ct = (e, t, n = "UTC") => {
1361
1361
  const [s, o] = t;
1362
1362
  let i = new Date(e);
1363
1363
  const r = () => {
1364
- i.setUTCHours(-oe(i, n), 0, 0, 0);
1364
+ i.setUTCHours(-H(i, n), 0, 0, 0);
1365
1365
  };
1366
1366
  switch (o) {
1367
1367
  case "milliseconds":
@@ -1377,23 +1377,27 @@ const Ct = (e, t, n = "UTC") => {
1377
1377
  break;
1378
1378
  case "minutes":
1379
1379
  i.setUTCMinutes(
1380
- Math.ceil(i.getTime() % re / be / s) * s,
1380
+ Math.ceil(i.getTime() % J / be / s) * s,
1381
1381
  0,
1382
1382
  0
1383
1383
  );
1384
1384
  break;
1385
- case "hours":
1385
+ case "hours": {
1386
+ const c = H(i, n);
1386
1387
  i.setUTCHours(
1387
- Math.ceil(i.getTime() % ce / re / s) * s,
1388
+ Math.ceil(
1389
+ (i.getTime() + c * J) % ce / J / s
1390
+ ) * s - c,
1388
1391
  0,
1389
1392
  0,
1390
1393
  0
1391
1394
  );
1392
1395
  break;
1396
+ }
1393
1397
  case "days":
1394
1398
  case "months":
1395
1399
  case "years":
1396
- o === "months" ? i.setUTCDate(1) : o === "years" && i.setUTCMonth(0, 1), r(), i.getTime() < e && (i = new Date(Y(i, [1, o])));
1400
+ o === "months" ? i.setUTCDate(1) : o === "years" && i.setUTCMonth(0, 1), r(), i.getTime() < e && (i = new Date(_(i, [1, o])));
1397
1401
  break;
1398
1402
  }
1399
1403
  return i.getTime();
@@ -1407,44 +1411,55 @@ const Ct = (e, t, n = "UTC") => {
1407
1411
  const { min: c, max: u } = i;
1408
1412
  if (!Number.isFinite(c) || !Number.isFinite(u))
1409
1413
  return [];
1410
- const l = Math.floor(r.chartAreaCanvasPX.width / t) + 1, d = (u - c) / l, [a, g] = vt.find(
1411
- (w) => se(w) >= d
1414
+ const l = Math.floor(r.chartAreaCanvasPX.width / t) + 1, f = (u - c) / l, [a, g] = vt.find(
1415
+ (v) => ie(v) >= f
1412
1416
  ) ?? [1, "milliseconds"];
1413
1417
  if (!a || !g)
1414
1418
  return [];
1415
- const f = Ct(c, [a, g], e), y = oe(f, e), h = [f];
1419
+ const d = Ct(c, [a, g], e), y = H(d, e);
1420
+ console.log(y, new Date(d));
1421
+ const h = [d];
1416
1422
  let m;
1417
- for (; !(h.length > 1e3); ) {
1423
+ for (; ; ) {
1424
+ if (h.length > 100)
1425
+ return [];
1418
1426
  switch (g) {
1419
1427
  case "milliseconds":
1420
1428
  case "seconds":
1421
1429
  case "minutes":
1422
1430
  case "hours": {
1423
- m = Y(f, [h.length * a, g]);
1431
+ const v = _(d, [
1432
+ h.length * a,
1433
+ g
1434
+ ]);
1435
+ m = _(v, [
1436
+ y - H(v, e),
1437
+ "hours"
1438
+ ]);
1424
1439
  break;
1425
1440
  }
1426
1441
  case "days": {
1427
- const w = Y(f, [
1442
+ const v = _(d, [
1428
1443
  h.length * a,
1429
1444
  g
1430
1445
  ]);
1431
- m = Y(w, [
1432
- y - oe(w, e),
1446
+ m = _(v, [
1447
+ y - H(v, e),
1433
1448
  "hours"
1434
1449
  ]);
1435
1450
  break;
1436
1451
  }
1437
1452
  case "months":
1438
1453
  case "years": {
1439
- const w = Y(
1440
- Y(Y(f, [y, "hours"]), [
1454
+ const v = _(
1455
+ _(_(d, [y, "hours"]), [
1441
1456
  h.length * a,
1442
1457
  g
1443
1458
  ]),
1444
1459
  [-y, "hours"]
1445
1460
  );
1446
- m = Y(w, [
1447
- y - oe(w, e),
1461
+ m = _(v, [
1462
+ y - H(v, e),
1448
1463
  "hours"
1449
1464
  ]);
1450
1465
  break;
@@ -1452,16 +1467,16 @@ const Ct = (e, t, n = "UTC") => {
1452
1467
  }
1453
1468
  if (m > u)
1454
1469
  break;
1455
- h.push(m);
1470
+ h[h.length - 1] !== m && h.push(m);
1456
1471
  }
1457
1472
  return (n ?? Pt({
1458
1473
  locale: s,
1459
1474
  showTimezone: o,
1460
1475
  timeZone: e
1461
1476
  }))(h);
1462
- }, K = (e, t, n) => e.find((s) => s.type === n)?.value !== t.find((s) => s.type === n)?.value, Pt = ({
1477
+ }, Y = (e, t, n) => e.find((s) => s.type === n)?.value !== t.find((s) => s.type === n)?.value, Pt = ({
1463
1478
  timeZone: e = Fe,
1464
- locale: t = ft,
1479
+ locale: t = dt,
1465
1480
  showTimezone: n = !0
1466
1481
  }) => {
1467
1482
  const s = new Intl.DateTimeFormat(t, {
@@ -1477,10 +1492,10 @@ const Ct = (e, t, n = "UTC") => {
1477
1492
  timeZone: e
1478
1493
  });
1479
1494
  return (o) => {
1480
- const i = o[1] - o[0], r = i < se([1, "days"]), c = i < se([1, "minutes"]), u = i < se([1, "seconds"]);
1481
- return o.map((l) => ({ value: l, label: s.formatToParts(new Date(l)) })).map((l, p, d) => {
1482
- const a = d[p - 1], g = p === 0 || K(l.label, a.label, "year"), f = p === 0 || K(l.label, a.label, "day"), y = p === 0 || K(l.label, a.label, "month"), h = p === 0 || K(l.label, a.label, "hour"), m = p === 0 || K(l.label, a.label, "timeZoneName"), w = p === 0 || K(l.label, a.label, "minute"), x = p === 0 || K(l.label, a.label, "second"), T = p === 0 || K(l.label, a.label, "fractionalSecond"), v = [];
1483
- if (r && (h || w || m || x || T)) {
1495
+ const i = o[1] - o[0], r = i < ie([1, "days"]), c = i < ie([1, "minutes"]), u = i < ie([1, "seconds"]);
1496
+ return o.map((l) => ({ value: l, label: s.formatToParts(new Date(l)) })).map((l, p, f) => {
1497
+ const a = f[p - 1], g = p === 0 || Y(l.label, a.label, "year"), d = p === 0 || Y(l.label, a.label, "day"), y = p === 0 || Y(l.label, a.label, "month"), h = p === 0 || Y(l.label, a.label, "hour"), m = p === 0 || Y(l.label, a.label, "timeZoneName"), v = p === 0 || Y(l.label, a.label, "minute"), x = p === 0 || Y(l.label, a.label, "second"), T = p === 0 || Y(l.label, a.label, "fractionalSecond"), w = [];
1498
+ if (r && (h || v || m || x || T)) {
1484
1499
  const b = l.label.find((P) => P.type === "hour")?.value, S = l.label.find((P) => P.type === "minute")?.value, E = l.label.find((P) => P.type === "timeZoneName")?.value;
1485
1500
  let C = "";
1486
1501
  if (c) {
@@ -1489,18 +1504,18 @@ const Ct = (e, t, n = "UTC") => {
1489
1504
  )?.value;
1490
1505
  C = `:${P}` + (u ? `.${A}` : "");
1491
1506
  }
1492
- v.push(
1507
+ w.push(
1493
1508
  `${b}:${S}${C}` + (n && m ? ` ${E}` : "")
1494
1509
  );
1495
1510
  }
1496
- return (f || y) && v.push(
1511
+ return (d || y) && w.push(
1497
1512
  [
1498
1513
  l.label.find((b) => b.type === "month")?.value,
1499
- f && l.label.find((b) => b.type === "day")?.value
1514
+ d && l.label.find((b) => b.type === "day")?.value
1500
1515
  ].filter(Boolean).join(" ")
1501
- ), g && v.push(l.label.find((b) => b.type === "year")?.value), {
1516
+ ), g && w.push(l.label.find((b) => b.type === "year")?.value), {
1502
1517
  value: l.value,
1503
- label: v.filter((b) => b).join(`
1518
+ label: w.filter((b) => b).join(`
1504
1519
  `)
1505
1520
  };
1506
1521
  });
@@ -1523,24 +1538,24 @@ export {
1523
1538
  Ft as XTicks,
1524
1539
  Ot as YTicks,
1525
1540
  U as applyStyles,
1526
- ie as clamp,
1541
+ re as clamp,
1527
1542
  V as clampXPosToChartArea,
1528
- H as clampYPosToChartArea,
1529
- F as deepEqual,
1543
+ W as clampYPosToChartArea,
1544
+ O as deepEqual,
1530
1545
  mt as defaultNumericalTicksFormatter,
1531
1546
  Rt as findClosestIndex,
1532
- X as getScale,
1547
+ F as getScale,
1533
1548
  $t as makeLinearTicks,
1534
1549
  Pt as makeTimeTickFormat,
1535
1550
  jt as makeTimeTicks,
1536
- _ as posToVal,
1551
+ X as posToVal,
1537
1552
  We as pxToValDistance,
1538
1553
  kt as sum,
1539
1554
  j as useDrawEffect,
1540
1555
  Ue as useFrameState,
1541
1556
  xe as useInteractionsEvent,
1542
- fe as valFits,
1543
- G as valToPos,
1557
+ de as valFits,
1558
+ Z as valToPos,
1544
1559
  ge as valToPxDistance
1545
1560
  };
1546
1561
  //# sourceMappingURL=canplot.mjs.map