"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderSelectionContext = renderSelectionContext;
const prompt_text_1 = require("./prompt-text");
const workflow_selection_fields_1 = require("./workflow-selection-fields");
function renderSelectionContext(selection) {
    const templateSlot = (0, workflow_selection_fields_1.getActiveWorkflowSelectionSlotMode)(selection);
    const candidateTemplates = (0, workflow_selection_fields_1.getActiveWorkflowSelectionCandidates)(selection);
    const lines = [
        ...(selection.workflowSurface !== undefined
            ? [`- ${prompt_text_1.PROMPT_TEXT.fieldWorkflowSurface}: ${selection.workflowSurface}`]
            : []),
        ...(templateSlot !== undefined
            ? [
                `- ${prompt_text_1.PROMPT_TEXT.fieldWorkflowTemplateSlot}: ${renderSelectionValue(templateSlot)}`,
            ]
            : []),
        `- ${prompt_text_1.PROMPT_TEXT.fieldExplicitTemplateName}: ${renderSelectionValue((0, workflow_selection_fields_1.getActiveWorkflowSelectionExplicitTemplateName)(selection))}`,
    ];
    if (candidateTemplates !== undefined) {
        lines.push(`- ${prompt_text_1.PROMPT_TEXT.fieldCandidateWorkflowTemplates}:`, ...renderSelectionCandidates(candidateTemplates));
    }
    return lines;
}
function renderSelectionCandidates(candidates) {
    if (!candidates || candidates.length === 0) {
        return [`  ${prompt_text_1.PROMPT_TEXT.none}`];
    }
    return candidates.map((candidate) => [
        `  - ${candidate.templateName}`,
        `description=${renderSelectionValue(candidate.description ?? null)}`,
        `requires.skills=${renderSelectionList(candidate.requiredSkills)}`,
        `requires.mcp=${renderSelectionList(candidate.requiredMcp)}`,
    ].join(" | "));
}
function renderSelectionValue(value) {
    return value === undefined || value === null ? prompt_text_1.PROMPT_TEXT.none : value;
}
function renderSelectionList(values) {
    return values === undefined || values === null || values.length === 0
        ? prompt_text_1.PROMPT_TEXT.none
        : values.join(", ");
}
