import { useRafFn as x } from "@vueuse/core";
import "../../scroll-bar/index.mjs";
import { ensureRangeValue as u } from "../../scroll-bar/utils/index.mjs";
const m = {
  horizontal: "x",
  vertical: "y"
}, p = () => {
}, R = (e) => 1 - (1 - e) ** 3, z = ({
  scrollOffset: e,
  maxScrollDistance: d,
  timer: l = 500,
  onScroll: o = p,
  onScrollEnd: f = p
}) => {
  let a, t, i;
  const { pause: r, resume: g, isActive: D } = x(
    () => {
      const s = Date.now(), n = m[t], v = s - a, c = u(v / l, 0, 1), w = R(c);
      c === 1 ? (e[n] = 0, r(), o(t), f(t)) : (e[n] = u(
        i * (1 - w),
        0,
        d[n]
      ), o(t));
    },
    { immediate: !1 }
  );
  function T(s) {
    t = s, a = Date.now(), i = e[m[s]], g();
  }
  function h() {
    r();
  }
  return { start: T, stop: h, isActive: D };
};
export {
  z as useScrollBack
};
