vizmatic 0.7.0 → 0.7.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.
package/dist/index.cjs CHANGED
@@ -62,6 +62,7 @@ __export(index_exports, {
62
62
  DonutChart: () => DonutChart,
63
63
  DotPoint: () => DotPoint,
64
64
  ELEMENT_SYMBOLS: () => ELEMENT_SYMBOLS,
65
+ EntityRelationshipDiagram: () => EntityRelationshipDiagram,
65
66
  EquationCard: () => EquationCard,
66
67
  FactRows: () => FactRows,
67
68
  Flow: () => Flow,
@@ -137,7 +138,9 @@ __export(index_exports, {
137
138
  byteDifferenceState: () => byteDifferenceState,
138
139
  cameraSvgTransform: () => cameraSvgTransform,
139
140
  canvas: () => canvas,
141
+ captionsToSrt: () => captionsToSrt,
140
142
  categoricalSampling: () => categoricalSampling,
143
+ chapterMetadata: () => chapterMetadata,
141
144
  checkFrame: () => checkFrame,
142
145
  colors: () => colors,
143
146
  compareByteSequences: () => compareByteSequences,
@@ -875,6 +878,7 @@ __export(primitives_exports, {
875
878
  DonutChart: () => DonutChart,
876
879
  DotPoint: () => DotPoint,
877
880
  ELEMENT_SYMBOLS: () => ELEMENT_SYMBOLS,
881
+ EntityRelationshipDiagram: () => EntityRelationshipDiagram,
878
882
  EquationCard: () => EquationCard,
879
883
  FactRows: () => FactRows,
880
884
  Flow: () => Flow,
@@ -2533,7 +2537,231 @@ function MetricCard({
2533
2537
  }
2534
2538
 
2535
2539
  // src/primitives/dense.ts
2536
- var import_react4 = __toESM(require("react"), 1);
2540
+ var import_react5 = __toESM(require("react"), 1);
2541
+
2542
+ // src/svg-accessibility.ts
2543
+ var import_react4 = require("react");
2544
+ var SVG_ACCESSIBILITY_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.svgAccessibilityComponent");
2545
+ function chartAccessibilityAttributes({ id, ariaLabel, description }) {
2546
+ const title = ariaLabel?.trim() || "Chart";
2547
+ return {
2548
+ role: "img",
2549
+ "aria-label": title,
2550
+ "aria-description": description,
2551
+ "data-vizmatic-chart-id": id,
2552
+ "data-vizmatic-chart-title": title,
2553
+ "data-vizmatic-chart-description": description
2554
+ };
2555
+ }
2556
+ function chartDescription(description, entries2) {
2557
+ return [description, entries2.length ? `${entries2.join("; ")}.` : "No data."].filter(Boolean).join(" ");
2558
+ }
2559
+ function componentHasSvgMetadata(type) {
2560
+ return typeof type === "function" && type[SVG_ACCESSIBILITY_COMPONENT] === true;
2561
+ }
2562
+ function svgToken(value) {
2563
+ if (value.length === 0) return "empty";
2564
+ return Array.from(value, (character) => {
2565
+ const codePoint = character.codePointAt(0) ?? 0;
2566
+ return /^[A-Za-z0-9.-]$/.test(character) ? character : `_u${codePoint.toString(16)}_`;
2567
+ }).join("");
2568
+ }
2569
+ function textProperty(props, name) {
2570
+ const value = props[name];
2571
+ return typeof value === "string" ? value : "";
2572
+ }
2573
+ function encodedTextProperty(props, name) {
2574
+ const value = textProperty(props, name);
2575
+ try {
2576
+ return decodeURIComponent(value);
2577
+ } catch {
2578
+ return value;
2579
+ }
2580
+ }
2581
+ function prepareAccessibleSvg(element) {
2582
+ const graphs = [];
2583
+ const explicitIds = /* @__PURE__ */ new Set();
2584
+ const visit = (node, graph) => {
2585
+ if (Array.isArray(node)) return node.map((child) => visit(child, graph));
2586
+ if (!(0, import_react4.isValidElement)(node)) return node;
2587
+ const component = node.type;
2588
+ if (componentHasSvgMetadata(component)) {
2589
+ return visit(component(node.props), graph);
2590
+ }
2591
+ const props = node.props;
2592
+ const title = textProperty(props, "data-vizmatic-svg-title");
2593
+ const isGraphRoot = title.length > 0;
2594
+ let activeGraph = graph;
2595
+ let elementKey = node.key;
2596
+ if (isGraphRoot) {
2597
+ const explicitId = textProperty(props, "data-vizmatic-svg-id");
2598
+ if (explicitId) {
2599
+ if (explicitIds.has(explicitId)) {
2600
+ throw new Error(`GraphDiagram SVG id "${explicitId}" must be unique in one exported SVG.`);
2601
+ }
2602
+ explicitIds.add(explicitId);
2603
+ }
2604
+ const index = graphs.length;
2605
+ const token = explicitId ? `id-${svgToken(explicitId)}` : `index-${index}`;
2606
+ activeGraph = {
2607
+ index,
2608
+ token,
2609
+ detectionKey: `vizmatic-graph-${index}`,
2610
+ title,
2611
+ description: textProperty(props, "data-vizmatic-svg-description"),
2612
+ nodes: [],
2613
+ edges: []
2614
+ };
2615
+ graphs.push(activeGraph);
2616
+ elementKey = activeGraph.detectionKey;
2617
+ }
2618
+ let nextProps;
2619
+ if (activeGraph && Object.hasOwn(props, "data-vizmatic-graph-node-id")) {
2620
+ const id = textProperty(props, "data-vizmatic-graph-node-id");
2621
+ const label = textProperty(props, "data-vizmatic-graph-node-label") || id;
2622
+ const detail = textProperty(props, "data-vizmatic-graph-node-detail");
2623
+ activeGraph.nodes.push({
2624
+ id,
2625
+ label,
2626
+ detail,
2627
+ title: textProperty(props, "data-vizmatic-graph-node-title") || label,
2628
+ href: textProperty(props, "data-vizmatic-graph-node-href") || void 0
2629
+ });
2630
+ elementKey = `${activeGraph.detectionKey}-node-${svgToken(id)}`;
2631
+ } else if (activeGraph && textProperty(props, "data-vizmatic-graph-edge-id")) {
2632
+ const id = encodedTextProperty(props, "data-vizmatic-graph-edge-id");
2633
+ activeGraph.edges.push({
2634
+ id,
2635
+ from: encodedTextProperty(props, "data-vizmatic-graph-edge-from"),
2636
+ to: encodedTextProperty(props, "data-vizmatic-graph-edge-to"),
2637
+ label: encodedTextProperty(props, "data-vizmatic-graph-edge-label"),
2638
+ title: encodedTextProperty(props, "data-vizmatic-graph-edge-title"),
2639
+ path: textProperty(props, "d"),
2640
+ href: encodedTextProperty(props, "data-vizmatic-graph-edge-href") || void 0
2641
+ });
2642
+ elementKey = `${activeGraph.detectionKey}-edge-${svgToken(id)}`;
2643
+ }
2644
+ const children = props.children;
2645
+ if (children === void 0) {
2646
+ if (isGraphRoot) {
2647
+ nextProps = { ...props, "data-vizmatic-svg-instance": activeGraph?.token };
2648
+ return (0, import_react4.cloneElement)(node, { ...nextProps, key: elementKey });
2649
+ }
2650
+ return node;
2651
+ }
2652
+ const preparedChildren = visit(children, activeGraph);
2653
+ nextProps = isGraphRoot ? { ...props, "data-vizmatic-svg-instance": activeGraph?.token } : { ...props };
2654
+ return (0, import_react4.cloneElement)(
2655
+ node,
2656
+ { ...nextProps, key: elementKey },
2657
+ preparedChildren
2658
+ );
2659
+ };
2660
+ return { element: visit(element), graphs };
2661
+ }
2662
+ function escapeXml(value) {
2663
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
2664
+ }
2665
+ function attribute(name, value) {
2666
+ return `${name}="${escapeXml(value)}"`;
2667
+ }
2668
+ function graphBaseId(graph) {
2669
+ return `vizmatic-graph-${graph.token}`;
2670
+ }
2671
+ function nodeId(graph, node) {
2672
+ return `${graphBaseId(graph)}-node-${svgToken(node.id)}`;
2673
+ }
2674
+ function edgeId(graph, edge) {
2675
+ return `${graphBaseId(graph)}-edge-${svgToken(edge.id)}`;
2676
+ }
2677
+ function labelForEdge(graph, edge) {
2678
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node.label]));
2679
+ const from = nodes.get(edge.from) ?? edge.from;
2680
+ const to = nodes.get(edge.to) ?? edge.to;
2681
+ return edge.title || (edge.label ? `${from} to ${to}: ${edge.label}` : `${from} to ${to}`);
2682
+ }
2683
+ function descriptionForEdge(graph, edge) {
2684
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node.label]));
2685
+ const from = nodes.get(edge.from) ?? edge.from;
2686
+ const to = nodes.get(edge.to) ?? edge.to;
2687
+ return `Relationship from ${from} to ${to}${edge.label ? `, labeled ${edge.label}` : ""}.`;
2688
+ }
2689
+ function nodeGroup(graph, node, layout) {
2690
+ const id = nodeId(graph, node);
2691
+ const label = node.detail ? `${node.label}: ${node.detail}` : node.label;
2692
+ const description = node.detail || node.label;
2693
+ const titleId = `${id}-title`;
2694
+ const descriptionId = `${id}-description`;
2695
+ const accessible = `<g ${attribute("id", id)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(node.title || node.label)}</title><desc id="${descriptionId}">${escapeXml(description)}</desc>`;
2696
+ if (!layout) return `${accessible}</g>`;
2697
+ const rect = `<rect x="${layout.left}" y="${layout.top}" width="${layout.width}" height="${layout.height}" fill="transparent" pointer-events="all"/>`;
2698
+ const hitTarget = node.href ? `<a ${attribute("href", node.href)} role="link" tabindex="0" ${attribute("aria-label", label)}>${rect}</a>` : rect;
2699
+ return `${accessible}${hitTarget}</g>`;
2700
+ }
2701
+ function edgeGroup(graph, edge, root) {
2702
+ const id = edgeId(graph, edge);
2703
+ const title = labelForEdge(graph, edge);
2704
+ const titleId = `${id}-title`;
2705
+ const descriptionId = `${id}-description`;
2706
+ const accessible = `<g ${attribute("id", id)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(title)}</title><desc id="${descriptionId}">${escapeXml(descriptionForEdge(graph, edge))}</desc>`;
2707
+ if (!root || !edge.path) return `${accessible}</g>`;
2708
+ const path = `<path d="${escapeXml(edge.path)}" transform="translate(${root.left} ${root.top})" fill="none" stroke="transparent" stroke-width="14" stroke-linecap="round" pointer-events="stroke"/>`;
2709
+ const hitTarget = edge.href ? `<a ${attribute("href", edge.href)} role="link" tabindex="0" ${attribute("aria-label", title)}>${path}</a>` : path;
2710
+ return `${accessible}${hitTarget}</g>`;
2711
+ }
2712
+ function addSvgAccessibility(svg, graphs, layoutNodes) {
2713
+ const chartIds = /* @__PURE__ */ new Set();
2714
+ const charts = layoutNodes.filter((node) => textProperty(node.props, "data-vizmatic-chart-title")).map((node, index) => {
2715
+ const id = textProperty(node.props, "data-vizmatic-chart-id");
2716
+ if (id && chartIds.has(id)) throw new Error(`Chart SVG id "${id}" must be unique in one exported SVG.`);
2717
+ if (id) chartIds.add(id);
2718
+ return {
2719
+ token: id ? `id-${svgToken(id)}` : `index-${index}`,
2720
+ title: textProperty(node.props, "data-vizmatic-chart-title"),
2721
+ description: textProperty(node.props, "data-vizmatic-chart-description")
2722
+ };
2723
+ });
2724
+ if (graphs.length === 0 && charts.length === 0) return svg;
2725
+ const items = [...graphs, ...charts];
2726
+ const title = items.map((item) => item.title).join(". ");
2727
+ const description = items.map((item) => `${item.title}. ${item.description}`).join(" ");
2728
+ const hasLinks = graphs.some(
2729
+ (graph) => graph.nodes.some((node) => node.href) || graph.edges.some((edge) => edge.href)
2730
+ );
2731
+ const rootTitleId = "vizmatic-svg-title";
2732
+ const rootDescriptionId = "vizmatic-svg-description";
2733
+ const groupMarkup = graphs.map((graph) => {
2734
+ const baseId = graphBaseId(graph);
2735
+ const titleId = `${baseId}-title`;
2736
+ const descriptionId = `${baseId}-description`;
2737
+ const root = layoutNodes.find((node) => node.key === graph.detectionKey);
2738
+ const nodes = graph.nodes.map((item) => {
2739
+ const layout = layoutNodes.find((node) => node.key === `${graph.detectionKey}-node-${svgToken(item.id)}`);
2740
+ if (item.href && !layout) {
2741
+ throw new Error(`Could not resolve GraphDiagram node "${item.id}" bounds for SVG link export.`);
2742
+ }
2743
+ return nodeGroup(graph, item, layout);
2744
+ }).join("");
2745
+ const edges = graph.edges.map((item) => {
2746
+ if (item.href && !root) {
2747
+ throw new Error(`Could not resolve GraphDiagram bounds for SVG edge link export: "${item.id}".`);
2748
+ }
2749
+ return edgeGroup(graph, item, root);
2750
+ }).join("");
2751
+ return `<g ${attribute("id", baseId)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(graph.title)}</title><desc id="${descriptionId}">${escapeXml(graph.description)}</desc>${nodes}${edges}</g>`;
2752
+ }).join("");
2753
+ const chartMarkup = charts.map((chart) => {
2754
+ const id = `vizmatic-chart-${chart.token}`;
2755
+ return `<g ${attribute("id", id)} role="group" aria-labelledby="${id}-title" aria-describedby="${id}-description"><title id="${id}-title">${escapeXml(chart.title)}</title><desc id="${id}-description">${escapeXml(chart.description)}</desc></g>`;
2756
+ }).join("");
2757
+ const metadata = `<title id="${rootTitleId}">${escapeXml(title)}</title><desc id="${rootDescriptionId}">${escapeXml(description)}</desc>`;
2758
+ return svg.replace(
2759
+ /^<svg\b([^>]*)>/,
2760
+ (_match, attrs) => `<svg${attrs} role="${hasLinks ? "group" : "img"}" aria-labelledby="${rootTitleId}" aria-describedby="${rootDescriptionId}">${metadata}`
2761
+ ).replace(/<\/svg>\s*$/, `${groupMarkup}${chartMarkup}</svg>`);
2762
+ }
2763
+
2764
+ // src/primitives/dense.ts
2537
2765
  var INTER_REGULAR = [281, 288, 466, 633, 642, 982, 644, 300, 365, 365, 501, 662, 288, 460, 288, 360, 631, 407, 610, 618, 646, 593, 620, 566, 619, 620, 288, 302, 662, 662, 662, 511, 966, 690, 654, 730, 722, 601, 590, 746, 743, 269, 571, 672, 565, 903, 753, 765, 639, 765, 644, 642, 646, 744, 690, 985, 682, 679, 629, 365, 360, 365, 471, 456, 323, 562, 612, 571, 612, 583, 370, 613, 591, 242, 242, 549, 242, 876, 591, 600, 612, 612, 376, 528, 327, 591, 562, 818, 546, 562, 552, 426, 333, 426, 662];
2538
2766
  var INTER_SEMIBOLD = [252, 321, 523, 644, 650, 1004, 663, 326, 373, 373, 540, 673, 319, 465, 319, 379, 660, 423, 623, 636, 666, 612, 640, 576, 640, 640, 319, 329, 673, 673, 673, 543, 999, 728, 659, 737, 722, 605, 588, 749, 746, 277, 580, 703, 565, 922, 759, 769, 645, 773, 652, 650, 660, 736, 728, 1020, 720, 713, 652, 373, 379, 373, 481, 469, 351, 574, 624, 583, 624, 591, 389, 625, 612, 262, 262, 569, 262, 900, 612, 609, 624, 624, 397, 549, 353, 612, 587, 839, 569, 588, 566, 455, 359, 455, 673];
2539
2767
  function estimateTextWidth(text, fontSize, options = {}) {
@@ -2556,7 +2784,7 @@ function statusColor(status, c) {
2556
2784
  }
2557
2785
  function StatusDot({ status = "ok", c, size }) {
2558
2786
  const resolved = size ?? densityOf(c).f(8);
2559
- return import_react4.default.createElement("div", {
2787
+ return import_react5.default.createElement("div", {
2560
2788
  style: {
2561
2789
  display: "flex",
2562
2790
  flexShrink: 0,
@@ -2578,7 +2806,8 @@ function Sparkline({
2578
2806
  endDot = true,
2579
2807
  min,
2580
2808
  max,
2581
- strokeWidth
2809
+ strokeWidth,
2810
+ ...accessibility
2582
2811
  }) {
2583
2812
  const d = densityOf(c);
2584
2813
  const w = width ?? d.f(72);
@@ -2593,7 +2822,7 @@ function Sparkline({
2593
2822
  const y = (value) => inset + (1 - (value - low) / range) * (h - inset * 2);
2594
2823
  const path = values.map((value, index) => `${index === 0 ? "M" : "L"} ${x(index).toFixed(2)} ${y(value).toFixed(2)}`).join(" ");
2595
2824
  const last = values.length - 1;
2596
- return import_react4.default.createElement(
2825
+ const chart = import_react5.default.createElement(
2597
2826
  "svg",
2598
2827
  {
2599
2828
  width: w,
@@ -2603,12 +2832,12 @@ function Sparkline({
2603
2832
  style: { display: "flex", flexShrink: 0 }
2604
2833
  },
2605
2834
  ...compactChildren([
2606
- area && values.length > 1 && import_react4.default.createElement("path", {
2835
+ area && values.length > 1 && import_react5.default.createElement("path", {
2607
2836
  key: "area",
2608
2837
  d: `${path} L ${x(last).toFixed(2)} ${h} L ${x(0).toFixed(2)} ${h} Z`,
2609
2838
  fill: withColorAlpha(stroke, 0.14)
2610
2839
  }),
2611
- import_react4.default.createElement("path", {
2840
+ import_react5.default.createElement("path", {
2612
2841
  key: "line",
2613
2842
  d: path,
2614
2843
  fill: "none",
@@ -2617,7 +2846,7 @@ function Sparkline({
2617
2846
  strokeLinecap: "round",
2618
2847
  strokeLinejoin: "round"
2619
2848
  }),
2620
- endDot && values.length > 0 && import_react4.default.createElement("circle", {
2849
+ endDot && values.length > 0 && import_react5.default.createElement("circle", {
2621
2850
  key: "dot",
2622
2851
  cx: x(last),
2623
2852
  cy: y(values[last]),
@@ -2626,12 +2855,21 @@ function Sparkline({
2626
2855
  })
2627
2856
  ])
2628
2857
  );
2858
+ if (!accessibility.ariaLabel && !accessibility.description) return chart;
2859
+ return import_react5.default.createElement("div", {
2860
+ ...chartAccessibilityAttributes({
2861
+ ...accessibility,
2862
+ ariaLabel: accessibility.ariaLabel ?? "Sparkline",
2863
+ description: chartDescription(accessibility.description, values.map((value, index) => `Point ${index + 1}: ${value}`))
2864
+ }),
2865
+ style: { display: "flex", width: w, height: h, flexShrink: 0 }
2866
+ }, chart);
2629
2867
  }
2630
2868
  function InlineBar({ value, c, width = "100%", height, tone, color, warnAt }) {
2631
2869
  const d = densityOf(c);
2632
2870
  const fraction = Math.max(0, Math.min(1, value));
2633
2871
  const fill = color ?? (warnAt != null && fraction >= warnAt ? c.warningLight : tone ? getToneColor(tone, c) : c.textSecondary);
2634
- return import_react4.default.createElement("div", {
2872
+ return import_react5.default.createElement("div", {
2635
2873
  style: {
2636
2874
  display: "flex",
2637
2875
  width,
@@ -2640,30 +2878,30 @@ function InlineBar({ value, c, width = "100%", height, tone, color, warnAt }) {
2640
2878
  backgroundColor: c.borderSubtle,
2641
2879
  overflow: "hidden"
2642
2880
  }
2643
- }, import_react4.default.createElement("div", {
2881
+ }, import_react5.default.createElement("div", {
2644
2882
  style: { display: "flex", width: `${Math.round(fraction * 1e3) / 10}%`, height: "100%", backgroundColor: fill }
2645
2883
  }));
2646
2884
  }
2647
2885
  function FactRows({ rows, c, width = "100%", fontSize, mono = true, gap }) {
2648
2886
  const d = densityOf(c);
2649
2887
  const size = fontSize ?? d.type.micro;
2650
- return import_react4.default.createElement("div", {
2888
+ return import_react5.default.createElement("div", {
2651
2889
  style: { display: "flex", flexDirection: "column", width, gap: gap ?? d.s(2) }
2652
- }, ...rows.map((row, index) => import_react4.default.createElement(
2890
+ }, ...rows.map((row, index) => import_react5.default.createElement(
2653
2891
  "div",
2654
2892
  {
2655
2893
  key: `fact-${index}`,
2656
2894
  style: { display: "flex", flexDirection: "column", width: "100%", gap: 1 }
2657
2895
  },
2658
- import_react4.default.createElement(
2896
+ import_react5.default.createElement(
2659
2897
  "div",
2660
2898
  {
2661
2899
  style: { display: "flex", justifyContent: "space-between", alignItems: "baseline", width: "100%", gap: d.s(8), lineHeight: 1.25 }
2662
2900
  },
2663
- import_react4.default.createElement("div", {
2901
+ import_react5.default.createElement("div", {
2664
2902
  style: { display: "flex", flexShrink: 0, color: c.textMuted, fontFamily: c.fontSans, fontSize: size }
2665
2903
  }, row.key),
2666
- import_react4.default.createElement("div", {
2904
+ import_react5.default.createElement("div", {
2667
2905
  style: {
2668
2906
  display: "flex",
2669
2907
  color: row.tone ? getReadableToneColor(row.tone, c) : c.textPrimary,
@@ -2678,20 +2916,20 @@ function FactRows({ rows, c, width = "100%", fontSize, mono = true, gap }) {
2678
2916
  }
2679
2917
  function MetricStrip({ metrics, c, width = "100%", direction = "row", sparkWidth }) {
2680
2918
  const d = densityOf(c);
2681
- return import_react4.default.createElement("div", {
2919
+ return import_react5.default.createElement("div", {
2682
2920
  style: { display: "flex", flexDirection: direction, width, gap: direction === "row" ? d.s(14) : d.s(6) }
2683
- }, ...metrics.map((metric, index) => import_react4.default.createElement(
2921
+ }, ...metrics.map((metric, index) => import_react5.default.createElement(
2684
2922
  "div",
2685
2923
  {
2686
2924
  key: `metric-${index}`,
2687
2925
  style: { display: "flex", flexDirection: "column", flex: direction === "row" ? 1 : void 0, minWidth: 0, gap: d.s(1) }
2688
2926
  },
2689
- import_react4.default.createElement(
2927
+ import_react5.default.createElement(
2690
2928
  "div",
2691
2929
  {
2692
2930
  style: { display: "flex", alignItems: "baseline", gap: d.s(2), lineHeight: 1.1 }
2693
2931
  },
2694
- import_react4.default.createElement("div", {
2932
+ import_react5.default.createElement("div", {
2695
2933
  style: {
2696
2934
  display: "flex",
2697
2935
  color: metric.tone ? getReadableToneColor(metric.tone, c) : c.textPrimary,
@@ -2699,12 +2937,12 @@ function MetricStrip({ metrics, c, width = "100%", direction = "row", sparkWidth
2699
2937
  fontSize: d.f(14)
2700
2938
  }
2701
2939
  }, metric.value),
2702
- ...compactChildren([metric.unit != null && import_react4.default.createElement("div", {
2940
+ ...compactChildren([metric.unit != null && import_react5.default.createElement("div", {
2703
2941
  key: "unit",
2704
2942
  style: { display: "flex", color: c.textMuted, fontFamily: c.fontSans, fontSize: d.type.micro }
2705
2943
  }, metric.unit)])
2706
2944
  ),
2707
- import_react4.default.createElement("div", {
2945
+ import_react5.default.createElement("div", {
2708
2946
  style: { display: "flex", color: c.textMuted, fontFamily: c.fontSans, fontSize: d.type.micro, lineHeight: 1.2 }
2709
2947
  }, metric.label),
2710
2948
  ...compactChildren([
@@ -2715,9 +2953,9 @@ function MetricStrip({ metrics, c, width = "100%", direction = "row", sparkWidth
2715
2953
  }
2716
2954
  function TagList({ tags, c, tone }) {
2717
2955
  const d = densityOf(c);
2718
- return import_react4.default.createElement("div", {
2956
+ return import_react5.default.createElement("div", {
2719
2957
  style: { display: "flex", flexWrap: "wrap", gap: d.s(3) }
2720
- }, ...tags.map((tag, index) => import_react4.default.createElement("div", {
2958
+ }, ...tags.map((tag, index) => import_react5.default.createElement("div", {
2721
2959
  key: `tag-${index}`,
2722
2960
  style: {
2723
2961
  display: "flex",
@@ -2735,7 +2973,7 @@ function TagList({ tags, c, tone }) {
2735
2973
  function DiagramLegend({ items, c, title, width }) {
2736
2974
  const d = densityOf(c);
2737
2975
  const sample = d.f(18);
2738
- return import_react4.default.createElement(
2976
+ return import_react5.default.createElement(
2739
2977
  "div",
2740
2978
  {
2741
2979
  style: {
@@ -2751,11 +2989,11 @@ function DiagramLegend({ items, c, title, width }) {
2751
2989
  }
2752
2990
  },
2753
2991
  ...compactChildren([
2754
- title != null && import_react4.default.createElement("div", { key: "title", style: { display: "flex", color: c.textMuted } }, title),
2992
+ title != null && import_react5.default.createElement("div", { key: "title", style: { display: "flex", color: c.textMuted } }, title),
2755
2993
  ...items.map((item, index) => {
2756
2994
  const color = item.color ?? (item.tone ? getToneColor(item.tone, c) : c.textSecondary);
2757
2995
  const style = item.style ?? "solid";
2758
- const mark = style === "swatch" || style === "dot" ? import_react4.default.createElement("div", {
2996
+ const mark = style === "swatch" || style === "dot" ? import_react5.default.createElement("div", {
2759
2997
  style: {
2760
2998
  display: "flex",
2761
2999
  width: d.g(8),
@@ -2764,12 +3002,12 @@ function DiagramLegend({ items, c, title, width }) {
2764
3002
  borderRadius: style === "dot" ? 999 : 2,
2765
3003
  backgroundColor: color
2766
3004
  }
2767
- }) : import_react4.default.createElement("svg", {
3005
+ }) : import_react5.default.createElement("svg", {
2768
3006
  width: sample,
2769
3007
  height: d.g(8),
2770
3008
  viewBox: `0 0 ${sample} ${d.g(8)}`,
2771
3009
  style: { display: "flex", flexShrink: 0 }
2772
- }, import_react4.default.createElement("line", {
3010
+ }, import_react5.default.createElement("line", {
2773
3011
  x1: 0,
2774
3012
  x2: sample,
2775
3013
  y1: d.g(4),
@@ -2779,10 +3017,10 @@ function DiagramLegend({ items, c, title, width }) {
2779
3017
  strokeDasharray: style === "dashed" ? "5 3" : style === "dotted" ? "1.5 3" : void 0,
2780
3018
  strokeLinecap: style === "dotted" ? "round" : "butt"
2781
3019
  }));
2782
- return import_react4.default.createElement("div", {
3020
+ return import_react5.default.createElement("div", {
2783
3021
  key: `legend-${index}`,
2784
3022
  style: { display: "flex", alignItems: "center", gap: d.s(5) }
2785
- }, mark, import_react4.default.createElement("div", { style: { display: "flex" } }, item.label));
3023
+ }, mark, import_react5.default.createElement("div", { style: { display: "flex" } }, item.label));
2786
3024
  })
2787
3025
  ])
2788
3026
  );
@@ -2797,9 +3035,9 @@ function SmallMultiples({ items, c, columns, cellWidth, cellHeight, sharedScale
2797
3035
  const sharedMax = sharedScale ? Math.max(...all) : void 0;
2798
3036
  const rows = [];
2799
3037
  for (let i = 0; i < items.length; i += perRow) rows.push(items.slice(i, i + perRow));
2800
- return import_react4.default.createElement("div", {
3038
+ return import_react5.default.createElement("div", {
2801
3039
  style: { display: "flex", flexDirection: "column", gap: d.s(10) }
2802
- }, ...rows.map((row, rowIndex) => import_react4.default.createElement("div", {
3040
+ }, ...rows.map((row, rowIndex) => import_react5.default.createElement("div", {
2803
3041
  key: `multiples-row-${rowIndex}`,
2804
3042
  style: { display: "flex", gap: d.s(16) }
2805
3043
  }, ...row.map((item, index) => {
@@ -2807,37 +3045,37 @@ function SmallMultiples({ items, c, columns, cellWidth, cellHeight, sharedScale
2807
3045
  const high = sharedMax ?? Math.max(...item.values, ...item.reference != null ? [item.reference] : []);
2808
3046
  const range = high - low || 1;
2809
3047
  const referenceY = item.reference != null ? d.g(3) + (1 - (item.reference - low) / range) * (height - d.g(6)) : void 0;
2810
- return import_react4.default.createElement(
3048
+ return import_react5.default.createElement(
2811
3049
  "div",
2812
3050
  {
2813
3051
  key: `multiple-${index}`,
2814
3052
  style: { display: "flex", flexDirection: "column", width, gap: d.s(2) }
2815
3053
  },
2816
- import_react4.default.createElement(
3054
+ import_react5.default.createElement(
2817
3055
  "div",
2818
3056
  {
2819
3057
  style: { display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: d.s(6), lineHeight: 1.2 }
2820
3058
  },
2821
- import_react4.default.createElement("div", {
3059
+ import_react5.default.createElement("div", {
2822
3060
  style: { display: "flex", alignItems: "center", gap: d.s(4), minWidth: 0, color: c.textSecondary, fontFamily: c.fontSans, fontSize: d.type.micro, whiteSpace: "nowrap", overflow: "hidden" }
2823
- }, ...compactChildren([item.status && import_react4.default.createElement(import_react4.default.Fragment, { key: "dot" }, StatusDot({ status: item.status, c, size: d.g(6) })), item.label])),
2824
- item.value != null && import_react4.default.createElement("div", {
3061
+ }, ...compactChildren([item.status && import_react5.default.createElement(import_react5.default.Fragment, { key: "dot" }, StatusDot({ status: item.status, c, size: d.g(6) })), item.label])),
3062
+ item.value != null && import_react5.default.createElement("div", {
2825
3063
  style: { display: "flex", flexShrink: 0, alignItems: "baseline", gap: d.s(2), color: item.tone ? getReadableToneColor(item.tone, c) : c.textPrimary, fontFamily: c.fontMono, fontSize: d.type.small }
2826
- }, ...compactChildren([item.value, item.unit != null && import_react4.default.createElement("span", { key: "unit", style: { display: "flex", color: c.textMuted, fontFamily: c.fontSans, fontSize: d.type.micro } }, item.unit)]))
3064
+ }, ...compactChildren([item.value, item.unit != null && import_react5.default.createElement("span", { key: "unit", style: { display: "flex", color: c.textMuted, fontFamily: c.fontSans, fontSize: d.type.micro } }, item.unit)]))
2827
3065
  ),
2828
- import_react4.default.createElement(
3066
+ import_react5.default.createElement(
2829
3067
  "div",
2830
3068
  {
2831
3069
  style: { display: "flex", position: "relative", width, height, borderBottom: `1px solid ${c.borderSubtle}` }
2832
3070
  },
2833
3071
  ...compactChildren([
2834
- referenceY != null && import_react4.default.createElement("svg", {
3072
+ referenceY != null && import_react5.default.createElement("svg", {
2835
3073
  key: "reference",
2836
3074
  width,
2837
3075
  height,
2838
3076
  viewBox: `0 0 ${width} ${height}`,
2839
3077
  style: { position: "absolute", left: 0, top: 0 }
2840
- }, import_react4.default.createElement("line", { x1: 0, x2: width, y1: referenceY, y2: referenceY, stroke: c.borderLight, strokeWidth: d.stroke.hair, strokeDasharray: `${d.s(4)} ${d.s(4)}` })),
3078
+ }, import_react5.default.createElement("line", { x1: 0, x2: width, y1: referenceY, y2: referenceY, stroke: c.borderLight, strokeWidth: d.stroke.hair, strokeDasharray: `${d.s(4)} ${d.s(4)}` })),
2841
3079
  Sparkline({ values: item.values, c, tone: item.tone, width, height, area, min: low, max: high })
2842
3080
  ])
2843
3081
  )
@@ -2846,7 +3084,7 @@ function SmallMultiples({ items, c, columns, cellWidth, cellHeight, sharedScale
2846
3084
  }
2847
3085
 
2848
3086
  // src/primitives/content.ts
2849
- var import_react5 = __toESM(require("react"), 1);
3087
+ var import_react6 = __toESM(require("react"), 1);
2850
3088
  function ProgressRow({
2851
3089
  label,
2852
3090
  value,
@@ -2864,7 +3102,7 @@ function ProgressRow({
2864
3102
  const accent = muted ? c.textMuted : getToneColor(tone, c);
2865
3103
  const accentText = muted ? c.textMuted : getReadableToneColor(tone, c);
2866
3104
  const pct = Math.round(Math.max(0, Math.min(1, value)) * 100);
2867
- return import_react5.default.createElement(
3105
+ return import_react6.default.createElement(
2868
3106
  "div",
2869
3107
  {
2870
3108
  style: {
@@ -2874,7 +3112,7 @@ function ProgressRow({
2874
3112
  width: "100%"
2875
3113
  }
2876
3114
  },
2877
- import_react5.default.createElement("div", {
3115
+ import_react6.default.createElement("div", {
2878
3116
  style: {
2879
3117
  width: labelWidth,
2880
3118
  color: muted ? c.textMuted : c.textPrimary,
@@ -2883,7 +3121,7 @@ function ProgressRow({
2883
3121
  lineHeight: 1
2884
3122
  }
2885
3123
  }, label),
2886
- import_react5.default.createElement(
3124
+ import_react6.default.createElement(
2887
3125
  "div",
2888
3126
  {
2889
3127
  style: {
@@ -2895,7 +3133,7 @@ function ProgressRow({
2895
3133
  overflow: "hidden"
2896
3134
  }
2897
3135
  },
2898
- import_react5.default.createElement("div", {
3136
+ import_react6.default.createElement("div", {
2899
3137
  style: {
2900
3138
  width: `${pct}%`,
2901
3139
  height: "100%",
@@ -2904,7 +3142,7 @@ function ProgressRow({
2904
3142
  }
2905
3143
  })
2906
3144
  ),
2907
- import_react5.default.createElement("div", {
3145
+ import_react6.default.createElement("div", {
2908
3146
  style: {
2909
3147
  width: valueWidth,
2910
3148
  color: accentText,
@@ -2930,8 +3168,8 @@ function ProgressList({
2930
3168
  return Column({
2931
3169
  gap,
2932
3170
  align: "stretch",
2933
- children: rows.map((row, index) => import_react5.default.createElement(
2934
- import_react5.default.Fragment,
3171
+ children: rows.map((row, index) => import_react6.default.createElement(
3172
+ import_react6.default.Fragment,
2935
3173
  { key: `progress-${index}` },
2936
3174
  ProgressRow({
2937
3175
  ...row,
@@ -2954,7 +3192,8 @@ function MiniBarChart({
2954
3192
  gap: gapProp,
2955
3193
  radius: radiusProp,
2956
3194
  fontSize: fontSizeProp,
2957
- showValues = false
3195
+ showValues = false,
3196
+ ...accessibility
2958
3197
  }) {
2959
3198
  const gap = gapProp ?? densityOf(c).s(10);
2960
3199
  const radius = radiusProp ?? densityOf(c).r(3);
@@ -2963,9 +3202,18 @@ function MiniBarChart({
2963
3202
  const requestedMax = max != null && max > 0 ? max : void 0;
2964
3203
  const safeMax = requestedMax ?? Math.max(1, ...data.map((item) => Math.max(0, item.value)));
2965
3204
  const barMaxHeight = Math.max(minBarHeight, height - (showValues ? 34 : 20));
2966
- return import_react5.default.createElement(
3205
+ return import_react6.default.createElement(
2967
3206
  "div",
2968
3207
  {
3208
+ ...chartAccessibilityAttributes({
3209
+ ...accessibility,
3210
+ ariaLabel: accessibility.ariaLabel ?? "Mini bar chart",
3211
+ description: chartDescription(accessibility.description, data.map((item, index) => {
3212
+ const label = typeof item.label === "string" || typeof item.label === "number" ? item.label : `Item ${index + 1}`;
3213
+ const value = typeof item.valueLabel === "string" || typeof item.valueLabel === "number" ? item.valueLabel : item.value;
3214
+ return `${label}: ${value}`;
3215
+ }))
3216
+ }),
2969
3217
  style: {
2970
3218
  display: "flex",
2971
3219
  alignItems: "flex-end",
@@ -2981,7 +3229,7 @@ function MiniBarChart({
2981
3229
  const tone = item.tone ?? "blue";
2982
3230
  const barHeight = Math.max(minBarHeight, Math.round(Math.max(0, item.value) / safeMax * barMaxHeight));
2983
3231
  const fill = item.color ?? getToneColor(tone, c);
2984
- return import_react5.default.createElement(
3232
+ return import_react6.default.createElement(
2985
3233
  "div",
2986
3234
  {
2987
3235
  key: `mini-bar-${index}-${String(item.label)}`,
@@ -2996,7 +3244,7 @@ function MiniBarChart({
2996
3244
  }
2997
3245
  },
2998
3246
  ...compactChildren([
2999
- showValues && import_react5.default.createElement("div", {
3247
+ showValues && import_react6.default.createElement("div", {
3000
3248
  style: {
3001
3249
  display: "flex",
3002
3250
  color: getReadableToneColor(tone, c),
@@ -3006,7 +3254,7 @@ function MiniBarChart({
3006
3254
  lineHeight: 1
3007
3255
  }
3008
3256
  }, item.valueLabel ?? item.value),
3009
- import_react5.default.createElement("div", {
3257
+ import_react6.default.createElement("div", {
3010
3258
  style: {
3011
3259
  display: "flex",
3012
3260
  width: barWidth,
@@ -3016,7 +3264,7 @@ function MiniBarChart({
3016
3264
  opacity: item.opacity ?? 1
3017
3265
  }
3018
3266
  }),
3019
- import_react5.default.createElement("div", {
3267
+ import_react6.default.createElement("div", {
3020
3268
  style: {
3021
3269
  display: "flex",
3022
3270
  color: c.textMuted,
@@ -3049,7 +3297,7 @@ function DetailList({
3049
3297
  return Column({
3050
3298
  gap,
3051
3299
  align: "stretch",
3052
- children: items.map((item, index) => import_react5.default.createElement("div", {
3300
+ children: items.map((item, index) => import_react6.default.createElement("div", {
3053
3301
  key: `detail-${index}`,
3054
3302
  style: {
3055
3303
  display: "flex",
@@ -3085,7 +3333,7 @@ function Tile({
3085
3333
  const accent = getToneColor(tone ?? "neutral", c);
3086
3334
  const textAlign = align;
3087
3335
  const crossAlign = align === "center" ? "center" : "flex-start";
3088
- const detailLines = (lines ?? []).map((line, index) => import_react5.default.createElement(
3336
+ const detailLines = (lines ?? []).map((line, index) => import_react6.default.createElement(
3089
3337
  "div",
3090
3338
  {
3091
3339
  key: `tile-line-${index}`,
@@ -3100,7 +3348,7 @@ function Tile({
3100
3348
  textAlign
3101
3349
  }
3102
3350
  },
3103
- import_react5.default.createElement("span", {
3351
+ import_react6.default.createElement("span", {
3104
3352
  style: {
3105
3353
  display: "flex",
3106
3354
  width: 3,
@@ -3120,7 +3368,7 @@ function Tile({
3120
3368
  radius,
3121
3369
  shadow,
3122
3370
  borderColor: tone ? withColorAlpha(accent, 0.5) : c.border,
3123
- children: import_react5.default.createElement(
3371
+ children: import_react6.default.createElement(
3124
3372
  "div",
3125
3373
  {
3126
3374
  style: {
@@ -3133,10 +3381,10 @@ function Tile({
3133
3381
  }
3134
3382
  },
3135
3383
  ...compactChildren([
3136
- icon != null && import_react5.default.createElement("div", {
3384
+ icon != null && import_react6.default.createElement("div", {
3137
3385
  style: { display: "flex", fontSize: densityOf(c).f(22), lineHeight: 1 }
3138
3386
  }, icon),
3139
- eyebrow != null && import_react5.default.createElement("div", {
3387
+ eyebrow != null && import_react6.default.createElement("div", {
3140
3388
  style: {
3141
3389
  ...typeOf(c, "tiny"),
3142
3390
  color: tone ? getReadableToneColor(tone, c) : c.textMuted,
@@ -3145,7 +3393,7 @@ function Tile({
3145
3393
  textAlign
3146
3394
  }
3147
3395
  }, renderMaybeMath(eyebrow, math)),
3148
- import_react5.default.createElement("div", {
3396
+ import_react6.default.createElement("div", {
3149
3397
  style: {
3150
3398
  ...typeOf(c, "label"),
3151
3399
  color: c.textPrimary,
@@ -3154,7 +3402,7 @@ function Tile({
3154
3402
  textAlign
3155
3403
  }
3156
3404
  }, renderMaybeMath(title, math)),
3157
- subtitle != null && import_react5.default.createElement("div", {
3405
+ subtitle != null && import_react6.default.createElement("div", {
3158
3406
  style: {
3159
3407
  ...typeOf(c, "tiny"),
3160
3408
  color: c.textSecondary,
@@ -3162,7 +3410,7 @@ function Tile({
3162
3410
  textAlign
3163
3411
  }
3164
3412
  }, renderMaybeMath(subtitle, math)),
3165
- detailLines.length > 0 && import_react5.default.createElement("div", {
3413
+ detailLines.length > 0 && import_react6.default.createElement("div", {
3166
3414
  style: {
3167
3415
  width: "100%",
3168
3416
  display: "flex",
@@ -3187,8 +3435,8 @@ function TileGrid({
3187
3435
  math = false
3188
3436
  }) {
3189
3437
  const gap = gapProp ?? densityOf(c).s(12);
3190
- const renderTile = (tile, index) => import_react5.default.createElement(
3191
- import_react5.default.Fragment,
3438
+ const renderTile = (tile, index) => import_react6.default.createElement(
3439
+ import_react6.default.Fragment,
3192
3440
  { key: `tile-${index}` },
3193
3441
  Tile({
3194
3442
  ...tile,
@@ -3209,15 +3457,15 @@ function TileGrid({
3209
3457
  return Column({
3210
3458
  gap,
3211
3459
  align: "stretch",
3212
- children: rows.map((rowTiles, rowIndex) => import_react5.default.createElement(
3213
- import_react5.default.Fragment,
3460
+ children: rows.map((rowTiles, rowIndex) => import_react6.default.createElement(
3461
+ import_react6.default.Fragment,
3214
3462
  { key: `tile-row-${rowIndex}` },
3215
3463
  Row({ gap, align: "stretch", justify: "start", children: rowTiles.map((tile, colIndex) => renderTile(tile, rowIndex * columns + colIndex)) })
3216
3464
  ))
3217
3465
  });
3218
3466
  }
3219
3467
  function isCodeLineSpec(line) {
3220
- return typeof line === "object" && line !== null && !import_react5.default.isValidElement(line) && "text" in line;
3468
+ return typeof line === "object" && line !== null && !import_react6.default.isValidElement(line) && "text" in line;
3221
3469
  }
3222
3470
  function CodeBlock({
3223
3471
  lines,
@@ -3244,7 +3492,7 @@ function CodeBlock({
3244
3492
  const accent = spec.tone ? getToneColor(spec.tone, c) : void 0;
3245
3493
  const accentText = spec.tone && accent ? getReadableToneColor(spec.tone, c, withColorAlpha(accent, 31 / 255), background ?? c.bgSubtle) : void 0;
3246
3494
  const textColor = spec.dim ? c.textMuted : accentText ?? c.textSecondary;
3247
- return import_react5.default.createElement(
3495
+ return import_react6.default.createElement(
3248
3496
  "div",
3249
3497
  {
3250
3498
  key: `code-line-${index}`,
@@ -3260,7 +3508,7 @@ function CodeBlock({
3260
3508
  }
3261
3509
  },
3262
3510
  ...compactChildren([
3263
- showLineNumbers && import_react5.default.createElement("div", {
3511
+ showLineNumbers && import_react6.default.createElement("div", {
3264
3512
  style: {
3265
3513
  display: "flex",
3266
3514
  width: numberWidth,
@@ -3272,7 +3520,7 @@ function CodeBlock({
3272
3520
  lineHeight: 1.5
3273
3521
  }
3274
3522
  }, String(index + 1)),
3275
- spec.prefix != null && import_react5.default.createElement("div", {
3523
+ spec.prefix != null && import_react6.default.createElement("div", {
3276
3524
  style: {
3277
3525
  display: "flex",
3278
3526
  flexShrink: 0,
@@ -3283,7 +3531,7 @@ function CodeBlock({
3283
3531
  lineHeight: 1.5
3284
3532
  }
3285
3533
  }, spec.prefix),
3286
- import_react5.default.createElement("div", {
3534
+ import_react6.default.createElement("div", {
3287
3535
  style: {
3288
3536
  display: "flex",
3289
3537
  flex: 1,
@@ -3298,7 +3546,7 @@ function CodeBlock({
3298
3546
  ])
3299
3547
  );
3300
3548
  });
3301
- return import_react5.default.createElement(
3549
+ return import_react6.default.createElement(
3302
3550
  "div",
3303
3551
  {
3304
3552
  style: {
@@ -3316,7 +3564,7 @@ function CodeBlock({
3316
3564
  }
3317
3565
  },
3318
3566
  ...compactChildren([
3319
- title != null && import_react5.default.createElement(
3567
+ title != null && import_react6.default.createElement(
3320
3568
  "div",
3321
3569
  {
3322
3570
  style: {
@@ -3331,7 +3579,7 @@ function CodeBlock({
3331
3579
  fontWeight: 400
3332
3580
  }
3333
3581
  },
3334
- import_react5.default.createElement("span", {
3582
+ import_react6.default.createElement("span", {
3335
3583
  style: {
3336
3584
  display: "flex",
3337
3585
  width: 8,
@@ -3343,7 +3591,7 @@ function CodeBlock({
3343
3591
  }),
3344
3592
  renderMaybeMath(title, math)
3345
3593
  ),
3346
- import_react5.default.createElement("div", {
3594
+ import_react6.default.createElement("div", {
3347
3595
  style: {
3348
3596
  display: "flex",
3349
3597
  flexDirection: "column",
@@ -3356,7 +3604,7 @@ function CodeBlock({
3356
3604
  }
3357
3605
  function renderComparisonDivider(divider, c, key) {
3358
3606
  const label = divider === true ? "vs" : divider;
3359
- return import_react5.default.createElement(
3607
+ return import_react6.default.createElement(
3360
3608
  "div",
3361
3609
  {
3362
3610
  key,
@@ -3369,7 +3617,7 @@ function renderComparisonDivider(divider, c, key) {
3369
3617
  flexShrink: 0
3370
3618
  }
3371
3619
  },
3372
- import_react5.default.createElement("div", {
3620
+ import_react6.default.createElement("div", {
3373
3621
  style: {
3374
3622
  display: "flex",
3375
3623
  alignItems: "center",
@@ -3401,8 +3649,8 @@ function Comparison({
3401
3649
  const gap = gapProp ?? densityOf(c).s(14);
3402
3650
  const children = sides2.flatMap((side, index) => {
3403
3651
  const tone = side.tone;
3404
- const panel = import_react5.default.createElement(
3405
- import_react5.default.Fragment,
3652
+ const panel = import_react6.default.createElement(
3653
+ import_react6.default.Fragment,
3406
3654
  { key: `comparison-side-${index}` },
3407
3655
  Panel({
3408
3656
  c,
@@ -3413,10 +3661,10 @@ function Comparison({
3413
3661
  width: side.width ?? sideWidth,
3414
3662
  minHeight,
3415
3663
  bodyStyle: { gap: 8 },
3416
- children: side.eyebrow != null ? import_react5.default.createElement(
3664
+ children: side.eyebrow != null ? import_react6.default.createElement(
3417
3665
  "div",
3418
3666
  { style: { display: "flex", flexDirection: "column", gap: 8 } },
3419
- import_react5.default.createElement("div", {
3667
+ import_react6.default.createElement("div", {
3420
3668
  style: {
3421
3669
  ...typeOf(c, "tiny"),
3422
3670
  color: c.textMuted,
@@ -3453,7 +3701,7 @@ function KeyValueList({
3453
3701
  const accent = row.tone ? getReadableToneColor(row.tone, c) : void 0;
3454
3702
  const isLast = index === rows.length - 1;
3455
3703
  const valueMono = row.valueMono ?? true;
3456
- return import_react5.default.createElement(
3704
+ return import_react6.default.createElement(
3457
3705
  "div",
3458
3706
  {
3459
3707
  key: `kv-row-${index}`,
@@ -3468,7 +3716,7 @@ function KeyValueList({
3468
3716
  boxSizing: "border-box"
3469
3717
  }
3470
3718
  },
3471
- import_react5.default.createElement("div", {
3719
+ import_react6.default.createElement("div", {
3472
3720
  style: {
3473
3721
  display: "flex",
3474
3722
  ...keyWidth != null ? { width: keyWidth, flexShrink: 0 } : {},
@@ -3479,7 +3727,7 @@ function KeyValueList({
3479
3727
  lineHeight: 1.3
3480
3728
  }
3481
3729
  }, renderMaybeMath(row.key, math)),
3482
- import_react5.default.createElement("div", {
3730
+ import_react6.default.createElement("div", {
3483
3731
  style: {
3484
3732
  display: "flex",
3485
3733
  flex: 1,
@@ -3494,7 +3742,7 @@ function KeyValueList({
3494
3742
  }, renderMaybeMath(row.value, math))
3495
3743
  );
3496
3744
  });
3497
- return import_react5.default.createElement(
3745
+ return import_react6.default.createElement(
3498
3746
  "div",
3499
3747
  {
3500
3748
  style: {
@@ -3506,7 +3754,7 @@ function KeyValueList({
3506
3754
  }
3507
3755
  },
3508
3756
  ...compactChildren([
3509
- title != null && import_react5.default.createElement("div", {
3757
+ title != null && import_react6.default.createElement("div", {
3510
3758
  style: {
3511
3759
  display: "flex",
3512
3760
  ...typeOf(c, "small"),
@@ -3541,11 +3789,11 @@ function WindowFrame({
3541
3789
  const isTerminal = variant === "terminal";
3542
3790
  const surface = background ?? (isTerminal ? c.bgSubtle : c.bgCard);
3543
3791
  const titleColor = isTerminal ? getReadableToneColor(tone, c, c.bgHover) : c.textSecondary;
3544
- const trafficDot = (color, key) => import_react5.default.createElement("span", {
3792
+ const trafficDot = (color, key) => import_react6.default.createElement("span", {
3545
3793
  key,
3546
3794
  style: { display: "flex", width: densityOf(c).g(9), height: densityOf(c).g(9), borderRadius: 999, backgroundColor: color }
3547
3795
  });
3548
- const titleBar = import_react5.default.createElement(
3796
+ const titleBar = import_react6.default.createElement(
3549
3797
  "div",
3550
3798
  {
3551
3799
  style: {
@@ -3560,7 +3808,7 @@ function WindowFrame({
3560
3808
  }
3561
3809
  },
3562
3810
  ...compactChildren([
3563
- dots && import_react5.default.createElement(
3811
+ dots && import_react6.default.createElement(
3564
3812
  "div",
3565
3813
  {
3566
3814
  style: { display: "flex", alignItems: "center", gap: densityOf(c).s(6), flexShrink: 0 }
@@ -3569,7 +3817,7 @@ function WindowFrame({
3569
3817
  trafficDot(c.borderLight, "dot-y"),
3570
3818
  trafficDot(c.borderLight, "dot-g")
3571
3819
  ),
3572
- title != null && (variant === "browser" ? import_react5.default.createElement("div", {
3820
+ title != null && (variant === "browser" ? import_react6.default.createElement("div", {
3573
3821
  style: {
3574
3822
  display: "flex",
3575
3823
  flex: 1,
@@ -3585,7 +3833,7 @@ function WindowFrame({
3585
3833
  fontWeight: 600,
3586
3834
  lineHeight: 1
3587
3835
  }
3588
- }, title) : import_react5.default.createElement("div", {
3836
+ }, title) : import_react6.default.createElement("div", {
3589
3837
  style: {
3590
3838
  display: "flex",
3591
3839
  flex: 1,
@@ -3597,12 +3845,12 @@ function WindowFrame({
3597
3845
  lineHeight: 1
3598
3846
  }
3599
3847
  }, title)),
3600
- dots && title != null && variant !== "browser" && import_react5.default.createElement("div", {
3848
+ dots && title != null && variant !== "browser" && import_react6.default.createElement("div", {
3601
3849
  style: { display: "flex", width: 52, flexShrink: 0 }
3602
3850
  }, "")
3603
3851
  ])
3604
3852
  );
3605
- return import_react5.default.createElement(
3853
+ return import_react6.default.createElement(
3606
3854
  "div",
3607
3855
  {
3608
3856
  style: {
@@ -3621,7 +3869,7 @@ function WindowFrame({
3621
3869
  }
3622
3870
  },
3623
3871
  titleBar,
3624
- import_react5.default.createElement("div", {
3872
+ import_react6.default.createElement("div", {
3625
3873
  style: {
3626
3874
  display: "flex",
3627
3875
  flexDirection: "column",
@@ -3636,7 +3884,7 @@ function WindowFrame({
3636
3884
  }
3637
3885
 
3638
3886
  // src/primitives/flows.ts
3639
- var import_react6 = __toESM(require("react"), 1);
3887
+ var import_react7 = __toESM(require("react"), 1);
3640
3888
  var statusGlyphs = {
3641
3889
  check: "\u2713",
3642
3890
  cross: "\u2717",
@@ -3673,7 +3921,7 @@ function StatusRow({
3673
3921
  const markerBackground = withColorAlpha(accent, markerBackgroundAlpha / 255);
3674
3922
  const accentText = getReadableToneColor(resolvedTone, c, markerBackground, c.bgCard);
3675
3923
  const glyph = statusGlyphs[status];
3676
- const marker = import_react6.default.createElement("div", {
3924
+ const marker = import_react7.default.createElement("div", {
3677
3925
  style: {
3678
3926
  display: "flex",
3679
3927
  alignItems: "center",
@@ -3691,7 +3939,7 @@ function StatusRow({
3691
3939
  lineHeight: 1
3692
3940
  }
3693
3941
  }, glyph);
3694
- return import_react6.default.createElement(
3942
+ return import_react7.default.createElement(
3695
3943
  "div",
3696
3944
  {
3697
3945
  style: {
@@ -3709,7 +3957,7 @@ function StatusRow({
3709
3957
  }
3710
3958
  },
3711
3959
  marker,
3712
- import_react6.default.createElement("div", {
3960
+ import_react7.default.createElement("div", {
3713
3961
  style: {
3714
3962
  display: "flex",
3715
3963
  flex: 1,
@@ -3720,7 +3968,7 @@ function StatusRow({
3720
3968
  lineHeight: 1.3
3721
3969
  }
3722
3970
  }, renderMaybeMath(label, math)),
3723
- detail != null && import_react6.default.createElement("div", {
3971
+ detail != null && import_react7.default.createElement("div", {
3724
3972
  style: {
3725
3973
  display: "flex",
3726
3974
  flexShrink: 0,
@@ -3747,8 +3995,8 @@ function StatusList({
3747
3995
  gap,
3748
3996
  align: "stretch",
3749
3997
  ...width != null ? { width } : {},
3750
- children: rows.map((row, index) => import_react6.default.createElement(
3751
- import_react6.default.Fragment,
3998
+ children: rows.map((row, index) => import_react7.default.createElement(
3999
+ import_react7.default.Fragment,
3752
4000
  { key: `status-${index}` },
3753
4001
  StatusRow({ ...row, c, boxed, fontSize, math })
3754
4002
  ))
@@ -3758,7 +4006,7 @@ function renderTimelineCard(event, c, math, width) {
3758
4006
  const resolvedTone = event.tone ?? statusTones[event.status ?? "dot"];
3759
4007
  const accentText = getReadableToneColor(resolvedTone, c);
3760
4008
  const resolvedWidth = event.width ?? width;
3761
- return import_react6.default.createElement(
4009
+ return import_react7.default.createElement(
3762
4010
  "div",
3763
4011
  {
3764
4012
  style: {
@@ -3772,7 +4020,7 @@ function renderTimelineCard(event, c, math, width) {
3772
4020
  }
3773
4021
  },
3774
4022
  ...compactChildren([
3775
- event.time != null && import_react6.default.createElement("div", {
4023
+ event.time != null && import_react7.default.createElement("div", {
3776
4024
  style: {
3777
4025
  display: "flex",
3778
4026
  color: event.tone || event.status ? accentText : c.textMuted,
@@ -3782,7 +4030,7 @@ function renderTimelineCard(event, c, math, width) {
3782
4030
  lineHeight: 1.15
3783
4031
  }
3784
4032
  }, renderMaybeMath(event.time, math)),
3785
- import_react6.default.createElement("div", {
4033
+ import_react7.default.createElement("div", {
3786
4034
  style: {
3787
4035
  display: "flex",
3788
4036
  color: c.textPrimary,
@@ -3793,7 +4041,7 @@ function renderTimelineCard(event, c, math, width) {
3793
4041
  ...textFitStyle()
3794
4042
  }
3795
4043
  }, renderMaybeMath(event.title, math)),
3796
- event.detail != null && import_react6.default.createElement("div", {
4044
+ event.detail != null && import_react7.default.createElement("div", {
3797
4045
  style: {
3798
4046
  display: "flex",
3799
4047
  color: c.textSecondary,
@@ -3821,7 +4069,7 @@ function Timeline({
3821
4069
  }) {
3822
4070
  const markerSize = markerSizeProp ?? densityOf(c).g(9);
3823
4071
  const gap = gapProp ?? densityOf(c).s(12);
3824
- const header = (title != null || subtitle != null) && import_react6.default.createElement(
4072
+ const header = (title != null || subtitle != null) && import_react7.default.createElement(
3825
4073
  "div",
3826
4074
  {
3827
4075
  style: {
@@ -3832,7 +4080,7 @@ function Timeline({
3832
4080
  }
3833
4081
  },
3834
4082
  ...compactChildren([
3835
- title != null && import_react6.default.createElement("div", {
4083
+ title != null && import_react7.default.createElement("div", {
3836
4084
  style: {
3837
4085
  display: "flex",
3838
4086
  alignItems: "center",
@@ -3844,7 +4092,7 @@ function Timeline({
3844
4092
  lineHeight: 1.2
3845
4093
  }
3846
4094
  }, renderMaybeMath(title, math)),
3847
- subtitle != null && import_react6.default.createElement("div", {
4095
+ subtitle != null && import_react7.default.createElement("div", {
3848
4096
  style: {
3849
4097
  display: "flex",
3850
4098
  color: c.textSecondary,
@@ -3857,7 +4105,7 @@ function Timeline({
3857
4105
  ])
3858
4106
  );
3859
4107
  if (direction === "horizontal") {
3860
- return import_react6.default.createElement(
4108
+ return import_react7.default.createElement(
3861
4109
  "div",
3862
4110
  {
3863
4111
  style: {
@@ -3869,7 +4117,7 @@ function Timeline({
3869
4117
  },
3870
4118
  ...compactChildren([
3871
4119
  header,
3872
- import_react6.default.createElement("div", {
4120
+ import_react7.default.createElement("div", {
3873
4121
  style: {
3874
4122
  display: "flex",
3875
4123
  alignItems: "stretch",
@@ -3878,7 +4126,7 @@ function Timeline({
3878
4126
  }
3879
4127
  }, ...events.map((event, index) => {
3880
4128
  const accent = getToneColor(event.tone ?? statusTones[event.status ?? "dot"], c);
3881
- return import_react6.default.createElement(
4129
+ return import_react7.default.createElement(
3882
4130
  "div",
3883
4131
  {
3884
4132
  key: `timeline-h-${index}`,
@@ -3891,7 +4139,7 @@ function Timeline({
3891
4139
  minWidth: 0
3892
4140
  }
3893
4141
  },
3894
- import_react6.default.createElement(
4142
+ import_react7.default.createElement(
3895
4143
  "div",
3896
4144
  {
3897
4145
  style: {
@@ -3900,7 +4148,7 @@ function Timeline({
3900
4148
  width: "100%"
3901
4149
  }
3902
4150
  },
3903
- import_react6.default.createElement("div", {
4151
+ import_react7.default.createElement("div", {
3904
4152
  style: {
3905
4153
  display: "flex",
3906
4154
  flex: 1,
@@ -3909,7 +4157,7 @@ function Timeline({
3909
4157
  opacity: index === 0 ? 0 : 1
3910
4158
  }
3911
4159
  }),
3912
- import_react6.default.createElement("div", {
4160
+ import_react7.default.createElement("div", {
3913
4161
  style: {
3914
4162
  display: "flex",
3915
4163
  width: markerSize,
@@ -3919,7 +4167,7 @@ function Timeline({
3919
4167
  flexShrink: 0
3920
4168
  }
3921
4169
  }),
3922
- import_react6.default.createElement("div", {
4170
+ import_react7.default.createElement("div", {
3923
4171
  style: {
3924
4172
  display: "flex",
3925
4173
  flex: 1,
@@ -3935,7 +4183,7 @@ function Timeline({
3935
4183
  ])
3936
4184
  );
3937
4185
  }
3938
- return import_react6.default.createElement(
4186
+ return import_react7.default.createElement(
3939
4187
  "div",
3940
4188
  {
3941
4189
  style: {
@@ -3947,7 +4195,7 @@ function Timeline({
3947
4195
  },
3948
4196
  ...compactChildren([
3949
4197
  header,
3950
- import_react6.default.createElement("div", {
4198
+ import_react7.default.createElement("div", {
3951
4199
  style: {
3952
4200
  display: "flex",
3953
4201
  flexDirection: "column",
@@ -3956,7 +4204,7 @@ function Timeline({
3956
4204
  }
3957
4205
  }, ...events.map((event, index) => {
3958
4206
  const accent = getToneColor(event.tone ?? statusTones[event.status ?? "dot"], c);
3959
- return import_react6.default.createElement(
4207
+ return import_react7.default.createElement(
3960
4208
  "div",
3961
4209
  {
3962
4210
  key: `timeline-v-${index}`,
@@ -3967,7 +4215,7 @@ function Timeline({
3967
4215
  width: "100%"
3968
4216
  }
3969
4217
  },
3970
- import_react6.default.createElement(
4218
+ import_react7.default.createElement(
3971
4219
  "div",
3972
4220
  {
3973
4221
  style: {
@@ -3978,7 +4226,7 @@ function Timeline({
3978
4226
  flexShrink: 0
3979
4227
  }
3980
4228
  },
3981
- import_react6.default.createElement("div", {
4229
+ import_react7.default.createElement("div", {
3982
4230
  style: {
3983
4231
  display: "flex",
3984
4232
  flex: 1,
@@ -3988,7 +4236,7 @@ function Timeline({
3988
4236
  opacity: index === 0 ? 0 : 1
3989
4237
  }
3990
4238
  }),
3991
- import_react6.default.createElement("div", {
4239
+ import_react7.default.createElement("div", {
3992
4240
  style: {
3993
4241
  display: "flex",
3994
4242
  width: markerSize,
@@ -3998,7 +4246,7 @@ function Timeline({
3998
4246
  flexShrink: 0
3999
4247
  }
4000
4248
  }),
4001
- import_react6.default.createElement("div", {
4249
+ import_react7.default.createElement("div", {
4002
4250
  style: {
4003
4251
  display: "flex",
4004
4252
  flex: 1,
@@ -4049,237 +4297,45 @@ function Flow({
4049
4297
  stages,
4050
4298
  c,
4051
4299
  direction = "horizontal",
4052
- gap: gapProp,
4053
- connectorLength: connectorLengthProp,
4054
- connectorTone = "neutral",
4055
- align = "center",
4056
- math = false
4057
- }) {
4058
- const connectorLength = connectorLengthProp ?? densityOf(c).s(32);
4059
- const gap = gapProp ?? densityOf(c).s(10);
4060
- const isHorizontal = direction === "horizontal";
4061
- const children = stages.flatMap((stage, index) => {
4062
- const elements = [
4063
- import_react6.default.createElement(import_react6.default.Fragment, { key: `stage-${index}` }, renderFlowStage(stage, c, math))
4064
- ];
4065
- if (index < stages.length - 1) {
4066
- elements.push(import_react6.default.createElement(
4067
- import_react6.default.Fragment,
4068
- { key: `connector-${index}` },
4069
- FlowArrow({
4070
- direction: isHorizontal ? "right" : "down",
4071
- length: connectorLength,
4072
- c,
4073
- tone: connectorTone
4074
- })
4075
- ));
4076
- }
4077
- return elements;
4078
- });
4079
- return (isHorizontal ? Row : Column)({
4080
- gap,
4081
- align,
4082
- justify: isHorizontal ? "start" : "center",
4083
- children
4084
- });
4085
- }
4086
-
4087
- // src/primitives/diagrams.ts
4088
- var import_react8 = __toESM(require("react"), 1);
4089
- var import_dagre = __toESM(require("@dagrejs/dagre"), 1);
4090
-
4091
- // src/svg-accessibility.ts
4092
- var import_react7 = require("react");
4093
- var SVG_ACCESSIBILITY_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.svgAccessibilityComponent");
4094
- function componentHasSvgMetadata(type) {
4095
- return typeof type === "function" && type[SVG_ACCESSIBILITY_COMPONENT] === true;
4096
- }
4097
- function svgToken(value) {
4098
- if (value.length === 0) return "empty";
4099
- return Array.from(value, (character) => {
4100
- const codePoint = character.codePointAt(0) ?? 0;
4101
- return /^[A-Za-z0-9.-]$/.test(character) ? character : `_u${codePoint.toString(16)}_`;
4102
- }).join("");
4103
- }
4104
- function textProperty(props, name) {
4105
- const value = props[name];
4106
- return typeof value === "string" ? value : "";
4107
- }
4108
- function encodedTextProperty(props, name) {
4109
- const value = textProperty(props, name);
4110
- try {
4111
- return decodeURIComponent(value);
4112
- } catch {
4113
- return value;
4114
- }
4115
- }
4116
- function prepareAccessibleSvg(element) {
4117
- const graphs = [];
4118
- const explicitIds = /* @__PURE__ */ new Set();
4119
- const visit = (node, graph) => {
4120
- if (Array.isArray(node)) return node.map((child) => visit(child, graph));
4121
- if (!(0, import_react7.isValidElement)(node)) return node;
4122
- const component = node.type;
4123
- if (componentHasSvgMetadata(component)) {
4124
- return visit(component(node.props), graph);
4125
- }
4126
- const props = node.props;
4127
- const title = textProperty(props, "data-vizmatic-svg-title");
4128
- const isGraphRoot = title.length > 0;
4129
- let activeGraph = graph;
4130
- let elementKey = node.key;
4131
- if (isGraphRoot) {
4132
- const explicitId = textProperty(props, "data-vizmatic-svg-id");
4133
- if (explicitId) {
4134
- if (explicitIds.has(explicitId)) {
4135
- throw new Error(`GraphDiagram SVG id "${explicitId}" must be unique in one exported SVG.`);
4136
- }
4137
- explicitIds.add(explicitId);
4138
- }
4139
- const index = graphs.length;
4140
- const token = explicitId ? `id-${svgToken(explicitId)}` : `index-${index}`;
4141
- activeGraph = {
4142
- index,
4143
- token,
4144
- detectionKey: `vizmatic-graph-${index}`,
4145
- title,
4146
- description: textProperty(props, "data-vizmatic-svg-description"),
4147
- nodes: [],
4148
- edges: []
4149
- };
4150
- graphs.push(activeGraph);
4151
- elementKey = activeGraph.detectionKey;
4152
- }
4153
- let nextProps;
4154
- if (activeGraph && Object.hasOwn(props, "data-vizmatic-graph-node-id")) {
4155
- const id = textProperty(props, "data-vizmatic-graph-node-id");
4156
- const label = textProperty(props, "data-vizmatic-graph-node-label") || id;
4157
- const detail = textProperty(props, "data-vizmatic-graph-node-detail");
4158
- activeGraph.nodes.push({
4159
- id,
4160
- label,
4161
- detail,
4162
- title: textProperty(props, "data-vizmatic-graph-node-title") || label,
4163
- href: textProperty(props, "data-vizmatic-graph-node-href") || void 0
4164
- });
4165
- elementKey = `${activeGraph.detectionKey}-node-${svgToken(id)}`;
4166
- } else if (activeGraph && textProperty(props, "data-vizmatic-graph-edge-id")) {
4167
- const id = encodedTextProperty(props, "data-vizmatic-graph-edge-id");
4168
- activeGraph.edges.push({
4169
- id,
4170
- from: encodedTextProperty(props, "data-vizmatic-graph-edge-from"),
4171
- to: encodedTextProperty(props, "data-vizmatic-graph-edge-to"),
4172
- label: encodedTextProperty(props, "data-vizmatic-graph-edge-label"),
4173
- title: encodedTextProperty(props, "data-vizmatic-graph-edge-title"),
4174
- path: textProperty(props, "d"),
4175
- href: encodedTextProperty(props, "data-vizmatic-graph-edge-href") || void 0
4176
- });
4177
- elementKey = `${activeGraph.detectionKey}-edge-${svgToken(id)}`;
4178
- }
4179
- const children = props.children;
4180
- if (children === void 0) {
4181
- if (isGraphRoot) {
4182
- nextProps = { ...props, "data-vizmatic-svg-instance": activeGraph?.token };
4183
- return (0, import_react7.cloneElement)(node, { ...nextProps, key: elementKey });
4184
- }
4185
- return node;
4186
- }
4187
- const preparedChildren = visit(children, activeGraph);
4188
- nextProps = isGraphRoot ? { ...props, "data-vizmatic-svg-instance": activeGraph?.token } : { ...props };
4189
- return (0, import_react7.cloneElement)(
4190
- node,
4191
- { ...nextProps, key: elementKey },
4192
- preparedChildren
4193
- );
4194
- };
4195
- return { element: visit(element), graphs };
4196
- }
4197
- function escapeXml(value) {
4198
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
4199
- }
4200
- function attribute(name, value) {
4201
- return `${name}="${escapeXml(value)}"`;
4202
- }
4203
- function graphBaseId(graph) {
4204
- return `vizmatic-graph-${graph.token}`;
4205
- }
4206
- function nodeId(graph, node) {
4207
- return `${graphBaseId(graph)}-node-${svgToken(node.id)}`;
4208
- }
4209
- function edgeId(graph, edge) {
4210
- return `${graphBaseId(graph)}-edge-${svgToken(edge.id)}`;
4211
- }
4212
- function labelForEdge(graph, edge) {
4213
- const nodes = new Map(graph.nodes.map((node) => [node.id, node.label]));
4214
- const from = nodes.get(edge.from) ?? edge.from;
4215
- const to = nodes.get(edge.to) ?? edge.to;
4216
- return edge.title || (edge.label ? `${from} to ${to}: ${edge.label}` : `${from} to ${to}`);
4217
- }
4218
- function descriptionForEdge(graph, edge) {
4219
- const nodes = new Map(graph.nodes.map((node) => [node.id, node.label]));
4220
- const from = nodes.get(edge.from) ?? edge.from;
4221
- const to = nodes.get(edge.to) ?? edge.to;
4222
- return `Relationship from ${from} to ${to}${edge.label ? `, labeled ${edge.label}` : ""}.`;
4223
- }
4224
- function nodeGroup(graph, node, layout) {
4225
- const id = nodeId(graph, node);
4226
- const label = node.detail ? `${node.label}: ${node.detail}` : node.label;
4227
- const description = node.detail || node.label;
4228
- const titleId = `${id}-title`;
4229
- const descriptionId = `${id}-description`;
4230
- const accessible = `<g ${attribute("id", id)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(node.title || node.label)}</title><desc id="${descriptionId}">${escapeXml(description)}</desc>`;
4231
- if (!layout) return `${accessible}</g>`;
4232
- const rect = `<rect x="${layout.left}" y="${layout.top}" width="${layout.width}" height="${layout.height}" fill="transparent" pointer-events="all"/>`;
4233
- const hitTarget = node.href ? `<a ${attribute("href", node.href)} role="link" tabindex="0" ${attribute("aria-label", label)}>${rect}</a>` : rect;
4234
- return `${accessible}${hitTarget}</g>`;
4235
- }
4236
- function edgeGroup(graph, edge, root) {
4237
- const id = edgeId(graph, edge);
4238
- const title = labelForEdge(graph, edge);
4239
- const titleId = `${id}-title`;
4240
- const descriptionId = `${id}-description`;
4241
- const accessible = `<g ${attribute("id", id)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(title)}</title><desc id="${descriptionId}">${escapeXml(descriptionForEdge(graph, edge))}</desc>`;
4242
- if (!root || !edge.path) return `${accessible}</g>`;
4243
- const path = `<path d="${escapeXml(edge.path)}" transform="translate(${root.left} ${root.top})" fill="none" stroke="transparent" stroke-width="14" stroke-linecap="round" pointer-events="stroke"/>`;
4244
- const hitTarget = edge.href ? `<a ${attribute("href", edge.href)} role="link" tabindex="0" ${attribute("aria-label", title)}>${path}</a>` : path;
4245
- return `${accessible}${hitTarget}</g>`;
4246
- }
4247
- function addSvgAccessibility(svg, graphs, layoutNodes) {
4248
- if (graphs.length === 0) return svg;
4249
- const title = graphs.map((graph) => graph.title).join(". ");
4250
- const description = graphs.map((graph) => `${graph.title}. ${graph.description}`).join(" ");
4251
- const hasLinks = graphs.some(
4252
- (graph) => graph.nodes.some((node) => node.href) || graph.edges.some((edge) => edge.href)
4253
- );
4254
- const rootTitleId = "vizmatic-svg-title";
4255
- const rootDescriptionId = "vizmatic-svg-description";
4256
- const groupMarkup = graphs.map((graph) => {
4257
- const baseId = graphBaseId(graph);
4258
- const titleId = `${baseId}-title`;
4259
- const descriptionId = `${baseId}-description`;
4260
- const root = layoutNodes.find((node) => node.key === graph.detectionKey);
4261
- const nodes = graph.nodes.map((item) => {
4262
- const layout = layoutNodes.find((node) => node.key === `${graph.detectionKey}-node-${svgToken(item.id)}`);
4263
- if (item.href && !layout) {
4264
- throw new Error(`Could not resolve GraphDiagram node "${item.id}" bounds for SVG link export.`);
4265
- }
4266
- return nodeGroup(graph, item, layout);
4267
- }).join("");
4268
- const edges = graph.edges.map((item) => {
4269
- if (item.href && !root) {
4270
- throw new Error(`Could not resolve GraphDiagram bounds for SVG edge link export: "${item.id}".`);
4271
- }
4272
- return edgeGroup(graph, item, root);
4273
- }).join("");
4274
- return `<g ${attribute("id", baseId)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(graph.title)}</title><desc id="${descriptionId}">${escapeXml(graph.description)}</desc>${nodes}${edges}</g>`;
4275
- }).join("");
4276
- const metadata = `<title id="${rootTitleId}">${escapeXml(title)}</title><desc id="${rootDescriptionId}">${escapeXml(description)}</desc>`;
4277
- return svg.replace(
4278
- /^<svg\b([^>]*)>/,
4279
- (_match, attrs) => `<svg${attrs} role="${hasLinks ? "group" : "img"}" aria-labelledby="${rootTitleId}" aria-describedby="${rootDescriptionId}">${metadata}`
4280
- ).replace(/<\/svg>\s*$/, `${groupMarkup}</svg>`);
4300
+ gap: gapProp,
4301
+ connectorLength: connectorLengthProp,
4302
+ connectorTone = "neutral",
4303
+ align = "center",
4304
+ math = false
4305
+ }) {
4306
+ const connectorLength = connectorLengthProp ?? densityOf(c).s(32);
4307
+ const gap = gapProp ?? densityOf(c).s(10);
4308
+ const isHorizontal = direction === "horizontal";
4309
+ const children = stages.flatMap((stage, index) => {
4310
+ const elements = [
4311
+ import_react7.default.createElement(import_react7.default.Fragment, { key: `stage-${index}` }, renderFlowStage(stage, c, math))
4312
+ ];
4313
+ if (index < stages.length - 1) {
4314
+ elements.push(import_react7.default.createElement(
4315
+ import_react7.default.Fragment,
4316
+ { key: `connector-${index}` },
4317
+ FlowArrow({
4318
+ direction: isHorizontal ? "right" : "down",
4319
+ length: connectorLength,
4320
+ c,
4321
+ tone: connectorTone
4322
+ })
4323
+ ));
4324
+ }
4325
+ return elements;
4326
+ });
4327
+ return (isHorizontal ? Row : Column)({
4328
+ gap,
4329
+ align,
4330
+ justify: isHorizontal ? "start" : "center",
4331
+ children
4332
+ });
4281
4333
  }
4282
4334
 
4335
+ // src/primitives/diagrams.ts
4336
+ var import_react8 = __toESM(require("react"), 1);
4337
+ var import_dagre = __toESM(require("@dagrejs/dagre"), 1);
4338
+
4283
4339
  // src/graph-routing.ts
4284
4340
  var EPSILON = 1e-3;
4285
4341
  var MAX_GRID_POINTS = 18e3;
@@ -7634,6 +7690,398 @@ function DeploymentDiagram({
7634
7690
  }
7635
7691
  Object.defineProperty(DeploymentDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
7636
7692
 
7693
+ // src/primitives/entity-relationship.ts
7694
+ var import_react11 = __toESM(require("react"), 1);
7695
+ var import_dagre2 = __toESM(require("@dagrejs/dagre"), 1);
7696
+ var cardinalityWords = {
7697
+ one: "exactly one",
7698
+ "zero-or-one": "zero or one",
7699
+ "one-or-many": "one or more",
7700
+ "zero-or-many": "zero or more"
7701
+ };
7702
+ var legendLines = [
7703
+ "PK primary key \xB7 FK foreign key \xB7 UQ unique \xB7 ? nullable",
7704
+ "|| one \xB7 o| zero or one \xB7 |< one or more \xB7 o< zero or more"
7705
+ ];
7706
+ function requiredText(value, label) {
7707
+ if (typeof value !== "string" || !value.trim()) throw new Error(`EntityRelationshipDiagram ${label} must be a non-empty string.`);
7708
+ }
7709
+ function positive(value, label, allowZero = false) {
7710
+ if (!Number.isFinite(value) || (allowZero ? value < 0 : value <= 0)) {
7711
+ throw new RangeError(`EntityRelationshipDiagram ${label} must be a finite ${allowZero ? "non-negative" : "positive"} number.`);
7712
+ }
7713
+ }
7714
+ function endpointAttributes(endpoint2) {
7715
+ return endpoint2.attribute === void 0 ? [] : typeof endpoint2.attribute === "string" ? [endpoint2.attribute] : endpoint2.attribute;
7716
+ }
7717
+ function attributeDescription(attribute2) {
7718
+ const constraints = [attribute2.primaryKey && "primary key", attribute2.foreignKey && "foreign key", attribute2.unique && "unique", attribute2.nullable ? "nullable" : "not null"].filter(Boolean);
7719
+ return `${attribute2.name} (${attribute2.type}, ${constraints.join(", ")})`;
7720
+ }
7721
+ function endpointDescription(endpoint2, entities) {
7722
+ const entity = entities.get(endpoint2.entity);
7723
+ const attributes = endpointAttributes(endpoint2);
7724
+ return `${entity.label ?? entity.id}${attributes.length ? ` [${attributes.join(", ")}]` : ""}`;
7725
+ }
7726
+ function validate(entities, relationships) {
7727
+ if (!entities.length) throw new Error("EntityRelationshipDiagram requires at least one entity.");
7728
+ const byId = /* @__PURE__ */ new Map();
7729
+ for (const entity of entities) {
7730
+ requiredText(entity.id, "entity id");
7731
+ if (byId.has(entity.id)) throw new Error(`EntityRelationshipDiagram has duplicate entity id "${entity.id}".`);
7732
+ if (entity.label !== void 0) requiredText(entity.label, `entity "${entity.id}" label`);
7733
+ const names = /* @__PURE__ */ new Set();
7734
+ for (const attribute2 of entity.attributes) {
7735
+ requiredText(attribute2.name, `entity "${entity.id}" attribute name`);
7736
+ requiredText(attribute2.type, `attribute "${entity.id}.${attribute2.name}" type`);
7737
+ if (names.has(attribute2.name)) throw new Error(`EntityRelationshipDiagram has duplicate attribute "${entity.id}.${attribute2.name}".`);
7738
+ if (attribute2.primaryKey && attribute2.nullable) throw new Error(`EntityRelationshipDiagram primary key "${entity.id}.${attribute2.name}" cannot be nullable.`);
7739
+ names.add(attribute2.name);
7740
+ }
7741
+ byId.set(entity.id, entity);
7742
+ }
7743
+ const ids = /* @__PURE__ */ new Set();
7744
+ for (const relationship of relationships) {
7745
+ requiredText(relationship.id, "relationship id");
7746
+ if (ids.has(relationship.id)) throw new Error(`EntityRelationshipDiagram has duplicate relationship id "${relationship.id}".`);
7747
+ ids.add(relationship.id);
7748
+ for (const endpoint2 of [relationship.from, relationship.to]) {
7749
+ const entity = byId.get(endpoint2.entity);
7750
+ if (!entity) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" references missing entity "${endpoint2.entity}".`);
7751
+ if (!Object.hasOwn(cardinalityWords, endpoint2.cardinality)) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" has invalid cardinality "${endpoint2.cardinality}".`);
7752
+ const attributes = endpointAttributes(endpoint2);
7753
+ if (endpoint2.attribute !== void 0 && attributes.length === 0) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" needs at least one endpoint attribute.`);
7754
+ if (new Set(attributes).size !== attributes.length) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" repeats an endpoint attribute.`);
7755
+ for (const name of attributes) {
7756
+ if (!entity.attributes.some((attribute2) => attribute2.name === name)) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" references missing attribute "${entity.id}.${name}".`);
7757
+ }
7758
+ }
7759
+ const from = endpointAttributes(relationship.from), to = endpointAttributes(relationship.to);
7760
+ if (from.length && to.length && from.length !== to.length) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" has mismatched composite attribute counts.`);
7761
+ }
7762
+ return byId;
7763
+ }
7764
+ function cardinalitySize(cardinality, scale) {
7765
+ const many = cardinality.endsWith("many"), optional = cardinality.startsWith("zero");
7766
+ return { length: ((optional ? many ? 25 : 19 : many ? 20 : 12) + 0.75) * scale, halfWidth: ((many ? 6 : 5) + 0.75) * scale };
7767
+ }
7768
+ function cardinalityBounds(cardinality, point, toward, scale) {
7769
+ const size = cardinalitySize(cardinality, scale);
7770
+ const horizontal = point.y === toward.y;
7771
+ const end = { x: point.x + Math.sign(toward.x - point.x) * size.length, y: point.y + Math.sign(toward.y - point.y) * size.length };
7772
+ return {
7773
+ left: Math.min(point.x, end.x) - (horizontal ? 0.75 * scale : size.halfWidth),
7774
+ right: Math.max(point.x, end.x) + (horizontal ? 0.75 * scale : size.halfWidth),
7775
+ top: Math.min(point.y, end.y) - (horizontal ? size.halfWidth : 0.75 * scale),
7776
+ bottom: Math.max(point.y, end.y) + (horizontal ? size.halfWidth : 0.75 * scale)
7777
+ };
7778
+ }
7779
+ function cardinalityGlyph(cardinality, point, toward, color, background, scale, key) {
7780
+ const length = Math.hypot(toward.x - point.x, toward.y - point.y);
7781
+ const ux = (toward.x - point.x) / length, uy = (toward.y - point.y) / length;
7782
+ const at = (along, across = 0) => ({ x: point.x + (ux * along - uy * across) * scale, y: point.y + (uy * along + ux * across) * scale });
7783
+ const bar = (along) => {
7784
+ const a = at(along, -5), b = at(along, 5);
7785
+ return `M ${a.x} ${a.y} L ${b.x} ${b.y}`;
7786
+ };
7787
+ const many = cardinality.endsWith("many");
7788
+ const optional = cardinality.startsWith("zero");
7789
+ const middle = at(13), top = at(0, -6), bottom = at(0, 6);
7790
+ const path = many ? `M ${top.x} ${top.y} L ${middle.x} ${middle.y} L ${bottom.x} ${bottom.y} M ${point.x} ${point.y} L ${middle.x} ${middle.y}` : bar(5);
7791
+ const circle = at(many ? 21 : 15);
7792
+ return import_react11.default.createElement(
7793
+ "g",
7794
+ { key, "data-er-cardinality": cardinality },
7795
+ import_react11.default.createElement("path", { d: `${path}${optional ? "" : ` ${bar(many ? 20 : 12)}`}`, fill: "none", stroke: color, strokeWidth: 1.5 * scale }),
7796
+ optional && import_react11.default.createElement("circle", { cx: circle.x, cy: circle.y, r: 4 * scale, fill: background, stroke: color, strokeWidth: 1.5 * scale })
7797
+ );
7798
+ }
7799
+ function EntityRelationshipDiagram({
7800
+ c: baseTheme,
7801
+ entities,
7802
+ relationships = [],
7803
+ title,
7804
+ description,
7805
+ id,
7806
+ direction = "LR",
7807
+ width,
7808
+ height,
7809
+ entityWidth,
7810
+ fontSize,
7811
+ padding: paddingProp,
7812
+ gap: gapProp,
7813
+ showLegend = true,
7814
+ density
7815
+ }) {
7816
+ const c = density === void 0 ? baseTheme : withDensity(baseTheme, density);
7817
+ const d = densityOf(c);
7818
+ const visibleTitle = title?.trim();
7819
+ const svgTitle = visibleTitle || "Entity relationship diagram";
7820
+ const textSize = fontSize ?? d.type.small;
7821
+ const headerSize = Math.max(textSize, d.type.label);
7822
+ const padding = paddingProp ?? d.s(32);
7823
+ const gap = gapProp ?? d.s(100);
7824
+ positive(textSize, "fontSize");
7825
+ positive(padding, "padding", true);
7826
+ positive(gap, "gap");
7827
+ if (width !== void 0) positive(width, "width");
7828
+ if (height !== void 0) positive(height, "height");
7829
+ if (entityWidth !== void 0) positive(entityWidth, "entityWidth");
7830
+ if (id !== void 0) requiredText(id, "id");
7831
+ if (!["LR", "RL", "TB", "BT"].includes(direction)) throw new Error("EntityRelationshipDiagram direction must be LR, RL, TB, or BT.");
7832
+ const byId = validate(entities, relationships);
7833
+ const lineScale = Math.max(0.8, textSize / 12);
7834
+ const markerSizes = relationships.flatMap((relationship) => [cardinalitySize(relationship.from.cardinality, lineScale), cardinalitySize(relationship.to.cardinality, lineScale)]);
7835
+ const markerLength = Math.max(0, ...markerSizes.map((size) => size.length));
7836
+ const markerPitch = Math.max(0, ...markerSizes.map((size) => size.halfWidth * 2)) + Math.max(d.s(4), lineScale * 1.5);
7837
+ const baseClearance = Math.max(28, d.s(28));
7838
+ const routingClearance = Math.max(baseClearance, markerLength + d.s(4) + Math.max(2, d.s(2)));
7839
+ const enlargedMarkers = routingClearance > baseClearance;
7840
+ const bodyPadding = enlargedMarkers && relationships.some((relationship) => relationship.from.entity === relationship.to.entity) ? Math.max(padding, routingClearance + d.s(4)) : padding;
7841
+ const anchorRow = (endpoint2) => {
7842
+ const entity = byId.get(endpoint2.entity), names = endpointAttributes(endpoint2);
7843
+ return names.length ? Math.round(names.reduce((sum, name) => sum + entity.attributes.findIndex((attribute2) => attribute2.name === name), 0) / names.length) : Math.floor(Math.max(0, entity.attributes.length - 1) / 2);
7844
+ };
7845
+ const rowEndpointCounts = new Map(entities.map((entity) => [entity.id, /* @__PURE__ */ new Map()]));
7846
+ const entityEndpointCounts = /* @__PURE__ */ new Map();
7847
+ for (const relationship of relationships) for (const endpoint2 of [relationship.from, relationship.to]) {
7848
+ const counts2 = rowEndpointCounts.get(endpoint2.entity), row = anchorRow(endpoint2);
7849
+ counts2.set(row, (counts2.get(row) ?? 0) + 1);
7850
+ entityEndpointCounts.set(endpoint2.entity, (entityEndpointCounts.get(endpoint2.entity) ?? 0) + 1);
7851
+ }
7852
+ const rowHeight = Math.ceil(Math.max(d.s(25), textSize * 1.7));
7853
+ const headerHeight = Math.ceil(Math.max(d.s(35), headerSize * 2));
7854
+ const inset = d.s(12);
7855
+ const keyWidth = Math.ceil(estimateTextWidth("PK FK UQ", textSize, { mono: true })) + inset;
7856
+ const titleHeight = visibleTitle ? Math.ceil(d.type.heading * 1.5 + d.s(12)) : 0;
7857
+ const legendHeight = showLegend ? Math.ceil(textSize * 3.2 + d.s(12)) : 0;
7858
+ const legendWidth = showLegend ? Math.max(480, ...legendLines.map((line) => estimateTextWidth(line, textSize) + padding * 2)) : 0;
7859
+ const labelPadding = relationships.some((relationship) => relationship.label) ? Math.ceil(textSize * 2 + d.s(8)) : 0;
7860
+ const graph = new import_dagre2.default.graphlib.Graph({ multigraph: true }).setGraph({
7861
+ rankdir: direction,
7862
+ nodesep: enlargedMarkers ? Math.max(gap * 0.75, routingClearance * 2 + markerPitch) : gap * 0.75,
7863
+ ranksep: Math.max(gap, 74, routingClearance * 2 + markerPitch),
7864
+ edgesep: d.s(26),
7865
+ marginx: 0,
7866
+ marginy: 0
7867
+ }).setDefaultEdgeLabel(() => ({}));
7868
+ const measures = new Map(entities.map((entity) => {
7869
+ const nameWidth = Math.max(30, ...entity.attributes.map((attribute2) => estimateTextWidth(attribute2.name, textSize, { mono: true })));
7870
+ const typeWidth = Math.max(24, ...entity.attributes.map((attribute2) => estimateTextWidth(attribute2.type + (attribute2.nullable ? "?" : ""), textSize, { mono: true })));
7871
+ const rowHeights = Array.from({ length: Math.max(1, entity.attributes.length) }, (_, index) => Math.max(rowHeight, Math.ceil((rowEndpointCounts.get(entity.id).get(index) ?? 0) * markerPitch)));
7872
+ let rowY = headerHeight;
7873
+ const rowCenters = rowHeights.map((height2) => {
7874
+ const center2 = rowY + height2 / 2;
7875
+ rowY += height2;
7876
+ return center2;
7877
+ });
7878
+ const measured = {
7879
+ width: Math.ceil(Math.max(
7880
+ entityWidth ?? d.s(210),
7881
+ estimateTextWidth(entity.label ?? entity.id, headerSize, { weight: 600 }) + inset * 2,
7882
+ keyWidth + nameWidth + typeWidth + inset * 4,
7883
+ direction === "TB" || direction === "BT" ? markerPitch * ((entityEndpointCounts.get(entity.id) ?? 0) + 1) : 0
7884
+ )),
7885
+ height: rowY,
7886
+ rowHeights,
7887
+ rowCenters,
7888
+ typeWidth: Math.ceil(typeWidth)
7889
+ };
7890
+ graph.setNode(entity.id, { width: measured.width, height: measured.height });
7891
+ return [entity.id, measured];
7892
+ }));
7893
+ for (const relationship of relationships) graph.setEdge(relationship.from.entity, relationship.to.entity, {
7894
+ width: relationship.label ? estimateTextWidth(relationship.label, textSize) + d.s(64) : 0,
7895
+ height: relationship.label ? textSize * 2 : 0,
7896
+ labelpos: "c"
7897
+ }, relationship.id);
7898
+ import_dagre2.default.layout(graph);
7899
+ const graphWidth = graph.graph().width ?? 0, graphHeight = graph.graph().height ?? 0;
7900
+ const minWidth = Math.ceil(Math.max(graphWidth + (bodyPadding + labelPadding) * 2, legendWidth, visibleTitle ? estimateTextWidth(visibleTitle, d.type.heading, { weight: 600 }) + padding * 2 : 0));
7901
+ const minHeight = Math.ceil(graphHeight + (bodyPadding + labelPadding) * 2 + titleHeight + legendHeight);
7902
+ if (width !== void 0 && width < minWidth) throw new RangeError(`EntityRelationshipDiagram width needs at least ${minWidth}px to keep entity text readable.`);
7903
+ if (height !== void 0 && height < minHeight) throw new RangeError(`EntityRelationshipDiagram height needs at least ${minHeight}px to keep entity text readable.`);
7904
+ const resolvedWidth = width ?? minWidth, resolvedHeight = height ?? minHeight;
7905
+ const offsetX = (resolvedWidth - graphWidth) / 2;
7906
+ const offsetY = bodyPadding + titleHeight + labelPadding + (resolvedHeight - minHeight) / 2;
7907
+ const nodes = entities.map((entity) => {
7908
+ const node = graph.node(entity.id), measure = measures.get(entity.id);
7909
+ return { id: entity.id, cx: node.x + offsetX, cy: node.y + offsetY, width: measure.width, height: measure.height, ports: [] };
7910
+ });
7911
+ const nodeById = new Map(nodes.map((node) => [node.id, node]));
7912
+ const portRequests = [];
7913
+ const endpointPort = (endpoint2, other, port) => {
7914
+ const node = nodeById.get(endpoint2.entity), target = nodeById.get(other.entity);
7915
+ const horizontal = direction === "LR" || direction === "RL";
7916
+ const side = node === target ? "right" : horizontal ? target.cx >= node.cx ? "right" : "left" : target.cy >= node.cy ? "bottom" : "top";
7917
+ const desired = side === "top" || side === "bottom" ? node.width / 2 : measures.get(node.id).rowCenters[anchorRow(endpoint2)];
7918
+ portRequests.push({ node, id: port, side, desired });
7919
+ };
7920
+ const edges = relationships.map((relationship, index) => {
7921
+ const fromPort = `from-${index}`, toPort = `to-${index}`;
7922
+ endpointPort(relationship.from, relationship.to, fromPort);
7923
+ endpointPort(relationship.to, relationship.from, toPort);
7924
+ return { from: relationship.from.entity, to: relationship.to.entity, fromPort, toPort };
7925
+ });
7926
+ for (const node of nodes) for (const side of ["left", "right", "top", "bottom"]) {
7927
+ const requests = portRequests.filter((request) => request.node === node && request.side === side).sort((a, b) => a.desired - b.desired);
7928
+ const extent = side === "left" || side === "right" ? node.height : node.width;
7929
+ const positions = [];
7930
+ for (let start = 0; start < requests.length; ) {
7931
+ let end = start + 1;
7932
+ while (end < requests.length && requests[end].desired === requests[start].desired) end++;
7933
+ for (let index = start; index < end; index++) positions[index] = requests[index].desired + (index - start - (end - start - 1) / 2) * markerPitch;
7934
+ start = end;
7935
+ }
7936
+ for (let index = 0; index < positions.length; index++) positions[index] = Math.max(positions[index], index ? positions[index - 1] + markerPitch : markerPitch / 2);
7937
+ for (let index = positions.length - 1; index >= 0; index--) positions[index] = Math.min(positions[index], index === positions.length - 1 ? extent - markerPitch / 2 : positions[index + 1] - markerPitch);
7938
+ requests.forEach((request, index) => node.ports.push({ id: request.id, side, offset: positions[index] / extent }));
7939
+ }
7940
+ const routed = routeOrthogonalGraph(nodes, edges, resolvedWidth, resolvedHeight - legendHeight, routingClearance, Math.max(d.s(18), markerPitch));
7941
+ if (routed.failures.length) throw new Error(`EntityRelationshipDiagram could not route relationship "${relationships[routed.failures[0].index].id}": ${routed.failures[0].reason}`);
7942
+ const relationshipText = (relationship) => `${endpointDescription(relationship.from, byId)} (${cardinalityWords[relationship.from.cardinality]}) to ${endpointDescription(relationship.to, byId)} (${cardinalityWords[relationship.to.cardinality]})${relationship.label ? `: ${relationship.label}` : ""}${relationship.identifying ? ", identifying relationship" : ", non-identifying relationship"}.`;
7943
+ const schemaSummary = `${entities.length} entities and ${relationships.length} relationships. ${entities.map((entity) => `${entity.label ?? entity.id}: ${entity.attributes.map(attributeDescription).join("; ") || "no attributes shown"}.`).join(" ")} ${relationships.map(relationshipText).join(" ")}`;
7944
+ const lineColor = c.textSecondary;
7945
+ const labels = [];
7946
+ const placedLabels = [];
7947
+ const markerBoxes = relationships.flatMap((relationship, index) => {
7948
+ const points = routed.routes.get(index);
7949
+ return [cardinalityBounds(relationship.from.cardinality, points[0], points[1], lineScale), cardinalityBounds(relationship.to.cardinality, points.at(-1), points.at(-2), lineScale)];
7950
+ });
7951
+ const occupied = nodes.map((node) => ({ left: node.cx - node.width / 2 - 3, right: node.cx + node.width / 2 + 3, top: node.cy - node.height / 2 - 3, bottom: node.cy + node.height / 2 + 3 }));
7952
+ const paths = relationships.flatMap((relationship, index) => {
7953
+ const points = routed.routes.get(index);
7954
+ const path = roundedPolylinePath(points, d.s(4)).d;
7955
+ if (relationship.label) {
7956
+ const segments = points.slice(1).map((point, at) => ({ a: points[at], b: point, length: Math.hypot(point.x - points[at].x, point.y - points[at].y) }));
7957
+ const labelWidth = Math.ceil(estimateTextWidth(relationship.label, textSize)) + d.s(10);
7958
+ const labelHeight = Math.ceil(textSize * 1.4) + 4;
7959
+ const candidates = segments.sort((a, b) => b.length - a.length).flatMap((segment) => {
7960
+ return [0.5, 0.25, 0.75].flatMap((fraction) => [1, 2, 3].flatMap((distance) => [-1, 1].map((side) => {
7961
+ const x = segment.a.x + (segment.b.x - segment.a.x) * fraction;
7962
+ const y = segment.a.y + (segment.b.y - segment.a.y) * fraction;
7963
+ const horizontal = segment.a.y === segment.b.y;
7964
+ const cx = x + (horizontal ? 0 : side * (labelWidth / 2 + d.s(6)) * distance);
7965
+ const cy = y + (horizontal ? side * (labelHeight / 2 + d.s(6)) * distance : 0);
7966
+ return { left: cx - labelWidth / 2, right: cx + labelWidth / 2, top: cy - labelHeight / 2, bottom: cy + labelHeight / 2 };
7967
+ })));
7968
+ });
7969
+ const label = candidates.find((box2) => box2.left >= 0 && box2.right <= resolvedWidth && box2.top >= padding + titleHeight && box2.bottom <= resolvedHeight - padding - legendHeight && ![...occupied, ...markerBoxes, ...placedLabels].some((other) => box2.left < other.right && box2.right > other.left && box2.top < other.bottom && box2.bottom > other.top) && ![...routed.routes.values()].some((route) => samplesHitBox(route, box2)));
7970
+ if (!label) throw new Error(`EntityRelationshipDiagram could not place label for relationship "${relationship.id}" without covering the schema. Increase gap or canvas size.`);
7971
+ placedLabels.push(label);
7972
+ labels.push(import_react11.default.createElement("div", { key: `label-${relationship.id}`, style: {
7973
+ position: "absolute",
7974
+ left: label.left,
7975
+ top: label.top,
7976
+ width: labelWidth,
7977
+ height: labelHeight,
7978
+ display: "flex",
7979
+ alignItems: "center",
7980
+ justifyContent: "center",
7981
+ backgroundColor: c.bg,
7982
+ color: c.textSecondary,
7983
+ fontSize: textSize,
7984
+ fontFamily: c.fontSans,
7985
+ whiteSpace: "nowrap"
7986
+ } }, relationship.label));
7987
+ }
7988
+ return [
7989
+ import_react11.default.createElement("path", {
7990
+ key: `path-${relationship.id}`,
7991
+ d: path,
7992
+ fill: "none",
7993
+ stroke: lineColor,
7994
+ strokeWidth: d.w(1.5),
7995
+ strokeDasharray: relationship.identifying ? void 0 : `${d.s(5)} ${d.s(4)}`,
7996
+ "data-vizmatic-graph-edge-id": encodeURIComponent(relationship.id),
7997
+ "data-vizmatic-graph-edge-from": encodeURIComponent(relationship.from.entity),
7998
+ "data-vizmatic-graph-edge-to": encodeURIComponent(relationship.to.entity),
7999
+ "data-vizmatic-graph-edge-label": encodeURIComponent(relationship.label ?? ""),
8000
+ "data-vizmatic-graph-edge-title": encodeURIComponent(relationshipText(relationship))
8001
+ }),
8002
+ cardinalityGlyph(relationship.from.cardinality, points[0], points[1], lineColor, c.bg, lineScale, `from-${relationship.id}`),
8003
+ cardinalityGlyph(relationship.to.cardinality, points.at(-1), points.at(-2), lineColor, c.bg, lineScale, `to-${relationship.id}`)
8004
+ ];
8005
+ });
8006
+ return import_react11.default.createElement(
8007
+ "div",
8008
+ {
8009
+ role: "img",
8010
+ "aria-label": svgTitle,
8011
+ "data-vizmatic-svg-id": id,
8012
+ "data-vizmatic-svg-title": svgTitle,
8013
+ "data-vizmatic-svg-description": [description, schemaSummary].filter(Boolean).join(" "),
8014
+ style: { display: "flex", position: "relative", flexShrink: 0, width: resolvedWidth, height: resolvedHeight }
8015
+ },
8016
+ visibleTitle && import_react11.default.createElement("div", { style: { position: "absolute", left: padding, top: padding, fontFamily: c.fontSans, fontSize: d.type.heading, fontWeight: 600, color: c.textPrimary } }, visibleTitle),
8017
+ import_react11.default.createElement("svg", { width: resolvedWidth, height: resolvedHeight, viewBox: `0 0 ${resolvedWidth} ${resolvedHeight}`, style: { position: "absolute", left: 0, top: 0 } }, ...paths),
8018
+ ...labels,
8019
+ ...entities.map((entity) => {
8020
+ const node = nodeById.get(entity.id), measure = measures.get(entity.id);
8021
+ const keyColor = getReadableToneColor(entity.tone ?? "blue", c, c.bgCard, c.bgCard);
8022
+ return import_react11.default.createElement(
8023
+ "div",
8024
+ {
8025
+ key: entity.id,
8026
+ "data-vizmatic-graph-node-id": entity.id,
8027
+ "data-vizmatic-graph-node-label": entity.label ?? entity.id,
8028
+ "data-vizmatic-graph-node-detail": entity.attributes.map(attributeDescription).join("; "),
8029
+ style: {
8030
+ position: "absolute",
8031
+ left: node.cx - node.width / 2,
8032
+ top: node.cy - node.height / 2,
8033
+ display: "flex",
8034
+ flexDirection: "column",
8035
+ width: node.width,
8036
+ height: node.height,
8037
+ border: `1px solid ${c.borderLight}`,
8038
+ borderRadius: d.r(4),
8039
+ backgroundColor: c.bgCard,
8040
+ overflow: "hidden"
8041
+ }
8042
+ },
8043
+ import_react11.default.createElement("div", { style: {
8044
+ display: "flex",
8045
+ alignItems: "center",
8046
+ height: headerHeight,
8047
+ flexShrink: 0,
8048
+ padding: `0 ${inset}px`,
8049
+ fontFamily: c.fontSans,
8050
+ fontSize: headerSize,
8051
+ fontWeight: 600,
8052
+ color: keyColor,
8053
+ backgroundColor: c.bgCardAlt,
8054
+ borderBottom: `1px solid ${c.borderLight}`
8055
+ } }, entity.label ?? entity.id),
8056
+ ...entity.attributes.map((attribute2, index) => import_react11.default.createElement(
8057
+ "div",
8058
+ { key: attribute2.name, style: {
8059
+ display: "flex",
8060
+ alignItems: "center",
8061
+ height: measure.rowHeights[index],
8062
+ flexShrink: 0,
8063
+ padding: `0 ${inset}px`,
8064
+ gap: inset,
8065
+ fontFamily: c.fontMono,
8066
+ fontSize: textSize,
8067
+ color: c.textPrimary
8068
+ } },
8069
+ import_react11.default.createElement("span", { style: { width: keyWidth - inset, flexShrink: 0, color: keyColor } }, [attribute2.primaryKey && "PK", attribute2.foreignKey && "FK", attribute2.unique && "UQ"].filter(Boolean).join(" ")),
8070
+ import_react11.default.createElement("span", { style: { flexGrow: 1, whiteSpace: "nowrap" } }, attribute2.name),
8071
+ import_react11.default.createElement("span", { style: { width: measure.typeWidth, flexShrink: 0, textAlign: "right", color: c.textSecondary } }, attribute2.type + (attribute2.nullable ? "?" : ""))
8072
+ )),
8073
+ !entity.attributes.length && import_react11.default.createElement("div", { style: { display: "flex", alignItems: "center", padding: `0 ${inset}px`, height: measure.rowHeights[0], fontSize: textSize, color: c.textSecondary, fontFamily: c.fontSans } }, "No attributes shown")
8074
+ );
8075
+ }),
8076
+ showLegend && import_react11.default.createElement(
8077
+ "div",
8078
+ { style: { position: "absolute", left: padding, right: padding, bottom: padding, display: "flex", flexDirection: "column", gap: d.s(5), fontSize: textSize, lineHeight: 1.3, fontFamily: c.fontSans, color: c.textSecondary } },
8079
+ ...legendLines.map((line) => import_react11.default.createElement("div", { key: line, style: { display: "flex", whiteSpace: "nowrap", flexShrink: 0 } }, line))
8080
+ )
8081
+ );
8082
+ }
8083
+ Object.defineProperty(EntityRelationshipDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
8084
+
7637
8085
  // src/primitives/transformer.ts
7638
8086
  var blockLabels = {
7639
8087
  embedding: "Embedding",
@@ -7895,7 +8343,7 @@ function TransformerTopology({
7895
8343
  Object.defineProperty(TransformerTopology, SVG_ACCESSIBILITY_COMPONENT, { value: true });
7896
8344
 
7897
8345
  // src/primitives/data.ts
7898
- var import_react11 = __toESM(require("react"), 1);
8346
+ var import_react12 = __toESM(require("react"), 1);
7899
8347
  function Matrix({
7900
8348
  data,
7901
8349
  c,
@@ -7915,7 +8363,8 @@ function Matrix({
7915
8363
  highlightCol,
7916
8364
  highlightCell,
7917
8365
  highlightColor = c.info,
7918
- colorDomain
8366
+ colorDomain,
8367
+ ...accessibility
7919
8368
  }) {
7920
8369
  const cellSize = cellSizeProp ?? densityOf(c).f(38);
7921
8370
  const fontSize = fontSizeProp ?? densityOf(c).type.small;
@@ -7967,9 +8416,19 @@ function Matrix({
7967
8416
  if (colorValue2 < 0.67) return c.infoDark;
7968
8417
  return c.positiveDark;
7969
8418
  };
7970
- return import_react11.default.createElement(
8419
+ const cellDescriptions = data.flatMap((row, rowIndex) => row.map((value, columnIndex) => {
8420
+ const label = labels?.[rowIndex]?.[columnIndex];
8421
+ const text = typeof label === "string" || typeof label === "number" ? label : formatValue(value);
8422
+ return `${rowLabels?.[rowIndex] ?? `Row ${rowIndex + 1}`}, ${colLabels?.[columnIndex] ?? `column ${columnIndex + 1}`}: ${text}`;
8423
+ }));
8424
+ return import_react12.default.createElement(
7971
8425
  "div",
7972
8426
  {
8427
+ ...chartAccessibilityAttributes({
8428
+ ...accessibility,
8429
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Matrix",
8430
+ description: chartDescription(accessibility.description, cellDescriptions)
8431
+ }),
7973
8432
  style: {
7974
8433
  display: "flex",
7975
8434
  flexDirection: "column",
@@ -7977,10 +8436,10 @@ function Matrix({
7977
8436
  gap: densityOf(c).s(8)
7978
8437
  }
7979
8438
  },
7980
- title && import_react11.default.createElement("div", {
8439
+ title && import_react12.default.createElement("div", {
7981
8440
  style: { ...typeOf(c, "label"), color: c.textPrimary }
7982
8441
  }, title),
7983
- import_react11.default.createElement(
8442
+ import_react12.default.createElement(
7984
8443
  "div",
7985
8444
  {
7986
8445
  style: {
@@ -7990,7 +8449,7 @@ function Matrix({
7990
8449
  }
7991
8450
  },
7992
8451
  // Column labels
7993
- colLabels && import_react11.default.createElement(
8452
+ colLabels && import_react12.default.createElement(
7994
8453
  "div",
7995
8454
  {
7996
8455
  style: {
@@ -8000,7 +8459,7 @@ function Matrix({
8000
8459
  }
8001
8460
  },
8002
8461
  ...colLabels.map(
8003
- (label, i) => import_react11.default.createElement("div", {
8462
+ (label, i) => import_react12.default.createElement("div", {
8004
8463
  key: `col-${i}`,
8005
8464
  style: {
8006
8465
  width: resolvedCellWidth,
@@ -8014,7 +8473,7 @@ function Matrix({
8014
8473
  )
8015
8474
  ),
8016
8475
  ...data.map(
8017
- (row, ri) => import_react11.default.createElement(
8476
+ (row, ri) => import_react12.default.createElement(
8018
8477
  "div",
8019
8478
  {
8020
8479
  key: `row-${ri}`,
@@ -8024,7 +8483,7 @@ function Matrix({
8024
8483
  alignItems: "center"
8025
8484
  }
8026
8485
  },
8027
- rowLabels && import_react11.default.createElement("div", {
8486
+ rowLabels && import_react12.default.createElement("div", {
8028
8487
  style: {
8029
8488
  width: resolvedRowLabelWidth,
8030
8489
  textAlign: "right",
@@ -8040,7 +8499,7 @@ function Matrix({
8040
8499
  const highlighted = ri === highlightRow || ci === highlightCol;
8041
8500
  const backgroundColor = highlighted ? compositeColor(withColorAlpha(highlightColor, 0.24), baseBackgroundColor) : baseBackgroundColor;
8042
8501
  const exactCell = ri === highlightCell?.row && ci === highlightCell?.col;
8043
- return import_react11.default.createElement("div", {
8502
+ return import_react12.default.createElement("div", {
8044
8503
  key: `cell-${ri}-${ci}`,
8045
8504
  style: {
8046
8505
  width: resolvedCellWidth,
@@ -8080,9 +8539,12 @@ function Heatmap({
8080
8539
  highlightCol,
8081
8540
  highlightCell,
8082
8541
  highlightColor,
8083
- colorDomain
8542
+ colorDomain,
8543
+ ...accessibility
8084
8544
  }) {
8085
8545
  return Matrix({
8546
+ ...accessibility,
8547
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Heatmap",
8086
8548
  data,
8087
8549
  colLabels: xLabels,
8088
8550
  rowLabels: yLabels,
@@ -8115,7 +8577,9 @@ function TiledMatrix({
8115
8577
  gap: gapProp,
8116
8578
  tone = "blue",
8117
8579
  muted = false,
8118
- crossedOut = false
8580
+ crossedOut = false,
8581
+ id,
8582
+ description
8119
8583
  }) {
8120
8584
  const gap = gapProp ?? densityOf(c).s(3);
8121
8585
  const safeRows = Math.max(1, Math.floor(rows));
@@ -8123,7 +8587,7 @@ function TiledMatrix({
8123
8587
  const baseAccent = getToneColor(tone, c);
8124
8588
  const cellRows = Array.from(
8125
8589
  { length: safeRows },
8126
- (_, row) => import_react11.default.createElement(
8590
+ (_, row) => import_react12.default.createElement(
8127
8591
  "div",
8128
8592
  {
8129
8593
  key: `tiled-matrix-row-${row}`,
@@ -8138,7 +8602,7 @@ function TiledMatrix({
8138
8602
  );
8139
8603
  const region = regionIndex >= 0 ? regions[regionIndex] : void 0;
8140
8604
  const accent = getToneColor(region?.tone ?? tone, c);
8141
- return import_react11.default.createElement("div", {
8605
+ return import_react12.default.createElement("div", {
8142
8606
  key: `tiled-matrix-cell-${row}-${col}`,
8143
8607
  "data-region": regionIndex >= 0 ? regionIndex : void 0,
8144
8608
  style: {
@@ -8154,7 +8618,7 @@ function TiledMatrix({
8154
8618
  })
8155
8619
  )
8156
8620
  );
8157
- const grid = import_react11.default.createElement(
8621
+ const grid = import_react12.default.createElement(
8158
8622
  "div",
8159
8623
  {
8160
8624
  "data-crossed-out": crossedOut ? "true" : void 0,
@@ -8173,7 +8637,7 @@ function TiledMatrix({
8173
8637
  },
8174
8638
  ...cellRows,
8175
8639
  ...crossedOut ? [
8176
- import_react11.default.createElement("div", {
8640
+ import_react12.default.createElement("div", {
8177
8641
  key: "cross-forward",
8178
8642
  style: {
8179
8643
  position: "absolute",
@@ -8188,7 +8652,7 @@ function TiledMatrix({
8188
8652
  boxShadow: `0 0 0 1px ${c.bgCard}`
8189
8653
  }
8190
8654
  }),
8191
- import_react11.default.createElement("div", {
8655
+ import_react12.default.createElement("div", {
8192
8656
  key: "cross-backward",
8193
8657
  style: {
8194
8658
  position: "absolute",
@@ -8205,11 +8669,17 @@ function TiledMatrix({
8205
8669
  })
8206
8670
  ] : []
8207
8671
  );
8208
- return import_react11.default.createElement(
8672
+ return import_react12.default.createElement(
8209
8673
  "div",
8210
8674
  {
8211
- role: "img",
8212
- "aria-label": ariaLabel ?? (typeof title === "string" ? title : "Tiled matrix"),
8675
+ ...chartAccessibilityAttributes({
8676
+ id,
8677
+ ariaLabel: ariaLabel ?? (typeof title === "string" ? title : "Tiled matrix"),
8678
+ description: chartDescription(description, [
8679
+ `${safeRows} rows by ${safeCols} columns`,
8680
+ ...regions.map((region, index) => `Region ${index + 1}: rows ${region.rowStart + 1} to ${region.rowEnd + 1}, columns ${region.colStart + 1} to ${region.colEnd + 1}`)
8681
+ ])
8682
+ }),
8213
8683
  style: {
8214
8684
  display: "flex",
8215
8685
  flexDirection: "column",
@@ -8218,7 +8688,7 @@ function TiledMatrix({
8218
8688
  }
8219
8689
  },
8220
8690
  ...compactChildren([
8221
- title && import_react11.default.createElement("div", {
8691
+ title && import_react12.default.createElement("div", {
8222
8692
  style: {
8223
8693
  color: muted ? c.textMuted : getReadableToneColor(tone, c),
8224
8694
  fontFamily: "Inter",
@@ -8228,7 +8698,7 @@ function TiledMatrix({
8228
8698
  textAlign: "center"
8229
8699
  }
8230
8700
  }, title),
8231
- subtitle && import_react11.default.createElement("div", {
8701
+ subtitle && import_react12.default.createElement("div", {
8232
8702
  style: {
8233
8703
  color: c.textMuted,
8234
8704
  fontFamily: "JetBrains Mono",
@@ -8274,7 +8744,7 @@ function DataTable({
8274
8744
  };
8275
8745
  const widths = Array.from({ length: columnCount }, (_, index) => columnWidth(index));
8276
8746
  const alignmentOf = (colIndex) => align?.[colIndex] ?? (colIndex < headerCols ? "left" : "right");
8277
- return import_react11.default.createElement(
8747
+ return import_react12.default.createElement(
8278
8748
  "div",
8279
8749
  {
8280
8750
  style: {
@@ -8283,7 +8753,7 @@ function DataTable({
8283
8753
  ...width != null ? { width } : {}
8284
8754
  }
8285
8755
  },
8286
- ...rows.map((row, rowIndex) => import_react11.default.createElement(
8756
+ ...rows.map((row, rowIndex) => import_react12.default.createElement(
8287
8757
  "div",
8288
8758
  {
8289
8759
  key: `${rowIndex}-${row.map(String).join("|")}`,
@@ -8299,7 +8769,7 @@ function DataTable({
8299
8769
  const isHeaderRow = rowIndex < headerRows;
8300
8770
  const isHeaderCol = colIndex < headerCols;
8301
8771
  const alignment = alignmentOf(colIndex);
8302
- return import_react11.default.createElement("div", {
8772
+ return import_react12.default.createElement("div", {
8303
8773
  key: `${rowIndex}-${colIndex}-${String(cell)}`,
8304
8774
  style: {
8305
8775
  ...width != null && colIndex === 0 ? { flex: 1 } : { width: widths[colIndex] },
@@ -8319,7 +8789,7 @@ function DataTable({
8319
8789
  );
8320
8790
  }
8321
8791
  function isGridCell(cell) {
8322
- return typeof cell === "object" && cell !== null && !import_react11.default.isValidElement(cell) && ("label" in cell || "tone" in cell || "color" in cell || "backgroundColor" in cell || "borderColor" in cell || "opacity" in cell);
8792
+ return typeof cell === "object" && cell !== null && !import_react12.default.isValidElement(cell) && ("label" in cell || "tone" in cell || "color" in cell || "backgroundColor" in cell || "borderColor" in cell || "opacity" in cell);
8323
8793
  }
8324
8794
  function Grid({
8325
8795
  rows,
@@ -8366,7 +8836,7 @@ function Grid({
8366
8836
  ...textFitStyle("center")
8367
8837
  };
8368
8838
  };
8369
- return import_react11.default.createElement(
8839
+ return import_react12.default.createElement(
8370
8840
  "div",
8371
8841
  {
8372
8842
  style: {
@@ -8376,7 +8846,7 @@ function Grid({
8376
8846
  alignItems: "center"
8377
8847
  }
8378
8848
  },
8379
- ...rows.map((row, rowIndex) => import_react11.default.createElement(
8849
+ ...rows.map((row, rowIndex) => import_react12.default.createElement(
8380
8850
  "div",
8381
8851
  {
8382
8852
  key: `grid-row-${rowIndex}`,
@@ -8385,7 +8855,7 @@ function Grid({
8385
8855
  gap
8386
8856
  }
8387
8857
  },
8388
- ...row.map((cell, colIndex) => import_react11.default.createElement("div", {
8858
+ ...row.map((cell, colIndex) => import_react12.default.createElement("div", {
8389
8859
  key: `grid-cell-${rowIndex}-${colIndex}`,
8390
8860
  style: cellStyle(cell, rowIndex, colIndex)
8391
8861
  }, renderCellLabel(cell)))
@@ -8414,7 +8884,8 @@ function AxisPlot({
8414
8884
  paths = [],
8415
8885
  xAxisLabel,
8416
8886
  yAxisLabel,
8417
- children
8887
+ children,
8888
+ ...accessibility
8418
8889
  }) {
8419
8890
  const padding = paddingProp ?? densityOf(c).s(18);
8420
8891
  const innerWidth = Math.max(1, width - padding * 2);
@@ -8446,7 +8917,7 @@ function AxisPlot({
8446
8917
  const x = padding + innerWidth * index / (gridCount + 1);
8447
8918
  const y = padding + innerHeight * index / (gridCount + 1);
8448
8919
  return [
8449
- import_react11.default.createElement("line", {
8920
+ import_react12.default.createElement("line", {
8450
8921
  key: `axis-grid-x-${index}`,
8451
8922
  x1: x,
8452
8923
  y1: padding,
@@ -8456,7 +8927,7 @@ function AxisPlot({
8456
8927
  strokeWidth: 1,
8457
8928
  opacity: 0.75
8458
8929
  }),
8459
- import_react11.default.createElement("line", {
8930
+ import_react12.default.createElement("line", {
8460
8931
  key: `axis-grid-y-${index}`,
8461
8932
  x1: padding,
8462
8933
  y1: y,
@@ -8471,7 +8942,7 @@ function AxisPlot({
8471
8942
  }
8472
8943
  if (showAxes) {
8473
8944
  elements.push(
8474
- import_react11.default.createElement("line", {
8945
+ import_react12.default.createElement("line", {
8475
8946
  key: "axis-x",
8476
8947
  x1: padding,
8477
8948
  y1: xAxisY,
@@ -8481,7 +8952,7 @@ function AxisPlot({
8481
8952
  strokeWidth: 1.6,
8482
8953
  opacity: 0.85
8483
8954
  }),
8484
- import_react11.default.createElement("line", {
8955
+ import_react12.default.createElement("line", {
8485
8956
  key: "axis-y",
8486
8957
  x1: yAxisX,
8487
8958
  y1: padding,
@@ -8504,7 +8975,7 @@ function AxisPlot({
8504
8975
  commands.push(`L ${sx(point.x)} ${sy(point.y)}`);
8505
8976
  }
8506
8977
  }
8507
- return [import_react11.default.createElement("path", {
8978
+ return [import_react12.default.createElement("path", {
8508
8979
  key: `axis-path-${index}`,
8509
8980
  d: commands.join(" "),
8510
8981
  fill: "none",
@@ -8559,16 +9030,28 @@ function AxisPlot({
8559
9030
  strokeWidth: point.strokeWidth,
8560
9031
  opacity: point.opacity
8561
9032
  })));
8562
- elements.push(...import_react11.default.Children.toArray(children).filter(import_react11.default.isValidElement));
8563
- const svg = import_react11.default.createElement("svg", {
9033
+ elements.push(...import_react12.default.Children.toArray(children).filter(import_react12.default.isValidElement));
9034
+ const accessible = chartAccessibilityAttributes({
9035
+ ...accessibility,
9036
+ ariaLabel: accessibility.ariaLabel ?? "Axis plot",
9037
+ description: chartDescription(accessibility.description, [
9038
+ `${xAxisLabel ?? "x"} range ${xMin} to ${xMax}, ${yAxisLabel ?? "y"} range ${yMin} to ${yMax}`,
9039
+ ...points.map((point, index) => `Point ${index + 1}: x ${point.x}, y ${point.y}`),
9040
+ ...vectors.map((vector2, index) => `Vector ${index + 1}: (${vector2.x1}, ${vector2.y1}) to (${vector2.x2}, ${vector2.y2})`),
9041
+ ...paths.map((path, index) => `Path ${index + 1}: ${path.points.map((point) => `(${point.x}, ${point.y})`).join(", ")}`)
9042
+ ])
9043
+ });
9044
+ const svg = import_react12.default.createElement("svg", {
9045
+ ...!xAxisLabel && !yAxisLabel ? accessible : {},
8564
9046
  width,
8565
9047
  height,
8566
9048
  viewBox: `0 0 ${width} ${height}`
8567
9049
  }, ...elements);
8568
9050
  if (!xAxisLabel && !yAxisLabel) return svg;
8569
- return import_react11.default.createElement(
9051
+ return import_react12.default.createElement(
8570
9052
  "div",
8571
9053
  {
9054
+ ...accessible,
8572
9055
  style: {
8573
9056
  position: "relative",
8574
9057
  width,
@@ -8577,7 +9060,7 @@ function AxisPlot({
8577
9060
  }
8578
9061
  },
8579
9062
  svg,
8580
- xAxisLabel && import_react11.default.createElement("div", {
9063
+ xAxisLabel && import_react12.default.createElement("div", {
8581
9064
  key: "axis-x-label",
8582
9065
  style: {
8583
9066
  position: "absolute",
@@ -8592,7 +9075,7 @@ function AxisPlot({
8592
9075
  fontWeight: 750
8593
9076
  }
8594
9077
  }, xAxisLabel),
8595
- yAxisLabel && import_react11.default.createElement("div", {
9078
+ yAxisLabel && import_react12.default.createElement("div", {
8596
9079
  key: "axis-y-label",
8597
9080
  style: {
8598
9081
  position: "absolute",
@@ -8611,10 +9094,10 @@ function AxisPlot({
8611
9094
  }
8612
9095
 
8613
9096
  // src/primitives/charts.ts
8614
- var import_react13 = __toESM(require("react"), 1);
9097
+ var import_react14 = __toESM(require("react"), 1);
8615
9098
 
8616
9099
  // src/canvas-chart-fit.ts
8617
- var import_react12 = __toESM(require("react"), 1);
9100
+ var import_react13 = __toESM(require("react"), 1);
8618
9101
  var CANVAS_CHART_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.canvasChartComponent");
8619
9102
  var CHART_FRAME_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.chartFrameComponent");
8620
9103
  var FIT_PROP = "__vizmaticCanvasChartFit";
@@ -8625,11 +9108,11 @@ function isCanvasChart(component) {
8625
9108
  }
8626
9109
  function CanvasChartFit({ children, width, height }) {
8627
9110
  let chart = children;
8628
- for (let depth = 0; (0, import_react12.isValidElement)(chart) && typeof chart.type === "function" && depth < 16; depth += 1) {
9111
+ for (let depth = 0; (0, import_react13.isValidElement)(chart) && typeof chart.type === "function" && depth < 16; depth += 1) {
8629
9112
  if (chart.type[CHART_FRAME_COMPONENT]) {
8630
9113
  const props = chart.props;
8631
9114
  const padding = typeof props.padding === "number" ? props.padding : 16;
8632
- chart = import_react12.default.cloneElement(chart, {
9115
+ chart = import_react13.default.cloneElement(chart, {
8633
9116
  ...props,
8634
9117
  width: typeof props.width === "number" ? props.width + 2 * (padding + 1) : props.width,
8635
9118
  height: void 0
@@ -8638,10 +9121,10 @@ function CanvasChartFit({ children, width, height }) {
8638
9121
  }
8639
9122
  chart = chart.type(chart.props);
8640
9123
  }
8641
- return import_react12.default.createElement("div", {
9124
+ return import_react13.default.createElement("div", {
8642
9125
  [FIT_PROP]: { width, height },
8643
9126
  style: { position: "relative", display: "flex", width, height, flexShrink: 0 }
8644
- }, import_react12.default.createElement("div", {
9127
+ }, import_react13.default.createElement("div", {
8645
9128
  style: { position: "absolute", left: 0, top: 0, display: "flex", alignItems: "flex-start" }
8646
9129
  }, chart));
8647
9130
  }
@@ -8650,16 +9133,16 @@ function prepareChartFits(element) {
8650
9133
  const hasText = (node) => {
8651
9134
  if (typeof node === "string" || typeof node === "number" || typeof node === "bigint") return true;
8652
9135
  if (Array.isArray(node)) return node.some(hasText);
8653
- return (0, import_react12.isValidElement)(node) && node.type === import_react12.default.Fragment && hasText(node.props.children);
9136
+ return (0, import_react13.isValidElement)(node) && node.type === import_react13.default.Fragment && hasText(node.props.children);
8654
9137
  };
8655
9138
  const visit = (node, scope) => {
8656
9139
  if (Array.isArray(node)) return node.map((child) => visit(child, scope));
8657
- if (!(0, import_react12.isValidElement)(node)) return node;
9140
+ if (!(0, import_react13.isValidElement)(node)) return node;
8658
9141
  const forwarded = node.type;
8659
9142
  const render = typeof node.type === "function" ? node.type : forwarded?.$$typeof === /* @__PURE__ */ Symbol.for("react.forward_ref") ? forwarded.render : void 0;
8660
9143
  if (render) {
8661
9144
  const resolved = visit(render(node.props), scope);
8662
- return node.key != null && (0, import_react12.isValidElement)(resolved) ? import_react12.default.cloneElement(resolved, { key: node.key }) : resolved;
9145
+ return node.key != null && (0, import_react13.isValidElement)(resolved) ? import_react13.default.cloneElement(resolved, { key: node.key }) : resolved;
8663
9146
  }
8664
9147
  const size = node.props[FIT_PROP];
8665
9148
  const props = { ...node.props };
@@ -8684,19 +9167,19 @@ function prepareChartFits(element) {
8684
9167
  ...style
8685
9168
  };
8686
9169
  }
8687
- return children === void 0 ? import_react12.default.cloneElement(node, props) : import_react12.default.cloneElement(node, props, preparedChildren);
9170
+ return children === void 0 ? import_react13.default.cloneElement(node, props) : import_react13.default.cloneElement(node, props, preparedChildren);
8688
9171
  };
8689
9172
  return { element: visit(element), sizes };
8690
9173
  }
8691
9174
  function fittedTree(element, geometry) {
8692
9175
  if (Array.isArray(element)) return element.map((child) => fittedTree(child, geometry));
8693
- if (!(0, import_react12.isValidElement)(element)) return element;
9176
+ if (!(0, import_react13.isValidElement)(element)) return element;
8694
9177
  const id = element.props[VIEWPORT_PROP];
8695
9178
  const children = element.props.children;
8696
9179
  if (typeof id === "string") {
8697
9180
  const fit = geometry.get(id);
8698
- const content = import_react12.default.Children.only(children);
8699
- return import_react12.default.cloneElement(element, {}, import_react12.default.cloneElement(content, { style: {
9181
+ const content = import_react13.default.Children.only(children);
9182
+ return import_react13.default.cloneElement(element, {}, import_react13.default.cloneElement(content, { style: {
8700
9183
  ...content.props.style,
8701
9184
  left: fit.left,
8702
9185
  top: fit.top,
@@ -8704,7 +9187,7 @@ function fittedTree(element, geometry) {
8704
9187
  transformOrigin: "top left"
8705
9188
  } }));
8706
9189
  }
8707
- return children === void 0 ? element : import_react12.default.cloneElement(element, {}, fittedTree(children, geometry));
9190
+ return children === void 0 ? element : import_react13.default.cloneElement(element, {}, fittedTree(children, geometry));
8708
9191
  }
8709
9192
  async function renderWithCanvasChartFit(render, element, options) {
8710
9193
  const prepared = prepareChartFits(element);
@@ -8865,7 +9348,7 @@ function chartLabel(key, text, x, y, c, options = {}) {
8865
9348
  );
8866
9349
  transform2 = void 0;
8867
9350
  }
8868
- return import_react13.default.createElement("div", {
9351
+ return import_react14.default.createElement("div", {
8869
9352
  key,
8870
9353
  style: {
8871
9354
  position: "absolute",
@@ -8908,7 +9391,7 @@ function pointLabelPlacement(x, y, plot, index, width = 70) {
8908
9391
  };
8909
9392
  }
8910
9393
  function ChartFrame(props) {
8911
- return import_react13.default.createElement(ChartFrameContent, props);
9394
+ return import_react14.default.createElement(ChartFrameContent, props);
8912
9395
  }
8913
9396
  function ChartFrameContent({
8914
9397
  children,
@@ -8920,13 +9403,21 @@ function ChartFrameContent({
8920
9403
  width = "100%",
8921
9404
  height,
8922
9405
  padding: paddingProp,
8923
- framed = false
9406
+ framed = false,
9407
+ id,
9408
+ ariaLabel,
9409
+ description
8924
9410
  }) {
8925
9411
  const d = densityOf(c);
8926
9412
  const padding = paddingProp ?? (framed ? d.s(14) : 0);
8927
- return import_react13.default.createElement(
9413
+ return import_react14.default.createElement(
8928
9414
  "div",
8929
9415
  {
9416
+ ...chartAccessibilityAttributes({
9417
+ id,
9418
+ ariaLabel: ariaLabel ?? title ?? "Chart",
9419
+ description: [subtitle, description].filter(Boolean).join(" ")
9420
+ }),
8930
9421
  style: {
8931
9422
  width,
8932
9423
  ...height ? { height } : {},
@@ -8938,20 +9429,20 @@ function ChartFrameContent({
8938
9429
  ...framed ? { borderRadius: d.r(8), border: `1px solid ${c.borderSubtle}`, backgroundColor: c.bgCard } : {}
8939
9430
  }
8940
9431
  },
8941
- (title || subtitle) && import_react13.default.createElement(
9432
+ (title || subtitle) && import_react14.default.createElement(
8942
9433
  "div",
8943
9434
  {
8944
9435
  style: { display: "flex", flexDirection: "column", gap: d.s(2), minWidth: 0, maxWidth: "100%" }
8945
9436
  },
8946
- title && import_react13.default.createElement("div", {
9437
+ title && import_react14.default.createElement("div", {
8947
9438
  style: { ...typeOf(c, "label"), ...textFitStyle(), color: c.textPrimary, fontWeight: 600 }
8948
9439
  }, title),
8949
- subtitle && import_react13.default.createElement("div", {
9440
+ subtitle && import_react14.default.createElement("div", {
8950
9441
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary, lineHeight: 1.35 }
8951
9442
  }, subtitle)
8952
9443
  ),
8953
9444
  children,
8954
- (legend || footer) && import_react13.default.createElement(
9445
+ (legend || footer) && import_react14.default.createElement(
8955
9446
  "div",
8956
9447
  {
8957
9448
  style: {
@@ -8961,18 +9452,18 @@ function ChartFrameContent({
8961
9452
  gap: d.s(12)
8962
9453
  }
8963
9454
  },
8964
- legend && import_react13.default.createElement(
9455
+ legend && import_react14.default.createElement(
8965
9456
  "div",
8966
9457
  {
8967
9458
  style: { display: "flex", alignItems: "center", gap: d.s(12), flexWrap: "wrap", minWidth: 0 }
8968
9459
  },
8969
- ...legend.map((item, index) => import_react13.default.createElement(
9460
+ ...legend.map((item, index) => import_react14.default.createElement(
8970
9461
  "div",
8971
9462
  {
8972
9463
  key: `${item.label}-${index}`,
8973
9464
  style: { display: "flex", alignItems: "center", gap: d.s(6), minWidth: 0 }
8974
9465
  },
8975
- import_react13.default.createElement("span", {
9466
+ import_react14.default.createElement("span", {
8976
9467
  style: {
8977
9468
  width: d.f(12),
8978
9469
  height: Math.max(2, d.w(2)),
@@ -8980,12 +9471,12 @@ function ChartFrameContent({
8980
9471
  display: "flex"
8981
9472
  }
8982
9473
  }),
8983
- import_react13.default.createElement("span", {
9474
+ import_react14.default.createElement("span", {
8984
9475
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary }
8985
9476
  }, item.label)
8986
9477
  ))
8987
9478
  ),
8988
- footer && import_react13.default.createElement("div", {
9479
+ footer && import_react14.default.createElement("div", {
8989
9480
  style: { ...typeOf(c, "tiny"), ...textFitStyle("right"), color: c.textMuted }
8990
9481
  }, footer)
8991
9482
  )
@@ -9055,7 +9546,8 @@ function PieChart({
9055
9546
  size,
9056
9547
  format = "decimal",
9057
9548
  showLegend = true,
9058
- footer
9549
+ footer,
9550
+ ...accessibility
9059
9551
  }) {
9060
9552
  const total = validateNonNegativeSegments(segments, "PieChart");
9061
9553
  const positiveSegments = segments.filter((segment) => segment.value > 0);
@@ -9069,7 +9561,7 @@ function PieChart({
9069
9561
  const start = cursor;
9070
9562
  const end = index === positiveSegments.length - 1 ? 270 : cursor + span;
9071
9563
  cursor += span;
9072
- return import_react13.default.createElement("path", {
9564
+ return import_react14.default.createElement("path", {
9073
9565
  key: `pie-segment-${segment.label}-${index}`,
9074
9566
  d: pieSectorPath(cx, cy, radius, start, end),
9075
9567
  fill: chartColor(segment.color, c, index),
@@ -9080,7 +9572,7 @@ function PieChart({
9080
9572
  "data-pie-share": total > 0 ? segment.value / total : 0
9081
9573
  });
9082
9574
  });
9083
- const legend = showLegend && positiveSegments.length > 0 && import_react13.default.createElement("div", {
9575
+ const legend = showLegend && positiveSegments.length > 0 && import_react14.default.createElement("div", {
9084
9576
  style: {
9085
9577
  display: "flex",
9086
9578
  flexDirection: "column",
@@ -9092,13 +9584,13 @@ function PieChart({
9092
9584
  const formattedValue = formatChartValue(segment.value, format);
9093
9585
  const share = formatChartValue(segment.value / total, "percent");
9094
9586
  const label = segment.valueLabel ?? (format === "percent" ? formattedValue : `${formattedValue} \xB7 ${share}`);
9095
- return import_react13.default.createElement(
9587
+ return import_react14.default.createElement(
9096
9588
  "div",
9097
9589
  {
9098
9590
  key: `pie-legend-${segment.label}-${index}`,
9099
9591
  style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 }
9100
9592
  },
9101
- import_react13.default.createElement("span", {
9593
+ import_react14.default.createElement("span", {
9102
9594
  style: {
9103
9595
  display: "flex",
9104
9596
  width: 10,
@@ -9108,10 +9600,10 @@ function PieChart({
9108
9600
  flexShrink: 0
9109
9601
  }
9110
9602
  }),
9111
- import_react13.default.createElement("span", {
9603
+ import_react14.default.createElement("span", {
9112
9604
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary, flex: 1 }
9113
9605
  }, segment.label),
9114
- import_react13.default.createElement("span", {
9606
+ import_react14.default.createElement("span", {
9115
9607
  style: {
9116
9608
  ...typeOf(c, "tiny"),
9117
9609
  color: c.textPrimary,
@@ -9123,12 +9615,15 @@ function PieChart({
9123
9615
  );
9124
9616
  }));
9125
9617
  return ChartFrame({
9618
+ ...accessibility,
9619
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pie chart",
9620
+ description: chartDescription(accessibility.description, valueDescriptions(segments, format)),
9126
9621
  c,
9127
9622
  title,
9128
9623
  subtitle,
9129
9624
  footer,
9130
9625
  width,
9131
- children: import_react13.default.createElement(
9626
+ children: import_react14.default.createElement(
9132
9627
  "div",
9133
9628
  {
9134
9629
  style: {
@@ -9140,7 +9635,7 @@ function PieChart({
9140
9635
  width: "100%"
9141
9636
  }
9142
9637
  },
9143
- import_react13.default.createElement(
9638
+ import_react14.default.createElement(
9144
9639
  "svg",
9145
9640
  {
9146
9641
  width: resolvedSize,
@@ -9149,7 +9644,7 @@ function PieChart({
9149
9644
  role: "img",
9150
9645
  "aria-label": title ?? "Pie chart"
9151
9646
  },
9152
- positiveSegments.length === 0 ? import_react13.default.createElement("circle", {
9647
+ positiveSegments.length === 0 ? import_react14.default.createElement("circle", {
9153
9648
  cx,
9154
9649
  cy,
9155
9650
  r: radius,
@@ -9175,7 +9670,8 @@ function DonutChart({
9175
9670
  centerLabel,
9176
9671
  centerValue,
9177
9672
  showLegend = true,
9178
- footer
9673
+ footer,
9674
+ ...accessibility
9179
9675
  }) {
9180
9676
  const positiveSegments = segments.filter((segment) => segment.value > 0);
9181
9677
  const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
@@ -9194,13 +9690,13 @@ function DonutChart({
9194
9690
  const end = cursor + rawSpan - gap / 2;
9195
9691
  cursor += rawSpan;
9196
9692
  if (end <= start) return null;
9197
- return import_react13.default.createElement("path", {
9693
+ return import_react14.default.createElement("path", {
9198
9694
  key: `donut-segment-${segment.label}-${index}`,
9199
9695
  d: donutArcPath(cx, cy, outerRadius, innerRadius, start, end),
9200
9696
  fill: chartColor(segment.color, c, index)
9201
9697
  });
9202
9698
  }).filter(Boolean);
9203
- const legend = showLegend && positiveSegments.length > 0 && import_react13.default.createElement("div", {
9699
+ const legend = showLegend && positiveSegments.length > 0 && import_react14.default.createElement("div", {
9204
9700
  style: {
9205
9701
  display: "flex",
9206
9702
  flexDirection: "column",
@@ -9208,7 +9704,7 @@ function DonutChart({
9208
9704
  flex: 1,
9209
9705
  minWidth: 112
9210
9706
  }
9211
- }, ...positiveSegments.map((segment, index) => import_react13.default.createElement(
9707
+ }, ...positiveSegments.map((segment, index) => import_react14.default.createElement(
9212
9708
  "div",
9213
9709
  {
9214
9710
  key: `donut-legend-${segment.label}-${index}`,
@@ -9219,7 +9715,7 @@ function DonutChart({
9219
9715
  minWidth: 0
9220
9716
  }
9221
9717
  },
9222
- import_react13.default.createElement("span", {
9718
+ import_react14.default.createElement("span", {
9223
9719
  style: {
9224
9720
  display: "flex",
9225
9721
  width: 10,
@@ -9229,7 +9725,7 @@ function DonutChart({
9229
9725
  flexShrink: 0
9230
9726
  }
9231
9727
  }),
9232
- import_react13.default.createElement("span", {
9728
+ import_react14.default.createElement("span", {
9233
9729
  style: {
9234
9730
  ...typeOf(c, "tiny"),
9235
9731
  ...textFitStyle(),
@@ -9237,7 +9733,7 @@ function DonutChart({
9237
9733
  flex: 1
9238
9734
  }
9239
9735
  }, segment.label),
9240
- import_react13.default.createElement("span", {
9736
+ import_react14.default.createElement("span", {
9241
9737
  style: {
9242
9738
  ...typeOf(c, "tiny"),
9243
9739
  color: c.textPrimary,
@@ -9248,6 +9744,9 @@ function DonutChart({
9248
9744
  }, segment.valueLabel ?? formatChartValue(segment.value, format))
9249
9745
  )));
9250
9746
  return ChartFrame({
9747
+ ...accessibility,
9748
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Donut chart",
9749
+ description: chartDescription(accessibility.description, valueDescriptions(positiveSegments, format)),
9251
9750
  c,
9252
9751
  title,
9253
9752
  subtitle,
@@ -9255,7 +9754,7 @@ function DonutChart({
9255
9754
  width,
9256
9755
  height,
9257
9756
  padding: densityOf(c).s(16),
9258
- children: import_react13.default.createElement(
9757
+ children: import_react14.default.createElement(
9259
9758
  "div",
9260
9759
  {
9261
9760
  style: {
@@ -9267,7 +9766,7 @@ function DonutChart({
9267
9766
  width: "100%"
9268
9767
  }
9269
9768
  },
9270
- import_react13.default.createElement(
9769
+ import_react14.default.createElement(
9271
9770
  "div",
9272
9771
  {
9273
9772
  style: {
@@ -9278,14 +9777,14 @@ function DonutChart({
9278
9777
  flexShrink: 0
9279
9778
  }
9280
9779
  },
9281
- import_react13.default.createElement(
9780
+ import_react14.default.createElement(
9282
9781
  "svg",
9283
9782
  {
9284
9783
  width: resolvedSize,
9285
9784
  height: resolvedSize,
9286
9785
  viewBox: `0 0 ${resolvedSize} ${resolvedSize}`
9287
9786
  },
9288
- positiveSegments.length === 0 ? import_react13.default.createElement("circle", {
9787
+ positiveSegments.length === 0 ? import_react14.default.createElement("circle", {
9289
9788
  cx,
9290
9789
  cy,
9291
9790
  r: (outerRadius + innerRadius) / 2,
@@ -9294,7 +9793,7 @@ function DonutChart({
9294
9793
  strokeWidth: resolvedThickness
9295
9794
  }) : paths
9296
9795
  ),
9297
- (centerLabel != null || resolvedCenterValue != null) && import_react13.default.createElement(
9796
+ (centerLabel != null || resolvedCenterValue != null) && import_react14.default.createElement(
9298
9797
  "div",
9299
9798
  {
9300
9799
  style: {
@@ -9313,7 +9812,7 @@ function DonutChart({
9313
9812
  textAlign: "center"
9314
9813
  }
9315
9814
  },
9316
- resolvedCenterValue != null && import_react13.default.createElement("div", {
9815
+ resolvedCenterValue != null && import_react14.default.createElement("div", {
9317
9816
  style: {
9318
9817
  ...typeOf(c, "small"),
9319
9818
  color: c.textPrimary,
@@ -9324,7 +9823,7 @@ function DonutChart({
9324
9823
  ...textFitStyle("center")
9325
9824
  }
9326
9825
  }, resolvedCenterValue),
9327
- centerLabel != null && import_react13.default.createElement("div", {
9826
+ centerLabel != null && import_react14.default.createElement("div", {
9328
9827
  style: {
9329
9828
  ...typeOf(c, "tiny"),
9330
9829
  color: c.textMuted,
@@ -9338,6 +9837,9 @@ function DonutChart({
9338
9837
  )
9339
9838
  });
9340
9839
  }
9840
+ function valueDescriptions(data, format = "decimal") {
9841
+ return data.map((item) => `${item.label}: ${item.valueLabel ?? formatChartValue(item.value, format)}`);
9842
+ }
9341
9843
  function StackedBar({
9342
9844
  segments,
9343
9845
  c,
@@ -9345,13 +9847,22 @@ function StackedBar({
9345
9847
  height = 68,
9346
9848
  title,
9347
9849
  subtitle,
9348
- showLegend = true
9850
+ showLegend = true,
9851
+ ...accessibility
9349
9852
  }) {
9350
9853
  const positiveSegments = segments.filter((segment) => segment.value > 0);
9351
9854
  const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
9352
- return import_react13.default.createElement(
9855
+ return import_react14.default.createElement(
9353
9856
  "div",
9354
9857
  {
9858
+ ...chartAccessibilityAttributes({
9859
+ ...accessibility,
9860
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Stacked bar",
9861
+ description: chartDescription(
9862
+ [subtitle, accessibility.description].filter(Boolean).join(" "),
9863
+ valueDescriptions(positiveSegments)
9864
+ )
9865
+ }),
9355
9866
  style: {
9356
9867
  width,
9357
9868
  display: "flex",
@@ -9359,7 +9870,7 @@ function StackedBar({
9359
9870
  gap: densityOf(c).s(10)
9360
9871
  }
9361
9872
  },
9362
- (title || subtitle) && import_react13.default.createElement(
9873
+ (title || subtitle) && import_react14.default.createElement(
9363
9874
  "div",
9364
9875
  {
9365
9876
  style: {
@@ -9368,14 +9879,14 @@ function StackedBar({
9368
9879
  gap: densityOf(c).s(3)
9369
9880
  }
9370
9881
  },
9371
- title && import_react13.default.createElement("div", {
9882
+ title && import_react14.default.createElement("div", {
9372
9883
  style: { ...typeOf(c, "label"), color: c.textPrimary, fontWeight: 600 }
9373
9884
  }, title),
9374
- subtitle && import_react13.default.createElement("div", {
9885
+ subtitle && import_react14.default.createElement("div", {
9375
9886
  style: { ...typeOf(c, "tiny"), color: c.textSecondary }
9376
9887
  }, subtitle)
9377
9888
  ),
9378
- import_react13.default.createElement(
9889
+ import_react14.default.createElement(
9379
9890
  "div",
9380
9891
  {
9381
9892
  style: {
@@ -9393,7 +9904,7 @@ function StackedBar({
9393
9904
  const share = total > 0 ? segment.value / total : 0;
9394
9905
  const segmentWidth = width * share;
9395
9906
  const color = chartColor(segment.color, c, index);
9396
- return import_react13.default.createElement(
9907
+ return import_react14.default.createElement(
9397
9908
  "div",
9398
9909
  {
9399
9910
  key: `${segment.label}-${index}`,
@@ -9407,7 +9918,7 @@ function StackedBar({
9407
9918
  ...index < positiveSegments.length - 1 ? { borderRight: `2px solid ${c.bgSubtle}` } : {}
9408
9919
  }
9409
9920
  },
9410
- segmentWidth >= 64 && import_react13.default.createElement("span", {
9921
+ segmentWidth >= 64 && import_react14.default.createElement("span", {
9411
9922
  style: {
9412
9923
  ...typeOf(c, "small"),
9413
9924
  color: getReadableTextColor(color, c),
@@ -9418,7 +9929,7 @@ function StackedBar({
9418
9929
  );
9419
9930
  })
9420
9931
  ),
9421
- showLegend && import_react13.default.createElement(
9932
+ showLegend && import_react14.default.createElement(
9422
9933
  "div",
9423
9934
  {
9424
9935
  style: {
@@ -9430,13 +9941,13 @@ function StackedBar({
9430
9941
  },
9431
9942
  ...positiveSegments.map((segment, index) => {
9432
9943
  const share = total > 0 ? segment.value / total : 0;
9433
- return import_react13.default.createElement(
9944
+ return import_react14.default.createElement(
9434
9945
  "div",
9435
9946
  {
9436
9947
  key: `legend-${segment.label}-${index}`,
9437
9948
  style: { display: "flex", alignItems: "center", gap: 7 }
9438
9949
  },
9439
- import_react13.default.createElement("span", {
9950
+ import_react14.default.createElement("span", {
9440
9951
  style: {
9441
9952
  width: 12,
9442
9953
  height: 12,
@@ -9445,7 +9956,7 @@ function StackedBar({
9445
9956
  backgroundColor: chartColor(segment.color, c, index)
9446
9957
  }
9447
9958
  }),
9448
- import_react13.default.createElement("span", {
9959
+ import_react14.default.createElement("span", {
9449
9960
  style: { ...typeOf(c, "tiny"), color: c.textSecondary }
9450
9961
  }, `${segment.label} ${segment.valueLabel ?? formatChartValue(share, "percent")}`)
9451
9962
  );
@@ -9466,7 +9977,8 @@ function BarChart({
9466
9977
  showGrid = true,
9467
9978
  showValues = true,
9468
9979
  yAxisLabel,
9469
- footer
9980
+ footer,
9981
+ ...accessibility
9470
9982
  }) {
9471
9983
  const d = densityOf(c);
9472
9984
  const margin = { top: d.f(16), right: d.g(8), bottom: d.f(26), left: d.f(yAxisLabel ? 62 : 34) };
@@ -9486,23 +9998,26 @@ function BarChart({
9486
9998
  return { item, index, x, y, barHeight, valueY, color: chartColor(item.color, c, 0) };
9487
9999
  });
9488
10000
  return ChartFrame({
10001
+ ...accessibility,
10002
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Bar chart",
10003
+ description: chartDescription(accessibility.description, valueDescriptions(data, format)),
9489
10004
  c,
9490
10005
  title,
9491
10006
  subtitle,
9492
10007
  width,
9493
10008
  footer,
9494
- children: import_react13.default.createElement(
10009
+ children: import_react14.default.createElement(
9495
10010
  "div",
9496
10011
  { style: { position: "relative", width, height, display: "flex" } },
9497
- import_react13.default.createElement(
10012
+ import_react14.default.createElement(
9498
10013
  "svg",
9499
10014
  { width, height, viewBox: `0 0 ${width} ${height}` },
9500
- showGrid && import_react13.default.createElement(
10015
+ showGrid && import_react14.default.createElement(
9501
10016
  "g",
9502
10017
  {},
9503
10018
  ...ticks.map((tick) => {
9504
10019
  const y = yInPlot(tick, domain, plot);
9505
- return import_react13.default.createElement("line", {
10020
+ return import_react14.default.createElement("line", {
9506
10021
  key: `tick-${tick}`,
9507
10022
  x1: plot.x,
9508
10023
  y1: y,
@@ -9513,9 +10028,9 @@ function BarChart({
9513
10028
  });
9514
10029
  })
9515
10030
  ),
9516
- import_react13.default.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
10031
+ import_react14.default.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
9517
10032
  ...barGeometries.map(
9518
- ({ item, index, x, y, barHeight, color }) => import_react13.default.createElement("rect", {
10033
+ ({ item, index, x, y, barHeight, color }) => import_react14.default.createElement("rect", {
9519
10034
  key: `${item.label}-${index}`,
9520
10035
  x,
9521
10036
  y,
@@ -9558,7 +10073,8 @@ function ParetoBarChart({
9558
10073
  format = "integer",
9559
10074
  showGrid = true,
9560
10075
  showValues = true,
9561
- footer
10076
+ footer,
10077
+ ...accessibility
9562
10078
  }) {
9563
10079
  let total = 0;
9564
10080
  for (const item of data) {
@@ -9603,17 +10119,22 @@ function ParetoBarChart({
9603
10119
  });
9604
10120
  const cumulativePath = bars.map(({ centerX, cumulativeY }, index) => `${index === 0 ? "M" : "L"} ${centerX.toFixed(1)} ${cumulativeY.toFixed(1)}`).join(" ");
9605
10121
  return ChartFrame({
10122
+ ...accessibility,
10123
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pareto bar chart",
10124
+ description: chartDescription(accessibility.description, bars.map(
10125
+ ({ item, cumulative }) => `${item.label}: ${item.valueLabel ?? formatChartValue(item.value, format)}, cumulative ${formatChartValue(cumulative, "percent")}`
10126
+ )),
9606
10127
  c,
9607
10128
  title,
9608
10129
  subtitle,
9609
10130
  width,
9610
10131
  footer,
9611
- children: import_react13.default.createElement(
10132
+ children: import_react14.default.createElement(
9612
10133
  "div",
9613
10134
  {
9614
10135
  style: { position: "relative", width, height, display: "flex" }
9615
10136
  },
9616
- import_react13.default.createElement(
10137
+ import_react14.default.createElement(
9617
10138
  "svg",
9618
10139
  {
9619
10140
  width,
@@ -9622,12 +10143,12 @@ function ParetoBarChart({
9622
10143
  role: "img",
9623
10144
  "aria-label": title ?? "Pareto bar chart"
9624
10145
  },
9625
- showGrid && import_react13.default.createElement(
10146
+ showGrid && import_react14.default.createElement(
9626
10147
  "g",
9627
10148
  {},
9628
10149
  ...countTicks.map((tick) => {
9629
10150
  const y = yInPlot(tick, valueDomain, plot);
9630
- return import_react13.default.createElement("line", {
10151
+ return import_react14.default.createElement("line", {
9631
10152
  key: `pareto-count-grid-${tick}`,
9632
10153
  x1: plot.x,
9633
10154
  y1: y,
@@ -9638,7 +10159,7 @@ function ParetoBarChart({
9638
10159
  });
9639
10160
  })
9640
10161
  ),
9641
- import_react13.default.createElement("line", {
10162
+ import_react14.default.createElement("line", {
9642
10163
  x1: plot.x,
9643
10164
  y1: plot.bottom,
9644
10165
  x2: plot.right,
@@ -9646,7 +10167,7 @@ function ParetoBarChart({
9646
10167
  stroke: c.borderLight,
9647
10168
  strokeWidth: d.stroke.hair
9648
10169
  }),
9649
- ...bars.map(({ item, order, x, y, height: barHeight, color }) => import_react13.default.createElement("rect", {
10170
+ ...bars.map(({ item, order, x, y, height: barHeight, color }) => import_react14.default.createElement("rect", {
9650
10171
  key: `pareto-bar-${item.label}-${order}`,
9651
10172
  x,
9652
10173
  y,
@@ -9658,7 +10179,7 @@ function ParetoBarChart({
9658
10179
  "data-pareto-value": item.value,
9659
10180
  "data-pareto-order": order
9660
10181
  })),
9661
- cumulativePath && import_react13.default.createElement("path", {
10182
+ cumulativePath && import_react14.default.createElement("path", {
9662
10183
  d: cumulativePath,
9663
10184
  fill: "none",
9664
10185
  stroke: chartColor("critical", c),
@@ -9667,7 +10188,7 @@ function ParetoBarChart({
9667
10188
  strokeLinejoin: "round",
9668
10189
  "data-pareto-cumulative-line": true
9669
10190
  }),
9670
- ...bars.map(({ item, sourceIndex, centerX, cumulativeY, cumulative, order }) => import_react13.default.createElement("circle", {
10191
+ ...bars.map(({ item, sourceIndex, centerX, cumulativeY, cumulative, order }) => import_react14.default.createElement("circle", {
9671
10192
  key: `pareto-cumulative-point-${order}`,
9672
10193
  cx: centerX,
9673
10194
  cy: cumulativeY,
@@ -9733,7 +10254,8 @@ function LineChart({
9733
10254
  showPoints = true,
9734
10255
  directLabels,
9735
10256
  yAxisLabel,
9736
- footer
10257
+ footer,
10258
+ ...accessibility
9737
10259
  }) {
9738
10260
  const d = densityOf(c);
9739
10261
  const direct = directLabels ?? series.length > 1;
@@ -9758,24 +10280,29 @@ function LineChart({
9758
10280
  return `${index === 0 ? "M" : "L"} ${point.x.toFixed(1)} ${point.y.toFixed(1)}`;
9759
10281
  }).join(" ");
9760
10282
  return ChartFrame({
10283
+ ...accessibility,
10284
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Line chart",
10285
+ description: chartDescription(accessibility.description, series.map(
10286
+ (item) => `${item.name}: ${item.points.map((value, index) => `${labels?.[index] ?? `Point ${index + 1}`}: ${formatChartValue(value, format)}`).join(", ")}`
10287
+ )),
9761
10288
  c,
9762
10289
  title,
9763
10290
  subtitle,
9764
10291
  width,
9765
10292
  footer,
9766
10293
  ...direct ? {} : { legend: series.length > 1 ? series.map((item, index) => ({ label: item.name, color: item.color ?? chartPalette[index % chartPalette.length] })) : void 0 },
9767
- children: import_react13.default.createElement(
10294
+ children: import_react14.default.createElement(
9768
10295
  "div",
9769
10296
  { style: { position: "relative", width, height, display: "flex" } },
9770
- import_react13.default.createElement(
10297
+ import_react14.default.createElement(
9771
10298
  "svg",
9772
10299
  { width, height, viewBox: `0 0 ${width} ${height}` },
9773
- showGrid && import_react13.default.createElement(
10300
+ showGrid && import_react14.default.createElement(
9774
10301
  "g",
9775
10302
  {},
9776
10303
  ...ticks.map((tick) => {
9777
10304
  const y = yInPlot(tick, domain, plot);
9778
- return import_react13.default.createElement("line", {
10305
+ return import_react14.default.createElement("line", {
9779
10306
  key: `line-tick-${tick}`,
9780
10307
  x1: plot.x,
9781
10308
  y1: y,
@@ -9786,7 +10313,7 @@ function LineChart({
9786
10313
  });
9787
10314
  })
9788
10315
  ),
9789
- import_react13.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
10316
+ import_react14.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
9790
10317
  ...series.flatMap((item, seriesIndex) => {
9791
10318
  if (item.points.length === 0) return [];
9792
10319
  const color = chartColor(item.color, c, seriesIndex);
@@ -9799,9 +10326,9 @@ function LineChart({
9799
10326
  }
9800
10327
  const elements = [];
9801
10328
  if (areaPath) {
9802
- elements.push(import_react13.default.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.1 }));
10329
+ elements.push(import_react14.default.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.1 }));
9803
10330
  }
9804
- elements.push(import_react13.default.createElement("path", {
10331
+ elements.push(import_react14.default.createElement("path", {
9805
10332
  key: `${item.name}-line`,
9806
10333
  d: linePath,
9807
10334
  fill: "none",
@@ -9813,7 +10340,7 @@ function LineChart({
9813
10340
  if (showPoints) {
9814
10341
  elements.push(...item.points.map((value, index) => {
9815
10342
  const point = pointFor(value, index);
9816
- return import_react13.default.createElement("circle", {
10343
+ return import_react14.default.createElement("circle", {
9817
10344
  key: `${item.name}-point-${index}`,
9818
10345
  cx: point.x,
9819
10346
  cy: point.y,
@@ -9866,7 +10393,7 @@ for (const chart of [PieChart, DonutChart, StackedBar, BarChart, ParetoBarChart,
9866
10393
  }
9867
10394
 
9868
10395
  // src/primitives/plots.ts
9869
- var import_react14 = __toESM(require("react"), 1);
10396
+ var import_react15 = __toESM(require("react"), 1);
9870
10397
  for (const chart of [ScatterPlot, ParetoChart, QuadrantChart, IntervalPlot]) {
9871
10398
  Object.defineProperty(chart, CANVAS_CHART_COMPONENT, { value: true });
9872
10399
  }
@@ -9875,6 +10402,12 @@ function xTickLabelAlign(index, count) {
9875
10402
  if (index === count - 1) return "right";
9876
10403
  return "center";
9877
10404
  }
10405
+ function pointDescription(point, index, formatX, formatY, xLabel = "x", yLabel = "y") {
10406
+ return `${point.label ?? `Point ${index + 1}`}: ${xLabel} ${formatChartValue(point.x, formatX)}, ${yLabel} ${formatChartValue(point.y, formatY)}`;
10407
+ }
10408
+ function pointDescriptions(points, formatX, formatY, xLabel = "x", yLabel = "y") {
10409
+ return points.map((point, index) => pointDescription(point, index, formatX, formatY, xLabel, yLabel));
10410
+ }
9878
10411
  function ScatterPlot({
9879
10412
  points,
9880
10413
  c,
@@ -9891,7 +10424,8 @@ function ScatterPlot({
9891
10424
  formatX = "decimal",
9892
10425
  formatY = "decimal",
9893
10426
  showGrid = true,
9894
- footer
10427
+ footer,
10428
+ ...accessibility
9895
10429
  }) {
9896
10430
  const margin = { top: 20, right: 24, bottom: xAxisLabel ? 46 : 34, left: yAxisLabel ? 54 : 42 };
9897
10431
  const plot = createPlotArea(width, height, margin);
@@ -9908,23 +10442,26 @@ function ScatterPlot({
9908
10442
  return { item, index, point, color: chartColor(item.color, c, index) };
9909
10443
  });
9910
10444
  return ChartFrame({
10445
+ ...accessibility,
10446
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Scatter plot",
10447
+ description: chartDescription(accessibility.description, pointDescriptions(points, formatX, formatY, xAxisLabel, yAxisLabel)),
9911
10448
  c,
9912
10449
  title,
9913
10450
  subtitle,
9914
10451
  width,
9915
10452
  footer,
9916
- children: import_react14.default.createElement(
10453
+ children: import_react15.default.createElement(
9917
10454
  "div",
9918
10455
  { style: { position: "relative", width, height, display: "flex" } },
9919
- import_react14.default.createElement(
10456
+ import_react15.default.createElement(
9920
10457
  "svg",
9921
10458
  { width, height, viewBox: `0 0 ${width} ${height}` },
9922
- showGrid && import_react14.default.createElement(
10459
+ showGrid && import_react15.default.createElement(
9923
10460
  "g",
9924
10461
  {},
9925
10462
  ...xTicks.map((tick) => {
9926
10463
  const x = xInPlot(tick, xDomain, plot);
9927
- return import_react14.default.createElement("line", {
10464
+ return import_react15.default.createElement("line", {
9928
10465
  key: `x-tick-${tick}`,
9929
10466
  x1: x,
9930
10467
  y1: plot.y,
@@ -9936,7 +10473,7 @@ function ScatterPlot({
9936
10473
  }),
9937
10474
  ...yTicks.map((tick) => {
9938
10475
  const y = yInPlot(tick, yDomain, plot);
9939
- return import_react14.default.createElement("line", {
10476
+ return import_react15.default.createElement("line", {
9940
10477
  key: `y-tick-${tick}`,
9941
10478
  x1: plot.x,
9942
10479
  y1: y,
@@ -9947,9 +10484,9 @@ function ScatterPlot({
9947
10484
  });
9948
10485
  })
9949
10486
  ),
9950
- import_react14.default.createElement("rect", { x: plot.x, y: plot.y, width: plot.innerWidth, height: plot.innerHeight, fill: "transparent", stroke: c.borderLight, strokeWidth: 1.2, rx: 6 }),
10487
+ import_react15.default.createElement("rect", { x: plot.x, y: plot.y, width: plot.innerWidth, height: plot.innerHeight, fill: "transparent", stroke: c.borderLight, strokeWidth: 1.2, rx: 6 }),
9951
10488
  ...pointGeometries.map(
9952
- ({ item, index, point, color }) => import_react14.default.createElement("circle", {
10489
+ ({ item, index, point, color }) => import_react15.default.createElement("circle", {
9953
10490
  key: `${item.label ?? "point"}-${index}`,
9954
10491
  cx: point.x,
9955
10492
  cy: point.y,
@@ -10051,7 +10588,8 @@ function ParetoChart({
10051
10588
  frontierColor,
10052
10589
  showGoal = true,
10053
10590
  goalLabel,
10054
- footer
10591
+ footer,
10592
+ ...accessibility
10055
10593
  }) {
10056
10594
  const margin = { top: 22, right: 26, bottom: xAxisLabel ? 48 : 36, left: yAxisLabel ? 56 : 44 };
10057
10595
  const plot = createPlotArea(width, height, margin);
@@ -10091,6 +10629,15 @@ function ParetoChart({
10091
10629
  const goalYEnd = yObjective === "maximize" ? goalYStart - 26 : goalYStart + 26;
10092
10630
  const arrowSize = 5;
10093
10631
  return ChartFrame({
10632
+ ...accessibility,
10633
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pareto frontier",
10634
+ description: chartDescription(accessibility.description, [
10635
+ `${xObjective} ${xAxisLabel ?? "x"}, ${yObjective} ${yAxisLabel ?? "y"}`,
10636
+ ...pointGeometries.map(
10637
+ ({ point, index, frontier: frontier2 }) => `${pointDescription(point, index, formatX, formatY, xAxisLabel, yAxisLabel)}, ${frontier2 ? "on the Pareto frontier" : "dominated"}`
10638
+ ),
10639
+ ...pointGeometries.length ? [] : ["No points"]
10640
+ ]),
10094
10641
  c,
10095
10642
  title,
10096
10643
  subtitle,
@@ -10100,18 +10647,18 @@ function ParetoChart({
10100
10647
  { label: "Pareto frontier", color: frontier },
10101
10648
  { label: "dominated", color: "neutral" }
10102
10649
  ],
10103
- children: import_react14.default.createElement(
10650
+ children: import_react15.default.createElement(
10104
10651
  "div",
10105
10652
  { style: { position: "relative", width, height, display: "flex" } },
10106
- import_react14.default.createElement(
10653
+ import_react15.default.createElement(
10107
10654
  "svg",
10108
10655
  { width, height, viewBox: `0 0 ${width} ${height}` },
10109
- showGrid && import_react14.default.createElement(
10656
+ showGrid && import_react15.default.createElement(
10110
10657
  "g",
10111
10658
  {},
10112
10659
  ...xTicks.map((tick) => {
10113
10660
  const x = pointFor(tick, yDomain.min).x;
10114
- return import_react14.default.createElement("line", {
10661
+ return import_react15.default.createElement("line", {
10115
10662
  key: `pareto-x-grid-${tick}`,
10116
10663
  x1: x,
10117
10664
  y1: plot.y,
@@ -10123,7 +10670,7 @@ function ParetoChart({
10123
10670
  }),
10124
10671
  ...yTicks.map((tick) => {
10125
10672
  const y = yInPlot(tick, yDomain, plot);
10126
- return import_react14.default.createElement("line", {
10673
+ return import_react15.default.createElement("line", {
10127
10674
  key: `pareto-y-grid-${tick}`,
10128
10675
  x1: plot.x,
10129
10676
  y1: y,
@@ -10134,7 +10681,7 @@ function ParetoChart({
10134
10681
  });
10135
10682
  })
10136
10683
  ),
10137
- import_react14.default.createElement("rect", {
10684
+ import_react15.default.createElement("rect", {
10138
10685
  x: plot.x,
10139
10686
  y: plot.y,
10140
10687
  width: plot.innerWidth,
@@ -10144,17 +10691,17 @@ function ParetoChart({
10144
10691
  strokeWidth: 1.2,
10145
10692
  rx: 6
10146
10693
  }),
10147
- showGoal && import_react14.default.createElement(
10694
+ showGoal && import_react15.default.createElement(
10148
10695
  "g",
10149
10696
  { "data-pareto-goal": true, stroke: frontier, fill: "none", strokeWidth: 2, strokeLinecap: "round" },
10150
- import_react14.default.createElement("line", { x1: goalXStart, y1: goalY, x2: goalXEnd, y2: goalY }),
10151
- import_react14.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY - arrowSize }),
10152
- import_react14.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY + arrowSize }),
10153
- import_react14.default.createElement("line", { x1: goalXStart, y1: goalYStart, x2: goalXStart, y2: goalYEnd }),
10154
- import_react14.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart - arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) }),
10155
- import_react14.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart + arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) })
10697
+ import_react15.default.createElement("line", { x1: goalXStart, y1: goalY, x2: goalXEnd, y2: goalY }),
10698
+ import_react15.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY - arrowSize }),
10699
+ import_react15.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY + arrowSize }),
10700
+ import_react15.default.createElement("line", { x1: goalXStart, y1: goalYStart, x2: goalXStart, y2: goalYEnd }),
10701
+ import_react15.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart - arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) }),
10702
+ import_react15.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart + arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) })
10156
10703
  ),
10157
- frontierPath && import_react14.default.createElement("path", {
10704
+ frontierPath && import_react15.default.createElement("path", {
10158
10705
  "data-pareto-frontier": true,
10159
10706
  d: frontierPath,
10160
10707
  fill: "none",
@@ -10163,7 +10710,7 @@ function ParetoChart({
10163
10710
  strokeLinecap: "round",
10164
10711
  strokeLinejoin: "round"
10165
10712
  }),
10166
- ...pointGeometries.filter((geometry) => !geometry.frontier).concat(pointGeometries.filter((geometry) => geometry.frontier)).map(({ point, index, x, y, color, frontier: isFrontier }) => import_react14.default.createElement("circle", {
10713
+ ...pointGeometries.filter((geometry) => !geometry.frontier).concat(pointGeometries.filter((geometry) => geometry.frontier)).map(({ point, index, x, y, color, frontier: isFrontier }) => import_react15.default.createElement("circle", {
10167
10714
  key: `pareto-point-${point.label ?? "point"}-${index}`,
10168
10715
  "data-pareto-status": isFrontier ? "frontier" : "dominated",
10169
10716
  cx: x,
@@ -10239,7 +10786,8 @@ function QuadrantChart({
10239
10786
  formatY = "decimal",
10240
10787
  showTicks = false,
10241
10788
  showGrid = false,
10242
- footer
10789
+ footer,
10790
+ ...accessibility
10243
10791
  }) {
10244
10792
  const margin = {
10245
10793
  top: 18,
@@ -10270,23 +10818,31 @@ function QuadrantChart({
10270
10818
  color: chartColor(point.color, c, index)
10271
10819
  }));
10272
10820
  return ChartFrame({
10821
+ ...accessibility,
10822
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Quadrant chart",
10823
+ description: chartDescription(accessibility.description, [
10824
+ `Thresholds: ${xAxisLabel ?? "x"} ${formatChartValue(resolvedXThreshold, formatX)}, ${yAxisLabel ?? "y"} ${formatChartValue(resolvedYThreshold, formatY)}`,
10825
+ ...regionEntries.map(({ key, region }) => `${key}: ${region.label}`),
10826
+ ...pointDescriptions(points, formatX, formatY, xAxisLabel, yAxisLabel),
10827
+ ...points.length ? [] : ["No points"]
10828
+ ]),
10273
10829
  c,
10274
10830
  title,
10275
10831
  subtitle,
10276
10832
  width,
10277
10833
  footer,
10278
- children: import_react14.default.createElement(
10834
+ children: import_react15.default.createElement(
10279
10835
  "div",
10280
10836
  {
10281
10837
  style: { position: "relative", width, height, display: "flex" }
10282
10838
  },
10283
- import_react14.default.createElement(
10839
+ import_react15.default.createElement(
10284
10840
  "svg",
10285
10841
  { width, height, viewBox: `0 0 ${width} ${height}` },
10286
10842
  ...regionEntries.map(({ key, region, x, y, width: regionWidth, height: regionHeight }, index) => {
10287
10843
  const color = chartColor(region.color, c, index);
10288
10844
  const emphasized = region.emphasis === true;
10289
- return import_react14.default.createElement("rect", {
10845
+ return import_react15.default.createElement("rect", {
10290
10846
  key: `quadrant-${key}`,
10291
10847
  x,
10292
10848
  y,
@@ -10298,12 +10854,12 @@ function QuadrantChart({
10298
10854
  strokeWidth: emphasized ? 2 : 0
10299
10855
  });
10300
10856
  }),
10301
- showGrid && import_react14.default.createElement(
10857
+ showGrid && import_react15.default.createElement(
10302
10858
  "g",
10303
10859
  {},
10304
10860
  ...xTicks.map((tick) => {
10305
10861
  const x = xInPlot(tick, xDomain, plot);
10306
- return import_react14.default.createElement("line", {
10862
+ return import_react15.default.createElement("line", {
10307
10863
  key: `quadrant-x-grid-${tick}`,
10308
10864
  x1: x,
10309
10865
  y1: plot.y,
@@ -10315,7 +10871,7 @@ function QuadrantChart({
10315
10871
  }),
10316
10872
  ...yTicks.map((tick) => {
10317
10873
  const y = yInPlot(tick, yDomain, plot);
10318
- return import_react14.default.createElement("line", {
10874
+ return import_react15.default.createElement("line", {
10319
10875
  key: `quadrant-y-grid-${tick}`,
10320
10876
  x1: plot.x,
10321
10877
  y1: y,
@@ -10326,7 +10882,7 @@ function QuadrantChart({
10326
10882
  });
10327
10883
  })
10328
10884
  ),
10329
- import_react14.default.createElement("rect", {
10885
+ import_react15.default.createElement("rect", {
10330
10886
  x: plot.x,
10331
10887
  y: plot.y,
10332
10888
  width: plot.innerWidth,
@@ -10336,7 +10892,7 @@ function QuadrantChart({
10336
10892
  strokeWidth: 1.2,
10337
10893
  rx: 8
10338
10894
  }),
10339
- import_react14.default.createElement("line", {
10895
+ import_react15.default.createElement("line", {
10340
10896
  x1: midX,
10341
10897
  y1: plot.y,
10342
10898
  x2: midX,
@@ -10344,7 +10900,7 @@ function QuadrantChart({
10344
10900
  stroke: c.borderLight,
10345
10901
  strokeWidth: 1.4
10346
10902
  }),
10347
- import_react14.default.createElement("line", {
10903
+ import_react15.default.createElement("line", {
10348
10904
  x1: plot.x,
10349
10905
  y1: midY,
10350
10906
  x2: plot.right,
@@ -10354,7 +10910,7 @@ function QuadrantChart({
10354
10910
  }),
10355
10911
  ...(showTicks ? xTicks : []).map((tick) => {
10356
10912
  const x = xInPlot(tick, xDomain, plot);
10357
- return import_react14.default.createElement("line", {
10913
+ return import_react15.default.createElement("line", {
10358
10914
  key: `quadrant-x-tick-${tick}`,
10359
10915
  x1: x,
10360
10916
  y1: plot.bottom,
@@ -10366,7 +10922,7 @@ function QuadrantChart({
10366
10922
  }),
10367
10923
  ...(showTicks ? yTicks : []).map((tick) => {
10368
10924
  const y = yInPlot(tick, yDomain, plot);
10369
- return import_react14.default.createElement("line", {
10925
+ return import_react15.default.createElement("line", {
10370
10926
  key: `quadrant-y-tick-${tick}`,
10371
10927
  x1: plot.x - 5,
10372
10928
  y1: y,
@@ -10376,7 +10932,7 @@ function QuadrantChart({
10376
10932
  strokeWidth: 1.2
10377
10933
  });
10378
10934
  }),
10379
- ...pointGeometries.map(({ point, index, x, y, color }) => import_react14.default.createElement("circle", {
10935
+ ...pointGeometries.map(({ point, index, x, y, color }) => import_react15.default.createElement("circle", {
10380
10936
  key: `quadrant-point-${point.label ?? index}`,
10381
10937
  cx: x,
10382
10938
  cy: y,
@@ -10452,7 +11008,8 @@ function IntervalPlot({
10452
11008
  max,
10453
11009
  format = "decimal",
10454
11010
  axisLabel,
10455
- footer
11011
+ footer,
11012
+ ...accessibility
10456
11013
  }) {
10457
11014
  const margin = { top: 22, right: 28, bottom: axisLabel ? 44 : 30, left: 96 };
10458
11015
  const plot = createPlotArea(width, height, margin);
@@ -10473,20 +11030,25 @@ function IntervalPlot({
10473
11030
  };
10474
11031
  });
10475
11032
  return ChartFrame({
11033
+ ...accessibility,
11034
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Interval plot",
11035
+ description: chartDescription(accessibility.description, data.map(
11036
+ (item) => `${item.label}: low ${item.lowLabel ?? formatChartValue(item.low, format)}, midpoint ${item.midLabel ?? formatChartValue(item.mid, format)}, high ${item.highLabel ?? formatChartValue(item.high, format)}`
11037
+ )),
10476
11038
  c,
10477
11039
  title,
10478
11040
  subtitle,
10479
11041
  width,
10480
11042
  footer,
10481
- children: import_react14.default.createElement(
11043
+ children: import_react15.default.createElement(
10482
11044
  "div",
10483
11045
  { style: { position: "relative", width, height, display: "flex" } },
10484
- import_react14.default.createElement(
11046
+ import_react15.default.createElement(
10485
11047
  "svg",
10486
11048
  { width, height, viewBox: `0 0 ${width} ${height}` },
10487
11049
  ...ticks.map((tick) => {
10488
11050
  const x = scaleX(tick);
10489
- return import_react14.default.createElement("line", {
11051
+ return import_react15.default.createElement("line", {
10490
11052
  key: `interval-tick-${tick}`,
10491
11053
  x1: x,
10492
11054
  y1: plot.y,
@@ -10496,10 +11058,10 @@ function IntervalPlot({
10496
11058
  strokeWidth: 1
10497
11059
  });
10498
11060
  }),
10499
- import_react14.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
11061
+ import_react15.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
10500
11062
  ...rows.flatMap(({ item, index, y, color, lowX, midX, highX }) => [
10501
- import_react14.default.createElement("line", { key: `${item.label}-range-${index}`, x1: lowX, y1: y, x2: highX, y2: y, stroke: color, strokeWidth: 9, strokeLinecap: "round", opacity: 0.9 }),
10502
- import_react14.default.createElement("circle", { key: `${item.label}-mid-${index}`, cx: midX, cy: y, r: 10, fill: c.bgCard, stroke: color, strokeWidth: 4 })
11063
+ import_react15.default.createElement("line", { key: `${item.label}-range-${index}`, x1: lowX, y1: y, x2: highX, y2: y, stroke: color, strokeWidth: 9, strokeLinecap: "round", opacity: 0.9 }),
11064
+ import_react15.default.createElement("circle", { key: `${item.label}-mid-${index}`, cx: midX, cy: y, r: 10, fill: c.bgCard, stroke: color, strokeWidth: 4 })
10503
11065
  ])
10504
11066
  ),
10505
11067
  ...ticks.map((tick, index) => {
@@ -10536,7 +11098,7 @@ function IntervalPlot({
10536
11098
  }
10537
11099
  function Badge({ label, c, color = "primary" }) {
10538
11100
  const solidColor = getReadableColor(color, c);
10539
- return import_react14.default.createElement("div", {
11101
+ return import_react15.default.createElement("div", {
10540
11102
  style: {
10541
11103
  display: "flex",
10542
11104
  alignItems: "center",
@@ -10557,7 +11119,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
10557
11119
  const offY = labelOffset?.y ?? -22;
10558
11120
  return [
10559
11121
  // Dot
10560
- import_react14.default.createElement("div", {
11122
+ import_react15.default.createElement("div", {
10561
11123
  key: `dot-${label}`,
10562
11124
  style: {
10563
11125
  position: "absolute",
@@ -10572,7 +11134,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
10572
11134
  }
10573
11135
  }),
10574
11136
  // Label
10575
- import_react14.default.createElement("div", {
11137
+ import_react15.default.createElement("div", {
10576
11138
  key: `label-${label}`,
10577
11139
  style: {
10578
11140
  position: "absolute",
@@ -10598,7 +11160,7 @@ function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
10598
11160
  if (i % 2 === 1) continue;
10599
11161
  const t = i / numDots;
10600
11162
  dots.push(
10601
- import_react14.default.createElement("div", {
11163
+ import_react15.default.createElement("div", {
10602
11164
  key: `dash-${i}`,
10603
11165
  style: {
10604
11166
  position: "absolute",
@@ -10615,7 +11177,7 @@ function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
10615
11177
  return dots;
10616
11178
  }
10617
11179
  function Legend({ items, c, title }) {
10618
- return import_react14.default.createElement(
11180
+ return import_react15.default.createElement(
10619
11181
  "div",
10620
11182
  {
10621
11183
  style: {
@@ -10628,7 +11190,7 @@ function Legend({ items, c, title }) {
10628
11190
  padding: `${densityOf(c).s(14)}px ${densityOf(c).s(16)}px`
10629
11191
  }
10630
11192
  },
10631
- title && import_react14.default.createElement("div", {
11193
+ title && import_react15.default.createElement("div", {
10632
11194
  style: {
10633
11195
  fontSize: densityOf(c).f(11),
10634
11196
  fontWeight: 700,
@@ -10639,13 +11201,13 @@ function Legend({ items, c, title }) {
10639
11201
  }
10640
11202
  }, title),
10641
11203
  ...items.map(
10642
- (item, i) => import_react14.default.createElement(
11204
+ (item, i) => import_react15.default.createElement(
10643
11205
  "div",
10644
11206
  {
10645
11207
  key: `legend-${i}`,
10646
11208
  style: { display: "flex", alignItems: "center", gap: 8 }
10647
11209
  },
10648
- import_react14.default.createElement("div", {
11210
+ import_react15.default.createElement("div", {
10649
11211
  style: {
10650
11212
  width: 16,
10651
11213
  height: item.style === "dashed" ? 0 : 2,
@@ -10655,7 +11217,7 @@ function Legend({ items, c, title }) {
10655
11217
  } : {}
10656
11218
  }
10657
11219
  }),
10658
- import_react14.default.createElement("div", {
11220
+ import_react15.default.createElement("div", {
10659
11221
  style: {
10660
11222
  fontSize: densityOf(c).f(11),
10661
11223
  color: c.textMuted,
@@ -10668,7 +11230,7 @@ function Legend({ items, c, title }) {
10668
11230
  }
10669
11231
 
10670
11232
  // src/primitives/board.ts
10671
- var import_react15 = __toESM(require("react"), 1);
11233
+ var import_react16 = __toESM(require("react"), 1);
10672
11234
  var CANVAS_ITEM_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.canvas-item");
10673
11235
  function dimension(value, name) {
10674
11236
  if (value !== void 0 && (!Number.isFinite(value) || value <= 0 || value > 8192)) {
@@ -10677,7 +11239,7 @@ function dimension(value, name) {
10677
11239
  return value;
10678
11240
  }
10679
11241
  function Board({ children, c, width = 960, height = 540, background }) {
10680
- return import_react15.default.createElement("div", { style: {
11242
+ return import_react16.default.createElement("div", { style: {
10681
11243
  display: "flex",
10682
11244
  position: "relative",
10683
11245
  width: dimension(width, "Board width"),
@@ -10689,15 +11251,15 @@ function Board({ children, c, width = 960, height = 540, background }) {
10689
11251
  }
10690
11252
  function CanvasItem({ children, x, y, width, height }) {
10691
11253
  if (!Number.isFinite(x) || !Number.isFinite(y)) throw new Error("CanvasItem x and y must be finite numbers.");
10692
- const sizedChildren = import_react15.default.Children.map(children, (child) => {
10693
- if (!import_react15.default.isValidElement(child)) return child;
11254
+ const sizedChildren = import_react16.default.Children.map(children, (child) => {
11255
+ if (!import_react16.default.isValidElement(child)) return child;
10694
11256
  if (width !== void 0 && height !== void 0 && isCanvasChart(child.type)) {
10695
- const chart = import_react15.default.cloneElement(child, { width: child.props.width ?? width, height: child.props.height ?? height });
10696
- return import_react15.default.createElement(CanvasChartFit, { width, height, __vizmaticTextScope: child.props.__vizmaticTextScope }, chart);
11257
+ const chart = import_react16.default.cloneElement(child, { width: child.props.width ?? width, height: child.props.height ?? height });
11258
+ return import_react16.default.createElement(CanvasChartFit, { width, height, __vizmaticTextScope: child.props.__vizmaticTextScope }, chart);
10697
11259
  }
10698
- return import_react15.default.cloneElement(child, { ...width !== void 0 ? { width } : {}, ...height !== void 0 ? { height } : {} });
11260
+ return import_react16.default.cloneElement(child, { ...width !== void 0 ? { width } : {}, ...height !== void 0 ? { height } : {} });
10699
11261
  });
10700
- return import_react15.default.createElement("div", { style: {
11262
+ return import_react16.default.createElement("div", { style: {
10701
11263
  display: "flex",
10702
11264
  position: "absolute",
10703
11265
  left: x,
@@ -10710,14 +11272,14 @@ function CanvasItem({ children, x, y, width, height }) {
10710
11272
  Object.defineProperty(CanvasItem, CANVAS_ITEM_COMPONENT, { value: true });
10711
11273
 
10712
11274
  // src/primitives/science-math-physics.ts
10713
- var import_react16 = __toESM(require("react"), 1);
11275
+ var import_react17 = __toESM(require("react"), 1);
10714
11276
  var MAX_SVG_SIZE = 4096;
10715
11277
  var FONT_SIZE = 13;
10716
11278
  function finite(value, name) {
10717
11279
  if (!Number.isFinite(value)) throw new TypeError(`${name} must be finite.`);
10718
11280
  return value;
10719
11281
  }
10720
- function positive(value, name) {
11282
+ function positive2(value, name) {
10721
11283
  finite(value, name);
10722
11284
  if (value <= 0) throw new RangeError(`${name} must be greater than zero.`);
10723
11285
  return value;
@@ -10782,14 +11344,14 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
10782
11344
  const d = densityOf(c);
10783
11345
  const overlays = [];
10784
11346
  const svgChildren = [
10785
- import_react16.default.createElement("title", { key: "title" }, title),
10786
- import_react16.default.createElement("desc", { key: "description" }, description)
11347
+ import_react17.default.createElement("title", { key: "title" }, title),
11348
+ import_react17.default.createElement("desc", { key: "description" }, description)
10787
11349
  ];
10788
11350
  for (const [index, child] of children.entries()) {
10789
- if (import_react16.default.isValidElement(child) && child.type === "text") {
11351
+ if (import_react17.default.isValidElement(child) && child.type === "text") {
10790
11352
  const textProps = child.props;
10791
- const text = import_react16.default.Children.toArray(textProps.children).map((part) => String(part)).join("");
10792
- overlays.push(import_react16.default.createElement(SvgMathText, {
11353
+ const text = import_react17.default.Children.toArray(textProps.children).map((part) => String(part)).join("");
11354
+ overlays.push(import_react17.default.createElement(SvgMathText, {
10793
11355
  key: `label-${index}`,
10794
11356
  text,
10795
11357
  x: textProps.x,
@@ -10806,7 +11368,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
10806
11368
  }
10807
11369
  }
10808
11370
  if (!UNNAMED_TITLES.has(title)) {
10809
- overlays.unshift(import_react16.default.createElement(SvgMathText, {
11371
+ overlays.unshift(import_react17.default.createElement(SvgMathText, {
10810
11372
  key: "diagram-title",
10811
11373
  text: title,
10812
11374
  x: 0,
@@ -10819,7 +11381,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
10819
11381
  dominantBaseline: "auto"
10820
11382
  }));
10821
11383
  }
10822
- return import_react16.default.createElement(
11384
+ return import_react17.default.createElement(
10823
11385
  "div",
10824
11386
  {
10825
11387
  role: "img",
@@ -10827,7 +11389,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
10827
11389
  "aria-description": description,
10828
11390
  style: { position: "relative", width, height, display: "flex", flexShrink: 0 }
10829
11391
  },
10830
- import_react16.default.createElement("svg", {
11392
+ import_react17.default.createElement("svg", {
10831
11393
  width,
10832
11394
  height,
10833
11395
  viewBox: `0 0 ${width} ${height}`,
@@ -10848,7 +11410,7 @@ function mapNumberLine(value, min, max, width, padding = 56) {
10848
11410
  finite(width, "NumberLine width");
10849
11411
  finite(padding, "NumberLine padding");
10850
11412
  if (padding < 0) throw new RangeError("NumberLine padding cannot be negative.");
10851
- positive(width - padding * 2, "NumberLine drawable width");
11413
+ positive2(width - padding * 2, "NumberLine drawable width");
10852
11414
  if (value < min || value > max) throw new RangeError("NumberLine value must lie within its domain.");
10853
11415
  return padding + (value - min) / range * (width - padding * 2);
10854
11416
  }
@@ -10901,9 +11463,9 @@ function NumberLine({
10901
11463
  const x = (value) => mapNumberLine(value, min, max, width);
10902
11464
  const axisY = Math.round(height * (interval && height < 220 ? 0.45 : 0.56));
10903
11465
  const elements = [
10904
- import_react16.default.createElement("line", { key: "axis", x1: 56, y1: axisY, x2: width - 56, y2: axisY, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
10905
- import_react16.default.createElement("path", { key: "left-arrow", d: `M 56 ${axisY} l 9 -5 v 10 z`, fill: c.textSecondary }),
10906
- import_react16.default.createElement("path", { key: "right-arrow", d: `M ${width - 56} ${axisY} l -9 -5 v 10 z`, fill: c.textSecondary })
11466
+ import_react17.default.createElement("line", { key: "axis", x1: 56, y1: axisY, x2: width - 56, y2: axisY, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
11467
+ import_react17.default.createElement("path", { key: "left-arrow", d: `M 56 ${axisY} l 9 -5 v 10 z`, fill: c.textSecondary }),
11468
+ import_react17.default.createElement("path", { key: "right-arrow", d: `M ${width - 56} ${axisY} l -9 -5 v 10 z`, fill: c.textSecondary })
10907
11469
  ];
10908
11470
  if (interval) {
10909
11471
  const fromX = x(interval.from);
@@ -10913,21 +11475,21 @@ function NumberLine({
10913
11475
  const includeTo = interval.includeTo !== false;
10914
11476
  const intervalY = axisY + 52;
10915
11477
  elements.push(
10916
- import_react16.default.createElement("line", { key: "interval", x1: fromX, y1: intervalY, x2: toX, y2: intervalY, stroke: color, strokeWidth: densityOf(c).w(8), strokeLinecap: "round", opacity: 0.62 }),
10917
- import_react16.default.createElement("circle", { key: "interval-from", cx: fromX, cy: intervalY, r: 7, fill: includeFrom ? color : c.bgSubtle, stroke: color, strokeWidth: densityOf(c).w(3) }),
10918
- import_react16.default.createElement("circle", { key: "interval-to", cx: toX, cy: intervalY, r: 7, fill: includeTo ? color : c.bgSubtle, stroke: color, strokeWidth: densityOf(c).w(3) })
11478
+ import_react17.default.createElement("line", { key: "interval", x1: fromX, y1: intervalY, x2: toX, y2: intervalY, stroke: color, strokeWidth: densityOf(c).w(8), strokeLinecap: "round", opacity: 0.62 }),
11479
+ import_react17.default.createElement("circle", { key: "interval-from", cx: fromX, cy: intervalY, r: 7, fill: includeFrom ? color : c.bgSubtle, stroke: color, strokeWidth: densityOf(c).w(3) }),
11480
+ import_react17.default.createElement("circle", { key: "interval-to", cx: toX, cy: intervalY, r: 7, fill: includeTo ? color : c.bgSubtle, stroke: color, strokeWidth: densityOf(c).w(3) })
10919
11481
  );
10920
11482
  if (interval.label) {
10921
11483
  const label = interval.label;
10922
11484
  const labelX = clamp2((fromX + toX) / 2, 56 + textWidth(label) / 2, width - 56 - textWidth(label) / 2);
10923
- elements.push(import_react16.default.createElement("text", { key: "interval-label", x: labelX, y: axisY + 82, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: FONT_SIZE }, label));
11485
+ elements.push(import_react17.default.createElement("text", { key: "interval-label", x: labelX, y: axisY + 82, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: FONT_SIZE }, label));
10924
11486
  }
10925
11487
  }
10926
11488
  for (const [index, tick] of resolvedTicks.entries()) {
10927
11489
  const tickX = x(tick.value);
10928
11490
  elements.push(
10929
- import_react16.default.createElement("line", { key: `tick-${index}`, x1: tickX, y1: axisY - 9, x2: tickX, y2: axisY + 9, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
10930
- import_react16.default.createElement("text", { key: `tick-label-${index}`, x: tickX, y: axisY + 34, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, tick.label ?? formatNumber(tick.value))
11491
+ import_react17.default.createElement("line", { key: `tick-${index}`, x1: tickX, y1: axisY - 9, x2: tickX, y2: axisY + 9, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
11492
+ import_react17.default.createElement("text", { key: `tick-label-${index}`, x: tickX, y: axisY + 34, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, tick.label ?? formatNumber(tick.value))
10931
11493
  );
10932
11494
  }
10933
11495
  markers.forEach((marker, index) => {
@@ -10937,9 +11499,9 @@ function NumberLine({
10937
11499
  const labelY = Math.max(66, axisY - 54 - lane * 30);
10938
11500
  const labelX = clamp2(markerX, 56 + textWidth(marker.label, 12) / 2, width - 56 - textWidth(marker.label, 12) / 2);
10939
11501
  elements.push(
10940
- import_react16.default.createElement("line", { key: `marker-line-${marker.id}`, x1: markerX, y1: axisY - 4, x2: markerX, y2: labelY + 7, stroke: color, strokeWidth: densityOf(c).w(1.5), strokeDasharray: "4 4", opacity: 0.8 }),
10941
- import_react16.default.createElement("circle", { key: `marker-point-${marker.id}`, cx: markerX, cy: axisY, r: 7, fill: color, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }),
10942
- import_react16.default.createElement("text", { key: `marker-label-${marker.id}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 650 }, marker.label)
11502
+ import_react17.default.createElement("line", { key: `marker-line-${marker.id}`, x1: markerX, y1: axisY - 4, x2: markerX, y2: labelY + 7, stroke: color, strokeWidth: densityOf(c).w(1.5), strokeDasharray: "4 4", opacity: 0.8 }),
11503
+ import_react17.default.createElement("circle", { key: `marker-point-${marker.id}`, cx: markerX, cy: axisY, r: 7, fill: color, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }),
11504
+ import_react17.default.createElement("text", { key: `marker-label-${marker.id}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 650 }, marker.label)
10943
11505
  );
10944
11506
  });
10945
11507
  const intervalDescription = interval ? ` The highlighted interval is ${interval.includeFrom === false ? "(" : "["}${formatNumber(interval.from)}, ${formatNumber(interval.to)}${interval.includeTo === false ? ")" : "]"}${interval.label ? `, labeled ${interval.label}` : ""}.` : "";
@@ -11014,7 +11576,7 @@ function GeometryDiagram({
11014
11576
  }
11015
11577
  if (angle.label !== void 0) labelText(angle.label, `GeometryDiagram angle ${index} label`, 32);
11016
11578
  if (angle.radius !== void 0) {
11017
- positive(angle.radius, `GeometryDiagram angle ${index} radius`);
11579
+ positive2(angle.radius, `GeometryDiagram angle ${index} radius`);
11018
11580
  if (angle.radius > 120) throw new RangeError(`GeometryDiagram angle ${index} radius cannot exceed 120 pixels.`);
11019
11581
  }
11020
11582
  colorValue(angle.color, c.accent, `GeometryDiagram angle ${index} color`);
@@ -11044,7 +11606,7 @@ function GeometryDiagram({
11044
11606
  const from = map(pointById.get(segment.from));
11045
11607
  const to = map(pointById.get(segment.to));
11046
11608
  const color = colorValue(segment.color, c.secondary, `GeometryDiagram segment ${index} color`);
11047
- elements.push(import_react16.default.createElement("line", {
11609
+ elements.push(import_react17.default.createElement("line", {
11048
11610
  key: `segment-${index}`,
11049
11611
  x1: from.x,
11050
11612
  y1: from.y,
@@ -11067,7 +11629,7 @@ function GeometryDiagram({
11067
11629
  const clearance = 8 + Math.abs(normalX) * halfWidth + Math.abs(normalY) * FONT_SIZE * 0.45;
11068
11630
  const labelX = clamp2(midX + normalX * clearance, 24 + halfWidth, width - 24 - halfWidth);
11069
11631
  const labelY = clamp2(midY + normalY * clearance + FONT_SIZE * 0.35, 58, height - 22);
11070
- elements.push(import_react16.default.createElement("text", { key: `segment-label-${index}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: FONT_SIZE }, segment.label));
11632
+ elements.push(import_react17.default.createElement("text", { key: `segment-label-${index}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: FONT_SIZE }, segment.label));
11071
11633
  }
11072
11634
  });
11073
11635
  angles.forEach((angle, index) => {
@@ -11086,17 +11648,17 @@ function GeometryDiagram({
11086
11648
  });
11087
11649
  const path = arc.map((point, part) => `${part === 0 ? "M" : "L"} ${point.x.toFixed(2)} ${point.y.toFixed(2)}`).join(" ");
11088
11650
  const color = colorValue(angle.color, c.accent, `GeometryDiagram angle ${index} color`);
11089
- elements.push(import_react16.default.createElement("path", { key: `angle-${index}`, d: path, fill: "none", stroke: color, strokeWidth: densityOf(c).w(2.5), strokeLinecap: "round" }));
11651
+ elements.push(import_react17.default.createElement("path", { key: `angle-${index}`, d: path, fill: "none", stroke: color, strokeWidth: densityOf(c).w(2.5), strokeLinecap: "round" }));
11090
11652
  if (angle.label) {
11091
11653
  const middle = a1 + delta / 2;
11092
11654
  const labelX = clamp2(v.x + (radius + 18) * Math.cos(middle), 28 + textWidth(angle.label) / 2, width - 28 - textWidth(angle.label) / 2);
11093
11655
  const labelY = clamp2(v.y - (radius + 18) * Math.sin(middle) + 4, 58, height - 20);
11094
- elements.push(import_react16.default.createElement("text", { key: `angle-label-${index}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 650 }, angle.label));
11656
+ elements.push(import_react17.default.createElement("text", { key: `angle-label-${index}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 650 }, angle.label));
11095
11657
  }
11096
11658
  });
11097
11659
  points.forEach((point) => {
11098
11660
  const position2 = map(point);
11099
- elements.push(import_react16.default.createElement("circle", { key: `point-${point.id}`, cx: position2.x, cy: position2.y, r: 5.5, fill: c.primary, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }));
11661
+ elements.push(import_react17.default.createElement("circle", { key: `point-${point.id}`, cx: position2.x, cy: position2.y, r: 5.5, fill: c.primary, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }));
11100
11662
  if (point.label) {
11101
11663
  const label = point.label;
11102
11664
  const labelWidth = textWidth(label);
@@ -11105,7 +11667,7 @@ function GeometryDiagram({
11105
11667
  const baseX = position2.x + (placeRight ? 12 : -12);
11106
11668
  const labelX = boundedTextX(baseX, width, label, placeRight ? "start" : "end");
11107
11669
  const labelY = clamp2(awayY > 0 ? position2.y + FONT_SIZE + 6 : position2.y - 10, 58, height - 20);
11108
- elements.push(import_react16.default.createElement("text", {
11670
+ elements.push(import_react17.default.createElement("text", {
11109
11671
  key: `point-label-${point.id}`,
11110
11672
  x: labelX,
11111
11673
  y: labelY,
@@ -11165,9 +11727,9 @@ function FreeBodyDiagram({
11165
11727
  if (!Number.isFinite(scale) || scale <= 0) throw new RangeError("FreeBodyDiagram vector magnitudes cannot be mapped into the viewport.");
11166
11728
  const mapVector = (x, y) => ({ x: center2.x + x * scale, y: center2.y - y * scale });
11167
11729
  const elements = [
11168
- import_react16.default.createElement("line", { key: "x-axis", x1: center2.x - available - 28, y1: center2.y, x2: center2.x + available + 28, y2: center2.y, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1.3) }),
11169
- import_react16.default.createElement("line", { key: "y-axis", x1: center2.x, y1: center2.y - available - 28, x2: center2.x, y2: center2.y + available + 28, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1.3) }),
11170
- import_react16.default.createElement("circle", { key: "body", cx: center2.x, cy: center2.y, r: 6, fill: c.bgCard, stroke: c.textPrimary, strokeWidth: densityOf(c).w(2) })
11730
+ import_react17.default.createElement("line", { key: "x-axis", x1: center2.x - available - 28, y1: center2.y, x2: center2.x + available + 28, y2: center2.y, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1.3) }),
11731
+ import_react17.default.createElement("line", { key: "y-axis", x1: center2.x, y1: center2.y - available - 28, x2: center2.x, y2: center2.y + available + 28, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1.3) }),
11732
+ import_react17.default.createElement("circle", { key: "body", cx: center2.x, cy: center2.y, r: 6, fill: c.bgCard, stroke: c.textPrimary, strokeWidth: densityOf(c).w(2) })
11171
11733
  ];
11172
11734
  forces.forEach((force) => {
11173
11735
  const color = colorValue(force.color, c.secondary, `FreeBodyDiagram force "${force.id}" color`);
@@ -11175,15 +11737,15 @@ function FreeBodyDiagram({
11175
11737
  if (showComponents) {
11176
11738
  const xEnd = mapVector(force.x, 0);
11177
11739
  const yStart = mapVector(force.x, 0);
11178
- if (force.x !== 0) elements.push(import_react16.default.createElement("line", { key: `component-x-${force.id}`, x1: center2.x, y1: center2.y, x2: xEnd.x, y2: xEnd.y, stroke: color, strokeWidth: densityOf(c).w(1.6), strokeDasharray: "5 5", opacity: 0.56 }));
11179
- if (force.y !== 0) elements.push(import_react16.default.createElement("line", { key: `component-y-${force.id}`, x1: yStart.x, y1: yStart.y, x2: end.x, y2: end.y, stroke: color, strokeWidth: densityOf(c).w(1.6), strokeDasharray: "5 5", opacity: 0.56 }));
11740
+ if (force.x !== 0) elements.push(import_react17.default.createElement("line", { key: `component-x-${force.id}`, x1: center2.x, y1: center2.y, x2: xEnd.x, y2: xEnd.y, stroke: color, strokeWidth: densityOf(c).w(1.6), strokeDasharray: "5 5", opacity: 0.56 }));
11741
+ if (force.y !== 0) elements.push(import_react17.default.createElement("line", { key: `component-y-${force.id}`, x1: yStart.x, y1: yStart.y, x2: end.x, y2: end.y, stroke: color, strokeWidth: densityOf(c).w(1.6), strokeDasharray: "5 5", opacity: 0.56 }));
11180
11742
  }
11181
11743
  elements.push(arrow(center2, end, color, `force-${force.id}`, 3));
11182
11744
  const direction = Math.sign(end.x - center2.x) || 1;
11183
11745
  const anchor = direction > 0 ? "start" : "end";
11184
11746
  const labelX = boundedTextX(end.x + direction * 12, width, force.label, anchor, 20);
11185
11747
  const labelY = clamp2(end.y - 11, 60, height - 20);
11186
- elements.push(import_react16.default.createElement("text", { key: `force-label-${force.id}`, x: labelX, y: labelY, textAnchor: anchor, fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 650 }, force.label));
11748
+ elements.push(import_react17.default.createElement("text", { key: `force-label-${force.id}`, x: labelX, y: labelY, textAnchor: anchor, fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 650 }, force.label));
11187
11749
  });
11188
11750
  if (showResultant && (resultant.x !== 0 || resultant.y !== 0)) {
11189
11751
  const end = mapVector(resultant.x, resultant.y);
@@ -11191,7 +11753,7 @@ function FreeBodyDiagram({
11191
11753
  const label = `R = ${formatNumber(resultant.magnitude)}`;
11192
11754
  const direction = Math.sign(end.x - center2.x) || 1;
11193
11755
  const anchor = direction > 0 ? "start" : "end";
11194
- elements.push(import_react16.default.createElement("text", {
11756
+ elements.push(import_react17.default.createElement("text", {
11195
11757
  key: "resultant-label",
11196
11758
  x: boundedTextX(end.x + direction * 12, width, label, anchor, 20),
11197
11759
  y: clamp2(end.y + 20, 60, height - 20),
@@ -11202,11 +11764,11 @@ function FreeBodyDiagram({
11202
11764
  fontWeight: 700
11203
11765
  }, label));
11204
11766
  } else if (showResultant) {
11205
- elements.push(import_react16.default.createElement("text", { key: "zero-resultant", x: center2.x + 38, y: center2.y + 38, fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 700 }, "R = 0"));
11767
+ elements.push(import_react17.default.createElement("text", { key: "zero-resultant", x: center2.x + 38, y: center2.y + 38, fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 700 }, "R = 0"));
11206
11768
  }
11207
11769
  elements.push(
11208
- import_react16.default.createElement("text", { key: "positive-x", x: width - 42, y: center2.y - 8, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, "+x"),
11209
- import_react16.default.createElement("text", { key: "positive-y", x: center2.x - 12, y: 72, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, "+y")
11770
+ import_react17.default.createElement("text", { key: "positive-x", x: width - 42, y: center2.y - 8, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, "+x"),
11771
+ import_react17.default.createElement("text", { key: "positive-y", x: center2.x - 12, y: 72, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, "+y")
11210
11772
  );
11211
11773
  return svgShell({ c, width, height, title, ariaLabel, description: `${forces.length} physical force vectors use one scale. The resultant is the vector sum ${formatNumber(resultant.x)} x plus ${formatNumber(resultant.y)} y. The vertical axis points upward in physical coordinates.`, children: elements });
11212
11774
  }
@@ -11218,20 +11780,20 @@ function arrow(start, end, color, key, strokeWidth) {
11218
11780
  const angle = Math.atan2(dy, dx);
11219
11781
  const left = { x: end.x - head * Math.cos(angle - Math.PI / 6), y: end.y - head * Math.sin(angle - Math.PI / 6) };
11220
11782
  const right = { x: end.x - head * Math.cos(angle + Math.PI / 6), y: end.y - head * Math.sin(angle + Math.PI / 6) };
11221
- return import_react16.default.createElement(
11783
+ return import_react17.default.createElement(
11222
11784
  "g",
11223
11785
  {
11224
11786
  key,
11225
11787
  "data-vector-role": key === "resultant" ? "resultant" : "force",
11226
11788
  "data-vector-id": key.startsWith("force-") ? key.slice("force-".length) : void 0
11227
11789
  },
11228
- import_react16.default.createElement("line", { x1: start.x, y1: start.y, x2: end.x, y2: end.y, stroke: color, strokeWidth, strokeLinecap: "round" }),
11229
- import_react16.default.createElement("path", { d: `M ${left.x} ${left.y} L ${end.x} ${end.y} L ${right.x} ${right.y}`, fill: "none", stroke: color, strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })
11790
+ import_react17.default.createElement("line", { x1: start.x, y1: start.y, x2: end.x, y2: end.y, stroke: color, strokeWidth, strokeLinecap: "round" }),
11791
+ import_react17.default.createElement("path", { d: `M ${left.x} ${left.y} L ${end.x} ${end.y} L ${right.x} ${right.y}`, fill: "none", stroke: color, strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })
11230
11792
  );
11231
11793
  }
11232
11794
  function validateWave(wave, index, c) {
11233
- positive(wave.amplitude, `WaveDiagram wave ${index} amplitude`);
11234
- positive(wave.wavelength, `WaveDiagram wave ${index} wavelength`);
11795
+ positive2(wave.amplitude, `WaveDiagram wave ${index} amplitude`);
11796
+ positive2(wave.wavelength, `WaveDiagram wave ${index} wavelength`);
11235
11797
  finite(wave.phase ?? 0, `WaveDiagram wave ${index} phase`);
11236
11798
  finite(wave.speed ?? 0, `WaveDiagram wave ${index} speed`);
11237
11799
  if (wave.label !== void 0) labelText(wave.label, `WaveDiagram wave ${index} label`, 22);
@@ -11326,28 +11888,28 @@ function WaveDiagram({
11326
11888
  const gridX = sx(xValue);
11327
11889
  const gridY = sy(yValue);
11328
11890
  elements.push(
11329
- import_react16.default.createElement("line", { key: `grid-x-${index}`, x1: gridX, y1: plot.top, x2: gridX, y2: plot.bottom, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1) }),
11330
- import_react16.default.createElement("line", { key: `grid-y-${index}`, x1: plot.left, y1: gridY, x2: plot.right, y2: gridY, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1) }),
11331
- import_react16.default.createElement("text", { key: `x-label-${index}`, x: gridX, y: plot.bottom + 22, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }, formatNumber(xValue)),
11332
- import_react16.default.createElement("text", { key: `y-label-${index}`, x: plot.left - 10, y: gridY + 4, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }, formatNumber(yValue))
11891
+ import_react17.default.createElement("line", { key: `grid-x-${index}`, x1: gridX, y1: plot.top, x2: gridX, y2: plot.bottom, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1) }),
11892
+ import_react17.default.createElement("line", { key: `grid-y-${index}`, x1: plot.left, y1: gridY, x2: plot.right, y2: gridY, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1) }),
11893
+ import_react17.default.createElement("text", { key: `x-label-${index}`, x: gridX, y: plot.bottom + 22, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }, formatNumber(xValue)),
11894
+ import_react17.default.createElement("text", { key: `y-label-${index}`, x: plot.left - 10, y: gridY + 4, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }, formatNumber(yValue))
11333
11895
  );
11334
11896
  }
11335
11897
  elements.push(
11336
- import_react16.default.createElement("line", { key: "x-axis", x1: plot.left, y1: sy(0), x2: plot.right, y2: sy(0), stroke: c.textSecondary, strokeWidth: densityOf(c).w(1.7) }),
11337
- import_react16.default.createElement("line", { key: "y-axis", x1: plot.left, y1: plot.top, x2: plot.left, y2: plot.bottom, stroke: c.textSecondary, strokeWidth: densityOf(c).w(1.7) }),
11338
- import_react16.default.createElement("text", { key: "axis-x-label", x: plot.right, y: height - 18, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: 12 }, "position x"),
11339
- import_react16.default.createElement("text", { key: "axis-y-label", x: plot.left + 8, y: plot.top - 9, fill: c.textSecondary, fontFamily: c.fontSans, fontSize: 12 }, "displacement y"),
11340
- import_react16.default.createElement("text", { key: "time-label", x: 24, y: 60, fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, `t = ${formatNumber(time)}`)
11898
+ import_react17.default.createElement("line", { key: "x-axis", x1: plot.left, y1: sy(0), x2: plot.right, y2: sy(0), stroke: c.textSecondary, strokeWidth: densityOf(c).w(1.7) }),
11899
+ import_react17.default.createElement("line", { key: "y-axis", x1: plot.left, y1: plot.top, x2: plot.left, y2: plot.bottom, stroke: c.textSecondary, strokeWidth: densityOf(c).w(1.7) }),
11900
+ import_react17.default.createElement("text", { key: "axis-x-label", x: plot.right, y: height - 18, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: 12 }, "position x"),
11901
+ import_react17.default.createElement("text", { key: "axis-y-label", x: plot.left + 8, y: plot.top - 9, fill: c.textSecondary, fontFamily: c.fontSans, fontSize: 12 }, "displacement y"),
11902
+ import_react17.default.createElement("text", { key: "time-label", x: 24, y: 60, fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, `t = ${formatNumber(time)}`)
11341
11903
  );
11342
11904
  const pathFor = (points) => points.map((point, index) => `${index === 0 ? "M" : "L"} ${sx(point.x).toFixed(2)} ${sy(point.y).toFixed(2)}`).join(" ");
11343
11905
  if (showComponents) {
11344
11906
  samples.forEach((waveSamples, index) => {
11345
11907
  const wave = waves[index];
11346
11908
  const color = colorValue(wave.color, c.secondary, `WaveDiagram wave ${index} color`);
11347
- elements.push(import_react16.default.createElement("path", { key: `component-${index}`, d: pathFor(waveSamples), fill: "none", stroke: color, strokeWidth: densityOf(c).w(2), opacity: showSum ? 0.68 : 1, strokeLinecap: "round", strokeLinejoin: "round" }));
11909
+ elements.push(import_react17.default.createElement("path", { key: `component-${index}`, d: pathFor(waveSamples), fill: "none", stroke: color, strokeWidth: densityOf(c).w(2), opacity: showSum ? 0.68 : 1, strokeLinecap: "round", strokeLinejoin: "round" }));
11348
11910
  });
11349
11911
  }
11350
- if (showSum) elements.push(import_react16.default.createElement("path", { key: "sum", d: pathFor(sumSamples), fill: "none", stroke: c.textPrimary, strokeWidth: densityOf(c).w(3.5), strokeLinecap: "round", strokeLinejoin: "round" }));
11912
+ if (showSum) elements.push(import_react17.default.createElement("path", { key: "sum", d: pathFor(sumSamples), fill: "none", stroke: c.textPrimary, strokeWidth: densityOf(c).w(3.5), strokeLinecap: "round", strokeLinejoin: "round" }));
11351
11913
  waves.forEach((wave, index) => {
11352
11914
  const label = wave.label ?? `wave ${index + 1}`;
11353
11915
  const color = colorValue(wave.color, c.secondary, `WaveDiagram wave ${index} color`);
@@ -11355,7 +11917,7 @@ function WaveDiagram({
11355
11917
  const row = index % 4;
11356
11918
  const legendX = plot.left + column * (plot.right - plot.left) / 2;
11357
11919
  const legendY = plot.top - 58 + row * 14;
11358
- elements.push(import_react16.default.createElement("line", {
11920
+ elements.push(import_react17.default.createElement("line", {
11359
11921
  key: `legend-swatch-${index}`,
11360
11922
  x1: legendX,
11361
11923
  y1: legendY - 4,
@@ -11365,7 +11927,7 @@ function WaveDiagram({
11365
11927
  strokeWidth: densityOf(c).w(3),
11366
11928
  strokeLinecap: "round"
11367
11929
  }));
11368
- elements.push(import_react16.default.createElement("text", {
11930
+ elements.push(import_react17.default.createElement("text", {
11369
11931
  key: `legend-${index}`,
11370
11932
  x: boundedTextX(legendX + 16, width, label, "start", 20, 11),
11371
11933
  y: legendY,
@@ -11375,15 +11937,15 @@ function WaveDiagram({
11375
11937
  fontWeight: 650
11376
11938
  }, label));
11377
11939
  });
11378
- if (showSum) elements.push(import_react16.default.createElement("text", { key: "sum-legend", x: width - 24, y: 60, textAnchor: "end", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 750 }, "sum"));
11940
+ if (showSum) elements.push(import_react17.default.createElement("text", { key: "sum-legend", x: width - 24, y: 60, textAnchor: "end", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 750 }, "sum"));
11379
11941
  if (probeX !== void 0) {
11380
11942
  const probeY = waves.reduce((sum, wave) => sum + waveValue(wave, probeX, time), 0);
11381
11943
  const probePosition = { x: sx(probeX), y: sy(probeY) };
11382
11944
  const label = `\u03A3y = ${formatNumber(probeY)}`;
11383
11945
  elements.push(
11384
- import_react16.default.createElement("line", { key: "probe-line", x1: probePosition.x, y1: plot.top, x2: probePosition.x, y2: plot.bottom, stroke: c.warning, strokeWidth: densityOf(c).w(1.5), strokeDasharray: "5 5" }),
11385
- import_react16.default.createElement("circle", { key: "probe-point", cx: probePosition.x, cy: probePosition.y, r: 6, fill: c.warning, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }),
11386
- import_react16.default.createElement("text", { key: "probe-label", x: clamp2(probePosition.x + 10, plot.left + 8, plot.right - textWidth(label)), y: clamp2(probePosition.y - 12, plot.top + 40, plot.bottom - 10), fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 650 }, label)
11946
+ import_react17.default.createElement("line", { key: "probe-line", x1: probePosition.x, y1: plot.top, x2: probePosition.x, y2: plot.bottom, stroke: c.warning, strokeWidth: densityOf(c).w(1.5), strokeDasharray: "5 5" }),
11947
+ import_react17.default.createElement("circle", { key: "probe-point", cx: probePosition.x, cy: probePosition.y, r: 6, fill: c.warning, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }),
11948
+ import_react17.default.createElement("text", { key: "probe-label", x: clamp2(probePosition.x + 10, plot.left + 8, plot.right - textWidth(label)), y: clamp2(probePosition.y - 12, plot.top + 40, plot.bottom - 10), fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 650 }, label)
11387
11949
  );
11388
11950
  }
11389
11951
  const summary = waves.map((wave, index) => `${wave.label ?? `wave ${index + 1}`} (A=${formatNumber(wave.amplitude)}, \u03BB=${formatNumber(wave.wavelength)}, \u03C6=${formatNumber(wave.phase ?? 0)}, v=${formatNumber(wave.speed ?? 0)})`).join("; ");
@@ -11391,9 +11953,9 @@ function WaveDiagram({
11391
11953
  }
11392
11954
 
11393
11955
  // src/primitives/science-chemistry.ts
11394
- var import_react17 = __toESM(require("react"), 1);
11956
+ var import_react18 = __toESM(require("react"), 1);
11395
11957
  function overlayText(key, props) {
11396
- return import_react17.default.createElement(import_react17.default.Fragment, { key }, SvgMathText(props));
11958
+ return import_react18.default.createElement(import_react18.default.Fragment, { key }, SvgMathText(props));
11397
11959
  }
11398
11960
  var ELEMENTS = /* @__PURE__ */ new Set([
11399
11961
  "H",
@@ -11645,7 +12207,7 @@ function MoleculeDiagram({
11645
12207
  const bondNodes = bonds.flatMap((bond, bondIndex) => {
11646
12208
  const from = points.get(bond.from);
11647
12209
  const to = points.get(bond.to);
11648
- return bondSegments(from, to, bond.order).map((segment, segmentIndex) => import_react17.default.createElement("line", {
12210
+ return bondSegments(from, to, bond.order).map((segment, segmentIndex) => import_react18.default.createElement("line", {
11649
12211
  key: `bond-${bondIndex}-${segmentIndex}`,
11650
12212
  x1: segment.x1,
11651
12213
  y1: segment.y1,
@@ -11665,10 +12227,10 @@ function MoleculeDiagram({
11665
12227
  const atomNodes = atoms.map((atom) => {
11666
12228
  const point = points.get(atom.id);
11667
12229
  const accent = atomColor(atom.element, c);
11668
- return import_react17.default.createElement(
12230
+ return import_react18.default.createElement(
11669
12231
  "g",
11670
12232
  { key: atom.id, "data-atom-id": atom.id, "data-element": atom.element },
11671
- import_react17.default.createElement("circle", { cx: point.x, cy: point.y, r: 19, fill: c.bgCard, stroke: accent, strokeWidth: densityOf(c).w(2) })
12233
+ import_react18.default.createElement("circle", { cx: point.x, cy: point.y, r: 19, fill: c.bgCard, stroke: accent, strokeWidth: densityOf(c).w(2) })
11672
12234
  );
11673
12235
  });
11674
12236
  const textNodes = atoms.flatMap((atom) => {
@@ -11681,7 +12243,7 @@ function MoleculeDiagram({
11681
12243
  ...atom.label ? [overlayText(`atom-${atom.id}-label`, { text: atom.label, x: point.x, y: labelY, fill: c.textSecondary, fontSize: densityOf(c).f(10), fontFamily: c.fontSans, textAnchor: "middle" })] : []
11682
12244
  ];
11683
12245
  });
11684
- const geometry = import_react17.default.createElement(
12246
+ const geometry = import_react18.default.createElement(
11685
12247
  "svg",
11686
12248
  {
11687
12249
  width: svgWidth,
@@ -11690,11 +12252,11 @@ function MoleculeDiagram({
11690
12252
  "aria-hidden": true,
11691
12253
  style: { position: "absolute", left: 0, top: 0, display: "block" }
11692
12254
  },
11693
- import_react17.default.createElement("rect", { x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
12255
+ import_react18.default.createElement("rect", { x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
11694
12256
  ...bondNodes,
11695
12257
  ...atomNodes
11696
12258
  );
11697
- return import_react17.default.createElement(
12259
+ return import_react18.default.createElement(
11698
12260
  "div",
11699
12261
  {
11700
12262
  role: "img",
@@ -11783,7 +12345,7 @@ function reactionBalance(reactants, products) {
11783
12345
  return { status: balanced ? "balanced" : "unbalanced", balanced, elementDeltas: deltas, chargeDelta };
11784
12346
  }
11785
12347
  function equationTerm(term, index, c) {
11786
- return import_react17.default.createElement(
12348
+ return import_react18.default.createElement(
11787
12349
  "span",
11788
12350
  {
11789
12351
  key: `term-${index}-${term.formula}`,
@@ -11797,22 +12359,22 @@ function equationTerm(term, index, c) {
11797
12359
  color: c.textPrimary
11798
12360
  }
11799
12361
  },
11800
- term.coefficient && term.coefficient !== 1 ? import_react17.default.createElement("span", { style: { color: getReadableColor("primary", c), fontWeight: 700, marginRight: 5 } }, `${term.coefficient}`) : null,
11801
- import_react17.default.createElement("span", { style: { overflowWrap: "anywhere" } }, term.formula),
11802
- term.state ? import_react17.default.createElement("span", { style: { marginLeft: 5, color: c.textSecondary, fontSize: "0.9em" } }, `(${term.state})`) : null
12362
+ term.coefficient && term.coefficient !== 1 ? import_react18.default.createElement("span", { style: { color: getReadableColor("primary", c), fontWeight: 700, marginRight: 5 } }, `${term.coefficient}`) : null,
12363
+ import_react18.default.createElement("span", { style: { overflowWrap: "anywhere" } }, term.formula),
12364
+ term.state ? import_react18.default.createElement("span", { style: { marginLeft: 5, color: c.textSecondary, fontSize: "0.9em" } }, `(${term.state})`) : null
11803
12365
  );
11804
12366
  }
11805
12367
  function equationSide(terms, label, c) {
11806
12368
  const children = [];
11807
12369
  terms.forEach((term, index) => {
11808
- if (index > 0) children.push(import_react17.default.createElement("span", {
12370
+ if (index > 0) children.push(import_react18.default.createElement("span", {
11809
12371
  key: `plus-${index}`,
11810
12372
  style: { color: c.textSecondary, padding: "0 7px", flex: "0 0 auto" },
11811
12373
  "aria-hidden": true
11812
12374
  }, "+"));
11813
12375
  children.push(equationTerm(term, index, c));
11814
12376
  });
11815
- return import_react17.default.createElement("div", {
12377
+ return import_react18.default.createElement("div", {
11816
12378
  role: "group",
11817
12379
  "aria-label": label,
11818
12380
  style: {
@@ -11844,7 +12406,7 @@ function ReactionEquation({
11844
12406
  const balance = reactionBalance(reactants, products);
11845
12407
  const accessibleEquation = `${reactants.map((term) => `${term.coefficient && term.coefficient !== 1 ? `${term.coefficient} ` : ""}${term.formula}${term.state ? ` (${term.state})` : ""}`).join(" + ")} ${reversible ? "reversibly yields" : "yields"} ${products.map((term) => `${term.coefficient && term.coefficient !== 1 ? `${term.coefficient} ` : ""}${term.formula}${term.state ? ` (${term.state})` : ""}`).join(" + ")}`;
11846
12408
  const balanceText = balance.status === "unavailable" ? "Balance unavailable: provide a complete composition map for every term." : balance.balanced ? "Balanced by supplied composition and charge." : `Not balanced by supplied composition and charge: ${Object.entries(balance.elementDeltas).filter(([, delta]) => delta !== 0).map(([element, delta]) => `${element} ${delta > 0 ? "+" : ""}${delta}`).join(", ") || "elements conserved"}, charge ${balance.chargeDelta > 0 ? "+" : ""}${balance.chargeDelta}.`;
11847
- return import_react17.default.createElement(
12409
+ return import_react18.default.createElement(
11848
12410
  "div",
11849
12411
  {
11850
12412
  role: "img",
@@ -11865,20 +12427,20 @@ function ReactionEquation({
11865
12427
  fontFamily: c.fontSans
11866
12428
  }
11867
12429
  },
11868
- import_react17.default.createElement(
12430
+ import_react18.default.createElement(
11869
12431
  "div",
11870
12432
  {
11871
12433
  style: { display: "flex", alignItems: "center", gap: 12, minWidth: 0 }
11872
12434
  },
11873
12435
  equationSide(reactants, "Reactants", c),
11874
- import_react17.default.createElement("span", {
12436
+ import_react18.default.createElement("span", {
11875
12437
  style: { flex: "0 0 auto", color: c.primaryLight, fontSize: densityOf(c).f(26), fontWeight: 700, padding: "0 2px" },
11876
12438
  "aria-hidden": true
11877
12439
  }, reversible ? "\u21CC" : "\u2192"),
11878
12440
  equationSide(products, "Products", c)
11879
12441
  ),
11880
- conditions !== void 0 && conditions.length > 0 ? import_react17.default.createElement("div", { style: { color: c.textSecondary, fontSize: densityOf(c).f(13) } }, `Conditions: ${conditions}`) : null,
11881
- import_react17.default.createElement("div", {
12442
+ conditions !== void 0 && conditions.length > 0 ? import_react18.default.createElement("div", { style: { color: c.textSecondary, fontSize: densityOf(c).f(13) } }, `Conditions: ${conditions}`) : null,
12443
+ import_react18.default.createElement("div", {
11882
12444
  style: {
11883
12445
  paddingTop: 8,
11884
12446
  borderTop: `1px solid ${c.borderSubtle}`,
@@ -11914,12 +12476,12 @@ function measurement(x, y1, y2, color, key, label) {
11914
12476
  const top = Math.min(y1, y2);
11915
12477
  const bottom = Math.max(y1, y2);
11916
12478
  const cap = 5;
11917
- return import_react17.default.createElement(
12479
+ return import_react18.default.createElement(
11918
12480
  "g",
11919
12481
  { key, "data-measurement": label, "aria-hidden": true },
11920
- import_react17.default.createElement("line", { x1: x, y1: top, x2: x, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5), strokeDasharray: "3 3" }),
11921
- import_react17.default.createElement("line", { x1: x - cap, y1: top, x2: x + cap, y2: top, stroke: color, strokeWidth: densityOf().w(1.5) }),
11922
- import_react17.default.createElement("line", { x1: x - cap, y1: bottom, x2: x + cap, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5) })
12482
+ import_react18.default.createElement("line", { x1: x, y1: top, x2: x, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5), strokeDasharray: "3 3" }),
12483
+ import_react18.default.createElement("line", { x1: x - cap, y1: top, x2: x + cap, y2: top, stroke: color, strokeWidth: densityOf().w(1.5) }),
12484
+ import_react18.default.createElement("line", { x1: x - cap, y1: bottom, x2: x + cap, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5) })
11923
12485
  );
11924
12486
  }
11925
12487
  function ReactionEnergyDiagram({
@@ -12000,19 +12562,19 @@ function ReactionEnergyDiagram({
12000
12562
  const revealWidth = progress === 0 ? 0 : (x1 - x0) * progress + 8;
12001
12563
  const gridValues = [scaleMin, (scaleMin + scaleMax) / 2, scaleMax];
12002
12564
  const svgNodes = [
12003
- import_react17.default.createElement("rect", { key: "background", x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
12004
- import_react17.default.createElement(
12565
+ import_react18.default.createElement("rect", { key: "background", x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
12566
+ import_react18.default.createElement(
12005
12567
  "defs",
12006
12568
  { key: "reveal-defs" },
12007
- import_react17.default.createElement(
12569
+ import_react18.default.createElement(
12008
12570
  "clipPath",
12009
12571
  { id: revealClipId, clipPathUnits: "userSpaceOnUse" },
12010
- import_react17.default.createElement("rect", { x: x0 - 4, y: plotTop, width: revealWidth, height: plotBottom - plotTop })
12572
+ import_react18.default.createElement("rect", { x: x0 - 4, y: plotTop, width: revealWidth, height: plotBottom - plotTop })
12011
12573
  )
12012
12574
  ),
12013
- import_react17.default.createElement("line", { key: "y-axis", x1: plotLeft, y1: plotTop, x2: plotLeft, y2: plotBottom, stroke: c.borderLight, strokeWidth: densityOf(c).w(1.4) }),
12014
- import_react17.default.createElement("line", { key: "x-axis", x1: plotLeft, y1: plotBottom, x2: plotRight, y2: plotBottom, stroke: c.borderLight, strokeWidth: densityOf(c).w(1.4) }),
12015
- ...gridValues.map((value, index) => import_react17.default.createElement("line", {
12575
+ import_react18.default.createElement("line", { key: "y-axis", x1: plotLeft, y1: plotTop, x2: plotLeft, y2: plotBottom, stroke: c.borderLight, strokeWidth: densityOf(c).w(1.4) }),
12576
+ import_react18.default.createElement("line", { key: "x-axis", x1: plotLeft, y1: plotBottom, x2: plotRight, y2: plotBottom, stroke: c.borderLight, strokeWidth: densityOf(c).w(1.4) }),
12577
+ ...gridValues.map((value, index) => import_react18.default.createElement("line", {
12016
12578
  key: `grid-${index}`,
12017
12579
  x1: plotLeft,
12018
12580
  y1: yFor(value),
@@ -12022,7 +12584,7 @@ function ReactionEnergyDiagram({
12022
12584
  strokeWidth: densityOf(c).w(1),
12023
12585
  strokeDasharray: "3 5"
12024
12586
  })),
12025
- import_react17.default.createElement("path", {
12587
+ import_react18.default.createElement("path", {
12026
12588
  key: "uncatalyzed-path",
12027
12589
  d: path,
12028
12590
  fill: "none",
@@ -12034,7 +12596,7 @@ function ReactionEnergyDiagram({
12034
12596
  "data-energy-path": "uncatalyzed",
12035
12597
  "data-progress": progress
12036
12598
  }),
12037
- catalyzedPath === void 0 ? null : import_react17.default.createElement("path", {
12599
+ catalyzedPath === void 0 ? null : import_react18.default.createElement("path", {
12038
12600
  key: "catalyzed-path",
12039
12601
  d: catalyzedPath,
12040
12602
  fill: "none",
@@ -12052,7 +12614,7 @@ function ReactionEnergyDiagram({
12052
12614
  ];
12053
12615
  const overlayNodes = [
12054
12616
  overlayText("title", { text: `${chartTitle} \xB7 ${unit}`, x: svgWidth / 2, y: 24, fill: c.textPrimary, fontSize: densityOf(c).f(16), fontFamily: c.fontSans, fontWeight: 700 }),
12055
- import_react17.default.createElement("div", {
12617
+ import_react18.default.createElement("div", {
12056
12618
  key: "energy-label",
12057
12619
  style: {
12058
12620
  position: "absolute",
@@ -12074,7 +12636,7 @@ function ReactionEnergyDiagram({
12074
12636
  ...catalyzedActivation === void 0 ? [] : [overlayText("catalyzed-activation-value", { text: `Ea (catalyzed) = ${energyText(catalyzedActivation)} ${unit}`, x: svgWidth / 2, y: svgHeight - 39, fill: getReadableColor("positive", c), fontSize: densityOf(c).f(12), fontFamily: c.fontSans })],
12075
12637
  overlayText("delta-value", { text: `\u0394E = ${signedEnergyText(delta)} ${unit}`, x: svgWidth / 2, y: svgHeight - 21, fill: getReadableColor("secondary", c), fontSize: densityOf(c).f(12), fontFamily: c.fontSans })
12076
12638
  ];
12077
- const geometry = import_react17.default.createElement(
12639
+ const geometry = import_react18.default.createElement(
12078
12640
  "svg",
12079
12641
  {
12080
12642
  width: svgWidth,
@@ -12085,7 +12647,7 @@ function ReactionEnergyDiagram({
12085
12647
  },
12086
12648
  ...svgNodes
12087
12649
  );
12088
- return import_react17.default.createElement("div", {
12650
+ return import_react18.default.createElement("div", {
12089
12651
  role: "img",
12090
12652
  "aria-label": ariaLabel ?? `${chartTitle} (${unit})`,
12091
12653
  "aria-description": desc,
@@ -12096,7 +12658,7 @@ function ReactionEnergyDiagram({
12096
12658
  }
12097
12659
 
12098
12660
  // src/primitives/science-ai.ts
12099
- var import_react18 = __toESM(require("react"), 1);
12661
+ var import_react19 = __toESM(require("react"), 1);
12100
12662
 
12101
12663
  // src/teaching-math.ts
12102
12664
  function finite2(value, name) {
@@ -12311,11 +12873,11 @@ function AttentionMatrix({
12311
12873
  const text = (key, value, x, y, size = 14, fill = c.textPrimary, anchor = "middle", background) => {
12312
12874
  const label = SvgMathText({ text: value, x, y, fill, fontSize: size, fontFamily: c.fontSans, fontWeight: 500, textAnchor: anchor, dominantBaseline: "alphabetic" });
12313
12875
  const style = label.props.style;
12314
- return import_react18.default.cloneElement(label, { key, ...background ? { style: { ...style, backgroundColor: background } } : {} });
12876
+ return import_react19.default.cloneElement(label, { key, ...background ? { style: { ...style, backgroundColor: background } } : {} });
12315
12877
  };
12316
12878
  const marks = [
12317
- import_react18.default.createElement("title", { key: "title" }, title),
12318
- import_react18.default.createElement("desc", { key: "description" }, "Rows are queries and columns are keys. Visible rows sum to one. Crosses denote masked keys. Values are attention probabilities, not explanations of model reasoning."),
12879
+ import_react19.default.createElement("title", { key: "title" }, title),
12880
+ import_react19.default.createElement("desc", { key: "description" }, "Rows are queries and columns are keys. Visible rows sum to one. Crosses denote masked keys. Values are attention probabilities, not explanations of model reasoning."),
12319
12881
  text("heading", title, 22, 30, 20, c.textPrimary, "start"),
12320
12882
  text("keys", "KEYS", left + (width - left - right) / 2, 58, 12, c.textSecondary),
12321
12883
  text("query-heading", "QUERY", 22, 81, 12, c.textSecondary, "start"),
@@ -12330,7 +12892,7 @@ function AttentionMatrix({
12330
12892
  const masked = mask?.[i][j] === false;
12331
12893
  const selected = activeQuery === i && (activeKey === void 0 || activeKey === j);
12332
12894
  const fill = masked ? c.bgCardAlt : compositeColor(withColorAlpha(c.primary, 0.12 + 0.88 * weight), c.bg);
12333
- marks.push(import_react18.default.createElement("rect", {
12895
+ marks.push(import_react19.default.createElement("rect", {
12334
12896
  key: `cell-${i}-${j}`,
12335
12897
  x: x + 2,
12336
12898
  y: y + 2,
@@ -12343,7 +12905,7 @@ function AttentionMatrix({
12343
12905
  }));
12344
12906
  if (masked) {
12345
12907
  const centerX = x + cellWidth / 2, centerY = y + cellHeight / 2;
12346
- marks.push(import_react18.default.createElement("path", { key: `mask-${i}-${j}`, d: `M${centerX - 4},${centerY - 4}l8,8m-8,0l8,-8`, stroke: c.textMuted, strokeWidth: 1.4 }));
12908
+ marks.push(import_react19.default.createElement("path", { key: `mask-${i}-${j}`, d: `M${centerX - 4},${centerY - 4}l8,8m-8,0l8,-8`, stroke: c.textMuted, strokeWidth: 1.4 }));
12347
12909
  } else {
12348
12910
  const label = weight.toFixed(2);
12349
12911
  if (cellWidth >= 38 && cellHeight >= 24) marks.push(text(`value-${i}-${j}`, label, x + cellWidth / 2, y + cellHeight / 2 + 5, 14, getReadableTextColor(fill, c, c.bg), "middle", fill));
@@ -12353,11 +12915,11 @@ function AttentionMatrix({
12353
12915
  marks.push(text(`sum-${i}`, total.toFixed(0), width - 30, y + cellHeight / 2 + 5, 14, c.textSecondary));
12354
12916
  });
12355
12917
  marks.push(text("footer", "Probability per query \xB7 \xD7 masked \xB7 shared color scale 0\u20131", 22, height - 22, 13, c.textSecondary, "start"));
12356
- const isLabel = (node) => import_react18.default.isValidElement(node) && node.type === "div";
12357
- return import_react18.default.createElement(
12918
+ const isLabel = (node) => import_react19.default.isValidElement(node) && node.type === "div";
12919
+ return import_react19.default.createElement(
12358
12920
  "div",
12359
12921
  { role: "img", "aria-label": title, style: { position: "relative", display: "flex", width, height, backgroundColor: c.bg, flexShrink: 0 } },
12360
- import_react18.default.createElement("svg", { width, height, viewBox: `0 0 ${width} ${height}` }, ...marks.filter((node) => !isLabel(node))),
12922
+ import_react19.default.createElement("svg", { width, height, viewBox: `0 0 ${width} ${height}` }, ...marks.filter((node) => !isLabel(node))),
12361
12923
  ...marks.filter(isLabel)
12362
12924
  );
12363
12925
  }
@@ -12390,7 +12952,7 @@ function transposeMatrix(matrix) {
12390
12952
  }
12391
12953
 
12392
12954
  // src/primitives/image-tensor.ts
12393
- var import_react19 = __toESM(require("react"), 1);
12955
+ var import_react20 = __toESM(require("react"), 1);
12394
12956
  var MAX_IMAGE_AXIS = 128;
12395
12957
  var MAX_IMAGE_PIXELS = 1024;
12396
12958
  var MAX_COMPONENT_SIZE = 32768;
@@ -12499,7 +13061,7 @@ function PixelGrid({
12499
13061
  const rgb = channel === "red" ? [pixel[0], 0, 0] : channel === "green" ? [0, pixel[1], 0] : channel === "blue" ? [0, 0, pixel[2]] : pixel;
12500
13062
  return `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
12501
13063
  };
12502
- const cells = pixels.flatMap((row, rowIndex) => row.map((pixel, columnIndex) => import_react19.default.createElement("rect", {
13064
+ const cells = pixels.flatMap((row, rowIndex) => row.map((pixel, columnIndex) => import_react20.default.createElement("rect", {
12503
13065
  key: `pixel-${rowIndex}-${columnIndex}`,
12504
13066
  x: offsetX + columnIndex * pixelSize,
12505
13067
  y: offsetY + rowIndex * pixelSize,
@@ -12510,7 +13072,7 @@ function PixelGrid({
12510
13072
  const strokeWidth = pixelSize * 0.16;
12511
13073
  const marks = [...cells];
12512
13074
  if (region) {
12513
- marks.push(import_react19.default.createElement("rect", {
13075
+ marks.push(import_react20.default.createElement("rect", {
12514
13076
  key: "region-highlight",
12515
13077
  x: offsetX + region.column * pixelSize + strokeWidth / 2,
12516
13078
  y: offsetY + region.row * pixelSize + strokeWidth / 2,
@@ -12523,7 +13085,7 @@ function PixelGrid({
12523
13085
  }));
12524
13086
  }
12525
13087
  if (activeCell) {
12526
- marks.push(import_react19.default.createElement("rect", {
13088
+ marks.push(import_react20.default.createElement("rect", {
12527
13089
  key: "active-cell-highlight",
12528
13090
  x: offsetX + activeCell.column * pixelSize + strokeWidth / 2,
12529
13091
  y: offsetY + activeCell.row * pixelSize + strokeWidth / 2,
@@ -12535,11 +13097,11 @@ function PixelGrid({
12535
13097
  }));
12536
13098
  }
12537
13099
  const channelLabel = channel === "rgb" ? "RGB" : `${channel} channel`;
12538
- return import_react19.default.createElement("div", {
13100
+ return import_react20.default.createElement("div", {
12539
13101
  role: "img",
12540
13102
  "aria-label": `${shape.rows} by ${shape.columns} pixel image, ${channelLabel}`,
12541
13103
  style: { position: "relative", display: "flex", width, height, backgroundColor: c.bgCard, flexShrink: 0 }
12542
- }, import_react19.default.createElement("svg", {
13104
+ }, import_react20.default.createElement("svg", {
12543
13105
  width,
12544
13106
  height,
12545
13107
  viewBox: `0 0 ${width} ${height}`,
@@ -14600,12 +15162,12 @@ var import_url = require("url");
14600
15162
  var import_zlib = require("zlib");
14601
15163
 
14602
15164
  // src/brand.ts
14603
- var import_react20 = __toESM(require("react"), 1);
15165
+ var import_react21 = __toESM(require("react"), 1);
14604
15166
  var DEFAULT_WATERMARK_TEXT = "Vizmatic";
14605
15167
  var WATERMARK_COLOR_DARK = "#a5a7ad";
14606
15168
  var WATERMARK_COLOR_LIGHT = "#5e5a50";
14607
15169
  function VizmaticIcon({ size = 14, color }) {
14608
- return import_react20.default.createElement(
15170
+ return import_react21.default.createElement(
14609
15171
  "svg",
14610
15172
  {
14611
15173
  xmlns: "http://www.w3.org/2000/svg",
@@ -14614,19 +15176,19 @@ function VizmaticIcon({ size = 14, color }) {
14614
15176
  viewBox: "0 0 28 28",
14615
15177
  fill: "none"
14616
15178
  },
14617
- import_react20.default.createElement("rect", { x: 2.5, y: 2.5, width: 23, height: 23, rx: 6.5, stroke: color, strokeWidth: 2, opacity: 0.54 }),
14618
- import_react20.default.createElement("rect", { x: 7, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.35 }),
14619
- import_react20.default.createElement("rect", { x: 15.5, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color }),
14620
- import_react20.default.createElement("rect", { x: 7, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.82 }),
14621
- import_react20.default.createElement("rect", { x: 15.5, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, stroke: color, strokeWidth: 1.5, opacity: 0.72 }),
14622
- import_react20.default.createElement("path", { d: "M9.75 9.75h8.5M9.75 18.25h8.5M9.75 9.75v8.5M18.25 9.75v8.5", stroke: color, strokeWidth: 1.6, strokeLinecap: "round", opacity: 0.88 })
15179
+ import_react21.default.createElement("rect", { x: 2.5, y: 2.5, width: 23, height: 23, rx: 6.5, stroke: color, strokeWidth: 2, opacity: 0.54 }),
15180
+ import_react21.default.createElement("rect", { x: 7, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.35 }),
15181
+ import_react21.default.createElement("rect", { x: 15.5, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color }),
15182
+ import_react21.default.createElement("rect", { x: 7, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.82 }),
15183
+ import_react21.default.createElement("rect", { x: 15.5, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, stroke: color, strokeWidth: 1.5, opacity: 0.72 }),
15184
+ import_react21.default.createElement("path", { d: "M9.75 9.75h8.5M9.75 18.25h8.5M9.75 9.75v8.5M18.25 9.75v8.5", stroke: color, strokeWidth: 1.6, strokeLinecap: "round", opacity: 0.88 })
14623
15185
  );
14624
15186
  }
14625
15187
  function normalizeWatermark(watermark) {
14626
15188
  if (watermark == null || watermark === false) return void 0;
14627
15189
  if (watermark === true) return {};
14628
15190
  if (typeof watermark === "string") return { text: watermark };
14629
- if (import_react20.default.isValidElement(watermark)) {
15191
+ if (import_react21.default.isValidElement(watermark)) {
14630
15192
  if (watermark.type !== Watermark) return { element: watermark };
14631
15193
  const { children, ...props } = watermark.props;
14632
15194
  return {
@@ -14655,7 +15217,7 @@ function positionStyle(position2) {
14655
15217
  function imageNode(image) {
14656
15218
  if (!image) return void 0;
14657
15219
  const imageOptions = typeof image === "string" ? { src: image } : image;
14658
- return import_react20.default.createElement("img", {
15220
+ return import_react21.default.createElement("img", {
14659
15221
  src: imageOptions.src,
14660
15222
  alt: imageOptions.alt ?? "",
14661
15223
  width: imageOptions.width ?? 14,
@@ -14670,9 +15232,9 @@ function imageNode(image) {
14670
15232
  }
14671
15233
  function iconNode(icon, color) {
14672
15234
  if (icon === false) return void 0;
14673
- if (icon == null) return import_react20.default.createElement(VizmaticIcon, { size: 13, color });
15235
+ if (icon == null) return import_react21.default.createElement(VizmaticIcon, { size: 13, color });
14674
15236
  if (typeof icon !== "string") return icon;
14675
- return import_react20.default.createElement("div", {
15237
+ return import_react21.default.createElement("div", {
14676
15238
  style: {
14677
15239
  minWidth: 13,
14678
15240
  height: 13,
@@ -14697,7 +15259,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
14697
15259
  const text = options?.text ?? DEFAULT_WATERMARK_TEXT;
14698
15260
  const content = options?.element ?? [
14699
15261
  icon,
14700
- text !== false && text && import_react20.default.createElement("div", {
15262
+ text !== false && text && import_react21.default.createElement("div", {
14701
15263
  key: "text",
14702
15264
  style: {
14703
15265
  fontSize: 11,
@@ -14708,7 +15270,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
14708
15270
  }
14709
15271
  }, text)
14710
15272
  ];
14711
- return import_react20.default.createElement(
15273
+ return import_react21.default.createElement(
14712
15274
  "div",
14713
15275
  {
14714
15276
  style: {
@@ -14719,7 +15281,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
14719
15281
  }
14720
15282
  },
14721
15283
  element,
14722
- options && import_react20.default.createElement(
15284
+ options && import_react21.default.createElement(
14723
15285
  "div",
14724
15286
  {
14725
15287
  style: {
@@ -16379,7 +16941,7 @@ function nonnegative(value, name) {
16379
16941
  finite3(value, name);
16380
16942
  if (value < 0) throw new Error(`${name} must be nonnegative`);
16381
16943
  }
16382
- function positive2(value, name) {
16944
+ function positive3(value, name) {
16383
16945
  finite3(value, name);
16384
16946
  if (value <= 0) throw new Error(`${name} must be positive`);
16385
16947
  }
@@ -16390,17 +16952,17 @@ function normalizedOpacity(value, name = "Canvas opacity") {
16390
16952
  function validateBounds(bounds4) {
16391
16953
  finite3(bounds4.x, "Canvas x");
16392
16954
  finite3(bounds4.y, "Canvas y");
16393
- positive2(bounds4.width, "Canvas width");
16394
- positive2(bounds4.height, "Canvas height");
16955
+ positive3(bounds4.width, "Canvas width");
16956
+ positive3(bounds4.height, "Canvas height");
16395
16957
  nonnegative(bounds4.radius ?? 14, "Canvas radius");
16396
16958
  }
16397
16959
  function layoutTokenRow(values, options = {}) {
16398
16960
  const { advance = 24, gap = 16, minWidth = 64, paddingX = 17, width } = options;
16399
16961
  nonnegative(advance, "Token advance");
16400
16962
  nonnegative(gap, "Token gap");
16401
- positive2(minWidth, "Token minimum width");
16963
+ positive3(minWidth, "Token minimum width");
16402
16964
  nonnegative(paddingX, "Token horizontal padding");
16403
- if (width !== void 0) positive2(width, "Token width");
16965
+ if (width !== void 0) positive3(width, "Token width");
16404
16966
  if (options.x !== void 0) finite3(options.x, "Token x");
16405
16967
  if (options.centerX !== void 0) finite3(options.centerX, "Token center x");
16406
16968
  const items = values.map((value) => {
@@ -16444,7 +17006,7 @@ function createCanvasComponents(painter) {
16444
17006
  }
16445
17007
  function card(options) {
16446
17008
  const { label, x, y, width, height, fontSize = 32, font = "sans", textColor, baselineOffset = fontSize * 0.34, labelOpacity = 1 } = options;
16447
- positive2(fontSize, "Canvas font size");
17009
+ positive3(fontSize, "Canvas font size");
16448
17010
  finite3(baselineOffset, "Canvas text baseline offset");
16449
17011
  const labelAlpha = normalizedOpacity(labelOpacity, "Canvas label opacity");
16450
17012
  return panel(options, () => {
@@ -16457,7 +17019,7 @@ function createCanvasComponents(painter) {
16457
17019
  const { values, x, y, cellSize = 112, gap = 8, inset = 0, format = String, style = {}, cellStyle } = options;
16458
17020
  finite3(x, "Matrix x");
16459
17021
  finite3(y, "Matrix y");
16460
- positive2(cellSize, "Matrix cell size");
17022
+ positive3(cellSize, "Matrix cell size");
16461
17023
  nonnegative(gap, "Matrix gap");
16462
17024
  finite3(inset, "Matrix inset");
16463
17025
  if (gap >= cellSize) throw new Error("Matrix gap must be smaller than cell size");
@@ -16488,7 +17050,7 @@ function createCanvasComponents(painter) {
16488
17050
  function tokenRow(options) {
16489
17051
  const { values, y, height = 68, reveal = 1, opacity = 1, ...style } = options;
16490
17052
  finite3(y, "Token row y");
16491
- positive2(height, "Token height");
17053
+ positive3(height, "Token height");
16492
17054
  finite3(reveal, "Token reveal");
16493
17055
  const alpha3 = normalizedOpacity(opacity);
16494
17056
  const items = layoutTokenRow(values, options);
@@ -16505,7 +17067,7 @@ function createCanvasComponents(painter) {
16505
17067
  function particle(options) {
16506
17068
  const { points, progress, radius = 9, fill, stroke, strokeWidth = 3 } = options;
16507
17069
  finite3(progress, "Particle progress");
16508
- positive2(radius, "Particle radius");
17070
+ positive3(radius, "Particle radius");
16509
17071
  nonnegative(strokeWidth, "Particle stroke width");
16510
17072
  if (progress <= 0 || progress >= 1) return null;
16511
17073
  const point = pointAlongPath(points, progress);
@@ -16600,14 +17162,14 @@ function createTeachingTransfer(painter) {
16600
17162
  }
16601
17163
 
16602
17164
  // src/teaching-grid.ts
16603
- function positive3(value, name) {
17165
+ function positive4(value, name) {
16604
17166
  if (!Number.isFinite(value) || value <= 0) throw new Error(`${name} must be finite and positive`);
16605
17167
  }
16606
17168
  function layoutCellGrid(options) {
16607
17169
  const { x, y, width, height, rows, columns } = options;
16608
17170
  if (![x, y, x + width, y + height].every(Number.isFinite)) throw new Error("Grid bounds must be finite");
16609
- positive3(width, "Grid width");
16610
- positive3(height, "Grid height");
17171
+ positive4(width, "Grid width");
17172
+ positive4(height, "Grid height");
16611
17173
  if (![rows, columns, rows * columns].every(Number.isSafeInteger) || rows <= 0 || columns <= 0) {
16612
17174
  throw new Error("Grid rows and columns must be positive safe integers");
16613
17175
  }
@@ -16649,9 +17211,9 @@ function createTeachingGrid(painter) {
16649
17211
  textColor = "#FFFFFF",
16650
17212
  padding = 4
16651
17213
  } = options;
16652
- positive3(lineWidth, "Grid line width");
17214
+ positive4(lineWidth, "Grid line width");
16653
17215
  if (lineWidth >= Math.min(width / columns, height / rows)) throw new Error("Grid line width must be smaller than a cell");
16654
- positive3(fontSize, "Grid font size");
17216
+ positive4(fontSize, "Grid font size");
16655
17217
  if (!Number.isFinite(padding) || padding < 0) throw new Error("Grid padding must be finite and nonnegative");
16656
17218
  if (labels && (labels.length !== rows || labels.some((row) => row.length !== columns))) {
16657
17219
  throw new Error("Grid labels must match rows and columns");
@@ -17078,14 +17640,14 @@ function weightedVectorState(options) {
17078
17640
  total: [...prefix2]
17079
17641
  };
17080
17642
  }
17081
- function positive4(value, name) {
17643
+ function positive5(value, name) {
17082
17644
  if (finite4(value, name) <= 0) throw new Error(`${name} must be positive`);
17083
17645
  }
17084
17646
  function bounds2(value, name) {
17085
17647
  finite4(value.x, `${name} x`);
17086
17648
  finite4(value.y, `${name} y`);
17087
- positive4(value.width, `${name} width`);
17088
- positive4(value.height, `${name} height`);
17649
+ positive5(value.width, `${name} width`);
17650
+ positive5(value.height, `${name} height`);
17089
17651
  }
17090
17652
  function createTeachingVectorAccumulation(painter) {
17091
17653
  return (options) => {
@@ -17106,9 +17668,9 @@ function createTeachingVectorAccumulation(painter) {
17106
17668
  } = options;
17107
17669
  bounds2(plot.bounds, "Vector plot");
17108
17670
  bounds2(ledger, "Vector ledger");
17109
- positive4(fontSize, "Vector font size");
17110
- positive4(width, "Vector stroke width");
17111
- positive4(endpointRadius, "Vector endpoint radius");
17671
+ positive5(fontSize, "Vector font size");
17672
+ positive5(width, "Vector stroke width");
17673
+ positive5(endpointRadius, "Vector endpoint radius");
17112
17674
  finite4(completedOpacity, "Completed vector opacity");
17113
17675
  if (completedOpacity < 0 || completedOpacity > 1) throw new Error("Completed vector opacity must lie between zero and one");
17114
17676
  const [x0, x1] = plot.xDomain, [y0, y1] = plot.yDomain;
@@ -17828,7 +18390,14 @@ function createTeachingTokenHistory(painter) {
17828
18390
  const progress = state.moving.progress;
17829
18391
  const settle = Math.max(0, (progress - 0.65) / 0.35);
17830
18392
  const grow = Math.max(0, (progress - 0.8) / 0.2);
17831
- const copyWidth = Math.min(from.width, fontSize * 3);
18393
+ const measuredWidth = painter.measureText?.(String(state.moving.token.token), fontSize, "mono");
18394
+ if (measuredWidth !== void 0 && (!Number.isFinite(measuredWidth) || measuredWidth < 0)) {
18395
+ throw new Error("Token history measured text width must be finite and nonnegative");
18396
+ }
18397
+ const copyWidth = Math.min(from.width, Math.max(
18398
+ fontSize * 3,
18399
+ measuredWidth === void 0 ? from.width : measuredWidth + 10
18400
+ ));
17832
18401
  const copyHeight = Math.min(from.height, fontSize * 1.8);
17833
18402
  const movingWidth = copyWidth + (from.width - copyWidth) * grow;
17834
18403
  const movingHeight = copyHeight + (from.height - copyHeight) * grow;
@@ -17861,15 +18430,15 @@ var PANEL = "#18283B";
17861
18430
  function finite6(value, name) {
17862
18431
  if (!Number.isFinite(value)) throw new Error(`${name} must be finite`);
17863
18432
  }
17864
- function positive5(value, name) {
18433
+ function positive6(value, name) {
17865
18434
  finite6(value, name);
17866
18435
  if (value <= 0) throw new Error(`${name} must be positive`);
17867
18436
  }
17868
18437
  function boundsOf(options) {
17869
18438
  finite6(options.x, "Teaching x");
17870
18439
  finite6(options.y, "Teaching y");
17871
- positive5(options.width, "Teaching width");
17872
- positive5(options.height, "Teaching height");
18440
+ positive6(options.width, "Teaching width");
18441
+ positive6(options.height, "Teaching height");
17873
18442
  return { x: options.x, y: options.y, width: options.width, height: options.height };
17874
18443
  }
17875
18444
  function amount(value, name = "Teaching progress") {
@@ -17905,7 +18474,7 @@ function createTeachingCanvas(painter) {
17905
18474
  }
17906
18475
  const { x, y, width, height } = bounds4;
17907
18476
  const { color = INK, gridColor, fontSize = 28, xTicks = [], yTicks = [], formatX = String, formatY = String } = options;
17908
- positive5(fontSize, "Axis font size");
18477
+ positive6(fontSize, "Axis font size");
17909
18478
  xTicks.forEach((tick) => finite6(tick, "Axis x tick"));
17910
18479
  yTicks.forEach((tick) => finite6(tick, "Axis y tick"));
17911
18480
  const plot = {
@@ -17946,7 +18515,7 @@ function createTeachingCanvas(painter) {
17946
18515
  }
17947
18516
  function curve(options) {
17948
18517
  const { plot, points, color, width = 4, progress = 1 } = options;
17949
- positive5(width, "Curve width");
18518
+ positive6(width, "Curve width");
17950
18519
  const mapped = points.map((point) => plot.point(point.x, point.y));
17951
18520
  const visible = tracePolyline(mapped, progress);
17952
18521
  if (visible.length > 1) painter.path(visible, { color, width, clip: plot.bounds });
@@ -17954,10 +18523,10 @@ function createTeachingCanvas(painter) {
17954
18523
  }
17955
18524
  function scatter(options) {
17956
18525
  const { plot, points, color = ACCENT, radius = 7, opacity = 1 } = options;
17957
- positive5(radius, "Scatter radius");
18526
+ positive6(radius, "Scatter radius");
17958
18527
  const alpha3 = amount(opacity, "Scatter opacity");
17959
18528
  const projected = points.map((point) => {
17960
- positive5(point.radius ?? radius, "Scatter point radius");
18529
+ positive6(point.radius ?? radius, "Scatter point radius");
17961
18530
  return {
17962
18531
  ...plot.point(point.x, point.y),
17963
18532
  radius: point.radius ?? radius,
@@ -17979,7 +18548,7 @@ function createTeachingCanvas(painter) {
17979
18548
  const bounds4 = boundsOf(options);
17980
18549
  const { x, y, width, height } = bounds4;
17981
18550
  const { values, labels, colors: colors2, color = ACCENT, progress = 1, showValues = false, format = String, fontSize = 28, gap = 20 } = options;
17982
- positive5(fontSize, "Bar font size");
18551
+ positive6(fontSize, "Bar font size");
17983
18552
  finite6(gap, "Bar gap");
17984
18553
  if (gap < 0) throw new Error("Bar gap must be nonnegative");
17985
18554
  values.forEach((value) => {
@@ -17990,12 +18559,12 @@ function createTeachingCanvas(painter) {
17990
18559
  if (colors2 && colors2.length !== values.length) throw new Error("Bar colors must match values");
17991
18560
  const maximumValue = values.reduce((maximum2, value) => Math.max(maximum2, value), 0);
17992
18561
  const maximum = options.max ?? (maximumValue || 1);
17993
- positive5(maximum, "Bar maximum");
18562
+ positive6(maximum, "Bar maximum");
17994
18563
  if (maximum < maximumValue) throw new Error("Bar maximum must contain every value");
17995
18564
  const reveal = amount(progress);
17996
18565
  if (!values.length) return { bars: [], slots: [], bounds: bounds4 };
17997
18566
  const barWidth = (width - gap * (values.length - 1)) / values.length;
17998
- positive5(barWidth, "Bar width after gaps");
18567
+ positive6(barWidth, "Bar width after gaps");
17999
18568
  const shapes = [];
18000
18569
  const slots = [];
18001
18570
  values.forEach((value, index) => {
@@ -18016,7 +18585,7 @@ function createTeachingCanvas(painter) {
18016
18585
  for (const node of nodes) {
18017
18586
  if (!node.id || Object.hasOwn(descriptors, node.id)) throw new Error("Flow node IDs must be nonempty and unique");
18018
18587
  const bounds4 = boundsOf(node);
18019
- positive5(node.fontSize ?? 30, "Flow node font size");
18588
+ positive6(node.fontSize ?? 30, "Flow node font size");
18020
18589
  finite6(node.radius ?? 14, "Flow node radius");
18021
18590
  if ((node.radius ?? 14) < 0) throw new Error("Flow node radius must be nonnegative");
18022
18591
  descriptors[node.id] = { ...bounds4, radius: node.radius ?? 14 };
@@ -18025,7 +18594,7 @@ function createTeachingCanvas(painter) {
18025
18594
  if (!Object.hasOwn(descriptors, edge.from) || !Object.hasOwn(descriptors, edge.to)) throw new Error("Flow edge must reference existing nodes");
18026
18595
  if (edge.from === edge.to) throw new Error("Flow edges must connect distinct nodes");
18027
18596
  if (edge.progress !== void 0) amount(edge.progress);
18028
- if (edge.width !== void 0) positive5(edge.width, "Flow edge width");
18597
+ if (edge.width !== void 0) positive6(edge.width, "Flow edge width");
18029
18598
  for (const gap of [edge.gap, edge.fromGap, edge.toGap]) {
18030
18599
  if (gap !== void 0) finite6(gap, "Flow edge gap");
18031
18600
  }
@@ -18272,6 +18841,35 @@ var import_promises3 = require("fs/promises");
18272
18841
  var import_path3 = require("path");
18273
18842
  var import_resvg_js3 = require("@resvg/resvg-js");
18274
18843
  var import_parse_css_color4 = __toESM(require("parse-css-color"), 1);
18844
+ function chapterMetadata(title, chapters, duration) {
18845
+ const escape = (value) => value.replace(/[\\=;#]/g, (c) => `\\${c}`).replace(/\r?\n/g, " ");
18846
+ const marks = chapters.filter((chapter) => Number.isFinite(chapter.time) && chapter.time < duration).map((chapter) => ({ title: chapter.title, time: Math.max(0, chapter.time) })).sort((a, b) => a.time - b.time);
18847
+ if (marks.length > 0) marks[0].time = 0;
18848
+ let out = ";FFMETADATA1\n";
18849
+ if (title) out += `title=${escape(title)}
18850
+ `;
18851
+ marks.forEach((mark, index) => {
18852
+ const end = index + 1 < marks.length ? marks[index + 1].time : duration;
18853
+ out += `[CHAPTER]
18854
+ TIMEBASE=1/1000
18855
+ START=${Math.round(mark.time * 1e3)}
18856
+ END=${Math.round(end * 1e3)}
18857
+ title=${escape(mark.title)}
18858
+ `;
18859
+ });
18860
+ return out;
18861
+ }
18862
+ function captionsToSrt(captions, duration) {
18863
+ const stamp = (seconds) => {
18864
+ const ms = Math.round(seconds * 1e3);
18865
+ const pad = (value, size = 2) => String(value).padStart(size, "0");
18866
+ return `${pad(Math.floor(ms / 36e5))}:${pad(Math.floor(ms / 6e4) % 60)}:${pad(Math.floor(ms / 1e3) % 60)},${pad(ms % 1e3, 3)}`;
18867
+ };
18868
+ return captions.filter((cue) => cue.t1 > 0 && cue.t0 < duration && cue.t1 > cue.t0 && cue.text.trim().length > 0).sort((a, b) => a.t0 - b.t0).map((cue, index) => `${index + 1}
18869
+ ${stamp(Math.max(0, cue.t0))} --> ${stamp(Math.min(duration, cue.t1))}
18870
+ ${cue.text.trim()}
18871
+ `).join("\n");
18872
+ }
18275
18873
  var MAX_STDERR_CHARS = 8192;
18276
18874
  var COLOR_FILTER = "scale=in_range=pc:out_range=tv:out_color_matrix=bt709:flags=lanczos+accurate_rnd+full_chroma_int,format=yuv420p,setparams=range=tv:color_primaries=bt709:color_trc=bt709:colorspace=bt709";
18277
18875
  var COLOR_TAGS = ["-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709", "-color_range", "tv"];
@@ -18485,12 +19083,37 @@ async function renderRgbaVideo(renderFrame2, options) {
18485
19083
  "-i",
18486
19084
  "pipe:0"
18487
19085
  ];
19086
+ let inputs = 1;
19087
+ let audioInput = -1;
18488
19088
  if (options.audioPath) {
18489
19089
  if (options.audioOffset) args.push("-ss", String(options.audioOffset));
18490
19090
  args.push("-i", (0, import_path3.resolve)(options.audioPath));
19091
+ audioInput = inputs++;
19092
+ }
19093
+ const sidecars = [];
19094
+ let metadataInput = -1, captionInput = -1;
19095
+ if (codec === "h264") {
19096
+ const chapters = options.chapters ?? [];
19097
+ if (options.title || chapters.length > 0) {
19098
+ const path = (0, import_path3.join)(outputDirectory, `.${(0, import_path3.basename)(outputPath)}.${(0, import_crypto.randomUUID)()}.tmp.ffmeta`);
19099
+ await (0, import_promises3.writeFile)(path, chapterMetadata(options.title, chapters, schedule.duration), { mode: 384 });
19100
+ sidecars.push(path);
19101
+ args.push("-f", "ffmetadata", "-i", path);
19102
+ metadataInput = inputs++;
19103
+ }
19104
+ const srt = captionsToSrt(options.captions ?? [], schedule.duration);
19105
+ if (srt) {
19106
+ const path = (0, import_path3.join)(outputDirectory, `.${(0, import_path3.basename)(outputPath)}.${(0, import_crypto.randomUUID)()}.tmp.srt`);
19107
+ await (0, import_promises3.writeFile)(path, srt, { mode: 384 });
19108
+ sidecars.push(path);
19109
+ args.push("-f", "srt", "-i", path);
19110
+ captionInput = inputs++;
19111
+ }
18491
19112
  }
18492
19113
  args.push("-map", "0:v:0");
18493
- if (options.audioPath) args.push("-map", "1:a:0", "-af", `asetpts=PTS-STARTPTS,apad,atrim=duration=${seconds}`);
19114
+ if (options.audioPath) args.push("-map", `${audioInput}:a:0`, "-af", `asetpts=PTS-STARTPTS,apad,atrim=duration=${seconds}`);
19115
+ if (captionInput >= 0) args.push("-map", `${captionInput}:0`, "-c:s", "mov_text", "-metadata:s:s:0", "language=eng");
19116
+ if (metadataInput >= 0) args.push("-map_metadata", String(metadataInput), "-map_chapters", String(metadataInput));
18494
19117
  args.push("-frames:v", String(schedule.count), "-t", seconds, "-vf", COLOR_FILTER);
18495
19118
  if (codec === "vp9") {
18496
19119
  args.push("-c:v", "libvpx-vp9", "-crf", String(crf), "-b:v", "0", "-deadline", "good", "-cpu-used", "2", "-row-mt", "1", "-threads:v", String(threads));
@@ -18514,6 +19137,7 @@ async function renderRgbaVideo(renderFrame2, options) {
18514
19137
  child = (0, import_child_process.spawn)(ffmpegPath, args, { stdio: ["pipe", "ignore", "pipe"] });
18515
19138
  } catch (error) {
18516
19139
  await (0, import_promises3.rm)(tempPath, { force: true });
19140
+ for (const path of sidecars) await (0, import_promises3.rm)(path, { force: true });
18517
19141
  throw error;
18518
19142
  }
18519
19143
  child.stderr?.on("data", (chunk) => {
@@ -18615,11 +19239,12 @@ async function renderRgbaVideo(renderFrame2, options) {
18615
19239
  throw error;
18616
19240
  } finally {
18617
19241
  await (0, import_promises3.rm)(tempPath, { force: true });
19242
+ for (const path of sidecars) await (0, import_promises3.rm)(path, { force: true });
18618
19243
  }
18619
19244
  }
18620
19245
 
18621
19246
  // src/scene-renderer.ts
18622
- var import_react21 = __toESM(require("react"), 1);
19247
+ var import_react22 = __toESM(require("react"), 1);
18623
19248
  var import_promises4 = require("fs/promises");
18624
19249
  var import_node_fs = require("fs");
18625
19250
  var import_node_path = require("path");
@@ -18803,6 +19428,7 @@ var SCENE_COMPONENT_NAMES = Object.freeze([
18803
19428
  "DiagramLegend",
18804
19429
  "DonutChart",
18805
19430
  "DotPoint",
19431
+ "EntityRelationshipDiagram",
18806
19432
  "EquationCard",
18807
19433
  "FactRows",
18808
19434
  "Flow",
@@ -19013,7 +19639,7 @@ function validateSceneComponentProps(name, props) {
19013
19639
  const check = (value, key) => {
19014
19640
  if (++values > 8192) throw new Error(`Editable scene ${name} props exceed their value budget.`);
19015
19641
  if (typeof value === "number") {
19016
- if (/^(?:width|height|x|y|x1|y1|x2|y2|cx|cy|r|rx|ry|radius|length|padding|gap|nodeWidth|nodeHeight|cellSize|cellWidth|cellHeight|fontSize|nodeSize|tileWidth|minHeight)$/i.test(key)) finite7(value, `${name}.${key}`);
19642
+ if (/^(?:width|height|x|y|x1|y1|x2|y2|cx|cy|r|rx|ry|radius|length|padding|gap|nodeWidth|nodeHeight|entityWidth|cellSize|cellWidth|cellHeight|fontSize|nodeSize|tileWidth|minHeight)$/i.test(key)) finite7(value, `${name}.${key}`);
19017
19643
  if (/^(?:rows|cols|columns|count|repeat|gridCount|tickCount)$/i.test(key)) integer(value, `${name}.${key}`, key === "gridCount" ? 0 : 1, 2e3);
19018
19644
  }
19019
19645
  if (Array.isArray(value)) value.forEach((item) => check(item, ""));
@@ -19041,6 +19667,12 @@ function validateSceneComponentProps(name, props) {
19041
19667
  for (const key of ["nodes", "groups", "boundaries", "blocks"]) entries(props[key], `${name}.${key}`, 128);
19042
19668
  for (const key of ["edges", "connections", "routes"]) entries(props[key], `${name}.${key}`, 256);
19043
19669
  }
19670
+ if (name === "EntityRelationshipDiagram") {
19671
+ entries(props.entities, "EntityRelationshipDiagram.entities", 128).forEach((entity) => {
19672
+ entries(record(entity, "Entity relationship entity").attributes, "EntityRelationshipDiagram.attributes", 64);
19673
+ });
19674
+ entries(props.relationships, "EntityRelationshipDiagram.relationships", 256);
19675
+ }
19044
19676
  if (name === "TransformerTopology" && props.expandRepeats) {
19045
19677
  const blocks = entries(props.blocks, "TransformerTopology.blocks", 128);
19046
19678
  const total = blocks.reduce((sum, block) => sum + integer(record(block, "Transformer block").repeat ?? 1, "Transformer block.repeat", 1, 128), 0);
@@ -19463,11 +20095,11 @@ function serializeSvg(node, budget, depth = 0) {
19463
20095
  if (node === null || node === void 0 || typeof node === "boolean") return "";
19464
20096
  if (typeof node === "string" || typeof node === "number") return emit(xml(node));
19465
20097
  if (Array.isArray(node)) return node.map((child) => serializeSvg(child, budget, depth + 1)).join("");
19466
- if (!import_react21.default.isValidElement(node)) throw new Error("Invalid resolved SVG child.");
19467
- if (node.type === import_react21.default.Fragment) return serializeSvg(node.props.children, budget, depth + 1);
20098
+ if (!import_react22.default.isValidElement(node)) throw new Error("Invalid resolved SVG child.");
20099
+ if (node.type === import_react22.default.Fragment) return serializeSvg(node.props.children, budget, depth + 1);
19468
20100
  if (node.type === SvgMathText) {
19469
20101
  const { text, x, y, fill, fontSize = 13, fontFamily = "JetBrains Mono", fontWeight = 700, textAnchor = "middle", dominantBaseline = "middle", opacity = 1 } = node.props;
19470
- return serializeSvg(import_react21.default.createElement("text", { x, y, fill, fontSize, fontFamily, fontWeight, textAnchor, dominantBaseline, opacity }, String(text)), budget, depth + 1);
20102
+ return serializeSvg(import_react22.default.createElement("text", { x, y, fill, fontSize, fontFamily, fontWeight, textAnchor, dominantBaseline, opacity }, String(text)), budget, depth + 1);
19471
20103
  }
19472
20104
  if (typeof node.type === "function") {
19473
20105
  return serializeSvg(node.type(node.props), budget, depth + 1);
@@ -19496,10 +20128,10 @@ function graphToReact(value, theme) {
19496
20128
  const props = Object.fromEntries(Object.entries(value.props).map(([name, prop]) => [name, convertProp(prop)]));
19497
20129
  const component = trustedComponents[value.type];
19498
20130
  if (component) props.c ??= theme;
19499
- return import_react21.default.createElement(component ?? value.type, props, ...value.children.map((child) => graphToReact(child, theme)));
20131
+ return import_react22.default.createElement(component ?? value.type, props, ...value.children.map((child) => graphToReact(child, theme)));
19500
20132
  }
19501
20133
  function renderSvgImage(element, assets, width, height, budget, outputScale = 1, includePng = true) {
19502
- const root = import_react21.default.cloneElement(element, { xmlns: "http://www.w3.org/2000/svg", width, height });
20134
+ const root = import_react22.default.cloneElement(element, { xmlns: "http://www.w3.org/2000/svg", width, height });
19503
20135
  const svg = serializeSvg(root, budget);
19504
20136
  const image = new import_resvg_js4.Resvg(svg, {
19505
20137
  font: { loadSystemFonts: false, fontFiles: assets.fontFiles, defaultFontFamily: "Inter" },
@@ -19512,7 +20144,7 @@ function renderSvgImage(element, assets, width, height, budget, outputScale = 1,
19512
20144
  function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
19513
20145
  if (++budget.nodes > SCENE_LIMITS.nodes * 16) throw new Error("Resolved scene exceeds its host element budget.");
19514
20146
  if (Array.isArray(node)) return node.map((child) => rasterizeNestedSvg(child, assets, defaultWidth, defaultHeight, budget));
19515
- if (!import_react21.default.isValidElement(node)) return node;
20147
+ if (!import_react22.default.isValidElement(node)) return node;
19516
20148
  if (node.type === "svg") {
19517
20149
  const width = typeof node.props.width === "number" ? node.props.width : defaultWidth;
19518
20150
  const height = typeof node.props.height === "number" ? node.props.height : defaultHeight;
@@ -19525,7 +20157,7 @@ function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
19525
20157
  throw new Error("Nested SVG rasterization exceeds the per-frame pixel or image budget.");
19526
20158
  }
19527
20159
  const { png } = renderSvgImage(node, assets, width, height, budget);
19528
- return import_react21.default.createElement("img", {
20160
+ return import_react22.default.createElement("img", {
19529
20161
  width,
19530
20162
  height,
19531
20163
  src: `data:image/png;base64,${Buffer.from(png).toString("base64")}`,
@@ -19534,20 +20166,20 @@ function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
19534
20166
  }
19535
20167
  if (typeof node.type === "function") return rasterizeNestedSvg(node.type(node.props), assets, defaultWidth, defaultHeight, budget);
19536
20168
  validateResolvedSceneResources(node.props);
19537
- return import_react21.default.cloneElement(node, {}, rasterizeNestedSvg(node.props.children, assets, defaultWidth, defaultHeight, budget));
20169
+ return import_react22.default.cloneElement(node, {}, rasterizeNestedSvg(node.props.children, assets, defaultWidth, defaultHeight, budget));
19538
20170
  }
19539
20171
  async function renderPreparedFrame(prepared, assets, time, outputScale, includePng) {
19540
20172
  const evaluated = await prepared.evaluate(time);
19541
20173
  const { width, height, theme } = prepared.request;
19542
20174
  const c = getThemeColors(theme);
19543
20175
  let element = graphToReact(evaluated.graph, c);
19544
- if (import_react21.default.isValidElement(element) && element.type === "svg") {
19545
- const image = renderSvgImage(import_react21.default.cloneElement(element, {
19546
- children: [import_react21.default.createElement("rect", { key: "__scene_background", width, height, fill: c.bg }), element.props.children]
20176
+ if (import_react22.default.isValidElement(element) && element.type === "svg") {
20177
+ const image = renderSvgImage(import_react22.default.cloneElement(element, {
20178
+ children: [import_react22.default.createElement("rect", { key: "__scene_background", width, height, fill: c.bg }), element.props.children]
19547
20179
  }), assets, width, height, { pixels: 0, count: 0, nodes: 0, svgBytes: 0 }, outputScale, includePng);
19548
20180
  return image;
19549
20181
  }
19550
- element = import_react21.default.createElement("div", { style: { display: "flex", position: "relative", width, height, backgroundColor: c.bg, fontFamily: "Inter", color: c.textPrimary } }, element);
20182
+ element = import_react22.default.createElement("div", { style: { display: "flex", position: "relative", width, height, backgroundColor: c.bg, fontFamily: "Inter", color: c.textPrimary } }, element);
19551
20183
  return withRenderContext({ background: "theme" }, async () => {
19552
20184
  element = rasterizeNestedSvg(element, assets, width, height, { pixels: 0, count: 0, nodes: 0, svgBytes: 0 });
19553
20185
  const accessible = prepareAccessibleSvg(element);
@@ -20215,7 +20847,7 @@ var import_path4 = require("path");
20215
20847
 
20216
20848
  // src/diagnostics.ts
20217
20849
  var import_parse_css_color5 = __toESM(require("parse-css-color"), 1);
20218
- var import_react22 = require("react");
20850
+ var import_react23 = require("react");
20219
20851
  var CHECK_DIAGNOSTIC_CODES = [
20220
20852
  "accessibility.low_contrast",
20221
20853
  "api.unsupported_prop",
@@ -20347,14 +20979,14 @@ function styleRecord(value) {
20347
20979
  return value;
20348
20980
  }
20349
20981
  function hasDirectText(children) {
20350
- return import_react22.Children.toArray(children).some((child) => typeof child === "string" || typeof child === "number");
20982
+ return import_react23.Children.toArray(children).some((child) => typeof child === "string" || typeof child === "number");
20351
20983
  }
20352
20984
  function elementId(props) {
20353
20985
  const value = props.id ?? props["data-vizmatic-id"];
20354
20986
  return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
20355
20987
  }
20356
20988
  function resolveFunctionComponent(node, trustedComponents2) {
20357
- if (!(0, import_react22.isValidElement)(node) || typeof node.type !== "function" || trustedComponents2.has(node.type)) return void 0;
20989
+ if (!(0, import_react23.isValidElement)(node) || typeof node.type !== "function" || trustedComponents2.has(node.type)) return void 0;
20358
20990
  const component = node.type;
20359
20991
  if (component.__vizmaticPrimitive) return void 0;
20360
20992
  if (component.prototype?.isReactComponent) return void 0;
@@ -20369,7 +21001,7 @@ function analyzeScene(element, theme, trustedComponents2, rootBackground2, svgCo
20369
21001
  const seen = /* @__PURE__ */ new Set();
20370
21002
  let visited = 0;
20371
21003
  function visit(node, inherited, path, namespace) {
20372
- if (visited++ >= MAX_CONTRAST_NODES || !(0, import_react22.isValidElement)(node)) return;
21004
+ if (visited++ >= MAX_CONTRAST_NODES || !(0, import_react23.isValidElement)(node)) return;
20373
21005
  const resolved = resolveFunctionComponent(node, trustedComponents2);
20374
21006
  if (resolved !== void 0) {
20375
21007
  visit(resolved, inherited, path, namespace);
@@ -20423,7 +21055,7 @@ function analyzeScene(element, theme, trustedComponents2, rootBackground2, svgCo
20423
21055
  }
20424
21056
  }
20425
21057
  }
20426
- import_react22.Children.forEach(props.children, (child, index) => visit(child, context, `${path}.${index}`, childNamespace));
21058
+ import_react23.Children.forEach(props.children, (child, index) => visit(child, context, `${path}.${index}`, childNamespace));
20427
21059
  }
20428
21060
  visit(element, { background: colorFromCss(rootBackground2) }, "root", "html");
20429
21061
  return diagnostics;
@@ -21116,6 +21748,7 @@ async function checkFrame(input, options = {}) {
21116
21748
  DonutChart,
21117
21749
  DotPoint,
21118
21750
  ELEMENT_SYMBOLS,
21751
+ EntityRelationshipDiagram,
21119
21752
  EquationCard,
21120
21753
  FactRows,
21121
21754
  Flow,
@@ -21191,7 +21824,9 @@ async function checkFrame(input, options = {}) {
21191
21824
  byteDifferenceState,
21192
21825
  cameraSvgTransform,
21193
21826
  canvas,
21827
+ captionsToSrt,
21194
21828
  categoricalSampling,
21829
+ chapterMetadata,
21195
21830
  checkFrame,
21196
21831
  colors,
21197
21832
  compareByteSequences,