import { useRef as t } from "react";
import l from "../../../rc-util/es/raf.mjs";
import v from "../utils/isFirefox.mjs";
import S from "./useOriginScroll.mjs";
function O(i, R, d, x, o) {
  var a = t(0), s = t(null), m = t(null), h = t(!1), F = S(R, d);
  function D(r, e) {
    l.cancel(s.current), a.current += e, m.current = e, !F(e) && (v || r.preventDefault(), s.current = l(function() {
      var u = h.current ? 10 : 1;
      o(a.current * u), a.current = 0;
    }));
  }
  function X(r, e) {
    o(e, !0), v || r.preventDefault();
  }
  var n = t(null), p = t(null);
  function b(r) {
    if (i) {
      l.cancel(p.current), p.current = l(function() {
        n.current = null;
      }, 2);
      var e = r.deltaX, u = r.deltaY, w = r.shiftKey, c = e, f = u;
      (n.current === "sx" || !n.current && w && u && !e) && (c = u, f = 0, n.current = "sx");
      var y = Math.abs(c), M = Math.abs(f);
      n.current === null && (n.current = x && y > M ? "x" : "y"), n.current === "y" ? D(r, f) : X(r, c);
    }
  }
  function g(r) {
    i && (h.current = r.detail === m.current);
  }
  return [b, g];
}
export {
  O as default
};
