@graphysdk/node-renderer 2.0.0-beta.1786440210947 → 2.0.0-beta.1787130761469

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,39 +1,39 @@
1
1
  import { existsSync as tt, readFileSync as ot } from "node:fs";
2
2
  import { createRequire as Le } from "node:module";
3
- import O from "node:path";
3
+ import H from "node:path";
4
4
  import { fileURLToPath as nt } from "node:url";
5
5
  import { convertGraphConfig as rt } from "@graphysdk/viz-engine/graph-config";
6
6
  import { curveCatmullRom as st, curveLinear as it, area as Re, line as we, arc as at } from "d3-shape";
7
- import { createStyleResolver as D, GROUP_VARIABLES as _e, getX as _, getY as w, getXMin as lt, getXMax as dt, getYMin as ct, getYMax as ft, getBarRectBounds as ut, buildColumnKey as ht, resolveBarBorderTreatment as Ie, resolveBarCornerRadiiPx as $, getBoundingRect as gt, getRuleDashPattern as mt, getRuleLabelTextColor as At, formatRuleValue as bt, buildFontString as S, getAngleExtent as pt, getRadiusExtent as yt, buildSliceGroupKey as Tt, getUnionExtent as Et, resolvePolarBarCornerRadiusUnit as St, createCompiler as Lt, isSafeUrl as Rt, extractPlainText as te, computePanelBorderPaths as wt, getDataLabelDimensions as _t, getDifferenceArrowDimensions as It, formatLegends as Bt, LayoutCompiler as Nt } from "@graphysdk/viz-engine";
8
- import { Buffer as Ct } from "node:buffer";
9
- let M, x;
10
- const vt = () => M ? Promise.resolve(M) : (x ??= import("@napi-rs/canvas").then((e) => (M = e, e)).catch((e) => {
7
+ import { createStyleResolver as P, GROUP_VARIABLES as Be, getX as v, getY as B, getXMin as lt, getXMax as dt, getYMin as ct, getYMax as ft, getBarRectBounds as ut, buildColumnKey as ht, resolveBarBorderTreatment as ve, resolveBarCornerRadiiPx as $, getBoundingRect as gt, getRuleDashPattern as mt, getRuleLabelTextColor as pt, formatRuleValue as At, buildFontString as R, getAngleExtent as bt, getRadiusExtent as yt, buildSliceGroupKey as Tt, getUnionExtent as St, resolvePolarBarCornerRadiusUnit as Et, createCompiler as Lt, toFontSpec as J, isSafeUrl as Rt, extractPlainText as te, computePanelBorderPaths as wt, resolvePanelBorderStyle as Bt, resolveGridLineStyle as vt, getAestheticFromScaleAestheticKey as U, computeLineBoxHeight as _t, getDifferenceArrowDimensions as Ct, formatLegends as Nt, resolveAxisLabelStyle as fe, resolveTickLabelStyle as ue, resolveTickLineStyle as he, DATA_LABEL_ROLES as It, DATA_LABEL_POSITIONS as Pt, resolveDataLabelStyle as kt, LayoutCompiler as Dt } from "@graphysdk/viz-engine";
8
+ import { Buffer as Ot } from "node:buffer";
9
+ let G, x;
10
+ const Ft = () => G ? Promise.resolve(G) : (x ??= import("@napi-rs/canvas").then((e) => (G = e, e)).catch((e) => {
11
11
  throw x = void 0, e;
12
- }), x), V = () => {
13
- if (!M)
12
+ }), x), z = () => {
13
+ if (!G)
14
14
  throw new Error("Canvas runtime is not loaded. Call loadCanvasRuntime() before rendering.");
15
- return M;
16
- }, T = "Inter", oe = /* @__PURE__ */ new Set();
17
- let ue = !1, Z = !1;
18
- const Be = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ne = (e) => {
19
- const t = Be(e);
20
- oe.has(t) || (V().GlobalFonts.register(e.data, e.family), oe.add(t));
21
- }, Pt = [
22
- { file: "Inter-Regular.ttf", family: T, weight: 400 },
23
- { file: "Inter-SemiBold.ttf", family: T, weight: 600 }
24
- ], kt = [
25
- { file: "inter-latin-400-normal.woff", family: T, weight: 400 },
26
- { file: "inter-latin-600-normal.woff", family: T, weight: 600 }
27
- ], Dt = "@fontsource/inter", Ft = () => {
15
+ return G;
16
+ }, E = "Inter", oe = /* @__PURE__ */ new Set();
17
+ let ge = !1, j = !1;
18
+ const _e = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ce = (e) => {
19
+ const t = _e(e);
20
+ oe.has(t) || (z().GlobalFonts.register(e.data, e.family), oe.add(t));
21
+ }, Ht = [
22
+ { file: "Inter-Regular.ttf", family: E, weight: 400 },
23
+ { file: "Inter-SemiBold.ttf", family: E, weight: 600 }
24
+ ], Mt = [
25
+ { file: "inter-latin-400-normal.woff", family: E, weight: 400 },
26
+ { file: "inter-latin-600-normal.woff", family: E, weight: 600 }
27
+ ], Gt = "@fontsource/inter", Ut = () => {
28
28
  try {
29
- const e = Le(import.meta.url), t = O.dirname(e.resolve("@graphysdk/node-renderer/package.json"));
30
- return O.join(t, "assets");
29
+ const e = Le(import.meta.url), t = H.dirname(e.resolve("@graphysdk/node-renderer/package.json"));
30
+ return H.join(t, "assets");
31
31
  } catch {
32
- return O.resolve(O.dirname(nt(import.meta.url)), "../assets");
32
+ return H.resolve(H.dirname(nt(import.meta.url)), "../assets");
33
33
  }
34
- }, Ce = (e, t, o) => {
34
+ }, Ne = (e, t, o) => {
35
35
  try {
36
- return tt(e) ? (Ne({
36
+ return tt(e) ? (Ce({
37
37
  family: t,
38
38
  data: ot(e),
39
39
  weight: o
@@ -41,20 +41,20 @@ const Be = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ne =
41
41
  } catch {
42
42
  return !1;
43
43
  }
44
- }, Ot = () => {
45
- const e = Ft();
46
- for (const { file: t, family: o, weight: n } of Pt)
47
- Ce(O.join(e, t), o, n) && (Z = !0);
48
- }, Ht = () => {
44
+ }, Wt = () => {
45
+ const e = Ut();
46
+ for (const { file: t, family: o, weight: n } of Ht)
47
+ Ne(H.join(e, t), o, n) && (j = !0);
48
+ }, Vt = () => {
49
49
  const e = Le(import.meta.url);
50
- for (const { file: t, family: o, weight: n } of kt)
51
- if (!oe.has(Be({ family: o, data: Buffer.alloc(0), weight: n })))
50
+ for (const { file: t, family: o, weight: n } of Mt)
51
+ if (!oe.has(_e({ family: o, data: Buffer.alloc(0), weight: n })))
52
52
  try {
53
- const s = e.resolve(`${Dt}/files/${t}`);
54
- Ce(s, o, n) && (Z = !0);
53
+ const s = e.resolve(`${Gt}/files/${t}`);
54
+ Ne(s, o, n) && (j = !0);
55
55
  } catch {
56
56
  }
57
- }, Mt = () => (ue || (ue = !0, Ot(), Ht()), Z), B = (e, t) => e.x + t * e.width, I = (e, t) => e.y + (1 - t) * e.height, ne = (e) => e === "catmull-rom" ? st : it, ve = (e) => {
57
+ }, Kt = () => (ge || (ge = !0, Wt(), Vt()), j), C = (e, t) => e.x + t * e.width, _ = (e, t) => e.y + (1 - t) * e.height, ne = (e) => e === "catmull-rom" ? st : it, Ie = (e) => {
58
58
  switch (e) {
59
59
  case "dashed":
60
60
  return [8, 4];
@@ -63,160 +63,160 @@ const Be = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ne =
63
63
  case "solid":
64
64
  return [];
65
65
  }
66
- }, F = (e) => e, Gt = (e, t) => t !== "connect" ? e : e.filter((o) => _(o) !== null && w(o) !== null), Ut = (e, t, o) => {
66
+ }, F = (e) => e, zt = (e, t) => t !== "connect" ? e : e.filter((o) => v(o) !== null && B(o) !== null), Xt = (e, t, o) => {
67
67
  const n = ne(t.interpolate), s = Re().curve(n), r = we().curve(n);
68
68
  if (e.mainAxis === "y") {
69
- const i = (l) => I(o, w(l) ?? 0), a = (l) => B(o, lt(l) ?? 0), d = (l) => B(o, dt(l) ?? _(l) ?? 0);
70
- s.y(i).x0(a).x1(d), r.y(i).x(d);
69
+ const i = (a) => _(o, B(a) ?? 0), l = (a) => C(o, lt(a) ?? 0), d = (a) => C(o, dt(a) ?? v(a) ?? 0);
70
+ s.y(i).x0(l).x1(d), r.y(i).x(d);
71
71
  } else {
72
- const i = (l) => B(o, _(l) ?? 0), a = (l) => I(o, ct(l) ?? 0), d = (l) => I(o, ft(l) ?? w(l) ?? 0);
73
- s.x(i).y0(a).y1(d), r.x(i).y(d);
72
+ const i = (a) => C(o, v(a) ?? 0), l = (a) => _(o, ct(a) ?? 0), d = (a) => _(o, ft(a) ?? B(a) ?? 0);
73
+ s.x(i).y0(l).y1(d), r.x(i).y(d);
74
74
  }
75
75
  if (t.missingValues === "gap") {
76
- const i = (a) => _(a) !== null && w(a) !== null;
76
+ const i = (l) => v(l) !== null && B(l) !== null;
77
77
  s.defined(i), r.defined(i);
78
78
  }
79
79
  return { areaGenerator: s, lineGenerator: r };
80
- }, Wt = F({
80
+ }, Yt = F({
81
81
  geom: "area",
82
82
  coord: "cartesian",
83
83
  draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
84
- const r = D({ colorScheme: s }).geomReaders(t), { areaGenerator: i, lineGenerator: a } = Ut(o, t.params, n), d = e;
85
- t.data.groupBy(_e.group).forEach((l) => {
86
- const c = Gt([...l], t.params.missingValues), f = c[0];
87
- if (!f) return;
88
- const u = r.get("color", f), h = r.get("alpha", f), g = r.get("strokeWidth", f), A = ve(r.get("lineType", f));
89
- e.save(), e.globalAlpha = h, e.fillStyle = u, e.beginPath(), i.context(d)(c), e.fill(), e.restore(), e.save(), e.globalAlpha = r.get("strokeAlpha", f), e.strokeStyle = u, e.lineWidth = g, e.setLineDash(A), e.lineJoin = "round", e.lineCap = "round", e.beginPath(), a.context(d)(c), e.stroke(), e.restore();
84
+ const r = P({ colorScheme: s }).geomReaders(t), { areaGenerator: i, lineGenerator: l } = Xt(o, t.params, n), d = e;
85
+ t.data.groupBy(Be.group).forEach((a) => {
86
+ const c = zt([...a], t.params.missingValues), u = c[0];
87
+ if (!u) return;
88
+ const f = r.get("color", u), h = r.get("alpha", u), g = r.get("strokeWidth", u), A = Ie(r.get("lineType", u));
89
+ e.save(), e.globalAlpha = h, e.fillStyle = f, e.beginPath(), i.context(d)(c), e.fill(), e.restore(), e.save(), e.globalAlpha = r.get("strokeAlpha", u), e.strokeStyle = f, e.lineWidth = g, e.setLineDash(A), e.lineJoin = "round", e.lineCap = "round", e.beginPath(), l.context(d)(c), e.stroke(), e.restore();
90
90
  });
91
91
  }
92
- }), he = (e, t, o, n, s, r) => {
93
- const i = Math.max(0, Math.min(r.rx ?? r.ry ?? 0, n / 2)), a = Math.max(0, Math.min(r.ry ?? r.rx ?? 0, s / 2)), d = Math.PI / 2;
94
- e.moveTo(t + i, o), e.lineTo(t + n - i, o), e.ellipse(t + n - i, o + a, i, a, 0, -d, 0), e.lineTo(t + n, o + s - a), e.ellipse(t + n - i, o + s - a, i, a, 0, 0, d), e.lineTo(t + i, o + s), e.ellipse(t + i, o + s - a, i, a, 0, d, Math.PI), e.lineTo(t, o + a), e.ellipse(t + i, o + a, i, a, 0, Math.PI, Math.PI * 1.5), e.closePath();
95
- }, Vt = F({
92
+ }), me = (e, t, o, n, s, r) => {
93
+ const i = Math.max(0, Math.min(r.rx ?? r.ry ?? 0, n / 2)), l = Math.max(0, Math.min(r.ry ?? r.rx ?? 0, s / 2)), d = Math.PI / 2;
94
+ e.moveTo(t + i, o), e.lineTo(t + n - i, o), e.ellipse(t + n - i, o + l, i, l, 0, -d, 0), e.lineTo(t + n, o + s - l), e.ellipse(t + n - i, o + s - l, i, l, 0, 0, d), e.lineTo(t + i, o + s), e.ellipse(t + i, o + s - l, i, l, 0, d, Math.PI), e.lineTo(t, o + l), e.ellipse(t + i, o + l, i, l, 0, Math.PI, Math.PI * 1.5), e.closePath();
95
+ }, qt = F({
96
96
  geom: "bar",
97
97
  coord: "cartesian",
98
98
  draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
99
- const { Path2D: r } = V(), i = D({ colorScheme: s }).geomReaders(t), a = o.mainAxis, d = /* @__PURE__ */ new Map();
100
- for (const l of t.data) {
101
- const c = ut(a, l);
99
+ const { Path2D: r } = z(), i = P({ colorScheme: s }).geomReaders(t), l = o.mainAxis, d = /* @__PURE__ */ new Map();
100
+ for (const a of t.data) {
101
+ const c = ut(l, a);
102
102
  if (!c) continue;
103
- const f = B(n, c.x), u = n.y + c.y * n.height, h = {
104
- x: f,
105
- y: u,
103
+ const u = C(n, c.x), f = n.y + c.y * n.height, h = {
104
+ x: u,
105
+ y: f,
106
106
  width: c.width * n.width,
107
107
  height: c.height * n.height,
108
- fill: i.get("color", l),
109
- opacity: i.get("alpha", l)
110
- }, g = ht(a, c), A = d.get(g);
108
+ fill: i.get("color", a),
109
+ opacity: i.get("alpha", a)
110
+ }, g = ht(l, c), A = d.get(g);
111
111
  A ? A.bars.push(h) : d.set(g, {
112
112
  bars: [h],
113
113
  style: {
114
- borderColor: i.get("borderColor", l),
115
- borderWidth: i.get("borderWidth", l),
116
- borderRadius: i.get("borderRadius", l),
117
- borderAlpha: i.get("alpha", l)
114
+ borderColor: i.get("borderColor", a),
115
+ borderWidth: i.get("borderWidth", a),
116
+ borderRadius: i.get("borderRadius", a),
117
+ borderAlpha: i.get("alpha", a)
118
118
  }
119
119
  });
120
120
  }
121
- for (const { bars: l, style: c } of d.values()) {
122
- const { borderColor: f, borderRadius: u, borderWidth: h, borderAlpha: g } = c, A = Ie(h), b = u === "full" ? void 0 : $({ borderRadius: u, mainAxis: a });
123
- if (!(l.length > 1)) {
124
- const [m] = l;
121
+ for (const { bars: a, style: c } of d.values()) {
122
+ const { borderColor: u, borderRadius: f, borderWidth: h, borderAlpha: g } = c, A = ve(h), p = f === "full" ? void 0 : $({ borderRadius: f, mainAxis: l });
123
+ if (!(a.length > 1)) {
124
+ const [m] = a;
125
125
  if (!m) continue;
126
- const v = b ?? $({ borderRadius: u, mainAxis: a, bounds: { width: m.width, height: m.height } }), L = new r();
127
- he(L, m.x, m.y, m.width, m.height, v), e.save(), e.globalAlpha = m.opacity, e.fillStyle = m.fill, e.fill(L), f !== void 0 && (e.clip(L), e.strokeStyle = f, e.lineWidth = A.outlineWidth, e.stroke(L)), e.restore();
126
+ const w = p ?? $({ borderRadius: f, mainAxis: l, bounds: { width: m.width, height: m.height } }), L = new r();
127
+ me(L, m.x, m.y, m.width, m.height, w), e.save(), e.globalAlpha = m.opacity, e.fillStyle = m.fill, e.fill(L), u !== void 0 && (e.clip(L), e.strokeStyle = u, e.lineWidth = A.outlineWidth, e.stroke(L)), e.restore();
128
128
  continue;
129
129
  }
130
- const p = gt(l), R = b ?? $({ borderRadius: u, mainAxis: a, bounds: { width: p.width, height: p.height } }), y = new r();
131
- he(y, p.x, p.y, p.width, p.height, R), e.save(), e.clip(y);
132
- for (const m of l)
133
- e.globalAlpha = m.opacity, e.fillStyle = m.fill, e.fillRect(m.x, m.y, m.width, m.height), f !== void 0 && (e.strokeStyle = f, e.lineWidth = A.separatorWidth, e.strokeRect(m.x, m.y, m.width, m.height));
134
- f !== void 0 && (e.globalAlpha = g, e.strokeStyle = f, e.lineWidth = A.outlineWidth, e.stroke(y)), e.restore();
130
+ const y = gt(a), S = p ?? $({ borderRadius: f, mainAxis: l, bounds: { width: y.width, height: y.height } }), T = new r();
131
+ me(T, y.x, y.y, y.width, y.height, S), e.save(), e.clip(T);
132
+ for (const m of a)
133
+ e.globalAlpha = m.opacity, e.fillStyle = m.fill, e.fillRect(m.x, m.y, m.width, m.height), u !== void 0 && (e.strokeStyle = u, e.lineWidth = A.separatorWidth, e.strokeRect(m.x, m.y, m.width, m.height));
134
+ u !== void 0 && (e.globalAlpha = g, e.strokeStyle = u, e.lineWidth = A.outlineWidth, e.stroke(T)), e.restore();
135
135
  }
136
136
  }
137
- }), ge = (e, t) => {
137
+ }), pe = (e, t) => {
138
138
  const o = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e.trim());
139
139
  if (o?.[1] !== void 0) {
140
- const s = o[1], r = s.length === 3 ? [...s].map((l) => l + l).join("") : s.slice(0, 6), i = Number.parseInt(r.slice(0, 2), 16), a = Number.parseInt(r.slice(2, 4), 16), d = Number.parseInt(r.slice(4, 6), 16);
141
- return `rgba(${i}, ${a}, ${d}, ${t})`;
140
+ const s = o[1], r = s.length === 3 ? [...s].map((a) => a + a).join("") : s.slice(0, 6), i = Number.parseInt(r.slice(0, 2), 16), l = Number.parseInt(r.slice(2, 4), 16), d = Number.parseInt(r.slice(4, 6), 16);
141
+ return `rgba(${i}, ${l}, ${d}, ${t})`;
142
142
  }
143
143
  const n = /^rgba?\(([^)]+)\)$/i.exec(e.trim());
144
144
  if (n?.[1] !== void 0) {
145
- const s = n[1].split(",").map((d) => d.trim()), [r, i, a] = s;
146
- if (r !== void 0 && i !== void 0 && a !== void 0)
147
- return `rgba(${r}, ${i}, ${a}, ${t})`;
145
+ const s = n[1].split(",").map((d) => d.trim()), [r, i, l] = s;
146
+ if (r !== void 0 && i !== void 0 && l !== void 0)
147
+ return `rgba(${r}, ${i}, ${l}, ${t})`;
148
148
  }
149
149
  return t === 0 ? "rgba(0, 0, 0, 0)" : e;
150
- }, Kt = (e, t) => t !== "connect" ? e : e.filter((o) => _(o) !== null && w(o) !== null), Xt = (e, t) => {
151
- const { seriesObservations: o, fillGenerator: n, panel: s, color: r, fillAlpha: i } = t, a = o.map((l) => w(l)).filter((l) => l !== null).map((l) => I(s, l));
152
- if (a.length === 0) return;
153
- const d = e.createLinearGradient(0, Math.min(...a), 0, s.y + s.height);
154
- d.addColorStop(0, r), d.addColorStop(0.7, ge(r, 0)), d.addColorStop(1, ge(r, 0)), e.save(), e.globalAlpha = i, e.fillStyle = d, e.beginPath(), n.context(e)(o), e.fill(), e.restore();
155
- }, zt = F({
150
+ }, jt = (e, t) => t !== "connect" ? e : e.filter((o) => v(o) !== null && B(o) !== null), Qt = (e, t) => {
151
+ const { seriesObservations: o, fillGenerator: n, panel: s, color: r, fillAlpha: i } = t, l = o.map((a) => B(a)).filter((a) => a !== null).map((a) => _(s, a));
152
+ if (l.length === 0) return;
153
+ const d = e.createLinearGradient(0, Math.min(...l), 0, s.y + s.height);
154
+ d.addColorStop(0, r), d.addColorStop(0.7, pe(r, 0)), d.addColorStop(1, pe(r, 0)), e.save(), e.globalAlpha = i, e.fillStyle = d, e.beginPath(), n.context(e)(o), e.fill(), e.restore();
155
+ }, Zt = F({
156
156
  geom: "line",
157
157
  coord: "cartesian",
158
158
  draw: (e, { layer: t, panel: o, colorScheme: n }) => {
159
- const s = D({ colorScheme: n }).geomReaders(t), r = we().x((a) => B(o, _(a) ?? 0)).y((a) => I(o, w(a) ?? 0)).curve(ne(t.params.interpolate)), i = Re().x((a) => B(o, _(a) ?? 0)).y0(o.y + o.height).y1((a) => I(o, w(a) ?? 0)).curve(ne(t.params.interpolate));
159
+ const s = P({ colorScheme: n }).geomReaders(t), r = we().x((l) => C(o, v(l) ?? 0)).y((l) => _(o, B(l) ?? 0)).curve(ne(t.params.interpolate)), i = Re().x((l) => C(o, v(l) ?? 0)).y0(o.y + o.height).y1((l) => _(o, B(l) ?? 0)).curve(ne(t.params.interpolate));
160
160
  if (t.params.missingValues === "gap") {
161
- const a = (d) => _(d) !== null && w(d) !== null;
162
- r.defined(a), i.defined(a);
161
+ const l = (d) => v(d) !== null && B(d) !== null;
162
+ r.defined(l), i.defined(l);
163
163
  }
164
- t.data.groupBy(_e.group).forEach((a) => {
165
- const d = Kt([...a], t.params.missingValues), l = d[0];
166
- if (!l) return;
167
- const c = s.get("strokeWidth", l), f = ve(s.get("lineType", l)), u = s.get("color", l), h = s.get("fillAlpha", l);
168
- h !== void 0 && Xt(e, { seriesObservations: d, fillGenerator: i, panel: o, color: u, fillAlpha: h }), e.save(), e.globalAlpha = s.get("alpha", l), e.strokeStyle = u, e.lineWidth = c, e.setLineDash(f), e.lineJoin = "round", e.lineCap = "round", e.beginPath(), r.context(e)(d), e.stroke(), e.restore();
164
+ t.data.groupBy(Be.group).forEach((l) => {
165
+ const d = jt([...l], t.params.missingValues), a = d[0];
166
+ if (!a) return;
167
+ const c = s.get("strokeWidth", a), u = Ie(s.get("lineType", a)), f = s.get("color", a), h = s.get("fillAlpha", a);
168
+ h !== void 0 && Qt(e, { seriesObservations: d, fillGenerator: i, panel: o, color: f, fillAlpha: h }), e.save(), e.globalAlpha = s.get("alpha", a), e.strokeStyle = f, e.lineWidth = c, e.setLineDash(u), e.lineJoin = "round", e.lineCap = "round", e.beginPath(), r.context(e)(d), e.stroke(), e.restore();
169
169
  });
170
170
  }
171
- }), Yt = F({
171
+ }), Jt = F({
172
172
  geom: "point",
173
173
  coord: "cartesian",
174
174
  draw: (e, { layer: t, panel: o, colorScheme: n }) => {
175
- const s = D({ colorScheme: n }).geomReaders(t);
175
+ const s = P({ colorScheme: n }).geomReaders(t);
176
176
  for (const r of t.data) {
177
- const i = _(r), a = w(r);
178
- if (i === null || a === null) continue;
179
- const d = B(o, i), l = I(o, a), c = s.get("size", r) / 2, f = s.get("borderWidth", r);
180
- e.save(), e.globalAlpha = s.get("alpha", r), e.fillStyle = s.get("color", r), e.strokeStyle = s.get("borderColor", r), e.lineWidth = f, e.beginPath(), e.arc(d, l, c, 0, Math.PI * 2), e.fill(), f > 0 && e.stroke(), e.restore();
177
+ const i = v(r), l = B(r);
178
+ if (i === null || l === null) continue;
179
+ const d = C(o, i), a = _(o, l), c = s.get("size", r) / 2, u = s.get("borderWidth", r);
180
+ e.save(), e.globalAlpha = s.get("alpha", r), e.fillStyle = s.get("color", r), e.strokeStyle = s.get("borderColor", r), e.lineWidth = u, e.beginPath(), e.arc(d, a, c, 0, Math.PI * 2), e.fill(), u > 0 && e.stroke(), e.restore();
181
181
  }
182
182
  }
183
- }), ae = 11, qt = "sans-serif", Zt = 500, P = 5, Pe = 5, re = 13, ke = 6, K = 12, me = 21.6, jt = (e, t) => {
183
+ }), le = 11, $t = "sans-serif", xt = 500, D = 5, Pe = 5, re = 13, ke = 6, X = 12, Ae = 21.6, eo = (e, t) => {
184
184
  const o = e.mapping.y !== void 0, n = t.mainAxis === "y";
185
185
  return o !== n;
186
- }, Qt = (e, t, o) => {
186
+ }, to = (e, t, o) => {
187
187
  const n = mt(t, o);
188
188
  e.setLineDash(n), n.length > 0 && (e.lineCap = "round");
189
- }, Jt = (e, t) => X(e) && X(t) ? `${e}: ${t}` : X(e) ? e : X(t) ? t : null, X = (e) => e != null && e.trim() !== "", $t = (e) => {
189
+ }, oo = (e, t) => Y(e) && Y(t) ? `${e}: ${t}` : Y(e) ? e : Y(t) ? t : null, Y = (e) => e != null && e.trim() !== "", no = (e) => {
190
190
  e.beginPath(), e.moveTo(2.48935, 16.9323), e.lineTo(9.07098, 9.82964), e.bezierCurveTo(9.51595, 9.34944, 9.51504, 8.60728, 9.0689, 8.12818), e.lineTo(2.48866, 1.06172), e.bezierCurveTo(1.85811, 0.384586, 0.974477, 0, 0.049217, 0), e.lineTo(0, 0), e.lineTo(0, 18), e.lineTo(0.0443689, 18), e.bezierCurveTo(0.972463, 18, 1.85854, 17.6131, 2.48935, 16.9323), e.closePath();
191
191
  }, De = (e, t, o, n, s, r) => {
192
192
  const i = Math.min(r, n / 2, s / 2);
193
193
  e.beginPath(), e.moveTo(t + i, o), e.lineTo(t + n - i, o), e.arcTo(t + n, o, t + n, o + i, i), e.lineTo(t + n, o + s - i), e.arcTo(t + n, o + s, t + n - i, o + s, i), e.lineTo(t + i, o + s), e.arcTo(t, o + s, t, o + s - i, i), e.lineTo(t, o + i), e.arcTo(t, o, t + i, o, i), e.closePath(), e.fill();
194
- }, xt = (e, t, o, n, s, r, i, a) => {
195
- const d = o + P * 2, l = ae + Pe * 2, c = n === "start", f = c ? r.x : r.x + r.width, u = I(r, s), h = c ? -re : -(d - re), g = c ? h + d - P : h + P - K;
196
- e.save(), e.translate(f, u), e.translate(0, -l / 2), e.fillStyle = i, De(e, h, 0, d, l, ke), e.save(), c || (e.translate(g + K / 2, l / 2), e.rotate(Math.PI), e.translate(-(g + K / 2), -l / 2)), e.translate(g, (l - me) / 2), e.scale(K / 10, me / 18), e.fillStyle = i, $t(e), e.fill(), e.restore(), e.fillStyle = a, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, h + P, l / 2), e.restore();
197
- }, eo = (e, t, o, n, s, r, i, a) => {
198
- const d = o + P * 2, l = ae + Pe * 2, c = n === "start", f = B(r, s), u = c ? r.y + r.height : r.y, h = c ? -re : -8;
199
- e.save(), e.translate(f, u), e.translate(-d / 2, 0), e.fillStyle = i, De(e, 0, h, d, l, ke), e.fillStyle = a, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, P, h + l / 2), e.restore();
200
- }, to = F({
194
+ }, ro = (e, t, o, n, s, r, i, l) => {
195
+ const d = o + D * 2, a = le + Pe * 2, c = n === "start", u = c ? r.x : r.x + r.width, f = _(r, s), h = c ? -re : -(d - re), g = c ? h + d - D : h + D - X;
196
+ e.save(), e.translate(u, f), e.translate(0, -a / 2), e.fillStyle = i, De(e, h, 0, d, a, ke), e.save(), c || (e.translate(g + X / 2, a / 2), e.rotate(Math.PI), e.translate(-(g + X / 2), -a / 2)), e.translate(g, (a - Ae) / 2), e.scale(X / 10, Ae / 18), e.fillStyle = i, no(e), e.fill(), e.restore(), e.fillStyle = l, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, h + D, a / 2), e.restore();
197
+ }, so = (e, t, o, n, s, r, i, l) => {
198
+ const d = o + D * 2, a = le + Pe * 2, c = n === "start", u = C(r, s), f = c ? r.y + r.height : r.y, h = c ? -re : -8;
199
+ e.save(), e.translate(u, f), e.translate(-d / 2, 0), e.fillStyle = i, De(e, 0, h, d, a, ke), e.fillStyle = l, e.textAlign = "left", e.textBaseline = "middle", e.fillText(t, D, h + a / 2), e.restore();
200
+ }, io = F({
201
201
  geom: "rule",
202
202
  coord: "cartesian",
203
- draw: (e, { layer: t, coordSystem: o, panel: n, compiled: s, textMeasurer: r, formattingLocale: i, colorScheme: a }) => {
203
+ draw: (e, { layer: t, coordSystem: o, panel: n, compiled: s, textMeasurer: r, formattingLocale: i, colorScheme: l }) => {
204
204
  const d = t.data.getFirst();
205
205
  if (!d) return;
206
- const l = jt(t, o), c = l ? w(d) : _(d);
206
+ const a = eo(t, o), c = a ? B(d) : v(d);
207
207
  if (c === null) return;
208
- const f = D({ colorScheme: a }).geomReaders(t), u = f.get("color", d), h = At(u), g = f.get("strokeWidth", d);
209
- if (e.save(), e.strokeStyle = u, e.lineWidth = g, Qt(e, f.get("lineType", d), g), e.beginPath(), l) {
210
- const y = I(n, c);
211
- e.moveTo(n.x, y), e.lineTo(n.x + n.width, y);
208
+ const u = P({ colorScheme: l }).geomReaders(t), f = u.get("color", d), h = pt(f), g = u.get("strokeWidth", d);
209
+ if (e.save(), e.strokeStyle = f, e.lineWidth = g, to(e, u.get("lineType", d), g), e.beginPath(), a) {
210
+ const T = _(n, c);
211
+ e.moveTo(n.x, T), e.lineTo(n.x + n.width, T);
212
212
  } else {
213
- const y = B(n, c);
214
- e.moveTo(y, n.y), e.lineTo(y, n.y + n.height);
213
+ const T = C(n, c);
214
+ e.moveTo(T, n.y), e.lineTo(T, n.y + n.height);
215
215
  }
216
216
  e.stroke(), e.restore();
217
- const A = Jt(
217
+ const A = oo(
218
218
  t.params.label,
219
- bt({
219
+ At({
220
220
  guides: s.guides,
221
221
  numberFormat: s.config.numberFormat,
222
222
  layer: t,
@@ -224,71 +224,71 @@ const Be = (e) => `${e.family}|${e.weight ?? 400}|${e.style ?? "normal"}`, Ne =
224
224
  })
225
225
  );
226
226
  if (A === null) return;
227
- const b = s.config.appearance.textScale, E = {
228
- family: qt,
229
- size: ae * b,
230
- weight: Zt
227
+ const p = s.config.appearance.textScale, b = {
228
+ family: $t,
229
+ size: le * p,
230
+ weight: xt
231
231
  };
232
- e.font = S(E);
233
- const p = r.measureText(A, E).width;
234
- (l ? xt : eo)(e, A, p, t.params.labelPosition, c, n, u, h);
232
+ e.font = R(b);
233
+ const y = r.measureText(A, b).width;
234
+ (a ? ro : so)(e, A, y, t.params.labelPosition, c, n, f, h);
235
235
  }
236
- }), H = at();
237
- H.digits(8);
238
- const oo = F({
236
+ }), M = at();
237
+ M.digits(8);
238
+ const ao = F({
239
239
  geom: "bar",
240
240
  coord: "polar",
241
241
  draw: (e, { layer: t, coordSystem: o, panel: n, colorScheme: s }) => {
242
- const r = n.x + n.width / 2, i = n.y + n.height / 2, a = Math.min(n.width, n.height) / 2, { Path2D: d } = V(), l = D({ colorScheme: s }).geomReaders(t);
243
- e.save(), e.translate(r, i), e.scale(a, a);
244
- const c = e, f = /* @__PURE__ */ new Map();
245
- for (const u of t.data) {
246
- const { startAngle: h, endAngle: g } = pt(u), { innerRadius: A, outerRadius: b } = yt(u);
247
- if (h === null || g === null || A === null || b === null) continue;
248
- const E = {
242
+ const r = n.x + n.width / 2, i = n.y + n.height / 2, l = Math.min(n.width, n.height) / 2, { Path2D: d } = z(), a = P({ colorScheme: s }).geomReaders(t);
243
+ e.save(), e.translate(r, i), e.scale(l, l);
244
+ const c = e, u = /* @__PURE__ */ new Map();
245
+ for (const f of t.data) {
246
+ const { startAngle: h, endAngle: g } = bt(f), { innerRadius: A, outerRadius: p } = yt(f);
247
+ if (h === null || g === null || A === null || p === null) continue;
248
+ const b = {
249
249
  startAngle: h,
250
250
  endAngle: g,
251
251
  innerRadius: A,
252
- outerRadius: b,
253
- fill: l.get("color", u),
254
- opacity: l.get("alpha", u)
255
- }, p = Tt(o.bandAxis, E), R = f.get(p);
256
- R ? R.items.push(E) : f.set(p, {
257
- items: [E],
252
+ outerRadius: p,
253
+ fill: a.get("color", f),
254
+ opacity: a.get("alpha", f)
255
+ }, y = Tt(o.bandAxis, b), S = u.get(y);
256
+ S ? S.items.push(b) : u.set(y, {
257
+ items: [b],
258
258
  style: {
259
- borderColor: l.get("borderColor", u),
260
- borderWidth: l.get("borderWidth", u),
261
- borderRadius: l.get("borderRadius", u),
262
- borderAlpha: l.get("alpha", u)
259
+ borderColor: a.get("borderColor", f),
260
+ borderWidth: a.get("borderWidth", f),
261
+ borderRadius: a.get("borderRadius", f),
262
+ borderAlpha: a.get("alpha", f)
263
263
  }
264
264
  });
265
265
  }
266
- for (const { items: u, style: h } of f.values()) {
267
- const { borderColor: g, borderRadius: A, borderWidth: b, borderAlpha: E } = h, p = Ie(b), R = g !== void 0 && a > 0, y = Et(u), m = St(A, y.outerRadius - y.innerRadius), v = a > 0 && (R || m > 0);
266
+ for (const { items: f, style: h } of u.values()) {
267
+ const { borderColor: g, borderRadius: A, borderWidth: p, borderAlpha: b } = h, y = ve(p), S = g !== void 0 && l > 0, T = St(f), m = Et(A, T.outerRadius - T.innerRadius), w = l > 0 && (S || m > 0);
268
268
  e.save();
269
269
  let L;
270
- v && (L = new d(), H.cornerRadius(m), H.context(L)(y), e.clip(L)), H.cornerRadius(0);
271
- for (const J of u)
272
- e.globalAlpha = J.opacity, e.fillStyle = J.fill, e.beginPath(), H.context(c)(J), e.fill(), R && (e.strokeStyle = g, e.lineWidth = p.separatorWidth / a, e.stroke());
273
- R && L && (e.globalAlpha = E, e.strokeStyle = g, e.lineWidth = p.outlineWidth / a, e.stroke(L)), e.restore();
270
+ w && (L = new d(), M.cornerRadius(m), M.context(L)(T), e.clip(L)), M.cornerRadius(0);
271
+ for (const k of f)
272
+ e.globalAlpha = k.opacity, e.fillStyle = k.fill, e.beginPath(), M.context(c)(k), e.fill(), S && (e.strokeStyle = g, e.lineWidth = y.separatorWidth / l, e.stroke());
273
+ S && L && (e.globalAlpha = b, e.strokeStyle = g, e.lineWidth = y.outlineWidth / l, e.stroke(L)), e.restore();
274
274
  }
275
275
  e.restore();
276
276
  }
277
- }), no = {
278
- bar: { cartesian: Vt, polar: oo },
279
- line: { cartesian: zt },
280
- area: { cartesian: Wt },
281
- point: { cartesian: Yt },
282
- rule: { cartesian: to }
283
- }, Fe = (e, t) => (
277
+ }), lo = {
278
+ bar: { cartesian: qt, polar: ao },
279
+ line: { cartesian: Zt },
280
+ area: { cartesian: Yt },
281
+ point: { cartesian: Jt },
282
+ rule: { cartesian: io }
283
+ }, Oe = (e, t) => (
284
284
  // `CompiledLayer.geom` is a plain string (a custom geom carries a name outside `GeomName`); the
285
285
  // node renderer ships only built-ins, so an unregistered name simply resolves to `null`.
286
- no[e.geom]?.[t.type] ?? null
287
- ), ro = (e, t, o) => {
286
+ lo[e.geom]?.[t.type] ?? null
287
+ ), co = (e, t, o) => {
288
288
  e.draw(t, o);
289
289
  };
290
- let Ae;
291
- const Oe = () => (Ae ??= Lt(), Ae), He = [
290
+ let be;
291
+ const Fe = () => (be ??= Lt(), be), He = [
292
292
  "line",
293
293
  "areaStacked",
294
294
  "bar",
@@ -302,139 +302,151 @@ const Oe = () => (Ae ??= Lt(), Ae), He = [
302
302
  "donut",
303
303
  "scatter",
304
304
  "bubble"
305
- ], so = [
305
+ ], fo = [
306
306
  "funnel",
307
307
  "heatmap",
308
308
  "waterfall",
309
309
  "mekko",
310
310
  "table"
311
- ], io = new Set(He), Fn = {
311
+ ], uo = new Set(He), Dn = {
312
312
  supportedGraphTypes: [...He],
313
- unsupportedGraphTypes: [...so],
313
+ unsupportedGraphTypes: [...fo],
314
314
  supportedGeoms: {
315
315
  cartesian: ["bar", "line", "area", "point", "rule"],
316
316
  polar: ["bar"]
317
317
  }
318
- }, C = (e) => ({ ok: !1, reason: e }), j = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ao = (e) => {
319
- if (!j(e)) return !1;
318
+ }, I = (e) => ({ ok: !1, reason: e }), Q = (e) => typeof e == "object" && e !== null && !Array.isArray(e), ho = (e) => {
319
+ if (!Q(e)) return !1;
320
320
  const { columns: t, rows: o } = e;
321
- return !Array.isArray(t) || !Array.isArray(o) ? !1 : t.every((n) => j(n) && typeof n.key == "string");
322
- }, lo = (e) => {
321
+ return !Array.isArray(t) || !Array.isArray(o) ? !1 : t.every((n) => Q(n) && typeof n.key == "string");
322
+ }, go = (e) => {
323
323
  if ("_unstable_mapping" in e && e._unstable_mapping !== void 0) return !0;
324
324
  const t = e.referenceLines;
325
- return j(t) ? t.trendline !== void 0 || t.averageLine !== void 0 : !1;
326
- }, co = (e) => {
327
- if (!j(e))
328
- return C("Chart config must be a plain object.");
329
- if (!ao(e.data))
330
- return C("Chart config is missing a valid `data` object (columns + rows).");
325
+ return Q(t) ? t.trendline !== void 0 || t.averageLine !== void 0 : !1;
326
+ }, mo = (e) => {
327
+ if (!Q(e))
328
+ return I("Chart config must be a plain object.");
329
+ if (!ho(e.data))
330
+ return I("Chart config is missing a valid `data` object (columns + rows).");
331
331
  const { data: t, ...o } = e;
332
332
  return { ok: !0, input: o, data: t };
333
- }, fo = (e) => {
334
- const t = co(e);
333
+ }, po = (e) => {
334
+ const t = mo(e);
335
335
  if (!t.ok) return t;
336
- if (lo(e))
337
- return C(
336
+ if (go(e))
337
+ return I(
338
338
  "Canvas renderer does not support `_unstable_mapping`, `referenceLines.trendline`, or `referenceLines.averageLine`."
339
339
  );
340
340
  const o = t.input.type ?? "column";
341
- if (!io.has(o))
342
- return C(`Unsupported chart type for canvas rendering: ${o}.`);
341
+ if (!uo.has(o))
342
+ return I(`Unsupported chart type for canvas rendering: ${o}.`);
343
343
  try {
344
- const n = Oe(), s = rt(t.input, t.data), r = n.compile({ input: s, data: t.data });
344
+ const n = Fe(), s = rt(t.input, t.data), r = n.compile({ input: s, data: t.data });
345
345
  if (!r.ok)
346
- return C(
346
+ return I(
347
347
  `Chart config failed to compile: ${r.errors.map((i) => i.message).join("; ")}`
348
348
  );
349
349
  for (const i of r.compiled.layers)
350
- if (Fe(i, r.compiled.coordSystem) === null)
351
- return C(`No canvas geom renderer for ${i.geom} (${r.compiled.coordSystem.type} coord).`);
350
+ if (Oe(i, r.compiled.coordSystem) === null)
351
+ return I(`No canvas geom renderer for ${i.geom} (${r.compiled.coordSystem.type} coord).`);
352
352
  return { ok: !0, compiled: r.compiled };
353
353
  } catch (n) {
354
354
  const s = n instanceof Error ? n.message : String(n);
355
- return C(`Chart config failed to compile: ${s}`);
355
+ return I(`Chart config failed to compile: ${s}`);
356
356
  }
357
- }, z = 6, q = 10, uo = 20, le = T, de = 12, Me = T, G = 12, ce = 1.3, U = 10, W = 12, k = 6, Ge = 16, ho = 24, Ue = 6, We = 3, se = 4, go = 8, mo = "#9ca3af", Ve = 16, Ao = 1.3, Ke = 13, bo = 1.4, Xe = 12, po = 1.4, Q = 8, fe = 12, yo = 1.3, To = 200, Eo = 120, So = 80, ze = 22, Lo = 9, Ro = 11, wo = 10, Y = 9, be = 12, _o = '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif', Io = 11.5, Bo = 550, No = { light: 0.55, mid: 0.75, dark: 0.08 }, Co = { light: 0.62, mid: 0.8, dark: 0.85 }, vo = 0.22, Po = 0.65, ko = T, Do = 12, Fo = { family: le, size: de }, Oo = { family: ko, size: Do }, Ho = { family: Me, size: G }, Mo = 8, pe = 1, Go = [2, 3], Uo = [1, 3], Wo = (e, t, o, n, s) => {
357
+ }, Me = E, W = 12, de = 1.3, V = 10, K = 12, O = 6, Ge = 16, Ao = 24, Ue = 6, We = 3, se = 4, bo = 8, yo = "#9ca3af", Ve = 16, To = 1.3, Ke = 13, So = 1.4, ze = 12, Eo = 1.4, Z = 8, ce = 12, Lo = 1.3, Ro = 200, wo = 120, Bo = 80, Xe = 22, vo = 9, _o = 11, Co = 10, q = 9, ye = 12, No = '-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif', Io = 11.5, Po = 550, ko = { light: 0.55, mid: 0.75, dark: 0.08 }, Do = { light: 0.62, mid: 0.8, dark: 0.85 }, Oo = 0.22, Fo = 0.65, Ho = { family: Me, size: W }, Mo = [2, 3], Go = [1, 3], ie = (e) => {
358
+ switch (e) {
359
+ case "dashed":
360
+ return Mo;
361
+ case "dotted":
362
+ return Go;
363
+ case "solid":
364
+ return [];
365
+ }
366
+ }, Uo = (e, t, o, n, s, r) => {
358
367
  if (!t.isVisible || t.ticks.length === 0) return;
359
- const r = t.position === "bottom" || t.position === "top", i = t.ticksVisible ? 1 : 0;
360
- e.save(), e.font = S(Fo), e.fillStyle = s.textSecondary, e.strokeStyle = s.gridLine, e.lineWidth = 1, e.setLineDash([]);
361
- for (const a of t.ticks) {
362
- const d = r ? a.position : 1 - a.position;
363
- t.ticksVisible && Ko(e, t.position, d, o, n), zo(
368
+ const i = t.position === "bottom" || t.position === "top";
369
+ e.save(), e.font = R(J(s, E)), e.fillStyle = s.textColor, e.strokeStyle = r.color, e.lineWidth = r.strokeWidth, e.setLineDash(ie(r.lineType));
370
+ for (const l of t.ticks) {
371
+ const d = i ? l.position : 1 - l.position;
372
+ t.ticksVisible && Vo(e, t.position, d, o, n, r.length), zo(
364
373
  e,
365
374
  t.position,
366
375
  d,
367
376
  o,
368
377
  n,
369
- a.formattedLabel,
378
+ l.formattedLabel,
370
379
  t.labelRotation,
371
- i
380
+ s.offset
372
381
  );
373
382
  }
374
383
  e.restore();
375
- }, Vo = (e, t, o, n) => {
384
+ }, Wo = (e, t, o, n, s) => {
376
385
  if (e === "bottom" || e === "top") {
377
- const a = n.x + t * n.width, d = e === "top" ? o.y + o.height : o.y, l = e === "top" ? -z : z;
378
- return { x1: a, y1: d, x2: a, y2: d + l };
379
- }
380
- const s = n.y + t * n.height, r = e === "right" ? o.x : o.x + o.width, i = e === "right" ? z : -z;
381
- return { x1: r, y1: s, x2: r + i, y2: s };
386
+ const d = n.x + t * n.width, a = e === "top" ? o.y + o.height : o.y, c = e === "top" ? -s : s;
387
+ return { x1: d, y1: a, x2: d, y2: a + c };
388
+ }
389
+ const r = n.y + t * n.height, i = e === "right" ? o.x : o.x + o.width, l = e === "right" ? s : -s;
390
+ return { x1: i, y1: r, x2: i + l, y2: r };
391
+ }, Vo = (e, t, o, n, s, r) => {
392
+ const { x1: i, y1: l, x2: d, y2: a } = Wo(t, o, n, s, r);
393
+ e.beginPath(), e.moveTo(i, l), e.lineTo(d, a), e.stroke();
382
394
  }, Ko = (e, t, o, n, s) => {
383
- const { x1: r, y1: i, x2: a, y2: d } = Vo(t, o, n, s);
384
- e.beginPath(), e.moveTo(r, i), e.lineTo(a, d), e.stroke();
385
- }, Xo = (e, t, o, n, s) => {
386
395
  if (e === "bottom" || e === "top") {
387
396
  const i = n.x + t * n.width;
388
397
  return e === "bottom" ? { x: i, y: o.y + s, textAlign: "center", textBaseline: "top" } : { x: i, y: o.y + o.height - s, textAlign: "center", textBaseline: "alphabetic" };
389
398
  }
390
399
  const r = n.y + t * n.height;
391
400
  return e === "left" ? { x: o.x + o.width - s, y: r, textAlign: "right", textBaseline: "middle" } : { x: o.x + s, y: r, textAlign: "left", textBaseline: "middle" };
392
- }, zo = (e, t, o, n, s, r, i, a) => {
393
- const d = q * a;
401
+ }, zo = (e, t, o, n, s, r, i, l) => {
394
402
  if (i !== 0 && (t === "top" || t === "bottom")) {
395
- const c = s.x + o * s.width, f = t === "top";
396
- e.save(), e.translate(c, f ? n.y + n.height - d : n.y + d), e.rotate(i * Math.PI / 180), e.textAlign = f ? "left" : "right", e.textBaseline = "middle", e.fillText(r, 0, 0), e.restore();
403
+ const a = s.x + o * s.width, c = t === "top";
404
+ e.save(), e.translate(a, c ? n.y + n.height - l : n.y + l), e.rotate(i * Math.PI / 180), e.textAlign = c ? "left" : "right", e.textBaseline = "middle", e.fillText(r, 0, 0), e.restore();
397
405
  return;
398
406
  }
399
- const l = Xo(t, o, n, s, d);
400
- e.textAlign = l.textAlign, e.textBaseline = l.textBaseline, e.fillText(r, l.x, l.y);
401
- }, Yo = (e, t, o, n) => {
407
+ const d = Ko(t, o, n, s, l);
408
+ e.textAlign = d.textAlign, e.textBaseline = d.textBaseline, e.fillText(r, d.x, d.y);
409
+ }, Xo = (e, t, o, n) => {
402
410
  if (!t.isVisible || !t.label) return;
403
- e.save(), e.font = S(Oo), e.fillStyle = n.textPrimary, e.textBaseline = "middle";
404
- const { x: s, y: r, alignment: i } = qo(t.position, o);
411
+ e.save(), e.font = R({
412
+ family: n.fontFamily ?? E,
413
+ size: n.fontSize,
414
+ weight: n.fontWeight
415
+ }), e.fillStyle = n.textColor, e.textBaseline = "middle";
416
+ const { x: s, y: r, alignment: i } = Yo(t.position, o);
405
417
  e.textAlign = i, e.fillText(t.label, s, r), e.restore();
406
- }, qo = (e, t) => {
418
+ }, Yo = (e, t) => {
407
419
  const o = t.y + t.height / 2;
408
420
  return e === "left" ? { x: t.x, y: o, alignment: "start" } : e === "right" ? { x: t.x + t.width, y: o, alignment: "end" } : { x: t.x + t.width / 2, y: o, alignment: "center" };
409
- }, Zo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEoAAABgCAYAAAC65+QhAAAKo0lEQVR42u2de4wdVR3HPzN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EGZtW3kNisBcTSLU0QAdxK0CZe2uWzQt5HpVWNTLWA0rXrHzaMZnAm5J2LovK7DdEXUmsiaclcj8zbyf84+amscxK3EagLK/Be6hyouQlzhrHUYKcSOHhrIikbmi0N3lrAupHzINbBVSgCmfg2lb/2CCV0bxUVZ803FJJduhBsXlNMSNeZwYZKUq142oQjUqYv997eSp74p0JXJlZ7jeDYxCqZYdKhhbuw4Z2pOHYcQ1V1gxLbXRUim/TTXSo+3v5ZPUTRlqz0q0VxQ4dMgQ5SXSRC1IwPLfVdLdX1mF4Lkr5Ybfii8rLixlLcvlgg2o2JaFCLXevpejXEnm3fLOcR/rTNUizYsU2OCxiP9+EhOUByIcqRxUYtSi595o2/7a00nqwblHiW4t25Jh4mZM5wcpjhxZkUg4qd2/tUKzA/LhyEm1fJvM3v5ynklIVE8gjYgkrdhp67EaZfjTj4XEce8eJFDtUxNFLnrcStNsFBdpNhpRYq2OkOOw8RdtCE7y+3psNSVwUp9ih+2gduU1L2Fmfh/t2jIUUNrJJkbBhxQIU5+Dy3SdSVEpx949JcNpV1NraW7wKxxhWj2ezIi+7VxJrq1o2DivhNr0OS9qUBFCkvN4XgDO6lazdphrvVJUFD5j1jmV5+QdMOFExzD3jGdKOGLcud1Gv0P/rGVyH29B6MiWcmBbARiVAHBNg9srvsqQdV3cDIXuz9ut88Tpp4cSi5I77RSWLGdKOGxUoBXq0Z8cW2C7D8X+n0XFXUtz9nJRhz1lt3xJkFxdvUMV7b7/K5tuAdEStpWgr8MpeVbNGVoHPwG20n6lBs21DhiGVLK9agOrZrwtxq7ePGm48X5PfgeuJWdvN381CG7+pIlBbfryEXCJpxlqRtBG10oHa6NXVx/8Ba+cluUx5B18AAAAASUVORK5CYII=", N = Xe;
410
422
  let ee;
411
423
  const jo = () => {
412
424
  if (ee) return ee;
413
- const { Image: e } = V(), t = new e(), o = Zo.replace(/^data:image\/png;base64,/, "");
414
- return t.src = Ct.from(o, "base64"), ee = t, t;
415
- }, Ye = (e, t, o = "full") => !e || t.width < Eo || t.height < So ? "hidden" : t.width < To || o === "mini" ? "mini" : "full", Qo = (e) => {
416
- const t = Jo(e);
425
+ const { Image: e } = z(), t = new e(), o = qo.replace(/^data:image\/png;base64,/, "");
426
+ return t.src = Ot.from(o, "base64"), ee = t, t;
427
+ }, Ye = (e, t, o = "full") => !e || t.width < wo || t.height < Bo ? "hidden" : t.width < Ro || o === "mini" ? "mini" : "full", Qo = (e) => {
428
+ const t = Zo(e);
417
429
  if (t === null) return "light";
418
- const o = $o(t);
419
- return o <= vo ? "dark" : o <= Po ? "mid" : "light";
420
- }, ie = (e, t, o) => e.placement !== o || Ye(e.enabled, t, e.variant) === "hidden" ? 0 : ze, qe = (e, t, o, n, s, r) => {
430
+ const o = Jo(t);
431
+ return o <= Oo ? "dark" : o <= Fo ? "mid" : "light";
432
+ }, ae = (e, t, o) => e.placement !== o || Ye(e.enabled, t, e.variant) === "hidden" ? 0 : Xe, qe = (e, t, o, n, s, r) => {
421
433
  if (t.placement !== r) return;
422
434
  const i = Ye(t.enabled, s, t.variant);
423
435
  if (i === "hidden") return;
424
- const a = Qo(n.background), d = a === "dark", l = { family: _o, size: Io, weight: 400 }, c = { ...l, weight: Bo };
425
- let f = 0;
426
- i === "full" && (e.font = S(l), f = e.measureText("Made with ").width, e.font = S(c), f += e.measureText("Graphy").width);
427
- const u = i === "mini" ? 0 : Lo, h = i === "mini" ? 0 : Ro, g = i === "mini" ? 0 : wo, A = i === "mini" ? N : u + Y + g + f + h, b = o.x + o.width - A, E = o.y + Math.max(0, (o.height || N) / 2 - N / 2);
428
- e.save(), e.globalAlpha = Co[a], e.textBaseline = "middle", e.textAlign = "left", d || (e.shadowColor = "rgba(0, 0, 0, 0.09)", e.shadowBlur = 4, e.shadowOffsetY = 1), e.beginPath(), e.roundRect(b, E, A, N, N / 2), e.fillStyle = `rgba(255, 255, 255, ${No[a]})`, e.fill(), e.shadowColor = "transparent", e.shadowBlur = 0, e.shadowOffsetY = 0;
429
- const p = d ? "#FFFFFF" : "#2A2A28", R = i === "mini" ? b + (A - Y) / 2 : b + u, y = E + (N - be) / 2;
430
- if (e.save(), d && (e.filter = "invert(1)"), e.drawImage(jo(), R, y, Y, be), e.restore(), i === "full") {
431
- const m = b + u + Y + g, v = E + N / 2;
432
- e.fillStyle = p, e.font = S(l), e.fillText("Made with ", m, v);
436
+ const l = Qo(n.background), d = l === "dark", a = { family: No, size: Io, weight: 400 }, c = { ...a, weight: Po };
437
+ let u = 0;
438
+ i === "full" && (e.font = R(a), u = e.measureText("Made with ").width, e.font = R(c), u += e.measureText("Graphy").width);
439
+ const f = i === "mini" ? 0 : vo, h = i === "mini" ? 0 : _o, g = i === "mini" ? 0 : Co, A = i === "mini" ? N : f + q + g + u + h, p = o.x + o.width - A, b = o.y + Math.max(0, (o.height || N) / 2 - N / 2);
440
+ e.save(), e.globalAlpha = Do[l], e.textBaseline = "middle", e.textAlign = "left", d || (e.shadowColor = "rgba(0, 0, 0, 0.09)", e.shadowBlur = 4, e.shadowOffsetY = 1), e.beginPath(), e.roundRect(p, b, A, N, N / 2), e.fillStyle = `rgba(255, 255, 255, ${ko[l]})`, e.fill(), e.shadowColor = "transparent", e.shadowBlur = 0, e.shadowOffsetY = 0;
441
+ const y = d ? "#FFFFFF" : "#2A2A28", S = i === "mini" ? p + (A - q) / 2 : p + f, T = b + (N - ye) / 2;
442
+ if (e.save(), d && (e.filter = "invert(1)"), e.drawImage(jo(), S, T, q, ye), e.restore(), i === "full") {
443
+ const m = p + f + q + g, w = b + N / 2;
444
+ e.fillStyle = y, e.font = R(a), e.fillText("Made with ", m, w);
433
445
  const L = e.measureText("Made with ").width;
434
- e.font = S(c), e.fillText("Graphy", m + L, v);
446
+ e.font = R(c), e.fillText("Graphy", m + L, w);
435
447
  }
436
448
  e.restore();
437
- }, Jo = (e) => {
449
+ }, Zo = (e) => {
438
450
  const t = e.trim();
439
451
  if (!t.startsWith("#")) return null;
440
452
  const o = t.slice(1);
@@ -451,13 +463,13 @@ const jo = () => {
451
463
  green: Number.parseInt(o.slice(2, 4), 16),
452
464
  blue: Number.parseInt(o.slice(4, 6), 16)
453
465
  } : null;
454
- }, $o = ({ red: e, green: t, blue: o }) => {
466
+ }, Jo = ({ red: e, green: t, blue: o }) => {
455
467
  const n = (s) => {
456
468
  const r = s / 255;
457
469
  return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
458
470
  };
459
471
  return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
460
- }, xo = { family: T, size: Ve, weight: 600 }, en = { family: T, size: Ke }, tn = { family: T, size: Xe }, on = { family: T, size: fe, weight: 500 }, nn = { family: T, size: fe }, Ze = Ve * Ao, rn = Ke * bo, je = Xe * po, Qe = fe * yo, Je = (e) => {
472
+ }, $o = { family: E, size: Ve, weight: 600 }, xo = { family: E, size: Ke }, en = { family: E, size: ze }, tn = { family: E, size: ce, weight: 500 }, on = { family: E, size: ce }, je = Ve * To, nn = Ke * So, Qe = ze * Eo, Ze = ce * Lo, Je = (e) => {
461
473
  if (e === null) return null;
462
474
  if (e.label !== void 0 && e.label !== "") return e.label;
463
475
  if (e.url !== void 0 && e.url !== "" && Rt(e.url))
@@ -467,70 +479,61 @@ const jo = () => {
467
479
  return e.url;
468
480
  }
469
481
  return null;
470
- }, sn = (e, t) => {
482
+ }, rn = (e, t) => {
471
483
  let o = 0;
472
484
  const n = e.isTitleVisible && e.title !== null, s = e.isSubtitleVisible && e.subtitle !== null;
473
- n && (o += Ze), s && (o > 0 && (o += Q), o += rn);
474
- const r = ie(e.brandMark, t, "header");
485
+ n && (o += je), s && (o > 0 && (o += Z), o += nn);
486
+ const r = ae(e.brandMark, t, "header");
475
487
  !n && !s && r > 0 && (o = r);
476
- const i = e.isCaptionVisible && e.caption !== null, a = e.isSourceVisible && Je(e.source) !== null, d = ie(e.brandMark, t, "footer");
477
- let l = 0;
478
- return i && (l += je), (a || d > 0) && (l > 0 && (l += Q), l += Math.max(Qe, d)), { headerHeight: o, footerHeight: l };
479
- }, an = (e, t, o, n, s) => {
488
+ const i = e.isCaptionVisible && e.caption !== null, l = e.isSourceVisible && Je(e.source) !== null, d = ae(e.brandMark, t, "footer");
489
+ let a = 0;
490
+ return i && (a += Qe), (l || d > 0) && (a > 0 && (a += Z), a += Math.max(Ze, d)), { headerHeight: o, footerHeight: a };
491
+ }, sn = (e, t, o, n, s) => {
480
492
  if (o.height === 0) return;
481
493
  e.save(), e.textBaseline = "top", e.textAlign = "left";
482
494
  let r = o.y;
483
- t.isTitleVisible && t.title !== null && (e.font = S(xo), e.fillStyle = n.textPrimary, e.fillText(te(t.title), o.x, r), r += Ze + Q), t.isSubtitleVisible && t.subtitle !== null && (e.font = S(en), e.fillStyle = n.textSecondary, e.fillText(te(t.subtitle), o.x, r)), e.restore(), qe(e, t.brandMark, o, n, s, "header");
484
- }, ln = (e, t, o, n, s) => {
495
+ t.isTitleVisible && t.title !== null && (e.font = R($o), e.fillStyle = n.textPrimary, e.fillText(te(t.title), o.x, r), r += je + Z), t.isSubtitleVisible && t.subtitle !== null && (e.font = R(xo), e.fillStyle = n.textSecondary, e.fillText(te(t.subtitle), o.x, r)), e.restore(), qe(e, t.brandMark, o, n, s, "header");
496
+ }, an = (e, t, o, n, s) => {
485
497
  if (o.height === 0) return;
486
- const r = t.isCaptionVisible ? t.caption : null, i = t.isSourceVisible ? Je(t.source) : null, a = ie(t.brandMark, s, "footer");
487
- if (r === null && i === null && a === 0) return;
498
+ const r = t.isCaptionVisible ? t.caption : null, i = t.isSourceVisible ? Je(t.source) : null, l = ae(t.brandMark, s, "footer");
499
+ if (r === null && i === null && l === 0) return;
488
500
  e.save(), e.textBaseline = "top", e.textAlign = "left";
489
501
  let d = o.y;
490
- if (r !== null && (e.font = S(tn), e.fillStyle = n.textSecondary, e.fillText(te(r), o.x, d), d += je + Q), i !== null) {
491
- let l = o.x;
492
- l = ye(e, "Source: ", on, n.textSecondary, l, d), ye(e, i, nn, n.textSecondary, l, d);
502
+ if (r !== null && (e.font = R(en), e.fillStyle = n.textSecondary, e.fillText(te(r), o.x, d), d += Qe + Z), i !== null) {
503
+ let a = o.x;
504
+ a = Te(e, "Source: ", tn, n.textSecondary, a, d), Te(e, i, on, n.textSecondary, a, d);
493
505
  }
494
506
  e.restore(), qe(
495
507
  e,
496
508
  t.brandMark,
497
- { x: o.x, y: d, width: o.width, height: Math.max(Qe, a) },
509
+ { x: o.x, y: d, width: o.width, height: Math.max(Ze, l) },
498
510
  n,
499
511
  s,
500
512
  "footer"
501
513
  );
502
- }, ye = (e, t, o, n, s, r) => (e.font = S(o), e.fillStyle = n, e.fillText(t, s, r), s + e.measureText(t).width), dn = (e, t, o, n, s) => {
503
- e.save(), e.lineCap = "round", e.strokeStyle = s.gridLine;
504
- for (const r of wt(o.border, n, Mo))
505
- e.lineWidth = r.lineWidth ?? pe, e.setLineDash(Te(r.lineStyle)), cn(e, r.segments), e.stroke();
506
- for (const r of t) {
507
- if (!r.gridVisible) continue;
508
- const i = r.position === "top" || r.position === "bottom";
509
- e.lineWidth = r.gridLineWidth ?? pe, e.setLineDash(Te(r.gridLineStyle));
510
- for (const a of r.ticks) {
511
- if (a.position <= 0 || a.position >= 1) continue;
512
- const d = i ? a.position : 1 - a.position;
513
- if (e.beginPath(), i) {
514
- const l = n.x + d * n.width;
515
- e.moveTo(l, n.y), e.lineTo(l, n.y + n.height);
514
+ }, Te = (e, t, o, n, s, r) => (e.font = R(o), e.fillStyle = n, e.fillText(t, s, r), s + e.measureText(t).width), ln = (e, t, o, n) => {
515
+ e.save(), e.lineCap = "round";
516
+ for (const s of wt(Bt(o), n))
517
+ e.strokeStyle = s.color, e.lineWidth = s.strokeWidth, e.setLineDash(ie(s.lineType)), dn(e, s.segments), e.stroke();
518
+ for (const s of t) {
519
+ if (!s.gridVisible) continue;
520
+ const r = s.position === "top" || s.position === "bottom", i = vt(o, U(s.scaleAestheticKey));
521
+ e.strokeStyle = i.color, e.lineWidth = i.strokeWidth, e.setLineDash(ie(i.lineType));
522
+ for (const l of s.ticks) {
523
+ if (l.position <= 0 || l.position >= 1) continue;
524
+ const d = r ? l.position : 1 - l.position;
525
+ if (e.beginPath(), r) {
526
+ const a = n.x + d * n.width;
527
+ e.moveTo(a, n.y), e.lineTo(a, n.y + n.height);
516
528
  } else {
517
- const l = n.y + d * n.height;
518
- e.moveTo(n.x, l), e.lineTo(n.x + n.width, l);
529
+ const a = n.y + d * n.height;
530
+ e.moveTo(n.x, a), e.lineTo(n.x + n.width, a);
519
531
  }
520
532
  e.stroke();
521
533
  }
522
534
  }
523
535
  e.restore();
524
- }, Te = (e) => {
525
- switch (e) {
526
- case "dashed":
527
- return Go;
528
- case "dotted":
529
- return Uo;
530
- case "solid":
531
- return [];
532
- }
533
- }, cn = (e, t) => {
536
+ }, dn = (e, t) => {
534
537
  e.beginPath();
535
538
  for (const o of t)
536
539
  switch (o.type) {
@@ -547,10 +550,10 @@ const jo = () => {
547
550
  e.closePath();
548
551
  break;
549
552
  }
550
- }, fn = (e, t, o, n) => {
551
- e.save(), e.font = S(Ho), e.textBaseline = "middle";
553
+ }, cn = (e, t, o, n) => {
554
+ e.save(), e.font = R(Ho), e.textBaseline = "middle";
552
555
  for (const r of t)
553
- r.display === "direct" && un(e, r, o, n);
556
+ r.display === "direct" && fn(e, r, o, n);
554
557
  const s = /* @__PURE__ */ new Map();
555
558
  for (const r of t) {
556
559
  if (r.display !== "pill" || r.items.length === 0) continue;
@@ -558,135 +561,136 @@ const jo = () => {
558
561
  i ? i.push(r) : s.set(r.position, [r]);
559
562
  }
560
563
  for (const [r, i] of s) {
561
- const a = o[r];
562
- a && (r === "top" || r === "bottom" ? hn(e, i, a, n) : gn(e, i, a, n));
564
+ const l = o[r];
565
+ l && (r === "top" || r === "bottom" ? un(e, i, l, n) : hn(e, i, l, n));
563
566
  }
564
567
  e.restore();
565
- }, un = (e, t, o, n) => {
568
+ }, fn = (e, t, o, n) => {
566
569
  const s = o[t.position];
567
570
  if (s) {
568
571
  e.textAlign = "left";
569
572
  for (const r of t.items)
570
- r.normalizedY !== null && (e.fillStyle = typeof r.visual.color == "string" ? r.visual.color : n.textPrimary, e.fillText(r.formattedLabel, s.x + go, I(s, r.normalizedY)));
573
+ r.normalizedY !== null && (e.fillStyle = typeof r.visual.color == "string" ? r.visual.color : n.textPrimary, e.fillText(r.formattedLabel, s.x + bo, _(s, r.normalizedY)));
571
574
  }
572
- }, hn = (e, t, o, n) => {
575
+ }, un = (e, t, o, n) => {
573
576
  const s = $e(t), r = s.reduce(
574
- (l, c, f) => l + An(c) + e.measureText(c.label).width + (f === 0 ? 0 : Ee(c)),
577
+ (a, c, u) => a + mn(c) + e.measureText(c.label).width + (u === 0 ? 0 : Se(c)),
575
578
  0
576
- ), i = G * ce;
577
- let a = o.x + Math.max(0, (o.width - r) / 2);
578
- const d = o.y + Ue + Math.max(i, W) / 2;
579
- for (let l = 0; l < s.length; l++) {
580
- const c = s[l];
581
- c && (l > 0 && (a += Ee(c)), a = xe(e, c, a, d, n));
582
- }
583
- }, gn = (e, t, o, n) => {
584
- const s = $e(t), r = Math.max(G * ce, W), i = 4, a = s.length * r + Math.max(0, s.length - 1) * i;
585
- let d = o.y + Math.max(0, (o.height - a) / 2) + r / 2;
586
- for (const l of s)
587
- xe(e, l, o.x, d, n), d += r + i;
579
+ ), i = W * de;
580
+ let l = o.x + Math.max(0, (o.width - r) / 2);
581
+ const d = o.y + Ue + Math.max(i, K) / 2;
582
+ for (let a = 0; a < s.length; a++) {
583
+ const c = s[a];
584
+ c && (a > 0 && (l += Se(c)), l = xe(e, c, l, d, n));
585
+ }
586
+ }, hn = (e, t, o, n) => {
587
+ const s = $e(t), r = Math.max(W * de, K), i = 4, l = s.length * r + Math.max(0, s.length - 1) * i;
588
+ let d = o.y + Math.max(0, (o.height - l) / 2) + r / 2;
589
+ for (const a of s)
590
+ xe(e, a, o.x, d, n), d += r + i;
588
591
  }, $e = (e) => {
589
592
  const t = [];
590
593
  for (const o of e) {
591
594
  const n = o.aesthetics.includes("size");
592
595
  o.items.forEach((s, r) => {
593
- const i = s.visual.size, a = n && typeof i == "number" && Number.isFinite(i) && i > 0 ? i : void 0;
596
+ const i = s.visual.size, l = n && typeof i == "number" && Number.isFinite(i) && i > 0 ? i : void 0;
594
597
  t.push({
595
598
  label: s.formattedLabel,
596
- colors: mn(s.visual.color),
597
- bubbleSize: a,
599
+ colors: gn(s.visual.color),
600
+ bubbleSize: l,
598
601
  isFirstInGroup: r === 0
599
602
  });
600
603
  });
601
604
  }
602
605
  return t;
603
- }, mn = (e) => typeof e == "string" ? [e] : Array.isArray(e) ? e.filter((t) => typeof t == "string") : [], Ee = (e) => e.isFirstInGroup ? ho : Ge, An = (e) => {
604
- if (e.bubbleSize !== void 0) return e.bubbleSize + k;
606
+ }, gn = (e) => typeof e == "string" ? [e] : Array.isArray(e) ? e.filter((t) => typeof t == "string") : [], Se = (e) => e.isFirstInGroup ? Ao : Ge, mn = (e) => {
607
+ if (e.bubbleSize !== void 0) return e.bubbleSize + O;
605
608
  const t = e.colors.length;
606
609
  if (t === 0) return 0;
607
- if (t === 1) return U + k;
610
+ if (t === 1) return V + O;
608
611
  const o = Math.min(t, We);
609
- return U + (o - 1) * se + k;
612
+ return V + (o - 1) * se + O;
610
613
  }, xe = (e, t, o, n, s) => {
611
614
  let r = o;
612
615
  if (t.bubbleSize !== void 0) {
613
616
  const i = t.bubbleSize / 2;
614
- e.fillStyle = t.colors[0] ?? mo, e.beginPath(), e.arc(r + i, n, i, 0, Math.PI * 2), e.fill(), r += t.bubbleSize + k;
617
+ e.fillStyle = t.colors[0] ?? yo, e.beginPath(), e.arc(r + i, n, i, 0, Math.PI * 2), e.fill(), r += t.bubbleSize + O;
615
618
  } else if (t.colors.length > 0) {
616
619
  const i = t.colors.slice(0, We);
617
- for (let a = 0; a < i.length; a++) {
618
- const d = i[a];
620
+ for (let l = 0; l < i.length; l++) {
621
+ const d = i[l];
619
622
  d && (e.fillStyle = d, e.fillRect(
620
- r + a * se,
621
- n - W / 2,
622
- U,
623
- W
623
+ r + l * se,
624
+ n - K / 2,
625
+ V,
626
+ K
624
627
  ));
625
628
  }
626
- r += U + (i.length - 1) * se + k;
629
+ r += V + (i.length - 1) * se + O;
627
630
  }
628
631
  return e.fillStyle = s.textPrimary, e.textAlign = "left", e.fillText(t.label, r, n), r + e.measureText(t.label).width;
629
- }, Se = (e, t) => Math.min(Math.max(...e), t), bn = (e) => (t) => {
630
- if (!t.isVisible || t.ticks.length === 0) return 0;
631
- const o = t.position === "top" || t.position === "bottom", n = t.ticks.map(
632
- (i) => e.measureText(i.formattedLabel, {
633
- family: le,
634
- size: de
635
- })
636
- ), s = t.labelMaxWidthPx ?? Number.POSITIVE_INFINITY;
637
- if (o) {
638
- if (t.labelRotation !== 0) {
639
- const i = n.map((a) => a.width);
640
- return Se(i, s) + 2 * q;
632
+ }, Ee = (e, t) => Math.min(Math.max(...e), t), pn = (e, t, o) => (n) => {
633
+ if (!n.isVisible || n.ticks.length === 0) return 0;
634
+ const s = n.position === "top" || n.position === "bottom", r = U(n.scaleAestheticKey), { offset: i, ...l } = t[r], d = n.ticksVisible ? Math.max(i, o[r].length) : i, a = J(l, E), c = n.ticks.map((h) => e.measureText(h.formattedLabel, a)), u = n.labelMaxWidthPx ?? Number.POSITIVE_INFINITY;
635
+ if (s) {
636
+ if (n.labelRotation !== 0) {
637
+ const h = c.map((g) => g.width);
638
+ return Ee(h, u) + 2 * d;
641
639
  }
642
- return Math.max(...n.map((i) => i.height)) + q;
640
+ return Math.max(...c.map((h) => h.height)) + d;
643
641
  }
644
- const r = n.map((i) => i.width);
645
- return Se(r, s) + q;
646
- }, pn = (e) => (t) => {
642
+ const f = c.map((h) => h.width);
643
+ return Ee(f, u) + d;
644
+ }, An = (e) => (t) => {
647
645
  if (t.items.length === 0) return 0;
648
- const o = { family: Me, size: G };
646
+ const o = { family: Me, size: W };
649
647
  if (t.position === "top" || t.position === "bottom") {
650
- const r = G * ce;
651
- return Math.max(r, W) + Ue * 2;
648
+ const r = W * de;
649
+ return Math.max(r, K) + Ue * 2;
652
650
  }
653
651
  const s = t.items.map((r) => {
654
652
  const i = e.measureText(r.formattedLabel, o).width;
655
- return U + k + i;
653
+ return V + O + i;
656
654
  });
657
655
  return Math.max(...s) + Ge;
658
- }, yn = (e) => (t, o) => {
659
- const { labelLineHeight: n, labelFontWeight: s } = It(o, 1);
656
+ }, bn = (e) => (t, o) => {
657
+ const { labelLineHeight: n, labelFontWeight: s } = Ct(o, 1);
660
658
  return e.measureText(t, {
661
- family: T,
659
+ family: E,
662
660
  size: n,
663
661
  weight: s
664
662
  });
665
- }, Tn = (e) => (t, o) => {
666
- const { fontSize: n, fontWeight: s } = _t(t, 1);
667
- return e.measureText(o, {
668
- family: T,
669
- size: n,
670
- weight: s
671
- });
672
- }, En = (e) => ({
673
- measureAxis: bn(e),
674
- measureAxisLabel: () => uo,
675
- measureLegend: pn(e),
676
- measureTickLabel: (t) => e.measureText(t, { family: le, size: de }),
677
- measureDifferenceArrowLabel: yn(e),
678
- measureDataLabel: Tn(e),
663
+ }, yn = (e, t) => (o, n, s) => {
664
+ const r = t[o][n], i = e.measureText(s, J(r, E));
665
+ return {
666
+ ...i,
667
+ width: i.width + r.paddingInline * 2,
668
+ height: i.height + r.paddingBlock * 2
669
+ };
670
+ }, Tn = ({
671
+ textMeasurer: e,
672
+ axisLabelStyles: t,
673
+ dataLabelStyles: o,
674
+ tickLabelStyles: n,
675
+ tickLineStyles: s
676
+ }) => ({
677
+ measureAxis: pn(e, n, s),
678
+ measureAxisLabel: (r) => _t(t[U(r.scaleAestheticKey)]),
679
+ measureLegend: An(e),
680
+ measureTickLabel: (r, i) => e.measureText(r, J(n[i], E)),
681
+ measureDifferenceArrowLabel: bn(e),
682
+ measureDataLabel: yn(e, o),
679
683
  measureHeadline: () => ({ width: 0, height: 0 }),
680
684
  measureHeadlineItemWidths: () => []
681
685
  });
682
686
  class Sn {
683
687
  constructor() {
684
688
  this.currentFont = "";
685
- const t = V().createCanvas(1, 1);
689
+ const t = z().createCanvas(1, 1);
686
690
  this.ctx = t.getContext("2d");
687
691
  }
688
692
  measureText(t, o) {
689
- const n = S(o);
693
+ const n = R(o);
690
694
  this.currentFont !== n && (this.ctx.font = n, this.currentFont = n);
691
695
  const s = this.ctx.measureText(t);
692
696
  return {
@@ -697,116 +701,157 @@ class Sn {
697
701
  };
698
702
  }
699
703
  }
700
- const Ln = {
704
+ const En = {
701
705
  background: "#ffffff",
702
706
  textPrimary: "#111827",
703
707
  textSecondary: "#6b7280",
704
708
  gridLine: "#e5e7eb",
705
- panelBorder: "#d1d5db",
706
709
  legendPillBackground: "rgba(0, 0, 0, 0.04)",
707
710
  legendPillBorder: "rgba(0, 0, 0, 0.08)"
708
- }, Rn = {
711
+ }, Ln = {
709
712
  background: "#0b0f17",
710
713
  textPrimary: "#e5e7eb",
711
714
  textSecondary: "#9ca3af",
712
715
  gridLine: "#1f2937",
713
- panelBorder: "#374151",
714
716
  legendPillBackground: "rgba(255, 255, 255, 0.06)",
715
717
  legendPillBorder: "rgba(255, 255, 255, 0.12)"
716
718
  }, On = async ({ input: e, data: t }, o) => {
717
- const s = Oe().compile({ input: e, data: t });
719
+ const s = Fe().compile({ input: e, data: t });
718
720
  if (!s.ok)
719
721
  throw new Error(
720
722
  `Failed to compile graph spec: ${s.errors.map((r) => r.message).join("; ")}`
721
723
  );
722
724
  return et(s.compiled, o);
723
725
  }, et = async (e, t) => {
724
- const { Canvas: o } = await vt();
725
- if (Mt(), t.fonts)
726
- for (const b of t.fonts) Ne(b);
727
- const n = Bt({
726
+ const { Canvas: o } = await Ft();
727
+ if (Kt(), t.fonts)
728
+ for (const w of t.fonts) Ce(w);
729
+ const n = Nt({
728
730
  legends: e.guides.legends.drawn,
729
731
  numberFormat: e.config.numberFormat,
730
732
  parsingLocale: e.config.parsingLocale,
731
733
  formattingLocale: t.formattingLocale
732
- }), s = { width: t.width, height: t.height }, { headerHeight: r, footerHeight: i } = sn(e.config.content, s), a = {
734
+ }), s = { width: t.width, height: t.height }, { headerHeight: r, footerHeight: i } = rn(e.config.content, s), l = {
733
735
  headerSize: { width: t.width, height: r },
734
736
  footerSize: { width: t.width, height: i }
735
- }, d = new Sn(), { layout: l, formattedAxes: c } = new Nt(En(d)).compile({
737
+ }, d = t.colorScheme ?? "light", a = P({ colorScheme: d }).chromeReaders(e.chrome), c = e.config.appearance.textScale, u = {
738
+ x: fe(a, "x", c),
739
+ y: fe(a, "y", c)
740
+ }, f = {
741
+ x: ue(a, "x", c),
742
+ y: ue(a, "y", c)
743
+ }, h = {
744
+ x: he(a, "x"),
745
+ y: he(a, "y")
746
+ }, g = {};
747
+ for (const w of It) {
748
+ const L = {};
749
+ for (const k of Pt)
750
+ L[k] = kt(a, w, k, c);
751
+ g[w] = L;
752
+ }
753
+ const A = new Sn(), p = Tn({
754
+ textMeasurer: A,
755
+ axisLabelStyles: u,
756
+ dataLabelStyles: g,
757
+ tickLabelStyles: f,
758
+ tickLineStyles: h
759
+ }), { layout: b, formattedAxes: y } = new Dt(p).compile({
736
760
  axes: e.guides.axes,
737
761
  numberFormat: e.config.numberFormat,
738
762
  parsingLocale: e.config.parsingLocale,
739
763
  formattedLegends: n,
740
764
  containerSize: { width: t.width, height: t.height },
741
- externalMeasurements: a,
765
+ externalMeasurements: l,
742
766
  formattingLocale: t.formattingLocale,
743
767
  layout: e.config.layout
744
- }), f = t.pixelRatio ?? 2, u = new o(t.width * f, t.height * f), h = u.getContext("2d");
745
- h.scale(f, f);
746
- const g = t.colorScheme ?? "light";
747
- return wn(
748
- h,
749
- g === "dark" ? Rn : Ln,
750
- g,
751
- t.width,
752
- t.height,
753
- e,
754
- c,
755
- n,
756
- l,
757
- d,
758
- t.formattingLocale
759
- ), u.encode("png");
760
- }, wn = (e, t, o, n, s, r, i, a, d, l, c) => {
761
- e.fillStyle = t.background, e.fillRect(0, 0, n, s), dn(e, i, r.guides.panel, d.panel, t), e.save(), e.beginPath(), e.rect(d.panel.x, d.panel.y, d.panel.width, d.panel.height), e.clip();
762
- const f = {
763
- coordSystem: r.coordSystem,
764
- panel: d.panel,
765
- compiled: r,
768
+ }), S = t.pixelRatio ?? 2, T = new o(t.width * S, t.height * S), m = T.getContext("2d");
769
+ return m.scale(S, S), Rn({
770
+ ctx: m,
771
+ theme: d === "dark" ? Ln : En,
772
+ colorScheme: d,
773
+ chromeReaders: a,
774
+ axisLabelStyles: u,
775
+ tickLabelStyles: f,
776
+ tickLineStyles: h,
777
+ width: t.width,
778
+ height: t.height,
779
+ compiled: e,
780
+ formattedAxes: y,
781
+ formattedLegends: n,
782
+ layout: b,
783
+ textMeasurer: A,
784
+ ...t.formattingLocale === void 0 ? {} : { formattingLocale: t.formattingLocale }
785
+ }), T.encode("png");
786
+ }, Rn = ({
787
+ ctx: e,
788
+ theme: t,
789
+ colorScheme: o,
790
+ chromeReaders: n,
791
+ axisLabelStyles: s,
792
+ tickLabelStyles: r,
793
+ tickLineStyles: i,
794
+ width: l,
795
+ height: d,
796
+ compiled: a,
797
+ formattedAxes: c,
798
+ formattedLegends: u,
799
+ layout: f,
800
+ textMeasurer: h,
801
+ formattingLocale: g
802
+ }) => {
803
+ e.fillStyle = t.background, e.fillRect(0, 0, l, d), ln(e, c, n, f.panel), e.save(), e.beginPath(), e.rect(f.panel.x, f.panel.y, f.panel.width, f.panel.height), e.clip();
804
+ const A = {
805
+ coordSystem: a.coordSystem,
806
+ panel: f.panel,
807
+ compiled: a,
766
808
  theme: t,
767
809
  colorScheme: o,
768
- textMeasurer: l,
769
- formattingLocale: c
810
+ textMeasurer: h,
811
+ formattingLocale: g
770
812
  };
771
- for (const u of r.layers) {
772
- const h = Fe(u, r.coordSystem);
773
- h && ro(h, e, { ...f, layer: u });
813
+ for (const p of a.layers) {
814
+ const b = Oe(p, a.coordSystem);
815
+ b && co(b, e, { ...A, layer: p });
774
816
  }
775
817
  e.restore();
776
- for (const u of i) {
777
- const h = d.axes[u.position];
778
- h && Wo(e, u, h, d.panel, t);
818
+ for (const p of c) {
819
+ const b = f.axes[p.position];
820
+ if (b) {
821
+ const y = U(p.scaleAestheticKey);
822
+ Uo(e, p, b, f.panel, r[y], i[y]);
823
+ }
779
824
  }
780
- for (const u of r.guides.axes) {
781
- const h = d.axisLabels[u.position];
782
- h && Yo(e, u, h, t);
825
+ for (const p of a.guides.axes) {
826
+ const b = f.axisLabels[p.position];
827
+ b && Xo(e, p, b, s[U(p.scaleAestheticKey)]);
783
828
  }
784
- fn(e, a, d.legends, t), an(e, r.config.content, d.header, t, { width: n, height: s }), ln(e, r.config.content, d.footer, t, { width: n, height: s });
829
+ cn(e, u, f.legends, t), sn(e, a.config.content, f.header, t, { width: l, height: d }), an(e, a.config.content, f.footer, t, { width: l, height: d });
785
830
  };
786
- class _n extends Error {
831
+ class wn extends Error {
787
832
  constructor(t) {
788
833
  super(t), this.name = "ChartConfigRenderError";
789
834
  }
790
835
  }
791
- const Hn = async (e, t) => {
792
- const o = fo(e);
836
+ const Fn = async (e, t) => {
837
+ const o = po(e);
793
838
  if (!o.ok)
794
- throw new _n(o.reason);
839
+ throw new wn(o.reason);
795
840
  return et(o.compiled, t);
796
841
  };
797
842
  export {
798
- Fn as CANVAS_CAPABILITY_MATRIX,
843
+ Dn as CANVAS_CAPABILITY_MATRIX,
799
844
  He as CANVAS_SUPPORTED_GRAPH_TYPES,
800
- so as CANVAS_UNSUPPORTED_GRAPH_TYPES,
801
- _n as ChartConfigRenderError,
845
+ fo as CANVAS_UNSUPPORTED_GRAPH_TYPES,
846
+ wn as ChartConfigRenderError,
802
847
  Sn as NodeCanvasTextMeasurer,
803
- fo as canRenderConfigWithCanvas,
804
- Rn as darkTheme,
805
- Mt as ensureDefaultFonts,
806
- Ln as lightTheme,
807
- vt as loadCanvasRuntime,
808
- co as parseChartConfig,
809
- Ne as registerFont,
810
- Hn as renderChartConfigToPng,
848
+ po as canRenderConfigWithCanvas,
849
+ Ln as darkTheme,
850
+ Kt as ensureDefaultFonts,
851
+ En as lightTheme,
852
+ Ft as loadCanvasRuntime,
853
+ mo as parseChartConfig,
854
+ Ce as registerFont,
855
+ Fn as renderChartConfigToPng,
811
856
  On as renderGraphToPng
812
857
  };