import React, { useState } from 'react'; import { Loader2 } from 'lucide-react'; import RemotionPreview from './RemotionPreview'; import Modal from './ui/Modal'; import SegmentedControl from './ui/SegmentedControl'; const ENTRANCE_OPTIONS = [ { value: 'spring', label: 'Bounce' }, { value: 'fade', label: 'Fade' }, { value: 'slide-up', label: 'Slide Up' }, { value: 'none', label: 'None' }, ]; // Must mirror hooks.py HOOK_STYLES. const HOOK_STYLES = [ { value: 'pill', label: 'Pills', box: 'rgba(255,255,255,0.98)', text: '#000', sans: true }, { value: 'classic', label: 'Classic', box: 'rgba(255,255,255,0.94)', text: '#000' }, { value: 'dark', label: 'Dark', box: 'rgba(18,18,20,0.92)', text: '#fff' }, { value: 'yellow', label: 'Yellow', box: 'rgba(255,214,0,0.96)', text: '#000' }, { value: 'red', label: 'Red', box: 'rgba(220,38,38,0.96)', text: '#fff' }, { value: 'outline', label: 'Outline', box: 'transparent', text: '#fff', outline: true }, { value: 'outline_yellow', label: 'Outline+', box: 'transparent', text: '#FFD600', outline: true }, ]; // Must mirror hooks.py HOOK_FONTS (all bundled: /fonts/*.ttf). const FONT_OPTIONS = [ { value: 'montserrat', label: 'Montserrat' }, { value: 'anton', label: 'Anton' }, { value: 'serif', label: 'Serif' }, ]; const FONT_CSS = { montserrat: { fontFamily: "'Montserrat-ExtraBold', 'Montserrat', sans-serif", fontWeight: 800 }, anton: { fontFamily: "'Anton-Regular', Impact, sans-serif", fontWeight: 400 }, serif: { fontFamily: "'Noto Serif', Georgia, serif", fontWeight: 700 }, }; // The style's own typeface when none is picked (what hooks.py renders). const styleFont = (st) => (st === 'pill' ? 'montserrat' : 'serif'); const POSITION_OPTIONS = [ { value: 'top', label: 'top' }, { value: 'center', label: 'center' }, { value: 'bottom', label: 'bottom' }, ]; const SIZE_OPTIONS = [ { value: 'S', label: 'Small' }, { value: 'M', label: 'Medium' }, { value: 'L', label: 'Large' }, ]; // Last-used hook settings, restored on the next open (style always reset to // classic otherwise, which users read as the picker being broken). function loadHookPrefs() { try { return JSON.parse(localStorage.getItem('cw_hook_prefs')) || {}; } catch { return {}; } } export default function HookModal({ isOpen, onClose, onGenerate, onRemove, isProcessing, videoUrl, initialText, durationInSeconds, existingSubtitles, hasCaptions, serverRender, burnedHook }) { const prefs = loadHookPrefs(); const [text, setText] = useState(initialText || 'POV: You are using the viral hook feature'); const [position, setPosition] = useState(prefs.position || 'top'); const [size, setSize] = useState(prefs.size || 'M'); const [style, setStyle] = useState(prefs.style || 'pill'); // null = follow the style's own typeface. const [font, setFont] = useState(prefs.font || null); const effectiveFont = font || styleFont(style); const [entranceAnimation, setEntranceAnimation] = useState(prefs.entranceAnimation || 'spring'); const [displayDuration, setDisplayDuration] = useState(5); if (!isOpen) return null; // Build hook config for Remotion preview const hookConfig = { text: text || 'Enter your text...', position, size, style, font: effectiveFont, entranceAnimation, displayDurationSec: displayDuration, }; const useRemotionPreview = !!videoUrl; // Fallback preview logic (same as original) const getPositionClass = () => { switch (position) { case 'center': return 'items-center justify-center'; case 'bottom': return 'items-center justify-end pb-[20%]'; case 'top': default: return 'items-center justify-start pt-[20%]'; } }; const getSizeStyle = () => { switch (size) { case 'S': return { fontSize: '14px', maxWidth: '80%' }; case 'L': return { fontSize: '24px', maxWidth: '95%' }; case 'M': default: return { fontSize: '18px', maxWidth: '90%' }; } }; const pillFontFace = "@font-face{font-family:'Montserrat-ExtraBold';src:url('/fonts/Montserrat-ExtraBold.ttf') format('truetype');font-weight:800;}" + "@font-face{font-family:'Anton-Regular';src:url('/fonts/Anton-Regular.ttf') format('truetype');font-weight:400;}"; return (
{/* Left: Preview */}
{useRemotionPreview ? ( ) : ( <>
{/* Right: Controls */}
{/* Text Input */}

Text