import{o as e}from"./rolldown-runtime.C0FnF6B9.js";import{r as t}from"./emotion-is-prop-valid.esm.CuYlOKOk.js";var n=e(t(),1);function r(e,t,r={}){let i=(0,n.useRef)(null),a=(0,n.useRef)(e),o=(0,n.useRef)(t),{autoStart:s=!0}=r;(0,n.useEffect)(()=>{a.current=e},[e]),(0,n.useEffect)(()=>{o.current=t},[t]);let c=(0,n.useCallback)(()=>{i.current&&=(clearTimeout(i.current),null)},[]),l=(0,n.useCallback)(e=>{c();let t=e===void 0?o.current:e;t!==null&&(i.current=setTimeout(()=>{a.current()},t))},[c]);return(0,n.useEffect)(()=>{if(s)return l(),c},[s,t,l,c]),(0,n.useEffect)(()=>c,[c]),{clear:c,restart:(0,n.useCallback)(e=>{l(e)},[l])}}export{r as t};