"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.feedbackCommand = void 0;
const helpers_1 = require("./helpers");
const context_1 = require("./context");
exports.feedbackCommand = {
    command: 'feedback [words..]',
    describe: 'Send product feedback to the Amplitude team',
    builder: (yargs) => yargs
        .positional('words', {
        describe: 'Feedback message (positional, space-separated)',
        type: 'string',
        array: true,
    })
        .options({
        message: {
            alias: 'm',
            describe: 'Feedback message',
            type: 'string',
        },
    }),
    handler: (argv) => {
        void (async () => {
            (0, helpers_1.setUI)(new helpers_1.LoggingUI());
            const fromFlag = typeof argv.message === 'string' ? argv.message.trim() : '';
            const positional = Array.isArray(argv.words)
                ? argv.words.join(' ').trim()
                : '';
            const message = (fromFlag || positional).trim();
            if (!message) {
                (0, helpers_1.getUI)().log.error(`Usage: ${context_1.CLI_INVOCATION} feedback <message>  or  feedback --message <message>`);
                process.exit(1);
                return;
            }
            try {
                const { trackWizardFeedback } = await import('../utils/track-wizard-feedback.js');
                await trackWizardFeedback(message);
                (0, helpers_1.getUI)().log.success('Thanks — your feedback was sent.');
                process.exit(0);
            }
            catch (e) {
                (0, helpers_1.getUI)().log.error(`Feedback failed: ${e instanceof Error ? e.message : String(e)}`);
                process.exit(1);
            }
        })();
    },
};
