"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const isActive = require("./dist-es-gestures-drag-state-is-active.cjs");
const setup = require("./dist-es-gestures-utils-setup.cjs");
function filterEvents(callback) {
  return (event) => {
    if (event.pointerType === "touch" || isActive.isDragActive())
      return;
    callback(event);
  };
}
function hover(elementOrSelector, onHoverStart, options = {}) {
  const [elements, eventOptions, cancel] = setup.setupGesture(elementOrSelector, options);
  const onPointerEnter = filterEvents((enterEvent) => {
    const { target } = enterEvent;
    const onHoverEnd = onHoverStart(enterEvent);
    if (typeof onHoverEnd !== "function" || !target)
      return;
    const onPointerLeave = filterEvents((leaveEvent) => {
      onHoverEnd(leaveEvent);
      target.removeEventListener("pointerleave", onPointerLeave);
    });
    target.addEventListener("pointerleave", onPointerLeave, eventOptions);
  });
  elements.forEach((element) => {
    element.addEventListener("pointerenter", onPointerEnter, eventOptions);
  });
  return cancel;
}
exports.hover = hover;
//# sourceMappingURL=dist-es-gestures-hover.cjs.map
