import { useEffect, useState } from "react"; import { Star } from "lucide-react"; import { motion, AnimatePresence } from "motion/react"; import { cls } from "@/lib/utils"; import Button from "@/components/ui/Button"; import HeroBackgroundSlot from "@/components/ui/HeroBackgroundSlot"; import TextAnimation from "@/components/ui/TextAnimation"; import ImageOrVideo from "@/components/ui/ImageOrVideo"; import ScrollReveal from "@/components/ui/ScrollReveal"; type Testimonial = { name: string; handle: string; text: string; rating: number; } & ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never }); type HeroSplitTestimonialProps = { tag: string; title: string; description: string; primaryButton: { text: string; href: string }; secondaryButton: { text: string; href: string }; testimonials: Testimonial[]; } & ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never }); const INTERVAL = 5000; const HeroSplitTestimonial = ({ tag, title, description, primaryButton, secondaryButton, imageSrc, videoSrc, testimonials, }: HeroSplitTestimonialProps) => { const [currentIndex, setCurrentIndex] = useState(0); useEffect(() => { if (testimonials.length <= 1) return; const interval = setInterval(() => { setCurrentIndex((prev) => (prev + 1) % testimonials.length); }, INTERVAL); return () => clearInterval(interval); }, [currentIndex, testimonials.length]); const testimonial = testimonials[currentIndex]; return (

{tag}

{Array.from({ length: 5 }).map((_, index) => ( ))}

{testimonial.text}

{testimonial.name} {testimonial.handle}
); }; export default HeroSplitTestimonial;