{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chevron-run",
  "title": "Chevron Run",
  "description": "A giant gradient chevron frames a big +312% with a serif caption underneath.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/chevron-run/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/BricolageGrotesque\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  interpolateColors,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadFont(\"normal\", {\n  weights: [\"500\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: serif } = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\nexport interface ChevronRunProps {\n  /** The figure that lands under the giant chevron. */\n  value?: string;\n  /** Serif italic line under the figure. */\n  caption?: string;\n  accent?: string;\n  /** Playback multiplier. */\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\n// Beat sheet (30fps, speed 1):\n//   0–50   a full-frame wall of up-chevrons races upward in staggered\n//          columns, speeding up until it smears\n//  48–74   column by column, from the centre out, three chevrons per column\n//          brake and lock into the giant chevron's band (taking its gradient)\n//          while the rest of the wall flies off\n//  72–86   the locked pieces fuse into one solid gradient chevron\n//  86–104  the figure drops into the cut-out under it, the caption follows\n// 104–     poster holds\nconst LOCK_AT = 48;\nconst LOCK_LEN = 14;\nconst FUSE_AT = 74;\nconst LAND_AT = 84;\n\nconst COLS = 13;\nconst ROWS = 15;\nconst BAND_ROWS = 3;\n\n// Every chevron (small and giant) shares this slope (dy/dx of an arm).\nconst SLOPE = 0.4;\n\n// gradients.sh \"fluted\" (bg #050507): #1d2a8f #2f7bff #ff7a3d #ffe2c4,\n// warm at the apex, deep blue down the arms.\nconst FLUTED = [\"#FFE2C4\", \"#FF7A3D\", \"#2F7BFF\", \"#1D2A8F\"];\nconst FLUTED_STOPS = [0, 0.3, 0.68, 1];\n\nconst THEMES = {\n  dark: {\n    bg: \"#08080A\",\n    fg: \"#F4F3F0\",\n    muted: \"#9A99A0\",\n    wall: 0.42,\n    fluted: FLUTED,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#6E6C68\",\n    wall: 0.5,\n    // the cream apex would melt into the paper; start a step warmer\n    fluted: [\"#FFA05E\", \"#FF7A3D\", \"#2F7BFF\", \"#1D2A8F\"],\n  },\n} as const;\n\nconst hash = (n: number) => {\n  const x = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n  return x - Math.floor(x);\n};\n\n/** Chevron \"^\" band: apex at (x, y), half-width a, vertical thickness th. */\nconst chevronPath = (x: number, y: number, a: number, th: number) => {\n  const h = a * SLOPE;\n  return `M ${x} ${y} L ${x + a} ${y + h} L ${x + a} ${y + h + th} L ${x} ${y + th} L ${x - a} ${y + h + th} L ${x - a} ${y + h} Z`;\n};\n\nexport function ChevronRun({\n  value = \"+312%\",\n  caption = \"growth since launch\",\n  accent = \"#3B5BFD\",\n  speed = 1,\n  theme = \"dark\",\n}: ChevronRunProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const p = THEMES[theme];\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  // ---- the giant chevron ---------------------------------------------------\n  const cx = W / 2;\n  const apexY = H * 0.07;\n  const T = H * 0.24;\n  const outerY = (x: number) => apexY + Math.abs(x - cx) * SLOPE;\n  const innerApexY = apexY + T;\n  const giantA = W * 0.75;\n  const gradY0 = apexY;\n  const gradY1 = apexY + (W / 2) * SLOPE + T;\n  const gradAt = (y: number) =>\n    interpolateColors(\n      Math.max(0, Math.min(1, (y - gradY0) / (gradY1 - gradY0))),\n      FLUTED_STOPS,\n      p.fluted,\n    );\n\n  // ---- the wall --------------------------------------------------------------\n  const colStep = W / (COLS - 1);\n  const rowStep = H * 0.078;\n  const L = ROWS * rowStep;\n  const a = colStep * 0.41;\n  const th = H * 0.025;\n  // distance travelled by the wall: a speed ramp, capped once the lock is done\n  const travel = (tt: number) => {\n    const x = Math.max(0, tt);\n    return (3.2 * x + 0.3 * x * x) * u;\n  };\n  const vel = (tt: number) => (travel(tt + 0.5) - travel(tt - 0.5)) / u;\n  const lockStart = (c: number) => LOCK_AT + Math.abs(c - (COLS - 1) / 2) * 1.3;\n  const fuse = interpolate(t, [FUSE_AT, FUSE_AT + 12], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const blurBase = Math.min(9 * u, vel(Math.min(t, LOCK_AT + 10)) * 0.28 * u);\n\n  const streamY = (c: number, k: number, tt: number) => {\n    const mult = 0.86 + 0.28 * hash(c * 7.3);\n    const phase = hash(c * 3.1 + 1) * rowStep + (c % 2) * rowStep * 0.5;\n    const y0 = k * rowStep + phase;\n    const y = (((y0 - travel(tt) * mult) % L) + L) % L;\n    return y - rowStep * 1.2;\n  };\n\n  const runners: React.ReactNode[] = [];\n  const lockers: React.ReactNode[] = [];\n  for (let c = 0; c < COLS; c++) {\n    const x = c * colStep;\n    const tL = lockStart(c);\n    const band = outerY(x);\n    // per target row, the wall chevron just below it at the lock moment\n    const taken = new Set<number>();\n    const picks: Array<{ k: number; y0: number; ty: number }> = [];\n    for (let r = 0; r < BAND_ROWS; r++) {\n      const ty = band + (T * (r + 0.18)) / BAND_ROWS;\n      let best = -1;\n      let bestD = Number.POSITIVE_INFINITY;\n      for (let k = 0; k < ROWS; k++) {\n        if (taken.has(k)) continue;\n        const d = streamY(c, k, tL) - ty;\n        if (d >= -rowStep * 0.25 && d < bestD) {\n          bestD = d;\n          best = k;\n        }\n      }\n      if (best >= 0) {\n        taken.add(best);\n        picks.push({ k: best, y0: streamY(c, best, tL), ty });\n      }\n    }\n    for (let k = 0; k < ROWS; k++) {\n      const pick = picks.find((q) => q.k === k);\n      const tone = 0.35 + 0.65 * hash(c * 13.7 + k * 3.3);\n      const isAccent = hash(c * 5.1 + k * 9.7) > 0.9;\n      if (pick && t >= tL) {\n        const e = EASE_OUT(Math.max(0, Math.min(1, (t - tL) / LOCK_LEN)));\n        const y = pick.y0 + (pick.ty - pick.y0) * e;\n        const tint = interpolate(t, [tL, tL + LOCK_LEN], [0, 1], CLAMP);\n        const grow = 1 + 0.42 * fuse;\n        lockers.push(\n          <path\n            key={`l${c}-${k}`}\n            d={chevronPath(x, y, a * grow, th * (1 + 1.6 * fuse))}\n            fill={interpolateColors(\n              tint,\n              [0, 1],\n              [isAccent ? accent : p.fg, gradAt(y + th)],\n            )}\n            opacity={\n              (isAccent ? 1 : p.wall * tone) +\n              (1 - (isAccent ? 1 : p.wall * tone)) * tint\n            }\n          />,\n        );\n        continue;\n      }\n      const y = streamY(c, k, t);\n      // the rest of the wall clears out once its column has locked\n      const leave = interpolate(t, [tL - 2, tL + 10], [1, 0], CLAMP);\n      if (leave <= 0 || y < -rowStep * 1.2 || y > H + rowStep) continue;\n      runners.push(\n        <path\n          key={`r${c}-${k}`}\n          d={chevronPath(x, y, a, th)}\n          fill={isAccent ? accent : p.fg}\n          opacity={leave * (isAccent ? 0.95 : p.wall * tone)}\n        />,\n      );\n    }\n  }\n\n  // ---- the figure -----------------------------------------------------------\n  const yBase = H * 0.8;\n  const capH = 0.66;\n  const textEm = 2.86;\n  const F = Math.min(\n    ((yBase - innerApexY) / SLOPE - 0.12 * W) / (textEm / 2 + capH / SLOPE),\n    (W * 0.7) / textEm,\n  );\n  const land = interpolate(t, [LAND_AT, LAND_AT + 14], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const capIn = interpolate(t, [LAND_AT + 8, LAND_AT + 24], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const solid = interpolate(t, [FUSE_AT + 2, FUSE_AT + 12], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const settle = interpolate(t, [FUSE_AT, FUSE_AT + 20], [0.985, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const drift = interpolate(t, [FUSE_AT, 150], [0, 1], CLAMP);\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      <svg\n        width={W}\n        height={H}\n        viewBox={`0 0 ${W} ${H}`}\n        style={{ position: \"absolute\", inset: 0 }}\n        role=\"img\"\n        aria-label={`${value} ${caption}`}\n      >\n        <defs>\n          <filter\n            id={`${uid}smear`}\n            filterUnits=\"userSpaceOnUse\"\n            x={0}\n            y={-H * 0.2}\n            width={W}\n            height={H * 1.4}\n          >\n            <feGaussianBlur stdDeviation={`0 ${blurBase.toFixed(2)}`} />\n          </filter>\n          <linearGradient\n            id={`${uid}fluted`}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={cx + W * 0.025 * drift}\n            y1={gradY0}\n            x2={cx - W * 0.025 * drift}\n            y2={gradY1}\n          >\n            {p.fluted.map((c, i) => (\n              <stop key={c} offset={FLUTED_STOPS[i]} stopColor={c} />\n            ))}\n          </linearGradient>\n          <clipPath id={`${uid}giant`}>\n            <path d={chevronPath(cx, apexY, giantA, T)} />\n          </clipPath>\n        </defs>\n\n        <g filter={blurBase > 0.3 ? `url(#${uid}smear)` : undefined}>\n          {runners}\n        </g>\n        {/* once fusing, the pieces are held inside the giant's outline */}\n        <g\n          opacity={1 - solid}\n          clipPath={fuse > 0 ? `url(#${uid}giant)` : undefined}\n        >\n          {lockers}\n        </g>\n        <path\n          d={chevronPath(cx, apexY, giantA, T)}\n          fill={`url(#${uid}fluted)`}\n          opacity={solid}\n          transform={`translate(${cx} ${apexY + T}) scale(${settle}) translate(${-cx} ${-(apexY + T)})`}\n        />\n      </svg>\n\n      {/* the figure drops into the cut-out */}\n      <div\n        style={{\n          position: \"absolute\",\n          left: 0,\n          right: 0,\n          top: yBase - F * 0.86,\n          textAlign: \"center\",\n          fontFamily: display,\n          fontWeight: 500,\n          fontSize: F,\n          lineHeight: 1,\n          letterSpacing: \"-0.035em\",\n          color: p.fg,\n          opacity: Math.min(1, land * 1.8),\n          transform: `translateY(${(1 - land) * -0.28 * F}px)`,\n          whiteSpace: \"nowrap\",\n        }}\n      >\n        {value}\n      </div>\n      <div\n        style={{\n          position: \"absolute\",\n          left: 0,\n          right: 0,\n          top: yBase + 0.16 * F,\n          textAlign: \"center\",\n          fontFamily: serif,\n          fontStyle: \"italic\",\n          fontWeight: 400,\n          fontSize: 46 * u,\n          lineHeight: 1,\n          letterSpacing: \"-0.01em\",\n          color: p.fg,\n          opacity: capIn * 0.78,\n          transform: `translateY(${(1 - capIn) * 12 * u}px)`,\n        }}\n      >\n        {caption}\n      </div>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/chevron-run.tsx"
    }
  ],
  "type": "registry:component"
}
