{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"count-grid","type":"registry:component","title":"Count Grid","description":"Number count-up grid: cards multiply and a counter jumps, the it-scales stat shot. A grid of cards rushes in under a horizontal smear, settles on five and a label, then the camera pulls back a fraction while every empty cell around them fills in from the middle out and the number jumps.","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/count-grid.tsx","type":"registry:component","target":"components/kuchi/count-grid.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 loadSans } from \"@remotion/google-fonts/Inter\";\r\nimport {\r\n  AbsoluteFill,\r\n  getRemotionEnvironment,\r\n  Img,\r\n  interpolate,\r\n  staticFile,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport {\r\n  Item,\r\n  mixOklch,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n} from \"@/lib/kuchi-ui\";\r\n\r\n/**\r\n * A grid of cards that rushes in, settles on a small count, then fills the\r\n * frame while the number jumps.\r\n *\r\n * Five cards and a label; the camera pulls back a fraction, every empty cell\r\n * around them fills in from the middle out, and the label goes from five to\r\n * five hundred. It is the \"and it scales\" shot — one thing, then all of them,\r\n * without a cut.\r\n *\r\n * Beat by beat, measured off the reference at 30fps:\r\n *\r\n * | beat | frames | what moves |\r\n * | --- | --- | --- |\r\n * | rush in | 0 – 7 | cell pitch 184 → 138, hard horizontal blur |\r\n * | settle | 7 – 19 | 138 → 121, blur gone by 12 |\r\n * | label | 11 – 18 | the whole line fades up at once |\r\n * | drift | 19 – 36 | 121 → 118, still moving, never held |\r\n * | fill | 37 – 46 | 118 → 96.5, every cell populates, 5 → 500 |\r\n *\r\n * The pull-back is a *scale*, not a camera z-move: the two centre columns hold\r\n * their midpoint at x 358.5 for all 47 frames while the pitch between them\r\n * walks 138.5 → 96.5, and the cards keep a constant fraction of the cell. And\r\n * the settle never actually settles — the pitch is still shedding a fifth of a\r\n * pixel per frame at frame 37, which is what stops the middle of the shot\r\n * looking like a freeze-frame.\r\n */\r\n\r\nconst { fontFamily: SANS } = loadSans();\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Geometry, in the reference's own 712×398 pixels\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\nexport const REF_W = 712;\r\nexport const REF_H = 398;\r\n\r\n/**\r\n * What the pull-back scales about.\r\n *\r\n * Horizontally it is the midpoint the two centre columns hold all clip: 358.75.\r\n * Vertically it is *not* the middle row — the centre row's own middle sits at\r\n * 202.5 and moves to 203.5 as the grid shrinks, which puts the fixed point 5px\r\n * lower, at 207.6. Scaling about the row instead leaves the whole grid a\r\n * pixel high through the entire fill.\r\n */\r\nexport const ORIGIN = { x: 358.75, y: 207.6 };\r\n\r\n/**\r\n * One cell at scale 1, and how much of it the card takes.\r\n *\r\n * The *cell* is measured — 120.5 × 147, the pitch the whole pull-back is fitted\r\n * to. The card inside it is a design choice and it is deliberately not the\r\n * reference's: measured, that card is 90.5 × 117 with a 30px gutter and a 6px\r\n * radius, which reads as a scatter of small rounded stickers. This one fills\r\n * 95% of its cell with a 3px corner, so the grid reads as a wall of frames.\r\n */\r\nexport const CELL = { w: 120.5, h: 147 };\r\nexport const CARD = { w: 114.5, h: 139.5, radius: 3 };\r\n\r\n/**\r\n * How much closer the grid sits than the reference's camera.\r\n *\r\n * One, now. It was 1.75 for exactly as long as it took to find out that the\r\n * cards were being *drawn* at reference-pixel size inside cells laid out at\r\n * render-pixel size — 0.42 of their own cell rather than 0.95 — and that no\r\n * amount of zoom fixes a missing unit conversion, it only moves the error into\r\n * the cell spacing as well. Left in place because it is the honest knob if the\r\n * grid should ever sit closer than the reference's, and because a `1` with this\r\n * note attached is cheaper than someone rediscovering the bug.\r\n */\r\nexport const GRID_ZOOM = 1;\r\n\r\n/** A column *boundary* sits on the centre; a row *centre* does. */\r\nexport const COL_EDGE = 359;\r\nexport const ROW_MID = 202.5;\r\n\r\n/**\r\n * The five that are there before the grid fills.\r\n *\r\n * `[col, row]`, with column 0 immediately right of the centre boundary and row\r\n * 0 the middle row. Four make a square around the label and the fifth hangs\r\n * below on the right — an even 2×2 reads as a swatch, and the odd one out is\r\n * what makes it read as a handful of people.\r\n */\r\nexport const SEED: readonly (readonly [number, number])[] = [\r\n  [-1, -1],\r\n  [0, -1],\r\n  [-1, 0],\r\n  [0, 0],\r\n  [0, 1],\r\n];\r\n\r\n/** The label, at scale 1. */\r\nexport const LABEL = {\r\n  cy: ROW_MID,\r\n  size: 30,\r\n  padX: 15,\r\n  height: 41,\r\n  radius: 9,\r\n};\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Curves\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\n/** When the grid stops being five cards and becomes all of them. */\r\nexport const FILL_AT = 37;\r\n\r\n/**\r\n * The cell pitch, in reference px — the one number the whole scene hangs on.\r\n *\r\n * Tracked as the distance between the two centre columns: 138.5 at frame 7,\r\n * 128 at 11, 121.5 at 19, 120 at 26, 118 from 32 to 36, then 113, 104, 99.5,\r\n * 96.5 across the fill. Before frame 7 the horizontal blur is wider than a card\r\n * and nothing can be measured, so that stretch is the same exponential run\r\n * backwards, which puts frame 0 at 174 — a card and a half outside the frame.\r\n *\r\n * Knots, not that exponential. Two of them fitted the settle and the fill to\r\n * within a pixel and a half each, which is a pixel and a half of grid, and they\r\n * met 3.7px apart at the switch going the *wrong way* — the pitch grew by 0.17\r\n * between 36 and 37, so the grid jolted outward on the exact frame it was\r\n * supposed to start collapsing. Every knot below is a measured frame and the\r\n * table is strictly decreasing, so it cannot do that.\r\n *\r\n * Every frame number here is zero-based, and every one of them was read off a\r\n * file called `f0NN.png` that is one-based: `f038.png` is frame 37. Taking the\r\n * filenames at face value put the whole clip a frame late and cost the switch\r\n * frame alone 17 mean.\r\n */\r\nexport function pitch(t: number, fps = 30): number {\r\n  return interpolate(\r\n    t * fps,\r\n    [\r\n      0, 7, 9, 11, 13, 15, 17, 19, 22, 26, 29, 31, 36, 37, 38, 39, 40, 41, 42,\r\n      43, 45, 46,\r\n    ],\r\n    [\r\n      174, 138.5, 132, 128, 125, 124, 122.5, 121.5, 120, 119.6, 119, 118.5, 118,\r\n      117.9, 113, 106, 104, 102, 99.5, 97.5, 96.6, 96.5,\r\n    ],\r\n    { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" },\r\n  );\r\n}\r\n\r\n/** The pitch as a multiple of the cell, which is what everything scales by. */\r\nexport function gridScale(t: number, fps = 30): number {\r\n  return pitch(t, fps) / CELL.w;\r\n}\r\n\r\n/**\r\n * The horizontal blur, in reference px.\r\n *\r\n * Measured as the frame's own horizontal gradient, which is what a smear\r\n * actually costs: 0.28 at frame 3, 1.90 at 4, 2.75 at 5, and then flat for ten\r\n * frames while it creeps to 3.18. So the blur is spent inside five frames and\r\n * the long ease that follows it is sharp.\r\n *\r\n * The first cut derived this from the pull-back's own speed, on the theory that\r\n * a blur and its motion should not be able to disagree. They can: the motion is\r\n * still shedding two pixels of pitch a frame at frame 8 and the reference is\r\n * already sharp there, so the derivative kept a smear on screen for seven\r\n * frames the reference does not have, and cost those frames 3 mean each.\r\n */\r\nexport function entryBlur(t: number, fps = 30): number {\r\n  return interpolate(t * fps, [0, 2, 3, 4, 5], [22, 14, 6, 2, 0], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n}\r\n\r\n/**\r\n * The one card that arrives late, in reference px of extra smear.\r\n *\r\n * The scene's own blur is spent by frame 5, but the card behind the label is\r\n * still a horizontal streak at 7 and only lands around 9 — every other card is\r\n * sharp and at scale by 5. It is the detail that makes the entry read as five\r\n * separate things arriving rather than one picture being pushed in, and it is\r\n * the only per-card timing in the piece.\r\n */\r\nexport const LATE_CARD: readonly [number, number] = [-1, 0];\r\n\r\nexport function lateBlur(t: number, fps = 30): number {\r\n  return interpolate(t * fps, [3, 5, 7, 9], [26, 17, 7, 0], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n}\r\n\r\n/** The label fading up, all of it at once. */\r\nexport function labelIn(t: number, fps = 30): number {\r\n  return interpolate(t * fps, [11, 13, 15, 17, 18], [0, 0.22, 0.55, 0.9, 1], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n}\r\n\r\n/**\r\n * How present a cell is.\r\n *\r\n * `ring` is the Chebyshev distance to the nearest seed cell, so the ring\r\n * touching the five arrives first and each one after it a frame later. That\r\n * ordering is measured: at frame 37 exactly two new columns exist, either side\r\n * of the original two, and by 38 there are eight.\r\n */\r\nexport function cellIn(ring: number, t: number, fps = 30): number {\r\n  if (ring === 0) return 1;\r\n  // Half a frame per ring and two frames each: the reference is 90% done in\r\n  // three frames — 20.3, 19.0, 19.8 mean change and then a decay — and a\r\n  // ring-per-frame stagger over three turned that into a five-frame ramp that\r\n  // peaked two frames after the reference had finished.\r\n  // The ramp *straddles* the switch frame rather than starting on it: at frame\r\n  // 37 the reference's first new columns are already half there — 80px wide\r\n  // against a settled 90 — so a ring that is still zero on 37 arrives a whole\r\n  // frame late and the change profile peaks two frames after the reference's.\r\n  //\r\n  // A whole frame of stagger, not half. On frame 37 the reference has ring one\r\n  // and nothing else; by 38 it has rings one and two, the second of them\r\n  // narrower than the first. Half a frame put ring two on screen a frame early\r\n  // and drew cards where the reference still had page.\r\n  const at = FILL_AT - 1 + (ring - 1);\r\n  return interpolate(t * fps, [at, at + 1.5], [0, 1], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n}\r\n\r\n/** Chebyshev distance from a cell to the nearest of the five. */\r\nexport function ringOf(col: number, row: number): number {\r\n  let best = Number.POSITIVE_INFINITY;\r\n  for (const [c, r] of SEED) {\r\n    best = Math.min(best, Math.max(Math.abs(col - c), Math.abs(row - r)));\r\n  }\r\n  return best;\r\n}\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Component\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\nexport interface CountGridProps {\r\n  /** What the label counts, before the grid fills and after. */\r\n  from?: string;\r\n  to?: string;\r\n  /** The noun after the number. */\r\n  noun?: string;\r\n  /** Card images, cycled across the grid. Anything `<Img>` can load. */\r\n  cards?: string[];\r\n  /** Defaults to the theme's `background`. */\r\n  background?: string;\r\n  /**\r\n   * The label's ink, left end and right end of its gradient. Default to\r\n   * `primary` walked halfway toward `foreground`, then `primary` — the navy →\r\n   * blue the reference had, but one that turns pale in dark mode instead of\r\n   * vanishing into it.\r\n   */\r\n  inkFrom?: string;\r\n  inkTo?: string;\r\n  theme?: Partial<KuchiTheme>;\r\n  mode?: \"light\" | \"dark\";\r\n  /** 1 is the measured speed. */\r\n  speed?: number;\r\n}\r\n\r\n/**\r\n * The card faces: frames out of kuchi's own showcase clips, and one still per\r\n * component in the registry — which is what the label is counting.\r\n *\r\n * Through `staticFile`, not as a bare path. A Remotion bundle copies the public\r\n * directory to `<bundle>/public/` and serves it from there, so a hard-coded\r\n * `/demos/posters/x.webp` is a 404 in every render while looking perfect in the\r\n * app — `staticFile` is what knows the difference. None of these live in\r\n * `public/` any more: a fresh install has no kuchi `public/`, so a relative\r\n * path there failed every render outside this repo. All of them are full URLs\r\n * on kuchi's media host; `staticFile` is only for a user's own relative paths.\r\n *\r\n * Both kinds on purpose. Eight frames alone tile visibly across forty cells;\r\n * the registry's stills alone are 16:9 scenes of dark text on white, and a 3:4\r\n * crop of one is a blank card. Interleaved they read the way a real library of\r\n * clips does — some motion, some interface — and land between the two on\r\n * weight, which is also where the reference's grid of portraits sits.\r\n */\r\nconst ART = [\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-08.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-08.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-05.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-10.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-10.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-05.svg\",\r\n];\r\nconst STILLS = [\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-04.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-03.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-03.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-05.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-04.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-04.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-06.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-01.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-06.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-01.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-07.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-04.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-01.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-04.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-09.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-01.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-04.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-05.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-12.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-10.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-03.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-03.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-10.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-10.svg\",\r\n];\r\n// `concat(...map)`, not `flatMap`: a stock Remotion project types against\r\n// ES2015, where `flatMap` does not exist and the install shows red.\r\nconst OWN_CARDS = ([] as string[])\r\n  .concat(...STILLS.map((s, i) => [ART[i % ART.length] as string, s]))\r\n  .map((f) => (f.startsWith(\"https://\") ? f : staticFile(f)));\r\n// index 0, 2, 4 … are ART by construction, and the five seed cells only ever\r\n// reach the first `SEED.length` of them.\r\n\r\n/**\r\n * A root-relative asset is a `public/` file. Only the site's own Player serves\r\n * it at that path; Remotion Studio and a render know its URL through\r\n * `staticFile()` alone — so every environment but the Player rewrites it.\r\n */\r\nfunction resolveSrc(src: string): string {\r\n  const isLocal = src.startsWith(\"/\") && !src.startsWith(\"//\");\r\n  if (!isLocal || getRemotionEnvironment().isPlayer) return src;\r\n  // A value that already came out of staticFile() carries the static base\r\n  // (`/static-<hash>/…`); running it through again would prefix it twice.\r\n  const base = staticFile(\"_\").slice(0, -2);\r\n  if (base && src.startsWith(`${base}/`)) return src;\r\n  try {\r\n    return staticFile(src.replace(/^\\/+/, \"\"));\r\n  } catch {\r\n    return src;\r\n  }\r\n}\r\n\r\nexport function CountGrid({\r\n  from = \"5\",\r\n  to = \"500\",\r\n  noun = \"clips\",\r\n  cards = OWN_CARDS,\r\n  background,\r\n  inkFrom,\r\n  inkTo,\r\n  speed = 1,\r\n  theme,\r\n  mode,\r\n}: CountGridProps) {\r\n  const t = useKuchiTheme(theme, mode);\r\n  const page = background ?? t.background;\r\n  const ink0 = inkFrom ?? mixOklch(t.primary, t.foreground, 0.5);\r\n  const ink1 = inkTo ?? t.primary;\r\n  // The card edge is half a hairline: forty full-strength borders read as a\r\n  // grid of boxes, not a wall of frames.\r\n  const cardEdge = mixOklch(t.card, t.border, 0.5);\r\n  const frame = useCurrentFrame();\r\n  const { fps, width, height } = useVideoConfig();\r\n  const now = frame / fps / (speed || 1);\r\n\r\n  const k = Math.min(width / REF_W, height / REF_H);\r\n  const ox = (width - REF_W * k) / 2;\r\n  const oy = (height - REF_H * k) / 2;\r\n\r\n  const s = gridScale(now, fps);\r\n  // The cards live one zoom step closer than everything else — see GRID_ZOOM.\r\n  const g = s * GRID_ZOOM;\r\n  const blur = entryBlur(now, fps) * k;\r\n  const late = lateBlur(now, fps) * k;\r\n  const label = labelIn(now, fps);\r\n\r\n  // Everything is laid out at scale 1 and then scaled about ORIGIN, so a cell's\r\n  // place in the grid never depends on the zoom — only its size does.\r\n  const at = (v: number, origin: number, scale = s) =>\r\n    (v - origin) * scale + origin;\r\n  // `cellW`/`cellH` stay in reference px — they are only ever compared against\r\n  // REF_W/REF_H to count how many cells reach the frame.\r\n  const cellW = CELL.w * g;\r\n  const cellH = CELL.h * g;\r\n  // The card's size is drawn, so it needs `k` — the same reference→render scale\r\n  // its own position already goes through. Without it the card was laid out in\r\n  // reference px inside a cell laid out in render px: 0.42 of its cell on a\r\n  // 1280-wide render instead of 0.95, which is every \"the images are too small\r\n  // and too far apart\" note in one bug.\r\n  const cardW = CARD.w * g * k;\r\n  const cardH = CARD.h * g * k;\r\n\r\n  // How many cells reach the frame at this scale, plus one so nothing pops in\r\n  // at the edge.\r\n  const cols = Math.ceil(REF_W / cellW / 2) + 2;\r\n  const rows = Math.ceil(REF_H / cellH / 2) + 2;\r\n\r\n  const cells: {\r\n    col: number;\r\n    row: number;\r\n    x: number;\r\n    y: number;\r\n    o: number;\r\n    i: number;\r\n    src: string;\r\n  }[] = [];\r\n  for (let row = -rows; row <= rows; row++) {\r\n    for (let col = -cols; col <= cols; col++) {\r\n      const o = cellIn(ringOf(col, row), now, fps);\r\n      if (o <= 0) continue;\r\n      const cx = at(COL_EDGE + (col + 0.5) * CELL.w, ORIGIN.x, g) * k + ox;\r\n      const cy = at(ROW_MID + row * CELL.h, ORIGIN.y, g) * k + oy;\r\n      if (cx < -cardW || cx > width + cardW) continue;\r\n      if (cy < -cardH || cy > height + cardH) continue;\r\n      // A stable, well-mixed index: neighbours must not share a card or the\r\n      // grid reads as wallpaper.\r\n      //\r\n      // `cards` alternates the two kinds, so its even slots are the ones with\r\n      // pictures on them. The five that carry the whole first half of the shot\r\n      // take only those; everything else takes the mix. Sharing one index put\r\n      // three of the five on registry stills — 16:9 scenes of dark text on\r\n      // white, cropped to 3:4 — and the hero moment was two blank cards and a\r\n      // label.\r\n      const mix = col * 7 + row * 13;\r\n      // `col * 2 + row` is the one small combination that is injective over the\r\n      // five seed cells modulo five — 7/13 sends (-1,-1) and (0,0) to the same\r\n      // slot, and the two cards diagonally across the label came out identical.\r\n      const seed = col * 2 + row;\r\n      const i =\r\n        ringOf(col, row) === 0\r\n          ? (2 * (((seed % SEED.length) + SEED.length) % SEED.length)) %\r\n            cards.length\r\n          : ((mix % cards.length) + cards.length) % cards.length;\r\n      cells.push({ col, row, x: cx, y: cy, o, i, src: cards[i] ?? \"\" });\r\n    }\r\n  }\r\n\r\n  // The grid cycles `cards`, so one card is drawn many times. Studio outlines\r\n  // the copy nearest the middle of the frame; the others are only pictures of\r\n  // it.\r\n  const nearest = new Map<number, (typeof cells)[number]>();\r\n  const off = (c: (typeof cells)[number]) =>\r\n    Math.hypot(c.x - width / 2, c.y - height / 2);\r\n  for (const c of cells) {\r\n    const held = nearest.get(c.i);\r\n    if (!held || off(c) < off(held)) nearest.set(c.i, c);\r\n  }\r\n\r\n  const filled = now * fps >= FILL_AT;\r\n  const pillH = LABEL.height * s * k;\r\n\r\n  return (\r\n    <AbsoluteFill\r\n      style={{\r\n        backgroundColor: page,\r\n        fontFamily: SANS,\r\n        overflow: \"hidden\",\r\n      }}\r\n    >\r\n      {/* A directional blur: the motion is horizontal, and CSS `blur()` is\r\n          round, so it softens the card's top and bottom edges — which are not\r\n          moving — as much as its sides. */}\r\n      <svg width={0} height={0} style={{ position: \"absolute\" }} aria-hidden>\r\n        <title>Motion blur</title>\r\n        <filter\r\n          id=\"count-grid-smear\"\r\n          x=\"-40%\"\r\n          y=\"-10%\"\r\n          width=\"180%\"\r\n          height=\"120%\"\r\n        >\r\n          <feGaussianBlur stdDeviation={`${blur} 0`} />\r\n        </filter>\r\n        <filter\r\n          id=\"count-grid-late\"\r\n          x=\"-90%\"\r\n          y=\"-10%\"\r\n          width=\"280%\"\r\n          height=\"120%\"\r\n        >\r\n          <feGaussianBlur stdDeviation={`${late} 0`} />\r\n        </filter>\r\n      </svg>\r\n\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          inset: 0,\r\n          filter: blur > 0.35 ? \"url(#count-grid-smear)\" : undefined,\r\n          ...(getRemotionEnvironment().isRendering\r\n            ? null\r\n            : { willChange: \"filter\" as const }),\r\n        }}\r\n      >\r\n        {cells.map((c) => (\r\n          <Item\r\n            key={`${c.col},${c.row}`}\r\n            index={c.i}\r\n            primary={nearest.get(c.i) === c}\r\n          >\r\n            <div\r\n              style={{\r\n                position: \"absolute\",\r\n                left: c.x - cardW / 2,\r\n                top: c.y - cardH / 2,\r\n                width: cardW,\r\n                height: cardH,\r\n                borderRadius: CARD.radius * g * k,\r\n                overflow: \"hidden\",\r\n                background: t.card,\r\n                // A hairline, not a shadow: a drop shadow under forty white\r\n                // tiles on a white page is forty grey smears.\r\n                boxShadow: `inset 0 0 0 ${Math.max(0.5, 0.9 * g * k)}px ${cardEdge}`,\r\n                display: \"flex\",\r\n                alignItems: \"center\",\r\n                opacity: c.o,\r\n                filter:\r\n                  late > 0.35 &&\r\n                  c.col === LATE_CARD[0] &&\r\n                  c.row === LATE_CARD[1]\r\n                    ? \"url(#count-grid-late)\"\r\n                    : undefined,\r\n              }}\r\n            >\r\n              {c.src ? (\r\n                <Img\r\n                  src={resolveSrc(c.src)}\r\n                  style={{\r\n                    width: cardW,\r\n                    height: cardH,\r\n                    // Preflight's `img { max-width: 100% }` against a box that\r\n                    // sizes from its content is 100% of nothing — the card\r\n                    // renders zero px wide on the site and perfectly in the mp4.\r\n                    maxWidth: \"none\",\r\n                    objectFit: \"cover\",\r\n                  }}\r\n                  alt=\"\"\r\n                />\r\n              ) : null}\r\n            </div>\r\n          </Item>\r\n        ))}\r\n      </div>\r\n\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: 0,\r\n          right: 0,\r\n          top: at(LABEL.cy, ORIGIN.y) * k + oy - pillH / 2,\r\n          display: \"flex\",\r\n          justifyContent: \"center\",\r\n          opacity: label,\r\n        }}\r\n      >\r\n        <div\r\n          style={{\r\n            display: \"flex\",\r\n            alignItems: \"center\",\r\n            height: pillH,\r\n            padding: `0 ${LABEL.padX * s * k}px`,\r\n            borderRadius: LABEL.radius * s * k,\r\n            background: t.card,\r\n            border: `1px solid ${t.border}`,\r\n            // Not a drop shadow: on a white page under a white pill it reads as\r\n            // a grey smear, and the reference has a hairline and nothing else.\r\n            boxShadow: \"none\",\r\n            fontSize: LABEL.size * s * k,\r\n            fontWeight: 400,\r\n            lineHeight: 1,\r\n            whiteSpace: \"nowrap\",\r\n            color: ink0,\r\n            textRendering: \"geometricPrecision\",\r\n          }}\r\n        >\r\n          <span\r\n            style={{\r\n              backgroundImage: `linear-gradient(90deg, ${ink0} 0%, ${ink1} 100%)`,\r\n              WebkitBackgroundClip: \"text\",\r\n              backgroundClip: \"text\",\r\n              color: \"transparent\",\r\n              paddingBottom: 0.14 * LABEL.size * s * k,\r\n            }}\r\n          >\r\n            {filled ? to : from} {noun}\r\n          </span>\r\n        </div>\r\n      </div>\r\n    </AbsoluteFill>\r\n  );\r\n}\r\n\r\nexport default CountGrid;\r\n"}]}