@canplot/react 0.1.7 → 0.1.9

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,149 +1,170 @@
1
- import { jsxs as at, jsx as X, Fragment as Et } from "react/jsx-runtime";
2
- import Z, { createContext as Pt, useContext as lt, useRef as L, useLayoutEffect as J, version as Mt, forwardRef as At, useMemo as ut, useState as N, useId as Rt, useEffect as _t } from "react";
3
- import { createStore as Ut, useStore as vt } from "zustand";
4
- const V = (t, s, e) => Math.min(Math.max(t, s), e), Lt = (t, s, e, c) => {
5
- const { min: o, max: n } = A(t, e), a = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = (Q(t, e) ? a.width : a.height) / (n - o);
1
+ import { jsxs as ut, jsx as A, Fragment as Rt } from "react/jsx-runtime";
2
+ import Z, { createContext as vt, useContext as J, useRef as D, useLayoutEffect as N, useEffect as wt, version as _t, forwardRef as Ut, useMemo as Q, useState as V, useId as Lt } from "react";
3
+ import { createStore as bt, useStore as Ct } from "zustand";
4
+ const j = (t, s, e) => Math.min(Math.max(t, s), e), ue = (t) => t.reduce((s, e) => s + (e ?? 0), 0), de = (t, s) => {
5
+ let e = 0;
6
+ for (let i = 0; i < t.length; i++)
7
+ Math.abs(t[i] - s) < Math.abs(t[e] - s) && (e = i);
8
+ return e;
9
+ }, Dt = (t, s, e, i) => {
10
+ const { min: o, max: n } = R(t, e), a = i === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = (et(t, e) ? a.width : a.height) / (n - o);
6
11
  return s / l;
7
- }, A = (t, s) => {
8
- const e = t.scales.find((c) => c.id === s);
12
+ }, R = (t, s) => {
13
+ const e = t.scales.find((i) => i.id === s);
9
14
  if (!e)
10
15
  throw new Error(`Scale ${s} not found`);
11
16
  return e;
12
- }, Q = (t, s) => t.scales.find((e) => e.id === s)?.origin === "x", ae = (t, s) => t.scales.find((e) => e.id === s)?.origin === "y", R = (t, s) => {
17
+ }, et = (t, s) => t.scales.find((e) => e.id === s)?.origin === "x", he = (t, s) => t.scales.find((e) => e.id === s)?.origin === "y", _ = (t, s) => {
13
18
  const e = window.devicePixelRatio || 1;
14
19
  t.lineCap = s?.lineCap ?? "butt", t.lineDashOffset = e * (s?.lineDashOffset ?? 0), t.lineJoin = s?.lineJoin ?? "miter", t.lineWidth = e * (s?.lineWidth ?? 1), t.miterLimit = e * (s?.miterLimit ?? 10), t.strokeStyle = s?.strokeStyle ?? "black", t.fillStyle = s?.fillStyle ?? t.strokeStyle, t.font = s?.font ?? `${10 * e}px sans-serif`, t.textAlign = s?.textAlign ?? "start", t.direction = s?.direction ?? "inherit", t.textBaseline = s?.textBaseline ?? "alphabetic", t.fontKerning = s?.fontKerning ?? "auto";
15
- }, dt = (t, s, e, c) => {
16
- const o = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: n, max: a } = A(t, e), l = (Q(t, e) ? o.width : o.height) / (a - n);
20
+ }, dt = (t, s, e, i) => {
21
+ const o = i === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: n, max: a } = R(t, e), l = (et(t, e) ? o.width : o.height) / (a - n);
17
22
  return s * l;
18
- }, j = (t, s, e, c) => {
19
- const { min: o } = A(t, e), n = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, a = dt(t, s - o, e, c);
20
- return Q(t, e) ? V(
23
+ }, H = (t, s, e, i) => {
24
+ const { min: o } = R(t, e), n = i === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, a = dt(t, s - o, e, i);
25
+ return et(t, e) ? j(
21
26
  n.x + a,
22
27
  n.x - 10 * n.width,
23
28
  n.x + 11 * n.width
24
- ) : V(
29
+ ) : j(
25
30
  n.y + n.height - a,
26
31
  n.y - 10 * n.height,
27
32
  n.y + 11 * n.height
28
33
  );
29
- }, le = (t, s, e) => {
30
- const { min: c, max: o } = A(t, e);
31
- return V(s, c, o);
34
+ }, fe = (t, s, e) => {
35
+ const { min: i, max: o } = R(t, e);
36
+ return j(s, i, o);
32
37
  }, O = (t, s, e) => {
33
- const c = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
34
- return V(s, c.x, c.x + c.width);
38
+ const i = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
39
+ return j(s, i.x, i.x + i.width);
35
40
  }, $ = (t, s, e) => {
36
- const c = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
37
- return V(s, c.y, c.y + c.height);
38
- }, it = (t, s, e) => {
39
- const { min: c, max: o } = A(t, e);
40
- return s >= c && s <= o;
41
- }, D = (t, s, e, c) => {
42
- const { min: o, max: n } = A(t, e), a = c === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = Q(t, e) ? (s - a.x) / a.width : (a.height - s + a.y) / a.height;
41
+ const i = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
42
+ return j(s, i.y, i.y + i.height);
43
+ }, at = (t, s, e) => {
44
+ const { min: i, max: o } = R(t, e);
45
+ return s >= i && s <= o;
46
+ }, X = (t, s, e, i) => {
47
+ const { min: o, max: n } = R(t, e), a = i === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = et(t, e) ? (s - a.x) / a.width : (a.height - s + a.y) / a.height;
43
48
  return o + l * (n - o);
44
- }, Dt = (t) => {
49
+ }, Xt = (t) => {
45
50
  const { ctx: s, scales: e } = t;
46
- for (const c of e) {
47
- if (!c.axis) continue;
48
- s.save(), R(s, {
51
+ for (const i of e) {
52
+ if (!i.axis) continue;
53
+ s.save(), _(s, {
49
54
  strokeStyle: "black",
50
55
  fillStyle: "black",
51
56
  lineWidth: 1,
52
- ...c.axis.style
57
+ ...i.axis.style
53
58
  });
54
- const o = c.axis.canvasRect;
55
- if (c.origin === "x") {
56
- if (c.axis.position === "bottom")
59
+ const o = i.axis.canvasRect;
60
+ if (i.origin === "x") {
61
+ if (i.axis.position === "bottom")
57
62
  s.beginPath(), s.moveTo(o.x, o.y), s.lineTo(o.x + o.width, o.y), s.stroke();
58
- else if (c.axis.position === "top") {
63
+ else if (i.axis.position === "top") {
59
64
  const n = o.y + o.height;
60
65
  s.beginPath(), s.moveTo(o.x, n), s.lineTo(o.x + o.width, n), s.stroke();
61
66
  }
62
- } else if (c.axis.position === "left") {
67
+ } else if (i.axis.position === "left") {
63
68
  const n = o.x + o.width;
64
69
  s.beginPath(), s.moveTo(n, o.y), s.lineTo(n, o.y + o.height), s.stroke();
65
- } else c.axis.position === "right" && (s.beginPath(), s.moveTo(o.x, o.y), s.lineTo(o.x, o.y + o.height), s.stroke());
70
+ } else i.axis.position === "right" && (s.beginPath(), s.moveTo(o.x, o.y), s.lineTo(o.x, o.y + o.height), s.stroke());
66
71
  s.restore();
67
72
  }
68
- }, Xt = () => Ut((t, s) => {
73
+ }, It = () => bt((t, s) => {
69
74
  const e = () => {
70
- const c = s()._frame;
71
- if (!c) throw new Error("No frame set in frame store");
72
- return c;
75
+ const i = s()._frame;
76
+ if (!i) throw new Error("No frame set in frame store");
77
+ return i;
73
78
  };
74
79
  return {
75
80
  _frame: null,
76
81
  getFrame: e,
77
82
  getCtx: () => e().ctx,
78
- clampXPosToChartArea: (c, o) => O(e(), c, o ?? "canvas"),
79
- clampYPosToChartArea: (c, o) => $(e(), c, o ?? "canvas"),
80
- valToPos: (c, o, n) => j(e(), c, o, n ?? "canvas"),
81
- valToPxDistance: (c, o, n) => dt(
83
+ clampXPosToChartArea: (i, o) => O(e(), i, o ?? "canvas"),
84
+ clampYPosToChartArea: (i, o) => $(e(), i, o ?? "canvas"),
85
+ valToPos: (i, o, n) => H(e(), i, o, n ?? "canvas"),
86
+ valToPxDistance: (i, o, n) => dt(
82
87
  e(),
83
- c,
88
+ i,
84
89
  o,
85
90
  n ?? "canvas"
86
91
  ),
87
- valFits: (c, o) => it(e(), c, o),
88
- getScale: (c) => A(e(), c)
92
+ valFits: (i, o) => at(e(), i, o),
93
+ getScale: (i) => R(e(), i)
89
94
  };
90
- }), ht = Pt(null), z = (t, s) => {
91
- const e = lt(ht);
92
- if (!e)
95
+ }), Kt = () => bt((t) => ({
96
+ notify: () => {
97
+ t((s) => ({ version: s.version + 1 }));
98
+ },
99
+ version: 0
100
+ })), ht = vt(null), Tt = vt(null), z = (t, s) => {
101
+ const e = J(ht), i = J(Tt);
102
+ if (!e || !i)
93
103
  throw new Error("useFrame must be used within a CanPlot component");
94
- const c = L(t);
95
- c.current = t, J(() => {
96
- c.current(e.getState()), e.subscribe((o) => {
97
- o._frame && c.current(o);
104
+ const o = D(t);
105
+ o.current = t, N(() => {
106
+ o.current(e.getState()), e.subscribe((n) => {
107
+ n._frame && o.current(n);
98
108
  });
99
- }, [e, ...s]);
109
+ }, [e]), wt(() => {
110
+ i.getState().notify();
111
+ }, [i, ...s]);
100
112
  }, ft = (t) => {
101
- const s = lt(ht);
113
+ const s = J(ht);
102
114
  if (!s)
103
115
  throw new Error("useFrame must be used within a CanPlot component");
104
- return vt(
116
+ return Ct(
105
117
  s,
106
118
  t ?? ((e) => e.getFrame())
107
119
  );
108
120
  };
109
- function Kt(t) {
121
+ function Ft(t) {
110
122
  return (s) => {
111
- for (const e of t) rt(e, s);
123
+ for (const e of t) lt(e, s);
112
124
  };
113
125
  }
114
- function It(t) {
126
+ function zt(t) {
115
127
  return (s) => {
116
128
  const e = [];
117
- for (const c of t) {
118
- const o = rt(c, s), n = typeof o == "function";
119
- e.push(n ? o : () => rt(c, null));
129
+ for (const i of t) {
130
+ const o = lt(i, s), n = typeof o == "function";
131
+ e.push(n ? o : () => lt(i, null));
120
132
  }
121
133
  return () => {
122
- for (const c of e) c();
134
+ for (const i of e) i();
123
135
  };
124
136
  };
125
137
  }
126
- function rt(t, s) {
138
+ function lt(t, s) {
127
139
  if (typeof t == "function")
128
140
  return t(s);
129
141
  t && (t.current = s);
130
142
  }
131
- var Ft = parseInt(Mt.split(".")[0], 10) >= 19 ? It : Kt;
132
- const ue = At(({ configuration: t, children: s, style: e, className: c }, o) => {
133
- const n = L(null), a = L(null), l = Yt(a), d = ut(Xt, []);
134
- J(() => {
143
+ var Yt = parseInt(_t.split(".")[0], 10) >= 19 ? zt : Ft;
144
+ const me = Ut(({ configuration: t, children: s, style: e, className: i }, o) => {
145
+ const n = D(null), a = D(null), l = $t(a), d = Q(It, []), u = Q(Kt, []);
146
+ N(() => {
135
147
  d.setState({
136
- _frame: Ot(t, l, n.current)
148
+ _frame: Bt(t, l, n.current)
149
+ });
150
+ }, [t, l, n, d]), N(() => d.subscribe((m) => {
151
+ m._frame && Nt(m._frame);
152
+ }), [d]), N(() => {
153
+ let m = !1;
154
+ return u.subscribe(() => {
155
+ m || (m = !0, window.requestAnimationFrame(() => {
156
+ m = !1, d.setState((f) => ({
157
+ _frame: f._frame ? { ...f._frame } : null
158
+ }));
159
+ }));
137
160
  });
138
- }, [t, l, n, d]), J(() => d.subscribe((r) => {
139
- r._frame && $t(r._frame);
140
- }), [d]);
141
- const u = window.devicePixelRatio || 1;
142
- return /* @__PURE__ */ at(
161
+ }, [u, d]);
162
+ const r = window.devicePixelRatio || 1;
163
+ return /* @__PURE__ */ ut(
143
164
  "div",
144
165
  {
145
- ref: Ft([o, a]),
146
- className: c,
166
+ ref: Yt([o, a]),
167
+ className: i,
147
168
  style: {
148
169
  position: "relative",
149
170
  overflow: "hidden",
@@ -151,12 +172,12 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
151
172
  },
152
173
  "data-canplotroot": !0,
153
174
  children: [
154
- /* @__PURE__ */ X(
175
+ /* @__PURE__ */ A(
155
176
  "canvas",
156
177
  {
157
178
  ref: n,
158
- width: l.width * u,
159
- height: l.height * u,
179
+ width: l.width * r,
180
+ height: l.height * r,
160
181
  style: {
161
182
  inset: 0,
162
183
  position: "absolute",
@@ -165,15 +186,22 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
165
186
  }
166
187
  }
167
188
  ),
168
- /* @__PURE__ */ X(zt, { frameStore: d, children: s })
189
+ /* @__PURE__ */ A(
190
+ Ot,
191
+ {
192
+ frameStore: d,
193
+ updateRequestStore: u,
194
+ children: s
195
+ }
196
+ )
169
197
  ]
170
198
  }
171
199
  );
172
- }), zt = ({ frameStore: t, children: s }) => vt(t, (c) => !!c._frame) ? /* @__PURE__ */ X(ht.Provider, { value: t, children: s }) : null, Yt = (t) => {
173
- const [s, e] = N({
200
+ }), Ot = ({ frameStore: t, updateRequestStore: s, children: e }) => Ct(t, (o) => !!o._frame) ? /* @__PURE__ */ A(Tt.Provider, { value: s, children: /* @__PURE__ */ A(ht.Provider, { value: t, children: e }) }) : null, $t = (t) => {
201
+ const [s, e] = V({
174
202
  width: 0,
175
203
  height: 0
176
- }), [c] = N(() => new ResizeObserver((o) => {
204
+ }), [i] = V(() => new ResizeObserver((o) => {
177
205
  for (const n of o) {
178
206
  const a = Math.round(n.contentRect.width), l = Math.round(n.contentRect.height);
179
207
  e(
@@ -181,16 +209,16 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
181
209
  );
182
210
  }
183
211
  }));
184
- return J(() => {
212
+ return N(() => {
185
213
  if (!t.current) return;
186
214
  const o = t.current.clientWidth, n = t.current.clientHeight;
187
215
  return e(
188
216
  (a) => a.width !== o || a.height !== n ? { ...a, width: o, height: n } : a
189
- ), c.observe(t.current, { box: "border-box" }), () => c.disconnect();
190
- }, [c, t]), s;
191
- }, Ot = (t, s, e) => {
192
- const c = e?.getContext("2d");
193
- if (!c) return null;
217
+ ), i.observe(t.current, { box: "border-box" }), () => i.disconnect();
218
+ }, [i, t]), s;
219
+ }, Bt = (t, s, e) => {
220
+ const i = e?.getContext("2d");
221
+ if (!i) return null;
194
222
  const o = window.devicePixelRatio || 1;
195
223
  if (s.width === 0 || s.height === 0)
196
224
  return null;
@@ -211,17 +239,17 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
211
239
  width: n.width * o,
212
240
  height: n.height * o
213
241
  }, l = [];
214
- let d = t.padding.left * o, u = c.canvas.width - t.padding.right * o, r = c.canvas.height - t.padding.bottom * o, p = t.padding.top * o;
242
+ let d = t.padding.left * o, u = i.canvas.width - t.padding.right * o, r = i.canvas.height - t.padding.bottom * o, m = t.padding.top * o;
215
243
  for (const h of t.scales) {
216
244
  if (!h.axis) {
217
245
  l.push({ ...h, axis: null });
218
246
  continue;
219
247
  }
220
- let i;
248
+ let c;
221
249
  if (h.origin === "x")
222
250
  switch (h.axis.position) {
223
251
  case "bottom":
224
- r -= h.axis.size * o, i = {
252
+ r -= h.axis.size * o, c = {
225
253
  x: n.x,
226
254
  y: r / o,
227
255
  width: n.width,
@@ -229,9 +257,9 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
229
257
  };
230
258
  break;
231
259
  case "top":
232
- p += h.axis.size * o, i = {
260
+ m += h.axis.size * o, c = {
233
261
  x: n.x,
234
- y: p / o - h.axis.size,
262
+ y: m / o - h.axis.size,
235
263
  width: n.width,
236
264
  height: h.axis.size
237
265
  };
@@ -243,7 +271,7 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
243
271
  else
244
272
  switch (h.axis.position) {
245
273
  case "left":
246
- d += h.axis.size * o, i = {
274
+ d += h.axis.size * o, c = {
247
275
  x: d / o - h.axis.size,
248
276
  y: n.y,
249
277
  width: h.axis.size,
@@ -251,7 +279,7 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
251
279
  };
252
280
  break;
253
281
  case "right":
254
- u -= h.axis.size * o, i = {
282
+ u -= h.axis.size * o, c = {
255
283
  x: u / o,
256
284
  y: n.y,
257
285
  width: h.axis.size,
@@ -262,57 +290,57 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
262
290
  case "bottom":
263
291
  throw new Error("Invalid axis position for y origin");
264
292
  }
265
- const m = {
266
- x: i.x * o,
267
- y: i.y * o,
268
- width: i.width * o,
269
- height: i.height * o
293
+ const p = {
294
+ x: c.x * o,
295
+ y: c.y * o,
296
+ width: c.width * o,
297
+ height: c.height * o
270
298
  };
271
299
  l.push({
272
300
  ...h,
273
301
  axis: {
274
302
  ...h.axis,
275
- cssRect: i,
276
- canvasRect: m
303
+ cssRect: c,
304
+ canvasRect: p
277
305
  }
278
306
  });
279
307
  }
280
308
  return {
281
- ctx: c,
309
+ ctx: i,
282
310
  dpr: o,
283
311
  padding: t.padding,
284
312
  scales: l,
285
313
  chartAreaCSS: n,
286
314
  chartAreaCanvasPX: a
287
315
  };
288
- }, $t = (t) => {
289
- t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height), Dt(t);
290
- }, de = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (z(
316
+ }, Nt = (t) => {
317
+ t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height), Xt(t);
318
+ }, pe = ({ data: t, xScaleId: s, yScaleId: e, style: i }) => (z(
291
319
  ({ getCtx: o, clampXPosToChartArea: n, clampYPosToChartArea: a, valToPos: l }) => {
292
320
  const d = o();
293
- d.save(), d.beginPath(), R(d, c);
321
+ d.save(), d.beginPath(), _(d, i);
294
322
  for (const u of t) {
295
- const r = n(l(u.x, s)), p = a(l(u.y, e));
296
- d.lineTo(r, p);
323
+ const r = n(l(u.x, s)), m = a(l(u.y, e));
324
+ d.lineTo(r, m);
297
325
  }
298
326
  d.stroke(), d.restore();
299
327
  },
300
- [t, s, e, c]
301
- ), null), he = ({ data: t, xScaleId: s, yScaleId: e, radius: c = 5, style: o }) => (z(({ getCtx: n, valToPos: a, valFits: l }) => {
328
+ [t, s, e, i]
329
+ ), null), ye = ({ data: t, xScaleId: s, yScaleId: e, radius: i = 5, style: o }) => (z(({ getCtx: n, valToPos: a, valFits: l }) => {
302
330
  const d = n();
303
- d.save(), d.beginPath(), R(d, o);
331
+ d.save(), d.beginPath(), _(d, o);
304
332
  for (const u of t) {
305
333
  if (!l(u.x, s) || !l(u.y, e))
306
334
  continue;
307
- const r = a(u.x, s), p = a(u.y, e);
308
- d.moveTo(r + c, p), d.arc(r, p, c, 0, Math.PI * 2);
335
+ const r = a(u.x, s), m = a(u.y, e);
336
+ d.moveTo(r + i, m), d.arc(r, m, i, 0, Math.PI * 2);
309
337
  }
310
338
  d.stroke(), d.fill(), d.restore();
311
- }, [t, s, e, c, o]), null), fe = ({
339
+ }, [t, s, e, i, o]), null), xe = ({
312
340
  data: t,
313
341
  xScaleId: s,
314
342
  yScaleId: e,
315
- style: c,
343
+ style: i,
316
344
  barWidth: o,
317
345
  xPositionOffset: n,
318
346
  radius: a
@@ -322,66 +350,66 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
322
350
  valToPxDistance: d,
323
351
  valToPos: u,
324
352
  clampXPosToChartArea: r,
325
- clampYPosToChartArea: p
353
+ clampYPosToChartArea: m
326
354
  }) => {
327
355
  if (t.length === 0) return;
328
356
  const f = l();
329
- f.save(), R(f, c);
357
+ f.save(), _(f, i);
330
358
  const h = d(o, s);
331
359
  f.beginPath();
332
- for (const i of t) {
333
- const y = u(i.x, s) - h / 2 + n * h, x = p(u(0, e)), v = p(u(i.y, e)), g = x - v, S = r(y), C = r(y + h) - S;
360
+ for (const c of t) {
361
+ const y = u(c.x, s) - h / 2 + n * h, x = m(u(0, e)), v = m(u(c.y, e)), S = x - v, g = r(y), C = r(y + h) - g;
334
362
  a ? f.roundRect(
335
- S,
363
+ g,
336
364
  v,
337
365
  C,
338
- g,
366
+ S,
339
367
  a
340
- ) : f.rect(S, v, C, g);
368
+ ) : f.rect(g, v, C, S);
341
369
  }
342
- f.closePath(), f.fill(), c?.strokeStyle && f.stroke(), f.restore();
370
+ f.closePath(), f.fill(), i?.strokeStyle && f.stroke(), f.restore();
343
371
  },
344
- [t, s, e, c, o, n, a]
345
- ), null), me = ({ data: t, xScaleId: s, yScaleId: e, style: c }) => (z(({ getCtx: o, clampXPosToChartArea: n, clampYPosToChartArea: a, valToPos: l }) => {
372
+ [t, s, e, i, o, n, a]
373
+ ), null), Se = ({ data: t, xScaleId: s, yScaleId: e, style: i }) => (z(({ getCtx: o, clampXPosToChartArea: n, clampYPosToChartArea: a, valToPos: l }) => {
346
374
  const d = [];
347
375
  for (const r of t) {
348
- const p = n(l(r.x, s)), f = a(l(r.y[0], e)), h = a(l(r.y[1], e));
349
- d.push({ x: p, y: f }), d.unshift({ x: p, y: h });
376
+ const m = n(l(r.x, s)), f = a(l(r.y[0], e)), h = a(l(r.y[1], e));
377
+ d.push({ x: m, y: f }), d.unshift({ x: m, y: h });
350
378
  }
351
379
  const u = o();
352
380
  if (d.length > 0) {
353
- u.save(), u.beginPath(), R(u, c), u.moveTo(d[0].x, d[0].y);
381
+ u.save(), u.beginPath(), _(u, i), u.moveTo(d[0].x, d[0].y);
354
382
  for (const r of d)
355
383
  u.lineTo(r.x, r.y);
356
384
  u.closePath(), u.fill(), u.restore();
357
385
  }
358
- }, [t, s, e, c]), null), pe = ({ data: t, stroked: s, xScaleId: e, yScaleId: c, style: o }) => (z(
386
+ }, [t, s, e, i]), null), ge = ({ data: t, stroked: s, xScaleId: e, yScaleId: i, style: o }) => (z(
359
387
  ({ getCtx: n, clampXPosToChartArea: a, clampYPosToChartArea: l, valToPos: d }) => {
360
388
  const u = [], r = n();
361
- for (const i of t) {
362
- const m = a(d(i.x, e)), y = l(d(i.y, c));
363
- u.push({ x: m, y });
389
+ for (const c of t) {
390
+ const p = a(d(c.x, e)), y = l(d(c.y, i));
391
+ u.push({ x: p, y });
364
392
  }
365
- const p = u.at(0), f = u.at(-1);
366
- if (!p || !f)
393
+ const m = u.at(0), f = u.at(-1);
394
+ if (!m || !f)
367
395
  return;
368
- const h = l(d(0, c));
369
- r.save(), r.beginPath(), R(r, o), r.moveTo(p.x, h);
370
- for (const i of u)
371
- r.lineTo(i.x, i.y);
396
+ const h = l(d(0, i));
397
+ r.save(), r.beginPath(), _(r, o), r.moveTo(m.x, h);
398
+ for (const c of u)
399
+ r.lineTo(c.x, c.y);
372
400
  if (r.lineTo(f.x, h), r.closePath(), r.fill(), s) {
373
- r.beginPath(), r.moveTo(p.x, p.y);
374
- for (const i of u)
375
- r.lineTo(i.x, i.y);
401
+ r.beginPath(), r.moveTo(m.x, m.y);
402
+ for (const c of u)
403
+ r.lineTo(c.x, c.y);
376
404
  r.stroke();
377
405
  }
378
406
  r.restore();
379
407
  },
380
- [t, s, e, c, o]
381
- ), null), ye = (t, s) => ft(
408
+ [t, s, e, i, o]
409
+ ), null), ve = (t, s) => ft(
382
410
  ({
383
411
  clampXPosToChartArea: e,
384
- clampYPosToChartArea: c,
412
+ clampYPosToChartArea: i,
385
413
  getScale: o,
386
414
  valToPos: n,
387
415
  valFits: a
@@ -399,59 +427,59 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
399
427
  }
400
428
  case "clamp": {
401
429
  const r = n(u.value, u.scaleId, s);
402
- l[d] = o(u.scaleId)?.origin === "x" ? e(r, s) : c(r, s);
430
+ l[d] = o(u.scaleId)?.origin === "x" ? e(r, s) : i(r, s);
403
431
  break;
404
432
  }
405
433
  }
406
434
  }
407
435
  return l;
408
436
  }
409
- ), xe = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: c, tickSize: o, ticks: n }) => (z(
437
+ ), we = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: i, tickSize: o, ticks: n }) => (z(
410
438
  ({ getCtx: a, valToPos: l, getScale: d, getFrame: u }) => {
411
- const r = a(), p = d(t);
412
- if (!p || !p.axis || p.origin !== "x") return;
413
- const f = p.axis, h = f.position === "top" ? f.canvasRect.y + f.canvasRect.height : f.canvasRect.y, i = window.devicePixelRatio || 1, m = h, y = (o ?? 6) * i, x = f.position === "top" ? h - y : h + y, v = (c ?? 12) * i;
414
- r.save(), r.fontKerning = "auto", R(r, {
439
+ const r = a(), m = d(t);
440
+ if (!m || !m.axis || m.origin !== "x") return;
441
+ const f = m.axis, h = f.position === "top" ? f.canvasRect.y + f.canvasRect.height : f.canvasRect.y, c = window.devicePixelRatio || 1, p = h, y = (o ?? 6) * c, x = f.position === "top" ? h - y : h + y, v = (i ?? 12) * c;
442
+ r.save(), r.fontKerning = "auto", _(r, {
415
443
  ...s
416
444
  }), r.beginPath();
417
- const g = Array.isArray(n) ? n : n({ ...p, axis: f }, u());
418
- for (const { value: S } of g) {
419
- const C = l(S, t, "canvas");
420
- r.moveTo(C, m), r.lineTo(C, x);
445
+ const S = Array.isArray(n) ? n : n({ ...m, axis: f }, u());
446
+ for (const { value: g } of S) {
447
+ const C = l(g, t, "canvas");
448
+ r.moveTo(C, p), r.lineTo(C, x);
421
449
  }
422
- r.stroke(), r.restore(), r.save(), R(r, {
450
+ r.stroke(), r.restore(), r.save(), _(r, {
423
451
  textBaseline: f.position === "top" ? "bottom" : "top",
424
452
  textAlign: "center",
425
453
  ...s,
426
454
  ...e
427
455
  });
428
- for (const { value: S, label: C } of g) {
429
- const w = l(S, t, "canvas"), b = C.split(`
456
+ for (const { value: g, label: C } of S) {
457
+ const w = l(g, t, "canvas"), b = C.split(`
430
458
  `);
431
459
  for (let k = 0; k < b.length; k++)
432
- r.fillText(b[k], w, x + i * 2 + k * v);
460
+ r.fillText(b[k], w, x + c * 2 + k * v);
433
461
  }
434
462
  r.restore();
435
463
  },
436
464
  [n, t, s, e]
437
- ), null), ge = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: c, tickSize: o, ticks: n }) => (z(
465
+ ), null), be = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: i, tickSize: o, ticks: n }) => (z(
438
466
  ({ getCtx: a, valToPos: l, getScale: d, getFrame: u }) => {
439
- const r = a(), p = d(t);
440
- if (!p || !p.axis || p.origin !== "y") return;
441
- const f = p.axis, h = f.position === "left" ? f.canvasRect.x + f.canvasRect.width : f.canvasRect.x, i = h, m = o ?? 6, y = f.position === "left" ? h - m : h + m, x = c ?? 12, v = Array.isArray(n) ? n : n({ ...p, axis: f }, u());
442
- r.save(), r.fontKerning = "auto", R(r, { ...s }), r.beginPath();
443
- for (const { value: g } of v) {
444
- const S = l(g, t, "canvas");
445
- r.moveTo(i, S), r.lineTo(y, S);
467
+ const r = a(), m = d(t);
468
+ if (!m || !m.axis || m.origin !== "y") return;
469
+ const f = m.axis, h = f.position === "left" ? f.canvasRect.x + f.canvasRect.width : f.canvasRect.x, c = h, p = o ?? 6, y = f.position === "left" ? h - p : h + p, x = i ?? 12, v = Array.isArray(n) ? n : n({ ...m, axis: f }, u());
470
+ r.save(), r.fontKerning = "auto", _(r, { ...s }), r.beginPath();
471
+ for (const { value: S } of v) {
472
+ const g = l(S, t, "canvas");
473
+ r.moveTo(c, g), r.lineTo(y, g);
446
474
  }
447
- r.stroke(), r.restore(), r.save(), R(r, {
475
+ r.stroke(), r.restore(), r.save(), _(r, {
448
476
  textBaseline: "middle",
449
477
  textAlign: f.position === "left" ? "right" : "left",
450
478
  ...s,
451
479
  ...e
452
480
  });
453
- for (const { value: g, label: S } of v) {
454
- const C = l(g, t, "canvas"), w = S.split(`
481
+ for (const { value: S, label: g } of v) {
482
+ const C = l(S, t, "canvas"), w = g.split(`
455
483
  `);
456
484
  for (let b = 0; b < w.length; b++)
457
485
  r.fillText(` ${w[b]} `, y, C + b * x);
@@ -466,12 +494,12 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
466
494
  syncKey: s,
467
495
  callback: e
468
496
  }), () => {
469
- const c = t.findIndex((o) => o.callback === e);
470
- c !== -1 && t.splice(c, 1);
497
+ const i = t.findIndex((o) => o.callback === e);
498
+ i !== -1 && t.splice(i, 1);
471
499
  }),
472
500
  dispatchEvent: (s, e) => {
473
- for (const c of t)
474
- c.syncKey === s && c.callback(s, e);
501
+ for (const i of t)
502
+ i.syncKey === s && i.callback(s, e);
475
503
  }
476
504
  };
477
505
  }, T = {
@@ -490,37 +518,37 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
490
518
  sync_mouseup: E(),
491
519
  sync_spanselect: E(),
492
520
  sync_pressandwheel: E()
493
- }, P = (t, s, e) => {
494
- const c = Z.useRef(e);
495
- c.current = e, Z.useEffect(() => T[t].addEventListener(
521
+ }, M = (t, s, e) => {
522
+ const i = Z.useRef(e);
523
+ i.current = e, Z.useEffect(() => T[t].addEventListener(
496
524
  s,
497
525
  (n, a) => {
498
- c.current(a, n);
526
+ i.current(a, n);
499
527
  }
500
- ), [s, t, c]);
528
+ ), [s, t, i]);
501
529
  }, mt = Z.createContext(""), pt = (t, s) => {
502
530
  const e = Z.useContext(mt);
503
- return P(t, e, s);
504
- }, Bt = (t, s, e, c, o) => {
531
+ return M(t, e, s);
532
+ }, Vt = (t, s, e, i, o) => {
505
533
  if (!s) return;
506
- const n = c ?? e.scales.find((p) => p.origin === "x")?.id, a = o ?? e.scales.find((p) => p.origin === "y")?.id;
534
+ const n = i ?? e.scales.find((m) => m.origin === "x")?.id, a = o ?? e.scales.find((m) => m.origin === "y")?.id;
507
535
  if (!n || !a)
508
536
  return;
509
537
  const l = t.clientX - s.left, d = {
510
538
  scaleId: n,
511
- value: D(e, l, n, "css")
539
+ value: X(e, l, n, "css")
512
540
  }, u = t.clientY - s.top, r = {
513
541
  scaleId: a,
514
- value: D(e, u, a, "css")
542
+ value: X(e, u, a, "css")
515
543
  };
516
544
  return { pointerSyncPosition: { x: d, y: r }, cssX: l, cssY: u };
517
545
  }, Y = (t, s) => {
518
- const e = t.x ? j(
546
+ const e = t.x ? H(
519
547
  s,
520
548
  t.x.value,
521
549
  t.x.scaleId,
522
550
  "css"
523
- ) : 0, c = t.y ? j(
551
+ ) : 0, i = t.y ? H(
524
552
  s,
525
553
  t.y.value,
526
554
  t.y.scaleId,
@@ -528,15 +556,15 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
528
556
  ) : 0;
529
557
  return {
530
558
  cssX: e,
531
- cssY: c,
559
+ cssY: i,
532
560
  scaled: Object.fromEntries(
533
561
  s.scales.map((o) => {
534
- const n = o.origin === "y" ? c : e;
535
- return [o.id, D(s, n, o.id, "css")];
562
+ const n = o.origin === "y" ? i : e;
563
+ return [o.id, X(s, n, o.id, "css")];
536
564
  })
537
565
  )
538
566
  };
539
- }, gt = (t, s, e) => {
567
+ }, St = (t, s, e) => {
540
568
  if (!s) {
541
569
  const a = t === "x" ? e.chartAreaCSS.x : e.chartAreaCSS.y, l = t === "x" ? e.chartAreaCSS.x + e.chartAreaCSS.width : e.chartAreaCSS.y + e.chartAreaCSS.height;
542
570
  return {
@@ -545,17 +573,17 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
545
573
  scaled: e.scales.flatMap((d) => {
546
574
  if (d.origin !== t)
547
575
  return [];
548
- const { min: u, max: r } = A(e, d.id);
576
+ const { min: u, max: r } = R(e, d.id);
549
577
  return [{ scaleId: d.id, from: u, to: r }];
550
578
  })
551
579
  };
552
580
  }
553
- const c = j(
581
+ const i = H(
554
582
  e,
555
583
  s.from,
556
584
  s.scaleId,
557
585
  "css"
558
- ), o = j(
586
+ ), o = H(
559
587
  e,
560
588
  s.to,
561
589
  s.scaleId,
@@ -564,7 +592,7 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
564
592
  (a) => {
565
593
  if (a.origin !== t)
566
594
  return [];
567
- const l = D(e, c, a.id, "css"), d = D(e, o, a.id, "css");
595
+ const l = X(e, i, a.id, "css"), d = X(e, o, a.id, "css");
568
596
  return [
569
597
  {
570
598
  scaleId: a.id,
@@ -575,15 +603,15 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
575
603
  }
576
604
  );
577
605
  return {
578
- fromCSS: c,
606
+ fromCSS: i,
579
607
  toCSS: o,
580
608
  scaled: n
581
609
  };
582
- }, Se = ({
610
+ }, Ce = ({
583
611
  id: t,
584
612
  onClick: s,
585
613
  onDblClick: e,
586
- onMouseMove: c,
614
+ onMouseMove: i,
587
615
  onMouseDown: o,
588
616
  onMouseUp: n,
589
617
  onDocumentMouseUp: a,
@@ -591,150 +619,150 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
591
619
  className: d,
592
620
  style: u,
593
621
  sync: r,
594
- children: p
622
+ children: m
595
623
  }) => {
596
- const f = Rt(), h = t || f;
597
- return P("dblclick", h, (i) => {
598
- e?.(i);
599
- }), P("click", h, (i) => {
600
- s?.(i);
601
- }), P("move", h, (i) => {
602
- c?.(i);
603
- }), P("mousedown", h, (i) => {
604
- o?.(i);
605
- }), P("mouseup", h, (i) => {
606
- n?.(i);
607
- }), P("documentmouseup", h, (i) => {
608
- a?.(i);
609
- }), P("spanselect", h, (i) => {
610
- l?.(i);
611
- }), /* @__PURE__ */ at(mt.Provider, { value: h, children: [
612
- /* @__PURE__ */ X(
613
- Nt,
624
+ const f = Lt(), h = t || f;
625
+ return M("dblclick", h, (c) => {
626
+ e?.(c);
627
+ }), M("click", h, (c) => {
628
+ s?.(c);
629
+ }), M("move", h, (c) => {
630
+ i?.(c);
631
+ }), M("mousedown", h, (c) => {
632
+ o?.(c);
633
+ }), M("mouseup", h, (c) => {
634
+ n?.(c);
635
+ }), M("documentmouseup", h, (c) => {
636
+ a?.(c);
637
+ }), M("spanselect", h, (c) => {
638
+ l?.(c);
639
+ }), /* @__PURE__ */ ut(mt.Provider, { value: h, children: [
640
+ /* @__PURE__ */ A(
641
+ jt,
614
642
  {
615
643
  className: d,
616
644
  style: u,
617
645
  sync: r
618
646
  }
619
647
  ),
620
- p
648
+ m
621
649
  ] });
622
- }, Nt = ({ className: t, style: s, sync: e }) => {
623
- const c = L(null), o = ft(), n = L(o);
650
+ }, jt = ({ className: t, style: s, sync: e }) => {
651
+ const i = D(null), o = ft(), n = D(o);
624
652
  n.current = o;
625
- const a = lt(mt), l = e?.key || a, d = L(null), u = L(null), r = L(null), p = () => {
626
- const i = c.current?.parentElement;
627
- if (i) {
628
- if (i.dataset.canplotroot === void 0)
653
+ const a = J(mt), l = e?.key || a, d = D(null), u = D(null), r = D(null), m = () => {
654
+ const c = i.current?.parentElement;
655
+ if (c) {
656
+ if (c.dataset.canplotroot === void 0)
629
657
  throw new Error(
630
658
  "ChartAreaInteractions must be used within a CanPlot component"
631
659
  );
632
- return i.getBoundingClientRect();
660
+ return c.getBoundingClientRect();
633
661
  }
634
- }, f = (i, m) => {
635
- const y = Bt(
636
- i,
637
- p(),
662
+ }, f = (c, p) => {
663
+ const y = Vt(
664
+ c,
665
+ m(),
638
666
  n.current,
639
667
  e?.xViaScaleId,
640
668
  e?.yViaScaleId
641
669
  );
642
- y && m(
670
+ y && p(
643
671
  y.pointerSyncPosition,
644
672
  { cssX: y.cssX, cssY: y.cssY },
645
673
  {
646
- ctrlKey: i.ctrlKey,
647
- altKey: i.altKey,
648
- shiftKey: i.shiftKey,
649
- metaKey: i.metaKey
674
+ ctrlKey: c.ctrlKey,
675
+ altKey: c.altKey,
676
+ shiftKey: c.shiftKey,
677
+ metaKey: c.metaKey
650
678
  }
651
679
  );
652
- }, h = L(f);
653
- return h.current = f, _t(() => {
654
- const i = (g) => {
655
- const S = u.current;
656
- S && T.sync_spanselect.dispatchEvent(l, {
657
- ...S,
680
+ }, h = D(f);
681
+ return h.current = f, wt(() => {
682
+ const c = (S) => {
683
+ const g = u.current;
684
+ g && T.sync_spanselect.dispatchEvent(l, {
685
+ ...g,
658
686
  completed: !0
659
687
  }), T.documentmouseup.dispatchEvent(l, {
660
688
  frame: n.current,
661
689
  keys: {
662
- ctrlKey: g.ctrlKey,
663
- altKey: g.altKey,
664
- shiftKey: g.shiftKey,
665
- metaKey: g.metaKey
690
+ ctrlKey: S.ctrlKey,
691
+ altKey: S.altKey,
692
+ shiftKey: S.shiftKey,
693
+ metaKey: S.metaKey
666
694
  }
667
695
  });
668
- }, m = (g) => {
669
- const S = {
670
- ctrlKey: g.ctrlKey,
671
- altKey: g.altKey,
672
- shiftKey: g.shiftKey,
673
- metaKey: g.metaKey
696
+ }, p = (S) => {
697
+ const g = {
698
+ ctrlKey: S.ctrlKey,
699
+ altKey: S.altKey,
700
+ shiftKey: S.shiftKey,
701
+ metaKey: S.metaKey
674
702
  }, C = r.current;
675
- if (C && Object.entries(S).some(
703
+ if (C && Object.entries(g).some(
676
704
  ([b, k]) => C.keys[b] !== k
677
705
  )) {
678
- const b = { ...C, keys: S };
706
+ const b = { ...C, keys: g };
679
707
  r.current = b, T.sync_move.dispatchEvent(l, b);
680
708
  }
681
709
  const w = u.current;
682
- if (w && Object.entries(S).some(
710
+ if (w && Object.entries(g).some(
683
711
  ([b, k]) => w.keys[b] !== k
684
712
  )) {
685
- g.stopPropagation(), g.preventDefault();
686
- const b = { ...w, keys: S };
713
+ S.stopPropagation(), S.preventDefault();
714
+ const b = { ...w, keys: g };
687
715
  u.current = b, T.sync_spanselect.dispatchEvent(
688
716
  l,
689
717
  b
690
718
  );
691
719
  }
692
- }, y = (g) => {
720
+ }, y = (S) => {
693
721
  h.current(
694
- g,
695
- (S, { cssX: C, cssY: w }, b) => {
722
+ S,
723
+ (g, { cssX: C, cssY: w }, b) => {
696
724
  const k = d.current;
697
- if (!k || !S.x || !S.y) return;
698
- const _ = n.current, M = k.xRangeCss.start, B = C, F = k.yRangeCss.start, et = w, st = A(_, S.x.scaleId), nt = A(_, S.y.scaleId);
725
+ if (!k || !g.x || !g.y) return;
726
+ const U = n.current, P = k.xRangeCss.start, B = C, F = k.yRangeCss.start, nt = w, ot = R(U, g.x.scaleId), it = R(U, g.y.scaleId);
699
727
  d.current = {
700
- xRangeCss: { start: M, end: B },
701
- yRangeCss: { start: F, end: et }
728
+ xRangeCss: { start: P, end: B },
729
+ yRangeCss: { start: F, end: nt }
702
730
  };
703
- let U = "none";
704
- const ot = Math.abs(F - et), ct = Math.abs(M - B);
705
- ot < 10 && ct < 10 ? U = "none" : ot > 30 && ct > 30 ? U = "box" : ot > ct ? U = "y" : U = "x";
706
- const Tt = U === "x" || U === "box" ? {
707
- scaleId: st.id,
708
- from: D(
709
- _,
710
- O(n.current, M, "css"),
711
- st.id,
731
+ let L = "none";
732
+ const ct = Math.abs(F - nt), rt = Math.abs(P - B);
733
+ ct < 10 && rt < 10 ? L = "none" : ct > 30 && rt > 30 ? L = "box" : ct > rt ? L = "y" : L = "x";
734
+ const Pt = L === "x" || L === "box" ? {
735
+ scaleId: ot.id,
736
+ from: X(
737
+ U,
738
+ O(n.current, P, "css"),
739
+ ot.id,
712
740
  "css"
713
741
  ),
714
- to: D(
715
- _,
742
+ to: X(
743
+ U,
716
744
  O(n.current, B, "css"),
717
- st.id,
745
+ ot.id,
718
746
  "css"
719
747
  )
720
- } : void 0, kt = U === "y" || U === "box" ? {
721
- scaleId: nt.id,
722
- from: D(
723
- _,
748
+ } : void 0, At = L === "y" || L === "box" ? {
749
+ scaleId: it.id,
750
+ from: X(
751
+ U,
724
752
  $(n.current, F, "css"),
725
- nt.id,
753
+ it.id,
726
754
  "css"
727
755
  ),
728
- to: D(
729
- _,
730
- $(n.current, et, "css"),
731
- nt.id,
756
+ to: X(
757
+ U,
758
+ $(n.current, nt, "css"),
759
+ it.id,
732
760
  "css"
733
761
  )
734
762
  } : void 0, xt = {
735
- mode: U,
736
- xRange: Tt,
737
- yRange: kt,
763
+ mode: L,
764
+ xRange: Pt,
765
+ yRange: At,
738
766
  completed: !1,
739
767
  keys: b
740
768
  };
@@ -744,119 +772,119 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
744
772
  );
745
773
  }
746
774
  );
747
- }, x = (g) => {
748
- h.current(g, (S, C, w) => {
775
+ }, x = (S) => {
776
+ h.current(S, (g, C, w) => {
749
777
  if (Object.values(w).some((k) => k)) {
750
- g.preventDefault();
751
- const k = Math.abs(g.deltaY) > Math.abs(g.deltaX) ? g.deltaY : g.deltaX;
778
+ S.preventDefault();
779
+ const k = Math.abs(S.deltaY) > Math.abs(S.deltaX) ? S.deltaY : S.deltaX;
752
780
  T.sync_pressandwheel.dispatchEvent(l, {
753
- positions: S,
781
+ positions: g,
754
782
  keys: w,
755
- deltaX: g.deltaX,
756
- deltaY: g.deltaY,
783
+ deltaX: S.deltaX,
784
+ deltaY: S.deltaY,
757
785
  deltaAbs: k
758
786
  });
759
787
  }
760
788
  });
761
789
  };
762
- document.addEventListener("mouseup", i), document.addEventListener("keydown", m), document.addEventListener("keyup", m), document.addEventListener("mousemove", y);
763
- const v = c.current;
790
+ document.addEventListener("mouseup", c), document.addEventListener("keydown", p), document.addEventListener("keyup", p), document.addEventListener("mousemove", y);
791
+ const v = i.current;
764
792
  return v?.addEventListener("wheel", x, {
765
793
  passive: !1
766
794
  }), () => {
767
- document.removeEventListener("mouseup", i), document.removeEventListener("keydown", m), document.removeEventListener("keyup", m), document.removeEventListener("mousemove", y), v?.removeEventListener("wheel", x);
795
+ document.removeEventListener("mouseup", c), document.removeEventListener("keydown", p), document.removeEventListener("keyup", p), document.removeEventListener("mousemove", y), v?.removeEventListener("wheel", x);
768
796
  };
769
- }, [n, l, h]), P("sync_dblclick", l, (i) => {
770
- const m = Y(
771
- i.positions,
797
+ }, [n, l, h]), M("sync_dblclick", l, (c) => {
798
+ const p = Y(
799
+ c.positions,
772
800
  n.current
773
801
  );
774
- m && T.dblclick.dispatchEvent(a, {
802
+ p && T.dblclick.dispatchEvent(a, {
775
803
  frame: n.current,
776
- pointer: m,
777
- keys: i.keys
804
+ pointer: p,
805
+ keys: c.keys
778
806
  });
779
- }), P("sync_click", l, (i) => {
780
- const m = Y(
781
- i.positions,
807
+ }), M("sync_click", l, (c) => {
808
+ const p = Y(
809
+ c.positions,
782
810
  n.current
783
811
  );
784
- m && T.click.dispatchEvent(a, {
812
+ p && T.click.dispatchEvent(a, {
785
813
  frame: n.current,
786
- pointer: m,
787
- keys: i.keys
814
+ pointer: p,
815
+ keys: c.keys
788
816
  });
789
- }), P("sync_move", l, (i) => {
790
- const m = i.positions ? Y(
791
- i.positions,
817
+ }), M("sync_move", l, (c) => {
818
+ const p = c.positions ? Y(
819
+ c.positions,
792
820
  n.current
793
821
  ) : null;
794
- r.current = i, T.move.dispatchEvent(a, {
822
+ r.current = c, T.move.dispatchEvent(a, {
795
823
  frame: n.current,
796
- pointer: m ?? null,
797
- keys: i.keys
824
+ pointer: p ?? null,
825
+ keys: c.keys
798
826
  });
799
- }), P("sync_mousedown", l, (i) => {
800
- const m = Y(
801
- i.positions,
827
+ }), M("sync_mousedown", l, (c) => {
828
+ const p = Y(
829
+ c.positions,
802
830
  n.current
803
831
  );
804
- m && T.mousedown.dispatchEvent(a, {
832
+ p && T.mousedown.dispatchEvent(a, {
805
833
  frame: n.current,
806
- pointer: m,
807
- keys: i.keys
834
+ pointer: p,
835
+ keys: c.keys
808
836
  });
809
- }), P("sync_mouseup", l, (i) => {
810
- const m = Y(
811
- i.positions,
837
+ }), M("sync_mouseup", l, (c) => {
838
+ const p = Y(
839
+ c.positions,
812
840
  n.current
813
841
  );
814
- m && T.mouseup.dispatchEvent(a, {
842
+ p && T.mouseup.dispatchEvent(a, {
815
843
  frame: n.current,
816
- pointer: m,
817
- keys: i.keys
844
+ pointer: p,
845
+ keys: c.keys
818
846
  });
819
- }), P(
847
+ }), M(
820
848
  "sync_pressandwheel",
821
849
  l,
822
- (i) => {
823
- const m = Y(
824
- i.positions,
850
+ (c) => {
851
+ const p = Y(
852
+ c.positions,
825
853
  n.current
826
854
  );
827
- m && T.pressandwheel.dispatchEvent(a, {
855
+ p && T.pressandwheel.dispatchEvent(a, {
828
856
  frame: n.current,
829
- pointer: m,
830
- keys: i.keys,
831
- deltaX: i.deltaX,
832
- deltaY: i.deltaY,
833
- deltaAbs: i.deltaAbs
857
+ pointer: p,
858
+ keys: c.keys,
859
+ deltaX: c.deltaX,
860
+ deltaY: c.deltaY,
861
+ deltaAbs: c.deltaAbs
834
862
  });
835
863
  }
836
- ), P("sync_spanselect", l, (i) => {
837
- const m = gt(
864
+ ), M("sync_spanselect", l, (c) => {
865
+ const p = St(
838
866
  "x",
839
- i.xRange,
867
+ c.xRange,
840
868
  n.current
841
- ), y = gt(
869
+ ), y = St(
842
870
  "y",
843
- i.yRange,
871
+ c.yRange,
844
872
  n.current
845
- ), x = m.scaled, v = y.scaled;
846
- i.completed && (d.current = null), T.spanselect.dispatchEvent(a, {
847
- mode: i.mode,
873
+ ), x = p.scaled, v = y.scaled;
874
+ c.completed && (d.current = null), T.spanselect.dispatchEvent(a, {
875
+ mode: c.mode,
848
876
  frame: n.current,
849
877
  xRanges: x,
850
878
  yRanges: v,
851
- completed: i.completed,
852
- x: { fromCSS: m.fromCSS, toCSS: m.toCSS },
879
+ completed: c.completed,
880
+ x: { fromCSS: p.fromCSS, toCSS: p.toCSS },
853
881
  y: { fromCSS: y.fromCSS, toCSS: y.toCSS },
854
- keys: i.keys
882
+ keys: c.keys
855
883
  });
856
- }), /* @__PURE__ */ X(
884
+ }), /* @__PURE__ */ A(
857
885
  "div",
858
886
  {
859
- ref: c,
887
+ ref: i,
860
888
  id: "interactions",
861
889
  className: t,
862
890
  style: {
@@ -868,34 +896,37 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
868
896
  zIndex: 25,
869
897
  ...s
870
898
  },
871
- onClick: (i) => {
872
- f(i, (m, y, x) => {
899
+ onDragStart: (c) => {
900
+ c.preventDefault();
901
+ },
902
+ onClick: (c) => {
903
+ f(c, (p, y, x) => {
873
904
  T.sync_click.dispatchEvent(l, {
874
- positions: m,
905
+ positions: p,
875
906
  keys: x
876
907
  });
877
908
  });
878
909
  },
879
- onMouseLeave: (i) => {
880
- f(i, (m, y, x) => {
910
+ onMouseLeave: (c) => {
911
+ f(c, (p, y, x) => {
881
912
  T.sync_move.dispatchEvent(l, {
882
913
  positions: null,
883
914
  keys: x
884
915
  });
885
916
  });
886
917
  },
887
- onMouseMove: (i) => {
888
- f(i, (m, y, x) => {
918
+ onMouseMove: (c) => {
919
+ f(c, (p, y, x) => {
889
920
  T.sync_move.dispatchEvent(l, {
890
- positions: m,
921
+ positions: p,
891
922
  keys: x
892
923
  });
893
924
  });
894
925
  },
895
- onMouseDown: (i) => {
896
- f(i, (m, { cssX: y, cssY: x }, v) => {
926
+ onMouseDown: (c) => {
927
+ f(c, (p, { cssX: y, cssY: x }, v) => {
897
928
  T.sync_mousedown.dispatchEvent(l, {
898
- positions: m,
929
+ positions: p,
899
930
  keys: v
900
931
  }), u.current = null, d.current = {
901
932
  xRangeCss: { start: y, end: y },
@@ -903,67 +934,67 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
903
934
  };
904
935
  });
905
936
  },
906
- onMouseUp: (i) => {
907
- f(i, (m, y, x) => {
937
+ onMouseUp: (c) => {
938
+ f(c, (p, y, x) => {
908
939
  T.sync_mouseup.dispatchEvent(l, {
909
- positions: m,
940
+ positions: p,
910
941
  keys: x
911
942
  });
912
943
  const v = u.current;
913
944
  u.current = null;
914
- const g = d.current;
915
- if (d.current = null, g && v) {
916
- const S = {
945
+ const S = d.current;
946
+ if (d.current = null, S && v) {
947
+ const g = {
917
948
  ...v,
918
949
  keys: x,
919
950
  completed: !0
920
951
  };
921
952
  T.sync_spanselect.dispatchEvent(
922
953
  l,
923
- S
954
+ g
924
955
  );
925
956
  }
926
957
  });
927
958
  },
928
- onDoubleClick: (i) => {
929
- f(i, (m, y, x) => {
959
+ onDoubleClick: (c) => {
960
+ f(c, (p, y, x) => {
930
961
  T.sync_dblclick.dispatchEvent(l, {
931
- positions: m,
962
+ positions: p,
932
963
  keys: x
933
964
  });
934
965
  });
935
966
  }
936
967
  }
937
968
  );
938
- }, ve = ({ data: t, renderTooltip: s, xScaleId: e }) => {
939
- const [c, o] = N(null);
969
+ }, Te = ({ data: t, renderTooltip: s, xScaleId: e }) => {
970
+ const [i, o] = V(null);
940
971
  pt("move", (a) => {
941
972
  o(a);
942
973
  });
943
- const n = ut(() => {
944
- if (!c)
974
+ const n = Q(() => {
975
+ if (!i)
945
976
  return null;
946
- const { frame: a, pointer: l } = c, d = l?.scaled[e];
977
+ const { frame: a, pointer: l } = i, d = l?.scaled[e];
947
978
  if (d === void 0)
948
979
  return null;
949
980
  const u = [];
950
981
  let r = d;
951
- for (const p of t) {
982
+ for (const m of t) {
952
983
  let f = null, h = 1 / 0;
953
- for (const [m, y] of p.points.entries()) {
954
- if (!it(a, y.x, e) || !it(a, y.y, p.yScaleId))
984
+ for (const [p, y] of m.points.entries()) {
985
+ if (!at(a, y.x, e) || !at(a, y.y, m.yScaleId))
955
986
  continue;
956
987
  const x = Math.abs(y.x - d);
957
- x < h && (h = x, f = m);
988
+ x < h && (h = x, f = p);
958
989
  }
959
- const i = p.points[f ?? -1];
960
- if (!i || dt(a, h, e, "css") > 30) {
961
- u.push({ seriesId: p.seriesId, y: null });
990
+ const c = m.points[f ?? -1];
991
+ if (!c || dt(a, h, e, "css") > 30) {
992
+ u.push({ seriesId: m.seriesId, y: null });
962
993
  continue;
963
994
  }
964
- r = i.x, u.push({
965
- seriesId: p.seriesId,
966
- y: i.y
995
+ r = c.x, u.push({
996
+ seriesId: m.seriesId,
997
+ y: c.y
967
998
  });
968
999
  }
969
1000
  return {
@@ -971,17 +1002,17 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
971
1002
  x: r,
972
1003
  points: u
973
1004
  };
974
- }, [t, c, e]);
1005
+ }, [t, i, e]);
975
1006
  return s(n);
976
- }, we = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: c }) => {
977
- const [o, n] = N(null);
1007
+ }, ke = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: i }) => {
1008
+ const [o, n] = V(null);
978
1009
  if (pt("move", (r) => {
979
1010
  n(r);
980
1011
  }), !o)
981
1012
  return null;
982
1013
  const { frame: a, pointer: l } = o, d = O(a, l?.cssX ?? 0, "css"), u = $(a, l?.cssY ?? 0, "css");
983
- return /* @__PURE__ */ at(Et, { children: [
984
- /* @__PURE__ */ X(
1014
+ return /* @__PURE__ */ ut(Rt, { children: [
1015
+ /* @__PURE__ */ A(
985
1016
  "div",
986
1017
  {
987
1018
  "data-show": !!l,
@@ -1001,10 +1032,10 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
1001
1032
  }
1002
1033
  }
1003
1034
  ),
1004
- /* @__PURE__ */ X(
1035
+ /* @__PURE__ */ A(
1005
1036
  "div",
1006
1037
  {
1007
- className: c?.(o),
1038
+ className: i?.(o),
1008
1039
  "data-show": !!l,
1009
1040
  style: {
1010
1041
  position: "absolute",
@@ -1021,12 +1052,12 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
1021
1052
  }
1022
1053
  )
1023
1054
  ] });
1024
- }, be = ({ makeClassName: t, makeStyle: s }) => {
1025
- const [e, c] = N(null);
1055
+ }, Ee = ({ makeClassName: t, makeStyle: s }) => {
1056
+ const [e, i] = V(null);
1026
1057
  pt("spanselect", (n) => {
1027
- c(n.mode === "none" || n.completed ? null : n);
1058
+ i(n.mode === "none" || n.completed ? null : n);
1028
1059
  });
1029
- const o = ut(() => {
1060
+ const o = Q(() => {
1030
1061
  if (!e)
1031
1062
  return null;
1032
1063
  const n = O(
@@ -1045,10 +1076,10 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
1045
1076
  e.frame,
1046
1077
  e.y.toCSS,
1047
1078
  "css"
1048
- ), u = Math.min(n, a), r = Math.min(l, d), p = Math.abs(a - n), f = Math.abs(d - l);
1049
- return { leftPx: u, topPx: r, widthPx: p, heightPx: f };
1079
+ ), u = Math.min(n, a), r = Math.min(l, d), m = Math.abs(a - n), f = Math.abs(d - l);
1080
+ return { leftPx: u, topPx: r, widthPx: m, heightPx: f };
1050
1081
  }, [e]);
1051
- return /* @__PURE__ */ X(
1082
+ return /* @__PURE__ */ A(
1052
1083
  "div",
1053
1084
  {
1054
1085
  className: e ? t?.(e) : void 0,
@@ -1064,9 +1095,9 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
1064
1095
  }
1065
1096
  }
1066
1097
  );
1067
- }, Ce = ({ style: t, children: s, scaleId: e, ...c }) => {
1098
+ }, Me = ({ style: t, children: s, scaleId: e, ...i }) => {
1068
1099
  const o = ft((n) => n.getScale(e)?.axis);
1069
- return o ? /* @__PURE__ */ X(
1100
+ return o ? /* @__PURE__ */ A(
1070
1101
  "div",
1071
1102
  {
1072
1103
  style: {
@@ -1078,31 +1109,31 @@ const ue = At(({ configuration: t, children: s, style: e, className: c }, o) =>
1078
1109
  width: o.cssRect.width,
1079
1110
  ...t
1080
1111
  },
1081
- ...c,
1112
+ ...i,
1082
1113
  children: s
1083
1114
  }
1084
1115
  ) : null;
1085
- }, wt = 60, Vt = 30, bt = "UTC", jt = "en-GB", Te = ({
1116
+ }, kt = 60, Ht = 30, Et = "UTC", Wt = "en-GB", Pe = ({
1086
1117
  space: t,
1087
1118
  formatter: s
1088
- } = {}) => (e, c) => {
1089
- const { min: o, max: n } = e, a = [], l = window.devicePixelRatio || 1, d = (t ?? (e.origin === "x" ? wt : Vt)) * l, u = Lt(
1090
- c,
1119
+ } = {}) => (e, i) => {
1120
+ const { min: o, max: n } = e, a = [], l = window.devicePixelRatio || 1, d = (t ?? (e.origin === "x" ? kt : Ht)) * l, u = Dt(
1121
+ i,
1091
1122
  d,
1092
1123
  e.id,
1093
1124
  "canvas"
1094
- ), r = H.find((f) => f > u) ?? 1;
1095
- let p = o % r < Number.EPSILON ? o : o + r - o % r;
1096
- for (; p <= n; )
1097
- a.push(p), p += r;
1098
- return (s ?? Ht)(a);
1099
- }, Ht = (t) => {
1125
+ ), r = W.find((f) => f > u) ?? 1;
1126
+ let m = o % r < Number.EPSILON ? o : o + r - o % r;
1127
+ for (; m <= n; )
1128
+ a.push(m), m += r;
1129
+ return (s ?? qt)(a);
1130
+ }, qt = (t) => {
1100
1131
  const s = Math.max(0, Math.ceil(-Math.log10(t[1] - t[0])));
1101
1132
  return t.map((e) => ({ value: e, label: e.toFixed(s) }));
1102
- }, H = [];
1133
+ }, W = [];
1103
1134
  for (let t = -12; t <= 12; t++)
1104
- H.push(1 * 10 ** t), H.push(2 * 10 ** t), H.push(5 * 10 ** t);
1105
- const Wt = 1, Ct = 1e3 * Wt, yt = 60 * Ct, q = 60 * yt, tt = 24 * q, Gt = 30 * tt, Zt = 365 * tt, Jt = [
1135
+ W.push(1 * 10 ** t), W.push(2 * 10 ** t), W.push(5 * 10 ** t);
1136
+ const Gt = 1, Mt = 1e3 * Gt, yt = 60 * Mt, tt = 60 * yt, st = 24 * tt, Zt = 30 * st, Jt = 365 * st, Qt = [
1106
1137
  // second divisors
1107
1138
  [1, "milliseconds"],
1108
1139
  [2, "milliseconds"],
@@ -1154,67 +1185,67 @@ const Wt = 1, Ct = 1e3 * Wt, yt = 60 * Ct, q = 60 * yt, tt = 24 * q, Gt = 30 * t
1154
1185
  [25, "years"],
1155
1186
  [50, "years"],
1156
1187
  [100, "years"]
1157
- ], W = (t) => {
1188
+ ], q = (t) => {
1158
1189
  const [s, e] = t;
1159
1190
  switch (e) {
1160
1191
  case "milliseconds":
1161
1192
  return s;
1162
1193
  case "seconds":
1163
- return s * Ct;
1194
+ return s * Mt;
1164
1195
  case "minutes":
1165
1196
  return s * yt;
1166
1197
  case "hours":
1167
- return s * q;
1168
- case "days":
1169
1198
  return s * tt;
1199
+ case "days":
1200
+ return s * st;
1170
1201
  case "months":
1171
- return s * Gt;
1172
- case "years":
1173
1202
  return s * Zt;
1203
+ case "years":
1204
+ return s * Jt;
1174
1205
  }
1175
- }, qt = (t, s) => {
1206
+ }, te = (t, s) => {
1176
1207
  const e = new Date(t);
1177
1208
  return e.setUTCMilliseconds(e.getUTCMilliseconds() + s), e.getTime();
1178
- }, Qt = (t, s) => {
1209
+ }, ee = (t, s) => {
1179
1210
  const e = new Date(t);
1180
1211
  return e.setUTCSeconds(e.getUTCSeconds() + s), e.getTime();
1181
- }, te = (t, s) => {
1212
+ }, se = (t, s) => {
1182
1213
  const e = new Date(t);
1183
1214
  return e.setUTCMinutes(e.getUTCMinutes() + s), e.getTime();
1184
- }, ee = (t, s) => {
1215
+ }, ne = (t, s) => {
1185
1216
  const e = new Date(t);
1186
1217
  return e.setUTCHours(e.getUTCHours() + s), e.getTime();
1187
- }, se = (t, s) => {
1218
+ }, oe = (t, s) => {
1188
1219
  const e = new Date(t);
1189
1220
  return e.setUTCDate(e.getUTCDate() + s), e.getTime();
1190
- }, St = (t, s) => {
1221
+ }, gt = (t, s) => {
1191
1222
  const e = new Date(t);
1192
1223
  return e.setUTCMonth(e.getUTCMonth() + s), e.getTime();
1193
- }, I = (t, s) => {
1194
- const [e, c] = s;
1195
- switch (c) {
1224
+ }, K = (t, s) => {
1225
+ const [e, i] = s;
1226
+ switch (i) {
1196
1227
  case "milliseconds":
1197
- return qt(t, e);
1228
+ return te(t, e);
1198
1229
  case "seconds":
1199
- return Qt(t, e);
1230
+ return ee(t, e);
1200
1231
  case "minutes":
1201
- return te(t, e);
1232
+ return se(t, e);
1202
1233
  case "hours":
1203
- return ee(t, e);
1234
+ return ne(t, e);
1204
1235
  case "days":
1205
- return se(t, e);
1236
+ return oe(t, e);
1206
1237
  case "months":
1207
- return St(t, e);
1238
+ return gt(t, e);
1208
1239
  case "years":
1209
- return St(t, e * 12);
1240
+ return gt(t, e * 12);
1210
1241
  }
1211
1242
  };
1212
1243
  function G(t, s) {
1213
- const e = new Date(t), c = new Date(e.toLocaleString("en-US", { timeZone: s })), o = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
1214
- return (c.getTime() - o.getTime()) / (3600 * 1e3);
1244
+ const e = new Date(t), i = new Date(e.toLocaleString("en-US", { timeZone: s })), o = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
1245
+ return (i.getTime() - o.getTime()) / (3600 * 1e3);
1215
1246
  }
1216
- const ne = (t, s, e = "UTC") => {
1217
- const [c, o] = s;
1247
+ const ie = (t, s, e = "UTC") => {
1248
+ const [i, o] = s;
1218
1249
  let n = new Date(t);
1219
1250
  const a = () => {
1220
1251
  n.setUTCHours(-G(n, e), 0, 0, 0);
@@ -1222,25 +1253,25 @@ const ne = (t, s, e = "UTC") => {
1222
1253
  switch (o) {
1223
1254
  case "milliseconds":
1224
1255
  n.setUTCMilliseconds(
1225
- Math.ceil(n.getUTCMilliseconds() / c) * c
1256
+ Math.ceil(n.getUTCMilliseconds() / i) * i
1226
1257
  );
1227
1258
  break;
1228
1259
  case "seconds":
1229
1260
  n.setUTCSeconds(
1230
- Math.ceil(n.getUTCSeconds() / c) * c,
1261
+ Math.ceil(n.getUTCSeconds() / i) * i,
1231
1262
  0
1232
1263
  );
1233
1264
  break;
1234
1265
  case "minutes":
1235
1266
  n.setUTCMinutes(
1236
- Math.ceil(n.getTime() % q / yt / c) * c,
1267
+ Math.ceil(n.getTime() % tt / yt / i) * i,
1237
1268
  0,
1238
1269
  0
1239
1270
  );
1240
1271
  break;
1241
1272
  case "hours":
1242
1273
  n.setUTCHours(
1243
- Math.ceil(n.getTime() % tt / q / c) * c,
1274
+ Math.ceil(n.getTime() % st / tt / i) * i,
1244
1275
  0,
1245
1276
  0,
1246
1277
  0
@@ -1249,20 +1280,20 @@ const ne = (t, s, e = "UTC") => {
1249
1280
  case "days":
1250
1281
  case "months":
1251
1282
  case "years":
1252
- o === "months" ? n.setUTCDate(1) : o === "years" && n.setUTCMonth(0, 1), a(), n.getTime() < t && (n = new Date(I(n, [1, o])));
1283
+ o === "months" ? n.setUTCDate(1) : o === "years" && n.setUTCMonth(0, 1), a(), n.getTime() < t && (n = new Date(K(n, [1, o])));
1253
1284
  break;
1254
1285
  }
1255
1286
  return n.getTime();
1256
- }, ke = ({
1257
- timeZone: t = bt,
1258
- space: s = wt,
1287
+ }, Ae = ({
1288
+ timeZone: t = Et,
1289
+ space: s = kt,
1259
1290
  formatter: e,
1260
- locale: c,
1291
+ locale: i,
1261
1292
  showTimezone: o
1262
1293
  } = {}) => (n, a) => {
1263
- const { min: l, max: d } = n, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1, p = (d - l) / u, [f, h] = Jt.find(
1264
- (v) => W(v) >= p
1265
- ) ?? [1, "milliseconds"], i = ne(l, [f, h], t), m = G(i, t), y = [i];
1294
+ const { min: l, max: d } = n, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1, m = (d - l) / u, [f, h] = Qt.find(
1295
+ (v) => q(v) >= m
1296
+ ) ?? [1, "milliseconds"], c = ie(l, [f, h], t), p = G(c, t), y = [c];
1266
1297
  let x;
1267
1298
  for (; ; ) {
1268
1299
  switch (h) {
@@ -1270,31 +1301,31 @@ const ne = (t, s, e = "UTC") => {
1270
1301
  case "seconds":
1271
1302
  case "minutes":
1272
1303
  case "hours": {
1273
- x = I(i, [y.length * f, h]);
1304
+ x = K(c, [y.length * f, h]);
1274
1305
  break;
1275
1306
  }
1276
1307
  case "days": {
1277
- const v = I(i, [
1308
+ const v = K(c, [
1278
1309
  y.length * f,
1279
1310
  h
1280
1311
  ]);
1281
- x = I(v, [
1282
- m - G(v, t),
1312
+ x = K(v, [
1313
+ p - G(v, t),
1283
1314
  "hours"
1284
1315
  ]);
1285
1316
  break;
1286
1317
  }
1287
1318
  case "months":
1288
1319
  case "years": {
1289
- const v = I(
1290
- I(I(i, [m, "hours"]), [
1320
+ const v = K(
1321
+ K(K(c, [p, "hours"]), [
1291
1322
  y.length * f,
1292
1323
  h
1293
1324
  ]),
1294
- [-m, "hours"]
1325
+ [-p, "hours"]
1295
1326
  );
1296
- x = I(v, [
1297
- m - G(v, t),
1327
+ x = K(v, [
1328
+ p - G(v, t),
1298
1329
  "hours"
1299
1330
  ]);
1300
1331
  break;
@@ -1304,17 +1335,17 @@ const ne = (t, s, e = "UTC") => {
1304
1335
  break;
1305
1336
  y.push(x);
1306
1337
  }
1307
- return (e ?? oe({
1308
- locale: c,
1338
+ return (e ?? ce({
1339
+ locale: i,
1309
1340
  showTimezone: o,
1310
1341
  timeZone: t
1311
1342
  }))(y);
1312
- }, K = (t, s, e) => t.find((c) => c.type === e)?.value !== s.find((c) => c.type === e)?.value, oe = ({
1313
- timeZone: t = bt,
1314
- locale: s = jt,
1343
+ }, I = (t, s, e) => t.find((i) => i.type === e)?.value !== s.find((i) => i.type === e)?.value, ce = ({
1344
+ timeZone: t = Et,
1345
+ locale: s = Wt,
1315
1346
  showTimezone: e = !0
1316
1347
  }) => {
1317
- const c = new Intl.DateTimeFormat(s, {
1348
+ const i = new Intl.DateTimeFormat(s, {
1318
1349
  year: "numeric",
1319
1350
  day: "numeric",
1320
1351
  month: "short",
@@ -1327,26 +1358,26 @@ const ne = (t, s, e = "UTC") => {
1327
1358
  timeZone: t
1328
1359
  });
1329
1360
  return (o) => {
1330
- const n = o[1] - o[0], a = n < W([1, "days"]), l = n < W([1, "minutes"]), d = n < W([1, "seconds"]);
1331
- return o.map((u) => ({ value: u, label: c.formatToParts(new Date(u)) })).map((u, r, p) => {
1332
- const f = p[r - 1], h = r === 0 || K(u.label, f.label, "year"), i = r === 0 || K(u.label, f.label, "day"), m = r === 0 || K(u.label, f.label, "month"), y = r === 0 || K(u.label, f.label, "hour"), x = r === 0 || K(u.label, f.label, "timeZoneName"), v = r === 0 || K(u.label, f.label, "minute"), g = r === 0 || K(u.label, f.label, "second"), S = r === 0 || K(u.label, f.label, "fractionalSecond"), C = [];
1333
- if (a && (y || v || x || g || S)) {
1334
- const w = u.label.find((M) => M.type === "hour")?.value, b = u.label.find((M) => M.type === "minute")?.value, k = u.label.find((M) => M.type === "timeZoneName")?.value;
1335
- let _ = "";
1361
+ const n = o[1] - o[0], a = n < q([1, "days"]), l = n < q([1, "minutes"]), d = n < q([1, "seconds"]);
1362
+ return o.map((u) => ({ value: u, label: i.formatToParts(new Date(u)) })).map((u, r, m) => {
1363
+ const f = m[r - 1], h = r === 0 || I(u.label, f.label, "year"), c = r === 0 || I(u.label, f.label, "day"), p = r === 0 || I(u.label, f.label, "month"), y = r === 0 || I(u.label, f.label, "hour"), x = r === 0 || I(u.label, f.label, "timeZoneName"), v = r === 0 || I(u.label, f.label, "minute"), S = r === 0 || I(u.label, f.label, "second"), g = r === 0 || I(u.label, f.label, "fractionalSecond"), C = [];
1364
+ if (a && (y || v || x || S || g)) {
1365
+ const w = u.label.find((P) => P.type === "hour")?.value, b = u.label.find((P) => P.type === "minute")?.value, k = u.label.find((P) => P.type === "timeZoneName")?.value;
1366
+ let U = "";
1336
1367
  if (l) {
1337
- const M = u.label.find((F) => F.type === "second")?.value, B = u.label.find(
1368
+ const P = u.label.find((F) => F.type === "second")?.value, B = u.label.find(
1338
1369
  (F) => F.type === "fractionalSecond"
1339
1370
  )?.value;
1340
- _ = `:${M}` + (d ? `.${B}` : "");
1371
+ U = `:${P}` + (d ? `.${B}` : "");
1341
1372
  }
1342
1373
  C.push(
1343
- `${w}:${b}${_}` + (e && x ? ` ${k}` : "")
1374
+ `${w}:${b}${U}` + (e && x ? ` ${k}` : "")
1344
1375
  );
1345
1376
  }
1346
- return (i || m) && C.push(
1377
+ return (c || p) && C.push(
1347
1378
  [
1348
1379
  u.label.find((w) => w.type === "month")?.value,
1349
- i && u.label.find((w) => w.type === "day")?.value
1380
+ c && u.label.find((w) => w.type === "day")?.value
1350
1381
  ].filter(Boolean).join(" ")
1351
1382
  ), h && C.push(u.label.find((w) => w.type === "year")?.value), {
1352
1383
  value: u.value,
@@ -1357,38 +1388,41 @@ const ne = (t, s, e = "UTC") => {
1357
1388
  };
1358
1389
  };
1359
1390
  export {
1360
- me as AreaPlot,
1361
- Ce as AxisOverlay,
1362
- fe as BarPlot,
1363
- ue as CanPlot,
1364
- Se as ChartAreaInteractions,
1365
- we as Crosshair,
1366
- de as LinePlot,
1367
- he as ScatterPlot,
1368
- be as SelectBox,
1369
- pe as SparklinePlot,
1370
- ve as TooltipsX,
1371
- xe as XTicks,
1372
- ge as YTicks,
1373
- R as applyStyles,
1374
- le as clampUnfit,
1391
+ Se as AreaPlot,
1392
+ Me as AxisOverlay,
1393
+ xe as BarPlot,
1394
+ me as CanPlot,
1395
+ Ce as ChartAreaInteractions,
1396
+ ke as Crosshair,
1397
+ pe as LinePlot,
1398
+ ye as ScatterPlot,
1399
+ Ee as SelectBox,
1400
+ ge as SparklinePlot,
1401
+ Te as TooltipsX,
1402
+ we as XTicks,
1403
+ be as YTicks,
1404
+ _ as applyStyles,
1405
+ j as clamp,
1406
+ fe as clampUnfit,
1375
1407
  O as clampXPosToChartArea,
1376
1408
  $ as clampYPosToChartArea,
1377
- Ht as defaultNumericalTicksFormatter,
1378
- A as getScale,
1379
- Q as isXScale,
1380
- ae as isYScale,
1381
- Te as makeLinearTicks,
1382
- oe as makeTimeTickFormat,
1383
- ke as makeTimeTicks,
1384
- D as posToVal,
1385
- Lt as pxToValDistance,
1409
+ qt as defaultNumericalTicksFormatter,
1410
+ de as findClosestIndex,
1411
+ R as getScale,
1412
+ et as isXScale,
1413
+ he as isYScale,
1414
+ Pe as makeLinearTicks,
1415
+ ce as makeTimeTickFormat,
1416
+ Ae as makeTimeTicks,
1417
+ X as posToVal,
1418
+ Dt as pxToValDistance,
1419
+ ue as sum,
1386
1420
  z as useDrawEffect,
1387
1421
  ft as useFrameState,
1388
1422
  pt as useInteractionsEvent,
1389
- ye as useXPositioned,
1390
- it as valFits,
1391
- j as valToPos,
1423
+ ve as useXPositioned,
1424
+ at as valFits,
1425
+ H as valToPos,
1392
1426
  dt as valToPxDistance
1393
1427
  };
1394
1428
  //# sourceMappingURL=canplot.mjs.map