// src/utils/scroll-to.ts
function scrollTo(element, targetPosition, duration) {
  const startPosition = element.scrollTop;
  const distance = targetPosition - startPosition;
  let startTime = null;
  function animation(currentTime) {
    if (startTime === null)
      startTime = currentTime;
    const timeElapsed = currentTime - startTime;
    const run = ease(timeElapsed, startPosition, distance, duration);
    element.scrollTop = run;
    if (timeElapsed < duration) {
      requestAnimationFrame(animation);
    }
  }
  function ease(t, b, c, d) {
    let [t2] = [t];
    const [b2, c2, d2] = [b, c, d];
    t2 /= d2 / 2;
    if (t2 < 1)
      return c2 / 2 * t2 * t2 + b2;
    t2--;
    return -c2 / 2 * (t2 * (t2 - 2) - 1) + b2;
  }
  requestAnimationFrame(animation);
}

export {
  scrollTo
};
//# sourceMappingURL=chunk-ZXQZRIRS.js.map