"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printErrorWithHelp = printErrorWithHelp;
exports.printLoginRequired = printLoginRequired;
exports.printUnknownEnvironment = printUnknownEnvironment;
exports.printConfigEnvironmentMissing = printConfigEnvironmentMissing;
exports.printNetworkIssue = printNetworkIssue;
exports.printCatalogueMissing = printCatalogueMissing;
exports.printInvalidCatalogue = printInvalidCatalogue;
const GENERAL_HELP_LINE = 'Use "playdrop help" for general help, or run "playdrop help <command>" to learn more about a specific command.';
function printErrorWithHelp(problem, suggestions, options = {}) {
    const { command, includeGeneralHelp = true } = options;
    console.error(problem);
    for (const suggestion of suggestions) {
        if (suggestion) {
            console.error(suggestion);
        }
    }
    if (!includeGeneralHelp) {
        return;
    }
    if (command) {
        console.error(`Use "playdrop help ${command}" for detailed guidance, or "playdrop help" for general help.`);
    }
    else {
        console.error(GENERAL_HELP_LINE);
    }
}
function printLoginRequired(context, command) {
    printErrorWithHelp(`${context} requires you to be logged in.`, [
        'Run "playdrop auth login" to authenticate.',
        'Use "playdrop auth whoami" to verify your current status.',
    ], { command });
}
function printUnknownEnvironment(env, available, command) {
    const listLine = available ? `Available environments: ${available}.` : '';
    const suggestions = [
        listLine,
        'Run "playdrop auth login --env <env>" to store a supported environment before retrying.',
    ].filter(Boolean);
    printErrorWithHelp(`Environment "${env}" is not supported.`, suggestions, { command });
}
function printConfigEnvironmentMissing(command) {
    printErrorWithHelp('No environment is configured yet.', [
        'Run "playdrop auth login" to choose an environment and save your credentials.',
        'Use "playdrop auth whoami" after logging in to confirm your status.',
    ], { command });
}
function printNetworkIssue(context, command) {
    printErrorWithHelp(context, [
        'Check your network connection and ensure the Playdrop API is reachable.',
        'Retry once connectivity is restored.'
    ], { command });
}
function printCatalogueMissing(directory, command) {
    printErrorWithHelp(`Processing "${directory}" requires a catalogue.json at the root, but none was found.`, [
        'Run "playdrop project init ." inside that folder to create the starter files without changing existing content.',
        'Use "playdrop project create app <name>" to register your apps and add them to the catalogue.'
    ], { command });
}
function printInvalidCatalogue(command) {
    printErrorWithHelp('No valid entries were found in the catalogue files.', [
        'Fix the catalogue.json files highlighted above, then rerun the command.'
    ], { command });
}
