import {
  FileText,
  Code,
  Bug,
  Wrench,
  Database,
  FileSearch,
  MessageCircle
} from 'lucide-react';
import { Tool, ToolCategory, ToolStatus } from '../types/tool';

/**
 * 工具数据配置
 * 定义所有可用的工具及其属性
 */
export const TOOLS_DATA: Tool[] = [
  {
    id: 'data-cleaning',
    name: 'AI检索图片/数据清洗',
    description: 'JSONL格式数据去重处理工具，支持基于URI字段的精确匹配去重',
    longDescription: '专业的数据清洗工具，支持JSONL格式文件的批量处理。通过URI字段进行精确匹配，快速去除重复数据，提供实时进度显示和详细的处理统计信息。',
    icon: FileText,
    route: '/tools/data-cleaning',
    category: ToolCategory.DATA_PROCESSING,
    status: ToolStatus.STABLE,
    tags: ['JSONL', '数据去重', '批量处理', 'URI匹配'],
    isPopular: true,
    version: '1.0.0',
    lastUpdated: '2024-01-15'
  },
  {
    id: 'json-parser',
    name: '容错JSON解析器',
    description: '基于Tree-sitter的大模型JSON容错解析器，支持处理不规范的JSON数据',
    longDescription: '高性能的JSON解析工具，专门处理大模型返回的不规范JSON数据。支持注释、无引号键名、尾随逗号等非标准格式，提供多种错误恢复策略。',
    icon: Code,
    route: '/tools/json-parser',
    category: ToolCategory.DEVELOPMENT,
    status: ToolStatus.STABLE,
    tags: ['JSON解析', 'Tree-sitter', '容错处理', '大模型'],
    isNew: true,
    version: '2.1.0',
    lastUpdated: '2024-01-20'
  },
  {
    id: 'debug-panel',
    name: 'JSON解析器调试面板',
    description: '用于测试后端命令是否正常工作的调试工具面板',
    longDescription: '开发者调试工具，提供完整的后端命令测试功能。支持实时测试各种JSON解析场景，查看详细的错误信息和性能统计数据。',
    icon: Bug,
    route: '/tools/debug-panel',
    category: ToolCategory.DEVELOPMENT,
    status: ToolStatus.BETA,
    tags: ['调试工具', '后端测试', '命令测试', '开发辅助'],
    version: '1.2.0',
    lastUpdated: '2024-01-18'
  },
  {
    id: 'ai-chat',
    name: 'AI 智能聊天',
    description: '基于 RAG 检索增强生成的智能对话助手，支持上下文保持和知识问答',
    longDescription: '先进的AI聊天工具，基于RAG（检索增强生成）技术，能够根据知识库提供准确的答案。支持上下文保持，最多保留3条对话记录，实时显示响应时间和参考来源。',
    icon: MessageCircle,
    route: '/tools/ai-chat',
    category: ToolCategory.AI_TOOLS,
    status: ToolStatus.STABLE,
    tags: ['AI聊天', 'RAG', '知识问答', '智能助手', '上下文保持'],
    isNew: true,
    isPopular: true,
    version: '1.0.0',
    lastUpdated: '2024-01-21'
  }
];

/**
 * 根据ID获取工具信息
 */
export const getToolById = (id: string): Tool | undefined => {
  return TOOLS_DATA.find(tool => tool.id === id);
};

/**
 * 根据分类获取工具列表
 */
export const getToolsByCategory = (category: ToolCategory): Tool[] => {
  return TOOLS_DATA.filter(tool => tool.category === category);
};

/**
 * 获取热门工具列表
 */
export const getPopularTools = (): Tool[] => {
  return TOOLS_DATA.filter(tool => tool.isPopular);
};

/**
 * 获取新功能工具列表
 */
export const getNewTools = (): Tool[] => {
  return TOOLS_DATA.filter(tool => tool.isNew);
};

/**
 * 搜索工具
 */
export const searchTools = (query: string): Tool[] => {
  const lowercaseQuery = query.toLowerCase();
  return TOOLS_DATA.filter(tool => 
    tool.name.toLowerCase().includes(lowercaseQuery) ||
    tool.description.toLowerCase().includes(lowercaseQuery) ||
    tool.tags?.some(tag => tag.toLowerCase().includes(lowercaseQuery))
  );
};

/**
 * 工具分类配置
 */
export const TOOL_CATEGORIES = [
  {
    id: ToolCategory.DATA_PROCESSING,
    name: '数据处理',
    description: '数据清洗、转换和处理工具',
    icon: Database,
    color: 'purple'
  },
  {
    id: ToolCategory.DEVELOPMENT,
    name: '开发调试',
    description: '开发和调试相关工具',
    icon: Code,
    color: 'indigo'
  },
  {
    id: ToolCategory.FILE_PROCESSING,
    name: '文件处理',
    description: '文件操作和处理工具',
    icon: FileSearch,
    color: 'orange'
  },
  {
    id: ToolCategory.AI_TOOLS,
    name: 'AI工具',
    description: '人工智能相关工具',
    icon: Wrench,
    color: 'pink'
  },
  {
    id: ToolCategory.UTILITIES,
    name: '实用工具',
    description: '通用实用工具集合',
    icon: Wrench,
    color: 'teal'
  }
];

/**
 * 获取分类配置
 */
export const getCategoryConfig = (category: ToolCategory) => {
  return TOOL_CATEGORIES.find(cat => cat.id === category);
};
