import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { apiClient } from '../lib/api-client';
export function useMessages(sessionId) {
    return useQuery({
        queryKey: ['messages', sessionId],
        queryFn: () => {
            if (!sessionId) {
                throw new Error('Session ID is required');
            }
            return apiClient.getMessages(sessionId);
        },
        enabled: !!sessionId,
    });
}
export function useSendMessage(sessionId) {
    const queryClient = useQueryClient();
    return useMutation({
        mutationFn: (data) => apiClient.sendMessage(sessionId, data),
        onSuccess: () => {
            queryClient.invalidateQueries({ queryKey: ['messages', sessionId] });
            queryClient.invalidateQueries({ queryKey: ['sessions'] });
        },
    });
}
//# sourceMappingURL=useMessages.js.map