{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "title-converge",
  "title": "Title Converge",
  "description": "Each letter drifts in on its own path and converges into the logo between two rules.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/title-converge/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Manrope\";\nimport { useId, useMemo } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadFont(\"normal\", {\n  weights: [\"500\", \"600\"],\n  subsets: [\"latin\"],\n});\n\nexport interface TitleConvergeProps {\n  /**\n   * Short word. Each letter drifts in on its own path. \"remocn\" (any case)\n   * is set as the real logo: the R mark followed by \"emocn\".\n   */\n  word?: string;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\n/** Manrope 500 advance widths (per mille) for ASCII 32–126. */\nconst ADV = [\n  200, 329, 417, 924, 602, 901, 657, 229, 435, 435, 446, 575, 278, 420, 270,\n  402, 626, 406, 578, 562, 596, 580, 621, 512, 591, 621, 314, 318, 622, 750,\n  622, 534, 907, 646, 619, 723, 681, 575, 510, 714, 697, 249, 476, 612, 518,\n  846, 696, 732, 616, 732, 640, 630, 600, 708, 616, 949, 622, 574, 630, 412,\n  402, 412, 673, 660, 506, 562, 600, 561, 600, 590, 362, 600, 604, 249, 263,\n  510, 249, 865, 604, 600, 600, 600, 374, 530, 412, 604, 523, 779, 536, 538,\n  531, 430, 269, 430, 680,\n];\n/** Manrope 500 letter kerning: \"AT60\" = A then T, -60/1000 em (\"+\" widens). */\nconst KERN = new Map<string, number>();\nfor (const tok of [\n  \"AA+35 AT60 AV70 AW70 AY60 Av40 Aw40 Ay50 BV30 BW30 BX30 BY30 CS+30\",\n  \"CX30 CY30 DV30 DW30 DX30 DY30 EG30 EO30 EQ30 GV30 GW30 GX30 GY30 IY40\",\n  \"KG35 KO35 KQ30 KS30 Kc40 Kd40 Ke40 Kg30 Ko40 Kq35 Kt31 Ku35 Ky45 LT100\",\n  \"LV80 LW80 LY100 Lv35 Lw35 Ly50 OV30 OW30 OX50 OY30 PA50 PX30 Pf+40\",\n  \"QV30 QW30 QX30 QY30 SX30 SY30 TJ80 TT+60 TY+30 Ta70 Tc80 Td80 Te80\",\n  \"Tg80 Tm50 Tn50 To80 Tp50 Tq80 Tr50 Ts60 Tu50 Tv60 Tw60 Tx70 Ty70 Tz60\",\n  \"UA30 US30 VA70 VJ30 Va45 Vc60 Vd60 Ve60 Vg45 Vm30 Vn30 Vo60 Vp30 Vq45\",\n  \"Vs30 Vu30 Vv30 Vw30 Vx30 WA70 WJ30 Wa45 Wc60 Wd60 We60 Wg45 Wm30 Wn30\",\n  \"Wo60 Wp30 Wq45 Ws30 Wu30 Wv30 Ww30 Wx30 XC30 XG30 XO30 XQ30 XT+40 YA70\",\n  \"YC40 YG40 YJ80 YO40 YQ40 YS30 YT+30 YY+31 Ya80 Yc80 Yd80 Ye80 Yg80\",\n  \"Ym50 Yn50 Yo80 Yp50 Yq80 Yr40 Ys80 Yu40 Yv35 Yw35 Yx30 Yy35 Yz35 ZT+40\",\n  \"Zv60 Zw60 aT60 aV30 aW30 aY60 ay30 bT60 bV30 bW30 bY80 by30 cT60 cV30\",\n  \"cW30 cY60 dY40 eT60 eV30 eW30 eY60 fI+31 fT+60 fb+31 fh+31 fk+31 gT50\",\n  \"gY50 hT60 kq30 mT60 mY70 nT60 nY70 oT60 oV30 oW30 oY80 pT60 pV30 pW30\",\n  \"pY80 qY40 sT50 sV30 sW30 sY60 uY40 vT60 vY35 va30 wT60 wY35 wa30 xT50\",\n  \"xY30 yT40 yY35 yf+40 yt+40 zT50 zY35 za30 zc40 zd40 ze40 zo40 zq30\",\n]\n  .join(\" \")\n  .split(\" \")) {\n  const m = /^(.)(.)(\\+?)(\\d+)$/.exec(tok);\n  if (m) KERN.set(m[1] + m[2], ((m[3] ? 1 : -1) * Number(m[4])) / 1000);\n}\nconst TRACK = -0.03;\nconst CAP = 0.72;\nconst ASCENDER = 0.75;\nconst X_HEIGHT = 0.54;\n\n/** The real remocn \"R\" mark (viewBox 124.06 × 134.26). */\nconst REMOCN_R_PATH =\n  \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n/** As on remocn.dev: the mark is 0.76em tall and sits 0.04em before \"emocn\". */\nconst MARK_H = 0.76;\nconst MARK_W = (MARK_H * 124.06) / 134.26;\nconst MARK_GAP = 0.04;\n/**\n * The logo word is the brand asset, so it keeps the logo's Manrope 600,\n * -0.025em tracking and kerning; every other word is set in Manrope 500.\n */\nconst LOGO_ADV: Record<string, number> = {\n  e: 0.596,\n  m: 0.882,\n  o: 0.61,\n  c: 0.568,\n  n: 0.615,\n};\nconst LOGO_KERN: Record<string, number> = { em: -0.015, mo: -0.006 };\nconst LOGO_TRACK = -0.025;\n\n/** Frame the camera finishes easing out and the last letter locks. */\nconst LOCK = 128;\nconst RULES = 116;\n\nconst DRIFT = Easing.bezier(0.3, 0.3, 0.2, 1);\nconst CAMERA = Easing.bezier(0.4, 0, 0.3, 1);\nconst SLIDE = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\n// Fill gradients: gradients.sh \"beam\" on dark, its deep end on light.\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    fill: [\"#F4F7FF\", \"#B9CCFF\", \"#7E9BFF\", \"#4F6BFF\"],\n    grain: 0.07,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    fill: [\"#1A1660\", \"#2B2FA8\", \"#3D5BFF\", \"#6A6BF0\"],\n    grain: 0.045,\n  },\n} as const;\n\nfunction hash(i: number, salt: number) {\n  const s = Math.sin(i * 127.1 + salt * 311.7) * 43758.5453;\n  return s - Math.floor(s);\n}\n\nfunction advance(ch: string) {\n  const code = ch.charCodeAt(0);\n  return (code >= 32 && code < 127 ? ADV[code - 32] : 620) / 1000;\n}\n\nfunction heightOf(ch: string) {\n  if (/[A-Z0-9]/.test(ch)) return CAP;\n  if (/[bdfhklt]/.test(ch)) return ASCENDER;\n  return X_HEIGHT;\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n  const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  return (\n    <svg\n      width=\"100%\"\n      height=\"100%\"\n      style={{ position: \"absolute\", inset: 0, opacity, pointerEvents: \"none\" }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={23}\n          stitchTiles=\"stitch\"\n        />\n        <feColorMatrix values=\"0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0\" />\n      </filter>\n      <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n    </svg>\n  );\n}\n\ninterface Letter {\n  ch: string;\n  mark: boolean;\n  left: number;\n  width: number;\n}\n\nexport function TitleConverge({\n  word = \"remocn\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: TitleConvergeProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const c = THEMES[theme];\n\n  // Kerned layout in em. The logo word swaps its \"r\" for the R mark.\n  const layout = useMemo(() => {\n    const isLogo = word.trim().toLowerCase() === \"remocn\";\n    const chars = Array.from(isLogo ? \"Remocn\" : word);\n    const letters: Letter[] = [];\n    let x = 0;\n    let top = 0;\n    chars.forEach((ch, i) => {\n      const mark = isLogo && i === 0;\n      const pair = chars[i - 1] + ch;\n      if (i > 0 && !letters[i - 1].mark) {\n        x += (isLogo ? LOGO_KERN[pair] : KERN.get(pair)) ?? 0;\n      }\n      const width = mark\n        ? MARK_W\n        : isLogo\n          ? (LOGO_ADV[ch] ?? advance(ch))\n          : advance(ch);\n      letters.push({ ch, mark, left: x, width });\n      top = Math.max(top, mark ? MARK_H : heightOf(ch));\n      const track = i < chars.length - 1 ? (isLogo ? LOGO_TRACK : TRACK) : 0;\n      x += mark ? MARK_W + MARK_GAP : width + track;\n    });\n    return { letters, total: x, top, weight: isLogo ? 600 : 500 };\n  }, [word]);\n  const { letters } = layout;\n  const n = letters.length;\n\n  const F = Math.min((W * 0.66) / layout.total, (H * 0.32) / layout.top);\n  const half = (layout.total * F) / 2;\n  const left = (i: number) => letters[i].left * F - half;\n  const topH = layout.top * F;\n  const baseline = topH / 2;\n\n  // Each letter: a straight path in from off-frame, its own length and speed.\n  const paths = useMemo(\n    () =>\n      letters.map((_, i) => {\n        const side = n === 1 ? 0 : (i / (n - 1)) * 2 - 1;\n        const vertical = i % 2 === 0 ? -1 : 1;\n        const outer = Math.abs(side);\n        const dx = side * (0.12 + outer * 0.6 + hash(i, 1) * 0.15);\n        const dy = vertical * (0.2 + hash(i, 2) * 0.18 + outer * 0.25);\n        return {\n          dx,\n          dy,\n          end: LOCK - 30 + outer * 26 + hash(i, 3) * 6,\n        };\n      }),\n    [letters, n],\n  );\n\n  const s0 = 5;\n  const cam = interpolate(t, [0, LOCK], [0, 1], { ...CLAMP, easing: CAMERA });\n  const push = interpolate(t, [LOCK, LOCK + 70], [0, 1], CLAMP);\n  const s = Math.exp(Math.log(s0) * (1 - cam)) * (1 + push * 0.014);\n  // Start framed on the middle of the word, a touch above centre.\n  const focusY = -topH * 0.12 * (1 - cam);\n\n  const ruleGap = topH * 0.34;\n  const ruleH = Math.max(1.5, 2.5 * u);\n  const ruleW = layout.total * F + 0.02 * F;\n  const slide = (d: number) =>\n    interpolate(t, [RULES + d, RULES + d + 26], [0, 1], {\n      ...CLAMP,\n      easing: SLIDE,\n    });\n  const topIn = slide(0);\n  const bottomIn = slide(5);\n  const travel = W / (2 * s) + ruleW / 2 + 8 * u;\n  const uid = `tc${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n\n  // The fill gradient lives in word space and turns a few degrees over the\n  // shot; letters drift through it and lock into one continuous sweep.\n  const angle = ((-16 + t * 0.05) * Math.PI) / 180;\n  const reach = half * 1.08;\n  const gx = Math.cos(angle) * reach;\n  const gy = Math.sin(angle) * reach;\n  const markScale = (MARK_H * F) / 134.26;\n\n  return (\n    <AbsoluteFill style={{ background: c.bg, overflow: \"hidden\" }}>\n      <svg\n        width={W}\n        height={H}\n        viewBox={`0 0 ${W} ${H}`}\n        style={{ position: \"absolute\", inset: 0 }}\n        aria-hidden\n      >\n        <g transform={`translate(${W / 2} ${H / 2}) scale(${s})`}>\n          <g transform={`translate(0 ${-focusY})`}>\n            {letters.map((l, i) => {\n              const p = paths[i];\n              const k = DRIFT(Math.min(1, Math.max(0, t / p.end)));\n              const off = (1 - k) * F;\n              const ox = left(i) + p.dx * off;\n              const oy = baseline + p.dy * off;\n              const flood = interpolate(t, [p.end - 16, p.end + 2], [0, 1], {\n                ...CLAMP,\n                easing: Easing.bezier(0.45, 0, 0.25, 1),\n              });\n              const line = interpolate(t, [p.end, p.end + 10], [1, 0], CLAMP);\n              const glyphTop = -(l.mark ? MARK_H : heightOf(l.ch)) * F;\n              const top = glyphTop - 0.04 * F;\n              const bottom = 0.04 * F;\n              const edge = bottom + (top - bottom) * flood;\n              const shape = (props: Record<string, string | number>) =>\n                l.mark ? (\n                  <path\n                    d={REMOCN_R_PATH}\n                    transform={`translate(0 ${-MARK_H * F}) scale(${markScale})`}\n                    {...props}\n                    strokeWidth={\n                      props.strokeWidth\n                        ? Number(props.strokeWidth) / markScale\n                        : undefined\n                    }\n                  />\n                ) : (\n                  <text\n                    x={0}\n                    y={0}\n                    fontFamily={display}\n                    fontWeight={layout.weight}\n                    fontSize={F}\n                    style={{ fontKerning: \"none\" }}\n                    {...props}\n                  >\n                    {l.ch}\n                  </text>\n                );\n              return (\n                <g key={`${i}-${l.ch}`} transform={`translate(${ox} ${oy})`}>\n                  <defs>\n                    <linearGradient\n                      id={`${uid}-f${i}`}\n                      gradientUnits=\"userSpaceOnUse\"\n                      x1={-gx - ox}\n                      y1={-gy - oy}\n                      x2={gx - ox}\n                      y2={gy - oy}\n                    >\n                      {c.fill.map((col, j) => (\n                        <stop\n                          key={col}\n                          offset={j / (c.fill.length - 1)}\n                          stopColor={col}\n                        />\n                      ))}\n                    </linearGradient>\n                    <clipPath id={`${uid}-${i}`}>\n                      <rect\n                        x={-0.2 * F}\n                        y={edge}\n                        width={F * 1.6}\n                        height={Math.max(0, bottom - edge)}\n                      />\n                    </clipPath>\n                  </defs>\n                  {line > 0 ? (\n                    <>\n                      {/* Outline of the glyph's union: the variable font's\n                          overlapping contours would show inside a plain stroke. */}\n                      <mask\n                        id={`${uid}-m${i}`}\n                        maskUnits=\"userSpaceOnUse\"\n                        x={-F}\n                        y={-2 * F}\n                        width={3 * F}\n                        height={3 * F}\n                      >\n                        {shape({\n                          fill: \"black\",\n                          stroke: \"white\",\n                          strokeWidth: (3 * u) / s,\n                          strokeLinejoin: \"miter\",\n                          paintOrder: \"stroke\",\n                        })}\n                      </mask>\n                      <rect\n                        x={-F}\n                        y={-2 * F}\n                        width={3 * F}\n                        height={3 * F}\n                        fill={c.fg}\n                        opacity={line * 0.9}\n                        mask={`url(#${uid}-m${i})`}\n                      />\n                    </>\n                  ) : null}\n                  {flood > 0 ? (\n                    <g clipPath={`url(#${uid}-${i})`}>\n                      {shape({ fill: `url(#${uid}-f${i})` })}\n                    </g>\n                  ) : null}\n                </g>\n              );\n            })}\n            <rect\n              x={-ruleW / 2 - (1 - topIn) * travel}\n              y={-topH + baseline - ruleGap - ruleH / s}\n              width={ruleW}\n              height={ruleH / s}\n              fill={accent}\n            />\n            <rect\n              x={-ruleW / 2 + (1 - bottomIn) * travel}\n              y={baseline + ruleGap}\n              width={ruleW}\n              height={ruleH / s}\n              fill={accent}\n            />\n          </g>\n        </g>\n      </svg>\n      <Grain opacity={c.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/title-converge.tsx"
    }
  ],
  "type": "registry:component"
}
