{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"status-cycle","type":"registry:component","title":"Status Cycle","description":"Status badge animation: a pill whose label cycles through states. A centred line whose status pill cycles: the label rolls up behind a hard clip while the pill's width springs past its target and back, and the line re-centres around it.","dependencies":["remotion","@remotion/google-fonts"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>. Pass mode=\"dark\" for dark frames.","registryDependencies":["https://kuchi.kalarislabs.com/r/kuchi-ui.json"],"files":[{"path":"components/kuchi/status-cycle.tsx","type":"registry:component","target":"components/kuchi/status-cycle.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport { loadFont as loadInter } from \"@remotion/google-fonts/Inter\";\r\nimport { useEffect, useMemo, useRef, useState } from \"react\";\r\nimport {\r\n  AbsoluteFill,\r\n  continueRender,\r\n  delayRender,\r\n  Easing,\r\n  getRemotionEnvironment,\r\n  interpolate,\r\n  spring,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport {\r\n  Item,\r\n  mixOklch,\r\n  resolveFont,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n} from \"@/lib/kuchi-ui\";\r\n\r\nconst { fontFamily: SANS } = loadInter(\"normal\", {\r\n  weights: [\"400\"],\r\n  subsets: [\"latin\"],\r\n});\r\n\r\nconst CLAMP = {\r\n  extrapolateLeft: \"clamp\",\r\n  extrapolateRight: \"clamp\",\r\n} as const;\r\n\r\n// ---------------------------------------------------------------------------\r\n// Proportions\r\n//\r\n// Every constant below is a *fraction* of the composition, never a pixel, so\r\n// the scene holds its shape at 720p, 1080p or a vertical crop. They were\r\n// measured off a reference recording at 802x450 by sub-pixel edge integration\r\n// and divided through; the comment on each names what was measured.\r\n// ---------------------------------------------------------------------------\r\n\r\n/**\r\n * Pill height as a multiple of the act-1 type size. Measured 44.21px against an\r\n * implied 39.2px em, both at 450.\r\n *\r\n * Keyed to the type rather than to the frame so that when a long status forces\r\n * the line to shrink, the pill shrinks with it instead of turning into a slab\r\n * with a small word floating in it.\r\n */\r\nconst PILL_H = 1.128;\r\n/** Pill centre, as a fraction of frame height. The lockup rides 1.6% low. */\r\nconst PILL_CY = 0.5164;\r\n/**\r\n * Corner radius as a fraction of the pill's own height.\r\n *\r\n * Not a stadium. Fitting a circle to the sub-pixel left edge over the pill's\r\n * top 12 rows gives R/h = 0.222–0.235 at rms 0.07–0.17px; R = h/2 fits the same\r\n * rows at rms 6.9–7.7px, two orders of magnitude worse. A stadium here reads as\r\n * a completely different object — it is the single easiest detail to get wrong.\r\n */\r\nconst PILL_R = 0.229;\r\n/** Pill padding either side of the label, as a fraction of pill height. */\r\nconst PILL_PAD = 0.19;\r\n/** Prefix-to-pill gap, as a fraction of pill height. Measured 6.5px of 44.2. */\r\nconst PILL_GAP = 0.147;\r\n/** Act-1 type size, as a fraction of frame height. Cap 29px / 0.72em of 450. */\r\nconst ACT1_EM = 0.087;\r\n/** Act-2 type size, as a fraction of frame height. Cap 72px / 0.72em of 450. */\r\nconst ACT2_EM = 0.222;\r\n/** Chip padding, as a fraction of its own type size. */\r\nconst CHIP_PAD_X = 0.42;\r\nconst CHIP_PAD_Y = 0.165;\r\n/** Chip corner radius and hairline, as fractions of chip height. */\r\nconst CHIP_R = 0.162;\r\nconst CHIP_BORDER = 0.017;\r\n/** Chip margin from the frame edge, as a fraction of frame width. */\r\nconst CHIP_INSET = 0.04;\r\n/** Share of the frame width the act-1 lockup may occupy before it is scaled. */\r\nconst ACT1_FIT = 0.92;\r\n/** Gap between stacked chips, as a fraction of frame height. */\r\nconst CHIP_GAP = 0.057;\r\n\r\n/**\r\n * The width morph is a **cubic-bezier, not a spring** — the `y2 > 1` control\r\n * value is the overshoot.\r\n *\r\n * This is not a stylistic preference. Fitting Remotion's `spring()` over a full\r\n * (damping, stiffness, rest) grid lands at rms 19.6px on a 207px travel, and the\r\n * failure is structural: a spring released from rest is at pi^2/242 = 4.1% of\r\n * travel one frame into an eleven-frame rise, and the reference is at 0.65%. No\r\n * triple is six times flatter at the start and still peaks that early. Fitted\r\n * per morph the reference gives (0.6,0,0.3,1.8) and (0.7,0.4,0.3,1.3); this is\r\n * their average, at rms 1.1–1.7% of travel.\r\n */\r\nconst WIDTH_EASE = Easing.bezier(0.65, 0.2, 0.3, 1.5);\r\n/** Seconds the width morph runs. Measured 15 and 14 frames on a 24fps clock. */\r\nconst WIDTH_SECONDS = 0.6;\r\n\r\n/**\r\n * The label roll: a symmetric ease-in-out — deliberately gentler and longer than\r\n * the reference.\r\n *\r\n * The reference rolls in 8 frames of 24fps on (0.75, 0, 0.25, 1) (measured\r\n * progress 0.010, 0.053, 0.164, 0.499, 0.833, 0.946, 0.990, 1.000). Rendered at\r\n * 30fps that is 10 frames whose middle two each move a third of the travel —\r\n * 32px a frame at 1080p — so the frame between them shows two half-cut labels and\r\n * the swap reads as a flicker, not a roll. Reported as \"flipping too fast\".\r\n *\r\n * (0.45, 0, 0.55, 1) over 0.5s is 15 frames at 30: no step above 13px at 1080p,\r\n * none below 0.8px (so no frozen frames in the tails, motion-quality rule 0).\r\n * 0.6s was tried first and read as too slow; 0.5s is the step between the two.\r\n * The label lands three frames before the width morph finishes its overshoot.\r\n */\r\nconst ROLL_EASE = Easing.bezier(0.45, 0, 0.55, 1);\r\n/** Seconds the roll runs. See ROLL_EASE for why it is not the reference's 1/3. */\r\nconst ROLL_SECONDS = 0.5;\r\n/** Roll travel, as a multiple of pill height. Measured 47.1px on a 46.2 pill. */\r\nconst ROLL_TRAVEL = 1.02;\r\n\r\n/** Seconds the green-to-cream crossfade takes. Measured 18 frames of 60fps. */\r\nconst FADE_SECONDS = 0.3;\r\n/** Seconds the lockup takes to leave upward. Measured 0.19s, exponential. */\r\nconst EXIT_SECONDS = 0.2;\r\n/** Time constant of the act-2 scroll step, in seconds. Fitted 1-exp(-t/tau). */\r\nconst SCROLL_TAU = 0.06;\r\n\r\n/**\r\n * The per-letter intro scale.\r\n *\r\n * Measured peak is 1.45x the settled size, and a spring's overshoot is\r\n * `exp(-pi*zeta/sqrt(1-zeta^2))` — so zeta = 0.25, which at stiffness 100 and\r\n * mass 1 is damping 5. That is where these numbers come from; they are not a\r\n * taste setting, and changing the damping moves the peak off the reference.\r\n */\r\nconst LETTER_SPRING = { damping: 5, stiffness: 100, mass: 1 } as const;\r\n\r\n/**\r\n * Pure scheduling and fitting math. Everything above the component is\r\n * frame-deterministic and side-effect free so it can be unit tested.\r\n */\r\n\r\n/** Accepts an array or the comma-separated string the customizer passes. */\r\nexport function toList(value?: string[] | string): string[] {\r\n  const list = typeof value === \"string\" ? value.split(\",\") : (value ?? []);\r\n  return list.map((s) => s.trim()).filter(Boolean);\r\n}\r\n\r\n/**\r\n * Exponential ease-out, in frames.\r\n *\r\n * The reference's scroll step is not any fixed-duration curve: easeOutCubic\r\n * predicts 0.977 at t=0.167s against a measured 0.918, and quint/expo are far\r\n * too fast at the head. `1 - exp(-t/tau)` fits every sample of every step at\r\n * tau = 0.060s, which is what a lerp-toward-target does, and it never overshoots\r\n * — the reference's peak progress is exactly 1.000 at every step.\r\n */\r\nexport function settle(frames: number, tau: number): number {\r\n  if (frames <= 0) return 0;\r\n  return 1 - Math.exp(-frames / tau);\r\n}\r\n\r\n/**\r\n * Which status is up at `frame`, and how many frames since it arrived.\r\n *\r\n * The index only ever advances, and `since` is relative to the swap that put\r\n * the current label up — so a swap still settling when the next one starts\r\n * hands over cleanly instead of compounding.\r\n */\r\nexport function statusAt({\r\n  frame,\r\n  introFrames,\r\n  statusHold,\r\n  count,\r\n}: {\r\n  frame: number;\r\n  introFrames: number;\r\n  statusHold: number;\r\n  count: number;\r\n}): { index: number; since: number } {\r\n  if (count <= 0) return { index: 0, since: 0 };\r\n  let index = 0;\r\n  for (let i = 1; i < count; i += 1) {\r\n    if (frame >= introFrames + (i - 1) * statusHold) index = i;\r\n  }\r\n  return { index, since: frame - (introFrames + (index - 1) * statusHold) };\r\n}\r\n\r\n/**\r\n * How many chips have arrived at `frame`, and how far the step they triggered\r\n * has run. Clamped to `count`, so the field stops stepping once the last chip\r\n * is in rather than scrolling the whole column off the top.\r\n */\r\nexport function chipAt({\r\n  frame,\r\n  beat,\r\n  stagger,\r\n  count,\r\n}: {\r\n  frame: number;\r\n  beat: number;\r\n  stagger: number;\r\n  count: number;\r\n}): { arrived: number; since: number } {\r\n  if (count <= 0 || frame < beat) return { arrived: 0, since: 0 };\r\n  const arrived = Math.min(count, Math.floor((frame - beat) / stagger) + 1);\r\n  return { arrived, since: frame - beat - (arrived - 1) * stagger };\r\n}\r\n\r\n/**\r\n * How much a measured line has to shrink to sit inside its budget.\r\n *\r\n * Only ever <= 1. Scaling *up* to fill the budget would make a two-word status\r\n * larger than a five-word one, which is the opposite of a design system.\r\n */\r\nexport function fitScale(measured: number, budget: number): number {\r\n  if (!(measured > 0) || !(budget > 0)) return 1;\r\n  return Math.min(1, budget / measured);\r\n}\r\n\r\nexport interface StatusCycleMotion {\r\n  /** Easing of the pill's width. `y2 > 1` on a bezier is what gives overshoot. */\r\n  widthEase: (t: number) => number;\r\n  /** Seconds the width morph runs. */\r\n  widthSeconds: number;\r\n  /** Easing of the label roll. */\r\n  rollEase: (t: number) => number;\r\n  /** Seconds the roll runs. */\r\n  rollSeconds: number;\r\n  /** Roll travel, as a multiple of pill height. */\r\n  rollTravel: number;\r\n  /** Seconds the field crossfade takes. */\r\n  fadeSeconds: number;\r\n  /** Seconds the lockup takes to leave upward. */\r\n  exitSeconds: number;\r\n  /** Time constant of an act-2 scroll step, in seconds. */\r\n  scrollTau: number;\r\n  /** Spring the intro's per-letter scale runs on. Damping sets the peak. */\r\n  letterSpring: { damping: number; stiffness: number; mass: number };\r\n  /** Frames between one letter's entry and the next. */\r\n  letterStagger: number;\r\n}\r\n\r\n/**\r\n * Measured defaults. Every one but the roll is fitted from frame data — see the\r\n * constant it reads from — so overriding one is a deliberate departure, not a\r\n * tweak. The roll departs from its reference on purpose; ROLL_EASE says why.\r\n */\r\nexport const STATUS_CYCLE_MOTION: StatusCycleMotion = {\r\n  widthEase: WIDTH_EASE,\r\n  widthSeconds: WIDTH_SECONDS,\r\n  rollEase: ROLL_EASE,\r\n  rollSeconds: ROLL_SECONDS,\r\n  rollTravel: ROLL_TRAVEL,\r\n  fadeSeconds: FADE_SECONDS,\r\n  exitSeconds: EXIT_SECONDS,\r\n  scrollTau: SCROLL_TAU,\r\n  letterSpring: LETTER_SPRING,\r\n  letterStagger: 1,\r\n};\r\n\r\nexport interface StatusCycleProps {\r\n  /** The line that does not change, to the left of the pill. */\r\n  prefix?: string;\r\n  /** Pill labels, in order. Also accepts a comma-separated string. */\r\n  statuses?: string[] | string;\r\n  /** Act-2 chip labels, in order. Also accepts a comma-separated string. */\r\n  chips?: string[] | string;\r\n  /** Act-1 field. Defaults to the design system's `primary`. */\r\n  fieldColor?: string;\r\n  /** Act-2 field. Defaults to the design system's `background`. */\r\n  pageColor?: string;\r\n  /** Pill fill. Defaults to `foreground`. */\r\n  pillColor?: string;\r\n  /** Pill label. Defaults to a pale tint of the field. */\r\n  pillLabelColor?: string;\r\n  /** Prefix ink. Defaults to `foreground`. */\r\n  prefixColor?: string;\r\n  /**\r\n   * Chip fills, cycled in order. The reference runs a period-3 cycle — a card,\r\n   * a pale tint, a saturated one — and that is what the default builds from the\r\n   * theme. Also accepts a comma-separated string.\r\n   */\r\n  chipFills?: string[] | string;\r\n  /** Chip ink. One colour on every chip, including the saturated one. */\r\n  chipTextColor?: string;\r\n  /** Chip hairline. Defaults to the design system's border, scaled for a\r\n   * surface this size (`mixOklch(border, foreground, 0.28)`). */\r\n  chipBorderColor?: string;\r\n  /** Act-1 type weight. */\r\n  fontWeight?: number;\r\n  /** Act-2 type weight. Measured 400 in the reference — the chips are bigger,\r\n   * not heavier, and bumping this is the usual way to make them look cheap. */\r\n  chipFontWeight?: number;\r\n  /**\r\n   * Pill corner radius in px. Defaults to 0.229 x pill height — which is very\r\n   * nearly shadcn's own `radius` token over a 40px control (10/40 = 0.25), so\r\n   * the default already sits in the design system rather than beside it. Pass\r\n   * `theme.radius` scaled to your own control size to match exactly.\r\n   */\r\n  pillRadius?: number;\r\n  /** Chip corner radius in px. Defaults to 0.162 x chip height. */\r\n  chipRadius?: number;\r\n  /** Chip hairline width in px. Defaults to 0.017 x chip height. */\r\n  chipBorderWidth?: number;\r\n  /** Pill centre, as a fraction of frame height. The reference rides 1.6% low. */\r\n  pillCenterY?: number;\r\n  /** Curve and timing overrides. Merged over {@link STATUS_CYCLE_MOTION}. */\r\n  motion?: Partial<StatusCycleMotion>;\r\n  /** Act-1 type size in px. Defaults to 8.7% of the composition height. */\r\n  fontSize?: number;\r\n  /** Act-2 type size in px. Defaults to 22.2% of the composition height. */\r\n  chipFontSize?: number;\r\n  /** Font stack. Defaults to Inter, loaded through `@remotion/google-fonts`. */\r\n  fontFamily?: string;\r\n  /**\r\n   * Frames from one status swap to the next. Keep it above the roll (0.5s, 15\r\n   * frames at 30fps) plus time to read the label: at or below the roll, the pill\r\n   * never rests and every label is read mid-flight.\r\n   */\r\n  statusHold?: number;\r\n  /** Frames the intro cascade is given before the first swap. */\r\n  introFrames?: number;\r\n  /** Frames from one chip's arrival to the next. */\r\n  chipStagger?: number;\r\n  /** Frame the scene starts on. */\r\n  startAt?: number;\r\n  /** Playback rate. */\r\n  speed?: number;\r\n  /** Design-system token overrides. */\r\n  theme?: Partial<KuchiTheme>;\r\n  mode?: \"light\" | \"dark\";\r\n}\r\n\r\ninterface Metrics {\r\n  /** Left offset and width of every prefix glyph, in layout px. */\r\n  letters: { left: number; width: number }[];\r\n  prefixWidth: number;\r\n  /** Distance from the prefix box's top to its baseline. */\r\n  baseline: number;\r\n  statusWidths: number[];\r\n  chipWidths: number[];\r\n}\r\n\r\nexport function StatusCycle({\r\n  prefix = \"kuchi is\",\r\n  statuses = [\"animating\", \"transitioning\", \"rendering a scene\", \"installed\"],\r\n  chips = [\r\n    \"text-reveal\",\r\n    \"phone-frame\",\r\n    \"answer-stream\",\r\n    \"word-flip\",\r\n    \"orbit-gallery\",\r\n  ],\r\n  fieldColor,\r\n  pageColor,\r\n  pillColor,\r\n  pillLabelColor,\r\n  prefixColor,\r\n  chipFills,\r\n  chipTextColor,\r\n  chipBorderColor,\r\n  fontWeight = 400,\r\n  chipFontWeight = 400,\r\n  pillRadius,\r\n  chipRadius,\r\n  chipBorderWidth,\r\n  pillCenterY = PILL_CY,\r\n  motion,\r\n  fontSize,\r\n  chipFontSize,\r\n  fontFamily,\r\n  statusHold = 30,\r\n  introFrames = 24,\r\n  chipStagger = 8,\r\n  startAt = 0,\r\n  speed = 1,\r\n  theme,\r\n  mode,\r\n}: StatusCycleProps) {\r\n  const frame = useCurrentFrame() * speed - startAt;\r\n  const { fps, width, height } = useVideoConfig();\r\n  const t = useKuchiTheme(theme, mode);\r\n  const face = resolveFont(fontFamily ?? t.fontFamily) ?? SANS;\r\n\r\n  // Memoised because they are `useEffect` dependencies: rebuilt every render,\r\n  // the measuring effect would re-run forever.\r\n  const labels = useMemo(() => toList(statuses), [statuses]);\r\n  const chipLabels = useMemo(() => toList(chips), [chips]);\r\n  const glyphs = useMemo(() => [...prefix], [prefix]);\r\n\r\n  const field = fieldColor ?? t.primary;\r\n  const page = pageColor ?? t.background;\r\n  const pillFill = pillColor ?? t.foreground;\r\n  const prefixInk = prefixColor ?? t.foreground;\r\n  // A pale tint of the field: the reference's label is its own brand colour\r\n  // lightened, and this reproduces that relationship in whatever palette the\r\n  // component lands in.\r\n  //\r\n  // Mixed toward `card`, NOT `background`, and that is load-bearing. `mixOklch`\r\n  // interpolates hue the short way round, and `background` (#faf9f6) is a *warm*\r\n  // off-white with a real hue near 90 degrees — so a mix from a 264-degree blue\r\n  // sweeps 174 degrees through green and lands on rgb(164,213,180). `card` is\r\n  // achromatic, its hue is undefined, and the blue's hue is carried through\r\n  // unchanged: rgb(178,205,247), the pale blue anyone would expect.\r\n  const labelInk = pillLabelColor ?? mixOklch(field, t.card, 0.62);\r\n  const chipInk = chipTextColor ?? t.foreground;\r\n  // One hairline on every chip, from the system's own recipe for scaling a\r\n  // border token up to a surface this size (design-system rule 3b) — not a\r\n  // per-fill blend, because the reference likewise inks every chip the same.\r\n  const chipEdge = chipBorderColor ?? mixOklch(t.border, t.foreground, 0.28);\r\n  const m = { ...STATUS_CYCLE_MOTION, ...motion };\r\n  const fills = toList(chipFills);\r\n  const fillCycle =\r\n    fills.length > 0 ? fills : [t.card, mixOklch(t.card, field, 0.14), field];\r\n\r\n  const nominalEm = fontSize ?? ACT1_EM * height;\r\n  const nominalChipEm = chipFontSize ?? ACT2_EM * height;\r\n\r\n  // -------------------------------------------------------------------------\r\n  // Measure. `offsetWidth`/`offsetLeft` are layout px, untouched by the\r\n  // transforms this scene is about to apply, which is exactly what makes them\r\n  // the right tool. Measured in a hidden, untransformed copy so frame 0 can\r\n  // never be captured against the wrong geometry.\r\n  // -------------------------------------------------------------------------\r\n  const [metrics, setMetrics] = useState<Metrics | null>(null);\r\n  const [handle] = useState(() => delayRender(\"status-cycle: measuring\"));\r\n  const letterRefs = useRef<(HTMLSpanElement | null)[]>([]);\r\n  const prefixRef = useRef<HTMLSpanElement | null>(null);\r\n  const baselineRef = useRef<HTMLSpanElement | null>(null);\r\n  const statusRefs = useRef<(HTMLSpanElement | null)[]>([]);\r\n  const chipRefs = useRef<(HTMLSpanElement | null)[]>([]);\r\n\r\n  useEffect(() => {\r\n    if (metrics) {\r\n      continueRender(handle);\r\n      return;\r\n    }\r\n    const prefixWidth = prefixRef.current?.offsetWidth ?? 0;\r\n    if (prefixWidth <= 0) return;\r\n    setMetrics({\r\n      letters: glyphs.map((_, i) => ({\r\n        left: letterRefs.current[i]?.offsetLeft ?? 0,\r\n        width: letterRefs.current[i]?.offsetWidth ?? 0,\r\n      })),\r\n      prefixWidth,\r\n      baseline: baselineRef.current?.offsetTop ?? 0,\r\n      statusWidths: labels.map(\r\n        (_, i) => statusRefs.current[i]?.offsetWidth ?? 0,\r\n      ),\r\n      chipWidths: chipLabels.map(\r\n        (_, i) => chipRefs.current[i]?.offsetWidth ?? 0,\r\n      ),\r\n    });\r\n  }, [metrics, handle, glyphs, labels, chipLabels]);\r\n\r\n  // -------------------------------------------------------------------------\r\n  // Timeline\r\n  // -------------------------------------------------------------------------\r\n  const swapAt = (i: number) => introFrames + (i - 1) * statusHold;\r\n  const act1End = swapAt(labels.length) + statusHold;\r\n  const fadeStart = act1End;\r\n  const fadeFrames = m.fadeSeconds * fps;\r\n  // The three events are one beat, not three. In the reference the lockup leaves\r\n  // and the first chip arrives on the same frame, and that frame is the exact\r\n  // midpoint of the crossfade — colour starts moving, the swap happens under it,\r\n  // colour finishes. Splitting them reads as three separate cuts.\r\n  const beat = fadeStart + fadeFrames / 2;\r\n\r\n  // Two opaque layers with an opacity ramp, not `mixOklch` between the two.\r\n  // The reference's own crossfade does look like an OKLCH mix — its R channel\r\n  // runs 2-5 points behind G and B, which an sRGB lerp cannot do — but its two\r\n  // colours are a green and a cream, 30 degrees of hue apart. Ours are whatever\r\n  // the theme says, and `primary` to `background` is 174 degrees, which OKLCH\r\n  // walks the short way *through green*. A layered crossfade is what the word\r\n  // means and it cannot swing.\r\n  const fadeP = interpolate(\r\n    frame,\r\n    [fadeStart, fadeStart + fadeFrames],\r\n    [0, 1],\r\n    CLAMP,\r\n  );\r\n\r\n  // -------------------------------------------------------------------------\r\n  // Fit\r\n  //\r\n  // A size measured off one sentence is a size that clips the next one. Both\r\n  // acts are measured at their nominal type size and then scaled down — never\r\n  // up — by however much the widest line overruns its share of the frame. Text\r\n  // width is linear in font size, so the measured widths scale with the same\r\n  // factor and no second measuring pass is needed.\r\n  // -------------------------------------------------------------------------\r\n  const rawPad = PILL_PAD * PILL_H * nominalEm;\r\n  const rawGap = PILL_GAP * PILL_H * nominalEm;\r\n  const rawLockup =\r\n    (metrics?.prefixWidth ?? 0) +\r\n    rawGap +\r\n    Math.max(0, ...(metrics?.statusWidths ?? [0])) +\r\n    2 * rawPad;\r\n  const act1Fit = metrics ? fitScale(rawLockup, ACT1_FIT * width) : 1;\r\n\r\n  const rawChip =\r\n    Math.max(0, ...(metrics?.chipWidths ?? [0])) +\r\n    2 * CHIP_PAD_X * nominalChipEm;\r\n  const chipFit = metrics ? fitScale(rawChip, (1 - 2 * CHIP_INSET) * width) : 1;\r\n\r\n  const em = nominalEm * act1Fit;\r\n  const chipEm = nominalChipEm * chipFit;\r\n  const pillH = PILL_H * em;\r\n  const pillPad = PILL_PAD * pillH;\r\n  const gap = PILL_GAP * pillH;\r\n  const prefixWidth = (metrics?.prefixWidth ?? 0) * act1Fit;\r\n\r\n  const pillWidths = (metrics?.statusWidths ?? labels.map(() => 0)).map(\r\n    (w) => w * act1Fit + 2 * pillPad,\r\n  );\r\n\r\n  /** Which label is up, and how far the swap into it has progressed. */\r\n  const widthSeconds = m.widthSeconds * fps;\r\n  const rollSeconds = m.rollSeconds * fps;\r\n  const { index, since } = statusAt({\r\n    frame,\r\n    introFrames,\r\n    statusHold,\r\n    count: labels.length,\r\n  });\r\n  // Index 0 opens from nothing rather than cutting in at full width. The tape\r\n  // cannot settle this — its first recorded frame already has a pill, and the\r\n  // reference's own calling->typing morph is arithmetically inseparable from\r\n  // the intro's tail — so this runs the same curve the other morphs run, over\r\n  // the intro, which is the least invented thing available.\r\n  const widthP =\r\n    index === 0\r\n      ? m.widthEase(Math.min(1, Math.max(0, frame / introFrames)))\r\n      : m.widthEase(Math.min(1, Math.max(0, since / widthSeconds)));\r\n  const rollP =\r\n    index === 0 ? 1 : m.rollEase(Math.min(1, Math.max(0, since / rollSeconds)));\r\n\r\n  const pillW = interpolate(\r\n    widthP,\r\n    [0, 1],\r\n    [index === 0 ? 0 : (pillWidths[index - 1] ?? 0), pillWidths[index] ?? 0],\r\n  );\r\n\r\n  // The whole lockup arrives on one slow scale settle. The reference's is still\r\n  // drifting -7% two seconds in; this one lands, because a settle nobody can see\r\n  // is frames spent on travel that only costs sharpness.\r\n  const groupScale = spring({\r\n    frame,\r\n    fps,\r\n    config: { damping: 26, stiffness: 90, mass: 1.4 },\r\n    from: 1.16,\r\n    to: 1,\r\n  });\r\n\r\n  const exitP = settle((frame - beat) * (1 / m.exitSeconds / fps), 0.28);\r\n  const exitY = frame < beat ? 0 : -exitP * 0.62 * height;\r\n\r\n  const total = prefixWidth + gap + pillW;\r\n  const originX = (width - total) / 2;\r\n  const cy = pillCenterY * height;\r\n\r\n  // Only the Player gets `will-change`: a render is spread across parallel tabs\r\n  // and each inherits a stale raster, so the same style comes out as several\r\n  // different rasterisations and the type shimmers while standing still.\r\n  const promote = getRemotionEnvironment().isRendering\r\n    ? null\r\n    : ({ willChange: \"transform\" } as const);\r\n\r\n  const typeStyle = {\r\n    fontFamily: face,\r\n    fontWeight,\r\n    // Hinting re-snaps every stem as the size slides, so the letterforms boil.\r\n    // Off, shape drift over a scale falls from 3.41% to 0.22%.\r\n    textRendering: \"geometricPrecision\" as const,\r\n    whiteSpace: \"nowrap\" as const,\r\n  };\r\n\r\n  return (\r\n    <AbsoluteFill style={{ backgroundColor: page, overflow: \"hidden\" }}>\r\n      <AbsoluteFill style={{ backgroundColor: field, opacity: 1 - fadeP }} />\r\n      {metrics ? null : (\r\n        <Measuring\r\n          glyphs={glyphs}\r\n          labels={labels}\r\n          chipLabels={chipLabels}\r\n          em={em}\r\n          chipEm={chipEm}\r\n          typeStyle={typeStyle}\r\n          letterRefs={letterRefs}\r\n          prefixRef={prefixRef}\r\n          baselineRef={baselineRef}\r\n          statusRefs={statusRefs}\r\n          chipRefs={chipRefs}\r\n        />\r\n      )}\r\n\r\n      {metrics && frame < beat + m.exitSeconds * fps ? (\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            left: 0,\r\n            top: 0,\r\n            transform: `translateY(${exitY}px) scale(${groupScale})`,\r\n            transformOrigin: `${width / 2}px ${cy}px`,\r\n            width,\r\n            height,\r\n            ...promote,\r\n          }}\r\n        >\r\n          <Prefix\r\n            glyphs={glyphs}\r\n            metrics={metrics}\r\n            frame={frame}\r\n            fps={fps}\r\n            em={em}\r\n            fit={act1Fit}\r\n            spring={m.letterSpring}\r\n            stagger={m.letterStagger}\r\n            x={originX}\r\n            cy={cy}\r\n            color={prefixInk}\r\n            typeStyle={typeStyle}\r\n          />\r\n          <Pill\r\n            labels={labels}\r\n            index={index}\r\n            rollP={rollP}\r\n            x={originX + prefixWidth + gap}\r\n            cy={cy}\r\n            width={pillW}\r\n            height={pillH}\r\n            em={em}\r\n            fill={pillFill}\r\n            ink={labelInk}\r\n            radius={pillRadius ?? PILL_R * pillH}\r\n            travel={m.rollTravel * pillH}\r\n            typeStyle={typeStyle}\r\n          />\r\n        </div>\r\n      ) : null}\r\n\r\n      {metrics ? (\r\n        <Chips\r\n          labels={chipLabels}\r\n          widths={metrics.chipWidths.map((w) => w * chipFit)}\r\n          frame={frame}\r\n          fps={fps}\r\n          beat={beat}\r\n          stagger={chipStagger}\r\n          em={chipEm}\r\n          width={width}\r\n          height={height}\r\n          fills={fillCycle}\r\n          ink={chipInk}\r\n          edge={chipEdge}\r\n          radius={chipRadius}\r\n          borderWidth={chipBorderWidth}\r\n          weight={chipFontWeight}\r\n          tau={m.scrollTau}\r\n          typeStyle={typeStyle}\r\n        />\r\n      ) : null}\r\n    </AbsoluteFill>\r\n  );\r\n}\r\n\r\n/**\r\n * The intro cascade: every glyph sits at its **final advance** and scales about\r\n * its own baseline, staggered left to right.\r\n *\r\n * Measured, not guessed. Tracking one 'o' by its counter gives 1.01x → 1.45x →\r\n * 1.00x while its stroke-to-height ratio holds at 0.149 ± 0.006 — so nothing is\r\n * animating a weight or width axis, it is a plain scale, and the letters only\r\n * *look* heavier early because at 1.45x they overlap their neighbours' fixed\r\n * slots. The prefix's total ink span is unchanged from the first frame to the\r\n * last, which is only possible if the layout is static and the transform is\r\n * per-glyph.\r\n *\r\n * The one deliberate departure from the reference is the pivot. The reference\r\n * scales each letter about its centre, which drags the baseline; a moving\r\n * baseline climbs the pixel grid in whole-pixel jumps, because the rasteriser\r\n * has no vertical sub-pixel positioning at all. Pivoting on the baseline takes\r\n * judder from 0.284px to 0.014px and direction reversals from 29 to 0, and it\r\n * costs a downward growth nobody can name.\r\n */\r\nfunction Prefix({\r\n  glyphs,\r\n  metrics,\r\n  frame,\r\n  fps,\r\n  em,\r\n  fit,\r\n  spring: springConfig,\r\n  stagger,\r\n  x,\r\n  cy,\r\n  color,\r\n  typeStyle,\r\n}: {\r\n  glyphs: string[];\r\n  metrics: Metrics;\r\n  frame: number;\r\n  fps: number;\r\n  em: number;\r\n  /** Scale the measured glyph offsets were taken at, relative to `em`. */\r\n  fit: number;\r\n  spring: { damping: number; stiffness: number; mass: number };\r\n  stagger: number;\r\n  x: number;\r\n  cy: number;\r\n  color: string;\r\n  typeStyle: React.CSSProperties;\r\n}) {\r\n  return (\r\n    <div\r\n      style={{\r\n        position: \"absolute\",\r\n        left: x,\r\n        top: cy - em,\r\n        height: 2 * em,\r\n        color,\r\n        fontSize: em,\r\n        lineHeight: 2,\r\n        ...typeStyle,\r\n      }}\r\n    >\r\n      {glyphs.map((g, i) => {\r\n        // Stagger of one frame. Measured: the shared scale curve takes about one\r\n        // 30fps frame to travel 0.71x → 1.01x, which is the gap the reference\r\n        // shows between adjacent letters.\r\n        const p = spring({\r\n          frame: frame - i * stagger,\r\n          fps,\r\n          config: springConfig,\r\n        });\r\n        // The spring carries the overshoot; `interpolate` extrapolates past 1,\r\n        // so mapping [0,1] onto [0.1,1] puts the peak at 1.4x on its own — no\r\n        // second curve, and nothing to keep in step with the damping.\r\n        const s = interpolate(p, [0, 1], [0.1, 1]);\r\n        return (\r\n          <span\r\n            // biome-ignore lint/suspicious/noArrayIndexKey: positional glyph slot\r\n            key={i}\r\n            style={{\r\n              position: \"absolute\",\r\n              left: (metrics.letters[i]?.left ?? 0) * fit,\r\n              top: 0,\r\n              transform: `scale(${s})`,\r\n              transformOrigin: `50% ${metrics.baseline * fit}px`,\r\n              ...typeStyle,\r\n            }}\r\n          >\r\n            {g === \" \" ? \" \" : g}\r\n          </span>\r\n        );\r\n      })}\r\n    </div>\r\n  );\r\n}\r\n\r\n/**\r\n * The pill: a width that animates straight through a label that never changes\r\n * size, and two stacked labels rolling upward behind a hard clip.\r\n *\r\n * The label is laid out at its full final width and centred, and the widening\r\n * pill reveals it from the middle out — proven on the reference by the two\r\n * inter-word gaps of \"sharing a moment\" sitting at x = 486.0 and 521.5 across\r\n * three frames while the pill grew 83px. So the width cannot be derived from a\r\n * padded text box each frame; it is its own animated quantity.\r\n *\r\n * There is no crossfade. The label ink's mean brightness holds inside a 4% band\r\n * through every swap, including the frames where both labels are half-clipped —\r\n * a fade would collapse it toward the fill. Pure translation plus clipping.\r\n */\r\nfunction Pill({\r\n  labels,\r\n  index,\r\n  rollP,\r\n  x,\r\n  cy,\r\n  width,\r\n  height,\r\n  em,\r\n  fill,\r\n  ink,\r\n  radius,\r\n  travel,\r\n  typeStyle,\r\n}: {\r\n  labels: string[];\r\n  index: number;\r\n  rollP: number;\r\n  x: number;\r\n  cy: number;\r\n  width: number;\r\n  height: number;\r\n  em: number;\r\n  fill: string;\r\n  ink: string;\r\n  radius: number;\r\n  travel: number;\r\n  typeStyle: React.CSSProperties;\r\n}) {\r\n  const showOutgoing = rollP < 1 && index > 0;\r\n\r\n  const label = (text: string, offset: number) => (\r\n    <div\r\n      style={{\r\n        position: \"absolute\",\r\n        left: \"50%\",\r\n        top: 0,\r\n        height,\r\n        display: \"flex\",\r\n        alignItems: \"center\",\r\n        transform: `translate(-50%, ${offset}px)`,\r\n        color: ink,\r\n        fontSize: em,\r\n        ...typeStyle,\r\n      }}\r\n    >\r\n      {text}\r\n    </div>\r\n  );\r\n\r\n  return (\r\n    <div\r\n      style={{\r\n        position: \"absolute\",\r\n        left: x,\r\n        top: cy - height / 2,\r\n        width,\r\n        height,\r\n        borderRadius: radius,\r\n        backgroundColor: fill,\r\n        overflow: \"hidden\",\r\n      }}\r\n    >\r\n      {showOutgoing ? label(labels[index - 1] ?? \"\", -rollP * travel) : null}\r\n      {label(labels[index] ?? \"\", (1 - rollP) * travel)}\r\n    </div>\r\n  );\r\n}\r\n\r\n/**\r\n * Act 2: chips ride a field that steps, not scrolls.\r\n *\r\n * The field is dead still between beats — residual velocity under 1px per\r\n * captured frame — and then jumps exactly one slot with a hard ease-out on the\r\n * frame a new chip appears. The chips themselves do nothing: measured across\r\n * every frame each is visible, width and fill are final from the first frame and\r\n * never change, and two chips in the same step travelled 140.02px and 139.34px,\r\n * so it is one transform on the container rather than per-chip animation.\r\n */\r\nfunction Chips({\r\n  labels,\r\n  widths,\r\n  frame,\r\n  fps,\r\n  beat,\r\n  stagger,\r\n  em,\r\n  width,\r\n  height,\r\n  fills,\r\n  ink,\r\n  edge,\r\n  radius,\r\n  borderWidth,\r\n  weight,\r\n  tau: scrollTau,\r\n  typeStyle,\r\n}: {\r\n  labels: string[];\r\n  widths: number[];\r\n  frame: number;\r\n  fps: number;\r\n  beat: number;\r\n  stagger: number;\r\n  em: number;\r\n  width: number;\r\n  height: number;\r\n  fills: string[];\r\n  ink: string;\r\n  edge: string;\r\n  radius?: number;\r\n  borderWidth?: number;\r\n  weight: number;\r\n  tau: number;\r\n  typeStyle: React.CSSProperties;\r\n}) {\r\n  if (frame < beat) return null;\r\n\r\n  const chipH = em * (1 + 2 * CHIP_PAD_Y);\r\n  const step = chipH + CHIP_GAP * height;\r\n  const tau = scrollTau * fps;\r\n\r\n  // How many chips have arrived, and how far the current step has run.\r\n  const { arrived, since } = chipAt({\r\n    frame,\r\n    beat,\r\n    stagger,\r\n    count: labels.length,\r\n  });\r\n  const p = settle(since, tau);\r\n  // The newest chip comes to rest one gap clear of the bottom edge. Landing it\r\n  // flush reads as clipped rather than as arrived — its border sits on the\r\n  // frame edge and half of it is lost to the codec.\r\n  const fieldY = height - CHIP_GAP * height - chipH - (arrived - 2 + p) * step;\r\n\r\n  return (\r\n    <div style={{ position: \"absolute\", inset: 0, overflow: \"hidden\" }}>\r\n      {labels.slice(0, arrived).map((text, i) => {\r\n        const w = (widths[i] ?? 0) + 2 * CHIP_PAD_X * em;\r\n        const left = i % 2 === 0;\r\n        const fill = fills[i % fills.length] ?? fills[0];\r\n        return (\r\n          // biome-ignore lint/suspicious/noArrayIndexKey: positional chip slot\r\n          <Item key={i} index={i}>\r\n            <div\r\n              style={{\r\n                position: \"absolute\",\r\n                top: 0,\r\n                left: left ? CHIP_INSET * width : undefined,\r\n                right: left ? undefined : CHIP_INSET * width,\r\n                transform: `translateY(${fieldY + i * step}px)`,\r\n                width: w,\r\n                height: chipH,\r\n                borderRadius: radius ?? CHIP_R * chipH,\r\n                backgroundColor: fill,\r\n                // A hairline and nothing else. The reference has no shadow — cream\r\n                // measured through a chip's top edge recovers to its flat value\r\n                // within 2px on both sides, with no directional darkening — and a\r\n                // drop shadow under a light chip on a light page is a grey smear.\r\n                border: `${borderWidth ?? CHIP_BORDER * chipH}px solid ${edge}`,\r\n                display: \"flex\",\r\n                alignItems: \"center\",\r\n                justifyContent: \"center\",\r\n                color: ink,\r\n                fontSize: em,\r\n                ...typeStyle,\r\n                fontWeight: weight,\r\n              }}\r\n            >\r\n              {text}\r\n            </div>\r\n          </Item>\r\n        );\r\n      })}\r\n    </div>\r\n  );\r\n}\r\n\r\n/**\r\n * The hidden, untransformed copy every measurement is taken from. Rendered only\r\n * until `metrics` exists, and `delayRender` holds frame 0 until then.\r\n */\r\nfunction Measuring({\r\n  glyphs,\r\n  labels,\r\n  chipLabels,\r\n  em,\r\n  chipEm,\r\n  typeStyle,\r\n  letterRefs,\r\n  prefixRef,\r\n  baselineRef,\r\n  statusRefs,\r\n  chipRefs,\r\n}: {\r\n  glyphs: string[];\r\n  labels: string[];\r\n  chipLabels: string[];\r\n  em: number;\r\n  chipEm: number;\r\n  typeStyle: React.CSSProperties;\r\n  // Plain `{ current }` shapes, not RefObject: React 18's RefObject is\r\n  // read-only and rejects what `useRef(null)` hands back in a React 19 project.\r\n  letterRefs: { current: (HTMLSpanElement | null)[] };\r\n  prefixRef: { current: HTMLSpanElement | null };\r\n  baselineRef: { current: HTMLSpanElement | null };\r\n  statusRefs: { current: (HTMLSpanElement | null)[] };\r\n  chipRefs: { current: (HTMLSpanElement | null)[] };\r\n}) {\r\n  return (\r\n    <div\r\n      aria-hidden\r\n      style={{\r\n        position: \"absolute\",\r\n        visibility: \"hidden\",\r\n        left: 0,\r\n        top: 0,\r\n        pointerEvents: \"none\",\r\n        // Each measured span is `inline-block` and gets its own line, so it\r\n        // reports its own text width. Left as blocks they fill this\r\n        // shrink-to-fit box and every label comes back the widest one's width —\r\n        // which is four identical pills and a prefix pushed off the frame.\r\n        display: \"flex\",\r\n        flexDirection: \"column\",\r\n        alignItems: \"flex-start\",\r\n      }}\r\n    >\r\n      <span\r\n        ref={prefixRef}\r\n        style={{ fontSize: em, lineHeight: 2, ...typeStyle }}\r\n      >\r\n        {glyphs.map((g, i) => (\r\n          <span\r\n            // biome-ignore lint/suspicious/noArrayIndexKey: positional glyph slot\r\n            key={i}\r\n            ref={(el) => {\r\n              letterRefs.current[i] = el;\r\n            }}\r\n            style={{ display: \"inline-block\" }}\r\n          >\r\n            {g === \" \" ? \" \" : g}\r\n          </span>\r\n        ))}\r\n        {/* A zero-sized inline-block sits ON the baseline, so `offsetTop` reads\r\n            it rather than a line-height ratio anyone has to guess. */}\r\n        <span\r\n          ref={baselineRef}\r\n          style={{ display: \"inline-block\", width: 0, height: 0 }}\r\n        />\r\n      </span>\r\n      {labels.map((text, i) => (\r\n        <span\r\n          // biome-ignore lint/suspicious/noArrayIndexKey: positional label slot\r\n          key={i}\r\n          ref={(el) => {\r\n            statusRefs.current[i] = el;\r\n          }}\r\n          style={{ display: \"inline-block\", fontSize: em, ...typeStyle }}\r\n        >\r\n          {text}\r\n        </span>\r\n      ))}\r\n      {chipLabels.map((text, i) => (\r\n        <span\r\n          // biome-ignore lint/suspicious/noArrayIndexKey: positional chip slot\r\n          key={i}\r\n          ref={(el) => {\r\n            chipRefs.current[i] = el;\r\n          }}\r\n          style={{ display: \"inline-block\", fontSize: chipEm, ...typeStyle }}\r\n        >\r\n          {text}\r\n        </span>\r\n      ))}\r\n    </div>\r\n  );\r\n}\r\n"}]}