import { useCallback } from "react";
export function useAgentQuickActions(input) {
    const { commands, focusPromptAtEnd, isExecuting, setActivePlaceholderInput, setInputPlaceholder, setPrompt, } = input;
    const stopIfExecuting = useCallback(() => {
        if (!isExecuting)
            return;
        try {
            void commands.stopRun();
        }
        catch { }
    }, [commands, isExecuting]);
    const handleSummaryQuickAction = useCallback((action) => {
        const text = (action.prompt || action.value || action.label || "").trim();
        if (!text)
            return;
        stopIfExecuting();
        void commands.sendQuickMessage(text);
    }, [commands, stopIfExecuting]);
    const handleMessageQuickAction = useCallback((action) => {
        const text = (action.prompt || action.value || action.label || "").trim();
        if (!text)
            return;
        if (/\{\{([^{}]+)\}\}|<<([^<>]+)>>/.test(text)) {
            setActivePlaceholderInput({
                text,
                behavior: action.behavior,
            });
            return;
        }
        if (action.behavior === "compose") {
            setPrompt(text);
            setInputPlaceholder(action.placeholder || "Review and edit, then press Enter to send");
            focusPromptAtEnd();
            return;
        }
        stopIfExecuting();
        void commands.sendQuickMessage(text);
    }, [
        commands,
        focusPromptAtEnd,
        setActivePlaceholderInput,
        setInputPlaceholder,
        setPrompt,
        stopIfExecuting,
    ]);
    return {
        handleSummaryQuickAction,
        handleMessageQuickAction,
    };
}
//# sourceMappingURL=useAgentQuickActions.js.map