import{useRef as r,useMemo as n,useEffect as t}from"react";var u=function(r,n){return Number.isFinite(n)?{timeout:setTimeout(r,n)}:{raf:requestAnimationFrame(r)}},e=function(e,i){void 0===i&&(i=0);var o=r(null),c=r([]),a=r(e);a.current=e;var f=n((function(){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];c.current=r,o.current||(o.current=u((function(){a.current.apply(a,c.current),o.current=null}),i))}}),[]);return t((function(){return function(){return(null==(r=o.current)?void 0:r.timeout)&&clearTimeout(r.timeout),void((null==r?void 0:r.raf)&&cancelAnimationFrame(r.raf));var r}}),[]),f};export{e as useThrottledCallback};
