/**
 * CLI theme — palette, markdown theme, and syntax highlighting.
 *
 * Adapted from OpenClaw's TUI theme with a cyan accent palette.
 * Uses chalk for hex-color styling and cli-highlight for code blocks.
 */
import chalk from 'chalk';
import { highlight, supportsLanguage } from 'cli-highlight';
// ── Color palette ───────────────────────────────────────────────────────────
export const palette = {
    text: '#E8E3D5',
    dim: '#7B7F87',
    accent: '#22D3EE',
    accentSoft: '#67E8F9',
    border: '#3C414B',
    userBg: '#2B2F36',
    userText: '#F3EEE0',
    systemText: '#9BA3B2',
    toolPendingBg: '#1F2A2F',
    toolSuccessBg: '#1E2D23',
    toolErrorBg: '#2F1F1F',
    toolTitle: '#22D3EE',
    toolOutput: '#E1DACB',
    quote: '#8CC8FF',
    quoteBorder: '#3B4D6B',
    code: '#F0C987',
    codeBlock: '#1E232A',
    codeBorder: '#6B7280',
    link: '#7DD3A5',
    error: '#F97066',
    success: '#7DD3A5',
};
// ── Helpers ─────────────────────────────────────────────────────────────────
const fg = (hex) => (text) => chalk.hex(hex)(text);
function createSyntaxTheme(fallback) {
    return {
        keyword: chalk.hex('#C586C0'),
        built_in: chalk.hex('#4EC9B0'),
        type: chalk.hex('#4EC9B0'),
        literal: chalk.hex('#569CD6'),
        number: chalk.hex('#B5CEA8'),
        string: chalk.hex('#CE9178'),
        regexp: chalk.hex('#D16969'),
        symbol: chalk.hex('#B5CEA8'),
        class: chalk.hex('#4EC9B0'),
        function: chalk.hex('#DCDCAA'),
        title: chalk.hex('#DCDCAA'),
        params: chalk.hex('#9CDCFE'),
        comment: chalk.hex('#6A9955'),
        doctag: chalk.hex('#608B4E'),
        meta: chalk.hex('#9CDCFE'),
        'meta-keyword': chalk.hex('#C586C0'),
        'meta-string': chalk.hex('#CE9178'),
        section: chalk.hex('#DCDCAA'),
        tag: chalk.hex('#569CD6'),
        name: chalk.hex('#9CDCFE'),
        attr: chalk.hex('#9CDCFE'),
        attribute: chalk.hex('#9CDCFE'),
        variable: chalk.hex('#9CDCFE'),
        bullet: chalk.hex('#D7BA7D'),
        code: chalk.hex('#CE9178'),
        emphasis: chalk.italic,
        strong: chalk.bold,
        formula: chalk.hex('#C586C0'),
        link: chalk.hex('#4EC9B0'),
        quote: chalk.hex('#6A9955'),
        addition: chalk.hex('#B5CEA8'),
        deletion: chalk.hex('#F44747'),
        'selector-tag': chalk.hex('#D7BA7D'),
        'selector-id': chalk.hex('#D7BA7D'),
        'selector-class': chalk.hex('#D7BA7D'),
        'selector-attr': chalk.hex('#D7BA7D'),
        'selector-pseudo': chalk.hex('#D7BA7D'),
        'template-tag': chalk.hex('#C586C0'),
        'template-variable': chalk.hex('#9CDCFE'),
        default: fallback,
    };
}
const syntaxTheme = createSyntaxTheme(fg(palette.code));
/**
 * Highlight code with syntax coloring.
 * Returns an array of lines with ANSI escape codes.
 */
function highlightCode(code, lang) {
    try {
        const language = lang && supportsLanguage(lang) ? lang : undefined;
        const highlighted = highlight(code, {
            language,
            theme: syntaxTheme,
            ignoreIllegals: true,
        });
        return highlighted.split('\n');
    }
    catch {
        return code.split('\n').map((line) => fg(palette.code)(line));
    }
}
// ── Markdown theme for pi-tui ───────────────────────────────────────────────
export const markdownTheme = {
    heading: (text) => chalk.bold(fg(palette.accent)(text)),
    link: (text) => fg(palette.link)(text),
    linkUrl: (text) => chalk.dim(text),
    code: (text) => fg(palette.code)(text),
    codeBlock: (text) => fg(palette.code)(text),
    codeBlockBorder: (text) => fg(palette.codeBorder)(text),
    quote: (text) => fg(palette.quote)(text),
    quoteBorder: (text) => fg(palette.quoteBorder)(text),
    hr: (text) => fg(palette.border)(text),
    listBullet: (text) => fg(palette.accentSoft)(text),
    bold: (text) => chalk.bold(text),
    italic: (text) => chalk.italic(text),
    strikethrough: (text) => chalk.strikethrough(text),
    underline: (text) => chalk.underline(text),
    highlightCode,
};
//# sourceMappingURL=theme.js.map