import { useEffect, useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import Typography from '../../ui/Typography'; import { FiCpu, FiCode, FiShield, FiMessageSquare } from 'react-icons/fi'; import { cn } from '../../../lib/utils'; /** * Rotating suggestion card with typewriter animation. */ export type AnimatedSuggestionsProps = { onSelect: (text: string) => void; }; export function AnimatedSuggestions(props: AnimatedSuggestionsProps) { const { onSelect } = props; const [currentIndex, setCurrentIndex] = useState(0); const [displayText, setDisplayText] = useState(''); const [isTyping, setIsTyping] = useState(true); const suggestions = [ { icon: FiCpu, text: 'Inscribe this poem...', color: 'from-purple-500/70 to-purple-600/70', }, { icon: FiCode, text: "What's the price of HBAR?", color: 'from-blue-500/70 to-blue-600/70', }, { icon: FiShield, text: 'Send 1 HBAR to 0.0.800', color: 'from-green-500/70 to-green-600/70', }, { icon: FiMessageSquare, text: 'Create an NFT collection', color: 'from-indigo-500/70 to-indigo-600/70', }, ]; const currentSuggestion = suggestions[currentIndex]; const Icon = currentSuggestion.icon; useEffect(() => { const targetText = currentSuggestion.text; let currentText = ''; let charIndex = 0; setIsTyping(true); setDisplayText(''); const typing = setInterval(() => { if (charIndex < targetText.length) { currentText += targetText[charIndex]; setDisplayText(currentText); charIndex++; } else { clearInterval(typing); setIsTyping(false); } }, 50); return () => clearInterval(typing); }, [currentIndex, currentSuggestion.text]); useEffect(() => { if (!isTyping) { const timer = setTimeout(() => { setCurrentIndex((prev) => (prev + 1) % suggestions.length); }, 3000); return () => clearTimeout(timer); } }, [isTyping, suggestions.length]); return (