import select from "@inquirer/select";
import input from "@inquirer/input";
import { getAvailablePromptTemplates } from "./file.js";
export const selectTemplate = async () => {
    const availableTemplates = getAvailablePromptTemplates();
    const answers = await select({
        message: "Select a template to use",
        choices: availableTemplates.map((t) => ({
            name: `${t.filename} - ${t.description}`,
            value: t.filename,
        })),
    });
    return answers;
};
export const getUrlsIfNeeded = async (urls) => {
    if (urls && urls.length > 0)
        return urls;
    const answers = await input({
        message: "Enter URLs for scripting references (comma separated):",
        validate: (inputText) => inputText.trim().length > 0 || "At least one URL is required",
    });
    return answers
        .split(",")
        .map((u) => u.trim())
        .filter((u) => u.length > 0);
};
