"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "useOutsideClick", {
    enumerable: true,
    get: function() {
        return useOutsideClick;
    }
});
var _react = require("react");
function useOutsideClick(callback, refs) {
    (0, _react.useEffect)(function() {
        var handleClick = function handleClick(event) {
            var isInside = refs.some(function(ref) {
                var el = ref.current;
                return el && el.contains(event.target);
            });
            if (!isInside) {
                callback(event);
            }
        };
        document.addEventListener('mousedown', handleClick);
        document.addEventListener('touchstart', handleClick);
        return function() {
            document.removeEventListener('mousedown', handleClick);
            document.removeEventListener('touchstart', handleClick);
        };
    }, [
        callback
    ]);
}
