/**
 * Interactive confirmation for `wk init` when no env approval / flags are provided.
 */
export async function promptTTYConfirmation(promptText, writeLine, readStdinLine) {
    writeLine(promptText);
    let line;
    if (readStdinLine) {
        line = await readStdinLine();
    }
    else if (process.stdin.isTTY) {
        line = await new Promise((resolve) => {
            process.stdin.setEncoding("utf8");
            process.stdin.once("data", (chunk) => {
                resolve(String(chunk).trim());
            });
        });
    }
    else {
        return false;
    }
    if (!line) {
        return false;
    }
    const lower = line.trim().toLowerCase();
    return lower === "y" || lower === "yes";
}
