import { pickLang } from './i18n.js';
export function projectCommand(cmd, lang) {
    const out = { ...cmd };
    if (cmd.description !== undefined) {
        out.description = pickLang(cmd.description, lang);
    }
    if (cmd.summary !== undefined) {
        out.summary = pickLang(cmd.summary, lang);
    }
    if (cmd.flags) {
        const flags = {};
        for (const [name, flag] of Object.entries(cmd.flags)) {
            const f = flag;
            flags[name] = {
                ...flag,
                description: pickLang(f.description, lang) ?? f.description,
                summary: pickLang(f.summary, lang) ?? f.summary,
            };
        }
        out.flags = flags;
    }
    if (cmd.args) {
        const args = {};
        for (const [name, arg] of Object.entries(cmd.args)) {
            const a = arg;
            args[name] = {
                ...arg,
                description: pickLang(a.description, lang) ?? a.description,
            };
        }
        out.args = args;
    }
    if (Array.isArray(cmd.examples)) {
        out.examples = cmd.examples.map((ex) => {
            if (typeof ex === 'string')
                return pickLang(ex, lang) ?? ex;
            return {
                ...ex,
                description: pickLang(ex.description, lang) ?? ex.description,
            };
        });
    }
    return out;
}
/** Topic 单语视图(无 flags / args / examples)。 */
export function projectTopic(topic, lang) {
    return {
        ...topic,
        description: pickLang(topic.description, lang) ?? topic.description,
    };
}
//# sourceMappingURL=projection.js.map