@opendata-ai/openchart-vanilla 8.9.1 → 9.0.0-rc.2

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.
Files changed (51) hide show
  1. package/README.md +4 -4
  2. package/dist/{chunk-REH5UQCL.js → chunk-46E3QB6O.js} +6 -20
  3. package/dist/chunk-46E3QB6O.js.map +1 -0
  4. package/dist/{chunk-APMUBW72.js → chunk-5OQZRGUL.js} +1565 -294
  5. package/dist/chunk-5OQZRGUL.js.map +1 -0
  6. package/dist/{chunk-GX6BWMJD.js → chunk-5ZLSMZRM.js} +466 -330
  7. package/dist/chunk-5ZLSMZRM.js.map +1 -0
  8. package/dist/{chunk-SDJHUELU.js → chunk-A5C4VCUO.js} +26 -45
  9. package/dist/chunk-A5C4VCUO.js.map +1 -0
  10. package/dist/{chunk-MGFXAROR.js → chunk-CMIJA63X.js} +5 -3
  11. package/dist/chunk-CMIJA63X.js.map +1 -0
  12. package/dist/chunk-FFP5GXIP.js +45 -0
  13. package/dist/chunk-FFP5GXIP.js.map +1 -0
  14. package/dist/{chunk-Q7YEEF2X.js → chunk-LDSPJFOU.js} +16 -50
  15. package/dist/chunk-LDSPJFOU.js.map +1 -0
  16. package/dist/chunk-NLKQ5AOA.js +448 -0
  17. package/dist/chunk-NLKQ5AOA.js.map +1 -0
  18. package/dist/{chunk-R5TZHNTG.js → chunk-RBXIZJPE.js} +17 -5
  19. package/dist/chunk-RBXIZJPE.js.map +1 -0
  20. package/dist/{chunk-CCRFYGHU.js → chunk-RY5JEGFM.js} +2368 -2339
  21. package/dist/chunk-RY5JEGFM.js.map +1 -0
  22. package/dist/export-gif.d.ts +2 -2
  23. package/dist/export-gif.js +4 -3
  24. package/dist/graph-3d/index.d.ts +28 -1
  25. package/dist/graph-3d/index.js +26 -12
  26. package/dist/graph-3d/index.js.map +1 -1
  27. package/dist/index.d.ts +155 -29
  28. package/dist/index.js +1774 -186
  29. package/dist/index.js.map +1 -1
  30. package/dist/{mount-TEjIdF0m.d.ts → mount-types-DeUCa2hy.d.ts} +34 -21
  31. package/dist/{renderer-registry-Cng76n8F.d.ts → renderer-registry-Bu22Roek.d.ts} +5 -22
  32. package/dist/simulation-worker.js +27 -26
  33. package/dist/static.d.ts +4 -2
  34. package/dist/static.js +34 -10
  35. package/dist/static.js.map +1 -1
  36. package/dist/story/index.d.ts +8 -6
  37. package/dist/story/index.js +15 -12
  38. package/dist/story/index.js.map +1 -1
  39. package/dist/styles.css +1 -1
  40. package/dist/styles.css.map +1 -1
  41. package/package.json +3 -3
  42. package/dist/chunk-APMUBW72.js.map +0 -1
  43. package/dist/chunk-CCRFYGHU.js.map +0 -1
  44. package/dist/chunk-GX6BWMJD.js.map +0 -1
  45. package/dist/chunk-MGFXAROR.js.map +0 -1
  46. package/dist/chunk-Q7YEEF2X.js.map +0 -1
  47. package/dist/chunk-R5TZHNTG.js.map +0 -1
  48. package/dist/chunk-REH5UQCL.js.map +0 -1
  49. package/dist/chunk-SDJHUELU.js.map +0 -1
  50. package/dist/chunk-UC4IHEUO.js +0 -73
  51. package/dist/chunk-UC4IHEUO.js.map +0 -1
@@ -0,0 +1,448 @@
1
+ import {
2
+ XLINK_NS,
3
+ applyTextStyle,
4
+ createSVGElement,
5
+ setAttrs
6
+ } from "./chunk-FFP5GXIP.js";
7
+
8
+ // src/motion/easing.ts
9
+ function linear(t) {
10
+ return t;
11
+ }
12
+ function cubicOut(t) {
13
+ const f = 1 - t;
14
+ return 1 - f * f * f;
15
+ }
16
+ function cubicInOut(t) {
17
+ return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
18
+ }
19
+ var clamp01 = (t) => Math.min(1, Math.max(0, t));
20
+ var lerp = (a, b, t) => a + (b - a) * t;
21
+
22
+ // src/renderers/chrome.ts
23
+ import {
24
+ computeNoteBandHeight,
25
+ FOOTNOTE_LINE_HEIGHT,
26
+ textAscent,
27
+ truncateToWidth,
28
+ wrapText
29
+ } from "@opendata-ai/openchart-core";
30
+ function renderChromeElement(parent, element, className, chromeKey, measureText, uppercase = false) {
31
+ const text = createSVGElement("text");
32
+ setAttrs(text, { x: element.x, y: element.y + textAscent(element.style.fontSize) });
33
+ applyTextStyle(text, element.style);
34
+ text.setAttribute("class", className);
35
+ text.setAttribute("data-chrome-key", chromeKey);
36
+ const renderedText = uppercase ? element.text.toUpperCase() : element.text;
37
+ const lines = wrapText(
38
+ renderedText,
39
+ element.style.fontSize,
40
+ element.style.fontWeight,
41
+ element.maxWidth,
42
+ measureText
43
+ );
44
+ let truncated = false;
45
+ if (element.maxLines != null && lines.length > element.maxLines) {
46
+ truncated = true;
47
+ lines.length = element.maxLines;
48
+ const lastIndex = element.maxLines - 1;
49
+ const measure = measureText ? (text2, fontSize, fontWeight) => measureText(text2, fontSize, fontWeight).width : void 0;
50
+ const withEllipsis = `${lines[lastIndex]}\u2026`;
51
+ lines[lastIndex] = truncateToWidth(
52
+ withEllipsis,
53
+ element.maxWidth,
54
+ element.style.fontSize,
55
+ element.style.fontWeight,
56
+ measure
57
+ );
58
+ }
59
+ if (lines.length === 1 && !truncated) {
60
+ text.textContent = renderedText;
61
+ } else if (lines.length === 1) {
62
+ text.textContent = lines[0];
63
+ } else {
64
+ const lineHeight = element.style.fontSize * (element.style.lineHeight ?? 1.3);
65
+ for (let i = 0; i < lines.length; i++) {
66
+ const tspan = createSVGElement("tspan");
67
+ setAttrs(tspan, { x: element.x, dy: i === 0 ? 0 : lineHeight });
68
+ tspan.textContent = lines[i];
69
+ text.appendChild(tspan);
70
+ }
71
+ }
72
+ parent.appendChild(text);
73
+ }
74
+ function renderChrome(parent, layout) {
75
+ const g = createSVGElement("g");
76
+ g.setAttribute("class", "oc-chrome");
77
+ const { chrome, measureText } = layout;
78
+ if (chrome.rule) {
79
+ const rule = createSVGElement("rect");
80
+ rule.setAttribute("class", "oc-chrome-rule");
81
+ setAttrs(rule, {
82
+ x: chrome.rule.x,
83
+ y: chrome.rule.y,
84
+ width: chrome.rule.width,
85
+ height: chrome.rule.thickness
86
+ });
87
+ rule.setAttribute("fill", chrome.rule.color);
88
+ rule.setAttribute("shape-rendering", "crispEdges");
89
+ g.appendChild(rule);
90
+ }
91
+ if (chrome.eyebrow && chrome.rule) {
92
+ renderChromeElement(g, chrome.eyebrow, "oc-eyebrow", "eyebrow", measureText, true);
93
+ } else if (chrome.eyebrow) {
94
+ const eyebrow = chrome.eyebrow;
95
+ const dotR = 3;
96
+ const dotGap = 8;
97
+ const dotX = eyebrow.x + dotR;
98
+ const dotY = eyebrow.y + eyebrow.style.fontSize * 0.42;
99
+ const dot = createSVGElement("circle");
100
+ dot.setAttribute("class", "oc-eyebrow-dot");
101
+ setAttrs(dot, { cx: dotX, cy: dotY, r: dotR });
102
+ dot.setAttribute("fill", eyebrow.style.fill ?? "currentColor");
103
+ g.appendChild(dot);
104
+ const shifted = {
105
+ ...eyebrow,
106
+ x: eyebrow.x + dotR * 2 + dotGap
107
+ };
108
+ renderChromeElement(g, shifted, "oc-eyebrow", "eyebrow", measureText, true);
109
+ }
110
+ if (chrome.title) {
111
+ renderChromeElement(g, chrome.title, "oc-title", "title", measureText);
112
+ }
113
+ if (chrome.subtitle) {
114
+ renderChromeElement(g, chrome.subtitle, "oc-subtitle", "subtitle", measureText);
115
+ }
116
+ const bottomOffset = layout.chrome.bottomAnchorY ?? layout.area.y + layout.area.height;
117
+ const bandHeight = layout.chrome.noteBandHeight ?? computeNoteBandHeight(layout.chrome, layout.theme);
118
+ let noteLine = 0;
119
+ if (chrome.footnotes && chrome.footnotes.length > 0) {
120
+ const fontSize = layout.theme.fonts.sizes.small;
121
+ const pad = layout.theme.spacing.padding;
122
+ const lineHeight = fontSize * FOOTNOTE_LINE_HEIGHT;
123
+ const style = {
124
+ fontFamily: layout.theme.fonts.family,
125
+ fontSize,
126
+ fontWeight: layout.theme.fonts.weights.normal,
127
+ fill: layout.theme.chrome.source.color,
128
+ lineHeight: FOOTNOTE_LINE_HEIGHT,
129
+ textAnchor: "start"
130
+ };
131
+ const list = createSVGElement("g");
132
+ list.setAttribute("role", "list");
133
+ list.setAttribute("aria-label", "Annotation notes, in source order");
134
+ g.appendChild(list);
135
+ for (let i = 0; i < chrome.footnotes.length; i++) {
136
+ const f = chrome.footnotes[i];
137
+ const y = bottomOffset + layout.theme.spacing.chartToFooter + textAscent(fontSize) + noteLine * lineHeight;
138
+ const el = createSVGElement("text");
139
+ el.setAttribute("class", "oc-footnotes");
140
+ el.setAttribute("role", "listitem");
141
+ if (!layout.a11y.hidden) el.setAttribute("tabindex", "0");
142
+ el.setAttribute(
143
+ "aria-label",
144
+ `${f.index}. ${f.text.replaceAll("**", "")}${f.subtitle ? `. ${f.subtitle.replaceAll("**", "")}` : ""}`
145
+ );
146
+ if (f.specIndex !== void 0) el.setAttribute("data-note-spec-index", String(f.specIndex));
147
+ if (f.id !== void 0) el.setAttribute("data-note-id", f.id);
148
+ setAttrs(el, { x: pad, y });
149
+ applyTextStyle(el, style);
150
+ const lines = f.lines ?? [`${f.index}. ${f.text}`];
151
+ lines.forEach((line, index) => {
152
+ const span = createSVGElement("tspan");
153
+ setAttrs(span, { x: pad, dy: index === 0 ? 0 : lineHeight });
154
+ const runs = f.spans?.[index];
155
+ if (runs) {
156
+ for (const run of runs) {
157
+ const part = createSVGElement("tspan");
158
+ if (run.bold) part.setAttribute("font-weight", "700");
159
+ part.textContent = run.text;
160
+ span.appendChild(part);
161
+ }
162
+ } else span.textContent = line;
163
+ el.appendChild(span);
164
+ });
165
+ noteLine += f.lines?.length ?? 1;
166
+ list.appendChild(el);
167
+ }
168
+ }
169
+ let summaryLine = noteLine;
170
+ for (const entry of chrome.seriesSummary ?? []) {
171
+ const size = layout.theme.fonts.sizes.small;
172
+ const el = createSVGElement("text");
173
+ el.setAttribute("class", "oc-series-summary");
174
+ el.setAttribute("data-series", entry.key);
175
+ setAttrs(el, {
176
+ x: layout.theme.spacing.padding,
177
+ y: bottomOffset + layout.theme.spacing.chartToFooter + textAscent(size) + summaryLine * size * FOOTNOTE_LINE_HEIGHT
178
+ });
179
+ applyTextStyle(el, {
180
+ fontFamily: layout.theme.fonts.family,
181
+ fontSize: size,
182
+ fontWeight: 500,
183
+ lineHeight: FOOTNOTE_LINE_HEIGHT,
184
+ fill: entry.color
185
+ });
186
+ entry.lines.forEach((line, index) => {
187
+ const span = createSVGElement("tspan");
188
+ setAttrs(span, {
189
+ x: layout.theme.spacing.padding,
190
+ dy: index === 0 ? 0 : size * FOOTNOTE_LINE_HEIGHT
191
+ });
192
+ span.textContent = line;
193
+ el.appendChild(span);
194
+ });
195
+ summaryLine += entry.lines.length;
196
+ g.appendChild(el);
197
+ }
198
+ if (chrome.source) {
199
+ renderChromeElement(
200
+ g,
201
+ { ...chrome.source, y: bottomOffset + chrome.source.y + bandHeight },
202
+ "oc-source",
203
+ "source",
204
+ measureText
205
+ );
206
+ }
207
+ if (chrome.byline) {
208
+ renderChromeElement(
209
+ g,
210
+ { ...chrome.byline, y: bottomOffset + chrome.byline.y + bandHeight },
211
+ "oc-byline",
212
+ "byline",
213
+ measureText
214
+ );
215
+ }
216
+ if (chrome.footer) {
217
+ renderChromeElement(
218
+ g,
219
+ { ...chrome.footer, y: bottomOffset + chrome.footer.y + bandHeight },
220
+ "oc-footer",
221
+ "footer",
222
+ measureText
223
+ );
224
+ }
225
+ if (chrome.brand) {
226
+ const brandY = bottomOffset + chrome.brand.y + bandHeight;
227
+ renderChromeElement(g, { ...chrome.brand, y: brandY }, "oc-brand", "brand", measureText);
228
+ }
229
+ parent.appendChild(g);
230
+ }
231
+
232
+ // src/renderers/brand.ts
233
+ import { computeNoteBandHeight as computeNoteBandHeight2 } from "@opendata-ai/openchart-core";
234
+ var BRAND_URL = "https://tryopendata.ai";
235
+ function renderAttributionBrand(parent, chrome, bottomOffset, measureText, includeCustom = true) {
236
+ if (includeCustom && chrome.brand) {
237
+ renderChromeElement(
238
+ parent,
239
+ { ...chrome.brand, y: bottomOffset + chrome.brand.y },
240
+ "oc-brand",
241
+ "brand",
242
+ measureText
243
+ );
244
+ }
245
+ const mark = chrome.watermark;
246
+ if (!mark) return;
247
+ const link = createSVGElement("a");
248
+ link.setAttribute("href", BRAND_URL);
249
+ link.setAttributeNS(XLINK_NS, "xlink:href", BRAND_URL);
250
+ link.setAttribute("target", "_blank");
251
+ link.setAttribute("rel", "noopener");
252
+ link.setAttribute("class", "oc-chrome-ref");
253
+ link.setAttribute("opacity", "0.55");
254
+ renderChromeElement(
255
+ link,
256
+ { ...mark, y: bottomOffset + mark.y },
257
+ "oc-watermark",
258
+ "watermark",
259
+ measureText
260
+ );
261
+ parent.appendChild(link);
262
+ }
263
+ function renderBrand(parent, layout) {
264
+ const bandHeight = layout.chrome.noteBandHeight ?? computeNoteBandHeight2(layout.chrome, layout.theme);
265
+ const bottomOffset = (layout.chrome.bottomAnchorY ?? layout.area.y + layout.area.height) + bandHeight;
266
+ renderAttributionBrand(parent, layout.chrome, bottomOffset, layout.measureText, false);
267
+ }
268
+
269
+ // src/theme-tokens.ts
270
+ import { adaptForLightLineStroke, cssTokenDefault } from "@opendata-ai/openchart-core";
271
+ function resolvedSurface(theme) {
272
+ return theme.colors.neutral.surface;
273
+ }
274
+ var stamped = /* @__PURE__ */ new WeakMap();
275
+ function readWithoutThemeStamp(el, name, read) {
276
+ const entry = stamped.get(el)?.get(name);
277
+ const value = el.style.getPropertyValue(name);
278
+ if (!entry || value !== entry.value) return read();
279
+ const priority = el.style.getPropertyPriority(name);
280
+ try {
281
+ if (entry.previous) el.style.setProperty(name, entry.previous, entry.priority);
282
+ else el.style.removeProperty(name);
283
+ return read();
284
+ } finally {
285
+ el.style.setProperty(name, value, priority);
286
+ }
287
+ }
288
+ function stampThemeProperties(el, theme, kind) {
289
+ el.classList.toggle("oc-dark", theme.isDark);
290
+ const accent = theme.colors.categorical[0] ?? cssTokenDefault("--oc-accent", "light");
291
+ const bg = resolvedSurface(theme);
292
+ const n = theme.colors.neutral;
293
+ const props = [
294
+ ["--oc-font-family", theme.fonts.family],
295
+ ["--oc-font-mono", theme.fonts.mono],
296
+ ["--oc-title-size", `${theme.chrome.title.fontSize}px`],
297
+ ["--oc-title-weight", `${theme.chrome.title.fontWeight}`],
298
+ ["--oc-subtitle-size", `${theme.chrome.subtitle.fontSize}px`],
299
+ ["--oc-subtitle-weight", `${theme.chrome.subtitle.fontWeight}`],
300
+ ["--oc-source-size", `${theme.chrome.source.fontSize}px`],
301
+ ["--oc-source-weight", `${theme.chrome.source.fontWeight}`],
302
+ ["--oc-body-size", `${theme.fonts.sizes.body}px`],
303
+ ["--oc-endpoint-label-size", `${theme.fonts.sizes.endpointLabel}px`],
304
+ ["--oc-endpoint-value-size", `${theme.fonts.sizes.endpointValue}px`],
305
+ ["--oc-endpoint-entry-gap", `${theme.spacing.endpointEntryGap}px`],
306
+ ["--oc-endpoint-value-gap", `${theme.spacing.endpointValueGap}px`],
307
+ ["--oc-endpoint-column-gap", `${theme.spacing.endpointColumnGap}px`],
308
+ ["--oc-eyebrow-size", `${theme.chrome.eyebrow.fontSize}px`],
309
+ ["--oc-eyebrow-weight", `${theme.chrome.eyebrow.fontWeight}`],
310
+ ["--oc-bg", bg],
311
+ ["--oc-text", theme.colors.text],
312
+ ["--oc-text-muted", theme.colors.axis],
313
+ // Secondary grays are derived from the theme's own text/background pair
314
+ // (ResolvedTheme.colors.neutral), so a warm or cool theme gets warm or
315
+ // cool grays instead of zinc. One direction only: theme -> CSS.
316
+ ["--oc-text-secondary", n.secondary],
317
+ ["--oc-text-faint", n.faint],
318
+ ["--oc-border", n.border],
319
+ ["--oc-gray-100", n[100]],
320
+ ["--oc-gray-200", n[200]],
321
+ ["--oc-gray-300", n[300]],
322
+ ["--oc-gray-400", n[400]],
323
+ ["--oc-gray-600", n[600]],
324
+ ["--oc-gray-800", n[800]],
325
+ ["--oc-gridline", theme.colors.gridline],
326
+ // --oc-axis is the hairline the axis line is drawn with, not the ink its
327
+ // tick labels take (that is --oc-text-muted, above).
328
+ ["--oc-axis", theme.colors.hairline],
329
+ ["--oc-border-radius", `${theme.borderRadius}px`],
330
+ ["--oc-accent", accent],
331
+ ["--oc-accent-strong", adaptForLightLineStroke(accent)],
332
+ ["--oc-positive", theme.colors.positive],
333
+ ["--oc-negative", theme.colors.negative],
334
+ ["--oc-space-2", `${theme.spacing.chromeGap * 2}px`],
335
+ ["--oc-space-4", `${theme.spacing.padding}px`]
336
+ ];
337
+ const authored = theme._authored;
338
+ const colors = authored?.colors && !Array.isArray(authored.colors) ? authored.colors : {};
339
+ const neutralAuthored = colors.text !== void 0 || colors.background !== void 0;
340
+ const colorAuthored = (key) => colors[key] !== void 0;
341
+ const chromeAuthored = (element, field) => {
342
+ if (authored?.chrome?.[element]?.[field] !== void 0) return true;
343
+ if (field === "fontWeight" || element === "eyebrow") return false;
344
+ return authored?.fonts?.sizes?.[element === "source" ? "small" : element] !== void 0;
345
+ };
346
+ const paletteAuthored = Array.isArray(authored?.colors) || colors.categorical !== void 0;
347
+ const enabled = {
348
+ "--oc-font-family": authored?.fonts?.family !== void 0,
349
+ "--oc-font-mono": authored?.fonts?.mono !== void 0,
350
+ "--oc-title-size": chromeAuthored("title", "fontSize"),
351
+ "--oc-title-weight": chromeAuthored("title", "fontWeight"),
352
+ "--oc-subtitle-size": chromeAuthored("subtitle", "fontSize"),
353
+ "--oc-subtitle-weight": chromeAuthored("subtitle", "fontWeight"),
354
+ "--oc-source-size": chromeAuthored("source", "fontSize"),
355
+ "--oc-source-weight": chromeAuthored("source", "fontWeight"),
356
+ "--oc-body-size": authored?.fonts?.sizes?.body !== void 0,
357
+ "--oc-endpoint-label-size": authored?.fonts?.sizes?.endpointLabel !== void 0,
358
+ "--oc-endpoint-value-size": authored?.fonts?.sizes?.endpointValue !== void 0,
359
+ "--oc-endpoint-entry-gap": authored?.spacing?.endpointEntryGap !== void 0,
360
+ "--oc-endpoint-value-gap": authored?.spacing?.endpointValueGap !== void 0,
361
+ "--oc-endpoint-column-gap": authored?.spacing?.endpointColumnGap !== void 0,
362
+ "--oc-eyebrow-size": chromeAuthored("eyebrow", "fontSize"),
363
+ "--oc-eyebrow-weight": chromeAuthored("eyebrow", "fontWeight"),
364
+ "--oc-bg": colorAuthored("background"),
365
+ "--oc-text": colorAuthored("text"),
366
+ "--oc-text-muted": colorAuthored("axis") || kind === "table" && neutralAuthored,
367
+ "--oc-text-secondary": neutralAuthored,
368
+ "--oc-text-faint": neutralAuthored,
369
+ "--oc-border": neutralAuthored || kind === "table" && colorAuthored("gridline"),
370
+ "--oc-gridline": colorAuthored("gridline"),
371
+ "--oc-axis": colorAuthored("hairline"),
372
+ "--oc-border-radius": authored?.borderRadius !== void 0,
373
+ "--oc-accent": paletteAuthored,
374
+ "--oc-accent-strong": paletteAuthored,
375
+ "--oc-positive": colorAuthored("positive"),
376
+ "--oc-negative": colorAuthored("negative"),
377
+ "--oc-space-2": authored?.spacing?.chromeGap !== void 0,
378
+ "--oc-space-4": authored?.spacing?.padding !== void 0
379
+ };
380
+ for (const key of [
381
+ "annotationLabel",
382
+ "annotationMuted",
383
+ "annotationLeader",
384
+ "annotationRule",
385
+ "annotationRangeFill",
386
+ "annotationMarkerFill",
387
+ "annotationPlate"
388
+ ]) {
389
+ const name = `--oc-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
390
+ props.push([name, theme.colors[key]]);
391
+ enabled[name] = colorAuthored(key) || (key === "annotationMarkerFill" || key === "annotationPlate") && neutralAuthored;
392
+ }
393
+ for (const key of [
394
+ "gridlineZero",
395
+ "mapNoDataFill",
396
+ "mapNoDataHatch",
397
+ "mapInteriorBorder",
398
+ "mapOutlineBorder"
399
+ ]) {
400
+ const name = `--oc-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
401
+ if (theme.colors[key] !== void 0) props.push([name, theme.colors[key]]);
402
+ enabled[name] = colorAuthored(key);
403
+ }
404
+ for (const level of [100, 200, 300, 400, 600, 800])
405
+ enabled[`--oc-gray-${level}`] = neutralAuthored;
406
+ if (kind === "table") {
407
+ if (!colorAuthored("axis")) props.find(([name]) => name === "--oc-text-muted")[1] = n[600];
408
+ if (colorAuthored("gridline"))
409
+ props.find(([name]) => name === "--oc-border")[1] = theme.colors.gridline;
410
+ }
411
+ const previous = stamped.get(el) ?? /* @__PURE__ */ new Map();
412
+ for (const [name, entry] of previous) {
413
+ if (!enabled[name]) {
414
+ if (el.style.getPropertyValue(name) === entry.value) {
415
+ if (entry.previous) el.style.setProperty(name, entry.previous, entry.priority);
416
+ else el.style.removeProperty(name);
417
+ }
418
+ previous.delete(name);
419
+ }
420
+ }
421
+ for (const [name, value] of props) {
422
+ if (!enabled[name]) continue;
423
+ const old = previous.get(name);
424
+ previous.set(name, {
425
+ previous: old?.previous ?? el.style.getPropertyValue(name),
426
+ priority: old?.priority ?? el.style.getPropertyPriority(name),
427
+ value
428
+ });
429
+ el.style.setProperty(name, value);
430
+ }
431
+ stamped.set(el, previous);
432
+ }
433
+
434
+ export {
435
+ renderChromeElement,
436
+ renderChrome,
437
+ renderAttributionBrand,
438
+ renderBrand,
439
+ resolvedSurface,
440
+ readWithoutThemeStamp,
441
+ stampThemeProperties,
442
+ linear,
443
+ cubicOut,
444
+ cubicInOut,
445
+ clamp01,
446
+ lerp
447
+ };
448
+ //# sourceMappingURL=chunk-NLKQ5AOA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/motion/easing.ts","../src/renderers/chrome.ts","../src/renderers/brand.ts","../src/theme-tokens.ts"],"sourcesContent":["/**\n * Shared easing and interpolation primitives.\n *\n * Single source of truth for the hand-rolled easings used by the canvas\n * scheduler (motion/tween.ts), the update-transition driver (transition.ts)\n * and the story tweens (story/tween.ts). No `d3-ease` dependency.\n */\n\n/** Linear (identity) easing. Required for stacked/segmented handoffs. */\nexport function linear(t: number): number {\n return t;\n}\n\n/** Cubic-out: decelerates into place. Maps to `'snappy'`. */\nexport function cubicOut(t: number): number {\n const f = 1 - t;\n return 1 - f * f * f;\n}\n\n/** Cubic-in-out: eases in and out. Maps to `'smooth'`. */\nexport function cubicInOut(t: number): number {\n return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;\n}\n\nexport const clamp01 = (t: number): number => Math.min(1, Math.max(0, t));\n\nexport const lerp = (a: number, b: number, t: number): number => a + (b - a) * t;\n","/**\n * Chrome rendering: title, subtitle, source, byline, footer.\n */\n\nimport type {\n ChartLayout,\n MeasureTextFn,\n ResolvedChromeElement,\n} from '@opendata-ai/openchart-core';\nimport {\n computeNoteBandHeight,\n FOOTNOTE_LINE_HEIGHT,\n textAscent,\n truncateToWidth,\n wrapText,\n} from '@opendata-ai/openchart-core';\nimport { applyTextStyle, createSVGElement, setAttrs } from './svg-dom';\n\nexport function renderChromeElement(\n parent: SVGElement,\n element: ResolvedChromeElement,\n className: string,\n chromeKey: string,\n measureText?: MeasureTextFn,\n uppercase = false,\n): void {\n const text = createSVGElement('text');\n // element.y is the TOP of the text box; convert to the alphabetic baseline\n // here instead of relying on dominant-baseline:hanging, which WebKit\n // positions from different font metrics and never inherits into tspans.\n setAttrs(text, { x: element.x, y: element.y + textAscent(element.style.fontSize) });\n applyTextStyle(text, element.style);\n text.setAttribute('class', className);\n text.setAttribute('data-chrome-key', chromeKey);\n\n // happy-dom doesn't apply CSS text-transform inside SVG measurement, so\n // pre-uppercase the rendered text for elements that style as uppercase.\n // Browsers honor the CSS rule too, so this is double-applied harmlessly.\n const renderedText = uppercase ? element.text.toUpperCase() : element.text;\n\n const lines = wrapText(\n renderedText,\n element.style.fontSize,\n element.style.fontWeight,\n element.maxWidth,\n measureText,\n );\n\n // Cap wrapped output to maxLines, truncating the last kept line with an\n // ellipsis so it fits maxWidth. Only when the natural wrap exceeds the cap.\n let truncated = false;\n if (element.maxLines != null && lines.length > element.maxLines) {\n truncated = true;\n lines.length = element.maxLines;\n const lastIndex = element.maxLines - 1;\n const measure = measureText\n ? (text: string, fontSize: number, fontWeight?: number) =>\n measureText(text, fontSize, fontWeight).width\n : undefined;\n // Content was dropped, so the last kept line always gets an ellipsis.\n // Append it first, then shrink to fit maxWidth if the combined string\n // overflows.\n const withEllipsis = `${lines[lastIndex]}…`;\n lines[lastIndex] = truncateToWidth(\n withEllipsis,\n element.maxWidth,\n element.style.fontSize,\n element.style.fontWeight,\n measure,\n );\n }\n\n if (lines.length === 1 && !truncated) {\n text.textContent = renderedText;\n } else if (lines.length === 1) {\n text.textContent = lines[0];\n } else {\n const lineHeight = element.style.fontSize * (element.style.lineHeight ?? 1.3);\n for (let i = 0; i < lines.length; i++) {\n const tspan = createSVGElement('tspan');\n setAttrs(tspan, { x: element.x, dy: i === 0 ? 0 : lineHeight });\n tspan.textContent = lines[i];\n text.appendChild(tspan);\n }\n }\n\n parent.appendChild(text);\n}\n\nexport function renderChrome(parent: SVGElement, layout: ChartLayout): void {\n const g = createSVGElement('g');\n g.setAttribute('class', 'oc-chrome');\n\n const { chrome, measureText } = layout;\n\n // Editorial rule: a short colored bar above the top chrome block.\n if (chrome.rule) {\n const rule = createSVGElement('rect');\n rule.setAttribute('class', 'oc-chrome-rule');\n setAttrs(rule, {\n x: chrome.rule.x,\n y: chrome.rule.y,\n width: chrome.rule.width,\n height: chrome.rule.thickness,\n });\n rule.setAttribute('fill', chrome.rule.color);\n rule.setAttribute('shape-rendering', 'crispEdges');\n g.appendChild(rule);\n }\n\n // Top chrome: render at their stored y positions (already absolute)\n if (chrome.eyebrow && chrome.rule) {\n // The rule already carries the accent above the block; a dot as well is\n // two pieces of furniture saying the same thing.\n renderChromeElement(g, chrome.eyebrow, 'oc-eyebrow', 'eyebrow', measureText, true);\n } else if (chrome.eyebrow) {\n // Leading accent dot — matches the editorial design system mock.\n // eyebrow.y is the top of the text box. Visual center is roughly\n // y + fontSize * 0.55 (cap height).\n const eyebrow = chrome.eyebrow;\n const dotR = 3;\n const dotGap = 8;\n const dotX = eyebrow.x + dotR;\n const dotY = eyebrow.y + eyebrow.style.fontSize * 0.42;\n const dot = createSVGElement('circle');\n dot.setAttribute('class', 'oc-eyebrow-dot');\n setAttrs(dot, { cx: dotX, cy: dotY, r: dotR });\n dot.setAttribute('fill', eyebrow.style.fill ?? 'currentColor');\n g.appendChild(dot);\n\n const shifted: ResolvedChromeElement = {\n ...eyebrow,\n x: eyebrow.x + dotR * 2 + dotGap,\n };\n renderChromeElement(g, shifted, 'oc-eyebrow', 'eyebrow', measureText, true);\n }\n if (chrome.title) {\n renderChromeElement(g, chrome.title, 'oc-title', 'title', measureText);\n }\n if (chrome.subtitle) {\n renderChromeElement(g, chrome.subtitle, 'oc-subtitle', 'subtitle', measureText);\n }\n\n const bottomOffset = layout.chrome.bottomAnchorY ?? layout.area.y + layout.area.height;\n\n // Footnotes from auto-thinned annotations, rendered above source/byline.\n // Each footnote gets its own line to avoid horizontal overflow.\n const bandHeight =\n layout.chrome.noteBandHeight ?? computeNoteBandHeight(layout.chrome, layout.theme);\n let noteLine = 0;\n if (chrome.footnotes && chrome.footnotes.length > 0) {\n const fontSize = layout.theme.fonts.sizes.small;\n const pad = layout.theme.spacing.padding;\n const lineHeight = fontSize * FOOTNOTE_LINE_HEIGHT;\n const style = {\n fontFamily: layout.theme.fonts.family,\n fontSize,\n fontWeight: layout.theme.fonts.weights.normal,\n fill: layout.theme.chrome.source.color,\n lineHeight: FOOTNOTE_LINE_HEIGHT,\n textAnchor: 'start' as const,\n };\n\n const list = createSVGElement('g');\n list.setAttribute('role', 'list');\n list.setAttribute('aria-label', 'Annotation notes, in source order');\n g.appendChild(list);\n for (let i = 0; i < chrome.footnotes.length; i++) {\n const f = chrome.footnotes[i];\n const y =\n bottomOffset +\n layout.theme.spacing.chartToFooter +\n textAscent(fontSize) +\n noteLine * lineHeight;\n const el = createSVGElement('text');\n el.setAttribute('class', 'oc-footnotes');\n el.setAttribute('role', 'listitem');\n if (!layout.a11y.hidden) el.setAttribute('tabindex', '0');\n el.setAttribute(\n 'aria-label',\n `${f.index}. ${f.text.replaceAll('**', '')}${f.subtitle ? `. ${f.subtitle.replaceAll('**', '')}` : ''}`,\n );\n if (f.specIndex !== undefined) el.setAttribute('data-note-spec-index', String(f.specIndex));\n if (f.id !== undefined) el.setAttribute('data-note-id', f.id);\n setAttrs(el, { x: pad, y });\n applyTextStyle(el, style);\n const lines = f.lines ?? [`${f.index}. ${f.text}`];\n lines.forEach((line, index) => {\n const span = createSVGElement('tspan');\n setAttrs(span, { x: pad, dy: index === 0 ? 0 : lineHeight });\n const runs = f.spans?.[index];\n if (runs) {\n for (const run of runs) {\n const part = createSVGElement('tspan');\n if (run.bold) part.setAttribute('font-weight', '700');\n part.textContent = run.text;\n span.appendChild(part);\n }\n } else span.textContent = line;\n el.appendChild(span);\n });\n noteLine += f.lines?.length ?? 1;\n list.appendChild(el);\n }\n }\n\n let summaryLine = noteLine;\n for (const entry of chrome.seriesSummary ?? []) {\n const size = layout.theme.fonts.sizes.small;\n const el = createSVGElement('text');\n el.setAttribute('class', 'oc-series-summary');\n el.setAttribute('data-series', entry.key);\n setAttrs(el, {\n x: layout.theme.spacing.padding,\n y:\n bottomOffset +\n layout.theme.spacing.chartToFooter +\n textAscent(size) +\n summaryLine * size * FOOTNOTE_LINE_HEIGHT,\n });\n applyTextStyle(el, {\n fontFamily: layout.theme.fonts.family,\n fontSize: size,\n fontWeight: 500,\n lineHeight: FOOTNOTE_LINE_HEIGHT,\n fill: entry.color,\n });\n entry.lines.forEach((line, index) => {\n const span = createSVGElement('tspan');\n setAttrs(span, {\n x: layout.theme.spacing.padding,\n dy: index === 0 ? 0 : size * FOOTNOTE_LINE_HEIGHT,\n });\n span.textContent = line;\n el.appendChild(span);\n });\n summaryLine += entry.lines.length;\n g.appendChild(el);\n }\n\n if (chrome.source) {\n renderChromeElement(\n g,\n { ...chrome.source, y: bottomOffset + chrome.source.y + bandHeight },\n 'oc-source',\n 'source',\n measureText,\n );\n }\n if (chrome.byline) {\n renderChromeElement(\n g,\n { ...chrome.byline, y: bottomOffset + chrome.byline.y + bandHeight },\n 'oc-byline',\n 'byline',\n measureText,\n );\n }\n if (chrome.footer) {\n renderChromeElement(\n g,\n { ...chrome.footer, y: bottomOffset + chrome.footer.y + bandHeight },\n 'oc-footer',\n 'footer',\n measureText,\n );\n }\n if (chrome.brand) {\n const brandY = bottomOffset + chrome.brand.y + bandHeight;\n renderChromeElement(g, { ...chrome.brand, y: brandY }, 'oc-brand', 'brand', measureText);\n }\n\n parent.appendChild(g);\n}\n","/** Shared measured attribution painting for SVG visualizations. */\nimport type { ChartLayout, MeasureTextFn, ResolvedChrome } from '@opendata-ai/openchart-core';\nimport { computeNoteBandHeight } from '@opendata-ai/openchart-core';\nimport { renderChromeElement } from './chrome';\nimport { createSVGElement, XLINK_NS } from './svg-dom';\n\nconst BRAND_URL = 'https://tryopendata.ai';\n\n/** Paint the exact portable footer mark resolved by computeChrome. */\nexport function renderAttributionBrand(\n parent: SVGElement,\n chrome: ResolvedChrome,\n bottomOffset: number,\n measureText?: MeasureTextFn,\n includeCustom = true,\n): void {\n if (includeCustom && chrome.brand) {\n renderChromeElement(\n parent,\n { ...chrome.brand, y: bottomOffset + chrome.brand.y },\n 'oc-brand',\n 'brand',\n measureText,\n );\n }\n const mark = chrome.watermark;\n if (!mark) return;\n const link = createSVGElement('a');\n link.setAttribute('href', BRAND_URL);\n link.setAttributeNS(XLINK_NS, 'xlink:href', BRAND_URL);\n link.setAttribute('target', '_blank');\n link.setAttribute('rel', 'noopener');\n link.setAttribute('class', 'oc-chrome-ref');\n link.setAttribute('opacity', '0.55');\n renderChromeElement(\n link,\n { ...mark, y: bottomOffset + mark.y },\n 'oc-watermark',\n 'watermark',\n measureText,\n );\n parent.appendChild(link);\n}\n\nexport function renderBrand(parent: SVGElement, layout: ChartLayout): void {\n const bandHeight =\n layout.chrome.noteBandHeight ?? computeNoteBandHeight(layout.chrome, layout.theme);\n const bottomOffset =\n (layout.chrome.bottomAnchorY ?? layout.area.y + layout.area.height) + bandHeight;\n renderAttributionBrand(parent, layout.chrome, bottomOffset, layout.measureText, false);\n}\n","/**\n * Project authored theme leaves to scoped CSS custom properties.\n *\n * Unauthored values remain in tokens.css / dark.css, leaving host CSS in\n * control. Derived neutral values follow authored text/background changes.\n */\n\nimport type { ResolvedTheme, ThemeConfig } from '@opendata-ai/openchart-core';\nimport { adaptForLightLineStroke, cssTokenDefault } from '@opendata-ai/openchart-core';\n\n/**\n * The opaque surface a theme paints on. A transparent theme background has no\n * color of its own, so it resolves to the static `--oc-bg` token for the mode --\n * the same value the engine's knockout strokes are cut in. Resolved once in\n * core, on `colors.neutral.surface`; this is a named read of it.\n */\nexport function resolvedSurface(theme: ResolvedTheme): string {\n return theme.colors.neutral.surface;\n}\n\ntype StyledElement = HTMLElement | SVGElement;\nconst stamped = new WeakMap<\n StyledElement,\n Map<string, { previous: string; priority: string; value: string }>\n>();\n\n/** Read the host cascade without an earlier authored token, then restore it synchronously. */\nexport function readWithoutThemeStamp<T>(el: StyledElement, name: string, read: () => T): T {\n const entry = stamped.get(el)?.get(name);\n const value = el.style.getPropertyValue(name);\n if (!entry || value !== entry.value) return read();\n const priority = el.style.getPropertyPriority(name);\n try {\n if (entry.previous) el.style.setProperty(name, entry.previous, entry.priority);\n else el.style.removeProperty(name);\n return read();\n } finally {\n el.style.setProperty(name, value, priority);\n }\n}\n\n/** Stamp only authored theme leaves. Defaults stay in CSS so host rules can override them. */\nexport function stampThemeProperties(\n el: StyledElement,\n theme: ResolvedTheme,\n kind?: 'table',\n): void {\n el.classList.toggle('oc-dark', theme.isDark);\n const accent = theme.colors.categorical[0] ?? cssTokenDefault('--oc-accent', 'light');\n const bg = resolvedSurface(theme);\n\n const n = theme.colors.neutral;\n\n const props: [string, string][] = [\n ['--oc-font-family', theme.fonts.family],\n ['--oc-font-mono', theme.fonts.mono],\n ['--oc-title-size', `${theme.chrome.title.fontSize}px`],\n ['--oc-title-weight', `${theme.chrome.title.fontWeight}`],\n ['--oc-subtitle-size', `${theme.chrome.subtitle.fontSize}px`],\n ['--oc-subtitle-weight', `${theme.chrome.subtitle.fontWeight}`],\n ['--oc-source-size', `${theme.chrome.source.fontSize}px`],\n ['--oc-source-weight', `${theme.chrome.source.fontWeight}`],\n ['--oc-body-size', `${theme.fonts.sizes.body}px`],\n ['--oc-endpoint-label-size', `${theme.fonts.sizes.endpointLabel}px`],\n ['--oc-endpoint-value-size', `${theme.fonts.sizes.endpointValue}px`],\n ['--oc-endpoint-entry-gap', `${theme.spacing.endpointEntryGap}px`],\n ['--oc-endpoint-value-gap', `${theme.spacing.endpointValueGap}px`],\n ['--oc-endpoint-column-gap', `${theme.spacing.endpointColumnGap}px`],\n ['--oc-eyebrow-size', `${theme.chrome.eyebrow.fontSize}px`],\n ['--oc-eyebrow-weight', `${theme.chrome.eyebrow.fontWeight}`],\n ['--oc-bg', bg],\n ['--oc-text', theme.colors.text],\n ['--oc-text-muted', theme.colors.axis],\n // Secondary grays are derived from the theme's own text/background pair\n // (ResolvedTheme.colors.neutral), so a warm or cool theme gets warm or\n // cool grays instead of zinc. One direction only: theme -> CSS.\n ['--oc-text-secondary', n.secondary],\n ['--oc-text-faint', n.faint],\n ['--oc-border', n.border],\n ['--oc-gray-100', n[100]],\n ['--oc-gray-200', n[200]],\n ['--oc-gray-300', n[300]],\n ['--oc-gray-400', n[400]],\n ['--oc-gray-600', n[600]],\n ['--oc-gray-800', n[800]],\n ['--oc-gridline', theme.colors.gridline],\n // --oc-axis is the hairline the axis line is drawn with, not the ink its\n // tick labels take (that is --oc-text-muted, above).\n ['--oc-axis', theme.colors.hairline],\n ['--oc-border-radius', `${theme.borderRadius}px`],\n ['--oc-accent', accent],\n ['--oc-accent-strong', adaptForLightLineStroke(accent)],\n ['--oc-positive', theme.colors.positive],\n ['--oc-negative', theme.colors.negative],\n ['--oc-space-2', `${theme.spacing.chromeGap * 2}px`],\n ['--oc-space-4', `${theme.spacing.padding}px`],\n ];\n\n const authored = theme._authored;\n const colors = authored?.colors && !Array.isArray(authored.colors) ? authored.colors : {};\n const neutralAuthored = colors.text !== undefined || colors.background !== undefined;\n const colorAuthored = (key: keyof Exclude<ThemeConfig['colors'], string[] | undefined>) =>\n colors[key] !== undefined;\n const chromeAuthored = (\n element: 'title' | 'subtitle' | 'source' | 'eyebrow',\n field: 'fontSize' | 'fontWeight',\n ) => {\n if (authored?.chrome?.[element]?.[field] !== undefined) return true;\n if (field === 'fontWeight' || element === 'eyebrow') return false;\n return authored?.fonts?.sizes?.[element === 'source' ? 'small' : element] !== undefined;\n };\n const paletteAuthored = Array.isArray(authored?.colors) || colors.categorical !== undefined;\n const enabled: Record<string, boolean> = {\n '--oc-font-family': authored?.fonts?.family !== undefined,\n '--oc-font-mono': authored?.fonts?.mono !== undefined,\n '--oc-title-size': chromeAuthored('title', 'fontSize'),\n '--oc-title-weight': chromeAuthored('title', 'fontWeight'),\n '--oc-subtitle-size': chromeAuthored('subtitle', 'fontSize'),\n '--oc-subtitle-weight': chromeAuthored('subtitle', 'fontWeight'),\n '--oc-source-size': chromeAuthored('source', 'fontSize'),\n '--oc-source-weight': chromeAuthored('source', 'fontWeight'),\n '--oc-body-size': authored?.fonts?.sizes?.body !== undefined,\n '--oc-endpoint-label-size': authored?.fonts?.sizes?.endpointLabel !== undefined,\n '--oc-endpoint-value-size': authored?.fonts?.sizes?.endpointValue !== undefined,\n '--oc-endpoint-entry-gap': authored?.spacing?.endpointEntryGap !== undefined,\n '--oc-endpoint-value-gap': authored?.spacing?.endpointValueGap !== undefined,\n '--oc-endpoint-column-gap': authored?.spacing?.endpointColumnGap !== undefined,\n '--oc-eyebrow-size': chromeAuthored('eyebrow', 'fontSize'),\n '--oc-eyebrow-weight': chromeAuthored('eyebrow', 'fontWeight'),\n '--oc-bg': colorAuthored('background'),\n '--oc-text': colorAuthored('text'),\n '--oc-text-muted': colorAuthored('axis') || (kind === 'table' && neutralAuthored),\n '--oc-text-secondary': neutralAuthored,\n '--oc-text-faint': neutralAuthored,\n '--oc-border': neutralAuthored || (kind === 'table' && colorAuthored('gridline')),\n '--oc-gridline': colorAuthored('gridline'),\n '--oc-axis': colorAuthored('hairline'),\n '--oc-border-radius': authored?.borderRadius !== undefined,\n '--oc-accent': paletteAuthored,\n '--oc-accent-strong': paletteAuthored,\n '--oc-positive': colorAuthored('positive'),\n '--oc-negative': colorAuthored('negative'),\n '--oc-space-2': authored?.spacing?.chromeGap !== undefined,\n '--oc-space-4': authored?.spacing?.padding !== undefined,\n };\n for (const key of [\n 'annotationLabel',\n 'annotationMuted',\n 'annotationLeader',\n 'annotationRule',\n 'annotationRangeFill',\n 'annotationMarkerFill',\n 'annotationPlate',\n ] as const) {\n const name = `--oc-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;\n props.push([name, theme.colors[key]]);\n enabled[name] =\n colorAuthored(key) ||\n ((key === 'annotationMarkerFill' || key === 'annotationPlate') && neutralAuthored);\n }\n for (const key of [\n 'gridlineZero',\n 'mapNoDataFill',\n 'mapNoDataHatch',\n 'mapInteriorBorder',\n 'mapOutlineBorder',\n ] as const) {\n const name = `--oc-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;\n if (theme.colors[key] !== undefined) props.push([name, theme.colors[key]]);\n enabled[name] = colorAuthored(key);\n }\n for (const level of [100, 200, 300, 400, 600, 800])\n enabled[`--oc-gray-${level}`] = neutralAuthored;\n if (kind === 'table') {\n if (!colorAuthored('axis')) props.find(([name]) => name === '--oc-text-muted')![1] = n[600];\n if (colorAuthored('gridline'))\n props.find(([name]) => name === '--oc-border')![1] = theme.colors.gridline;\n }\n const previous = stamped.get(el) ?? new Map();\n for (const [name, entry] of previous) {\n if (!enabled[name]) {\n // Do not erase a host change made since our last stamp.\n if (el.style.getPropertyValue(name) === entry.value) {\n if (entry.previous) el.style.setProperty(name, entry.previous, entry.priority);\n else el.style.removeProperty(name);\n }\n previous.delete(name);\n }\n }\n for (const [name, value] of props) {\n if (!enabled[name]) continue;\n const old = previous.get(name);\n previous.set(name, {\n previous: old?.previous ?? el.style.getPropertyValue(name),\n priority: old?.priority ?? el.style.getPropertyPriority(name),\n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iB,IAAI;AAAA,MACzD,UAAU,KAAK,YAAY,GAAG,MAAM,oBAAoB,IAAI;AAAA,MAC5D;AAAA,IACF,CAAC;AACD,OAAG,MAAM,YAAY,MAAM,KAAK;AAAA,EAClC;AACA,UAAQ,IAAI,IAAI,QAAQ;AAC1B;","names":["text","computeNoteBandHeight","computeNoteBandHeight"]}
@@ -1,6 +1,7 @@
1
1
  import {
2
+ copyComputedThemeProperties,
2
3
  injectThemeStyleBlock
3
- } from "./chunk-SDJHUELU.js";
4
+ } from "./chunk-A5C4VCUO.js";
4
5
 
5
6
  // src/export.ts
6
7
  function getSVGDimensions(svg) {
@@ -147,14 +148,24 @@ function getSVGBackgroundColor(svgElement, fallback) {
147
148
  return fill;
148
149
  }
149
150
  function exportSVG(svgElement) {
150
- if (!svgElement.getAttribute("xmlns")) {
151
- svgElement.setAttribute("xmlns", "http://www.w3.org/2000/svg");
151
+ const clone = svgElement.cloneNode(true);
152
+ for (const control of clone.querySelectorAll(
153
+ ".oc-selection-overlay, .oc-anchor-handle, .oc-connector-handle"
154
+ ))
155
+ control.remove();
156
+ clone.classList.remove("oc-note-active");
157
+ for (const element of clone.querySelectorAll(".oc-note-active")) {
158
+ element.classList.remove("oc-note-active");
159
+ }
160
+ if (!clone.getAttribute("xmlns")) {
161
+ clone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
152
162
  }
153
163
  const serializer = new XMLSerializer();
154
- return serializer.serializeToString(svgElement);
164
+ return serializer.serializeToString(clone);
155
165
  }
156
166
  async function exportSVGWithFonts(svgElement, options) {
157
167
  const clone = svgElement.cloneNode(true);
168
+ copyComputedThemeProperties(svgElement, clone);
158
169
  const shouldEmbed = options?.embedFonts ?? true;
159
170
  injectThemeStyleBlock(clone, options?.theme);
160
171
  if (shouldEmbed) {
@@ -214,6 +225,7 @@ function rasterizeSVGToCanvas(svgString, width, height, dpi, prepare) {
214
225
  async function prepareRasterSVG(svgElement, shouldEmbed, theme) {
215
226
  const { width, height } = getSVGDimensions(svgElement);
216
227
  const clone = svgElement.cloneNode(true);
228
+ copyComputedThemeProperties(svgElement, clone);
217
229
  injectThemeStyleBlock(clone, theme);
218
230
  if (shouldEmbed) {
219
231
  await embedFonts(clone);
@@ -297,4 +309,4 @@ export {
297
309
  exportJPG,
298
310
  exportCSV
299
311
  };
300
- //# sourceMappingURL=chunk-R5TZHNTG.js.map
312
+ //# sourceMappingURL=chunk-RBXIZJPE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/export.ts"],"sourcesContent":["/**\n * Export utilities: serialize charts to SVG, PNG, JPG, or CSV.\n *\n * - SVG: serializes the rendered DOM element via XMLSerializer\n * - SVG with fonts: async version that embeds @font-face data URIs\n * - PNG: renders SVG to canvas, then extracts as Blob\n * - JPG: same as PNG but with JPEG compression and background fill\n * - CSV: converts a data array to comma-separated text\n */\n\nimport type { ResolvedTheme } from '@opendata-ai/openchart-core';\nimport { copyComputedThemeProperties, injectThemeStyleBlock } from './theme-style-block';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface SVGExportOptions {\n /** Embed fonts as base64 data URIs in the SVG. Defaults to true. */\n embedFonts?: boolean;\n /**\n * Resolved theme to inline as a `<style>` block, so class-based fills (metric\n * cells, eyebrow dot, legend text, endpoint labels) survive\n * serialization away from the page stylesheet. Omit to skip — a chart whose\n * chrome is all inline-filled exports fine without it.\n */\n theme?: ResolvedTheme;\n}\n\nexport interface PNGExportOptions extends SVGExportOptions {\n /** DPI scaling factor. Defaults to 2 for retina-quality output. */\n dpi?: number;\n}\n\nexport interface JPGExportOptions extends PNGExportOptions {\n /** JPEG quality from 0 to 1. Defaults to 0.92. */\n quality?: number;\n}\n\ninterface FontFaceData {\n family: string;\n weight: string;\n style: string;\n base64: string;\n format: string;\n}\n\n// ---------------------------------------------------------------------------\n// Dimension parsing\n// ---------------------------------------------------------------------------\n\n/**\n * Extract dimensions from an SVG element, trying width/height attributes\n * first, then falling back to viewBox.\n */\nexport function getSVGDimensions(svg: SVGElement): { width: number; height: number } {\n const w = parseFloat(svg.getAttribute('width') || '');\n const h = parseFloat(svg.getAttribute('height') || '');\n if (w && h) return { width: w, height: h };\n\n const vb = svg.getAttribute('viewBox');\n if (vb) {\n const parts = vb.split(/[\\s,]+/).map(Number);\n if (parts.length >= 4 && parts[2] && parts[3]) {\n return { width: parts[2], height: parts[3] };\n }\n }\n\n return { width: 600, height: 400 };\n}\n\n/**\n * Ensure an SVG string has explicit width/height attributes.\n *\n * When an SVG only has a viewBox (no width/height), browsers loading it as\n * an Image blob may use 300x150 as the intrinsic size instead of the viewBox\n * dimensions. This causes clipping at non-1x DPI scaling. Injecting explicit\n * width/height into the root <svg> tag fixes the intrinsic size.\n */\nexport function ensureSVGDimensions(svgString: string, width: number, height: number): string {\n // If the <svg> already has a width attribute, leave it alone\n if (/^<svg[^>]*\\swidth\\s*=/.test(svgString)) return svgString;\n // Inject width and height right after <svg\n return svgString.replace(/^(<svg)/, `$1 width=\"${width}\" height=\"${height}\"`);\n}\n\n// ---------------------------------------------------------------------------\n// Font embedding\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve an authored font declaration, including SVG inheritance. Inline\n * styles win over presentation attributes, as they do in the live renderer.\n * This also works on detached terminal scenes used for exports.\n */\nfunction inheritedFontProperty(element: SVGElement, root: SVGElement, property: string): string {\n let current: SVGElement | null = element;\n while (current) {\n const value = current.style.getPropertyValue(property) || current.getAttribute(property);\n const keyword = value?.trim().toLowerCase();\n // Unlike inheritance, initial resets to normal weight or the browser's\n // default family, which has no authored font face to embed.\n if (keyword === 'initial') return property === 'font-weight' ? '400' : '';\n if (value && keyword !== 'inherit' && keyword !== 'unset') return value;\n if (current === root) break;\n current = current.parentElement as SVGElement | null;\n }\n return '';\n}\n\nfunction normalizeFontWeight(weight: string): string {\n const value = weight.trim();\n return value === 'normal' ? '400' : value === 'bold' ? '700' : value;\n}\n\n/** Collect font families and weights, including styled spans within labels. */\nfunction collectUsedFonts(svgElement: SVGElement): Map<string, Set<string>> {\n const fonts = new Map<string, Set<string>>();\n const textElements = svgElement.querySelectorAll<SVGElement>('text, tspan');\n\n for (const el of textElements) {\n const family = inheritedFontProperty(el, svgElement, 'font-family');\n const weight = normalizeFontWeight(\n inheritedFontProperty(el, svgElement, 'font-weight') || '400',\n );\n if (family) {\n // Take the first font in the stack (e.g., \"Inter, sans-serif\" → \"Inter\")\n const primary = family.split(',')[0].trim().replace(/[\"']/g, '');\n if (!fonts.has(primary)) fonts.set(primary, new Set());\n fonts.get(primary)!.add(String(weight));\n }\n }\n\n return fonts;\n}\n\n/**\n * Find @font-face rules in document stylesheets that match the requested fonts.\n * Returns the src URLs for .woff2 files.\n */\nfunction findFontFaceRules(\n usedFonts: Map<string, Set<string>>,\n): Array<{ family: string; weight: string; style: string; url: string; format: string }> {\n const results: Array<{\n family: string;\n weight: string;\n style: string;\n url: string;\n format: string;\n }> = [];\n\n try {\n for (const sheet of document.styleSheets) {\n let rules: CSSRuleList;\n try {\n rules = sheet.cssRules;\n } catch {\n // Cross-origin stylesheet, skip\n continue;\n }\n\n for (const rule of rules) {\n if (!(rule instanceof CSSFontFaceRule)) continue;\n\n const familyRaw = rule.style.getPropertyValue('font-family').replace(/[\"']/g, '').trim();\n const weight = normalizeFontWeight(rule.style.getPropertyValue('font-weight') || '400');\n const style = rule.style.getPropertyValue('font-style') || 'normal';\n const src = rule.style.getPropertyValue('src');\n\n const weights = usedFonts.get(familyRaw);\n if (!weights) continue;\n\n // Check if this weight is used (handle ranges like \"100 900\")\n const weightMatch = weights.has(weight) || weight.includes(' ');\n if (!weightMatch) continue;\n\n // Extract woff2 URL from src descriptor\n const woff2Match = src.match(/url\\([\"']?([^\"')]+\\.woff2[^\"')]*?)[\"']?\\)/);\n if (woff2Match) {\n results.push({\n family: familyRaw,\n weight,\n style,\n url: woff2Match[1],\n format: 'woff2',\n });\n }\n }\n }\n } catch {\n // Stylesheet access failed entirely, return empty\n }\n\n return results;\n}\n\n/**\n * Fetch font files and convert to base64 data URIs.\n */\nasync function fetchFontsAsBase64(\n fontRules: Array<{ family: string; weight: string; style: string; url: string; format: string }>,\n): Promise<FontFaceData[]> {\n const results: FontFaceData[] = [];\n\n const fetches = fontRules.map(async (rule) => {\n try {\n const response = await fetch(rule.url);\n if (!response.ok) return;\n const buffer = await response.arrayBuffer();\n const base64 = arrayBufferToBase64(buffer);\n results.push({\n family: rule.family,\n weight: rule.weight,\n style: rule.style,\n base64,\n format: rule.format,\n });\n } catch {\n // Font fetch failed (CORS, network, etc.) - skip this font\n }\n });\n\n await Promise.all(fetches);\n return results;\n}\n\nfunction arrayBufferToBase64(buffer: ArrayBuffer): string {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n/**\n * Inject @font-face rules with base64 data URIs into the SVG's <defs>.\n */\nfunction injectFontsIntoSVG(svgElement: SVGElement, fonts: FontFaceData[]): void {\n if (fonts.length === 0) return;\n\n const cssRules = fonts\n .map(\n (f) =>\n `@font-face { font-family: '${f.family}'; font-weight: ${f.weight}; font-style: ${f.style}; src: url(data:font/${f.format};base64,${f.base64}) format('${f.format}'); }`,\n )\n .join('\\n');\n\n const ns = 'http://www.w3.org/2000/svg';\n let defs = svgElement.querySelector('defs');\n if (!defs) {\n defs = document.createElementNS(ns, 'defs');\n svgElement.insertBefore(defs, svgElement.firstChild);\n }\n\n const styleEl = document.createElementNS(ns, 'style');\n styleEl.textContent = cssRules;\n defs.insertBefore(styleEl, defs.firstChild);\n}\n\n/**\n * Embed fonts into an SVG element by finding matching @font-face rules\n * in the page's stylesheets, fetching the font files, and injecting\n * them as base64 data URIs.\n *\n * Modifies the SVG element in place. Call this before serialization.\n * If font fetching fails for any font, that font is silently skipped\n * and the export proceeds with system font fallback for that face.\n */\nexport async function embedFonts(svgElement: SVGElement): Promise<void> {\n const usedFonts = collectUsedFonts(svgElement);\n if (usedFonts.size === 0) return;\n\n const fontRules = findFontFaceRules(usedFonts);\n if (fontRules.length === 0) return;\n\n const fontData = await fetchFontsAsBase64(fontRules);\n injectFontsIntoSVG(svgElement, fontData);\n}\n\n// ---------------------------------------------------------------------------\n// SVG background color\n// ---------------------------------------------------------------------------\n\n/**\n * Read the chart's background color from its first rect element. Falls back to\n * `fallback` (white when omitted) when the chart has no opaque background,\n * which matters for formats that can't carry alpha (JPEG, GIF).\n *\n * Pass the resolved theme's `colors.background` as `fallback` when the caller\n * has one: canvas mark mode suppresses the SVG background rect (the canvas\n * paints it), so without it a dark chart would flood-fill white.\n */\nexport function getSVGBackgroundColor(svgElement: SVGElement, fallback?: string): string {\n const firstRect = svgElement.querySelector('rect');\n const fill = firstRect?.getAttribute('fill');\n if (!fill || fill === 'none' || fill === 'transparent') return fallback ?? '#ffffff';\n return fill;\n}\n\n// ---------------------------------------------------------------------------\n// SVG export\n// ---------------------------------------------------------------------------\n\n/**\n * Serialize an SVG element to an XML string.\n *\n * @param svgElement - The rendered SVG element to serialize.\n * @returns The SVG markup as a string.\n */\nexport function exportSVG(svgElement: SVGElement): string {\n // Export a clean snapshot without changing the live chart's focus/selection.\n // Every SVG and raster path serializes here, including font-embedded exports.\n const clone = svgElement.cloneNode(true) as SVGElement;\n for (const control of clone.querySelectorAll(\n '.oc-selection-overlay, .oc-anchor-handle, .oc-connector-handle',\n ))\n control.remove();\n clone.classList.remove('oc-note-active');\n for (const element of clone.querySelectorAll('.oc-note-active')) {\n element.classList.remove('oc-note-active');\n }\n if (!clone.getAttribute('xmlns')) {\n clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');\n }\n const serializer = new XMLSerializer();\n return serializer.serializeToString(clone);\n}\n\n/**\n * Serialize an SVG element with embedded fonts to an XML string.\n *\n * Collects font-family declarations from the SVG's text elements,\n * finds matching @font-face rules in the page's stylesheets, fetches\n * the font files, and embeds them as base64 data URIs. The resulting\n * SVG is self-contained and renders correctly without external fonts.\n *\n * @param svgElement - The rendered SVG element to serialize.\n * @param options - Export options.\n * @returns A Promise resolving to the SVG markup as a string.\n */\nexport async function exportSVGWithFonts(\n svgElement: SVGElement,\n options?: SVGExportOptions,\n): Promise<string> {\n const clone = svgElement.cloneNode(true) as SVGElement;\n copyComputedThemeProperties(svgElement, clone);\n const shouldEmbed = options?.embedFonts ?? true;\n injectThemeStyleBlock(clone, options?.theme);\n if (shouldEmbed) {\n await embedFonts(clone);\n }\n return exportSVG(clone);\n}\n\n// ---------------------------------------------------------------------------\n// Raster export (PNG / JPG)\n// ---------------------------------------------------------------------------\n\n/**\n * Cache the one-time probe for Display P3 canvas support. Rendering raster\n * exports into a display-p3 canvas makes toBlob embed a wide-gamut color profile\n * (verified: an sRGB PNG has no iCCP chunk; a display-p3 PNG does — and JPEG\n * upgrades from an sRGB to a P3 profile), so the export matches the on-screen\n * chart instead of reading as an untagged/sRGB image that looks washed out on\n * P3 displays.\n */\nlet p3Supported: boolean | undefined;\n\nfunction supportsDisplayP3(): boolean {\n if (p3Supported !== undefined) return p3Supported;\n try {\n const probe = document.createElement('canvas');\n const ctx = probe.getContext('2d', { colorSpace: 'display-p3' }) as\n | (CanvasRenderingContext2D & { getContextAttributes?: () => { colorSpace?: string } })\n | null;\n p3Supported = !!ctx && ctx.getContextAttributes?.().colorSpace === 'display-p3';\n } catch {\n p3Supported = false;\n }\n return p3Supported;\n}\n\n/**\n * Create a 2D context in the widest color space the runtime supports. A\n * display-p3 canvas is what makes toBlob embed the profile. Callers that read\n * pixels back for a non-color-managed sink (GIF quantization) must NOT rely on\n * this — they must read back in sRGB explicitly.\n */\nfunction getExportContext(canvas: HTMLCanvasElement): CanvasRenderingContext2D {\n const ctx = supportsDisplayP3()\n ? canvas.getContext('2d', { colorSpace: 'display-p3' })\n : canvas.getContext('2d');\n if (!ctx) {\n throw new Error('Canvas 2D context not available');\n }\n return ctx;\n}\n\n/**\n * Draw a serialized SVG string onto a canvas at DPI scaling.\n *\n * Shared by PNG/JPG export and per-frame GIF rendering: loads the SVG string\n * as an Image via an object URL, draws it into a `width*dpi × height*dpi`\n * canvas, and hands the canvas back once painted. The caller decides how to\n * read the result (toBlob for PNG/JPG, getImageData for GIF frames).\n *\n * An optional `prepare` hook runs before drawing the image, used by JPG export\n * to fill an opaque background so transparency doesn't render as black.\n *\n * @param svgString - Serialized SVG markup (should already carry width/height).\n * @param width - Logical width in CSS pixels.\n * @param height - Logical height in CSS pixels.\n * @param dpi - Device pixel ratio scaling factor.\n * @param prepare - Optional pre-draw hook receiving the scaled 2D context.\n * @returns A Promise resolving to the painted canvas.\n */\nexport function rasterizeSVGToCanvas(\n svgString: string,\n width: number,\n height: number,\n dpi: number,\n prepare?: (ctx: CanvasRenderingContext2D, canvas: HTMLCanvasElement) => void,\n): Promise<HTMLCanvasElement> {\n if (!width || !height) {\n throw new Error(`SVG has zero dimensions (width=${width}, height=${height})`);\n }\n\n const canvas = document.createElement('canvas');\n canvas.width = width * dpi;\n canvas.height = height * dpi;\n\n const ctx = getExportContext(canvas);\n\n prepare?.(ctx, canvas);\n ctx.scale(dpi, dpi);\n\n const img = new Image();\n const blob = new Blob([svgString], { type: 'image/svg+xml;charset=utf-8' });\n const url = URL.createObjectURL(blob);\n\n return new Promise<HTMLCanvasElement>((resolve, reject) => {\n img.onload = () => {\n ctx.drawImage(img, 0, 0, width, height);\n URL.revokeObjectURL(url);\n resolve(canvas);\n };\n\n img.onerror = () => {\n URL.revokeObjectURL(url);\n reject(\n new Error(\n `Failed to load SVG as image (width=${width}, height=${height}, svgLength=${svgString.length})`,\n ),\n );\n };\n\n img.src = url;\n });\n}\n\n/**\n * Serialize an SVG element (optionally embedding fonts) into a canvas-ready\n * string with explicit width/height. Shared by the raster exporters.\n */\nasync function prepareRasterSVG(\n svgElement: SVGElement,\n shouldEmbed: boolean,\n theme?: ResolvedTheme,\n): Promise<{ svgString: string; width: number; height: number }> {\n const { width, height } = getSVGDimensions(svgElement);\n const clone = svgElement.cloneNode(true) as SVGElement;\n copyComputedThemeProperties(svgElement, clone);\n // Inline the theme style block so class-based fills survive the detach from\n // the page stylesheet. No-op when theme is undefined.\n injectThemeStyleBlock(clone, theme);\n if (shouldEmbed) {\n await embedFonts(clone);\n }\n const svgString = ensureSVGDimensions(exportSVG(clone), width, height);\n return { svgString, width, height };\n}\n\n/**\n * Render an SVG element to a PNG Blob via a canvas.\n *\n * Embeds fonts by default so the exported image matches on-screen rendering.\n * Set `embedFonts: false` to skip font embedding for faster exports.\n *\n * @param svgElement - The rendered SVG element.\n * @param options - Optional DPI scaling and font embedding.\n * @returns A Promise resolving to the PNG Blob.\n */\nexport async function exportPNG(svgElement: SVGElement, options?: PNGExportOptions): Promise<Blob> {\n const dpi = options?.dpi ?? 2;\n const shouldEmbed = options?.embedFonts ?? true;\n const { svgString, width, height } = await prepareRasterSVG(\n svgElement,\n shouldEmbed,\n options?.theme,\n );\n const canvas = await rasterizeSVGToCanvas(svgString, width, height, dpi);\n\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob((result) => {\n if (result) {\n resolve(result);\n } else {\n reject(new Error('Canvas toBlob returned null'));\n }\n }, 'image/png');\n });\n}\n\n/**\n * Render an SVG element to a JPEG Blob via a canvas.\n *\n * Same pipeline as exportPNG but outputs JPEG with configurable quality.\n * The canvas is filled with the chart's background color before drawing\n * to avoid transparent backgrounds rendering as black in JPEG format.\n *\n * @param svgElement - The rendered SVG element.\n * @param options - Optional DPI scaling, JPEG quality, and font embedding.\n * @returns A Promise resolving to the JPEG Blob.\n */\nexport async function exportJPG(svgElement: SVGElement, options?: JPGExportOptions): Promise<Blob> {\n const dpi = options?.dpi ?? 2;\n const quality = options?.quality ?? 0.92;\n const shouldEmbed = options?.embedFonts ?? true;\n const backgroundColor = getSVGBackgroundColor(svgElement);\n const { svgString, width, height } = await prepareRasterSVG(\n svgElement,\n shouldEmbed,\n options?.theme,\n );\n\n // Fill an opaque background before drawing so transparency doesn't render\n // as black in the JPEG. Runs before ctx.scale, so use the raw canvas size.\n const canvas = await rasterizeSVGToCanvas(svgString, width, height, dpi, (ctx, cv) => {\n ctx.fillStyle = backgroundColor;\n ctx.fillRect(0, 0, cv.width, cv.height);\n });\n\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n (result) => {\n if (result) {\n resolve(result);\n } else {\n reject(new Error('Canvas toBlob returned null'));\n }\n },\n 'image/jpeg',\n quality,\n );\n });\n}\n\n// ---------------------------------------------------------------------------\n// CSV export\n// ---------------------------------------------------------------------------\n\n/**\n * Convert an array of data objects to a CSV string.\n *\n * Uses the keys from the first row as column headers.\n * Values are quoted if they contain commas, quotes, or newlines.\n *\n * @param data - Array of row objects.\n * @returns CSV-formatted string.\n */\nexport function exportCSV(data: Record<string, unknown>[]): string {\n if (data.length === 0) return '';\n\n const headers = Object.keys(data[0]);\n const rows = [headers.map(csvEscape).join(',')];\n\n for (const row of data) {\n const values = headers.map((h) => csvEscape(String(row[h] ?? '')));\n rows.push(values.join(','));\n }\n\n return rows.join('\\n');\n}\n\nfunction csvEscape(value: string): string {\n if (value.includes(',') || value.includes('\"') || value.includes('\\n') || value.includes('\\r')) {\n return `\"${value.replace(/\"/g, '\"\"')}\"`;\n }\n return value;\n}\n"],"mappings":";;;;;;AAuDO,SAAS,iBAAiB,KAAoD;AACnF,QAAM,IAAI,WAAW,IAAI,aAAa,OAAO,KAAK,EAAE;AACpD,QAAM,IAAI,WAAW,IAAI,aAAa,QAAQ,KAAK,EAAE;AACrD,MAAI,KAAK,EAAG,QAAO,EAAE,OAAO,GAAG,QAAQ,EAAE;AAEzC,QAAM,KAAK,IAAI,aAAa,SAAS;AACrC,MAAI,IAAI;AACN,UAAM,QAAQ,GAAG,MAAM,QAAQ,EAAE,IAAI,MAAM;AAC3C,QAAI,MAAM,UAAU,KAAK,MAAM,CAAC,KAAK,MAAM,CAAC,GAAG;AAC7C,aAAO,EAAE,OAAO,MAAM,CAAC,GAAG,QAAQ,MAAM,CAAC,EAAE;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO,EAAE,OAAO,KAAK,Q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