{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ripple-mark",
  "title": "Ripple Mark",
  "description": "Dots ripple across the frame and assemble the Remocn logo.",
  "dependencies": ["remotion", "@remotion/google-fonts", "@remotion/paths"],
  "files": [
    {
      "path": "registry/remocn/ripple-mark/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { getLength, getPointAtLength, getSubpaths } from \"@remotion/paths\";\nimport { useId, useMemo } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\n// Manrope is the remocn.dev brand face: 600 for the logo's \"emocn\" (the brand\n// asset), 500 for any other name set next to a custom mark.\nconst { fontFamily: manrope } = loadManrope(\"normal\", {\n  weights: [\"500\", \"600\"],\n  subsets: [\"latin\"],\n});\n\nexport interface RippleMarkProps {\n  logo?: string | string[];\n  name?: string;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\n// The real remocn.dev \"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\nconst DEFAULT_MARK = [REMOCN_R_PATH];\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst GROW = Easing.bezier(0.34, 1.32, 0.64, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    dot: \"#E8E7EA\",\n    dotAlpha: 0.42,\n    light: \"rgba(255,255,255,0.05)\",\n    grain: 0.06,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    dot: \"#2A2A2E\",\n    dotAlpha: 0.34,\n    light: \"rgba(255,255,255,0.8)\",\n    grain: 0.045,\n  },\n} as const;\n\n// gradients.sh \"beam\" across the lit mark: bright top-left into the brand blue.\nconst BEAM = [\"#f4f7ff\", \"#8fb4ff\", \"#3d5bff\", \"#1a1660\"];\nfunction ramp(stops: string[], n: number) {\n  return Array.from({ length: n }, (_, i) => {\n    const k = (i / (n - 1)) * (stops.length - 1);\n    const j = Math.min(stops.length - 2, Math.floor(k));\n    const f = k - j;\n    const a = Number.parseInt(stops[j].slice(1), 16);\n    const b = Number.parseInt(stops[j + 1].slice(1), 16);\n    const ch = (sh: number) =>\n      Math.round(((a >> sh) & 255) * (1 - f) + ((b >> sh) & 255) * f)\n        .toString(16)\n        .padStart(2, \"0\");\n    return `#${ch(16)}${ch(8)}${ch(0)}`;\n  });\n}\nconst LIT_STEPS = 8;\n\nconst RIPPLE_AT = 7;\nconst PAN_AT = 46;\nconst PAN_DUR = 30;\nconst WORD_AT = 56;\nconst BUCKETS = 5;\n\n// Manrope advance widths (per 1000 em) for ASCII 32–126, extracted offline.\nconst MANROPE_600 = [\n  200, 344, 442, 928, 615, 900, 662, 244, 444, 444, 456, 574, 290, 420, 286,\n  418, 642, 422, 587, 572, 602, 584, 622, 523, 602, 622, 328, 330, 630, 750,\n  630, 544, 910, 658, 625, 730, 690, 580, 516, 723, 710, 264, 488, 630, 526,\n  850, 706, 740, 627, 740, 650, 644, 604, 714, 628, 962, 639, 593, 647, 418,\n  418, 418, 676, 660, 522, 570, 608, 568, 608, 596, 370, 608, 615, 264, 276,\n  524, 264, 882, 615, 610, 608, 608, 386, 536, 422, 615, 538, 790, 545, 548,\n  532, 439, 284, 439, 698,\n];\nconst MANROPE_500 = [\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\n// Manrope in a line-height: 1 box: baseline sits 0.883em below the top.\nconst BASELINE = 0.883;\n\nfunction textWidth(text: string, size: number, tracking: number, w: number[]) {\n  let em = 0;\n  const chars = Array.from(text);\n  chars.forEach((ch, i) => {\n    const code = ch.charCodeAt(0);\n    em += (code >= 32 && code < 127 ? w[code - 32] : 600) / 1000;\n    if (i < chars.length - 1) em += tracking;\n  });\n  return em * size;\n}\n\ntype Poly = [number, number][];\n\nfunction insideEvenOdd(px: number, py: number, polys: Poly[]) {\n  let inside = false;\n  for (const poly of polys) {\n    for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {\n      const [xi, yi] = poly[i];\n      const [xj, yj] = poly[j];\n      if (\n        yi > py !== yj > py &&\n        px < ((xj - xi) * (py - yi)) / (yj - yi) + xi\n      ) {\n        inside = !inside;\n      }\n    }\n  }\n  return inside;\n}\n\nfunction flattenLogo(paths: string[]) {\n  const parts = paths.map((d) => {\n    const polys: Poly[] = [];\n    for (const sub of getSubpaths(d)) {\n      const len = getLength(sub);\n      if (len <= 0) continue;\n      const n = Math.max(24, Math.min(600, Math.ceil(len * 4)));\n      const poly: Poly = [];\n      for (let i = 0; i <= n; i++) {\n        const p = getPointAtLength(sub, (len * i) / n);\n        if (p) poly.push([p.x, p.y]);\n      }\n      polys.push(poly);\n    }\n    return polys;\n  });\n  let minX = Number.POSITIVE_INFINITY;\n  let minY = Number.POSITIVE_INFINITY;\n  let maxX = Number.NEGATIVE_INFINITY;\n  let maxY = Number.NEGATIVE_INFINITY;\n  for (const polys of parts) {\n    for (const poly of polys) {\n      for (const [x, y] of poly) {\n        minX = Math.min(minX, x);\n        minY = Math.min(minY, y);\n        maxX = Math.max(maxX, x);\n        maxY = Math.max(maxY, y);\n      }\n    }\n  }\n  return { parts, minX, minY, w: maxX - minX || 1, h: maxY - minY || 1 };\n}\n\nexport function RippleMark({\n  logo,\n  name = \"remocn\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: RippleMarkProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const pal = THEMES[theme];\n\n  const paths = useMemo(\n    () => (logo ? (Array.isArray(logo) ? logo : [logo]) : DEFAULT_MARK),\n    [logo],\n  );\n  const shape = useMemo(() => flattenLogo(paths), [paths]);\n\n  // Fine pitch so the R's strokes read three to four dots thick.\n  const pitch = H / 80;\n  const markH = H * 0.245;\n  const scale = markH / shape.h;\n  const markW = shape.w * scale;\n  // Default mark + \"remocn\" is the real logo: the R stands in for the first\n  // letter, \"emocn\" follows in Manrope 600 with the R 0.76em tall on the\n  // baseline. Any other name is set beside the mark in Manrope 500.\n  const brand = !logo && name.trim().toLowerCase() === \"remocn\";\n  const word = brand ? \"emocn\" : name;\n  const fontSize = brand ? markH / 0.76 : (markH * 0.46) / 0.54;\n  const weight = brand ? 600 : 500;\n  const tracking = brand ? -0.025 : -0.02;\n  const wordW = word\n    ? textWidth(word, fontSize, tracking, brand ? MANROPE_600 : MANROPE_500)\n    : 0;\n  const gap = word ? (brand ? fontSize * 0.07 : markH * 0.28) : 0;\n  const groupW = markW + gap + wordW;\n  const pan = word ? W / 2 - markW / 2 - (W - groupW) / 2 : 0;\n\n  const ox = W / 2;\n  const oy = H / 2;\n  const markLeft = ox - markW / 2;\n  const markTop = oy - markH / 2;\n\n  const grid = useMemo(() => {\n    const c0 = Math.floor((-pitch * 2 - ox) / pitch);\n    const c1 = Math.ceil((W + pan + pitch * 2 - ox) / pitch);\n    const r0 = Math.floor((-pitch * 2 - oy) / pitch);\n    const r1 = Math.ceil((H + pitch * 2 - oy) / pitch);\n    const out: { x: number; y: number; d: number; cov: number }[] = [];\n    const S = 4;\n    for (let r = r0; r <= r1; r++) {\n      for (let c = c0; c <= c1; c++) {\n        const x = ox + (c + 0.5) * pitch;\n        const y = oy + (r + 0.5) * pitch;\n        let cov = 0;\n        if (\n          x > markLeft - pitch &&\n          x < markLeft + markW + pitch &&\n          y > markTop - pitch &&\n          y < markTop + markH + pitch\n        ) {\n          let hits = 0;\n          for (let i = 0; i < S; i++) {\n            for (let j = 0; j < S; j++) {\n              const sx = x + ((i + 0.5) / S - 0.5) * pitch;\n              const sy = y + ((j + 0.5) / S - 0.5) * pitch;\n              const lx = (sx - markLeft) / scale + shape.minX;\n              const ly = (sy - markTop) / scale + shape.minY;\n              if (shape.parts.some((polys) => insideEvenOdd(lx, ly, polys)))\n                hits++;\n            }\n          }\n          cov = hits / (S * S);\n        }\n        out.push({ x, y, d: Math.hypot(x - ox, y - oy), cov });\n      }\n    }\n    return out;\n  }, [pitch, ox, oy, W, H, pan, markLeft, markTop, markW, markH, scale, shape]);\n\n  const v = 13 * u;\n  const panE = EASE_IO(\n    interpolate(t, [PAN_AT, PAN_AT + PAN_DUR], [0, 1], CLAMP),\n  );\n  const px = -pan * panE;\n  const r0 = pitch * 0.15;\n  const rOut = pitch * 0.09;\n  const rIn = pitch * 0.47;\n  const pre = interpolate(t, [0, RIPPLE_AT, RIPPLE_AT + 6], [0, 1, 0], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const reach = Math.hypot(W + pan, H) * 0.75;\n\n  const neutral: string[][] = Array.from({ length: BUCKETS }, () => []);\n  // key runs 1 (top-left) → 0 (bottom-right); buckets are indexed by key.\n  // The palette's mid blue is swapped for the accent so the mark stays on brand.\n  const LITC = useMemo(\n    () =>\n      theme === \"light\"\n        ? ramp([BEAM[3], accent, accent, BEAM[1]], LIT_STEPS)\n        : ramp([accent, accent, BEAM[1], \"#dfe7ff\"], LIT_STEPS),\n    [theme, accent],\n  );\n  const lit: string[][] = Array.from({ length: LIT_STEPS }, () => []);\n  const circle = (x: number, y: number, r: number) =>\n    `M${(x - r).toFixed(2)} ${y.toFixed(2)}a${r.toFixed(2)} ${r.toFixed(2)} 0 1 0 ${(2 * r).toFixed(2)} 0a${r.toFixed(2)} ${r.toFixed(2)} 0 1 0 ${(-2 * r).toFixed(2)} 0`;\n\n  for (const p of grid) {\n    const local = t - RIPPLE_AT - p.d / v;\n    const amp = Math.max(0, 1 - p.d / reach);\n    const g = Math.exp(-((local / 3.4) ** 2)) * amp;\n    const push = Math.exp(-(((local - 1.5) / 3) ** 2)) * amp;\n    const ux = p.d > 0 ? (p.x - ox) / p.d : 0;\n    const uy = p.d > 0 ? (p.y - oy) / p.d : 0;\n    const x = p.x + px + ux * push * 4 * u;\n    const y = p.y + uy * push * 4 * u;\n    if (x < -pitch || x > W + pitch || y < -pitch || y > H + pitch) continue;\n\n    let r: number;\n    if (p.cov > 0.4 && local > 0) {\n      const k = GROW(interpolate(local, [0, 14], [0, 1], CLAMP));\n      const fill = Math.min(1, (p.cov - 0.4) / 0.35);\n      r = r0 + (rIn * (0.5 + 0.5 * fill) - r0) * k;\n      r *= 1 + g * 0.25;\n      const lx = (p.x - markLeft) / markW;\n      const ly = (p.y - markTop) / markH;\n      const key = 1 - (lx * 0.6 + ly * 0.4);\n      const n = LIT_STEPS;\n      lit[Math.max(0, Math.min(n - 1, Math.floor(key * n)))].push(\n        circle(x, y, r),\n      );\n      continue;\n    }\n    const settle = EASE_OUT(interpolate(local, [0, 18], [0, 1], CLAMP));\n    r = r0 + (rOut - r0) * settle;\n    r *= 1 + g * 1.5;\n    if (p.d < pitch * 0.8) r *= 1 + pre * 1.6;\n    const sx = (x - W / 2) / (W * 0.55);\n    const sy = (y - H / 2) / (H * 0.7);\n    const fall = 1 - Math.min(1, sx * sx + sy * sy) * 0.6;\n    const b = fall * (1 - settle * 0.35) + g * 0.8;\n    const bucket = Math.max(0, Math.min(BUCKETS - 1, Math.floor(b * BUCKETS)));\n    neutral[bucket].push(circle(x, y, r));\n  }\n\n  const cam = interpolate(t, [0, PAN_AT + PAN_DUR + 40], [1.04, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const wordLeft = markLeft + px + markW + gap;\n  const baseline = markTop + markH;\n  const letters = word.split(\"\");\n\n  return (\n    <AbsoluteFill style={{ background: pal.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(ellipse 55% 60% at 50% 46%, ${pal.light}, transparent 75%)`,\n        }}\n      />\n      <AbsoluteFill\n        style={{ transform: `scale(${cam})`, transformOrigin: \"50% 50%\" }}\n      >\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          {neutral.map((segs, i) =>\n            segs.length ? (\n              <path\n                key={`n${i}`}\n                d={segs.join(\"\")}\n                fill={pal.dot}\n                opacity={pal.dotAlpha * (0.3 + (i / (BUCKETS - 1)) * 0.7)}\n              />\n            ) : null,\n          )}\n          {lit.map((segs, i) =>\n            segs.length ? (\n              <path key={`a${i}`} d={segs.join(\"\")} fill={LITC[i]} />\n            ) : null,\n          )}\n        </svg>\n        {word ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: wordLeft,\n              top: baseline - fontSize * BASELINE,\n              display: \"flex\",\n              fontFamily: manrope,\n              fontWeight: weight,\n              fontSize,\n              lineHeight: 1,\n              letterSpacing: `${tracking}em`,\n              color: pal.fg,\n              whiteSpace: \"pre\",\n            }}\n          >\n            {letters.map((ch, i) => {\n              const k = interpolate(t - WORD_AT - i * 2.5, [0, 16], [0, 1], {\n                ...CLAMP,\n                easing: EASE_OUT,\n              });\n              return (\n                <span\n                  key={`${uid}-${i}`}\n                  style={{\n                    display: \"inline-block\",\n                    opacity: k,\n                    transform: `translateX(${(1 - k) * 22 * u}px)`,\n                    filter: `blur(${(1 - k) * 6 * u}px)`,\n                  }}\n                >\n                  {ch}\n                </span>\n              );\n            })}\n          </div>\n        ) : null}\n      </AbsoluteFill>\n      <svg\n        width=\"100%\"\n        height=\"100%\"\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          opacity: pal.grain,\n          pointerEvents: \"none\",\n        }}\n        aria-hidden\n      >\n        <filter id={`${uid}-grain`}>\n          <feTurbulence\n            type=\"fractalNoise\"\n            baseFrequency=\"0.9\"\n            numOctaves={2}\n            seed={9}\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(#${uid}-grain)`} />\n      </svg>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/ripple-mark.tsx"
    }
  ],
  "type": "registry:component"
}
