"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const crypto_1 = tslib_1.__importDefault(require("crypto"));
const inquirer_1 = require("inquirer");
async function promptConfirm(message) {
    return await inquirer_1.prompt([
        {
            message,
            type: 'confirm',
            name: 'answer',
            default: false,
        },
    ]);
}
exports.promptConfirm = promptConfirm;
async function promptMetaData(yes) {
    const answer = yes
        ? { name: 'My Awesome Tutorial' }
        : await inquirer_1.prompt([
            {
                name: 'name',
                message: 'Tutorial Name',
                default: 'My Awesome Tutorial',
            },
            {
                name: 'description',
                message: 'Description',
            },
            {
                name: 'topics',
                message: 'Topics',
            },
            {
                name: 'categories',
                message: 'Categories',
            },
        ]);
    answer.id = crypto_1.default.randomBytes(16).toString('hex');
    // TODO: process user input with inquirer built-ins
    const { topics, categories } = answer;
    if (topics) {
        answer.topics = topics.split(/\W+/);
    }
    else {
        delete answer.topics;
    }
    if (categories) {
        answer.categories = categories.split(/\W+/);
    }
    else {
        delete answer.categories;
    }
    return answer;
}
exports.promptMetaData = promptMetaData;
