import { useState, useLayoutEffect, useEffect, useCallback } from 'react'; import { AnimatePresence, motion } from 'framer-motion'; const getUrlIndex = () => parseInt(window.location.hash.split('#')[1] || 0, 10); export function Slides({ children }) { const [slide, setSlide] = useState(getUrlIndex() % children.length); useEffect(() => { window.location.hash = '#' + slide; }, [slide]); const next = useCallback(() => setSlide((s) => (s + 1) % children.length), [children]); const prev = useCallback(() => setSlide((s) => (s + children.length - 1) % children.length), [children]); useLayoutEffect(() => { const handleKeyPress = async (e) => { if (e.ctrlKey && e.altKey) { if (e.code === 'ArrowRight') { next(); } else if (e.code === 'ArrowLeft') { prev(); } e.preventDefault(); } }; window.addEventListener('keydown', handleKeyPress, true); return () => window.removeEventListener('keydown', handleKeyPress, true); }, [slide]); return (