import { useEffect } from "react";
export function useOutsideClick(callback, refs) {
    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
    ]);
}
