"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Feature = require("./dist-es-motion-features-Feature.cjs");
require("../motion-utils/dist-es-errors.cjs");
const hover = require("../motion-dom/dist-es-gestures-hover.cjs");
const eventInfo = require("./dist-es-events-event-info.cjs");
const frame = require("./dist-es-frameloop-frame.cjs");
function handleHoverEvent(node, event, lifecycle) {
  const { props } = node;
  if (node.animationState && props.whileHover) {
    node.animationState.setActive("whileHover", lifecycle === "Start");
  }
  const eventName = "onHover" + lifecycle;
  const callback = props[eventName];
  if (callback) {
    frame.frame.postRender(() => callback(event, eventInfo.extractEventInfo(event)));
  }
}
class HoverGesture extends Feature.Feature {
  mount() {
    const { current } = this.node;
    if (!current)
      return;
    this.unmount = hover.hover(current, (startEvent) => {
      handleHoverEvent(this.node, startEvent, "Start");
      return (endEvent) => handleHoverEvent(this.node, endEvent, "End");
    });
  }
  unmount() {
  }
}
exports.HoverGesture = HoverGesture;
//# sourceMappingURL=dist-es-gestures-hover.cjs.map
