vizmatic 0.7.0 → 0.7.1

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,
@@ -875,6 +876,7 @@ __export(primitives_exports, {
875
876
  DonutChart: () => DonutChart,
876
877
  DotPoint: () => DotPoint,
877
878
  ELEMENT_SYMBOLS: () => ELEMENT_SYMBOLS,
879
+ EntityRelationshipDiagram: () => EntityRelationshipDiagram,
878
880
  EquationCard: () => EquationCard,
879
881
  FactRows: () => FactRows,
880
882
  Flow: () => Flow,
@@ -2533,7 +2535,231 @@ function MetricCard({
2533
2535
  }
2534
2536
 
2535
2537
  // src/primitives/dense.ts
2536
- var import_react4 = __toESM(require("react"), 1);
2538
+ var import_react5 = __toESM(require("react"), 1);
2539
+
2540
+ // src/svg-accessibility.ts
2541
+ var import_react4 = require("react");
2542
+ var SVG_ACCESSIBILITY_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.svgAccessibilityComponent");
2543
+ function chartAccessibilityAttributes({ id, ariaLabel, description }) {
2544
+ const title = ariaLabel?.trim() || "Chart";
2545
+ return {
2546
+ role: "img",
2547
+ "aria-label": title,
2548
+ "aria-description": description,
2549
+ "data-vizmatic-chart-id": id,
2550
+ "data-vizmatic-chart-title": title,
2551
+ "data-vizmatic-chart-description": description
2552
+ };
2553
+ }
2554
+ function chartDescription(description, entries2) {
2555
+ return [description, entries2.length ? `${entries2.join("; ")}.` : "No data."].filter(Boolean).join(" ");
2556
+ }
2557
+ function componentHasSvgMetadata(type) {
2558
+ return typeof type === "function" && type[SVG_ACCESSIBILITY_COMPONENT] === true;
2559
+ }
2560
+ function svgToken(value) {
2561
+ if (value.length === 0) return "empty";
2562
+ return Array.from(value, (character) => {
2563
+ const codePoint = character.codePointAt(0) ?? 0;
2564
+ return /^[A-Za-z0-9.-]$/.test(character) ? character : `_u${codePoint.toString(16)}_`;
2565
+ }).join("");
2566
+ }
2567
+ function textProperty(props, name) {
2568
+ const value = props[name];
2569
+ return typeof value === "string" ? value : "";
2570
+ }
2571
+ function encodedTextProperty(props, name) {
2572
+ const value = textProperty(props, name);
2573
+ try {
2574
+ return decodeURIComponent(value);
2575
+ } catch {
2576
+ return value;
2577
+ }
2578
+ }
2579
+ function prepareAccessibleSvg(element) {
2580
+ const graphs = [];
2581
+ const explicitIds = /* @__PURE__ */ new Set();
2582
+ const visit = (node, graph) => {
2583
+ if (Array.isArray(node)) return node.map((child) => visit(child, graph));
2584
+ if (!(0, import_react4.isValidElement)(node)) return node;
2585
+ const component = node.type;
2586
+ if (componentHasSvgMetadata(component)) {
2587
+ return visit(component(node.props), graph);
2588
+ }
2589
+ const props = node.props;
2590
+ const title = textProperty(props, "data-vizmatic-svg-title");
2591
+ const isGraphRoot = title.length > 0;
2592
+ let activeGraph = graph;
2593
+ let elementKey = node.key;
2594
+ if (isGraphRoot) {
2595
+ const explicitId = textProperty(props, "data-vizmatic-svg-id");
2596
+ if (explicitId) {
2597
+ if (explicitIds.has(explicitId)) {
2598
+ throw new Error(`GraphDiagram SVG id "${explicitId}" must be unique in one exported SVG.`);
2599
+ }
2600
+ explicitIds.add(explicitId);
2601
+ }
2602
+ const index = graphs.length;
2603
+ const token = explicitId ? `id-${svgToken(explicitId)}` : `index-${index}`;
2604
+ activeGraph = {
2605
+ index,
2606
+ token,
2607
+ detectionKey: `vizmatic-graph-${index}`,
2608
+ title,
2609
+ description: textProperty(props, "data-vizmatic-svg-description"),
2610
+ nodes: [],
2611
+ edges: []
2612
+ };
2613
+ graphs.push(activeGraph);
2614
+ elementKey = activeGraph.detectionKey;
2615
+ }
2616
+ let nextProps;
2617
+ if (activeGraph && Object.hasOwn(props, "data-vizmatic-graph-node-id")) {
2618
+ const id = textProperty(props, "data-vizmatic-graph-node-id");
2619
+ const label = textProperty(props, "data-vizmatic-graph-node-label") || id;
2620
+ const detail = textProperty(props, "data-vizmatic-graph-node-detail");
2621
+ activeGraph.nodes.push({
2622
+ id,
2623
+ label,
2624
+ detail,
2625
+ title: textProperty(props, "data-vizmatic-graph-node-title") || label,
2626
+ href: textProperty(props, "data-vizmatic-graph-node-href") || void 0
2627
+ });
2628
+ elementKey = `${activeGraph.detectionKey}-node-${svgToken(id)}`;
2629
+ } else if (activeGraph && textProperty(props, "data-vizmatic-graph-edge-id")) {
2630
+ const id = encodedTextProperty(props, "data-vizmatic-graph-edge-id");
2631
+ activeGraph.edges.push({
2632
+ id,
2633
+ from: encodedTextProperty(props, "data-vizmatic-graph-edge-from"),
2634
+ to: encodedTextProperty(props, "data-vizmatic-graph-edge-to"),
2635
+ label: encodedTextProperty(props, "data-vizmatic-graph-edge-label"),
2636
+ title: encodedTextProperty(props, "data-vizmatic-graph-edge-title"),
2637
+ path: textProperty(props, "d"),
2638
+ href: encodedTextProperty(props, "data-vizmatic-graph-edge-href") || void 0
2639
+ });
2640
+ elementKey = `${activeGraph.detectionKey}-edge-${svgToken(id)}`;
2641
+ }
2642
+ const children = props.children;
2643
+ if (children === void 0) {
2644
+ if (isGraphRoot) {
2645
+ nextProps = { ...props, "data-vizmatic-svg-instance": activeGraph?.token };
2646
+ return (0, import_react4.cloneElement)(node, { ...nextProps, key: elementKey });
2647
+ }
2648
+ return node;
2649
+ }
2650
+ const preparedChildren = visit(children, activeGraph);
2651
+ nextProps = isGraphRoot ? { ...props, "data-vizmatic-svg-instance": activeGraph?.token } : { ...props };
2652
+ return (0, import_react4.cloneElement)(
2653
+ node,
2654
+ { ...nextProps, key: elementKey },
2655
+ preparedChildren
2656
+ );
2657
+ };
2658
+ return { element: visit(element), graphs };
2659
+ }
2660
+ function escapeXml(value) {
2661
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
2662
+ }
2663
+ function attribute(name, value) {
2664
+ return `${name}="${escapeXml(value)}"`;
2665
+ }
2666
+ function graphBaseId(graph) {
2667
+ return `vizmatic-graph-${graph.token}`;
2668
+ }
2669
+ function nodeId(graph, node) {
2670
+ return `${graphBaseId(graph)}-node-${svgToken(node.id)}`;
2671
+ }
2672
+ function edgeId(graph, edge) {
2673
+ return `${graphBaseId(graph)}-edge-${svgToken(edge.id)}`;
2674
+ }
2675
+ function labelForEdge(graph, edge) {
2676
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node.label]));
2677
+ const from = nodes.get(edge.from) ?? edge.from;
2678
+ const to = nodes.get(edge.to) ?? edge.to;
2679
+ return edge.title || (edge.label ? `${from} to ${to}: ${edge.label}` : `${from} to ${to}`);
2680
+ }
2681
+ function descriptionForEdge(graph, edge) {
2682
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node.label]));
2683
+ const from = nodes.get(edge.from) ?? edge.from;
2684
+ const to = nodes.get(edge.to) ?? edge.to;
2685
+ return `Relationship from ${from} to ${to}${edge.label ? `, labeled ${edge.label}` : ""}.`;
2686
+ }
2687
+ function nodeGroup(graph, node, layout) {
2688
+ const id = nodeId(graph, node);
2689
+ const label = node.detail ? `${node.label}: ${node.detail}` : node.label;
2690
+ const description = node.detail || node.label;
2691
+ const titleId = `${id}-title`;
2692
+ const descriptionId = `${id}-description`;
2693
+ 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>`;
2694
+ if (!layout) return `${accessible}</g>`;
2695
+ const rect = `<rect x="${layout.left}" y="${layout.top}" width="${layout.width}" height="${layout.height}" fill="transparent" pointer-events="all"/>`;
2696
+ const hitTarget = node.href ? `<a ${attribute("href", node.href)} role="link" tabindex="0" ${attribute("aria-label", label)}>${rect}</a>` : rect;
2697
+ return `${accessible}${hitTarget}</g>`;
2698
+ }
2699
+ function edgeGroup(graph, edge, root) {
2700
+ const id = edgeId(graph, edge);
2701
+ const title = labelForEdge(graph, edge);
2702
+ const titleId = `${id}-title`;
2703
+ const descriptionId = `${id}-description`;
2704
+ 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>`;
2705
+ if (!root || !edge.path) return `${accessible}</g>`;
2706
+ 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"/>`;
2707
+ const hitTarget = edge.href ? `<a ${attribute("href", edge.href)} role="link" tabindex="0" ${attribute("aria-label", title)}>${path}</a>` : path;
2708
+ return `${accessible}${hitTarget}</g>`;
2709
+ }
2710
+ function addSvgAccessibility(svg, graphs, layoutNodes) {
2711
+ const chartIds = /* @__PURE__ */ new Set();
2712
+ const charts = layoutNodes.filter((node) => textProperty(node.props, "data-vizmatic-chart-title")).map((node, index) => {
2713
+ const id = textProperty(node.props, "data-vizmatic-chart-id");
2714
+ if (id && chartIds.has(id)) throw new Error(`Chart SVG id "${id}" must be unique in one exported SVG.`);
2715
+ if (id) chartIds.add(id);
2716
+ return {
2717
+ token: id ? `id-${svgToken(id)}` : `index-${index}`,
2718
+ title: textProperty(node.props, "data-vizmatic-chart-title"),
2719
+ description: textProperty(node.props, "data-vizmatic-chart-description")
2720
+ };
2721
+ });
2722
+ if (graphs.length === 0 && charts.length === 0) return svg;
2723
+ const items = [...graphs, ...charts];
2724
+ const title = items.map((item) => item.title).join(". ");
2725
+ const description = items.map((item) => `${item.title}. ${item.description}`).join(" ");
2726
+ const hasLinks = graphs.some(
2727
+ (graph) => graph.nodes.some((node) => node.href) || graph.edges.some((edge) => edge.href)
2728
+ );
2729
+ const rootTitleId = "vizmatic-svg-title";
2730
+ const rootDescriptionId = "vizmatic-svg-description";
2731
+ const groupMarkup = graphs.map((graph) => {
2732
+ const baseId = graphBaseId(graph);
2733
+ const titleId = `${baseId}-title`;
2734
+ const descriptionId = `${baseId}-description`;
2735
+ const root = layoutNodes.find((node) => node.key === graph.detectionKey);
2736
+ const nodes = graph.nodes.map((item) => {
2737
+ const layout = layoutNodes.find((node) => node.key === `${graph.detectionKey}-node-${svgToken(item.id)}`);
2738
+ if (item.href && !layout) {
2739
+ throw new Error(`Could not resolve GraphDiagram node "${item.id}" bounds for SVG link export.`);
2740
+ }
2741
+ return nodeGroup(graph, item, layout);
2742
+ }).join("");
2743
+ const edges = graph.edges.map((item) => {
2744
+ if (item.href && !root) {
2745
+ throw new Error(`Could not resolve GraphDiagram bounds for SVG edge link export: "${item.id}".`);
2746
+ }
2747
+ return edgeGroup(graph, item, root);
2748
+ }).join("");
2749
+ 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>`;
2750
+ }).join("");
2751
+ const chartMarkup = charts.map((chart) => {
2752
+ const id = `vizmatic-chart-${chart.token}`;
2753
+ 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>`;
2754
+ }).join("");
2755
+ const metadata = `<title id="${rootTitleId}">${escapeXml(title)}</title><desc id="${rootDescriptionId}">${escapeXml(description)}</desc>`;
2756
+ return svg.replace(
2757
+ /^<svg\b([^>]*)>/,
2758
+ (_match, attrs) => `<svg${attrs} role="${hasLinks ? "group" : "img"}" aria-labelledby="${rootTitleId}" aria-describedby="${rootDescriptionId}">${metadata}`
2759
+ ).replace(/<\/svg>\s*$/, `${groupMarkup}${chartMarkup}</svg>`);
2760
+ }
2761
+
2762
+ // src/primitives/dense.ts
2537
2763
  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
2764
  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
2765
  function estimateTextWidth(text, fontSize, options = {}) {
@@ -2556,7 +2782,7 @@ function statusColor(status, c) {
2556
2782
  }
2557
2783
  function StatusDot({ status = "ok", c, size }) {
2558
2784
  const resolved = size ?? densityOf(c).f(8);
2559
- return import_react4.default.createElement("div", {
2785
+ return import_react5.default.createElement("div", {
2560
2786
  style: {
2561
2787
  display: "flex",
2562
2788
  flexShrink: 0,
@@ -2578,7 +2804,8 @@ function Sparkline({
2578
2804
  endDot = true,
2579
2805
  min,
2580
2806
  max,
2581
- strokeWidth
2807
+ strokeWidth,
2808
+ ...accessibility
2582
2809
  }) {
2583
2810
  const d = densityOf(c);
2584
2811
  const w = width ?? d.f(72);
@@ -2593,7 +2820,7 @@ function Sparkline({
2593
2820
  const y = (value) => inset + (1 - (value - low) / range) * (h - inset * 2);
2594
2821
  const path = values.map((value, index) => `${index === 0 ? "M" : "L"} ${x(index).toFixed(2)} ${y(value).toFixed(2)}`).join(" ");
2595
2822
  const last = values.length - 1;
2596
- return import_react4.default.createElement(
2823
+ const chart = import_react5.default.createElement(
2597
2824
  "svg",
2598
2825
  {
2599
2826
  width: w,
@@ -2603,12 +2830,12 @@ function Sparkline({
2603
2830
  style: { display: "flex", flexShrink: 0 }
2604
2831
  },
2605
2832
  ...compactChildren([
2606
- area && values.length > 1 && import_react4.default.createElement("path", {
2833
+ area && values.length > 1 && import_react5.default.createElement("path", {
2607
2834
  key: "area",
2608
2835
  d: `${path} L ${x(last).toFixed(2)} ${h} L ${x(0).toFixed(2)} ${h} Z`,
2609
2836
  fill: withColorAlpha(stroke, 0.14)
2610
2837
  }),
2611
- import_react4.default.createElement("path", {
2838
+ import_react5.default.createElement("path", {
2612
2839
  key: "line",
2613
2840
  d: path,
2614
2841
  fill: "none",
@@ -2617,7 +2844,7 @@ function Sparkline({
2617
2844
  strokeLinecap: "round",
2618
2845
  strokeLinejoin: "round"
2619
2846
  }),
2620
- endDot && values.length > 0 && import_react4.default.createElement("circle", {
2847
+ endDot && values.length > 0 && import_react5.default.createElement("circle", {
2621
2848
  key: "dot",
2622
2849
  cx: x(last),
2623
2850
  cy: y(values[last]),
@@ -2626,12 +2853,21 @@ function Sparkline({
2626
2853
  })
2627
2854
  ])
2628
2855
  );
2856
+ if (!accessibility.ariaLabel && !accessibility.description) return chart;
2857
+ return import_react5.default.createElement("div", {
2858
+ ...chartAccessibilityAttributes({
2859
+ ...accessibility,
2860
+ ariaLabel: accessibility.ariaLabel ?? "Sparkline",
2861
+ description: chartDescription(accessibility.description, values.map((value, index) => `Point ${index + 1}: ${value}`))
2862
+ }),
2863
+ style: { display: "flex", width: w, height: h, flexShrink: 0 }
2864
+ }, chart);
2629
2865
  }
2630
2866
  function InlineBar({ value, c, width = "100%", height, tone, color, warnAt }) {
2631
2867
  const d = densityOf(c);
2632
2868
  const fraction = Math.max(0, Math.min(1, value));
2633
2869
  const fill = color ?? (warnAt != null && fraction >= warnAt ? c.warningLight : tone ? getToneColor(tone, c) : c.textSecondary);
2634
- return import_react4.default.createElement("div", {
2870
+ return import_react5.default.createElement("div", {
2635
2871
  style: {
2636
2872
  display: "flex",
2637
2873
  width,
@@ -2640,30 +2876,30 @@ function InlineBar({ value, c, width = "100%", height, tone, color, warnAt }) {
2640
2876
  backgroundColor: c.borderSubtle,
2641
2877
  overflow: "hidden"
2642
2878
  }
2643
- }, import_react4.default.createElement("div", {
2879
+ }, import_react5.default.createElement("div", {
2644
2880
  style: { display: "flex", width: `${Math.round(fraction * 1e3) / 10}%`, height: "100%", backgroundColor: fill }
2645
2881
  }));
2646
2882
  }
2647
2883
  function FactRows({ rows, c, width = "100%", fontSize, mono = true, gap }) {
2648
2884
  const d = densityOf(c);
2649
2885
  const size = fontSize ?? d.type.micro;
2650
- return import_react4.default.createElement("div", {
2886
+ return import_react5.default.createElement("div", {
2651
2887
  style: { display: "flex", flexDirection: "column", width, gap: gap ?? d.s(2) }
2652
- }, ...rows.map((row, index) => import_react4.default.createElement(
2888
+ }, ...rows.map((row, index) => import_react5.default.createElement(
2653
2889
  "div",
2654
2890
  {
2655
2891
  key: `fact-${index}`,
2656
2892
  style: { display: "flex", flexDirection: "column", width: "100%", gap: 1 }
2657
2893
  },
2658
- import_react4.default.createElement(
2894
+ import_react5.default.createElement(
2659
2895
  "div",
2660
2896
  {
2661
2897
  style: { display: "flex", justifyContent: "space-between", alignItems: "baseline", width: "100%", gap: d.s(8), lineHeight: 1.25 }
2662
2898
  },
2663
- import_react4.default.createElement("div", {
2899
+ import_react5.default.createElement("div", {
2664
2900
  style: { display: "flex", flexShrink: 0, color: c.textMuted, fontFamily: c.fontSans, fontSize: size }
2665
2901
  }, row.key),
2666
- import_react4.default.createElement("div", {
2902
+ import_react5.default.createElement("div", {
2667
2903
  style: {
2668
2904
  display: "flex",
2669
2905
  color: row.tone ? getReadableToneColor(row.tone, c) : c.textPrimary,
@@ -2678,20 +2914,20 @@ function FactRows({ rows, c, width = "100%", fontSize, mono = true, gap }) {
2678
2914
  }
2679
2915
  function MetricStrip({ metrics, c, width = "100%", direction = "row", sparkWidth }) {
2680
2916
  const d = densityOf(c);
2681
- return import_react4.default.createElement("div", {
2917
+ return import_react5.default.createElement("div", {
2682
2918
  style: { display: "flex", flexDirection: direction, width, gap: direction === "row" ? d.s(14) : d.s(6) }
2683
- }, ...metrics.map((metric, index) => import_react4.default.createElement(
2919
+ }, ...metrics.map((metric, index) => import_react5.default.createElement(
2684
2920
  "div",
2685
2921
  {
2686
2922
  key: `metric-${index}`,
2687
2923
  style: { display: "flex", flexDirection: "column", flex: direction === "row" ? 1 : void 0, minWidth: 0, gap: d.s(1) }
2688
2924
  },
2689
- import_react4.default.createElement(
2925
+ import_react5.default.createElement(
2690
2926
  "div",
2691
2927
  {
2692
2928
  style: { display: "flex", alignItems: "baseline", gap: d.s(2), lineHeight: 1.1 }
2693
2929
  },
2694
- import_react4.default.createElement("div", {
2930
+ import_react5.default.createElement("div", {
2695
2931
  style: {
2696
2932
  display: "flex",
2697
2933
  color: metric.tone ? getReadableToneColor(metric.tone, c) : c.textPrimary,
@@ -2699,12 +2935,12 @@ function MetricStrip({ metrics, c, width = "100%", direction = "row", sparkWidth
2699
2935
  fontSize: d.f(14)
2700
2936
  }
2701
2937
  }, metric.value),
2702
- ...compactChildren([metric.unit != null && import_react4.default.createElement("div", {
2938
+ ...compactChildren([metric.unit != null && import_react5.default.createElement("div", {
2703
2939
  key: "unit",
2704
2940
  style: { display: "flex", color: c.textMuted, fontFamily: c.fontSans, fontSize: d.type.micro }
2705
2941
  }, metric.unit)])
2706
2942
  ),
2707
- import_react4.default.createElement("div", {
2943
+ import_react5.default.createElement("div", {
2708
2944
  style: { display: "flex", color: c.textMuted, fontFamily: c.fontSans, fontSize: d.type.micro, lineHeight: 1.2 }
2709
2945
  }, metric.label),
2710
2946
  ...compactChildren([
@@ -2715,9 +2951,9 @@ function MetricStrip({ metrics, c, width = "100%", direction = "row", sparkWidth
2715
2951
  }
2716
2952
  function TagList({ tags, c, tone }) {
2717
2953
  const d = densityOf(c);
2718
- return import_react4.default.createElement("div", {
2954
+ return import_react5.default.createElement("div", {
2719
2955
  style: { display: "flex", flexWrap: "wrap", gap: d.s(3) }
2720
- }, ...tags.map((tag, index) => import_react4.default.createElement("div", {
2956
+ }, ...tags.map((tag, index) => import_react5.default.createElement("div", {
2721
2957
  key: `tag-${index}`,
2722
2958
  style: {
2723
2959
  display: "flex",
@@ -2735,7 +2971,7 @@ function TagList({ tags, c, tone }) {
2735
2971
  function DiagramLegend({ items, c, title, width }) {
2736
2972
  const d = densityOf(c);
2737
2973
  const sample = d.f(18);
2738
- return import_react4.default.createElement(
2974
+ return import_react5.default.createElement(
2739
2975
  "div",
2740
2976
  {
2741
2977
  style: {
@@ -2751,11 +2987,11 @@ function DiagramLegend({ items, c, title, width }) {
2751
2987
  }
2752
2988
  },
2753
2989
  ...compactChildren([
2754
- title != null && import_react4.default.createElement("div", { key: "title", style: { display: "flex", color: c.textMuted } }, title),
2990
+ title != null && import_react5.default.createElement("div", { key: "title", style: { display: "flex", color: c.textMuted } }, title),
2755
2991
  ...items.map((item, index) => {
2756
2992
  const color = item.color ?? (item.tone ? getToneColor(item.tone, c) : c.textSecondary);
2757
2993
  const style = item.style ?? "solid";
2758
- const mark = style === "swatch" || style === "dot" ? import_react4.default.createElement("div", {
2994
+ const mark = style === "swatch" || style === "dot" ? import_react5.default.createElement("div", {
2759
2995
  style: {
2760
2996
  display: "flex",
2761
2997
  width: d.g(8),
@@ -2764,12 +3000,12 @@ function DiagramLegend({ items, c, title, width }) {
2764
3000
  borderRadius: style === "dot" ? 999 : 2,
2765
3001
  backgroundColor: color
2766
3002
  }
2767
- }) : import_react4.default.createElement("svg", {
3003
+ }) : import_react5.default.createElement("svg", {
2768
3004
  width: sample,
2769
3005
  height: d.g(8),
2770
3006
  viewBox: `0 0 ${sample} ${d.g(8)}`,
2771
3007
  style: { display: "flex", flexShrink: 0 }
2772
- }, import_react4.default.createElement("line", {
3008
+ }, import_react5.default.createElement("line", {
2773
3009
  x1: 0,
2774
3010
  x2: sample,
2775
3011
  y1: d.g(4),
@@ -2779,10 +3015,10 @@ function DiagramLegend({ items, c, title, width }) {
2779
3015
  strokeDasharray: style === "dashed" ? "5 3" : style === "dotted" ? "1.5 3" : void 0,
2780
3016
  strokeLinecap: style === "dotted" ? "round" : "butt"
2781
3017
  }));
2782
- return import_react4.default.createElement("div", {
3018
+ return import_react5.default.createElement("div", {
2783
3019
  key: `legend-${index}`,
2784
3020
  style: { display: "flex", alignItems: "center", gap: d.s(5) }
2785
- }, mark, import_react4.default.createElement("div", { style: { display: "flex" } }, item.label));
3021
+ }, mark, import_react5.default.createElement("div", { style: { display: "flex" } }, item.label));
2786
3022
  })
2787
3023
  ])
2788
3024
  );
@@ -2797,9 +3033,9 @@ function SmallMultiples({ items, c, columns, cellWidth, cellHeight, sharedScale
2797
3033
  const sharedMax = sharedScale ? Math.max(...all) : void 0;
2798
3034
  const rows = [];
2799
3035
  for (let i = 0; i < items.length; i += perRow) rows.push(items.slice(i, i + perRow));
2800
- return import_react4.default.createElement("div", {
3036
+ return import_react5.default.createElement("div", {
2801
3037
  style: { display: "flex", flexDirection: "column", gap: d.s(10) }
2802
- }, ...rows.map((row, rowIndex) => import_react4.default.createElement("div", {
3038
+ }, ...rows.map((row, rowIndex) => import_react5.default.createElement("div", {
2803
3039
  key: `multiples-row-${rowIndex}`,
2804
3040
  style: { display: "flex", gap: d.s(16) }
2805
3041
  }, ...row.map((item, index) => {
@@ -2807,37 +3043,37 @@ function SmallMultiples({ items, c, columns, cellWidth, cellHeight, sharedScale
2807
3043
  const high = sharedMax ?? Math.max(...item.values, ...item.reference != null ? [item.reference] : []);
2808
3044
  const range = high - low || 1;
2809
3045
  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(
3046
+ return import_react5.default.createElement(
2811
3047
  "div",
2812
3048
  {
2813
3049
  key: `multiple-${index}`,
2814
3050
  style: { display: "flex", flexDirection: "column", width, gap: d.s(2) }
2815
3051
  },
2816
- import_react4.default.createElement(
3052
+ import_react5.default.createElement(
2817
3053
  "div",
2818
3054
  {
2819
3055
  style: { display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: d.s(6), lineHeight: 1.2 }
2820
3056
  },
2821
- import_react4.default.createElement("div", {
3057
+ import_react5.default.createElement("div", {
2822
3058
  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", {
3059
+ }, ...compactChildren([item.status && import_react5.default.createElement(import_react5.default.Fragment, { key: "dot" }, StatusDot({ status: item.status, c, size: d.g(6) })), item.label])),
3060
+ item.value != null && import_react5.default.createElement("div", {
2825
3061
  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)]))
3062
+ }, ...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
3063
  ),
2828
- import_react4.default.createElement(
3064
+ import_react5.default.createElement(
2829
3065
  "div",
2830
3066
  {
2831
3067
  style: { display: "flex", position: "relative", width, height, borderBottom: `1px solid ${c.borderSubtle}` }
2832
3068
  },
2833
3069
  ...compactChildren([
2834
- referenceY != null && import_react4.default.createElement("svg", {
3070
+ referenceY != null && import_react5.default.createElement("svg", {
2835
3071
  key: "reference",
2836
3072
  width,
2837
3073
  height,
2838
3074
  viewBox: `0 0 ${width} ${height}`,
2839
3075
  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)}` })),
3076
+ }, 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
3077
  Sparkline({ values: item.values, c, tone: item.tone, width, height, area, min: low, max: high })
2842
3078
  ])
2843
3079
  )
@@ -2846,7 +3082,7 @@ function SmallMultiples({ items, c, columns, cellWidth, cellHeight, sharedScale
2846
3082
  }
2847
3083
 
2848
3084
  // src/primitives/content.ts
2849
- var import_react5 = __toESM(require("react"), 1);
3085
+ var import_react6 = __toESM(require("react"), 1);
2850
3086
  function ProgressRow({
2851
3087
  label,
2852
3088
  value,
@@ -2864,7 +3100,7 @@ function ProgressRow({
2864
3100
  const accent = muted ? c.textMuted : getToneColor(tone, c);
2865
3101
  const accentText = muted ? c.textMuted : getReadableToneColor(tone, c);
2866
3102
  const pct = Math.round(Math.max(0, Math.min(1, value)) * 100);
2867
- return import_react5.default.createElement(
3103
+ return import_react6.default.createElement(
2868
3104
  "div",
2869
3105
  {
2870
3106
  style: {
@@ -2874,7 +3110,7 @@ function ProgressRow({
2874
3110
  width: "100%"
2875
3111
  }
2876
3112
  },
2877
- import_react5.default.createElement("div", {
3113
+ import_react6.default.createElement("div", {
2878
3114
  style: {
2879
3115
  width: labelWidth,
2880
3116
  color: muted ? c.textMuted : c.textPrimary,
@@ -2883,7 +3119,7 @@ function ProgressRow({
2883
3119
  lineHeight: 1
2884
3120
  }
2885
3121
  }, label),
2886
- import_react5.default.createElement(
3122
+ import_react6.default.createElement(
2887
3123
  "div",
2888
3124
  {
2889
3125
  style: {
@@ -2895,7 +3131,7 @@ function ProgressRow({
2895
3131
  overflow: "hidden"
2896
3132
  }
2897
3133
  },
2898
- import_react5.default.createElement("div", {
3134
+ import_react6.default.createElement("div", {
2899
3135
  style: {
2900
3136
  width: `${pct}%`,
2901
3137
  height: "100%",
@@ -2904,7 +3140,7 @@ function ProgressRow({
2904
3140
  }
2905
3141
  })
2906
3142
  ),
2907
- import_react5.default.createElement("div", {
3143
+ import_react6.default.createElement("div", {
2908
3144
  style: {
2909
3145
  width: valueWidth,
2910
3146
  color: accentText,
@@ -2930,8 +3166,8 @@ function ProgressList({
2930
3166
  return Column({
2931
3167
  gap,
2932
3168
  align: "stretch",
2933
- children: rows.map((row, index) => import_react5.default.createElement(
2934
- import_react5.default.Fragment,
3169
+ children: rows.map((row, index) => import_react6.default.createElement(
3170
+ import_react6.default.Fragment,
2935
3171
  { key: `progress-${index}` },
2936
3172
  ProgressRow({
2937
3173
  ...row,
@@ -2954,7 +3190,8 @@ function MiniBarChart({
2954
3190
  gap: gapProp,
2955
3191
  radius: radiusProp,
2956
3192
  fontSize: fontSizeProp,
2957
- showValues = false
3193
+ showValues = false,
3194
+ ...accessibility
2958
3195
  }) {
2959
3196
  const gap = gapProp ?? densityOf(c).s(10);
2960
3197
  const radius = radiusProp ?? densityOf(c).r(3);
@@ -2963,9 +3200,18 @@ function MiniBarChart({
2963
3200
  const requestedMax = max != null && max > 0 ? max : void 0;
2964
3201
  const safeMax = requestedMax ?? Math.max(1, ...data.map((item) => Math.max(0, item.value)));
2965
3202
  const barMaxHeight = Math.max(minBarHeight, height - (showValues ? 34 : 20));
2966
- return import_react5.default.createElement(
3203
+ return import_react6.default.createElement(
2967
3204
  "div",
2968
3205
  {
3206
+ ...chartAccessibilityAttributes({
3207
+ ...accessibility,
3208
+ ariaLabel: accessibility.ariaLabel ?? "Mini bar chart",
3209
+ description: chartDescription(accessibility.description, data.map((item, index) => {
3210
+ const label = typeof item.label === "string" || typeof item.label === "number" ? item.label : `Item ${index + 1}`;
3211
+ const value = typeof item.valueLabel === "string" || typeof item.valueLabel === "number" ? item.valueLabel : item.value;
3212
+ return `${label}: ${value}`;
3213
+ }))
3214
+ }),
2969
3215
  style: {
2970
3216
  display: "flex",
2971
3217
  alignItems: "flex-end",
@@ -2981,7 +3227,7 @@ function MiniBarChart({
2981
3227
  const tone = item.tone ?? "blue";
2982
3228
  const barHeight = Math.max(minBarHeight, Math.round(Math.max(0, item.value) / safeMax * barMaxHeight));
2983
3229
  const fill = item.color ?? getToneColor(tone, c);
2984
- return import_react5.default.createElement(
3230
+ return import_react6.default.createElement(
2985
3231
  "div",
2986
3232
  {
2987
3233
  key: `mini-bar-${index}-${String(item.label)}`,
@@ -2996,7 +3242,7 @@ function MiniBarChart({
2996
3242
  }
2997
3243
  },
2998
3244
  ...compactChildren([
2999
- showValues && import_react5.default.createElement("div", {
3245
+ showValues && import_react6.default.createElement("div", {
3000
3246
  style: {
3001
3247
  display: "flex",
3002
3248
  color: getReadableToneColor(tone, c),
@@ -3006,7 +3252,7 @@ function MiniBarChart({
3006
3252
  lineHeight: 1
3007
3253
  }
3008
3254
  }, item.valueLabel ?? item.value),
3009
- import_react5.default.createElement("div", {
3255
+ import_react6.default.createElement("div", {
3010
3256
  style: {
3011
3257
  display: "flex",
3012
3258
  width: barWidth,
@@ -3016,7 +3262,7 @@ function MiniBarChart({
3016
3262
  opacity: item.opacity ?? 1
3017
3263
  }
3018
3264
  }),
3019
- import_react5.default.createElement("div", {
3265
+ import_react6.default.createElement("div", {
3020
3266
  style: {
3021
3267
  display: "flex",
3022
3268
  color: c.textMuted,
@@ -3049,7 +3295,7 @@ function DetailList({
3049
3295
  return Column({
3050
3296
  gap,
3051
3297
  align: "stretch",
3052
- children: items.map((item, index) => import_react5.default.createElement("div", {
3298
+ children: items.map((item, index) => import_react6.default.createElement("div", {
3053
3299
  key: `detail-${index}`,
3054
3300
  style: {
3055
3301
  display: "flex",
@@ -3085,7 +3331,7 @@ function Tile({
3085
3331
  const accent = getToneColor(tone ?? "neutral", c);
3086
3332
  const textAlign = align;
3087
3333
  const crossAlign = align === "center" ? "center" : "flex-start";
3088
- const detailLines = (lines ?? []).map((line, index) => import_react5.default.createElement(
3334
+ const detailLines = (lines ?? []).map((line, index) => import_react6.default.createElement(
3089
3335
  "div",
3090
3336
  {
3091
3337
  key: `tile-line-${index}`,
@@ -3100,7 +3346,7 @@ function Tile({
3100
3346
  textAlign
3101
3347
  }
3102
3348
  },
3103
- import_react5.default.createElement("span", {
3349
+ import_react6.default.createElement("span", {
3104
3350
  style: {
3105
3351
  display: "flex",
3106
3352
  width: 3,
@@ -3120,7 +3366,7 @@ function Tile({
3120
3366
  radius,
3121
3367
  shadow,
3122
3368
  borderColor: tone ? withColorAlpha(accent, 0.5) : c.border,
3123
- children: import_react5.default.createElement(
3369
+ children: import_react6.default.createElement(
3124
3370
  "div",
3125
3371
  {
3126
3372
  style: {
@@ -3133,10 +3379,10 @@ function Tile({
3133
3379
  }
3134
3380
  },
3135
3381
  ...compactChildren([
3136
- icon != null && import_react5.default.createElement("div", {
3382
+ icon != null && import_react6.default.createElement("div", {
3137
3383
  style: { display: "flex", fontSize: densityOf(c).f(22), lineHeight: 1 }
3138
3384
  }, icon),
3139
- eyebrow != null && import_react5.default.createElement("div", {
3385
+ eyebrow != null && import_react6.default.createElement("div", {
3140
3386
  style: {
3141
3387
  ...typeOf(c, "tiny"),
3142
3388
  color: tone ? getReadableToneColor(tone, c) : c.textMuted,
@@ -3145,7 +3391,7 @@ function Tile({
3145
3391
  textAlign
3146
3392
  }
3147
3393
  }, renderMaybeMath(eyebrow, math)),
3148
- import_react5.default.createElement("div", {
3394
+ import_react6.default.createElement("div", {
3149
3395
  style: {
3150
3396
  ...typeOf(c, "label"),
3151
3397
  color: c.textPrimary,
@@ -3154,7 +3400,7 @@ function Tile({
3154
3400
  textAlign
3155
3401
  }
3156
3402
  }, renderMaybeMath(title, math)),
3157
- subtitle != null && import_react5.default.createElement("div", {
3403
+ subtitle != null && import_react6.default.createElement("div", {
3158
3404
  style: {
3159
3405
  ...typeOf(c, "tiny"),
3160
3406
  color: c.textSecondary,
@@ -3162,7 +3408,7 @@ function Tile({
3162
3408
  textAlign
3163
3409
  }
3164
3410
  }, renderMaybeMath(subtitle, math)),
3165
- detailLines.length > 0 && import_react5.default.createElement("div", {
3411
+ detailLines.length > 0 && import_react6.default.createElement("div", {
3166
3412
  style: {
3167
3413
  width: "100%",
3168
3414
  display: "flex",
@@ -3187,8 +3433,8 @@ function TileGrid({
3187
3433
  math = false
3188
3434
  }) {
3189
3435
  const gap = gapProp ?? densityOf(c).s(12);
3190
- const renderTile = (tile, index) => import_react5.default.createElement(
3191
- import_react5.default.Fragment,
3436
+ const renderTile = (tile, index) => import_react6.default.createElement(
3437
+ import_react6.default.Fragment,
3192
3438
  { key: `tile-${index}` },
3193
3439
  Tile({
3194
3440
  ...tile,
@@ -3209,15 +3455,15 @@ function TileGrid({
3209
3455
  return Column({
3210
3456
  gap,
3211
3457
  align: "stretch",
3212
- children: rows.map((rowTiles, rowIndex) => import_react5.default.createElement(
3213
- import_react5.default.Fragment,
3458
+ children: rows.map((rowTiles, rowIndex) => import_react6.default.createElement(
3459
+ import_react6.default.Fragment,
3214
3460
  { key: `tile-row-${rowIndex}` },
3215
3461
  Row({ gap, align: "stretch", justify: "start", children: rowTiles.map((tile, colIndex) => renderTile(tile, rowIndex * columns + colIndex)) })
3216
3462
  ))
3217
3463
  });
3218
3464
  }
3219
3465
  function isCodeLineSpec(line) {
3220
- return typeof line === "object" && line !== null && !import_react5.default.isValidElement(line) && "text" in line;
3466
+ return typeof line === "object" && line !== null && !import_react6.default.isValidElement(line) && "text" in line;
3221
3467
  }
3222
3468
  function CodeBlock({
3223
3469
  lines,
@@ -3244,7 +3490,7 @@ function CodeBlock({
3244
3490
  const accent = spec.tone ? getToneColor(spec.tone, c) : void 0;
3245
3491
  const accentText = spec.tone && accent ? getReadableToneColor(spec.tone, c, withColorAlpha(accent, 31 / 255), background ?? c.bgSubtle) : void 0;
3246
3492
  const textColor = spec.dim ? c.textMuted : accentText ?? c.textSecondary;
3247
- return import_react5.default.createElement(
3493
+ return import_react6.default.createElement(
3248
3494
  "div",
3249
3495
  {
3250
3496
  key: `code-line-${index}`,
@@ -3260,7 +3506,7 @@ function CodeBlock({
3260
3506
  }
3261
3507
  },
3262
3508
  ...compactChildren([
3263
- showLineNumbers && import_react5.default.createElement("div", {
3509
+ showLineNumbers && import_react6.default.createElement("div", {
3264
3510
  style: {
3265
3511
  display: "flex",
3266
3512
  width: numberWidth,
@@ -3272,7 +3518,7 @@ function CodeBlock({
3272
3518
  lineHeight: 1.5
3273
3519
  }
3274
3520
  }, String(index + 1)),
3275
- spec.prefix != null && import_react5.default.createElement("div", {
3521
+ spec.prefix != null && import_react6.default.createElement("div", {
3276
3522
  style: {
3277
3523
  display: "flex",
3278
3524
  flexShrink: 0,
@@ -3283,7 +3529,7 @@ function CodeBlock({
3283
3529
  lineHeight: 1.5
3284
3530
  }
3285
3531
  }, spec.prefix),
3286
- import_react5.default.createElement("div", {
3532
+ import_react6.default.createElement("div", {
3287
3533
  style: {
3288
3534
  display: "flex",
3289
3535
  flex: 1,
@@ -3298,7 +3544,7 @@ function CodeBlock({
3298
3544
  ])
3299
3545
  );
3300
3546
  });
3301
- return import_react5.default.createElement(
3547
+ return import_react6.default.createElement(
3302
3548
  "div",
3303
3549
  {
3304
3550
  style: {
@@ -3316,7 +3562,7 @@ function CodeBlock({
3316
3562
  }
3317
3563
  },
3318
3564
  ...compactChildren([
3319
- title != null && import_react5.default.createElement(
3565
+ title != null && import_react6.default.createElement(
3320
3566
  "div",
3321
3567
  {
3322
3568
  style: {
@@ -3331,7 +3577,7 @@ function CodeBlock({
3331
3577
  fontWeight: 400
3332
3578
  }
3333
3579
  },
3334
- import_react5.default.createElement("span", {
3580
+ import_react6.default.createElement("span", {
3335
3581
  style: {
3336
3582
  display: "flex",
3337
3583
  width: 8,
@@ -3343,7 +3589,7 @@ function CodeBlock({
3343
3589
  }),
3344
3590
  renderMaybeMath(title, math)
3345
3591
  ),
3346
- import_react5.default.createElement("div", {
3592
+ import_react6.default.createElement("div", {
3347
3593
  style: {
3348
3594
  display: "flex",
3349
3595
  flexDirection: "column",
@@ -3356,7 +3602,7 @@ function CodeBlock({
3356
3602
  }
3357
3603
  function renderComparisonDivider(divider, c, key) {
3358
3604
  const label = divider === true ? "vs" : divider;
3359
- return import_react5.default.createElement(
3605
+ return import_react6.default.createElement(
3360
3606
  "div",
3361
3607
  {
3362
3608
  key,
@@ -3369,7 +3615,7 @@ function renderComparisonDivider(divider, c, key) {
3369
3615
  flexShrink: 0
3370
3616
  }
3371
3617
  },
3372
- import_react5.default.createElement("div", {
3618
+ import_react6.default.createElement("div", {
3373
3619
  style: {
3374
3620
  display: "flex",
3375
3621
  alignItems: "center",
@@ -3401,8 +3647,8 @@ function Comparison({
3401
3647
  const gap = gapProp ?? densityOf(c).s(14);
3402
3648
  const children = sides2.flatMap((side, index) => {
3403
3649
  const tone = side.tone;
3404
- const panel = import_react5.default.createElement(
3405
- import_react5.default.Fragment,
3650
+ const panel = import_react6.default.createElement(
3651
+ import_react6.default.Fragment,
3406
3652
  { key: `comparison-side-${index}` },
3407
3653
  Panel({
3408
3654
  c,
@@ -3413,10 +3659,10 @@ function Comparison({
3413
3659
  width: side.width ?? sideWidth,
3414
3660
  minHeight,
3415
3661
  bodyStyle: { gap: 8 },
3416
- children: side.eyebrow != null ? import_react5.default.createElement(
3662
+ children: side.eyebrow != null ? import_react6.default.createElement(
3417
3663
  "div",
3418
3664
  { style: { display: "flex", flexDirection: "column", gap: 8 } },
3419
- import_react5.default.createElement("div", {
3665
+ import_react6.default.createElement("div", {
3420
3666
  style: {
3421
3667
  ...typeOf(c, "tiny"),
3422
3668
  color: c.textMuted,
@@ -3453,7 +3699,7 @@ function KeyValueList({
3453
3699
  const accent = row.tone ? getReadableToneColor(row.tone, c) : void 0;
3454
3700
  const isLast = index === rows.length - 1;
3455
3701
  const valueMono = row.valueMono ?? true;
3456
- return import_react5.default.createElement(
3702
+ return import_react6.default.createElement(
3457
3703
  "div",
3458
3704
  {
3459
3705
  key: `kv-row-${index}`,
@@ -3468,7 +3714,7 @@ function KeyValueList({
3468
3714
  boxSizing: "border-box"
3469
3715
  }
3470
3716
  },
3471
- import_react5.default.createElement("div", {
3717
+ import_react6.default.createElement("div", {
3472
3718
  style: {
3473
3719
  display: "flex",
3474
3720
  ...keyWidth != null ? { width: keyWidth, flexShrink: 0 } : {},
@@ -3479,7 +3725,7 @@ function KeyValueList({
3479
3725
  lineHeight: 1.3
3480
3726
  }
3481
3727
  }, renderMaybeMath(row.key, math)),
3482
- import_react5.default.createElement("div", {
3728
+ import_react6.default.createElement("div", {
3483
3729
  style: {
3484
3730
  display: "flex",
3485
3731
  flex: 1,
@@ -3494,7 +3740,7 @@ function KeyValueList({
3494
3740
  }, renderMaybeMath(row.value, math))
3495
3741
  );
3496
3742
  });
3497
- return import_react5.default.createElement(
3743
+ return import_react6.default.createElement(
3498
3744
  "div",
3499
3745
  {
3500
3746
  style: {
@@ -3506,7 +3752,7 @@ function KeyValueList({
3506
3752
  }
3507
3753
  },
3508
3754
  ...compactChildren([
3509
- title != null && import_react5.default.createElement("div", {
3755
+ title != null && import_react6.default.createElement("div", {
3510
3756
  style: {
3511
3757
  display: "flex",
3512
3758
  ...typeOf(c, "small"),
@@ -3541,11 +3787,11 @@ function WindowFrame({
3541
3787
  const isTerminal = variant === "terminal";
3542
3788
  const surface = background ?? (isTerminal ? c.bgSubtle : c.bgCard);
3543
3789
  const titleColor = isTerminal ? getReadableToneColor(tone, c, c.bgHover) : c.textSecondary;
3544
- const trafficDot = (color, key) => import_react5.default.createElement("span", {
3790
+ const trafficDot = (color, key) => import_react6.default.createElement("span", {
3545
3791
  key,
3546
3792
  style: { display: "flex", width: densityOf(c).g(9), height: densityOf(c).g(9), borderRadius: 999, backgroundColor: color }
3547
3793
  });
3548
- const titleBar = import_react5.default.createElement(
3794
+ const titleBar = import_react6.default.createElement(
3549
3795
  "div",
3550
3796
  {
3551
3797
  style: {
@@ -3560,7 +3806,7 @@ function WindowFrame({
3560
3806
  }
3561
3807
  },
3562
3808
  ...compactChildren([
3563
- dots && import_react5.default.createElement(
3809
+ dots && import_react6.default.createElement(
3564
3810
  "div",
3565
3811
  {
3566
3812
  style: { display: "flex", alignItems: "center", gap: densityOf(c).s(6), flexShrink: 0 }
@@ -3569,7 +3815,7 @@ function WindowFrame({
3569
3815
  trafficDot(c.borderLight, "dot-y"),
3570
3816
  trafficDot(c.borderLight, "dot-g")
3571
3817
  ),
3572
- title != null && (variant === "browser" ? import_react5.default.createElement("div", {
3818
+ title != null && (variant === "browser" ? import_react6.default.createElement("div", {
3573
3819
  style: {
3574
3820
  display: "flex",
3575
3821
  flex: 1,
@@ -3585,7 +3831,7 @@ function WindowFrame({
3585
3831
  fontWeight: 600,
3586
3832
  lineHeight: 1
3587
3833
  }
3588
- }, title) : import_react5.default.createElement("div", {
3834
+ }, title) : import_react6.default.createElement("div", {
3589
3835
  style: {
3590
3836
  display: "flex",
3591
3837
  flex: 1,
@@ -3597,12 +3843,12 @@ function WindowFrame({
3597
3843
  lineHeight: 1
3598
3844
  }
3599
3845
  }, title)),
3600
- dots && title != null && variant !== "browser" && import_react5.default.createElement("div", {
3846
+ dots && title != null && variant !== "browser" && import_react6.default.createElement("div", {
3601
3847
  style: { display: "flex", width: 52, flexShrink: 0 }
3602
3848
  }, "")
3603
3849
  ])
3604
3850
  );
3605
- return import_react5.default.createElement(
3851
+ return import_react6.default.createElement(
3606
3852
  "div",
3607
3853
  {
3608
3854
  style: {
@@ -3621,7 +3867,7 @@ function WindowFrame({
3621
3867
  }
3622
3868
  },
3623
3869
  titleBar,
3624
- import_react5.default.createElement("div", {
3870
+ import_react6.default.createElement("div", {
3625
3871
  style: {
3626
3872
  display: "flex",
3627
3873
  flexDirection: "column",
@@ -3636,7 +3882,7 @@ function WindowFrame({
3636
3882
  }
3637
3883
 
3638
3884
  // src/primitives/flows.ts
3639
- var import_react6 = __toESM(require("react"), 1);
3885
+ var import_react7 = __toESM(require("react"), 1);
3640
3886
  var statusGlyphs = {
3641
3887
  check: "\u2713",
3642
3888
  cross: "\u2717",
@@ -3673,7 +3919,7 @@ function StatusRow({
3673
3919
  const markerBackground = withColorAlpha(accent, markerBackgroundAlpha / 255);
3674
3920
  const accentText = getReadableToneColor(resolvedTone, c, markerBackground, c.bgCard);
3675
3921
  const glyph = statusGlyphs[status];
3676
- const marker = import_react6.default.createElement("div", {
3922
+ const marker = import_react7.default.createElement("div", {
3677
3923
  style: {
3678
3924
  display: "flex",
3679
3925
  alignItems: "center",
@@ -3691,7 +3937,7 @@ function StatusRow({
3691
3937
  lineHeight: 1
3692
3938
  }
3693
3939
  }, glyph);
3694
- return import_react6.default.createElement(
3940
+ return import_react7.default.createElement(
3695
3941
  "div",
3696
3942
  {
3697
3943
  style: {
@@ -3709,7 +3955,7 @@ function StatusRow({
3709
3955
  }
3710
3956
  },
3711
3957
  marker,
3712
- import_react6.default.createElement("div", {
3958
+ import_react7.default.createElement("div", {
3713
3959
  style: {
3714
3960
  display: "flex",
3715
3961
  flex: 1,
@@ -3720,7 +3966,7 @@ function StatusRow({
3720
3966
  lineHeight: 1.3
3721
3967
  }
3722
3968
  }, renderMaybeMath(label, math)),
3723
- detail != null && import_react6.default.createElement("div", {
3969
+ detail != null && import_react7.default.createElement("div", {
3724
3970
  style: {
3725
3971
  display: "flex",
3726
3972
  flexShrink: 0,
@@ -3747,8 +3993,8 @@ function StatusList({
3747
3993
  gap,
3748
3994
  align: "stretch",
3749
3995
  ...width != null ? { width } : {},
3750
- children: rows.map((row, index) => import_react6.default.createElement(
3751
- import_react6.default.Fragment,
3996
+ children: rows.map((row, index) => import_react7.default.createElement(
3997
+ import_react7.default.Fragment,
3752
3998
  { key: `status-${index}` },
3753
3999
  StatusRow({ ...row, c, boxed, fontSize, math })
3754
4000
  ))
@@ -3758,7 +4004,7 @@ function renderTimelineCard(event, c, math, width) {
3758
4004
  const resolvedTone = event.tone ?? statusTones[event.status ?? "dot"];
3759
4005
  const accentText = getReadableToneColor(resolvedTone, c);
3760
4006
  const resolvedWidth = event.width ?? width;
3761
- return import_react6.default.createElement(
4007
+ return import_react7.default.createElement(
3762
4008
  "div",
3763
4009
  {
3764
4010
  style: {
@@ -3772,7 +4018,7 @@ function renderTimelineCard(event, c, math, width) {
3772
4018
  }
3773
4019
  },
3774
4020
  ...compactChildren([
3775
- event.time != null && import_react6.default.createElement("div", {
4021
+ event.time != null && import_react7.default.createElement("div", {
3776
4022
  style: {
3777
4023
  display: "flex",
3778
4024
  color: event.tone || event.status ? accentText : c.textMuted,
@@ -3782,7 +4028,7 @@ function renderTimelineCard(event, c, math, width) {
3782
4028
  lineHeight: 1.15
3783
4029
  }
3784
4030
  }, renderMaybeMath(event.time, math)),
3785
- import_react6.default.createElement("div", {
4031
+ import_react7.default.createElement("div", {
3786
4032
  style: {
3787
4033
  display: "flex",
3788
4034
  color: c.textPrimary,
@@ -3793,7 +4039,7 @@ function renderTimelineCard(event, c, math, width) {
3793
4039
  ...textFitStyle()
3794
4040
  }
3795
4041
  }, renderMaybeMath(event.title, math)),
3796
- event.detail != null && import_react6.default.createElement("div", {
4042
+ event.detail != null && import_react7.default.createElement("div", {
3797
4043
  style: {
3798
4044
  display: "flex",
3799
4045
  color: c.textSecondary,
@@ -3821,7 +4067,7 @@ function Timeline({
3821
4067
  }) {
3822
4068
  const markerSize = markerSizeProp ?? densityOf(c).g(9);
3823
4069
  const gap = gapProp ?? densityOf(c).s(12);
3824
- const header = (title != null || subtitle != null) && import_react6.default.createElement(
4070
+ const header = (title != null || subtitle != null) && import_react7.default.createElement(
3825
4071
  "div",
3826
4072
  {
3827
4073
  style: {
@@ -3832,7 +4078,7 @@ function Timeline({
3832
4078
  }
3833
4079
  },
3834
4080
  ...compactChildren([
3835
- title != null && import_react6.default.createElement("div", {
4081
+ title != null && import_react7.default.createElement("div", {
3836
4082
  style: {
3837
4083
  display: "flex",
3838
4084
  alignItems: "center",
@@ -3844,7 +4090,7 @@ function Timeline({
3844
4090
  lineHeight: 1.2
3845
4091
  }
3846
4092
  }, renderMaybeMath(title, math)),
3847
- subtitle != null && import_react6.default.createElement("div", {
4093
+ subtitle != null && import_react7.default.createElement("div", {
3848
4094
  style: {
3849
4095
  display: "flex",
3850
4096
  color: c.textSecondary,
@@ -3857,7 +4103,7 @@ function Timeline({
3857
4103
  ])
3858
4104
  );
3859
4105
  if (direction === "horizontal") {
3860
- return import_react6.default.createElement(
4106
+ return import_react7.default.createElement(
3861
4107
  "div",
3862
4108
  {
3863
4109
  style: {
@@ -3869,7 +4115,7 @@ function Timeline({
3869
4115
  },
3870
4116
  ...compactChildren([
3871
4117
  header,
3872
- import_react6.default.createElement("div", {
4118
+ import_react7.default.createElement("div", {
3873
4119
  style: {
3874
4120
  display: "flex",
3875
4121
  alignItems: "stretch",
@@ -3878,7 +4124,7 @@ function Timeline({
3878
4124
  }
3879
4125
  }, ...events.map((event, index) => {
3880
4126
  const accent = getToneColor(event.tone ?? statusTones[event.status ?? "dot"], c);
3881
- return import_react6.default.createElement(
4127
+ return import_react7.default.createElement(
3882
4128
  "div",
3883
4129
  {
3884
4130
  key: `timeline-h-${index}`,
@@ -3891,7 +4137,7 @@ function Timeline({
3891
4137
  minWidth: 0
3892
4138
  }
3893
4139
  },
3894
- import_react6.default.createElement(
4140
+ import_react7.default.createElement(
3895
4141
  "div",
3896
4142
  {
3897
4143
  style: {
@@ -3900,7 +4146,7 @@ function Timeline({
3900
4146
  width: "100%"
3901
4147
  }
3902
4148
  },
3903
- import_react6.default.createElement("div", {
4149
+ import_react7.default.createElement("div", {
3904
4150
  style: {
3905
4151
  display: "flex",
3906
4152
  flex: 1,
@@ -3909,7 +4155,7 @@ function Timeline({
3909
4155
  opacity: index === 0 ? 0 : 1
3910
4156
  }
3911
4157
  }),
3912
- import_react6.default.createElement("div", {
4158
+ import_react7.default.createElement("div", {
3913
4159
  style: {
3914
4160
  display: "flex",
3915
4161
  width: markerSize,
@@ -3919,7 +4165,7 @@ function Timeline({
3919
4165
  flexShrink: 0
3920
4166
  }
3921
4167
  }),
3922
- import_react6.default.createElement("div", {
4168
+ import_react7.default.createElement("div", {
3923
4169
  style: {
3924
4170
  display: "flex",
3925
4171
  flex: 1,
@@ -3935,7 +4181,7 @@ function Timeline({
3935
4181
  ])
3936
4182
  );
3937
4183
  }
3938
- return import_react6.default.createElement(
4184
+ return import_react7.default.createElement(
3939
4185
  "div",
3940
4186
  {
3941
4187
  style: {
@@ -3947,7 +4193,7 @@ function Timeline({
3947
4193
  },
3948
4194
  ...compactChildren([
3949
4195
  header,
3950
- import_react6.default.createElement("div", {
4196
+ import_react7.default.createElement("div", {
3951
4197
  style: {
3952
4198
  display: "flex",
3953
4199
  flexDirection: "column",
@@ -3956,7 +4202,7 @@ function Timeline({
3956
4202
  }
3957
4203
  }, ...events.map((event, index) => {
3958
4204
  const accent = getToneColor(event.tone ?? statusTones[event.status ?? "dot"], c);
3959
- return import_react6.default.createElement(
4205
+ return import_react7.default.createElement(
3960
4206
  "div",
3961
4207
  {
3962
4208
  key: `timeline-v-${index}`,
@@ -3967,7 +4213,7 @@ function Timeline({
3967
4213
  width: "100%"
3968
4214
  }
3969
4215
  },
3970
- import_react6.default.createElement(
4216
+ import_react7.default.createElement(
3971
4217
  "div",
3972
4218
  {
3973
4219
  style: {
@@ -3978,7 +4224,7 @@ function Timeline({
3978
4224
  flexShrink: 0
3979
4225
  }
3980
4226
  },
3981
- import_react6.default.createElement("div", {
4227
+ import_react7.default.createElement("div", {
3982
4228
  style: {
3983
4229
  display: "flex",
3984
4230
  flex: 1,
@@ -3988,7 +4234,7 @@ function Timeline({
3988
4234
  opacity: index === 0 ? 0 : 1
3989
4235
  }
3990
4236
  }),
3991
- import_react6.default.createElement("div", {
4237
+ import_react7.default.createElement("div", {
3992
4238
  style: {
3993
4239
  display: "flex",
3994
4240
  width: markerSize,
@@ -3998,7 +4244,7 @@ function Timeline({
3998
4244
  flexShrink: 0
3999
4245
  }
4000
4246
  }),
4001
- import_react6.default.createElement("div", {
4247
+ import_react7.default.createElement("div", {
4002
4248
  style: {
4003
4249
  display: "flex",
4004
4250
  flex: 1,
@@ -4039,247 +4285,55 @@ function renderFlowStage(stage, c, math) {
4039
4285
  c,
4040
4286
  width: stage.width,
4041
4287
  minWidth: stage.minWidth,
4042
- minHeight: stage.minHeight,
4043
- padding: stage.padding ?? 12,
4044
- bodyStyle: { gap: 8 },
4045
- children: stage.children ?? DetailList({ items: stage.lines ?? [], c, tone, math })
4046
- });
4047
- }
4048
- function Flow({
4049
- stages,
4050
- c,
4051
- 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>`);
4288
+ minHeight: stage.minHeight,
4289
+ padding: stage.padding ?? 12,
4290
+ bodyStyle: { gap: 8 },
4291
+ children: stage.children ?? DetailList({ items: stage.lines ?? [], c, tone, math })
4292
+ });
4293
+ }
4294
+ function Flow({
4295
+ stages,
4296
+ c,
4297
+ direction = "horizontal",
4298
+ gap: gapProp,
4299
+ connectorLength: connectorLengthProp,
4300
+ connectorTone = "neutral",
4301
+ align = "center",
4302
+ math = false
4303
+ }) {
4304
+ const connectorLength = connectorLengthProp ?? densityOf(c).s(32);
4305
+ const gap = gapProp ?? densityOf(c).s(10);
4306
+ const isHorizontal = direction === "horizontal";
4307
+ const children = stages.flatMap((stage, index) => {
4308
+ const elements = [
4309
+ import_react7.default.createElement(import_react7.default.Fragment, { key: `stage-${index}` }, renderFlowStage(stage, c, math))
4310
+ ];
4311
+ if (index < stages.length - 1) {
4312
+ elements.push(import_react7.default.createElement(
4313
+ import_react7.default.Fragment,
4314
+ { key: `connector-${index}` },
4315
+ FlowArrow({
4316
+ direction: isHorizontal ? "right" : "down",
4317
+ length: connectorLength,
4318
+ c,
4319
+ tone: connectorTone
4320
+ })
4321
+ ));
4322
+ }
4323
+ return elements;
4324
+ });
4325
+ return (isHorizontal ? Row : Column)({
4326
+ gap,
4327
+ align,
4328
+ justify: isHorizontal ? "start" : "center",
4329
+ children
4330
+ });
4281
4331
  }
4282
4332
 
4333
+ // src/primitives/diagrams.ts
4334
+ var import_react8 = __toESM(require("react"), 1);
4335
+ var import_dagre = __toESM(require("@dagrejs/dagre"), 1);
4336
+
4283
4337
  // src/graph-routing.ts
4284
4338
  var EPSILON = 1e-3;
4285
4339
  var MAX_GRID_POINTS = 18e3;
@@ -7634,6 +7688,398 @@ function DeploymentDiagram({
7634
7688
  }
7635
7689
  Object.defineProperty(DeploymentDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
7636
7690
 
7691
+ // src/primitives/entity-relationship.ts
7692
+ var import_react11 = __toESM(require("react"), 1);
7693
+ var import_dagre2 = __toESM(require("@dagrejs/dagre"), 1);
7694
+ var cardinalityWords = {
7695
+ one: "exactly one",
7696
+ "zero-or-one": "zero or one",
7697
+ "one-or-many": "one or more",
7698
+ "zero-or-many": "zero or more"
7699
+ };
7700
+ var legendLines = [
7701
+ "PK primary key \xB7 FK foreign key \xB7 UQ unique \xB7 ? nullable",
7702
+ "|| one \xB7 o| zero or one \xB7 |< one or more \xB7 o< zero or more"
7703
+ ];
7704
+ function requiredText(value, label) {
7705
+ if (typeof value !== "string" || !value.trim()) throw new Error(`EntityRelationshipDiagram ${label} must be a non-empty string.`);
7706
+ }
7707
+ function positive(value, label, allowZero = false) {
7708
+ if (!Number.isFinite(value) || (allowZero ? value < 0 : value <= 0)) {
7709
+ throw new RangeError(`EntityRelationshipDiagram ${label} must be a finite ${allowZero ? "non-negative" : "positive"} number.`);
7710
+ }
7711
+ }
7712
+ function endpointAttributes(endpoint2) {
7713
+ return endpoint2.attribute === void 0 ? [] : typeof endpoint2.attribute === "string" ? [endpoint2.attribute] : endpoint2.attribute;
7714
+ }
7715
+ function attributeDescription(attribute2) {
7716
+ const constraints = [attribute2.primaryKey && "primary key", attribute2.foreignKey && "foreign key", attribute2.unique && "unique", attribute2.nullable ? "nullable" : "not null"].filter(Boolean);
7717
+ return `${attribute2.name} (${attribute2.type}, ${constraints.join(", ")})`;
7718
+ }
7719
+ function endpointDescription(endpoint2, entities) {
7720
+ const entity = entities.get(endpoint2.entity);
7721
+ const attributes = endpointAttributes(endpoint2);
7722
+ return `${entity.label ?? entity.id}${attributes.length ? ` [${attributes.join(", ")}]` : ""}`;
7723
+ }
7724
+ function validate(entities, relationships) {
7725
+ if (!entities.length) throw new Error("EntityRelationshipDiagram requires at least one entity.");
7726
+ const byId = /* @__PURE__ */ new Map();
7727
+ for (const entity of entities) {
7728
+ requiredText(entity.id, "entity id");
7729
+ if (byId.has(entity.id)) throw new Error(`EntityRelationshipDiagram has duplicate entity id "${entity.id}".`);
7730
+ if (entity.label !== void 0) requiredText(entity.label, `entity "${entity.id}" label`);
7731
+ const names = /* @__PURE__ */ new Set();
7732
+ for (const attribute2 of entity.attributes) {
7733
+ requiredText(attribute2.name, `entity "${entity.id}" attribute name`);
7734
+ requiredText(attribute2.type, `attribute "${entity.id}.${attribute2.name}" type`);
7735
+ if (names.has(attribute2.name)) throw new Error(`EntityRelationshipDiagram has duplicate attribute "${entity.id}.${attribute2.name}".`);
7736
+ if (attribute2.primaryKey && attribute2.nullable) throw new Error(`EntityRelationshipDiagram primary key "${entity.id}.${attribute2.name}" cannot be nullable.`);
7737
+ names.add(attribute2.name);
7738
+ }
7739
+ byId.set(entity.id, entity);
7740
+ }
7741
+ const ids = /* @__PURE__ */ new Set();
7742
+ for (const relationship of relationships) {
7743
+ requiredText(relationship.id, "relationship id");
7744
+ if (ids.has(relationship.id)) throw new Error(`EntityRelationshipDiagram has duplicate relationship id "${relationship.id}".`);
7745
+ ids.add(relationship.id);
7746
+ for (const endpoint2 of [relationship.from, relationship.to]) {
7747
+ const entity = byId.get(endpoint2.entity);
7748
+ if (!entity) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" references missing entity "${endpoint2.entity}".`);
7749
+ if (!Object.hasOwn(cardinalityWords, endpoint2.cardinality)) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" has invalid cardinality "${endpoint2.cardinality}".`);
7750
+ const attributes = endpointAttributes(endpoint2);
7751
+ if (endpoint2.attribute !== void 0 && attributes.length === 0) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" needs at least one endpoint attribute.`);
7752
+ if (new Set(attributes).size !== attributes.length) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" repeats an endpoint attribute.`);
7753
+ for (const name of attributes) {
7754
+ if (!entity.attributes.some((attribute2) => attribute2.name === name)) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" references missing attribute "${entity.id}.${name}".`);
7755
+ }
7756
+ }
7757
+ const from = endpointAttributes(relationship.from), to = endpointAttributes(relationship.to);
7758
+ if (from.length && to.length && from.length !== to.length) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" has mismatched composite attribute counts.`);
7759
+ }
7760
+ return byId;
7761
+ }
7762
+ function cardinalitySize(cardinality, scale) {
7763
+ const many = cardinality.endsWith("many"), optional = cardinality.startsWith("zero");
7764
+ return { length: ((optional ? many ? 25 : 19 : many ? 20 : 12) + 0.75) * scale, halfWidth: ((many ? 6 : 5) + 0.75) * scale };
7765
+ }
7766
+ function cardinalityBounds(cardinality, point, toward, scale) {
7767
+ const size = cardinalitySize(cardinality, scale);
7768
+ const horizontal = point.y === toward.y;
7769
+ const end = { x: point.x + Math.sign(toward.x - point.x) * size.length, y: point.y + Math.sign(toward.y - point.y) * size.length };
7770
+ return {
7771
+ left: Math.min(point.x, end.x) - (horizontal ? 0.75 * scale : size.halfWidth),
7772
+ right: Math.max(point.x, end.x) + (horizontal ? 0.75 * scale : size.halfWidth),
7773
+ top: Math.min(point.y, end.y) - (horizontal ? size.halfWidth : 0.75 * scale),
7774
+ bottom: Math.max(point.y, end.y) + (horizontal ? size.halfWidth : 0.75 * scale)
7775
+ };
7776
+ }
7777
+ function cardinalityGlyph(cardinality, point, toward, color, background, scale, key) {
7778
+ const length = Math.hypot(toward.x - point.x, toward.y - point.y);
7779
+ const ux = (toward.x - point.x) / length, uy = (toward.y - point.y) / length;
7780
+ const at = (along, across = 0) => ({ x: point.x + (ux * along - uy * across) * scale, y: point.y + (uy * along + ux * across) * scale });
7781
+ const bar = (along) => {
7782
+ const a = at(along, -5), b = at(along, 5);
7783
+ return `M ${a.x} ${a.y} L ${b.x} ${b.y}`;
7784
+ };
7785
+ const many = cardinality.endsWith("many");
7786
+ const optional = cardinality.startsWith("zero");
7787
+ const middle = at(13), top = at(0, -6), bottom = at(0, 6);
7788
+ 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);
7789
+ const circle = at(many ? 21 : 15);
7790
+ return import_react11.default.createElement(
7791
+ "g",
7792
+ { key, "data-er-cardinality": cardinality },
7793
+ import_react11.default.createElement("path", { d: `${path}${optional ? "" : ` ${bar(many ? 20 : 12)}`}`, fill: "none", stroke: color, strokeWidth: 1.5 * scale }),
7794
+ optional && import_react11.default.createElement("circle", { cx: circle.x, cy: circle.y, r: 4 * scale, fill: background, stroke: color, strokeWidth: 1.5 * scale })
7795
+ );
7796
+ }
7797
+ function EntityRelationshipDiagram({
7798
+ c: baseTheme,
7799
+ entities,
7800
+ relationships = [],
7801
+ title,
7802
+ description,
7803
+ id,
7804
+ direction = "LR",
7805
+ width,
7806
+ height,
7807
+ entityWidth,
7808
+ fontSize,
7809
+ padding: paddingProp,
7810
+ gap: gapProp,
7811
+ showLegend = true,
7812
+ density
7813
+ }) {
7814
+ const c = density === void 0 ? baseTheme : withDensity(baseTheme, density);
7815
+ const d = densityOf(c);
7816
+ const visibleTitle = title?.trim();
7817
+ const svgTitle = visibleTitle || "Entity relationship diagram";
7818
+ const textSize = fontSize ?? d.type.small;
7819
+ const headerSize = Math.max(textSize, d.type.label);
7820
+ const padding = paddingProp ?? d.s(32);
7821
+ const gap = gapProp ?? d.s(100);
7822
+ positive(textSize, "fontSize");
7823
+ positive(padding, "padding", true);
7824
+ positive(gap, "gap");
7825
+ if (width !== void 0) positive(width, "width");
7826
+ if (height !== void 0) positive(height, "height");
7827
+ if (entityWidth !== void 0) positive(entityWidth, "entityWidth");
7828
+ if (id !== void 0) requiredText(id, "id");
7829
+ if (!["LR", "RL", "TB", "BT"].includes(direction)) throw new Error("EntityRelationshipDiagram direction must be LR, RL, TB, or BT.");
7830
+ const byId = validate(entities, relationships);
7831
+ const lineScale = Math.max(0.8, textSize / 12);
7832
+ const markerSizes = relationships.flatMap((relationship) => [cardinalitySize(relationship.from.cardinality, lineScale), cardinalitySize(relationship.to.cardinality, lineScale)]);
7833
+ const markerLength = Math.max(0, ...markerSizes.map((size) => size.length));
7834
+ const markerPitch = Math.max(0, ...markerSizes.map((size) => size.halfWidth * 2)) + Math.max(d.s(4), lineScale * 1.5);
7835
+ const baseClearance = Math.max(28, d.s(28));
7836
+ const routingClearance = Math.max(baseClearance, markerLength + d.s(4) + Math.max(2, d.s(2)));
7837
+ const enlargedMarkers = routingClearance > baseClearance;
7838
+ const bodyPadding = enlargedMarkers && relationships.some((relationship) => relationship.from.entity === relationship.to.entity) ? Math.max(padding, routingClearance + d.s(4)) : padding;
7839
+ const anchorRow = (endpoint2) => {
7840
+ const entity = byId.get(endpoint2.entity), names = endpointAttributes(endpoint2);
7841
+ 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);
7842
+ };
7843
+ const rowEndpointCounts = new Map(entities.map((entity) => [entity.id, /* @__PURE__ */ new Map()]));
7844
+ const entityEndpointCounts = /* @__PURE__ */ new Map();
7845
+ for (const relationship of relationships) for (const endpoint2 of [relationship.from, relationship.to]) {
7846
+ const counts2 = rowEndpointCounts.get(endpoint2.entity), row = anchorRow(endpoint2);
7847
+ counts2.set(row, (counts2.get(row) ?? 0) + 1);
7848
+ entityEndpointCounts.set(endpoint2.entity, (entityEndpointCounts.get(endpoint2.entity) ?? 0) + 1);
7849
+ }
7850
+ const rowHeight = Math.ceil(Math.max(d.s(25), textSize * 1.7));
7851
+ const headerHeight = Math.ceil(Math.max(d.s(35), headerSize * 2));
7852
+ const inset = d.s(12);
7853
+ const keyWidth = Math.ceil(estimateTextWidth("PK FK UQ", textSize, { mono: true })) + inset;
7854
+ const titleHeight = visibleTitle ? Math.ceil(d.type.heading * 1.5 + d.s(12)) : 0;
7855
+ const legendHeight = showLegend ? Math.ceil(textSize * 3.2 + d.s(12)) : 0;
7856
+ const legendWidth = showLegend ? Math.max(480, ...legendLines.map((line) => estimateTextWidth(line, textSize) + padding * 2)) : 0;
7857
+ const labelPadding = relationships.some((relationship) => relationship.label) ? Math.ceil(textSize * 2 + d.s(8)) : 0;
7858
+ const graph = new import_dagre2.default.graphlib.Graph({ multigraph: true }).setGraph({
7859
+ rankdir: direction,
7860
+ nodesep: enlargedMarkers ? Math.max(gap * 0.75, routingClearance * 2 + markerPitch) : gap * 0.75,
7861
+ ranksep: Math.max(gap, 74, routingClearance * 2 + markerPitch),
7862
+ edgesep: d.s(26),
7863
+ marginx: 0,
7864
+ marginy: 0
7865
+ }).setDefaultEdgeLabel(() => ({}));
7866
+ const measures = new Map(entities.map((entity) => {
7867
+ const nameWidth = Math.max(30, ...entity.attributes.map((attribute2) => estimateTextWidth(attribute2.name, textSize, { mono: true })));
7868
+ const typeWidth = Math.max(24, ...entity.attributes.map((attribute2) => estimateTextWidth(attribute2.type + (attribute2.nullable ? "?" : ""), textSize, { mono: true })));
7869
+ 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)));
7870
+ let rowY = headerHeight;
7871
+ const rowCenters = rowHeights.map((height2) => {
7872
+ const center2 = rowY + height2 / 2;
7873
+ rowY += height2;
7874
+ return center2;
7875
+ });
7876
+ const measured = {
7877
+ width: Math.ceil(Math.max(
7878
+ entityWidth ?? d.s(210),
7879
+ estimateTextWidth(entity.label ?? entity.id, headerSize, { weight: 600 }) + inset * 2,
7880
+ keyWidth + nameWidth + typeWidth + inset * 4,
7881
+ direction === "TB" || direction === "BT" ? markerPitch * ((entityEndpointCounts.get(entity.id) ?? 0) + 1) : 0
7882
+ )),
7883
+ height: rowY,
7884
+ rowHeights,
7885
+ rowCenters,
7886
+ typeWidth: Math.ceil(typeWidth)
7887
+ };
7888
+ graph.setNode(entity.id, { width: measured.width, height: measured.height });
7889
+ return [entity.id, measured];
7890
+ }));
7891
+ for (const relationship of relationships) graph.setEdge(relationship.from.entity, relationship.to.entity, {
7892
+ width: relationship.label ? estimateTextWidth(relationship.label, textSize) + d.s(64) : 0,
7893
+ height: relationship.label ? textSize * 2 : 0,
7894
+ labelpos: "c"
7895
+ }, relationship.id);
7896
+ import_dagre2.default.layout(graph);
7897
+ const graphWidth = graph.graph().width ?? 0, graphHeight = graph.graph().height ?? 0;
7898
+ const minWidth = Math.ceil(Math.max(graphWidth + (bodyPadding + labelPadding) * 2, legendWidth, visibleTitle ? estimateTextWidth(visibleTitle, d.type.heading, { weight: 600 }) + padding * 2 : 0));
7899
+ const minHeight = Math.ceil(graphHeight + (bodyPadding + labelPadding) * 2 + titleHeight + legendHeight);
7900
+ if (width !== void 0 && width < minWidth) throw new RangeError(`EntityRelationshipDiagram width needs at least ${minWidth}px to keep entity text readable.`);
7901
+ if (height !== void 0 && height < minHeight) throw new RangeError(`EntityRelationshipDiagram height needs at least ${minHeight}px to keep entity text readable.`);
7902
+ const resolvedWidth = width ?? minWidth, resolvedHeight = height ?? minHeight;
7903
+ const offsetX = (resolvedWidth - graphWidth) / 2;
7904
+ const offsetY = bodyPadding + titleHeight + labelPadding + (resolvedHeight - minHeight) / 2;
7905
+ const nodes = entities.map((entity) => {
7906
+ const node = graph.node(entity.id), measure = measures.get(entity.id);
7907
+ return { id: entity.id, cx: node.x + offsetX, cy: node.y + offsetY, width: measure.width, height: measure.height, ports: [] };
7908
+ });
7909
+ const nodeById = new Map(nodes.map((node) => [node.id, node]));
7910
+ const portRequests = [];
7911
+ const endpointPort = (endpoint2, other, port) => {
7912
+ const node = nodeById.get(endpoint2.entity), target = nodeById.get(other.entity);
7913
+ const horizontal = direction === "LR" || direction === "RL";
7914
+ const side = node === target ? "right" : horizontal ? target.cx >= node.cx ? "right" : "left" : target.cy >= node.cy ? "bottom" : "top";
7915
+ const desired = side === "top" || side === "bottom" ? node.width / 2 : measures.get(node.id).rowCenters[anchorRow(endpoint2)];
7916
+ portRequests.push({ node, id: port, side, desired });
7917
+ };
7918
+ const edges = relationships.map((relationship, index) => {
7919
+ const fromPort = `from-${index}`, toPort = `to-${index}`;
7920
+ endpointPort(relationship.from, relationship.to, fromPort);
7921
+ endpointPort(relationship.to, relationship.from, toPort);
7922
+ return { from: relationship.from.entity, to: relationship.to.entity, fromPort, toPort };
7923
+ });
7924
+ for (const node of nodes) for (const side of ["left", "right", "top", "bottom"]) {
7925
+ const requests = portRequests.filter((request) => request.node === node && request.side === side).sort((a, b) => a.desired - b.desired);
7926
+ const extent = side === "left" || side === "right" ? node.height : node.width;
7927
+ const positions = [];
7928
+ for (let start = 0; start < requests.length; ) {
7929
+ let end = start + 1;
7930
+ while (end < requests.length && requests[end].desired === requests[start].desired) end++;
7931
+ for (let index = start; index < end; index++) positions[index] = requests[index].desired + (index - start - (end - start - 1) / 2) * markerPitch;
7932
+ start = end;
7933
+ }
7934
+ for (let index = 0; index < positions.length; index++) positions[index] = Math.max(positions[index], index ? positions[index - 1] + markerPitch : markerPitch / 2);
7935
+ 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);
7936
+ requests.forEach((request, index) => node.ports.push({ id: request.id, side, offset: positions[index] / extent }));
7937
+ }
7938
+ const routed = routeOrthogonalGraph(nodes, edges, resolvedWidth, resolvedHeight - legendHeight, routingClearance, Math.max(d.s(18), markerPitch));
7939
+ if (routed.failures.length) throw new Error(`EntityRelationshipDiagram could not route relationship "${relationships[routed.failures[0].index].id}": ${routed.failures[0].reason}`);
7940
+ 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"}.`;
7941
+ 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(" ")}`;
7942
+ const lineColor = c.textSecondary;
7943
+ const labels = [];
7944
+ const placedLabels = [];
7945
+ const markerBoxes = relationships.flatMap((relationship, index) => {
7946
+ const points = routed.routes.get(index);
7947
+ return [cardinalityBounds(relationship.from.cardinality, points[0], points[1], lineScale), cardinalityBounds(relationship.to.cardinality, points.at(-1), points.at(-2), lineScale)];
7948
+ });
7949
+ 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 }));
7950
+ const paths = relationships.flatMap((relationship, index) => {
7951
+ const points = routed.routes.get(index);
7952
+ const path = roundedPolylinePath(points, d.s(4)).d;
7953
+ if (relationship.label) {
7954
+ 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) }));
7955
+ const labelWidth = Math.ceil(estimateTextWidth(relationship.label, textSize)) + d.s(10);
7956
+ const labelHeight = Math.ceil(textSize * 1.4) + 4;
7957
+ const candidates = segments.sort((a, b) => b.length - a.length).flatMap((segment) => {
7958
+ return [0.5, 0.25, 0.75].flatMap((fraction) => [1, 2, 3].flatMap((distance) => [-1, 1].map((side) => {
7959
+ const x = segment.a.x + (segment.b.x - segment.a.x) * fraction;
7960
+ const y = segment.a.y + (segment.b.y - segment.a.y) * fraction;
7961
+ const horizontal = segment.a.y === segment.b.y;
7962
+ const cx = x + (horizontal ? 0 : side * (labelWidth / 2 + d.s(6)) * distance);
7963
+ const cy = y + (horizontal ? side * (labelHeight / 2 + d.s(6)) * distance : 0);
7964
+ return { left: cx - labelWidth / 2, right: cx + labelWidth / 2, top: cy - labelHeight / 2, bottom: cy + labelHeight / 2 };
7965
+ })));
7966
+ });
7967
+ 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)));
7968
+ if (!label) throw new Error(`EntityRelationshipDiagram could not place label for relationship "${relationship.id}" without covering the schema. Increase gap or canvas size.`);
7969
+ placedLabels.push(label);
7970
+ labels.push(import_react11.default.createElement("div", { key: `label-${relationship.id}`, style: {
7971
+ position: "absolute",
7972
+ left: label.left,
7973
+ top: label.top,
7974
+ width: labelWidth,
7975
+ height: labelHeight,
7976
+ display: "flex",
7977
+ alignItems: "center",
7978
+ justifyContent: "center",
7979
+ backgroundColor: c.bg,
7980
+ color: c.textSecondary,
7981
+ fontSize: textSize,
7982
+ fontFamily: c.fontSans,
7983
+ whiteSpace: "nowrap"
7984
+ } }, relationship.label));
7985
+ }
7986
+ return [
7987
+ import_react11.default.createElement("path", {
7988
+ key: `path-${relationship.id}`,
7989
+ d: path,
7990
+ fill: "none",
7991
+ stroke: lineColor,
7992
+ strokeWidth: d.w(1.5),
7993
+ strokeDasharray: relationship.identifying ? void 0 : `${d.s(5)} ${d.s(4)}`,
7994
+ "data-vizmatic-graph-edge-id": encodeURIComponent(relationship.id),
7995
+ "data-vizmatic-graph-edge-from": encodeURIComponent(relationship.from.entity),
7996
+ "data-vizmatic-graph-edge-to": encodeURIComponent(relationship.to.entity),
7997
+ "data-vizmatic-graph-edge-label": encodeURIComponent(relationship.label ?? ""),
7998
+ "data-vizmatic-graph-edge-title": encodeURIComponent(relationshipText(relationship))
7999
+ }),
8000
+ cardinalityGlyph(relationship.from.cardinality, points[0], points[1], lineColor, c.bg, lineScale, `from-${relationship.id}`),
8001
+ cardinalityGlyph(relationship.to.cardinality, points.at(-1), points.at(-2), lineColor, c.bg, lineScale, `to-${relationship.id}`)
8002
+ ];
8003
+ });
8004
+ return import_react11.default.createElement(
8005
+ "div",
8006
+ {
8007
+ role: "img",
8008
+ "aria-label": svgTitle,
8009
+ "data-vizmatic-svg-id": id,
8010
+ "data-vizmatic-svg-title": svgTitle,
8011
+ "data-vizmatic-svg-description": [description, schemaSummary].filter(Boolean).join(" "),
8012
+ style: { display: "flex", position: "relative", flexShrink: 0, width: resolvedWidth, height: resolvedHeight }
8013
+ },
8014
+ 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),
8015
+ import_react11.default.createElement("svg", { width: resolvedWidth, height: resolvedHeight, viewBox: `0 0 ${resolvedWidth} ${resolvedHeight}`, style: { position: "absolute", left: 0, top: 0 } }, ...paths),
8016
+ ...labels,
8017
+ ...entities.map((entity) => {
8018
+ const node = nodeById.get(entity.id), measure = measures.get(entity.id);
8019
+ const keyColor = getReadableToneColor(entity.tone ?? "blue", c, c.bgCard, c.bgCard);
8020
+ return import_react11.default.createElement(
8021
+ "div",
8022
+ {
8023
+ key: entity.id,
8024
+ "data-vizmatic-graph-node-id": entity.id,
8025
+ "data-vizmatic-graph-node-label": entity.label ?? entity.id,
8026
+ "data-vizmatic-graph-node-detail": entity.attributes.map(attributeDescription).join("; "),
8027
+ style: {
8028
+ position: "absolute",
8029
+ left: node.cx - node.width / 2,
8030
+ top: node.cy - node.height / 2,
8031
+ display: "flex",
8032
+ flexDirection: "column",
8033
+ width: node.width,
8034
+ height: node.height,
8035
+ border: `1px solid ${c.borderLight}`,
8036
+ borderRadius: d.r(4),
8037
+ backgroundColor: c.bgCard,
8038
+ overflow: "hidden"
8039
+ }
8040
+ },
8041
+ import_react11.default.createElement("div", { style: {
8042
+ display: "flex",
8043
+ alignItems: "center",
8044
+ height: headerHeight,
8045
+ flexShrink: 0,
8046
+ padding: `0 ${inset}px`,
8047
+ fontFamily: c.fontSans,
8048
+ fontSize: headerSize,
8049
+ fontWeight: 600,
8050
+ color: keyColor,
8051
+ backgroundColor: c.bgCardAlt,
8052
+ borderBottom: `1px solid ${c.borderLight}`
8053
+ } }, entity.label ?? entity.id),
8054
+ ...entity.attributes.map((attribute2, index) => import_react11.default.createElement(
8055
+ "div",
8056
+ { key: attribute2.name, style: {
8057
+ display: "flex",
8058
+ alignItems: "center",
8059
+ height: measure.rowHeights[index],
8060
+ flexShrink: 0,
8061
+ padding: `0 ${inset}px`,
8062
+ gap: inset,
8063
+ fontFamily: c.fontMono,
8064
+ fontSize: textSize,
8065
+ color: c.textPrimary
8066
+ } },
8067
+ 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(" ")),
8068
+ import_react11.default.createElement("span", { style: { flexGrow: 1, whiteSpace: "nowrap" } }, attribute2.name),
8069
+ import_react11.default.createElement("span", { style: { width: measure.typeWidth, flexShrink: 0, textAlign: "right", color: c.textSecondary } }, attribute2.type + (attribute2.nullable ? "?" : ""))
8070
+ )),
8071
+ !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")
8072
+ );
8073
+ }),
8074
+ showLegend && import_react11.default.createElement(
8075
+ "div",
8076
+ { 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 } },
8077
+ ...legendLines.map((line) => import_react11.default.createElement("div", { key: line, style: { display: "flex", whiteSpace: "nowrap", flexShrink: 0 } }, line))
8078
+ )
8079
+ );
8080
+ }
8081
+ Object.defineProperty(EntityRelationshipDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
8082
+
7637
8083
  // src/primitives/transformer.ts
7638
8084
  var blockLabels = {
7639
8085
  embedding: "Embedding",
@@ -7895,7 +8341,7 @@ function TransformerTopology({
7895
8341
  Object.defineProperty(TransformerTopology, SVG_ACCESSIBILITY_COMPONENT, { value: true });
7896
8342
 
7897
8343
  // src/primitives/data.ts
7898
- var import_react11 = __toESM(require("react"), 1);
8344
+ var import_react12 = __toESM(require("react"), 1);
7899
8345
  function Matrix({
7900
8346
  data,
7901
8347
  c,
@@ -7915,7 +8361,8 @@ function Matrix({
7915
8361
  highlightCol,
7916
8362
  highlightCell,
7917
8363
  highlightColor = c.info,
7918
- colorDomain
8364
+ colorDomain,
8365
+ ...accessibility
7919
8366
  }) {
7920
8367
  const cellSize = cellSizeProp ?? densityOf(c).f(38);
7921
8368
  const fontSize = fontSizeProp ?? densityOf(c).type.small;
@@ -7967,9 +8414,19 @@ function Matrix({
7967
8414
  if (colorValue2 < 0.67) return c.infoDark;
7968
8415
  return c.positiveDark;
7969
8416
  };
7970
- return import_react11.default.createElement(
8417
+ const cellDescriptions = data.flatMap((row, rowIndex) => row.map((value, columnIndex) => {
8418
+ const label = labels?.[rowIndex]?.[columnIndex];
8419
+ const text = typeof label === "string" || typeof label === "number" ? label : formatValue(value);
8420
+ return `${rowLabels?.[rowIndex] ?? `Row ${rowIndex + 1}`}, ${colLabels?.[columnIndex] ?? `column ${columnIndex + 1}`}: ${text}`;
8421
+ }));
8422
+ return import_react12.default.createElement(
7971
8423
  "div",
7972
8424
  {
8425
+ ...chartAccessibilityAttributes({
8426
+ ...accessibility,
8427
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Matrix",
8428
+ description: chartDescription(accessibility.description, cellDescriptions)
8429
+ }),
7973
8430
  style: {
7974
8431
  display: "flex",
7975
8432
  flexDirection: "column",
@@ -7977,10 +8434,10 @@ function Matrix({
7977
8434
  gap: densityOf(c).s(8)
7978
8435
  }
7979
8436
  },
7980
- title && import_react11.default.createElement("div", {
8437
+ title && import_react12.default.createElement("div", {
7981
8438
  style: { ...typeOf(c, "label"), color: c.textPrimary }
7982
8439
  }, title),
7983
- import_react11.default.createElement(
8440
+ import_react12.default.createElement(
7984
8441
  "div",
7985
8442
  {
7986
8443
  style: {
@@ -7990,7 +8447,7 @@ function Matrix({
7990
8447
  }
7991
8448
  },
7992
8449
  // Column labels
7993
- colLabels && import_react11.default.createElement(
8450
+ colLabels && import_react12.default.createElement(
7994
8451
  "div",
7995
8452
  {
7996
8453
  style: {
@@ -8000,7 +8457,7 @@ function Matrix({
8000
8457
  }
8001
8458
  },
8002
8459
  ...colLabels.map(
8003
- (label, i) => import_react11.default.createElement("div", {
8460
+ (label, i) => import_react12.default.createElement("div", {
8004
8461
  key: `col-${i}`,
8005
8462
  style: {
8006
8463
  width: resolvedCellWidth,
@@ -8014,7 +8471,7 @@ function Matrix({
8014
8471
  )
8015
8472
  ),
8016
8473
  ...data.map(
8017
- (row, ri) => import_react11.default.createElement(
8474
+ (row, ri) => import_react12.default.createElement(
8018
8475
  "div",
8019
8476
  {
8020
8477
  key: `row-${ri}`,
@@ -8024,7 +8481,7 @@ function Matrix({
8024
8481
  alignItems: "center"
8025
8482
  }
8026
8483
  },
8027
- rowLabels && import_react11.default.createElement("div", {
8484
+ rowLabels && import_react12.default.createElement("div", {
8028
8485
  style: {
8029
8486
  width: resolvedRowLabelWidth,
8030
8487
  textAlign: "right",
@@ -8040,7 +8497,7 @@ function Matrix({
8040
8497
  const highlighted = ri === highlightRow || ci === highlightCol;
8041
8498
  const backgroundColor = highlighted ? compositeColor(withColorAlpha(highlightColor, 0.24), baseBackgroundColor) : baseBackgroundColor;
8042
8499
  const exactCell = ri === highlightCell?.row && ci === highlightCell?.col;
8043
- return import_react11.default.createElement("div", {
8500
+ return import_react12.default.createElement("div", {
8044
8501
  key: `cell-${ri}-${ci}`,
8045
8502
  style: {
8046
8503
  width: resolvedCellWidth,
@@ -8080,9 +8537,12 @@ function Heatmap({
8080
8537
  highlightCol,
8081
8538
  highlightCell,
8082
8539
  highlightColor,
8083
- colorDomain
8540
+ colorDomain,
8541
+ ...accessibility
8084
8542
  }) {
8085
8543
  return Matrix({
8544
+ ...accessibility,
8545
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Heatmap",
8086
8546
  data,
8087
8547
  colLabels: xLabels,
8088
8548
  rowLabels: yLabels,
@@ -8115,7 +8575,9 @@ function TiledMatrix({
8115
8575
  gap: gapProp,
8116
8576
  tone = "blue",
8117
8577
  muted = false,
8118
- crossedOut = false
8578
+ crossedOut = false,
8579
+ id,
8580
+ description
8119
8581
  }) {
8120
8582
  const gap = gapProp ?? densityOf(c).s(3);
8121
8583
  const safeRows = Math.max(1, Math.floor(rows));
@@ -8123,7 +8585,7 @@ function TiledMatrix({
8123
8585
  const baseAccent = getToneColor(tone, c);
8124
8586
  const cellRows = Array.from(
8125
8587
  { length: safeRows },
8126
- (_, row) => import_react11.default.createElement(
8588
+ (_, row) => import_react12.default.createElement(
8127
8589
  "div",
8128
8590
  {
8129
8591
  key: `tiled-matrix-row-${row}`,
@@ -8138,7 +8600,7 @@ function TiledMatrix({
8138
8600
  );
8139
8601
  const region = regionIndex >= 0 ? regions[regionIndex] : void 0;
8140
8602
  const accent = getToneColor(region?.tone ?? tone, c);
8141
- return import_react11.default.createElement("div", {
8603
+ return import_react12.default.createElement("div", {
8142
8604
  key: `tiled-matrix-cell-${row}-${col}`,
8143
8605
  "data-region": regionIndex >= 0 ? regionIndex : void 0,
8144
8606
  style: {
@@ -8154,7 +8616,7 @@ function TiledMatrix({
8154
8616
  })
8155
8617
  )
8156
8618
  );
8157
- const grid = import_react11.default.createElement(
8619
+ const grid = import_react12.default.createElement(
8158
8620
  "div",
8159
8621
  {
8160
8622
  "data-crossed-out": crossedOut ? "true" : void 0,
@@ -8173,7 +8635,7 @@ function TiledMatrix({
8173
8635
  },
8174
8636
  ...cellRows,
8175
8637
  ...crossedOut ? [
8176
- import_react11.default.createElement("div", {
8638
+ import_react12.default.createElement("div", {
8177
8639
  key: "cross-forward",
8178
8640
  style: {
8179
8641
  position: "absolute",
@@ -8188,7 +8650,7 @@ function TiledMatrix({
8188
8650
  boxShadow: `0 0 0 1px ${c.bgCard}`
8189
8651
  }
8190
8652
  }),
8191
- import_react11.default.createElement("div", {
8653
+ import_react12.default.createElement("div", {
8192
8654
  key: "cross-backward",
8193
8655
  style: {
8194
8656
  position: "absolute",
@@ -8205,11 +8667,17 @@ function TiledMatrix({
8205
8667
  })
8206
8668
  ] : []
8207
8669
  );
8208
- return import_react11.default.createElement(
8670
+ return import_react12.default.createElement(
8209
8671
  "div",
8210
8672
  {
8211
- role: "img",
8212
- "aria-label": ariaLabel ?? (typeof title === "string" ? title : "Tiled matrix"),
8673
+ ...chartAccessibilityAttributes({
8674
+ id,
8675
+ ariaLabel: ariaLabel ?? (typeof title === "string" ? title : "Tiled matrix"),
8676
+ description: chartDescription(description, [
8677
+ `${safeRows} rows by ${safeCols} columns`,
8678
+ ...regions.map((region, index) => `Region ${index + 1}: rows ${region.rowStart + 1} to ${region.rowEnd + 1}, columns ${region.colStart + 1} to ${region.colEnd + 1}`)
8679
+ ])
8680
+ }),
8213
8681
  style: {
8214
8682
  display: "flex",
8215
8683
  flexDirection: "column",
@@ -8218,7 +8686,7 @@ function TiledMatrix({
8218
8686
  }
8219
8687
  },
8220
8688
  ...compactChildren([
8221
- title && import_react11.default.createElement("div", {
8689
+ title && import_react12.default.createElement("div", {
8222
8690
  style: {
8223
8691
  color: muted ? c.textMuted : getReadableToneColor(tone, c),
8224
8692
  fontFamily: "Inter",
@@ -8228,7 +8696,7 @@ function TiledMatrix({
8228
8696
  textAlign: "center"
8229
8697
  }
8230
8698
  }, title),
8231
- subtitle && import_react11.default.createElement("div", {
8699
+ subtitle && import_react12.default.createElement("div", {
8232
8700
  style: {
8233
8701
  color: c.textMuted,
8234
8702
  fontFamily: "JetBrains Mono",
@@ -8274,7 +8742,7 @@ function DataTable({
8274
8742
  };
8275
8743
  const widths = Array.from({ length: columnCount }, (_, index) => columnWidth(index));
8276
8744
  const alignmentOf = (colIndex) => align?.[colIndex] ?? (colIndex < headerCols ? "left" : "right");
8277
- return import_react11.default.createElement(
8745
+ return import_react12.default.createElement(
8278
8746
  "div",
8279
8747
  {
8280
8748
  style: {
@@ -8283,7 +8751,7 @@ function DataTable({
8283
8751
  ...width != null ? { width } : {}
8284
8752
  }
8285
8753
  },
8286
- ...rows.map((row, rowIndex) => import_react11.default.createElement(
8754
+ ...rows.map((row, rowIndex) => import_react12.default.createElement(
8287
8755
  "div",
8288
8756
  {
8289
8757
  key: `${rowIndex}-${row.map(String).join("|")}`,
@@ -8299,7 +8767,7 @@ function DataTable({
8299
8767
  const isHeaderRow = rowIndex < headerRows;
8300
8768
  const isHeaderCol = colIndex < headerCols;
8301
8769
  const alignment = alignmentOf(colIndex);
8302
- return import_react11.default.createElement("div", {
8770
+ return import_react12.default.createElement("div", {
8303
8771
  key: `${rowIndex}-${colIndex}-${String(cell)}`,
8304
8772
  style: {
8305
8773
  ...width != null && colIndex === 0 ? { flex: 1 } : { width: widths[colIndex] },
@@ -8319,7 +8787,7 @@ function DataTable({
8319
8787
  );
8320
8788
  }
8321
8789
  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);
8790
+ 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
8791
  }
8324
8792
  function Grid({
8325
8793
  rows,
@@ -8366,7 +8834,7 @@ function Grid({
8366
8834
  ...textFitStyle("center")
8367
8835
  };
8368
8836
  };
8369
- return import_react11.default.createElement(
8837
+ return import_react12.default.createElement(
8370
8838
  "div",
8371
8839
  {
8372
8840
  style: {
@@ -8376,7 +8844,7 @@ function Grid({
8376
8844
  alignItems: "center"
8377
8845
  }
8378
8846
  },
8379
- ...rows.map((row, rowIndex) => import_react11.default.createElement(
8847
+ ...rows.map((row, rowIndex) => import_react12.default.createElement(
8380
8848
  "div",
8381
8849
  {
8382
8850
  key: `grid-row-${rowIndex}`,
@@ -8385,7 +8853,7 @@ function Grid({
8385
8853
  gap
8386
8854
  }
8387
8855
  },
8388
- ...row.map((cell, colIndex) => import_react11.default.createElement("div", {
8856
+ ...row.map((cell, colIndex) => import_react12.default.createElement("div", {
8389
8857
  key: `grid-cell-${rowIndex}-${colIndex}`,
8390
8858
  style: cellStyle(cell, rowIndex, colIndex)
8391
8859
  }, renderCellLabel(cell)))
@@ -8414,7 +8882,8 @@ function AxisPlot({
8414
8882
  paths = [],
8415
8883
  xAxisLabel,
8416
8884
  yAxisLabel,
8417
- children
8885
+ children,
8886
+ ...accessibility
8418
8887
  }) {
8419
8888
  const padding = paddingProp ?? densityOf(c).s(18);
8420
8889
  const innerWidth = Math.max(1, width - padding * 2);
@@ -8446,7 +8915,7 @@ function AxisPlot({
8446
8915
  const x = padding + innerWidth * index / (gridCount + 1);
8447
8916
  const y = padding + innerHeight * index / (gridCount + 1);
8448
8917
  return [
8449
- import_react11.default.createElement("line", {
8918
+ import_react12.default.createElement("line", {
8450
8919
  key: `axis-grid-x-${index}`,
8451
8920
  x1: x,
8452
8921
  y1: padding,
@@ -8456,7 +8925,7 @@ function AxisPlot({
8456
8925
  strokeWidth: 1,
8457
8926
  opacity: 0.75
8458
8927
  }),
8459
- import_react11.default.createElement("line", {
8928
+ import_react12.default.createElement("line", {
8460
8929
  key: `axis-grid-y-${index}`,
8461
8930
  x1: padding,
8462
8931
  y1: y,
@@ -8471,7 +8940,7 @@ function AxisPlot({
8471
8940
  }
8472
8941
  if (showAxes) {
8473
8942
  elements.push(
8474
- import_react11.default.createElement("line", {
8943
+ import_react12.default.createElement("line", {
8475
8944
  key: "axis-x",
8476
8945
  x1: padding,
8477
8946
  y1: xAxisY,
@@ -8481,7 +8950,7 @@ function AxisPlot({
8481
8950
  strokeWidth: 1.6,
8482
8951
  opacity: 0.85
8483
8952
  }),
8484
- import_react11.default.createElement("line", {
8953
+ import_react12.default.createElement("line", {
8485
8954
  key: "axis-y",
8486
8955
  x1: yAxisX,
8487
8956
  y1: padding,
@@ -8504,7 +8973,7 @@ function AxisPlot({
8504
8973
  commands.push(`L ${sx(point.x)} ${sy(point.y)}`);
8505
8974
  }
8506
8975
  }
8507
- return [import_react11.default.createElement("path", {
8976
+ return [import_react12.default.createElement("path", {
8508
8977
  key: `axis-path-${index}`,
8509
8978
  d: commands.join(" "),
8510
8979
  fill: "none",
@@ -8559,16 +9028,28 @@ function AxisPlot({
8559
9028
  strokeWidth: point.strokeWidth,
8560
9029
  opacity: point.opacity
8561
9030
  })));
8562
- elements.push(...import_react11.default.Children.toArray(children).filter(import_react11.default.isValidElement));
8563
- const svg = import_react11.default.createElement("svg", {
9031
+ elements.push(...import_react12.default.Children.toArray(children).filter(import_react12.default.isValidElement));
9032
+ const accessible = chartAccessibilityAttributes({
9033
+ ...accessibility,
9034
+ ariaLabel: accessibility.ariaLabel ?? "Axis plot",
9035
+ description: chartDescription(accessibility.description, [
9036
+ `${xAxisLabel ?? "x"} range ${xMin} to ${xMax}, ${yAxisLabel ?? "y"} range ${yMin} to ${yMax}`,
9037
+ ...points.map((point, index) => `Point ${index + 1}: x ${point.x}, y ${point.y}`),
9038
+ ...vectors.map((vector2, index) => `Vector ${index + 1}: (${vector2.x1}, ${vector2.y1}) to (${vector2.x2}, ${vector2.y2})`),
9039
+ ...paths.map((path, index) => `Path ${index + 1}: ${path.points.map((point) => `(${point.x}, ${point.y})`).join(", ")}`)
9040
+ ])
9041
+ });
9042
+ const svg = import_react12.default.createElement("svg", {
9043
+ ...!xAxisLabel && !yAxisLabel ? accessible : {},
8564
9044
  width,
8565
9045
  height,
8566
9046
  viewBox: `0 0 ${width} ${height}`
8567
9047
  }, ...elements);
8568
9048
  if (!xAxisLabel && !yAxisLabel) return svg;
8569
- return import_react11.default.createElement(
9049
+ return import_react12.default.createElement(
8570
9050
  "div",
8571
9051
  {
9052
+ ...accessible,
8572
9053
  style: {
8573
9054
  position: "relative",
8574
9055
  width,
@@ -8577,7 +9058,7 @@ function AxisPlot({
8577
9058
  }
8578
9059
  },
8579
9060
  svg,
8580
- xAxisLabel && import_react11.default.createElement("div", {
9061
+ xAxisLabel && import_react12.default.createElement("div", {
8581
9062
  key: "axis-x-label",
8582
9063
  style: {
8583
9064
  position: "absolute",
@@ -8592,7 +9073,7 @@ function AxisPlot({
8592
9073
  fontWeight: 750
8593
9074
  }
8594
9075
  }, xAxisLabel),
8595
- yAxisLabel && import_react11.default.createElement("div", {
9076
+ yAxisLabel && import_react12.default.createElement("div", {
8596
9077
  key: "axis-y-label",
8597
9078
  style: {
8598
9079
  position: "absolute",
@@ -8611,10 +9092,10 @@ function AxisPlot({
8611
9092
  }
8612
9093
 
8613
9094
  // src/primitives/charts.ts
8614
- var import_react13 = __toESM(require("react"), 1);
9095
+ var import_react14 = __toESM(require("react"), 1);
8615
9096
 
8616
9097
  // src/canvas-chart-fit.ts
8617
- var import_react12 = __toESM(require("react"), 1);
9098
+ var import_react13 = __toESM(require("react"), 1);
8618
9099
  var CANVAS_CHART_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.canvasChartComponent");
8619
9100
  var CHART_FRAME_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.chartFrameComponent");
8620
9101
  var FIT_PROP = "__vizmaticCanvasChartFit";
@@ -8625,11 +9106,11 @@ function isCanvasChart(component) {
8625
9106
  }
8626
9107
  function CanvasChartFit({ children, width, height }) {
8627
9108
  let chart = children;
8628
- for (let depth = 0; (0, import_react12.isValidElement)(chart) && typeof chart.type === "function" && depth < 16; depth += 1) {
9109
+ for (let depth = 0; (0, import_react13.isValidElement)(chart) && typeof chart.type === "function" && depth < 16; depth += 1) {
8629
9110
  if (chart.type[CHART_FRAME_COMPONENT]) {
8630
9111
  const props = chart.props;
8631
9112
  const padding = typeof props.padding === "number" ? props.padding : 16;
8632
- chart = import_react12.default.cloneElement(chart, {
9113
+ chart = import_react13.default.cloneElement(chart, {
8633
9114
  ...props,
8634
9115
  width: typeof props.width === "number" ? props.width + 2 * (padding + 1) : props.width,
8635
9116
  height: void 0
@@ -8638,10 +9119,10 @@ function CanvasChartFit({ children, width, height }) {
8638
9119
  }
8639
9120
  chart = chart.type(chart.props);
8640
9121
  }
8641
- return import_react12.default.createElement("div", {
9122
+ return import_react13.default.createElement("div", {
8642
9123
  [FIT_PROP]: { width, height },
8643
9124
  style: { position: "relative", display: "flex", width, height, flexShrink: 0 }
8644
- }, import_react12.default.createElement("div", {
9125
+ }, import_react13.default.createElement("div", {
8645
9126
  style: { position: "absolute", left: 0, top: 0, display: "flex", alignItems: "flex-start" }
8646
9127
  }, chart));
8647
9128
  }
@@ -8650,16 +9131,16 @@ function prepareChartFits(element) {
8650
9131
  const hasText = (node) => {
8651
9132
  if (typeof node === "string" || typeof node === "number" || typeof node === "bigint") return true;
8652
9133
  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);
9134
+ return (0, import_react13.isValidElement)(node) && node.type === import_react13.default.Fragment && hasText(node.props.children);
8654
9135
  };
8655
9136
  const visit = (node, scope) => {
8656
9137
  if (Array.isArray(node)) return node.map((child) => visit(child, scope));
8657
- if (!(0, import_react12.isValidElement)(node)) return node;
9138
+ if (!(0, import_react13.isValidElement)(node)) return node;
8658
9139
  const forwarded = node.type;
8659
9140
  const render = typeof node.type === "function" ? node.type : forwarded?.$$typeof === /* @__PURE__ */ Symbol.for("react.forward_ref") ? forwarded.render : void 0;
8660
9141
  if (render) {
8661
9142
  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;
9143
+ return node.key != null && (0, import_react13.isValidElement)(resolved) ? import_react13.default.cloneElement(resolved, { key: node.key }) : resolved;
8663
9144
  }
8664
9145
  const size = node.props[FIT_PROP];
8665
9146
  const props = { ...node.props };
@@ -8684,19 +9165,19 @@ function prepareChartFits(element) {
8684
9165
  ...style
8685
9166
  };
8686
9167
  }
8687
- return children === void 0 ? import_react12.default.cloneElement(node, props) : import_react12.default.cloneElement(node, props, preparedChildren);
9168
+ return children === void 0 ? import_react13.default.cloneElement(node, props) : import_react13.default.cloneElement(node, props, preparedChildren);
8688
9169
  };
8689
9170
  return { element: visit(element), sizes };
8690
9171
  }
8691
9172
  function fittedTree(element, geometry) {
8692
9173
  if (Array.isArray(element)) return element.map((child) => fittedTree(child, geometry));
8693
- if (!(0, import_react12.isValidElement)(element)) return element;
9174
+ if (!(0, import_react13.isValidElement)(element)) return element;
8694
9175
  const id = element.props[VIEWPORT_PROP];
8695
9176
  const children = element.props.children;
8696
9177
  if (typeof id === "string") {
8697
9178
  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: {
9179
+ const content = import_react13.default.Children.only(children);
9180
+ return import_react13.default.cloneElement(element, {}, import_react13.default.cloneElement(content, { style: {
8700
9181
  ...content.props.style,
8701
9182
  left: fit.left,
8702
9183
  top: fit.top,
@@ -8704,7 +9185,7 @@ function fittedTree(element, geometry) {
8704
9185
  transformOrigin: "top left"
8705
9186
  } }));
8706
9187
  }
8707
- return children === void 0 ? element : import_react12.default.cloneElement(element, {}, fittedTree(children, geometry));
9188
+ return children === void 0 ? element : import_react13.default.cloneElement(element, {}, fittedTree(children, geometry));
8708
9189
  }
8709
9190
  async function renderWithCanvasChartFit(render, element, options) {
8710
9191
  const prepared = prepareChartFits(element);
@@ -8865,7 +9346,7 @@ function chartLabel(key, text, x, y, c, options = {}) {
8865
9346
  );
8866
9347
  transform2 = void 0;
8867
9348
  }
8868
- return import_react13.default.createElement("div", {
9349
+ return import_react14.default.createElement("div", {
8869
9350
  key,
8870
9351
  style: {
8871
9352
  position: "absolute",
@@ -8908,7 +9389,7 @@ function pointLabelPlacement(x, y, plot, index, width = 70) {
8908
9389
  };
8909
9390
  }
8910
9391
  function ChartFrame(props) {
8911
- return import_react13.default.createElement(ChartFrameContent, props);
9392
+ return import_react14.default.createElement(ChartFrameContent, props);
8912
9393
  }
8913
9394
  function ChartFrameContent({
8914
9395
  children,
@@ -8920,13 +9401,21 @@ function ChartFrameContent({
8920
9401
  width = "100%",
8921
9402
  height,
8922
9403
  padding: paddingProp,
8923
- framed = false
9404
+ framed = false,
9405
+ id,
9406
+ ariaLabel,
9407
+ description
8924
9408
  }) {
8925
9409
  const d = densityOf(c);
8926
9410
  const padding = paddingProp ?? (framed ? d.s(14) : 0);
8927
- return import_react13.default.createElement(
9411
+ return import_react14.default.createElement(
8928
9412
  "div",
8929
9413
  {
9414
+ ...chartAccessibilityAttributes({
9415
+ id,
9416
+ ariaLabel: ariaLabel ?? title ?? "Chart",
9417
+ description: [subtitle, description].filter(Boolean).join(" ")
9418
+ }),
8930
9419
  style: {
8931
9420
  width,
8932
9421
  ...height ? { height } : {},
@@ -8938,20 +9427,20 @@ function ChartFrameContent({
8938
9427
  ...framed ? { borderRadius: d.r(8), border: `1px solid ${c.borderSubtle}`, backgroundColor: c.bgCard } : {}
8939
9428
  }
8940
9429
  },
8941
- (title || subtitle) && import_react13.default.createElement(
9430
+ (title || subtitle) && import_react14.default.createElement(
8942
9431
  "div",
8943
9432
  {
8944
9433
  style: { display: "flex", flexDirection: "column", gap: d.s(2), minWidth: 0, maxWidth: "100%" }
8945
9434
  },
8946
- title && import_react13.default.createElement("div", {
9435
+ title && import_react14.default.createElement("div", {
8947
9436
  style: { ...typeOf(c, "label"), ...textFitStyle(), color: c.textPrimary, fontWeight: 600 }
8948
9437
  }, title),
8949
- subtitle && import_react13.default.createElement("div", {
9438
+ subtitle && import_react14.default.createElement("div", {
8950
9439
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary, lineHeight: 1.35 }
8951
9440
  }, subtitle)
8952
9441
  ),
8953
9442
  children,
8954
- (legend || footer) && import_react13.default.createElement(
9443
+ (legend || footer) && import_react14.default.createElement(
8955
9444
  "div",
8956
9445
  {
8957
9446
  style: {
@@ -8961,18 +9450,18 @@ function ChartFrameContent({
8961
9450
  gap: d.s(12)
8962
9451
  }
8963
9452
  },
8964
- legend && import_react13.default.createElement(
9453
+ legend && import_react14.default.createElement(
8965
9454
  "div",
8966
9455
  {
8967
9456
  style: { display: "flex", alignItems: "center", gap: d.s(12), flexWrap: "wrap", minWidth: 0 }
8968
9457
  },
8969
- ...legend.map((item, index) => import_react13.default.createElement(
9458
+ ...legend.map((item, index) => import_react14.default.createElement(
8970
9459
  "div",
8971
9460
  {
8972
9461
  key: `${item.label}-${index}`,
8973
9462
  style: { display: "flex", alignItems: "center", gap: d.s(6), minWidth: 0 }
8974
9463
  },
8975
- import_react13.default.createElement("span", {
9464
+ import_react14.default.createElement("span", {
8976
9465
  style: {
8977
9466
  width: d.f(12),
8978
9467
  height: Math.max(2, d.w(2)),
@@ -8980,12 +9469,12 @@ function ChartFrameContent({
8980
9469
  display: "flex"
8981
9470
  }
8982
9471
  }),
8983
- import_react13.default.createElement("span", {
9472
+ import_react14.default.createElement("span", {
8984
9473
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary }
8985
9474
  }, item.label)
8986
9475
  ))
8987
9476
  ),
8988
- footer && import_react13.default.createElement("div", {
9477
+ footer && import_react14.default.createElement("div", {
8989
9478
  style: { ...typeOf(c, "tiny"), ...textFitStyle("right"), color: c.textMuted }
8990
9479
  }, footer)
8991
9480
  )
@@ -9055,7 +9544,8 @@ function PieChart({
9055
9544
  size,
9056
9545
  format = "decimal",
9057
9546
  showLegend = true,
9058
- footer
9547
+ footer,
9548
+ ...accessibility
9059
9549
  }) {
9060
9550
  const total = validateNonNegativeSegments(segments, "PieChart");
9061
9551
  const positiveSegments = segments.filter((segment) => segment.value > 0);
@@ -9069,7 +9559,7 @@ function PieChart({
9069
9559
  const start = cursor;
9070
9560
  const end = index === positiveSegments.length - 1 ? 270 : cursor + span;
9071
9561
  cursor += span;
9072
- return import_react13.default.createElement("path", {
9562
+ return import_react14.default.createElement("path", {
9073
9563
  key: `pie-segment-${segment.label}-${index}`,
9074
9564
  d: pieSectorPath(cx, cy, radius, start, end),
9075
9565
  fill: chartColor(segment.color, c, index),
@@ -9080,7 +9570,7 @@ function PieChart({
9080
9570
  "data-pie-share": total > 0 ? segment.value / total : 0
9081
9571
  });
9082
9572
  });
9083
- const legend = showLegend && positiveSegments.length > 0 && import_react13.default.createElement("div", {
9573
+ const legend = showLegend && positiveSegments.length > 0 && import_react14.default.createElement("div", {
9084
9574
  style: {
9085
9575
  display: "flex",
9086
9576
  flexDirection: "column",
@@ -9092,13 +9582,13 @@ function PieChart({
9092
9582
  const formattedValue = formatChartValue(segment.value, format);
9093
9583
  const share = formatChartValue(segment.value / total, "percent");
9094
9584
  const label = segment.valueLabel ?? (format === "percent" ? formattedValue : `${formattedValue} \xB7 ${share}`);
9095
- return import_react13.default.createElement(
9585
+ return import_react14.default.createElement(
9096
9586
  "div",
9097
9587
  {
9098
9588
  key: `pie-legend-${segment.label}-${index}`,
9099
9589
  style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 }
9100
9590
  },
9101
- import_react13.default.createElement("span", {
9591
+ import_react14.default.createElement("span", {
9102
9592
  style: {
9103
9593
  display: "flex",
9104
9594
  width: 10,
@@ -9108,10 +9598,10 @@ function PieChart({
9108
9598
  flexShrink: 0
9109
9599
  }
9110
9600
  }),
9111
- import_react13.default.createElement("span", {
9601
+ import_react14.default.createElement("span", {
9112
9602
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary, flex: 1 }
9113
9603
  }, segment.label),
9114
- import_react13.default.createElement("span", {
9604
+ import_react14.default.createElement("span", {
9115
9605
  style: {
9116
9606
  ...typeOf(c, "tiny"),
9117
9607
  color: c.textPrimary,
@@ -9123,12 +9613,15 @@ function PieChart({
9123
9613
  );
9124
9614
  }));
9125
9615
  return ChartFrame({
9616
+ ...accessibility,
9617
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pie chart",
9618
+ description: chartDescription(accessibility.description, valueDescriptions(segments, format)),
9126
9619
  c,
9127
9620
  title,
9128
9621
  subtitle,
9129
9622
  footer,
9130
9623
  width,
9131
- children: import_react13.default.createElement(
9624
+ children: import_react14.default.createElement(
9132
9625
  "div",
9133
9626
  {
9134
9627
  style: {
@@ -9140,7 +9633,7 @@ function PieChart({
9140
9633
  width: "100%"
9141
9634
  }
9142
9635
  },
9143
- import_react13.default.createElement(
9636
+ import_react14.default.createElement(
9144
9637
  "svg",
9145
9638
  {
9146
9639
  width: resolvedSize,
@@ -9149,7 +9642,7 @@ function PieChart({
9149
9642
  role: "img",
9150
9643
  "aria-label": title ?? "Pie chart"
9151
9644
  },
9152
- positiveSegments.length === 0 ? import_react13.default.createElement("circle", {
9645
+ positiveSegments.length === 0 ? import_react14.default.createElement("circle", {
9153
9646
  cx,
9154
9647
  cy,
9155
9648
  r: radius,
@@ -9175,7 +9668,8 @@ function DonutChart({
9175
9668
  centerLabel,
9176
9669
  centerValue,
9177
9670
  showLegend = true,
9178
- footer
9671
+ footer,
9672
+ ...accessibility
9179
9673
  }) {
9180
9674
  const positiveSegments = segments.filter((segment) => segment.value > 0);
9181
9675
  const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
@@ -9194,13 +9688,13 @@ function DonutChart({
9194
9688
  const end = cursor + rawSpan - gap / 2;
9195
9689
  cursor += rawSpan;
9196
9690
  if (end <= start) return null;
9197
- return import_react13.default.createElement("path", {
9691
+ return import_react14.default.createElement("path", {
9198
9692
  key: `donut-segment-${segment.label}-${index}`,
9199
9693
  d: donutArcPath(cx, cy, outerRadius, innerRadius, start, end),
9200
9694
  fill: chartColor(segment.color, c, index)
9201
9695
  });
9202
9696
  }).filter(Boolean);
9203
- const legend = showLegend && positiveSegments.length > 0 && import_react13.default.createElement("div", {
9697
+ const legend = showLegend && positiveSegments.length > 0 && import_react14.default.createElement("div", {
9204
9698
  style: {
9205
9699
  display: "flex",
9206
9700
  flexDirection: "column",
@@ -9208,7 +9702,7 @@ function DonutChart({
9208
9702
  flex: 1,
9209
9703
  minWidth: 112
9210
9704
  }
9211
- }, ...positiveSegments.map((segment, index) => import_react13.default.createElement(
9705
+ }, ...positiveSegments.map((segment, index) => import_react14.default.createElement(
9212
9706
  "div",
9213
9707
  {
9214
9708
  key: `donut-legend-${segment.label}-${index}`,
@@ -9219,7 +9713,7 @@ function DonutChart({
9219
9713
  minWidth: 0
9220
9714
  }
9221
9715
  },
9222
- import_react13.default.createElement("span", {
9716
+ import_react14.default.createElement("span", {
9223
9717
  style: {
9224
9718
  display: "flex",
9225
9719
  width: 10,
@@ -9229,7 +9723,7 @@ function DonutChart({
9229
9723
  flexShrink: 0
9230
9724
  }
9231
9725
  }),
9232
- import_react13.default.createElement("span", {
9726
+ import_react14.default.createElement("span", {
9233
9727
  style: {
9234
9728
  ...typeOf(c, "tiny"),
9235
9729
  ...textFitStyle(),
@@ -9237,7 +9731,7 @@ function DonutChart({
9237
9731
  flex: 1
9238
9732
  }
9239
9733
  }, segment.label),
9240
- import_react13.default.createElement("span", {
9734
+ import_react14.default.createElement("span", {
9241
9735
  style: {
9242
9736
  ...typeOf(c, "tiny"),
9243
9737
  color: c.textPrimary,
@@ -9248,6 +9742,9 @@ function DonutChart({
9248
9742
  }, segment.valueLabel ?? formatChartValue(segment.value, format))
9249
9743
  )));
9250
9744
  return ChartFrame({
9745
+ ...accessibility,
9746
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Donut chart",
9747
+ description: chartDescription(accessibility.description, valueDescriptions(positiveSegments, format)),
9251
9748
  c,
9252
9749
  title,
9253
9750
  subtitle,
@@ -9255,7 +9752,7 @@ function DonutChart({
9255
9752
  width,
9256
9753
  height,
9257
9754
  padding: densityOf(c).s(16),
9258
- children: import_react13.default.createElement(
9755
+ children: import_react14.default.createElement(
9259
9756
  "div",
9260
9757
  {
9261
9758
  style: {
@@ -9267,7 +9764,7 @@ function DonutChart({
9267
9764
  width: "100%"
9268
9765
  }
9269
9766
  },
9270
- import_react13.default.createElement(
9767
+ import_react14.default.createElement(
9271
9768
  "div",
9272
9769
  {
9273
9770
  style: {
@@ -9278,14 +9775,14 @@ function DonutChart({
9278
9775
  flexShrink: 0
9279
9776
  }
9280
9777
  },
9281
- import_react13.default.createElement(
9778
+ import_react14.default.createElement(
9282
9779
  "svg",
9283
9780
  {
9284
9781
  width: resolvedSize,
9285
9782
  height: resolvedSize,
9286
9783
  viewBox: `0 0 ${resolvedSize} ${resolvedSize}`
9287
9784
  },
9288
- positiveSegments.length === 0 ? import_react13.default.createElement("circle", {
9785
+ positiveSegments.length === 0 ? import_react14.default.createElement("circle", {
9289
9786
  cx,
9290
9787
  cy,
9291
9788
  r: (outerRadius + innerRadius) / 2,
@@ -9294,7 +9791,7 @@ function DonutChart({
9294
9791
  strokeWidth: resolvedThickness
9295
9792
  }) : paths
9296
9793
  ),
9297
- (centerLabel != null || resolvedCenterValue != null) && import_react13.default.createElement(
9794
+ (centerLabel != null || resolvedCenterValue != null) && import_react14.default.createElement(
9298
9795
  "div",
9299
9796
  {
9300
9797
  style: {
@@ -9313,7 +9810,7 @@ function DonutChart({
9313
9810
  textAlign: "center"
9314
9811
  }
9315
9812
  },
9316
- resolvedCenterValue != null && import_react13.default.createElement("div", {
9813
+ resolvedCenterValue != null && import_react14.default.createElement("div", {
9317
9814
  style: {
9318
9815
  ...typeOf(c, "small"),
9319
9816
  color: c.textPrimary,
@@ -9324,7 +9821,7 @@ function DonutChart({
9324
9821
  ...textFitStyle("center")
9325
9822
  }
9326
9823
  }, resolvedCenterValue),
9327
- centerLabel != null && import_react13.default.createElement("div", {
9824
+ centerLabel != null && import_react14.default.createElement("div", {
9328
9825
  style: {
9329
9826
  ...typeOf(c, "tiny"),
9330
9827
  color: c.textMuted,
@@ -9338,6 +9835,9 @@ function DonutChart({
9338
9835
  )
9339
9836
  });
9340
9837
  }
9838
+ function valueDescriptions(data, format = "decimal") {
9839
+ return data.map((item) => `${item.label}: ${item.valueLabel ?? formatChartValue(item.value, format)}`);
9840
+ }
9341
9841
  function StackedBar({
9342
9842
  segments,
9343
9843
  c,
@@ -9345,13 +9845,22 @@ function StackedBar({
9345
9845
  height = 68,
9346
9846
  title,
9347
9847
  subtitle,
9348
- showLegend = true
9848
+ showLegend = true,
9849
+ ...accessibility
9349
9850
  }) {
9350
9851
  const positiveSegments = segments.filter((segment) => segment.value > 0);
9351
9852
  const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
9352
- return import_react13.default.createElement(
9853
+ return import_react14.default.createElement(
9353
9854
  "div",
9354
9855
  {
9856
+ ...chartAccessibilityAttributes({
9857
+ ...accessibility,
9858
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Stacked bar",
9859
+ description: chartDescription(
9860
+ [subtitle, accessibility.description].filter(Boolean).join(" "),
9861
+ valueDescriptions(positiveSegments)
9862
+ )
9863
+ }),
9355
9864
  style: {
9356
9865
  width,
9357
9866
  display: "flex",
@@ -9359,7 +9868,7 @@ function StackedBar({
9359
9868
  gap: densityOf(c).s(10)
9360
9869
  }
9361
9870
  },
9362
- (title || subtitle) && import_react13.default.createElement(
9871
+ (title || subtitle) && import_react14.default.createElement(
9363
9872
  "div",
9364
9873
  {
9365
9874
  style: {
@@ -9368,14 +9877,14 @@ function StackedBar({
9368
9877
  gap: densityOf(c).s(3)
9369
9878
  }
9370
9879
  },
9371
- title && import_react13.default.createElement("div", {
9880
+ title && import_react14.default.createElement("div", {
9372
9881
  style: { ...typeOf(c, "label"), color: c.textPrimary, fontWeight: 600 }
9373
9882
  }, title),
9374
- subtitle && import_react13.default.createElement("div", {
9883
+ subtitle && import_react14.default.createElement("div", {
9375
9884
  style: { ...typeOf(c, "tiny"), color: c.textSecondary }
9376
9885
  }, subtitle)
9377
9886
  ),
9378
- import_react13.default.createElement(
9887
+ import_react14.default.createElement(
9379
9888
  "div",
9380
9889
  {
9381
9890
  style: {
@@ -9393,7 +9902,7 @@ function StackedBar({
9393
9902
  const share = total > 0 ? segment.value / total : 0;
9394
9903
  const segmentWidth = width * share;
9395
9904
  const color = chartColor(segment.color, c, index);
9396
- return import_react13.default.createElement(
9905
+ return import_react14.default.createElement(
9397
9906
  "div",
9398
9907
  {
9399
9908
  key: `${segment.label}-${index}`,
@@ -9407,7 +9916,7 @@ function StackedBar({
9407
9916
  ...index < positiveSegments.length - 1 ? { borderRight: `2px solid ${c.bgSubtle}` } : {}
9408
9917
  }
9409
9918
  },
9410
- segmentWidth >= 64 && import_react13.default.createElement("span", {
9919
+ segmentWidth >= 64 && import_react14.default.createElement("span", {
9411
9920
  style: {
9412
9921
  ...typeOf(c, "small"),
9413
9922
  color: getReadableTextColor(color, c),
@@ -9418,7 +9927,7 @@ function StackedBar({
9418
9927
  );
9419
9928
  })
9420
9929
  ),
9421
- showLegend && import_react13.default.createElement(
9930
+ showLegend && import_react14.default.createElement(
9422
9931
  "div",
9423
9932
  {
9424
9933
  style: {
@@ -9430,13 +9939,13 @@ function StackedBar({
9430
9939
  },
9431
9940
  ...positiveSegments.map((segment, index) => {
9432
9941
  const share = total > 0 ? segment.value / total : 0;
9433
- return import_react13.default.createElement(
9942
+ return import_react14.default.createElement(
9434
9943
  "div",
9435
9944
  {
9436
9945
  key: `legend-${segment.label}-${index}`,
9437
9946
  style: { display: "flex", alignItems: "center", gap: 7 }
9438
9947
  },
9439
- import_react13.default.createElement("span", {
9948
+ import_react14.default.createElement("span", {
9440
9949
  style: {
9441
9950
  width: 12,
9442
9951
  height: 12,
@@ -9445,7 +9954,7 @@ function StackedBar({
9445
9954
  backgroundColor: chartColor(segment.color, c, index)
9446
9955
  }
9447
9956
  }),
9448
- import_react13.default.createElement("span", {
9957
+ import_react14.default.createElement("span", {
9449
9958
  style: { ...typeOf(c, "tiny"), color: c.textSecondary }
9450
9959
  }, `${segment.label} ${segment.valueLabel ?? formatChartValue(share, "percent")}`)
9451
9960
  );
@@ -9466,7 +9975,8 @@ function BarChart({
9466
9975
  showGrid = true,
9467
9976
  showValues = true,
9468
9977
  yAxisLabel,
9469
- footer
9978
+ footer,
9979
+ ...accessibility
9470
9980
  }) {
9471
9981
  const d = densityOf(c);
9472
9982
  const margin = { top: d.f(16), right: d.g(8), bottom: d.f(26), left: d.f(yAxisLabel ? 62 : 34) };
@@ -9486,23 +9996,26 @@ function BarChart({
9486
9996
  return { item, index, x, y, barHeight, valueY, color: chartColor(item.color, c, 0) };
9487
9997
  });
9488
9998
  return ChartFrame({
9999
+ ...accessibility,
10000
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Bar chart",
10001
+ description: chartDescription(accessibility.description, valueDescriptions(data, format)),
9489
10002
  c,
9490
10003
  title,
9491
10004
  subtitle,
9492
10005
  width,
9493
10006
  footer,
9494
- children: import_react13.default.createElement(
10007
+ children: import_react14.default.createElement(
9495
10008
  "div",
9496
10009
  { style: { position: "relative", width, height, display: "flex" } },
9497
- import_react13.default.createElement(
10010
+ import_react14.default.createElement(
9498
10011
  "svg",
9499
10012
  { width, height, viewBox: `0 0 ${width} ${height}` },
9500
- showGrid && import_react13.default.createElement(
10013
+ showGrid && import_react14.default.createElement(
9501
10014
  "g",
9502
10015
  {},
9503
10016
  ...ticks.map((tick) => {
9504
10017
  const y = yInPlot(tick, domain, plot);
9505
- return import_react13.default.createElement("line", {
10018
+ return import_react14.default.createElement("line", {
9506
10019
  key: `tick-${tick}`,
9507
10020
  x1: plot.x,
9508
10021
  y1: y,
@@ -9513,9 +10026,9 @@ function BarChart({
9513
10026
  });
9514
10027
  })
9515
10028
  ),
9516
- import_react13.default.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
10029
+ import_react14.default.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
9517
10030
  ...barGeometries.map(
9518
- ({ item, index, x, y, barHeight, color }) => import_react13.default.createElement("rect", {
10031
+ ({ item, index, x, y, barHeight, color }) => import_react14.default.createElement("rect", {
9519
10032
  key: `${item.label}-${index}`,
9520
10033
  x,
9521
10034
  y,
@@ -9558,7 +10071,8 @@ function ParetoBarChart({
9558
10071
  format = "integer",
9559
10072
  showGrid = true,
9560
10073
  showValues = true,
9561
- footer
10074
+ footer,
10075
+ ...accessibility
9562
10076
  }) {
9563
10077
  let total = 0;
9564
10078
  for (const item of data) {
@@ -9603,17 +10117,22 @@ function ParetoBarChart({
9603
10117
  });
9604
10118
  const cumulativePath = bars.map(({ centerX, cumulativeY }, index) => `${index === 0 ? "M" : "L"} ${centerX.toFixed(1)} ${cumulativeY.toFixed(1)}`).join(" ");
9605
10119
  return ChartFrame({
10120
+ ...accessibility,
10121
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pareto bar chart",
10122
+ description: chartDescription(accessibility.description, bars.map(
10123
+ ({ item, cumulative }) => `${item.label}: ${item.valueLabel ?? formatChartValue(item.value, format)}, cumulative ${formatChartValue(cumulative, "percent")}`
10124
+ )),
9606
10125
  c,
9607
10126
  title,
9608
10127
  subtitle,
9609
10128
  width,
9610
10129
  footer,
9611
- children: import_react13.default.createElement(
10130
+ children: import_react14.default.createElement(
9612
10131
  "div",
9613
10132
  {
9614
10133
  style: { position: "relative", width, height, display: "flex" }
9615
10134
  },
9616
- import_react13.default.createElement(
10135
+ import_react14.default.createElement(
9617
10136
  "svg",
9618
10137
  {
9619
10138
  width,
@@ -9622,12 +10141,12 @@ function ParetoBarChart({
9622
10141
  role: "img",
9623
10142
  "aria-label": title ?? "Pareto bar chart"
9624
10143
  },
9625
- showGrid && import_react13.default.createElement(
10144
+ showGrid && import_react14.default.createElement(
9626
10145
  "g",
9627
10146
  {},
9628
10147
  ...countTicks.map((tick) => {
9629
10148
  const y = yInPlot(tick, valueDomain, plot);
9630
- return import_react13.default.createElement("line", {
10149
+ return import_react14.default.createElement("line", {
9631
10150
  key: `pareto-count-grid-${tick}`,
9632
10151
  x1: plot.x,
9633
10152
  y1: y,
@@ -9638,7 +10157,7 @@ function ParetoBarChart({
9638
10157
  });
9639
10158
  })
9640
10159
  ),
9641
- import_react13.default.createElement("line", {
10160
+ import_react14.default.createElement("line", {
9642
10161
  x1: plot.x,
9643
10162
  y1: plot.bottom,
9644
10163
  x2: plot.right,
@@ -9646,7 +10165,7 @@ function ParetoBarChart({
9646
10165
  stroke: c.borderLight,
9647
10166
  strokeWidth: d.stroke.hair
9648
10167
  }),
9649
- ...bars.map(({ item, order, x, y, height: barHeight, color }) => import_react13.default.createElement("rect", {
10168
+ ...bars.map(({ item, order, x, y, height: barHeight, color }) => import_react14.default.createElement("rect", {
9650
10169
  key: `pareto-bar-${item.label}-${order}`,
9651
10170
  x,
9652
10171
  y,
@@ -9658,7 +10177,7 @@ function ParetoBarChart({
9658
10177
  "data-pareto-value": item.value,
9659
10178
  "data-pareto-order": order
9660
10179
  })),
9661
- cumulativePath && import_react13.default.createElement("path", {
10180
+ cumulativePath && import_react14.default.createElement("path", {
9662
10181
  d: cumulativePath,
9663
10182
  fill: "none",
9664
10183
  stroke: chartColor("critical", c),
@@ -9667,7 +10186,7 @@ function ParetoBarChart({
9667
10186
  strokeLinejoin: "round",
9668
10187
  "data-pareto-cumulative-line": true
9669
10188
  }),
9670
- ...bars.map(({ item, sourceIndex, centerX, cumulativeY, cumulative, order }) => import_react13.default.createElement("circle", {
10189
+ ...bars.map(({ item, sourceIndex, centerX, cumulativeY, cumulative, order }) => import_react14.default.createElement("circle", {
9671
10190
  key: `pareto-cumulative-point-${order}`,
9672
10191
  cx: centerX,
9673
10192
  cy: cumulativeY,
@@ -9733,7 +10252,8 @@ function LineChart({
9733
10252
  showPoints = true,
9734
10253
  directLabels,
9735
10254
  yAxisLabel,
9736
- footer
10255
+ footer,
10256
+ ...accessibility
9737
10257
  }) {
9738
10258
  const d = densityOf(c);
9739
10259
  const direct = directLabels ?? series.length > 1;
@@ -9758,24 +10278,29 @@ function LineChart({
9758
10278
  return `${index === 0 ? "M" : "L"} ${point.x.toFixed(1)} ${point.y.toFixed(1)}`;
9759
10279
  }).join(" ");
9760
10280
  return ChartFrame({
10281
+ ...accessibility,
10282
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Line chart",
10283
+ description: chartDescription(accessibility.description, series.map(
10284
+ (item) => `${item.name}: ${item.points.map((value, index) => `${labels?.[index] ?? `Point ${index + 1}`}: ${formatChartValue(value, format)}`).join(", ")}`
10285
+ )),
9761
10286
  c,
9762
10287
  title,
9763
10288
  subtitle,
9764
10289
  width,
9765
10290
  footer,
9766
10291
  ...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(
10292
+ children: import_react14.default.createElement(
9768
10293
  "div",
9769
10294
  { style: { position: "relative", width, height, display: "flex" } },
9770
- import_react13.default.createElement(
10295
+ import_react14.default.createElement(
9771
10296
  "svg",
9772
10297
  { width, height, viewBox: `0 0 ${width} ${height}` },
9773
- showGrid && import_react13.default.createElement(
10298
+ showGrid && import_react14.default.createElement(
9774
10299
  "g",
9775
10300
  {},
9776
10301
  ...ticks.map((tick) => {
9777
10302
  const y = yInPlot(tick, domain, plot);
9778
- return import_react13.default.createElement("line", {
10303
+ return import_react14.default.createElement("line", {
9779
10304
  key: `line-tick-${tick}`,
9780
10305
  x1: plot.x,
9781
10306
  y1: y,
@@ -9786,7 +10311,7 @@ function LineChart({
9786
10311
  });
9787
10312
  })
9788
10313
  ),
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 }),
10314
+ 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
10315
  ...series.flatMap((item, seriesIndex) => {
9791
10316
  if (item.points.length === 0) return [];
9792
10317
  const color = chartColor(item.color, c, seriesIndex);
@@ -9799,9 +10324,9 @@ function LineChart({
9799
10324
  }
9800
10325
  const elements = [];
9801
10326
  if (areaPath) {
9802
- elements.push(import_react13.default.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.1 }));
10327
+ elements.push(import_react14.default.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.1 }));
9803
10328
  }
9804
- elements.push(import_react13.default.createElement("path", {
10329
+ elements.push(import_react14.default.createElement("path", {
9805
10330
  key: `${item.name}-line`,
9806
10331
  d: linePath,
9807
10332
  fill: "none",
@@ -9813,7 +10338,7 @@ function LineChart({
9813
10338
  if (showPoints) {
9814
10339
  elements.push(...item.points.map((value, index) => {
9815
10340
  const point = pointFor(value, index);
9816
- return import_react13.default.createElement("circle", {
10341
+ return import_react14.default.createElement("circle", {
9817
10342
  key: `${item.name}-point-${index}`,
9818
10343
  cx: point.x,
9819
10344
  cy: point.y,
@@ -9866,7 +10391,7 @@ for (const chart of [PieChart, DonutChart, StackedBar, BarChart, ParetoBarChart,
9866
10391
  }
9867
10392
 
9868
10393
  // src/primitives/plots.ts
9869
- var import_react14 = __toESM(require("react"), 1);
10394
+ var import_react15 = __toESM(require("react"), 1);
9870
10395
  for (const chart of [ScatterPlot, ParetoChart, QuadrantChart, IntervalPlot]) {
9871
10396
  Object.defineProperty(chart, CANVAS_CHART_COMPONENT, { value: true });
9872
10397
  }
@@ -9875,6 +10400,12 @@ function xTickLabelAlign(index, count) {
9875
10400
  if (index === count - 1) return "right";
9876
10401
  return "center";
9877
10402
  }
10403
+ function pointDescription(point, index, formatX, formatY, xLabel = "x", yLabel = "y") {
10404
+ return `${point.label ?? `Point ${index + 1}`}: ${xLabel} ${formatChartValue(point.x, formatX)}, ${yLabel} ${formatChartValue(point.y, formatY)}`;
10405
+ }
10406
+ function pointDescriptions(points, formatX, formatY, xLabel = "x", yLabel = "y") {
10407
+ return points.map((point, index) => pointDescription(point, index, formatX, formatY, xLabel, yLabel));
10408
+ }
9878
10409
  function ScatterPlot({
9879
10410
  points,
9880
10411
  c,
@@ -9891,7 +10422,8 @@ function ScatterPlot({
9891
10422
  formatX = "decimal",
9892
10423
  formatY = "decimal",
9893
10424
  showGrid = true,
9894
- footer
10425
+ footer,
10426
+ ...accessibility
9895
10427
  }) {
9896
10428
  const margin = { top: 20, right: 24, bottom: xAxisLabel ? 46 : 34, left: yAxisLabel ? 54 : 42 };
9897
10429
  const plot = createPlotArea(width, height, margin);
@@ -9908,23 +10440,26 @@ function ScatterPlot({
9908
10440
  return { item, index, point, color: chartColor(item.color, c, index) };
9909
10441
  });
9910
10442
  return ChartFrame({
10443
+ ...accessibility,
10444
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Scatter plot",
10445
+ description: chartDescription(accessibility.description, pointDescriptions(points, formatX, formatY, xAxisLabel, yAxisLabel)),
9911
10446
  c,
9912
10447
  title,
9913
10448
  subtitle,
9914
10449
  width,
9915
10450
  footer,
9916
- children: import_react14.default.createElement(
10451
+ children: import_react15.default.createElement(
9917
10452
  "div",
9918
10453
  { style: { position: "relative", width, height, display: "flex" } },
9919
- import_react14.default.createElement(
10454
+ import_react15.default.createElement(
9920
10455
  "svg",
9921
10456
  { width, height, viewBox: `0 0 ${width} ${height}` },
9922
- showGrid && import_react14.default.createElement(
10457
+ showGrid && import_react15.default.createElement(
9923
10458
  "g",
9924
10459
  {},
9925
10460
  ...xTicks.map((tick) => {
9926
10461
  const x = xInPlot(tick, xDomain, plot);
9927
- return import_react14.default.createElement("line", {
10462
+ return import_react15.default.createElement("line", {
9928
10463
  key: `x-tick-${tick}`,
9929
10464
  x1: x,
9930
10465
  y1: plot.y,
@@ -9936,7 +10471,7 @@ function ScatterPlot({
9936
10471
  }),
9937
10472
  ...yTicks.map((tick) => {
9938
10473
  const y = yInPlot(tick, yDomain, plot);
9939
- return import_react14.default.createElement("line", {
10474
+ return import_react15.default.createElement("line", {
9940
10475
  key: `y-tick-${tick}`,
9941
10476
  x1: plot.x,
9942
10477
  y1: y,
@@ -9947,9 +10482,9 @@ function ScatterPlot({
9947
10482
  });
9948
10483
  })
9949
10484
  ),
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 }),
10485
+ 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
10486
  ...pointGeometries.map(
9952
- ({ item, index, point, color }) => import_react14.default.createElement("circle", {
10487
+ ({ item, index, point, color }) => import_react15.default.createElement("circle", {
9953
10488
  key: `${item.label ?? "point"}-${index}`,
9954
10489
  cx: point.x,
9955
10490
  cy: point.y,
@@ -10051,7 +10586,8 @@ function ParetoChart({
10051
10586
  frontierColor,
10052
10587
  showGoal = true,
10053
10588
  goalLabel,
10054
- footer
10589
+ footer,
10590
+ ...accessibility
10055
10591
  }) {
10056
10592
  const margin = { top: 22, right: 26, bottom: xAxisLabel ? 48 : 36, left: yAxisLabel ? 56 : 44 };
10057
10593
  const plot = createPlotArea(width, height, margin);
@@ -10091,6 +10627,15 @@ function ParetoChart({
10091
10627
  const goalYEnd = yObjective === "maximize" ? goalYStart - 26 : goalYStart + 26;
10092
10628
  const arrowSize = 5;
10093
10629
  return ChartFrame({
10630
+ ...accessibility,
10631
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pareto frontier",
10632
+ description: chartDescription(accessibility.description, [
10633
+ `${xObjective} ${xAxisLabel ?? "x"}, ${yObjective} ${yAxisLabel ?? "y"}`,
10634
+ ...pointGeometries.map(
10635
+ ({ point, index, frontier: frontier2 }) => `${pointDescription(point, index, formatX, formatY, xAxisLabel, yAxisLabel)}, ${frontier2 ? "on the Pareto frontier" : "dominated"}`
10636
+ ),
10637
+ ...pointGeometries.length ? [] : ["No points"]
10638
+ ]),
10094
10639
  c,
10095
10640
  title,
10096
10641
  subtitle,
@@ -10100,18 +10645,18 @@ function ParetoChart({
10100
10645
  { label: "Pareto frontier", color: frontier },
10101
10646
  { label: "dominated", color: "neutral" }
10102
10647
  ],
10103
- children: import_react14.default.createElement(
10648
+ children: import_react15.default.createElement(
10104
10649
  "div",
10105
10650
  { style: { position: "relative", width, height, display: "flex" } },
10106
- import_react14.default.createElement(
10651
+ import_react15.default.createElement(
10107
10652
  "svg",
10108
10653
  { width, height, viewBox: `0 0 ${width} ${height}` },
10109
- showGrid && import_react14.default.createElement(
10654
+ showGrid && import_react15.default.createElement(
10110
10655
  "g",
10111
10656
  {},
10112
10657
  ...xTicks.map((tick) => {
10113
10658
  const x = pointFor(tick, yDomain.min).x;
10114
- return import_react14.default.createElement("line", {
10659
+ return import_react15.default.createElement("line", {
10115
10660
  key: `pareto-x-grid-${tick}`,
10116
10661
  x1: x,
10117
10662
  y1: plot.y,
@@ -10123,7 +10668,7 @@ function ParetoChart({
10123
10668
  }),
10124
10669
  ...yTicks.map((tick) => {
10125
10670
  const y = yInPlot(tick, yDomain, plot);
10126
- return import_react14.default.createElement("line", {
10671
+ return import_react15.default.createElement("line", {
10127
10672
  key: `pareto-y-grid-${tick}`,
10128
10673
  x1: plot.x,
10129
10674
  y1: y,
@@ -10134,7 +10679,7 @@ function ParetoChart({
10134
10679
  });
10135
10680
  })
10136
10681
  ),
10137
- import_react14.default.createElement("rect", {
10682
+ import_react15.default.createElement("rect", {
10138
10683
  x: plot.x,
10139
10684
  y: plot.y,
10140
10685
  width: plot.innerWidth,
@@ -10144,17 +10689,17 @@ function ParetoChart({
10144
10689
  strokeWidth: 1.2,
10145
10690
  rx: 6
10146
10691
  }),
10147
- showGoal && import_react14.default.createElement(
10692
+ showGoal && import_react15.default.createElement(
10148
10693
  "g",
10149
10694
  { "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) })
10695
+ import_react15.default.createElement("line", { x1: goalXStart, y1: goalY, x2: goalXEnd, y2: goalY }),
10696
+ import_react15.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY - arrowSize }),
10697
+ import_react15.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY + arrowSize }),
10698
+ import_react15.default.createElement("line", { x1: goalXStart, y1: goalYStart, x2: goalXStart, y2: goalYEnd }),
10699
+ import_react15.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart - arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) }),
10700
+ import_react15.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart + arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) })
10156
10701
  ),
10157
- frontierPath && import_react14.default.createElement("path", {
10702
+ frontierPath && import_react15.default.createElement("path", {
10158
10703
  "data-pareto-frontier": true,
10159
10704
  d: frontierPath,
10160
10705
  fill: "none",
@@ -10163,7 +10708,7 @@ function ParetoChart({
10163
10708
  strokeLinecap: "round",
10164
10709
  strokeLinejoin: "round"
10165
10710
  }),
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", {
10711
+ ...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
10712
  key: `pareto-point-${point.label ?? "point"}-${index}`,
10168
10713
  "data-pareto-status": isFrontier ? "frontier" : "dominated",
10169
10714
  cx: x,
@@ -10239,7 +10784,8 @@ function QuadrantChart({
10239
10784
  formatY = "decimal",
10240
10785
  showTicks = false,
10241
10786
  showGrid = false,
10242
- footer
10787
+ footer,
10788
+ ...accessibility
10243
10789
  }) {
10244
10790
  const margin = {
10245
10791
  top: 18,
@@ -10270,23 +10816,31 @@ function QuadrantChart({
10270
10816
  color: chartColor(point.color, c, index)
10271
10817
  }));
10272
10818
  return ChartFrame({
10819
+ ...accessibility,
10820
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Quadrant chart",
10821
+ description: chartDescription(accessibility.description, [
10822
+ `Thresholds: ${xAxisLabel ?? "x"} ${formatChartValue(resolvedXThreshold, formatX)}, ${yAxisLabel ?? "y"} ${formatChartValue(resolvedYThreshold, formatY)}`,
10823
+ ...regionEntries.map(({ key, region }) => `${key}: ${region.label}`),
10824
+ ...pointDescriptions(points, formatX, formatY, xAxisLabel, yAxisLabel),
10825
+ ...points.length ? [] : ["No points"]
10826
+ ]),
10273
10827
  c,
10274
10828
  title,
10275
10829
  subtitle,
10276
10830
  width,
10277
10831
  footer,
10278
- children: import_react14.default.createElement(
10832
+ children: import_react15.default.createElement(
10279
10833
  "div",
10280
10834
  {
10281
10835
  style: { position: "relative", width, height, display: "flex" }
10282
10836
  },
10283
- import_react14.default.createElement(
10837
+ import_react15.default.createElement(
10284
10838
  "svg",
10285
10839
  { width, height, viewBox: `0 0 ${width} ${height}` },
10286
10840
  ...regionEntries.map(({ key, region, x, y, width: regionWidth, height: regionHeight }, index) => {
10287
10841
  const color = chartColor(region.color, c, index);
10288
10842
  const emphasized = region.emphasis === true;
10289
- return import_react14.default.createElement("rect", {
10843
+ return import_react15.default.createElement("rect", {
10290
10844
  key: `quadrant-${key}`,
10291
10845
  x,
10292
10846
  y,
@@ -10298,12 +10852,12 @@ function QuadrantChart({
10298
10852
  strokeWidth: emphasized ? 2 : 0
10299
10853
  });
10300
10854
  }),
10301
- showGrid && import_react14.default.createElement(
10855
+ showGrid && import_react15.default.createElement(
10302
10856
  "g",
10303
10857
  {},
10304
10858
  ...xTicks.map((tick) => {
10305
10859
  const x = xInPlot(tick, xDomain, plot);
10306
- return import_react14.default.createElement("line", {
10860
+ return import_react15.default.createElement("line", {
10307
10861
  key: `quadrant-x-grid-${tick}`,
10308
10862
  x1: x,
10309
10863
  y1: plot.y,
@@ -10315,7 +10869,7 @@ function QuadrantChart({
10315
10869
  }),
10316
10870
  ...yTicks.map((tick) => {
10317
10871
  const y = yInPlot(tick, yDomain, plot);
10318
- return import_react14.default.createElement("line", {
10872
+ return import_react15.default.createElement("line", {
10319
10873
  key: `quadrant-y-grid-${tick}`,
10320
10874
  x1: plot.x,
10321
10875
  y1: y,
@@ -10326,7 +10880,7 @@ function QuadrantChart({
10326
10880
  });
10327
10881
  })
10328
10882
  ),
10329
- import_react14.default.createElement("rect", {
10883
+ import_react15.default.createElement("rect", {
10330
10884
  x: plot.x,
10331
10885
  y: plot.y,
10332
10886
  width: plot.innerWidth,
@@ -10336,7 +10890,7 @@ function QuadrantChart({
10336
10890
  strokeWidth: 1.2,
10337
10891
  rx: 8
10338
10892
  }),
10339
- import_react14.default.createElement("line", {
10893
+ import_react15.default.createElement("line", {
10340
10894
  x1: midX,
10341
10895
  y1: plot.y,
10342
10896
  x2: midX,
@@ -10344,7 +10898,7 @@ function QuadrantChart({
10344
10898
  stroke: c.borderLight,
10345
10899
  strokeWidth: 1.4
10346
10900
  }),
10347
- import_react14.default.createElement("line", {
10901
+ import_react15.default.createElement("line", {
10348
10902
  x1: plot.x,
10349
10903
  y1: midY,
10350
10904
  x2: plot.right,
@@ -10354,7 +10908,7 @@ function QuadrantChart({
10354
10908
  }),
10355
10909
  ...(showTicks ? xTicks : []).map((tick) => {
10356
10910
  const x = xInPlot(tick, xDomain, plot);
10357
- return import_react14.default.createElement("line", {
10911
+ return import_react15.default.createElement("line", {
10358
10912
  key: `quadrant-x-tick-${tick}`,
10359
10913
  x1: x,
10360
10914
  y1: plot.bottom,
@@ -10366,7 +10920,7 @@ function QuadrantChart({
10366
10920
  }),
10367
10921
  ...(showTicks ? yTicks : []).map((tick) => {
10368
10922
  const y = yInPlot(tick, yDomain, plot);
10369
- return import_react14.default.createElement("line", {
10923
+ return import_react15.default.createElement("line", {
10370
10924
  key: `quadrant-y-tick-${tick}`,
10371
10925
  x1: plot.x - 5,
10372
10926
  y1: y,
@@ -10376,7 +10930,7 @@ function QuadrantChart({
10376
10930
  strokeWidth: 1.2
10377
10931
  });
10378
10932
  }),
10379
- ...pointGeometries.map(({ point, index, x, y, color }) => import_react14.default.createElement("circle", {
10933
+ ...pointGeometries.map(({ point, index, x, y, color }) => import_react15.default.createElement("circle", {
10380
10934
  key: `quadrant-point-${point.label ?? index}`,
10381
10935
  cx: x,
10382
10936
  cy: y,
@@ -10452,7 +11006,8 @@ function IntervalPlot({
10452
11006
  max,
10453
11007
  format = "decimal",
10454
11008
  axisLabel,
10455
- footer
11009
+ footer,
11010
+ ...accessibility
10456
11011
  }) {
10457
11012
  const margin = { top: 22, right: 28, bottom: axisLabel ? 44 : 30, left: 96 };
10458
11013
  const plot = createPlotArea(width, height, margin);
@@ -10473,20 +11028,25 @@ function IntervalPlot({
10473
11028
  };
10474
11029
  });
10475
11030
  return ChartFrame({
11031
+ ...accessibility,
11032
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Interval plot",
11033
+ description: chartDescription(accessibility.description, data.map(
11034
+ (item) => `${item.label}: low ${item.lowLabel ?? formatChartValue(item.low, format)}, midpoint ${item.midLabel ?? formatChartValue(item.mid, format)}, high ${item.highLabel ?? formatChartValue(item.high, format)}`
11035
+ )),
10476
11036
  c,
10477
11037
  title,
10478
11038
  subtitle,
10479
11039
  width,
10480
11040
  footer,
10481
- children: import_react14.default.createElement(
11041
+ children: import_react15.default.createElement(
10482
11042
  "div",
10483
11043
  { style: { position: "relative", width, height, display: "flex" } },
10484
- import_react14.default.createElement(
11044
+ import_react15.default.createElement(
10485
11045
  "svg",
10486
11046
  { width, height, viewBox: `0 0 ${width} ${height}` },
10487
11047
  ...ticks.map((tick) => {
10488
11048
  const x = scaleX(tick);
10489
- return import_react14.default.createElement("line", {
11049
+ return import_react15.default.createElement("line", {
10490
11050
  key: `interval-tick-${tick}`,
10491
11051
  x1: x,
10492
11052
  y1: plot.y,
@@ -10496,10 +11056,10 @@ function IntervalPlot({
10496
11056
  strokeWidth: 1
10497
11057
  });
10498
11058
  }),
10499
- import_react14.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
11059
+ import_react15.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
10500
11060
  ...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 })
11061
+ 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 }),
11062
+ import_react15.default.createElement("circle", { key: `${item.label}-mid-${index}`, cx: midX, cy: y, r: 10, fill: c.bgCard, stroke: color, strokeWidth: 4 })
10503
11063
  ])
10504
11064
  ),
10505
11065
  ...ticks.map((tick, index) => {
@@ -10536,7 +11096,7 @@ function IntervalPlot({
10536
11096
  }
10537
11097
  function Badge({ label, c, color = "primary" }) {
10538
11098
  const solidColor = getReadableColor(color, c);
10539
- return import_react14.default.createElement("div", {
11099
+ return import_react15.default.createElement("div", {
10540
11100
  style: {
10541
11101
  display: "flex",
10542
11102
  alignItems: "center",
@@ -10557,7 +11117,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
10557
11117
  const offY = labelOffset?.y ?? -22;
10558
11118
  return [
10559
11119
  // Dot
10560
- import_react14.default.createElement("div", {
11120
+ import_react15.default.createElement("div", {
10561
11121
  key: `dot-${label}`,
10562
11122
  style: {
10563
11123
  position: "absolute",
@@ -10572,7 +11132,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
10572
11132
  }
10573
11133
  }),
10574
11134
  // Label
10575
- import_react14.default.createElement("div", {
11135
+ import_react15.default.createElement("div", {
10576
11136
  key: `label-${label}`,
10577
11137
  style: {
10578
11138
  position: "absolute",
@@ -10598,7 +11158,7 @@ function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
10598
11158
  if (i % 2 === 1) continue;
10599
11159
  const t = i / numDots;
10600
11160
  dots.push(
10601
- import_react14.default.createElement("div", {
11161
+ import_react15.default.createElement("div", {
10602
11162
  key: `dash-${i}`,
10603
11163
  style: {
10604
11164
  position: "absolute",
@@ -10615,7 +11175,7 @@ function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
10615
11175
  return dots;
10616
11176
  }
10617
11177
  function Legend({ items, c, title }) {
10618
- return import_react14.default.createElement(
11178
+ return import_react15.default.createElement(
10619
11179
  "div",
10620
11180
  {
10621
11181
  style: {
@@ -10628,7 +11188,7 @@ function Legend({ items, c, title }) {
10628
11188
  padding: `${densityOf(c).s(14)}px ${densityOf(c).s(16)}px`
10629
11189
  }
10630
11190
  },
10631
- title && import_react14.default.createElement("div", {
11191
+ title && import_react15.default.createElement("div", {
10632
11192
  style: {
10633
11193
  fontSize: densityOf(c).f(11),
10634
11194
  fontWeight: 700,
@@ -10639,13 +11199,13 @@ function Legend({ items, c, title }) {
10639
11199
  }
10640
11200
  }, title),
10641
11201
  ...items.map(
10642
- (item, i) => import_react14.default.createElement(
11202
+ (item, i) => import_react15.default.createElement(
10643
11203
  "div",
10644
11204
  {
10645
11205
  key: `legend-${i}`,
10646
11206
  style: { display: "flex", alignItems: "center", gap: 8 }
10647
11207
  },
10648
- import_react14.default.createElement("div", {
11208
+ import_react15.default.createElement("div", {
10649
11209
  style: {
10650
11210
  width: 16,
10651
11211
  height: item.style === "dashed" ? 0 : 2,
@@ -10655,7 +11215,7 @@ function Legend({ items, c, title }) {
10655
11215
  } : {}
10656
11216
  }
10657
11217
  }),
10658
- import_react14.default.createElement("div", {
11218
+ import_react15.default.createElement("div", {
10659
11219
  style: {
10660
11220
  fontSize: densityOf(c).f(11),
10661
11221
  color: c.textMuted,
@@ -10668,7 +11228,7 @@ function Legend({ items, c, title }) {
10668
11228
  }
10669
11229
 
10670
11230
  // src/primitives/board.ts
10671
- var import_react15 = __toESM(require("react"), 1);
11231
+ var import_react16 = __toESM(require("react"), 1);
10672
11232
  var CANVAS_ITEM_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.canvas-item");
10673
11233
  function dimension(value, name) {
10674
11234
  if (value !== void 0 && (!Number.isFinite(value) || value <= 0 || value > 8192)) {
@@ -10677,7 +11237,7 @@ function dimension(value, name) {
10677
11237
  return value;
10678
11238
  }
10679
11239
  function Board({ children, c, width = 960, height = 540, background }) {
10680
- return import_react15.default.createElement("div", { style: {
11240
+ return import_react16.default.createElement("div", { style: {
10681
11241
  display: "flex",
10682
11242
  position: "relative",
10683
11243
  width: dimension(width, "Board width"),
@@ -10689,15 +11249,15 @@ function Board({ children, c, width = 960, height = 540, background }) {
10689
11249
  }
10690
11250
  function CanvasItem({ children, x, y, width, height }) {
10691
11251
  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;
11252
+ const sizedChildren = import_react16.default.Children.map(children, (child) => {
11253
+ if (!import_react16.default.isValidElement(child)) return child;
10694
11254
  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);
11255
+ const chart = import_react16.default.cloneElement(child, { width: child.props.width ?? width, height: child.props.height ?? height });
11256
+ return import_react16.default.createElement(CanvasChartFit, { width, height, __vizmaticTextScope: child.props.__vizmaticTextScope }, chart);
10697
11257
  }
10698
- return import_react15.default.cloneElement(child, { ...width !== void 0 ? { width } : {}, ...height !== void 0 ? { height } : {} });
11258
+ return import_react16.default.cloneElement(child, { ...width !== void 0 ? { width } : {}, ...height !== void 0 ? { height } : {} });
10699
11259
  });
10700
- return import_react15.default.createElement("div", { style: {
11260
+ return import_react16.default.createElement("div", { style: {
10701
11261
  display: "flex",
10702
11262
  position: "absolute",
10703
11263
  left: x,
@@ -10710,14 +11270,14 @@ function CanvasItem({ children, x, y, width, height }) {
10710
11270
  Object.defineProperty(CanvasItem, CANVAS_ITEM_COMPONENT, { value: true });
10711
11271
 
10712
11272
  // src/primitives/science-math-physics.ts
10713
- var import_react16 = __toESM(require("react"), 1);
11273
+ var import_react17 = __toESM(require("react"), 1);
10714
11274
  var MAX_SVG_SIZE = 4096;
10715
11275
  var FONT_SIZE = 13;
10716
11276
  function finite(value, name) {
10717
11277
  if (!Number.isFinite(value)) throw new TypeError(`${name} must be finite.`);
10718
11278
  return value;
10719
11279
  }
10720
- function positive(value, name) {
11280
+ function positive2(value, name) {
10721
11281
  finite(value, name);
10722
11282
  if (value <= 0) throw new RangeError(`${name} must be greater than zero.`);
10723
11283
  return value;
@@ -10782,14 +11342,14 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
10782
11342
  const d = densityOf(c);
10783
11343
  const overlays = [];
10784
11344
  const svgChildren = [
10785
- import_react16.default.createElement("title", { key: "title" }, title),
10786
- import_react16.default.createElement("desc", { key: "description" }, description)
11345
+ import_react17.default.createElement("title", { key: "title" }, title),
11346
+ import_react17.default.createElement("desc", { key: "description" }, description)
10787
11347
  ];
10788
11348
  for (const [index, child] of children.entries()) {
10789
- if (import_react16.default.isValidElement(child) && child.type === "text") {
11349
+ if (import_react17.default.isValidElement(child) && child.type === "text") {
10790
11350
  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, {
11351
+ const text = import_react17.default.Children.toArray(textProps.children).map((part) => String(part)).join("");
11352
+ overlays.push(import_react17.default.createElement(SvgMathText, {
10793
11353
  key: `label-${index}`,
10794
11354
  text,
10795
11355
  x: textProps.x,
@@ -10806,7 +11366,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
10806
11366
  }
10807
11367
  }
10808
11368
  if (!UNNAMED_TITLES.has(title)) {
10809
- overlays.unshift(import_react16.default.createElement(SvgMathText, {
11369
+ overlays.unshift(import_react17.default.createElement(SvgMathText, {
10810
11370
  key: "diagram-title",
10811
11371
  text: title,
10812
11372
  x: 0,
@@ -10819,7 +11379,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
10819
11379
  dominantBaseline: "auto"
10820
11380
  }));
10821
11381
  }
10822
- return import_react16.default.createElement(
11382
+ return import_react17.default.createElement(
10823
11383
  "div",
10824
11384
  {
10825
11385
  role: "img",
@@ -10827,7 +11387,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
10827
11387
  "aria-description": description,
10828
11388
  style: { position: "relative", width, height, display: "flex", flexShrink: 0 }
10829
11389
  },
10830
- import_react16.default.createElement("svg", {
11390
+ import_react17.default.createElement("svg", {
10831
11391
  width,
10832
11392
  height,
10833
11393
  viewBox: `0 0 ${width} ${height}`,
@@ -10848,7 +11408,7 @@ function mapNumberLine(value, min, max, width, padding = 56) {
10848
11408
  finite(width, "NumberLine width");
10849
11409
  finite(padding, "NumberLine padding");
10850
11410
  if (padding < 0) throw new RangeError("NumberLine padding cannot be negative.");
10851
- positive(width - padding * 2, "NumberLine drawable width");
11411
+ positive2(width - padding * 2, "NumberLine drawable width");
10852
11412
  if (value < min || value > max) throw new RangeError("NumberLine value must lie within its domain.");
10853
11413
  return padding + (value - min) / range * (width - padding * 2);
10854
11414
  }
@@ -10901,9 +11461,9 @@ function NumberLine({
10901
11461
  const x = (value) => mapNumberLine(value, min, max, width);
10902
11462
  const axisY = Math.round(height * (interval && height < 220 ? 0.45 : 0.56));
10903
11463
  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 })
11464
+ import_react17.default.createElement("line", { key: "axis", x1: 56, y1: axisY, x2: width - 56, y2: axisY, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
11465
+ import_react17.default.createElement("path", { key: "left-arrow", d: `M 56 ${axisY} l 9 -5 v 10 z`, fill: c.textSecondary }),
11466
+ import_react17.default.createElement("path", { key: "right-arrow", d: `M ${width - 56} ${axisY} l -9 -5 v 10 z`, fill: c.textSecondary })
10907
11467
  ];
10908
11468
  if (interval) {
10909
11469
  const fromX = x(interval.from);
@@ -10913,21 +11473,21 @@ function NumberLine({
10913
11473
  const includeTo = interval.includeTo !== false;
10914
11474
  const intervalY = axisY + 52;
10915
11475
  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) })
11476
+ 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 }),
11477
+ 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) }),
11478
+ 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
11479
  );
10920
11480
  if (interval.label) {
10921
11481
  const label = interval.label;
10922
11482
  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));
11483
+ 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
11484
  }
10925
11485
  }
10926
11486
  for (const [index, tick] of resolvedTicks.entries()) {
10927
11487
  const tickX = x(tick.value);
10928
11488
  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))
11489
+ 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) }),
11490
+ 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
11491
  );
10932
11492
  }
10933
11493
  markers.forEach((marker, index) => {
@@ -10937,9 +11497,9 @@ function NumberLine({
10937
11497
  const labelY = Math.max(66, axisY - 54 - lane * 30);
10938
11498
  const labelX = clamp2(markerX, 56 + textWidth(marker.label, 12) / 2, width - 56 - textWidth(marker.label, 12) / 2);
10939
11499
  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)
11500
+ 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 }),
11501
+ 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) }),
11502
+ 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
11503
  );
10944
11504
  });
10945
11505
  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 +11574,7 @@ function GeometryDiagram({
11014
11574
  }
11015
11575
  if (angle.label !== void 0) labelText(angle.label, `GeometryDiagram angle ${index} label`, 32);
11016
11576
  if (angle.radius !== void 0) {
11017
- positive(angle.radius, `GeometryDiagram angle ${index} radius`);
11577
+ positive2(angle.radius, `GeometryDiagram angle ${index} radius`);
11018
11578
  if (angle.radius > 120) throw new RangeError(`GeometryDiagram angle ${index} radius cannot exceed 120 pixels.`);
11019
11579
  }
11020
11580
  colorValue(angle.color, c.accent, `GeometryDiagram angle ${index} color`);
@@ -11044,7 +11604,7 @@ function GeometryDiagram({
11044
11604
  const from = map(pointById.get(segment.from));
11045
11605
  const to = map(pointById.get(segment.to));
11046
11606
  const color = colorValue(segment.color, c.secondary, `GeometryDiagram segment ${index} color`);
11047
- elements.push(import_react16.default.createElement("line", {
11607
+ elements.push(import_react17.default.createElement("line", {
11048
11608
  key: `segment-${index}`,
11049
11609
  x1: from.x,
11050
11610
  y1: from.y,
@@ -11067,7 +11627,7 @@ function GeometryDiagram({
11067
11627
  const clearance = 8 + Math.abs(normalX) * halfWidth + Math.abs(normalY) * FONT_SIZE * 0.45;
11068
11628
  const labelX = clamp2(midX + normalX * clearance, 24 + halfWidth, width - 24 - halfWidth);
11069
11629
  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));
11630
+ 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
11631
  }
11072
11632
  });
11073
11633
  angles.forEach((angle, index) => {
@@ -11086,17 +11646,17 @@ function GeometryDiagram({
11086
11646
  });
11087
11647
  const path = arc.map((point, part) => `${part === 0 ? "M" : "L"} ${point.x.toFixed(2)} ${point.y.toFixed(2)}`).join(" ");
11088
11648
  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" }));
11649
+ 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
11650
  if (angle.label) {
11091
11651
  const middle = a1 + delta / 2;
11092
11652
  const labelX = clamp2(v.x + (radius + 18) * Math.cos(middle), 28 + textWidth(angle.label) / 2, width - 28 - textWidth(angle.label) / 2);
11093
11653
  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));
11654
+ 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
11655
  }
11096
11656
  });
11097
11657
  points.forEach((point) => {
11098
11658
  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) }));
11659
+ 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
11660
  if (point.label) {
11101
11661
  const label = point.label;
11102
11662
  const labelWidth = textWidth(label);
@@ -11105,7 +11665,7 @@ function GeometryDiagram({
11105
11665
  const baseX = position2.x + (placeRight ? 12 : -12);
11106
11666
  const labelX = boundedTextX(baseX, width, label, placeRight ? "start" : "end");
11107
11667
  const labelY = clamp2(awayY > 0 ? position2.y + FONT_SIZE + 6 : position2.y - 10, 58, height - 20);
11108
- elements.push(import_react16.default.createElement("text", {
11668
+ elements.push(import_react17.default.createElement("text", {
11109
11669
  key: `point-label-${point.id}`,
11110
11670
  x: labelX,
11111
11671
  y: labelY,
@@ -11165,9 +11725,9 @@ function FreeBodyDiagram({
11165
11725
  if (!Number.isFinite(scale) || scale <= 0) throw new RangeError("FreeBodyDiagram vector magnitudes cannot be mapped into the viewport.");
11166
11726
  const mapVector = (x, y) => ({ x: center2.x + x * scale, y: center2.y - y * scale });
11167
11727
  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) })
11728
+ 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) }),
11729
+ 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) }),
11730
+ 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
11731
  ];
11172
11732
  forces.forEach((force) => {
11173
11733
  const color = colorValue(force.color, c.secondary, `FreeBodyDiagram force "${force.id}" color`);
@@ -11175,15 +11735,15 @@ function FreeBodyDiagram({
11175
11735
  if (showComponents) {
11176
11736
  const xEnd = mapVector(force.x, 0);
11177
11737
  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 }));
11738
+ 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 }));
11739
+ 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
11740
  }
11181
11741
  elements.push(arrow(center2, end, color, `force-${force.id}`, 3));
11182
11742
  const direction = Math.sign(end.x - center2.x) || 1;
11183
11743
  const anchor = direction > 0 ? "start" : "end";
11184
11744
  const labelX = boundedTextX(end.x + direction * 12, width, force.label, anchor, 20);
11185
11745
  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));
11746
+ 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
11747
  });
11188
11748
  if (showResultant && (resultant.x !== 0 || resultant.y !== 0)) {
11189
11749
  const end = mapVector(resultant.x, resultant.y);
@@ -11191,7 +11751,7 @@ function FreeBodyDiagram({
11191
11751
  const label = `R = ${formatNumber(resultant.magnitude)}`;
11192
11752
  const direction = Math.sign(end.x - center2.x) || 1;
11193
11753
  const anchor = direction > 0 ? "start" : "end";
11194
- elements.push(import_react16.default.createElement("text", {
11754
+ elements.push(import_react17.default.createElement("text", {
11195
11755
  key: "resultant-label",
11196
11756
  x: boundedTextX(end.x + direction * 12, width, label, anchor, 20),
11197
11757
  y: clamp2(end.y + 20, 60, height - 20),
@@ -11202,11 +11762,11 @@ function FreeBodyDiagram({
11202
11762
  fontWeight: 700
11203
11763
  }, label));
11204
11764
  } 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"));
11765
+ 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
11766
  }
11207
11767
  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")
11768
+ 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"),
11769
+ 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
11770
  );
11211
11771
  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
11772
  }
@@ -11218,20 +11778,20 @@ function arrow(start, end, color, key, strokeWidth) {
11218
11778
  const angle = Math.atan2(dy, dx);
11219
11779
  const left = { x: end.x - head * Math.cos(angle - Math.PI / 6), y: end.y - head * Math.sin(angle - Math.PI / 6) };
11220
11780
  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(
11781
+ return import_react17.default.createElement(
11222
11782
  "g",
11223
11783
  {
11224
11784
  key,
11225
11785
  "data-vector-role": key === "resultant" ? "resultant" : "force",
11226
11786
  "data-vector-id": key.startsWith("force-") ? key.slice("force-".length) : void 0
11227
11787
  },
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" })
11788
+ import_react17.default.createElement("line", { x1: start.x, y1: start.y, x2: end.x, y2: end.y, stroke: color, strokeWidth, strokeLinecap: "round" }),
11789
+ 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
11790
  );
11231
11791
  }
11232
11792
  function validateWave(wave, index, c) {
11233
- positive(wave.amplitude, `WaveDiagram wave ${index} amplitude`);
11234
- positive(wave.wavelength, `WaveDiagram wave ${index} wavelength`);
11793
+ positive2(wave.amplitude, `WaveDiagram wave ${index} amplitude`);
11794
+ positive2(wave.wavelength, `WaveDiagram wave ${index} wavelength`);
11235
11795
  finite(wave.phase ?? 0, `WaveDiagram wave ${index} phase`);
11236
11796
  finite(wave.speed ?? 0, `WaveDiagram wave ${index} speed`);
11237
11797
  if (wave.label !== void 0) labelText(wave.label, `WaveDiagram wave ${index} label`, 22);
@@ -11326,28 +11886,28 @@ function WaveDiagram({
11326
11886
  const gridX = sx(xValue);
11327
11887
  const gridY = sy(yValue);
11328
11888
  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))
11889
+ 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) }),
11890
+ 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) }),
11891
+ 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)),
11892
+ 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
11893
  );
11334
11894
  }
11335
11895
  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)}`)
11896
+ 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) }),
11897
+ 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) }),
11898
+ 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"),
11899
+ 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"),
11900
+ import_react17.default.createElement("text", { key: "time-label", x: 24, y: 60, fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, `t = ${formatNumber(time)}`)
11341
11901
  );
11342
11902
  const pathFor = (points) => points.map((point, index) => `${index === 0 ? "M" : "L"} ${sx(point.x).toFixed(2)} ${sy(point.y).toFixed(2)}`).join(" ");
11343
11903
  if (showComponents) {
11344
11904
  samples.forEach((waveSamples, index) => {
11345
11905
  const wave = waves[index];
11346
11906
  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" }));
11907
+ 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
11908
  });
11349
11909
  }
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" }));
11910
+ 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
11911
  waves.forEach((wave, index) => {
11352
11912
  const label = wave.label ?? `wave ${index + 1}`;
11353
11913
  const color = colorValue(wave.color, c.secondary, `WaveDiagram wave ${index} color`);
@@ -11355,7 +11915,7 @@ function WaveDiagram({
11355
11915
  const row = index % 4;
11356
11916
  const legendX = plot.left + column * (plot.right - plot.left) / 2;
11357
11917
  const legendY = plot.top - 58 + row * 14;
11358
- elements.push(import_react16.default.createElement("line", {
11918
+ elements.push(import_react17.default.createElement("line", {
11359
11919
  key: `legend-swatch-${index}`,
11360
11920
  x1: legendX,
11361
11921
  y1: legendY - 4,
@@ -11365,7 +11925,7 @@ function WaveDiagram({
11365
11925
  strokeWidth: densityOf(c).w(3),
11366
11926
  strokeLinecap: "round"
11367
11927
  }));
11368
- elements.push(import_react16.default.createElement("text", {
11928
+ elements.push(import_react17.default.createElement("text", {
11369
11929
  key: `legend-${index}`,
11370
11930
  x: boundedTextX(legendX + 16, width, label, "start", 20, 11),
11371
11931
  y: legendY,
@@ -11375,15 +11935,15 @@ function WaveDiagram({
11375
11935
  fontWeight: 650
11376
11936
  }, label));
11377
11937
  });
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"));
11938
+ 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
11939
  if (probeX !== void 0) {
11380
11940
  const probeY = waves.reduce((sum, wave) => sum + waveValue(wave, probeX, time), 0);
11381
11941
  const probePosition = { x: sx(probeX), y: sy(probeY) };
11382
11942
  const label = `\u03A3y = ${formatNumber(probeY)}`;
11383
11943
  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)
11944
+ 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" }),
11945
+ 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) }),
11946
+ 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
11947
  );
11388
11948
  }
11389
11949
  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 +11951,9 @@ function WaveDiagram({
11391
11951
  }
11392
11952
 
11393
11953
  // src/primitives/science-chemistry.ts
11394
- var import_react17 = __toESM(require("react"), 1);
11954
+ var import_react18 = __toESM(require("react"), 1);
11395
11955
  function overlayText(key, props) {
11396
- return import_react17.default.createElement(import_react17.default.Fragment, { key }, SvgMathText(props));
11956
+ return import_react18.default.createElement(import_react18.default.Fragment, { key }, SvgMathText(props));
11397
11957
  }
11398
11958
  var ELEMENTS = /* @__PURE__ */ new Set([
11399
11959
  "H",
@@ -11645,7 +12205,7 @@ function MoleculeDiagram({
11645
12205
  const bondNodes = bonds.flatMap((bond, bondIndex) => {
11646
12206
  const from = points.get(bond.from);
11647
12207
  const to = points.get(bond.to);
11648
- return bondSegments(from, to, bond.order).map((segment, segmentIndex) => import_react17.default.createElement("line", {
12208
+ return bondSegments(from, to, bond.order).map((segment, segmentIndex) => import_react18.default.createElement("line", {
11649
12209
  key: `bond-${bondIndex}-${segmentIndex}`,
11650
12210
  x1: segment.x1,
11651
12211
  y1: segment.y1,
@@ -11665,10 +12225,10 @@ function MoleculeDiagram({
11665
12225
  const atomNodes = atoms.map((atom) => {
11666
12226
  const point = points.get(atom.id);
11667
12227
  const accent = atomColor(atom.element, c);
11668
- return import_react17.default.createElement(
12228
+ return import_react18.default.createElement(
11669
12229
  "g",
11670
12230
  { 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) })
12231
+ import_react18.default.createElement("circle", { cx: point.x, cy: point.y, r: 19, fill: c.bgCard, stroke: accent, strokeWidth: densityOf(c).w(2) })
11672
12232
  );
11673
12233
  });
11674
12234
  const textNodes = atoms.flatMap((atom) => {
@@ -11681,7 +12241,7 @@ function MoleculeDiagram({
11681
12241
  ...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
12242
  ];
11683
12243
  });
11684
- const geometry = import_react17.default.createElement(
12244
+ const geometry = import_react18.default.createElement(
11685
12245
  "svg",
11686
12246
  {
11687
12247
  width: svgWidth,
@@ -11690,11 +12250,11 @@ function MoleculeDiagram({
11690
12250
  "aria-hidden": true,
11691
12251
  style: { position: "absolute", left: 0, top: 0, display: "block" }
11692
12252
  },
11693
- import_react17.default.createElement("rect", { x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
12253
+ import_react18.default.createElement("rect", { x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
11694
12254
  ...bondNodes,
11695
12255
  ...atomNodes
11696
12256
  );
11697
- return import_react17.default.createElement(
12257
+ return import_react18.default.createElement(
11698
12258
  "div",
11699
12259
  {
11700
12260
  role: "img",
@@ -11783,7 +12343,7 @@ function reactionBalance(reactants, products) {
11783
12343
  return { status: balanced ? "balanced" : "unbalanced", balanced, elementDeltas: deltas, chargeDelta };
11784
12344
  }
11785
12345
  function equationTerm(term, index, c) {
11786
- return import_react17.default.createElement(
12346
+ return import_react18.default.createElement(
11787
12347
  "span",
11788
12348
  {
11789
12349
  key: `term-${index}-${term.formula}`,
@@ -11797,22 +12357,22 @@ function equationTerm(term, index, c) {
11797
12357
  color: c.textPrimary
11798
12358
  }
11799
12359
  },
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
12360
+ term.coefficient && term.coefficient !== 1 ? import_react18.default.createElement("span", { style: { color: getReadableColor("primary", c), fontWeight: 700, marginRight: 5 } }, `${term.coefficient}`) : null,
12361
+ import_react18.default.createElement("span", { style: { overflowWrap: "anywhere" } }, term.formula),
12362
+ term.state ? import_react18.default.createElement("span", { style: { marginLeft: 5, color: c.textSecondary, fontSize: "0.9em" } }, `(${term.state})`) : null
11803
12363
  );
11804
12364
  }
11805
12365
  function equationSide(terms, label, c) {
11806
12366
  const children = [];
11807
12367
  terms.forEach((term, index) => {
11808
- if (index > 0) children.push(import_react17.default.createElement("span", {
12368
+ if (index > 0) children.push(import_react18.default.createElement("span", {
11809
12369
  key: `plus-${index}`,
11810
12370
  style: { color: c.textSecondary, padding: "0 7px", flex: "0 0 auto" },
11811
12371
  "aria-hidden": true
11812
12372
  }, "+"));
11813
12373
  children.push(equationTerm(term, index, c));
11814
12374
  });
11815
- return import_react17.default.createElement("div", {
12375
+ return import_react18.default.createElement("div", {
11816
12376
  role: "group",
11817
12377
  "aria-label": label,
11818
12378
  style: {
@@ -11844,7 +12404,7 @@ function ReactionEquation({
11844
12404
  const balance = reactionBalance(reactants, products);
11845
12405
  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
12406
  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(
12407
+ return import_react18.default.createElement(
11848
12408
  "div",
11849
12409
  {
11850
12410
  role: "img",
@@ -11865,20 +12425,20 @@ function ReactionEquation({
11865
12425
  fontFamily: c.fontSans
11866
12426
  }
11867
12427
  },
11868
- import_react17.default.createElement(
12428
+ import_react18.default.createElement(
11869
12429
  "div",
11870
12430
  {
11871
12431
  style: { display: "flex", alignItems: "center", gap: 12, minWidth: 0 }
11872
12432
  },
11873
12433
  equationSide(reactants, "Reactants", c),
11874
- import_react17.default.createElement("span", {
12434
+ import_react18.default.createElement("span", {
11875
12435
  style: { flex: "0 0 auto", color: c.primaryLight, fontSize: densityOf(c).f(26), fontWeight: 700, padding: "0 2px" },
11876
12436
  "aria-hidden": true
11877
12437
  }, reversible ? "\u21CC" : "\u2192"),
11878
12438
  equationSide(products, "Products", c)
11879
12439
  ),
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", {
12440
+ conditions !== void 0 && conditions.length > 0 ? import_react18.default.createElement("div", { style: { color: c.textSecondary, fontSize: densityOf(c).f(13) } }, `Conditions: ${conditions}`) : null,
12441
+ import_react18.default.createElement("div", {
11882
12442
  style: {
11883
12443
  paddingTop: 8,
11884
12444
  borderTop: `1px solid ${c.borderSubtle}`,
@@ -11914,12 +12474,12 @@ function measurement(x, y1, y2, color, key, label) {
11914
12474
  const top = Math.min(y1, y2);
11915
12475
  const bottom = Math.max(y1, y2);
11916
12476
  const cap = 5;
11917
- return import_react17.default.createElement(
12477
+ return import_react18.default.createElement(
11918
12478
  "g",
11919
12479
  { 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) })
12480
+ import_react18.default.createElement("line", { x1: x, y1: top, x2: x, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5), strokeDasharray: "3 3" }),
12481
+ import_react18.default.createElement("line", { x1: x - cap, y1: top, x2: x + cap, y2: top, stroke: color, strokeWidth: densityOf().w(1.5) }),
12482
+ import_react18.default.createElement("line", { x1: x - cap, y1: bottom, x2: x + cap, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5) })
11923
12483
  );
11924
12484
  }
11925
12485
  function ReactionEnergyDiagram({
@@ -12000,19 +12560,19 @@ function ReactionEnergyDiagram({
12000
12560
  const revealWidth = progress === 0 ? 0 : (x1 - x0) * progress + 8;
12001
12561
  const gridValues = [scaleMin, (scaleMin + scaleMax) / 2, scaleMax];
12002
12562
  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(
12563
+ import_react18.default.createElement("rect", { key: "background", x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
12564
+ import_react18.default.createElement(
12005
12565
  "defs",
12006
12566
  { key: "reveal-defs" },
12007
- import_react17.default.createElement(
12567
+ import_react18.default.createElement(
12008
12568
  "clipPath",
12009
12569
  { id: revealClipId, clipPathUnits: "userSpaceOnUse" },
12010
- import_react17.default.createElement("rect", { x: x0 - 4, y: plotTop, width: revealWidth, height: plotBottom - plotTop })
12570
+ import_react18.default.createElement("rect", { x: x0 - 4, y: plotTop, width: revealWidth, height: plotBottom - plotTop })
12011
12571
  )
12012
12572
  ),
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", {
12573
+ 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) }),
12574
+ 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) }),
12575
+ ...gridValues.map((value, index) => import_react18.default.createElement("line", {
12016
12576
  key: `grid-${index}`,
12017
12577
  x1: plotLeft,
12018
12578
  y1: yFor(value),
@@ -12022,7 +12582,7 @@ function ReactionEnergyDiagram({
12022
12582
  strokeWidth: densityOf(c).w(1),
12023
12583
  strokeDasharray: "3 5"
12024
12584
  })),
12025
- import_react17.default.createElement("path", {
12585
+ import_react18.default.createElement("path", {
12026
12586
  key: "uncatalyzed-path",
12027
12587
  d: path,
12028
12588
  fill: "none",
@@ -12034,7 +12594,7 @@ function ReactionEnergyDiagram({
12034
12594
  "data-energy-path": "uncatalyzed",
12035
12595
  "data-progress": progress
12036
12596
  }),
12037
- catalyzedPath === void 0 ? null : import_react17.default.createElement("path", {
12597
+ catalyzedPath === void 0 ? null : import_react18.default.createElement("path", {
12038
12598
  key: "catalyzed-path",
12039
12599
  d: catalyzedPath,
12040
12600
  fill: "none",
@@ -12052,7 +12612,7 @@ function ReactionEnergyDiagram({
12052
12612
  ];
12053
12613
  const overlayNodes = [
12054
12614
  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", {
12615
+ import_react18.default.createElement("div", {
12056
12616
  key: "energy-label",
12057
12617
  style: {
12058
12618
  position: "absolute",
@@ -12074,7 +12634,7 @@ function ReactionEnergyDiagram({
12074
12634
  ...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
12635
  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
12636
  ];
12077
- const geometry = import_react17.default.createElement(
12637
+ const geometry = import_react18.default.createElement(
12078
12638
  "svg",
12079
12639
  {
12080
12640
  width: svgWidth,
@@ -12085,7 +12645,7 @@ function ReactionEnergyDiagram({
12085
12645
  },
12086
12646
  ...svgNodes
12087
12647
  );
12088
- return import_react17.default.createElement("div", {
12648
+ return import_react18.default.createElement("div", {
12089
12649
  role: "img",
12090
12650
  "aria-label": ariaLabel ?? `${chartTitle} (${unit})`,
12091
12651
  "aria-description": desc,
@@ -12096,7 +12656,7 @@ function ReactionEnergyDiagram({
12096
12656
  }
12097
12657
 
12098
12658
  // src/primitives/science-ai.ts
12099
- var import_react18 = __toESM(require("react"), 1);
12659
+ var import_react19 = __toESM(require("react"), 1);
12100
12660
 
12101
12661
  // src/teaching-math.ts
12102
12662
  function finite2(value, name) {
@@ -12311,11 +12871,11 @@ function AttentionMatrix({
12311
12871
  const text = (key, value, x, y, size = 14, fill = c.textPrimary, anchor = "middle", background) => {
12312
12872
  const label = SvgMathText({ text: value, x, y, fill, fontSize: size, fontFamily: c.fontSans, fontWeight: 500, textAnchor: anchor, dominantBaseline: "alphabetic" });
12313
12873
  const style = label.props.style;
12314
- return import_react18.default.cloneElement(label, { key, ...background ? { style: { ...style, backgroundColor: background } } : {} });
12874
+ return import_react19.default.cloneElement(label, { key, ...background ? { style: { ...style, backgroundColor: background } } : {} });
12315
12875
  };
12316
12876
  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."),
12877
+ import_react19.default.createElement("title", { key: "title" }, title),
12878
+ 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
12879
  text("heading", title, 22, 30, 20, c.textPrimary, "start"),
12320
12880
  text("keys", "KEYS", left + (width - left - right) / 2, 58, 12, c.textSecondary),
12321
12881
  text("query-heading", "QUERY", 22, 81, 12, c.textSecondary, "start"),
@@ -12330,7 +12890,7 @@ function AttentionMatrix({
12330
12890
  const masked = mask?.[i][j] === false;
12331
12891
  const selected = activeQuery === i && (activeKey === void 0 || activeKey === j);
12332
12892
  const fill = masked ? c.bgCardAlt : compositeColor(withColorAlpha(c.primary, 0.12 + 0.88 * weight), c.bg);
12333
- marks.push(import_react18.default.createElement("rect", {
12893
+ marks.push(import_react19.default.createElement("rect", {
12334
12894
  key: `cell-${i}-${j}`,
12335
12895
  x: x + 2,
12336
12896
  y: y + 2,
@@ -12343,7 +12903,7 @@ function AttentionMatrix({
12343
12903
  }));
12344
12904
  if (masked) {
12345
12905
  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 }));
12906
+ 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
12907
  } else {
12348
12908
  const label = weight.toFixed(2);
12349
12909
  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 +12913,11 @@ function AttentionMatrix({
12353
12913
  marks.push(text(`sum-${i}`, total.toFixed(0), width - 30, y + cellHeight / 2 + 5, 14, c.textSecondary));
12354
12914
  });
12355
12915
  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(
12916
+ const isLabel = (node) => import_react19.default.isValidElement(node) && node.type === "div";
12917
+ return import_react19.default.createElement(
12358
12918
  "div",
12359
12919
  { 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))),
12920
+ import_react19.default.createElement("svg", { width, height, viewBox: `0 0 ${width} ${height}` }, ...marks.filter((node) => !isLabel(node))),
12361
12921
  ...marks.filter(isLabel)
12362
12922
  );
12363
12923
  }
@@ -12390,7 +12950,7 @@ function transposeMatrix(matrix) {
12390
12950
  }
12391
12951
 
12392
12952
  // src/primitives/image-tensor.ts
12393
- var import_react19 = __toESM(require("react"), 1);
12953
+ var import_react20 = __toESM(require("react"), 1);
12394
12954
  var MAX_IMAGE_AXIS = 128;
12395
12955
  var MAX_IMAGE_PIXELS = 1024;
12396
12956
  var MAX_COMPONENT_SIZE = 32768;
@@ -12499,7 +13059,7 @@ function PixelGrid({
12499
13059
  const rgb = channel === "red" ? [pixel[0], 0, 0] : channel === "green" ? [0, pixel[1], 0] : channel === "blue" ? [0, 0, pixel[2]] : pixel;
12500
13060
  return `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
12501
13061
  };
12502
- const cells = pixels.flatMap((row, rowIndex) => row.map((pixel, columnIndex) => import_react19.default.createElement("rect", {
13062
+ const cells = pixels.flatMap((row, rowIndex) => row.map((pixel, columnIndex) => import_react20.default.createElement("rect", {
12503
13063
  key: `pixel-${rowIndex}-${columnIndex}`,
12504
13064
  x: offsetX + columnIndex * pixelSize,
12505
13065
  y: offsetY + rowIndex * pixelSize,
@@ -12510,7 +13070,7 @@ function PixelGrid({
12510
13070
  const strokeWidth = pixelSize * 0.16;
12511
13071
  const marks = [...cells];
12512
13072
  if (region) {
12513
- marks.push(import_react19.default.createElement("rect", {
13073
+ marks.push(import_react20.default.createElement("rect", {
12514
13074
  key: "region-highlight",
12515
13075
  x: offsetX + region.column * pixelSize + strokeWidth / 2,
12516
13076
  y: offsetY + region.row * pixelSize + strokeWidth / 2,
@@ -12523,7 +13083,7 @@ function PixelGrid({
12523
13083
  }));
12524
13084
  }
12525
13085
  if (activeCell) {
12526
- marks.push(import_react19.default.createElement("rect", {
13086
+ marks.push(import_react20.default.createElement("rect", {
12527
13087
  key: "active-cell-highlight",
12528
13088
  x: offsetX + activeCell.column * pixelSize + strokeWidth / 2,
12529
13089
  y: offsetY + activeCell.row * pixelSize + strokeWidth / 2,
@@ -12535,11 +13095,11 @@ function PixelGrid({
12535
13095
  }));
12536
13096
  }
12537
13097
  const channelLabel = channel === "rgb" ? "RGB" : `${channel} channel`;
12538
- return import_react19.default.createElement("div", {
13098
+ return import_react20.default.createElement("div", {
12539
13099
  role: "img",
12540
13100
  "aria-label": `${shape.rows} by ${shape.columns} pixel image, ${channelLabel}`,
12541
13101
  style: { position: "relative", display: "flex", width, height, backgroundColor: c.bgCard, flexShrink: 0 }
12542
- }, import_react19.default.createElement("svg", {
13102
+ }, import_react20.default.createElement("svg", {
12543
13103
  width,
12544
13104
  height,
12545
13105
  viewBox: `0 0 ${width} ${height}`,
@@ -14600,12 +15160,12 @@ var import_url = require("url");
14600
15160
  var import_zlib = require("zlib");
14601
15161
 
14602
15162
  // src/brand.ts
14603
- var import_react20 = __toESM(require("react"), 1);
15163
+ var import_react21 = __toESM(require("react"), 1);
14604
15164
  var DEFAULT_WATERMARK_TEXT = "Vizmatic";
14605
15165
  var WATERMARK_COLOR_DARK = "#a5a7ad";
14606
15166
  var WATERMARK_COLOR_LIGHT = "#5e5a50";
14607
15167
  function VizmaticIcon({ size = 14, color }) {
14608
- return import_react20.default.createElement(
15168
+ return import_react21.default.createElement(
14609
15169
  "svg",
14610
15170
  {
14611
15171
  xmlns: "http://www.w3.org/2000/svg",
@@ -14614,19 +15174,19 @@ function VizmaticIcon({ size = 14, color }) {
14614
15174
  viewBox: "0 0 28 28",
14615
15175
  fill: "none"
14616
15176
  },
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 })
15177
+ 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 }),
15178
+ import_react21.default.createElement("rect", { x: 7, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.35 }),
15179
+ import_react21.default.createElement("rect", { x: 15.5, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color }),
15180
+ import_react21.default.createElement("rect", { x: 7, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.82 }),
15181
+ 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 }),
15182
+ 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
15183
  );
14624
15184
  }
14625
15185
  function normalizeWatermark(watermark) {
14626
15186
  if (watermark == null || watermark === false) return void 0;
14627
15187
  if (watermark === true) return {};
14628
15188
  if (typeof watermark === "string") return { text: watermark };
14629
- if (import_react20.default.isValidElement(watermark)) {
15189
+ if (import_react21.default.isValidElement(watermark)) {
14630
15190
  if (watermark.type !== Watermark) return { element: watermark };
14631
15191
  const { children, ...props } = watermark.props;
14632
15192
  return {
@@ -14655,7 +15215,7 @@ function positionStyle(position2) {
14655
15215
  function imageNode(image) {
14656
15216
  if (!image) return void 0;
14657
15217
  const imageOptions = typeof image === "string" ? { src: image } : image;
14658
- return import_react20.default.createElement("img", {
15218
+ return import_react21.default.createElement("img", {
14659
15219
  src: imageOptions.src,
14660
15220
  alt: imageOptions.alt ?? "",
14661
15221
  width: imageOptions.width ?? 14,
@@ -14670,9 +15230,9 @@ function imageNode(image) {
14670
15230
  }
14671
15231
  function iconNode(icon, color) {
14672
15232
  if (icon === false) return void 0;
14673
- if (icon == null) return import_react20.default.createElement(VizmaticIcon, { size: 13, color });
15233
+ if (icon == null) return import_react21.default.createElement(VizmaticIcon, { size: 13, color });
14674
15234
  if (typeof icon !== "string") return icon;
14675
- return import_react20.default.createElement("div", {
15235
+ return import_react21.default.createElement("div", {
14676
15236
  style: {
14677
15237
  minWidth: 13,
14678
15238
  height: 13,
@@ -14697,7 +15257,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
14697
15257
  const text = options?.text ?? DEFAULT_WATERMARK_TEXT;
14698
15258
  const content = options?.element ?? [
14699
15259
  icon,
14700
- text !== false && text && import_react20.default.createElement("div", {
15260
+ text !== false && text && import_react21.default.createElement("div", {
14701
15261
  key: "text",
14702
15262
  style: {
14703
15263
  fontSize: 11,
@@ -14708,7 +15268,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
14708
15268
  }
14709
15269
  }, text)
14710
15270
  ];
14711
- return import_react20.default.createElement(
15271
+ return import_react21.default.createElement(
14712
15272
  "div",
14713
15273
  {
14714
15274
  style: {
@@ -14719,7 +15279,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
14719
15279
  }
14720
15280
  },
14721
15281
  element,
14722
- options && import_react20.default.createElement(
15282
+ options && import_react21.default.createElement(
14723
15283
  "div",
14724
15284
  {
14725
15285
  style: {
@@ -16379,7 +16939,7 @@ function nonnegative(value, name) {
16379
16939
  finite3(value, name);
16380
16940
  if (value < 0) throw new Error(`${name} must be nonnegative`);
16381
16941
  }
16382
- function positive2(value, name) {
16942
+ function positive3(value, name) {
16383
16943
  finite3(value, name);
16384
16944
  if (value <= 0) throw new Error(`${name} must be positive`);
16385
16945
  }
@@ -16390,17 +16950,17 @@ function normalizedOpacity(value, name = "Canvas opacity") {
16390
16950
  function validateBounds(bounds4) {
16391
16951
  finite3(bounds4.x, "Canvas x");
16392
16952
  finite3(bounds4.y, "Canvas y");
16393
- positive2(bounds4.width, "Canvas width");
16394
- positive2(bounds4.height, "Canvas height");
16953
+ positive3(bounds4.width, "Canvas width");
16954
+ positive3(bounds4.height, "Canvas height");
16395
16955
  nonnegative(bounds4.radius ?? 14, "Canvas radius");
16396
16956
  }
16397
16957
  function layoutTokenRow(values, options = {}) {
16398
16958
  const { advance = 24, gap = 16, minWidth = 64, paddingX = 17, width } = options;
16399
16959
  nonnegative(advance, "Token advance");
16400
16960
  nonnegative(gap, "Token gap");
16401
- positive2(minWidth, "Token minimum width");
16961
+ positive3(minWidth, "Token minimum width");
16402
16962
  nonnegative(paddingX, "Token horizontal padding");
16403
- if (width !== void 0) positive2(width, "Token width");
16963
+ if (width !== void 0) positive3(width, "Token width");
16404
16964
  if (options.x !== void 0) finite3(options.x, "Token x");
16405
16965
  if (options.centerX !== void 0) finite3(options.centerX, "Token center x");
16406
16966
  const items = values.map((value) => {
@@ -16444,7 +17004,7 @@ function createCanvasComponents(painter) {
16444
17004
  }
16445
17005
  function card(options) {
16446
17006
  const { label, x, y, width, height, fontSize = 32, font = "sans", textColor, baselineOffset = fontSize * 0.34, labelOpacity = 1 } = options;
16447
- positive2(fontSize, "Canvas font size");
17007
+ positive3(fontSize, "Canvas font size");
16448
17008
  finite3(baselineOffset, "Canvas text baseline offset");
16449
17009
  const labelAlpha = normalizedOpacity(labelOpacity, "Canvas label opacity");
16450
17010
  return panel(options, () => {
@@ -16457,7 +17017,7 @@ function createCanvasComponents(painter) {
16457
17017
  const { values, x, y, cellSize = 112, gap = 8, inset = 0, format = String, style = {}, cellStyle } = options;
16458
17018
  finite3(x, "Matrix x");
16459
17019
  finite3(y, "Matrix y");
16460
- positive2(cellSize, "Matrix cell size");
17020
+ positive3(cellSize, "Matrix cell size");
16461
17021
  nonnegative(gap, "Matrix gap");
16462
17022
  finite3(inset, "Matrix inset");
16463
17023
  if (gap >= cellSize) throw new Error("Matrix gap must be smaller than cell size");
@@ -16488,7 +17048,7 @@ function createCanvasComponents(painter) {
16488
17048
  function tokenRow(options) {
16489
17049
  const { values, y, height = 68, reveal = 1, opacity = 1, ...style } = options;
16490
17050
  finite3(y, "Token row y");
16491
- positive2(height, "Token height");
17051
+ positive3(height, "Token height");
16492
17052
  finite3(reveal, "Token reveal");
16493
17053
  const alpha3 = normalizedOpacity(opacity);
16494
17054
  const items = layoutTokenRow(values, options);
@@ -16505,7 +17065,7 @@ function createCanvasComponents(painter) {
16505
17065
  function particle(options) {
16506
17066
  const { points, progress, radius = 9, fill, stroke, strokeWidth = 3 } = options;
16507
17067
  finite3(progress, "Particle progress");
16508
- positive2(radius, "Particle radius");
17068
+ positive3(radius, "Particle radius");
16509
17069
  nonnegative(strokeWidth, "Particle stroke width");
16510
17070
  if (progress <= 0 || progress >= 1) return null;
16511
17071
  const point = pointAlongPath(points, progress);
@@ -16600,14 +17160,14 @@ function createTeachingTransfer(painter) {
16600
17160
  }
16601
17161
 
16602
17162
  // src/teaching-grid.ts
16603
- function positive3(value, name) {
17163
+ function positive4(value, name) {
16604
17164
  if (!Number.isFinite(value) || value <= 0) throw new Error(`${name} must be finite and positive`);
16605
17165
  }
16606
17166
  function layoutCellGrid(options) {
16607
17167
  const { x, y, width, height, rows, columns } = options;
16608
17168
  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");
17169
+ positive4(width, "Grid width");
17170
+ positive4(height, "Grid height");
16611
17171
  if (![rows, columns, rows * columns].every(Number.isSafeInteger) || rows <= 0 || columns <= 0) {
16612
17172
  throw new Error("Grid rows and columns must be positive safe integers");
16613
17173
  }
@@ -16649,9 +17209,9 @@ function createTeachingGrid(painter) {
16649
17209
  textColor = "#FFFFFF",
16650
17210
  padding = 4
16651
17211
  } = options;
16652
- positive3(lineWidth, "Grid line width");
17212
+ positive4(lineWidth, "Grid line width");
16653
17213
  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");
17214
+ positive4(fontSize, "Grid font size");
16655
17215
  if (!Number.isFinite(padding) || padding < 0) throw new Error("Grid padding must be finite and nonnegative");
16656
17216
  if (labels && (labels.length !== rows || labels.some((row) => row.length !== columns))) {
16657
17217
  throw new Error("Grid labels must match rows and columns");
@@ -17078,14 +17638,14 @@ function weightedVectorState(options) {
17078
17638
  total: [...prefix2]
17079
17639
  };
17080
17640
  }
17081
- function positive4(value, name) {
17641
+ function positive5(value, name) {
17082
17642
  if (finite4(value, name) <= 0) throw new Error(`${name} must be positive`);
17083
17643
  }
17084
17644
  function bounds2(value, name) {
17085
17645
  finite4(value.x, `${name} x`);
17086
17646
  finite4(value.y, `${name} y`);
17087
- positive4(value.width, `${name} width`);
17088
- positive4(value.height, `${name} height`);
17647
+ positive5(value.width, `${name} width`);
17648
+ positive5(value.height, `${name} height`);
17089
17649
  }
17090
17650
  function createTeachingVectorAccumulation(painter) {
17091
17651
  return (options) => {
@@ -17106,9 +17666,9 @@ function createTeachingVectorAccumulation(painter) {
17106
17666
  } = options;
17107
17667
  bounds2(plot.bounds, "Vector plot");
17108
17668
  bounds2(ledger, "Vector ledger");
17109
- positive4(fontSize, "Vector font size");
17110
- positive4(width, "Vector stroke width");
17111
- positive4(endpointRadius, "Vector endpoint radius");
17669
+ positive5(fontSize, "Vector font size");
17670
+ positive5(width, "Vector stroke width");
17671
+ positive5(endpointRadius, "Vector endpoint radius");
17112
17672
  finite4(completedOpacity, "Completed vector opacity");
17113
17673
  if (completedOpacity < 0 || completedOpacity > 1) throw new Error("Completed vector opacity must lie between zero and one");
17114
17674
  const [x0, x1] = plot.xDomain, [y0, y1] = plot.yDomain;
@@ -17861,15 +18421,15 @@ var PANEL = "#18283B";
17861
18421
  function finite6(value, name) {
17862
18422
  if (!Number.isFinite(value)) throw new Error(`${name} must be finite`);
17863
18423
  }
17864
- function positive5(value, name) {
18424
+ function positive6(value, name) {
17865
18425
  finite6(value, name);
17866
18426
  if (value <= 0) throw new Error(`${name} must be positive`);
17867
18427
  }
17868
18428
  function boundsOf(options) {
17869
18429
  finite6(options.x, "Teaching x");
17870
18430
  finite6(options.y, "Teaching y");
17871
- positive5(options.width, "Teaching width");
17872
- positive5(options.height, "Teaching height");
18431
+ positive6(options.width, "Teaching width");
18432
+ positive6(options.height, "Teaching height");
17873
18433
  return { x: options.x, y: options.y, width: options.width, height: options.height };
17874
18434
  }
17875
18435
  function amount(value, name = "Teaching progress") {
@@ -17905,7 +18465,7 @@ function createTeachingCanvas(painter) {
17905
18465
  }
17906
18466
  const { x, y, width, height } = bounds4;
17907
18467
  const { color = INK, gridColor, fontSize = 28, xTicks = [], yTicks = [], formatX = String, formatY = String } = options;
17908
- positive5(fontSize, "Axis font size");
18468
+ positive6(fontSize, "Axis font size");
17909
18469
  xTicks.forEach((tick) => finite6(tick, "Axis x tick"));
17910
18470
  yTicks.forEach((tick) => finite6(tick, "Axis y tick"));
17911
18471
  const plot = {
@@ -17946,7 +18506,7 @@ function createTeachingCanvas(painter) {
17946
18506
  }
17947
18507
  function curve(options) {
17948
18508
  const { plot, points, color, width = 4, progress = 1 } = options;
17949
- positive5(width, "Curve width");
18509
+ positive6(width, "Curve width");
17950
18510
  const mapped = points.map((point) => plot.point(point.x, point.y));
17951
18511
  const visible = tracePolyline(mapped, progress);
17952
18512
  if (visible.length > 1) painter.path(visible, { color, width, clip: plot.bounds });
@@ -17954,10 +18514,10 @@ function createTeachingCanvas(painter) {
17954
18514
  }
17955
18515
  function scatter(options) {
17956
18516
  const { plot, points, color = ACCENT, radius = 7, opacity = 1 } = options;
17957
- positive5(radius, "Scatter radius");
18517
+ positive6(radius, "Scatter radius");
17958
18518
  const alpha3 = amount(opacity, "Scatter opacity");
17959
18519
  const projected = points.map((point) => {
17960
- positive5(point.radius ?? radius, "Scatter point radius");
18520
+ positive6(point.radius ?? radius, "Scatter point radius");
17961
18521
  return {
17962
18522
  ...plot.point(point.x, point.y),
17963
18523
  radius: point.radius ?? radius,
@@ -17979,7 +18539,7 @@ function createTeachingCanvas(painter) {
17979
18539
  const bounds4 = boundsOf(options);
17980
18540
  const { x, y, width, height } = bounds4;
17981
18541
  const { values, labels, colors: colors2, color = ACCENT, progress = 1, showValues = false, format = String, fontSize = 28, gap = 20 } = options;
17982
- positive5(fontSize, "Bar font size");
18542
+ positive6(fontSize, "Bar font size");
17983
18543
  finite6(gap, "Bar gap");
17984
18544
  if (gap < 0) throw new Error("Bar gap must be nonnegative");
17985
18545
  values.forEach((value) => {
@@ -17990,12 +18550,12 @@ function createTeachingCanvas(painter) {
17990
18550
  if (colors2 && colors2.length !== values.length) throw new Error("Bar colors must match values");
17991
18551
  const maximumValue = values.reduce((maximum2, value) => Math.max(maximum2, value), 0);
17992
18552
  const maximum = options.max ?? (maximumValue || 1);
17993
- positive5(maximum, "Bar maximum");
18553
+ positive6(maximum, "Bar maximum");
17994
18554
  if (maximum < maximumValue) throw new Error("Bar maximum must contain every value");
17995
18555
  const reveal = amount(progress);
17996
18556
  if (!values.length) return { bars: [], slots: [], bounds: bounds4 };
17997
18557
  const barWidth = (width - gap * (values.length - 1)) / values.length;
17998
- positive5(barWidth, "Bar width after gaps");
18558
+ positive6(barWidth, "Bar width after gaps");
17999
18559
  const shapes = [];
18000
18560
  const slots = [];
18001
18561
  values.forEach((value, index) => {
@@ -18016,7 +18576,7 @@ function createTeachingCanvas(painter) {
18016
18576
  for (const node of nodes) {
18017
18577
  if (!node.id || Object.hasOwn(descriptors, node.id)) throw new Error("Flow node IDs must be nonempty and unique");
18018
18578
  const bounds4 = boundsOf(node);
18019
- positive5(node.fontSize ?? 30, "Flow node font size");
18579
+ positive6(node.fontSize ?? 30, "Flow node font size");
18020
18580
  finite6(node.radius ?? 14, "Flow node radius");
18021
18581
  if ((node.radius ?? 14) < 0) throw new Error("Flow node radius must be nonnegative");
18022
18582
  descriptors[node.id] = { ...bounds4, radius: node.radius ?? 14 };
@@ -18025,7 +18585,7 @@ function createTeachingCanvas(painter) {
18025
18585
  if (!Object.hasOwn(descriptors, edge.from) || !Object.hasOwn(descriptors, edge.to)) throw new Error("Flow edge must reference existing nodes");
18026
18586
  if (edge.from === edge.to) throw new Error("Flow edges must connect distinct nodes");
18027
18587
  if (edge.progress !== void 0) amount(edge.progress);
18028
- if (edge.width !== void 0) positive5(edge.width, "Flow edge width");
18588
+ if (edge.width !== void 0) positive6(edge.width, "Flow edge width");
18029
18589
  for (const gap of [edge.gap, edge.fromGap, edge.toGap]) {
18030
18590
  if (gap !== void 0) finite6(gap, "Flow edge gap");
18031
18591
  }
@@ -18619,7 +19179,7 @@ async function renderRgbaVideo(renderFrame2, options) {
18619
19179
  }
18620
19180
 
18621
19181
  // src/scene-renderer.ts
18622
- var import_react21 = __toESM(require("react"), 1);
19182
+ var import_react22 = __toESM(require("react"), 1);
18623
19183
  var import_promises4 = require("fs/promises");
18624
19184
  var import_node_fs = require("fs");
18625
19185
  var import_node_path = require("path");
@@ -18803,6 +19363,7 @@ var SCENE_COMPONENT_NAMES = Object.freeze([
18803
19363
  "DiagramLegend",
18804
19364
  "DonutChart",
18805
19365
  "DotPoint",
19366
+ "EntityRelationshipDiagram",
18806
19367
  "EquationCard",
18807
19368
  "FactRows",
18808
19369
  "Flow",
@@ -19013,7 +19574,7 @@ function validateSceneComponentProps(name, props) {
19013
19574
  const check = (value, key) => {
19014
19575
  if (++values > 8192) throw new Error(`Editable scene ${name} props exceed their value budget.`);
19015
19576
  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}`);
19577
+ 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
19578
  if (/^(?:rows|cols|columns|count|repeat|gridCount|tickCount)$/i.test(key)) integer(value, `${name}.${key}`, key === "gridCount" ? 0 : 1, 2e3);
19018
19579
  }
19019
19580
  if (Array.isArray(value)) value.forEach((item) => check(item, ""));
@@ -19041,6 +19602,12 @@ function validateSceneComponentProps(name, props) {
19041
19602
  for (const key of ["nodes", "groups", "boundaries", "blocks"]) entries(props[key], `${name}.${key}`, 128);
19042
19603
  for (const key of ["edges", "connections", "routes"]) entries(props[key], `${name}.${key}`, 256);
19043
19604
  }
19605
+ if (name === "EntityRelationshipDiagram") {
19606
+ entries(props.entities, "EntityRelationshipDiagram.entities", 128).forEach((entity) => {
19607
+ entries(record(entity, "Entity relationship entity").attributes, "EntityRelationshipDiagram.attributes", 64);
19608
+ });
19609
+ entries(props.relationships, "EntityRelationshipDiagram.relationships", 256);
19610
+ }
19044
19611
  if (name === "TransformerTopology" && props.expandRepeats) {
19045
19612
  const blocks = entries(props.blocks, "TransformerTopology.blocks", 128);
19046
19613
  const total = blocks.reduce((sum, block) => sum + integer(record(block, "Transformer block").repeat ?? 1, "Transformer block.repeat", 1, 128), 0);
@@ -19463,11 +20030,11 @@ function serializeSvg(node, budget, depth = 0) {
19463
20030
  if (node === null || node === void 0 || typeof node === "boolean") return "";
19464
20031
  if (typeof node === "string" || typeof node === "number") return emit(xml(node));
19465
20032
  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);
20033
+ if (!import_react22.default.isValidElement(node)) throw new Error("Invalid resolved SVG child.");
20034
+ if (node.type === import_react22.default.Fragment) return serializeSvg(node.props.children, budget, depth + 1);
19468
20035
  if (node.type === SvgMathText) {
19469
20036
  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);
20037
+ return serializeSvg(import_react22.default.createElement("text", { x, y, fill, fontSize, fontFamily, fontWeight, textAnchor, dominantBaseline, opacity }, String(text)), budget, depth + 1);
19471
20038
  }
19472
20039
  if (typeof node.type === "function") {
19473
20040
  return serializeSvg(node.type(node.props), budget, depth + 1);
@@ -19496,10 +20063,10 @@ function graphToReact(value, theme) {
19496
20063
  const props = Object.fromEntries(Object.entries(value.props).map(([name, prop]) => [name, convertProp(prop)]));
19497
20064
  const component = trustedComponents[value.type];
19498
20065
  if (component) props.c ??= theme;
19499
- return import_react21.default.createElement(component ?? value.type, props, ...value.children.map((child) => graphToReact(child, theme)));
20066
+ return import_react22.default.createElement(component ?? value.type, props, ...value.children.map((child) => graphToReact(child, theme)));
19500
20067
  }
19501
20068
  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 });
20069
+ const root = import_react22.default.cloneElement(element, { xmlns: "http://www.w3.org/2000/svg", width, height });
19503
20070
  const svg = serializeSvg(root, budget);
19504
20071
  const image = new import_resvg_js4.Resvg(svg, {
19505
20072
  font: { loadSystemFonts: false, fontFiles: assets.fontFiles, defaultFontFamily: "Inter" },
@@ -19512,7 +20079,7 @@ function renderSvgImage(element, assets, width, height, budget, outputScale = 1,
19512
20079
  function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
19513
20080
  if (++budget.nodes > SCENE_LIMITS.nodes * 16) throw new Error("Resolved scene exceeds its host element budget.");
19514
20081
  if (Array.isArray(node)) return node.map((child) => rasterizeNestedSvg(child, assets, defaultWidth, defaultHeight, budget));
19515
- if (!import_react21.default.isValidElement(node)) return node;
20082
+ if (!import_react22.default.isValidElement(node)) return node;
19516
20083
  if (node.type === "svg") {
19517
20084
  const width = typeof node.props.width === "number" ? node.props.width : defaultWidth;
19518
20085
  const height = typeof node.props.height === "number" ? node.props.height : defaultHeight;
@@ -19525,7 +20092,7 @@ function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
19525
20092
  throw new Error("Nested SVG rasterization exceeds the per-frame pixel or image budget.");
19526
20093
  }
19527
20094
  const { png } = renderSvgImage(node, assets, width, height, budget);
19528
- return import_react21.default.createElement("img", {
20095
+ return import_react22.default.createElement("img", {
19529
20096
  width,
19530
20097
  height,
19531
20098
  src: `data:image/png;base64,${Buffer.from(png).toString("base64")}`,
@@ -19534,20 +20101,20 @@ function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
19534
20101
  }
19535
20102
  if (typeof node.type === "function") return rasterizeNestedSvg(node.type(node.props), assets, defaultWidth, defaultHeight, budget);
19536
20103
  validateResolvedSceneResources(node.props);
19537
- return import_react21.default.cloneElement(node, {}, rasterizeNestedSvg(node.props.children, assets, defaultWidth, defaultHeight, budget));
20104
+ return import_react22.default.cloneElement(node, {}, rasterizeNestedSvg(node.props.children, assets, defaultWidth, defaultHeight, budget));
19538
20105
  }
19539
20106
  async function renderPreparedFrame(prepared, assets, time, outputScale, includePng) {
19540
20107
  const evaluated = await prepared.evaluate(time);
19541
20108
  const { width, height, theme } = prepared.request;
19542
20109
  const c = getThemeColors(theme);
19543
20110
  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]
20111
+ if (import_react22.default.isValidElement(element) && element.type === "svg") {
20112
+ const image = renderSvgImage(import_react22.default.cloneElement(element, {
20113
+ children: [import_react22.default.createElement("rect", { key: "__scene_background", width, height, fill: c.bg }), element.props.children]
19547
20114
  }), assets, width, height, { pixels: 0, count: 0, nodes: 0, svgBytes: 0 }, outputScale, includePng);
19548
20115
  return image;
19549
20116
  }
19550
- element = import_react21.default.createElement("div", { style: { display: "flex", position: "relative", width, height, backgroundColor: c.bg, fontFamily: "Inter", color: c.textPrimary } }, element);
20117
+ element = import_react22.default.createElement("div", { style: { display: "flex", position: "relative", width, height, backgroundColor: c.bg, fontFamily: "Inter", color: c.textPrimary } }, element);
19551
20118
  return withRenderContext({ background: "theme" }, async () => {
19552
20119
  element = rasterizeNestedSvg(element, assets, width, height, { pixels: 0, count: 0, nodes: 0, svgBytes: 0 });
19553
20120
  const accessible = prepareAccessibleSvg(element);
@@ -20215,7 +20782,7 @@ var import_path4 = require("path");
20215
20782
 
20216
20783
  // src/diagnostics.ts
20217
20784
  var import_parse_css_color5 = __toESM(require("parse-css-color"), 1);
20218
- var import_react22 = require("react");
20785
+ var import_react23 = require("react");
20219
20786
  var CHECK_DIAGNOSTIC_CODES = [
20220
20787
  "accessibility.low_contrast",
20221
20788
  "api.unsupported_prop",
@@ -20347,14 +20914,14 @@ function styleRecord(value) {
20347
20914
  return value;
20348
20915
  }
20349
20916
  function hasDirectText(children) {
20350
- return import_react22.Children.toArray(children).some((child) => typeof child === "string" || typeof child === "number");
20917
+ return import_react23.Children.toArray(children).some((child) => typeof child === "string" || typeof child === "number");
20351
20918
  }
20352
20919
  function elementId(props) {
20353
20920
  const value = props.id ?? props["data-vizmatic-id"];
20354
20921
  return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
20355
20922
  }
20356
20923
  function resolveFunctionComponent(node, trustedComponents2) {
20357
- if (!(0, import_react22.isValidElement)(node) || typeof node.type !== "function" || trustedComponents2.has(node.type)) return void 0;
20924
+ if (!(0, import_react23.isValidElement)(node) || typeof node.type !== "function" || trustedComponents2.has(node.type)) return void 0;
20358
20925
  const component = node.type;
20359
20926
  if (component.__vizmaticPrimitive) return void 0;
20360
20927
  if (component.prototype?.isReactComponent) return void 0;
@@ -20369,7 +20936,7 @@ function analyzeScene(element, theme, trustedComponents2, rootBackground2, svgCo
20369
20936
  const seen = /* @__PURE__ */ new Set();
20370
20937
  let visited = 0;
20371
20938
  function visit(node, inherited, path, namespace) {
20372
- if (visited++ >= MAX_CONTRAST_NODES || !(0, import_react22.isValidElement)(node)) return;
20939
+ if (visited++ >= MAX_CONTRAST_NODES || !(0, import_react23.isValidElement)(node)) return;
20373
20940
  const resolved = resolveFunctionComponent(node, trustedComponents2);
20374
20941
  if (resolved !== void 0) {
20375
20942
  visit(resolved, inherited, path, namespace);
@@ -20423,7 +20990,7 @@ function analyzeScene(element, theme, trustedComponents2, rootBackground2, svgCo
20423
20990
  }
20424
20991
  }
20425
20992
  }
20426
- import_react22.Children.forEach(props.children, (child, index) => visit(child, context, `${path}.${index}`, childNamespace));
20993
+ import_react23.Children.forEach(props.children, (child, index) => visit(child, context, `${path}.${index}`, childNamespace));
20427
20994
  }
20428
20995
  visit(element, { background: colorFromCss(rootBackground2) }, "root", "html");
20429
20996
  return diagnostics;
@@ -21116,6 +21683,7 @@ async function checkFrame(input, options = {}) {
21116
21683
  DonutChart,
21117
21684
  DotPoint,
21118
21685
  ELEMENT_SYMBOLS,
21686
+ EntityRelationshipDiagram,
21119
21687
  EquationCard,
21120
21688
  FactRows,
21121
21689
  Flow,