import react from "react";
import { useChatService } from "../providers/chat-service.provider.js";
import { AutopilotChatEvent } from "../service/index.js";
const useIsStreamingMessage = (message)=>{
    const chatService = useChatService();
    const [isStreaming, setIsStreaming] = react.useState(message.stream && !message.done);
    react.useEffect(()=>{
        const unsubscribeSendChunk = chatService.on(AutopilotChatEvent.SendChunk, (msg)=>{
            if (msg.id === message.id) setIsStreaming(msg.stream && !msg.done);
        });
        const unsubscribeStopResponse = chatService.on(AutopilotChatEvent.StopResponse, ()=>{
            setIsStreaming(false);
        });
        return ()=>{
            unsubscribeSendChunk();
            unsubscribeStopResponse();
        };
    }, [
        message.id,
        chatService
    ]);
    return {
        isStreaming
    };
};
export { useIsStreamingMessage };
