/**
 * 全局 Mock 数据管理系统
 *
 * 统一管理所有页面的 Mock 数据，支持：
 * 1. 按页面类型配置不同的数据展示
 * 2. 支持字段级别的显示/隐藏控制
 * 3. 支持数据过滤（如：我创建的应用 vs 全部应用）
 * 4. 支持用户上下文（当前登录用户）
 */

// ==================== 类型定义 ====================

export interface AppCardData {
    id: string;
    name: string;
    description: string;
    icon?: string;
    iconImage?: string;
    iconBgColor?: 'blue' | 'indigo' | 'teal' | 'purple' | 'rose' | 'cyan' | 'amber' | 'green' | 'orange';
    creator?: string;  // 创建者
    creatorId?: string;  // 创建者 ID
    maintainers?: string[];  // 维护者 ID 列表
    maintainerNames?: string[];  // 维护者姓名列表
    tags?: Array<{
        label: string;
        color: 'slate' | 'blue' | 'indigo' | 'teal' | 'purple' | 'rose' | 'cyan' | 'amber';
    }>;
    certification?: string;
    isHot?: boolean;
    viewCount?: number;  // 浏览次数
    favoriteCount?: number;  // 收藏次数
    createTime?: string;  // 创建时间
    updateTime?: string;  // 更新时间
    status?: 'draft' | 'pending' | 'approved' | 'rejected';  // 应用状态
    department?: string;  // 所属部门
    visible?: 'public' | 'private' | 'vip';  // 可见性
}

// 页面类型枚举
export type PageType =
    | 'appPlaza'           // 全部 RAG 应用（应用广场）
    | 'professional'       // 专业知识
    | 'functional'         // 职能管理
    | 'project'            // 项目级应用
    | 'myApps'             // 我创建的应用
    | 'allApps'            // 全部应用（我创建的应用页面 TAB）
    | 'maintainerApps'     // 我可以维护的应用
    | 'knowledgeLib'       // 知识库列表
    | 'datasetManagement'  // 数据集管理
    | 'evaluationTask'     // 评估任务
    | 'revisionTool'       // 修订工具
    ;

// 页面配置接口
export interface PageConfig {
    showCreator?: boolean;      // 是否显示创建者字段
    showActions?: boolean;      // 是否显示操作按钮（分享/收藏）
    showCertification?: boolean; // 是否显示认证标识
    showTags?: boolean;         // 是否显示标签
    showHot?: boolean;          // 是否显示热门标识
    showViewCount?: boolean;    // 是否显示浏览次数
    showFavoriteCount?: boolean; // 是否显示收藏次数
    showStatus?: boolean;       // 是否显示状态
    showDepartment?: boolean;   // 是否显示部门
    showVisible?: boolean;      // 是否显示可见性
    filterByCurrentUser?: boolean; // 是否只显示当前用户的数据
    title?: string;             // 页面标题
    description?: string;       // 页面描述
}

// 当前登录用户信息
export interface CurrentUser {
    id: string;
    name: string;
    nickName?: string;
    department?: string;
    userType?: string;
}

// ==================== 模拟用户数据 ====================

// 当前登录用户（可通过 LocalStorage 获取真实用户信息）
export const mockCurrentUser: CurrentUser = {
    id: 'user_003',
    name: 'wangwu',
    nickName: '王五',
    department: '大数据局',
    userType: 'admin',
};

// ==================== 基础数据列表（用于表单下拉框等） ====================

// 应用类型列表
export const mockAppTypes = [
    { label: '智能问答', value: '10', dictCode: '10' },
    { label: '文档分析', value: '20', dictCode: '20' },
    { label: '数据分析', value: '30', dictCode: '30' },
    { label: '公文处理', value: '40', dictCode: '40' },
    { label: '会议助手', value: '50', dictCode: '50' },
    { label: '专业应用', value: '62', dictCode: '62' },
];

// 是否公开类型
export const mockAppVisibleTypes = [
    { label: '公开', value: '0' },
    { label: '私有', value: '1' },
];

// 用户类型
export const mockUserTypes = [
    { label: '普通用户', value: 'common' },
    { label: 'VIP 用户', value: 'vip' },
    { label: '管理员', value: 'admin' },
];

// 项目列表（级联数据）
export const mockAppProjects = [
    {
        label: '政务服务中心',
        value: '100',
        children: [
            { label: '窗口服务', value: '101' },
            { label: '在线咨询', value: '102' },
        ],
    },
    {
        label: '市场监管局',
        value: '200',
        children: [
            { label: '企业注册', value: '201' },
            { label: '质量监管', value: '202' },
        ],
    },
    {
        label: '大数据局',
        value: '300',
        children: [
            { label: '数据共享', value: '301' },
            { label: '智慧城市', value: '302' },
        ],
    },
];

// 模型列表
export const mockModelList = [
    {
        model: 'Qwen3-30B',
        modelName: 'Qwen3-30B',
        modelCode: 'Qwen3-30B',
        maxToken: 4096,
        bindingModel: 'bge-reranker-v2-m3',
    },
    {
        model: 'Qwen3-14B',
        modelName: 'Qwen3-14B',
        modelCode: 'Qwen3-14B',
        maxToken: 2048,
        bindingModel: 'bge-reranker-v2-m3',
    },
    {
        model: 'Qwen3-7B',
        modelName: 'Qwen3-7B',
        modelCode: 'Qwen3-7B',
        maxToken: 1024,
        bindingModel: 'bge-reranker-base',
    },
];

// 重排模型列表
export const mockRerankModelList = [
    { model: 'bge-reranker-v2-m3', maxToken: 512, bindingModel: '' },
    { model: 'bge-reranker-base', maxToken: 512, bindingModel: '' },
    { model: 'reranker-2', maxToken: 512, bindingModel: '' },
];

// 知识库列表
export const mockKnowledgeList = [
    { label: '政务服务知识库', value: 'know_001', createBy: 'user_001' },
    { label: '市场监管法规库', value: 'know_002', createBy: 'user_002' },
    { label: '财税政策知识库', value: 'know_003', createBy: 'user_003' },
    { label: '人社服务知识库', value: 'know_004', createBy: 'user_004' },
    { label: '医保政策库', value: 'know_005', createBy: 'user_005' },
];

// 用户列表数据（用于 VIP 用户选择）
export const mockUserList = [
    {
        key: '1',
        name: '张三',
        nickName: '小张',
        userName: 'zhangsan',
        deptName: '政务服务中心',
        userTypeName: '普通用户',
        userId: 'user_001',
    },
    {
        key: '2',
        name: '李四',
        nickName: '老李',
        userName: 'lisi',
        deptName: '市场监管局',
        userTypeName: 'VIP 用户',
        userId: 'user_002',
    },
    {
        key: '3',
        name: '王五',
        nickName: '五哥',
        userName: 'wangwu',
        deptName: '大数据局',
        userTypeName: '管理员',
        userId: 'user_003',
    },
    {
        key: '4',
        name: '赵六',
        nickName: '小赵',
        userName: 'zhaoliu',
        deptName: '财政局',
        userTypeName: '普通用户',
        userId: 'user_004',
    },
    {
        key: '5',
        name: '钱七',
        nickName: '七姐',
        userName: 'qianqi',
        deptName: '人社局',
        userTypeName: 'VIP 用户',
        userId: 'user_005',
    },
];

// ==================== 应用数据 ====================

// 全量应用数据（包含所有创建者的应用）
export const allAppsData: AppCardData[] = [
    // 张三创建的应用
    {
        id: 'app001',
        name: '智审助手 Pro',
        description: '自动化公文审查、错别字纠正及语义合规性实时预警系统。',
        icon: 'solar:document-text-bold-duotone',
        iconBgColor: 'blue',
        creator: '张三',
        creatorId: 'user_001',
        maintainers: ['user_001', 'user_003'],  // 张三、王五可以维护
        maintainerNames: ['张三', '王五'],
        tags: [
            { label: 'NLP', color: 'blue' },
            { label: '私有部署', color: 'slate' },
        ],
        certification: '信创一级认证',
        viewCount: 1280,
        favoriteCount: 56,
        createTime: '2024-01-15 10:30:00',
        updateTime: '2024-01-19 10:30',
        status: 'approved',
        department: '政务服务中心',
        visible: 'public',
    },
    {
        id: 'app002',
        name: '视觉政务预警',
        description: '针对政务服务中心的窗口行为分析与人流密度实时监测。',
        icon: 'solar:mask-happly-bold-duotone',
        iconBgColor: 'indigo',
        creator: '张三',
        creatorId: 'user_001',
        maintainers: ['user_001'],  // 只有张三可以维护
        maintainerNames: ['张三'],
        tags: [
            { label: 'CV', color: 'slate' },
            { label: '安防', color: 'indigo' },
        ],
        certification: '二级审计',
        isHot: true,
        viewCount: 2560,
        favoriteCount: 128,
        createTime: '2024-01-14 09:15:00',
        updateTime: '2024-01-19 09:15',
        status: 'approved',
        department: '政务服务中心',
        visible: 'public',
    },
    // 李四创建的应用
    {
        id: 'app003',
        name: '经济态势分析仪',
        description: '多部门数据聚合，通过 AI 预测宏观经济指标走势。',
        icon: 'solar:chart-line-up-bold-duotone',
        iconBgColor: 'teal',
        creator: '李四',
        creatorId: 'user_002',
        tags: [
            { label: 'Big Data', color: 'slate' },
            { label: '决策', color: 'teal' },
        ],
        certification: '省级认证',
        viewCount: 1890,
        favoriteCount: 95,
        createTime: '2024-01-13 16:45:00',
        updateTime: '2024-01-18 16:45',
        status: 'approved',
        department: '发改委',
        visible: 'public',
    },
    {
        id: 'app004',
        name: '政策语义智译',
        description: '将晦涩的政策公文转化为通俗易懂的惠民说明。',
        icon: 'solar:translation-2-bold-duotone',
        iconBgColor: 'purple',
        creator: '李四',
        creatorId: 'user_002',
        tags: [
            { label: 'LLM', color: 'slate' },
            { label: '惠民', color: 'purple' },
        ],
        certification: '国产化适配',
        viewCount: 1456,
        favoriteCount: 72,
        createTime: '2024-01-12 14:20:00',
        updateTime: '2024-01-18 14:20',
        status: 'approved',
        department: '发改委',
        visible: 'public',
    },
    // 王五（当前用户）创建的应用
    {
        id: 'app005',
        name: '权限行为内审',
        description: 'AI 行为审计，自动识别并拦截异常访问行为。',
        icon: 'solar:key-minimalistic-square-bold-duotone',
        iconBgColor: 'rose',
        creator: '王五',
        creatorId: 'user_003',
        tags: [
            { label: '安全', color: 'slate' },
            { label: '审计', color: 'rose' },
        ],
        certification: '等保三级认证',
        isHot: true,
        viewCount: 3200,
        favoriteCount: 186,
        createTime: '2024-01-11 11:30:00',
        updateTime: '2024-01-17 11:30',
        status: 'approved',
        department: '大数据局',
        visible: 'public',
        proName: '上海虹口区北外滩 480 项目 - 第四事业部',
    },
    {
        id: 'app006',
        name: '12345 智播报',
        description: '语音政务热线智能分类与工单自动派发系统。',
        icon: 'solar:user-speak-bold-duotone',
        iconBgColor: 'cyan',
        creator: '王五',
        creatorId: 'user_003',
        tags: [
            { label: '语音', color: 'slate' },
            { label: '政务', color: 'cyan' },
        ],
        certification: '内网可用',
        viewCount: 2780,
        favoriteCount: 145,
        createTime: '2024-01-10 09:00:00',
        updateTime: '2024-01-17 09:00',
        status: 'approved',
        department: '大数据局',
        visible: 'public',
        proName: '北京市朝阳区 CBD 核心区 Z6 地块',
    },
    // 赵六创建的应用
    {
        id: 'app007',
        name: '法条案例检索云',
        description: '法律条文智能解析，同类案例精准定位与推荐。',
        icon: 'solar:square-academic-cap-bold-duotone',
        iconBgColor: 'amber',
        creator: '赵六',
        creatorId: 'user_004',
        tags: [
            { label: '法律', color: 'slate' },
            { label: '检索', color: 'amber' },
        ],
        certification: '高度合规',
        viewCount: 1650,
        favoriteCount: 88,
        createTime: '2024-01-09 15:45:00',
        updateTime: '2024-01-16 15:45',
        status: 'approved',
        department: '司法局',
        visible: 'public',
    },
    {
        id: 'app008',
        name: '智能客服助手',
        description: '24/7 智能客服问答服务，自动处理常见政务咨询。',
        icon: 'solar:headphones-square-bold-duotone',
        iconBgColor: 'blue',
        creator: '赵六',
        creatorId: 'user_004',
        tags: [
            { label: 'NLP', color: 'slate' },
            { label: '客服', color: 'blue' },
        ],
        certification: '企业级认证',
        viewCount: 4200,
        favoriteCount: 256,
        createTime: '2024-01-08 13:20:00',
        updateTime: '2024-01-16 13:20',
        status: 'approved',
        department: '司法局',
        visible: 'public',
    },
    // 钱七创建的应用
    {
        id: 'app009',
        name: '财税政策智询',
        description: '财税政策智能问答与税收筹划建议系统。',
        icon: 'solar:calculator-bold-duotone',
        iconBgColor: 'green',
        creator: '钱七',
        creatorId: 'user_005',
        tags: [
            { label: '财税', color: 'slate' },
            { label: '问答', color: 'teal' },
        ],
        certification: '税务局认证',
        viewCount: 1980,
        favoriteCount: 112,
        createTime: '2024-01-07 10:00:00',
        updateTime: '2024-01-15 10:00',
        status: 'approved',
        department: '财政局',
        visible: 'public',
    },
    // 孙八创建的应用
    {
        id: 'app010',
        name: '社保医保智办',
        description: '社保医保政策咨询与业务办理指引助手。',
        icon: 'solar:heart-hand-shake-bold-duotone',
        iconBgColor: 'rose',
        creator: '孙八',
        creatorId: 'user_006',
        tags: [
            { label: '社保', color: 'slate' },
            { label: '医保', color: 'rose' },
        ],
        certification: '省级认证',
        viewCount: 3560,
        favoriteCount: 198,
        createTime: '2024-01-06 14:30:00',
        updateTime: '2024-01-15 14:30',
        status: 'approved',
        department: '人社局',
        visible: 'public',
    },
    // 周九创建的应用（专业知识类）
    {
        id: 'prof001',
        name: '法律智能咨询',
        description: '基于 AI 的法律条文解读和案例推荐系统。',
        icon: 'solar:scale-bold-duotone',
        iconBgColor: 'blue',
        creator: '周九',
        creatorId: 'user_007',
        tags: [
            { label: '法律', color: 'blue' },
            { label: '专业', color: 'slate' },
        ],
        certification: '专业认证',
        viewCount: 2100,
        favoriteCount: 125,
        createTime: '2024-01-05 09:00:00',
        updateTime: '2024-01-14 09:00',
        status: 'approved',
        department: '司法局',
        visible: 'public',
    },
    {
        id: 'prof002',
        name: '医疗诊断辅助',
        description: 'AI 辅助医疗诊断，提供专业医学建议。',
        icon: 'solar:heart-pulse-bold-duotone',
        iconBgColor: 'rose',
        creator: '周九',
        creatorId: 'user_007',
        tags: [
            { label: '医疗', color: 'rose' },
            { label: '专业', color: 'slate' },
        ],
        certification: '医疗认证',
        viewCount: 2850,
        favoriteCount: 165,
        createTime: '2024-01-04 11:00:00',
        updateTime: '2024-01-14 11:00',
        status: 'approved',
        department: '卫健委',
        visible: 'public',
    },
    // 职能管理类应用
    {
        id: 'func001',
        name: '人力资源管理系统',
        description: '员工信息、考勤、绩效一体化管理。',
        icon: 'solar:users-group-rounded-bold-duotone',
        iconBgColor: 'blue',
        creator: '吴十',
        creatorId: 'user_008',
        tags: [
            { label: 'HR', color: 'blue' },
            { label: '管理', color: 'slate' },
        ],
        certification: '企业级认证',
        viewCount: 1560,
        favoriteCount: 78,
        createTime: '2024-01-03 10:00:00',
        updateTime: '2024-01-13 10:00',
        status: 'approved',
        department: '人社局',
        visible: 'public',
    },
    {
        id: 'func002',
        name: '行政审批系统',
        description: '企业内部行政审批流程自动化。',
        icon: 'solar:clipboard-check-bold-duotone',
        iconBgColor: 'green',
        creator: '吴十',
        creatorId: 'user_008',
        tags: [
            { label: '行政', color: 'green' },
            { label: '管理', color: 'slate' },
        ],
        certification: '安全认证',
        viewCount: 1320,
        favoriteCount: 65,
        createTime: '2024-01-02 14:00:00',
        updateTime: '2024-01-13 14:00',
        status: 'approved',
        department: '行政审批局',
        visible: 'public',
    },
    // 项目级应用
    {
        id: 'proj001',
        name: '智慧园区管理',
        description: '园区安防、能耗、设备一体化管理。',
        icon: 'solar:building-bold-duotone',
        iconBgColor: 'blue',
        creator: '郑十一',
        creatorId: 'user_009',
        proName: '上海虹口区北外滩 480 项目 - 第四事业部',
        tags: [
            { label: '园区', color: 'blue' },
            { label: '项目', color: 'slate' },
        ],
        certification: '项目认证',
        viewCount: 1890,
        favoriteCount: 95,
        createTime: '2024-01-01 09:00:00',
        updateTime: '2024-01-12 09:00',
        status: 'approved',
        department: '住建局',
        visible: 'public',
    },
    {
        id: 'proj002',
        name: '工程项目管理',
        description: '工程进度、质量、安全全方位管理。',
        icon: 'solar:hammer-bold-duotone',
        iconBgColor: 'amber',
        creator: '郑十一',
        creatorId: 'user_009',
        proName: '北京朝阳区 CBD 核心区 Z15 地块项目',
        tags: [
            { label: '工程', color: 'amber' },
            { label: '项目', color: 'slate' },
        ],
        certification: '工程认证',
        viewCount: 2150,
        favoriteCount: 118,
        createTime: '2023-12-31 10:00:00',
        updateTime: '2024-01-12 10:00',
        status: 'approved',
        department: '住建局',
        visible: 'public',
    },
];

// ==================== 页面配置 ====================

// 各页面的默认配置
export const pageConfigs: Record<PageType, PageConfig> = {
    // 应用广场 - 全公司可见，显示创建者
    appPlaza: {
        showCreator: true,
        showActions: true,
        showCertification: true,
        showTags: true,
        showHot: true,
        showViewCount: true,
        showFavoriteCount: true,
        showStatus: false,
        showDepartment: false,
        showVisible: false,
        filterByCurrentUser: false,
        title: '全部 RAG 应用',
        description: '根据您的常用部门与岗位职责为您推荐',
    },
    // 专业知识 - 全公司可见，显示创建者
    professional: {
        showCreator: true,
        showActions: true,
        showCertification: true,
        showTags: true,
        showHot: true,
        showViewCount: false,
        showFavoriteCount: false,
        showStatus: false,
        showDepartment: false,
        showVisible: false,
        filterByCurrentUser: false,
        title: '专业知识',
        description: '专业知识类 RAG 应用',
    },
    // 职能管理 - 全公司可见，显示创建者
    functional: {
        showCreator: true,
        showActions: true,
        showCertification: true,
        showTags: true,
        showHot: true,
        showViewCount: false,
        showFavoriteCount: false,
        showStatus: false,
        showDepartment: false,
        showVisible: false,
        filterByCurrentUser: false,
        title: '职能管理',
        description: '职能管理类 RAG 应用',
    },
    // 项目级应用 - 全公司可见，显示创建者
    project: {
        showCreator: true,
        showActions: true,
        showCertification: true,
        showTags: true,
        showHot: true,
        showViewCount: false,
        showFavoriteCount: false,
        showStatus: false,
        showDepartment: false,
        showVisible: false,
        filterByCurrentUser: false,
        title: '项目级应用',
        description: '项目级 RAG 应用',
    },
    // 我创建的应用 - 只显示当前用户的数据，不显示创建者（因为都是自己的）
    myApps: {
        showCreator: false,  // 不显示创建者，因为都是"我"
        showActions: true,
        showCertification: true,
        showTags: true,
        showHot: false,
        showViewCount: false,
        showFavoriteCount: false,
        showStatus: true,  // 显示审核状态
        showDepartment: false,
        showVisible: true,  // 显示可见性（公开/私有）
        filterByCurrentUser: true,  // 只显示当前用户的数据
        title: '我创建的应用',
        description: '管理和维护您创建的所有 RAG 应用',
    },
    // 知识库列表
    knowledgeLib: {
        showCreator: true,
        showActions: false,
        showCertification: false,
        showTags: false,
        showHot: false,
        showViewCount: false,
        showFavoriteCount: false,
        showStatus: false,
        showDepartment: false,
        showVisible: false,
        filterByCurrentUser: false,
        title: '知识库',
        description: '管理您的所有知识库',
    },
    // 数据集管理
    datasetManagement: {
        showCreator: false,
        showActions: false,
        showCertification: false,
        showTags: false,
        showHot: false,
        showViewCount: false,
        showFavoriteCount: false,
        showStatus: true,
        showDepartment: false,
        showVisible: false,
        filterByCurrentUser: false,
        title: '数据集管理',
        description: '管理评估数据集',
    },
    // 评估任务
    evaluationTask: {
        showCreator: false,
        showActions: false,
        showCertification: false,
        showTags: false,
        showHot: false,
        showViewCount: false,
        showFavoriteCount: false,
        showStatus: true,
        showDepartment: false,
        showVisible: false,
        filterByCurrentUser: false,
        title: '评估任务',
        description: '管理模型评估任务',
    },
    // 修订工具
    revisionTool: {
        showCreator: false,
        showActions: false,
        showCertification: false,
        showTags: false,
        showHot: false,
        showViewCount: false,
        showFavoriteCount: false,
        showStatus: true,
        showDepartment: false,
        showVisible: false,
        filterByCurrentUser: false,
        title: '修订工具',
        description: '管理知识库修订任务',
    },
};

// ==================== 工具函数 ====================

/**
 * 根据页面类型获取应用数据
 * @param pageType 页面类型
 * @param currentUser 当前用户（可选，默认为 mockCurrentUser）
 * @returns 过滤后的应用数据数组
 */
export const getAppsByPageType = (
    pageType: PageType,
    currentUser: CurrentUser = mockCurrentUser
): AppCardData[] => {
    const config = pageConfigs[pageType];
    let apps = [...allAppsData];

    // 根据页面类型过滤数据
    switch (pageType) {
        case 'allApps':
            // 全部应用（我创建的应用页面 TAB）- 显示所有应用
            return apps;

        case 'myApps':
            // 只显示当前用户创建的应用
            return apps.filter(app => app.creatorId === currentUser.id);

        case 'maintainerApps':
            // 我可以维护的应用（创建者或维护者）
            return apps.filter(app =>
                app.creatorId === currentUser.id ||
                (app.maintainers && app.maintainers.includes(currentUser.id))
            );

        case 'professional':
            // 专业知识类应用
            return apps.filter(app => app.id.startsWith('prof') || app.department === '司法局' || app.department === '卫健委');

        case 'functional':
            // 职能管理类应用
            return apps.filter(app => app.id.startsWith('func'));

        case 'project':
            // 项目级应用
            return apps.filter(app => app.id.startsWith('proj'));

        case 'appPlaza':
        default:
            // 应用广场显示所有应用（排除特定分类的）
            return apps.filter(app =>
                !app.id.startsWith('prof') &&
                !app.id.startsWith('func') &&
                !app.id.startsWith('proj')
            );
    }
};

/**
 * 根据配置处理应用数据的显示字段
 * @param app 应用数据
 * @param config 页面配置
 * @returns 处理后的应用数据
 */
export const processAppData = (
    app: AppCardData,
    config: PageConfig
): AppCardData => {
    const processed: any = { ...app };

    // 根据配置隐藏字段
    if (!config.showCreator) {
        delete processed.creator;
        delete processed.creatorId;
    }
    if (!config.showTags) {
        delete processed.tags;
    }
    if (!config.showCertification) {
        delete processed.certification;
    }
    if (!config.showHot) {
        delete processed.isHot;
    }
    if (!config.showViewCount) {
        delete processed.viewCount;
    }
    if (!config.showFavoriteCount) {
        delete processed.favoriteCount;
    }
    if (!config.showStatus) {
        delete processed.status;
    }
    if (!config.showDepartment) {
        delete processed.department;
    }
    if (!config.showVisible) {
        delete processed.visible;
    }

    return processed as AppCardData;
};

/**
 * 获取页面配置
 * @param pageType 页面类型
 * @returns 页面配置对象
 */
export const getPageConfig = (pageType: PageType): PageConfig => {
    return pageConfigs[pageType];
};

/**
 * 获取当前用户信息
 * @returns 当前用户信息
 */
export const getCurrentUser = (): CurrentUser => {
    // 实际项目中可以从 LocalStorage 获取真实用户信息
    // const userInfo = LocalStorage.getUserInfo();
    // return { ...mockCurrentUser, ...userInfo };
    return mockCurrentUser;
};

// ==================== 应用详情 Mock 数据（用于创建/编辑页面） ====================

// 预设问题列表
export const mockPresetQuestions = [
    '如何进行公文格式审查？',
    '常见的公文错误有哪些？',
    '公文审查的标准是什么？',
    '如何纠正公文中的错别字？',
    '公文语义合规性如何判断？',
];

// 应用详情数据（编辑模式默认值）
export const mockAppDetail = {
    id: 'app_001',
    appId: 'app_001',
    name: '智审助手 Pro',
    desc: '自动化公文审查、错别字纠正及语义合规性实时预警系统，助力政务公文处理提质增效。',
    prompt: `--- 系统指令与角色定义 ---
# 核心角色：AI 文档处理专家
你是一位结合公司多种领域的专业知识训练的 AI 文档处理专家，基于 Qwen3 的预训练模型能力。
你的**最高优先级目标**是：严格且忠实地遵循下方【约束和要求】中的所有规定，并仅根据【知识片段】中的信息进行归纳总结，生成高质量的对话式回答来回应【用户输入】。

--- 约束和要求：严格执行 ---
一、 核心回答原则
**1. 严格基于知识片段**：你的回答必须完全源自"知识片段"的归纳总结。
**2. 禁止使用外部知识**：严禁使用你自身的预训练知识进行回答或补充。
**3. 主动澄清模糊问题**：如果用户问题模糊，你必须根据知识片段内容，主动询问用户可能想问的具体方向。

--- 任务输入 ---
# 知识片段
{{知识}}
# 用户输入
{{用户}}

--- 最终回答 ---
[直接输出对话式回答，不要复述用户问题]`,
    topP: 0.5,
    topK: 50,
    temperature: 0.5,
    knowledgeIds: ['know_001', 'know_002'],
    model: 'Qwen3-30B',
    iconColor: '#1D4ED8',
    iconType: 'RobotOutlined',
    questionlist: [
        { id: 1, value: '如何进行公文格式审查？' },
        { id: 2, value: '常见的公文错误有哪些？' },
        { id: 3, value: '公文审查的标准是什么？' },
    ],
    maxToken: 4096,
    updateDate: '2024-01-19 10:30:00',
    appProId: '100',
    typeId: '10',
    visible: '0',
    sort: 1,
    groupVisible: false,
    knowledgeInfo: JSON.stringify({
        param_desc: 'moderate',
        show_recall_result: true,
        recall_method: 'mixed',
        rerank_status: true,
        rerank_model_name: 'bge-reranker-v2-m3',
        slice_config_type: 'customized',
        slice_count: 15,
        is_multi_round: 'Y',
        multi_round: 5,
        rerank_index_type_list: [
            { index_type_id: 0, knowledge_id: 'know_001' },
        ],
        recall_index_type_list: [
            { index_type_id: 0, knowledge_id: 'know_001' },
        ],
    }),
    vipList: [],
};

// ==================== 知识库 Mock 数据 ====================

// 知识库列表数据
export const mockKnowledgeLibList = [
    {
        knowledgeId: 'a3035904115816665088',
        name: '政务公文知识库',
        createBy: 'user_001',  // 张三创建
        maintainers: ['user_001', 'user_003'],  // 张三、王五可以维护
        maintainerNames: ['张三', '王五'],
        standardClassification: '0',
        splittingType: '1',
        docCount: 128,
        sliceCount: 1024,
        createTime: '2024-01-15 10:30:00',
        updateTime: '2024-01-19 10:30',
    },
    {
        knowledgeId: 'a3031624518677696512',
        name: '法律法规知识库',
        createBy: 'user_001',  // 张三创建
        maintainers: ['user_001'],  // 只有张三可以维护
        maintainerNames: ['张三'],
        standardClassification: '1',
        splittingType: '1',
        docCount: 256,
        sliceCount: 2048,
        createTime: '2024-01-14 09:15:00',
        updateTime: '2024-01-19 09:15',
    },
    {
        knowledgeId: 'a3031551725244125184',
        name: '惠民政策知识库',
        createBy: 'user_002',  // 李四创建
        maintainers: ['user_002', 'user_003'],  // 李四、王五可以维护
        maintainerNames: ['李四', '王五'],
        standardClassification: '2',
        splittingType: '2',
        docCount: 89,
        sliceCount: 567,
        createTime: '2024-01-13 16:45:00',
        updateTime: '2024-01-18 16:45',
    },
    {
        knowledgeId: 'a3029758382289850368',
        name: '行政审批知识库',
        createBy: 'user_003',  // 王五创建
        maintainers: ['user_003'],  // 只有王五可以维护
        maintainerNames: ['王五'],
        standardClassification: '0',
        splittingType: '1',
        docCount: 175,
        sliceCount: 1320,
        createTime: '2024-01-12 14:20:00',
        updateTime: '2024-01-18 14:20',
    },
    {
        knowledgeId: 'a3028990898263691264',
        name: '安全生产知识库',
        createBy: 'user_004',  // 赵六创建
        maintainers: ['user_004', 'user_003'],  // 赵六、王五可以维护
        maintainerNames: ['赵六', '王五'],
        standardClassification: '1',
        splittingType: '2',
        docCount: 95,
        sliceCount: 760,
        createTime: '2024-01-11 11:30:00',
        updateTime: '2024-01-17 11:30',
    },
    {
        knowledgeId: 'a3028397661308194816',
        name: '财税政策知识库',
        createBy: 'admin',
        standardClassification: '2',
        splittingType: '1',
        docCount: 142,
        sliceCount: 980,
        createTime: '2024-01-10 09:00:00',
        updateTime: '2024-01-17 09:00',
    },
    {
        knowledgeId: 'a3019239688480624640',
        name: '科技创新知识库',
        createBy: 'admin',
        standardClassification: '0',
        splittingType: '2',
        docCount: 67,
        sliceCount: 445,
        createTime: '2024-01-09 15:45:00',
        updateTime: '2024-01-16 15:45',
    },
    {
        knowledgeId: 'a3018882078170550272',
        name: '社会保障知识库',
        createBy: 'admin',
        standardClassification: '1',
        splittingType: '1',
        docCount: 118,
        sliceCount: 890,
        createTime: '2024-01-08 10:15:00',
        updateTime: '2024-01-16 10:15',
    }
];

// 知识库详情数据
export const mockKnowledgeLibDetail = {
    knowledgeId: 'a3035904115816665088',
    name: '政务公文知识库',
    createBy: 'admin',
    standardClassification: '0',
    splittingType: '1',
    docCount: 128,
    sliceCount: 1024,
    createTime: '2024-01-15 10:30:00',
    updateTime: '2024-01-19 10:30',
    description: '政务公文处理相关知识库',
    embeddingId: 'embedding_001',
};

// 文档列表数据
export const mockDocumentList = [
    {
        id: 'doc001',
        name: '政务服务指南.pdf',
        url: '/files/doc001.pdf',
        length: 1024000,
        sentenceSize: 150,
        knowledgeType: 1,
        customSeparator: ['\\n'],
        embeddingStat: 1,
        wordNum: 5000,
        parseImage: 0,
        createTime: '2024-01-15 10:30:00',
        updateTime: '2024-01-19 10:30',
        knowledgeId: 'a3035904115816665088',
        knowledgeName: '政务公文知识库',
        status: 'completed',
    },
    {
        id: 'doc002',
        name: '行政法规汇编.docx',
        url: '/files/doc002.docx',
        length: 2048000,
        sentenceSize: 200,
        knowledgeType: 2,
        customSeparator: ['\\n'],
        embeddingStat: 1,
        wordNum: 8000,
        parseImage: 0,
        createTime: '2024-01-14 09:15:00',
        updateTime: '2024-01-19 09:15',
        knowledgeId: 'a3035904115816665088',
        knowledgeName: '政务公文知识库',
        status: 'completed',
    },
    {
        id: 'doc003',
        name: '公文格式规范.pdf',
        url: '/files/doc003.pdf',
        length: 512000,
        sentenceSize: 100,
        knowledgeType: 1,
        customSeparator: ['\\n'],
        embeddingStat: 1,
        wordNum: 3000,
        parseImage: 0,
        createTime: '2024-01-13 16:45:00',
        updateTime: '2024-01-18 16:45',
        knowledgeId: 'a3035904115816665088',
        knowledgeName: '政务公文知识库',
        status: 'completed',
    },
    {
        id: 'doc004',
        name: '审批流程说明.txt',
        url: '/files/doc004.txt',
        length: 256000,
        sentenceSize: 80,
        knowledgeType: 5,
        customSeparator: ['\\n'],
        embeddingStat: 1,
        wordNum: 2000,
        parseImage: 0,
        createTime: '2024-01-12 14:20:00',
        updateTime: '2024-01-18 14:20',
        knowledgeId: 'a3035904115816665088',
        knowledgeName: '政务公文知识库',
        status: 'completed',
    },
    {
        id: 'doc005',
        name: '政策解读材料.pdf',
        url: '/files/doc005.pdf',
        length: 768000,
        sentenceSize: 120,
        knowledgeType: 1,
        customSeparator: ['\\n'],
        embeddingStat: 1,
        wordNum: 4500,
        parseImage: 0,
        createTime: '2024-01-11 11:30:00',
        updateTime: '2024-01-17 11:30',
        knowledgeId: 'a3035904115816665088',
        knowledgeName: '政务公文知识库',
        status: 'processing',
    },
];

// 切片列表数据
export const mockSliceList = [
    {
        sliceId: 'slice001',
        knowledgeId: 'a3035904115816665088',
        documentId: 'doc001',
        sliceText: '政务服务是指政府机关通过多种渠道和方式，为公民、法人和其他组织提供的各类公共服务。',
        sliceNum: 1,
        createTime: '2024-01-15 10:30:00',
        updateTime: '2024-01-19 10:30',
        status: 'active',
    },
    {
        sliceId: 'slice002',
        knowledgeId: 'a3035904115816665088',
        documentId: 'doc001',
        sliceText: '政务服务的目标是提高政府工作效率，优化服务质量，方便群众办事。',
        sliceNum: 2,
        createTime: '2024-01-15 10:31:00',
        updateTime: '2024-01-19 10:31',
        status: 'active',
    },
    {
        sliceId: 'slice003',
        knowledgeId: 'a3035904115816665088',
        documentId: 'doc001',
        sliceText: '政务服务包括行政审批、公共服务、政务公开等多个方面。',
        sliceNum: 3,
        createTime: '2024-01-15 10:32:00',
        updateTime: '2024-01-19 10:32',
        status: 'active',
    },
    {
        sliceId: 'slice004',
        knowledgeId: 'a3035904115816665088',
        documentId: 'doc002',
        sliceText: '行政法规是国务院根据宪法和法律制定的规范性文件，具有普遍约束力。',
        sliceNum: 1,
        createTime: '2024-01-14 09:15:00',
        updateTime: '2024-01-19 09:15',
        status: 'active',
    },
    {
        sliceId: 'slice005',
        knowledgeId: 'a3035904115816665088',
        documentId: 'doc002',
        sliceText: '行政法规的制定程序包括立项、起草、审查、决定、公布等环节。',
        sliceNum: 2,
        createTime: '2024-01-14 09:16:00',
        updateTime: '2024-01-19 09:16',
        status: 'active',
    },
];

// 修订工具列表数据
export const mockReviseToolList = [
    {
        knowledgeName: '政务公文知识库',
        knowledgeId: 'a3035904115816665088',
        length: '10MB',
        appNames: ['智审助手 Pro', '12345 智播报'],
        documentSize: 128,
        createTime: '2024-01-15 10:30:00',
        updateTime: '2024-01-19 10:30',
        status: 'completed',
    },
    {
        knowledgeName: '法律法规知识库',
        knowledgeId: 'a3031624518677696512',
        length: '25MB',
        appNames: ['法条案例检索云'],
        documentSize: 256,
        createTime: '2024-01-14 09:15:00',
        updateTime: '2024-01-19 09:15',
        status: 'completed',
    },
    {
        knowledgeName: '惠民政策知识库',
        knowledgeId: 'a3031551725244125184',
        length: '8MB',
        appNames: ['政策语义智译'],
        documentSize: 89,
        createTime: '2024-01-13 16:45:00',
        updateTime: '2024-01-18 16:45',
        status: 'processing',
    },
];

// 修订历史记录数据
export const mockReviseHistoryList = [
    {
        id: 'rev001',
        knowledgeId: 'a3035904115816665088',
        knowledgeName: '政务公文知识库',
        documentName: '政务服务指南.pdf',
        refDocumentName: '行政法规汇编.docx',
        sliceId: 'slice001',
        refSliceId: 'slice004',
        revisionStatus: '1',
        createTime: '2024-01-19 10:30:00',
        createBy: 'admin',
    },
    {
        id: 'rev002',
        knowledgeId: 'a3035904115816665088',
        knowledgeName: '政务公文知识库',
        documentName: '公文格式规范.pdf',
        refDocumentName: '审批流程说明.txt',
        sliceId: 'slice003',
        refSliceId: 'slice005',
        revisionStatus: '1',
        createTime: '2024-01-18 14:20:00',
        createBy: 'admin',
    },
];

// 向量化模型列表
export const mockEmbeddingList = [
    { id: 'emb001', name: 'bge-large-zh-v1.5', modelCode: 'bge-large-zh-v1.5' },
    { id: 'emb002', name: 'bge-base-zh-v1.5', modelCode: 'bge-base-zh-v1.5' },
    { id: 'emb003', name: 'text-embedding-ada-002', modelCode: 'ada-002' },
];

// 解析类型列表
export const mockParsingTypeList = [
    { dictLabel: '通用解析', dictValue: '0', remark: '适用于大多数文档类型' },
    { dictLabel: '表格解析', dictValue: '1', remark: '适用于包含表格的文档' },
    { dictLabel: '图片解析', dictValue: '2', remark: '适用于包含图片的文档' },
    { dictLabel: '公式解析', dictValue: '3', remark: '适用于包含数学公式的文档' },
];

// 切分规则列表
export const mockSplittingTypeList = [
    { dictLabel: '按段落切分', dictValue: '0', remark: '按照自然段落进行切分' },
    { dictLabel: '按固定长度切分', dictValue: '1', remark: '按照固定字符长度切分' },
    { dictLabel: '按标题切分', dictValue: '2', remark: '按照文档标题层级切分' },
    { dictLabel: '自定义切分', dictValue: '5', remark: '使用自定义分隔符切分' },
];

// 标准分类列表
export const mockStandardClassificationList = [
    { dictLabel: '公文类', dictValue: '0' },
    { dictLabel: '法律类', dictValue: '1' },
    { dictLabel: '政策类', dictValue: '2' },
];

// 修订状态列表
export const mockRevisionStatusList = [
    { dictLabel: '未修订', dictValue: '0' },
    { dictLabel: '已修订', dictValue: '1' },
];

// 聊天记录列表
export const mockChatHistoryList = [
    {
        id: 'chat001',
        appId: 'app001',
        appName: '智审助手 Pro',
        userId: 'user001',
        userName: '张三',
        question: '如何进行公文格式审查？',
        answer: '公文格式审查主要包括以下几个方面：1. 标题格式检查；2. 正文格式检查；3. 附件格式检查...',
        createTime: '2024-01-19 10:30:00',
    },
    {
        id: 'chat002',
        appId: 'app001',
        appName: '智审助手 Pro',
        userId: 'user002',
        userName: '李四',
        question: '常见的公文错误有哪些？',
        answer: '常见的公文错误包括：1. 标题不规范；2. 主送机关错误；3. 正文格式问题...',
        createTime: '2024-01-19 09:15:00',
    },
];

// ==================== 导出 ====================

// 类型导出
export type {
    PageType,
    PageConfig,
    CurrentUser,
    AppCardData,
};

// 默认导出（包含所有数据和函数）
export default {
    allAppsData,
    mockCurrentUser,
    mockAppTypes,
    mockAppVisibleTypes,
    mockUserTypes,
    mockAppProjects,
    mockModelList,
    mockRerankModelList,
    mockKnowledgeList,
    mockUserList,
    pageConfigs,
    getAppsByPageType,
    processAppData,
    getPageConfig,
    getCurrentUser,
    mockPresetQuestions,
    mockAppDetail,
    // 知识库相关 Mock 数据
    mockKnowledgeLibList,
    mockKnowledgeLibDetail,
    mockDocumentList,
    mockSliceList,
    mockReviseToolList,
    mockReviseHistoryList,
    mockEmbeddingList,
    mockParsingTypeList,
    mockSplittingTypeList,
    mockStandardClassificationList,
    mockRevisionStatusList,
    mockChatHistoryList,
};
