import { useCallback } from "react";
import { selectShouldShowThinkingDots } from "./agentSessionSelectors";
import { selectHasSpawnedAgents, selectHasTodoContent, } from "./agentSessionSelectors";
export function useAgentTerminalViewState(input) {
    const { agent, agentStub, messages, error, hideGreeting, isSubmitting, isConnecting, activeInlineDialog, allPendingApprovalsCount, isAgentThinking, isExecuting, isWaitingForResponse, sessionCostLimitExceeded, isLoading, sessionState, } = input;
    const showInitialThinkingSplash = messages.length === 0 &&
        !error &&
        hideGreeting &&
        (isSubmitting || isConnecting);
    const shouldShowThinkingDots = selectShouldShowThinkingDots({
        activeInlineDialog,
        allPendingApprovalsCount,
        isAgentThinking,
        isConnecting,
        isExecuting,
        isSubmitting,
        isWaitingForResponse,
        messages,
        sessionCostLimitExceeded,
        showInitialThinkingSplash,
    });
    const parentAgentId = agent?.parentAgentId ||
        agent?.ParentAgentId ||
        agentStub?.parentAgentId ||
        agentStub?.ParentAgentId;
    const handleBackToParent = useCallback(() => {
        if (!parentAgentId)
            return;
        window.dispatchEvent(new CustomEvent("editor:openAgent", {
            detail: { agentId: parentAgentId },
        }));
    }, [parentAgentId]);
    return {
        showInitialThinkingSplash,
        shouldShowThinkingDots,
        parentAgentId,
        handleBackToParent,
        shouldShowLoadingContent: isLoading && !activeInlineDialog,
        hasSpawnedAgents: selectHasSpawnedAgents(sessionState),
        hasTodoContent: selectHasTodoContent(sessionState),
        hasHistoryContent: sessionState.operationHistory.length > 0,
    };
}
//# sourceMappingURL=useAgentTerminalViewState.js.map