"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLegacyTargetAliasEnvVars = exports.getBuiltinArgv0TargetMap = exports.getRuntimeTargetChoices = exports.getPersistedTargetChoices = exports.formatTargetChoices = exports.isPersistedTargetType = exports.isRuntimeTargetType = exports.PERSISTED_TARGET_TYPES = exports.RUNTIME_TARGET_TYPES = exports.TARGET_METADATA = void 0;
exports.TARGET_METADATA = {
    claude: {
        displayName: 'Claude Code',
        runtimeAliases: [],
        persistedTarget: true,
    },
    droid: {
        displayName: 'Factory Droid',
        runtimeAliases: ['ccs-droid', 'ccsd'],
        legacyAliasEnvVar: 'CCS_DROID_ALIASES',
        persistedTarget: true,
    },
    codex: {
        displayName: 'Codex CLI',
        runtimeAliases: ['ccs-codex', 'ccsx', 'ccsxp'],
        legacyAliasEnvVar: 'CCS_CODEX_ALIASES',
        persistedTarget: false,
    },
};
exports.RUNTIME_TARGET_TYPES = Object.freeze(Object.keys(exports.TARGET_METADATA));
exports.PERSISTED_TARGET_TYPES = Object.freeze(exports.RUNTIME_TARGET_TYPES.filter((target) => exports.TARGET_METADATA[target].persistedTarget));
const RUNTIME_TARGET_SET = new Set(exports.RUNTIME_TARGET_TYPES);
const PERSISTED_TARGET_SET = new Set(exports.PERSISTED_TARGET_TYPES);
function isRuntimeTargetType(value) {
    return typeof value === 'string' && RUNTIME_TARGET_SET.has(value);
}
exports.isRuntimeTargetType = isRuntimeTargetType;
function isPersistedTargetType(value) {
    return typeof value === 'string' && PERSISTED_TARGET_SET.has(value);
}
exports.isPersistedTargetType = isPersistedTargetType;
function formatTargetChoices(targets, conjunction = 'comma') {
    if (targets.length === 0)
        return '';
    if (targets.length === 1)
        return targets[0];
    if (conjunction === 'comma')
        return targets.join(', ');
    if (targets.length === 2)
        return `${targets[0]} or ${targets[1]}`;
    return `${targets.slice(0, -1).join(', ')}, or ${targets[targets.length - 1]}`;
}
exports.formatTargetChoices = formatTargetChoices;
function getPersistedTargetChoices() {
    return formatTargetChoices(exports.PERSISTED_TARGET_TYPES, 'or');
}
exports.getPersistedTargetChoices = getPersistedTargetChoices;
function getRuntimeTargetChoices() {
    return formatTargetChoices(exports.RUNTIME_TARGET_TYPES, 'comma');
}
exports.getRuntimeTargetChoices = getRuntimeTargetChoices;
function getBuiltinArgv0TargetMap() {
    const map = {};
    for (const target of exports.RUNTIME_TARGET_TYPES) {
        for (const alias of exports.TARGET_METADATA[target].runtimeAliases) {
            map[alias] = target;
        }
    }
    return map;
}
exports.getBuiltinArgv0TargetMap = getBuiltinArgv0TargetMap;
function getLegacyTargetAliasEnvVars() {
    const result = {};
    for (const target of exports.RUNTIME_TARGET_TYPES) {
        const envVar = exports.TARGET_METADATA[target].legacyAliasEnvVar;
        if (envVar) {
            result[target] = envVar;
        }
    }
    return result;
}
exports.getLegacyTargetAliasEnvVars = getLegacyTargetAliasEnvVars;
//# sourceMappingURL=target-metadata.js.map