"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseEjectArgs = parseEjectArgs;
const catalog_1 = require("../../i18n/catalog");
const EJECT_TARGETS = [
    "workflows",
    "system-prompts",
    "catalog",
    "all",
];
function parseEjectArgs(args, locale = catalog_1.DEFAULT_APP_LOCALE) {
    const [targetToken, ...rest] = args;
    if (targetToken === undefined) {
        throw new Error((0, catalog_1.translate)(locale, "cli.parser.eject.usage"));
    }
    const target = parseEjectTarget(targetToken, locale);
    const values = { target };
    for (const token of rest) {
        switch (token) {
            case "--force":
                values.force = true;
                break;
            default:
                throw new Error((0, catalog_1.translate)(locale, "cli.parser.eject.unknownOption", { token }));
        }
    }
    return values;
}
function parseEjectTarget(value, locale) {
    if (isEjectTarget(value)) {
        return value;
    }
    throw new Error((0, catalog_1.translate)(locale, "cli.parser.eject.invalidTarget", { target: value }));
}
function isEjectTarget(value) {
    return EJECT_TARGETS.some((target) => target === value);
}
