@opendata-ai/openchart-core 9.0.0 → 9.1.0

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.js CHANGED
@@ -443,7 +443,7 @@ function resolveMarkDef(mark) {
443
443
  return typeof mark === "string" ? { type: mark } : mark;
444
444
  }
445
445
  function isChartSpec(spec) {
446
- return "mark" in spec && !("layer" in spec);
446
+ return "mark" in spec && !("layer" in spec) && spec.type !== "race";
447
447
  }
448
448
  function isLayerSpec(spec) {
449
449
  return "layer" in spec && Array.isArray(spec.layer);
@@ -463,6 +463,9 @@ function isTileMapSpec(spec) {
463
463
  function isBarListSpec(spec) {
464
464
  return "type" in spec && spec.type === "barlist";
465
465
  }
466
+ function isRaceSpec(spec) {
467
+ return typeof spec === "object" && spec !== null && !Array.isArray(spec) && "type" in spec && spec.type === "race";
468
+ }
466
469
  function isGeoMapSpec(spec) {
467
470
  return "type" in spec && spec.type === "map";
468
471
  }
@@ -624,6 +627,283 @@ function findAccessibleColor(baseColor, bg, targetRatio = 4.5) {
624
627
  return baseColor;
625
628
  }
626
629
 
630
+ // src/motion/curves.ts
631
+ var SNAP = [
632
+ { t: 0, value: 0 },
633
+ { t: 0.02, value: 0.1876 },
634
+ { t: 0.04, value: 0.3469 },
635
+ { t: 0.06, value: 0.4773 },
636
+ { t: 0.08, value: 0.582 },
637
+ { t: 0.1, value: 0.6656 },
638
+ { t: 0.12, value: 0.7325 },
639
+ { t: 0.14, value: 0.7862 },
640
+ { t: 0.16, value: 0.8296 },
641
+ { t: 0.18, value: 0.8647 },
642
+ { t: 0.2, value: 0.8931 },
643
+ { t: 0.22, value: 0.9161 },
644
+ { t: 0.24, value: 0.9346 },
645
+ { t: 0.26, value: 0.9494 },
646
+ { t: 0.28, value: 0.961 },
647
+ { t: 0.3, value: 0.97 },
648
+ { t: 0.35, value: 0.9768 },
649
+ { t: 0.4, value: 0.9825 },
650
+ { t: 0.45, value: 0.987 },
651
+ { t: 0.5, value: 0.9906 },
652
+ { t: 0.55, value: 0.9934 },
653
+ { t: 0.6, value: 0.9956 },
654
+ { t: 0.65, value: 0.9971 },
655
+ { t: 0.7, value: 0.9983 },
656
+ { t: 0.75, value: 0.999 },
657
+ { t: 0.8, value: 0.9995 },
658
+ { t: 0.85, value: 0.9998 },
659
+ { t: 0.9, value: 0.9999 },
660
+ { t: 0.95, value: 1 },
661
+ { t: 1, value: 1 }
662
+ ];
663
+ var GLIDE = [
664
+ { t: 0, value: 0 },
665
+ { t: 0.025, value: 6e-3 },
666
+ { t: 0.05, value: 0.0285 },
667
+ { t: 0.075, value: 0.0764 },
668
+ { t: 0.1, value: 0.1562 },
669
+ { t: 0.125, value: 0.2556 },
670
+ { t: 0.15, value: 0.3506 },
671
+ { t: 0.175, value: 0.4318 },
672
+ { t: 0.2, value: 0.5 },
673
+ { t: 0.225, value: 0.5577 },
674
+ { t: 0.25, value: 0.6072 },
675
+ { t: 0.275, value: 0.6503 },
676
+ { t: 0.3, value: 0.6881 },
677
+ { t: 0.325, value: 0.7216 },
678
+ { t: 0.35, value: 0.7514 },
679
+ { t: 0.375, value: 0.7782 },
680
+ { t: 0.4, value: 0.8023 },
681
+ { t: 0.425, value: 0.824 },
682
+ { t: 0.45, value: 0.8438 },
683
+ { t: 0.475, value: 0.8616 },
684
+ { t: 0.5, value: 0.8778 },
685
+ { t: 0.55, value: 0.9059 },
686
+ { t: 0.6, value: 0.9291 },
687
+ { t: 0.65, value: 0.948 },
688
+ { t: 0.7, value: 0.9633 },
689
+ { t: 0.75, value: 0.9755 },
690
+ { t: 0.8, value: 0.9849 },
691
+ { t: 0.85, value: 0.9918 },
692
+ { t: 0.9, value: 0.9965 },
693
+ { t: 0.95, value: 0.9991 },
694
+ { t: 1, value: 1 }
695
+ ];
696
+ var CURVE_INPUTS = {
697
+ /** Decks snap: a fast attack for quick fades and short accents. */
698
+ snap: SNAP,
699
+ /** Soft ease-out with a gentle start. The sampled source of the default `smooth`. */
700
+ glide: GLIDE,
701
+ /** The default ease: an alias of `glide`, so the default improves with no spec change. */
702
+ smooth: GLIDE,
703
+ /** Today's old `smooth` (a gentle ease-out), kept under its own name. */
704
+ gentle: [0, 0.157, 0.438, 0.64, 0.766, 0.85, 0.906, 0.941, 0.964, 0.978, 0.988, 0.994, 0.998, 1],
705
+ /**
706
+ * Monotone, non-overshooting ease-out, faster than `snap`. Sampled from
707
+ * `M0,0 C0.04,0.75 0.12,0.97 0.3,0.995 C0.4,1 0.5,1 0.6,1` then held at 1: it is
708
+ * ~0.78 at t=0.1 (snap: ~0.67), 0.951 at 0.2, reaches 0.999 by t~0.45 and
709
+ * is exactly 1 from t=0.55, so it settles sooner than `snap` or `smooth`.
710
+ */
711
+ snappy: [
712
+ { t: 0, value: 0 },
713
+ { t: 0.02, value: 0.2926 },
714
+ { t: 0.04, value: 0.4806 },
715
+ { t: 0.06, value: 0.6111 },
716
+ { t: 0.08, value: 0.7061 },
717
+ { t: 0.1, value: 0.7772 },
718
+ { t: 0.12, value: 0.8315 },
719
+ { t: 0.14, value: 0.8735 },
720
+ { t: 0.16, value: 0.9061 },
721
+ { t: 0.18, value: 0.9314 },
722
+ { t: 0.2, value: 0.951 },
723
+ { t: 0.22, value: 0.966 },
724
+ { t: 0.24, value: 0.9773 },
725
+ { t: 0.26, value: 0.9855 },
726
+ { t: 0.28, value: 0.9913 },
727
+ { t: 0.3, value: 0.995 },
728
+ { t: 0.35, value: 0.9971 },
729
+ { t: 0.4, value: 0.9985 },
730
+ { t: 0.45, value: 0.9994 },
731
+ { t: 0.5, value: 0.9998 },
732
+ { t: 0.55, value: 1 },
733
+ { t: 0.6, value: 1 },
734
+ { t: 0.8, value: 1 },
735
+ { t: 1, value: 1 }
736
+ ],
737
+ /**
738
+ * Accent only (annotation markers and the like): Decks
739
+ * `M0,0 C0.1,0.7 0.18,1.13 0.4,1.06 C0.58,0.99 0.8,1 1,1` overshoots to ~1.067
740
+ * near t=0.35 and settles by ~0.8. NOT monotone, so it is never an authored
741
+ * ease and never used for value-encoding geometry (use evalValueCurve there).
742
+ */
743
+ punch: [
744
+ { t: 0, value: 0 },
745
+ { t: 0.025, value: 0.1714 },
746
+ { t: 0.05, value: 0.3321 },
747
+ { t: 0.075, value: 0.4776 },
748
+ { t: 0.1, value: 0.605 },
749
+ { t: 0.125, value: 0.7132 },
750
+ { t: 0.15, value: 0.8029 },
751
+ { t: 0.175, value: 0.8757 },
752
+ { t: 0.2, value: 0.9336 },
753
+ { t: 0.225, value: 0.9787 },
754
+ { t: 0.25, value: 1.0127 },
755
+ { t: 0.275, value: 1.0373 },
756
+ { t: 0.3, value: 1.0539 },
757
+ { t: 0.325, value: 1.0636 },
758
+ { t: 0.35, value: 1.0673 },
759
+ { t: 0.375, value: 1.0659 },
760
+ { t: 0.4, value: 1.06 },
761
+ { t: 0.425, value: 1.0509 },
762
+ { t: 0.45, value: 1.0428 },
763
+ { t: 0.475, value: 1.0358 },
764
+ { t: 0.5, value: 1.0296 },
765
+ { t: 0.55, value: 1.0196 },
766
+ { t: 0.6, value: 1.0122 },
767
+ { t: 0.65, value: 1.0069 },
768
+ { t: 0.7, value: 1.0033 },
769
+ { t: 0.75, value: 1.0011 },
770
+ { t: 0.8, value: 0.9999 },
771
+ { t: 0.85, value: 0.9995 },
772
+ { t: 0.9, value: 0.9996 },
773
+ { t: 0.95, value: 0.9998 },
774
+ { t: 1, value: 1 }
775
+ ]
776
+ };
777
+ function buildCurve(name, input) {
778
+ if (input.length < 2) throw new Error(`Curve "${name}" needs at least two stops`);
779
+ const evenlySpaced = typeof input[0] === "number";
780
+ const stops = evenlySpaced ? input.map((value, i, all) => ({ t: i / (all.length - 1), value })) : input.map((s) => ({ t: s.t, value: s.value }));
781
+ if (stops[0].t !== 0 || stops[stops.length - 1].t !== 1) {
782
+ throw new Error(`Curve "${name}" must start at t=0 and end at t=1`);
783
+ }
784
+ for (let i = 1; i < stops.length; i++) {
785
+ if (!(stops[i].t > stops[i - 1].t)) {
786
+ throw new Error(`Curve "${name}" stops must have strictly increasing t`);
787
+ }
788
+ }
789
+ let monotone = stops[0].value === 0 && stops[stops.length - 1].value === 1;
790
+ const envelope = [];
791
+ let runningMax = 0;
792
+ for (let i = 0; i < stops.length; i++) {
793
+ if (i > 0 && stops[i].value < stops[i - 1].value) monotone = false;
794
+ runningMax = Math.max(runningMax, clamp01(stops[i].value));
795
+ envelope.push(runningMax);
796
+ }
797
+ return { stops, evenlySpaced, monotone, envelope };
798
+ }
799
+ var CURVES = Object.fromEntries(
800
+ Object.entries(CURVE_INPUTS).map(([name, input]) => [name, buildCurve(name, input)])
801
+ );
802
+ var CURVE_NAMES = Object.keys(CURVE_INPUTS);
803
+ function clamp01(v) {
804
+ return v < 0 ? 0 : v > 1 ? 1 : v;
805
+ }
806
+ function getCurve(name) {
807
+ const curve = CURVES[name];
808
+ if (!curve) throw new Error(`Unknown curve "${name}"`);
809
+ return curve;
810
+ }
811
+ function segmentIndex(stops, t) {
812
+ let lo = 0;
813
+ let hi = stops.length - 1;
814
+ while (hi - lo > 1) {
815
+ const mid = lo + hi >> 1;
816
+ if (stops[mid].t <= t) lo = mid;
817
+ else hi = mid;
818
+ }
819
+ return lo;
820
+ }
821
+ function curveStops(name) {
822
+ return getCurve(name).stops;
823
+ }
824
+ function isMonotoneCurve(name) {
825
+ return getCurve(name).monotone;
826
+ }
827
+ function evalCurve(name, t) {
828
+ const { stops } = getCurve(name);
829
+ const x = Number.isNaN(t) ? 0 : clamp01(t);
830
+ const i = segmentIndex(stops, x);
831
+ const a = stops[i];
832
+ const b = stops[Math.min(i + 1, stops.length - 1)];
833
+ if (b.t === a.t) return a.value;
834
+ return a.value + (b.value - a.value) * (x - a.t) / (b.t - a.t);
835
+ }
836
+ function evalValueCurve(name, t) {
837
+ const curve = getCurve(name);
838
+ const x = Number.isNaN(t) ? 0 : clamp01(t);
839
+ const i = segmentIndex(curve.stops, x);
840
+ return Math.max(curve.envelope[i], clamp01(evalCurve(name, x)));
841
+ }
842
+ function invertCurve(name, p) {
843
+ const curve = getCurve(name);
844
+ if (!curve.monotone) throw new Error(`Curve "${name}" is not monotone and cannot be inverted`);
845
+ const { stops } = curve;
846
+ const target = clamp01(p);
847
+ if (target <= stops[0].value) return 0;
848
+ for (let i = 1; i < stops.length; i++) {
849
+ const b = stops[i];
850
+ if (b.value >= target) {
851
+ const a = stops[i - 1];
852
+ if (b.value === a.value) return a.t;
853
+ return a.t + (target - a.value) * (b.t - a.t) / (b.value - a.value);
854
+ }
855
+ }
856
+ return 1;
857
+ }
858
+ function formatPercent(t) {
859
+ return `${Number((t * 100).toFixed(4))}%`;
860
+ }
861
+ function curveToCSSLinear(name, options) {
862
+ const curve = getCurve(name);
863
+ const items = curve.stops.map(
864
+ (s) => curve.evenlySpaced ? String(s.value) : `${s.value} ${formatPercent(s.t)}`
865
+ );
866
+ const indent = options?.indent;
867
+ if (indent === void 0) return `linear(${items.join(", ")})`;
868
+ const inner = `${indent} `;
869
+ return `linear(
870
+ ${inner}${items.join(`,
871
+ ${inner}`)}
872
+ ${indent})`;
873
+ }
874
+ function evalCubicBezier(bezier, t) {
875
+ const [x1, y1, x2, y2] = bezier;
876
+ const x = t < 0 ? 0 : t > 1 ? 1 : t;
877
+ if (x1 === y1 && x2 === y2) return x;
878
+ const cx = 3 * x1;
879
+ const bx = 3 * (x2 - x1) - cx;
880
+ const ax = 1 - cx - bx;
881
+ const cy = 3 * y1;
882
+ const by = 3 * (y2 - y1) - cy;
883
+ const ay = 1 - cy - by;
884
+ const sampleX = (s2) => ((ax * s2 + bx) * s2 + cx) * s2;
885
+ const slopeX = (s2) => (3 * ax * s2 + 2 * bx) * s2 + cx;
886
+ let s = x;
887
+ for (let i = 0; i < 8; i++) {
888
+ const err = sampleX(s) - x;
889
+ if (Math.abs(err) < 1e-7) return ((ay * s + by) * s + cy) * s;
890
+ const d = slopeX(s);
891
+ if (Math.abs(d) < 1e-6) break;
892
+ s -= err / d;
893
+ }
894
+ let lo = 0;
895
+ let hi = 1;
896
+ s = x;
897
+ for (let i = 0; i < 40; i++) {
898
+ const v = sampleX(s);
899
+ if (Math.abs(v - x) < 1e-7) break;
900
+ if (v < x) lo = s;
901
+ else hi = s;
902
+ s = (lo + hi) / 2;
903
+ }
904
+ return ((ay * s + by) * s + cy) * s;
905
+ }
906
+
627
907
  // src/styles/token-definitions.ts
628
908
  var CSS_TOKEN_ROOT_SELECTORS = [
629
909
  ".oc-root",
@@ -649,15 +929,35 @@ var CSS_TOKENS = [
649
929
  {
650
930
  section: "Animation easing presets via CSS linear()",
651
931
  name: "--oc-ease-smooth",
652
- light: "linear(\n 0,\n 0.157,\n 0.438,\n 0.64,\n 0.766,\n 0.85,\n 0.906,\n 0.941,\n 0.964,\n 0.978,\n 0.988,\n 0.994,\n 0.998,\n 1\n )"
932
+ light: curveToCSSLinear("smooth", { indent: " " })
653
933
  },
654
934
  {
655
935
  name: "--oc-ease-snappy",
656
- light: "linear(\n 0,\n 0.012,\n 0.048,\n 0.108,\n 0.194,\n 0.302,\n 0.426,\n 0.559,\n 0.69,\n 0.808,\n 0.905,\n 0.973,\n 1.013,\n 1.028,\n 1.023,\n 1.006,\n 0.984,\n 0.966,\n 0.957,\n 0.957,\n 0.964,\n 0.975,\n 0.986,\n 0.995,\n 1,\n 1.003,\n 1.002,\n 1,\n 0.998,\n 0.998,\n 0.999,\n 1\n )",
936
+ light: curveToCSSLinear("snappy", { indent: " " }),
937
+ consumers: "EASE_VAR_MAP in vanilla renderers"
938
+ },
939
+ {
940
+ name: "--oc-ease-gentle",
941
+ light: curveToCSSLinear("gentle", { indent: " " }),
657
942
  consumers: "EASE_VAR_MAP in vanilla renderers"
658
943
  },
659
- { section: "Animation timing defaults", name: "--oc-animation-duration", light: "450ms" },
660
- { name: "--oc-animation-stagger", light: "30ms" },
944
+ {
945
+ name: "--oc-ease-snap",
946
+ light: curveToCSSLinear("snap", { indent: " " }),
947
+ consumers: "FADE_CURVE and curve-timed roles in the generated animation CSS"
948
+ },
949
+ {
950
+ name: "--oc-ease-punch",
951
+ light: curveToCSSLinear("punch", { indent: " " }),
952
+ consumers: "Curve-timed accent roles in the generated animation CSS"
953
+ },
954
+ {
955
+ name: "--oc-ease-glide",
956
+ light: curveToCSSLinear("glide", { indent: " " }),
957
+ consumers: "Curve-timed roles in the generated animation CSS"
958
+ },
959
+ { section: "Animation timing defaults", name: "--oc-animation-duration", light: "800ms" },
960
+ { name: "--oc-animation-stagger", light: "80ms" },
661
961
  { name: "--oc-annotation-delay", light: "150ms" },
662
962
  { section: "Typography scale (editorial design system)", name: "--oc-title-size", light: "26px" },
663
963
  {
@@ -1394,11 +1694,11 @@ var RESOLVED_TABLE_700_DEFAULT = {
1394
1694
  scale: 1
1395
1695
  };
1396
1696
  var RESOLVED_TABLE_CACHE = /* @__PURE__ */ new Map();
1397
- for (const [weightStr, scale] of Object.entries(WEIGHT_ADJUSTMENT)) {
1697
+ for (const [weightStr, scale2] of Object.entries(WEIGHT_ADJUSTMENT)) {
1398
1698
  const weight = Number(weightStr);
1399
1699
  RESOLVED_TABLE_CACHE.set(
1400
1700
  weight,
1401
- weight >= 650 ? { table: CHAR_WIDTHS_700, avg: AVG_CHAR_WIDTH_700, scale } : { table: CHAR_WIDTHS_400, avg: AVG_CHAR_WIDTH_400, scale }
1701
+ weight >= 650 ? { table: CHAR_WIDTHS_700, avg: AVG_CHAR_WIDTH_700, scale: scale2 } : { table: CHAR_WIDTHS_400, avg: AVG_CHAR_WIDTH_400, scale: scale2 }
1402
1702
  );
1403
1703
  }
1404
1704
  function resolveTable(fontWeight) {
@@ -1416,27 +1716,27 @@ function charWidthRatio(ch, table, avg) {
1416
1716
  return avg;
1417
1717
  }
1418
1718
  function estimateCharWidth(fontSize, fontWeight = 400) {
1419
- const { avg, scale } = resolveTable(fontWeight);
1420
- return fontSize * avg * scale;
1719
+ const { avg, scale: scale2 } = resolveTable(fontWeight);
1720
+ return fontSize * avg * scale2;
1421
1721
  }
1422
- function measureLine(line, table, avg, scale, fontSize) {
1722
+ function measureLine(line, table, avg, scale2, fontSize) {
1423
1723
  let sum = 0;
1424
1724
  for (const ch of line) {
1425
1725
  sum += charWidthRatio(ch, table, avg);
1426
1726
  }
1427
- return sum * fontSize * scale;
1727
+ return sum * fontSize * scale2;
1428
1728
  }
1429
1729
  function estimateTextWidth(text, fontSize, fontWeight = 400) {
1430
- const { table, avg, scale } = resolveTable(fontWeight);
1730
+ const { table, avg, scale: scale2 } = resolveTable(fontWeight);
1431
1731
  if (text.includes("\n")) {
1432
1732
  let maxWidth = 0;
1433
1733
  for (const line of text.split("\n")) {
1434
- const w = measureLine(line, table, avg, scale, fontSize);
1734
+ const w = measureLine(line, table, avg, scale2, fontSize);
1435
1735
  if (w > maxWidth) maxWidth = w;
1436
1736
  }
1437
1737
  return maxWidth;
1438
1738
  }
1439
- return measureLine(text, table, avg, scale, fontSize);
1739
+ return measureLine(text, table, avg, scale2, fontSize);
1440
1740
  }
1441
1741
  var BRAND_RESERVE_WIDTH = 130;
1442
1742
  var BRAND_FONT_SIZE = 12;
@@ -1522,8 +1822,8 @@ function applyHeightConstraints(strategy, heightClass) {
1522
1822
  };
1523
1823
  }
1524
1824
  function getLayoutStrategy(breakpoint, heightClass = "normal") {
1525
- const base = getWidthStrategy(breakpoint);
1526
- return applyHeightConstraints(base, heightClass);
1825
+ const base2 = getWidthStrategy(breakpoint);
1826
+ return applyHeightConstraints(base2, heightClass);
1527
1827
  }
1528
1828
  var HEIGHT_NO_GRID_MAX = 150;
1529
1829
  var COMPACT_MAX_X_TICKS = 3;
@@ -1602,18 +1902,19 @@ function truncateToWidth(label, budget, fontSize, fontWeight, measure = estimate
1602
1902
  if (!Number.isFinite(budget)) return label;
1603
1903
  if (measure(label, fontSize, fontWeight) <= budget) return label;
1604
1904
  const ELLIPSIS = "\u2026";
1905
+ const characters = Array.from(label);
1605
1906
  let lo = 0;
1606
- let hi = label.length;
1907
+ let hi = characters.length;
1607
1908
  while (lo < hi) {
1608
1909
  const mid = Math.ceil((lo + hi) / 2);
1609
- const candidate = label.slice(0, mid) + ELLIPSIS;
1910
+ const candidate = characters.slice(0, mid).join("") + ELLIPSIS;
1610
1911
  if (measure(candidate, fontSize, fontWeight) <= budget) {
1611
1912
  lo = mid;
1612
1913
  } else {
1613
1914
  hi = mid - 1;
1614
1915
  }
1615
1916
  }
1616
- return lo > 0 ? label.slice(0, lo).trimEnd() + ELLIPSIS : ELLIPSIS;
1917
+ return characters.slice(0, lo).join("").trimEnd() + ELLIPSIS;
1617
1918
  }
1618
1919
  function truncateRotatedLabel(label, tickAngle, tickFontSize, tickFontWeight, measure = estimateTextWidth) {
1619
1920
  const budget = maxRotatedLabelWidth(tickAngle, tickFontSize);
@@ -1892,9 +2193,9 @@ function adaptForLightLineStroke(color) {
1892
2193
  function isRecord(value) {
1893
2194
  return value !== null && typeof value === "object" && !Array.isArray(value);
1894
2195
  }
1895
- function mergeThemeObjects(base, override) {
2196
+ function mergeThemeObjects(base2, override) {
1896
2197
  if (!isRecord(override) || "light" in override || "dark" in override) return override;
1897
- const result = isRecord(base) ? { ...base } : {};
2198
+ const result = isRecord(base2) ? { ...base2 } : {};
1898
2199
  for (const [key, value] of Object.entries(override)) {
1899
2200
  if (value !== void 0) result[key] = mergeThemeObjects(result[key], value);
1900
2201
  }
@@ -1903,9 +2204,9 @@ function mergeThemeObjects(base, override) {
1903
2204
  function normalize(config) {
1904
2205
  return Array.isArray(config.colors) ? { ...config, colors: { categorical: config.colors } } : config;
1905
2206
  }
1906
- function mergeThemeConfig(base, override) {
1907
- if (!override) return base;
1908
- return mergeThemeObjects(base ? normalize(base) : {}, normalize(override));
2207
+ function mergeThemeConfig(base2, override) {
2208
+ if (!override) return base2;
2209
+ return mergeThemeObjects(base2 ? normalize(base2) : {}, normalize(override));
1909
2210
  }
1910
2211
 
1911
2212
  // src/theme/presets.ts
@@ -1959,16 +2260,30 @@ var wire = {
1959
2260
  };
1960
2261
  var broadsheet = {
1961
2262
  colors: {
1962
- categorical: ["#1d5f8a", "#e3120b", "#7fb0d3", "#e0a63b", "#3a8a6e", "#8c8680"],
1963
- categoricalFill: ["#3b7097", "#ee493a", "#97c2e2", "#efbb64", "#579a81", "#9e9893"],
1964
- background: { light: "#fffdf9", dark: "#171513" },
1965
- text: { light: "#1a1714", dark: "#f4f1ea" },
1966
- gridline: { light: "rgba(26,23,20,0.08)", dark: "rgba(244,241,234,0.07)" },
2263
+ categorical: [
2264
+ { light: "#1d5f8a", dark: "#5e9fd6" },
2265
+ { light: "#e3120b", dark: "#f4655a" },
2266
+ { light: "#7fb0d3", dark: "#93c2e2" },
2267
+ { light: "#e0a63b", dark: "#e0b267" },
2268
+ { light: "#3a8a6e", dark: "#4fb093" },
2269
+ { light: "#8c8680", dark: "#9aa1a8" }
2270
+ ],
2271
+ categoricalFill: [
2272
+ { light: "#3b7097", dark: "#80b5e3" },
2273
+ { light: "#ee493a", dark: "#ec5b50" },
2274
+ { light: "#97c2e2", dark: "#acd3eb" },
2275
+ { light: "#efbb64", dark: "#c6ad55" },
2276
+ { light: "#579a81", dark: "#5bd2ac" },
2277
+ { light: "#9e9893", dark: "#b4b9bf" }
2278
+ ],
2279
+ background: { light: "#fffdf9", dark: "#12181f" },
2280
+ text: { light: "#1a1714", dark: "#e9ebe6" },
2281
+ gridline: { light: "rgba(26,23,20,0.08)", dark: "rgba(233,235,230,0.07)" },
1967
2282
  // Heavier than the default 0.14: newsprint rules are drawn to be seen.
1968
- hairline: { light: "rgba(26,23,20,0.28)", dark: "rgba(244,241,234,0.28)" },
1969
- axis: { light: "#6b645c", dark: "#a8a099" },
1970
- annotationFill: { light: "rgba(26,23,20,0.05)", dark: "rgba(244,241,234,0.07)" },
1971
- annotationText: { light: "#6b645c", dark: "#a8a099" }
2283
+ hairline: { light: "rgba(26,23,20,0.28)", dark: "rgba(233,235,230,0.28)" },
2284
+ axis: { light: "#6b645c", dark: "#9aa4ad" },
2285
+ annotationFill: { light: "rgba(26,23,20,0.05)", dark: "rgba(233,235,230,0.07)" },
2286
+ annotationText: { light: "#6b645c", dark: "#9aa4ad" }
1972
2287
  },
1973
2288
  fonts: {
1974
2289
  sizes: { title: 24, subtitle: 14, body: 13, small: 11 }
@@ -2040,7 +2355,7 @@ var legacyEditorial = {
2040
2355
  function resolveTokenLight(v) {
2041
2356
  return typeof v === "string" ? v : v.light;
2042
2357
  }
2043
- function themeConfigToPartial(config, base) {
2358
+ function themeConfigToPartial(config, base2) {
2044
2359
  const partial = {};
2045
2360
  if (config.colors) {
2046
2361
  const colors = {};
@@ -2143,10 +2458,10 @@ function themeConfigToPartial(config, base) {
2143
2458
  if (config.rule) {
2144
2459
  partial.rule = {
2145
2460
  color: resolveTokenLight(
2146
- config.rule.color ?? base.rule?.color ?? (config.colors && !Array.isArray(config.colors) ? config.colors.text : void 0) ?? DEFAULT_THEME.colors.text
2461
+ config.rule.color ?? base2.rule?.color ?? (config.colors && !Array.isArray(config.colors) ? config.colors.text : void 0) ?? DEFAULT_THEME.colors.text
2147
2462
  ),
2148
- width: config.rule.width ?? base.rule?.width ?? 40,
2149
- thickness: config.rule.thickness ?? base.rule?.thickness ?? 3
2463
+ width: config.rule.width ?? base2.rule?.width ?? 40,
2464
+ thickness: config.rule.thickness ?? base2.rule?.thickness ?? 3
2150
2465
  };
2151
2466
  }
2152
2467
  if (config.rule === null) partial.rule = null;
@@ -2259,8 +2574,8 @@ function adjustOpacity(hex, opacity) {
2259
2574
  const toHex = (n) => n.toString(16).padStart(2, "0");
2260
2575
  return `#${toHex(mix2(r))}${toHex(mix2(g))}${toHex(mix2(b))}`;
2261
2576
  }
2262
- function resolveTheme(userTheme, base = DEFAULT_THEME) {
2263
- let merged = userTheme ? mergeThemeObjects(base, themeConfigToPartial(userTheme, base)) : { ...base };
2577
+ function resolveTheme(userTheme, base2 = DEFAULT_THEME) {
2578
+ let merged = userTheme ? mergeThemeObjects(base2, themeConfigToPartial(userTheme, base2)) : { ...base2 };
2264
2579
  for (const [element, size] of Object.entries({
2265
2580
  title: "title",
2266
2581
  subtitle: "subtitle",
@@ -2938,7 +3253,7 @@ function buildD3Formatter(formatStr) {
2938
3253
  }
2939
3254
  return null;
2940
3255
  }
2941
- function formatPercent(value, options) {
3256
+ function formatPercent2(value, options) {
2942
3257
  const fraction = options?.fraction ?? true;
2943
3258
  const percent = fraction ? value * 100 : value;
2944
3259
  if (Number.isFinite(percent) && percent !== 0 && Math.abs(percent) < 0.1) {
@@ -3001,7 +3316,7 @@ function resolveNumberFormatter(formatStr, ctx) {
3001
3316
  }
3002
3317
  if (formatStr === "percent") {
3003
3318
  const fraction = ctx?.extent ? Math.max(Math.abs(ctx.extent[0]), Math.abs(ctx.extent[1])) <= 1 : true;
3004
- return (v) => formatPercent(v, { fraction });
3319
+ return (v) => formatPercent2(v, { fraction });
3005
3320
  }
3006
3321
  if (formatStr === "currency") {
3007
3322
  const isTable = ctx?.surface === "table";
@@ -3305,8 +3620,8 @@ function inferFieldType(data, field) {
3305
3620
  continue;
3306
3621
  }
3307
3622
  if (typeof value === "string") {
3308
- const num = Number(value);
3309
- if (!Number.isNaN(num) && Number.isFinite(num) && value.trim() !== "") {
3623
+ const num2 = Number(value);
3624
+ if (!Number.isNaN(num2) && Number.isFinite(num2) && value.trim() !== "") {
3310
3625
  numericCount++;
3311
3626
  continue;
3312
3627
  }
@@ -3547,23 +3862,953 @@ function springDuration(config) {
3547
3862
  }
3548
3863
  return MAX_SPRING_DURATION;
3549
3864
  }
3865
+ var VELOCITY_STEP = 1e-4;
3550
3866
  function sampleMotion(phase, elapsedMs) {
3551
3867
  if (phase.duration <= 0 || elapsedMs >= phase.duration) {
3552
3868
  return { position: 1, velocity: 0, settled: true };
3553
3869
  }
3554
3870
  if (elapsedMs <= 0) return { position: 0, velocity: 0, settled: false };
3555
3871
  if (phase.spring) return springState(elapsedMs, phase.spring);
3872
+ const ease = phase.ease ?? "smooth";
3556
3873
  const t = elapsedMs / phase.duration;
3557
- const power = phase.ease === "snappy" ? 5 : 3;
3874
+ const lo = Math.max(0, t - VELOCITY_STEP);
3875
+ const hi = Math.min(1, t + VELOCITY_STEP);
3876
+ const slope = (evalValueCurve(ease, hi) - evalValueCurve(ease, lo)) / (hi - lo);
3558
3877
  return {
3559
- position: 1 - (1 - t) ** power,
3560
- velocity: power * (1 - t) ** (power - 1) * 1e3 / phase.duration,
3878
+ position: evalValueCurve(ease, t),
3879
+ velocity: slope * 1e3 / phase.duration,
3561
3880
  settled: false
3562
3881
  };
3563
3882
  }
3564
3883
  function motionCSS(phase) {
3565
3884
  return `linear(${Array.from({ length: 101 }, (_, i) => sampleMotion(phase, i * phase.duration / 100).position.toFixed(6)).join(",")})`;
3566
3885
  }
3886
+
3887
+ // src/motion/stagger.ts
3888
+ var MAX_TOTAL_STAGGER_MS = 450;
3889
+ function clampStaggerDelay(delay, elementCount) {
3890
+ if (elementCount <= 1 || !(delay > 0)) return 0;
3891
+ return Math.min(delay, MAX_TOTAL_STAGGER_MS / (elementCount - 1));
3892
+ }
3893
+ var CELL_SWEEP_BUDGET_MS = 600;
3894
+ function shuffledSweepDelays(count, budgetMs, seed) {
3895
+ if (count <= 0) return [];
3896
+ if (count === 1) return [0];
3897
+ const last = count - 1;
3898
+ const delays = Array.from({ length: count }, (_, i) => i / last * budgetMs);
3899
+ let state = 2654435769 ^ seed * 2654435761;
3900
+ for (let i = last; i > 0; i--) {
3901
+ state = state + 1831565813 | 0;
3902
+ let t = state ^ state >>> 15;
3903
+ t = Math.imul(t, t | 1);
3904
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
3905
+ const r = ((t ^ t >>> 14) >>> 0) % (i + 1);
3906
+ [delays[i], delays[r]] = [delays[r], delays[i]];
3907
+ }
3908
+ return delays;
3909
+ }
3910
+ var MAP_POINT_STAGGER_FALLBACK_MS = 60;
3911
+ var MAP_FEATURE_MAX_DURATION_MS = 500;
3912
+ var MAP_SWEEP_BUDGET_MS = 540;
3913
+ function mapFeatureDuration(durationMs) {
3914
+ return Math.min(durationMs, MAP_FEATURE_MAX_DURATION_MS);
3915
+ }
3916
+ function mapSweepTiming(durationMs, featureCount, bulk) {
3917
+ const featureDurationMs = mapFeatureDuration(durationMs);
3918
+ const budgetMs = bulk ? 0 : MAP_SWEEP_BUDGET_MS;
3919
+ const n = Math.max(featureCount, 1);
3920
+ const staggerMs2 = !bulk && n > 1 ? budgetMs / (n - 1) : 0;
3921
+ return { featureDurationMs, budgetMs, staggerMs: staggerMs2 };
3922
+ }
3923
+ function tilemapTileDelays(animationIndices) {
3924
+ const baseStagger = 800 / Math.max(animationIndices.length, 1);
3925
+ const delays = [];
3926
+ let seed = 17;
3927
+ for (const idx of animationIndices) {
3928
+ seed = seed * 1103515245 + 12345 & 2147483647;
3929
+ const jitter = (seed % 1e3 / 1e3 - 0.5) * 0.8;
3930
+ delays.push(Math.max(0, Math.round(idx * baseStagger * (1 + jitter))));
3931
+ }
3932
+ return delays;
3933
+ }
3934
+
3935
+ // src/motion/choreography.ts
3936
+ var num = (value) => ({ type: "number", value });
3937
+ var inset = (top, right, bottom, left) => ({
3938
+ type: "inset",
3939
+ top,
3940
+ right,
3941
+ bottom,
3942
+ left
3943
+ });
3944
+ var translateY = (value, unit = "px") => ({
3945
+ type: "translateY",
3946
+ value,
3947
+ unit
3948
+ });
3949
+ var translate = (x, y) => ({ type: "translate", x, y });
3950
+ var scale = (value) => ({ type: "scale", value });
3951
+ var css = (value) => ({ type: "css", css: value });
3952
+ var KEYFRAMES = {
3953
+ "oc-enter-bar": {
3954
+ comment: "Bar entrance: clip-path reveal from the baseline (vertical columns), no fade:\na value mark is solid from its first frame. Grows bottom-to-top unless the\nrenderer stamps --oc-bar-from (a negative column grows top-to-bottom).",
3955
+ stops: [
3956
+ { offset: 0, values: { "clip-path": css("inset(var(--oc-bar-from, 100% 0 0 0))") } },
3957
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
3958
+ ]
3959
+ },
3960
+ "oc-enter-bar-h": {
3961
+ comment: "Bar entrance: clip-path reveal from the baseline (horizontal bars), no fade.\nGrows left-to-right unless --oc-bar-from is stamped (negative bars).",
3962
+ stops: [
3963
+ { offset: 0, values: { "clip-path": css("inset(var(--oc-bar-from, 0 100% 0 0))") } },
3964
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
3965
+ ]
3966
+ },
3967
+ "oc-enter-stack": {
3968
+ comment: "Stack entrance: one clip over the whole stack, no fade. Grows bottom-to-top\nfrom --oc-stack-from, which the renderer stamps when the baseline is not the\nbottom edge, so the clip starts collapsed on the baseline and grows both\nways from it.",
3969
+ stops: [
3970
+ { offset: 0, values: { "clip-path": css("inset(var(--oc-stack-from, 100% 0 0 0))") } },
3971
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
3972
+ ]
3973
+ },
3974
+ "oc-enter-stack-h": {
3975
+ comment: "Horizontal stack entrance: grows left-to-right, or both ways from the\nbaseline when --oc-stack-from is stamped.",
3976
+ stops: [
3977
+ { offset: 0, values: { "clip-path": css("inset(var(--oc-stack-from, 0 100% 0 0))") } },
3978
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
3979
+ ]
3980
+ },
3981
+ "oc-enter-line": {
3982
+ comment: "Line/area entrance: clip-path reveal left-to-right + fade in.\nLines draw in following reading direction with a soft lead-in.",
3983
+ stops: [
3984
+ { offset: 0, values: { "clip-path": inset(0, 100, 0, 0), opacity: num(0) } },
3985
+ { offset: 0.15, values: { opacity: num(1) } },
3986
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0), opacity: num(1) } }
3987
+ ]
3988
+ },
3989
+ "oc-enter-point": {
3990
+ comment: "Point/arc entrance: scale up + fade in from center",
3991
+ stops: [
3992
+ { offset: 0, values: { opacity: num(0), transform: scale(0.3) } },
3993
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
3994
+ ]
3995
+ },
3996
+ "oc-enter-map-fill": {
3997
+ comment: "Map feature entrance: fade in while transitioning fill from a neutral base\nto the data-driven color stored in --oc-feature-fill. The target opacity is\n--oc-feature-target-opacity (default 1) so features under a focus dim\nanimate straight to their dimmed rest opacity instead of hitting 1 and then\nsnapping down when the dim is applied post-animation.\nNon-interpolable fills (the url(#pattern) hatch on no-data features) do not\ntransition: the browser holds the neutral and flips to the pattern when the\neased progress passes 50%, so those features fade in rather than\ncross-fade.",
3998
+ stops: [
3999
+ { offset: 0, values: { fill: css("var(--oc-secondary)"), opacity: num(0) } },
4000
+ {
4001
+ offset: 1,
4002
+ values: {
4003
+ fill: css("var(--oc-feature-fill)"),
4004
+ opacity: css("var(--oc-feature-target-opacity, 1)")
4005
+ }
4006
+ }
4007
+ ]
4008
+ },
4009
+ "oc-enter-map-point": {
4010
+ comment: "Map point pop-in: gentle scale from 0.75 + fade. Uses transform-origin to\nscale from the circle's own center (cx/cy) rather than the SVG origin.",
4011
+ stops: [
4012
+ { offset: 0, values: { opacity: num(0), transform: scale(0.75) } },
4013
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
4014
+ ]
4015
+ },
4016
+ "oc-enter-pop": {
4017
+ comment: "Line point pop: fade in while scaling up from 0.4. The renderer stamps an\ninline px transform-origin at the point centre, so it grows in place\n(and in GIF frames, which carry no animation CSS).",
4018
+ stops: [
4019
+ { offset: 0, values: { opacity: num(0), transform: scale(0.4) } },
4020
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
4021
+ ]
4022
+ },
4023
+ "oc-enter-cell": {
4024
+ comment: "Grid cell pop: fade in while scaling up from 0.85 about the cell centre\n(inline px transform-origin stamped by the renderer).",
4025
+ stops: [
4026
+ { offset: 0, values: { opacity: num(0), transform: scale(0.85) } },
4027
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
4028
+ ]
4029
+ },
4030
+ "oc-enter-arc": {
4031
+ comment: "Slice growth: fade in while scaling up from 0.94. The slice path is drawn\naround its group's local origin (the group carries translate(cx, cy)), so\nthe default transform-origin of 0 0 is the pie centre.",
4032
+ stops: [
4033
+ { offset: 0, values: { opacity: num(0), transform: scale(0.94) } },
4034
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
4035
+ ]
4036
+ },
4037
+ "oc-enter-fade-only": {
4038
+ comment: "Pure opacity fade (no transform). Safe for elements with existing transforms\nlike arc groups that use translate() for positioning.",
4039
+ stops: [
4040
+ { offset: 0, values: { opacity: num(0) } },
4041
+ { offset: 1, values: { opacity: num(1) } }
4042
+ ]
4043
+ },
4044
+ "oc-enter-fade": {
4045
+ comment: "Fade + subtle slide up (table chrome)",
4046
+ stops: [
4047
+ { offset: 0, values: { opacity: num(0), transform: translateY(4) } },
4048
+ { offset: 1, values: { opacity: num(1), transform: translateY(0) } }
4049
+ ]
4050
+ },
4051
+ "oc-enter-rise": {
4052
+ comment: "Text rise: 0.6em up to rest. Its opacity runs as a separate quick fade.",
4053
+ stops: [
4054
+ { offset: 0, values: { transform: translateY(0.6, "em") } },
4055
+ { offset: 1, values: { transform: translateY(0) } }
4056
+ ]
4057
+ },
4058
+ "oc-enter-slide": {
4059
+ comment: "Row slide: 4px up to rest. Its opacity runs as a separate quick fade.",
4060
+ stops: [
4061
+ { offset: 0, values: { transform: translateY(4) } },
4062
+ { offset: 1, values: { transform: translateY(0) } }
4063
+ ]
4064
+ },
4065
+ "oc-table-enter-row": {
4066
+ comment: "Table row entrance: slide up only, no opacity (cells fade independently\nto avoid opacity compounding between row and cell animations)",
4067
+ stops: [
4068
+ { offset: 0, values: { transform: translateY(6) } },
4069
+ { offset: 1, values: { transform: translateY(0) } }
4070
+ ]
4071
+ },
4072
+ "oc-table-enter-bar-fill": {
4073
+ comment: "Table bar fill entrance: clip-path grow only, no opacity\n(preserves resting opacity: 0.15 from table.css)",
4074
+ stops: [
4075
+ { offset: 0, values: { "clip-path": inset(0, 100, 0, 0) } },
4076
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
4077
+ ]
4078
+ },
4079
+ "oc-pulse": {
4080
+ comment: "Live-tile pulse: the terminator dot of a sparkline swells once when new\ndata lands, so a glance at a wall of tiles catches which one just moved.\n`r` is animated as a presentation attribute (SVG geometry properties are\nanimatable in CSS); the fallback is simply no swell.",
4081
+ stops: [
4082
+ { offset: 0, values: { r: css("var(--oc-pulse-r, 4px)"), "fill-opacity": num(1) } },
4083
+ {
4084
+ offset: 0.45,
4085
+ values: { r: css("calc(var(--oc-pulse-r, 4px) * 1.8)"), "fill-opacity": num(0.5) }
4086
+ },
4087
+ { offset: 1, values: { r: css("var(--oc-pulse-r, 4px)"), "fill-opacity": num(1) } }
4088
+ ]
4089
+ },
4090
+ "oc-tooltip-in": {
4091
+ comment: "Tooltip entrance",
4092
+ stops: [
4093
+ { offset: 0, values: { opacity: num(0), transform: translateY(2) } },
4094
+ { offset: 1, values: { opacity: num(1), transform: translateY(0) } }
4095
+ ]
4096
+ }
4097
+ };
4098
+ function pct(v) {
4099
+ return v === 0 ? "0" : `${v}%`;
4100
+ }
4101
+ function keyframeValueToCSS(value) {
4102
+ switch (value.type) {
4103
+ case "number":
4104
+ return String(value.value);
4105
+ case "inset":
4106
+ return `inset(${pct(value.top)} ${pct(value.right)} ${pct(value.bottom)} ${pct(value.left)})`;
4107
+ case "translateY":
4108
+ return value.value === 0 ? "translateY(0)" : `translateY(${value.value}${value.unit})`;
4109
+ case "translate":
4110
+ return `translate(${value.x}px, ${value.y}px)`;
4111
+ case "scale":
4112
+ return `scale(${value.value})`;
4113
+ case "css":
4114
+ return value.css;
4115
+ default:
4116
+ return value;
4117
+ }
4118
+ }
4119
+ function lerp(a, b, e) {
4120
+ return a + (b - a) * e;
4121
+ }
4122
+ function interpolateValue(a, b, e) {
4123
+ if (a.type === "number" && b.type === "number") return num(lerp(a.value, b.value, e));
4124
+ if (a.type === "inset" && b.type === "inset") {
4125
+ return inset(
4126
+ lerp(a.top, b.top, e),
4127
+ lerp(a.right, b.right, e),
4128
+ lerp(a.bottom, b.bottom, e),
4129
+ lerp(a.left, b.left, e)
4130
+ );
4131
+ }
4132
+ if (a.type === "translateY" && b.type === "translateY") {
4133
+ const unit = a.value === 0 ? b.unit : a.unit;
4134
+ return translateY(lerp(a.value, b.value, e), unit);
4135
+ }
4136
+ if (a.type === "translate" && b.type === "translate") {
4137
+ return translate(lerp(a.x, b.x, e), lerp(a.y, b.y, e));
4138
+ }
4139
+ if (a.type === "scale" && b.type === "scale") return scale(lerp(a.value, b.value, e));
4140
+ return e < 0.5 ? a : b;
4141
+ }
4142
+ function evalKeyframes(name, t, ease) {
4143
+ const x = t < 0 ? 0 : t > 1 ? 1 : t;
4144
+ const stops = KEYFRAMES[name].stops;
4145
+ const out = {};
4146
+ for (const prop of keyframeProperties(name)) {
4147
+ const own = stops.filter((s) => s.values[prop] !== void 0);
4148
+ let i = 0;
4149
+ while (i < own.length - 2 && own[i + 1].offset <= x) i++;
4150
+ const a = own[i];
4151
+ const b = own[i + 1] ?? a;
4152
+ const span = b.offset - a.offset;
4153
+ const local = span > 0 ? Math.min(1, Math.max(0, (x - a.offset) / span)) : 1;
4154
+ out[prop] = interpolateValue(a.values[prop], b.values[prop], ease(local));
4155
+ }
4156
+ return out;
4157
+ }
4158
+ function keyframeProperties(name) {
4159
+ const seen = [];
4160
+ for (const stop of KEYFRAMES[name].stops) {
4161
+ for (const prop of Object.keys(stop.values)) {
4162
+ if (!seen.includes(prop)) seen.push(prop);
4163
+ }
4164
+ }
4165
+ return seen;
4166
+ }
4167
+ function settleOffset(name, props) {
4168
+ let end = 0;
4169
+ const stops = KEYFRAMES[name].stops;
4170
+ for (const prop of props) {
4171
+ const own = stops.filter((s) => s.values[prop] !== void 0);
4172
+ for (let i = 1; i < own.length; i++) {
4173
+ const changed = keyframeValueToCSS(own[i].values[prop]) !== keyframeValueToCSS(own[i - 1].values[prop]);
4174
+ if (changed) end = Math.max(end, own[i].offset);
4175
+ }
4176
+ }
4177
+ return end;
4178
+ }
4179
+ var FADE_CURVE = "snap";
4180
+ var TEXT_FADE_MS = 140;
4181
+ var LABEL_FADE_MS = 260;
4182
+ var POINT_FADE_MS = 300;
4183
+ var CELL_POP_MS = 400;
4184
+ var ARC_GROW_MS = 450;
4185
+ var LINE_POINT_POP_MS = 320;
4186
+ var LINE_POINT_CASCADE_MS = 240;
4187
+ var AUTHOR = { kind: "author" };
4188
+ var EASE_IN = { kind: "css", css: "ease-in", bezier: [0.42, 0, 1, 1] };
4189
+ var base = (factor) => ({ kind: "base", factor });
4190
+ var fixed = (ms) => ({ kind: "fixed", ms });
4191
+ var when = (of, progress) => ({
4192
+ kind: "progress",
4193
+ progress,
4194
+ of
4195
+ });
4196
+ var ROLE_DEFS = [
4197
+ {
4198
+ name: "bar",
4199
+ scope: "chart",
4200
+ comment: "Vertical bars (default): the author curve over the full duration, no fade.\noc-mark-bar is reserved for future mark type aliases.\nA bar with a value-end radius draws as <path> rather than <rect>\n(SVG rx rounds all four corners or none), so both shapes match.",
4201
+ selectors: [".oc-mark-rect :is(rect, path)", ".oc-mark-bar :is(rect, path)"],
4202
+ emit: "shorthand",
4203
+ keyframe: "oc-enter-bar",
4204
+ horizontalKeyframe: "oc-enter-bar-h",
4205
+ timing: AUTHOR,
4206
+ durationBasis: "phase",
4207
+ duration: base(1),
4208
+ delay: { stagger: "mark" }
4209
+ },
4210
+ {
4211
+ name: "bar-h",
4212
+ scope: "chart",
4213
+ comment: "Horizontal bars (data-orient is on the mark group, not the SVG root)",
4214
+ selectors: [
4215
+ '.oc-mark-rect[data-orient="horizontal"] :is(rect, path)',
4216
+ '.oc-mark-bar[data-orient="horizontal"] :is(rect, path)'
4217
+ ],
4218
+ emit: ["name"],
4219
+ keyframe: "oc-enter-bar-h",
4220
+ timing: AUTHOR,
4221
+ durationBasis: "phase",
4222
+ duration: base(1),
4223
+ delay: { stagger: "mark" }
4224
+ },
4225
+ {
4226
+ name: "cell",
4227
+ scope: "chart",
4228
+ comment: "Grid cells (heatmap, waffle, calendar) have no baseline to grow from:\neach pops in on its own scattered start. The renderer stamps\n--oc-cell-delay from a seeded shuffle over CELL_SWEEP_BUDGET_MS, so the\ngrid fills in no particular pattern.",
4229
+ selectors: [".oc-mark-rect[data-cell] :is(rect, path)"],
4230
+ emit: "shorthand",
4231
+ keyframe: "oc-enter-cell",
4232
+ timing: AUTHOR,
4233
+ durationBasis: "phase",
4234
+ duration: fixed(CELL_POP_MS),
4235
+ delay: { stagger: "mark" }
4236
+ },
4237
+ {
4238
+ name: "stack-reveal",
4239
+ scope: "chart",
4240
+ comment: "Stacked bars reveal as one group per stack, each on its own stagger slot;\ntheir segments do not animate. A stack that crosses zero grows both ways\nfrom the baseline (--oc-stack-from).",
4241
+ selectors: [".oc-stack-reveal"],
4242
+ emit: "shorthand",
4243
+ keyframe: "oc-enter-stack",
4244
+ horizontalKeyframe: "oc-enter-stack-h",
4245
+ timing: AUTHOR,
4246
+ durationBasis: "phase",
4247
+ duration: base(1),
4248
+ delay: { stagger: "mark" },
4249
+ suppress: [".oc-stack-reveal .oc-mark-rect :is(rect, path)"]
4250
+ },
4251
+ {
4252
+ name: "stack-reveal-h",
4253
+ scope: "chart",
4254
+ selectors: ['.oc-stack-reveal[data-orient="horizontal"]'],
4255
+ emit: ["name"],
4256
+ keyframe: "oc-enter-stack-h",
4257
+ timing: AUTHOR,
4258
+ durationBasis: "phase",
4259
+ duration: base(1),
4260
+ delay: { stagger: "mark" }
4261
+ },
4262
+ {
4263
+ name: "line-area",
4264
+ scope: "chart",
4265
+ comment: "Line and area marks: entire group clips left-to-right + fades in",
4266
+ selectors: [".oc-mark-line", ".oc-mark-area"],
4267
+ emit: "shorthand",
4268
+ keyframe: "oc-enter-line",
4269
+ timing: AUTHOR,
4270
+ durationBasis: "phase",
4271
+ duration: base(1),
4272
+ delay: { stagger: "mark" }
4273
+ },
4274
+ {
4275
+ name: "arc",
4276
+ scope: "chart",
4277
+ comment: "Arc marks (pie/donut slices): each slice path fades and grows from the pie\ncentre. The transform goes on the path, never the group, whose translate()\nattribute positions the slice.",
4278
+ selectors: [".oc-mark-arc > path"],
4279
+ emit: "shorthand",
4280
+ keyframe: "oc-enter-arc",
4281
+ timing: AUTHOR,
4282
+ durationBasis: "phase",
4283
+ duration: fixed(ARC_GROW_MS),
4284
+ delay: { stagger: "mark" }
4285
+ },
4286
+ {
4287
+ name: "point",
4288
+ scope: "chart",
4289
+ comment: "Point marks (scatter, dot): a quick fade on the author curve, no scale.\nPoints render as bare <circle> elements with class oc-mark-point directly,\nnot wrapped in a group, so we target circle.oc-mark-point (not descendant).",
4290
+ selectors: ["circle.oc-mark-point", "circle.oc-mark-circle"],
4291
+ emit: "shorthand",
4292
+ keyframe: "oc-enter-fade-only",
4293
+ timing: AUTHOR,
4294
+ durationBasis: "phase",
4295
+ duration: fixed(POINT_FADE_MS),
4296
+ delay: { stagger: "mark" }
4297
+ },
4298
+ {
4299
+ name: "line-point",
4300
+ scope: "chart",
4301
+ comment: "Points on line/area charts pop in once their own line has drawn (0.97),\ncascading left to right over LINE_POINT_CASCADE_MS. The renderer stamps\neach point's delay and marks it data-line-point (a scatter's trendline also\nprecedes its circles, so position can't select these). Points hidden under an endpoint marker stay hidden.",
4302
+ selectors: ["circle.oc-mark-point[data-line-point]"],
4303
+ emit: "shorthand",
4304
+ keyframe: "oc-enter-pop",
4305
+ timing: { kind: "curve", curve: "punch" },
4306
+ accent: true,
4307
+ durationBasis: "phase",
4308
+ duration: fixed(LINE_POINT_POP_MS),
4309
+ delay: { after: when("line-area", 0.97), stagger: "mark" },
4310
+ suppress: ['circle.oc-mark-point[opacity="0"]']
4311
+ },
4312
+ {
4313
+ name: "text",
4314
+ scope: "chart",
4315
+ comment: "Text marks: rise 0.6em on the author curve, with a quick fade",
4316
+ selectors: [".oc-mark-text text"],
4317
+ emit: "shorthand",
4318
+ keyframe: "oc-enter-rise",
4319
+ timing: AUTHOR,
4320
+ durationBasis: "phase",
4321
+ duration: base(1),
4322
+ fade: { ms: TEXT_FADE_MS },
4323
+ delay: { stagger: "mark" }
4324
+ },
4325
+ {
4326
+ name: "rule",
4327
+ scope: "chart",
4328
+ comment: "Rule marks: fade in place, never translate (a moving rule reads a wrong value)",
4329
+ selectors: [".oc-mark-rule line"],
4330
+ emit: "shorthand",
4331
+ keyframe: "oc-enter-fade-only",
4332
+ timing: AUTHOR,
4333
+ durationBasis: "phase",
4334
+ duration: base(0.5),
4335
+ delay: { stagger: "mark" }
4336
+ },
4337
+ {
4338
+ name: "tick",
4339
+ scope: "chart",
4340
+ comment: "Tick marks: fade in place",
4341
+ selectors: [".oc-mark-tick line"],
4342
+ emit: "shorthand",
4343
+ keyframe: "oc-enter-fade-only",
4344
+ timing: AUTHOR,
4345
+ durationBasis: "phase",
4346
+ duration: base(0.5),
4347
+ delay: { stagger: "mark" }
4348
+ },
4349
+ {
4350
+ name: "label",
4351
+ scope: "chart",
4352
+ comment: "Data labels (bar values, line end labels) fade in place once their mark has\nlanded: when the bar at the label's --oc-mark-index reaches 0.97. Lines\nshare the bar's duration and curve, so the bar anchor stands in for them.\nLabels never move during the entrance.",
4353
+ selectors: [".oc-mark-label"],
4354
+ emit: "shorthand",
4355
+ keyframe: "oc-enter-fade-only",
4356
+ timing: AUTHOR,
4357
+ durationBasis: "phase",
4358
+ duration: fixed(LABEL_FADE_MS),
4359
+ delay: { after: when("bar", 0.97), stagger: "mark" }
4360
+ },
4361
+ {
4362
+ name: "arc-label",
4363
+ scope: "chart",
4364
+ comment: "Pie/donut slice labels fade in place once their own slice reaches 0.97.",
4365
+ selectors: [".oc-mark-arc > .oc-mark-label"],
4366
+ emit: "shorthand",
4367
+ keyframe: "oc-enter-fade-only",
4368
+ timing: AUTHOR,
4369
+ durationBasis: "phase",
4370
+ duration: fixed(LABEL_FADE_MS),
4371
+ delay: { after: when("arc", 0.97), stagger: "mark" }
4372
+ },
4373
+ {
4374
+ name: "endpoint-label",
4375
+ scope: "chart",
4376
+ comment: "Trailing endpoint labels (marker, name, value) and area interior labels:\nfade in as their own series' line reaches the end, never before it. The\nrenderer stamps each entry with its series' --oc-mark-index.",
4377
+ selectors: [
4378
+ '.oc-endpoint-label-entry[data-endpoint-side="trailing"]',
4379
+ ".oc-area-interior-label"
4380
+ ],
4381
+ emit: "shorthand",
4382
+ keyframe: "oc-enter-fade-only",
4383
+ timing: AUTHOR,
4384
+ durationBasis: "phase",
4385
+ duration: fixed(POINT_FADE_MS),
4386
+ delay: { after: when("line-area", 0.95), stagger: "mark" }
4387
+ },
4388
+ {
4389
+ name: "annotation",
4390
+ scope: "chart",
4391
+ comment: "Annotations: fade in once the last mark is 90% of the way there",
4392
+ selectors: [".oc-annotation"],
4393
+ emit: "shorthand",
4394
+ keyframe: "oc-enter-fade-only",
4395
+ timing: { kind: "curve", curve: "glide" },
4396
+ durationBasis: "phase",
4397
+ duration: fixed(300),
4398
+ delay: {
4399
+ after: { kind: "progress", progress: 0.9, of: "bar", ofLast: true },
4400
+ plusAnnotationDelay: true,
4401
+ stagger: "none"
4402
+ }
4403
+ },
4404
+ {
4405
+ name: "tilemap-tile",
4406
+ scope: "chart",
4407
+ comment: "Tilemap tiles: fade in with jittered stagger for organic feel.\nPer-tile delay is computed in the renderer with pseudo-random variation.",
4408
+ selectors: [".oc-tilemap-tile"],
4409
+ emit: "shorthand",
4410
+ keyframe: "oc-enter-fade-only",
4411
+ timing: EASE_IN,
4412
+ durationBasis: "phase",
4413
+ duration: base(0.35),
4414
+ delay: { stagger: "tilemap-tile" }
4415
+ },
4416
+ {
4417
+ name: "map-feature",
4418
+ scope: "chart",
4419
+ comment: "Map features: fill color reveal with shuffled stagger.\nPer-feature --oc-map-delay is computed in the renderer via a seeded\nFisher-Yates shuffle so features pop in organically.",
4420
+ selectors: [".oc-map-feature"],
4421
+ emit: "shorthand",
4422
+ keyframe: "oc-enter-map-fill",
4423
+ timing: AUTHOR,
4424
+ durationBasis: "map",
4425
+ duration: base(1),
4426
+ delay: { stagger: "map-sweep" }
4427
+ },
4428
+ {
4429
+ name: "map-bulk",
4430
+ scope: "chart",
4431
+ comment: "Bulk mode: high feature counts (counties, ~3k+) get a single group\nfade instead of per-feature fill animations. opacity is GPU-compositable\nso this stays smooth regardless of child count.",
4432
+ selectors: [".oc-map-features[data-bulk-animate]"],
4433
+ emit: "shorthand",
4434
+ keyframe: "oc-enter-fade-only",
4435
+ timing: AUTHOR,
4436
+ durationBasis: "map",
4437
+ duration: base(1),
4438
+ delay: { stagger: "none" },
4439
+ suppress: [".oc-map-features[data-bulk-animate] .oc-map-feature"]
4440
+ },
4441
+ {
4442
+ name: "map-border",
4443
+ scope: "chart",
4444
+ comment: "Map borders: fade in once most of the feature sweep has started",
4445
+ selectors: [".oc-map-borders path"],
4446
+ emit: "shorthand",
4447
+ keyframe: "oc-enter-fade-only",
4448
+ timing: EASE_IN,
4449
+ durationBasis: "map",
4450
+ duration: base(0.4),
4451
+ delay: { after: { kind: "sweep", progress: 0.6 }, stagger: "none" }
4452
+ },
4453
+ {
4454
+ name: "map-point",
4455
+ scope: "chart",
4456
+ comment: "Map points: gentle scale (0.75->1) + fade pop-in just after the borders.\ntransform-origin set per-circle in the renderer so scale happens\naround each circle's own center, not the SVG origin.",
4457
+ selectors: [".oc-map-point"],
4458
+ emit: "shorthand",
4459
+ keyframe: "oc-enter-map-point",
4460
+ timing: AUTHOR,
4461
+ durationBasis: "map",
4462
+ duration: base(0.4),
4463
+ delay: { after: { kind: "sweep", progress: 0.65 }, stagger: "map-point" }
4464
+ },
4465
+ {
4466
+ name: "sankey-node",
4467
+ scope: "chart",
4468
+ comment: "Sankey nodes: fade in with stagger by column depth (left-to-right)",
4469
+ selectors: [".oc-sankey-node rect"],
4470
+ emit: "shorthand",
4471
+ keyframe: "oc-enter-fade-only",
4472
+ timing: AUTHOR,
4473
+ durationBasis: "phase",
4474
+ duration: base(1),
4475
+ delay: { stagger: "mark" }
4476
+ },
4477
+ {
4478
+ name: "sankey-link",
4479
+ scope: "chart",
4480
+ comment: "Sankey links: fade in when their source node is halfway in. Each link\ncarries its source node's --oc-mark-index.",
4481
+ selectors: [".oc-sankey-link path"],
4482
+ emit: "shorthand",
4483
+ keyframe: "oc-enter-fade-only",
4484
+ timing: AUTHOR,
4485
+ durationBasis: "phase",
4486
+ duration: base(1),
4487
+ delay: { after: when("sankey-node", 0.5), stagger: "mark" }
4488
+ },
4489
+ {
4490
+ name: "barlist-row",
4491
+ scope: "chart",
4492
+ comment: "Barlist rows: slide up with a quick fade per row; bars grow left-to-right",
4493
+ selectors: [".oc-barlist-row"],
4494
+ emit: "shorthand",
4495
+ keyframe: "oc-enter-slide",
4496
+ timing: AUTHOR,
4497
+ durationBasis: "phase",
4498
+ duration: base(0.6),
4499
+ fade: { ms: TEXT_FADE_MS },
4500
+ delay: { stagger: "mark" }
4501
+ },
4502
+ {
4503
+ name: "barlist-bar",
4504
+ scope: "chart",
4505
+ selectors: [".oc-barlist-bar"],
4506
+ emit: "shorthand",
4507
+ keyframe: "oc-enter-bar-h",
4508
+ timing: AUTHOR,
4509
+ durationBasis: "phase",
4510
+ duration: base(1),
4511
+ delay: { stagger: "mark" }
4512
+ },
4513
+ {
4514
+ name: "table-chrome",
4515
+ scope: "table",
4516
+ comment: "Chrome (title/subtitle): fade + slide up",
4517
+ selectors: ["> .oc-chrome"],
4518
+ emit: "shorthand",
4519
+ keyframe: "oc-enter-fade",
4520
+ timing: AUTHOR,
4521
+ durationBasis: "phase",
4522
+ duration: base(0.6),
4523
+ delay: { stagger: "none" }
4524
+ },
4525
+ {
4526
+ name: "table-thead",
4527
+ scope: "table",
4528
+ comment: "Table header: quick fade before rows start",
4529
+ selectors: ["thead"],
4530
+ emit: "shorthand",
4531
+ keyframe: "oc-enter-fade-only",
4532
+ timing: AUTHOR,
4533
+ durationBasis: "phase",
4534
+ duration: base(0.4),
4535
+ delay: { stagger: "none" }
4536
+ },
4537
+ {
4538
+ name: "table-row",
4539
+ scope: "table",
4540
+ comment: "Row entrance: slide up only, no opacity (cells handle their own fading\nto avoid opacity compounding between row and cell animations)",
4541
+ selectors: ["tbody tr"],
4542
+ emit: "shorthand",
4543
+ keyframe: "oc-table-enter-row",
4544
+ timing: AUTHOR,
4545
+ durationBasis: "phase",
4546
+ duration: base(1),
4547
+ delay: { stagger: "row" }
4548
+ },
4549
+ {
4550
+ name: "table-cell",
4551
+ scope: "table",
4552
+ comment: "Cell text: fade in synced with row slide",
4553
+ selectors: ["tbody td"],
4554
+ emit: "shorthand",
4555
+ keyframe: "oc-enter-fade-only",
4556
+ timing: AUTHOR,
4557
+ durationBasis: "phase",
4558
+ duration: base(0.5),
4559
+ delay: { stagger: "row" }
4560
+ },
4561
+ {
4562
+ name: "table-heatmap-cell",
4563
+ scope: "table",
4564
+ comment: "Heatmap/category cell backgrounds: longer fade, once the row is halfway in",
4565
+ selectors: ["td.oc-table-heatmap", "td.oc-table-category"],
4566
+ emit: "shorthand",
4567
+ keyframe: "oc-enter-fade-only",
4568
+ timing: AUTHOR,
4569
+ durationBasis: "phase",
4570
+ duration: base(0.7),
4571
+ delay: { after: when("table-row", 0.5), stagger: "row" }
4572
+ },
4573
+ {
4574
+ name: "table-bar-fill",
4575
+ scope: "table",
4576
+ comment: "Bar fill: clip-path grow only (no opacity change to preserve resting\nopacity: 0.15 from table.css), once the row is halfway in",
4577
+ selectors: [".oc-table-bar-fill"],
4578
+ emit: "shorthand",
4579
+ keyframe: "oc-table-enter-bar-fill",
4580
+ timing: AUTHOR,
4581
+ durationBasis: "phase",
4582
+ duration: base(1),
4583
+ delay: { after: when("table-row", 0.5), stagger: "row" }
4584
+ },
4585
+ {
4586
+ name: "table-sparkline",
4587
+ scope: "table",
4588
+ comment: "Sparkline SVG: clip-path reveal left-to-right once the row is mostly in.\nTargets the SVG directly (not the wrapper) to avoid clipping\nabsolutely-positioned dots and labels.",
4589
+ selectors: [".oc-table-sparkline > svg"],
4590
+ emit: "shorthand",
4591
+ keyframe: "oc-enter-line",
4592
+ timing: AUTHOR,
4593
+ durationBasis: "phase",
4594
+ duration: base(0.8),
4595
+ delay: { after: when("table-row", 0.7), stagger: "row" }
4596
+ },
4597
+ {
4598
+ name: "table-sparkline-dot",
4599
+ scope: "table",
4600
+ comment: "Sparkline dots and labels: fade in as the line draws through the end",
4601
+ selectors: [".oc-table-sparkline-dot", ".oc-table-sparkline-labels"],
4602
+ emit: "shorthand",
4603
+ keyframe: "oc-enter-fade-only",
4604
+ timing: AUTHOR,
4605
+ durationBasis: "phase",
4606
+ duration: base(0.3),
4607
+ delay: { after: when("table-sparkline", 0.95), stagger: "row" }
4608
+ },
4609
+ {
4610
+ name: "table-search-pagination",
4611
+ scope: "table",
4612
+ comment: "Search and pagination: quick fade on mount",
4613
+ selectors: [".oc-table-search", ".oc-table-pagination"],
4614
+ emit: "shorthand",
4615
+ keyframe: "oc-enter-fade-only",
4616
+ timing: AUTHOR,
4617
+ durationBasis: "phase",
4618
+ duration: base(0.5),
4619
+ delay: { stagger: "none" }
4620
+ }
4621
+ ];
4622
+ var ROLE_VAR_OVERRIDES = {
4623
+ annotation: { delay: "--oc-annotation-enter-delay" }
4624
+ };
4625
+ function roleVars(role) {
4626
+ const override = ROLE_VAR_OVERRIDES[role];
4627
+ return {
4628
+ delay: override?.delay ?? `--oc-${role}-delay`,
4629
+ duration: override?.duration ?? `--oc-${role}-dur`,
4630
+ after: override?.after ?? `--oc-${role}-after`
4631
+ };
4632
+ }
4633
+ var NON_OPACITY = ["clip-path", "transform", "fill", "r", "fill-opacity"];
4634
+ var ENTRANCE_ROLES = ROLE_DEFS.map((def) => ({
4635
+ ...def,
4636
+ geometryFraction: settleOffset(def.keyframe, NON_OPACITY),
4637
+ opacityFraction: settleOffset(def.keyframe, ["opacity"]),
4638
+ vars: roleVars(def.name)
4639
+ }));
4640
+ var ROLE_BY_NAME = new Map(ENTRANCE_ROLES.map((row) => [row.name, row]));
4641
+ function entranceRole(role) {
4642
+ const row = ROLE_BY_NAME.get(role);
4643
+ if (!row) throw new Error(`Unknown entrance role "${role}"`);
4644
+ return row;
4645
+ }
4646
+ var DEFAULT_STAGGER_MS = 80;
4647
+ var DEFAULT_ANNOTATION_DELAY_MS = 150;
4648
+ function clean(ms) {
4649
+ return Math.round(ms * 1e6) / 1e6;
4650
+ }
4651
+ function roleBaseDuration(role, phase) {
4652
+ return entranceRole(role).durationBasis === "map" ? mapFeatureDuration(phase.duration) : phase.duration;
4653
+ }
4654
+ function roleDurationMs(role, phase) {
4655
+ const row = entranceRole(role);
4656
+ return row.duration.kind === "base" ? roleBaseDuration(role, phase) * row.duration.factor : row.duration.ms;
4657
+ }
4658
+ function staggerMs(rule, index, ctx) {
4659
+ switch (rule) {
4660
+ case "none":
4661
+ return 0;
4662
+ case "mark":
4663
+ case "row":
4664
+ return index * (ctx.staggerMs ?? DEFAULT_STAGGER_MS);
4665
+ case "map-point":
4666
+ return index * (ctx.pointStaggerMs ?? MAP_POINT_STAGGER_FALLBACK_MS);
4667
+ case "map-sweep":
4668
+ return index * (ctx.staggerMs ?? 0);
4669
+ case "tilemap-tile":
4670
+ return ctx.delayMs ?? 0;
4671
+ default:
4672
+ return rule;
4673
+ }
4674
+ }
4675
+ function parentContext(ctx) {
4676
+ return {
4677
+ staggerMs: ctx.staggerMs,
4678
+ annotationDelayMs: ctx.annotationDelayMs,
4679
+ pointStaggerMs: ctx.pointStaggerMs,
4680
+ afterMs: ctx.afterMs,
4681
+ lastMarkIndex: ctx.lastMarkIndex
4682
+ };
4683
+ }
4684
+ function progressTimeMs(role, index, phase, context, progress) {
4685
+ const { delayMs, durationMs } = entranceTiming(role, index, phase, context);
4686
+ return clean(delayMs + invertRoleEase(role, phase, progress) * durationMs);
4687
+ }
4688
+ function anchorMs(role, phase, context = {}) {
4689
+ const anchor = entranceRole(role).delay.after;
4690
+ if (!anchor) return 0;
4691
+ const stamped = context.afterMs?.[role];
4692
+ if (stamped !== void 0) return stamped;
4693
+ if (anchor.kind === "sweep") return clean(anchor.progress * MAP_SWEEP_BUDGET_MS);
4694
+ const index = anchor.ofLast ? context.lastMarkIndex ?? 0 : 0;
4695
+ return progressTimeMs(anchor.of, index, phase, parentContext(context), anchor.progress);
4696
+ }
4697
+ function entranceAnchorVars(phase, context = {}, scope = "chart") {
4698
+ const vars = {};
4699
+ for (const row of ENTRANCE_ROLES) {
4700
+ if (row.scope !== scope || !row.delay.after) continue;
4701
+ vars[row.vars.after] = `${anchorMs(row.name, phase, context)}ms`;
4702
+ }
4703
+ return vars;
4704
+ }
4705
+ function entranceTiming(role, index, phase, context = {}) {
4706
+ const row = entranceRole(role);
4707
+ const durationMs = roleDurationMs(role, phase);
4708
+ let delayMs;
4709
+ if (context.stampedDelayMs !== void 0) {
4710
+ delayMs = context.stampedDelayMs;
4711
+ } else {
4712
+ delayMs = staggerMs(row.delay.stagger, index, context) + anchorMs(role, phase, context);
4713
+ if (row.delay.plusAnnotationDelay) {
4714
+ delayMs += context.annotationDelayMs ?? DEFAULT_ANNOTATION_DELAY_MS;
4715
+ }
4716
+ }
4717
+ const fadeMs = row.fade?.ms ?? 0;
4718
+ return {
4719
+ delayMs: clean(delayMs),
4720
+ durationMs: clean(durationMs),
4721
+ geometryMs: clean(durationMs * row.geometryFraction),
4722
+ opacityMs: clean(row.fade ? fadeMs : durationMs * row.opacityFraction),
4723
+ fadeMs
4724
+ };
4725
+ }
4726
+ function entranceEndMs(context) {
4727
+ const { phase, roles, ...timing } = context;
4728
+ let end = 0;
4729
+ for (const [role, value] of Object.entries(roles)) {
4730
+ const extent = typeof value === "number" ? { count: value } : value;
4731
+ if (!(extent.count > 0)) continue;
4732
+ const index = extent.maxIndex ?? extent.count - 1;
4733
+ const endOf = (stampedDelayMs) => {
4734
+ const t = entranceTiming(role, index, phase, {
4735
+ ...timing,
4736
+ delayMs: extent.maxDelayMs,
4737
+ stampedDelayMs
4738
+ });
4739
+ return t.delayMs + Math.max(t.durationMs, t.fadeMs);
4740
+ };
4741
+ const stamped = extent.stampedCount ?? 0;
4742
+ if (stamped > 0 && extent.maxStampedDelayMs !== void 0) {
4743
+ end = Math.max(end, endOf(extent.maxStampedDelayMs));
4744
+ }
4745
+ if (extent.count > stamped) end = Math.max(end, endOf());
4746
+ }
4747
+ return clean(end);
4748
+ }
4749
+ function evalRoleEase(role, phase, t) {
4750
+ const { timing } = entranceRole(role);
4751
+ switch (timing.kind) {
4752
+ case "author": {
4753
+ if (phase.spring) {
4754
+ const d = roleBaseDuration(role, phase);
4755
+ const x = t < 0 ? 0 : t > 1 ? 1 : t;
4756
+ return sampleMotion({ duration: d, spring: phase.spring }, x * d).position;
4757
+ }
4758
+ return evalCurve(phase.ease ?? "smooth", t);
4759
+ }
4760
+ case "curve":
4761
+ return evalCurve(timing.curve, t);
4762
+ case "css":
4763
+ return evalCubicBezier(timing.bezier, t);
4764
+ default:
4765
+ return timing;
4766
+ }
4767
+ }
4768
+ function firstReach(f, p) {
4769
+ if (f(0) >= p) return 0;
4770
+ const steps = 256;
4771
+ let prev = 0;
4772
+ for (let i = 1; i <= steps; i++) {
4773
+ const t = i / steps;
4774
+ if (f(t) >= p) {
4775
+ let lo = prev;
4776
+ let hi = t;
4777
+ for (let k = 0; k < 40; k++) {
4778
+ const mid = (lo + hi) / 2;
4779
+ if (f(mid) >= p) hi = mid;
4780
+ else lo = mid;
4781
+ }
4782
+ return hi;
4783
+ }
4784
+ prev = t;
4785
+ }
4786
+ return 1;
4787
+ }
4788
+ function invertRoleEase(role, phase, p) {
4789
+ const { timing } = entranceRole(role);
4790
+ if (timing.kind === "author" && !phase.spring) {
4791
+ return invertCurve(phase.ease ?? "smooth", p);
4792
+ }
4793
+ if (timing.kind === "curve" && isMonotoneCurve(timing.curve)) {
4794
+ return invertCurve(timing.curve, p);
4795
+ }
4796
+ return firstReach((t) => evalRoleEase(role, phase, t), p);
4797
+ }
4798
+ var EXIT_FADE_MS = 120;
4799
+ var EXIT_CURVE = "gentle";
4800
+ var UPDATE_ENTER_START = 0.4;
4801
+ function updateTimeline(update, exit, hasRemovals) {
4802
+ const updateDelayMs = hasRemovals ? Math.max(0, exit.duration) : 0;
4803
+ const enterLead = UPDATE_ENTER_START * update.duration;
4804
+ return {
4805
+ exitMs: exit.duration,
4806
+ updateDelayMs,
4807
+ enterDelayMs: updateDelayMs + enterLead,
4808
+ enterMs: update.duration - enterLead,
4809
+ totalMs: Math.max(updateDelayMs + update.duration, exit.duration)
4810
+ };
4811
+ }
3567
4812
  export {
3568
4813
  ACHROMATIC_RAMP,
3569
4814
  AXIS_TITLE_GAP,
@@ -3580,13 +4825,19 @@ export {
3580
4825
  CATEGORICAL_FILL_PALETTE_DARK,
3581
4826
  CATEGORICAL_PALETTE,
3582
4827
  CATEGORICAL_PALETTE_DARK,
4828
+ CELL_SWEEP_BUDGET_MS,
3583
4829
  COMPACT_MAX_X_TICKS,
3584
4830
  COMPACT_WIDTH,
3585
4831
  CSS_TOKENS,
3586
4832
  CSS_TOKEN_ROOT_SELECTORS,
4833
+ CURVE_NAMES,
3587
4834
  DEFAULT_THEME,
3588
4835
  DIVERGING_PALETTES,
4836
+ ENTRANCE_ROLES,
4837
+ EXIT_CURVE,
4838
+ EXIT_FADE_MS,
3589
4839
  EXTENDED_OFFSET_STRATEGIES,
4840
+ FADE_CURVE,
3590
4841
  FLUID_SPRING,
3591
4842
  FOOTNOTE_LINE_HEIGHT,
3592
4843
  GRAPH_ENCODING_RULES,
@@ -3596,8 +4847,13 @@ export {
3596
4847
  HEIGHT_SHORT_MAX,
3597
4848
  HPAD_COMPACT_FRACTION,
3598
4849
  HPAD_COMPACT_MIN,
4850
+ KEYFRAMES,
3599
4851
  LABEL_GAP_COMPACT,
3600
4852
  LABEL_GAP_DEFAULT,
4853
+ LINE_POINT_CASCADE_MS,
4854
+ MAP_FEATURE_MAX_DURATION_MS,
4855
+ MAP_POINT_STAGGER_FALLBACK_MS,
4856
+ MAP_SWEEP_BUDGET_MS,
3601
4857
  MARK_DISPLAY_NAMES,
3602
4858
  MARK_ENCODING_RULES,
3603
4859
  MARK_TYPES,
@@ -3607,6 +4863,7 @@ export {
3607
4863
  MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX,
3608
4864
  MAX_SPRING_DURATION,
3609
4865
  MAX_SR_TABLE_ROWS,
4866
+ MAX_TOTAL_STAGGER_MS,
3610
4867
  MOTION_REST_THRESHOLD,
3611
4868
  NARROW_VIEWPORT_MAX,
3612
4869
  OFFSET_STRATEGIES,
@@ -3615,6 +4872,7 @@ export {
3615
4872
  TICK_LABEL_OFFSET,
3616
4873
  TICK_LINE_HEIGHT_FACTOR,
3617
4874
  TOP_PAD_EXTRA_NARROW,
4875
+ UPDATE_ENTER_START,
3618
4876
  X_AXIS_BAND_HEIGHT,
3619
4877
  X_AXIS_ROTATED_EXTENT_CAP,
3620
4878
  X_AXIS_TITLE_BAND,
@@ -3623,6 +4881,7 @@ export {
3623
4881
  adaptColorForDarkMode,
3624
4882
  adaptForLightLineStroke,
3625
4883
  adaptTheme,
4884
+ anchorMs,
3626
4885
  annotationSource,
3627
4886
  applyEditTransaction,
3628
4887
  areaChart,
@@ -3633,6 +4892,7 @@ export {
3633
4892
  buildD3Formatter,
3634
4893
  buildTemporalFormatter,
3635
4894
  checkPaletteDistinguishability,
4895
+ clampStaggerDelay,
3636
4896
  clarity,
3637
4897
  columnChart,
3638
4898
  computeChrome,
@@ -3642,6 +4902,8 @@ export {
3642
4902
  computeXAxisExtentFromLabels,
3643
4903
  contrastRatio,
3644
4904
  cssTokenDefault,
4905
+ curveStops,
4906
+ curveToCSSLinear,
3645
4907
  dataTable,
3646
4908
  deepMergeSpec,
3647
4909
  defaultNumberFormatter,
@@ -3651,14 +4913,23 @@ export {
3651
4913
  dotChart,
3652
4914
  elementRef,
3653
4915
  encodePointerToken,
4916
+ entranceAnchorVars,
4917
+ entranceEndMs,
4918
+ entranceRole,
4919
+ entranceTiming,
3654
4920
  essay,
3655
4921
  estimateTextWidth,
4922
+ evalCubicBezier,
4923
+ evalCurve,
4924
+ evalKeyframes,
4925
+ evalRoleEase,
4926
+ evalValueCurve,
3656
4927
  findAccessibleColor,
3657
4928
  formatCurrency,
3658
4929
  formatDate,
3659
4930
  formatNumber,
3660
4931
  formatOrdinal,
3661
- formatPercent,
4932
+ formatPercent2 as formatPercent,
3662
4933
  generateAltText,
3663
4934
  generateAriaLabels,
3664
4935
  generateDataTable,
@@ -3669,6 +4940,8 @@ export {
3669
4940
  getRepresentativeColor,
3670
4941
  heuristicMeasure,
3671
4942
  inferFieldType,
4943
+ invertCurve,
4944
+ invertRoleEase,
3672
4945
  isAxislessMark,
3673
4946
  isBarListSpec,
3674
4947
  isChartSpec,
@@ -3678,7 +4951,9 @@ export {
3678
4951
  isGradientDef,
3679
4952
  isGraphSpec,
3680
4953
  isLayerSpec,
4954
+ isMonotoneCurve,
3681
4955
  isOpaqueColor,
4956
+ isRaceSpec,
3682
4957
  isRangeAnnotation,
3683
4958
  isRefLineAnnotation,
3684
4959
  isSankeySpec,
@@ -3688,8 +4963,12 @@ export {
3688
4963
  isValueDef,
3689
4964
  isYearContext,
3690
4965
  jsonPointer,
4966
+ keyframeProperties,
4967
+ keyframeValueToCSS,
3691
4968
  legacyEditorial,
3692
4969
  lineChart,
4970
+ mapFeatureDuration,
4971
+ mapSweepTiming,
3693
4972
  maxRotatedLabelWidth,
3694
4973
  meetsAA,
3695
4974
  mergeThemeConfig,
@@ -3697,6 +4976,7 @@ export {
3697
4976
  overlapArea,
3698
4977
  pickLabelColor,
3699
4978
  pieChart,
4979
+ progressTimeMs,
3700
4980
  resolveChromeEconomy,
3701
4981
  resolveCollisions,
3702
4982
  resolveMarkDef,
@@ -3705,15 +4985,20 @@ export {
3705
4985
  resolveNumberFormatter,
3706
4986
  resolveSchemeName,
3707
4987
  resolveTheme,
4988
+ roleBaseDuration,
4989
+ roleVars,
3708
4990
  sampleMotion,
3709
4991
  scatterChart,
4992
+ shuffledSweepDelays,
3710
4993
  simulateColorBlindness,
3711
4994
  springDuration,
3712
4995
  terminal,
3713
4996
  textAscent,
3714
4997
  tileMap,
4998
+ tilemapTileDelays,
3715
4999
  truncateRotatedLabel,
3716
5000
  truncateToWidth,
5001
+ updateTimeline,
3717
5002
  wire,
3718
5003
  wrapText
3719
5004
  };