import { isDragActive as P } from "./drag/state/is-active.es.js";
import { setupGesture as h } from "./utils/setup.es.js";
function m(s) {
  return !(s.pointerType === "touch" || P());
}
function D(s, v, f = {}) {
  const [u, n, l] = h(s, f);
  return u.forEach((t) => {
    let d = !1, r = !1, o;
    const E = () => {
      t.removeEventListener("pointerleave", a);
    }, c = (e) => {
      o && (o(e), o = void 0), E();
    }, i = (e) => {
      d = !1, window.removeEventListener("pointerup", i), window.removeEventListener("pointercancel", i), r && (r = !1, c(e));
    }, w = () => {
      d = !0, window.addEventListener("pointerup", i, n), window.addEventListener("pointercancel", i, n);
    }, a = (e) => {
      if (e.pointerType !== "touch") {
        if (d) {
          r = !0;
          return;
        }
        c(e);
      }
    }, L = (e) => {
      if (!m(e))
        return;
      r = !1;
      const p = v(t, e);
      typeof p == "function" && (o = p, t.addEventListener("pointerleave", a, n));
    };
    t.addEventListener("pointerenter", L, n), t.addEventListener("pointerdown", w, n);
  }), l;
}
export {
  D as hover
};
//# sourceMappingURL=hover.es.js.map
