{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "slash-wipe",
  "title": "Slash Wipe",
  "description": "A gradient slash wipes across and reveals a large title, '/transitions', with a one-line sub.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/slash-wipe/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadBricolage } from \"@remotion/google-fonts/BricolageGrotesque\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst bricolage = loadBricolage(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"600\"],\n  subsets: [\"latin\"],\n});\n\nexport interface SlashSection {\n  title: string;\n  sub?: string;\n}\n\nexport interface SlashWipeProps {\n  sections?: SlashSection[];\n  every?: number;\n  logo?: React.ReactNode;\n  accent?: string;\n  background?: string;\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst DEFAULT_SECTIONS: SlashSection[] = [\n  { title: \"captions\", sub: \"31 caption styles that follow every word.\" },\n  { title: \"transitions\", sub: \"Cuts that land on the beat.\" },\n];\n\nconst FLUTED = [\"#1d2a8f\", \"#2f7bff\", \"#ff7a3d\", \"#ffe2c4\"] as const;\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0B\", fg: \"#F4F3F0\", muted: \"#9A99A1\" },\n  light: { bg: \"#F5F4F0\", fg: \"#111113\", muted: \"#6E6C67\" },\n} as const;\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IN_OUT = Easing.bezier(0.7, 0, 0.25, 1);\nconst EASE_SWEEP = Easing.bezier(0.55, 0, 0.2, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\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\nfunction RemocnLogo({ fontSize, color }: { fontSize: number; color: string }) {\n  return (\n    <div\n      style={{\n        display: \"flex\",\n        alignItems: \"baseline\",\n        color,\n        fontFamily: manrope.fontFamily,\n        fontWeight: 600,\n        fontSize,\n        letterSpacing: \"-0.025em\",\n        lineHeight: 1,\n      }}\n    >\n      <svg\n        viewBox=\"0 0 124.06 134.26\"\n        style={{ height: \"0.76em\", width: \"auto\" }}\n        aria-hidden\n      >\n        <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n      </svg>\n      <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n    </div>\n  );\n}\n\nfunction estimateEm(text: string) {\n  let w = 0;\n  for (const ch of text) {\n    if (ch === \" \") w += 0.22;\n    else if (/[iljtfr.,'’!|]/.test(ch)) w += 0.33;\n    else if (/[mw]/.test(ch)) w += 0.84;\n    else if (/[MW]/.test(ch)) w += 0.9;\n    else if (/[A-Z]/.test(ch)) w += 0.66;\n    else w += 0.56;\n  }\n  return w;\n}\n\nconst SLASH = {\n  k: 0.36,\n  sw: 0.1,\n  desc: 0.12,\n  asc: 0.78,\n  gap: 0.07,\n};\n\nexport function SlashWipe({\n  sections = DEFAULT_SECTIONS,\n  every = 56,\n  logo,\n  accent = \"#3B5BFD\",\n  background,\n  speed = 1,\n  theme = \"dark\",\n}: SlashWipeProps) {\n  const raw = useCurrentFrame();\n  const frame = raw * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const p = PALETTES[theme];\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  const list = sections.length >= 1 ? sections.slice(0, 5) : DEFAULT_SECTIONS;\n  const n = list.length;\n  const portrait = H > W * 1.1;\n  const u = Math.min(W, H) / 720;\n  const margin = (portrait ? 64 : 64) * u;\n\n  const slashAdvance =\n    SLASH.sw + SLASH.k * (SLASH.asc + SLASH.desc) + SLASH.gap;\n  const avail = W - margin * 2;\n  const base = (portrait ? 230 : 210) * u;\n  const yb = H * (portrait ? 0.5 : 0.565);\n  const k = SLASH.k;\n  const pad = 20 * u;\n  const geo = list.map((s) => {\n    const fs = Math.min(\n      base,\n      avail / (estimateEm(s.title) + slashAdvance + 0.04),\n    );\n    const x0 = margin - fs * 0.02;\n    const yBot = yb + fs * SLASH.desc;\n    return {\n      fs,\n      x0,\n      sw: fs * SLASH.sw,\n      yBot,\n      yTop: yb - fs * SLASH.asc,\n      xText: x0 + fs * slashAdvance,\n      xL: x0 + k * (yBot - yb),\n    };\n  });\n  const lineX = (xAtBase: number, y: number) => xAtBase + k * (yb - y);\n  const travel = W + k * (H + pad - yb) + base * SLASH.sw + pad * 4;\n\n  const T = (j: number) => 22 + j * every;\n  const sweep = (j: number) => {\n    const t0 = T(j);\n    const stretch = interpolate(frame, [t0, t0 + 8], [0, 1], {\n      ...CLAMP,\n      easing: EASE_IN_OUT,\n    });\n    const lead = interpolate(frame, [t0 + 6, t0 + 24], [0, travel], {\n      ...CLAMP,\n      easing: EASE_SWEEP,\n    });\n    const trail = interpolate(frame, [t0 + 10, t0 + 30], [0, travel], {\n      ...CLAMP,\n      easing: EASE_SWEEP,\n    });\n    return {\n      started: frame >= t0,\n      wiping: frame >= t0 + 6,\n      done: frame >= t0 + 30,\n      stretch,\n      lead: geo[j].xL + geo[j].sw + lead,\n      trail: geo[j].xL + trail,\n    };\n  };\n\n  const regionOf = (i: number) => {\n    const top = -pad;\n    const bot = H + pad;\n    let lt = -W * 4;\n    let lb = -W * 4;\n    let rt = W * 4;\n    let rb = W * 4;\n    if (i > 0) {\n      const s = sweep(i - 1);\n      if (!s.started) return null;\n      if (!s.done) {\n        rt = lineX(s.trail, top);\n        rb = lineX(s.trail, bot);\n      }\n    }\n    if (i < n - 1) {\n      const s = sweep(i);\n      if (s.done) return null;\n      if (s.wiping) {\n        lt = lineX(s.lead, top);\n        lb = lineX(s.lead, bot);\n      }\n    }\n    return `polygon(${lt}px ${top}px, ${Math.max(rt, lt)}px ${top}px, ${Math.max(rb, lb)}px ${bot}px, ${lb}px ${bot}px)`;\n  };\n\n  const gradStops = (\n    <>\n      <stop offset=\"0\" stopColor={FLUTED[0]} />\n      <stop\n        offset=\"0.42\"\n        stopColor={`color-mix(in oklab, ${accent} 60%, ${FLUTED[1]})`}\n      />\n      <stop offset=\"0.8\" stopColor={FLUTED[2]} />\n      <stop offset=\"1\" stopColor={FLUTED[3]} />\n    </>\n  );\n\n  const renderSection = (s: SlashSection, i: number) => {\n    const clip = regionOf(i);\n    if (clip === null) return null;\n    const { fs, x0, sw, yBot, yTop, xText } = geo[i];\n    const glyphPoints = [\n      [x0, yBot],\n      [x0 + sw, yBot],\n      [x0 + sw + k * (yBot - yTop), yTop],\n      [x0 + k * (yBot - yTop), yTop],\n    ]\n      .map(([x, y]) => `${x},${y}`)\n      .join(\" \");\n    const arrive = i === 0 ? null : T(i - 1);\n    const rise =\n      arrive === null\n        ? interpolate(frame, [0, 16], [0, 1], { ...CLAMP, easing: EASE_OUT })\n        : 1;\n    const slide =\n      arrive === null\n        ? 1\n        : interpolate(frame, [arrive + 12, arrive + 34], [0, 1], {\n            ...CLAMP,\n            easing: EASE_OUT,\n          });\n    const subStart = arrive === null ? 8 : arrive + 22;\n    const subT = interpolate(frame, [subStart, subStart + 16], [0, 1], {\n      ...CLAMP,\n      easing: EASE_OUT,\n    });\n    const glyphT =\n      arrive === null\n        ? interpolate(frame, [0, 14], [0, 1], { ...CLAMP, easing: EASE_OUT })\n        : 1;\n    const clipId = `${uid}-w${i}`;\n    const gradId = `${uid}-g${i}`;\n    return (\n      <div\n        key={`${s.title}-${i}`}\n        style={{ position: \"absolute\", inset: 0, clipPath: clip }}\n      >\n        <svg\n          width={W}\n          height={H}\n          viewBox={`0 0 ${W} ${H}`}\n          style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n          aria-hidden\n        >\n          <defs>\n            <clipPath id={clipId}>\n              <rect\n                x={xText - fs * 0.06}\n                y={yb - fs * 1.05}\n                width={W}\n                height={fs * 1.35}\n              />\n            </clipPath>\n            <linearGradient\n              id={gradId}\n              gradientUnits=\"userSpaceOnUse\"\n              x1={0}\n              y1={yBot}\n              x2={0}\n              y2={yTop}\n            >\n              {gradStops}\n            </linearGradient>\n          </defs>\n          <polygon\n            points={glyphPoints}\n            fill={`url(#${gradId})`}\n            style={{\n              clipPath: `inset(${(1 - glyphT) * 100}% 0 0 0)`,\n            }}\n          />\n          <g clipPath={`url(#${clipId})`}>\n            <text\n              x={xText}\n              y={yb}\n              fill={p.fg}\n              style={{\n                fontFamily: bricolage.fontFamily,\n                fontWeight: 500,\n                fontSize: fs,\n                letterSpacing: \"-0.04em\",\n                transform: `translate(${(1 - slide) * -fs * 1.6}px, ${(1 - rise) * fs * 1.1}px)`,\n              }}\n            >\n              {s.title}\n            </text>\n          </g>\n        </svg>\n        {s.sub ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: xText + fs * 0.03,\n              top: yb + fs * 0.34,\n              maxWidth: W - xText - margin,\n              fontFamily: bricolage.fontFamily,\n              fontWeight: 400,\n              fontSize: (portrait ? 42 : 32) * u,\n              lineHeight: 1.3,\n              letterSpacing: \"-0.015em\",\n              color: p.muted,\n              textWrap: \"balance\",\n              opacity: subT,\n              transform: `translateX(${(1 - subT) * -18 * u}px)`,\n            }}\n          >\n            {s.sub}\n          </div>\n        ) : null}\n      </div>\n    );\n  };\n\n  let band: React.ReactNode = null;\n  for (let j = 0; j < n - 1; j++) {\n    const s = sweep(j);\n    if (!s.started || s.done) continue;\n    const top = interpolate(s.stretch, [0, 1], [geo[j].yTop, -pad]);\n    const bot = interpolate(s.stretch, [0, 1], [geo[j].yBot, H + pad]);\n    const pts = [\n      [lineX(s.trail, bot), bot],\n      [lineX(s.lead, bot), bot],\n      [lineX(s.lead, top), top],\n      [lineX(s.trail, top), top],\n    ]\n      .map(([x, y]) => `${x},${y}`)\n      .join(\" \");\n    const gid = `${uid}-band`;\n    band = (\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        <defs>\n          <linearGradient\n            id={gid}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={0}\n            y1={bot}\n            x2={0}\n            y2={top}\n          >\n            {gradStops}\n          </linearGradient>\n        </defs>\n        <polygon points={pts} fill={`url(#${gid})`} />\n      </svg>\n    );\n  }\n\n  const transparent = background === \"transparent\";\n  const logoT = interpolate(frame, [0, 16], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n\n  return (\n    <AbsoluteFill\n      style={{\n        background: transparent ? \"transparent\" : (background ?? p.bg),\n        overflow: \"hidden\",\n      }}\n    >\n      {list.map(renderSection)}\n      {band}\n      {logo === null ? null : (\n        <div\n          style={{\n            position: \"absolute\",\n            left: margin,\n            top: margin * 0.75,\n            opacity: logoT,\n          }}\n        >\n          {logo ?? (\n            <RemocnLogo fontSize={(portrait ? 34 : 26) * u} color={p.fg} />\n          )}\n        </div>\n      )}\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/slash-wipe.tsx"
    }
  ],
  "type": "registry:component"
}
