import { Container, Spacer, Text } from '../../tui/index.js';
import { ApprovalButtonBar, Border } from './approval.js';
function formatModeName(mode) {
    return mode.length > 0 ? mode.charAt(0).toUpperCase() + mode.slice(1) : mode;
}
export class SwitchModeApprovalComponent extends Container {
    buttonBar;
    onDone;
    constructor(data, theme, onDone, queueInfo) {
        super();
        this.onDone = onDone;
        const borderColor = (s) => theme.fg('border', s);
        const queueLabel = queueInfo
            ? theme.fg('accent', ` (${queueInfo.current}/${queueInfo.total})`)
            : '';
        const title = ` Switch from ${formatModeName(data.currentMode)} to ${formatModeName(data.targetMode)}`;
        const reason = data.reason?.trim();
        this.addChild(new Border(borderColor));
        this.addChild(new Text(theme.fg('accent', title) + queueLabel, 0, 0));
        if (reason) {
            this.addChild(new Spacer(1));
            this.addChild(new Text(theme.fg('dim', `  ${reason}`), 0, 0));
        }
        this.addChild(new Spacer(1));
        this.buttonBar = new ApprovalButtonBar(theme, '←→ select  enter confirm  esc cancel', true);
        this.addChild(this.buttonBar.getContainer());
        this.addChild(new Border(borderColor));
    }
    handleInput(keyData) {
        const choice = this.buttonBar.handleInput(keyData);
        if (choice)
            this.onDone(choice);
    }
}
//# sourceMappingURL=switch-mode-approval.js.map