@celljs/ta-edu 4.25.0 → 4.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/web/index.js +3090 -315
package/web/index.js CHANGED
@@ -278,9 +278,13 @@ var TaSecretRef;
278
278
 
279
279
  // web-src/edu-protocol.ts
280
280
  var NAME = "@celljs/ta-edu";
281
+ var PAGE = `${NAME}/home`;
281
282
  var MARK = "[ta:edu]";
282
283
  var QUIZ = "ta-quiz";
283
284
  var LEARNING = "ta-learning";
285
+ var GROUP_KIND = "ta-rooms";
286
+ var DIRECT_KIND = "ta-direct";
287
+ var STATE = "edu:";
284
288
  var IDENTITIES = ["student", "parent", "teacher", "homeroom"];
285
289
  var STAGES = ["primary", "junior", "senior"];
286
290
  var Keys;
@@ -289,6 +293,9 @@ var Keys;
289
293
  Keys.MISTAKES = "mistakes";
290
294
  Keys.CHATS = "chats";
291
295
  Keys.ANSWERS = "answers";
296
+ Keys.DAYS = "days";
297
+ Keys.POSTED = "posted";
298
+ Keys.TEACHER_KEY = "teacherKey";
292
299
  })(Keys ||= {});
293
300
 
294
301
  // web-src/edu-util.ts
@@ -296,6 +303,7 @@ var DAY = 86400000;
296
303
  var INTERVALS = [1, 3, 7, 14, 30];
297
304
  var MAX_MISTAKES = 300;
298
305
  var MAX_ANSWERED = 200;
306
+ var MAX_DAYS = 60;
299
307
  var EduUtil;
300
308
  ((EduUtil) => {
301
309
  function settings(value) {
@@ -307,10 +315,129 @@ var EduUtil;
307
315
  subject: typeof stored.subject === "string" ? stored.subject : "",
308
316
  textbook: typeof stored.textbook === "string" ? stored.textbook : "",
309
317
  consent: stored.consent === true,
310
- asked: stored.asked === true
318
+ current: IDENTITIES.includes(stored.current) && identities.includes(stored.current) ? stored.current : undefined,
319
+ classes: Array.isArray(stored.classes) ? stored.classes.filter((one) => typeof one === "string") : [],
320
+ klass: typeof stored.klass === "string" ? stored.klass : undefined,
321
+ reportTo: typeof stored.reportTo === "string" ? stored.reportTo : undefined,
322
+ reportAt: typeof stored.reportAt === "number" ? stored.reportAt : undefined
311
323
  };
312
324
  }
313
325
  EduUtil.settings = settings;
326
+ function current(settings2) {
327
+ return settings2.current ?? settings2.identities[0];
328
+ }
329
+ EduUtil.current = current;
330
+ function dayOf(time) {
331
+ const date = new Date(time);
332
+ return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
333
+ }
334
+ EduUtil.dayOf = dayOf;
335
+ function days(value) {
336
+ if (!value || typeof value !== "object") {
337
+ return {};
338
+ }
339
+ return Object.fromEntries(Object.entries(value).filter(([key, day]) => /^\d{4}-\d{2}-\d{2}$/.test(key) && typeof day?.n === "number" && typeof day?.right === "number"));
340
+ }
341
+ EduUtil.days = days;
342
+ function withDay(all, now, right) {
343
+ const key = dayOf(now);
344
+ const day = all[key] ?? { n: 0, right: 0 };
345
+ const next = { ...all, [key]: { n: day.n + 1, right: day.right + (right ? 1 : 0) } };
346
+ const keys = Object.keys(next).sort();
347
+ for (const old of keys.slice(0, Math.max(0, keys.length - MAX_DAYS))) {
348
+ delete next[old];
349
+ }
350
+ return next;
351
+ }
352
+ EduUtil.withDay = withDay;
353
+ function streak(all, now) {
354
+ let count = 0;
355
+ let time = all[dayOf(now)]?.n ? now : now - DAY;
356
+ while (all[dayOf(time)]?.n) {
357
+ count++;
358
+ time -= DAY;
359
+ }
360
+ return count;
361
+ }
362
+ EduUtil.streak = streak;
363
+ function week(all, now) {
364
+ const today = new Date(now);
365
+ const monday = now - (today.getDay() + 6) % 7 * DAY;
366
+ return Array.from({ length: 7 }, (_, at) => {
367
+ const time = monday + at * DAY;
368
+ const day = all[dayOf(time)];
369
+ return { n: day?.n ?? 0, right: day?.right ?? 0, today: dayOf(time) === dayOf(now), future: time > now && dayOf(time) !== dayOf(now) };
370
+ });
371
+ }
372
+ EduUtil.week = week;
373
+ function lastWeek(all, now) {
374
+ let n = 0;
375
+ let right = 0;
376
+ let days2 = 0;
377
+ for (let at = 0;at < 7; at++) {
378
+ const day = all[dayOf(now - at * DAY)];
379
+ if (day?.n) {
380
+ n += day.n;
381
+ right += day.right;
382
+ days2++;
383
+ }
384
+ }
385
+ return { n, right, days: days2 };
386
+ }
387
+ EduUtil.lastWeek = lastWeek;
388
+ function books(mistakes2, now, other) {
389
+ const by = new Map;
390
+ for (const mistake of mistakes2) {
391
+ const subject = mistake.subject?.trim() || other;
392
+ by.set(subject, [...by.get(subject) ?? [], mistake]);
393
+ }
394
+ return [...by].map(([subject, list]) => ({
395
+ subject,
396
+ mistakes: [...list].sort((a, b) => a.due - b.due),
397
+ due: list.filter((one) => one.due <= now).length,
398
+ progress: Math.round(list.reduce((sum, one) => sum + one.level, 0) / (list.length * INTERVALS.length) * 100)
399
+ })).sort((a, b) => b.due - a.due || b.mistakes.length - a.mistakes.length || a.subject.localeCompare(b.subject));
400
+ }
401
+ EduUtil.books = books;
402
+ function weak(mistakes2, count = 3) {
403
+ const by = new Map;
404
+ for (const mistake of mistakes2) {
405
+ if (mistake.topic && mistake.level < 2) {
406
+ by.set(mistake.topic, (by.get(mistake.topic) ?? 0) + 1);
407
+ }
408
+ }
409
+ return [...by].sort((a, b) => b[1] - a[1]).slice(0, count).map(([topic]) => topic);
410
+ }
411
+ EduUtil.weak = weak;
412
+ function result(posted, submissions) {
413
+ const total = posted.questions.length;
414
+ const bands = [0, 0, 0, 0, 0];
415
+ const wrong = posted.questions.map(() => []);
416
+ let sum = 0;
417
+ for (const one of submissions) {
418
+ const right = one.right.filter(Boolean).length;
419
+ const score = total ? right / total : 0;
420
+ sum += score;
421
+ bands[score < 0.6 ? 0 : Math.min(4, Math.floor(score * 10) - 5)]++;
422
+ for (const [at, ok] of one.right.entries()) {
423
+ if (!ok && at < total) {
424
+ wrong[at].push(one.name);
425
+ }
426
+ }
427
+ }
428
+ return { count: submissions.length, average: submissions.length ? Math.round(sum / submissions.length * 1000) / 10 : 0, bands, wrong };
429
+ }
430
+ EduUtil.result = result;
431
+ function hardest(result2) {
432
+ let best;
433
+ result2.wrong.forEach((names, at) => {
434
+ if (names.length && (best === undefined || names.length > result2.wrong[best].length)) {
435
+ best = at;
436
+ }
437
+ });
438
+ return best;
439
+ }
440
+ EduUtil.hardest = hardest;
314
441
  function locked(settings2, identity) {
315
442
  return identity === "student" && settings2.stage === "primary" && !settings2.consent;
316
443
  }
@@ -347,6 +474,7 @@ var EduUtil;
347
474
  question: known?.question ?? question2.q,
348
475
  answer: answerText(question2),
349
476
  given,
477
+ subject: question2.subject ?? known?.subject,
350
478
  topic: question2.topic ?? known?.topic,
351
479
  explain: question2.explain ?? known?.explain,
352
480
  at: now,
@@ -402,10 +530,10 @@ var EduUtil;
402
530
  return;
403
531
  }
404
532
  const options = strings(raw.options);
405
- const base = { q, explain: text(raw.explain), topic: text(raw.topic), review: text(raw.review) };
533
+ const base = { q, explain: text(raw.explain), subject: text(raw.subject), topic: text(raw.topic), review: text(raw.review) };
406
534
  const answer = raw.answer;
407
535
  if (options.length >= 2) {
408
- const byText = options.findIndex((one) => one === text(answer));
536
+ const byText = options.indexOf(text(answer) ?? "");
409
537
  const byLetter = typeof answer === "string" && /^[A-Za-z]$/.test(answer.trim()) ? answer.trim().toUpperCase().charCodeAt(0) - 65 : -1;
410
538
  const index = typeof answer === "number" ? answer : byText >= 0 ? byText : byLetter;
411
539
  return index >= 0 && index < options.length ? { ...base, kind: "choice", options, answer: index } : undefined;
@@ -421,7 +549,13 @@ var EduUtil;
421
549
  const raw = parse(code);
422
550
  const list = Array.isArray(raw?.questions) ? raw.questions : Array.isArray(raw) ? raw : undefined;
423
551
  const questions = list?.flatMap((one) => question(one) ?? []) ?? [];
424
- return questions.length ? { title: text(raw?.title), questions, reveal: raw?.reveal === true } : undefined;
552
+ if (!questions.length) {
553
+ return;
554
+ }
555
+ const id = text(raw?.id);
556
+ const room = text(raw?.room);
557
+ const teacher = text(raw?.teacher);
558
+ return { title: text(raw?.title), questions, reveal: raw?.reveal === true, ...id && room && teacher ? { id, room, teacher } : {} };
425
559
  }
426
560
  EduUtil.quiz = quiz;
427
561
  function learning(code) {
@@ -431,7 +565,12 @@ var EduUtil;
431
565
  const value = typeof one?.value === "number" ? Math.max(0, Math.min(100, Math.round(one.value))) : undefined;
432
566
  return label && value !== undefined ? [{ label, value, note: text(one.note) }] : [];
433
567
  }) : [];
434
- return items.length ? { title: text(raw?.title), items, weak: strings(raw?.weak), next: strings(raw?.next) } : undefined;
568
+ const stats = Array.isArray(raw?.stats) ? raw.stats.flatMap((one) => {
569
+ const label = text(one?.label);
570
+ const value = text(one?.value);
571
+ return label && value ? [{ label, value }] : [];
572
+ }) : [];
573
+ return items.length || stats.length ? { title: text(raw?.title), items, weak: strings(raw?.weak), next: strings(raw?.next), stats, report: raw?.report === true } : undefined;
435
574
  }
436
575
  EduUtil.learning = learning;
437
576
  function parse(code) {
@@ -443,6 +582,89 @@ var EduUtil;
443
582
  }
444
583
  })(EduUtil ||= {});
445
584
 
585
+ // web-src/edu-roles.ts
586
+ var QUIZ_FORMAT = `To give questions to answer, write a fenced block of language ${QUIZ} holding JSON, which Ta draws as a card the user answers in, checked at once: {"title"?: string, "reveal"?: boolean, "questions": [{"q": string, "options"?: [string] (a choice question; "answer" the letter), "answer": "B" | true | false (true or false question) | ["answers", "taken as right"] (fill in the blank), "explain": string, "subject": the school subject, "topic": the point it tests, "review"?: id of the mistake it reviews}]}. Mistakes the user makes in it are kept for review. To show how someone is learning, a ${LEARNING} block: {"title"?: string, "items": [{"label": topic, "value": 0-100 mastery, "note"?: string}], "weak"?: [string], "next"?: [what to do next]}.`;
587
+ var ROLES = {
588
+ student: {
589
+ assistant: "assistantStudent",
590
+ tagline: "taglineStudent",
591
+ icon: "BookOpen",
592
+ skills: ["edu-tutor", "edu-quiz"],
593
+ actions: [
594
+ { key: "explain", icon: "Image" },
595
+ { key: "quizMe", icon: "ListChecks", send: true },
596
+ { key: "review", icon: "RotateCcw", send: true },
597
+ { key: "recite", icon: "Mic" }
598
+ ],
599
+ rules: "You tutor a student. Never give the final answer or a whole solution before the student has tried: ask what they know, give one hint at a time, let them do each step, and show the full solution only once they reached it or asked twice after trying. Check understanding with a question in another form. Never write their essays or homework for them: outlines, questions and comments on what they wrote. Encourage effort, not talent. If they speak of distress, listen, and tell them to talk to a parent or a teacher they trust."
600
+ },
601
+ parent: {
602
+ assistant: "assistantParent",
603
+ tagline: "taglineParent",
604
+ icon: "House",
605
+ skills: ["edu-parent", "edu-quiz"],
606
+ actions: [
607
+ { key: "check", icon: "Image" },
608
+ { key: "talk", icon: "MessageCircle" },
609
+ { key: "toTeacher", icon: "Send" },
610
+ { key: "plan", icon: "Calendar" }
611
+ ],
612
+ rules: "You help a parent help their child. Tell the parent where and why the child went wrong, the words to explain it to the child at their age, and one practice question; do not do the homework for the child. Help them keep calm and kind; on messages to teachers, help them be clear, specific and respectful. Their child is theirs to judge: no labels, no diagnosis."
613
+ },
614
+ teacher: {
615
+ assistant: "assistantTeacher",
616
+ tagline: "taglineTeacher",
617
+ icon: "Pencil",
618
+ skills: ["edu-grading", "edu-quiz", "edu-lesson"],
619
+ actions: [
620
+ { key: "grade", icon: "ListChecks" },
621
+ { key: "makeQuiz", icon: "FilePlus" },
622
+ { key: "lesson", icon: "FileText" },
623
+ { key: "exam", icon: "ChartSpline" },
624
+ { key: "weekly", icon: "Calendar", send: true }
625
+ ],
626
+ rules: 'You assist a teacher. Marking: right or wrong for each question, the causes of the mistakes grouped, what the class shares, and an outline to go over it; what you are unsure of you say. Questions: in three levels (basic, better, stretch) with answers and explanations, "reveal": true. Score sheets and records in the working directory you read yourself; you count, the teacher decides. Names of students stay on this computer.'
627
+ },
628
+ homeroom: {
629
+ assistant: "assistantHomeroom",
630
+ tagline: "taglineHomeroom",
631
+ icon: "Users",
632
+ skills: ["edu-homeroom"],
633
+ actions: [
634
+ { key: "reply", icon: "MessageCircle" },
635
+ { key: "comments", icon: "Pencil" },
636
+ { key: "meeting", icon: "Users" },
637
+ { key: "notice", icon: "Megaphone" }
638
+ ],
639
+ rules: "You assist a class teacher. Replies to parents are drafts the teacher sends: warm, clear, within what the school decides, never promising what is not theirs. Report comments come from what the teacher told of each student, specific and kind, no stock phrases. A student at risk (self-harm, abuse, bullying): tell the teacher to bring in the school counsellor, the school leaders and the parents at once; do not handle it alone."
640
+ }
641
+ };
642
+ var STAGE_NAMES = { primary: "primary school", junior: "middle school", senior: "high school" };
643
+ var EduRoles;
644
+ ((EduRoles) => {
645
+ function prompt(identity, settings) {
646
+ const role = ROLES[identity];
647
+ const about = [
648
+ settings.stage && `stage: ${STAGE_NAMES[settings.stage]}`,
649
+ settings.subject && `subjects: ${settings.subject}`,
650
+ settings.textbook && `textbooks: ${settings.textbook}`
651
+ ].filter(Boolean);
652
+ return [
653
+ `${MARK} You are Ta for a ${identity === "homeroom" ? "class teacher" : identity} in school education in China${about.length ? ` (${about.join("; ")})` : ""}.`,
654
+ role.rules,
655
+ `Skills for this: ${role.skills.join(", ")}.`,
656
+ "What students, scores and families are is private: keep it on this computer, and leave names out of what is shared unless the user asks.",
657
+ QUIZ_FORMAT
658
+ ].join(`
659
+ `);
660
+ }
661
+ EduRoles.prompt = prompt;
662
+ function action(words, key) {
663
+ return words[key];
664
+ }
665
+ EduRoles.action = action;
666
+ })(EduRoles ||= {});
667
+
446
668
  // ../ta-protocol/esm/common/language.js
447
669
  var TaLanguageUtil;
448
670
  (function(TaLanguageUtil2) {
@@ -540,10 +762,6 @@ Draft me a reply; I will read it before I send it:` },
540
762
  textbookHint: "The edition your school uses",
541
763
  consentLabel: "Primary pupils may use the study buddy",
542
764
  consentHint: "Turned on by a parent or teacher",
543
- askTitle: "Ta can help the way your role needs",
544
- askWho: "You are",
545
- askStage: "Stage",
546
- later: "Later",
547
765
  quiz: "Practice",
548
766
  submit: "Check",
549
767
  right: "Right",
@@ -610,10 +828,6 @@ var ZH = {
610
828
  textbookHint: "学校用的教材版本",
611
829
  consentLabel: "允许小学生使用学习伙伴",
612
830
  consentHint: "由家长或老师开启",
613
- askTitle: "Ta 可以按你的身份来帮你",
614
- askWho: "你是",
615
- askStage: "学段",
616
- later: "以后再说",
617
831
  quiz: "练习",
618
832
  submit: "提交",
619
833
  right: "答对了",
@@ -680,10 +894,6 @@ var ZH_TW = {
680
894
  textbookHint: "學校用的教材版本",
681
895
  consentLabel: "允許小學生使用學習夥伴",
682
896
  consentHint: "由家長或老師開啟",
683
- askTitle: "Ta 可以依你的身分來幫你",
684
- askWho: "你是",
685
- askStage: "學段",
686
- later: "以後再說",
687
897
  quiz: "練習",
688
898
  submit: "送出",
689
899
  right: "答對了",
@@ -750,10 +960,6 @@ var JA = {
750
960
  textbookHint: "学校で使っている教科書",
751
961
  consentLabel: "小学生が学習パートナーを使える",
752
962
  consentHint: "保護者か先生がオンにします",
753
- askTitle: "Ta はあなたの立場に合わせて手伝います",
754
- askWho: "あなたは",
755
- askStage: "学校段階",
756
- later: "あとで",
757
963
  quiz: "練習",
758
964
  submit: "答え合わせ",
759
965
  right: "正解",
@@ -782,86 +988,1153 @@ var EduWords;
782
988
  EduWords.format = format;
783
989
  })(EduWords ||= {});
784
990
 
991
+ // web-src/edu-chats.ts
992
+ var EduChats;
993
+ ((EduChats) => {
994
+ function identityOf(store, sessionFile) {
995
+ const { chats } = store.state;
996
+ return sessionFile ? Object.keys(chats).find((one) => chats[one] === sessionFile) : undefined;
997
+ }
998
+ EduChats.identityOf = identityOf;
999
+ async function open(pi, store, identity) {
1000
+ const words = EduWords.of(pi.ui.language);
1001
+ const { settings, chats } = store.state;
1002
+ if (EduUtil.locked(settings, identity)) {
1003
+ const yes = await pi.ui.confirm(words.consentTitle, words.consentMessage, { confirmLabel: words.consentConfirm });
1004
+ if (!yes) {
1005
+ return;
1006
+ }
1007
+ await store.setSettings({ consent: true });
1008
+ }
1009
+ const role = EduRoles.prompt(identity, store.state.settings);
1010
+ const title = words[ROLES[identity].assistant];
1011
+ const file = chats[identity];
1012
+ if (file) {
1013
+ const open2 = (await pi.server.listSessions()).find((session) => session.sessionFile === file);
1014
+ if (open2) {
1015
+ await pi.switchSession(open2.sessionId);
1016
+ pi.ui.showView("");
1017
+ return open2.sessionId;
1018
+ }
1019
+ const saved = (await pi.server.listSavedSessions()).find((session) => session.sessionFile === file);
1020
+ if (saved) {
1021
+ const opened2 = pi.server.openSession({ cwd: saved.cwd, sessionFile: file, group: NAME, appendSystemPrompt: role });
1022
+ const id2 = opened2.then((session) => session.sessionId);
1023
+ await pi.switchSession(id2, { title, cwd: saved.cwd, sessionFile: file });
1024
+ pi.ui.showView("");
1025
+ return id2;
1026
+ }
1027
+ }
1028
+ const { cwd } = await pi.server.getServerInfo();
1029
+ const opened = pi.server.openSession({ cwd, group: NAME, appendSystemPrompt: role });
1030
+ const named = opened.then(async (session) => {
1031
+ if (session.sessionFile) {
1032
+ await store.setChat(identity, session.sessionFile);
1033
+ }
1034
+ await pi.server.setSessionName(session.sessionId, title);
1035
+ });
1036
+ const id = opened.then((session) => session.sessionId);
1037
+ await pi.switchSession(id, { title, cwd });
1038
+ pi.ui.showView("");
1039
+ await named;
1040
+ return id;
1041
+ }
1042
+ EduChats.open = open;
1043
+ async function say(pi, store, identity, message, images) {
1044
+ const id = await open(pi, store, identity);
1045
+ if (id) {
1046
+ await send(pi, id, message, images);
1047
+ }
1048
+ }
1049
+ EduChats.say = say;
1050
+ async function send(pi, sessionId, message, images) {
1051
+ await pi.server.prompt(sessionId, { message, ...images?.length ? { images } : {}, clientMessageId: crypto.randomUUID() });
1052
+ }
1053
+ EduChats.send = send;
1054
+ })(EduChats ||= {});
1055
+ var EduPhotos;
1056
+ ((EduPhotos) => {
1057
+ function pick() {
1058
+ return new Promise((resolve) => {
1059
+ const input = document.createElement("input");
1060
+ input.type = "file";
1061
+ input.accept = "image/*";
1062
+ input.multiple = true;
1063
+ input.style.display = "none";
1064
+ input.addEventListener("change", () => {
1065
+ const files = [...input.files ?? []].slice(0, 6);
1066
+ input.remove();
1067
+ Promise.all(files.map(shrink)).then(resolve, () => resolve([]));
1068
+ });
1069
+ input.addEventListener("cancel", () => {
1070
+ input.remove();
1071
+ resolve([]);
1072
+ });
1073
+ document.body.appendChild(input);
1074
+ input.click();
1075
+ });
1076
+ }
1077
+ EduPhotos.pick = pick;
1078
+ async function shrink(file) {
1079
+ const bitmap = await createImageBitmap(file);
1080
+ const scale = Math.min(1, 1600 / Math.max(bitmap.width, bitmap.height));
1081
+ const canvas = document.createElement("canvas");
1082
+ canvas.width = Math.round(bitmap.width * scale);
1083
+ canvas.height = Math.round(bitmap.height * scale);
1084
+ canvas.getContext("2d")?.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
1085
+ bitmap.close();
1086
+ const url = canvas.toDataURL("image/jpeg", 0.85);
1087
+ return { type: "image", data: url.slice(url.indexOf(",") + 1), mimeType: "image/jpeg" };
1088
+ }
1089
+ function upload(pi, accept) {
1090
+ return new Promise((resolve) => {
1091
+ const input = document.createElement("input");
1092
+ input.type = "file";
1093
+ input.accept = accept;
1094
+ input.style.display = "none";
1095
+ input.addEventListener("change", () => {
1096
+ const file = input.files?.[0];
1097
+ input.remove();
1098
+ if (!file) {
1099
+ resolve(undefined);
1100
+ return;
1101
+ }
1102
+ const reader = new FileReader;
1103
+ reader.onload = () => {
1104
+ const url = String(reader.result);
1105
+ const path = `edu/${file.name.replace(/[\\/]/g, "_")}`;
1106
+ pi.workspace.uploadFile(path, url.slice(url.indexOf(",") + 1)).then(() => resolve(path), () => resolve(undefined));
1107
+ };
1108
+ reader.onerror = () => resolve(undefined);
1109
+ reader.readAsDataURL(file);
1110
+ });
1111
+ input.addEventListener("cancel", () => {
1112
+ input.remove();
1113
+ resolve(undefined);
1114
+ });
1115
+ document.body.appendChild(input);
1116
+ input.click();
1117
+ });
1118
+ }
1119
+ EduPhotos.upload = upload;
1120
+ })(EduPhotos ||= {});
1121
+
1122
+ // web-src/i18n-home.ts
1123
+ var EN2 = {
1124
+ eduTitle: "Education",
1125
+ pickTitle: "I am…",
1126
+ pickHint: "Pick all that fit; switch between them at the top",
1127
+ pickStage: "Stage",
1128
+ done: "Done",
1129
+ roles: "Roles",
1130
+ homeDetailPick: "Pick who you are to start",
1131
+ streak: "{count} days in a row",
1132
+ noStreak: "Start a streak today",
1133
+ dueHead: "{count} questions to review",
1134
+ dueNone: "Nothing to review today",
1135
+ reviewOf: "{subject} · review {n}",
1136
+ lastWrong: "Last time you wrote {given}",
1137
+ startReview: "Start review",
1138
+ noDueHint: "What you get wrong goes into your mistakes and comes back just before you would forget it",
1139
+ tilePhoto: "Snap a question",
1140
+ tileQuiz: "Quiz me",
1141
+ tileRecite: "Recite",
1142
+ tileSpeak: "Speaking",
1143
+ speakText: "Let's practise speaking: talk with me in simple English about my day, one question at a time, and correct my mistakes gently",
1144
+ mistakesBook: "Mistakes",
1145
+ bookCount: "{count} in all · {due} due",
1146
+ subjectLine: "{count} · {due} due",
1147
+ otherSubject: "Other",
1148
+ thisWeek: "This week",
1149
+ statQuestions: "questions",
1150
+ statRight: "right",
1151
+ statDays: "days studied",
1152
+ weekdays: "MTWTFSS",
1153
+ toParent: "Send my week to a parent",
1154
+ toParentOn: "Each week to {name}",
1155
+ pickParent: "Send it to",
1156
+ noFriends: "Add your parent as a friend in Ta first",
1157
+ reportPrivacy: "Only counts, how many were right and weak points go, never what you said",
1158
+ stopSending: "Stop sending",
1159
+ sendNow: "Send now",
1160
+ reportSent: "Sent to {name}",
1161
+ reportFailed: "Not sent: say hello to them in Ta first",
1162
+ reportTitle: "{name}'s week",
1163
+ reportIntro: "How {name}'s week went",
1164
+ reportNote: "{count} mistakes",
1165
+ bookTitle: "{subject}",
1166
+ yourAnswer: "Yours",
1167
+ rightAnswer: "Answer",
1168
+ dueNow: "Due now",
1169
+ dueIn: "In {days} days",
1170
+ reviewThese: "Review these",
1171
+ childWeek: "{name}'s week",
1172
+ fromChild: "From {name}'s Ta, {time}",
1173
+ noReport: "No week from your child yet",
1174
+ noReportHint: "Your child turns on Send my week to a parent under Education, Student, and picks you",
1175
+ howToHelp: "How to help",
1176
+ askTeacher: "Ask the teacher",
1177
+ tileCheck: "Explain a question",
1178
+ tileTalk: "Talk with my child",
1179
+ tileTeacher: "Write to the teacher",
1180
+ tilePlan: "Weekend plan",
1181
+ notices: "From the teachers",
1182
+ count: "{count}",
1183
+ linkClassHint: "Link your child's class group, and the teachers' notices show here",
1184
+ linkClass: "Link a class group",
1185
+ parentPrivacy: "Your child chooses to send it, and sees what is sent",
1186
+ noClass: "No class group linked",
1187
+ noClassHint: "Make a group chat in Ta with your students and parents, then link it here. Practice sent to it is answered right in the chat, the answers going to you alone",
1188
+ latestQuiz: "Latest practice",
1189
+ submitted: "{count} of {total} handed in",
1190
+ average: "{score}% right on average",
1191
+ hardest: "Question {no}: {pct}% wrong",
1192
+ hardestWho: "{count} students",
1193
+ goOver: "Plan going over it",
1194
+ followUp: "More practice for them",
1195
+ noQuiz: "No practice sent yet",
1196
+ noQuizHint: "Set questions with the teaching assistant, then tap Send to class on them",
1197
+ tileMake: "Set questions",
1198
+ tileLesson: "Prepare a lesson",
1199
+ tileScores: "Analyse scores",
1200
+ tileMark: "Mark homework",
1201
+ askTopic: "Questions on",
1202
+ askTopicHint: "Linear equations, 10 questions",
1203
+ askLesson: "Lesson on",
1204
+ askLessonHint: "What a fraction means",
1205
+ askRecite: "Which passage?",
1206
+ askRecitePrefill: `Help me learn it by heart: let me try first, then tell me what I got wrong.
1207
+ `,
1208
+ sendToClass: "Send to class",
1209
+ sentToClass: "Sent to {klass}",
1210
+ pickClass: "Send to which class?",
1211
+ quizIntro: "{title} · {count} questions, handed to the teacher when done",
1212
+ handedIn: "Handed to the teacher",
1213
+ handIn: "Hand to the teacher",
1214
+ noTeacherKey: "The teacher has not opened Education in Ta yet: hand it in again later",
1215
+ handedCount: "{count} handed in",
1216
+ results: "See results",
1217
+ parentAsks: "Parents asking you",
1218
+ waiting: "{count} waiting",
1219
+ noAsks: "No parent asked you this week",
1220
+ draftReply: "Draft a reply",
1221
+ tileReply: "Reply to a parent",
1222
+ tileComments: "Report comments",
1223
+ tileMeeting: "Class meeting",
1224
+ tileNotice: "Send a notice",
1225
+ noticeTitle: "Notice to {klass}",
1226
+ noticePrefix: "[Class notice] ",
1227
+ recentNotices: "Recent notices",
1228
+ classesTitle: "Class groups",
1229
+ classesHint: "The group chats that are your classes",
1230
+ noGroups: "No group chats yet: make one in Partners, then link it here",
1231
+ manageClasses: "Class groups",
1232
+ chipPhoto: "Snap a question",
1233
+ chipHint: "A hint",
1234
+ chipHintText: "One more hint, please, not the answer",
1235
+ chipAgain: "Explain it differently",
1236
+ chipAgainText: "Explain that another way",
1237
+ chipGot: "I get it",
1238
+ chipGotText: "I get it: give me one like it to try",
1239
+ photoStudent: "I can't do this one. Don't tell me the answer yet, help me think it through",
1240
+ photoParent: "My child got this wrong: where, and how do I explain it to them?",
1241
+ photoTeacher: "Mark these: right or wrong for each question, the causes of the mistakes grouped, and an outline for going over them",
1242
+ scoresText: "Analyse the score sheet {file}: the weak points the class shares, and the students to look after",
1243
+ goOverText: 'Plan how to go over the practice "{title}" in class',
1244
+ followUpText: 'Set more practice on question {no} of "{title}" for those who got it wrong',
1245
+ noticeHelp: "A notice from the teacher: what do I need to do, and when?",
1246
+ askHelp: "A parent wrote to me in the class group. Draft me a reply; I will read it before I send it",
1247
+ failed: "It did not work: {error}",
1248
+ today: "Today",
1249
+ yesterday: "Yesterday"
1250
+ };
1251
+ var ZH2 = {
1252
+ eduTitle: "教育",
1253
+ pickTitle: "我是…",
1254
+ pickHint: "可以多选,在顶上切换",
1255
+ pickStage: "学段",
1256
+ done: "完成",
1257
+ roles: "身份",
1258
+ homeDetailPick: "选好身份就能开始",
1259
+ streak: "已连续学习 {count} 天",
1260
+ noStreak: "今天开始连续学习",
1261
+ dueHead: "还有 {count} 道题该复习了",
1262
+ dueNone: "今天没有要复习的题",
1263
+ reviewOf: "{subject} · 第 {n} 次复习",
1264
+ lastWrong: "上次答成 {given}",
1265
+ startReview: "开始复习",
1266
+ noDueHint: "做错的题会记进错题本,在你快忘的时候再考你",
1267
+ tilePhoto: "拍题问",
1268
+ tileQuiz: "考考我",
1269
+ tileRecite: "背诵默写",
1270
+ tileSpeak: "口语练习",
1271
+ speakText: "陪我练英语口语:用简单的英语聊我今天的事,一次问一个问题,温和地纠正我的错",
1272
+ mistakesBook: "错题本",
1273
+ bookCount: "共 {count} 道 · 到期 {due}",
1274
+ subjectLine: "{count} 道 · 到期 {due}",
1275
+ otherSubject: "其他",
1276
+ thisWeek: "这周",
1277
+ statQuestions: "题",
1278
+ statRight: "正确率",
1279
+ statDays: "天在学",
1280
+ weekdays: "一二三四五六日",
1281
+ toParent: "每周把学情发给家长",
1282
+ toParentOn: "每周发给 {name}",
1283
+ pickParent: "发给谁",
1284
+ noFriends: "先在 Ta 里加家长为好友",
1285
+ reportPrivacy: "只发做题数、正确率和薄弱点,不发对话内容",
1286
+ stopSending: "不再发送",
1287
+ sendNow: "现在发一次",
1288
+ reportSent: "已发给 {name}",
1289
+ reportFailed: "没发出去:先在 Ta 里和对方说一句话",
1290
+ reportTitle: "{name}这周",
1291
+ reportIntro: "{name}这周的学习情况",
1292
+ reportNote: "{count} 道错题",
1293
+ bookTitle: "{subject}错题",
1294
+ yourAnswer: "你的答案",
1295
+ rightAnswer: "正确答案",
1296
+ dueNow: "该复习了",
1297
+ dueIn: "{days} 天后复习",
1298
+ reviewThese: "复习这些",
1299
+ childWeek: "{name}这周",
1300
+ fromChild: "{time} 由{name}的 Ta 发来",
1301
+ noReport: "还没收到孩子的学情",
1302
+ noReportHint: "请孩子在「教育 · 学生」里打开「每周把学情发给家长」,选你",
1303
+ howToHelp: "怎么陪孩子练",
1304
+ askTeacher: "问问老师",
1305
+ tileCheck: "辅导这道题",
1306
+ tileTalk: "和孩子聊聊",
1307
+ tileTeacher: "给老师留言",
1308
+ tilePlan: "周末计划",
1309
+ notices: "老师的通知",
1310
+ count: "{count} 条",
1311
+ linkClassHint: "关联孩子的班级群,老师的通知会出现在这里",
1312
+ linkClass: "关联班级群",
1313
+ parentPrivacy: "孩子自己决定发不发,发了什么他看得到",
1314
+ noClass: "还没关联班级群",
1315
+ noClassHint: "在 Ta 里建一个群,邀请学生和家长,再在这里关联。发到班级的练习,学生在群里直接作答,答案只交给你",
1316
+ latestQuiz: "最近的练习",
1317
+ submitted: "{count} / {total} 已交",
1318
+ average: "平均正确率 {score}%",
1319
+ hardest: "第 {no} 题错了 {pct}%",
1320
+ hardestWho: "{count} 人",
1321
+ goOver: "生成讲评",
1322
+ followUp: "给他们补一套",
1323
+ noQuiz: "还没发过练习",
1324
+ noQuizHint: "在教学助手里出一套题,点题卡上的「发到班级」",
1325
+ tileMake: "出练习",
1326
+ tileLesson: "备课",
1327
+ tileScores: "成绩分析",
1328
+ tileMark: "批改作业",
1329
+ askTopic: "练习什么内容",
1330
+ askTopicHint: "如 一元一次方程,10 道",
1331
+ askLesson: "课题",
1332
+ askLessonHint: "如 分数的意义",
1333
+ askRecite: "背哪一段",
1334
+ askRecitePrefill: `帮我背这一段,先让我自己背,再告诉我哪里错了:
1335
+ `,
1336
+ sendToClass: "发到班级",
1337
+ sentToClass: "已发到 {klass}",
1338
+ pickClass: "发到哪个班",
1339
+ quizIntro: "{title} · {count} 题,做完自动交给老师",
1340
+ handedIn: "已交给老师",
1341
+ handIn: "交给老师",
1342
+ noTeacherKey: "老师还没打开 Ta 的教育,稍后再交",
1343
+ handedCount: "已交 {count} 人",
1344
+ results: "看结果",
1345
+ parentAsks: "家长找你",
1346
+ waiting: "{count} 条待回",
1347
+ noAsks: "这周没有家长 @ 你",
1348
+ draftReply: "拟回复",
1349
+ tileReply: "回家长",
1350
+ tileComments: "写评语",
1351
+ tileMeeting: "班会方案",
1352
+ tileNotice: "发通知",
1353
+ noticeTitle: "发到 {klass} 的通知",
1354
+ noticePrefix: "【班级通知】",
1355
+ recentNotices: "最近的通知",
1356
+ classesTitle: "班级群",
1357
+ classesHint: "哪些群聊是你的班级",
1358
+ noGroups: "还没有群聊:先在伙伴里建一个,再回来关联",
1359
+ manageClasses: "班级群",
1360
+ chipPhoto: "拍题",
1361
+ chipHint: "给点提示",
1362
+ chipHintText: "再给我一点提示,别直接说答案",
1363
+ chipAgain: "换个讲法",
1364
+ chipAgainText: "换个讲法再讲一遍",
1365
+ chipGot: "我会了",
1366
+ chipGotText: "我会了,出一道同类题让我试试",
1367
+ photoStudent: "这道题我不会,先别告诉我答案,带我一步步想",
1368
+ photoParent: "孩子这道题做错了,错在哪,我该怎么讲给他听?",
1369
+ photoTeacher: "批改这些作业:逐题判对错,归类错因,最后给讲评提纲",
1370
+ scoresText: "分析成绩表 {file}:找出全班共性的薄弱点和需要关注的学生",
1371
+ goOverText: "为练习「{title}」设计课上讲评",
1372
+ followUpText: "给做错练习「{title}」第 {no} 题的同学补一套同类题",
1373
+ noticeHelp: "这是老师发的通知:我需要做什么、什么时候做?",
1374
+ askHelp: "家长在班级群里找我,帮我拟一段回复,我看过再发",
1375
+ failed: "没做成:{error}",
1376
+ today: "今天",
1377
+ yesterday: "昨天"
1378
+ };
1379
+ var ZH_TW2 = {
1380
+ eduTitle: "教育",
1381
+ pickTitle: "我是…",
1382
+ pickHint: "可以複選,在頂端切換",
1383
+ pickStage: "學段",
1384
+ done: "完成",
1385
+ roles: "身分",
1386
+ homeDetailPick: "選好身分就能開始",
1387
+ streak: "已連續學習 {count} 天",
1388
+ noStreak: "今天開始連續學習",
1389
+ dueHead: "還有 {count} 道題該複習了",
1390
+ dueNone: "今天沒有要複習的題",
1391
+ reviewOf: "{subject} · 第 {n} 次複習",
1392
+ lastWrong: "上次答成 {given}",
1393
+ startReview: "開始複習",
1394
+ noDueHint: "做錯的題會記進錯題本,在你快忘的時候再考你",
1395
+ tilePhoto: "拍題問",
1396
+ tileQuiz: "考考我",
1397
+ tileRecite: "背誦默寫",
1398
+ tileSpeak: "口說練習",
1399
+ speakText: "陪我練英語口說:用簡單的英語聊我今天的事,一次問一個問題,溫和地糾正我的錯",
1400
+ mistakesBook: "錯題本",
1401
+ bookCount: "共 {count} 道 · 到期 {due}",
1402
+ subjectLine: "{count} 道 · 到期 {due}",
1403
+ otherSubject: "其他",
1404
+ thisWeek: "這週",
1405
+ statQuestions: "題",
1406
+ statRight: "正確率",
1407
+ statDays: "天在學",
1408
+ weekdays: "一二三四五六日",
1409
+ toParent: "每週把學習狀況傳給家長",
1410
+ toParentOn: "每週傳給 {name}",
1411
+ pickParent: "傳給誰",
1412
+ noFriends: "先在 Ta 裡加家長為好友",
1413
+ reportPrivacy: "只傳做題數、正確率和弱點,不傳對話內容",
1414
+ stopSending: "不再傳送",
1415
+ sendNow: "現在傳一次",
1416
+ reportSent: "已傳給 {name}",
1417
+ reportFailed: "沒傳出去:先在 Ta 裡和對方說一句話",
1418
+ reportTitle: "{name}這週",
1419
+ reportIntro: "{name}這週的學習狀況",
1420
+ reportNote: "{count} 道錯題",
1421
+ bookTitle: "{subject}錯題",
1422
+ yourAnswer: "你的答案",
1423
+ rightAnswer: "正確答案",
1424
+ dueNow: "該複習了",
1425
+ dueIn: "{days} 天後複習",
1426
+ reviewThese: "複習這些",
1427
+ childWeek: "{name}這週",
1428
+ fromChild: "{time} 由{name}的 Ta 傳來",
1429
+ noReport: "還沒收到孩子的學習狀況",
1430
+ noReportHint: "請孩子在「教育 · 學生」裡開啟「每週把學習狀況傳給家長」,選你",
1431
+ howToHelp: "怎麼陪孩子練",
1432
+ askTeacher: "問問老師",
1433
+ tileCheck: "輔導這道題",
1434
+ tileTalk: "和孩子聊聊",
1435
+ tileTeacher: "給老師留言",
1436
+ tilePlan: "週末計畫",
1437
+ notices: "老師的通知",
1438
+ count: "{count} 則",
1439
+ linkClassHint: "連結孩子的班級群組,老師的通知會出現在這裡",
1440
+ linkClass: "連結班級群組",
1441
+ parentPrivacy: "孩子自己決定傳不傳,傳了什麼他看得到",
1442
+ noClass: "還沒連結班級群組",
1443
+ noClassHint: "在 Ta 裡建一個群組,邀請學生和家長,再在這裡連結。傳到班級的練習,學生在群組裡直接作答,答案只交給你",
1444
+ latestQuiz: "最近的練習",
1445
+ submitted: "{count} / {total} 已交",
1446
+ average: "平均正確率 {score}%",
1447
+ hardest: "第 {no} 題錯了 {pct}%",
1448
+ hardestWho: "{count} 人",
1449
+ goOver: "產生講評",
1450
+ followUp: "給他們補一套",
1451
+ noQuiz: "還沒傳過練習",
1452
+ noQuizHint: "在教學助手裡出一套題,點題卡上的「傳到班級」",
1453
+ tileMake: "出練習",
1454
+ tileLesson: "備課",
1455
+ tileScores: "成績分析",
1456
+ tileMark: "批改作業",
1457
+ askTopic: "練習什麼內容",
1458
+ askTopicHint: "如 一元一次方程式,10 題",
1459
+ askLesson: "課題",
1460
+ askLessonHint: "如 分數的意義",
1461
+ askRecite: "背哪一段",
1462
+ askRecitePrefill: `幫我背這一段,先讓我自己背,再告訴我哪裡錯了:
1463
+ `,
1464
+ sendToClass: "傳到班級",
1465
+ sentToClass: "已傳到 {klass}",
1466
+ pickClass: "傳到哪個班",
1467
+ quizIntro: "{title} · {count} 題,做完自動交給老師",
1468
+ handedIn: "已交給老師",
1469
+ handIn: "交給老師",
1470
+ noTeacherKey: "老師還沒開啟 Ta 的教育,稍後再交",
1471
+ handedCount: "已交 {count} 人",
1472
+ results: "看結果",
1473
+ parentAsks: "家長找你",
1474
+ waiting: "{count} 則待回",
1475
+ noAsks: "這週沒有家長 @ 你",
1476
+ draftReply: "擬回覆",
1477
+ tileReply: "回家長",
1478
+ tileComments: "寫評語",
1479
+ tileMeeting: "班會方案",
1480
+ tileNotice: "發通知",
1481
+ noticeTitle: "傳到 {klass} 的通知",
1482
+ noticePrefix: "【班級通知】",
1483
+ recentNotices: "最近的通知",
1484
+ classesTitle: "班級群組",
1485
+ classesHint: "哪些群組是你的班級",
1486
+ noGroups: "還沒有群組:先在夥伴裡建一個,再回來連結",
1487
+ manageClasses: "班級群組",
1488
+ chipPhoto: "拍題",
1489
+ chipHint: "給點提示",
1490
+ chipHintText: "再給我一點提示,別直接說答案",
1491
+ chipAgain: "換個講法",
1492
+ chipAgainText: "換個講法再講一遍",
1493
+ chipGot: "我會了",
1494
+ chipGotText: "我會了,出一道同類題讓我試試",
1495
+ photoStudent: "這道題我不會,先別告訴我答案,帶我一步步想",
1496
+ photoParent: "孩子這道題做錯了,錯在哪,我該怎麼講給他聽?",
1497
+ photoTeacher: "批改這些作業:逐題判對錯,歸類錯因,最後給講評提綱",
1498
+ scoresText: "分析成績表 {file}:找出全班共同的弱點和需要關注的學生",
1499
+ goOverText: "為練習「{title}」設計課堂講評",
1500
+ followUpText: "給做錯練習「{title}」第 {no} 題的同學補一套同類題",
1501
+ noticeHelp: "這是老師傳的通知:我需要做什麼、什麼時候做?",
1502
+ askHelp: "家長在班級群組裡找我,幫我擬一段回覆,我看過再傳",
1503
+ failed: "沒做成:{error}",
1504
+ today: "今天",
1505
+ yesterday: "昨天"
1506
+ };
1507
+ var JA2 = {
1508
+ eduTitle: "教育",
1509
+ pickTitle: "わたしは…",
1510
+ pickHint: "複数選べます。上で切り替えます",
1511
+ pickStage: "学校段階",
1512
+ done: "完了",
1513
+ roles: "立場",
1514
+ homeDetailPick: "立場を選ぶと始まります",
1515
+ streak: "{count} 日連続で学習中",
1516
+ noStreak: "今日から連続学習を始めよう",
1517
+ dueHead: "復習する問題があと {count} 問",
1518
+ dueNone: "今日復習する問題はありません",
1519
+ reviewOf: "{subject} · {n} 回目の復習",
1520
+ lastWrong: "前回の答え:{given}",
1521
+ startReview: "復習を始める",
1522
+ noDueHint: "間違えた問題は間違いノートに入り、忘れかけたころにもう一度出ます",
1523
+ tilePhoto: "写真で質問",
1524
+ tileQuiz: "問題を出して",
1525
+ tileRecite: "暗記・暗唱",
1526
+ tileSpeak: "会話練習",
1527
+ speakText: "英会話の練習相手になってください:今日のことを簡単な英語で一問ずつ聞いて、間違いはやさしく直してください",
1528
+ mistakesBook: "間違いノート",
1529
+ bookCount: "全 {count} 問 · 期限 {due}",
1530
+ subjectLine: "{count} 問 · 期限 {due}",
1531
+ otherSubject: "その他",
1532
+ thisWeek: "今週",
1533
+ statQuestions: "問",
1534
+ statRight: "正答率",
1535
+ statDays: "日学習",
1536
+ weekdays: "月火水木金土日",
1537
+ toParent: "毎週の学習状況を保護者に送る",
1538
+ toParentOn: "毎週 {name} に送信",
1539
+ pickParent: "送り先",
1540
+ noFriends: "先に Ta で保護者を友だちに追加してください",
1541
+ reportPrivacy: "送るのは問題数・正答率・弱点だけで、会話の内容は送りません",
1542
+ stopSending: "送るのをやめる",
1543
+ sendNow: "今すぐ送る",
1544
+ reportSent: "{name} に送りました",
1545
+ reportFailed: "送れませんでした:先に Ta で相手にひとこと送ってください",
1546
+ reportTitle: "{name}の今週",
1547
+ reportIntro: "{name}の今週の学習状況",
1548
+ reportNote: "間違い {count} 問",
1549
+ bookTitle: "{subject}の間違い",
1550
+ yourAnswer: "あなたの答え",
1551
+ rightAnswer: "正解",
1552
+ dueNow: "復習の時期",
1553
+ dueIn: "{days} 日後に復習",
1554
+ reviewThese: "これを復習",
1555
+ childWeek: "{name}の今週",
1556
+ fromChild: "{time} {name}の Ta から",
1557
+ noReport: "お子さんの学習状況はまだ届いていません",
1558
+ noReportHint: "お子さんが「教育 · 生徒」で「毎週の学習状況を保護者に送る」をオンにし、あなたを選びます",
1559
+ howToHelp: "どう手伝うか",
1560
+ askTeacher: "先生に聞く",
1561
+ tileCheck: "この問題を教える",
1562
+ tileTalk: "子どもと話す",
1563
+ tileTeacher: "先生に連絡",
1564
+ tilePlan: "週末の計画",
1565
+ notices: "先生からのお知らせ",
1566
+ count: "{count} 件",
1567
+ linkClassHint: "お子さんのクラスのグループをつなぐと、先生のお知らせがここに出ます",
1568
+ linkClass: "クラスのグループをつなぐ",
1569
+ parentPrivacy: "送るかどうかはお子さんが決め、送った内容はお子さんにも見えます",
1570
+ noClass: "クラスのグループがまだありません",
1571
+ noClassHint: "Ta で生徒と保護者のグループを作り、ここでつなぎます。クラスに送った練習はグループの中で答えられ、答えはあなただけに届きます",
1572
+ latestQuiz: "最近の練習",
1573
+ submitted: "{count} / {total} 提出",
1574
+ average: "平均正答率 {score}%",
1575
+ hardest: "第 {no} 問は {pct}% が間違い",
1576
+ hardestWho: "{count} 人",
1577
+ goOver: "解説の案を作る",
1578
+ followUp: "その生徒に追加練習",
1579
+ noQuiz: "まだ練習を送っていません",
1580
+ noQuizHint: "授業アシスタントで問題を作り、カードの「クラスに送る」を押します",
1581
+ tileMake: "問題を作る",
1582
+ tileLesson: "授業準備",
1583
+ tileScores: "成績分析",
1584
+ tileMark: "宿題を採点",
1585
+ askTopic: "練習の内容",
1586
+ askTopicHint: "例:一次方程式、10 問",
1587
+ askLesson: "単元",
1588
+ askLessonHint: "例:分数の意味",
1589
+ askRecite: "どの部分を覚えますか",
1590
+ askRecitePrefill: `この部分を覚えたいです。まず自分で言ってみるので、違うところを教えてください:
1591
+ `,
1592
+ sendToClass: "クラスに送る",
1593
+ sentToClass: "{klass} に送りました",
1594
+ pickClass: "どのクラスに送りますか",
1595
+ quizIntro: "{title} · {count} 問、終わると先生に提出されます",
1596
+ handedIn: "先生に提出しました",
1597
+ handIn: "先生に提出",
1598
+ noTeacherKey: "先生がまだ Ta の教育を開いていません。あとで提出してください",
1599
+ handedCount: "{count} 人提出",
1600
+ results: "結果を見る",
1601
+ parentAsks: "保護者からの連絡",
1602
+ waiting: "未返信 {count} 件",
1603
+ noAsks: "今週は保護者からの @ はありません",
1604
+ draftReply: "返信の下書き",
1605
+ tileReply: "保護者に返信",
1606
+ tileComments: "所見を書く",
1607
+ tileMeeting: "学級活動",
1608
+ tileNotice: "お知らせを送る",
1609
+ noticeTitle: "{klass} へのお知らせ",
1610
+ noticePrefix: "【クラスのお知らせ】",
1611
+ recentNotices: "最近のお知らせ",
1612
+ classesTitle: "クラスのグループ",
1613
+ classesHint: "どのグループがあなたのクラスか",
1614
+ noGroups: "グループがまだありません:パートナーで作ってから、ここでつなぎます",
1615
+ manageClasses: "クラスのグループ",
1616
+ chipPhoto: "写真で質問",
1617
+ chipHint: "ヒント",
1618
+ chipHintText: "もう少しヒントをください。答えはまだ言わないで",
1619
+ chipAgain: "別の説明",
1620
+ chipAgainText: "別の言い方でもう一度説明して",
1621
+ chipGot: "わかった",
1622
+ chipGotText: "わかりました。同じような問題を一問出して",
1623
+ photoStudent: "この問題がわかりません。答えはまだ言わずに、一歩ずつ考えさせてください",
1624
+ photoParent: "子どもがこの問題を間違えました。どこが違うか、どう説明すればいいですか",
1625
+ photoTeacher: "これを採点してください。一問ずつ正誤、間違いの原因の分類、最後に解説の要点を",
1626
+ scoresText: "成績表 {file} を分析して、クラス共通の弱点と気にかけるべき生徒を挙げてください",
1627
+ goOverText: "練習「{title}」の授業での解説を考えてください",
1628
+ followUpText: "練習「{title}」の第 {no} 問を間違えた生徒に、同じような問題を作ってください",
1629
+ noticeHelp: "先生からのお知らせです。何をいつまでにすればいいですか",
1630
+ askHelp: "保護者がクラスのグループで連絡をくれました。返信の下書きをお願いします。読んでから送ります",
1631
+ failed: "うまくいきませんでした:{error}",
1632
+ today: "今日",
1633
+ yesterday: "昨日"
1634
+ };
1635
+ var HOME_WORDS = { "zh-CN": ZH2, "zh-TW": ZH_TW2, "en-US": EN2, "ja-JP": JA2 };
1636
+ var NOTICE_PREFIXES = [...new Set(Object.values(HOME_WORDS).map((words) => words.noticePrefix))];
1637
+ var HomeWordsUtil;
1638
+ ((HomeWordsUtil) => {
1639
+ function of(language) {
1640
+ return TaLanguageUtil.pick(language, HOME_WORDS);
1641
+ }
1642
+ HomeWordsUtil.of = of;
1643
+ })(HomeWordsUtil ||= {});
1644
+
785
1645
  // web-src/react.ts
786
1646
  var React;
787
1647
  function bind(react) {
788
1648
  React = react;
789
1649
  }
790
1650
 
791
- // web-src/cards.tsx
1651
+ // web-src/ui.tsx
1652
+ var TONES = { student: "0", parent: "4", teacher: "3", homeroom: "5" };
1653
+ var TINTS = { student: "edu", parent: "book", teacher: "class", homeroom: "learn" };
1654
+ function tone(n) {
1655
+ return { "--ted-ink": `var(--ta-tint-ink-${n})`, "--ted-tile": `var(--ta-tint-${n})` };
1656
+ }
1657
+ function format(text, values) {
1658
+ return EduWords.format(text, values);
1659
+ }
792
1660
  function useStore(store) {
793
1661
  const [, tick] = React.useReducer((n) => n + 1, 0);
794
1662
  React.useEffect(() => store.subscribe(tick), [store]);
795
1663
  return store.state;
796
1664
  }
797
- function rightOf(question, given) {
798
- const { answer } = question;
799
- if (typeof answer === "number") {
800
- return given === String(answer);
1665
+ function useRooms(rooms) {
1666
+ const [, tick] = React.useReducer((n) => n + 1, 0);
1667
+ React.useEffect(() => rooms.subscribe(tick), [rooms]);
1668
+ return rooms.version;
1669
+ }
1670
+ function useAsync(read, keys) {
1671
+ const [value, setValue] = React.useState();
1672
+ React.useEffect(() => {
1673
+ let live = true;
1674
+ read().then((got) => live && setValue(got), () => {
1675
+ return;
1676
+ });
1677
+ return () => {
1678
+ live = false;
1679
+ };
1680
+ }, keys);
1681
+ return value;
1682
+ }
1683
+ function iconOf(pi, name, fallback = "BookOpen") {
1684
+ return pi.ui.icons[name] ?? pi.ui.icons[fallback] ?? pi.ui.icons.BookOpen;
1685
+ }
1686
+ function when(at, language, words) {
1687
+ const date = new Date(at);
1688
+ const now = new Date;
1689
+ const time = date.toLocaleTimeString(language, { hour: "2-digit", minute: "2-digit", hour12: false });
1690
+ if (EduUtil.dayOf(at) === EduUtil.dayOf(now.getTime())) {
1691
+ return time;
801
1692
  }
802
- if (typeof answer === "boolean") {
803
- return given === String(answer);
1693
+ if (EduUtil.dayOf(at) === EduUtil.dayOf(now.getTime() - 86400000)) {
1694
+ return `${words.yesterday} ${time}`;
804
1695
  }
805
- return EduUtil.blankRight(answer, given);
1696
+ return date.toLocaleDateString(language, now.getTime() - at < 6 * 86400000 ? { weekday: "short" } : { month: "numeric", day: "numeric" });
806
1697
  }
807
- function givenText(question, given) {
808
- if (question.kind === "choice") {
809
- const index = Number(given);
810
- return `${EduUtil.letter(index)}. ${question.options[index] ?? ""}`.trim();
811
- }
812
- return question.kind === "judge" ? given === "true" ? "✓" : "✗" : given;
1698
+ function failed(pi, words) {
1699
+ return (error) => pi.ui.notify(format(words.failed, { error: error instanceof Error ? error.message : String(error) }), "error");
813
1700
  }
814
- function Question(props) {
815
- const { pi, words, question, index, given, reveal } = props;
816
- const [typed, setTyped] = React.useState("");
817
- const done = given !== undefined;
818
- const shown = done || reveal;
819
- const right = done && rightOf(question, given);
820
- const Markdown = pi.ui.Markdown;
821
- const choice = (value, label, key) => {
822
- const isAnswer = shown && rightOf(question, value) && question.kind !== "blank";
823
- const state = isAnswer ? "right" : done && given === value ? "wrong" : undefined;
824
- return /* @__PURE__ */ React.createElement("button", {
825
- key,
826
- type: "button",
827
- className: "ted-option",
828
- "data-state": state,
829
- disabled: shown,
830
- onClick: () => props.answer(value)
831
- }, label);
832
- };
833
- return /* @__PURE__ */ React.createElement("li", {
834
- className: "ted-q",
835
- "data-state": done ? right ? "right" : "wrong" : undefined
836
- }, /* @__PURE__ */ React.createElement("div", {
837
- className: "ted-q-head"
838
- }, /* @__PURE__ */ React.createElement("span", {
839
- className: "ted-q-no"
840
- }, index + 1), /* @__PURE__ */ React.createElement("div", {
841
- className: "ted-q-text"
842
- }, /* @__PURE__ */ React.createElement(Markdown, {
843
- text: question.q
844
- }))), question.kind === "choice" && /* @__PURE__ */ React.createElement("div", {
845
- className: "ted-options"
846
- }, question.options.map((option, at) => choice(String(at), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("b", null, EduUtil.letter(at)), /* @__PURE__ */ React.createElement("span", null, option)), String(at)))), question.kind === "judge" && /* @__PURE__ */ React.createElement("div", {
847
- className: "ted-options ted-judge"
848
- }, choice("true", words.judgeTrue, "true"), choice("false", words.judgeFalse, "false")), question.kind === "blank" && !shown && /* @__PURE__ */ React.createElement("form", {
849
- className: "ted-blank",
850
- onSubmit: (event) => {
851
- event.preventDefault();
852
- if (typed.trim()) {
853
- props.answer(typed.trim());
854
- }
1701
+ function Tile({ icon: Icon, tone: hue, size = "row" }) {
1702
+ return /* @__PURE__ */ React.createElement("span", {
1703
+ className: `ted-tile ted-tile-${size}`,
1704
+ style: tone(hue)
1705
+ }, /* @__PURE__ */ React.createElement(Icon, {
1706
+ size: size === "big" ? 22 : 18,
1707
+ strokeWidth: 1.8
1708
+ }));
1709
+ }
1710
+ function Actions({ context, actions }) {
1711
+ const { pi } = context;
1712
+ const [busy, setBusy] = React.useState();
1713
+ const home = HomeWordsUtil.of(pi.ui.language);
1714
+ return /* @__PURE__ */ React.createElement("div", {
1715
+ className: "ted-actions"
1716
+ }, actions.map((action) => /* @__PURE__ */ React.createElement("button", {
1717
+ key: action.key,
1718
+ type: "button",
1719
+ className: "ted-action",
1720
+ disabled: busy === action.key,
1721
+ onClick: () => {
1722
+ setBusy(action.key);
1723
+ Promise.resolve().then(action.run).catch(failed(pi, home)).finally(() => setBusy(undefined));
855
1724
  }
856
- }, /* @__PURE__ */ React.createElement("input", {
857
- className: "ta-input",
858
- value: typed,
859
- placeholder: words.blank,
860
- onChange: (event) => setTyped(event.target.value)
861
- }), /* @__PURE__ */ React.createElement("button", {
862
- type: "submit",
863
- className: "ta-button",
864
- disabled: !typed.trim()
1725
+ }, /* @__PURE__ */ React.createElement(Tile, {
1726
+ icon: iconOf(pi, action.icon, action.fallback),
1727
+ tone: action.tone,
1728
+ size: "big"
1729
+ }), /* @__PURE__ */ React.createElement("span", null, action.label))));
1730
+ }
1731
+ function Assistant({ context, identity }) {
1732
+ const { pi, store } = context;
1733
+ const words = EduWords.of(pi.ui.language);
1734
+ const home = HomeWordsUtil.of(pi.ui.language);
1735
+ const role = ROLES[identity];
1736
+ return /* @__PURE__ */ React.createElement("div", {
1737
+ className: "ted-panel ted-list ted-assistant"
1738
+ }, /* @__PURE__ */ React.createElement("button", {
1739
+ type: "button",
1740
+ className: "ted-row",
1741
+ onClick: () => void EduChats.open(pi, store, identity).catch(failed(pi, home))
1742
+ }, /* @__PURE__ */ React.createElement(Tile, {
1743
+ icon: iconOf(pi, role.icon),
1744
+ tone: TONES[identity]
1745
+ }), /* @__PURE__ */ React.createElement("span", {
1746
+ className: "ted-row-main"
1747
+ }, /* @__PURE__ */ React.createElement("span", {
1748
+ className: "ted-row-title"
1749
+ }, words[role.assistant]), /* @__PURE__ */ React.createElement("span", {
1750
+ className: "ted-row-sub"
1751
+ }, words[role.tagline])), /* @__PURE__ */ React.createElement(pi.ui.icons.ChevronRight, {
1752
+ size: 16
1753
+ })));
1754
+ }
1755
+ function Section({ title, aside, children }) {
1756
+ return /* @__PURE__ */ React.createElement("section", {
1757
+ className: "ted-section"
1758
+ }, /* @__PURE__ */ React.createElement("div", {
1759
+ className: "ted-section-head"
1760
+ }, /* @__PURE__ */ React.createElement("h3", null, title), aside !== undefined && /* @__PURE__ */ React.createElement("span", {
1761
+ className: "ted-section-aside"
1762
+ }, aside)), children);
1763
+ }
1764
+ async function ask(context, identity, title, hint, prefix, many = false) {
1765
+ const { pi, store } = context;
1766
+ const text = many ? await pi.ui.editor(title, hint) : await pi.ui.input(title, hint);
1767
+ if (text?.trim()) {
1768
+ await EduChats.say(pi, store, identity, `${prefix}${text.trim()}`);
1769
+ }
1770
+ }
1771
+ async function photo(context, identity, text) {
1772
+ const images = await EduPhotos.pick();
1773
+ if (images.length) {
1774
+ await EduChats.say(context.pi, context.store, identity, text, images);
1775
+ }
1776
+ }
1777
+ function reviewContext(mistakes) {
1778
+ const lines = mistakes.slice(0, 10).map((one) => JSON.stringify({ id: one.id, q: one.question, answer: one.answer, given: one.given, subject: one.subject, topic: one.topic }));
1779
+ return `[${NAME}:review]
1780
+ The mistakes the user is due to review. For each, ask a new question on the same point in another form (other numbers, words or setting), with "review" its id and "subject" its subject, in one quiz card; then go over what they still get wrong.
1781
+ ${lines.join(`
1782
+ `)}`;
1783
+ }
1784
+ function review(context, mistakes) {
1785
+ const { pi, store } = context;
1786
+ const words = EduWords.of(pi.ui.language);
1787
+ return EduChats.say(pi, store, "student", TaMessageContext.wrap(reviewContext(mistakes), format(words.review.text, { count: mistakes.length })));
1788
+ }
1789
+ function toneOf(text) {
1790
+ return String(Number.parseInt(EduUtil.hash(text), 36) % 9);
1791
+ }
1792
+ function Stats({ items }) {
1793
+ return /* @__PURE__ */ React.createElement("div", {
1794
+ className: "ted-stats"
1795
+ }, items.map(([value, label, unit]) => /* @__PURE__ */ React.createElement("div", {
1796
+ key: label,
1797
+ className: "ted-stat"
1798
+ }, /* @__PURE__ */ React.createElement("b", null, value, unit && /* @__PURE__ */ React.createElement("small", null, unit)), /* @__PURE__ */ React.createElement("span", null, label))));
1799
+ }
1800
+ function Count({ text, count, tone: tone2 }) {
1801
+ const [before, after = ""] = text.split("{count}");
1802
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, before, /* @__PURE__ */ React.createElement("em", {
1803
+ className: "ted-count",
1804
+ style: { color: `var(--ta-tint-ink-${tone2})` }
1805
+ }, count), after);
1806
+ }
1807
+ function homeDetail(store, words, home) {
1808
+ const { settings, mistakes } = store.state;
1809
+ const identity = EduUtil.current(settings);
1810
+ if (!identity) {
1811
+ return { detail: home.homeDetailPick, unseen: false };
1812
+ }
1813
+ const due = EduUtil.due(mistakes, Date.now()).length;
1814
+ if (identity === "student" && due) {
1815
+ return { detail: `${format(home.dueHead, { count: due })} · ${words.student}`, unseen: true };
1816
+ }
1817
+ return { detail: `${words[ROLES[identity].tagline]} · ${words[identity]}`, unseen: false };
1818
+ }
1819
+
1820
+ // web-src/family.tsx
1821
+ function ParentHome({ context }) {
1822
+ const { pi, store, rooms } = context;
1823
+ const version = useRooms(rooms);
1824
+ const home = HomeWordsUtil.of(pi.ui.language);
1825
+ const reports = useAsync(() => rooms.reports(), [version]);
1826
+ const notices = useAsync(() => rooms.notices(), [version, store.state.settings.classes.join()]);
1827
+ const [child, setChild] = React.useState();
1828
+ const children = [...new Map((reports ?? []).map((report2) => [report2.child, report2])).values()];
1829
+ const report = children.find((one) => one.child === child) ?? children[0];
1830
+ const Lock = iconOf(pi, "Lock");
1831
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children.length > 1 && /* @__PURE__ */ React.createElement("div", {
1832
+ className: "ted-chips"
1833
+ }, children.map((one) => /* @__PURE__ */ React.createElement("button", {
1834
+ key: one.child,
1835
+ type: "button",
1836
+ className: "ted-chip",
1837
+ "aria-pressed": one === report,
1838
+ onClick: () => setChild(one.child)
1839
+ }, one.child))), report ? /* @__PURE__ */ React.createElement(ReportCard, {
1840
+ context,
1841
+ report
1842
+ }) : /* @__PURE__ */ React.createElement("div", {
1843
+ className: "ted-panel ted-empty"
1844
+ }, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1845
+ compact: true,
1846
+ title: reports ? home.noReport : " ",
1847
+ hint: home.noReportHint
1848
+ })), /* @__PURE__ */ React.createElement(Actions, {
1849
+ context,
1850
+ actions: [
1851
+ {
1852
+ key: "check",
1853
+ label: home.tileCheck,
1854
+ icon: "Camera",
1855
+ fallback: "Image",
1856
+ tone: "4",
1857
+ run: () => photo(context, "parent", home.photoParent)
1858
+ },
1859
+ {
1860
+ key: "talk",
1861
+ label: home.tileTalk,
1862
+ icon: "MessageCircle",
1863
+ tone: "5",
1864
+ run: () => ask(context, "parent", home.tileTalk, "", EduWords.of(pi.ui.language).talk.text, true)
1865
+ },
1866
+ {
1867
+ key: "teacher",
1868
+ label: home.tileTeacher,
1869
+ icon: "Send",
1870
+ tone: "3",
1871
+ run: () => ask(context, "parent", home.tileTeacher, "", EduWords.of(pi.ui.language).toTeacher.text, true)
1872
+ },
1873
+ {
1874
+ key: "plan",
1875
+ label: home.tilePlan,
1876
+ icon: "Calendar",
1877
+ tone: "0",
1878
+ run: () => ask(context, "parent", home.tilePlan, "", EduWords.of(pi.ui.language).plan.text, true)
1879
+ }
1880
+ ]
1881
+ }), /* @__PURE__ */ React.createElement(Assistant, {
1882
+ context,
1883
+ identity: "parent"
1884
+ }), /* @__PURE__ */ React.createElement(Notices, {
1885
+ context,
1886
+ notices,
1887
+ identity: "parent"
1888
+ }), /* @__PURE__ */ React.createElement("p", {
1889
+ className: "ted-privacy"
1890
+ }, /* @__PURE__ */ React.createElement(Lock, {
1891
+ size: 12
1892
+ }), home.parentPrivacy));
1893
+ }
1894
+ function ReportCard({ context, report }) {
1895
+ const { pi, store } = context;
1896
+ const home = HomeWordsUtil.of(pi.ui.language);
1897
+ const { learning } = report;
1898
+ const about = `[${NAME}:report]
1899
+ The week of the user's child, as the child's Ta sent it:
1900
+ ${JSON.stringify(learning)}`;
1901
+ const say = (text) => void EduChats.say(pi, store, "parent", TaMessageContext.wrap(about, text)).catch(failed(pi, home));
1902
+ return /* @__PURE__ */ React.createElement("div", {
1903
+ className: "ted-panel ted-report"
1904
+ }, /* @__PURE__ */ React.createElement("div", {
1905
+ className: "ted-panel-head"
1906
+ }, /* @__PURE__ */ React.createElement("span", {
1907
+ className: "ted-panel-title"
1908
+ }, format(home.childWeek, { name: report.child })), /* @__PURE__ */ React.createElement("span", {
1909
+ className: "ted-panel-aside"
1910
+ }, format(home.fromChild, { name: report.child, time: when(report.at, pi.ui.language, home) }))), learning.stats.length > 0 && /* @__PURE__ */ React.createElement(Stats, {
1911
+ items: learning.stats.map((one) => [one.value, one.label])
1912
+ }), (learning.weak.length > 0 || learning.items.length > 0) && /* @__PURE__ */ React.createElement("div", {
1913
+ className: "ted-report-rows"
1914
+ }, learning.items.map((item) => /* @__PURE__ */ React.createElement("div", {
1915
+ key: item.label,
1916
+ className: "ted-report-row"
1917
+ }, /* @__PURE__ */ React.createElement("span", {
1918
+ className: "ted-tone",
1919
+ "data-level": item.value >= 70 ? "good" : item.value >= 40 ? "warn" : "bad"
1920
+ }), /* @__PURE__ */ React.createElement("b", null, item.label), /* @__PURE__ */ React.createElement("small", null, item.note ? `${item.note} · ${item.value}%` : `${item.value}%`))), learning.weak.length > 0 && /* @__PURE__ */ React.createElement("div", {
1921
+ className: "ted-tags"
1922
+ }, learning.weak.map((one) => /* @__PURE__ */ React.createElement("span", {
1923
+ key: one,
1924
+ className: "ted-tag"
1925
+ }, one)))), /* @__PURE__ */ React.createElement("div", {
1926
+ className: "ted-panel-acts"
1927
+ }, /* @__PURE__ */ React.createElement("button", {
1928
+ type: "button",
1929
+ className: "ta-button ta-primary ted-pill",
1930
+ onClick: () => say(home.howToHelp)
1931
+ }, home.howToHelp), /* @__PURE__ */ React.createElement("button", {
1932
+ type: "button",
1933
+ className: "ta-button ted-pill",
1934
+ onClick: () => say(EduWords.of(pi.ui.language).toTeacher.text)
1935
+ }, home.askTeacher)));
1936
+ }
1937
+ function Notices({ context, notices, identity }) {
1938
+ const { pi, store, rooms } = context;
1939
+ const home = HomeWordsUtil.of(pi.ui.language);
1940
+ const Megaphone = iconOf(pi, "Megaphone");
1941
+ const School = iconOf(pi, "Users");
1942
+ if (!pi.rooms) {
1943
+ return null;
1944
+ }
1945
+ if (!rooms.classes().length) {
1946
+ return /* @__PURE__ */ React.createElement(Section, {
1947
+ title: home.notices
1948
+ }, /* @__PURE__ */ React.createElement("div", {
1949
+ className: "ted-panel ted-list"
1950
+ }, /* @__PURE__ */ React.createElement("button", {
1951
+ type: "button",
1952
+ className: "ted-row",
1953
+ onClick: () => openClasses(context)
1954
+ }, /* @__PURE__ */ React.createElement(Tile, {
1955
+ icon: School,
1956
+ tone: TONES.homeroom
1957
+ }), /* @__PURE__ */ React.createElement("span", {
1958
+ className: "ted-row-main"
1959
+ }, /* @__PURE__ */ React.createElement("span", {
1960
+ className: "ted-row-title"
1961
+ }, home.linkClass), /* @__PURE__ */ React.createElement("span", {
1962
+ className: "ted-row-sub ted-wrap"
1963
+ }, home.linkClassHint)), /* @__PURE__ */ React.createElement(pi.ui.icons.ChevronRight, {
1964
+ size: 16
1965
+ }))));
1966
+ }
1967
+ const list = (notices ?? []).slice(0, 5);
1968
+ return /* @__PURE__ */ React.createElement(Section, {
1969
+ title: identity === "parent" ? home.notices : home.recentNotices,
1970
+ aside: list.length ? format(home.count, { count: list.length }) : undefined
1971
+ }, /* @__PURE__ */ React.createElement("div", {
1972
+ className: "ted-panel ted-list"
1973
+ }, list.length ? list.map((notice) => /* @__PURE__ */ React.createElement("button", {
1974
+ key: notice.id,
1975
+ type: "button",
1976
+ className: "ted-row",
1977
+ onClick: () => void EduChats.say(pi, store, identity, `${home.noticeHelp}
1978
+
1979
+ > ${notice.text.replace(/\n/g, `
1980
+ > `)}`).catch(failed(pi, home))
1981
+ }, /* @__PURE__ */ React.createElement(Tile, {
1982
+ icon: Megaphone,
1983
+ tone: TONES.homeroom
1984
+ }), /* @__PURE__ */ React.createElement("span", {
1985
+ className: "ted-row-main"
1986
+ }, /* @__PURE__ */ React.createElement("span", {
1987
+ className: "ted-row-title ted-clamp"
1988
+ }, notice.text), /* @__PURE__ */ React.createElement("span", {
1989
+ className: "ted-row-sub"
1990
+ }, `${notice.klass} · ${notice.from} · ${when(notice.at, pi.ui.language, home)}`)))) : /* @__PURE__ */ React.createElement("div", {
1991
+ className: "ted-quiet"
1992
+ }, notices ? home.linkClassHint : " ")));
1993
+ }
1994
+ function openClasses(context) {
1995
+ const { pi } = context;
1996
+ const home = HomeWordsUtil.of(pi.ui.language);
1997
+ pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
1998
+ title: home.classesTitle,
1999
+ onClose: close
2000
+ }, /* @__PURE__ */ React.createElement(ClassPicker, {
2001
+ context,
2002
+ close
2003
+ })));
2004
+ }
2005
+ function ClassPicker({ context, close }) {
2006
+ const { pi, store, rooms } = context;
2007
+ useRooms(rooms);
2008
+ const state = useStore(store);
2009
+ const home = HomeWordsUtil.of(pi.ui.language);
2010
+ const { classes } = state.settings;
2011
+ const groups = rooms.groups();
2012
+ const teacher = state.settings.identities.some((one) => one === "teacher" || one === "homeroom");
2013
+ const toggle = (room) => {
2014
+ const on = classes.includes(room.id);
2015
+ store.setSettings({ classes: on ? classes.filter((one) => one !== room.id) : [...classes, room.id], ...on ? {} : { klass: room.id } });
2016
+ if (!on && teacher) {
2017
+ rooms.publishKey(room).catch(() => {
2018
+ return;
2019
+ });
2020
+ }
2021
+ };
2022
+ return /* @__PURE__ */ React.createElement("div", {
2023
+ className: "ted-picker"
2024
+ }, /* @__PURE__ */ React.createElement("div", {
2025
+ className: "ted-picker-hint ted-picker-hint-alone"
2026
+ }, home.classesHint), groups.length ? /* @__PURE__ */ React.createElement("div", {
2027
+ className: "ted-list"
2028
+ }, groups.map((room) => {
2029
+ const on = classes.includes(room.id);
2030
+ return /* @__PURE__ */ React.createElement("button", {
2031
+ key: room.id,
2032
+ type: "button",
2033
+ className: "ted-row",
2034
+ "aria-pressed": on,
2035
+ onClick: () => toggle(room)
2036
+ }, /* @__PURE__ */ React.createElement(Tile, {
2037
+ icon: pi.ui.icons.Users,
2038
+ tone: toneOf(room.id)
2039
+ }), /* @__PURE__ */ React.createElement("span", {
2040
+ className: "ted-row-main"
2041
+ }, /* @__PURE__ */ React.createElement("span", {
2042
+ className: "ted-row-title"
2043
+ }, room.title), /* @__PURE__ */ React.createElement("span", {
2044
+ className: "ted-row-sub"
2045
+ }, room.members.length)), /* @__PURE__ */ React.createElement("span", {
2046
+ className: "ted-check",
2047
+ "data-on": on || undefined
2048
+ }, on && /* @__PURE__ */ React.createElement(pi.ui.icons.Check, {
2049
+ size: 13,
2050
+ strokeWidth: 3
2051
+ })));
2052
+ })) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
2053
+ compact: true,
2054
+ title: home.noGroups
2055
+ }), /* @__PURE__ */ React.createElement("div", {
2056
+ className: "ted-picker-foot"
2057
+ }, /* @__PURE__ */ React.createElement("button", {
2058
+ type: "button",
2059
+ className: "ta-button ta-primary",
2060
+ onClick: close
2061
+ }, home.done)));
2062
+ }
2063
+
2064
+ // web-src/cards.tsx
2065
+ function useStore2(store) {
2066
+ const [, tick] = React.useReducer((n) => n + 1, 0);
2067
+ React.useEffect(() => store.subscribe(tick), [store]);
2068
+ return store.state;
2069
+ }
2070
+ function rightOf(question, given) {
2071
+ const { answer } = question;
2072
+ if (typeof answer === "number") {
2073
+ return given === String(answer);
2074
+ }
2075
+ if (typeof answer === "boolean") {
2076
+ return given === String(answer);
2077
+ }
2078
+ return EduUtil.blankRight(answer, given);
2079
+ }
2080
+ function givenText(question, given) {
2081
+ if (question.kind === "choice") {
2082
+ const index = Number(given);
2083
+ return `${EduUtil.letter(index)}. ${question.options[index] ?? ""}`.trim();
2084
+ }
2085
+ return question.kind === "judge" ? given === "true" ? "✓" : "✗" : given;
2086
+ }
2087
+ function Question(props) {
2088
+ const { pi, words, question, index, given, reveal } = props;
2089
+ const [typed, setTyped] = React.useState("");
2090
+ const done = given !== undefined;
2091
+ const shown = done || reveal;
2092
+ const right = done && rightOf(question, given);
2093
+ const Markdown = pi.ui.Markdown;
2094
+ const choice = (value, label, key) => {
2095
+ const isAnswer = shown && rightOf(question, value) && question.kind !== "blank";
2096
+ const state = isAnswer ? "right" : done && given === value ? "wrong" : undefined;
2097
+ return /* @__PURE__ */ React.createElement("button", {
2098
+ key,
2099
+ type: "button",
2100
+ className: "ted-option",
2101
+ "data-state": state,
2102
+ disabled: shown,
2103
+ onClick: () => props.answer(value)
2104
+ }, label);
2105
+ };
2106
+ return /* @__PURE__ */ React.createElement("li", {
2107
+ className: "ted-q",
2108
+ "data-state": done ? right ? "right" : "wrong" : undefined
2109
+ }, /* @__PURE__ */ React.createElement("div", {
2110
+ className: "ted-q-head"
2111
+ }, /* @__PURE__ */ React.createElement("span", {
2112
+ className: "ted-q-no"
2113
+ }, index + 1), /* @__PURE__ */ React.createElement("div", {
2114
+ className: "ted-q-text"
2115
+ }, /* @__PURE__ */ React.createElement(Markdown, {
2116
+ text: question.q
2117
+ }))), question.kind === "choice" && /* @__PURE__ */ React.createElement("div", {
2118
+ className: "ted-options"
2119
+ }, question.options.map((option, at) => choice(String(at), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("b", null, EduUtil.letter(at)), /* @__PURE__ */ React.createElement("span", null, option)), String(at)))), question.kind === "judge" && /* @__PURE__ */ React.createElement("div", {
2120
+ className: "ted-options ted-judge"
2121
+ }, choice("true", words.judgeTrue, "true"), choice("false", words.judgeFalse, "false")), question.kind === "blank" && !shown && /* @__PURE__ */ React.createElement("form", {
2122
+ className: "ted-blank",
2123
+ onSubmit: (event) => {
2124
+ event.preventDefault();
2125
+ if (typed.trim()) {
2126
+ props.answer(typed.trim());
2127
+ }
2128
+ }
2129
+ }, /* @__PURE__ */ React.createElement("input", {
2130
+ className: "ta-input",
2131
+ value: typed,
2132
+ placeholder: words.blank,
2133
+ onChange: (event) => setTyped(event.target.value)
2134
+ }), /* @__PURE__ */ React.createElement("button", {
2135
+ type: "submit",
2136
+ className: "ta-button",
2137
+ disabled: !typed.trim()
865
2138
  }, words.submit)), shown && /* @__PURE__ */ React.createElement("div", {
866
2139
  className: "ted-result"
867
2140
  }, done && question.kind === "blank" && /* @__PURE__ */ React.createElement("div", {
@@ -874,9 +2147,11 @@ function Question(props) {
874
2147
  text: question.explain
875
2148
  }))));
876
2149
  }
877
- function quizCard(pi, store) {
2150
+ function quizCard(pi, store, rooms) {
878
2151
  return function QuizCard({ code, closed, send }) {
879
- const state = useStore(store);
2152
+ const state = useStore2(store);
2153
+ const [, tick] = React.useReducer((n) => n + 1, 0);
2154
+ React.useEffect(() => rooms.subscribe(tick), []);
880
2155
  const words = EduWords.of(pi.ui.language);
881
2156
  const quiz = closed ? EduUtil.quiz(code) : undefined;
882
2157
  if (!closed) {
@@ -891,6 +2166,9 @@ function quizCard(pi, store) {
891
2166
  throw new Error("Not a quiz");
892
2167
  }
893
2168
  const card = EduUtil.hash(code);
2169
+ const room = quiz.room ? rooms.rooms.find((one) => one.id === quiz.room) : undefined;
2170
+ const mine = !!room && !!quiz.teacher && rooms.me(room) === quiz.teacher;
2171
+ const reveal = quiz.reveal || mine;
894
2172
  const given = state.answers[card] ?? {};
895
2173
  const answered = quiz.questions.filter((_, at) => given[at] !== undefined);
896
2174
  const wrong = quiz.questions.flatMap((question, at) => given[at] !== undefined && !rightOf(question, given[at]) ? [{ question, at }] : []);
@@ -913,7 +2191,7 @@ ${lines.join(`
913
2191
  size: 15
914
2192
  })), /* @__PURE__ */ React.createElement("span", {
915
2193
  className: "ted-title"
916
- }, quiz.title ?? words.quiz), answered.length > 0 && !quiz.reveal && /* @__PURE__ */ React.createElement("span", {
2194
+ }, quiz.title ?? words.quiz), answered.length > 0 && !reveal && /* @__PURE__ */ React.createElement("span", {
917
2195
  className: "ted-score"
918
2196
  }, EduWords.format(words.score, { right: answered.length - wrong.length, total: quiz.questions.length }))), /* @__PURE__ */ React.createElement("ol", {
919
2197
  className: "ted-qs"
@@ -924,16 +2202,157 @@ ${lines.join(`
924
2202
  question,
925
2203
  index: at,
926
2204
  given: given[at],
927
- reveal: quiz.reveal,
2205
+ reveal,
928
2206
  answer: (value) => void store.answer(card, at, question, value, givenText(question, value), rightOf(question, value))
929
- }))), all && wrong.length > 0 && !quiz.reveal && /* @__PURE__ */ React.createElement("div", {
2207
+ }))), mine && room && /* @__PURE__ */ React.createElement(Handed, {
2208
+ pi,
2209
+ rooms,
2210
+ quiz,
2211
+ room
2212
+ }), !mine && quiz.id && all && /* @__PURE__ */ React.createElement(HandIn, {
2213
+ pi,
2214
+ rooms,
2215
+ quiz,
2216
+ name: () => rooms.server?.getIdentity().then((one) => one.name),
2217
+ given
2218
+ }), all && wrong.length > 0 && !reveal && /* @__PURE__ */ React.createElement("div", {
930
2219
  className: "ted-foot"
931
2220
  }, /* @__PURE__ */ React.createElement("button", {
932
2221
  type: "button",
933
2222
  className: "ta-button ta-primary",
934
2223
  onClick: explain
935
- }, words.explainWrong)));
2224
+ }, words.explainWrong)), quiz.reveal && !quiz.id && state.settings.identities.includes("teacher") && rooms.server && /* @__PURE__ */ React.createElement(SendToClass, {
2225
+ pi,
2226
+ store,
2227
+ rooms,
2228
+ quiz
2229
+ }));
2230
+ };
2231
+ }
2232
+ function HandIn(props) {
2233
+ const { pi, rooms, quiz, given } = props;
2234
+ const home = HomeWordsUtil.of(pi.ui.language);
2235
+ const [status, setStatus] = React.useState("checking");
2236
+ const handIn = React.useCallback(async () => {
2237
+ setStatus("sending");
2238
+ try {
2239
+ const name = await props.name() ?? "";
2240
+ const submission = {
2241
+ name,
2242
+ given: quiz.questions.map((question, at) => givenText(question, given[at] ?? "")),
2243
+ right: quiz.questions.map((question, at) => given[at] !== undefined && rightOf(question, given[at])),
2244
+ at: Date.now()
2245
+ };
2246
+ const result = await rooms.submit(quiz, submission);
2247
+ setStatus(result === "sent" ? "sent" : result === "no-key" ? "no-key" : "failed");
2248
+ } catch {
2249
+ setStatus("failed");
2250
+ }
2251
+ }, [quiz, given, rooms]);
2252
+ React.useEffect(() => {
2253
+ rooms.submitted(quiz).then((done) => done ? setStatus("sent") : handIn(), () => handIn());
2254
+ }, []);
2255
+ const Check = pi.ui.icons.Check;
2256
+ return /* @__PURE__ */ React.createElement("div", {
2257
+ className: "ted-foot ted-handin",
2258
+ "data-status": status
2259
+ }, status === "sent" ? /* @__PURE__ */ React.createElement("span", {
2260
+ className: "ted-handed"
2261
+ }, /* @__PURE__ */ React.createElement(Check, {
2262
+ size: 14,
2263
+ strokeWidth: 2.6
2264
+ }), home.handedIn) : status === "checking" || status === "sending" ? /* @__PURE__ */ React.createElement(pi.ui.Loading, {
2265
+ compact: true
2266
+ }) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
2267
+ className: "ted-handin-note"
2268
+ }, status === "no-key" ? home.noTeacherKey : ""), /* @__PURE__ */ React.createElement("button", {
2269
+ type: "button",
2270
+ className: "ta-button",
2271
+ onClick: () => void handIn()
2272
+ }, home.handIn)));
2273
+ }
2274
+ function Handed({ pi, rooms, quiz, room }) {
2275
+ const home = HomeWordsUtil.of(pi.ui.language);
2276
+ const [count, setCount] = React.useState();
2277
+ React.useEffect(() => {
2278
+ rooms.server?.getState(room.id, `edu:sub:${quiz.id}:`).then((state) => setCount(Object.keys(state).length), () => {
2279
+ return;
2280
+ });
2281
+ }, [room.id, quiz.id, rooms.version]);
2282
+ return /* @__PURE__ */ React.createElement("div", {
2283
+ className: "ted-foot ted-handin"
2284
+ }, /* @__PURE__ */ React.createElement("span", {
2285
+ className: "ted-handin-note"
2286
+ }, count === undefined ? "" : EduWords.format(home.handedCount, { count })), /* @__PURE__ */ React.createElement("button", {
2287
+ type: "button",
2288
+ className: "ta-button",
2289
+ onClick: () => void pi.ui.showView(PAGE)
2290
+ }, home.results));
2291
+ }
2292
+ function SendToClass({ pi, store, rooms, quiz }) {
2293
+ const home = HomeWordsUtil.of(pi.ui.language);
2294
+ const [sent, setSent] = React.useState();
2295
+ const [busy, setBusy] = React.useState(false);
2296
+ const context = { pi, store, rooms };
2297
+ const post = async (room) => {
2298
+ setBusy(true);
2299
+ try {
2300
+ const intro = EduWords.format(home.quizIntro, { title: quiz.title ?? EduWords.of(pi.ui.language).quiz, count: quiz.questions.length });
2301
+ await rooms.postQuiz(room, quiz, intro);
2302
+ await store.setSettings({ klass: room.id });
2303
+ setSent(room.title);
2304
+ pi.ui.notify(EduWords.format(home.sentToClass, { klass: room.title }));
2305
+ } catch (error) {
2306
+ pi.ui.notify(EduWords.format(home.failed, { error: error instanceof Error ? error.message : String(error) }), "error");
2307
+ } finally {
2308
+ setBusy(false);
2309
+ }
2310
+ };
2311
+ const pick = async () => {
2312
+ await rooms.load();
2313
+ const classes = rooms.classes();
2314
+ if (!classes.length) {
2315
+ openClasses(context);
2316
+ return;
2317
+ }
2318
+ if (classes.length === 1) {
2319
+ if (await pi.ui.confirm(home.sendToClass, classes[0].title, { confirmLabel: home.sendToClass })) {
2320
+ await post(classes[0]);
2321
+ }
2322
+ return;
2323
+ }
2324
+ pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
2325
+ title: home.pickClass,
2326
+ onClose: close
2327
+ }, /* @__PURE__ */ React.createElement("div", {
2328
+ className: "ted-list"
2329
+ }, classes.map((room) => /* @__PURE__ */ React.createElement("button", {
2330
+ key: room.id,
2331
+ type: "button",
2332
+ className: "ted-row",
2333
+ onClick: () => {
2334
+ close();
2335
+ post(room);
2336
+ }
2337
+ }, /* @__PURE__ */ React.createElement("span", {
2338
+ className: "ted-row-main"
2339
+ }, /* @__PURE__ */ React.createElement("span", {
2340
+ className: "ted-row-title"
2341
+ }, room.title)))))));
936
2342
  };
2343
+ const Send = pi.ui.icons.Send;
2344
+ return /* @__PURE__ */ React.createElement("div", {
2345
+ className: "ted-foot ted-handin"
2346
+ }, /* @__PURE__ */ React.createElement("span", {
2347
+ className: "ted-handin-note"
2348
+ }, sent ? EduWords.format(home.sentToClass, { klass: sent }) : ""), /* @__PURE__ */ React.createElement("button", {
2349
+ type: "button",
2350
+ className: "ta-button",
2351
+ disabled: busy,
2352
+ onClick: () => void pick()
2353
+ }, /* @__PURE__ */ React.createElement(Send, {
2354
+ size: 14
2355
+ }), home.sendToClass));
937
2356
  }
938
2357
  function learningCard(pi) {
939
2358
  return function LearningCard({ code, closed, send }) {
@@ -960,7 +2379,12 @@ function learningCard(pi) {
960
2379
  size: 15
961
2380
  })), /* @__PURE__ */ React.createElement("span", {
962
2381
  className: "ted-title"
963
- }, learning.title ?? words.learning)), /* @__PURE__ */ React.createElement("ul", {
2382
+ }, learning.title ?? words.learning)), learning.stats.length > 0 && /* @__PURE__ */ React.createElement("div", {
2383
+ className: "ted-stats ted-stats-card"
2384
+ }, learning.stats.map((one) => /* @__PURE__ */ React.createElement("div", {
2385
+ key: one.label,
2386
+ className: "ted-stat"
2387
+ }, /* @__PURE__ */ React.createElement("b", null, one.value), /* @__PURE__ */ React.createElement("span", null, one.label)))), learning.items.length > 0 && /* @__PURE__ */ React.createElement("ul", {
964
2388
  className: "ted-bars"
965
2389
  }, learning.items.map((item) => /* @__PURE__ */ React.createElement("li", {
966
2390
  key: item.label,
@@ -1000,199 +2424,118 @@ function learningCard(pi) {
1000
2424
  };
1001
2425
  }
1002
2426
 
1003
- // web-src/edu-roles.ts
1004
- var QUIZ_FORMAT = `To give questions to answer, write a fenced block of language ${QUIZ} holding JSON, which Ta draws as a card the user answers in, checked at once: {"title"?: string, "reveal"?: boolean, "questions": [{"q": string, "options"?: [string] (a choice question; "answer" the letter), "answer": "B" | true | false (true or false question) | ["answers", "taken as right"] (fill in the blank), "explain": string, "topic": string, "review"?: id of the mistake it reviews}]}. Mistakes the user makes in it are kept for review. To show how someone is learning, a ${LEARNING} block: {"title"?: string, "items": [{"label": topic, "value": 0-100 mastery, "note"?: string}], "weak"?: [string], "next"?: [what to do next]}.`;
1005
- var ROLES = {
1006
- student: {
1007
- assistant: "assistantStudent",
1008
- tagline: "taglineStudent",
1009
- icon: "BookOpen",
1010
- skills: ["edu-tutor", "edu-quiz"],
1011
- actions: [
1012
- { key: "explain", icon: "Image" },
1013
- { key: "quizMe", icon: "ListChecks", send: true },
1014
- { key: "review", icon: "RotateCcw", send: true },
1015
- { key: "recite", icon: "Mic" }
1016
- ],
1017
- rules: "You tutor a student. Never give the final answer or a whole solution before the student has tried: ask what they know, give one hint at a time, let them do each step, and show the full solution only once they reached it or asked twice after trying. Check understanding with a question in another form. Never write their essays or homework for them: outlines, questions and comments on what they wrote. Encourage effort, not talent. If they speak of distress, listen, and tell them to talk to a parent or a teacher they trust."
1018
- },
1019
- parent: {
1020
- assistant: "assistantParent",
1021
- tagline: "taglineParent",
1022
- icon: "House",
1023
- skills: ["edu-parent", "edu-quiz"],
1024
- actions: [
1025
- { key: "check", icon: "Image" },
1026
- { key: "talk", icon: "MessageCircle" },
1027
- { key: "toTeacher", icon: "Send" },
1028
- { key: "plan", icon: "Calendar" }
1029
- ],
1030
- rules: "You help a parent help their child. Tell the parent where and why the child went wrong, the words to explain it to the child at their age, and one practice question; do not do the homework for the child. Help them keep calm and kind; on messages to teachers, help them be clear, specific and respectful. Their child is theirs to judge: no labels, no diagnosis."
1031
- },
1032
- teacher: {
1033
- assistant: "assistantTeacher",
1034
- tagline: "taglineTeacher",
1035
- icon: "Pencil",
1036
- skills: ["edu-grading", "edu-quiz", "edu-lesson"],
1037
- actions: [
1038
- { key: "grade", icon: "ListChecks" },
1039
- { key: "makeQuiz", icon: "FilePlus" },
1040
- { key: "lesson", icon: "FileText" },
1041
- { key: "exam", icon: "ChartSpline" },
1042
- { key: "weekly", icon: "Calendar", send: true }
1043
- ],
1044
- rules: 'You assist a teacher. Marking: right or wrong for each question, the causes of the mistakes grouped, what the class shares, and an outline to go over it; what you are unsure of you say. Questions: in three levels (basic, better, stretch) with answers and explanations, "reveal": true. Score sheets and records in the working directory you read yourself; you count, the teacher decides. Names of students stay on this computer.'
1045
- },
1046
- homeroom: {
1047
- assistant: "assistantHomeroom",
1048
- tagline: "taglineHomeroom",
1049
- icon: "Users",
1050
- skills: ["edu-homeroom"],
1051
- actions: [
1052
- { key: "reply", icon: "MessageCircle" },
1053
- { key: "comments", icon: "Pencil" },
1054
- { key: "meeting", icon: "Users" },
1055
- { key: "notice", icon: "Megaphone" }
1056
- ],
1057
- rules: "You assist a class teacher. Replies to parents are drafts the teacher sends: warm, clear, within what the school decides, never promising what is not theirs. Report comments come from what the teacher told of each student, specific and kind, no stock phrases. A student at risk (self-harm, abuse, bullying): tell the teacher to bring in the school counsellor, the school leaders and the parents at once; do not handle it alone."
1058
- }
1059
- };
1060
- var STAGE_NAMES = { primary: "primary school", junior: "middle school", senior: "high school" };
1061
- var EduRoles;
1062
- ((EduRoles) => {
1063
- function prompt(identity, settings) {
1064
- const role = ROLES[identity];
1065
- const about = [
1066
- settings.stage && `stage: ${STAGE_NAMES[settings.stage]}`,
1067
- settings.subject && `subjects: ${settings.subject}`,
1068
- settings.textbook && `textbooks: ${settings.textbook}`
1069
- ].filter(Boolean);
1070
- return [
1071
- `${MARK} You are Ta for a ${identity === "homeroom" ? "class teacher" : identity} in school education in China${about.length ? ` (${about.join("; ")})` : ""}.`,
1072
- role.rules,
1073
- `Skills for this: ${role.skills.join(", ")}.`,
1074
- "What students, scores and families are is private: keep it on this computer, and leave names out of what is shared unless the user asks.",
1075
- QUIZ_FORMAT
1076
- ].join(`
1077
- `);
1078
- }
1079
- EduRoles.prompt = prompt;
1080
- function action(words, key) {
1081
- return words[key];
2427
+ // web-src/composer.tsx
2428
+ var TONES2 = { student: "0", parent: "4", teacher: "3", homeroom: "5" };
2429
+ function photoText(identity, pi) {
2430
+ const home = HomeWordsUtil.of(pi.ui.language);
2431
+ return identity === "student" ? home.photoStudent : identity === "parent" ? home.photoParent : home.photoTeacher;
2432
+ }
2433
+ async function run(pi, store, conversation, identity, key) {
2434
+ const words = EduWords.of(pi.ui.language);
2435
+ const action = ROLES[identity].actions.find((one) => one.key === key);
2436
+ if (!action) {
2437
+ return;
1082
2438
  }
1083
- EduRoles.action = action;
1084
- })(EduRoles ||= {});
1085
-
1086
- // web-src/edu-chats.ts
1087
- var EduChats;
1088
- ((EduChats) => {
1089
- function identityOf(store, sessionFile) {
1090
- const { chats } = store.state;
1091
- return sessionFile ? Object.keys(chats).find((one) => chats[one] === sessionFile) : undefined;
2439
+ const { label, text } = EduRoles.action(words, action.key);
2440
+ if (action.key === "review") {
2441
+ const due = EduUtil.due(store.state.mistakes, Date.now());
2442
+ await EduChats.send(pi, conversation.sessionId, TaMessageContext.wrap(reviewContext(due), EduWords.format(text, { count: due.length })));
2443
+ return;
1092
2444
  }
1093
- EduChats.identityOf = identityOf;
1094
- async function open(pi, store, identity) {
1095
- const words = EduWords.of(pi.ui.language);
1096
- const { settings, chats } = store.state;
1097
- if (EduUtil.locked(settings, identity)) {
1098
- const yes = await pi.ui.confirm(words.consentTitle, words.consentMessage, { confirmLabel: words.consentConfirm });
1099
- if (!yes) {
1100
- return;
1101
- }
1102
- await store.setSettings({ consent: true });
2445
+ if (action.icon === "Image") {
2446
+ const images = await EduPhotos.pick();
2447
+ if (images.length) {
2448
+ await EduChats.send(pi, conversation.sessionId, photoText(identity, pi), images);
1103
2449
  }
1104
- const role = EduRoles.prompt(identity, store.state.settings);
1105
- const title = words[ROLES[identity].assistant];
1106
- const file = chats[identity];
1107
- if (file) {
1108
- const open2 = (await pi.server.listSessions()).find((session) => session.sessionFile === file);
1109
- if (open2) {
1110
- await pi.switchSession(open2.sessionId);
1111
- pi.ui.showView("");
1112
- return;
1113
- }
1114
- const saved = (await pi.server.listSavedSessions()).find((session) => session.sessionFile === file);
1115
- if (saved) {
1116
- const opened2 = pi.server.openSession({ cwd: saved.cwd, sessionFile: file, group: NAME, appendSystemPrompt: role });
1117
- await pi.switchSession(opened2.then((session) => session.sessionId), { title, cwd: saved.cwd, sessionFile: file });
1118
- pi.ui.showView("");
1119
- return;
1120
- }
1121
- }
1122
- const { cwd } = await pi.server.getServerInfo();
1123
- const opened = pi.server.openSession({ cwd, group: NAME, appendSystemPrompt: role });
1124
- const named = opened.then(async (session) => {
1125
- await pi.server.setSessionName(session.sessionId, title);
1126
- if (session.sessionFile) {
1127
- await store.setChat(identity, session.sessionFile);
1128
- }
1129
- });
1130
- await pi.switchSession(opened.then((session) => session.sessionId), { title, cwd });
1131
- pi.ui.showView("");
1132
- await named;
2450
+ return;
1133
2451
  }
1134
- EduChats.open = open;
1135
- })(EduChats ||= {});
1136
-
1137
- // web-src/composer.tsx
1138
- function useStore2(store) {
1139
- const [, tick] = React.useReducer((n) => n + 1, 0);
1140
- React.useEffect(() => store.subscribe(tick), [store]);
1141
- return store.state;
1142
- }
1143
- function reviewContext(store) {
1144
- const due = EduUtil.due(store.state.mistakes, Date.now()).slice(0, 10);
1145
- const lines = due.map((one) => JSON.stringify({ id: one.id, q: one.question, answer: one.answer, given: one.given, topic: one.topic }));
1146
- return `[${NAME}:review]
1147
- The mistakes the user is due to review. For each, ask a new question on the same point in another form (other numbers, words or setting), with "review" its id, in one quiz card; then go over what they still get wrong.
1148
- ${lines.join(`
1149
- `)}`;
1150
- }
1151
- function AskWho({ pi, store }) {
1152
- const state = useStore2(store);
1153
- const [picked, setPicked] = React.useState();
1154
- const { settings } = state;
1155
- if (!state.loaded || settings.asked) {
1156
- return null;
2452
+ const message = action.send ? text : await pi.ui.editor(label, text);
2453
+ if (message?.trim()) {
2454
+ await EduChats.send(pi, conversation.sessionId, message.trim());
1157
2455
  }
2456
+ }
2457
+ function Empty({ pi, store, conversation, identity }) {
2458
+ useStore(store);
1158
2459
  const words = EduWords.of(pi.ui.language);
1159
- const pick = (identity) => {
1160
- setPicked(identity);
1161
- store.setSettings({ identities: [...new Set([...settings.identities, identity])] });
1162
- };
2460
+ const role = ROLES[identity];
2461
+ const Icon = iconOf(pi, role.icon);
2462
+ const due = EduUtil.due(store.state.mistakes, Date.now()).length;
2463
+ const actions = role.actions.filter((action) => action.key !== "review" || due > 0).slice(0, 4);
2464
+ return /* @__PURE__ */ React.createElement("div", {
2465
+ className: "ted-hero"
2466
+ }, /* @__PURE__ */ React.createElement("span", {
2467
+ className: "ted-hero-face",
2468
+ style: tone(TONES2[identity])
2469
+ }, /* @__PURE__ */ React.createElement(Icon, {
2470
+ size: 30,
2471
+ strokeWidth: 1.8
2472
+ })), /* @__PURE__ */ React.createElement("h1", {
2473
+ className: "ted-hero-title"
2474
+ }, words[role.assistant]), /* @__PURE__ */ React.createElement("p", {
2475
+ className: "ted-hero-hint"
2476
+ }, words[role.tagline]), /* @__PURE__ */ React.createElement("div", {
2477
+ className: "ted-hero-starts"
2478
+ }, actions.map((action) => {
2479
+ const { label } = EduRoles.action(words, action.key);
2480
+ const ActionIcon = iconOf(pi, action.icon === "Image" ? "Camera" : action.icon, action.icon);
2481
+ return /* @__PURE__ */ React.createElement("button", {
2482
+ key: action.key,
2483
+ type: "button",
2484
+ className: "ted-start",
2485
+ onClick: () => void run(pi, store, conversation, identity, action.key)
2486
+ }, /* @__PURE__ */ React.createElement(ActionIcon, {
2487
+ size: 16,
2488
+ strokeWidth: 1.9
2489
+ }), /* @__PURE__ */ React.createElement("span", null, action.key === "review" ? `${label} · ${due}` : label));
2490
+ })));
2491
+ }
2492
+ function Chips({ pi, conversation }) {
2493
+ const home = HomeWordsUtil.of(pi.ui.language);
2494
+ const chips = [
2495
+ {
2496
+ key: "photo",
2497
+ label: home.chipPhoto,
2498
+ icon: "Camera",
2499
+ fallback: "Image",
2500
+ run: async () => {
2501
+ const images = await EduPhotos.pick();
2502
+ if (images.length) {
2503
+ await EduChats.send(pi, conversation.sessionId, home.photoStudent, images);
2504
+ }
2505
+ }
2506
+ },
2507
+ { key: "hint", label: home.chipHint, icon: "Lightbulb", run: () => EduChats.send(pi, conversation.sessionId, home.chipHintText) },
2508
+ {
2509
+ key: "again",
2510
+ label: home.chipAgain,
2511
+ icon: "Shuffle",
2512
+ fallback: "RotateCcw",
2513
+ run: () => EduChats.send(pi, conversation.sessionId, home.chipAgainText)
2514
+ },
2515
+ { key: "got", label: home.chipGot, icon: "Check", run: () => EduChats.send(pi, conversation.sessionId, home.chipGotText) }
2516
+ ];
1163
2517
  return /* @__PURE__ */ React.createElement("div", {
1164
- className: "ted-ask"
1165
- }, /* @__PURE__ */ React.createElement("div", {
1166
- className: "ted-ask-head"
1167
- }, /* @__PURE__ */ React.createElement("span", {
1168
- className: "ted-ask-title"
1169
- }, words.askTitle), /* @__PURE__ */ React.createElement("button", {
1170
- type: "button",
1171
- className: "ted-ask-later",
1172
- onClick: () => void store.setSettings({ asked: true })
1173
- }, words.later)), /* @__PURE__ */ React.createElement("div", {
1174
- className: "ted-ask-row"
1175
- }, /* @__PURE__ */ React.createElement("span", {
1176
- className: "ted-ask-label"
1177
- }, picked ? words.askStage : words.askWho), picked ? STAGES.map((stage) => /* @__PURE__ */ React.createElement("button", {
1178
- key: stage,
1179
- type: "button",
1180
- className: "ted-chip",
1181
- onClick: () => void store.setSettings({ stage, asked: true })
1182
- }, words[stage])) : IDENTITIES.map((identity) => /* @__PURE__ */ React.createElement("button", {
1183
- key: identity,
1184
- type: "button",
1185
- className: "ted-chip",
1186
- onClick: () => pick(identity)
1187
- }, words[identity]))));
2518
+ className: "ted-chiprow"
2519
+ }, chips.map((chip) => {
2520
+ const Icon = chip.key === "photo" ? iconOf(pi, chip.icon, chip.fallback) : undefined;
2521
+ return /* @__PURE__ */ React.createElement("button", {
2522
+ key: chip.key,
2523
+ type: "button",
2524
+ className: "ted-chip ted-chip-icon",
2525
+ onClick: () => void chip.run().catch(() => {
2526
+ return;
2527
+ })
2528
+ }, Icon && /* @__PURE__ */ React.createElement(Icon, {
2529
+ size: 14,
2530
+ strokeWidth: 2
2531
+ }), chip.label);
2532
+ }));
1188
2533
  }
1189
2534
  function eduComposer(pi, store) {
2535
+ const identityOf = (conversation) => conversation.group === NAME ? EduChats.identityOf(store, conversation.sessionFile) : undefined;
1190
2536
  return {
1191
2537
  actions: (conversation) => {
1192
- if (conversation.group !== NAME) {
1193
- return [];
1194
- }
1195
- const identity = EduChats.identityOf(store, conversation.sessionFile);
2538
+ const identity = identityOf(conversation);
1196
2539
  if (!identity) {
1197
2540
  return [];
1198
2541
  }
@@ -1208,27 +2551,410 @@ function eduComposer(pi, store) {
1208
2551
  icon,
1209
2552
  detail: due ? String(due) : undefined,
1210
2553
  disabled: due === 0,
1211
- run: () => void pi.sendUserMessage(TaMessageContext.wrap(reviewContext(store), EduWords.format(text, { count: due })))
2554
+ run: () => void run(pi, store, conversation, identity, action.key)
1212
2555
  };
1213
2556
  }
1214
- return action.send ? { key: action.key, label, icon, run: () => void pi.sendUserMessage(text) } : { key: action.key, label, icon, insert: text };
2557
+ return action.send || action.icon === "Image" ? { key: action.key, label, icon, run: () => void run(pi, store, conversation, identity, action.key) } : { key: action.key, label, icon, insert: text };
1215
2558
  });
1216
2559
  },
1217
2560
  subscribe: (listener) => store.subscribe(listener),
1218
- above: ({ conversation }) => conversation.kind === "double" ? /* @__PURE__ */ React.createElement(AskWho, {
2561
+ above: ({ conversation }) => identityOf(conversation) === "student" ? /* @__PURE__ */ React.createElement(Chips, {
1219
2562
  pi,
1220
- store
1221
- }) : null
2563
+ conversation
2564
+ }) : null,
2565
+ empty: (conversation) => {
2566
+ const identity = identityOf(conversation);
2567
+ return identity ? /* @__PURE__ */ React.createElement(Empty, {
2568
+ pi,
2569
+ store,
2570
+ conversation,
2571
+ identity
2572
+ }) : undefined;
2573
+ }
2574
+ };
2575
+ }
2576
+
2577
+ // web-src/edu-report.ts
2578
+ var WEEK = 7 * 86400000;
2579
+ var EduReport;
2580
+ ((EduReport) => {
2581
+ function of(days, mistakes, name, words, now) {
2582
+ const week = EduUtil.lastWeek(days, now);
2583
+ const books = EduUtil.books(mistakes, now, words.otherSubject);
2584
+ const format2 = (text, values) => text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
2585
+ return {
2586
+ title: format2(words.reportTitle, { name }),
2587
+ stats: [
2588
+ { label: words.statQuestions, value: String(week.n) },
2589
+ { label: words.statRight, value: week.n ? `${Math.round(week.right / week.n * 100)}%` : "—" },
2590
+ { label: words.statDays, value: String(week.days) }
2591
+ ],
2592
+ items: books.slice(0, 5).map((book) => ({ label: book.subject, value: book.progress, note: format2(words.reportNote, { count: book.mistakes.length }) })),
2593
+ weak: EduUtil.weak(mistakes),
2594
+ next: [],
2595
+ report: true
2596
+ };
2597
+ }
2598
+ EduReport.of = of;
2599
+ function due(reportTo, reportAt, now) {
2600
+ return !!reportTo && (!reportAt || now - reportAt >= WEEK);
2601
+ }
2602
+ EduReport.due = due;
2603
+ })(EduReport ||= {});
2604
+
2605
+ // web-src/edu-seal.ts
2606
+ var CURVE = { name: "ECDH", namedCurve: "P-256" };
2607
+ function base64(bytes) {
2608
+ let text = "";
2609
+ for (const byte of new Uint8Array(bytes)) {
2610
+ text += String.fromCharCode(byte);
2611
+ }
2612
+ return btoa(text);
2613
+ }
2614
+ function bytes(text) {
2615
+ const binary = atob(text);
2616
+ const out = new Uint8Array(binary.length);
2617
+ for (let i = 0;i < binary.length; i++) {
2618
+ out[i] = binary.charCodeAt(i);
2619
+ }
2620
+ return out;
2621
+ }
2622
+ async function secret(privateKey, publicKey) {
2623
+ const other = await crypto.subtle.importKey("jwk", publicKey, CURVE, false, []);
2624
+ return crypto.subtle.deriveKey({ name: "ECDH", public: other }, privateKey, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
2625
+ }
2626
+ var EduSeal;
2627
+ ((EduSeal) => {
2628
+ async function keys() {
2629
+ const pair = await crypto.subtle.generateKey(CURVE, true, ["deriveKey"]);
2630
+ return { publicKey: await crypto.subtle.exportKey("jwk", pair.publicKey), privateKey: await crypto.subtle.exportKey("jwk", pair.privateKey) };
2631
+ }
2632
+ EduSeal.keys = keys;
2633
+ function isKeys(value) {
2634
+ const keys2 = value;
2635
+ return !!keys2 && typeof keys2.publicKey?.x === "string" && typeof keys2.privateKey?.d === "string";
2636
+ }
2637
+ EduSeal.isKeys = isKeys;
2638
+ function isPublic(value) {
2639
+ const key = value;
2640
+ return !!key && key.kty === "EC" && typeof key.x === "string" && typeof key.y === "string" && !("d" in key);
2641
+ }
2642
+ EduSeal.isPublic = isPublic;
2643
+ async function seal(value, publicKey) {
2644
+ const pair = await crypto.subtle.generateKey(CURVE, true, ["deriveKey"]);
2645
+ const key = await secret(pair.privateKey, publicKey);
2646
+ const iv = crypto.getRandomValues(new Uint8Array(12));
2647
+ const data = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, key, new TextEncoder().encode(JSON.stringify(value)));
2648
+ const e = await crypto.subtle.exportKey("jwk", pair.publicKey);
2649
+ return { e: { kty: e.kty, crv: e.crv, x: e.x, y: e.y }, iv: base64(iv), d: base64(data) };
2650
+ }
2651
+ EduSeal.seal = seal;
2652
+ async function open(sealed, keys2) {
2653
+ const value = sealed;
2654
+ if (!value || !isPublic(value.e) || typeof value.iv !== "string" || typeof value.d !== "string") {
2655
+ return;
2656
+ }
2657
+ try {
2658
+ const mine = await crypto.subtle.importKey("jwk", keys2.privateKey, CURVE, false, ["deriveKey"]);
2659
+ const key = await secret(mine, value.e);
2660
+ const data = await crypto.subtle.decrypt({ name: "AES-GCM", iv: bytes(value.iv) }, key, bytes(value.d));
2661
+ return JSON.parse(new TextDecoder().decode(data));
2662
+ } catch {
2663
+ return;
2664
+ }
2665
+ }
2666
+ EduSeal.open = open;
2667
+ })(EduSeal ||= {});
2668
+
2669
+ // web-src/edu-rooms.ts
2670
+ var DAY2 = 86400000;
2671
+ var EduRoomUtil;
2672
+ ((EduRoomUtil) => {
2673
+ function keyOf(member) {
2674
+ return `${STATE}key:${member}`;
2675
+ }
2676
+ EduRoomUtil.keyOf = keyOf;
2677
+ function submissionOf(quiz, member) {
2678
+ return `${STATE}sub:${quiz}:${member}`;
2679
+ }
2680
+ EduRoomUtil.submissionOf = submissionOf;
2681
+ function notice(text) {
2682
+ const prefix = NOTICE_PREFIXES.find((one) => text.startsWith(one));
2683
+ return prefix ? text.slice(prefix.length).trim() : undefined;
2684
+ }
2685
+ EduRoomUtil.notice = notice;
2686
+ function report(text) {
2687
+ const match = new RegExp(`\`\`\`${LEARNING}\\n([\\s\\S]*?)\\n\`\`\``).exec(text);
2688
+ const learning = match ? EduUtil.learning(match[1]) : undefined;
2689
+ return learning?.report ? learning : undefined;
2690
+ }
2691
+ EduRoomUtil.report = report;
2692
+ function asks(lines, me, since) {
2693
+ const answered = new Set(lines.filter((line) => line.from === me && line.re).map((line) => line.re));
2694
+ const after = (line) => lines.some((other) => other.from === me && other.at > line.at);
2695
+ return lines.filter((line) => line.from !== me && line.at >= since && line.person && line.to?.includes(me) && !answered.has(line.id) && !after(line));
2696
+ }
2697
+ EduRoomUtil.asks = asks;
2698
+ function quizText(quiz, intro) {
2699
+ const body = {
2700
+ id: quiz.id,
2701
+ room: quiz.room,
2702
+ teacher: quiz.teacher,
2703
+ title: quiz.title,
2704
+ questions: quiz.questions.map((question) => ({
2705
+ q: question.q,
2706
+ ...question.kind === "choice" ? { options: question.options } : {},
2707
+ answer: question.kind === "choice" ? EduUtil.letter(question.answer) : question.answer,
2708
+ ...question.explain ? { explain: question.explain } : {},
2709
+ ...question.subject ? { subject: question.subject } : {},
2710
+ ...question.topic ? { topic: question.topic } : {}
2711
+ }))
2712
+ };
2713
+ return `${intro}
2714
+
2715
+ \`\`\`${QUIZ}
2716
+ ${JSON.stringify(body)}
2717
+ \`\`\``;
2718
+ }
2719
+ EduRoomUtil.quizText = quizText;
2720
+ function reportText(learning, intro) {
2721
+ return `${intro}
2722
+
2723
+ \`\`\`${LEARNING}
2724
+ ${JSON.stringify(learning)}
2725
+ \`\`\``;
2726
+ }
2727
+ EduRoomUtil.reportText = reportText;
2728
+ })(EduRoomUtil ||= {});
2729
+
2730
+ class EduRooms {
2731
+ pi;
2732
+ store;
2733
+ list = [];
2734
+ friendList = [];
2735
+ listeners = new Set;
2736
+ loading;
2737
+ stop;
2738
+ version = 0;
2739
+ constructor(pi, store) {
2740
+ this.pi = pi;
2741
+ this.store = store;
2742
+ }
2743
+ get server() {
2744
+ return this.pi.rooms;
2745
+ }
2746
+ get rooms() {
2747
+ return this.list;
2748
+ }
2749
+ get friends() {
2750
+ return this.friendList;
2751
+ }
2752
+ subscribe = (listener) => {
2753
+ this.listeners.add(listener);
2754
+ if (!this.stop && this.pi.onRoomEvent) {
2755
+ this.stop = this.pi.onRoomEvent((event) => {
2756
+ if (event.type === "rooms" || event.type === "state" && event.key.startsWith(STATE)) {
2757
+ this.load();
2758
+ }
2759
+ }, { messages: false, state: [STATE] });
2760
+ this.load();
2761
+ }
2762
+ return () => {
2763
+ this.listeners.delete(listener);
2764
+ if (!this.listeners.size) {
2765
+ this.stop?.();
2766
+ this.stop = undefined;
2767
+ }
2768
+ };
1222
2769
  };
2770
+ load() {
2771
+ const server = this.server;
2772
+ if (!server) {
2773
+ return Promise.resolve();
2774
+ }
2775
+ this.loading ??= Promise.all([server.listRooms().catch(() => this.list), server.listFriends().catch(() => this.friendList)]).then(([rooms, friends]) => {
2776
+ this.list = rooms.filter((room) => room.status === "member");
2777
+ this.friendList = friends.filter((friend) => friend.status === "friend");
2778
+ this.version++;
2779
+ for (const listener of this.listeners) {
2780
+ listener();
2781
+ }
2782
+ }).finally(() => {
2783
+ this.loading = undefined;
2784
+ });
2785
+ return this.loading;
2786
+ }
2787
+ groups() {
2788
+ return this.list.filter((room) => room.kind === GROUP_KIND);
2789
+ }
2790
+ classes() {
2791
+ const { classes } = this.store.state.settings;
2792
+ return classes.flatMap((id) => this.list.find((room) => room.id === id) ?? []);
2793
+ }
2794
+ me(room) {
2795
+ return room.members.find((member) => member.self)?.member;
2796
+ }
2797
+ async publishKey(room) {
2798
+ const me = this.me(room);
2799
+ const server = this.server;
2800
+ if (!me || !server) {
2801
+ return;
2802
+ }
2803
+ const keys = await this.store.teacherKeys();
2804
+ const key = EduRoomUtil.keyOf(me);
2805
+ const state = await server.getState(room.id, key);
2806
+ if (state[key]?.value && JSON.stringify(state[key].value) === JSON.stringify(keys.publicKey)) {
2807
+ return;
2808
+ }
2809
+ await server.setState(room.id, key, keys.publicKey);
2810
+ }
2811
+ async postQuiz(room, quiz, intro) {
2812
+ const me = this.me(room);
2813
+ const server = this.server;
2814
+ if (!me || !server) {
2815
+ throw new Error("Not in the class.");
2816
+ }
2817
+ await this.publishKey(room);
2818
+ const id = `q${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
2819
+ const sent = { ...quiz, reveal: false, id, room: room.id, teacher: me };
2820
+ await server.say(room.id, EduRoomUtil.quizText(sent, intro));
2821
+ const gone = await this.store.addPosted({ id, room: room.id, title: quiz.title ?? "", at: Date.now(), questions: quiz.questions });
2822
+ for (const old of gone) {
2823
+ const state = await server.getState(old.room, `${STATE}sub:${old.id}:`).catch(() => ({}));
2824
+ for (const key of Object.keys(state)) {
2825
+ await server.setState(old.room, key, null).catch(() => {
2826
+ return;
2827
+ });
2828
+ }
2829
+ }
2830
+ }
2831
+ async submit(quiz, submission) {
2832
+ const server = this.server;
2833
+ if (!quiz.id || !quiz.room || !quiz.teacher || !server) {
2834
+ return "not-in";
2835
+ }
2836
+ if (!this.list.length) {
2837
+ await this.load();
2838
+ }
2839
+ const room = this.list.find((one) => one.id === quiz.room);
2840
+ const me = room && this.me(room);
2841
+ if (!room || !me) {
2842
+ return "not-in";
2843
+ }
2844
+ const key = (await server.getState(room.id, EduRoomUtil.keyOf(quiz.teacher)))[EduRoomUtil.keyOf(quiz.teacher)]?.value;
2845
+ if (!EduSeal.isPublic(key)) {
2846
+ return "no-key";
2847
+ }
2848
+ await server.setState(room.id, EduRoomUtil.submissionOf(quiz.id, me), await EduSeal.seal(submission, key));
2849
+ return "sent";
2850
+ }
2851
+ async submitted(quiz) {
2852
+ const room = quiz.room ? this.list.find((one) => one.id === quiz.room) : undefined;
2853
+ const me = room && this.me(room);
2854
+ if (!room || !me || !quiz.id || !this.server) {
2855
+ return false;
2856
+ }
2857
+ const key = EduRoomUtil.submissionOf(quiz.id, me);
2858
+ return !!(await this.server.getState(room.id, key))[key]?.value;
2859
+ }
2860
+ async submissions(posted) {
2861
+ const server = this.server;
2862
+ if (!server) {
2863
+ return [];
2864
+ }
2865
+ const keys = await this.store.teacherKeys();
2866
+ const state = await server.getState(posted.room, `${STATE}sub:${posted.id}:`).catch(() => ({}));
2867
+ const opened = await Promise.all(Object.values(state).map((value) => EduSeal.open(value.value, keys)));
2868
+ return opened.filter((one) => !!one && typeof one.name === "string" && Array.isArray(one.right));
2869
+ }
2870
+ async lines(room, limit = 80) {
2871
+ return (await this.server?.readChat?.(room, { limit }).catch(() => {
2872
+ return;
2873
+ }))?.lines ?? [];
2874
+ }
2875
+ async notices() {
2876
+ const since = Date.now() - 30 * DAY2;
2877
+ const all = await Promise.all(this.classes().map(async (room) => (await this.lines(room.id)).flatMap((line) => {
2878
+ const text = !line.failed && line.at >= since ? EduRoomUtil.notice(line.text) : undefined;
2879
+ return text ? [{ id: line.id, room: room.id, klass: room.title, from: line.name, text, at: line.at }] : [];
2880
+ })));
2881
+ return all.flat().sort((a, b) => b.at - a.at);
2882
+ }
2883
+ async postNotice(room, text, prefix) {
2884
+ await this.server?.say(room, `${prefix}${text.trim()}`);
2885
+ }
2886
+ async asks() {
2887
+ const since = Date.now() - 7 * DAY2;
2888
+ const all = await Promise.all(this.classes().map(async (room) => {
2889
+ const me = this.me(room);
2890
+ return me ? EduRoomUtil.asks(await this.lines(room.id), me, since).map((line) => ({
2891
+ id: line.id,
2892
+ room: room.id,
2893
+ klass: room.title,
2894
+ from: line.name,
2895
+ text: line.text,
2896
+ at: line.at
2897
+ })) : [];
2898
+ }));
2899
+ return all.flat().sort((a, b) => b.at - a.at);
2900
+ }
2901
+ async reports() {
2902
+ const directs = this.list.filter((room) => room.kind === DIRECT_KIND);
2903
+ const found = await Promise.all(directs.map(async (room) => {
2904
+ const lines = await this.lines(room.id, 60);
2905
+ for (const line of [...lines].reverse()) {
2906
+ const learning = room.members.find((member) => member.member === line.from)?.self ? undefined : EduRoomUtil.report(line.text);
2907
+ if (learning) {
2908
+ return [{ room: room.id, child: line.name, at: line.at, learning }];
2909
+ }
2910
+ }
2911
+ return [];
2912
+ }));
2913
+ return found.flat().sort((a, b) => b.at - a.at);
2914
+ }
2915
+ async sendReport(friend, learning, intro, make = true) {
2916
+ const server = this.server;
2917
+ if (!server) {
2918
+ return false;
2919
+ }
2920
+ let room = await this.direct(friend);
2921
+ if (!room && make && this.pi.ui.openPartner && await this.pi.ui.openPartner(friend, "friend")) {
2922
+ for (let tries = 0;tries < 20 && !room; tries++) {
2923
+ await new Promise((resolve) => setTimeout(resolve, 500));
2924
+ room = await this.direct(friend, true);
2925
+ }
2926
+ }
2927
+ if (!room) {
2928
+ return false;
2929
+ }
2930
+ await server.say(room.id, EduRoomUtil.reportText(learning, intro));
2931
+ return true;
2932
+ }
2933
+ async direct(friend, again = false) {
2934
+ if (again || !this.list.length) {
2935
+ await this.load();
2936
+ }
2937
+ return this.list.filter((room) => room.kind === DIRECT_KIND && room.members.some((member) => !member.self && member.id === friend)).sort((a, b) => a.createdAt - b.createdAt)[0];
2938
+ }
1223
2939
  }
1224
2940
 
1225
2941
  // web-src/edu-store.ts
1226
- var KEYS = [Keys.SETTINGS, Keys.MISTAKES, Keys.CHATS, Keys.ANSWERS];
2942
+ var KEYS = [Keys.SETTINGS, Keys.MISTAKES, Keys.CHATS, Keys.ANSWERS, Keys.DAYS, Keys.POSTED];
2943
+ var MAX_POSTED = 30;
1227
2944
 
1228
2945
  class EduStore {
1229
2946
  pi;
1230
- current = { loaded: false, settings: EduUtil.settings(undefined), mistakes: [], chats: {}, answers: {} };
2947
+ current = {
2948
+ loaded: false,
2949
+ settings: EduUtil.settings(undefined),
2950
+ mistakes: [],
2951
+ chats: {},
2952
+ answers: {},
2953
+ days: {},
2954
+ posted: []
2955
+ };
1231
2956
  listeners = new Set;
2957
+ keys;
1232
2958
  constructor(pi) {
1233
2959
  this.pi = pi;
1234
2960
  this.read();
@@ -1237,10 +2963,10 @@ class EduStore {
1237
2963
  get state() {
1238
2964
  return this.current;
1239
2965
  }
1240
- subscribe(listener) {
2966
+ subscribe = (listener) => {
1241
2967
  this.listeners.add(listener);
1242
2968
  return () => this.listeners.delete(listener);
1243
- }
2969
+ };
1244
2970
  setSettings(change) {
1245
2971
  const settings = { ...this.current.settings, ...change };
1246
2972
  this.set({ ...this.current, settings });
@@ -1252,25 +2978,52 @@ class EduStore {
1252
2978
  return this.write(Keys.CHATS, chats);
1253
2979
  }
1254
2980
  answer(card, index, question, value, shown, right) {
2981
+ const now = Date.now();
1255
2982
  const answers = EduUtil.withAnswer(this.current.answers, card, index, value);
1256
- const mistakes = EduUtil.answered(this.current.mistakes, question, shown, right, Date.now());
1257
- this.set({ ...this.current, answers, mistakes });
1258
- return Promise.all([this.write(Keys.ANSWERS, answers), this.write(Keys.MISTAKES, mistakes)]).then(() => {
2983
+ const mistakes = EduUtil.answered(this.current.mistakes, question, shown, right, now);
2984
+ const days = EduUtil.withDay(this.current.days, now, right);
2985
+ this.set({ ...this.current, answers, mistakes, days });
2986
+ return Promise.all([this.write(Keys.ANSWERS, answers), this.write(Keys.MISTAKES, mistakes), this.write(Keys.DAYS, days)]).then(() => {
1259
2987
  return;
1260
2988
  });
1261
2989
  }
2990
+ async addPosted(posted) {
2991
+ const all = [...this.current.posted.filter((one) => one.id !== posted.id), posted];
2992
+ const list = all.slice(-MAX_POSTED);
2993
+ this.set({ ...this.current, posted: list });
2994
+ await this.write(Keys.POSTED, list);
2995
+ return all.slice(0, all.length - list.length);
2996
+ }
2997
+ teacherKeys() {
2998
+ this.keys ??= this.pi.storage.get(Keys.TEACHER_KEY).then(async (kept) => {
2999
+ if (EduSeal.isKeys(kept)) {
3000
+ return kept;
3001
+ }
3002
+ const made = await EduSeal.keys();
3003
+ await this.pi.storage.set(Keys.TEACHER_KEY, made);
3004
+ return made;
3005
+ });
3006
+ return this.keys;
3007
+ }
1262
3008
  write(key, value) {
1263
3009
  return this.pi.storage.set(key, value).catch((error) => this.pi.ui.notify(error instanceof Error ? error.message : String(error), "error"));
1264
3010
  }
1265
3011
  read() {
1266
- Promise.all(KEYS.map((key) => this.pi.storage.get(key))).then(([settings, mistakes, chats, answers]) => this.set({
3012
+ Promise.all(KEYS.map((key) => this.pi.storage.get(key))).then(([settings, mistakes, chats, answers, days, posted]) => this.update({
1267
3013
  loaded: true,
1268
3014
  settings: EduUtil.settings(settings),
1269
3015
  mistakes: EduUtil.mistakes(mistakes),
1270
3016
  chats: chats && typeof chats === "object" ? chats : {},
1271
- answers: EduUtil.answers(answers)
3017
+ answers: EduUtil.answers(answers),
3018
+ days: EduUtil.days(days),
3019
+ posted: Array.isArray(posted) ? posted.filter((one) => typeof one?.id === "string" && typeof one.room === "string" && Array.isArray(one.questions)) : []
1272
3020
  }), () => this.set({ ...this.current, loaded: true }));
1273
3021
  }
3022
+ update(state) {
3023
+ if (!this.current.loaded || JSON.stringify(state) !== JSON.stringify(this.current)) {
3024
+ this.set(state);
3025
+ }
3026
+ }
1274
3027
  set(state) {
1275
3028
  this.current = state;
1276
3029
  for (const listener of this.listeners) {
@@ -1284,23 +3037,20 @@ function eduHome(pi, store) {
1284
3037
  return {
1285
3038
  items: () => {
1286
3039
  const words = EduWords.of(pi.ui.language);
1287
- const { settings, mistakes } = store.state;
1288
- const due = EduUtil.due(mistakes, Date.now()).length;
1289
- return settings.identities.map((identity) => {
1290
- const role = ROLES[identity];
1291
- const detail = EduUtil.locked(settings, identity) ? words.locked : identity === "student" && due ? EduWords.format(words.due, { count: due }) : words[role.tagline];
1292
- return {
1293
- id: identity,
1294
- title: words[role.assistant],
3040
+ const home = HomeWordsUtil.of(pi.ui.language);
3041
+ const { detail, unseen } = homeDetail(store, words, home);
3042
+ return [
3043
+ {
3044
+ id: "edu",
3045
+ title: home.eduTitle,
1295
3046
  detail,
1296
- icon: pi.ui.icons[role.icon] ?? pi.ui.icons.BookOpen,
1297
- tint: identity,
1298
- unseen: identity === "student" && due > 0,
3047
+ icon: pi.ui.icons.BookOpen,
3048
+ tint: TINTS.student,
3049
+ unseen,
1299
3050
  place: "double",
1300
- sessionFile: store.state.chats[identity],
1301
- open: () => EduChats.open(pi, store, identity)
1302
- };
1303
- });
3051
+ open: () => pi.ui.showView(PAGE)
3052
+ }
3053
+ ];
1304
3054
  },
1305
3055
  subscribe: (listener) => store.subscribe(listener)
1306
3056
  };
@@ -1312,12 +3062,820 @@ function eduChatIcons(pi, store) {
1312
3062
  return;
1313
3063
  }
1314
3064
  const identity = EduChats.identityOf(store, chat.sessionFile);
1315
- return { icon: pi.ui.icons[identity ? ROLES[identity].icon : "BookOpen"] ?? pi.ui.icons.BookOpen, tint: identity };
3065
+ return { icon: pi.ui.icons[identity ? ROLES[identity].icon : "BookOpen"] ?? pi.ui.icons.BookOpen, tint: TINTS[identity ?? "student"] };
1316
3066
  },
1317
3067
  subscribe: (listener) => store.subscribe(listener)
1318
3068
  };
1319
3069
  }
1320
3070
 
3071
+ // web-src/school.tsx
3072
+ function ClassPill({ context }) {
3073
+ const { pi, store, rooms } = context;
3074
+ const classes = rooms.classes();
3075
+ const klass = classes.find((room) => room.id === store.state.settings.klass) ?? classes[0];
3076
+ const ChevronDown = iconOf(pi, "ChevronDown");
3077
+ if (!klass) {
3078
+ return null;
3079
+ }
3080
+ return /* @__PURE__ */ React.createElement("div", {
3081
+ className: "ted-chips"
3082
+ }, classes.map((room) => /* @__PURE__ */ React.createElement("button", {
3083
+ key: room.id,
3084
+ type: "button",
3085
+ className: "ted-chip",
3086
+ "aria-pressed": room === klass,
3087
+ onClick: () => void store.setSettings({ klass: room.id })
3088
+ }, room.title)), /* @__PURE__ */ React.createElement("button", {
3089
+ type: "button",
3090
+ className: "ted-chip ted-chip-quiet",
3091
+ onClick: () => openClasses(context),
3092
+ "aria-label": HomeWordsUtil.of(pi.ui.language).manageClasses
3093
+ }, /* @__PURE__ */ React.createElement(ChevronDown, {
3094
+ size: 14
3095
+ })));
3096
+ }
3097
+ function NoClass({ context }) {
3098
+ const { pi } = context;
3099
+ const home = HomeWordsUtil.of(pi.ui.language);
3100
+ return /* @__PURE__ */ React.createElement("div", {
3101
+ className: "ted-panel ted-empty"
3102
+ }, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
3103
+ compact: true,
3104
+ title: home.noClass,
3105
+ hint: home.noClassHint
3106
+ }, pi.rooms && /* @__PURE__ */ React.createElement("button", {
3107
+ type: "button",
3108
+ className: "ta-button ta-primary ted-pill",
3109
+ onClick: () => openClasses(context)
3110
+ }, home.linkClass)));
3111
+ }
3112
+ function TeacherHome({ context }) {
3113
+ const { pi, store, rooms } = context;
3114
+ const version = useRooms(rooms);
3115
+ const words = EduWords.of(pi.ui.language);
3116
+ const home = HomeWordsUtil.of(pi.ui.language);
3117
+ const classes = rooms.classes();
3118
+ const klass = classes.find((room) => room.id === store.state.settings.klass) ?? classes[0];
3119
+ const posted = klass ? [...store.state.posted].reverse().find((one) => one.room === klass.id) : undefined;
3120
+ const submissions = useAsync(() => posted ? rooms.submissions(posted) : Promise.resolve([]), [version, posted?.id]);
3121
+ React.useEffect(() => {
3122
+ if (klass) {
3123
+ rooms.publishKey(klass).catch(() => {
3124
+ return;
3125
+ });
3126
+ }
3127
+ }, [klass, rooms]);
3128
+ const actions = /* @__PURE__ */ React.createElement(Actions, {
3129
+ context,
3130
+ actions: [
3131
+ {
3132
+ key: "make",
3133
+ label: home.tileMake,
3134
+ icon: "ListChecks",
3135
+ tone: "3",
3136
+ run: () => ask(context, "teacher", home.askTopic, home.askTopicHint, words.makeQuiz.text)
3137
+ },
3138
+ {
3139
+ key: "lesson",
3140
+ label: home.tileLesson,
3141
+ icon: "FileText",
3142
+ tone: "0",
3143
+ run: () => ask(context, "teacher", home.askLesson, home.askLessonHint, words.lesson.text)
3144
+ },
3145
+ {
3146
+ key: "scores",
3147
+ label: home.tileScores,
3148
+ icon: "ChartColumn",
3149
+ fallback: "ChartSpline",
3150
+ tone: "4",
3151
+ run: async () => {
3152
+ const file = await EduPhotos.upload(pi, ".xlsx,.xls,.csv,.tsv");
3153
+ if (file) {
3154
+ await EduChats.say(pi, store, "teacher", format(home.scoresText, { file }));
3155
+ }
3156
+ }
3157
+ },
3158
+ { key: "mark", label: home.tileMark, icon: "Camera", fallback: "Image", tone: "5", run: () => photo(context, "teacher", home.photoTeacher) }
3159
+ ]
3160
+ });
3161
+ if (!classes.length) {
3162
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, actions, /* @__PURE__ */ React.createElement(Assistant, {
3163
+ context,
3164
+ identity: "teacher"
3165
+ }), /* @__PURE__ */ React.createElement(Section, {
3166
+ title: HomeWordsUtil.of(pi.ui.language).classesTitle
3167
+ }, /* @__PURE__ */ React.createElement(NoClass, {
3168
+ context
3169
+ })));
3170
+ }
3171
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ClassPill, {
3172
+ context
3173
+ }), klass && (posted ? /* @__PURE__ */ React.createElement(QuizResults, {
3174
+ context,
3175
+ klass,
3176
+ posted,
3177
+ submissions
3178
+ }) : /* @__PURE__ */ React.createElement("div", {
3179
+ className: "ted-panel ted-empty"
3180
+ }, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
3181
+ compact: true,
3182
+ title: home.noQuiz,
3183
+ hint: home.noQuizHint
3184
+ }))), actions, /* @__PURE__ */ React.createElement(Assistant, {
3185
+ context,
3186
+ identity: "teacher"
3187
+ }));
3188
+ }
3189
+ function QuizResults({ context, klass, posted, submissions }) {
3190
+ const { pi, store } = context;
3191
+ const home = HomeWordsUtil.of(pi.ui.language);
3192
+ const students = Math.max(0, klass.members.filter((member) => !member.self).length);
3193
+ const result = EduUtil.result(posted, submissions ?? []);
3194
+ const hardest = EduUtil.hardest(result);
3195
+ const most = Math.max(1, ...result.bands);
3196
+ const title = posted.title || home.latestQuiz;
3197
+ const about = `[${NAME}:class-quiz]
3198
+ The practice the user sent to the class ${klass.title}, and how the class answered (names stay on this computer):
3199
+ ${JSON.stringify({ questions: posted.questions.map((q) => ({ q: q.q, answer: EduUtil.answerText(q) })), wrong: result.wrong, average: result.average, count: result.count })}`;
3200
+ const say = (text) => void EduChats.say(pi, store, "teacher", TaMessageContext.wrap(about, text)).catch(failed(pi, home));
3201
+ return /* @__PURE__ */ React.createElement("div", {
3202
+ className: "ted-panel ted-quizcard"
3203
+ }, /* @__PURE__ */ React.createElement("div", {
3204
+ className: "ted-panel-head"
3205
+ }, /* @__PURE__ */ React.createElement("span", {
3206
+ className: "ted-panel-title"
3207
+ }, title), /* @__PURE__ */ React.createElement("span", {
3208
+ className: "ted-panel-aside"
3209
+ }, format(home.submitted, { count: result.count, total: students || result.count }))), /* @__PURE__ */ React.createElement("div", {
3210
+ className: "ted-meter ted-meter-thick"
3211
+ }, /* @__PURE__ */ React.createElement("i", {
3212
+ style: { width: `${students ? Math.min(100, result.count / students * 100) : 0}%`, background: "var(--ta-tint-ink-3)" }
3213
+ })), result.count > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
3214
+ className: "ted-hist"
3215
+ }, result.bands.map((count, at) => /* @__PURE__ */ React.createElement("span", {
3216
+ key: at,
3217
+ className: "ted-hist-bar"
3218
+ }, /* @__PURE__ */ React.createElement("small", {
3219
+ className: "ted-hist-n"
3220
+ }, count || ""), /* @__PURE__ */ React.createElement("i", {
3221
+ style: { height: `${count ? Math.max(6, count / most * 100) : 2}%` },
3222
+ "data-top": count === most || undefined
3223
+ }), /* @__PURE__ */ React.createElement("small", null, ["<60", "60", "70", "80", "90+"][at])))), /* @__PURE__ */ React.createElement("div", {
3224
+ className: "ted-panel-line"
3225
+ }, /* @__PURE__ */ React.createElement("span", null, format(home.average, { score: result.average })), hardest !== undefined && /* @__PURE__ */ React.createElement("span", {
3226
+ className: "ted-hard"
3227
+ }, /* @__PURE__ */ React.createElement("span", {
3228
+ className: "ted-tone",
3229
+ "data-level": "bad"
3230
+ }), format(home.hardest, { no: hardest + 1, pct: Math.round(result.wrong[hardest].length / result.count * 100) }), /* @__PURE__ */ React.createElement("small", null, format(home.hardestWho, { count: result.wrong[hardest].length })))), /* @__PURE__ */ React.createElement("div", {
3231
+ className: "ted-panel-acts"
3232
+ }, /* @__PURE__ */ React.createElement("button", {
3233
+ type: "button",
3234
+ className: "ta-button ta-primary ted-pill",
3235
+ onClick: () => say(format(home.goOverText, { title }))
3236
+ }, home.goOver), hardest !== undefined && /* @__PURE__ */ React.createElement("button", {
3237
+ type: "button",
3238
+ className: "ta-button ted-pill",
3239
+ onClick: () => say(format(home.followUpText, { title, no: hardest + 1 }))
3240
+ }, home.followUp))));
3241
+ }
3242
+ function HomeroomHome({ context }) {
3243
+ const { pi, store, rooms } = context;
3244
+ const version = useRooms(rooms);
3245
+ const words = EduWords.of(pi.ui.language);
3246
+ const home = HomeWordsUtil.of(pi.ui.language);
3247
+ const classes = rooms.classes();
3248
+ const klass = classes.find((room) => room.id === store.state.settings.klass) ?? classes[0];
3249
+ const asks = useAsync(() => rooms.asks(), [version, store.state.settings.classes.join()]);
3250
+ const notices = useAsync(() => rooms.notices(), [version, store.state.settings.classes.join()]);
3251
+ const [, again] = React.useReducer((n) => n + 1, 0);
3252
+ const notice = async () => {
3253
+ if (!klass) {
3254
+ openClasses(context);
3255
+ return;
3256
+ }
3257
+ const text = await pi.ui.editor(format(home.noticeTitle, { klass: klass.title }), "");
3258
+ if (text?.trim()) {
3259
+ await rooms.postNotice(klass.id, text, home.noticePrefix);
3260
+ pi.ui.notify(format(home.sentToClass, { klass: klass.title }));
3261
+ await rooms.load();
3262
+ again();
3263
+ }
3264
+ };
3265
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, classes.length > 0 && /* @__PURE__ */ React.createElement(ClassPill, {
3266
+ context
3267
+ }), classes.length > 0 && /* @__PURE__ */ React.createElement(Asks, {
3268
+ context,
3269
+ asks
3270
+ }), /* @__PURE__ */ React.createElement(Actions, {
3271
+ context,
3272
+ actions: [
3273
+ {
3274
+ key: "reply",
3275
+ label: home.tileReply,
3276
+ icon: "MessageCircle",
3277
+ tone: "4",
3278
+ run: () => ask(context, "homeroom", home.tileReply, "", words.reply.text, true)
3279
+ },
3280
+ {
3281
+ key: "comments",
3282
+ label: home.tileComments,
3283
+ icon: "Pencil",
3284
+ tone: "5",
3285
+ run: () => ask(context, "homeroom", home.tileComments, "", words.comments.text, true)
3286
+ },
3287
+ {
3288
+ key: "meeting",
3289
+ label: home.tileMeeting,
3290
+ icon: "Users",
3291
+ tone: "3",
3292
+ run: () => ask(context, "homeroom", home.tileMeeting, "", words.meeting.text)
3293
+ },
3294
+ { key: "notice", label: home.tileNotice, icon: "Megaphone", tone: "0", run: notice }
3295
+ ]
3296
+ }), /* @__PURE__ */ React.createElement(Assistant, {
3297
+ context,
3298
+ identity: "homeroom"
3299
+ }), classes.length > 0 ? /* @__PURE__ */ React.createElement(Notices, {
3300
+ context,
3301
+ notices,
3302
+ identity: "homeroom"
3303
+ }) : /* @__PURE__ */ React.createElement(Section, {
3304
+ title: home.classesTitle
3305
+ }, /* @__PURE__ */ React.createElement(NoClass, {
3306
+ context
3307
+ })));
3308
+ }
3309
+ function Asks({ context, asks }) {
3310
+ const { pi, store } = context;
3311
+ const home = HomeWordsUtil.of(pi.ui.language);
3312
+ const Pencil = iconOf(pi, "Pencil");
3313
+ const list = asks ?? [];
3314
+ return /* @__PURE__ */ React.createElement(Section, {
3315
+ title: home.parentAsks,
3316
+ aside: list.length ? format(home.waiting, { count: list.length }) : undefined
3317
+ }, /* @__PURE__ */ React.createElement("div", {
3318
+ className: "ted-panel ted-list"
3319
+ }, list.length ? list.slice(0, 6).map((one) => /* @__PURE__ */ React.createElement("button", {
3320
+ key: one.id,
3321
+ type: "button",
3322
+ className: "ted-row ted-row-top",
3323
+ onClick: () => void EduChats.say(pi, store, "homeroom", `${home.askHelp}
3324
+
3325
+ ${one.from}(${one.klass}):
3326
+ > ${one.text.replace(/\n/g, `
3327
+ > `)}`).catch(failed(pi, home))
3328
+ }, /* @__PURE__ */ React.createElement("span", {
3329
+ className: "ted-letter ted-round",
3330
+ style: tone(toneOf(one.from))
3331
+ }, [...one.from][0]), /* @__PURE__ */ React.createElement("span", {
3332
+ className: "ted-row-main"
3333
+ }, /* @__PURE__ */ React.createElement("span", {
3334
+ className: "ted-row-line"
3335
+ }, /* @__PURE__ */ React.createElement("span", {
3336
+ className: "ted-row-title"
3337
+ }, one.from), /* @__PURE__ */ React.createElement("span", {
3338
+ className: "ted-row-sub"
3339
+ }, when(one.at, pi.ui.language, home))), /* @__PURE__ */ React.createElement("span", {
3340
+ className: "ted-row-sub ted-clamp"
3341
+ }, one.text), /* @__PURE__ */ React.createElement("span", {
3342
+ className: "ted-draft"
3343
+ }, /* @__PURE__ */ React.createElement(Pencil, {
3344
+ size: 11,
3345
+ strokeWidth: 2.2
3346
+ }), home.draftReply)))) : /* @__PURE__ */ React.createElement("div", {
3347
+ className: "ted-quiet"
3348
+ }, asks ? home.noAsks : " ")));
3349
+ }
3350
+
3351
+ // web-src/student.tsx
3352
+ function WeekDots({ context }) {
3353
+ const { pi, store } = context;
3354
+ const home = HomeWordsUtil.of(pi.ui.language);
3355
+ const week = EduUtil.week(store.state.days, Date.now());
3356
+ return /* @__PURE__ */ React.createElement("div", {
3357
+ className: "ted-dots"
3358
+ }, week.map((day, at) => /* @__PURE__ */ React.createElement("span", {
3359
+ key: at,
3360
+ className: "ted-dot",
3361
+ "data-on": day.n > 0 || undefined,
3362
+ "data-today": day.today || undefined
3363
+ }, /* @__PURE__ */ React.createElement("i", null), [...home.weekdays][at])));
3364
+ }
3365
+ function StudentHome({ context, books, openBook }) {
3366
+ const { pi, store } = context;
3367
+ const state = store.state;
3368
+ const words = EduWords.of(pi.ui.language);
3369
+ const home = HomeWordsUtil.of(pi.ui.language);
3370
+ const now = Date.now();
3371
+ const due = EduUtil.due(state.mistakes, now);
3372
+ const streak = EduUtil.streak(state.days, now);
3373
+ const first = due[0];
3374
+ const week = EduUtil.lastWeek(state.days, now);
3375
+ const days = EduUtil.week(state.days, now);
3376
+ const most = Math.max(1, ...days.map((day) => day.n));
3377
+ const ChevronRight = iconOf(pi, "ChevronRight");
3378
+ const total = state.mistakes.length;
3379
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
3380
+ className: "ted-greet"
3381
+ }, /* @__PURE__ */ React.createElement("div", {
3382
+ className: "ted-greet-sub"
3383
+ }, streak ? format(home.streak, { count: streak }) : home.noStreak), /* @__PURE__ */ React.createElement("h2", {
3384
+ className: "ted-greet-title"
3385
+ }, due.length ? /* @__PURE__ */ React.createElement(Count, {
3386
+ text: home.dueHead,
3387
+ count: due.length,
3388
+ tone: TONES.student
3389
+ }) : home.dueNone)), /* @__PURE__ */ React.createElement("div", {
3390
+ className: "ted-panel ted-today"
3391
+ }, first ? /* @__PURE__ */ React.createElement("div", {
3392
+ className: "ted-today-q"
3393
+ }, /* @__PURE__ */ React.createElement("div", {
3394
+ className: "ted-meta"
3395
+ }, /* @__PURE__ */ React.createElement("span", {
3396
+ className: "ted-meta-dot"
3397
+ }), format(home.reviewOf, { subject: first.subject || first.topic || home.otherSubject, n: first.level + 1 })), /* @__PURE__ */ React.createElement("div", {
3398
+ className: "ted-today-text"
3399
+ }, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
3400
+ text: first.question
3401
+ })), /* @__PURE__ */ React.createElement("div", {
3402
+ className: "ted-meta ted-meta-faint"
3403
+ }, format(home.lastWrong, { given: first.given }))) : /* @__PURE__ */ React.createElement("div", {
3404
+ className: "ted-today-q ted-today-none"
3405
+ }, home.noDueHint), /* @__PURE__ */ React.createElement("div", {
3406
+ className: "ted-today-foot"
3407
+ }, /* @__PURE__ */ React.createElement(WeekDots, {
3408
+ context
3409
+ }), due.length > 0 && /* @__PURE__ */ React.createElement("button", {
3410
+ type: "button",
3411
+ className: "ta-button ta-primary ted-pill",
3412
+ onClick: () => void review(context, due).catch(failed(pi, home))
3413
+ }, home.startReview))), /* @__PURE__ */ React.createElement(Actions, {
3414
+ context,
3415
+ actions: [
3416
+ {
3417
+ key: "photo",
3418
+ label: home.tilePhoto,
3419
+ icon: "Camera",
3420
+ fallback: "Image",
3421
+ tone: "0",
3422
+ run: () => photo(context, "student", home.photoStudent)
3423
+ },
3424
+ { key: "quiz", label: home.tileQuiz, icon: "ListChecks", tone: "3", run: () => EduChats.say(pi, store, "student", words.quizMe.text) },
3425
+ {
3426
+ key: "recite",
3427
+ label: home.tileRecite,
3428
+ icon: "Quote",
3429
+ fallback: "BookOpen",
3430
+ tone: "4",
3431
+ run: () => ask(context, "student", home.askRecite, "", home.askRecitePrefill, true)
3432
+ },
3433
+ {
3434
+ key: "speak",
3435
+ label: home.tileSpeak,
3436
+ icon: "Headphones",
3437
+ fallback: "Mic",
3438
+ tone: "5",
3439
+ run: () => EduChats.say(pi, store, "student", home.speakText)
3440
+ }
3441
+ ]
3442
+ }), /* @__PURE__ */ React.createElement(Assistant, {
3443
+ context,
3444
+ identity: "student"
3445
+ }), /* @__PURE__ */ React.createElement("div", {
3446
+ className: "ted-grid"
3447
+ }, /* @__PURE__ */ React.createElement(Section, {
3448
+ title: home.mistakesBook,
3449
+ aside: total ? format(home.bookCount, { count: total, due: due.length }) : undefined
3450
+ }, books.length ? /* @__PURE__ */ React.createElement("div", {
3451
+ className: "ted-panel ted-list"
3452
+ }, books.map((book) => /* @__PURE__ */ React.createElement("button", {
3453
+ key: book.subject,
3454
+ type: "button",
3455
+ className: "ted-row",
3456
+ onClick: () => openBook(book.subject)
3457
+ }, /* @__PURE__ */ React.createElement("span", {
3458
+ className: "ted-letter",
3459
+ style: tone(toneOf(book.subject))
3460
+ }, [...book.subject][0]), /* @__PURE__ */ React.createElement("span", {
3461
+ className: "ted-row-main"
3462
+ }, /* @__PURE__ */ React.createElement("span", {
3463
+ className: "ted-row-line"
3464
+ }, /* @__PURE__ */ React.createElement("span", {
3465
+ className: "ted-row-title"
3466
+ }, book.subject), /* @__PURE__ */ React.createElement("span", {
3467
+ className: "ted-row-sub"
3468
+ }, format(home.subjectLine, { count: book.mistakes.length, due: book.due }))), /* @__PURE__ */ React.createElement("span", {
3469
+ className: "ted-meter"
3470
+ }, /* @__PURE__ */ React.createElement("i", {
3471
+ style: { width: `${Math.max(4, book.progress)}%`, background: `var(--ta-tint-ink-${toneOf(book.subject)})` }
3472
+ }))), /* @__PURE__ */ React.createElement("span", {
3473
+ className: "ted-row-value"
3474
+ }, book.progress, "%"), /* @__PURE__ */ React.createElement(ChevronRight, {
3475
+ size: 16
3476
+ })))) : /* @__PURE__ */ React.createElement("div", {
3477
+ className: "ted-panel ted-quiet"
3478
+ }, home.noDueHint)), /* @__PURE__ */ React.createElement(Section, {
3479
+ title: home.thisWeek
3480
+ }, /* @__PURE__ */ React.createElement("div", {
3481
+ className: "ted-panel ted-week"
3482
+ }, /* @__PURE__ */ React.createElement(Stats, {
3483
+ items: [
3484
+ [String(week.n), home.statQuestions],
3485
+ [week.n ? `${Math.round(week.right / week.n * 100)}` : "—", home.statRight, week.n ? "%" : ""],
3486
+ [String(week.days), home.statDays]
3487
+ ]
3488
+ }), /* @__PURE__ */ React.createElement("div", {
3489
+ className: "ted-weekbars"
3490
+ }, days.map((day, at) => /* @__PURE__ */ React.createElement("span", {
3491
+ key: at,
3492
+ className: "ted-weekbar",
3493
+ "data-today": day.today || undefined
3494
+ }, /* @__PURE__ */ React.createElement("i", {
3495
+ style: { height: `${day.n ? Math.max(8, day.n / most * 100) : 4}%` },
3496
+ "data-none": !day.n || undefined
3497
+ }), /* @__PURE__ */ React.createElement("small", null, [...home.weekdays][at]))))), /* @__PURE__ */ React.createElement(ToParent, {
3498
+ context
3499
+ }))));
3500
+ }
3501
+ function ToParent({ context }) {
3502
+ const { pi, store, rooms } = context;
3503
+ const home = HomeWordsUtil.of(pi.ui.language);
3504
+ const { settings } = store.state;
3505
+ const friend = rooms.friends.find((one) => one.id === settings.reportTo);
3506
+ const Send = iconOf(pi, "Send");
3507
+ if (!pi.rooms) {
3508
+ return null;
3509
+ }
3510
+ const menu = () => pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
3511
+ title: home.pickParent,
3512
+ onClose: close
3513
+ }, /* @__PURE__ */ React.createElement(FriendPicker, {
3514
+ context,
3515
+ close
3516
+ })));
3517
+ return /* @__PURE__ */ React.createElement("div", {
3518
+ className: "ted-panel ted-list ted-toparent"
3519
+ }, /* @__PURE__ */ React.createElement("button", {
3520
+ type: "button",
3521
+ className: "ted-row",
3522
+ onClick: menu
3523
+ }, /* @__PURE__ */ React.createElement(Tile, {
3524
+ icon: Send,
3525
+ tone: TONES.parent
3526
+ }), /* @__PURE__ */ React.createElement("span", {
3527
+ className: "ted-row-main"
3528
+ }, /* @__PURE__ */ React.createElement("span", {
3529
+ className: "ted-row-title"
3530
+ }, friend ? format(home.toParentOn, { name: friend.name }) : home.toParent), /* @__PURE__ */ React.createElement("span", {
3531
+ className: "ted-row-sub"
3532
+ }, home.reportPrivacy)), /* @__PURE__ */ React.createElement("span", {
3533
+ className: "ted-switchmark",
3534
+ "data-on": friend ? true : undefined
3535
+ })));
3536
+ }
3537
+ function FriendPicker({ context, close }) {
3538
+ const { pi, store, rooms } = context;
3539
+ useRooms(rooms);
3540
+ const home = HomeWordsUtil.of(pi.ui.language);
3541
+ const { settings } = store.state;
3542
+ const [busy, setBusy] = React.useState(false);
3543
+ const send = async (id, name) => {
3544
+ setBusy(true);
3545
+ try {
3546
+ const learning = EduReport.of(store.state.days, store.state.mistakes, (await pi.rooms.getIdentity()).name, home, Date.now());
3547
+ const sent = await rooms.sendReport(id, learning, format(home.reportIntro, { name: (await pi.rooms.getIdentity()).name }));
3548
+ if (sent) {
3549
+ await store.setSettings({ reportTo: id, reportAt: Date.now() });
3550
+ pi.ui.notify(format(home.reportSent, { name }));
3551
+ close();
3552
+ } else {
3553
+ pi.ui.notify(home.reportFailed, "warning");
3554
+ }
3555
+ } catch (error) {
3556
+ failed(pi, home)(error);
3557
+ } finally {
3558
+ setBusy(false);
3559
+ }
3560
+ };
3561
+ return /* @__PURE__ */ React.createElement("div", {
3562
+ className: "ted-picker"
3563
+ }, /* @__PURE__ */ React.createElement("div", {
3564
+ className: "ted-picker-hint ted-picker-hint-alone"
3565
+ }, home.reportPrivacy), rooms.friends.length ? /* @__PURE__ */ React.createElement("div", {
3566
+ className: "ted-list"
3567
+ }, rooms.friends.map((friend) => /* @__PURE__ */ React.createElement("button", {
3568
+ key: friend.id,
3569
+ type: "button",
3570
+ className: "ted-row",
3571
+ disabled: busy,
3572
+ onClick: () => void send(friend.id, friend.name)
3573
+ }, /* @__PURE__ */ React.createElement(pi.ui.Face, {
3574
+ seed: friend.id,
3575
+ look: friend.look,
3576
+ size: 36
3577
+ }), /* @__PURE__ */ React.createElement("span", {
3578
+ className: "ted-row-main"
3579
+ }, /* @__PURE__ */ React.createElement("span", {
3580
+ className: "ted-row-title"
3581
+ }, friend.name)), /* @__PURE__ */ React.createElement("span", {
3582
+ className: "ted-check",
3583
+ "data-on": friend.id === settings.reportTo || undefined
3584
+ }, friend.id === settings.reportTo && /* @__PURE__ */ React.createElement(pi.ui.icons.Check, {
3585
+ size: 13,
3586
+ strokeWidth: 3
3587
+ }))))) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
3588
+ compact: true,
3589
+ title: home.noFriends
3590
+ }), settings.reportTo && /* @__PURE__ */ React.createElement("div", {
3591
+ className: "ted-picker-foot"
3592
+ }, /* @__PURE__ */ React.createElement("button", {
3593
+ type: "button",
3594
+ className: "ta-button",
3595
+ onClick: () => void store.setSettings({ reportTo: undefined }).then(close)
3596
+ }, home.stopSending)));
3597
+ }
3598
+ function MistakeBook({ context, book }) {
3599
+ const { pi } = context;
3600
+ const home = HomeWordsUtil.of(pi.ui.language);
3601
+ if (!book) {
3602
+ return null;
3603
+ }
3604
+ const now = Date.now();
3605
+ return /* @__PURE__ */ React.createElement("div", {
3606
+ className: "ted-page"
3607
+ }, /* @__PURE__ */ React.createElement("div", {
3608
+ className: "ted-col"
3609
+ }, /* @__PURE__ */ React.createElement("div", {
3610
+ className: "ted-greet"
3611
+ }, /* @__PURE__ */ React.createElement("h2", {
3612
+ className: "ted-greet-title"
3613
+ }, format(home.bookTitle, { subject: book.subject })), /* @__PURE__ */ React.createElement("div", {
3614
+ className: "ted-greet-sub"
3615
+ }, format(home.subjectLine, { count: book.mistakes.length, due: book.due }))), /* @__PURE__ */ React.createElement("div", {
3616
+ className: "ted-panel ted-list"
3617
+ }, book.mistakes.map((mistake) => /* @__PURE__ */ React.createElement("div", {
3618
+ key: mistake.id,
3619
+ className: "ted-mistake"
3620
+ }, /* @__PURE__ */ React.createElement("div", {
3621
+ className: "ted-meta"
3622
+ }, mistake.topic && /* @__PURE__ */ React.createElement("span", null, mistake.topic), /* @__PURE__ */ React.createElement("span", {
3623
+ className: "ted-due",
3624
+ "data-now": mistake.due <= now || undefined
3625
+ }, mistake.due <= now ? home.dueNow : format(home.dueIn, { days: Math.ceil((mistake.due - now) / 86400000) }))), /* @__PURE__ */ React.createElement("div", {
3626
+ className: "ted-mistake-q"
3627
+ }, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
3628
+ text: mistake.question
3629
+ })), /* @__PURE__ */ React.createElement("div", {
3630
+ className: "ted-mistake-a"
3631
+ }, /* @__PURE__ */ React.createElement("span", {
3632
+ className: "ted-given"
3633
+ }, /* @__PURE__ */ React.createElement("small", null, home.yourAnswer), /* @__PURE__ */ React.createElement("s", null, mistake.given)), /* @__PURE__ */ React.createElement("span", {
3634
+ className: "ted-right"
3635
+ }, /* @__PURE__ */ React.createElement("small", null, home.rightAnswer), mistake.answer))))), /* @__PURE__ */ React.createElement("div", {
3636
+ className: "ted-bottom"
3637
+ }, /* @__PURE__ */ React.createElement("button", {
3638
+ type: "button",
3639
+ className: "ta-button ta-primary ted-wide",
3640
+ onClick: () => void review(context, book.mistakes).catch(failed(pi, home))
3641
+ }, home.reviewThese))));
3642
+ }
3643
+
3644
+ // web-src/page.tsx
3645
+ function EduHead({ context }) {
3646
+ const { pi, store, rooms } = context;
3647
+ const state = useStore(store);
3648
+ useRooms(rooms);
3649
+ const words = EduWords.of(pi.ui.language);
3650
+ const home = HomeWordsUtil.of(pi.ui.language);
3651
+ const { settings } = state;
3652
+ const identity = EduUtil.current(settings);
3653
+ const klass = rooms.classes().find((room) => room.id === settings.klass) ?? rooms.classes()[0];
3654
+ const sub = identity === "teacher" || identity === "homeroom" ? [settings.subject, klass?.title].filter(Boolean).join(" · ") : [settings.stage && words[settings.stage], settings.textbook].filter(Boolean).join(" · ");
3655
+ return /* @__PURE__ */ React.createElement("div", {
3656
+ className: "ted-pagehead"
3657
+ }, /* @__PURE__ */ React.createElement("span", {
3658
+ className: "ted-pagehead-title"
3659
+ }, home.eduTitle), sub && /* @__PURE__ */ React.createElement("span", {
3660
+ className: "ted-pagehead-sub"
3661
+ }, sub));
3662
+ }
3663
+ function EduPage({ context }) {
3664
+ const { pi, store, rooms } = context;
3665
+ const state = useStore(store);
3666
+ useRooms(rooms);
3667
+ const home = HomeWordsUtil.of(pi.ui.language);
3668
+ const [book, setBook] = React.useState();
3669
+ const [shown, setShown] = React.useState();
3670
+ const scroller = React.useRef(null);
3671
+ const scrolls = React.useRef({});
3672
+ const identity = EduUtil.current(state.settings);
3673
+ const drawn = useDrawn(state.settings.identities, state.loaded && !!identity);
3674
+ React.useLayoutEffect(() => {
3675
+ if (identity && scroller.current) {
3676
+ scroller.current.scrollTop = scrolls.current[identity] ?? 0;
3677
+ }
3678
+ }, [identity]);
3679
+ if (!state.loaded) {
3680
+ return /* @__PURE__ */ React.createElement(pi.ui.Loading, null);
3681
+ }
3682
+ if (!identity) {
3683
+ return /* @__PURE__ */ React.createElement("div", {
3684
+ className: "ted-page"
3685
+ }, /* @__PURE__ */ React.createElement("div", {
3686
+ className: "ted-col"
3687
+ }, /* @__PURE__ */ React.createElement(Picker, {
3688
+ context,
3689
+ first: true
3690
+ })));
3691
+ }
3692
+ const books = EduUtil.books(state.mistakes, Date.now(), home.otherSubject);
3693
+ const open = book !== undefined;
3694
+ const homes = state.settings.identities.filter((one) => one === identity || drawn.includes(one));
3695
+ const base = /* @__PURE__ */ React.createElement("div", {
3696
+ className: "ted-page",
3697
+ ref: scroller
3698
+ }, /* @__PURE__ */ React.createElement("div", {
3699
+ className: "ted-col"
3700
+ }, /* @__PURE__ */ React.createElement(Switcher, {
3701
+ context,
3702
+ identity,
3703
+ onSwitch: () => {
3704
+ if (scroller.current) {
3705
+ scrolls.current[identity] = scroller.current.scrollTop;
3706
+ }
3707
+ }
3708
+ }), homes.map((one) => /* @__PURE__ */ React.createElement("div", {
3709
+ className: "ted-role",
3710
+ key: one,
3711
+ hidden: one !== identity
3712
+ }, one === "student" && /* @__PURE__ */ React.createElement(StudentHome, {
3713
+ context,
3714
+ books,
3715
+ openBook: (subject) => {
3716
+ setBook(subject);
3717
+ setShown(subject);
3718
+ }
3719
+ }), one === "parent" && /* @__PURE__ */ React.createElement(ParentHome, {
3720
+ context
3721
+ }), one === "teacher" && /* @__PURE__ */ React.createElement(TeacherHome, {
3722
+ context
3723
+ }), one === "homeroom" && /* @__PURE__ */ React.createElement(HomeroomHome, {
3724
+ context
3725
+ })))));
3726
+ const top = shown !== undefined ? /* @__PURE__ */ React.createElement(MistakeBook, {
3727
+ context,
3728
+ book: books.find((one) => one.subject === shown)
3729
+ }) : null;
3730
+ return pi.ui.Stack ? /* @__PURE__ */ React.createElement(pi.ui.Stack, {
3731
+ base,
3732
+ top,
3733
+ open,
3734
+ onClose: () => setBook(undefined)
3735
+ }) : open ? top : base;
3736
+ }
3737
+ function useDrawn(identities, ready) {
3738
+ const [drawn, setDrawn] = React.useState([]);
3739
+ const all = identities.join();
3740
+ React.useEffect(() => {
3741
+ if (!ready) {
3742
+ return;
3743
+ }
3744
+ const idle = window.requestIdleCallback ?? ((run2) => window.setTimeout(run2, 300));
3745
+ const cancel = window.cancelIdleCallback ?? window.clearTimeout;
3746
+ const handle = idle(() => setDrawn(all.split(",")), { timeout: 800 });
3747
+ return () => cancel(handle);
3748
+ }, [all, ready]);
3749
+ return drawn;
3750
+ }
3751
+ function Switcher({ context, identity, onSwitch }) {
3752
+ const { pi, store } = context;
3753
+ const words = EduWords.of(pi.ui.language);
3754
+ const home = HomeWordsUtil.of(pi.ui.language);
3755
+ const { identities } = store.state.settings;
3756
+ const Plus = iconOf(pi, "Plus");
3757
+ const at = identities.indexOf(identity);
3758
+ const style = { "--ted-n": identities.length, "--ted-at": Math.max(0, at) };
3759
+ return /* @__PURE__ */ React.createElement("div", {
3760
+ className: "ted-switch",
3761
+ "data-many": identities.length > 3 || undefined
3762
+ }, /* @__PURE__ */ React.createElement("div", {
3763
+ className: "ted-switch-items",
3764
+ role: "tablist",
3765
+ "aria-label": home.roles,
3766
+ style
3767
+ }, /* @__PURE__ */ React.createElement("span", {
3768
+ className: "ted-switch-thumb",
3769
+ "aria-hidden": "true"
3770
+ }), identities.map((one) => {
3771
+ const Icon = iconOf(pi, ROLES[one].icon);
3772
+ return /* @__PURE__ */ React.createElement("button", {
3773
+ key: one,
3774
+ type: "button",
3775
+ role: "tab",
3776
+ "aria-selected": one === identity,
3777
+ className: "ted-switch-item",
3778
+ style: tone(TONES[one]),
3779
+ onClick: () => {
3780
+ if (one !== identity) {
3781
+ onSwitch();
3782
+ store.setSettings({ current: one });
3783
+ }
3784
+ }
3785
+ }, /* @__PURE__ */ React.createElement(Icon, {
3786
+ size: 15,
3787
+ strokeWidth: 2
3788
+ }), /* @__PURE__ */ React.createElement("span", null, words[one]));
3789
+ })), /* @__PURE__ */ React.createElement("button", {
3790
+ type: "button",
3791
+ className: "ted-switch-add",
3792
+ "aria-label": home.roles,
3793
+ onClick: () => openPicker(context)
3794
+ }, /* @__PURE__ */ React.createElement(Plus, {
3795
+ size: 16,
3796
+ strokeWidth: 2
3797
+ })));
3798
+ }
3799
+ function openPicker(context) {
3800
+ const { pi } = context;
3801
+ const home = HomeWordsUtil.of(pi.ui.language);
3802
+ pi.ui.custom(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
3803
+ title: home.pickTitle,
3804
+ onClose: close
3805
+ }, /* @__PURE__ */ React.createElement(Picker, {
3806
+ context,
3807
+ close
3808
+ })));
3809
+ }
3810
+ function Picker({ context, first, close }) {
3811
+ const { pi, store } = context;
3812
+ const state = useStore(store);
3813
+ const words = EduWords.of(pi.ui.language);
3814
+ const home = HomeWordsUtil.of(pi.ui.language);
3815
+ const { settings } = state;
3816
+ const Check = iconOf(pi, "Check");
3817
+ const toggle = (identity) => {
3818
+ const on = settings.identities.includes(identity);
3819
+ const identities = on ? settings.identities.filter((one) => one !== identity) : IDENTITIES.filter((one) => one === identity || settings.identities.includes(one));
3820
+ store.setSettings({ identities, current: on ? settings.current === identity ? undefined : settings.current : identity });
3821
+ };
3822
+ return /* @__PURE__ */ React.createElement("div", {
3823
+ className: "ted-picker"
3824
+ }, first && /* @__PURE__ */ React.createElement("div", {
3825
+ className: "ted-picker-head"
3826
+ }, /* @__PURE__ */ React.createElement("div", {
3827
+ className: "ted-picker-title"
3828
+ }, home.pickTitle), /* @__PURE__ */ React.createElement("div", {
3829
+ className: "ted-picker-hint"
3830
+ }, home.pickHint)), !first && /* @__PURE__ */ React.createElement("div", {
3831
+ className: "ted-picker-hint ted-picker-hint-alone"
3832
+ }, home.pickHint), /* @__PURE__ */ React.createElement("div", {
3833
+ className: "ted-list"
3834
+ }, IDENTITIES.map((identity) => {
3835
+ const Icon = iconOf(pi, ROLES[identity].icon);
3836
+ const on = settings.identities.includes(identity);
3837
+ return /* @__PURE__ */ React.createElement("button", {
3838
+ key: identity,
3839
+ type: "button",
3840
+ className: "ted-row",
3841
+ "aria-pressed": on,
3842
+ onClick: () => toggle(identity)
3843
+ }, /* @__PURE__ */ React.createElement(Tile, {
3844
+ icon: Icon,
3845
+ tone: TONES[identity]
3846
+ }), /* @__PURE__ */ React.createElement("span", {
3847
+ className: "ted-row-main"
3848
+ }, /* @__PURE__ */ React.createElement("span", {
3849
+ className: "ted-row-title"
3850
+ }, words[identity]), /* @__PURE__ */ React.createElement("span", {
3851
+ className: "ted-row-sub"
3852
+ }, words[ROLES[identity].tagline])), /* @__PURE__ */ React.createElement("span", {
3853
+ className: "ted-check",
3854
+ "data-on": on || undefined
3855
+ }, on && /* @__PURE__ */ React.createElement(Check, {
3856
+ size: 13,
3857
+ strokeWidth: 3
3858
+ })));
3859
+ })), /* @__PURE__ */ React.createElement("div", {
3860
+ className: "ted-label"
3861
+ }, home.pickStage), /* @__PURE__ */ React.createElement("fieldset", {
3862
+ className: "ta-segmented ted-stage",
3863
+ "aria-label": home.pickStage
3864
+ }, STAGES.map((stage) => /* @__PURE__ */ React.createElement("button", {
3865
+ key: stage,
3866
+ type: "button",
3867
+ "aria-pressed": stage === settings.stage,
3868
+ className: stage === settings.stage ? "ta-on" : undefined,
3869
+ onClick: () => void store.setSettings({ stage })
3870
+ }, words[stage]))), close && /* @__PURE__ */ React.createElement("div", {
3871
+ className: "ted-picker-foot"
3872
+ }, /* @__PURE__ */ React.createElement("button", {
3873
+ type: "button",
3874
+ className: "ta-button ta-primary",
3875
+ onClick: close
3876
+ }, home.done)));
3877
+ }
3878
+
1321
3879
  // web-src/settings.tsx
1322
3880
  function useSettings(store) {
1323
3881
  const [, tick] = React.useReducer((n) => n + 1, 0);
@@ -1341,8 +3899,7 @@ function eduSettings(pi, store) {
1341
3899
  className: "ted-chip",
1342
3900
  "aria-pressed": on,
1343
3901
  onClick: () => void store.setSettings({
1344
- identities: on ? settings.identities.filter((one) => one !== identity) : [...settings.identities, identity],
1345
- asked: true
3902
+ identities: on ? settings.identities.filter((one) => one !== identity) : [...settings.identities, identity]
1346
3903
  })
1347
3904
  }, w[identity]);
1348
3905
  }));
@@ -1403,6 +3960,190 @@ function eduSettings(pi, store) {
1403
3960
 
1404
3961
  // web-src/style.ts
1405
3962
  var STYLE = `
3963
+ /* The page of Education: a column on a phone, two side by side where there is room. */
3964
+ .ted-page { --ted-s: var(--ta-font-scale, 1); container-type: inline-size; min-height: 100%; box-sizing: border-box; padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); background: var(--ta-side); color: var(--ta-text); font-size: calc(14px * var(--ted-s)); line-height: 1.5; overflow-y: auto; height: 100%; }
3965
+ .ted-col { max-width: var(--ta-page-wide, 880px); margin: 0 auto; }
3966
+ .ted-pagehead { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.25; }
3967
+ .ted-pagehead-title { font-weight: 600; font-size: calc(15px * var(--ta-font-scale, 1)); }
3968
+ .ted-pagehead-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); font-size: calc(11.5px * var(--ta-font-scale, 1)); }
3969
+ .ted-switch { display: flex; align-items: center; gap: 2px; margin: 6px 0 14px; padding: 3px; border-radius: 12px; background: var(--ta-chip); }
3970
+ /* The selected one sits on a thumb that slides to it; what is in the items never changes, so nothing in the row moves. */
3971
+ .ted-switch-items { position: relative; flex: 1; min-width: 0; display: flex; }
3972
+ .ted-switch-thumb { position: absolute; top: 0; bottom: 0; left: 0; width: calc(100% / var(--ted-n)); border-radius: 9px; background: var(--ta-segment); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.04); transform: translateX(calc(100% * var(--ted-at))); transition: transform 240ms var(--ta-ease); will-change: transform; }
3973
+ .ted-switch-item { position: relative; flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: calc(34px * var(--ted-s)); padding: 0 6px; border: 0; border-radius: 9px; background: transparent; color: var(--ta-secondary); font: inherit; font-size: calc(14px * var(--ted-s)); font-weight: 500; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color 200ms; }
3974
+ .ted-switch-item svg { flex: none; color: var(--ta-muted); transition: color 200ms; }
3975
+ .ted-switch-item span { overflow: hidden; text-overflow: ellipsis; }
3976
+ .ted-switch-item[aria-selected='true'] { color: var(--ta-text); }
3977
+ .ted-switch-item[aria-selected='true'] svg { color: var(--ted-ink); }
3978
+ .ted-switch[data-many] .ted-switch-item svg { display: none; }
3979
+ .ted-switch-add { flex: none; display: inline-flex; align-items: center; justify-content: center; width: calc(34px * var(--ted-s)); height: calc(34px * var(--ted-s)); border: 0; border-radius: 9px; background: transparent; color: var(--ta-muted); cursor: pointer; }
3980
+ .ted-switch-add:hover { color: var(--ta-text); }
3981
+ .ted-role[hidden] { display: none; }
3982
+ .ted-role { animation: ted-in 160ms var(--ta-ease); }
3983
+ @keyframes ted-in { from { opacity: 0; } }
3984
+ @media (prefers-reduced-motion: reduce) { .ted-role { animation: none; } .ted-switch-thumb { transition: none; } }
3985
+ .ted-greet { margin: 2px 2px 12px; }
3986
+ .ted-greet-sub { color: var(--ta-muted); font-size: calc(12.5px * var(--ted-s)); }
3987
+ .ted-greet-title { margin: 2px 0 0; font-size: calc(22px * var(--ted-s)); font-weight: 600; letter-spacing: -0.2px; line-height: 1.3; }
3988
+ .ted-count { font-style: normal; font-variant-numeric: tabular-nums; }
3989
+ .ted-panel { border-radius: 16px; background: var(--ta-card); }
3990
+ :root[data-theme='light'] .ted-panel, :root[data-theme='light'] .ted-action { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
3991
+ :root:not([data-theme='light']) .ted-page { --ta-card: var(--ta-raised); }
3992
+ /* In the dark a tile of a tint is as dark as the card it is on: lifted to be seen. */
3993
+ :root:not([data-theme='light']) :is(.ted-tile, .ted-letter, .ted-avatar, .ted-hero-face) { background: var(--ta-hover-strong); }
3994
+ .ted-today { padding: 14px 14px 12px; }
3995
+ .ted-today-q { padding: 2px 2px 12px; border-bottom: 1px solid var(--ta-border-muted); }
3996
+ .ted-today-none { color: var(--ta-secondary); font-size: calc(13.5px * var(--ted-s)); }
3997
+ .ted-meta { display: flex; align-items: center; gap: 6px; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
3998
+ .ted-meta-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ta-tint-ink-0); }
3999
+ .ted-meta-faint { margin-top: 6px; }
4000
+ .ted-today-text { margin-top: 6px; font-size: calc(17px * var(--ted-s)); font-weight: 500; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
4001
+ .ted-today-text p { margin: 0; }
4002
+ .ted-today-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; }
4003
+ .ted-dots { display: flex; gap: 7px; }
4004
+ .ted-dot { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ta-muted); font-size: calc(10.5px * var(--ted-s)); }
4005
+ .ted-dot i { width: 16px; height: 16px; border-radius: 50%; background: var(--ta-chip); }
4006
+ .ted-dot[data-on] i { background: color-mix(in oklab, var(--ta-tint-ink-0) 32%, var(--ta-card)); }
4007
+ .ted-dot[data-today] { color: var(--ta-text); font-weight: 600; }
4008
+ .ted-dot[data-today] i { box-shadow: inset 0 0 0 1.5px var(--ta-tint-ink-0); }
4009
+ .ted-dot[data-today][data-on] i { background: var(--ta-tint-ink-0); box-shadow: none; }
4010
+ .ta-button.ted-pill { height: calc(34px * var(--ted-s)); padding: 0 16px; border-radius: 999px; font-size: calc(13.5px * var(--ted-s)); font-weight: 600; }
4011
+ .ted-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0 4px; }
4012
+ .ted-action { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; padding: 12px 2px 11px; border: 0; border-radius: 16px; background: var(--ta-card); color: var(--ta-body); font: inherit; font-size: calc(12.5px * var(--ted-s)); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 120ms var(--ta-ease), background 120ms; }
4013
+ .ted-action span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4014
+ .ted-action:hover:not(:disabled) { background: var(--ta-hover); }
4015
+ .ted-action:active:not(:disabled) { transform: scale(0.97); }
4016
+ .ted-action:disabled { opacity: 0.6; }
4017
+ .ted-tile { flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: var(--ted-tile, var(--ta-chip)); color: var(--ted-ink, var(--ta-secondary)); }
4018
+ .ted-tile-row { width: calc(36px * var(--ted-s)); height: calc(36px * var(--ted-s)); }
4019
+ .ted-tile-big { width: calc(42px * var(--ted-s)); height: calc(42px * var(--ted-s)); border-radius: 13px; }
4020
+ .ted-grid { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 20px; }
4021
+ @container (min-width: 720px) { .ted-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .ted-actions { gap: 10px; } }
4022
+ .ted-section { margin-top: 16px; }
4023
+ .ted-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 4px 8px; }
4024
+ .ted-section-head h3 { margin: 0; font-size: calc(15px * var(--ted-s)); font-weight: 600; }
4025
+ .ted-section-aside { color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); white-space: nowrap; }
4026
+ .ted-list { display: flex; flex-direction: column; padding: 2px 0; }
4027
+ .ted-row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; padding: 11px 14px; box-sizing: border-box; border: 0; background: transparent; color: var(--ta-muted); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
4028
+ .ted-row:disabled { opacity: 0.55; cursor: default; }
4029
+ button.ted-row:hover:not(:disabled) { background: var(--ta-hover); }
4030
+ .ted-panel.ted-list > .ted-row:first-child { border-radius: 16px 16px 0 0; }
4031
+ .ted-panel.ted-list > .ted-row:last-child { border-radius: 0 0 16px 16px; }
4032
+ .ted-panel.ted-list > .ted-row:only-child { border-radius: 16px; }
4033
+ .ted-row + .ted-row::before, .ted-mistake + .ted-mistake::before { content: ''; position: absolute; top: 0; left: calc(62px * var(--ted-s)); right: 0; border-top: 1px solid var(--ta-border-muted); }
4034
+ .ted-row-top { align-items: flex-start; }
4035
+ .ted-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
4036
+ .ted-row-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
4037
+ .ted-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-text); font-size: calc(15px * var(--ted-s)); font-weight: 500; }
4038
+ .ted-row-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-muted); font-size: calc(12.5px * var(--ted-s)); }
4039
+ .ted-row-line .ted-row-sub { flex: none; }
4040
+ .ted-wrap { white-space: normal; }
4041
+ .ted-clamp { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
4042
+ .ted-row-title.ted-clamp { font-size: calc(14.5px * var(--ted-s)); }
4043
+ .ted-row-value { flex: none; min-width: 2.6em; color: var(--ta-secondary); font-size: calc(12.5px * var(--ted-s)); font-variant-numeric: tabular-nums; text-align: right; }
4044
+ .ted-letter { flex: none; display: inline-flex; align-items: center; justify-content: center; width: calc(36px * var(--ted-s)); height: calc(36px * var(--ted-s)); border-radius: 11px; background: var(--ted-tile); color: var(--ted-ink); font-weight: 600; font-size: calc(15px * var(--ted-s)); }
4045
+ .ted-round { border-radius: 50%; }
4046
+ .ted-meter { display: block; height: 4px; margin-top: 7px; border-radius: 2px; background: var(--ta-chip); overflow: hidden; }
4047
+ .ted-meter i { display: block; height: 100%; border-radius: 2px; transition: width 400ms var(--ta-ease); }
4048
+ .ted-meter-thick { height: 6px; margin: 0 0 4px; border-radius: 3px; }
4049
+ .ted-check { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; box-sizing: border-box; border: 1.5px solid var(--ta-border-field); border-radius: 50%; color: #fff; transition: background 120ms, border-color 120ms; }
4050
+ .ted-check[data-on] { border-color: var(--ta-green); background: var(--ta-green); }
4051
+ .ted-switchmark { flex: none; width: 36px; height: 22px; border-radius: 11px; background: var(--ta-chip); position: relative; transition: background 160ms; }
4052
+ .ted-switchmark::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 160ms var(--ta-ease); }
4053
+ .ted-switchmark[data-on] { background: var(--ta-green); }
4054
+ .ted-switchmark[data-on]::after { transform: translateX(14px); }
4055
+ .ted-toparent { margin-top: 12px; }
4056
+ .ted-toparent .ted-row-sub { white-space: normal; }
4057
+ .ted-quiet { padding: 14px; color: var(--ta-muted); font-size: calc(13px * var(--ted-s)); }
4058
+ .ted-week { padding: 14px; }
4059
+ .ted-stats { display: flex; }
4060
+ .ted-stat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
4061
+ .ted-stat + .ted-stat { padding-left: 14px; border-left: 1px solid var(--ta-border-muted); }
4062
+ .ted-stat b { font-size: calc(22px * var(--ted-s)); font-weight: 600; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; line-height: 1.25; }
4063
+ .ted-stat b small { margin-left: 1px; color: var(--ta-secondary); font-size: calc(13px * var(--ted-s)); font-weight: 500; }
4064
+ .ted-stat span { color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
4065
+ .ted-weekbars { display: flex; gap: 12px; height: 76px; margin-top: 14px; }
4066
+ .ted-weekbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
4067
+ .ted-weekbar i { display: block; width: 100%; max-width: 28px; border-radius: 4px; background: color-mix(in oklab, var(--ta-tint-ink-0) 34%, var(--ta-card)); transition: height 400ms var(--ta-ease); }
4068
+ .ted-weekbar i[data-none] { background: var(--ta-chip); }
4069
+ .ted-weekbar[data-today] i:not([data-none]) { background: var(--ta-tint-ink-0); }
4070
+ .ted-weekbar small { color: var(--ta-muted); font-size: calc(10.5px * var(--ted-s)); }
4071
+ .ted-weekbar[data-today] small { color: var(--ta-text); font-weight: 600; }
4072
+ .ted-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
4073
+ .ted-panel-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(16px * var(--ted-s)); font-weight: 600; }
4074
+ .ted-panel-aside { flex: none; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
4075
+ .ted-panel-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
4076
+ .ted-panel-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--ta-border-muted); color: var(--ta-secondary); font-size: calc(13px * var(--ted-s)); }
4077
+ .ted-report, .ted-quizcard { padding: 14px; }
4078
+ .ted-report-rows { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--ta-border-muted); }
4079
+ .ted-report-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; }
4080
+ .ted-report-row b { flex: 1; min-width: 0; font-size: calc(14px * var(--ted-s)); font-weight: 500; }
4081
+ .ted-report-row small { color: var(--ta-muted); font-size: calc(12.5px * var(--ted-s)); }
4082
+ .ted-report .ted-tags { margin-top: 6px; }
4083
+ .ted-tone { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ta-green); }
4084
+ .ted-tone[data-level='warn'] { background: var(--ta-yellow); }
4085
+ .ted-tone[data-level='bad'] { background: var(--ta-red); }
4086
+ .ted-hard { display: inline-flex; align-items: center; gap: 6px; color: var(--ta-text); }
4087
+ .ted-hard small { color: var(--ta-muted); }
4088
+ .ted-hist { display: flex; align-items: stretch; gap: 12px; height: 108px; margin-top: 14px; }
4089
+ .ted-hist-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
4090
+ .ted-hist-bar i { display: block; width: 100%; border-radius: 5px 5px 2px 2px; background: color-mix(in oklab, var(--ta-tint-ink-3) 38%, var(--ta-card)); transition: height 400ms var(--ta-ease); }
4091
+ .ted-hist-bar i[data-top] { background: var(--ta-tint-ink-3); }
4092
+ .ted-hist-bar small { color: var(--ta-muted); font-size: calc(11px * var(--ted-s)); font-variant-numeric: tabular-nums; }
4093
+ .ted-hist-bar .ted-hist-n { color: var(--ta-secondary); min-height: 1.4em; }
4094
+ .ted-empty { padding: 6px 4px; }
4095
+ .ted-empty .ted-pill { margin-top: 4px; }
4096
+ .ted-chips { display: flex; gap: 6px; margin: 0 0 12px; overflow-x: auto; scrollbar-width: none; }
4097
+ .ted-chips::-webkit-scrollbar { display: none; }
4098
+ .ted-chip-quiet { width: calc(32px * var(--ta-font-scale, 1)); padding: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--ta-muted); }
4099
+ .ted-privacy { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 16px 0 4px; color: var(--ta-muted); font-size: calc(11.5px * var(--ted-s)); }
4100
+ .ted-draft { display: inline-flex; align-self: flex-start; align-items: center; gap: 3px; margin-top: 5px; padding: 1px 7px; border-radius: 5px; background: color-mix(in oklab, var(--ta-tint-ink-3) 12%, transparent); color: var(--ta-tint-ink-3); font-size: calc(11.5px * var(--ted-s)); font-weight: 500; }
4101
+ .ted-mistake { position: relative; padding: 12px 14px; }
4102
+ .ted-mistake + .ted-mistake::before { left: 14px; }
4103
+ .ted-mistake-q { margin: 6px 0 8px; color: var(--ta-text); font-size: calc(15px * var(--ted-s)); }
4104
+ .ted-mistake-q p { margin: 0; }
4105
+ .ted-mistake-a { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: calc(13.5px * var(--ted-s)); }
4106
+ .ted-mistake-a small { margin-right: 6px; color: var(--ta-muted); font-size: calc(12px * var(--ted-s)); }
4107
+ .ted-mistake-a s { color: var(--ta-red); text-decoration-color: color-mix(in srgb, var(--ta-red) 60%, transparent); }
4108
+ .ted-right { color: var(--ta-green); }
4109
+ .ted-due { margin-left: auto; }
4110
+ .ted-due[data-now] { color: var(--ta-tint-ink-0); font-weight: 500; }
4111
+ .ted-bottom { position: sticky; bottom: 0; padding: 14px 0 4px; background: linear-gradient(to bottom, transparent, var(--ta-side) 30%); }
4112
+ .ta-button.ted-wide { width: 100%; height: calc(44px * var(--ted-s)); border-radius: 12px; font-size: calc(15px * var(--ted-s)); font-weight: 600; }
4113
+ .ted-picker { display: flex; flex-direction: column; min-width: min(420px, 100%); }
4114
+ .ted-picker-head { margin: 18px 4px 14px; }
4115
+ .ted-picker-title { font-size: calc(22px * var(--ted-s, 1)); font-weight: 600; }
4116
+ .ted-picker-hint { color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale, 1)); }
4117
+ .ted-picker-hint-alone { margin: 0 0 10px; }
4118
+ .ted-page .ted-picker .ted-list { border-radius: 16px; background: var(--ta-card); }
4119
+ .ted-picker .ted-list { border: 1px solid var(--ta-border-muted); border-radius: 14px; background: var(--ta-card); overflow: hidden; }
4120
+ .ted-picker .ted-row { border-radius: 0; }
4121
+ .ted-label { margin: 18px 4px 7px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale, 1)); }
4122
+ .ted-stage { display: flex; min-width: 0; margin: 0; border: 0; }
4123
+ .ted-stage button { flex: 1; }
4124
+ .ted-picker-foot { display: flex; justify-content: flex-end; margin-top: 18px; }
4125
+ /* An assistant's conversation before anything is said in it. */
4126
+ .ted-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 460px; margin: 0 auto; padding: 12vh 16px 24px; text-align: center; }
4127
+ .ted-hero-face { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; margin-bottom: 10px; border-radius: 22px; background: var(--ted-tile); color: var(--ted-ink); }
4128
+ .ted-hero-title { margin: 0; font-size: calc(22px * var(--ta-font-scale, 1)); font-weight: 600; }
4129
+ .ted-hero-hint { margin: 0 0 18px; color: var(--ta-muted); font-size: calc(13.5px * var(--ta-font-scale, 1)); }
4130
+ .ted-hero-starts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
4131
+ .ted-start { display: flex; align-items: center; gap: 8px; min-width: 0; height: calc(44px * var(--ta-font-scale, 1)); padding: 0 14px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); color: var(--ta-text); font: inherit; font-size: calc(14px * var(--ta-font-scale, 1)); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
4132
+ .ted-start svg { flex: none; color: var(--ta-muted); }
4133
+ .ted-start span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4134
+ .ted-start:hover { background: var(--ta-hover); }
4135
+ .ted-chiprow { display: flex; gap: 6px; margin: 0 0 8px; overflow-x: auto; scrollbar-width: none; }
4136
+ .ted-chiprow::-webkit-scrollbar { display: none; }
4137
+ .ted-chip-icon { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 0 10px; }
4138
+ .ted-assistant { margin-top: 12px; }
4139
+ .ted-avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--ted-tile); color: var(--ted-ink); }
4140
+ .ted-chip-icon svg { color: var(--ta-muted); }
4141
+ /* Under a quiz of a class. */
4142
+ .ted-handin { align-items: center; justify-content: space-between; gap: 10px; }
4143
+ .ted-handin-note { min-width: 0; color: var(--ta-muted); font-size: calc(12.5px * var(--ted-s)); }
4144
+ .ted-handed { display: inline-flex; align-items: center; gap: 5px; color: var(--ta-green); font-size: calc(13px * var(--ted-s)); font-weight: 500; }
4145
+ .ted-stats-card { padding: 12px 14px; }
4146
+
1406
4147
  .ted-card { --ted-s: var(--ta-font-scale, 1); margin: 2px 0 12px; max-width: 560px; border: 1px solid var(--ta-border); border-radius: 12px; background: var(--ta-card); color: var(--ta-text); font-size: calc(13.5px * var(--ted-s)); line-height: 1.55; overflow: hidden; overflow-wrap: anywhere; }
1407
4148
  .ted-card > * + * { border-top: 1px solid var(--ta-border-muted); }
1408
4149
  .ted-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
@@ -1462,13 +4203,6 @@ var STYLE = `
1462
4203
  .ted-chip[aria-pressed='true'] { border-color: color-mix(in srgb, var(--ta-blue) 60%, transparent); background: color-mix(in srgb, var(--ta-blue) 10%, transparent); color: var(--ta-blue); }
1463
4204
  [data-touch] .ted-chip { height: 32px; }
1464
4205
  .ted-field { width: 200px; max-width: 100%; height: 32px; }
1465
- .ted-ask { margin: 0 0 8px; padding: 10px 12px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); }
1466
- .ted-ask-head { display: flex; align-items: center; gap: 8px; }
1467
- .ted-ask-later { flex: none; padding: 0; border: 0; background: none; color: var(--ta-muted); font: inherit; font-size: calc(12.5px * var(--ta-font-scale, 1)); cursor: pointer; }
1468
- .ted-ask-later:hover { color: var(--ta-text); }
1469
- .ted-ask-title { flex: 1; min-width: 0; color: var(--ta-text); font-size: calc(13.5px * var(--ta-font-scale, 1)); font-weight: 600; }
1470
- .ted-ask-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
1471
- .ted-ask-label { margin-right: 2px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale, 1)); }
1472
4206
  `;
1473
4207
  function injectStyle() {
1474
4208
  const element = document.createElement("style");
@@ -1483,13 +4217,54 @@ function activate(pi) {
1483
4217
  bind(pi.React);
1484
4218
  const removeStyle = injectStyle();
1485
4219
  const store = new EduStore(pi);
4220
+ const rooms = new EduRooms(pi, store);
4221
+ const context = { pi, store, rooms };
4222
+ pi.registerView("home", {
4223
+ title: () => HomeWordsUtil.of(pi.ui.language).eduTitle,
4224
+ icon: pi.ui.icons.BookOpen,
4225
+ render: () => /* @__PURE__ */ React.createElement(EduPage, {
4226
+ context
4227
+ }),
4228
+ head: () => /* @__PURE__ */ React.createElement(EduHead, {
4229
+ context
4230
+ }),
4231
+ navigation: false
4232
+ });
4233
+ pi.registerAvatar(({ session, size }) => {
4234
+ const identity = EduChats.identityOf(store, session.sessionFile);
4235
+ const Icon = iconOf(pi, identity ? ROLES[identity].icon : "BookOpen");
4236
+ return /* @__PURE__ */ React.createElement("span", {
4237
+ className: "ted-avatar",
4238
+ style: { ...tone(TONES[identity ?? "student"]), width: size, height: size }
4239
+ }, /* @__PURE__ */ React.createElement(Icon, {
4240
+ size: Math.round(size * 0.55),
4241
+ strokeWidth: 2
4242
+ }));
4243
+ });
1486
4244
  pi.registerHomeItems?.(eduHome(pi, store));
1487
4245
  pi.registerChatIcon?.(eduChatIcons(pi, store));
1488
4246
  pi.registerComposerAddon(eduComposer(pi, store));
1489
4247
  pi.registerSettings(eduSettings(pi, store));
1490
- pi.registerCodeRenderer?.(QUIZ, quizCard(pi, store), { spoken: (code) => EduUtil.quiz(code)?.title });
4248
+ pi.registerCodeRenderer?.(QUIZ, quizCard(pi, store, rooms), { spoken: (code) => EduUtil.quiz(code)?.title });
1491
4249
  pi.registerCodeRenderer?.(LEARNING, learningCard(pi), { spoken: (code) => EduUtil.learning(code)?.title });
1492
- return removeStyle;
4250
+ const weekly = store.subscribe(() => {
4251
+ const { loaded, settings, days, mistakes } = store.state;
4252
+ if (!loaded || !settings.reportTo || !EduReport.due(settings.reportTo, settings.reportAt, Date.now()) || !pi.rooms) {
4253
+ return;
4254
+ }
4255
+ const to = settings.reportTo;
4256
+ store.setSettings({ reportAt: Date.now() });
4257
+ pi.rooms.getIdentity().then((me) => {
4258
+ const home = HomeWordsUtil.of(pi.ui.language);
4259
+ return rooms.sendReport(to, EduReport.of(days, mistakes, me.name, home, Date.now()), EduWords.format(home.reportIntro, { name: me.name }), false);
4260
+ }).catch(() => {
4261
+ return;
4262
+ });
4263
+ });
4264
+ return () => {
4265
+ weekly();
4266
+ removeStyle();
4267
+ };
1493
4268
  }
1494
4269
  export {
1495
4270
  activate as default