{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "quote-hero",
  "title": "Quote Hero",
  "description": "A big pull quote with an underlined italic phrase and a named founder attribution.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/quote-hero/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/InstrumentSans\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  Img,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: sans } = loadFont(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: serif } = loadSerif(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n// the highlighted phrase turns italic\nloadSerif(\"italic\", { weights: [\"400\"], subsets: [\"latin\"] });\n\n/** gradients.sh \"silk\" (#3b3fd8 #f3d6c0 #8a7bff): a diagonal sheen for the big mark. */\nconst silk = (deg: number) =>\n  `linear-gradient(${deg}deg, #B3A6FF 8%, #5B4FE8 19%, #3B3FD8 25%, #B08FD8 31%, #F3D6C0 37%)`;\n\nexport interface Quote {\n  /** The testimonial, without quote marks: curly marks are added for you. */\n  quote: string;\n  /** A phrase from `quote` that gets the highlighter sweep. */\n  highlight?: string;\n  name: string;\n  role: string;\n  company: string;\n  /** Portrait URL; initials on a neutral disc when absent. */\n  avatar?: string;\n}\n\nexport interface QuoteHeroProps {\n  quotes?: Quote[];\n  /** Frames each quote owns, including its exit. */\n  quoteDuration?: number;\n  accent?: string;\n  /** Playback multiplier. */\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst DEFAULT_QUOTES: Quote[] = [\n  {\n    quote:\n      \"remocn turned our launch video from a two-week agency project into an afternoon. We shipped it the same day.\",\n    highlight: \"into an afternoon\",\n    name: \"Maya Chen\",\n    role: \"Head of Design\",\n    company: \"Kitebase\",\n  },\n  {\n    quote:\n      \"The components feel art-directed, not generated. Our changelog videos finally look like the product.\",\n    highlight: \"finally look like the product\",\n    name: \"Leo Park\",\n    role: \"Founder\",\n    company: \"Fernway\",\n  },\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 EASE_IN = Easing.bezier(0.5, 0, 0.75, 0);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    key: \"rgba(255,255,255,0.06)\",\n    fg: \"#F3F2EF\",\n    muted: \"#8B8A90\",\n    hair: \"rgba(255,255,255,0.14)\",\n    disc: \"#1D1D20\",\n    discRing: \"rgba(255,255,255,0.08)\",\n    marker: 0.85,\n    grain: 0.07,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    key: \"rgba(255,255,255,0.95)\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    hair: \"rgba(18,18,20,0.14)\",\n    disc: \"#E6E3DC\",\n    discRing: \"rgba(18,18,20,0.06)\",\n    marker: 0.42,\n    grain: 0.045,\n  },\n} as const;\n\ntype Theme = (typeof THEMES)[keyof typeof THEMES];\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 }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={7}\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\nfunction withAlpha(color: string, a: number) {\n  const m = /^#([0-9a-f]{6})$/i.exec(color);\n  if (!m) return color;\n  const v = Number.parseInt(m[1], 16);\n  return `rgba(${(v >> 16) & 255},${(v >> 8) & 255},${v & 255},${a})`;\n}\n\nfunction hash(s: string) {\n  let h = 2166136261;\n  for (let i = 0; i < s.length; i++) {\n    h ^= s.charCodeAt(i);\n    h = Math.imul(h, 16777619);\n  }\n  return h >>> 0;\n}\n\n/** Rough advance widths for Instrument Serif, in em. Good enough to balance lines. */\nfunction measure(word: string) {\n  let w = 0;\n  for (const ch of word) {\n    if (/[A-Z]/.test(ch)) w += 0.6;\n    else if (/[mw]/.test(ch)) w += 0.66;\n    else if (/[ijlft.,;:'’!-]/.test(ch)) w += 0.25;\n    else if (/[0-9]/.test(ch)) w += 0.48;\n    else w += 0.43;\n  }\n  return w * 0.84;\n}\n\n/** Balanced wrap: aim every line at total / lineCount instead of filling greedily. */\nfunction balance(words: string[], maxEm: number) {\n  const space = 0.22;\n  const widths = words.map(measure);\n  const total = widths.reduce((a, b) => a + b, 0) + space * (words.length - 1);\n  const wrap = (target: number) => {\n    const lines: number[][] = [[]];\n    let w = 0;\n    widths.forEach((ww, i) => {\n      const line = lines[lines.length - 1];\n      const next = line.length ? w + space + ww : ww;\n      if (line.length && next > target) {\n        lines.push([i]);\n        w = ww;\n      } else {\n        line.push(i);\n        w = next;\n      }\n    });\n    return lines;\n  };\n  const count = Math.max(1, Math.ceil(total / (maxEm * 0.94)));\n  const balanced = wrap(Math.min(maxEm, (total / count) * 1.06));\n  return balanced.length <= count ? balanced : wrap(maxEm);\n}\n\n/** Where the big mark's box starts, in G, relative to the first line. Tuned by eye. */\nconst MARK_TOP = -0.1;\n\ninterface Piece {\n  text: string;\n  hl: boolean;\n}\n\n/** Splits the quote into lines of pieces, marking the highlighted phrase. */\nfunction layout(quote: string, highlight: string | undefined, maxEm: number) {\n  const words = `“${quote.trim()}”`.split(/\\s+/);\n  const lines = balance(words, maxEm);\n  const joined = words.join(\" \");\n  const hs = highlight ? joined.indexOf(highlight) : -1;\n  const he = hs >= 0 && highlight ? hs + highlight.length : -1;\n  const starts: number[] = [];\n  let off = 0;\n  for (const w of words) {\n    starts.push(off);\n    off += w.length + 1;\n  }\n  return lines.map((idx, li) => {\n    const pieces: Piece[] = [];\n    const push = (text: string, hl: boolean) => {\n      if (!text) return;\n      const last = pieces[pieces.length - 1];\n      if (last && last.hl === hl) last.text += text;\n      else pieces.push({ text, hl });\n    };\n    idx.forEach((wi, k) => {\n      let w = words[wi];\n      // the opening mark hangs in the margin; it is drawn separately\n      if (li === 0 && k === 0) w = w.slice(1);\n      const s = starts[wi] + (li === 0 && k === 0 ? 1 : 0);\n      const e = s + w.length;\n      if (k > 0) {\n        const spaceHl = hs >= 0 && s - 1 >= hs && s - 1 < he;\n        push(\" \", spaceHl);\n      }\n      if (hs < 0 || e <= hs || s >= he) {\n        push(w, false);\n      } else {\n        const a = Math.max(hs, s) - s;\n        const b = Math.min(he, e) - s;\n        push(w.slice(0, a), false);\n        push(w.slice(a, b), true);\n        push(w.slice(b), false);\n      }\n    });\n    return pieces;\n  });\n}\n\nfunction CompanyMark({\n  company,\n  size,\n  color,\n}: {\n  company: string;\n  size: number;\n  color: string;\n}) {\n  const v = hash(`${company}:mark`) % 4;\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 20 20\" aria-hidden>\n      {v === 0 ? (\n        <path\n          d=\"M10 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16zm0 4.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7z\"\n          fill={color}\n          fillRule=\"evenodd\"\n        />\n      ) : v === 1 ? (\n        <>\n          <rect x=\"2\" y=\"3\" width=\"16\" height=\"6\" rx=\"3\" fill={color} />\n          <rect x=\"2\" y=\"11\" width=\"10\" height=\"6\" rx=\"3\" fill={color} />\n        </>\n      ) : v === 2 ? (\n        <path d=\"M10 1.5l8.5 8.5-8.5 8.5L1.5 10z\" fill={color} />\n      ) : (\n        <path\n          d=\"M2 18V10a8 8 0 0 1 16 0v8h-5v-8a3 3 0 0 0-6 0v8z\"\n          fill={color}\n        />\n      )}\n    </svg>\n  );\n}\n\nfunction initials(name: string) {\n  return name\n    .split(/\\s+/)\n    .map((p) => p[0] ?? \"\")\n    .join(\"\")\n    .slice(0, 2)\n    .toUpperCase();\n}\n\nfunction QuoteBlock({\n  q,\n  t,\n  start,\n  exitAt,\n  u,\n  c,\n  accent,\n  width,\n  height,\n}: {\n  q: Quote;\n  t: number;\n  start: number;\n  exitAt: number;\n  u: number;\n  c: Theme;\n  accent: string;\n  width: number;\n  height: number;\n}) {\n  const F = 70 * u;\n  const LH = 1.1;\n  const maxW = width * 0.7;\n  const lines = layout(q.quote, q.highlight, maxW / F);\n  const left = width * 0.19;\n  const authorGap = 52 * u;\n  const avatar = 60 * u;\n  const blockH = lines.length * F * LH + authorGap + avatar;\n  const top = (height - blockH) / 2 - 6 * u;\n\n  const lineAt = (i: number) => start + i * 5;\n  const revealEnd = lineAt(lines.length - 1) + 16;\n  const authorAt = revealEnd - 6;\n  const sweepAt = revealEnd + 4;\n\n  const out = interpolate(t, [exitAt, exitAt + 12], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IN,\n  });\n  if (t < start - 1 || out >= 1) return null;\n\n  // highlight pieces sweep one after another, timed by their length\n  const hlLengths: number[] = [];\n  for (const line of lines)\n    for (const p of line) if (p.hl) hlLengths.push(p.text.length);\n  const hlTotal = hlLengths.reduce((a, b) => a + b, 0) || 1;\n  const SWEEP = 18;\n  let hlIndex = 0;\n  let hlOffset = 0;\n\n  const G = 7.6 * F; // the big mark\n  const markIn = interpolate(t, [start - 2, start + 20], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const drift = interpolate(t, [start, start + 200], [0, 1], CLAMP);\n\n  const settle = (k: number) =>\n    interpolate(t, [authorAt + k * 3, authorAt + k * 3 + 18], [0, 1], {\n      ...CLAMP,\n      easing: EASE_OUT,\n    });\n\n  const markerColor = withAlpha(accent, c.marker);\n\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        left,\n        top,\n        width: maxW,\n        opacity: 1 - out,\n        transform: `translateY(${-out * 14 * u}px)`,\n        filter: out > 0.02 ? `blur(${out * 4 * u}px)` : undefined,\n      }}\n    >\n      {/* the opening mark: oversized, hung in the margin, filled with silk */}\n      <div\n        style={{\n          position: \"absolute\",\n          right: \"100%\",\n          top: MARK_TOP * G,\n          marginRight: 0.02 * F,\n          opacity: markIn,\n        }}\n      >\n        <div\n          style={{\n            fontFamily: serif,\n            fontWeight: 400,\n            fontSize: G,\n            lineHeight: 1,\n            // the glyph only uses the top ~half of its em box: the sheen's stops sit there\n            backgroundImage: silk(152 + drift * 16),\n            WebkitBackgroundClip: \"text\",\n            backgroundClip: \"text\",\n            color: \"transparent\",\n            transform: `translateY(${(1 - markIn) * 0.08 * G}px)`,\n          }}\n        >\n          {\"“\"}\n        </div>\n      </div>\n      {lines.map((pieces, li) => {\n        const p = interpolate(t, [lineAt(li), lineAt(li) + 18], [0, 1], {\n          ...CLAMP,\n          easing: EASE_OUT,\n        });\n        return (\n          <div\n            key={li}\n            style={{\n              // vertical mask only; room for descenders and the marker\n              clipPath: \"inset(0 -50% 0 -50%)\",\n              paddingBottom: 0.16 * F,\n              marginBottom: -0.16 * F,\n            }}\n          >\n            <div\n              style={{\n                position: \"relative\",\n                transform: `translateY(${(1 - p) * 112}%)`,\n                fontFamily: serif,\n                fontWeight: 400,\n                fontSize: F,\n                lineHeight: LH,\n                letterSpacing: \"-0.012em\",\n                color: c.fg,\n                whiteSpace: \"pre\",\n              }}\n            >\n              {pieces.map((piece, pi) => {\n                if (!piece.hl) return <span key={pi}>{piece.text}</span>;\n                const from =\n                  sweepAt + (hlOffset / hlTotal) * SWEEP + hlIndex * 1;\n                const dur = Math.max(6, (piece.text.length / hlTotal) * SWEEP);\n                hlOffset += piece.text.length;\n                hlIndex += 1;\n                const s = interpolate(t, [from, from + dur], [0, 1], {\n                  ...CLAMP,\n                  easing: hlIndex === 1 ? EASE_IO : EASE_OUT,\n                });\n                return (\n                  <span\n                    key={pi}\n                    style={{\n                      position: \"relative\",\n                      display: \"inline-block\",\n                      isolation: \"isolate\",\n                    }}\n                  >\n                    <span\n                      style={{\n                        position: \"absolute\",\n                        left: -0.05 * F,\n                        right: -0.05 * F,\n                        bottom: 0.1 * F,\n                        height: 0.2 * F,\n                        borderRadius: 0.05 * F,\n                        background: markerColor,\n                        zIndex: -1,\n                        transform: \"rotate(-0.4deg)\",\n                        clipPath: `inset(0 ${(1 - s) * 100}% 0 0)`,\n                      }}\n                    />\n                    <span style={{ fontStyle: \"italic\" }}>{piece.text}</span>\n                  </span>\n                );\n              })}\n            </div>\n          </div>\n        );\n      })}\n\n      {/* author */}\n      <div\n        style={{\n          display: \"flex\",\n          alignItems: \"center\",\n          gap: 16 * u,\n          marginTop: authorGap,\n          fontFamily: sans,\n        }}\n      >\n        <div\n          style={{\n            width: avatar,\n            height: avatar,\n            borderRadius: \"50%\",\n            overflow: \"hidden\",\n            flexShrink: 0,\n            background: c.disc,\n            boxShadow: `inset 0 0 0 ${Math.max(1, u)}px ${c.discRing}`,\n            display: \"flex\",\n            alignItems: \"center\",\n            justifyContent: \"center\",\n            color: c.fg,\n            fontWeight: 500,\n            fontSize: 18 * u,\n            letterSpacing: \"-0.01em\",\n            opacity: settle(0),\n            transform: `translateY(${(1 - settle(0)) * 14 * u}px) scale(${0.94 + settle(0) * 0.06})`,\n          }}\n        >\n          {q.avatar ? (\n            <Img\n              src={q.avatar}\n              style={{ width: \"100%\", height: \"100%\", objectFit: \"cover\" }}\n            />\n          ) : (\n            initials(q.name)\n          )}\n        </div>\n        <div\n          style={{\n            display: \"flex\",\n            flexDirection: \"column\",\n            gap: 5 * u,\n            opacity: settle(1),\n            transform: `translateY(${(1 - settle(1)) * 14 * u}px)`,\n          }}\n        >\n          <span\n            style={{\n              color: c.fg,\n              fontWeight: 500,\n              fontSize: 21 * u,\n              letterSpacing: \"-0.015em\",\n              lineHeight: 1.1,\n            }}\n          >\n            {q.name}\n          </span>\n          <span\n            style={{\n              color: c.muted,\n              fontWeight: 400,\n              fontSize: 17 * u,\n              lineHeight: 1.1,\n            }}\n          >\n            {q.role}, {q.company}\n          </span>\n        </div>\n        <div\n          style={{\n            width: Math.max(1, u),\n            height: 34 * u,\n            margin: `0 ${12 * u}px`,\n            background: c.hair,\n            transform: `scaleY(${settle(2)})`,\n          }}\n        />\n        <div\n          style={{\n            display: \"flex\",\n            alignItems: \"center\",\n            gap: 8 * u,\n            color: c.fg,\n            opacity: settle(3) * 0.88,\n            transform: `translateY(${(1 - settle(3)) * 14 * u}px)`,\n          }}\n        >\n          <CompanyMark company={q.company} size={22 * u} color={c.fg} />\n          <span\n            style={{\n              fontWeight: 500,\n              fontSize: 23 * u,\n              letterSpacing: \"-0.03em\",\n              lineHeight: 1,\n            }}\n          >\n            {q.company.toLowerCase()}\n          </span>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport function QuoteHero({\n  quotes = DEFAULT_QUOTES,\n  quoteDuration = 120,\n  accent = \"#3B5BFD\",\n  speed = 1,\n  theme = \"dark\",\n}: QuoteHeroProps) {\n  const frame = useCurrentFrame();\n  const { width, height } = useVideoConfig();\n  const t = frame * speed;\n  const u = Math.min(width / 1280, height / 720);\n  const c = THEMES[theme];\n  const n = quotes.length;\n  const total = 6 + n * quoteDuration;\n  const push = interpolate(t, [0, total], [0, 1], CLAMP);\n\n  return (\n    <AbsoluteFill style={{ background: c.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(ellipse 65% 75% at 40% 40%, ${c.key}, transparent 72%)`,\n        }}\n      />\n      <AbsoluteFill\n        style={{\n          transform: `scale(${1 + push * 0.03})`,\n          transformOrigin: \"30% 50%\",\n        }}\n      >\n        {quotes.map((q, i) => {\n          const start = 6 + i * quoteDuration;\n          const exitAt = i === n - 1 ? 1e9 : start + quoteDuration - 8;\n          return (\n            <QuoteBlock\n              key={i}\n              q={q}\n              t={t}\n              start={start}\n              exitAt={exitAt}\n              u={u}\n              c={c}\n              accent={accent}\n              width={width}\n              height={height}\n            />\n          );\n        })}\n      </AbsoluteFill>\n      <Grain opacity={c.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/quote-hero.tsx"
    }
  ],
  "type": "registry:component"
}
