// Plaintext sectioned renderer for the debug dump.
//
// No ANSI colors — output is meant to be pasted into a GitHub issue, so
// we keep it grep-friendly and copyable. Each section is a header line
// followed by `key: value` lines or a free-form text block.
export function renderSection(title, lines) {
    return { title, body: lines.join("\n") };
}
export function renderKeyValues(rows) {
    const maxKey = rows.reduce((m, [k]) => Math.max(m, k.length), 0);
    return rows.map(([k, v]) => `  ${k.padEnd(maxKey, " ")}  ${formatValue(v)}`);
}
function formatValue(value) {
    if (value === undefined)
        return "<unset>";
    if (value === null)
        return "<null>";
    if (typeof value === "string")
        return value;
    if (Array.isArray(value))
        return JSON.stringify(value);
    if (typeof value === "object")
        return JSON.stringify(value);
    return String(value);
}
export function renderDocument(sections, generatedAt) {
    const out = [];
    out.push("=".repeat(72));
    out.push("Doc Detective diagnostic dump");
    if (generatedAt)
        out.push(`Generated: ${generatedAt}`);
    out.push("=".repeat(72));
    for (const s of sections) {
        out.push("");
        out.push(`-- ${s.title} `.padEnd(72, "-"));
        out.push(s.body);
    }
    out.push("");
    out.push("=".repeat(72));
    return out.join("\n");
}
//# sourceMappingURL=render.js.map