"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const chalk_1 = __importDefault(require("chalk"));
const profile_manager_1 = require("../../lib/profile-manager");
class ContextDelete extends core_1.Command {
    async run() {
        const { args, flags } = await this.parse(ContextDelete);
        if (args.name === profile_manager_1.ProfileManager.DEFAULT_PROFILE) {
            this.error(`Cannot delete the '${profile_manager_1.ProfileManager.DEFAULT_PROFILE}' profile`);
        }
        const active = profile_manager_1.ProfileManager.getActiveProfile();
        if (args.name === active) {
            this.error(`Cannot delete the active profile '${args.name}'. Switch to another profile first with 'flui context use <name>'.`);
        }
        if (!profile_manager_1.ProfileManager.profileExists(args.name)) {
            this.error(`Profile '${args.name}' does not exist`);
        }
        if (!flags.force) {
            console.log(chalk_1.default.yellow(`⚠️  This will permanently delete all data in profile '${args.name}'.`));
            console.log(chalk_1.default.dim(`   Re-run with --force to confirm deletion.`));
            return;
        }
        try {
            profile_manager_1.ProfileManager.deleteProfile(args.name);
            console.log(chalk_1.default.green(`✓ Profile '${args.name}' deleted`));
        }
        catch (error) {
            this.error(error instanceof Error ? error.message : String(error));
        }
    }
}
ContextDelete.description = 'Delete a profile';
ContextDelete.examples = [
    '<%= config.bin %> <%= command.id %> dev --force',
];
ContextDelete.args = {
    name: core_1.Args.string({
        required: true,
        description: 'Profile name to delete',
    }),
};
ContextDelete.flags = {
    force: core_1.Flags.boolean({
        char: 'f',
        description: 'Skip confirmation prompt',
        default: false,
    }),
};
exports.default = ContextDelete;
