import { confirmLinkedValue, readLinkedConfig, USE_LINKED_DETAILS, } from "../read-linked-config.js";
import { isInteractiveTerminal } from "../terminal.js";
export async function confirmLinkedConfig(argv) {
    if (argv[USE_LINKED_DETAILS] === false) {
        return;
    }
    if (argv["api-key"]) {
        return;
    }
    if (argv.account !== undefined || argv.project !== undefined) {
        return;
    }
    const linked = await readLinkedConfig(argv);
    if (!linked.accountName || !linked.projectName) {
        return;
    }
    if (!isInteractiveTerminal() || argv.prompt === false) {
        argv.account = linked.accountName;
        argv.project = linked.projectName;
        return;
    }
    const useLinked = await confirmLinkedValue(`Use linked project '${linked.projectName}' in account '${linked.accountName}'?`);
    if (useLinked) {
        argv.account = linked.accountName;
        argv.project = linked.projectName;
        return;
    }
    argv[USE_LINKED_DETAILS] = false;
}
//# sourceMappingURL=confirm-linked-config.js.map