import { useQuery } from '@tanstack/react-query';
const defaultQueueState = {
    currentMessageId: null,
    queuedMessages: [],
    queueLength: 0,
};
export function useQueueState(sessionId) {
    const { data } = useQuery({
        queryKey: ['queueState', sessionId],
        enabled: !!sessionId,
        initialData: defaultQueueState,
        staleTime: Infinity,
    });
    return data ?? defaultQueueState;
}
export function useMessageQueuePosition(sessionId, messageId) {
    const queueState = useQueueState(sessionId);
    if (!sessionId || !queueState) {
        return { isQueued: false, isRunning: false, position: null };
    }
    if (queueState.currentMessageId === messageId) {
        return { isQueued: false, isRunning: true, position: null };
    }
    const queuedItem = queueState.queuedMessages.find((item) => item.messageId === messageId);
    if (queuedItem) {
        return { isQueued: true, isRunning: false, position: queuedItem.position };
    }
    return { isQueued: false, isRunning: false, position: null };
}
//# sourceMappingURL=useQueueState.js.map