function easeInOutQuad(progress) {
  return progress < 0.5 ? 2 * progress * progress : 1 - Math.pow(-2 * progress + 2, 2) / 2;
}
class AnimationManager {
  constructor() {
    this.animationId = null;
    this.startTime = 0;
    this.startProgress = 0;
  }
  /**
   * Start a new animation
   * @param targetProgress - Target progress value (0-1)
   * @param fromProgress - Starting progress value (0-1)
   * @param config - Animation configuration
   */
  start(targetProgress, fromProgress, config) {
    this.cancel();
    this.startTime = performance.now();
    this.startProgress = fromProgress;
    const step = (now) => {
      try {
        const elapsed = now - this.startTime;
        const t = config.duration <= 0 ? 1 : Math.min(elapsed / config.duration, 1);
        const currentProgress = this.startProgress + (targetProgress - this.startProgress) * t;
        config.onUpdate(currentProgress);
        if (t >= 1) {
          this.animationId = null;
          config.onComplete?.();
        } else {
          this.animationId = requestAnimationFrame(step);
        }
      } catch (error) {
        this.animationId = null;
        config.onError?.(error);
      }
    };
    this.animationId = requestAnimationFrame(step);
  }
  /**
   * Cancel the current animation
   */
  cancel() {
    if (this.animationId !== null) {
      cancelAnimationFrame(this.animationId);
      this.animationId = null;
    }
  }
  /**
   * Check if animation is running
   */
  isRunning() {
    return this.animationId !== null;
  }
}
function frameLerp(current, to, speed = 0.1) {
  const diff = to - current;
  if (Math.abs(diff) < 0.5) {
    return to;
  }
  return current + diff * speed;
}
export {
  AnimationManager,
  easeInOutQuad,
  frameLerp
};
//# sourceMappingURL=animation-utils.js.map
