import { useEffect } from 'react';
const useClickOutside = (ref, callback, ignoreRefs = [], options) => {
    useEffect(() => {
        const handleClickOutside = (event) => {
            const target = event.target;
            const isIgnoredSelector = options?.ignoreSelectors?.some((selector) => target instanceof Element && target.closest(selector));
            if (ref.current &&
                !ref.current.contains(target) &&
                !ignoreRefs.some((ignoreRef) => ignoreRef?.current && ignoreRef.current.contains(target)) &&
                !isIgnoredSelector) {
                callback();
            }
        };
        document.addEventListener('mousedown', handleClickOutside);
        return () => {
            document.removeEventListener('mousedown', handleClickOutside);
        };
    }, [ref, callback, ignoreRefs, options]);
};
export default useClickOutside;
//# sourceMappingURL=useClickOutside.js.map