/**
 * Terminal 主题配置
 */

export interface TerminalTheme {
    name: string;
    label: string;
    theme: {
        background: string;
        foreground: string;
        cursor: string;
        black: string;
        red: string;
        green: string;
        yellow: string;
        blue: string;
        magenta: string;
        cyan: string;
        white: string;
        brightBlack: string;
        brightRed: string;
        brightGreen: string;
        brightYellow: string;
        brightBlue: string;
        brightMagenta: string;
        brightCyan: string;
        brightWhite: string;
        selectionBackground?: string;
        selectionForeground?: string;
    };
}

export const TERMINAL_THEMES: TerminalTheme[] = [
    {
        name: 'dark',
        label: '暗色（默认）',
        theme: {
            background: '#1e1e1e',
            foreground: '#d4d4d4',
            cursor: '#d4d4d4',
            black: '#000000',
            red: '#cd3131',
            green: '#0dbc79',
            yellow: '#e5e510',
            blue: '#2472c8',
            magenta: '#bc3fbc',
            cyan: '#11a8cd',
            white: '#e5e5e5',
            brightBlack: '#666666',
            brightRed: '#f14c4c',
            brightGreen: '#23d18b',
            brightYellow: '#f5f543',
            brightBlue: '#3b8eea',
            brightMagenta: '#d670d6',
            brightCyan: '#29b8db',
            brightWhite: '#e5e5e5',
            selectionBackground: 'rgba(255, 255, 255, 0.3)',
        },
    },
    {
        name: 'monokai',
        label: 'Monokai（摩诺凯）',
        theme: {
            background: '#272822',
            foreground: '#f8f8f2',
            cursor: '#f8f8f0',
            black: '#272822',
            red: '#f92672',
            green: '#a6e22e',
            yellow: '#f4bf75',
            blue: '#66d9ef',
            magenta: '#ae81ff',
            cyan: '#a1efe4',
            white: '#f8f8f2',
            brightBlack: '#75715e',
            brightRed: '#f92672',
            brightGreen: '#a6e22e',
            brightYellow: '#f4bf75',
            brightBlue: '#66d9ef',
            brightMagenta: '#ae81ff',
            brightCyan: '#a1efe4',
            brightWhite: '#f9f8f5',
            selectionBackground: 'rgba(255, 255, 255, 0.3)',
        },
    },
    {
        name: 'dracula',
        label: 'Dracula（德古拉）',
        theme: {
            background: '#282a36',
            foreground: '#f8f8f2',
            cursor: '#f8f8f2',
            black: '#21222c',
            red: '#ff5555',
            green: '#50fa7b',
            yellow: '#f1fa8c',
            blue: '#bd93f9',
            magenta: '#ff79c6',
            cyan: '#8be9fd',
            white: '#f8f8f2',
            brightBlack: '#6272a4',
            brightRed: '#ff6e6e',
            brightGreen: '#69ff94',
            brightYellow: '#ffffa5',
            brightBlue: '#d6acff',
            brightMagenta: '#ff92df',
            brightCyan: '#a4ffff',
            brightWhite: '#ffffff',
            selectionBackground: 'rgba(68, 71, 90, 0.5)',
        },
    },
    {
        name: 'solarized-dark',
        label: 'Solarized Dark（太阳化暗色）',
        theme: {
            background: '#002b36',
            foreground: '#839496',
            cursor: '#839496',
            black: '#073642',
            red: '#dc322f',
            green: '#859900',
            yellow: '#b58900',
            blue: '#268bd2',
            magenta: '#d33682',
            cyan: '#2aa198',
            white: '#eee8d5',
            brightBlack: '#002b36',
            brightRed: '#cb4b16',
            brightGreen: '#586e75',
            brightYellow: '#657b83',
            brightBlue: '#839496',
            brightMagenta: '#6c71c4',
            brightCyan: '#93a1a1',
            brightWhite: '#fdf6e3',
            selectionBackground: 'rgba(7, 54, 66, 0.5)',
        },
    },
    {
        name: 'nord',
        label: 'Nord（北欧）',
        theme: {
            background: '#2e3440',
            foreground: '#d8dee9',
            cursor: '#d8dee9',
            black: '#3b4252',
            red: '#bf616a',
            green: '#a3be8c',
            yellow: '#ebcb8b',
            blue: '#81a1c1',
            magenta: '#b48ead',
            cyan: '#88c0d0',
            white: '#e5e9f0',
            brightBlack: '#4c566a',
            brightRed: '#bf616a',
            brightGreen: '#a3be8c',
            brightYellow: '#ebcb8b',
            brightBlue: '#81a1c1',
            brightMagenta: '#b48ead',
            brightCyan: '#8fbcbb',
            brightWhite: '#eceff4',
            selectionBackground: 'rgba(76, 86, 106, 0.5)',
        },
    },
    {
        name: 'solarized-light',
        label: 'Solarized Light（太阳化亮色）',
        theme: {
            background: '#fdf6e3',
            foreground: '#657b83',
            cursor: '#657b83',
            black: '#073642',
            red: '#dc322f',
            green: '#859900',
            yellow: '#b58900',
            blue: '#268bd2',
            magenta: '#d33682',
            cyan: '#2aa198',
            white: '#eee8d5',
            brightBlack: '#002b36',
            brightRed: '#cb4b16',
            brightGreen: '#586e75',
            brightYellow: '#657b83',
            brightBlue: '#839496',
            brightMagenta: '#6c71c4',
            brightCyan: '#93a1a1',
            brightWhite: '#fdf6e3',
            selectionBackground: 'rgba(7, 54, 66, 0.2)',
        },
    },
    {
        name: 'gruvbox-dark',
        label: 'Gruvbox Dark（复古暗色）',
        theme: {
            background: '#282828',
            foreground: '#ebdbb2',
            cursor: '#ebdbb2',
            black: '#282828',
            red: '#cc241d',
            green: '#98971a',
            yellow: '#d79921',
            blue: '#458588',
            magenta: '#b16286',
            cyan: '#689d6a',
            white: '#a89984',
            brightBlack: '#928374',
            brightRed: '#fb4934',
            brightGreen: '#b8bb26',
            brightYellow: '#fabd2f',
            brightBlue: '#83a598',
            brightMagenta: '#d3869b',
            brightCyan: '#8ec07c',
            brightWhite: '#ebdbb2',
            selectionBackground: 'rgba(235, 219, 178, 0.3)',
        },
    },
    {
        name: 'one-dark',
        label: 'One Dark（单色暗）',
        theme: {
            background: '#282c34',
            foreground: '#abb2bf',
            cursor: '#528bff',
            black: '#282c34',
            red: '#e06c75',
            green: '#98c379',
            yellow: '#e5c07b',
            blue: '#61afef',
            magenta: '#c678dd',
            cyan: '#56b6c2',
            white: '#abb2bf',
            brightBlack: '#5c6370',
            brightRed: '#e06c75',
            brightGreen: '#98c379',
            brightYellow: '#e5c07b',
            brightBlue: '#61afef',
            brightMagenta: '#c678dd',
            brightCyan: '#56b6c2',
            brightWhite: '#ffffff',
            selectionBackground: 'rgba(171, 178, 191, 0.3)',
        },
    },
    {
        name: 'material',
        label: 'Material（质感）',
        theme: {
            background: '#263238',
            foreground: '#eeffff',
            cursor: '#ffcc00',
            black: '#000000',
            red: '#e53935',
            green: '#91b859',
            yellow: '#ffb62c',
            blue: '#6182b8',
            magenta: '#7c4dff',
            cyan: '#39adb5',
            white: '#ffffff',
            brightBlack: '#000000',
            brightRed: '#ff5370',
            brightGreen: '#c3e88d',
            brightYellow: '#ffcb6b',
            brightBlue: '#82aaff',
            brightMagenta: '#c792ea',
            brightCyan: '#89ddff',
            brightWhite: '#ffffff',
            selectionBackground: 'rgba(128, 203, 196, 0.3)',
        },
    },
    {
        name: 'github',
        label: 'GitHub（GitHub）',
        theme: {
            background: '#ffffff',
            foreground: '#24292e',
            cursor: '#044289',
            black: '#24292e',
            red: '#d73a49',
            green: '#22863a',
            yellow: '#b08800',
            blue: '#0366d6',
            magenta: '#6f42c1',
            cyan: '#1b7c83',
            white: '#6a737d',
            brightBlack: '#586069',
            brightRed: '#cb2431',
            brightGreen: '#22863a',
            brightYellow: '#b08800',
            brightBlue: '#005cc5',
            brightMagenta: '#5a32a3',
            brightCyan: '#3192aa',
            brightWhite: '#959da5',
            selectionBackground: 'rgba(3, 102, 214, 0.2)',
        },
    },
    {
        name: 'tokyo-night',
        label: 'Tokyo Night（东京夜）',
        theme: {
            background: '#1a1b26',
            foreground: '#c0caf5',
            cursor: '#c0caf5',
            black: '#15161e',
            red: '#f7768e',
            green: '#9ece6a',
            yellow: '#e0af68',
            blue: '#7aa2f7',
            magenta: '#bb9af7',
            cyan: '#7dcfff',
            white: '#a9b1d6',
            brightBlack: '#414868',
            brightRed: '#f7768e',
            brightGreen: '#9ece6a',
            brightYellow: '#e0af68',
            brightBlue: '#7aa2f7',
            brightMagenta: '#bb9af7',
            brightCyan: '#7dcfff',
            brightWhite: '#c0caf5',
            selectionBackground: 'rgba(192, 202, 245, 0.3)',
        },
    },
];

export const getThemeByName = (name: string): TerminalTheme => {
    return TERMINAL_THEMES.find(t => t.name === name) || TERMINAL_THEMES[0];
};
