import { Container, Spacer, Text } from "@voxcode-dev/voxcode-tui";
import { theme } from "../theme/theme.js";
import { DynamicBorder } from "./dynamic-border.js";
import { keyHint } from "./keybinding-hints.js";
export class ConfirmDialog extends Container {
    onResult;
    _focused = false;
    get focused() {
        return this._focused;
    }
    set focused(value) {
        this._focused = value;
    }
    constructor(title, message, onResult) {
        super();
        this.onResult = onResult;
        this.addChild(new DynamicBorder());
        this.addChild(new Spacer(1));
        this.addChild(new Text(theme.fg("warning", theme.bold(` ${title} `)), 1, 0));
        this.addChild(new Spacer(1));
        this.addChild(new Text(theme.fg("text", ` ${message} `), 1, 0));
        this.addChild(new Spacer(1));
        this.addChild(new Text(theme.fg("dim", ` ${keyHint("tui.select.confirm", "confirm")}  ${keyHint("tui.select.cancel", "cancel")} `), 1, 0));
        this.addChild(new Spacer(1));
        this.addChild(new DynamicBorder());
    }
    handleInput(data) {
        if (data === "\r" || data === "\n") {
            this.onResult(true);
        }
        else if (data === "\x1b") {
            this.onResult(false);
        }
    }
}
//# sourceMappingURL=confirm-dialog.js.map