import { SUBJECT_FILTER_OPTIONS } from '@/utils/subject';

export interface ParentChild {
    id: string;
    name: string;
    account: string;
    school: string;
    className: string;
    examNo: string;
}

export interface SubjectTrend {
    subject: string;
    status?: 'up' | 'down' | 'stable' | 'none';
    trendName?: string;
}

export interface GradeBand {
    label: string;
    level: 'excellent' | 'good' | 'middle' | 'weak';
    subjects: SubjectTrend[];
}

export interface ReportItem {
    id: string;
    subject: string;
    category: string;
    title: string;
    score: number;
    date: string;
    grade: string;
}

export interface ReportScoreBlock {
    label: string;
    value: string;
    desc: string;
}

export interface ReportRank {
    label: string;
    value: string;
}

export interface ReportAnalysisRow {
    range: string;
    type: string;
    score: string;
    rate: string;
}

export interface ReportDifficultyRow {
    difficulty: string;
    range: string;
    score: string;
    rate: string;
}

/** 答题卡列表用的轻量字段（不含 HTML） */
export type ReportQuestionSummary = Pick<
    ReportQuestion,
    'no' | 'type' | 'score' | 'status' | 'classRate' | 'schoolRate' | 'knowledge'
>;

export interface QuestionOption {
    /** 选项标签（A、B、C、D...） */
    label: string;
    /** 选项内容（HTML 格式） */
    value: string;
}

export interface ReportQuestion {
    no: number;
    type: string;
    score: string;
    status: 'correct' | 'wrong' | 'unanswered';
    /** 供 rich-text 渲染的题干 HTML */
    stemHtml: string;
    /** 题干中的图片（与学生端一致，从 HTML 中拆出单独展示） */
    stemImages: string[];
    /** 选择题的选项列表 */
    options: QuestionOption[];
    /** 供 rich-text 渲染的正确答案 HTML */
    correctAnswerHtml: string;
    /** 纯文本学员答案（选择题等） */
    studentAnswer: string;
    /** 供 rich-text 渲染的学员答案 HTML（富文本作答） */
    studentAnswerHtml: string;
    /** 学员上传的图片答案 */
    studentAnswerImages: string[];
    classRate: string;
    schoolRate: string;
    knowledge: string;
}

export interface ReportKnowledgeRatio {
    name: string;
    percent: number;
    tone: 'blue' | 'orange' | 'green';
}

export interface ReportKnowledgeScore {
    name: string;
    fullScore: number;
    score: number;
}

export interface ReportDetail {
    id: string;
    scoreBlocks: ReportScoreBlock[];
    ranks: ReportRank[];
    analysisRows: ReportAnalysisRow[];
    difficultyRows: ReportDifficultyRow[];
    questions: ReportQuestion[];
    knowledgeRatios: ReportKnowledgeRatio[];
    knowledgeScores: ReportKnowledgeScore[];
}

export interface QuickAction {
    title: string;
    desc: string;
    tone: 'cyan' | 'green' | 'orange';
}

export interface KnowledgeWeakPoint {
    name: string;
    subject: string;
    grade: string;
    category: string;
    fullScore: number;
    score: number;
    wrongPercent: number;
    tone: 'blue' | 'orange' | 'green' | 'rose';
}

export interface AbilityTrendPoint {
    date: string;
    score: number;
}

export interface AbilitySummary {
    label: string;
    value: string;
    desc: string;
}

// 家长端首版先用结构化本地数据承载页面功能，后续接接口只需要替换这里的来源。
export const parentChildren: ParentChild[] = [
    {
        id: 'child-1',
        name: '小星河',
        account: '3620012788',
        school: '山东蓝翔技校（初中）',
        className: '初2027级3班',
        examNo: '3620012788',
    },
    {
        id: 'child-2',
        name: '小灵犀',
        account: '3620012563',
        school: '山东蓝翔技校（初中）',
        className: '初2027级3班',
        examNo: '3620012563',
    },
];

export const gradeBands: GradeBand[] = [
    {
        label: '优势保持',
        level: 'excellent',
        subjects: [],
    },
    {
        label: '良好巩固',
        level: 'good',
        subjects: [{ subject: '数学', status: 'down' }],
    },
    {
        label: '重点提升',
        level: 'middle',
        subjects: [
            { subject: '语文', status: 'up' },
            { subject: '英语', status: 'up' },
        ],
    },
    {
        label: '及时补弱',
        level: 'weak',
        subjects: [],
    },
];

export const quickActions: QuickAction[] = [
    { title: '学情追踪', desc: '查看本周学习变化', tone: 'cyan' },
    { title: '错题练习', desc: '按薄弱点再练一遍', tone: 'orange' },
    // { title: '课程学习', desc: '进入课程任务', tone: 'green' },
];

export const reportList: ReportItem[] = [
    {
        id: 'r1',
        subject: '数学',
        category: '周作业',
        title: '2023-2024学年（上）初2023级七年级上期末模拟（五）数学',
        score: 100,
        date: '2024-01-12',
        grade: '初一',
    },
    {
        id: 'r2',
        subject: '多科',
        category: '月考',
        title: '2023-2024学年（上）初2023级阶段性练习',
        score: 60,
        date: '2024-01-08',
        grade: '初一',
    },
    {
        id: 'r3',
        subject: '语文',
        category: '周作业',
        title: '2023-2024学年（上）初2023级七年级上期末模拟（三）语文',
        score: 92,
        date: '2023-12-28',
        grade: '初一',
    },
    {
        id: 'r4',
        subject: '英语',
        category: '周作业',
        title: '2023-2024学年（上）初2023级七年级上期末模拟（三）英语',
        score: 88.5,
        date: '2023-12-28',
        grade: '初一',
    },
];

export const reportDetails: Record<string, ReportDetail> = {
    r1: {
        id: 'r1',
        scoreBlocks: [
            { label: '我的得分', value: '120', desc: '总分 120' },
            { label: '满分', value: '120', desc: '本次卷面' },
            { label: '得分率', value: '100.0%', desc: '超过多数同学' },
        ],
        ranks: [
            { label: '班级排名', value: '1/45' },
            { label: '年级排名', value: '6/680' },
        ],
        analysisRows: [
            { range: '1-10', type: '选择题', score: '40/40', rate: '100%' },
            { range: '11-16', type: '填空题', score: '30/30', rate: '100%' },
            { range: '17-21', type: '解答题', score: '20/20', rate: '100%' },
            { range: '22-23', type: '压轴题', score: '5/10', rate: '50%' },
        ],
        difficultyRows: [
            { difficulty: '简单题', range: '1-8', score: '32/32', rate: '100%' },
            { difficulty: '中等题', range: '9-18', score: '42/44', rate: '95.5%' },
            { difficulty: '难题', range: '19-23', score: '18/24', rate: '75.0%' },
        ],
        questions: [
            {
                no: 1, type: '选择题', score: '4/4', status: 'correct', stem: '请结合材料完成本题要求。',
                correctAnswer: 'A', studentAnswer: 'A', classRate: '88%', schoolRate: '84%', knowledge: '字音字形',
                options: [
                    { label: 'A', value: '脍炙人口' },
                    { label: 'B', value: '哄堂大笑' },
                    { label: 'C', value: '锋芒毕露' },
                    { label: 'D', value: '忍俊不禁' },
                ],
            },
            {
                no: 2, type: '选择题', score: '4/4', status: 'correct', stem: '根据题意选择最符合要求的一项。',
                correctAnswer: 'C', studentAnswer: 'C', classRate: '84%', schoolRate: '81%', knowledge: '词语运用',
                options: [
                    { label: 'A', value: '通过这次活动，使我们开阔了眼界。' },
                    { label: 'B', value: '他的写作水平有了明显的提高。' },
                    { label: 'C', value: '春天的西湖是一个美丽的季节。' },
                    { label: 'D', value: '我们要养成认真思考的习惯。' },
                ],
            },
            {
                no: 3, type: '选择题', score: '4/4', status: 'correct', stem: '阅读材料并判断关键条件。',
                correctAnswer: 'B', studentAnswer: 'B', classRate: '80%', schoolRate: '78%', knowledge: '病句辨析',
                options: [
                    { label: 'A', value: '他是多少个死难者中幸免的一个。' },
                    { label: 'B', value: '文章的主题确定以后，还要根据主题的需要组织材料。' },
                    { label: 'C', value: '由于运用了科学的复习方法，他的学习效率有了很大改进。' },
                    { label: 'D', value: '老工人的一席话深深触动了小明的心。' },
                ],
            },
            {
                no: 4, type: '选择题', score: '4/4', status: 'correct', stem: '从选项中选出表达准确的一项。',
                correctAnswer: 'D', studentAnswer: 'D', classRate: '76%', schoolRate: '75%', knowledge: '文学常识',
                options: [
                    { label: 'A', value: '《诗经》是我国第一部诗歌总集。' },
                    { label: 'B', value: '《论语》是孔子及其弟子的语录体著作。' },
                    { label: 'C', value: '《史记》是我国第一部纪传体通史。' },
                    { label: 'D', value: '《红楼梦》的作者是吴承恩。' },
                ],
            },
            {
                no: 5, type: '选择题', score: '4/4', status: 'correct', stem: '根据语境判断标点使用。',
                correctAnswer: 'A', studentAnswer: 'A', classRate: '72%', schoolRate: '72%', knowledge: '标点符号',
                options: [
                    { label: 'A', value: '"你到哪里去？"她轻声问道。' },
                    { label: 'B', value: '"你到哪里去"？她轻声问道。' },
                    { label: 'C', value: '"你到哪里去，"她轻声问道。' },
                    { label: 'D', value: '"你到哪里去"她轻声问道。' },
                ],
            },
            {
                no: 6, type: '选择题', score: '4/4', status: 'correct', stem: '判断句子修辞手法。',
                correctAnswer: 'B', studentAnswer: 'B', classRate: '88%', schoolRate: '69%', knowledge: '修辞手法',
                options: [
                    { label: 'A', value: '比喻' },
                    { label: 'B', value: '拟人' },
                    { label: 'C', value: '排比' },
                    { label: 'D', value: '夸张' },
                ],
            },
            {
                no: 7, type: '选择题', score: '4/4', status: 'correct', stem: '结合古诗文选择正确理解。',
                correctAnswer: 'C', studentAnswer: 'C', classRate: '84%', schoolRate: '84%', knowledge: '古诗文默写',
                options: [
                    { label: 'A', value: '海内存知己，天涯若比邻——王勃《送杜少府之任蜀州》' },
                    { label: 'B', value: '大漠孤烟直，长河落日圆——王维《使至塞上》' },
                    { label: 'C', value: '感时花溅泪，恨别鸟惊心——杜甫《春望》' },
                    { label: 'D', value: '落红不是无情物，化作春泥更护花——龚自珍《己亥杂诗》' },
                ],
            },
            {
                no: 8, type: '选择题', score: '4/4', status: 'correct', stem: '阅读片段后概括中心信息。',
                correctAnswer: 'D', studentAnswer: 'D', classRate: '80%', schoolRate: '81%', knowledge: '名著阅读',
                options: [
                    { label: 'A', value: '《朝花夕拾》——鲁迅回忆童年生活的散文集' },
                    { label: 'B', value: '《骆驼祥子》——老舍描写北京底层劳动人民的小说' },
                    { label: 'C', value: '《钢铁是怎样炼成的》——奥斯特洛夫斯基自传体小说' },
                    { label: 'D', value: '《海底两万里》——凡尔纳的科幻小说，描写了海底探险' },
                ],
            },
            {
                no: 9, type: '选择题', score: '4/4', status: 'correct', stem: '判断句间衔接是否连贯。',
                correctAnswer: 'A', studentAnswer: 'A', classRate: '76%', schoolRate: '78%', knowledge: '语段衔接',
                options: [
                    { label: 'A', value: '首先……其次……最后……' },
                    { label: 'B', value: '然后……接着……最后……' },
                    { label: 'C', value: '不但……而且……还……' },
                    { label: 'D', value: '因为……所以……因此……' },
                ],
            },
            {
                no: 10, type: '选择题', score: '4/4', status: 'correct', stem: '完成句式转换。',
                correctAnswer: 'C', studentAnswer: 'C', classRate: '72%', schoolRate: '75%', knowledge: '句式转换',
                options: [
                    { label: 'A', value: '把字句：我把作业写完了。' },
                    { label: 'B', value: '被字句：作业被我写完了。' },
                    { label: 'C', value: '反问句：难道这不是事实吗？' },
                    { label: 'D', value: '感叹句：这真是太好了！' },
                ],
            },
            { no: 11, type: '填空题', score: '5/5', status: 'correct', stem: '补全古文实词解释。', correctAnswer: '明察', studentAnswer: '明察', classRate: '88%', schoolRate: '72%', knowledge: '古文实词' },
            { no: 12, type: '填空题', score: '5/5', status: 'correct', stem: '补全古文虚词用法。', correctAnswer: '之', studentAnswer: '之', classRate: '84%', schoolRate: '69%', knowledge: '古文虚词' },
            { no: 13, type: '填空题', score: '5/5', status: 'correct', stem: '判断文言断句位置。', correctAnswer: 'B', studentAnswer: 'B', classRate: '80%', schoolRate: '84%', knowledge: '文言断句' },
            { no: 14, type: '填空题', score: '5/5', status: 'correct', stem: '翻译关键句子。', correctAnswer: '符合语境', studentAnswer: '符合语境', classRate: '76%', schoolRate: '81%', knowledge: '翻译理解' },
            { no: 15, type: '填空题', score: '5/5', status: 'correct', stem: '赏析诗句表达效果。', correctAnswer: '借景抒情', studentAnswer: '借景抒情', classRate: '72%', schoolRate: '78%', knowledge: '诗歌鉴赏' },
            { no: 16, type: '填空题', score: '5/5', status: 'correct', stem: '概括现代文段落作用。', correctAnswer: '承上启下', studentAnswer: '承上启下', classRate: '68%', schoolRate: '74%', knowledge: '段落作用' },
            { no: 17, type: '解答题', score: '4/4', status: 'correct', stem: '结合文本分析人物形象。', correctAnswer: '要点完整', studentAnswer: '要点完整', classRate: '81%', schoolRate: '77%', knowledge: '人物形象' },
            { no: 18, type: '解答题', score: '4/4', status: 'correct', stem: '解释标题的含义。', correctAnswer: '双层含义', studentAnswer: '双层含义', classRate: '79%', schoolRate: '73%', knowledge: '标题含义' },
            { no: 19, type: '解答题', score: '4/4', status: 'correct', stem: '分析语句表达效果。', correctAnswer: '修辞与情感', studentAnswer: '修辞与情感', classRate: '73%', schoolRate: '70%', knowledge: '语句赏析' },
            { no: 20, type: '解答题', score: '4/4', status: 'correct', stem: '根据材料提出观点。', correctAnswer: '观点明确', studentAnswer: '观点明确', classRate: '70%', schoolRate: '68%', knowledge: '观点表达' },
            { no: 21, type: '解答题', score: '4/4', status: 'correct', stem: '完成综合探究。', correctAnswer: '材料充分', studentAnswer: '材料充分', classRate: '66%', schoolRate: '63%', knowledge: '综合探究' },
            { no: 22, type: '压轴题', score: '2/5', status: 'wrong', stem: '结合整篇文章完成开放表达。', correctAnswer: '围绕主题并联系生活', studentAnswer: '联系不足', classRate: '52%', schoolRate: '49%', knowledge: '开放表达' },
            { no: 23, type: '压轴题', score: '3/5', status: 'wrong', stem: '完成写作片段升格。', correctAnswer: '结构完整、语言有层次', studentAnswer: '结构较散', classRate: '48%', schoolRate: '44%', knowledge: '写作表达' },
        ],
        knowledgeRatios: [
            { name: '函数与图像', percent: 40, tone: 'blue' },
            { name: '几何证明', percent: 35, tone: 'orange' },
            { name: '方程应用', percent: 25, tone: 'green' },
        ],
        knowledgeScores: [
            { name: '《西游记》', fullScore: 2, score: 0 },
            { name: '情感主旨', fullScore: 2, score: 0 },
            { name: '环境描写', fullScore: 4, score: 1.5 },
            { name: '开放表达', fullScore: 5, score: 2 },
            { name: '写作表达', fullScore: 5, score: 3 },
        ],
    },
};

export const subjectOptions = SUBJECT_FILTER_OPTIONS.map((item) => item.label);
export const gradeOptions = ['全部年级', '初一', '初二', '初三'];
export const categoryOptions = ['全部类型', '周作业', '月考'];

export const knowledgeWeakPoints: KnowledgeWeakPoint[] = [
    {
        name: '函数与图像',
        subject: '数学',
        grade: '初一',
        category: '周作业',
        fullScore: 20,
        score: 8,
        wrongPercent: 40,
        tone: 'blue',
    },
    {
        name: '几何证明',
        subject: '数学',
        grade: '初一',
        category: '周作业',
        fullScore: 20,
        score: 9,
        wrongPercent: 45,
        tone: 'orange',
    },
    {
        name: '方程应用',
        subject: '数学',
        grade: '初一',
        category: '月考',
        fullScore: 20,
        score: 15,
        wrongPercent: 25,
        tone: 'green',
    },
    {
        name: '现代文阅读',
        subject: '语文',
        grade: '初一',
        category: '周作业',
        fullScore: 16,
        score: 10,
        wrongPercent: 38,
        tone: 'rose',
    },
    {
        name: '完形填空',
        subject: '英语',
        grade: '初一',
        category: '月考',
        fullScore: 15,
        score: 11,
        wrongPercent: 27,
        tone: 'blue',
    },
];

export const abilityTrend: AbilityTrendPoint[] = [
    { date: '11-22', score: 62 },
    { date: '11-28', score: 68 },
    { date: '12-05', score: 72 },
    { date: '12-13', score: 91 },
    { date: '12-20', score: 75 },
    { date: '12-27', score: 78 },
    { date: '01-03', score: 81 },
    { date: '01-08', score: 76 },
    { date: '01-14', score: 79 },
];

export const abilitySummary: AbilitySummary[] = [
    {
        label: '得分能力综合评估',
        value: '良好',
        desc: '最近一次峰值明显，整体维持在良好区间。',
    },
    {
        label: '得分能力稳定性',
        value: '相对波动',
        desc: '12月中旬后回落，需要关注高分后的复盘质量。',
    },
];
