{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "caption-emoji-pop",
  "title": "Caption Emoji Pop",
  "description": "Captions with emoji that pop in alongside words.",
  "dependencies": [
    "@editframe/react"
  ],
  "files": [
    {
      "path": "registry/bases/editframe/components/caption-emoji-pop/index.tsx",
      "content": "\"use client\";\n\nimport { Timegroup } from \"@editframe/react\";\nimport type { CSSProperties } from \"react\";\n\nexport interface CaptionWord {\n  text: string;\n  start: number;\n  end: number;\n}\n\nexport interface CaptionEmojiPopProps {\n  words?: CaptionWord[];\n  color?: string;\n  accentColor?: string;\n  fontSize?: number;\n  fontWeight?: number | string;\n  background?: string;\n  speed?: number;\n  fps?: number;\n  durationInFrames?: number;\n  width?: number;\n  height?: number;\n  className?: string;\n}\n\nconst DEFAULT_WORDS: CaptionWord[] = [\n  { end: 0.35, start: 0, text: \"Every\" },\n  { end: 0.65, start: 0.35, text: \"great\" },\n  { end: 1, start: 0.65, text: \"video\" },\n  { end: 1.45, start: 1.1, text: \"starts\" },\n  { end: 1.65, start: 1.45, text: \"with\" },\n  { end: 1.8, start: 1.65, text: \"a\" },\n  { end: 2.15, start: 1.8, text: \"single\" },\n  { end: 2.7, start: 2.15, text: \"frame.\" },\n  { end: 3.2, start: 3, text: \"No\" },\n  { end: 3.9, start: 3.2, text: \"timelines.\" },\n  { end: 4.2, start: 4, text: \"No\" },\n  { end: 4.5, start: 4.2, text: \"drag\" },\n  { end: 4.65, start: 4.5, text: \"and\" },\n  { end: 5.1, start: 4.65, text: \"drop.\" },\n  { end: 5.55, start: 5.3, text: \"Just\" },\n  { end: 6, start: 5.55, text: \"code.\" },\n];\n\nconst WORDS_PER_GROUP = 3;\n\nconst EMOJI_MAP: Record<string, string> = {\n  \"code.\": \"⌨️\",\n  \"drop.\": \"🔥\",\n  \"frame.\": \"🖼️\",\n  \"timelines.\": \"⏱️\",\n  video: \"📹\",\n};\n\nconst ACCENT_WORDS = new Set([\n  \"video\",\n  \"frame.\",\n  \"code.\",\n  \"timelines.\",\n  \"drop.\",\n]);\n\nexport const CaptionEmojiPop = ({\n  words = DEFAULT_WORDS,\n  color = \"#ffffff\",\n  accentColor = \"#FF76FF\",\n  fontSize = 72,\n  fontWeight = 900,\n  background = \"#0a0a0a\",\n  speed = 1,\n  fps = 30,\n  durationInFrames = 180,\n  width = 1280,\n  height = 720,\n  className,\n}: CaptionEmojiPopProps) => {\n  const safeSpeed = Math.max(0.01, speed);\n  const durationMs = (durationInFrames / fps) * 1000;\n\n  const groups = [];\n  for (let i = 0; i < words.length; i += WORDS_PER_GROUP) {\n    const groupWords = words.slice(i, i + WORDS_PER_GROUP);\n    const emoji =\n      groupWords.map((w) => EMOJI_MAP[w.text]).find(Boolean) ?? null;\n    groups.push({\n      emoji,\n      endMs: ((groupWords.at(-1)?.end ?? 0) * 1000) / safeSpeed + 180,\n      startMs: (groupWords[0].start * 1000) / safeSpeed,\n      words: groupWords,\n    });\n  }\n\n  const containerStyle: CSSProperties = {\n    background,\n    height,\n    overflow: \"hidden\",\n    position: \"relative\",\n    width,\n  };\n\n  return (\n    <Timegroup\n      className={className}\n      duration={`${durationMs}ms`}\n      mode=\"fixed\"\n      style={containerStyle}\n    >\n      <>\n        <style>{`\n          @keyframes framecn-cep-grp-in {\n            from { opacity: 0; transform: scaleX(0.8); }\n            to   { opacity: 1; transform: scaleX(1); }\n          }\n          @keyframes framecn-cep-grp-out {\n            from { opacity: 1; transform: scaleX(1); }\n            to   { opacity: 0; transform: scaleX(0.75); }\n          }\n          @keyframes framecn-cep-emoji-in {\n            from { opacity: 0; transform: scale(0.5) translateY(10px); }\n            to   { opacity: 1; transform: scale(1) translateY(0); }\n          }\n        `}</style>\n        <div\n          style={{\n            bottom: Math.round(height * 0.12),\n            left: 0,\n            position: \"absolute\",\n            right: 0,\n          }}\n        >\n          {groups.map((group, gi) => (\n            <div\n              key={gi}\n              style={{\n                alignItems: \"center\",\n                animation: [\n                  `framecn-cep-grp-in 200ms cubic-bezier(0.34,1.56,0.64,1) ${group.startMs}ms both`,\n                  `framecn-cep-grp-out 150ms ease-in ${group.endMs}ms forwards`,\n                ].join(\", \"),\n                display: \"flex\",\n                flexDirection: \"column\",\n                gap: \"0.15em\",\n                left: 0,\n                opacity: 0,\n                position: \"absolute\",\n                right: 0,\n              }}\n            >\n              {group.emoji && (\n                <span\n                  style={{\n                    animation: `framecn-cep-emoji-in 250ms cubic-bezier(0.34,1.56,0.64,1) ${group.startMs + 50}ms both`,\n                    display: \"block\",\n                    fontSize: fontSize * 0.8,\n                    lineHeight: 1,\n                    textAlign: \"center\",\n                  }}\n                >\n                  {group.emoji}\n                </span>\n              )}\n              <div\n                style={{\n                  alignItems: \"center\",\n                  display: \"flex\",\n                  flexWrap: \"wrap\",\n                  gap: \"0.25em\",\n                  justifyContent: \"center\",\n                  padding: \"0 80px\",\n                }}\n              >\n                {group.words.map((word, wi) => (\n                  <span\n                    key={wi}\n                    style={{\n                      color: ACCENT_WORDS.has(word.text) ? accentColor : color,\n                      display: \"inline-block\",\n                      fontFamily:\n                        \"'Gabarito', 'Montserrat', var(--font-geist-sans), sans-serif\",\n                      fontSize,\n                      fontWeight,\n                      lineHeight: 1,\n                    }}\n                  >\n                    {word.text}\n                  </span>\n                ))}\n              </div>\n            </div>\n          ))}\n        </div>\n      </>\n    </Timegroup>\n  );\n};\n",
      "type": "registry:component",
      "target": "components/framecn/caption-emoji-pop.tsx"
    }
  ],
  "type": "registry:component"
}