@canplot/react 0.1.10 → 0.1.12

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