"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SemanticsExpandTermCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const LivingDictionary_1 = require("../services/LivingDictionary");
exports.SemanticsExpandTermCommand = new commander_1.Command("semantics:expand-term")
    .description("Show expanded meaning and related terms for a given term")
    .argument("<term>", "term to expand")
    .action(async (term) => {
    const dict = new LivingDictionary_1.LivingDictionary();
    await dict.load();
    const entry = dict.lookupTerm(term);
    if (!entry) {
        const similar = dict.searchTerms(term);
        if (similar.length > 0) {
            console.log(chalk_1.default.yellow(`\n  "${term}" not found in dictionary.`));
            console.log(chalk_1.default.dim(`  Did you mean one of these?\n`));
            for (const s of similar) {
                console.log(`     · ${chalk_1.default.cyan(s.term)} — ${s.definition.substring(0, 80)}`);
            }
            console.log();
        }
        else {
            console.log(chalk_1.default.yellow(`\n  "${term}" not found in dictionary.\n`));
        }
        return;
    }
    console.log(chalk_1.default.bold(`\n📖 ${entry.term}`));
    console.log(chalk_1.default.dim("─".repeat(50)));
    console.log(`  ${chalk_1.default.bold("Definition:")} ${entry.definition}`);
    console.log(`  ${chalk_1.default.bold("Category:")}   ${entry.category}`);
    console.log(`  ${chalk_1.default.bold("Source:")}     ${entry.source}`);
    console.log(`  ${chalk_1.default.bold("Status:")}     ${entry.status}`);
    if (entry.aliases.length > 0) {
        console.log(`  ${chalk_1.default.bold("Aliases:")}    ${entry.aliases.join(", ")}`);
    }
    if (entry.context) {
        console.log(`  ${chalk_1.default.bold("Context:")}    ${entry.context.substring(0, 200)}`);
    }
    const expanded = dict.expandTerm(term);
    if (expanded.length > 1) {
        console.log(chalk_1.default.dim(`\n  Expanded meaning:`));
        for (const item of expanded) {
            console.log(`     · ${item}`);
        }
    }
    console.log();
});
//# sourceMappingURL=semantics-expand-term.js.map