"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = tslib_1.__importStar(require("react")); var util_1 = require("./misc/util"); var useState = React.useState; var useHover = function (element) { var _a = useState(false), state = _a[0], setState = _a[1]; var onMouseEnter = function (originalOnMouseEnter) { return function (event) { (originalOnMouseEnter || util_1.noop)(event); setState(true); }; }; var onMouseLeave = function (originalOnMouseLeave) { return function (event) { (originalOnMouseLeave || util_1.noop)(event); setState(false); }; }; if (typeof element === 'function') { element = element(state); } var el = React.cloneElement(element, { onMouseEnter: onMouseEnter(element.props.onMouseEnter), onMouseLeave: onMouseLeave(element.props.onMouseLeave), }); return [el, state]; }; exports.default = useHover;