// Extra data for academy v2 — student detail, inbox, progress.

// Full profile for the focal student (Sophie Lam)
const TL_STUDENT_S1_FULL = {
  id: 's1', name: 'Sophie Lam',         nameZh: '林澄熹',
  studentNo: 'TL-2024-S1042',
  photo: null, photoColor: '#E8DCC8', photoMono: 'SL',
  dob: '2016-08-14', age: 9,
  enrolled: '2024-12-08',
  branch: 'Tsim Sha Tsui',
  studio: 'Studio 4',
  instrument: 'Piano',
  level: 'ABRSM Grade 3',
  teacher: 'Ms. Chen Wai-Lam',
  teacherId: 't1',
  weeklySlot: 'Tuesday · 15:00 · 45 min',
  lifecycle: 'Enrolled · Y2 · Recital prep',

  primary: {
    name: 'Mrs. Lam Hoi-Yi',  nameZh: '林海怡',
    relation: 'Mother', relationZh: '母親',
    phone: '+852 9123 4567',
    whatsapp: true,
    email: 'hylam@example.hk',
    preferred: 'WhatsApp',
    language: 'Cantonese / English',
  },
  secondary: {
    name: 'Mr. Lam Wing-Shun',  nameZh: '林永信',
    relation: 'Father',  relationZh: '父親',
    phone: '+852 9234 5678',
    whatsapp: false,
    email: 'wslam@example.hk',
    preferred: 'Email',
    language: 'Cantonese',
  },
  emergency: {
    name: 'Mrs. Lam Mei-Fong (grandmother)',
    nameZh: '林美芳 (祖母)',
    phone: '+852 9876 5432',
  },
  address: 'Flat 12B, 8 Hung Hom Road, Hung Hom, Kowloon',
  staffNote: 'Parent prefers Cantonese for verbal updates. Sophie is shy with new teachers — keep the same room and slot.',
  staffNoteZh: '家長偏好以廣東話作口頭溝通。Sophie 對新老師較內向 — 維持同一琴室及時段。',
};

// Practice log — last 28 days, minutes per day
const TL_PRACTICE_28 = [
  20,30,15,0,25,40,35,
  30,25,0,35,45,30,40,
  25,30,30,0,40,45,50,
  30,25,35,40,30,45,45,
];

// Exam history
const TL_EXAMS_S1 = [
  { exam: 'ABRSM Piano Grade 1', date: '2024-06-12', result: 'Distinction', score: 137 },
  { exam: 'ABRSM Piano Grade 2', date: '2025-06-08', result: 'Merit',       score: 128 },
  { exam: 'ABRSM Piano Grade 3', date: '2026-06-15', result: 'Upcoming',    score: null, prep: true },
  { exam: 'ABRSM Theory Grade 1', date: '2025-03-15', result: 'Pass',        score: 84 },
];

// Communications log — every message sent to Mrs. Lam
const TL_COMMS_S1 = [
  { id: 'c1', when: '2026-04-21 15:48', kind: 'WhatsApp', dir: 'out', subject: 'Lesson handbook · Apr 21',  read: true,  sent: 'Ms. Chen' },
  { id: 'c2', when: '2026-04-21 17:12', kind: 'WhatsApp', dir: 'in',  subject: 'Reply: Thanks! Will work on it 🙏', read: true, sent: 'Mrs. Lam' },
  { id: 'c3', when: '2026-04-14 16:02', kind: 'WhatsApp', dir: 'out', subject: 'Lesson handbook · Apr 14',  read: true,  sent: 'Ms. Chen' },
  { id: 'c4', when: '2026-04-07 14:55', kind: 'WhatsApp', dir: 'in',  subject: 'Sophie unwell — sick leave today', read: true, sent: 'Mrs. Lam' },
  { id: 'c5', when: '2026-03-31 16:00', kind: 'WhatsApp', dir: 'out', subject: 'Lesson handbook · Mar 31',  read: true,  sent: 'Ms. Chen' },
  { id: 'c6', when: '2026-03-24 16:08', kind: 'WhatsApp', dir: 'out', subject: 'Lesson handbook · Mar 24',  read: true,  sent: 'Ms. Chen' },
  { id: 'c7', when: '2026-03-15 09:30', kind: 'Email',    dir: 'out', subject: 'Term 2 invoice · HK$4,800', read: true,  sent: 'TST Branch' },
  { id: 'c8', when: '2026-02-28 10:00', kind: 'Email',    dir: 'out', subject: 'Spring recital — sign-up open', read: true, sent: 'TST Branch' },
];

// — INBOX threads — every parent at TST with active conversation —
const TL_THREADS = [
  { id: 'th1', studentId: 's1', name: 'Mrs. Lam',     family: 'Sophie Lam · Piano Gr.3',     lastMsg: 'Thanks! Will work on it 🙏',                        when: '17:12',  unread: 0, you: false, starred: true,  by: 'Ms. Chen' },
  { id: 'th2', studentId: 's2', name: 'Mr. Wong',     family: 'Marcus Wong · Violin Gr.5',   lastMsg: 'Could we move next Tuesday to 17:30?',              when: '16:48',  unread: 2, you: false, starred: false, by: 'Mr. Cheung' },
  { id: 'th3', studentId: 's3', name: 'Mrs. Cheung',  family: 'Emily Cheung · Piano Gr.1',   lastMsg: 'Lesson handbook · Apr 28',                          when: '15:20',  unread: 0, you: true,  starred: false, by: 'Ms. Chen' },
  { id: 'th4', studentId: 's4', name: 'Mrs. Ip',      family: 'Daniel Ip · Guitar Gr.6',     lastMsg: 'Reminder: Term 2 fees outstanding',                 when: '11:05',  unread: 1, you: true,  starred: false, by: 'TST Branch', urgent: true },
  { id: 'th5', studentId: 's5', name: 'Mr. Tang',     family: 'Chloe Tang · Cello Gr.4',     lastMsg: 'Is the exam date confirmed?',                       when: 'Yest.',  unread: 1, you: false, starred: false, by: 'Ms. Lo' },
  { id: 'th6', studentId: 's6', name: 'Mrs. Ho',      family: 'Aiden Ho · Saxophone Gr.3',   lastMsg: 'Lesson handbook · Apr 27',                          when: 'Yest.',  unread: 0, you: true,  starred: false, by: 'Mr. Lai' },
  { id: 'th7', studentId: 's7', name: 'Mr. Mak',      family: 'Isabella Mak · Flute Gr.2',   lastMsg: '好的，下星期見。',                                     when: 'Mon',    unread: 0, you: false, starred: false, by: 'Ms. Ng' },
  { id: 'th8', studentId: 'sX', name: 'Wong family',  family: 'Trial enquiry · Piano',       lastMsg: 'Will Aria need her own keyboard at home?',          when: 'Mon',    unread: 1, you: false, starred: false, by: 'Karen (Front desk)' },
];

// Conversation messages for the active thread (Mrs. Lam · Sophie)
const TL_THREAD_S1_MSGS = [
  { id: 'm1', from: 'them', name: 'Mrs. Lam',  text: 'Good morning! Sophie really enjoyed yesterday\u2019s lesson 😊', when: 'Mon 09:14' },
  { id: 'm2', from: 'you',  name: 'Ms. Chen',  text: 'So glad to hear that! She\u2019s really finding her voice on the Arabesque.', when: 'Mon 09:32' },
  { id: 'm3', from: 'sys',  text: 'Lesson handbook · Apr 21 sent — opened',  when: 'Tue 15:48' },
  { id: 'm4', from: 'them', name: 'Mrs. Lam',  text: 'Read the handbook — thank you for the detailed notes! Will work on bars 9–12 with the metronome 🙏', when: 'Tue 17:12' },
  { id: 'm5', from: 'you',  name: 'Ms. Chen',  text: 'Slow practice is the goal — under tempo is fine for the next 4 days.', when: 'Tue 17:20' },
];

// Broadcast templates
const TL_BROADCAST_TPL = [
  { id: 'tp1', label: 'Holiday closure',          en: 'Branch closed for public holiday', zh: '分行公眾假期休息' },
  { id: 'tp2', label: 'Fees reminder',            en: 'Term 2 fees outstanding',          zh: '第二期學費提醒' },
  { id: 'tp3', label: 'Recital sign-up',          en: 'Spring recital — sign-up open',    zh: '春季演奏會開始報名' },
  { id: 'tp4', label: 'Exam date confirmed',      en: 'ABRSM exam date confirmed',        zh: 'ABRSM 考試日期已確認' },
  { id: 'tp5', label: 'Studio change',            en: 'Studio change for next lesson',    zh: '下堂琴室更改' },
];

// — PROGRESS view: by teacher —
const TL_TEACHER_PROGRESS = [
  {
    id: 't1', name: 'Ms. Chen Wai-Lam', subject: 'Piano · Theory · Aural',
    students: 28, weeklyLessons: 26,
    avgSkill: 3.6,           // 0-5
    skillDelta: 0.18,        // since Jan
    examPassRate: 0.94,      // last 12 mo
    handbookOnTime: 0.98,
    parentOpen: 0.97,
    avgPiecesPerTerm: 4.2,
    flagged: 1,              // students at risk
    risers: 4,
    trend: [3.2, 3.3, 3.4, 3.5, 3.55, 3.6],
    risk: [{ id: 's4', name: 'Daniel Ip', why: 'Attendance 88% · piece pace -1.5/term' }],
    rising: [
      { id: 's1', name: 'Sophie Lam',   why: 'Skill +0.4 in 3 months · recital ready' },
      { id: 's3', name: 'Emily Cheung', why: 'Theory Gr.1 distinction projected' },
    ],
  },
  {
    id: 't2', name: 'Mr. Cheung Ka-Ho', subject: 'Violin · Viola',
    students: 24, weeklyLessons: 22,
    avgSkill: 3.4, skillDelta: 0.10, examPassRate: 0.89,
    handbookOnTime: 0.91, parentOpen: 0.94, avgPiecesPerTerm: 3.8,
    flagged: 2, risers: 3,
    trend: [3.2, 3.25, 3.3, 3.3, 3.35, 3.4],
    risk: [
      { id: 's2', name: 'Marcus Wong', why: 'Lesson reschedule streak · 3 in 4 weeks' },
      { id: 'x1', name: 'Lucas Cheng', why: 'Trial \u2192 unconfirmed enrol' },
    ],
    rising: [],
  },
  {
    id: 't3', name: 'Ms. Lo Hiu-Ting', subject: 'Cello',
    students: 18, weeklyLessons: 17,
    avgSkill: 3.5, skillDelta: 0.22, examPassRate: 0.92,
    handbookOnTime: 0.96, parentOpen: 0.95, avgPiecesPerTerm: 4.0,
    flagged: 0, risers: 2,
    trend: [3.0, 3.15, 3.25, 3.35, 3.4, 3.5],
    risk: [],
    rising: [{ id: 's5', name: 'Chloe Tang', why: 'Skill +0.5 · confident performer' }],
  },
  {
    id: 't4', name: 'Mr. Lai Chun-Wai', subject: 'Saxophone · Clarinet',
    students: 19, weeklyLessons: 18,
    avgSkill: 3.2, skillDelta: 0.05, examPassRate: 0.84,
    handbookOnTime: 0.82, parentOpen: 0.88, avgPiecesPerTerm: 3.4,
    flagged: 3, risers: 1,
    trend: [3.1, 3.1, 3.15, 3.15, 3.2, 3.2],
    risk: [
      { id: 's6', name: 'Aiden Ho',  why: 'Practice <60 min/wk avg' },
      { id: 'x2', name: 'Ryan Sze',  why: 'Missed 2 lessons last month' },
      { id: 'x3', name: 'Tara Yip',  why: 'Parent reply rate dropping' },
    ],
    rising: [],
  },
  {
    id: 't5', name: 'Ms. Wong Sze-Man', subject: 'Piano',
    students: 26, weeklyLessons: 25,
    avgSkill: 3.7, skillDelta: 0.20, examPassRate: 0.96,
    handbookOnTime: 0.99, parentOpen: 0.98, avgPiecesPerTerm: 4.5,
    flagged: 0, risers: 5,
    trend: [3.3, 3.4, 3.5, 3.55, 3.65, 3.7],
    risk: [],
    rising: [],
  },
];

Object.assign(window, {
  TL_STUDENT_S1_FULL, TL_PRACTICE_28, TL_EXAMS_S1, TL_COMMS_S1,
  TL_THREADS, TL_THREAD_S1_MSGS, TL_BROADCAST_TPL,
  TL_TEACHER_PROGRESS,
});
