import { useEffect, useState } from 'react'; import { motion } from 'framer-motion'; interface GlitchCrashProps { onComplete?: () => void; } const GlitchCrash = ({ onComplete }: GlitchCrashProps) => { const [phase, setPhase] = useState(0); const [glitchText, setGlitchText] = useState(''); const errorMessages = [ 'BUFFER OVERFLOW DETECTED', 'STACK SMASHING DETECTED', 'SEGMENTATION FAULT', 'MEMORY CORRUPTION', 'KERNEL PANIC', 'SYSTEM HALTED', '0xDEADBEEF', 'FATAL ERROR', 'CORE DUMPED', ]; useEffect(() => { const interval = setInterval(() => { const chars = '!@#$%^&*()_+-=[]{}|;:,.<>?/~`░▒▓█▀▄▌▐■□▢▣▤▥▦▧▨▩'; let text = ''; for (let i = 0; i < 100; i++) { text += chars[Math.floor(Math.random() * chars.length)]; if (i % 20 === 19) text += '\n'; } setGlitchText(text); }, 50); const phaseTimer = setInterval(() => { setPhase(p => p + 1); }, 800); const endTimer = setTimeout(() => { onComplete?.(); }, 8000); return () => { clearInterval(interval); clearInterval(phaseTimer); clearTimeout(endTimer); }; }, [onComplete]); return ( {/* Glitch color overlay */}
{/* Scanlines */}
{/* Random noise */}
        {glitchText}
        {glitchText}
        {glitchText}
        {glitchText}
        {glitchText}
      
{/* Error messages */}
{errorMessages.slice(0, Math.min(phase + 1, errorMessages.length)).map((msg, i) => ( {msg} ))}
{/* Final message */} {phase > 6 && (
SYSTEM OVERFLOW
You broke the matrix. Congratulations.
(Refreshing in a moment...)
)} {/* Glitch bars */} {Array.from({ length: 10 }).map((_, i) => (
))} ); }; export default GlitchCrash;