import{useRef as t,useState as e,useEffect as u}from"react";let timeout=null,useMarqueeItem=r=>{let{index:o,activeItem:i,hoverItem:m,timeToScroll:n=0,setHoverItem:c,setActiveItem:l}=r??{},a=t(!0),[T,s]=e(!1),f=t(!1);return u(()=>{m===o?.toString()?(s(!0),timeout&&clearTimeout(timeout),timeout=setTimeout(()=>{f.current||(s(!1),c?.())},1e3)):s(!1)},[m,o,c]),u(()=>{if(a.current){timeout=setTimeout(()=>{a.current=!1},500);return}return i===o?.toString()?(s(!0),f.current=!0,timeout&&clearTimeout(timeout),timeout=setTimeout(()=>{s(!1),f.current=!1,l?.()},n+1e3)):s(!1),()=>{timeout&&clearTimeout(timeout)}},[i,o,l,n]),{isActive:T}};export{useMarqueeItem};
