"use strict";
// src/cli/ChatBanner.ts
// OPENLIFE banner — pixel-block letters + Cristo Redentor silhouette.
// Reference: Downloads/ChatGPT Image 15 de mai. de 2026, 13_58_20.png
Object.defineProperty(exports, "__esModule", { value: true });
exports.openlifeBanner = openlifeBanner;
exports.inventoryPanel = inventoryPanel;
exports.bootOutput = bootOutput;
const MatrixTheme_1 = require("./MatrixTheme");
// Pixel-block OPENLIFE — 5 rows tall. Each letter is 7 cols wide + 1 gap.
// Built from full block (█) so it stays Matrix-green and crisp.
const OPENLIFE_BLOCK = [
    ' ██████  ██████  ███████ ███    ██ ██      ██ ███████ ███████',
    '██    ██ ██   ██ ██      ████   ██ ██      ██ ██      ██     ',
    '██    ██ ██████  █████   ██ ██  ██ ██      ██ █████   █████  ',
    '██    ██ ██      ██      ██  ██ ██ ██      ██ ██      ██     ',
    ' ██████  ██      ███████ ██   ████ ███████ ██ ██      ███████',
];
// Cristo Redentor silhouette — stylized to fit ~16 cols × 8 rows.
// Built from block characters with the famous T-shaped pose centered.
const CRISTO = [
    '          ▄          ',
    '        ▟███▙        ',
    '    ▄▄▟▓▓███▓▓▙▄▄    ', // arms outstretched
    '         ███         ',
    '         ███         ',
    '       ▟█████▙       ',
    '     ▟▓▓█████▓▓▙     ', // robe widens
    '   ▟▓░▒▓█████▓▒░▓▙   ',
    ' ▟▓░░▒▒▓██▓██▓▒▒░░▓▙ ', // base of statue
    '▟▓░░░░▒▒▒▓▓▓▓▓▒▒▒░░░░▓▙',
];
// Mountain/horizon line beneath the statue (Pão de Açúcar feel).
const HORIZON = '▁▂▃▄▆▇█▇▆▅▄▃▂▁▁▂▃▅▇█▇▆▄▃▂▁▁▂▄▅▇█▇▅▄▂▁▁▂▃▅▇█▇▅▃▂▁';
/**
 * Render the full OpenLife boot banner.
 * Pure function — no side effects. Caller `console.log`s the result.
 *
 * In non-TTY environments (CI, piped output, NO_COLOR), returns plain text
 * without ANSI codes so log scrapers stay readable.
 */
function openlifeBanner() {
    const useColor = (0, MatrixTheme_1.supportsColor)();
    const head = useColor ? MatrixTheme_1.MATRIX.head : '';
    const body = useColor ? MatrixTheme_1.MATRIX.body : '';
    const tail = useColor ? MatrixTheme_1.MATRIX.tail : '';
    const reset = useColor ? MatrixTheme_1.ANSI.reset : '';
    const lines = [];
    lines.push('');
    // OPENLIFE in bright matrix green
    for (const row of OPENLIFE_BLOCK) {
        lines.push(`  ${head}${row}${reset}`);
    }
    lines.push('');
    // Cristo silhouette in mid green (centered relative to OPENLIFE width)
    const bannerWidth = OPENLIFE_BLOCK[0].length;
    for (const row of CRISTO) {
        lines.push(`  ${body}${(0, MatrixTheme_1.center)(row, bannerWidth)}${reset}`);
    }
    // Horizon line in faded green
    lines.push(`  ${tail}${(0, MatrixTheme_1.center)(HORIZON, bannerWidth)}${reset}`);
    lines.push('');
    return lines.join('\n');
}
function inventoryPanel(stats) {
    const useColor = (0, MatrixTheme_1.supportsColor)();
    const head = useColor ? MatrixTheme_1.MATRIX.head : '';
    const body = useColor ? MatrixTheme_1.MATRIX.body : '';
    const tail = useColor ? MatrixTheme_1.MATRIX.tail : '';
    const reset = useColor ? MatrixTheme_1.ANSI.reset : '';
    // Truncate cwd to fit; keep last 50 chars (the meaningful tail).
    const cwd = stats.cwd.length > 50 ? '…' + stats.cwd.slice(-49) : stats.cwd;
    const w = 64;
    const top = '┌─ openlife ' + '─'.repeat(w - 12) + '┐';
    // Bottom must match top width exactly (both 65 chars: ┌ + 63 chars + ┐).
    const bot = '└' + '─'.repeat(top.length - 2) + '┘';
    const row = (label, value) => {
        const left = `${label}  ${value}`.padEnd(w - 2, ' ');
        return `│ ${body}${left}${reset}│`;
    };
    const lines = [];
    lines.push(`${tail}${top}${reset}`);
    lines.push(row('VERSION:'.padEnd(10), stats.version));
    lines.push(row('MODEL:  '.padEnd(10), stats.model));
    lines.push(row('SESSION:'.padEnd(10), stats.sessionId));
    lines.push(row('CWD:    '.padEnd(10), cwd));
    const nameRow = (label, count, names) => {
        const listed = (names && names.length > 0)
            ? names.slice(0, 7).join(', ') + (count > 7 ? '...' : '')
            : String(count);
        const left = `${(label + ' (' + count + ')').padEnd(14)}  ${listed}`;
        return `│ ${body}${left.padEnd(w - 2)}${reset}│`;
    };
    lines.push(nameRow('Agents', stats.agents, stats.agentNames));
    lines.push(nameRow('Squads', stats.squads, stats.squadNames));
    lines.push(nameRow('Skills', stats.skills, stats.skillNames));
    lines.push(nameRow('MCPs', stats.mcps, stats.mcpNames));
    lines.push(`│ ${tail}${'type /help for commands  ·  /agents /skills /squads to explore'.padEnd(w - 2)}${reset}│`);
    lines.push(`${tail}${bot}${reset}`);
    // Wrap top/bot in head color for emphasis
    lines[0] = `${head}${top}${reset}`;
    lines[lines.length - 1] = `${head}${bot}${reset}`;
    return lines.join('\n');
}
/**
 * Combined boot output (banner + inventory panel + welcome line).
 * Useful test handle and one-shot console.log target from ChatTui.
 */
function bootOutput(stats) {
    const useColor = (0, MatrixTheme_1.supportsColor)();
    const body = useColor ? MatrixTheme_1.MATRIX.body : '';
    const tail = useColor ? MatrixTheme_1.MATRIX.tail : '';
    const reset = useColor ? MatrixTheme_1.ANSI.reset : '';
    return [
        openlifeBanner(),
        inventoryPanel(stats),
        '',
        `${body}Welcome to OpenLife. Type your message or /help for commands.${reset}`,
        `${tail}${'━'.repeat(60)}${reset}`,
        '',
    ].join('\n');
}
