/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { useCallback } from 'react';
import { useKeypress } from '../hooks/useKeypress.js';
import { ShellExecutionService } from '@vybestack/llxprt-code-core';
import { keyToAnsi } from '../hooks/keyToAnsi.js';
export const ShellInputPrompt = ({ activeShellPtyId, focus = true, }) => {
    const handleInput = useCallback((key) => {
        if (!focus) {
            return;
        }
        const targetPtyId = activeShellPtyId ?? ShellExecutionService.getLastActivePtyId();
        if (!targetPtyId) {
            return;
        }
        if (key.ctrl && key.shift && key.name === 'up') {
            ShellExecutionService.scrollPty(targetPtyId, -1);
            return;
        }
        if (key.ctrl && key.shift && key.name === 'down') {
            ShellExecutionService.scrollPty(targetPtyId, 1);
            return;
        }
        const ansiSequence = keyToAnsi(key);
        if (ansiSequence) {
            ShellExecutionService.writeToPty(targetPtyId, ansiSequence);
        }
    }, [focus, activeShellPtyId]);
    useKeypress(handleInput, { isActive: focus });
    return null;
};
//# sourceMappingURL=ShellInputPrompt.js.map