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