"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useMouseEvents = void 0;
var _react = require("react");
var useMouseEvents = exports.useMouseEvents = function useMouseEvents(ref, pointerEvents, handleMouseEnter, handleMouseLeave) {
  (0, _react.useEffect)(function () {
    var node = ref === null || ref === void 0 ? void 0 : ref.current;
    if (ref && node && pointerEvents && handleMouseEnter && handleMouseLeave) {
      node === null || node === void 0 || node.addEventListener('mouseenter', handleMouseEnter);
      node === null || node === void 0 || node.addEventListener('mouseleave', handleMouseLeave);
      node === null || node === void 0 || node.addEventListener('mousedown', function (evt) {
        return evt.stopPropagation();
      });
    }
    return function () {
      if (ref && node && pointerEvents && handleMouseEnter && handleMouseLeave) {
        node === null || node === void 0 || node.removeEventListener('mouseenter', handleMouseEnter);
        node === null || node === void 0 || node.removeEventListener('mouseleave', handleMouseLeave);
        node === null || node === void 0 || node.removeEventListener('mousedown', function (evt) {
          return evt.stopPropagation();
        });
      }
    };
  }, [ref, pointerEvents, handleMouseEnter, handleMouseLeave]);
};