// src/lib/raf-throttle.ts
function rafThrottle(fn) {
  let rafId = 0;
  let lastArgs = null;
  const scheduled = ((...args) => {
    lastArgs = args;
    if (rafId !== 0) return;
    rafId = requestAnimationFrame(() => {
      rafId = 0;
      const a = lastArgs;
      lastArgs = null;
      if (a) fn(...a);
    });
  });
  scheduled.cancel = () => {
    if (rafId !== 0) {
      cancelAnimationFrame(rafId);
      rafId = 0;
    }
    lastArgs = null;
  };
  return scheduled;
}
export {
  rafThrottle
};
//# sourceMappingURL=raf-throttle.js.map