wrong-notebook 2026.11.4-5 → 2026.11.4-7

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 (505) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/server/app/_global-error.html +1 -1
  4. package/.next/server/app/_global-error.rsc +1 -1
  5. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  6. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  8. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  9. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/admin/page.js.nft.json +1 -1
  11. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/admin/user/[id]/page.js.nft.json +1 -1
  13. package/.next/server/app/admin/user/[id]/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/admin/cnm-tags/route.js.nft.json +1 -1
  15. package/.next/server/app/api/admin/dashboard/route.js.nft.json +1 -1
  16. package/.next/server/app/api/admin/debug-logs/export/route.js.nft.json +1 -1
  17. package/.next/server/app/api/admin/debug-logs/route.js.nft.json +1 -1
  18. package/.next/server/app/api/admin/migrate-tags/route.js.nft.json +1 -1
  19. package/.next/server/app/api/admin/system-reset/route.js.nft.json +1 -1
  20. package/.next/server/app/api/admin/users/[id]/detail/route.js.nft.json +1 -1
  21. package/.next/server/app/api/admin/users/[id]/route.js.nft.json +1 -1
  22. package/.next/server/app/api/admin/users/route.js.nft.json +1 -1
  23. package/.next/server/app/api/ai/models/route.js +3 -3
  24. package/.next/server/app/api/ai/models/route.js.nft.json +1 -1
  25. package/.next/server/app/api/ai/test/route.js.nft.json +1 -1
  26. package/.next/server/app/api/analytics/route.js.nft.json +1 -1
  27. package/.next/server/app/api/analyze/route.js +4 -4
  28. package/.next/server/app/api/analyze/route.js.nft.json +1 -1
  29. package/.next/server/app/api/error-items/[id]/delete/route.js.nft.json +1 -1
  30. package/.next/server/app/api/error-items/[id]/figure/route.js +14 -14
  31. package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
  32. package/.next/server/app/api/error-items/[id]/fix-latex/route.js +2 -2
  33. package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
  34. package/.next/server/app/api/error-items/[id]/geogebra/route.js +16 -16
  35. package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
  36. package/.next/server/app/api/error-items/[id]/image/route.js.nft.json +1 -1
  37. package/.next/server/app/api/error-items/[id]/notes/route.js.nft.json +1 -1
  38. package/.next/server/app/api/error-items/[id]/practice-records/route.js.nft.json +1 -1
  39. package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
  40. package/.next/server/app/api/error-items/[id]/retag/route.js +5 -5
  41. package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
  42. package/.next/server/app/api/error-items/[id]/route.js.nft.json +1 -1
  43. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js +12 -12
  44. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
  45. package/.next/server/app/api/error-items/[id]/svg-animation/route.js +12 -12
  46. package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
  47. package/.next/server/app/api/error-items/answer-space/route.js.nft.json +1 -1
  48. package/.next/server/app/api/error-items/batch-delete/route.js.nft.json +1 -1
  49. package/.next/server/app/api/error-items/clear/route.js.nft.json +1 -1
  50. package/.next/server/app/api/error-items/export-questions/route.js.nft.json +1 -1
  51. package/.next/server/app/api/error-items/list/route.js +1 -1
  52. package/.next/server/app/api/error-items/list/route.js.nft.json +1 -1
  53. package/.next/server/app/api/error-items/route.js +14 -13
  54. package/.next/server/app/api/error-items/route.js.nft.json +1 -1
  55. package/.next/server/app/api/error-items/short/[shortId]/route.js.nft.json +1 -1
  56. package/.next/server/app/api/error-items/similarity/route.js +4 -4
  57. package/.next/server/app/api/error-items/similarity/route.js.nft.json +1 -1
  58. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js +2 -2
  59. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
  60. package/.next/server/app/api/exams/[id]/results/route.js +2 -2
  61. package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
  62. package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
  63. package/.next/server/app/api/exams/[id]/route.js +2 -2
  64. package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
  65. package/.next/server/app/api/exams/route.js.nft.json +1 -1
  66. package/.next/server/app/api/export/route.js.nft.json +1 -1
  67. package/.next/server/app/api/geogebra-analyze/route.js +1 -1
  68. package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
  69. package/.next/server/app/api/health/route.js.nft.json +1 -1
  70. package/.next/server/app/api/import/route.js +6 -6
  71. package/.next/server/app/api/import/route.js.nft.json +1 -1
  72. package/.next/server/app/api/import-batches/[id]/confirm-all/route.js +8 -8
  73. package/.next/server/app/api/import-batches/[id]/confirm-all/route.js.nft.json +1 -1
  74. package/.next/server/app/api/import-batches/[id]/fix-text/route.js +6 -6
  75. package/.next/server/app/api/import-batches/[id]/fix-text/route.js.nft.json +1 -1
  76. package/.next/server/app/api/import-batches/[id]/read/route.js +8 -8
  77. package/.next/server/app/api/import-batches/[id]/read/route.js.nft.json +1 -1
  78. package/.next/server/app/api/import-batches/[id]/retry/route.js +8 -8
  79. package/.next/server/app/api/import-batches/[id]/retry/route.js.nft.json +1 -1
  80. package/.next/server/app/api/import-batches/[id]/route.js +8 -8
  81. package/.next/server/app/api/import-batches/[id]/route.js.nft.json +1 -1
  82. package/.next/server/app/api/import-batches/[id]/start/route.js +8 -8
  83. package/.next/server/app/api/import-batches/[id]/start/route.js.nft.json +1 -1
  84. package/.next/server/app/api/import-batches/route.js +8 -8
  85. package/.next/server/app/api/import-batches/route.js.nft.json +1 -1
  86. package/.next/server/app/api/import-tasks/[id]/confirm/route.js +6 -6
  87. package/.next/server/app/api/import-tasks/[id]/confirm/route.js.nft.json +1 -1
  88. package/.next/server/app/api/import-tasks/[id]/read/route.js +6 -6
  89. package/.next/server/app/api/import-tasks/[id]/read/route.js.nft.json +1 -1
  90. package/.next/server/app/api/import-tasks/[id]/retry/route.js +4 -4
  91. package/.next/server/app/api/import-tasks/[id]/retry/route.js.nft.json +1 -1
  92. package/.next/server/app/api/import-tasks/[id]/route.js +6 -6
  93. package/.next/server/app/api/import-tasks/[id]/route.js.nft.json +1 -1
  94. package/.next/server/app/api/import-tasks/route.js +8 -8
  95. package/.next/server/app/api/import-tasks/route.js.nft.json +1 -1
  96. package/.next/server/app/api/initialize/route.js.nft.json +1 -1
  97. package/.next/server/app/api/logs/frontend/route.js.nft.json +1 -1
  98. package/.next/server/app/api/minimax-code/checkin/route.js +2 -2
  99. package/.next/server/app/api/minimax-code/checkin/route.js.nft.json +1 -1
  100. package/.next/server/app/api/minimax-code/login/route.js.nft.json +1 -1
  101. package/.next/server/app/api/minimax-code/route.js +3 -3
  102. package/.next/server/app/api/minimax-code/route.js.nft.json +1 -1
  103. package/.next/server/app/api/notebooks/[id]/retag/route.js +7 -7
  104. package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
  105. package/.next/server/app/api/notebooks/[id]/route.js.nft.json +1 -1
  106. package/.next/server/app/api/notebooks/route.js.nft.json +1 -1
  107. package/.next/server/app/api/openclaw/batch-upload/route.js +8 -8
  108. package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
  109. package/.next/server/app/api/paper-groups/[id]/route.js.nft.json +1 -1
  110. package/.next/server/app/api/paper-groups/route.js.nft.json +1 -1
  111. package/.next/server/app/api/practice/generate/route.js +16 -16
  112. package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
  113. package/.next/server/app/api/practice/grade/route.js.nft.json +1 -1
  114. package/.next/server/app/api/practice/record/[id]/route.js.nft.json +1 -1
  115. package/.next/server/app/api/practice/record/route.js.nft.json +1 -1
  116. package/.next/server/app/api/reanswer/route.js +2 -2
  117. package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
  118. package/.next/server/app/api/register/route.js.nft.json +1 -1
  119. package/.next/server/app/api/requests/[id]/route.js.nft.json +1 -1
  120. package/.next/server/app/api/review/due/route.js.nft.json +1 -1
  121. package/.next/server/app/api/settings/route.js.nft.json +1 -1
  122. package/.next/server/app/api/setup/route.js.nft.json +1 -1
  123. package/.next/server/app/api/stats/activity/route.js.nft.json +1 -1
  124. package/.next/server/app/api/stats/practice/clear/route.js.nft.json +1 -1
  125. package/.next/server/app/api/stats/practice/route.js.nft.json +1 -1
  126. package/.next/server/app/api/stats/repeated-mistakes/route.js.nft.json +1 -1
  127. package/.next/server/app/api/stats/weak-tags/route.js.nft.json +1 -1
  128. package/.next/server/app/api/tags/route.js.nft.json +1 -1
  129. package/.next/server/app/api/tags/stats/route.js.nft.json +1 -1
  130. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  131. package/.next/server/app/api/tts/[id]/route.js.nft.json +1 -1
  132. package/.next/server/app/api/tts/batch/route.js +4 -4
  133. package/.next/server/app/api/tts/batch/route.js.nft.json +1 -1
  134. package/.next/server/app/api/tts/route.js.nft.json +1 -1
  135. package/.next/server/app/api/tts/status/route.js.nft.json +1 -1
  136. package/.next/server/app/api/user/route.js.nft.json +1 -1
  137. package/.next/server/app/api/version/route.js.nft.json +1 -1
  138. package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
  139. package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
  140. package/.next/server/app/exams/[id]/page.js.nft.json +1 -1
  141. package/.next/server/app/exams/[id]/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app/exams/[id]/print/page.js.nft.json +1 -1
  143. package/.next/server/app/exams/[id]/print/page_client-reference-manifest.js +1 -1
  144. package/.next/server/app/exams/page.js.nft.json +1 -1
  145. package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
  146. package/.next/server/app/import-batches/[id]/page.js.nft.json +1 -1
  147. package/.next/server/app/import-batches/[id]/page_client-reference-manifest.js +1 -1
  148. package/.next/server/app/import-tasks/[id]/page.js.nft.json +1 -1
  149. package/.next/server/app/import-tasks/[id]/page_client-reference-manifest.js +1 -1
  150. package/.next/server/app/import-tasks/page.js.nft.json +1 -1
  151. package/.next/server/app/import-tasks/page_client-reference-manifest.js +1 -1
  152. package/.next/server/app/initialize/page.js.nft.json +1 -1
  153. package/.next/server/app/initialize/page_client-reference-manifest.js +1 -1
  154. package/.next/server/app/login/page.js.nft.json +1 -1
  155. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  156. package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
  157. package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
  158. package/.next/server/app/notebooks/[id]/page.js.nft.json +1 -1
  159. package/.next/server/app/notebooks/[id]/page_client-reference-manifest.js +1 -1
  160. package/.next/server/app/notebooks/page.js.nft.json +1 -1
  161. package/.next/server/app/notebooks/page_client-reference-manifest.js +1 -1
  162. package/.next/server/app/page.js.nft.json +1 -1
  163. package/.next/server/app/page_client-reference-manifest.js +1 -1
  164. package/.next/server/app/practice/page.js.nft.json +1 -1
  165. package/.next/server/app/practice/page_client-reference-manifest.js +1 -1
  166. package/.next/server/app/print-preview/page.js.nft.json +1 -1
  167. package/.next/server/app/print-preview/page_client-reference-manifest.js +1 -1
  168. package/.next/server/app/register/page.js.nft.json +1 -1
  169. package/.next/server/app/register/page_client-reference-manifest.js +1 -1
  170. package/.next/server/app/review/page.js.nft.json +1 -1
  171. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  172. package/.next/server/app/setup/page.js.nft.json +1 -1
  173. package/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  174. package/.next/server/app/stats/page.js.nft.json +1 -1
  175. package/.next/server/app/stats/page_client-reference-manifest.js +1 -1
  176. package/.next/server/app/tags/page.js.nft.json +1 -1
  177. package/.next/server/app/tags/page_client-reference-manifest.js +1 -1
  178. package/.next/server/chunks/[root-of-the-server]__0-ii_w4q2w_78._.js +3 -0
  179. package/.next/server/chunks/{[root-of-the-server]__1dovdb1wrr_0e._.js → [root-of-the-server]__04yihz3dovm0z._.js} +2 -2
  180. package/.next/server/chunks/{[root-of-the-server]__1xuw793xxu29t._.js → [root-of-the-server]__0cizcawcu31he._.js} +2 -2
  181. package/.next/server/chunks/{[root-of-the-server]__0ujhx0glgcxja._.js → [root-of-the-server]__0eqjbieakyy2g._.js} +1 -1
  182. package/.next/server/chunks/{[root-of-the-server]__0vt48u-0ebzdv._.js → [root-of-the-server]__0gk6xz_lxrrer._.js} +1 -1
  183. package/.next/server/chunks/[root-of-the-server]__0hcbw1sliw973._.js +1 -1
  184. package/.next/server/chunks/[root-of-the-server]__0kehix4ojdnhw._.js +1 -1
  185. package/.next/server/chunks/{[root-of-the-server]__0855dkhk7zs77._.js → [root-of-the-server]__0l8sbsrfjhttk._.js} +2 -2
  186. package/.next/server/chunks/[root-of-the-server]__0lgbdth9-z6qg._.js +1 -1
  187. package/.next/server/chunks/[root-of-the-server]__0o9oim91bxvxq._.js +3 -0
  188. package/.next/server/chunks/[root-of-the-server]__0rwoy4jm7s8o7._.js +3 -0
  189. package/.next/server/chunks/[root-of-the-server]__0si2-m5an9zl7._.js +1 -1
  190. package/.next/server/chunks/[root-of-the-server]__0svdqovwfpro2._.js +1 -1
  191. package/.next/server/chunks/[root-of-the-server]__0svpy5s3x369z._.js +3 -0
  192. package/.next/server/chunks/[root-of-the-server]__0ukr4xnposhv9._.js +3 -0
  193. package/.next/server/chunks/[root-of-the-server]__0vrag-4p6eznc._.js +1 -1
  194. package/.next/server/chunks/[root-of-the-server]__11wpfrrg965mf._.js +3 -0
  195. package/.next/server/chunks/{[root-of-the-server]__0dqy62vnjwvwp._.js → [root-of-the-server]__13cos0n0yw_z6._.js} +1 -1
  196. package/.next/server/chunks/[root-of-the-server]__14gc66h_h3i2i._.js +3 -0
  197. package/.next/server/chunks/[root-of-the-server]__163ocf8u6v-xl._.js +3 -0
  198. package/.next/server/chunks/[root-of-the-server]__16_meybuj-s5w._.js +3 -0
  199. package/.next/server/chunks/[root-of-the-server]__17659spbpgn__._.js +3 -0
  200. package/.next/server/chunks/[root-of-the-server]__1bw1tevy-ufwx._.js +3 -0
  201. package/.next/server/chunks/{[root-of-the-server]__0zrg03ldx65tk._.js → [root-of-the-server]__1dqb3qtykno2z._.js} +1 -1
  202. package/.next/server/chunks/[root-of-the-server]__1f-ve8idsq57l._.js +1 -1
  203. package/.next/server/chunks/{[root-of-the-server]__1b-acwmm5hhg0._.js → [root-of-the-server]__1fp6mylnljj_6._.js} +1 -1
  204. package/.next/server/chunks/[root-of-the-server]__1gc1jsjtvhvls._.js +3 -0
  205. package/.next/server/chunks/[root-of-the-server]__1ii155nyrptua._.js +3 -0
  206. package/.next/server/chunks/{[root-of-the-server]__0v8mfczhz1ax1._.js → [root-of-the-server]__1vorkvvfkrr39._.js} +2 -2
  207. package/.next/server/chunks/[root-of-the-server]__1x_yvd3pxoee7._.js +3 -0
  208. package/.next/server/chunks/{[root-of-the-server]__1ybmwcbaqk63j._.js → [root-of-the-server]__1y9cx1kv17pl_._.js} +2 -2
  209. package/.next/server/chunks/[root-of-the-server]__20bo6axxlug5q._.js +3 -0
  210. package/.next/server/chunks/[root-of-the-server]__20vfjg0kexwpn._.js +3 -0
  211. package/.next/server/chunks/_011-ll5i30j2e._.js +1 -1
  212. package/.next/server/chunks/_03ovgh1-4xf3f._.js +1 -1
  213. package/.next/server/chunks/_05-ouasholjra._.js +3 -0
  214. package/.next/server/chunks/_06pseal2zu-71._.js +1 -1
  215. package/.next/server/chunks/_08i9pskmlafnp._.js +1 -1
  216. package/.next/server/chunks/_0d66myj_8567o._.js +1 -1
  217. package/.next/server/chunks/_0p-sas2zxy3iv._.js +1 -1
  218. package/.next/server/chunks/_0tkov27xr068i._.js +3 -3
  219. package/.next/server/chunks/_0tl0cy5j96d7h._.js +1 -1
  220. package/.next/server/chunks/_0zs7jfzzshbfq._.js +1 -1
  221. package/.next/server/chunks/_12xi_xqvtrn3k._.js +1 -1
  222. package/.next/server/chunks/_1638xaazsmf2m._.js +3 -3
  223. package/.next/server/chunks/_18hm5aaxkr500._.js +1 -1
  224. package/.next/server/chunks/_1a1aqmie1d3u_._.js +1 -1
  225. package/.next/server/chunks/_1ad8i3ukisj99._.js +3 -0
  226. package/.next/server/chunks/_1b0269xt-c8f7._.js +1 -1
  227. package/.next/server/chunks/_1cydcmia78z15._.js +1 -1
  228. package/.next/server/chunks/_1lz-5f4_92l2u._.js +3 -0
  229. package/.next/server/chunks/_1sp0xk1c5jx5r._.js +1 -1
  230. package/.next/server/chunks/_1vddun9dxzaqo._.js +3 -3
  231. package/.next/server/chunks/_1zbkha-v5mkk0._.js +1 -1
  232. package/.next/server/chunks/src_lib_0clsw_ng7x3ih._.js +3 -0
  233. package/.next/server/chunks/{src_lib_0zeksho3data7._.js → src_lib_0n6nhl7_avcme._.js} +1 -1
  234. package/.next/server/chunks/src_lib_0so-2topfosjo._.js +1 -1
  235. package/.next/server/chunks/src_lib_1-8qgpevmw3ew._.js +3 -0
  236. package/.next/server/chunks/src_lib_1_m3-y2t3e4xi._.js +22 -19
  237. package/.next/server/chunks/src_lib_1oc3awtm80lqn._.js +3 -0
  238. package/.next/server/chunks/src_lib_background-tasks_ts_02j9z7pcmiqfj._.js +1 -1
  239. package/.next/server/chunks/src_lib_exam_exam_ts_18c3t7bnr1z5k._.js +1 -1
  240. package/.next/server/chunks/src_lib_import_import-batches_ts_0nq3mn0v5uj28._.js +1 -1
  241. package/.next/server/chunks/src_lib_import_import-tasks_ts_01f-g_upv7llt._.js +1 -1
  242. package/.next/server/chunks/src_lib_question_question-analysis_ts_1-3x2cfxlr3fs._.js +1 -1
  243. package/.next/server/chunks/src_lib_question_question-deduplication_ts_0gumctesi3szc._.js +1 -1
  244. package/.next/server/chunks/src_lib_tags_retag_ts_09s5xwrzcy144._.js +1 -1
  245. package/.next/server/chunks/ssr/{[root-of-the-server]__0z7upqzuqtse6._.js → [root-of-the-server]__1epxx0lrejssz._.js} +1 -1
  246. package/.next/server/chunks/ssr/{_1lltqgoq4vqfe._.js → _01zv6gqnnj9oy._.js} +2 -2
  247. package/.next/server/chunks/ssr/{_0fp_p60hb9ex8._.js → _05gdkgyyr0suj._.js} +1 -1
  248. package/.next/server/chunks/ssr/_05k02824g2tpo._.js +1 -1
  249. package/.next/server/chunks/ssr/_0haie2cnycj6w._.js +1 -1
  250. package/.next/server/chunks/ssr/_0xlbgtld9_r3o._.js +1 -1
  251. package/.next/server/chunks/ssr/_1cpvkaqiyve6g._.js +3 -0
  252. package/.next/server/chunks/ssr/{node_modules_0y-9u3ez_29oz._.js → node_modules_115tsi2nro4tk._.js} +1 -1
  253. package/.next/server/chunks/ssr/{node_modules_109z-y1z_gtxg._.js → node_modules_1we6ggthjslzt._.js} +1 -1
  254. package/.next/server/chunks/ssr/{node_modules_08vtqzu_wfcb5._.js → node_modules_1yz9gg4275g30._.js} +1 -1
  255. package/.next/server/chunks/ssr/{node_modules_heic-to_dist_csp_heic-to_1_jdv4y0yz52i.js → node_modules_heic-to_dist_csp_heic-to_038nbq-p7grtd.js} +1 -1
  256. package/.next/server/chunks/ssr/{node_modules_heic-to_dist_csp_heic-to_1zqrtb3kykd7q.js → node_modules_heic-to_dist_csp_heic-to_1b61b0i6philz.js} +1 -1
  257. package/.next/server/chunks/ssr/src_app_error-items_[id]_page_tsx_04xwwdmyh7_9q._.js +1 -1
  258. package/.next/server/chunks/ssr/src_app_exams_[id]_page_tsx_0xcjflkgkwzgd._.js +1 -1
  259. package/.next/server/chunks/ssr/src_app_import-batches_[id]_page_tsx_0mhg_vriwmkkw._.js +1 -1
  260. package/.next/server/chunks/ssr/src_app_notebooks_[id]_page_tsx_08njm-5-txm8_._.js +1 -1
  261. package/.next/server/chunks/ssr/src_app_page_tsx_1chiuahujsxm1._.js +3 -3
  262. package/.next/server/chunks/ssr/src_app_practice_page_tsx_10gnx53v3kpzb._.js +1 -1
  263. package/.next/server/chunks/ssr/src_components_providers_tsx_09kw-mv3nb6xs._.js +12 -12
  264. package/.next/server/chunks/ssr/src_lib_0773v8b5gb93o._.js +3 -3
  265. package/.next/server/chunks/ssr/src_lib_1qhs590-z9xnh._.js +3 -3
  266. package/.next/server/chunks/ssr/src_lib_1z8akixo3j8ti._.js +3 -3
  267. package/.next/server/chunks/ssr/src_lib_api-client_ts_04r2_ex-gua5i._.js +1 -1
  268. package/.next/server/chunks/ssr/src_lib_i18n_en_ts_08zkpwnoqey5s._.js +1 -1
  269. package/.next/server/middleware-build-manifest.js +3 -3
  270. package/.next/server/pages/500.html +1 -1
  271. package/.next/static/chunks/{2xww3vrggzkc3.js → 05pa84fjsr-h8.js} +4 -4
  272. package/.next/static/chunks/07a3zn8uvj2i0.js +1 -0
  273. package/.next/static/chunks/{0ge9zqd21b4xd.js → 0ppbk9n8iiwlv.js} +4 -4
  274. package/.next/static/chunks/0qb4cgf04m6y_.js +1 -0
  275. package/.next/static/chunks/0wr5pvnu47q_0.js +6 -0
  276. package/.next/static/chunks/{3jkntcd5fwsid.js → 0y9dgn85yuuy5.js} +1 -1
  277. package/.next/static/chunks/{3-5otbeiq86n5.js → 1ep255e058_3b.js} +1 -1
  278. package/.next/static/chunks/{31uxxyexyu66p.js → 28qmcol3c39_a.js} +12 -12
  279. package/.next/static/chunks/2eieglv-e8e1j.js +1 -0
  280. package/.next/static/chunks/33vv8ujyvnonj.js +1 -0
  281. package/.next/static/chunks/{113lhm-f9le_y.js → 343yopry-myz8.js} +2 -2
  282. package/.next/static/chunks/3fyp0ya1q-g_k.js +1 -0
  283. package/.next/static/chunks/3g93k83oklg4_.js +1 -0
  284. package/.next/static/chunks/3gdidqib5e1mw.js +1 -0
  285. package/.next/static/chunks/{040et8v6_v-s6.js → 3x0gnqbvstc69.js} +1 -1
  286. package/.next/static/chunks/40t8efajfu_xz.js +12 -0
  287. package/package.json +1 -1
  288. package/prisma/seed.db +0 -0
  289. package/public/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  290. package/public/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  291. package/public/pdfjs/cmaps/78-H.bcmap +0 -0
  292. package/public/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  293. package/public/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  294. package/public/pdfjs/cmaps/78-V.bcmap +0 -0
  295. package/public/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  296. package/public/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  297. package/public/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  298. package/public/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  299. package/public/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  300. package/public/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  301. package/public/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  302. package/public/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  303. package/public/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  304. package/public/pdfjs/cmaps/Add-H.bcmap +0 -0
  305. package/public/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  306. package/public/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  307. package/public/pdfjs/cmaps/Add-V.bcmap +0 -0
  308. package/public/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  309. package/public/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  310. package/public/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  311. package/public/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  312. package/public/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  313. package/public/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  314. package/public/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  315. package/public/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  316. package/public/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  317. package/public/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  318. package/public/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  319. package/public/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  320. package/public/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  321. package/public/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  322. package/public/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  323. package/public/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  324. package/public/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  325. package/public/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  326. package/public/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  327. package/public/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  328. package/public/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  329. package/public/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  330. package/public/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  331. package/public/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  332. package/public/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  333. package/public/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  334. package/public/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  335. package/public/pdfjs/cmaps/B5-H.bcmap +0 -0
  336. package/public/pdfjs/cmaps/B5-V.bcmap +0 -0
  337. package/public/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  338. package/public/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  339. package/public/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  340. package/public/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  341. package/public/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  342. package/public/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  343. package/public/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  344. package/public/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  345. package/public/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  346. package/public/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  347. package/public/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  348. package/public/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  349. package/public/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  350. package/public/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  351. package/public/pdfjs/cmaps/EUC-H.bcmap +0 -0
  352. package/public/pdfjs/cmaps/EUC-V.bcmap +0 -0
  353. package/public/pdfjs/cmaps/Ext-H.bcmap +0 -0
  354. package/public/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  355. package/public/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  356. package/public/pdfjs/cmaps/Ext-V.bcmap +0 -0
  357. package/public/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  358. package/public/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  359. package/public/pdfjs/cmaps/GB-H.bcmap +4 -0
  360. package/public/pdfjs/cmaps/GB-V.bcmap +0 -0
  361. package/public/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  362. package/public/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  363. package/public/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  364. package/public/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  365. package/public/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  366. package/public/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  367. package/public/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  368. package/public/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  369. package/public/pdfjs/cmaps/GBT-H.bcmap +0 -0
  370. package/public/pdfjs/cmaps/GBT-V.bcmap +0 -0
  371. package/public/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  372. package/public/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  373. package/public/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  374. package/public/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  375. package/public/pdfjs/cmaps/H.bcmap +0 -0
  376. package/public/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  377. package/public/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  378. package/public/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  379. package/public/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  380. package/public/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  381. package/public/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  382. package/public/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  383. package/public/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  384. package/public/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  385. package/public/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  386. package/public/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  387. package/public/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  388. package/public/pdfjs/cmaps/Hankaku.bcmap +0 -0
  389. package/public/pdfjs/cmaps/Hiragana.bcmap +0 -0
  390. package/public/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  391. package/public/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  392. package/public/pdfjs/cmaps/KSC-H.bcmap +0 -0
  393. package/public/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  394. package/public/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  395. package/public/pdfjs/cmaps/KSC-V.bcmap +0 -0
  396. package/public/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  397. package/public/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  398. package/public/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  399. package/public/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  400. package/public/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  401. package/public/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  402. package/public/pdfjs/cmaps/Katakana.bcmap +0 -0
  403. package/public/pdfjs/cmaps/LICENSE +36 -0
  404. package/public/pdfjs/cmaps/NWP-H.bcmap +0 -0
  405. package/public/pdfjs/cmaps/NWP-V.bcmap +0 -0
  406. package/public/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  407. package/public/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  408. package/public/pdfjs/cmaps/Roman.bcmap +0 -0
  409. package/public/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  410. package/public/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  411. package/public/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  412. package/public/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  413. package/public/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  414. package/public/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  415. package/public/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  416. package/public/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  417. package/public/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  418. package/public/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  419. package/public/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  420. package/public/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  421. package/public/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  422. package/public/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  423. package/public/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  424. package/public/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  425. package/public/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  426. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  427. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  428. package/public/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  429. package/public/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  430. package/public/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  431. package/public/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  432. package/public/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  433. package/public/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  434. package/public/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  435. package/public/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  436. package/public/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  437. package/public/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  438. package/public/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  439. package/public/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  440. package/public/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  441. package/public/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  442. package/public/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  443. package/public/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  444. package/public/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  445. package/public/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  446. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  447. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  448. package/public/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  449. package/public/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  450. package/public/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  451. package/public/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  452. package/public/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  453. package/public/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  454. package/public/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  455. package/public/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  456. package/public/pdfjs/cmaps/V.bcmap +0 -0
  457. package/public/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  458. package/public/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  459. package/public/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  460. package/public/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  461. package/public/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  462. package/public/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  463. package/public/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  464. package/public/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  465. package/public/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  466. package/public/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  467. package/public/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  468. package/public/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  469. package/public/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  470. package/public/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  471. package/public/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  472. package/public/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  473. package/public/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  474. package/.next/server/chunks/[root-of-the-server]__04w57bdna9ax0._.js +0 -3
  475. package/.next/server/chunks/[root-of-the-server]__0fdkyswheen4o._.js +0 -3
  476. package/.next/server/chunks/[root-of-the-server]__0ig1r6paxqzt0._.js +0 -3
  477. package/.next/server/chunks/[root-of-the-server]__0j7ua4rsijb4c._.js +0 -3
  478. package/.next/server/chunks/[root-of-the-server]__0l7jho_lr2z5g._.js +0 -3
  479. package/.next/server/chunks/[root-of-the-server]__0rspref34j958._.js +0 -3
  480. package/.next/server/chunks/[root-of-the-server]__0vf3rgatj1f3u._.js +0 -3
  481. package/.next/server/chunks/[root-of-the-server]__0x8ehtaj_x2pf._.js +0 -3
  482. package/.next/server/chunks/[root-of-the-server]__120o1w9mcwgta._.js +0 -3
  483. package/.next/server/chunks/[root-of-the-server]__14n0eki4tdk02._.js +0 -3
  484. package/.next/server/chunks/[root-of-the-server]__15a3t94ps7jx2._.js +0 -3
  485. package/.next/server/chunks/[root-of-the-server]__1d6ftxzea6h0a._.js +0 -3
  486. package/.next/server/chunks/[root-of-the-server]__1e81i8l09skcp._.js +0 -3
  487. package/.next/server/chunks/[root-of-the-server]__1f5_yaclxhuvj._.js +0 -3
  488. package/.next/server/chunks/[root-of-the-server]__1rxi33p9h8zrj._.js +0 -3
  489. package/.next/server/chunks/[root-of-the-server]__1xqcu4ft3d7id._.js +0 -3
  490. package/.next/server/chunks/[root-of-the-server]__1yaf9vp_o6cro._.js +0 -3
  491. package/.next/server/chunks/_055vhdh_7iydn._.js +0 -3
  492. package/.next/server/chunks/_1lesklvhr_pfq._.js +0 -3
  493. package/.next/server/chunks/src_lib_1d99xj4d-pofa._.js +0 -3
  494. package/.next/static/chunks/02lw0b8i38sj3.js +0 -6
  495. package/.next/static/chunks/0g1lk2opoyqly.js +0 -1
  496. package/.next/static/chunks/1fmrzsulv-ddd.js +0 -1
  497. package/.next/static/chunks/1uso50ewx5j8v.js +0 -1
  498. package/.next/static/chunks/1yg8trzska8uv.js +0 -1
  499. package/.next/static/chunks/21ghhv1twe4or.js +0 -12
  500. package/.next/static/chunks/28bc-wd48lcls.js +0 -1
  501. package/.next/static/chunks/37309r9ttt-oa.js +0 -1
  502. package/.next/static/chunks/438pvifm_o4g_.js +0 -1
  503. /package/.next/static/{isKicFguXFifPUwKaqFfK → Rh_2qSdtR7MzUEFCrjWo3}/_buildManifest.js +0 -0
  504. /package/.next/static/{isKicFguXFifPUwKaqFfK → Rh_2qSdtR7MzUEFCrjWo3}/_clientMiddlewareManifest.js +0 -0
  505. /package/.next/static/{isKicFguXFifPUwKaqFfK → Rh_2qSdtR7MzUEFCrjWo3}/_ssgManifest.js +0 -0
@@ -1,6 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,952683,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(618566),i=e.i(518515),a=e.i(456420);let s={name:"file-up",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]};s.node;let o=(0,a.f)(s);var l=e.i(325597),u=e.i(328623),d=e.i(747819),c=e.i(866531),m=e.i(515288),f=e.i(519455),g=e.i(624687),h=e.i(110204),p=e.i(856522),x=e.i(632781),N=e.i(772382),y=e.i(7891),y=y,w=e.i(395925),b=e.i(111110),S=e.i(511445),v=e.i(574041),T=e.i(438465),E=e.i(674166),A=e.i(967489),k=e.i(597138),j=e.i(294114);function O({onSubmit:e,defaultNotebookId:n,defaultNotebookName:i,isSaving:a}){let{t:s}=(0,b.b)(),[o,u]=(0,r.useState)(null),[d,c]=(0,r.useState)(""),[I,_]=(0,r.useState)(""),[P,$]=(0,r.useState)(""),[C,M]=(0,r.useState)(""),[L,D]=(0,r.useState)(""),[q,R]=(0,r.useState)("unknown"),[z,U]=(0,r.useState)([]),[F,G]=(0,r.useState)(n||""),[B,V]=(0,r.useState)(""),[H,W]=(0,r.useState)(""),Q=async()=>{if(d.trim()){if(!F)return void j.c.warning(s.editor.messages?.selectNotebook||"Please select a notebook");await e({questionText:d.trim(),answerText:I.trim(),analysis:P.trim(),wrongAnswerText:C.trim(),mistakeAnalysis:L.trim(),mistakeStatus:q,knowledgePoints:z,subjectId:F,gradeSemester:B||void 0,paperLevel:H||void 0})}},Y=e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),d.trim()&&F&&!a&&Q())},K=[{key:"question",label:s.editor?.question||"Question Text",value:d,setter:c,placeholder:s.directEntry.questionPlaceholder,minHeight:"min-h-[180px]",required:!0},{key:"answer",label:s.editor?.answer||"Answer",value:I,setter:_,placeholder:s.directEntry.answerPlaceholder,minHeight:"min-h-[120px]"},{key:"analysis",label:s.editor?.analysis||"Analysis / Explanation",value:P,setter:$,placeholder:s.directEntry.analysisPlaceholder,minHeight:"min-h-[150px]"},{key:"wrongAnswer",label:s.editor?.wrongAnswerText||"Wrong Answer / Work",value:C,setter:M,placeholder:s.directEntry.wrongAnswerPlaceholder,minHeight:"min-h-[100px]"},{key:"mistakeAnalysis",label:s.editor?.mistakeAnalysis||"Mistake Cause Analysis",value:L,setter:D,placeholder:s.directEntry.mistakeAnalysisPlaceholder,minHeight:"min-h-[100px]"}];return(0,t.jsx)(m.N,{className:"rounded-2xl",children:(0,t.jsxs)(m.O,{className:"p-6 space-y-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,t.jsx)(l.f,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:s.directEntry.title})]}),(0,t.jsxs)(f.f,{variant:"ghost",size:"sm",onClick:()=>{c(""),_(""),$(""),M(""),D(""),R("unknown"),U([]),V(""),W("")},disabled:a,className:"text-muted-foreground hover:text-destructive",children:[(0,t.jsx)(w.f,{className:"h-4 w-4 mr-1"}),s.directEntry.reset]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)(h.f,{children:[s.editor?.selectNotebook||"Select Notebook"," *"]}),(0,t.jsx)(T.f,{value:F,onChange:G})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(h.f,{children:s.editor?.gradeSemester||"Grade/Semester"}),(0,t.jsx)("input",{type:"text",value:B,onChange:e=>V(e.target.value),placeholder:s.directEntry.gradeSemesterPlaceholder,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(h.f,{children:s.editor?.paperLevel||"Paper Level"}),(0,t.jsx)(E.f,{value:H,onChange:W})]})]}),K.map(e=>(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)(h.f,{className:e.required?"text-primary font-semibold":"",children:[e.label," ",e.required&&"*"]}),(0,t.jsx)(f.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(o===e.key?null:e.key),disabled:!e.value,children:o===e.key?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(y.f,{className:"h-3 w-3 mr-1"}),s.directEntry.edit]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(N.f,{className:"h-3 w-3 mr-1"}),s.directEntry.preview]})})]}),o===e.key?(0,t.jsx)("div",{className:`rounded-md border bg-muted/30 p-4 ${e.minHeight} overflow-auto cursor-pointer`,onClick:()=>u(null),children:(0,t.jsx)(S.f,{content:e.value})}):(0,t.jsx)(g.f,{value:e.value,onChange:t=>e.setter(t.target.value),onKeyDown:Y,placeholder:e.placeholder,className:`${e.minHeight} font-mono text-sm resize-y`,disabled:a})]},e.key)),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(h.f,{children:s.editor?.mistakeStatus||"Attempt Status"}),(0,t.jsxs)(A.d,{value:q,onValueChange:e=>R(e),children:[(0,t.jsx)(A.P,{className:"w-[200px]",children:(0,t.jsx)(A.U,{})}),(0,t.jsxs)(A.r,{children:[(0,t.jsx)(A.T,{value:"not_attempted",children:s.editor?.mistakeStatuses?.notAttempted||"Not attempted"}),(0,t.jsx)(A.T,{value:"wrong_attempt",children:s.editor?.mistakeStatuses?.wrongAttempt||"Wrong attempt"}),(0,t.jsx)(A.T,{value:"unknown",children:s.editor?.mistakeStatuses?.unknown||"Unknown"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(h.f,{children:s.editor?.tags||"Knowledge Points (Press Enter to add)"}),(0,t.jsx)(v.f,{value:z,onChange:U,placeholder:s.editor?.tagsPlaceholder||"Enter knowledge tags, select from suggestions...",enterHint:s.editor?.createTagHint,subject:(0,k.f)(i||null)||void 0}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:s.editor?.tagsHint||"💡 Tag suggestions will appear as you type"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 pt-2",children:[(0,t.jsx)(f.f,{onClick:Q,disabled:!d.trim()||!F||a,className:"w-full bg-gradient-to-r from-indigo-600 to-violet-500 hover:from-indigo-700 hover:to-violet-600 text-white font-medium",size:"lg",children:a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),s.directEntry.saving]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.f,{className:"mr-2 h-4 w-4"}),s.directEntry.save]})}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground text-center",children:s.directEntry.hint})]})]})})}var I=e.i(226091);function _({fileName:e,done:r,total:n}){let{t:i}=(0,b.b)();return(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 py-10 text-center",role:"status",children:[(0,t.jsx)(x.f,{className:"h-8 w-8 animate-spin text-primary"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i.fileImport.processingImages.replace("{name}",e).replace("{done}",String(r)).replace("{total}",String(n))})]})}function P({textKey:e,fileName:r,batchCount:n,rendered:i,total:a}){let s,{t:o}=(0,b.b)();return s="parsing"===e?o.fileImport.parsing.replace("{name}",r??""):"creating"===e?o.fileImport.creating.replace("{count}",String(n??0)):"rendering-pdf"===e?o.fileImport.pdfRendering.replace("{done}",String(i??0)).replace("{total}",String(a??0)):o.fileImport.pdfCreatingBatches.replace("{done}",String(i??0)).replace("{total}",String(a??0)),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 py-10 text-center",role:"status",children:[(0,t.jsx)(x.f,{className:"h-8 w-8 animate-spin text-primary"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s})]})}let $={name:"file-spreadsheet",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]};$.node;let C=(0,a.f)($);var M=e.i(725981),L=e.i(310115),D=e.i(201276),q=e.i(303163),R=e.i(651304),z=e.i(407198);function U(e,t){let r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.click(),URL.revokeObjectURL(r)}function F({onFile:e}){let{t:r}=(0,b.b)(),n=R.b.map(e=>e.extensions.join(" / ")).join("、"),i=async()=>{try{let e=await (0,z.n)();U(e,"question-template.xlsx")}catch(e){D.V.error("[FileImport]","Build xlsx template failed",{error:(0,q.Z)(e)}),j.c.error(r.fileImport.templateFailed)}};return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"rounded-xl border border-dashed p-6 text-center",children:[(0,t.jsx)(M.f,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground"}),(0,t.jsx)("p",{className:"mb-1 text-sm font-medium",children:r.fileImport.pickHint}),(0,t.jsx)("p",{className:"mb-4 text-xs text-muted-foreground",children:r.fileImport.supportedFormats.replace("{formats}",n)}),(0,t.jsx)(L.f,{types:R.b,onFile:e})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:r.fileImport.templates}),(0,t.jsxs)("button",{type:"button",onClick:()=>void i(),className:"inline-flex items-center gap-1 underline hover:text-foreground",children:[(0,t.jsx)(C,{className:"h-3.5 w-3.5"}),r.fileImport.xlsxTemplate]}),(0,t.jsxs)("button",{type:"button",onClick:()=>{U(new Blob([(0,z.j)()],{type:"text/csv;charset=utf-8"}),"question-template.csv")},className:"inline-flex items-center gap-1 underline hover:text-foreground",children:[(0,t.jsx)(I.f,{className:"h-3.5 w-3.5"}),r.fileImport.csvTemplate]})]})]})}function G({fileName:e,summary:r,notebookId:n,onNotebookChange:i,onConfirm:a,onReset:s}){let{t:o}=(0,b.b)();return(0,t.jsxs)("div",{className:"space-y-4","data-testid":"file-import-summary",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e}),(0,t.jsx)(f.f,{variant:"ghost",size:"sm",onClick:s,children:o.fileImport.repick})]}),(0,t.jsx)("p",{className:"text-sm",children:o.fileImport.totalQuestions.replace("{count}",String(r.total))}),r.errorCount>0&&(0,t.jsxs)("div",{className:"rounded-lg bg-destructive/10 p-3 text-sm text-destructive",role:"alert",children:[(0,t.jsx)("p",{className:"font-medium",children:o.fileImport.errorsFound.replace("{count}",String(r.errorCount))}),(0,t.jsx)("ul",{className:"mt-1 list-inside list-disc space-y-0.5",children:r.errors.map((e,r)=>(0,t.jsx)("li",{children:e.index>=0?o.fileImport.errorItem.replace("{index}",String(e.index+1)).replace("{message}",e.message):e.message},r))})]}),r.warnings.length>0&&(0,t.jsx)("div",{className:"rounded-lg bg-amber-500/10 p-3 text-sm text-amber-700 dark:text-amber-300",children:(0,t.jsx)("ul",{className:"list-inside list-disc space-y-0.5",children:r.warnings.map((e,r)=>(0,t.jsx)("li",{children:e},r))})}),r.ignoredFieldTexts.length>0&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:o.fileImport.ignoredFields.replace("{fields}",r.ignoredFieldTexts.join("、"))}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",htmlFor:"file-import-notebook",children:o.fileImport.targetNotebook}),(0,t.jsx)(T.f,{value:n,onChange:i}),!n&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:o.fileImport.notebookRequired})]}),(0,t.jsx)(f.f,{onClick:a,disabled:!n||0===r.total,className:"w-full bg-gradient-to-r from-indigo-600 to-violet-500 font-medium text-white hover:from-indigo-700 hover:to-violet-600",size:"lg",children:o.fileImport.confirm.replace("{count}",String(r.total))})]})}let B={name:"file-exclamation-point",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["file-warning"]};B.node;let V=(0,a.f)(B);var H=e.i(213761);async function W(e,t){return new Promise((r,n)=>{e.toBlob(e=>{if(!e)return void n(Error("CANVAS_EMPTY"));let t=new FileReader;t.onload=()=>r(t.result),t.onerror=()=>n(t.error??Error("READ_FAILED")),t.readAsDataURL(e)},"image/jpeg",t)})}async function Q(e,t){let r=t.limits??H.K,n=[],i=t.pages.length,a=null,s=null;try{for(let o=0;o<i;o++){let l=t.pages[o],u=await e.getPage(l),d=u.getViewport({scale:1}),c=function(e,t,r=H.K){let n=function(e,t,r=H.K){return Math.min(1,r.maxLongEdge/Math.max(e,t),Math.sqrt(r.maxPixels/Math.max(1,e*t)))}(e,t,r);return{width:Math.max(1,Math.floor(e*n)),height:Math.max(1,Math.floor(t*n)),scale:n}}(d.width,d.height,r);if(!a||!s){let e=(a=document.createElement("canvas")).getContext("2d");if(!e)throw Error("CANVAS_UNSUPPORTED");s=e}a.width=c.width,a.height=c.height,s.fillStyle="#ffffff",s.fillRect(0,0,c.width,c.height);let m=u.getViewport({scale:c.scale});await u.render({canvasContext:s,viewport:m}).promise;let f=await W(a,r.startQuality);n.push({pageNumber:l,dataUrl:f,width:c.width,height:c.height,bytes:Math.floor(3*f.slice(f.indexOf(",")+1).length/4)}),a.width=0,a.height=0,t.onProgress?.(o+1,i)}}finally{a&&(a.width=0,a.height=0);try{await e.cleanup?.()}catch{}}return n}function Y({fileName:e,pageCount:n,notebookId:i,onNotebookChange:a,onConfirm:s,onReset:o}){let{t:l}=(0,b.b)(),[u,d]=(0,r.useState)(""),[c,m]=(0,r.useState)(null),[g,h]=(0,r.useState)(!1),p=async()=>{let e=function(e,t){let r=e.trim();if(!r)return{ok:!1,error:{kind:"empty",message:"页码范围不能为空"}};let n=new Set,i=r.split(/[,,、]/).map(e=>e.trim()).filter(Boolean);if(0===i.length)return{ok:!1,error:{kind:"empty",message:"页码范围不能为空"}};for(let e of i){let r=e.match(/^(\d+)(?:\s*-\s*(\d+))?$/);if(!r)return{ok:!1,error:{kind:"invalid",message:`无法识别的页码段「${e}」,请使用如 1-3,5 的写法`}};let i=Number.parseInt(r[1],10),a=void 0!==r[2]?Number.parseInt(r[2],10):i;if(i<1||a<1||i>t||a>t)return{ok:!1,error:{kind:"out_of_range",message:`页码超出范围(共 ${t} 页)`}};if(a<i)return{ok:!1,error:{kind:"invalid",message:`页码段「${e}」起始页不能大于结束页`}};for(let e=i;e<=a;e++)n.add(e)}let a=Array.from(n).sort((e,t)=>e-t);return 0===a.length?{ok:!1,error:{kind:"empty",message:"页码范围不能为空"}}:a.length>20?{ok:!1,error:{kind:"invalid",message:`单次最多转换 20 页,当前选择了 ${a.length} 页,请缩小范围`}}:{ok:!0,pages:a}}(u.trim()?u:`1-${n}`,n);if(!e.ok)return void m(l.fileImport.pdfPageRangeInvalid.replace("{message}",e.error.message));m(null),h(!0);try{await s(e.pages)}finally{h(!1)}};return(0,t.jsxs)("div",{className:"space-y-4","data-testid":"file-import-scanned-pdf",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e}),(0,t.jsx)(f.f,{variant:"ghost",size:"sm",onClick:o,children:l.fileImport.repick})]}),(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-lg bg-amber-500/10 p-3 text-sm text-amber-700 dark:text-amber-300",children:[(0,t.jsx)(V,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"font-medium",children:l.fileImport.pdfScannedTitle.replace("{count}",String(n))}),(0,t.jsx)("p",{children:l.fileImport.pdfScannedHint})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",htmlFor:"scanned-pdf-range",children:l.fileImport.pdfPageRangeLabel.replace("{max}",String(20))}),(0,t.jsx)("input",{id:"scanned-pdf-range",type:"text",inputMode:"text",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:l.fileImport.pdfPageRangePlaceholder,value:u,onChange:e=>{d(e.target.value),c&&m(null)}}),c&&(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:c})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",htmlFor:"scanned-pdf-notebook",children:l.fileImport.targetNotebook}),(0,t.jsx)(T.f,{value:i,onChange:a}),!i&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:l.fileImport.notebookRequired})]}),(0,t.jsx)(f.f,{onClick:()=>void p(),disabled:!i||g||0===n,className:"w-full bg-gradient-to-r from-indigo-600 to-violet-500 font-medium text-white hover:from-indigo-700 hover:to-violet-600",size:"lg",children:l.fileImport.pdfConfirm})]})}var K=e.i(411382),X=e.i(54105),Z=e.i(772325),J=e.i(978056),ee=e.i(722219),ee=ee,et=ee,er=ee,en=e.i(398019);let ei="wrong-notebook-questions",ea=en.K,es=K.z.object({dataUrl:X.z.string().regex(/^data:image\/(png|jpeg|webp);base64,/,"INVALID_IMAGE_DATA_URL").max(5242880,"IMAGE_TOO_LARGE"),alt:X.z.string().max(200).optional()}),eo=K.z.object({text:X.z.string().max(2e4),material:X.z.string().max(2e4).optional(),section:X.z.string().max(500).optional(),label:X.z.string().max(20).optional(),answer:X.z.string().max(2e4).optional(),analysis:X.z.string().max(5e4).optional(),knowledgePoints:Z.z.array(X.z.string().max(200)).max(100).optional(),difficultyStars:J.z.number().int().min(1).max(5).optional(),wrongAnswer:X.z.string().max(2e4).optional(),subject:X.z.string().max(100).optional(),gradeSemester:X.z.string().max(100).optional(),source:X.z.string().max(200).optional(),questionType:X.z.string().max(100).optional(),figureSvg:X.z.string().max(ea).optional(),images:Z.z.array(es).max(10).optional(),extensions:ee.record(X.z.string(),et.unknown()).optional()});K.z.object({format:er.literal(ei),version:er.literal(1),exportedAt:X.z.string().optional(),generator:X.z.string().max(200).optional(),questions:Z.z.array(eo).max(5e3)});let el="MISSING_FORMAT",eu="MISSING_VERSION",ed="INVALID_DIFFICULTY",ec="INVALID_QUESTION_SHAPE",em=/[、,,;;]/;function ef(e){if("string"!=typeof e)return;let t=e.trim();return t.length>0?t:void 0}function eg(e,t,r){if(void 0!==e&&e.length>t)return r}function eh(e){let t=[],r=[],n=null;if(Array.isArray(e))n=e,r.push(el,eu);else{if("object"!=typeof e||null===e||Array.isArray(e))return{questions:[],errors:[{index:-1,reason:ec}],warnings:r};{let t=e.format,i=e.version;void 0===t?r.push(el):t!==ei&&r.push("UNKNOWN_FORMAT"),void 0===i?r.push(eu):"number"==typeof i&&i>1&&r.push("UNSUPPORTED_VERSION");let a=e.questions;if(!Array.isArray(a))return{questions:[],errors:[{index:-1,reason:"QUESTIONS_REQUIRED"}],warnings:r};n=a}}let i=n;i.length>5e3&&(r.push("TOO_MANY_QUESTIONS"),i=i.slice(0,5e3));let a=[];return i.forEach((e,r)=>{let n=function(e){if("object"!=typeof e||null===e||Array.isArray(e))return{error:ec};let t="string"==typeof e.text?e.text.trim():"";if(!t)return{error:"TEXT_REQUIRED"};if(t.length>2e4)return{error:"TEXT_TOO_LONG"};let r=ef(e.material),n=eg(r,2e4,"MATERIAL_TOO_LONG");if(n)return{error:n};let i=ef(e.section),a=eg(i,500,"SECTION_TOO_LONG");if(a)return{error:a};let s=ef(e.label),o=eg(s,20,"LABEL_TOO_LONG");if(o)return{error:o};let l=ef(e.answer),u=eg(l,2e4,"ANSWER_TOO_LONG");if(u)return{error:u};let d=ef(e.analysis),c=eg(d,5e4,"ANALYSIS_TOO_LONG");if(c)return{error:c};let m=ef(e.wrongAnswer),f=eg(m,2e4,"WRONG_ANSWER_TOO_LONG");if(f)return{error:f};let g=ef(e.subject),h=eg(g,100,"SUBJECT_TOO_LONG");if(h)return{error:h};let p=ef(e.gradeSemester),x=eg(p,100,"GRADE_SEMESTER_TOO_LONG");if(x)return{error:x};let N=ef(e.source),y=eg(N,200,"SOURCE_TOO_LONG");if(y)return{error:y};let w=ef(e.questionType),b=eg(w,100,"QUESTION_TYPE_TOO_LONG");if(b)return{error:b};let S=ef(e.figureSvg),v=eg(S,ea,"FIGURE_SVG_TOO_LONG");if(v)return{error:v};let T=function(e){if(null==e)return{points:[]};let t=[];if("string"==typeof e){let r=e.trim();if(!r)return{points:[]};t.push(...r.split(em))}else{if(!Array.isArray(e))return{error:ec};t.push(...e)}let r=[];for(let e of t){if("string"!=typeof e)return{error:ec};let t=e.trim();if(t){if(t.length>200)return{error:"KNOWLEDGE_POINT_TOO_LONG"};r.push(t)}}return r.length>100?{error:"TOO_MANY_KNOWLEDGE_POINTS"}:{points:r}}(e.knowledgePoints);if("error"in T)return{error:T.error};let E=function(e){let t;if(null==e||""===e)return{stars:void 0};if("number"==typeof e)t=e;else{if("string"!=typeof e)return{error:ed};let r=e.trim();if(!r)return{stars:void 0};t=Number(r)}return!Number.isInteger(t)||t<1||t>5?{error:ed}:{stars:t}}(e.difficultyStars);if("error"in E)return{error:E.error};let A=function(e){if(null==e)return{images:[]};if(!Array.isArray(e))return{error:ec};if(e.length>10)return{error:"TOO_MANY_IMAGES"};let t=[];for(let r of e){if("object"!=typeof r||null===r)return{error:ec};let e=r.dataUrl;if("string"!=typeof e||!/^data:image\/(png|jpeg|webp);base64,/.test(e))return{error:"INVALID_IMAGE_DATA_URL"};if(e.length>5242880)return{error:"IMAGE_TOO_LARGE"};let n=ef(r.alt);t.push(void 0===n?{dataUrl:e}:{dataUrl:e,alt:n})}return{images:t}}(e.images);if("error"in A)return{error:A.error};let k="object"!=typeof e.extensions||null===e.extensions||Array.isArray(e.extensions)?void 0:e.extensions,j={text:t};return void 0!==r&&(j.material=r),void 0!==i&&(j.section=i),void 0!==s&&(j.label=s),void 0!==l&&(j.answer=l),void 0!==d&&(j.analysis=d),T.points.length>0&&(j.knowledgePoints=T.points),void 0!==E.stars&&(j.difficultyStars=E.stars),void 0!==m&&(j.wrongAnswer=m),void 0!==g&&(j.subject=g),void 0!==p&&(j.gradeSemester=p),void 0!==N&&(j.source=N),void 0!==w&&(j.questionType=w),void 0!==S&&(j.figureSvg=S),A.images.length>0&&(j.images=A.images),void 0!==k&&(j.extensions=k),{question:j}}(e);"error"in n?t.push({index:r,reason:n.error}):a.push(n.question)}),{questions:a,errors:t,warnings:r}}async function ep(e){let t,{text:r}=(0,R.n)(e);try{t=JSON.parse(r)}catch{return{questions:[],errors:[{index:-1,reason:"INVALID_JSON"}],warnings:[]}}return eh(t)}var ex=e.i(825624),eN=e.i(229969);let ey=[208,207,17,224];function ew(e){return new TextDecoder("utf-8").decode(e)}function eb(e){let t=new DOMParser().parseFromString(e,"application/xml");if(t.getElementsByTagName("parsererror")[0])throw Error("INVALID_DOCX");return t}let eS="http://schemas.openxmlformats.org/wordprocessingml/2006/main";class ev{abstractLevels=new Map;instances=new Map;styleLinks=new Map;counters=new Map;constructor(e,t){e&&(this.loadAbstractNums(e),this.loadNums(e)),t&&this.loadStyleLinks(t)}loadAbstractNums(e){for(let t of Array.from(e.getElementsByTagNameNS(eS,"abstractNum"))){let e=t.getAttributeNS(eS,"abstractNumId");if(!e)continue;let r=new Map;for(let e of Array.from(t.getElementsByTagNameNS(eS,"lvl"))){let t=Number(e.getAttributeNS(eS,"ilvl")??"");if(!Number.isInteger(t))continue;let n=e.getElementsByTagNameNS(eS,"numFmt")[0]?.getAttributeNS(eS,"val")??"decimal",i=e.getElementsByTagNameNS(eS,"lvlText")[0]?.getAttributeNS(eS,"val")??"%1.",a=Number(e.getElementsByTagNameNS(eS,"start")[0]?.getAttributeNS(eS,"val")??"1");r.set(t,{numFmt:n,lvlText:i,start:Number.isFinite(a)?a:1})}this.abstractLevels.set(e,r)}}loadNums(e){for(let t of Array.from(e.getElementsByTagNameNS(eS,"num"))){let e=t.getAttributeNS(eS,"numId"),r=t.getElementsByTagNameNS(eS,"abstractNumId")[0]?.getAttributeNS(eS,"val");if(!e||!r)continue;let n=new Map;for(let e of Array.from(t.getElementsByTagNameNS(eS,"lvlOverride"))){let t=Number(e.getAttributeNS(eS,"ilvl")??"");if(!Number.isInteger(t))continue;let r={},i=e.getElementsByTagNameNS(eS,"startOverride")[0]?.getAttributeNS(eS,"val");if(null!=i){let e=Number(i);Number.isFinite(e)&&(r.start=e)}let a=e.getElementsByTagNameNS(eS,"lvl")[0];if(a){let e=a.getElementsByTagNameNS(eS,"numFmt")[0]?.getAttributeNS(eS,"val");e&&(r.numFmt=e);let t=a.getElementsByTagNameNS(eS,"lvlText")[0]?.getAttributeNS(eS,"val");t&&(r.lvlText=t)}n.set(t,r)}this.instances.set(e,{abstractId:r,overrides:n})}}loadStyleLinks(e){for(let t of Array.from(e.getElementsByTagNameNS(eS,"style"))){let e=t.getAttributeNS(eS,"styleId");if(!e)continue;let r=t.getElementsByTagNameNS(eS,"numPr")[0];if(!r)continue;let n=r.getElementsByTagNameNS(eS,"numId")[0]?.getAttributeNS(eS,"val");n&&this.styleLinks.set(e,n)}}resolveNumPr(e){let t=e.getElementsByTagNameNS(eS,"pPr")[0];if(!t)return null;let r=t.getElementsByTagNameNS(eS,"numPr")[0],n=null,i=0;if(r){n=r.getElementsByTagNameNS(eS,"numId")[0]?.getAttributeNS(eS,"val")??null;let e=r.getElementsByTagNameNS(eS,"ilvl")[0]?.getAttributeNS(eS,"val");if(null!=e){let t=Number(e);Number.isInteger(t)&&t>=0&&(i=t)}}if(!n){let e=t.getElementsByTagNameNS(eS,"pStyle")[0]?.getAttributeNS(eS,"val");e&&(n=this.styleLinks.get(e)??null)}return n&&"0"!==n?[n,i]:null}getLevel(e,t){let r=this.instances.get(e);if(!r)return null;let n=this.abstractLevels.get(r.abstractId)?.get(t);if(!n)return null;let i=r.overrides.get(t);return i?{numFmt:i.numFmt??n.numFmt,lvlText:i.lvlText??n.lvlText,start:i.start??n.start}:n}resetDeeperLevels(e,t){for(let r of this.counters.keys()){let[n,i]=r.split(":");n===e&&Number(i)>t&&this.counters.delete(r)}}take(e,t,r){let n=`${e}:${t}`,i=this.counters.get(n);return void 0===i?(this.counters.set(n,r+1),r):(this.counters.set(n,i+1),i)}format(e,t){switch(e){case"chineseCounting":case"chineseCountingThousand":case"ideographTraditional":return function e(t){if(!Number.isFinite(t)||t<=0||t>9999)return String(t);let r="零一二三四五六七八九";if(t<10)return r[t];if(10===t)return"十";if(t<20)return`十${r[t%10]}`;if(t<100){let e=Math.floor(t/10),n=t%10;return`${r[e]}十${n?r[n]:""}`}if(t<1e3){let n=Math.floor(t/100),i=t%100;return 0===i?`${r[n]}百`:i<10?`${r[n]}百零${r[i]}`:`${r[n]}百${e(i)}`}let n=Math.floor(t/1e3),i=t%1e3;return 0===i?`${r[n]}千`:i<100?`${r[n]}千零${e(i)}`:`${r[n]}千${e(i)}`}(t);case"upperLetter":if(t<1||t>26)return String(t);return String.fromCharCode(64+t);case"lowerLetter":if(t<1||t>26)return String(t);return String.fromCharCode(96+t);case"upperRoman":return eE(t).toUpperCase();case"lowerRoman":return eE(t);case"decimalEnclosedCircle":if(t>=1&&t<=20)return String.fromCharCode(9312+t-1);return String(t);default:return String(t)}}paragraphNumber(e,t){let r=this.getLevel(e,t);if(!r)return null;this.resetDeeperLevels(e,t);let n=this.take(e,t,r.start);return"bullet"===r.numFmt?r.lvlText:r.lvlText.replace(/%(\d+)/g,(i,a)=>{let s=Number(a)-1;if(s===t)return this.format(r.numFmt,n);let o=this.getLevel(e,s);if(!o)return"";let l=this.counters.get(`${e}:${s}`)??o.start;return this.format(o.numFmt,l-1)})}}let eT=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]];function eE(e){if(!Number.isFinite(e)||e<=0||e>=4e3)return String(e);let t=e,r="";for(let[e,n]of eT)for(;t>=e;)r+=n,t-=e;return r}let eA=[{prefix:"wingdings",table:{61472:"□",61473:"■",61474:"▲",61475:"▼",61476:"◆",61477:"●",61478:"○",61480:"▲",61481:"▼",61482:"◆",61483:"●",61484:"○",61486:"□",61488:"→",61489:"←",61490:"↑",61491:"↓",61492:"↔",61493:"↕",61494:"▶",61495:"◀",61496:"▲",61497:"▼",61498:"■",61499:"□",61500:"●",61501:"○",61502:"◆",61503:"◇",61504:"☆",61505:"★",61506:"♥",61507:"♦",61508:"♣",61509:"♠",61516:"✓",61517:"✗",61522:"•",61532:"○",61533:"●",61550:"√",61601:"•",61602:"◦",61603:"▪",61604:"–",61605:"—",61607:"⁃",61623:"•",61656:"➔",61692:"✓"}},{prefix:"symbol",table:{97:"α",98:"β",103:"γ",100:"δ",101:"ε",122:"ζ",104:"η",113:"θ",105:"ι",107:"κ",108:"λ",109:"μ",110:"ν",120:"ξ",112:"π",114:"ρ",115:"σ",116:"τ",117:"υ",102:"φ",99:"χ",121:"ψ",119:"ω",65:"Α",66:"Β",71:"Γ",68:"Δ",69:"Ε",90:"Ζ",72:"Η",81:"Θ",73:"Ι",75:"Κ",76:"Λ",77:"Μ",78:"Ν",88:"Ξ",80:"Π",82:"Ρ",83:"Σ",84:"Τ",85:"Υ",70:"Φ",67:"Χ",89:"Ψ",87:"Ω",180:"×",181:"÷",177:"±",178:"·",179:"∙",182:"∂",184:"≠",187:"≤",188:"≥",190:"≈",191:"≡",194:"∈",197:"∉",198:"∋",201:"∅",206:"∩",207:"∪",210:"⊂",211:"⊃",212:"⊄",213:"⊆",214:"⊇",219:"∧",220:"∨",221:"¬",222:"⇒",223:"⇔",224:"∀",225:"∃",226:"∄",227:"∅",228:"∆",229:"∇",230:"∏",231:"∑",232:"−",233:"∗",234:"√",235:"∞",236:"∠",237:"∥",238:"∧",239:"∨",240:"∩",241:"∪",242:"∫",243:"∬",244:"∴",245:"∵",246:"∶",247:"∷",248:"⊥",249:"∟",250:"⌒",251:"⊙",252:"○",253:"●",254:"□",255:"■"}}],ek="http://schemas.openxmlformats.org/wordprocessingml/2006/main",ej="http://schemas.openxmlformats.org/officeDocument/2006/math",eO="[图片]",eI="[公式]";function e_(e){return e.replace(/ /g," ")}function eP(e,t){let r=e.trim();return/^-?\d+(\.\d+)?$/.test(r)?`${t}${r}`:`${t}{${r}}`}function e$(e,t,r){return e.nodeType===e.ELEMENT_NODE&&e.localName===r&&e.namespaceURI===t}function eC(e){let t=e.getAttributeNS(ek,"val");if(null===t)return!0;let r=t.trim().toLowerCase();return"0"!==r&&"false"!==r&&"off"!==r}function eM(e){for(let t of Array.from(e.getElementsByTagName("*"))){let e=t.getAttribute("ProgID");if(e&&/Equation/i.test(e))return!0}return!1}function eL(e,t={},r={relationships:{},files:{}}){let n=[];return!function e(t,r,n){for(let i of Array.from(t.childNodes))if(i.nodeType===i.ELEMENT_NODE)if(e$(i,ek,"ins"))e(i,r,n);else{if(e$(i,ek,"del"))continue;e$(i,ek,"r")?n.push(function(e,t){let r=e.getElementsByTagNameNS(ek,"rPr")[0]??null,n={...t,skip:!1,vertAlign:"baseline"};if(!function(e,t){if(!e)return;let r=e.getElementsByTagNameNS(ek,"strike")[0];r&&eC(r)&&(t.skip=!0);let n=e.getElementsByTagNameNS(ek,"dstrike")[0];n&&eC(n)&&(t.skip=!0);let i=e.getElementsByTagNameNS(ek,"vanish")[0];i&&eC(i)&&(t.skip=!0);let a=e.getElementsByTagNameNS(ek,"vertAlign")[0];if(a){let e=a.getAttributeNS(ek,"val")??"";"superscript"===e?t.vertAlign="superscript":"subscript"===e&&(t.vertAlign="subscript")}}(r,n),n.skip)return"";let i=[];for(let t of Array.from(e.childNodes))t.nodeType!==t.TEXT_NODE&&e$(t,ek,"t")&&i.push(t.textContent??"");let a="";for(let r of Array.from(e.childNodes))if(e$(r,ek,"tab"))a+=" ";else if(e$(r,ek,"br")||e$(r,ek,"cr"))a+="\n";else if(e$(r,ek,"noBreakHyphen"))a+="‑";else if(e$(r,ek,"softHyphen"))a+="­";else if(e$(r,ek,"sym")){let e=r.getAttributeNS(ek,"font")??"",t=parseInt((r.getAttributeNS(ek,"char")??"").replace(/^0x/i,""),16);a+=Number.isFinite(t)?function(e,t){let r=e.trim().toLowerCase();for(let{prefix:e,table:n}of eA){if(!r.startsWith(e))continue;let i=n[t];if(void 0!==i)return i}return"[符号]"}(e,t):"[符号]"}else e$(r,ek,"drawing")||e$(r,ek,"pict")?(e$(r,ek,"pict")&&eM(r)&&t.docxContext.mathCollector&&(t.docxContext.mathCollector.oleCount+=1),a+=t.handlers.image?.(r,t.docxContext)??eO):(e$(r,ej,"oMath")||e$(r,ej,"oMathPara"))&&(a+=t.handlers.math?.(r,t.docxContext)??eI);if(0===i.length)return e_(a);let s=e_(i.join("")+a);return"superscript"===n.vertAlign?s=eP(s,"^"):"subscript"===n.vertAlign&&(s=eP(s,"_")),s}(i,r)):e$(i,ej,"oMath")||e$(i,ej,"oMathPara")?n.push(r.handlers.math?.(i,r.docxContext)??eI):e$(i,ek,"hyperlink")||e$(i,ek,"smartTag")?e(i,r,n):e$(i,ek,"pict")||e$(i,ek,"drawing")?(e$(i,ek,"pict")&&eM(i)&&r.docxContext.mathCollector&&(r.docxContext.mathCollector.oleCount+=1),n.push(r.handlers.image?.(i,r.docxContext)??eO)):e(i,r,n)}}(e,{skip:!1,vertAlign:"baseline",handlers:t,docxContext:r},n),n.join("")}let eD="http://schemas.openxmlformats.org/officeDocument/2006/math";function eq(e,t){return e.nodeType===e.ELEMENT_NODE&&e.localName===t&&e.namespaceURI===eD}function eR(e,t){return e.getAttributeNS(eD,t)??e.getAttribute(t)??e.getAttribute(`m:${t}`)}function ez(e,t){if(!e)return null;let r=eR(e,t);if(null!==r)return r;let n=eF(e,t);return n?eR(n,"val"):null}function eU(e){return e.textContent??""}function eF(e,t){for(let r of Array.from(e.children))if(eq(r,t))return r;return null}function eG(e,t){return Array.from(e.children).filter(e=>eq(e,t))}let eB={"\\":"\\backslash ","~":"\\sim ","^":"\\hat{\\ }"};function eV(e){return e.replace(/[#$%&_{}\\~^]/g,e=>eB[e]??`\\${e}`)}let eH={"×":"\\times","÷":"\\div","≤":"\\le","≥":"\\ge","≠":"\\ne","≈":"\\approx","≡":"\\equiv","±":"\\pm","∓":"\\mp","∝":"\\propto","∞":"\\infty",π:"\\pi","∠":"\\angle","△":"\\triangle","□":"\\square","⊥":"\\perp","∥":"\\parallel","°":"^\\circ","√":"\\sqrt{}","∴":"\\therefore","∵":"\\because","∈":"\\in","∉":"\\notin","∪":"\\cup","∩":"\\cap","⊂":"\\subset","⊆":"\\subseteq","⊃":"\\supset","∀":"\\forall","∃":"\\exists","∑":"\\sum","∏":"\\prod","∫":"\\int","∬":"\\iint","∮":"\\oint","→":"\\to","←":"\\leftarrow","↔":"\\leftrightarrow","⇒":"\\Rightarrow","⇔":"\\Leftrightarrow","⋅":"\\cdot","⊙":"\\odot","⊗":"\\otimes","∂":"\\partial","∇":"\\nabla",ℓ:"\\ell",ℏ:"\\hbar","′":"'","″":"''"},eW={α:"\\alpha",β:"\\beta",γ:"\\gamma",δ:"\\delta",ε:"\\varepsilon",ζ:"\\zeta",η:"\\eta",θ:"\\theta",ι:"\\iota",κ:"\\kappa",λ:"\\lambda",μ:"\\mu",ν:"\\nu",ξ:"\\xi",π:"\\pi",ρ:"\\rho",σ:"\\sigma",τ:"\\tau",υ:"\\upsilon",φ:"\\varphi",χ:"\\chi",ψ:"\\psi",ω:"\\omega",Α:"A",Β:"B",Γ:"\\Gamma",Δ:"\\Delta",Ε:"E",Ζ:"Z",Η:"H",Θ:"\\Theta",Ι:"I",Κ:"K",Λ:"\\Lambda",Μ:"M",Ν:"N",Ξ:"\\Xi",Ο:"O",Π:"\\Pi",Ρ:"P",Σ:"\\Sigma",Τ:"T",Υ:"Y",Φ:"\\Phi",Χ:"X",Ψ:"\\Psi",Ω:"\\Omega"},eQ={"̂":"\\hat","^":"\\hat",ˇ:"\\check","˘":"\\breve","¯":"\\bar","‾":"\\overline","˙":"\\dot","¨":"\\ddot","⃛":"\\dddot","⃗":"\\vec","˜":"\\tilde","→":"\\vec","´":"\\acute","`":"\\grave"},eY={"∑":"\\sum","∏":"\\prod","∐":"\\coprod","∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨂":"\\bigotimes","⨁":"\\bigoplus"},eK={sin:"\\sin",cos:"\\cos",tan:"\\tan",cot:"\\cot",sec:"\\sec",csc:"\\csc",arcsin:"\\arcsin",arccos:"\\arccos",arctan:"\\arctan",sinh:"\\sinh",cosh:"\\cosh",tanh:"\\tanh",log:"\\log",ln:"\\ln",lg:"\\lg",lim:"\\lim",max:"\\max",min:"\\min",sup:"\\sup",inf:"\\inf",det:"\\det",exp:"\\exp",deg:"\\deg",gcd:"\\gcd"};function eX(e){let t=e.trim();return 1===t.length?t:/^\\[a-zA-Z]+$/.test(t)?` ${t} `:`{${t}}`}function eZ(e){let t="";for(let r of e)r in eW?t+=eW[r]:r in eH?t+=eH[r]:t+=eV(r);return t}function eJ(e,t){let r=[];for(let n of Array.from(e.children))r.push(e2(n,t));return r.join("")}function e0(e,t,r){let n=eF(e,"e"),i=eF(e,"sup"),a=eF(e,"sub"),s=n?eJ(n,t):"";if("sup"===r){let e=i?eJ(i,t):"";return`${s}^${eX(e)}`}if("sub"===r){let e=a?eJ(a,t):"";return`${s}_${eX(e)}`}let o=a?eJ(a,t):"",l=i?eJ(i,t):"";return`${s}_${eX(o)}^${eX(l)}`}function e1(e,t,r){let n=eF(e,"e"),i=eF(e,"lim"),a=n?eJ(n,t):"",s=eK[a.trim()]??a,o=i?eJ(i,t):"";return"low"===r?`${s}_{${o}}`:`${s}^{${o}}`}function e2(e,t){if(e.namespaceURI!==eD)return e.textContent??"";switch(e.localName){case"r":var r;let n="",i=null!==eF(e,"rPr")&&null!==eF(eF(e,"rPr"),"nor");for(let t of Array.from(e.childNodes))t.nodeType===t.ELEMENT_NODE&&(eq(t,"t")||"t"===t.localName&&t.namespaceURI!==eD?n+=eU(t):eq(t,"br")&&(n+=" "));let a=eZ(n);return i?`\\text{${n.replace(/\\/g,"\\\\").replace(/[#$%&_{}~^]/g,e=>`\\${e}`)}}`:a;case"t":return eZ(eU(e));case"f":let s,o,l,u,d;return s=ez(eF(e,"fPr"),"type")??"bar",o=eF(e,"num"),l=eF(e,"den"),u=o?eJ(o,t):"",d=l?eJ(l,t):"","lin"===s?`${u}/${d}`:"skw"===s?`${u}\\big/${d}`:"noBar"===s?`{${u} \\atop ${d}}`:`\\frac{${u}}{${d}}`;case"sSup":return e0(e,t,"sup");case"sSub":return e0(e,t,"sub");case"sSubSup":return e0(e,t,"subsup");case"sPre":let c,m,f;return c=eF(e,"e"),m=eF(e,"sup"),f=eF(e,"sub"),`${c?eJ(c,t):""}_${f?eX(eJ(f,t)):""}^{${m?eJ(m,t):""}}`;case"rad":let g=eF(e,"deg"),h=eF(e,"e"),p=h?eJ(h,t):"";if("1"===(ez(eF(e,"radPr"),"degHide")??eR(e,"degHide"))||!g||0===g.children.length)return`\\sqrt{${p}}`;let x=eJ(g,t);return`\\sqrt[${x}]{${p}}`;case"d":return function(e,t){var r;let n=eF(e,"dPr"),i=ez(n,"begChr")??"(",a=ez(n,"endChr")??")",s=eG(e,"e"),o=s.map(e=>Array.from(e.children).find(e=>eq(e,"eqArr"))).find(e=>void 0!==e);if(o&&"{"===i){let e=eG(o,"e").map(e=>eJ(e,t)).join(" \\\\ ");return`\\begin{cases} ${e} \\end{cases}`}let l=s.length>0?s.map(e=>eJ(e,t)).join(""):(r=Array.from(e.children).filter(e=>!eq(e,"dPr")),r.map(e=>e2(e,t)).join(""));return`${i}${l}${a}`}(e,t);case"nary":let N,y,w,b,S,v,T,E,A,k,j;return y=ez(N=eF(e,"naryPr"),"chr")??"∫",ez(N,"limLoc")??"undOvr",w=eY[y]??eZ(y),b=eF(e,"sub"),S=eF(e,"sup"),v=eF(e,"e"),T=ez(N,"subHide"),E=ez(N,"supHide"),A=b&&"1"!==T?eJ(b,t):"",k=S&&"1"!==E?eJ(S,t):"",j=v?eJ(v,t):"",`${w}${A?`_${eX(A)}`:""}${k?`^${eX(k)}`:""} ${j}`;case"func":return function(e,t){let r=eF(e,"fName"),n=eF(e,"e"),i="";if(r){let e=[];for(let t of Array.from(r.childNodes))if(t.nodeType===t.ELEMENT_NODE&&eq(t,"r"))for(let r of Array.from(t.getElementsByTagNameNS(eD,"t")))e.push(eU(r));i=e.join("")}let a=eK[i]??`\\operatorname{${eV(i)}}`,s=n?eJ(n,t):"";return`${a}${s?`{${s}}`:""}`}(e,t);case"limLow":return e1(e,t,"low");case"limUpp":return e1(e,t,"upp");case"acc":let O,I,_,P;return O=ez(eF(e,"accPr"),"chr")??"̂",_=(I=eF(e,"e"))?eJ(I,t):"",P=eQ[O]??"\\hat",`${P}{${_}}`;case"bar":let $,C,M;return $=ez(eF(e,"barPr"),"pos")??"top",M=(C=eF(e,"e"))?eJ(C,t):"","bot"===$?`\\underline{${M}}`:`\\overline{${M}}`;case"groupChr":let L,D,q,R,z;return D=ez(L=eF(e,"groupChrPr"),"chr")??"⏞",q=ez(L,"pos")??"top",z=(R=eF(e,"e"))?eJ(R,t):"",`${"⏟"===D||"bot"===q?"\\underbrace":"\\overbrace"}{${z}}`;case"eqArr":let U;return U=eG(e,"e").map(e=>eJ(e,t)).join(" \\\\ "),`\\begin{aligned} ${U} \\end{aligned}`;case"m":let F=[];for(let r of eG(e,"mr")){let e=eG(r,"e");F.push(e.map(e=>eJ(e,t)).join(" & "))}if(0===F.length){let r=eG(e,"e");r.length>0&&F.push(r.map(e=>eJ(e,t)).join(" & "))}return`\\begin{matrix} ${F.join(" \\\\ ")} \\end{matrix}`;case"box":case"borderBox":{let r=eF(e,"e");return r?eJ(r,t):""}case"e":case"oMath":case"oMathPara":return eJ(e,t);case"sty":case"scr":case"rPr":case"ctrlPr":case"dPr":case"naryPr":case"accPr":case"barPr":case"groupChrPr":case"fPr":case"radPr":case"sSupPr":case"sSubPr":case"sSubSupPr":case"sPrePr":case"limLowPr":case"limUppPr":case"mPr":case"mr":case"nor":return"";default:return r=e.localName,t.unsupportedSet.has(r)||(t.unsupportedSet.add(r),t.unsupported.push(r)),eJ(e,t)}}let e4="http://schemas.openxmlformats.org/wordprocessingml/2006/main",e5={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp"},e6=new Set(["emf","wmf","tiff","tif","svg","ico","pcx","tga"]);function e8(e){let t={text:e.text};e.material&&(t.material=e.material),e.section&&(t.section=e.section),e.label&&(t.label=e.label),e.answer&&(t.answer=e.answer),e.analysis&&(t.analysis=e.analysis),e.knowledgePoints?.length&&(t.knowledgePoints=e.knowledgePoints),null!==e.difficultyStars&&void 0!==e.difficultyStars&&(t.difficultyStars=e.difficultyStars),e.wrongAnswer&&(t.wrongAnswer=e.wrongAnswer),e.questionType&&(t.questionType=e.questionType);let r=e.images;return r?.length&&(t.images=r),t}async function e3(e,t={},r){var n;let i,a=new Uint8Array(e);if(!(a.length<ey.length)&&ey.every((e,t)=>a[t]===e))return{questions:[],errors:[{index:-1,reason:"LEGACY_DOC_NOT_SUPPORTED"}],warnings:[]};try{i=function(e){let t=function(e){let t=new Map;for(let[r,n]of Object.entries(e))t.set(r.toLowerCase(),n);return t}(function(e){let t;try{t=(0,eN.r)(e)}catch{throw Error("INVALID_DOCX")}return t}(e)),r=t.get("word/document.xml");if(!r)throw Error("INVALID_DOCX");let n=t.get("word/numbering.xml"),i=t.get("word/styles.xml");return{document:eb(ew(r)),numbering:n?eb(ew(n)):null,styles:i?eb(ew(i)):null,relationships:function(e){let t=e.get("word/_rels/document.xml.rels");if(!t)return{};let r=eb(ew(t)),n={};for(let e of Array.from(r.getElementsByTagNameNS("http://schemas.openxmlformats.org/package/2006/relationships","Relationship"))){let t=e.getAttribute("Id"),r=e.getAttribute("Target");t&&r&&(n[t]=r)}return n}(t),files:function(e){let t={};for(let[r,n]of e)t[r]=n;return t}(t)}}(a)}catch{return{questions:[],errors:[{index:-1,reason:"INVALID_DOCX"}],warnings:[]}}let s={unsupported:new Set,oleCount:0},o={images:[],unsupported:new Set},l=(e,t)=>{let r=function(e,t,r){let n=function(e){for(let t of Array.from(e.getElementsByTagNameNS("http://schemas.openxmlformats.org/drawingml/2006/main","blip"))){let e=t.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","embed");if(e)return e}for(let t of Array.from(e.getElementsByTagNameNS("urn:schemas-microsoft-com:vml","imagedata"))){let e=t.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships","id");if(e)return e}return null}(e);if(!n)return null;let i=t.relationships[n];if(!i)return null;let a=`word/${i}`.toLowerCase(),s=t.files[a];if(!s)return null;let o=a.split(".").pop()?.toLowerCase()??"";if(e6.has(o))return r.unsupported.add(o),null;let l=e5[o];if(!l)return r.unsupported.add(o||"unknown"),null;let u="";for(let e=0;e<s.length;e+=8192)u+=String.fromCharCode(...s.subarray(e,Math.min(e+8192,s.length)));let d=btoa(u);return`data:${l};base64,${d}`}(e,t,o);if(null===r)return;let n=o.images.length;return o.images.push(r),`⟦IMG:${n}⟧`},u=t.image?(e,r)=>t.image(e,r)??l(e,r):l,d={math:e=>{let t,{latex:r,unsupported:n}=(t={unsupported:[],unsupportedSet:new Set},{latex:eq(e,"oMathPara")?function(e,t){let r=[];for(let n of Array.from(e.children))eq(n,"oMath")&&r.push(e2(n,t));return 0===r.length?eJ(e,t):r.join(" \\quad ")}(e,t):e2(e,t),unsupported:t.unsupported});for(let e of n)s.unsupported.add(e);let i=r.trim();return i?"oMathPara"===e.localName?`
2
- $$
3
- ${i}
4
- $$
5
- `:`$${i}$`:eI},...t,image:u},c={relationships:i.relationships,files:i.files,mathCollector:s},m=new ev(i.numbering,i.styles),f=(function(e,t,r,n){let i=e.getElementsByTagNameNS(e4,"body")[0];if(!i)return[];let a=[],s=e=>{for(let i of Array.from(e.childNodes))if(i.nodeType===i.ELEMENT_NODE&&i.namespaceURI===e4)if("p"===i.localName){let e=eL(i,r,n),s=t.resolveNumPr(i),o=s?t.paragraphNumber(s[0],s[1]):null,l=o?.trim()??"",u=/[.、.。::)))]\s*$/.test(l),d=l?u?l:`${l} `:"";a.push(`${d}${e}`)}else if("tbl"===i.localName)for(let e of Array.from(i.getElementsByTagNameNS(e4,"tr"))){let t=function e(t,r={},n={relationships:{},files:{}}){let i=[];for(let a of Array.from(t.childNodes))a.nodeType===a.ELEMENT_NODE&&e$(a,ek,"tc")&&i.push((function(t,r={},n={relationships:{},files:{}}){let i=[];for(let a of Array.from(t.childNodes))if(a.nodeType===a.ELEMENT_NODE){if(e$(a,ek,"p")){let e=eL(a,r,n);e.trim()&&i.push(e)}else if(e$(a,ek,"tbl"))for(let t of function(t,r={},n={relationships:{},files:{}}){let i=[];for(let a of Array.from(t.childNodes))a.nodeType===a.ELEMENT_NODE&&e$(a,ek,"tr")&&i.push(e(a,r,n));return i}(a,r,n))t.trim()&&i.push(t)}return i.join(" ")})(a,r,n).trim());return i.join(" ")}(e,r,n);t.trim()&&a.push(t)}else"sdt"===i.localName&&s(i)};return s(i),a})(i.document,m,d,c).join("\n"),g=(0,ex.J)(f,r),h=[];if(g.ignored.length>0&&h.push((n=g.ignored.length,`IGNORED_PARAGRAPHS:${n}`)),g.detected||1!==g.questions.length||h.push("SINGLE_QUESTION"),s.unsupported.size>0){let e=Array.from(s.unsupported).slice(0,10).join(",");h.push(`MATH_UNSUPPORTED:${e}`)}if(s.oleCount>0&&h.push(`OLE_EQUATION:${s.oleCount}`),o.unsupported.size>0){let e=Array.from(o.unsupported).slice(0,10).join(",");h.push(`IMAGE_UNSUPPORTED:${e}`)}let p=eh(g.questions.map(e=>{var t;let r,n,i,a;return t=o.images,r=[e.text,e.material,e.answer,e.analysis],n=[],i=r.map(e=>{let r;if(!e)return e;let{text:i,usedIndexes:a}=(r=[],{text:e.replace(/⟦IMG:(\d+)⟧/g,(e,n)=>{let i=parseInt(n,10);return i>=0&&i<t.length&&!r.includes(i)&&r.push(i),"[图片]"}),usedIndexes:r});return n.push(...a),i}),a=Array.from(new Set(n)).sort((e,t)=>e-t).filter(e=>e<t.length).map(e=>({dataUrl:t[e]})),{...e,text:i[0]??e.text,material:i[1]??e.material,answer:i[2]??e.answer,analysis:i[3]??e.analysis,...a.length>0?{images:a}:{}}}).map(e8));return{questions:p.questions,errors:p.errors,warnings:[...h,...p.warnings]}}let e7="option_",e9=["A","B","C","D","E","F"],te={题干:"text",题目:"text",题目内容:"text",题目文本:"text",question:"text",text:"text",stem:"text",材料:"material",阅读材料:"material",material:"material",大题:"section",题型分组:"section",section:"section",题号:"label",序号:"label",no:"label",label:"label",number:"label",答案:"answer",参考答案:"answer",正确答案:"answer",answer:"answer",解析:"analysis",答案解析:"analysis",分析:"analysis",详解:"analysis",analysis:"analysis",explanation:"analysis",知识点:"knowledgePoints",考点:"knowledgePoints",knowledge:"knowledgePoints",knowledgepoints:"knowledgePoints",tags:"knowledgePoints",难度:"difficultyStars",难度星级:"difficultyStars",difficulty:"difficultyStars",difficultystars:"difficultyStars",错答:"wrongAnswer",我的答案:"wrongAnswer",学生答案:"wrongAnswer",wronganswer:"wrongAnswer",学科:"subject",科目:"subject",subject:"subject",年级:"gradeSemester",年级学期:"gradeSemester",grade:"gradeSemester",gradesemester:"gradeSemester",来源:"source",出处:"source",source:"source",题型:"questionType",type:"questionType",questiontype:"questionType"};function tt(e){return null==e?"":"string"==typeof e?e:"number"==typeof e?(Number.isInteger(e),String(e)):"boolean"==typeof e?e?"TRUE":"FALSE":e instanceof Date?e.toISOString().slice(0,10):String(e)}function tr(e,t,r){for(let n=0;n<e.length;n++)if(e[n].field===r)return tt(t[n]).trim();return""}function tn(e,t){let r=[],n=[];if(!e||0===e.length)return{questions:[],errors:[{index:-1,reason:"EMPTY_TABLE"}],warnings:r};let i=-1,a=null,s=Math.min(5,e.length);for(let t=0;t<s;t++){let r=function(e){let t=[],r=!1;for(let n of e){let e=String(n),i=function(e){let t=e.trim().toLowerCase();return(t=(t=t.replace(/[ ]/g,"")).replace(/[A-Za-z0-9]/g,e=>{let t=e.charCodeAt(0);return t>=65281&&t<=65374?String.fromCharCode(t-65248):e})).replace(/[\s ]+/g,"")}(e);if(!i)continue;let a=te[i];if(a){"text"===a&&(r=!0),t.push({field:a,rawName:e});continue}let s=function(e){let t=e.match(/^(?:选项|选择|choice|option)([a-f])$/);return t?e9.indexOf(t[1].toUpperCase()):/^[a-f]$/.test(e)?e9.indexOf(e.toUpperCase()):null}(i);if(null!==s&&s<6){t.push({field:`${e7}${s}`,rawName:e});continue}t.push({field:"unknown",rawName:e})}return r?t:null}(e[t].map(e=>tt(e)));if(r){i=t,a=r;break}}if(-1===i||!a)return{questions:[],errors:[{index:-1,reason:"TEXT_COLUMN_NOT_FOUND"}],warnings:r};for(let e of a.filter(e=>"unknown"===e.field))r.push(`UNKNOWN_COLUMN:${e.rawName}`);let o=-1;for(let e of a)"string"==typeof e.field&&e.field.startsWith(e7)&&(o=Math.max(o,Number(e.field.slice(e7.length))));let l=[];for(let r=i+1;r<e.length;r++){let s=e[r];if(s.every(e=>""===tt(e).trim()))continue;let o=tr(a,s,"text");if(!o){n.push({index:r-i-1,reason:`TEXT_REQUIRED:row=${r-i}`});continue}let u={text:o},d=tr(a,s,"material");d&&(u.material=d);let c=tr(a,s,"section");c?u.section=c:t&&(u.section=t);let m=tr(a,s,"label");m&&(u.label=m);let f=tr(a,s,"answer");f&&(u.answer=f);let g=tr(a,s,"analysis");g&&(u.analysis=g);let h=tr(a,s,"knowledgePoints");h&&(u.knowledgePoints=h.split(/[、,,;;]/).map(e=>e.trim()).filter(Boolean));let p=tr(a,s,"difficultyStars");if(p){let e=function(e){let t=e.trim();if(!t)return null;let r=t.match(/^([★☆]+)$/);if(r){let e=r[1].split("").filter(e=>"★"===e).length;return e>=1&&e<=5?e:null}let n=Number(t);if(!Number.isNaN(n))return n>=1&&n<=5&&Number.isInteger(n)?n:n>=0&&n<=1?n>=.8?1:n>=.6?2:n>=.4?3:n>=.2?4:5:null;return({易:1,较易:2,容易:1,中等:3,中:3,较难:4,难:5,困难:5})[t]??null}(p);null!==e&&(u.difficultyStars=e)}let x=tr(a,s,"wrongAnswer");x&&(u.wrongAnswer=x);let N=tr(a,s,"subject");N&&(u.subject=N);let y=tr(a,s,"gradeSemester");y&&(u.gradeSemester=y);let w=tr(a,s,"source");w&&(u.source=w);let b=tr(a,s,"questionType");b&&(u.questionType=b);let S=function(e,t){let r=[];for(let n=0;n<e.length;n++){let i=e[n].field;if("string"==typeof i&&i.startsWith(e7)){let e=Number(i.slice(e7.length)),a=tt(t[n]).trim();a&&(r[e]=a)}}return r.filter(e=>void 0!==e&&""!==e)}(a,s);if(S.length>0){let e=S.map((e,t)=>{let r=e9[t]??String(t+1);return`${r}.${e}`});u.text=`${o}
6
- ${e.join("\n")}`}l.push({raw:u,index:r-i-1})}let u=eh({format:ei,version:1,questions:l.map(e=>e.raw)}),d=[...n,...u.errors.map(e=>{let t=l[e.index];return{index:t?t.index:e.index,reason:e.reason}})].sort((e,t)=>e.index-t.index);return{questions:u.questions,errors:d,warnings:[...r,...u.warnings]}}async function ti(t){let{default:r}=await e.A(84955),n=await r(t),i=[],a=[],s=[],o=0;for(let e of n){let t=e.data;if(!t||0===t.length)continue;let r=t.some(e=>e.map(e=>String(e??"").trim().toLowerCase()).some(e=>{let t=e.replace(/[\s ]+/g,"");return"section"===t||"大题"===t||"题型分组"===t})),l=tn(t,n.length>1&&!r?e.sheet:void 0);for(let e of l.errors)a.push({index:-1===e.index?-1:e.index+o,reason:e.reason});s.push(...l.warnings.map(t=>`[${e.sheet}] ${t}`)),i.push(...l.questions),o+=l.questions.length}return{questions:i,errors:a,warnings:s}}let ta=/^[\s\-–—·..]*\d{1,4}[\s\-–—·..]*$/;function ts(e){return e.replace(/\uFB00/g,"ff").replace(/\uFB01/g,"fi").replace(/\uFB02/g,"fl").replace(/\uFB03/g,"ffi").replace(/\uFB04/g,"ffl").replace(/\u00A0/g," ").replace(/\u3000/g," ")}function to(e){let t=e.trim();if(!t)return null;if(ta.test(t))return{key:"",isPageNumberOnly:!0};let r=t.replace(/\d+/g,"").trim();return r?{key:r,isPageNumberOnly:!1}:null}function tl(e){if(!e)return!1;let t=e.charCodeAt(0);return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=12288&&t<=12351||t>=65280&&t<=65519}let tu=null;function td(){return tu||(tu=(async()=>{let t=await e.A(825834);return t.GlobalWorkerOptions.workerSrc=new e.U(e.r(979463)).toString(),t})()),tu}function tc(e){let t={text:e.text};return e.material&&(t.material=e.material),e.section&&(t.section=e.section),e.label&&(t.label=e.label),e.answer&&(t.answer=e.answer),e.analysis&&(t.analysis=e.analysis),e.knowledgePoints?.length&&(t.knowledgePoints=e.knowledgePoints),null!==e.difficultyStars&&void 0!==e.difficultyStars&&(t.difficultyStars=e.difficultyStars),e.wrongAnswer&&(t.wrongAnswer=e.wrongAnswer),e.questionType&&(t.questionType=e.questionType),t}async function tm(e,t={}){var r;let n,i=t.pdfjs??await td(),a=new Uint8Array(e.slice(0));try{n=await i.getDocument(t.standardFontDataUrl?{data:a,standardFontDataUrl:t.standardFontDataUrl,verbosity:0}:{data:a}).promise}catch(e){if("PasswordException"===(e instanceof Error?e.name:""))return{questions:[],errors:[{index:-1,reason:"PDF_ENCRYPTED"}],warnings:[]};return{questions:[],errors:[{index:-1,reason:"INVALID_PDF"}],warnings:[]}}let s=[],o=[],l=0,u=0,d=[];try{l=n.numPages;for(let e=1;e<=l;e++){let t=await n.getPage(e),r=t.getViewport({scale:1});o.push({width:r.width,height:r.height});let i=await t.getTextContent(),a=0;for(let t of i.items){if(!("str"in t))continue;let r=ts(t.str);if(!r.trim())continue;let[n,,,,i,o]=t.transform,l=Math.abs(n)||1;s.push({str:r,x:i,y:o,width:t.width*l,height:t.height,page:e});let d=r.trim().length;a+=d,u+=d}d.push(a)}}catch(t){let e=t instanceof Error?t.name:"";if("PasswordException"===e)return{questions:[],errors:[{index:-1,reason:"PDF_ENCRYPTED"}],warnings:[]};return{questions:[],errors:[{index:-1,reason:"INVALID_PDF"}],warnings:[]}}finally{try{await n.cleanup()}catch{}}if(0===l||u/Math.max(l,1)<20)return{questions:[],errors:[{index:-1,reason:"PDF_NO_TEXT_LAYER"}],warnings:[`PAGES:${l}`]};let c=(function(e,t){let r=e.map(e=>({...e,str:ts(e.str)})).filter(e=>e.str.trim().length>0),n=function(e,t){let r=new Map;for(let t of e){let e=r.get(t.page)??[];e.push(t),r.set(t.page,e)}let n=[];for(let[e,i]of r){let r=t.find((t,r)=>r+1===e),a=r?.height??0,s=[...i].sort((e,t)=>e.y-t.y||e.x-t.x),o=[];for(let e of s){let t=o[o.length-1],r=t?.[t.length-1],n=.5*Math.max(e.height,r?.height??0);t&&r&&Math.abs(e.y-r.y)<=n?t.push(e):o.push([e])}for(let t of o){t.sort((e,t)=>e.x-t.x);let r="",i=null;for(let e of t)i&&(!(e.x-(i.x+i.width)>.15*Math.max(e.height,i.height,1))||r.endsWith(" ")||e.str.startsWith(" ")||tl(r[r.length-1])||tl(e.str[0])||(r+=" ")),r+=e.str,i=e;let s=t.reduce((e,t)=>Math.max(e,t.height),0),o=t.reduce((e,t)=>e+t.y,0)/t.length;n.push({text:r.trimEnd(),x:t[0].x,yTop:a-o+s,height:s,page:e})}}return n}(r,t),i=function(e,t){let r=new Map,n=new Map;for(let t of e){let e=n.get(t.page)??[];e.push(t),n.set(t.page,e)}for(let[e,i]of n){let n=t.find((t,r)=>r+1===e);if(!n||n.width<=0)continue;let a=n.width/2,s=.06*n.width,o=i.filter(e=>e.x+e.width<=a+s).reduce((e,t)=>e+t.str.trim().length,0),l=i.filter(e=>e.x>=a-s).reduce((e,t)=>e+t.str.trim().length,0),u=o+l;!(u<1)&&!i.some(e=>e.x<a+s&&e.x+e.width>a-s)&&o>=.25*u&&l>=.25*u&&r.set(e,{width:n.width,height:n.height})}return r}(r,t),a=function(e,t){let r=[...new Set(e.map(e=>e.page))].filter(e=>e>=1);if(0===r.length)return[];let n=Math.max(2,Math.ceil(.5*(t.length||r.length))),i=new Map;for(let r of e){let e=t.find((e,t)=>t+1===r.page),n=e?.height??0;if(n<=0)continue;let a=r.yTop<=.15*n,s=r.yTop>=.92*n;if(!a&&!s||r.text.length>100)continue;let o=to(r.text);if(!o)continue;let l=`${a?"H":"F"}:${o.key}:${o.isPageNumberOnly?"#":"*"}`,u=i.get(l);u?(u.pages.add(r.page),u.minYTop=Math.min(u.minYTop,r.yTop),u.maxYTopBottom=Math.max(u.maxYTopBottom,r.yTop)):i.set(l,{key:o.key,pages:new Set([r.page]),isPageNumberOnly:o.isPageNumberOnly,minYTop:r.yTop,maxYTopBottom:r.yTop})}return[...i.values()].filter(e=>e.pages.size>=n)}(n,t),s=new Set;for(let e of a)for(let t of n){if(t.page<1||!e.pages.has(t.page))continue;let r=to(t.text);r?.key===e.key&&(!e.isPageNumberOnly||r.isPageNumberOnly)&&t.yTop>=e.minYTop&&t.yTop<=e.maxYTopBottom&&s.add(t)}return n.filter(e=>!s.has(e)).sort((e,t)=>e.page-t.page||e.yTop-t.yTop||e.x-t.x).map(e=>{let t=i.get(e.page);if(!t)return e;let r=t.width/2;return{...e,yTop:e.x>=r?e.yTop+t.height:e.yTop}}).sort((e,t)=>e.page-t.page||e.yTop-t.yTop||e.x-t.x)})(s,o).map(e=>e.text).join("\n"),m=(0,ex.J)(c,t.splitOptions),f=[`PAGES:${l}`],g=d.filter(e=>0===e).length;g>0&&f.push(`EMPTY_PAGES:${g}`),m.ignored.length>0&&f.push((r=m.ignored.length,`IGNORED_PARAGRAPHS:${r}`)),m.detected||1!==m.questions.length||f.push("SINGLE_QUESTION");let h=eh(m.questions.map(tc));return{questions:h.questions,errors:h.errors,warnings:[...f,...h.warnings]}}let tf={maxLength:ex.f,maxQuestions:ex.k},tg={maxLength:ex.f,maxQuestions:ex.k},th={json:e=>ep(e.buffer),docx:e=>e3(e.buffer,{},tf),xlsx:e=>ti(e.buffer),csv:async function(e){let t,{text:r}=(0,R.n)(e.buffer),{rows:n}=(t=function(e){let t=e.split(/\r?\n/,1)[0]??"",r=",",n=0;for(let e of[",",";"," "]){let i=t.split(e).length-1;i>n&&(n=i,r=e)}return r}(r),{rows:function(e,t){let r=[],n=[],i="",a=!1,s=0;for(65279===e.charCodeAt(0)&&(s=1);s<e.length;){let o=e[s];if(a){'"'===o?'"'===e[s+1]?(i+='"',s+=2):(a=!1,s+=1):(i+=o,s+=1);continue}if('"'===o&&""===i){a=!0,s+=1;continue}if(o===t){n.push(i),i="",s+=1;continue}if("\r"===o){"\n"===e[s+1]&&(s+=1),n.push(i),i="",r.push(n),n=[],s+=1;continue}if("\n"===o){n.push(i),i="",r.push(n),n=[],s+=1;continue}i+=o,s+=1}return(""!==i||n.length>0)&&(n.push(i),r.push(n)),r.filter(e=>e.some(e=>""!==e.trim()))}(r,t),delimiter:t});return tn(n)},pdf:e=>tm(e.buffer,{splitOptions:tg})};function tp(){let e=(e,t)=>{let r=document.createElement("canvas");return r.width=e,r.height=t,r},t=(e,t,r)=>{e.fillStyle="#ffffff",e.fillRect(0,0,t,r)},r=(e,t)=>e.toDataURL("image/jpeg",t),n=e=>Math.floor(3*e.slice(e.indexOf(",")+1).length/4);return{async renderComposite(i,a){let s=e(a.canvasWidth,a.canvasHeight),o=s.getContext("2d");if(!o)throw Error("CANVAS_UNSUPPORTED");t(o,a.canvasWidth,a.canvasHeight),o.imageSmoothingEnabled=!0,o.imageSmoothingQuality="high";for(let e=0;e<i.length;e++){let t=a.placements[e];o.drawImage(i[e].source,0,0,i[e].width,i[e].height,0,t.y,t.width,t.height)}let l=r(s,.85),u=1;for(;n(l)>1048576&&u>.1;){u*=.85;let n=Math.max(1,Math.round(a.canvasWidth*u)),s=Math.max(1,Math.round(a.canvasHeight*u)),o=e(n,s),d=o.getContext("2d");if(!d)throw Error("CANVAS_UNSUPPORTED");t(d,n,s),d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high";for(let e=0;e<i.length;e++){let t=a.placements[e];d.drawImage(i[e].source,0,0,i[e].width,i[e].height,0,Math.round(t.y*u),Math.round(t.width*u),Math.round(t.height*u))}l=r(o,.85)}return l},async renderSingle(i,a,s){let o=function(e,t,r=1600){let n=Math.max(e,t);if(n<=r)return{width:e,height:t};let i=r/n;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}(i.width,i.height,a),l=e(o.width,o.height),u=l.getContext("2d");if(!u)throw Error("CANVAS_UNSUPPORTED");t(u,o.width,o.height),u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(i.source,0,0,i.width,i.height,0,0,o.width,o.height);let d=r(l,.85),c=1;for(;n(d)>s&&c>.1;){c*=.85;let n=Math.max(1,Math.round(o.width*c)),a=Math.max(1,Math.round(o.height*c)),s=e(n,a),l=s.getContext("2d");if(!l)throw Error("CANVAS_UNSUPPORTED");t(l,n,a),l.imageSmoothingEnabled=!0,l.imageSmoothingQuality="high",l.drawImage(i.source,0,0,i.width,i.height,0,0,n,a),d=r(s,.85)}return d}}}async function tx(e,t=tp()){if(0===e.length)throw Error("NO_IMAGES");if(1===e.length)return t.renderSingle(e[0],1600,1048576);let r=function(e,t=16){let r=e.map(t=>{var r,n,i;return r=t.width,n=t.height,i=Math.max(...e.map(e=>e.width)),r<=0?{width:i,height:0}:{width:i,height:Math.max(1,Math.round(i/r*n))}}),{width:n,height:i}=function(e,t=16){return 0===e.length?{width:0,height:0}:{width:Math.max(...e.map(e=>e.width)),height:e.reduce((e,t)=>e+t.height,0)+t*(e.length-1)}}(r,t),a=function(e,t=16){let r=[],n=0;for(let i of e)r.push(n),n+=i.height+t;return r}(r,t);return{canvasWidth:n,canvasHeight:i,placements:r.map((e,t)=>({...e,y:a[t]}))}}(e.map(e=>({width:e.width,height:e.height})));return t.renderComposite(e,r)}async function tN(e){let t=atob(e.slice(e.indexOf(",")+1)),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return createImageBitmap(new Blob([r],{type:e.slice(5,e.indexOf(";"))}))}async function ty(e){let t=await tN(e);return{source:t,width:t.width,height:t.height}}let tw=["subject","gradeSemester","source","figureSvg","extensions"],tb={subject:{zh:"学科",en:"subject"},gradeSemester:{zh:"年级学期",en:"gradeSemester"},source:{zh:"来源",en:"source"},figureSvg:{zh:"配图 SVG",en:"figureSvg"},extensions:{zh:"扩展字段",en:"extensions"}};async function tS(e,t={}){let{renderer:r,decodeFn:n,onProgress:i}=t,a=e.length,s=0,o=[];for(let t of e){let e={text:t.text,material:t.material??null,section:t.section??null,label:t.label??null,answer:t.answer??null,analysis:t.analysis??null,knowledgePoints:t.knowledgePoints?.length?t.knowledgePoints:null,difficultyStars:t.difficultyStars??null,wrongAnswer:t.wrongAnswer??null,questionType:t.questionType??null};if(t.images?.length&&r&&n)try{let i=await Promise.all(t.images.map(e=>n(e.dataUrl)));e.image=await tx(i,r)}catch{e.image=null}o.push(e),s+=1,i?.(s,a)}return o}let tv={UNKNOWN_COLUMN:{zh:e=>`未识别的列「${e}」,该列内容已忽略`,en:e=>`Unrecognized column "${e}"; its content was ignored`},IGNORED_PARAGRAPHS:{zh:e=>`${e} 个段落未计入题目(标题、说明等)`,en:e=>`${e} paragraph(s) not counted as questions (titles, notes, etc.)`},TEXT_REQUIRED:{zh:e=>e.startsWith("row=")?`第 ${e.slice(4)} 行缺少题干`:"缺少题干",en:e=>e.startsWith("row=")?`Row ${e.slice(4)} is missing question text`:"Question text is required"}},tT={INVALID_JSON:{zh:"不是合法的 JSON 文件,请检查文件内容",en:"Not a valid JSON file; please check the file content"},INVALID_DOCX:{zh:"无法读取该 Word 文件,文件可能已损坏或不是 .docx 格式",en:"Cannot read this Word file; it may be corrupted or not a .docx file"},LEGACY_DOC_NOT_SUPPORTED:{zh:"旧版 .doc 格式暂不支持,请在 Word 中另存为 .docx 后再导入",en:"Legacy .doc is not supported; please save it as .docx in Word and import again"},TEXT_COLUMN_NOT_FOUND:{zh:"未找到「题干」列,请使用题库模板或检查表头",en:'No "question text" column found; please use the question template or check the header row'},EMPTY_TABLE:{zh:"表格为空,没有可导入的题目",en:"The table is empty; there are no questions to import"},QUESTIONS_REQUIRED:{zh:"文件中没有题目(questions 为空)",en:"The file contains no questions (questions is empty)"},INVALID_QUESTION_SHAPE:{zh:"题目格式不正确(questions 应为题目数组)",en:'Invalid question format ("questions" should be an array of questions)'},PDF_NO_TEXT_LAYER:{zh:"这是扫描版 PDF(没有文字层),可在下方选择页码范围转为图片,由 AI 识别分题导入",en:"This is a scanned PDF (no text layer). You can select a page range below to convert it to images and import with AI recognition."},PDF_ENCRYPTED:{zh:"这是加密 PDF,暂不支持导入,请先去除密码后重试",en:"This PDF is password-protected and cannot be imported; please remove the password and try again"},INVALID_PDF:{zh:"无法读取该 PDF 文件,文件可能已损坏或不是有效的 PDF",en:"Cannot read this PDF file; it may be corrupted or not a valid PDF"}},tE={TEXT_REQUIRED:{zh:"缺少题干,已跳过",en:"Missing question text; skipped"},TEXT_TOO_LONG:{zh:"题干过长,已跳过",en:"Question text is too long; skipped"},MATERIAL_TOO_LONG:{zh:"公共材料过长,该题已跳过",en:"Shared material is too long; question skipped"},SECTION_TOO_LONG:{zh:"大题标题过长,该题已跳过",en:"Section title is too long; question skipped"},LABEL_TOO_LONG:{zh:"题号过长,该题已跳过",en:"Label is too long; question skipped"},ANSWER_TOO_LONG:{zh:"答案过长,该题已跳过",en:"Answer is too long; question skipped"},ANALYSIS_TOO_LONG:{zh:"解析过长,该题已跳过",en:"Analysis is too long; question skipped"},INVALID_DIFFICULTY:{zh:"难度值无效(应为 1~5),该题已跳过",en:"Invalid difficulty (should be 1–5); question skipped"},WRONG_ANSWER_TOO_LONG:{zh:"错答内容过长,该题已跳过",en:"Wrong answer is too long; question skipped"},SUBJECT_TOO_LONG:{zh:"学科字段过长,该题已跳过",en:"Subject is too long; question skipped"},GRADE_SEMESTER_TOO_LONG:{zh:"年级学期字段过长,该题已跳过",en:"Grade/semester is too long; question skipped"},SOURCE_TOO_LONG:{zh:"来源字段过长,该题已跳过",en:"Source is too long; question skipped"},QUESTION_TYPE_TOO_LONG:{zh:"题型字段过长,该题已跳过",en:"Question type is too long; question skipped"},KNOWLEDGE_POINT_TOO_LONG:{zh:"知识点过长,该题已跳过",en:"Knowledge point is too long; question skipped"},TOO_MANY_KNOWLEDGE_POINTS:{zh:"知识点数量超过上限,该题已跳过",en:"Too many knowledge points; question skipped"},INVALID_IMAGE_DATA_URL:{zh:"图片数据无效,该题已跳过",en:"Invalid image data; question skipped"},IMAGE_TOO_LARGE:{zh:"图片过大,该题已跳过",en:"Image is too large; question skipped"},TOO_MANY_IMAGES:{zh:"图片数量超过上限,该题已跳过",en:"Too many images; question skipped"},FIGURE_SVG_TOO_LONG:{zh:"配图 SVG 过长,该题已跳过",en:"Figure SVG is too long; question skipped"},INVALID_QUESTION_SHAPE:{zh:"题目格式不正确,该题已跳过",en:"Invalid question shape; skipped"}},tA={MISSING_FORMAT:{zh:"文件缺少 format 字段,已按题目交换格式解析",en:'The file is missing the "format" field; parsed as the question exchange format'},UNKNOWN_FORMAT:{zh:"format 字段不是已知的题目交换格式,已尝试按 v1 解析",en:'The "format" field is not the known exchange format; tried parsing as v1'},MISSING_VERSION:{zh:"文件缺少 version 字段,已按 v1 解析",en:'The file is missing the "version" field; parsed as v1'},UNSUPPORTED_VERSION:{zh:"文件版本高于当前支持的 v1,已按 v1 宽松规则解析",en:"The file version is newer than the supported v1; parsed with v1 tolerant rules"},TOO_MANY_QUESTIONS:{zh:"题目数量超过文件上限,超出部分已截断",en:"Question count exceeds the per-file limit; the rest was truncated"},SINGLE_QUESTION:{zh:"只识别出一道题;如果文件里有多道题,请检查题号格式",en:"Only one question was recognized; if the file has more, check the question numbering"}},tk={UNKNOWN_COLUMN:{zh:e=>`未识别的列「${e}」,该列内容已忽略`,en:e=>`Unrecognized column "${e}"; its content was ignored`},IGNORED_PARAGRAPHS:{zh:e=>`${e} 个段落未计入题目(标题、说明等)`,en:e=>`${e} paragraph(s) not counted as questions (titles, notes, etc.)`},IMAGE_UNSUPPORTED:{zh:e=>`以下格式的图片暂不支持导入,已跳过:${e}`,en:e=>`Image format(s) not supported, skipped: ${e}`},OLE_EQUATION:{zh:e=>`${e} 个 MathType 公式对象按图片导入`,en:e=>`${e} MathType equation object(s) imported as image(s)`},MATH_UNSUPPORTED:{zh:e=>`部分 OMML 结构未识别:${e}`,en:e=>`Some OMML structures not recognized: ${e}`},PAGES:{zh:e=>`共 ${e} 页`,en:e=>`${e} page${"1"===e?"":"s"} in total`},EMPTY_PAGES:{zh:e=>`其中 ${e} 页没有文字内容(空白页或纯图片页),未计入题目`,en:e=>`${e} page${"1"===e?" has":"s have"} no text content (blank or image-only) and were not counted as questions`}};var tj=e.i(682638),tO=e.i(119472);async function tI(e,t,r={}){let n=r.createBatch??tO.v,i=[],a=[];for(let s=0;s<e.length;s++){let o=e[s];try{let e=await n({source:"image",imageBase64:o.dataUrl,imageInfo:{sourceType:"pdf-page",sourceBytes:o.bytes,sourceWidth:o.width,sourceHeight:o.height,outputWidth:o.width,outputHeight:o.height,outputBytes:o.bytes,quality:void 0},language:t.language,subjectId:t.notebookId,targetSubjectId:t.notebookId});i.push({pageNumber:o.pageNumber,batch:e})}catch(e){a.push({pageNumber:o.pageNumber,error:e})}r.onProgress?.(s+1,e.length)}return{successes:i,failures:a}}async function t_(e,t,r){let n=await td();return Q(await n.getDocument({data:new Uint8Array(e.slice(0))}).promise,{pages:t,onProgress:r})}function tP({defaultNotebookId:e}){let{t:i,language:a}=(0,b.b)(),[s,o]=(0,r.useState)(e??""),{phase:l,handleFile:u,handleConfirm:d,handleReset:c,handleScannedPdfConfirm:f}=function({language:e,notebookId:t,texts:i,scannedPdfDeps:a}){let s=(0,n.useRouter)(),[o,l]=(0,r.useState)({kind:"pick"}),u=async()=>{let r;if("summary"!==o.kind)return;if(!t)return void j.c.error(i.notebookRequired);if(o.summary.total>tj.e)return void j.c.error(i.tooManyQuestions.replace("{max}",String(tj.e)));l({kind:"creating",fileName:o.fileName,batchCount:Math.ceil(o.summary.total/60)});let n=o.result.questions.some(e=>e.images?.length);try{if(n){let e=tp();r=await tS(o.result.questions,{renderer:e,decodeFn:ty,onProgress:(e,t)=>{l({kind:"processingImages",fileName:o.fileName,done:e,total:t})}})}else r=await tS(o.result.questions)}catch(e){D.V.error("[FileImport]","Process images failed",{error:(0,q.Z)(e)}),j.c.error(i.parseFailed),l({kind:"summary",fileName:o.fileName,fileType:o.fileType,result:o.result,summary:o.summary});return}l({kind:"creating",fileName:o.fileName,batchCount:Math.ceil(o.summary.total/60)});try{let{batches:n,failures:a}=await (0,tj.r)(r,{language:e,subjectId:t,targetSubjectId:t,origin:{fileName:o.fileName,format:o.fileType.key}});for(let e of(n.length>0&&(j.c.success(i.batchesCreated.replace("{count}",String(n.length))),s.push(1===n.length?`/import-batches/${n[0].id}`:"/import-tasks")),a))j.c.error(i.batchFailed.replace("{index}",String(e.index+1)).replace("{error}",(0,q.Z)(e.error)));0===n.length&&a.length>0&&l({kind:"summary",fileName:o.fileName,fileType:o.fileType,result:o.result,summary:o.summary})}catch(e){D.V.error("[FileImport]","Create batches failed",{error:(0,q.Z)(e)}),j.c.error((0,q.Z)(e)),l({kind:"summary",fileName:o.fileName,fileType:o.fileType,result:o.result,summary:o.summary})}},d=async r=>{let n;if("scanned-pdf"!==o.kind)return;if(!t)return void j.c.error(i.notebookRequired);let{fileName:u,buffer:d}=o;l({kind:"rendering-pdf",fileName:u,rendered:0,total:r.length});try{n=a?.renderPages?await a.renderPages(d,r,(e,t)=>{l({kind:"rendering-pdf",fileName:u,rendered:e,total:t})}):await t_(d,r,(e,t)=>{l({kind:"rendering-pdf",fileName:u,rendered:e,total:t})})}catch(e){D.V.error("[FileImport]","Render scanned PDF failed",{error:(0,q.Z)(e)}),j.c.error(i.pdfRenderFailed),l({kind:"scanned-pdf",fileName:u,buffer:d,pageCount:o.pageCount});return}l({kind:"creating-pdf-batches",fileName:u,created:0,total:n.length});let c=a?.createBatches??tI,{successes:m,failures:f}=await c(n,{language:e,notebookId:t},{onProgress:(e,t)=>{l({kind:"creating-pdf-batches",fileName:u,created:e,total:t})}});for(let e of f){var g;(g=e.error,g?.status===429)?j.c.error(i.pdfQuotaExceeded.replace("{page}",String(e.pageNumber))):j.c.error(i.pdfPageFailed.replace("{page}",String(e.pageNumber)).replace("{error}",(0,q.Z)(e.error)))}m.length>0?(j.c.success(i.batchesCreated.replace("{count}",String(m.length))),s.push(1===m.length?`/import-batches/${m[0].batch.id}`:"/import-tasks")):l({kind:"scanned-pdf",fileName:u,buffer:d,pageCount:o.pageCount})};return{phase:o,handleFile:async(t,r)=>{var n;let a,s,o,u,d,c=th[r.key]??null;if(!c)return void j.c.error(i.unsupportedType);l({kind:"parsing",fileName:t.name});try{s=await t.arrayBuffer(),a=await c({name:t.name,buffer:s})}catch(e){D.V.error("[FileImport]","Parse file failed",{error:(0,q.Z)(e)}),j.c.error(i.parseFailed),l({kind:"pick"});return}let m=(o=(n=a).errors.slice().sort((e,t)=>e.index-t.index).slice(0,5).map(t=>({index:t.index,message:function(e,t){let r=e.indexOf(":"),n=-1===r?e:e.slice(0,r),i=-1===r?"":e.slice(r+1);if(i&&tv[n])return tv[n][t](i);let a=tE[n]??tT[n];return a?a[t]:"zh"===t?`未知错误(${e})`:`Unknown error (${e})`}(t.reason,e)})),u=n.warnings.map(t=>(function(e,t){let r,n=e.match(/^(\[[^\]]*\])\s*(.*)$/),i=n?n[1]:"",a=n?n[2]:e,s=a.indexOf(":"),o=-1===s?a:a.slice(0,s),l=-1===s?"":a.slice(s+1);if(l&&tk[o])r=tk[o][t](l);else{let e=tA[o];r=e?e[t]:"zh"===t?`未知警告(${a})`:`Unknown warning (${a})`}return i?`${i} ${r}`:r})(t,e)),d=function(e){let t=new Map;for(let r of tw){let n=0;for(let t of e)(function(e,t){let r=e[t];return null!=r&&("string"==typeof r?r.trim().length>0:Array.isArray(r)?r.length>0:Object.keys(r).length>0)})(t,r)&&(n+=1);n>0&&t.set(r,n)}return Array.from(t.entries()).map(([e,t])=>({field:e,count:t}))}(n.questions),{total:n.questions.length,importable:n.questions.length,errorCount:n.errors.length,warningCount:n.warnings.length,errors:o,warnings:u,ignoredFields:d,ignoredFieldTexts:d.map(({field:t,count:r})=>{let n=tb[t][e];return"zh"===e?`${n}(${r} 题)`:`${n} (${r} question${r>1?"s":""})`})});if(D.V.info("[FileImport]","File parsed",{fileName:t.name,type:r.key,total:m.total,errors:m.errorCount,warnings:m.warningCount}),0===m.total){if("pdf"===r.key&&a.errors.some(e=>"PDF_NO_TEXT_LAYER"===e.reason)){let e=function(e){for(let t of e.warnings)if(t.startsWith("PAGES:")){let e=Number.parseInt(t.slice(6),10);return Number.isFinite(e)?e:null}return null}(a)??0;l({kind:"scanned-pdf",fileName:t.name,buffer:s,pageCount:e});return}let e=m.errors[0]?.message;j.c.error(e??i.noQuestions),l({kind:"pick"});return}l({kind:"summary",fileName:t.name,fileType:r,result:a,summary:m})},handleConfirm:u,handleReset:()=>l({kind:"pick"}),handleScannedPdfConfirm:d}}({language:"en"===a?"en":"zh",notebookId:s,texts:i.fileImport});return(0,t.jsx)(m.N,{className:"rounded-2xl","data-testid":"file-import-panel",children:(0,t.jsxs)(m.O,{className:"space-y-4 p-6",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-muted-foreground",children:[(0,t.jsx)(I.f,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:i.fileImport.title})]}),(0,t.jsx)(t$,{phase:l,notebookId:s,onNotebookChange:o,onFile:u,onConfirm:d,onReset:c,onScannedPdfConfirm:f})]})})}function t$({phase:e,notebookId:r,onNotebookChange:n,onFile:i,onConfirm:a,onReset:s,onScannedPdfConfirm:o}){switch(e.kind){case"parsing":return(0,t.jsx)(P,{textKey:"parsing",fileName:e.fileName});case"processingImages":return(0,t.jsx)(_,{fileName:e.fileName,done:e.done,total:e.total});case"creating":return(0,t.jsx)(P,{textKey:"creating",batchCount:e.batchCount});case"rendering-pdf":return(0,t.jsx)(P,{textKey:"rendering-pdf",rendered:e.rendered,total:e.total});case"creating-pdf-batches":return(0,t.jsx)(P,{textKey:"creating-pdf-batches",rendered:e.created,total:e.total});case"scanned-pdf":return(0,t.jsx)(Y,{fileName:e.fileName,pageCount:e.pageCount,notebookId:r,onNotebookChange:n,onConfirm:o,onReset:s});case"summary":return(0,t.jsx)(G,{fileName:e.fileName,summary:e.summary,notebookId:r,onNotebookChange:n,onConfirm:a,onReset:s});default:return(0,t.jsx)(F,{onFile:i})}}var tC=e.i(522016),tM=e.i(217255),tL=e.i(856423),tD=e.i(975153),tq=e.i(218964),tR=e.i(697886);let tz=()=>()=>{};function tU({href:e,icon:r,label:n,value:i}){return(0,t.jsxs)(tC.default,{href:e,className:"rounded-xl bg-white/15 px-4 py-3 backdrop-blur-sm transition-colors hover:bg-white/20",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-white/75",children:[(0,t.jsx)(r,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:n})]}),(0,t.jsx)("div",{className:"mt-1 text-2xl font-bold tabular-nums",children:i??"–"})]})}function tF({notebookCount:e,itemCount:n,dueCount:i,targetNotebook:a}){let{t:s,language:o}=(0,b.b)(),{data:l}=(0,tM.useSession)(),u=(0,r.useSyncExternalStore)(tz,()=>new Date().getHours(),()=>null),d=null===u?s.common.welcome.replace(/[,,\s]+$/,""):u<12?s.home.greetingMorning:u<18?s.home.greetingAfternoon:s.home.greetingEvening,c=l?.user?.name||l?.user?.email||"";return(0,t.jsxs)("section",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-indigo-600 via-indigo-500 to-violet-500 p-5 text-white shadow-lg shadow-indigo-500/20 md:p-7",children:[(0,t.jsx)("div",{className:"pointer-events-none absolute -right-10 -top-12 h-44 w-44 rounded-full bg-white/10 blur-2xl"}),(0,t.jsx)("div",{className:"pointer-events-none absolute -bottom-16 right-24 h-40 w-40 rounded-full bg-fuchsia-300/20 blur-2xl"}),(0,t.jsxs)("div",{className:"relative flex flex-col gap-5 md:flex-row md:items-end md:justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("h1",{className:"text-xl font-bold tracking-tight md:text-2xl",children:[d,c&&`${"zh"===o?",":", "}${c}`]}),(0,t.jsx)("p",{className:"max-w-md text-sm text-white/80",children:s.home.heroSubtitle}),a&&(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 rounded-full bg-white/15 px-3 py-1 text-xs font-medium",children:[(0,t.jsx)(tR.f,{className:"h-3.5 w-3.5"}),s.home.targetNotebook.replace("{name}",a)]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-3 md:w-96",children:[(0,t.jsx)(tU,{href:"/notebooks",icon:tL.f,label:s.home.notebookCount,value:e}),(0,t.jsx)(tU,{href:"/notebooks",icon:tq.f,label:s.home.itemCount,value:n}),(0,t.jsx)(tU,{href:"/review",icon:tD.f,label:s.home.dueCount,value:i})]})]})]})}var tG=e.i(12130),tB=e.i(430634),tV=e.i(576019),tH=e.i(847483),tW=e.i(497346),tQ=e.i(717448),tY=e.i(798469),tK=e.i(86963),tX=e.i(956738),tZ=e.i(185592),tJ=e.i(41931),t0=e.i(35209),t1=e.i(598053),t2=e.i(315092);function t4(){let{t:e}=(0,b.b)();(0,t0.f)(e.pageTitle.home);let a=(0,n.useSearchParams)().get("notebook"),[s,m]=(0,r.useState)([]),[f,g]=(0,r.useState)(null),[h,p]=(0,r.useState)("image"),x=a?s.find(e=>e.id===a):void 0,N=(0,t1.f)({logPrefix:"[Home]",analyzeSubjectId:a,importSubjectId:a,textNotebook:x&&{id:x.id,name:x.name}});(0,r.useEffect)(()=>{tJ.k.get("/api/notebooks").then(e=>m(e)).catch(e=>D.V.error("[Home]","Failed to fetch notebooks",{error:e})),tJ.k.get("/api/review/due?pageSize=1").then(e=>g(e.total)).catch(e=>D.V.error("[Home]","Failed to fetch due reviews",{error:e}))},[]);let y=async e=>{N.setAnalysisStep("saving"),await N.saveQuestion({...e,wrongAnswerText:e.wrongAnswerText||null,mistakeAnalysis:e.mistakeAnalysis||null,mistakeStatus:e.mistakeStatus||"unknown",originalImageUrl:""}),N.setAnalysisStep("idle")},w=s.reduce((e,t)=>e+(t._count?.errorItems||0),0),S=[{value:"image",icon:i.f,label:e.app?.uploadImage||"Take Photo"},{value:"text",icon:u.f,label:e.app?.manualInput||"Manual Input"},{value:"file",icon:o,label:e.app?.fileImport||"Import File"},{value:"direct",icon:l.f,label:e.app?.directInput||"Manual Entry"}];return(0,t.jsxs)("main",{className:"min-h-screen",children:[(0,t.jsx)(tX.f,{status:N.analysisStep,completed:N.completedStages}),(0,t.jsxs)("div",{className:`mx-auto space-y-6 px-4 py-6 md:px-8 md:py-8 ${"review"===N.step?"max-w-6xl":"max-w-4xl"}`,children:[(0,t.jsx)(tW.f,{message:N.saveError,onDismiss:N.dismissSaveError}),"upload"===N.step&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tF,{notebookCount:s.length,itemCount:w,dueCount:f,targetNotebook:a?x?.name:void 0}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(tZ.f,{options:S,value:h,onChange:p}),N.pendingTask&&(0,t.jsx)(tV.f,{task:N.pendingTask,onRefresh:N.refreshPendingTask,onDismiss:N.dismissPendingTask}),N.lastImported&&(0,t.jsx)(tB.f,{imported:N.lastImported,onDismiss:N.dismissImported}),N.batchImages?(0,t.jsx)(d.f,{images:N.batchImages,subjectId:a,onClose:N.closeBatch}):"image"===h?(0,t.jsxs)(t.Fragment,{children:[N.parts.length>0&&(0,t.jsx)(tH.f,{parts:N.parts.map(e=>e.dataUrl),busy:N.isBusy,onFinish:()=>void N.finishParts(),onDiscard:N.discardParts}),(0,t.jsx)(tY.f,{onImageSelect:N.selectImage,isAnalyzing:N.isBusy})]}):"text"===h?(0,t.jsx)(tQ.f,{onSubmit:N.submitText,isAnalyzing:N.isBusy,defaultNotebookName:x?.name,onCreateBatch:N.createTextBatch,creatingBatch:N.creatingBatch,onSwitchToFileImport:()=>p("file")}):"file"===h?(0,t.jsx)(tP,{defaultNotebookId:a||void 0}):(0,t.jsx)(O,{onSubmit:y,defaultNotebookId:a||void 0,defaultNotebookName:x?.name,isSaving:"saving"===N.analysisStep})]})]}),N.croppingImage&&(0,t.jsx)(tG.f,{imageSrc:N.croppingImage,open:N.isCropperOpen,onClose:N.closeCropper,onRegionsSelected:N.cropRegions,allowMulti:0===N.parts.length,onAutoSplit:0===N.parts.length?N.autoSplitImage:void 0,onAddPart:N.parts.length<t2.u-1?N.addPart:void 0,partCount:N.parts.length}),"review"===N.step&&N.parsedData&&(0,t.jsx)(c.f,{initialData:N.parsedData,onSave:N.saveReviewed,onCancel:N.cancelReview,imagePreview:N.currentImage,initialSubjectId:a||void 0,aiTimeout:N.aiTimeout})]})]})}e.s(["default",0,function(){return(0,t.jsx)(r.Suspense,{fallback:(0,t.jsx)(tK.f,{}),children:(0,t.jsx)(t4,{})})}],952683)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,864272,e=>{"use strict";var t=e.i(843476),a=e.i(271645),s=e.i(522016),i=e.i(618566),r=e.i(13285),n=e.i(853138),l=e.i(632781),c=e.i(77071),o=e.i(456420);let d={name:"undo-2",size:24,node:[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]};d.node;let m=(0,o.f)(d),u={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};u.node;let h=(0,o.f)(u);var x=e.i(111110);function p({inputProps:e,created:a}){let{t:i}=(0,x.b)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{type:"file",accept:"image/*",className:"hidden","data-testid":"continuation-input",...e}),a.length>0&&(0,t.jsx)("ul",{className:"space-y-1 rounded-lg border border-primary/40 bg-primary/5 p-3 text-sm","data-testid":"continuation-notice",children:a.map((e,a)=>(0,t.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(r.f,{className:"h-4 w-4 text-primary"}),i.importBatch.continuation.notice.replace("{n}",String(a+2))]}),(0,t.jsxs)(s.default,{href:`/import-batches/${e}`,className:"flex items-center gap-1 text-primary underline-offset-2 hover:underline",children:[i.importBatch.continuation.open,(0,t.jsx)(h,{className:"h-3 w-3"})]})]},e))})]})}let f={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};f.node;let g=(0,o.f)(f),y={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};y.node;let b=(0,o.f)(y);var j=e.i(716327),w=e.i(456539),v=e.i(508734);let k={name:"crop",size:24,node:[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]};k.node;let N=(0,o.f)(k),B={name:"file-plus-corner",size:24,node:[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]],aliases:["file-plus-2"]};B.node;let S=(0,o.f)(B),C={name:"merge",size:24,node:[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]};C.node;let z=(0,o.f)(C),T={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]};T.node;let A=(0,o.f)(T);var I=e.i(328623),M=e.i(759659),$=e.i(263676),R=e.i(793479),E=e.i(110204),P=e.i(967489),F=e.i(624687),q=e.i(411382),D=e.i(978056),H=e.i(54105),U=e.i(772325),_=e.i(722219),_=_,O=e.i(282492),L=e.i(825624);let V=q.z.object({x:D.z.number().min(0).max(1),y:D.z.number().min(0).max(1),width:D.z.number().min(.01).max(1),height:D.z.number().min(.01).max(1)}).refine(e=>e.x+e.width<=1.0001&&e.y+e.height<=1.0001,{message:"REGION_OUT_OF_BOUNDS"}),K=["unclear","partial","unlocated"],G=H.z.string().max(1572864,"DRAFT_IMAGE_TOO_LARGE").regex(/^data:image\/(?:jpeg|png|webp);base64,[A-Za-z0-9+/]+=*$/,"DRAFT_IMAGE_INVALID"),Q=q.z.object({original:H.z.string().max(2e4),text:H.z.string().max(2e4),uncertain:U.z.array(H.z.string().max(200)).max(20)}),W=q.z.object({key:H.z.string().regex(/^[A-Za-z0-9_-]{1,40}$/),label:H.z.string().max(20).nullable(),text:H.z.string().max(2e4),material:H.z.string().max(2e4).nullable(),section:H.z.string().max(500).nullable(),selected:_.boolean(),regions:U.z.array(V).max(4),hasFigure:_.boolean(),flags:U.z.array(O.z.enum(K)).max(K.length),fix:Q.nullish(),answer:H.z.string().max(2e4).nullish(),analysis:H.z.string().max(2e4).nullish(),knowledgePoints:U.z.array(H.z.string().max(200)).max(100).optional(),difficultyStars:D.z.number().int().min(1).max(5).nullish(),questionType:H.z.string().max(200).nullish(),wrongAnswer:H.z.string().max(2e4).nullish(),image:G.nullish()}),X=["blurry","partial","truncated","tooMany"];function Y(e=[]){let t=new Set(e);for(;;){let e=`q${Math.random().toString(36).slice(2,10)}`;if(!t.has(e))return e}}function Z(e,t){return"image"===t?e.regions.length>0:e.text.trim().length>0}function J(e,t){return e.items.filter(e=>e.selected&&Z(e,t))}function ee(e,t){return{...e,items:t}}function et(e,t){return e.items.findIndex(e=>e.key===t)}function ea(e,t,a){return ee(e,e.items.map(e=>{if(e.key!==t)return e;let s={...e,...a};return void 0!==a.text&&(s.text=a.text.slice(0,2e4),s.text!==e.text&&(s.fix=null)),void 0!==a.answer&&(s.answer=a.answer?.slice(0,2e4)??null),void 0!==a.analysis&&(s.analysis=a.analysis?.slice(0,2e4)??null),void 0!==a.knowledgePoints&&(s.knowledgePoints=a.knowledgePoints.slice(0,100).map(e=>e.slice(0,200))),void 0!==a.difficultyStars&&(s.difficultyStars=a.difficultyStars),void 0!==a.questionType&&(s.questionType=a.questionType),void 0!==a.wrongAnswer&&(s.wrongAnswer=a.wrongAnswer?.slice(0,2e4)??null),void 0!==a.regions&&(s.regions=a.regions.slice(0,4),s.flags=s.regions.length>0?e.flags.filter(e=>"unlocated"!==e):[...new Set([...e.flags,"unlocated"])]),s}))}function es(e,t){return ee(e,e.items.filter(e=>e.key!==t))}function ei(e,t,a){let s=et(e,t),i=s+a;if(s<0||i<0||i>=e.items.length)return e;let r=[...e.items];return[r[s],r[i]]=[r[i],r[s]],ee(e,r)}function er(e,t){return[e,t].filter(e=>e?.trim()).join("\n").trim()||null}function en(e,t){let a=t?new Set(t):null,s=!1,i=e.items.map(e=>e.fix&&(!a||a.has(e.key))?(s=!0,e.fix.original===e.text?{...e,text:e.fix.text,fix:null}:{...e,fix:null}):e);return s?ee(e,i):e}q.z.object({items:U.z.array(W).max(L.S),ignored:U.z.array(H.z.string().max(2e4)).max(200),warnings:U.z.array(O.z.enum(X)).max(X.length)}).superRefine((e,t)=>{let a=new Set;for(let s of e.items)a.has(s.key)&&t.addIssue({code:"custom",message:"DUPLICATE_ITEM_KEY"}),a.add(s.key)});var el=e.i(401280);let ec=[1,2,3,4,5],eo=[el.O,...el.V];function ed({item:e,onEdit:s}){let{t:i}=(0,x.b)(),[r,n]=(0,a.useState)(!1),l=!!(e.answer?.trim()||e.analysis?.trim()||e.knowledgePoints?.length||null!=e.difficultyStars||e.wrongAnswer?.trim());return(0,t.jsxs)("div",{className:"rounded-lg border border-dashed p-2",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between text-xs font-medium text-muted-foreground",onClick:()=>n(e=>!e),"aria-expanded":r,children:[(0,t.jsx)("span",{children:i.importBatch.fields.title}),r?(0,t.jsx)(w.f,{className:"h-3.5 w-3.5"}):(0,t.jsx)(j.f,{className:"h-3.5 w-3.5"})]}),r&&(0,t.jsxs)("div",{className:"mt-2 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-type`,className:"text-xs",children:i.questionType.label}),(0,t.jsxs)(P.d,{value:e.questionType??el.O,onValueChange:t=>s(a=>ea(a,e.key,{questionType:t===el.O?null:(0,el.P)(t)})),children:[(0,t.jsx)(P.P,{className:"h-8 w-full text-sm","aria-label":i.questionType.label,children:(0,t.jsx)(P.U,{})}),(0,t.jsx)(P.r,{children:eo.map(e=>(0,t.jsx)(P.T,{value:e,children:e===el.O?i.questionType.notSet:i.questionType.names[e]},e))})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-answer`,className:"text-xs",children:i.importBatch.fields.answer}),(0,t.jsx)(F.f,{id:`${e.key}-answer`,value:e.answer??"",onChange:t=>s(a=>ea(a,e.key,{answer:t.target.value})),className:"min-h-16 text-sm",placeholder:i.importBatch.fields.answerPlaceholder})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-analysis`,className:"text-xs",children:i.importBatch.fields.analysis}),(0,t.jsx)(F.f,{id:`${e.key}-analysis`,value:e.analysis??"",onChange:t=>s(a=>ea(a,e.key,{analysis:t.target.value})),className:"min-h-20 text-sm",placeholder:i.importBatch.fields.analysisPlaceholder})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-knowledge`,className:"text-xs",children:i.importBatch.fields.knowledgePoints}),(0,t.jsx)(R.f,{id:`${e.key}-knowledge`,value:(e.knowledgePoints??[]).join(", "),onChange:t=>s(a=>ea(a,e.key,{knowledgePoints:t.target.value.split(/[,,、]/).map(e=>e.trim()).filter(Boolean)})),className:"text-sm",placeholder:i.importBatch.fields.knowledgePlaceholder})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{className:"text-xs",children:i.importBatch.fields.difficulty}),(0,t.jsxs)(P.d,{value:null!=e.difficultyStars?String(e.difficultyStars):"none",onValueChange:t=>s(a=>ea(a,e.key,{difficultyStars:"none"===t?null:Number(t)})),children:[(0,t.jsx)(P.P,{className:"h-8 w-full text-sm","aria-label":i.importBatch.fields.difficulty,children:(0,t.jsx)(P.U,{})}),(0,t.jsxs)(P.r,{children:[(0,t.jsx)(P.T,{value:"none",children:i.importBatch.fields.difficultyNone}),ec.map(e=>(0,t.jsx)(P.T,{value:String(e),children:"★".repeat(e)},e))]})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-wrong`,className:"text-xs",children:i.importBatch.fields.wrongAnswer}),(0,t.jsx)(F.f,{id:`${e.key}-wrong`,value:e.wrongAnswer??"",onChange:t=>s(a=>ea(a,e.key,{wrongAnswer:t.target.value})),className:"min-h-16 text-sm",placeholder:i.importBatch.fields.wrongAnswerPlaceholder})]})]}),!r&&l&&(0,t.jsx)("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[e.answer?.trim()&&i.importBatch.fields.answer,e.analysis?.trim()&&i.importBatch.fields.analysis,e.knowledgePoints?.length&&`${i.importBatch.fields.knowledgePoints}(${e.knowledgePoints.length})`,null!=e.difficultyStars&&"★".repeat(e.difficultyStars),e.wrongAnswer?.trim()&&i.importBatch.fields.wrongAnswer].filter(Boolean).join(" · ")})]})}var em=e.i(975157);function eu({imageUrl:e,imageSize:a,regions:s,className:i}){let r=function(e){if(0===e.length)return null;let t=Math.min(...e.map(e=>e.x)),a=Math.min(...e.map(e=>e.y));return{x:t,y:a,width:Math.max(...e.map(e=>e.x+e.width))-t,height:Math.max(...e.map(e=>e.y+e.height))-a}}(s);if(!r)return null;let n=r.width*a.width/Math.max(1,r.height*a.height);return(0,t.jsx)("div",{className:(0,em.f)("relative w-full overflow-hidden rounded-md border bg-white",i),style:{aspectRatio:String(Math.max(.25,Math.min(8,n)))},"aria-hidden":!0,children:(0,t.jsx)("img",{src:e,alt:"",className:"absolute max-w-none select-none",draggable:!1,style:{width:`${100/r.width}%`,height:`${100/r.height}%`,left:`${-r.x/r.width*100}%`,top:`${-r.y/r.height*100}%`}})})}var eh=e.i(689664),ex=e.i(519455);function ep(e,t,a){if(!a)return;let s=e[e.length-1];s&&s.type===t?s.text+=a:e.push({type:t,text:a})}function ef({fix:e,onAccept:s,onReject:i}){let{t:r}=(0,x.b)(),n=(0,a.useMemo)(()=>(function(e,t){let a=Array.from(e),s=Array.from(t),i=0;for(;i<a.length&&i<s.length&&a[i]===s[i];)i++;let r=a.length,n=s.length;for(;r>i&&n>i&&a[r-1]===s[n-1];)r--,n--;let l=[];ep(l,"same",a.slice(0,i).join(""));let c=a.slice(i,r),o=s.slice(i,n),d=c.length,m=o.length;if(d*m>2e6)ep(l,"removed",c.join("")),ep(l,"added",o.join(""));else{let e=m+1,t=new Uint32Array((d+1)*e);for(let a=d-1;a>=0;a--)for(let s=m-1;s>=0;s--)t[a*e+s]=c[a]===o[s]?t[(a+1)*e+s+1]+1:Math.max(t[(a+1)*e+s],t[a*e+s+1]);let a=0,s=0;for(;a<d&&s<m;)c[a]===o[s]?(ep(l,"same",c[a]),a++,s++):t[(a+1)*e+s]>=t[a*e+s+1]?ep(l,"removed",c[a++]):ep(l,"added",o[s++]);ep(l,"removed",c.slice(a).join("")),ep(l,"added",o.slice(s).join(""))}return ep(l,"same",a.slice(r).join("")),l})(e.original,e.text),[e.original,e.text]);return(0,t.jsxs)("div",{className:"space-y-2 rounded-lg border border-violet-300 bg-violet-50/60 p-2 text-sm dark:border-violet-800 dark:bg-violet-950/30","data-testid":"text-fix-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1 text-xs font-medium text-violet-700 dark:text-violet-300",children:[(0,t.jsx)(I.f,{className:"h-3 w-3"}),r.importBatch.fixText.title]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:r.importBatch.fixText.legend})]}),(0,t.jsx)("p",{className:"whitespace-pre-wrap break-words font-mono text-sm","data-testid":"text-fix-diff",children:n.map((e,a)=>"same"===e.type?(0,t.jsx)("span",{children:e.text},a):"removed"===e.type?(0,t.jsx)("del",{className:"bg-red-100 text-red-700 decoration-red-500 dark:bg-red-950/50 dark:text-red-300",children:e.text},a):(0,t.jsx)("ins",{className:"bg-emerald-100 text-emerald-800 no-underline dark:bg-emerald-950/50 dark:text-emerald-300",children:e.text},a))}),e.uncertain.length>0&&(0,t.jsxs)("div",{className:"text-xs text-amber-800 dark:text-amber-300",children:[(0,t.jsx)("span",{children:r.importBatch.fixText.uncertain}),(0,t.jsx)("ul",{className:"mt-0.5 list-inside list-disc",children:e.uncertain.map((e,a)=>(0,t.jsx)("li",{className:"break-words",children:e},a))})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",onClick:s,children:[(0,t.jsx)(eh.f,{className:"mr-1 h-4 w-4"}),r.importBatch.fixText.accept]}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:i,children:[(0,t.jsx)($.X,{className:"mr-1 h-4 w-4"}),r.importBatch.fixText.reject]})]})]})}var eg=e.i(487486),ey=e.i(257428);function eb({image:e,alt:s,onRemove:i}){let[r,n]=(0,a.useState)(!1);return(0,t.jsxs)("div",{className:"relative inline-block",children:[(0,t.jsx)("button",{type:"button",onClick:()=>n(!0),className:"block overflow-hidden rounded-lg border","aria-label":s,children:(0,t.jsx)("img",{src:e,alt:s,className:"max-h-32 w-auto object-contain"})}),(0,t.jsx)(ex.f,{type:"button",size:"icon",variant:"ghost",className:"absolute -right-2 -top-2 h-6 w-6 rounded-full bg-background border shadow-sm",onClick:i,"aria-label":"删除图片",children:(0,t.jsx)($.X,{className:"h-3 w-3"})}),r&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>n(!1),"aria-label":"关闭大图",children:(0,t.jsx)("img",{src:e,alt:s,className:"max-h-full max-w-full object-contain"})})]})}function ej({item:e,index:s,total:i,source:r,expanded:c,onToggleExpand:o,onEdit:d,image:m,onAdjustRegion:u,highlighted:h,onFixText:p,fixing:f,fixBusy:y,onContinue:k,continuing:B}){let{t:C}=(0,x.b)(),T=(0,a.useRef)(null),$=Z(e,r),R=`draft-item-${e.key}`,E=e.fix&&e.fix.original===e.text?e.fix:null;return(0,t.jsxs)("li",{id:R,className:(0,em.f)("rounded-xl border bg-card p-3 transition-colors",!e.selected&&"opacity-70",h&&"border-primary ring-2 ring-primary/30"),"data-testid":"draft-item","data-selected":e.selected,"data-fix-pending":E?"true":void 0,children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(ey.f,{className:"mt-1 h-5 w-5",checked:e.selected,disabled:!$,onCheckedChange:t=>d(a=>{var s,i;return s=e.key,i=!0===t,ee(a,a.items.map(e=>e.key===s?{...e,selected:i}:e))}),"aria-label":C.importBatch.question.replace("{index}",String(s+1))}),(0,t.jsxs)("button",{type:"button",className:"min-w-0 flex-1 text-left",onClick:o,"aria-expanded":c,"aria-controls":`${R}-body`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,t.jsx)("span",{className:"font-semibold",children:C.importBatch.question.replace("{index}",String(s+1))}),e.label&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:C.importBatch.originalLabel.replace("{label}",e.label)}),e.material&&(0,t.jsx)(eg.f,{variant:"secondary",children:C.importBatch.material}),e.hasFigure&&(0,t.jsx)(eg.f,{variant:"outline",children:C.importBatch.hasFigure}),E&&(0,t.jsx)(eg.f,{className:"bg-violet-600 text-white hover:bg-violet-600",children:C.importBatch.fixText.pending}),e.section&&(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.section.split("\n")[0]})]}),!c&&!E&&e.text&&(0,t.jsx)("p",{className:"mt-1 line-clamp-3 whitespace-pre-line break-words text-sm text-muted-foreground",children:e.text}),e.flags.length>0&&(0,t.jsx)("ul",{className:"mt-1 space-y-0.5",children:e.flags.map(e=>(0,t.jsxs)("li",{className:"flex items-center gap-1 text-xs text-amber-700 dark:text-amber-300",children:[(0,t.jsx)(n.f,{className:"h-3 w-3 shrink-0"}),C.importBatch.flags[e]]},e))})]}),(0,t.jsx)(ex.f,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 shrink-0",onClick:o,"aria-label":c?C.importBatch.collapse:C.importBatch.edit,children:c?(0,t.jsx)(w.f,{className:"h-4 w-4"}):(0,t.jsx)(j.f,{className:"h-4 w-4"})})]}),m&&e.regions.length>0&&(0,t.jsx)("button",{type:"button",className:"mt-2 block w-full max-w-md pl-8",onClick:u,"aria-label":C.importBatch.adjustRegion,children:(0,t.jsx)(eu,{imageUrl:m.url,imageSize:m,regions:e.regions,className:"max-h-48"})}),k&&(0,t.jsx)("div",{className:"mt-2 pl-8",children:(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:k,disabled:B,"data-testid":"draft-continue",children:[B?(0,t.jsx)(l.f,{className:"mr-1 h-4 w-4 animate-spin"}):(0,t.jsx)(S,{className:"mr-1 h-4 w-4"}),B?C.importBatch.continuation.working:C.importBatch.continuation.button]})}),E&&(0,t.jsx)("div",{className:"mt-2 pl-8",children:(0,t.jsx)(ef,{fix:E,onAccept:()=>d(t=>en(t,[e.key])),onReject:()=>d(t=>{var a;return a=e.key,ee(t,t.items.map(e=>e.key===a&&e.fix?{...e,fix:null}:e))})})}),c&&(0,t.jsxs)("div",{id:`${R}-body`,className:"mt-3 space-y-3 pl-8",children:[e.material&&(0,t.jsxs)("div",{className:"rounded-lg bg-muted/60 p-2 text-sm",children:[(0,t.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"text-xs font-medium",children:[C.importBatch.material," · ",C.importBatch.materialHint]}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>d(t=>ea(t,e.key,{material:null})),children:C.importBatch.removeMaterial})]}),(0,t.jsx)("p",{className:"line-clamp-6 whitespace-pre-line break-words text-muted-foreground",children:e.material})]}),"text"===r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(F.f,{ref:T,"aria-label":C.importBatch.questionText,value:e.text,onChange:t=>d(a=>ea(a,e.key,{text:t.target.value}),`text-${e.key}`),className:"min-h-28 font-mono text-sm"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:C.importBatch.splitHint}),e.image&&(0,t.jsx)(eb,{image:e.image,alt:C.importBatch.questionImage,onRemove:()=>d(t=>ea(t,e.key,{image:null}))}),(0,t.jsx)(ed,{item:e,onEdit:e=>d(e)})]}):(0,t.jsxs)(t.Fragment,{children:[e.text&&(0,t.jsx)("p",{className:"whitespace-pre-line break-words text-sm text-muted-foreground",children:e.text}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:C.importBatch.imageTextHint})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:["text"===r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:()=>{let t=T.current?.selectionStart??0;d(a=>(function(e,t,a){let s=et(e,t);if(s<0||e.items.length>=L.S)return e;let i=e.items[s],r=i.text.slice(0,a).replace(/\s+$/,""),n=i.text.slice(a).replace(/^\s+/,"");if(!r||!n)return e;let l={...i,key:Y(e.items.map(e=>e.key)),label:null,text:n,regions:[],flags:i.regions.length>0?["unlocated"]:[],selected:!(i.regions.length>0)&&i.selected,answer:null,analysis:null,knowledgePoints:void 0,difficultyStars:null,questionType:null,wrongAnswer:null,fix:null},c=[...e.items];return c.splice(s,1,{...i,text:r,fix:null},l),ee(e,c)})(a,e.key,t))},children:[(0,t.jsx)(A,{className:"mr-1 h-4 w-4"}),C.importBatch.splitHere]}),p&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:p,disabled:y||!e.text.trim(),children:[f?(0,t.jsx)(l.f,{className:"mr-1 h-4 w-4 animate-spin"}):(0,t.jsx)(I.f,{className:"mr-1 h-4 w-4"}),f?C.importBatch.fixText.running:C.importBatch.fixText.one]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:u,children:[(0,t.jsx)(N,{className:"mr-1 h-4 w-4"}),e.regions.length?C.importBatch.adjustRegion:C.importBatch.locate]}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:()=>d(t=>(function(e,t){let a=et(e,t);if(a<0||e.items.length>=L.S)return e;let s=e.items[a],i={...s,key:Y(e.items.map(e=>e.key)),label:null,regions:s.regions.map(e=>({...e}))},r=[...e.items];return r.splice(a+1,0,i),ee(e,r)})(t,e.key)),children:[(0,t.jsx)(v.f,{className:"mr-1 h-4 w-4"}),C.importBatch.duplicate]})]}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",disabled:0===s,onClick:()=>d(t=>(function(e,t){let a=et(e,t);if(a<=0)return e;let s=e.items[a-1],i=e.items[a],r={...s,text:[s.text,i.text].filter(e=>e.trim()).join("\n").slice(0,2e4),material:s.material??i.material,selected:s.selected||i.selected,regions:[...s.regions,...i.regions].slice(0,4),hasFigure:s.hasFigure||i.hasFigure,flags:[...new Set([...s.flags,...i.flags])].filter(e=>"unlocated"!==e||s.regions.length+i.regions.length===0),answer:er(s.answer,i.answer)?.slice(0,2e4)??null,analysis:er(s.analysis,i.analysis)?.slice(0,2e4)??null,knowledgePoints:[...new Set([...s.knowledgePoints??[],...i.knowledgePoints??[]])].slice(0,100),difficultyStars:s.difficultyStars??i.difficultyStars,questionType:s.questionType??i.questionType,wrongAnswer:er(s.wrongAnswer,i.wrongAnswer)?.slice(0,2e4)??null,fix:null},n=[...e.items];return n.splice(a-1,2,r),ee(e,n)})(t,e.key)),children:[(0,t.jsx)(z,{className:"mr-1 h-4 w-4"}),C.importBatch.mergeUp]}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",disabled:0===s,onClick:()=>d(t=>ei(t,e.key,-1)),"aria-label":C.importBatch.moveUp,children:(0,t.jsx)(b,{className:"h-4 w-4"})}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",disabled:s===i-1,onClick:()=>d(t=>ei(t,e.key,1)),"aria-label":C.importBatch.moveDown,children:(0,t.jsx)(g,{className:"h-4 w-4"})}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>d(t=>es(t,e.key)),children:[(0,t.jsx)(M.f,{className:"mr-1 h-4 w-4"}),C.importBatch.delete]})]})]})]})}function ew({count:e,missingRegions:a,pendingFixes:s=0,confirmBeforeImport:i,starting:r,onStart:n,onDiscard:c,source:o,analysisMode:d,onAnalysisModeChange:m,hasTargetNotebook:u}){let{t:h}=(0,x.b)(),p="none"===d,f="tags"===d,g=p?(i?h.importBatch.startNoneReview:h.importBatch.startNoneAuto).replace("{count}",String(e)):f?(i?h.importBatch.startTagsReview:h.importBatch.startTagsAuto).replace("{count}",String(e)):(i?h.importBatch.startReview:h.importBatch.startAuto).replace("{count}",String(e)),y=0===e?h.importBatch.nothingSelected:a>0?h.importBatch.needsRegion.replace("{count}",String(a)):p?h.importBatch.startHintNone:f?h.importBatch.startHintTags:s>0?h.importBatch.fixText.pendingHint.replace("{count}",String(s)):i?h.importBatch.startHintReview:h.importBatch.startHintAuto,b=(p||f)&&!u,j=b?h.importBatch.startNoneNoTarget:void 0;return(0,t.jsx)("div",{className:"fixed inset-x-0 bottom-[calc(4rem+env(safe-area-inset-bottom))] z-30 border-t bg-background/95 py-3 pl-4 pr-16 shadow-[0_-4px_12px_rgba(0,0,0,0.06)] backdrop-blur md:sticky md:bottom-4 md:rounded-xl md:border md:px-4","data-testid":"draft-start-bar",children:(0,t.jsxs)("div",{className:"mx-auto flex max-w-4xl flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:["text"===o&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:"radiogroup","aria-label":h.importBatch.analysisModeLabel,children:[(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":"ai"===d,disabled:!!r,onClick:()=>m("ai"),className:`rounded-full border px-2.5 py-1 transition-colors ${"ai"===d?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:border-primary/40"}`,"data-testid":"draft-analysis-ai",children:h.importBatch.analysisAi}),(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":f,disabled:!!r||b,onClick:()=>m("tags"),title:j,className:`rounded-full border px-2.5 py-1 transition-colors ${f?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:border-primary/40"} disabled:cursor-not-allowed disabled:opacity-50`,"data-testid":"draft-analysis-tags",children:h.importBatch.analysisTags}),(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":p,disabled:!!r||b,onClick:()=>m("none"),title:j,className:`rounded-full border px-2.5 py-1 transition-colors ${p?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:border-primary/40"} disabled:cursor-not-allowed disabled:opacity-50`,"data-testid":"draft-analysis-none",children:h.importBatch.analysisNone})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground md:max-w-md","data-testid":"draft-start-hint",children:r??y})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(ex.f,{type:"button",variant:"ghost",onClick:c,disabled:!!r,className:"shrink-0",children:h.importBatch.discard}),(0,t.jsxs)(ex.f,{type:"button",onClick:n,disabled:0===e||!!r,className:"min-w-0 flex-1 md:flex-none","data-testid":"draft-start",children:[r?(0,t.jsx)(l.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(I.f,{className:"mr-2 h-4 w-4"}),(0,t.jsx)("span",{className:"truncate",children:g})]})]})]})})}function ev({ignored:e,onRestore:s}){let{t:i}=(0,x.b)(),[r,n]=(0,a.useState)(!1);return 0===e.length?null:(0,t.jsxs)("section",{className:"rounded-xl border p-3",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between text-left text-sm font-medium",onClick:()=>n(e=>!e),"aria-expanded":r,children:[i.importBatch.ignoredTitle.replace("{count}",String(e.length)),r?(0,t.jsx)(w.f,{className:"h-4 w-4"}):(0,t.jsx)(j.f,{className:"h-4 w-4"})]}),r&&(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:i.importBatch.ignoredHint}),(0,t.jsx)("ul",{className:"space-y-2",children:e.map((e,a)=>(0,t.jsxs)("li",{className:"flex items-start gap-2 rounded-lg bg-muted/50 p-2 text-sm",children:[(0,t.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words text-muted-foreground",children:e}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"outline",className:"h-7 shrink-0",onClick:()=>s(a),children:i.importBatch.addAsQuestion})]},`${a}-${e.slice(0,20)}`))})]})]})}function ek({imageUrl:e,items:s,onSelectItem:i,highlightedKey:r}){let{t:n}=(0,x.b)(),[l,c]=(0,a.useState)(!0);return(0,t.jsxs)("section",{className:"rounded-xl border bg-card p-3","data-testid":"page-image-overview",children:[(0,t.jsxs)(ex.f,{type:"button",variant:"ghost",size:"sm",className:"mb-2 h-8 px-2 md:hidden",onClick:()=>c(e=>!e),"aria-expanded":l,children:[l?(0,t.jsx)(w.f,{className:"mr-1 h-4 w-4"}):(0,t.jsx)(j.f,{className:"mr-1 h-4 w-4"}),l?n.importBatch.hideImage:n.importBatch.showImage]}),(0,t.jsxs)("div",{className:(0,em.f)("relative mx-auto w-fit max-w-full",!l&&"hidden md:block"),children:[(0,t.jsx)("img",{src:e,alt:"",className:"block max-h-[70vh] max-w-full select-none rounded-md",draggable:!1}),s.map((e,a)=>e.regions.map((s,l)=>(0,t.jsx)("button",{type:"button",onClick:()=>i(e.key),className:(0,em.f)("absolute rounded-sm border-2 transition-colors",e.selected?"border-primary bg-primary/10":"border-dashed border-muted-foreground/70 bg-transparent",r===e.key&&"border-amber-500 bg-amber-400/20"),style:{left:`${100*s.x}%`,top:`${100*s.y}%`,width:`${100*s.width}%`,height:`${100*s.height}%`},"aria-label":n.importBatch.question.replace("{index}",String(a+1)),children:0===l&&(0,t.jsx)("span",{className:(0,em.f)("absolute -left-0.5 -top-0.5 rounded-br-md px-1.5 text-xs font-semibold text-white",e.selected?"bg-primary":"bg-muted-foreground"),children:a+1})},`${e.key}-${l}`)))]})]})}var eN=e.i(232660),eB=e.i(776639);let eS={x:.1,y:.1,width:.8,height:.3};function eC(e){return{unit:"%",x:100*e.x,y:100*e.y,width:100*e.width,height:100*e.height}}function ez(e){let t={x:e.x/100,y:e.y/100,width:e.width/100,height:e.height/100};return t.width>=.01&&t.height>=.01?t:null}function eT({open:e,imageUrl:s,regions:i,onClose:r,onSave:n}){let{t:l}=(0,x.b)(),[o,d]=(0,a.useState)(()=>(i.length?i:[eS]).map(eC)),[m,u]=(0,a.useState)(0),h=o[Math.min(m,o.length-1)];return(0,t.jsx)(eB.N,{open:e,onOpenChange:e=>!e&&r(),children:(0,t.jsxs)(eB.d,{className:"flex h-[90vh] max-w-3xl flex-col gap-0 p-0",children:[(0,t.jsxs)(eB.s,{className:"shrink-0 border-b p-4",children:[(0,t.jsx)(eB.F,{children:l.importBatch.regionDialogTitle}),(0,t.jsx)(eB.C,{children:l.importBatch.regionDialogHint})]}),(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-auto bg-black p-3",children:(0,t.jsx)("div",{className:"mx-auto w-fit",children:(0,t.jsx)(eN.f,{crop:h,onChange:(e,t)=>d(e=>e.map((e,a)=>a===m?t:e)),children:(0,t.jsx)("img",{src:s,alt:"",className:"block max-h-[65vh] max-w-full",draggable:!1})})})}),(0,t.jsxs)("div",{className:"shrink-0 space-y-3 border-t p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[o.map((e,a)=>(0,t.jsx)("button",{type:"button",onClick:()=>u(a),className:(0,em.f)("rounded-md border px-3 py-1 text-sm",a===m?"border-primary bg-primary/10 font-medium":"text-muted-foreground"),children:l.importBatch.regionTab.replace("{index}",String(a+1))},a)),o.length<4&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:()=>{d(e=>[...e,eC(eS)]),u(o.length)},children:[(0,t.jsx)(c.f,{className:"mr-1 h-4 w-4"}),l.importBatch.addRegion]}),o.length>1&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{d(e=>e.filter((e,t)=>t!==m)),u(0)},children:[(0,t.jsx)(M.f,{className:"mr-1 h-4 w-4"}),l.importBatch.removeRegion]})]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(ex.f,{type:"button",variant:"outline",onClick:r,children:l.common.cancel}),(0,t.jsx)(ex.f,{type:"button",onClick:()=>{let e=o.map(ez).filter(e=>null!==e);e.length&&n(e)},children:l.importBatch.saveRegion})]})]})]})})}let eA={name:"check-check",size:24,node:[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]};eA.node;let eI=(0,o.f)(eA);function eM({targetCount:e,pendingCount:a,fixing:s,onFix:i,onAcceptAll:r}){let{t:n}=(0,x.b)();return(0,t.jsxs)("div",{className:"space-y-1 rounded-lg border border-dashed p-3","data-testid":"text-fix-toolbar",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:i,disabled:s||0===e,children:[s?(0,t.jsx)(l.f,{className:"mr-1 h-4 w-4 animate-spin"}):(0,t.jsx)(I.f,{className:"mr-1 h-4 w-4"}),s?n.importBatch.fixText.running:n.importBatch.fixText.selected.replace("{count}",String(e))]}),a>0&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",onClick:r,children:[(0,t.jsx)(eI,{className:"mr-1 h-4 w-4"}),n.importBatch.fixText.acceptAll.replace("{count}",String(a))]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.importBatch.fixText.hint})]})}var e$=e.i(767077),eR=e.i(499930),eE=e.i(294114),eP=e.i(201276),eF=e.i(119472),eq=e.i(213761);function eD({batch:e,draft:s,onEdit:i,onUndo:r,canUndo:o,saveState:d,image:u,confirmBeforeImport:h,starting:f,onStart:g,onDiscard:y,analysisMode:b,onAnalysisModeChange:j,hasConflictCopy:w,onRestoreConflict:v,onDismissConflict:k}){let{t:N}=(0,x.b)(),B=e.source,[S,C]=(0,a.useState)(null),[z,T]=(0,a.useState)(null),[A,I]=(0,a.useState)(null),M=s.items.filter(e=>e.selected&&Z(e,B)),$=s.items.length>0&&s.items.every(e=>e.selected||!Z(e,B)),R=s.items.filter(e=>e.selected&&!Z(e,B)).length,E=function(e,t,s){let{t:i}=(0,x.b)(),[r,n]=(0,a.useState)([]);return{fix:(0,a.useCallback)(async a=>{let r=t.items.filter(e=>a.includes(e.key)&&e.text.trim()).map(e=>({key:e.key,text:e.text}));if(0!==r.length){n(r.map(e=>e.key));try{let t=await (0,eF.$)(e,r);t.fixes.length>0&&s(e=>{let a,s,i;return a=new Map(t.fixes.map(e=>[e.key,e])),s=!1,i=e.items.map(e=>{let t=a.get(e.key);return t&&e.text===t.original&&t.text!==t.original?(s=!0,{...e,fix:{original:t.original,text:t.text,uncertain:t.uncertain}}):e}),s?ee(e,i):e});let a=[t.fixes.length>0?i.importBatch.fixText.done.replace("{count}",String(t.fixes.length)):null,t.unchanged.length>0?i.importBatch.fixText.unchanged.replace("{count}",String(t.unchanged.length)):null,t.failed.length>0?i.importBatch.fixText.failed.replace("{count}",String(t.failed.length)):null].filter(Boolean).join(" ");t.failed.length>0?eE.c.warning(a):eE.c.success(a)}catch(e){eP.V.error("[ImportBatch]","Text fix failed",{error:e}),eE.c.error((0,e$.f)(e,i))}finally{n([])}}},[e,t,s,i]),fixingKeys:r,fixing:r.length>0}}(e.id,s,i),P=function(e,t,s,i){let{t:r,language:n}=(0,x.b)(),l=(0,a.useRef)(null),c=(0,a.useRef)(null),[o,d]=(0,a.useState)(null),[m,u]=(0,a.useState)([]),h=async a=>{let l=a.target.files?.[0];a.target.value="";let o=s.items.find(e=>e.key===c.current);if(l&&o&&t){d(o.key);try{let a=await (0,eq.p)(l);try{let s=await (0,eR.y)(t),l=await (0,eR.k)(s,o.regions,a),c={...(0,eq.N)(a,l),sourceType:"continuation"},d=await (0,eF.v)({source:"image",imageBase64:l.dataUrl,imageInfo:c,language:n,subjectId:e.subjectId,targetSubjectId:e.targetSubjectId,paperLevel:e.paperLevel});i(e=>es(e,o.key)),u(e=>[...e,d.id]),eP.V.info("[ImportBatch]","Continuation batch created",{batchId:d.id,...c}),eE.c.success(r.importBatch.continuation.created)}finally{a.dispose()}}catch(e){eP.V.error("[ImportBatch]","Continuation failed",{error:e}),eE.c.error(e instanceof eq.o?r.upload.decodeErrors[e.code].replace("{format}",e.format.toUpperCase()):(0,e$.f)(e,r))}finally{d(null)}}};return{pick:e=>{c.current=e,l.current?.click()},busyKey:o,created:m,inputProps:{ref:l,onChange:e=>void h(e)}}}(e,u?.url??null,s,i),F="text"===B?s.items.filter(e=>e.fix&&e.fix.original===e.text).length:0,q="text"===B?M.filter(e=>!(e.fix&&e.fix.original===e.text)).map(e=>e.key):[];return(0,t.jsxs)("div",{className:"space-y-4 pb-36 md:pb-24",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("p",{className:"text-base font-semibold","data-testid":"draft-summary",children:[N.importBatch.detected.replace("{count}",String(s.items.length)),(0,t.jsx)("span",{className:"mx-2 text-muted-foreground",children:"·"}),N.importBatch.selected.replace("{count}",String(M.length))]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)("span",{className:"mr-2 flex items-center gap-1 text-xs text-muted-foreground","aria-live":"polite","data-testid":"draft-save-state","data-state":d,children:["saving"===d&&(0,t.jsx)(l.f,{className:"h-3 w-3 animate-spin"}),N.importBatch.save[d]]}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",disabled:!o,onClick:r,children:[(0,t.jsx)(m,{className:"mr-1 h-4 w-4"}),N.importBatch.undo]}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:()=>i(e=>(function(e,t,a=()=>!0){return ee(e,e.items.map(e=>({...e,selected:t&&a(e)})))})(e,!$,e=>Z(e,B))),children:$?N.importBatch.selectNone:N.importBatch.selectAll})]})]}),w&&(0,t.jsxs)("div",{className:"space-y-2 rounded-lg border border-primary/40 bg-primary/5 p-3 text-sm",role:"status","data-testid":"draft-conflict",children:[(0,t.jsx)("p",{children:N.importBatch.conflictKept}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(ex.f,{type:"button",size:"sm",onClick:v,children:N.importBatch.restoreMine}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:k,children:N.importBatch.discardMine})]})]}),"text"===B&&s.items.length>0&&(0,t.jsx)(eM,{targetCount:q.length,pendingCount:F,fixing:E.fixing,onFix:()=>void E.fix(q),onAcceptAll:()=>i(e=>en(e))}),s.warnings.length>0&&(0,t.jsx)("ul",{className:"space-y-1 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200",children:s.warnings.map(e=>(0,t.jsxs)("li",{className:"flex items-start gap-2",children:[(0,t.jsx)(n.f,{className:"mt-0.5 h-4 w-4 shrink-0"}),N.importBatch.warnings[e]]},e))}),(0,t.jsx)(p,{inputProps:P.inputProps,created:P.created}),u&&(0,t.jsx)(ek,{imageUrl:u.url,items:s.items,onSelectItem:e=>{T(e),C(e),document.getElementById(`draft-item-${e}`)?.scrollIntoView({behavior:"smooth",block:"center"})},highlightedKey:z}),0===s.items.length?(0,t.jsx)("p",{className:"rounded-xl border border-dashed p-6 text-center text-sm text-muted-foreground",children:N.importBatch.emptyDraft}):(0,t.jsx)("ol",{className:"space-y-3",children:s.items.map((e,a)=>{var r;return(0,t.jsx)(ej,{item:e,index:a,total:s.items.length,source:B,expanded:S===e.key,onToggleExpand:()=>C(t=>t===e.key?null:e.key),onEdit:i,image:u,onAdjustRegion:()=>I({key:e.key,regions:e.regions}),highlighted:z===e.key,onFixText:"text"===B?()=>void E.fix([e.key]):void 0,fixing:E.fixingKeys.includes(e.key),fixBusy:E.fixing,onContinue:u&&(r=s.items.length,e.regions.length>0&&(e.flags.includes("partial")||a===r-1))?()=>P.pick(e.key):void 0,continuing:P.busyKey===e.key},e.key)})}),u&&(0,t.jsxs)(ex.f,{type:"button",variant:"outline",size:"sm",onClick:()=>I({key:null,regions:[]}),children:[(0,t.jsx)(c.f,{className:"mr-1 h-4 w-4"}),N.importBatch.addQuestion]}),(0,t.jsx)(ev,{ignored:s.ignored,onRestore:e=>i(t=>(function(e,t){let a=e.ignored[t];if(void 0===a||e.items.length>=L.S)return e;let s={key:Y(e.items.map(e=>e.key)),label:null,text:a,material:null,section:null,selected:!0,regions:[],hasFigure:!1,flags:[]};return{...e,items:[...e.items,s],ignored:e.ignored.filter((e,a)=>a!==t)}})(t,e))}),(0,t.jsx)(ew,{count:M.length,missingRegions:R,pendingFixes:F,confirmBeforeImport:h,starting:f,onStart:g,onDiscard:y,source:B,analysisMode:b,onAnalysisModeChange:j,hasTargetNotebook:!!e.targetSubjectId||!!e.subjectId}),u&&A&&(0,t.jsx)(eT,{open:!0,imageUrl:u.url,regions:A.regions,onClose:()=>I(null),onSave:e=>{let t=A.key;i(a=>t?ea(a,t,{regions:e,selected:!0}):function(e,t){if(e.items.length>=L.S)return e;let a={key:Y(e.items.map(e=>e.key)),label:null,text:"",material:null,section:null,selected:!0,regions:[t],hasFigure:!1,flags:[]};return{...e,items:[...e.items,a]}}(a,e[0])),I(null)}})]})}var eH=e.i(399847),eU=e.i(395925);function e_({batch:e,busy:a,onRetry:s,onDiscard:i}){let{t:r}=(0,x.b)(),n=r.errors,c=e.error?"string"==typeof n[e.error]?n[e.error]:e.error:null;return"splitting"===e.phase?(0,t.jsxs)("section",{className:"flex items-start gap-3 rounded-xl border bg-card p-4",role:"status","data-testid":"batch-splitting",children:[(0,t.jsx)(l.f,{className:"mt-0.5 h-5 w-5 shrink-0 animate-spin text-primary"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,t.jsx)("p",{className:"font-medium",children:r.importBatch.phase.splitting}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:r.importBatch.splittingHint}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:i,children:r.importBatch.discard})]})]}):(0,t.jsxs)("section",{className:"flex items-start gap-3 rounded-xl border border-destructive/40 bg-card p-4","data-testid":"batch-failed",children:[(0,t.jsx)(eH.f,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,t.jsx)("p",{className:"font-medium",children:r.importBatch.phase.failed}),c&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:c}),"image"===e.source&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:r.importBatch.manualFallback}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",onClick:s,disabled:a,children:[(0,t.jsx)(eU.f,{className:"mr-1 h-4 w-4"}),r.importBatch.retrySplit]}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:i,children:r.importBatch.discard})]})]})]})}var eO=e.i(551757),eL=e.i(615568),eV=e.i(168148);let eK={analyzing:.5,saving:.9,review:1,saved:1,failed:1};function eG({task:e}){let{t:a}=(0,x.b)(),s=a.importBatch.itemStatus;if("saved"===e.status){let a=e.errorItemId?e.duplicate?s.duplicate:s.saved:s.deleted;return(0,t.jsxs)("span",{className:"flex items-center gap-1 text-green-700 dark:text-green-300",children:[(0,t.jsx)(eO.f,{className:"h-4 w-4"}),a]})}return"failed"===e.status?(0,t.jsxs)("span",{className:"flex items-center gap-1 text-destructive",children:[(0,t.jsx)(eH.f,{className:"h-4 w-4"}),s.failed]}):"review"===e.status?(0,t.jsxs)("span",{className:"flex items-center gap-1 text-primary",children:[(0,t.jsx)(eL.f,{className:"h-4 w-4"}),s.review]}):(0,t.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:[(0,t.jsx)(l.f,{className:"h-4 w-4 animate-spin"}),s[e.status]]})}function eQ({batch:e,image:a,busy:i,onRetryFailed:r,onRetryOne:n,onConfirmAll:l}){let{t:c}=(0,x.b)(),{counts:o}=e,d=o.total-o.active,m=o.total?Math.round(e.tasks.reduce((e,t)=>e+eK[t.status],0)/o.total*100):0,u=new Map((e.draft?.items??[]).map((e,t)=>[e.key,{item:e,index:t}])),h=c.errors;return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("section",{className:"space-y-3 rounded-xl border bg-card p-4","data-testid":"batch-progress","data-phase":e.phase,children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,t.jsx)("p",{className:"text-base font-semibold",children:c.importBatch.progress.replace("{done}",String(d)).replace("{total}",String(o.total))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.importTasks.stageEstimate})]}),(0,t.jsx)(eV.f,{value:m,"aria-label":c.importTasks.stageEstimate,"aria-valuetext":c.common.progress.estimated.replace("{percent}",String(m)),className:"h-2"}),(0,t.jsxs)("ul",{className:"flex flex-wrap gap-x-4 gap-y-1 text-sm","data-testid":"batch-counts",children:[(0,t.jsx)("li",{className:"text-green-700 dark:text-green-300",children:c.importBatch.counts.saved.replace("{count}",String(o.saved-o.duplicate))}),o.duplicate>0&&(0,t.jsx)("li",{className:"text-muted-foreground",children:c.importBatch.counts.duplicate.replace("{count}",String(o.duplicate))}),o.review>0&&(0,t.jsx)("li",{className:"text-primary",children:c.importBatch.counts.review.replace("{count}",String(o.review))}),o.failed>0&&(0,t.jsx)("li",{className:"text-destructive",children:c.importBatch.counts.failed.replace("{count}",String(o.failed))}),o.active>0&&(0,t.jsx)("li",{className:"text-muted-foreground",children:c.importBatch.counts.active.replace("{count}",String(o.active))})]}),o.active>0&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.importBatch.leaveHint}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[o.failed>0&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",onClick:r,disabled:i,children:[(0,t.jsx)(eU.f,{className:"mr-1 h-4 w-4"}),c.importBatch.retryFailed.replace("{count}",String(o.failed))]}),o.review>0&&(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:l,disabled:i,children:c.importBatch.confirmAll.replace("{count}",String(o.review))})]})]}),(0,t.jsx)("ol",{className:"space-y-3",children:e.tasks.map(e=>{let r=u.get(e.batchItemKey??""),l=e.error?"string"==typeof h[e.error]?h[e.error]:e.error:null;return(0,t.jsxs)("li",{className:(0,em.f)("flex gap-3 rounded-xl border bg-card p-3 text-sm",e.unread&&"review"===e.status&&"border-primary/50"),"data-testid":"batch-task","data-status":e.status,children:[a&&r&&r.item.regions.length>0&&(0,t.jsx)(eu,{imageUrl:a.url,imageSize:a,regions:r.item.regions,className:"w-20 shrink-0 self-start sm:w-28"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:c.importBatch.question.replace("{index}",String((r?.index??0)+1))}),(0,t.jsx)(eG,{task:e})]}),(0,t.jsx)("p",{className:"line-clamp-2 break-words text-muted-foreground",children:e.excerpt||r?.item.text}),"saved"===e.status&&e.errorItemId&&!e.duplicate&&e.notebookName&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.importTasks.savedTo.replace("{notebook}",e.notebookName).replace("{id}",e.errorItemShortId||"-")}),l&&"failed"===e.status&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:l}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 pt-1",children:["review"===e.status&&(0,t.jsx)(ex.f,{asChild:!0,size:"sm",children:(0,t.jsx)(s.default,{href:`/import-tasks/${e.id}`,children:c.importBatch.review})}),"saved"===e.status&&e.errorItemId&&(0,t.jsx)(ex.f,{asChild:!0,size:"sm",variant:"outline",children:(0,t.jsx)(s.default,{href:`/error-items/${e.errorItemId}`,children:c.importBatch.viewItem})}),"failed"===e.status&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:()=>n(e),disabled:i,children:[(0,t.jsx)(eU.f,{className:"mr-1 h-3 w-3"}),c.importTasks.retry]})]})]})]},e.id)})})]})}var eW=e.i(912505),eX=e.i(393842),eY=e.i(86963),eZ=e.i(127175),eJ=e.i(35209),e0=e.i(25197);e.s(["default",0,function(){let e=(0,i.useParams)(),n=(0,i.useRouter)(),l=e.id,{t:c}=(0,x.b)();(0,eJ.f)(c.importBatch.title);let o=function(e,t={}){let[s,i]=(0,a.useState)(null),[r,n]=(0,a.useState)(!1),[l,c]=(0,a.useState)(null),[o,d]=(0,a.useState)("saved"),m=(0,a.useRef)([]),[u,h]=(0,a.useState)(!1),x=(0,a.useRef)(0),p=(0,a.useRef)(0),f=(0,a.useRef)(0),g=(0,a.useRef)(null),y=(0,a.useRef)(null),b=(0,a.useRef)(null),j=(0,a.useRef)(async()=>!0),[w,v]=(0,a.useState)(null),k=(0,a.useRef)(t.onConflict);(0,a.useEffect)(()=>{k.current=t.onConflict},[t.onConflict]);let N=(0,a.useCallback)((e,t=!1)=>{i(t=>t&&!e.imageData&&t.imageData&&t.id===e.id?{...e,imageData:t.imageData}:e);let a=p.current!==f.current;(t||!a||"draft"!==e.status)&&(null!==g.current&&e.version!==x.current&&(m.current=[],h(!1)),x.current=e.version,g.current=e.draft,c(e.draft),f.current=p.current,d("saved"))},[]),B=(0,a.useCallback)(async()=>{if("u"<typeof document||"hidden"!==document.visibilityState)try{N(await (0,eF.w)(e)),n(!1)}catch(e){e?.status===404&&n(!0)}},[e,N]);(0,a.useEffect)(()=>{let t=!1;(0,eF.w)(e,{image:!0}).then(e=>{t||N(e,!0)}).catch(e=>{t||e?.status!==404||n(!0)});let a=(0,eZ.E)(()=>void B());return()=>{t=!0,a()}},[e,N,B]);let S=s?.phase==="splitting"||s?.phase==="processing";(0,a.useEffect)(()=>{if(!S)return;let e=setInterval(()=>void B(),2500);return()=>clearInterval(e)},[S,B]);let C=(0,a.useCallback)(async()=>{let t=p.current;d("saving");try{let a=await (0,eF.S)(e,x.current,g.current);return x.current=a.version,f.current=t,i(e=>e?{...a,imageData:e.imageData}:a),d(p.current===t?"saved":"dirty"),"ok"}catch(t){let e=(0,eF.n)(t);if(e){let t=g.current;return"draft"===e.status&&t&&v(t),N(e,!0),k.current?.(),"conflict"}return d("error"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>void j.current(),5e3),"error"}},[e,N]),z=(0,a.useCallback)(async()=>{for(b.current&&(clearTimeout(b.current),b.current=null);;){let e=y.current??(y.current=(async()=>{try{for(;p.current!==f.current&&g.current;)if(await C()!=="ok")return!1;return!0}finally{y.current=null}})());if(!await e)return!1;if(p.current===f.current)return!0}},[C]);(0,a.useEffect)(()=>{j.current=z},[z]),(0,a.useEffect)(()=>{let e=()=>{"hidden"===document.visibilityState&&p.current!==f.current&&z()};return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("pagehide",e)}},[z]),(0,a.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);let T=(0,a.useCallback)(e=>{g.current=e,c(e),p.current+=1,d("dirty"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>void z(),800)},[z]),A=(0,a.useRef)(null),I=(0,a.useCallback)((e,t)=>{let a=g.current;if(!a)return;let s=e(a);if(s===a)return;let i=Date.now(),r=t&&A.current?.group===t&&i-A.current.at<1500;A.current=t?{group:t,at:i}:null,r||(m.current=[...m.current.slice(-29),a],h(!0)),T(s)},[T]),M=(0,a.useCallback)(()=>{let e=m.current.pop();A.current=null,h(m.current.length>0),e&&T(e)},[T]),$=(0,a.useCallback)(()=>{v(null),w&&I(()=>w)},[w,I]);return{batch:s,draft:l,notFound:r,saveState:o,refresh:B,save:z,edit:I,undo:M,canUndo:u,conflictCopy:w,restoreConflictCopy:$,dismissConflictCopy:()=>v(null),version:()=>x.current,replace:e=>N(e,!0)}}(l,{onConflict:()=>eE.c.info(c.importBatch.conflict)}),{batch:d,draft:m,notFound:u}=o,h=function(e){let[t,s]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(!e)return;let t=!1,a=new Image;return a.onload=()=>{t||s({url:e,width:a.naturalWidth,height:a.naturalHeight})},a.src=e,()=>{t=!0}},[e]),t&&t.url===e?t:null}(d?.source==="image"?d.imageData:null),[p,f]=(0,a.useState)(null),[g,y]=(0,a.useState)(null),[b,j]=(0,a.useState)(!1),[w,v]=(0,a.useState)("ai"),k=(0,a.useRef)(null),[N,B]=(0,a.useState)(null);if(m!==N&&(B(m),m&&d?.source==="text")){let e=J(m,"text");v(e.length>0&&e.every(e=>e.answer?.trim())?"tags":"ai")}if((0,a.useEffect)(()=>{(0,e0.x)().then(f)},[]),(0,a.useEffect)(()=>{d?.unread&&k.current!==`${d.id}:${d.phase}:${d.counts.active}`&&(k.current=`${d.id}:${d.phase}:${d.counts.active}`,(0,eF.f)(d.id).catch(e=>eP.V.warn("[ImportBatch]","Mark read failed",{error:e})))},[d]),u)return(0,t.jsx)("main",{className:"mx-auto max-w-3xl px-4 py-6 md:px-8 md:py-8",children:(0,t.jsx)(eW.f,{icon:r.f,title:c.importBatch.notFound,action:(0,t.jsx)(s.default,{href:"/import-tasks",children:(0,t.jsx)(ex.f,{children:c.importTasks.viewTasks})})})});if(!d||null===p||"image"===d.source&&"draft"===d.status&&!h)return(0,t.jsx)(eY.f,{});let S=async e=>{j(!0);try{await e()}catch(t){let e=(0,eF.n)(t);e?(o.replace(e),eE.c.info(c.importBatch.conflict)):eE.c.error((0,e$.f)(t,c))}finally{j(!1)}},C=async()=>{if(m){y(c.importBatch.submitting);try{let e;if(!await o.save())return;if("image"===d.source){if(!d.imageData)throw Error("IMAGE_EMPTY");let t=await (0,eR.y)(d.imageData),a=J(m,"image");e=[];let s=0;for(let i of a){y(c.importBatch.cropping.replace("{done}",String(e.length+1)).replace("{total}",String(a.length)));let r=await (0,eR.M)(t,i.regions);s+=r.bytes,e.push({key:i.key,imageBase64:r.dataUrl,imageInfo:{outputWidth:r.width,outputHeight:r.height,outputBytes:r.bytes,quality:r.quality}})}if(e.reduce((e,t)=>e+t.imageBase64.length,0)>0x3c00000)return void eE.c.error(c.errors.IMPORT_BATCH_TOO_LARGE);y(c.importBatch.uploadingImages.replace("{count}",String(e.length)).replace("{size}",`${(s/1024/1024).toFixed(1)}MB`))}o.replace(await (0,eF.g)(d.id,o.version(),e,w)),window.scrollTo({top:0})}catch(t){eP.V.error("[ImportBatch]","Start failed",{error:t});let e=(0,eF.n)(t);e?(o.replace(e),eE.c.info(c.importBatch.conflict)):eE.c.error((0,e$.f)(t,c))}finally{y(null)}}},z=async()=>{await (0,eE.u)(c.importBatch.discardConfirm)&&await S(async()=>{await (0,eF.o)(d.id),eE.c.success(c.importBatch.discarded),n.push("/import-tasks")})},T=()=>S(async()=>{o.replace(await (0,eF.s)(d.id)),eE.c.info(c.importTasks.retried)}),A=`${c.importBatch.source[d.source]} \xb7 ${c.importBatch.phase[d.phase]}`;return(0,t.jsxs)("main",{className:"mx-auto max-w-4xl space-y-4 px-4 py-6 md:px-8 md:py-8",children:[(0,t.jsx)(eX.f,{backHref:"/import-tasks",title:c.importBatch.title,description:A}),"splitting"===d.phase||"failed"===d.phase?(0,t.jsx)(e_,{batch:d,busy:b,onRetry:T,onDiscard:z}):"draft"===d.status&&m?(0,t.jsx)(eD,{batch:d,draft:m,onEdit:o.edit,onUndo:o.undo,canUndo:o.canUndo,saveState:o.saveState,image:h,confirmBeforeImport:p,starting:g,onStart:C,onDiscard:z,analysisMode:w,onAnalysisModeChange:v,hasConflictCopy:!!o.conflictCopy,onRestoreConflict:o.restoreConflictCopy,onDismissConflict:o.dismissConflictCopy}):(0,t.jsx)(eQ,{batch:d,image:h,busy:b,onRetryFailed:T,onRetryOne:e=>S(async()=>{await (0,eZ.R)(e.id),eE.c.info(c.importTasks.retried),await o.refresh()}),onConfirmAll:()=>S(async()=>{let e=await (0,eF.J)(d.id);o.replace(e.batch),eE.c.success(c.importBatch.confirmAllDone.replace("{count}",String(e.saved)))})})]})}],864272)}]);
@@ -1 +0,0 @@
1
- (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,711241,e=>{var t=e.i(456420);let r={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};r.node;let a=(0,t.f)(r);e.s(["f",0,a],711241)},576248,e=>{var t=e.i(456420);let r={name:"circle-question-mark",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["help-circle","circle-help"]};r.node;let a=(0,t.f)(r);e.s(["f",0,a],576248)},856522,e=>{var t=e.i(456420);let r={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]};r.node;let a=(0,t.f)(r);e.s(["f",0,a],856522)},652109,e=>{var t=e.i(843476),r=e.i(271645),a=e.i(618566),s=e.i(632781),i=e.i(711241),n=e.i(519455),l=e.i(515288),c=e.i(624687),d=e.i(793479),o=e.i(511445),u=e.i(522016),m=e.i(548161),x=e.i(856522),g=e.i(393733),f=e.i(111110),h=e.i(41931),p=e.i(201276);function b({errorItemId:e,suggested:a,question:i,difficulty:c}){let{t:d}=(0,f.b)(),[o,j]=(0,r.useState)(a),[y,v]=(0,r.useState)(!1),[N,w]=(0,r.useState)(!1),[k,S]=(0,r.useState)(null),A=async()=>{if(o){v(!0),S(null);try{await h.k.post("/api/practice/record",{errorItemId:e,result:o,difficulty:c,subject:i.subject||null,questionText:i.questionText,answerText:i.answerText,analysis:i.analysis,figureSvg:i.figureSvg??null}),w(!0)}catch(e){p.V.error("[Practice]","Failed to save practice result",{error:e instanceof Error?e.message:String(e)}),S(d.mastery.resultSaveFailed)}finally{v(!1)}}};return(0,t.jsxs)(l.N,{className:N?"border-green-500":"border-primary/40",children:[(0,t.jsx)(l.Y,{children:(0,t.jsx)(l.v,{className:"text-base",children:d.mastery.markResult})}),(0,t.jsxs)(l.O,{className:"space-y-3",children:[(0,t.jsx)(g.f,{value:o,onChange:j,disabled:N||y}),a&&!N&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:d.mastery.suggested}),N?(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 text-sm text-green-700 dark:text-green-300",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(m.f,{className:"h-4 w-4"}),d.mastery.resultSaved]}),(0,t.jsx)(u.default,{href:`/error-items/${e}`,className:"text-primary hover:underline sm:ml-auto",children:d.mastery.viewQuestion})]}):(0,t.jsxs)(n.f,{onClick:A,disabled:!o||y,className:"w-full sm:w-auto",children:[y?(0,t.jsx)(s.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(x.f,{className:"mr-2 h-4 w-4"}),d.mastery.saveResult]}),k&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:k})]})]})}var j=e.i(149704);let y={easy:"bg-green-100 text-green-700 hover:bg-green-200",medium:"bg-blue-100 text-blue-700 hover:bg-blue-200",hard:"bg-orange-100 text-orange-700 hover:bg-orange-200",harder:"bg-red-100 text-red-700 hover:bg-red-200"};function v({value:e,onChange:r}){let{t:a}=(0,f.b)(),s={easy:a.practice.difficulty?.easy||"Easy",medium:a.practice.difficulty?.medium||"Medium",hard:a.practice.difficulty?.hard||"Hard",harder:a.practice.difficulty?.harder||"Challenge"};return(0,t.jsxs)("div",{className:"flex items-center gap-2 bg-muted/50 p-2 rounded-lg",children:[(0,t.jsxs)("span",{className:"text-sm font-medium text-muted-foreground",children:[a.practice.difficulty?.label||"Difficulty",":"]}),(0,t.jsx)("div",{className:"flex gap-1",children:Object.keys(y).map(a=>{let i=y[a],n=e===a;return(0,t.jsx)("button",{onClick:()=>r(a),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${n?i.replace("bg-","bg-opacity-100 bg-").replace("text-","ring-2 ring-offset-1 ring-"):"bg-transparent hover:bg-muted text-muted-foreground"} ${n?i:""}`,children:s[a]},a)})})]})}function N({value:e,onChange:r,disabled:a}){let{t:s}=(0,f.b)();return(0,t.jsxs)("select",{value:e,onChange:e=>r(e.target.value),className:"h-8 text-xs border rounded px-2 bg-background",disabled:a,children:[(0,t.jsx)("option",{value:"easy",children:s.practice.difficulty?.easy||"Easy"}),(0,t.jsx)("option",{value:"medium",children:s.practice.difficulty?.medium||"Medium"}),(0,t.jsx)("option",{value:"hard",children:s.practice.difficulty?.hard||"Hard"}),(0,t.jsx)("option",{value:"harder",children:s.practice.difficulty?.harder||"Challenge"})]})}var w=e.i(741120);function k({loading:e,onClick:r,regenerate:a}){let{t:i}=(0,f.b)();return(0,t.jsx)(n.f,{size:a?"sm":"lg",variant:a?"ghost":"default",onClick:r,disabled:e,children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.f,{className:"mr-2 h-4 w-4 animate-spin"}),i.practice.generating]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w.f,{className:"mr-2 h-4 w-4"}),a?i.practice.regenerate:i.practice.generate]})})}var S=e.i(772382),A=e.i(456420);let C={name:"send",size:24,node:[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]};C.node;let R=(0,A.f)(C);var T=e.i(583967);function E({isSubmitted:e,grading:r,isCorrect:a,gradeFailed:i,gradeReason:c,notes:d,canSubmit:o,onSubmit:u,onReveal:x}){let{t:g}=(0,f.b)();if(!e)return(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-center gap-2",children:[(0,t.jsxs)(n.f,{size:"lg",onClick:u,disabled:!o,className:"w-full md:w-auto",children:[(0,t.jsx)(R,{className:"mr-2 h-4 w-4"}),g.app.submitAnswer||"Submit Answer"]}),(0,t.jsxs)(n.f,{size:"lg",variant:"outline",onClick:x,className:"w-full md:w-auto",children:[(0,t.jsx)(S.f,{className:"mr-2 h-4 w-4"}),g.practice.checkAnswer||"Check Answer"]})]});if(r)return(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",role:"status",children:[(0,t.jsx)(s.f,{className:"h-5 w-5 animate-spin"}),g.practice.grading]});if(null===a)return i?(0,t.jsx)("p",{className:"rounded-lg border border-amber-200 dark:border-amber-900 bg-amber-50 dark:bg-amber-950/40 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",role:"status",children:g.practice.gradeFailed}):null;let h=a?m.f:T.f,p=a?"green":"red";return(0,t.jsx)(l.N,{className:a?"border-green-500 bg-green-50 dark:bg-green-950/40":"border-red-500 bg-red-50 dark:bg-red-950/40",children:(0,t.jsxs)(l.O,{className:"pt-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)(h,{className:`h-8 w-8 ${"green"===p?"text-green-600":"text-red-600"}`}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:`text-xl font-bold ${"green"===p?"text-green-600":"text-red-600"}`,children:a?g.practice.correct||"Correct!":g.practice.incorrect||"Incorrect"}),(0,t.jsx)("p",{className:"green"===p?"text-green-700 dark:text-green-300":"text-red-700 dark:text-red-300",children:a?g.practice.correctMessage||"Great job, keep it up!":g.practice.incorrectMessage||"Review the analysis and try again!"})]})]}),c&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:g.practice.aiGradeReason.replace("{reason}",c)}),d&&(0,t.jsxs)("div",{className:"mt-4 p-3 bg-background rounded-lg border",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-muted-foreground mb-1",children:g.practice.yourNotes||"Your Notes:"}),(0,t.jsx)("p",{className:"text-foreground whitespace-pre-wrap",children:d})]})]})})}var O=e.i(35209);let I=/^(?:答案?(?:是|为)?|解|answer(?: is)?|the answer is)[::]?/i,$=/^\(?([A-H]{1,4})\)?(?:$|[.、::)]|\s+(?![a-zA-Z]))/;function q(e){return e.replace(/[!-~]/g,e=>String.fromCharCode(e.charCodeAt(0)-65248)).replace(/ /g," ").replace(/\$|\\\(|\\\)|\\\[|\\\]/g,"").replace(/\\(?:text|mathrm)\{([^}]*)\}/g,"$1").replace(/[\s。.,,;;!!]+$/g,"").trim().replace(I,"").replace(/\s+/g,"").toLowerCase()}let P=/证明|求证|论证|推导|说明|解释|步骤|过程|列式|理由|原因|\b(?:prove|proof|justify|derive|explain|demonstrate|show|why|reason)\b/iu;var _=e.i(303163);let z=[["AI_CONNECTION_FAILED","aiConnectionFailed"],["AI_RESPONSE_ERROR","aiResponseError"],["AI_AUTH_ERROR","aiAuth"],["AI_OUTPUT_TRUNCATED","AI_OUTPUT_TRUNCATED"],["AI_UNKNOWN_ERROR","AI_UNKNOWN_ERROR"]];function U(){let e=(0,a.useSearchParams)(),u=(0,a.useRouter)(),m=e.get("id"),{t:x,language:g}=(0,f.b)();(0,O.f)(x.practice.title);let y=function(e){let{t,language:a}=(0,f.b)(),[s,i]=(0,r.useState)(null),[n,l]=(0,r.useState)(!1),[c,d]=(0,r.useState)(null),[o,u]=(0,r.useState)(!1),[m,x]=(0,r.useState)(""),[g,b]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[v,N]=(0,r.useState)(null),[w,k]=(0,r.useState)(!1),[S,A]=(0,r.useState)(null),[C,R]=(0,r.useState)(!1),[T,E]=(0,r.useState)("medium"),[O,U]=(0,r.useState)("medium"),[F,M]=(0,r.useState)(0),[V,D]=(0,r.useState)(null),[H,Y]=(0,r.useState)(null),[L,G]=(0,r.useState)(!0);(0,r.useEffect)(()=>{h.k.get("/api/settings").then(D).catch(e=>p.V.error("[Practice]","Failed to fetch config",{error:e}))},[]),(0,r.useEffect)(()=>{if(!e)return;let t=!1;return h.k.get(`/api/practice/generate?errorItemId=${encodeURIComponent(e)}`).then(({practice:e})=>{!t&&e&&(i(t=>t??{questionText:e.questionText,answerText:e.answerText,analysis:e.analysis,subject:e.subject||"其他",knowledgePoints:[],wrongAnswerText:"",mistakeAnalysis:"",mistakeStatus:"unknown",requiresImage:!1,figureSvg:e.figureSvg??null}),E(e.difficulty),U(e.difficulty),Y(e.generatedAt))}).catch(e=>p.V.warn("[Practice]","Failed to load last practice question",{error:e instanceof Error?e.message:String(e)})).finally(()=>{t||G(!1)}),()=>{t=!0}},[e]);let K=V?.timeouts?.analyze||18e4,B=async()=>{if(e){l(!0),d(null),x(""),b(""),y(!1),N(null),A(null),R(!1),u(!1);try{p.V.info("[Practice]","Generating question",{timeout:K});let t=await h.k.post("/api/practice/generate",{errorItemId:e,language:a,difficulty:T},{timeout:K,recoverable:!0});i(t),U(T),Y(t.generatedAt??null),M(e=>e+1)}catch(s){p.V.error("[Practice]","Failed to generate practice question",{error:s});let e=(0,_.d)(s)||"",r=z.find(([t])=>e.includes(t)),a=t.practice.errors?.default||"Failed to generate";d(r&&t.errors?.[r[1]]||a)}finally{l(!1)}}},Q=async()=>{if(m.trim()&&s&&e){if(y(!0),function(e,t,r){if(!r.trim()||P.test(r))return null;let a=q(e),s=q(t);if(!a||!s)return null;if(a===s)return!0;let i=t.trim().replace(I,"").trim().match($),n=a.replace(/^\((.*)\)$/,"$1");if(i&&/^[a-h]{1,4}$/.test(n)){let e=e=>[...e.toLowerCase()].sort().join("");return e(n)===e(i[1])||null}return null}(m,s.answerText,s.questionText)){N(!0),u(!0);return}k(!0);try{let t=await h.k.post("/api/practice/grade",{errorItemId:e,userAnswer:m,language:a},{timeout:K,recoverable:!0});N(t.correct),A(t.reason)}catch(e){p.V.warn("[Practice]","Failed to grade answer",{error:e}),N(null),R(!0)}finally{k(!1),u(!0)}}};return{question:s,loading:n,loadingCached:L,error:c,generatedAt:H,difficulty:T,setDifficulty:E,generatedDifficulty:O,questionVersion:F,userAnswer:m,setUserAnswer:x,notes:g,setNotes:b,isSubmitted:j,isCorrect:v,grading:w,gradeReason:S,gradeFailed:C,showAnswer:o,suggestedResult:null===v?null:v?"correct":"wrong",generateQuestion:B,submitAnswer:Q,revealAnswer:()=>{y(!0),N(null),u(!0)}}}(m),{question:w,loading:S}=y;return m?(0,t.jsxs)("div",{className:"max-w-3xl mx-auto space-y-8",children:[(0,t.jsx)("div",{className:"flex justify-between items-center mb-4",children:(0,t.jsxs)(n.f,{variant:"ghost",onClick:()=>u.back(),children:[(0,t.jsx)(i.f,{className:"mr-2 h-4 w-4"}),x.common?.back||"Back"]})}),(0,t.jsxs)("div",{className:"text-center space-y-4",children:[(0,t.jsx)("h1",{className:"text-3xl font-bold",children:x.practice.title}),(0,t.jsx)("p",{className:"text-muted-foreground",children:x.practice.subtitle}),y.error&&(0,t.jsxs)("div",{className:"relative rounded-xl border border-destructive/30 bg-destructive/10 px-4 py-3 text-destructive",role:"alert",children:[(0,t.jsxs)("strong",{className:"font-bold",children:[x.common?.error||"Error",": "]}),(0,t.jsxs)("span",{className:"block whitespace-pre-wrap",children:[" ",y.error]})]}),y.loadingCached&&!w&&(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsx)(s.f,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),!w&&!y.loadingCached&&(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,t.jsx)(v,{value:y.difficulty,onChange:y.setDifficulty}),(0,t.jsx)(k,{loading:S,onClick:y.generateQuestion})]})]}),w&&(0,t.jsxs)("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[(0,t.jsxs)(l.N,{className:"border-primary/50 shadow-lg",children:[(0,t.jsx)(l.Y,{children:(0,t.jsxs)(l.v,{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{children:x.app.practiceProblem}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(N,{value:y.difficulty,onChange:y.setDifficulty,disabled:S}),(0,t.jsx)(k,{loading:S,onClick:y.generateQuestion,regenerate:!0})]})]})}),(0,t.jsxs)(l.O,{children:[y.generatedAt&&(0,t.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:(x.practice.lastGeneratedAt||"Generated at {time}").replace("{time}",new Date(y.generatedAt).toLocaleString("zh"===g?"zh-CN":"en-US"))}),(0,t.jsx)(o.f,{content:w.questionText,className:"font-medium"}),(0,t.jsx)(j.f,{svg:w.figureSvg})]})]}),(0,t.jsxs)(l.N,{className:"border-blue-200",children:[(0,t.jsx)(l.Y,{children:(0,t.jsx)(l.v,{className:"text-blue-600",children:x.app.yourAnswer||"Your Answer"})}),(0,t.jsxs)(l.O,{className:"space-y-4",children:[(0,t.jsx)(d.f,{placeholder:x.app.answerPlaceholder||"Enter your answer...",value:y.userAnswer,onChange:e=>y.setUserAnswer(e.target.value),disabled:y.isSubmitted,className:"text-lg"}),(0,t.jsx)(c.f,{placeholder:x.app.notesPlaceholder||"Record your thinking process (optional)...",value:y.notes,onChange:e=>y.setNotes(e.target.value),disabled:y.isSubmitted,rows:3})]})]}),(0,t.jsx)(E,{isSubmitted:y.isSubmitted,grading:y.grading,isCorrect:y.isCorrect,gradeFailed:y.gradeFailed,gradeReason:y.gradeReason,notes:y.notes,canSubmit:!!y.userAnswer.trim(),onSubmit:y.submitAnswer,onReveal:y.revealAnswer}),y.showAnswer&&(0,t.jsxs)("div",{className:"space-y-6 animate-in fade-in slide-in-from-top-2",children:[(0,t.jsx)(b,{errorItemId:m,suggested:y.suggestedResult,question:w,difficulty:y.generatedDifficulty},y.questionVersion),(0,t.jsxs)(l.N,{className:"bg-muted/50",children:[(0,t.jsx)(l.Y,{children:(0,t.jsx)(l.v,{className:"text-green-600",children:x.practice.correctAnswer})}),(0,t.jsx)(l.O,{children:(0,t.jsx)(o.f,{content:w.answerText,className:"font-bold"})})]}),(0,t.jsxs)(l.N,{children:[(0,t.jsx)(l.Y,{children:(0,t.jsx)(l.v,{children:x.practice.detailedAnalysis})}),(0,t.jsx)(l.O,{className:"space-y-4",children:(0,t.jsx)(o.f,{content:w.analysis})})]})]})]})]}):(0,t.jsx)("div",{className:"p-8 text-center",children:x.practice.invalidRequest||"Invalid Request"})}e.s(["default",0,function(){return(0,t.jsx)("main",{className:"min-h-screen px-4 py-6 md:px-8 md:py-8",children:(0,t.jsx)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex justify-center p-8",children:(0,t.jsx)(s.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),children:(0,t.jsx)(U,{})})})},"dynamic",0,"force-dynamic"],652109)},393733,e=>{var t=e.i(843476),r=e.i(548161),a=e.i(576248),s=e.i(583967),i=e.i(111110);let n=[{value:"correct",icon:r.f,active:"border-green-600 bg-green-50 dark:bg-green-950/40 text-green-700 dark:text-green-300"},{value:"wrong",icon:s.f,active:"border-red-600 bg-red-50 dark:bg-red-950/40 text-red-700 dark:text-red-300"},{value:"not_attempted",icon:a.f,active:"border-amber-600 bg-amber-50 dark:bg-amber-950/40 text-amber-700 dark:text-amber-300"}];e.s(["f",0,function({value:e,onChange:r,disabled:a,size:s="md"}){let{t:l}=(0,i.b)(),c="sm"===s?"px-2 py-1 text-xs":"px-3 py-2 text-sm";return(0,t.jsx)("div",{className:"grid grid-cols-3 gap-2",role:"radiogroup",children:n.map(({value:i,icon:n,active:d})=>(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e===i,disabled:a,onClick:()=>r(i),className:`flex items-center justify-center gap-1 rounded-md border font-medium transition-colors disabled:opacity-60 ${c} ${e===i?d:"border-input hover:bg-muted"}`,children:[(0,t.jsx)(n,{className:"sm"===s?"h-3 w-3":"h-4 w-4"}),l.mastery.results[i]]},i))})}])},149704,e=>{var t=e.i(843476),r=e.i(111110),a=e.i(398019),s=e.i(184110),i=e.i(975157);let n={left:"mr-auto",center:"mx-auto",right:"ml-auto"};e.s(["f",0,function({svg:e,scale:l,align:c,className:d}){let{t:o}=(0,r.b)();if(!e)return null;let u=(0,s.V)(l),m=(0,s.o)(c);return(0,t.jsx)("figure",{className:(0,i.f)("question-figure my-3",d),children:(0,t.jsx)("img",{src:(0,a.d)(e),alt:o.figure.alt,className:(0,i.f)(n[m],"block h-auto max-w-full rounded border bg-white p-2"),style:{..."left"===m?{marginLeft:0,marginRight:"auto"}:"right"===m?{marginLeft:"auto",marginRight:0}:{},maxHeight:360,zoom:u/100,maxWidth:`${Math.min(u,100)}%`}})})}])},184110,e=>{let t=["left","center","right"],r="center";function a(e){return"number"==typeof e&&Number.isInteger(e)&&e>=10&&e<=200}e.s(["E",0,r,"n",0,100,"j",0,t,"a",0,200,"_",0,10,"x",0,a,"o",0,function(e){return"string"==typeof e&&t.includes(e)?e:r},"V",0,function(e){return a(e)?e:100}])},398019,e=>{e.s(["K",0,1e5,"d",0,function(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}])},35209,e=>{var t=e.i(271645),r=e.i(111110);e.s(["f",0,function(...e){let{t:a}=(0,r.b)(),s=[a.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,t.useEffect)(()=>{document.title=s},[s])}])}])})();
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,204573,e=>{"use strict";var t=e.i(843476),a=e.i(271645),s=e.i(522016),n=e.i(618566),r=e.i(711241),i=e.i(456420);let l={name:"file-question-mark",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]],aliases:["file-question"]};l.node;let o=(0,i.f)(l);var c=e.i(741120),d=e.i(759659),u=e.i(469937),m=e.i(314381),g=e.i(632781),h=e.i(3198),x=e.i(519455),f=e.i(111110),p=e.i(41931),v=e.i(303163),j=e.i(201276);function y({errorItemId:e,commands:s,onUpdate:n}){let{t:r}=(0,f.b)(),[i,l]=(0,a.useState)(!1),[o,c]=(0,a.useState)(null),d=async()=>{l(!0),c(null);try{let t=await p.k.post(`/api/error-items/${e}/geogebra`,{},{recoverable:!0});t.suitable&&t.commands.length>0?n({geogebraCommands:JSON.stringify(t.commands)}):c(t.description||r.geogebra.notSuitable)}catch(t){j.V.error("[ErrorDetail]","GeoGebra analysis failed",{error:t});let e=(0,v.d)(t)||(0,v.Z)(t);e.includes("AI_AUTH_ERROR")?c(r.geogebra.authFailed):e.includes("AI_CONNECTION")?c(r.geogebra.connectionFailed):c(r.geogebra.analyzeFailed)}finally{l(!1)}},u=async t=>{await p.k.put(`/api/error-items/${e}`,{geogebraCommands:t}),n({geogebraCommands:t})},b=async()=>{await p.k.delete(`/api/error-items/${e}/geogebra`),n({geogebraCommands:null})};return s?(0,t.jsx)(h.f,{commands:s,height:700,showToolBar:!0,showAlgebraInput:!1,showMenuBar:!1,onRegenerate:d,onSaveCommands:u,onDelete:b}):(0,t.jsxs)("div",{className:"rounded-lg border border-dashed p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(m.f,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:r.geogebra.title})]}),(0,t.jsx)(x.f,{variant:"outline",size:"sm",onClick:d,disabled:i,children:i?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.f,{className:"mr-2 h-4 w-4 animate-spin"}),r.geogebra.analyzing]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m.f,{className:"mr-2 h-4 w-4"}),r.geogebra.generate]})})]}),o&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:o}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:r.geogebra.hint})]})}function b({src:e,onClose:a}){let{t:s}=(0,f.b)();return e?(0,t.jsx)("div",{className:"fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4",onClick:a,children:(0,t.jsxs)("div",{className:"relative max-w-7xl max-h-full",children:[(0,t.jsx)("button",{className:"absolute -top-12 right-0 text-white hover:text-gray-300 text-lg font-semibold bg-black/50 px-4 py-2 rounded",onClick:a,children:s.detail?.close||"✕ Close"}),(0,t.jsx)("img",{src:e,alt:"Full size",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:e=>e.stopPropagation()}),(0,t.jsx)("p",{className:"text-center text-white/70 text-sm mt-4",children:s.detail?.clickOutside||"Click outside to close"})]})}):null}var w=e.i(141176),N=e.i(511445),k=e.i(515288);let S={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]};S.node;let A=(0,i.f)(S);var C=e.i(856522),I=e.i(263676);function T({onClick:e,label:a}){let{t:s}=(0,f.b)();return(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",onClick:e,children:[(0,t.jsx)(A,{className:"h-4 w-4 mr-1"}),a||s.common?.edit||"Edit"]})}function E({onSave:e,onCancel:a,children:s}){let{t:n}=(0,f.b)();return(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(x.f,{size:"sm",onClick:e,children:[(0,t.jsx)(C.f,{className:"h-4 w-4 mr-1"}),n.common?.save||"Save"]}),(0,t.jsxs)(x.f,{size:"sm",variant:"outline",onClick:a,children:[(0,t.jsx)(I.X,{className:"h-4 w-4 mr-1"}),n.common?.cancel||"Cancel"]}),s]})}function F({title:e,actions:a}){return(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[e,a]})}var M=e.i(294114);function L({read:e,save:t,logLabel:s,successMessage:n,failureMessage:r}){let{t:i}=(0,f.b)(),[l,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(e),u=async()=>{try{await t(c),o(!1),M.c.success(n||i.common?.messages?.saveSuccess||"Saved successfully")}catch(e){j.V.error("[ErrorDetail]",`Failed to save ${s}`,{error:e}),M.c.error(r||i.common?.messages?.saveFailed||"Save failed")}};return{editing:l,value:c,setValue:d,start:()=>{d(e()),o(!0)},cancel:()=>o(!1),submit:u}}function z({title:e,value:a,onSave:s,logLabel:n,rows:r,placeholder:i,editorLabel:l,emptyText:o,cardClassName:c,titleClassName:d,contentClassName:u,headerActions:m,children:g}){let h=L({read:()=>a||"",save:s,logLabel:n}),x=(0,t.jsx)(w.f,{value:h.value,onChange:h.setValue,placeholder:i,rows:r,className:"w-full font-mono text-sm"});return(0,t.jsxs)(k.N,{className:c,children:[(0,t.jsx)(k.Y,{children:(0,t.jsx)(F,{title:(0,t.jsx)(k.v,{className:d,children:e}),actions:!h.editing&&(0,t.jsxs)("div",{className:"flex flex-wrap justify-end",children:[m,(0,t.jsx)(T,{onClick:h.start})]})})}),(0,t.jsxs)(k.O,{className:"space-y-4",children:[h.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[l?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:l}),x]}):x,(0,t.jsx)(E,{onSave:h.submit,onCancel:h.cancel})]}):!a&&o?(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:o}):(0,t.jsx)(N.f,{content:a,className:u}),g]})]})}var $=e.i(624687);function q({item:e,onUpdate:a}){let{t:s}=(0,f.b)(),n=L({read:()=>e.userNotes||"",save:async t=>{await p.k.patch(`/api/error-items/${e.id}/notes`,{userNotes:t}),a({userNotes:t})},logLabel:"notes",successMessage:s.common?.messages?.noteSaveSuccess||"Notes saved successfully"});return(0,t.jsxs)(k.N,{children:[(0,t.jsx)(k.Y,{children:(0,t.jsx)(F,{title:(0,t.jsx)(k.v,{children:s.detail.yourNotes}),actions:!n.editing&&(0,t.jsx)(T,{onClick:n.start,label:s.detail.editNotes})})}),(0,t.jsx)(k.O,{children:n.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)($.f,{value:n.value,onChange:e=>n.setValue(e.target.value),placeholder:s.detail.notesPlaceholder||"Enter your notes...",rows:5,className:"w-full"}),(0,t.jsx)(E,{onSave:n.submit,onCancel:n.cancel})]}):(0,t.jsx)("div",{className:"whitespace-pre-wrap",children:e.userNotes?(0,t.jsx)("p",{className:"text-foreground",children:e.userNotes}):(0,t.jsx)("p",{className:"text-muted-foreground italic",children:s.detail.noNotes})})})]})}let R={name:"shapes",size:24,node:[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]};R.node;let V=(0,i.f)(R);function O({errorItemId:e,onDone:s}){let{t:n}=(0,f.b)(),[r,i]=(0,a.useState)(!1),l=async()=>{i(!0);try{let t=await p.k.post(`/api/error-items/${e}/figure`,{},{recoverable:!0});s(t),t.figureSvg||M.c.warning(n.figure.noFigure)}catch(a){let e=a?.data?.message||"",t=n.errors[e];j.V.error("[RegenerateFigure]","Failed to regenerate figure",{code:e}),M.c.error("NO_ORIGINAL_IMAGE"===e?n.figure.noImage:"string"==typeof t?t:n.figure.failed)}finally{i(!1)}};return(0,t.jsxs)(x.f,{variant:"outline",size:"sm",onClick:l,disabled:r,className:"flex items-center gap-2",children:[r?(0,t.jsx)(g.f,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(V,{className:"h-4 w-4"}),r?n.figure.regenerating:n.figure.regenerate]})}let U={name:"image-plus",size:24,node:[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]};U.node;let D=(0,i.f)(U);var _=e.i(12130),H=e.i(213761);function P({errorItemId:e,hasImage:s,onDone:n}){let{t:r}=(0,f.b)(),i=(0,a.useRef)(null),[l,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(null);(0,a.useEffect)(()=>()=>c?.dispose(),[c]);let u=async()=>{(!s||await (0,M.u)(r.replaceImage.confirm))&&i.current?.click()},m=async e=>{if(e){o(!0);try{d(await (0,H.p)(e))}catch(e){M.c.error(e instanceof H.o?r.upload.decodeErrors[e.code].replace("{format}",e.format.toUpperCase()):r.replaceImage.invalid)}finally{o(!1)}}},h=async t=>{if(c&&0!==t.length){o(!0);try{let{dataUrl:a}=await (0,H.X)(c,t[0]);d(null);let s=await p.k.put(`/api/error-items/${e}/image`,{imageDataUrl:a});n(s.originalImageUrl),M.c.success(r.replaceImage.done)}catch(t){let e=t?.data?.message||"";j.V.error("[ReplaceImage]","Failed to replace original image",{code:e}),M.c.error("INVALID_IMAGE"===e?r.replaceImage.invalid:r.replaceImage.failed)}finally{o(!1)}}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:i,type:"file",accept:"image/*,.heic,.heif",className:"hidden",onChange:e=>{m(e.target.files?.[0]),e.target.value=""}}),c&&(0,t.jsx)(_.f,{imageSrc:c.previewUrl,open:!l,onClose:()=>d(null),allowMulti:!1,onRegionsSelected:e=>void h(e)}),(0,t.jsxs)(x.f,{variant:"outline",size:"sm",onClick:u,disabled:l,className:"flex items-center gap-2",children:[l?(0,t.jsx)(g.f,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(D,{className:"h-4 w-4"}),l?r.replaceImage.uploading:s?r.replaceImage.replace:r.replaceImage.add]})]})}var G=e.i(520732),B=e.i(438465),X=e.i(28342),Q=e.i(674166),W=e.i(967489),Z=e.i(401280),K=e.i(470279);function Y({item:e,onChanged:a}){var s;let{t:n}=(0,f.b)(),r=n.common?.notSet||"Not set",{groups:i}=(0,K.f)(),l=L({read:()=>({subjectId:e.subjectId||null,gradeSemester:e.gradeSemester||"",paperLevel:e.paperLevel||"",questionType:e.questionType||""}),save:async t=>{let{subjectId:s,paperLevel:n,questionType:r,...i}=t;await p.k.put(`/api/error-items/${e.id}`,{...i,...n!==(e.paperLevel||"")?{paperLevel:n||null}:{},...s!==(e.subjectId||null)?{subjectId:s}:{},...r!==(e.questionType||"")?{questionType:r||null}:{}}),await a()},logLabel:"metadata",successMessage:n.common?.messages?.metaUpdateSuccess||"Metadata updated successfully!",failureMessage:n.common?.messages?.updateFailed||"Update failed"}),o=e=>l.setValue({...l.value,...e});return(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsx)(F,{title:(0,t.jsx)("h4",{className:"text-sm font-semibold",children:n.detail?.questionInfo||"Question Info"}),actions:!l.editing&&(0,t.jsx)(T,{onClick:l.start})}),l.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:n.notebooks?.title||"Notebook"}),(0,t.jsx)(B.f,{value:l.value.subjectId||void 0,onChange:e=>o({subjectId:e})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:n.questionType.label||"Question Type"}),(0,t.jsxs)(W.d,{value:l.value.questionType,onValueChange:e=>o({questionType:e===Z.O?"":e}),children:[(0,t.jsx)(W.P,{children:(0,t.jsx)(W.U,{placeholder:n.questionType.notSet||"Not set"})}),(0,t.jsxs)(W.r,{children:[(0,t.jsx)(W.T,{value:Z.O,children:n.questionType.clear||"Clear"}),Z.V.map(e=>(0,t.jsx)(W.T,{value:e,children:n.questionType.names?.[e]||e},e))]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{htmlFor:"detail-grade-semester",className:"text-sm text-muted-foreground",children:n.editor.gradeSemester}),(0,t.jsx)(X.f,{id:"detail-grade-semester",value:l.value.gradeSemester,onChange:e=>o({gradeSemester:e})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:n.filter.paperLevel}),(0,t.jsx)(Q.f,{value:l.value.paperLevel,onChange:e=>o({paperLevel:e})})]}),(0,t.jsx)(E,{onSave:l.submit,onCancel:l.cancel})]}):(0,t.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[n.notebooks?.title||"Notebook",":"]}),(0,t.jsx)("span",{className:"font-medium",children:e.subject?.name||r})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[n.questionType.label||"Question Type",":"]}),(0,t.jsx)("span",{className:"font-medium",children:(s=e.questionType)?n.questionType.names?.[s]||s:r})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[n.editor.gradeSemester,":"]}),(0,t.jsx)("span",{className:"font-medium",children:e.gradeSemester||r})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[n.filter.paperLevel,":"]}),(0,t.jsx)("span",{className:"font-medium",children:(e=>{if(!e)return r;let t=i.find(t=>t.id===e);return t?.name||e})(e.paperLevel)})]})]})]})}var J=e.i(487486),ee=e.i(328623);function et({errorItemId:e,onDone:s,onSuggested:n}){let{t:r}=(0,f.b)(),[i,l]=(0,a.useState)(!1),o=async()=>{l(!0);try{if(n){let t=await p.k.post(`/api/error-items/${e}/retag`,{preview:!0},{recoverable:!0});n(t.tags)}else await p.k.post(`/api/error-items/${e}/retag`,{},{recoverable:!0}),s?.()}catch(a){let e=a?.data?.message||"",t=r.errors[e];j.V.error("[RetagItem]","Failed to regenerate tags",{code:e}),M.c.error("NO_TAGS_SELECTED"===e?r.retag.noTags:"string"==typeof t?t:r.retag.itemFailed)}finally{l(!1)}};return(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",onClick:o,disabled:i,children:[i?(0,t.jsx)(g.f,{className:"h-4 w-4 mr-1 animate-spin"}):(0,t.jsx)(ee.f,{className:"h-4 w-4 mr-1"}),n?i?r.retag.suggestRunning:r.retag.suggestButton:i?r.retag.itemRunning:r.retag.itemButton]})}var ea=e.i(574041),es=e.i(597138),en=e.i(428602);function er({item:e,educationStage:a,onChanged:s}){let{t:n}=(0,f.b)(),r=(0,en.f)(e),i=L({read:()=>(0,en.f)(e),save:async t=>{await p.k.put(`/api/error-items/${e.id}`,{knowledgePoints:t}),await s()},logLabel:"tags",successMessage:n.common?.messages?.tagUpdateSuccess||"Tags updated successfully!",failureMessage:n.common?.messages?.updateFailed||"Update failed"});return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(F,{title:(0,t.jsx)("h4",{className:"text-sm font-semibold",children:n.editor?.tags||"Knowledge Tags"}),actions:!i.editing&&(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)(et,{errorItemId:e.id,onDone:s}),(0,t.jsx)(T,{onClick:i.start})]})}),i.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(ea.f,{value:i.value,onChange:i.setValue,placeholder:n.editor?.tagsPlaceholder||"Enter or select knowledge tags...",subject:(0,es.f)(e.subject?.name||null)||void 0,gradeStage:a}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.editor?.tagsHint||"Select from standard or custom tags"}),(0,t.jsx)(E,{onSave:i.submit,onCancel:i.cancel,children:(0,t.jsx)(et,{errorItemId:e.id,onSuggested:i.setValue})})]}):(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:r.map(e=>(0,t.jsx)(J.f,{variant:"secondary",children:e},e))})]})}var ei=e.i(580860);let el={name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]};el.node;let eo=(0,i.f)(el);function ec({src:e,alt:a,showLabel:s,hideLabel:n,visible:r,onVisibleChange:i,onEnlarge:l,variant:o="ghost",actions:c}){let{t:d}=(0,f.b)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[e&&(0,t.jsx)(x.f,{variant:o,size:"sm",onClick:()=>i(!r),className:`flex items-center gap-2 ${"ghost"===o?"text-muted-foreground":""}`,children:r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ei.f,{className:"h-4 w-4"}),n]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eo,{className:"h-4 w-4"}),s]})}),c]}),e&&r&&(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("img",{src:e,alt:a,className:"w-full rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>l(e)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1 text-center",children:d.detail?.clickToEnlarge||"Click to enlarge"})]})]})}function ed({item:e,educationStage:s,saveFields:n,onUpdate:r,reload:i,onEnlarge:l}){let{t:o}=(0,f.b)(),[c,d]=(0,a.useState)(!1),u=L({read:()=>e.questionText,save:e=>n({questionText:e}),logLabel:"question"});return(0,t.jsxs)(k.N,{children:[(0,t.jsx)(k.Y,{children:(0,t.jsx)(F,{title:(0,t.jsx)(k.v,{children:o.detail.question}),actions:!u.editing&&(0,t.jsx)(T,{onClick:u.start})})}),(0,t.jsxs)(k.O,{className:"space-y-4",children:[u.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(w.f,{value:u.value,onChange:u.setValue,placeholder:"Enter question text...",rows:8,className:"w-full font-mono text-sm"}),(0,t.jsx)(E,{onSave:u.submit,onCancel:u.cancel})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(N.f,{content:e.questionText}),(0,t.jsx)(G.f,{svg:e.figureSvg,scale:e.figureScale,align:e.figureAlign,onSave:(e,t)=>n({figureScale:e,figureAlign:t})},`${e.id}-${e.figureScale??100}-${e.figureAlign??"center"}`)]}),(0,t.jsx)(er,{item:e,educationStage:s,onChanged:i}),(0,t.jsx)(Y,{item:e,onChanged:i}),(0,t.jsx)("div",{className:"pt-3",children:(0,t.jsx)(ec,{src:e.originalImageUrl,alt:o.detail.originalProblem||"Original Problem",showLabel:o.replaceImage?.view||"View original image",hideLabel:o.replaceImage?.hide||"Hide original image",variant:"outline",visible:c,onVisibleChange:d,onEnlarge:l,actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(P,{errorItemId:e.id,hasImage:!!e.originalImageUrl,onDone:e=>{r({originalImageUrl:e}),d(!0)}}),e.originalImageUrl&&(0,t.jsx)(O,{errorItemId:e.id,onDone:r})]})})})]})]})}var eu=e.i(991722);function em({item:e,saveFields:s,onEnlarge:n}){let{t:r,language:i}=(0,f.b)(),[l,o]=(0,a.useState)(!1),c=L({read:()=>({text:e.wrongAnswerText||"",status:e.mistakeStatus||"unknown"}),save:({text:e,status:t})=>s({wrongAnswerText:e,mistakeStatus:(0,eu.x)(t,e)}),logLabel:"wrong answer"});return(0,t.jsxs)(k.N,{children:[(0,t.jsx)(k.Y,{children:(0,t.jsx)(F,{title:(0,t.jsx)(k.v,{children:r.editor?.wrongAnswerText||"Wrong Answer / Work"}),actions:!c.editing&&(0,t.jsx)(T,{onClick:c.start})})}),(0,t.jsx)(k.O,{className:"space-y-4",children:c.editing?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:r.editor?.mistakeStatus||"Attempt Status"}),(0,t.jsxs)(W.d,{value:c.value.status,onValueChange:e=>c.setValue({...c.value,status:e}),children:[(0,t.jsx)(W.P,{children:(0,t.jsx)(W.U,{})}),(0,t.jsxs)(W.r,{children:[(0,t.jsx)(W.T,{value:"not_attempted",children:r.editor?.mistakeStatuses?.notAttempted||"Not attempted"}),(0,t.jsx)(W.T,{value:"wrong_attempt",children:r.editor?.mistakeStatuses?.wrongAttempt||"Wrong attempt"}),(0,t.jsx)(W.T,{value:"unknown",children:r.editor?.mistakeStatuses?.unknown||"Unknown"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:r.editor?.wrongAnswerText||"Wrong Answer / Work"}),(0,t.jsx)(w.f,{value:c.value.text,onChange:e=>c.setValue({text:e,status:e.trim()?"wrong_attempt":c.value.status}),rows:5,className:"w-full font-mono text-sm"})]}),(0,t.jsx)(E,{onSave:c.submit,onCancel:c.cancel})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(J.f,{variant:"secondary",children:(0,eu.i)(e.mistakeStatus,i)}),e.wrongAnswerText?(0,t.jsx)(N.f,{content:e.wrongAnswerText}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:r.detail?.noMistakeAnalysis||"No mistake analysis yet."}),e.wrongAnswerImageUrl&&(0,t.jsx)("div",{className:"pt-3",children:(0,t.jsx)(ec,{src:e.wrongAnswerImageUrl,alt:r.detail.wrongAnswerImageAlt,showLabel:r.detail.viewImage,hideLabel:r.detail.hideImage,visible:l,onVisibleChange:o,onEnlarge:n})})]})})]})}let eg={name:"square-function",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]],aliases:["function-square"]};eg.node;let eh=(0,i.f)(eg);var ex=e.i(716400),ef=e.i(369939);let ep=new Set(["ne","neq","nabla","nu","not","notin","ni","nexists","ngeq","nleq","nmid","nparallel","nsubseteq"]);function ev(e){return e.length>80?`${e.slice(0,80)}…`:e}let ej=["questionText","answerText","analysis","wrongAnswerText","mistakeAnalysis"];function ey({errorItemId:e,fields:s,onDone:n}){let{t:r}=(0,f.b)(),[i,l]=(0,a.useState)(!1),o=(0,a.useMemo)(()=>Object.values(function(e){let t={};for(let a of ej){let s=function(e){if(!e?.trim())return[];let{masked:t,segments:a}=(0,ef.F)(e),s=[];for(let e of a)try{ex.f.renderToString(e.tex,{displayMode:e.displayMode,throwOnError:!0,strict:"ignore"})}catch(a){let t=a instanceof Error?a.message.replace(/^KaTeX parse error:\s*/,""):String(a);s.push({snippet:ev(e.source),message:t})}let n=t.replace(/@@MATH\d+@@/g," "),r=n.replace(/\\\$/g,"").match(/\$/g);r&&s.push({snippet:"$",message:`有 ${r.length} 个未配对的 $ 定界符`});let i=n.match(/\\[()[\]]/g);i&&s.push({snippet:i.join(" "),message:"有未配对的 \\( \\) 或 \\[ \\] 定界符"});let l=[...new Set(n.match(/\\[a-zA-Z]{2,}/g)||[])].filter(e=>!e.startsWith("\\n")||ep.has(e.slice(1)));return l.length>0&&s.push({snippet:ev(l.join(" ")),message:"LaTeX 命令没有放在 $…$ 中,会原样显示"}),s}(e[a]);s.length>0&&(t[a]=s)}return t}(s)).reduce((e,t)=>e+(t?.length??0),0),[s]),c=async()=>{l(!0);try{let t=await p.k.post(`/api/error-items/${e}/fix-latex`,{},{timeout:3e5,recoverable:!0});n(t.updated);let a=t.fixedFields.map(e=>r.fixLatex.fields[e]).join(r.common.listSeparator);M.c.info(0===t.issuesBefore?r.fixLatex.noIssues:0===t.fixedFields.length?r.fixLatex.notFixed:0===t.issuesAfter?r.fixLatex.fixedAll.replace("{fields}",a):r.fixLatex.fixedPartly.replace("{fields}",a).replace("{count}",String(t.issuesAfter)))}catch(a){let e=a?.data?.message||"",t=r.errors[e];j.V.error("[FixLatex]","Failed to fix LaTeX",{code:e}),M.c.error("string"==typeof t?t:r.fixLatex.failed)}finally{l(!1)}};return 0!==o||i?(0,t.jsxs)(x.f,{variant:"outline",size:"sm",onClick:c,disabled:i,className:"border-amber-500 text-amber-700 dark:text-amber-400",title:r.fixLatex.issuesFound.replace("{count}",String(o)),children:[i?(0,t.jsx)(g.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(eh,{className:"mr-2 h-4 w-4"}),i?r.fixLatex.running:r.fixLatex.button,!i&&o>0&&(0,t.jsxs)("span",{className:"ml-1",children:["(",o,")"]})]}):null}var eb=e.i(991686),ew=e.i(846968),eN=e.i(931454);function ek({errorItemId:e,onDone:s}){let{t:n,language:r}=(0,f.b)(),[i,l]=(0,a.useState)(!1),o=async()=>{if(await (0,M.u)(n.reanswerItem.confirm)){l(!0);try{let t=await p.k.post(`/api/error-items/${e}/reanswer`,{language:r},{timeout:6e5,recoverable:!0});s(t)}catch(a){let e=a?.data?.message||"",t=n.errors[e];j.V.error("[RegenerateAnswer]","Failed to regenerate answer",{code:e}),M.c.error("NO_QUESTION_TEXT"===e?n.reanswerItem.noQuestionText:"string"==typeof t?t:n.reanswerItem.failed)}finally{l(!1)}}};return(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",onClick:o,disabled:i,children:[i?(0,t.jsx)(g.f,{className:"h-4 w-4 mr-1 animate-spin"}):(0,t.jsx)(eN.f,{className:"h-4 w-4 mr-1"}),i?n.reanswerItem.running:n.reanswerItem.button]})}var eS=e.i(689664),eA=e.i(508734);function eC({shortId:e,className:s=""}){let{t:n}=(0,f.b)(),[r,i]=(0,a.useState)(!1);if(!e)return null;let l=async t=>{t.preventDefault(),t.stopPropagation();try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{window.prompt(n.shortId.copy,e)}};return(0,t.jsxs)("button",{type:"button",onClick:l,title:r?n.shortId.copied:n.shortId.copy,className:`inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 font-mono text-xs text-muted-foreground hover:text-foreground transition-colors ${s}`,children:[(0,t.jsx)("span",{children:n.shortId.label}),(0,t.jsx)("span",{className:"font-semibold text-foreground",children:e}),r?(0,t.jsx)(eS.f,{className:"h-3 w-3 text-green-600"}):(0,t.jsx)(eA.f,{className:"h-3 w-3"})]})}let eI={name:"audio-lines",size:24,node:[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]};eI.node;let eT=(0,i.f)(eI),eE={name:"clapperboard",size:24,node:[["path",{d:"m12.296 3.464 3.02 3.956",key:"qash78"}],["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z",key:"1h7j8b"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"4lm6w1"}],["path",{d:"m6.18 5.276 3.1 3.899",key:"zjj9t3"}]]};eE.node;let eF=(0,i.f)(eE),eM={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]};eM.node;let eL=(0,i.f)(eM),ez={name:"minimize",size:24,node:[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]};ez.node;let e$=(0,i.f)(ez),eq={name:"pause",size:24,node:[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]};eq.node;let eR=(0,i.f)(eq);var eV=e.i(21357),eO=e.i(395925);let eU={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]};eU.node;let eD=(0,i.f)(eU),e_={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]};e_.node;let eH=(0,i.f)(e_);var eP=e.i(975157);function eG({supported:e,enabled:a,rate:s,fullscreen:n,onToggle:r,onCycleRate:i}){let{t:l}=(0,f.b)(),o=(0,eP.f)("h-8 shrink-0",n&&"text-white hover:bg-white/20 hover:text-white"),c=e?a?l.svgAnimation.voiceOff:l.svgAnimation.voiceOn:l.svgAnimation.voiceUnsupported;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{title:c,className:"shrink-0",children:(0,t.jsx)(x.f,{variant:"ghost",size:"sm",className:(0,eP.f)(o,"w-8 p-0",a&&e&&!n&&"text-primary"),onClick:r,disabled:!e,"aria-label":c,"aria-pressed":a&&e,children:a&&e?(0,t.jsx)(eD,{className:"h-4 w-4"}):(0,t.jsx)(eH,{className:"h-4 w-4"})})}),a&&e&&(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",className:(0,eP.f)(o,"px-1.5 text-xs tabular-nums"),onClick:i,"aria-label":l.svgAnimation.voiceRate,title:l.svgAnimation.voiceRate,children:[s,"×"]})]})}let eB=/<metadata\b[^>]*\bid\s*=\s*["']narration["'][^>]*>([\s\S]*?)<\/metadata\s*>/gi,eX={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};function eQ(e){let t=e;if("string"==typeof t){let e=t.indexOf("["),a=t.lastIndexOf("]");if(-1===e||a<e)return null;try{t=JSON.parse(t.slice(e,a+1))}catch{return null}}if(!Array.isArray(t))return null;let a=[];for(let e of t){if(!e||"object"!=typeof e)continue;let{begin:t,text:s}=e,n="number"==typeof t?t:"string"==typeof t?eY(t):null;if(null===n||!Number.isFinite(n)||n<0||"string"!=typeof s)continue;let r=s.replace(/\s+/g," ").trim();r&&a.push({begin:Math.round(100*n)/100,text:r})}a.sort((e,t)=>e.begin-t.begin);let s=[];for(let e of a){let t=s[s.length-1];t&&t.begin===e.begin?t.text=`${t.text} ${e.text}`:s.push({...e})}let n=s.slice(0,20).map(e=>({...e,text:e.text.slice(0,300)}));return n.length>0?n:null}function eW(e){for(let t of e.matchAll(eB)){let e=eQ(t[1].replace(/&(#x[0-9a-f]+|#\d+|lt|gt|amp|quot|apos);/gi,(e,t)=>{if("#"!==t[0])return eX[t.toLowerCase()];let a="x"===t[1]||"X"===t[1]?parseInt(t.slice(2),16):Number(t.slice(1));return Number.isFinite(a)&&a<=1114111?String.fromCodePoint(a):e}));if(e)return e}return null}let eZ=/<(?:animate|animateTransform|animateMotion|set)\b[^>]*>/gi;function eK(e,t){let a=e.match(RegExp(`\\s${t}\\s*=\\s*("([^"]*)"|'([^']*)')`,"i"));return a?(a[2]??a[3]??"").trim():null}function eY(e){if(!e)return null;let t=e.trim(),a=t.match(/^(?:(\d+):)?(\d+):(\d+(?:\.\d+)?)$/);if(a)return 3600*Number(a[1]??0)+60*Number(a[2])+Number(a[3]);let s=t.match(/^(\d+(?:\.\d+)?)(h|min|s|ms)?$/);if(!s)return null;let n={h:3600,min:60,s:1,ms:.001}[s[2]??"s"]??1;return Number(s[1])*n}let eJ=new Set(["opacity","visibility","display","fill-opacity"]);function e0(e){let t=e.getAttribute("viewBox")?.split(/[\s,]+/).map(Number),a=t?.length===4&&t[3]>0?t[1]+t[3]:parseFloat(e.getAttribute("height")??"");if(!(a>0))return null;let s=t?.length===4?t[1]+.78*t[3]:.78*a,n=[];for(let t of Array.from(e.querySelectorAll("text"))){if(t.closest("defs, metadata"))continue;let a=parseFloat(t.getAttribute("y")??t.querySelector("tspan[y]")?.getAttribute("y")??"");if(!(a>=s))continue;let r=Array.from(t.querySelectorAll("tspan")),i=(r.length>0?r.map(e=>e.textContent??"").join(" "):t.textContent??"").replace(/\s+/g," ").trim(),l=function(e,t){for(let a=e;a&&a!==t;a=a.parentElement)for(let e of Array.from(a.children)){let t=e.localName;if("set"!==t&&"animate"!==t)continue;let a=e.getAttribute("attributeName")??"";if(eJ.has(a)&&!function(e,t){if(null===t)return!1;let a=t.trim();return"visibility"===e?"hidden"===a:"display"===e?"none"===a:0===Number(a)}(a,e.getAttribute("to")??e.getAttribute("values")?.split(";").pop()??null))return eY((e.getAttribute("begin")??"0").split(";")[0])}return 0}(t,e);i&&null!==l&&n.push({begin:l,y:a,text:i})}return n.sort((e,t)=>e.begin-t.begin||e.y-t.y),eQ(n.map(({begin:e,text:t})=>({begin:e,text:t})))}var e1=e.i(79058);let e2={zh:["zh","cmn"],en:["en"]};function e3(){return"speechSynthesis"in window&&"u">typeof SpeechSynthesisUtterance?window.speechSynthesis:null}let e4=!1;function e5(){let e=e3();if(!e||e4)return;e4=!0;let t=new SpeechSynthesisUtterance(" ");t.volume=0,e.speak(t)}let e8=[1,1.25,1.5,.75],e6="svg-narration-enabled",e7="svg-narration-rate";function e9(e){try{return localStorage.getItem(e)}catch{return null}}function te(e,t){try{localStorage.setItem(e,t)}catch{}}function tt(e,t){return Math.max(8e3,400*e.length/t+5e3)}function ta(e,t){let a=-1;for(let s=0;s<e.length&&e[s].begin<=t+.05;s++)a=s;return a}function ts(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function tn({svg:e,errorItemId:s}){let{t:n,language:r}=(0,f.b)(),i=(0,a.useRef)(null),l=(0,a.useRef)(null),o=(0,a.useRef)(null),[c,d]=(0,a.useState)(null),[u,m]=(0,a.useState)(!1),[g,h]=(0,a.useState)(0),[p,v]=(0,a.useState)(!1),[j,y]=(0,a.useState)(!1),b=p||j,w=(0,a.useMemo)(()=>(function(e){let t=0;for(let a of e.match(eZ)||[]){let e=eK(a,"begin"),s=null===e?0:eY(e.split(";")[0]);if(null===s)continue;let n=eK(a,"repeatCount");if("indefinite"!==n&&"indefinite"!==eK(a,"repeatDur"))t=Math.max(t,s+(eY(eK(a,"dur"))??0)*(n&&Number.isFinite(Number(n))?Number(n):1))}return t})(e),[e]),N=(0,a.useMemo)(()=>(function(e){let t=e.match(/<svg\b[^>]*>/i)?.[0]??"",a=eK(t,"viewBox")?.split(/[\s,]+/).map(Number);if(a?.length===4&&a[2]>0&&a[3]>0)return a[2]/a[3];let s=parseFloat(eK(t,"width")??""),n=parseFloat(eK(t,"height")??"");return s>0&&n>0?s/n:1.6})(e),[e]),k=(0,a.useMemo)(()=>`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:"><style>html,body{margin:0;height:100%;background:#fff;overflow:hidden}svg{display:block;width:100%;height:100%}</style></head><body>${e}</body></html>`,[e]),S=(0,a.useMemo)(()=>eW(e),[e]),[A,C]=(0,a.useState)(null),I=S??A,T=(0,a.useCallback)(()=>{let e=l.current?.contentDocument;return"function"==typeof e?.getAnimations?e.getAnimations():[]},[]),E=function({segments:e,language:t,errorItemId:s,holdAnimation:n}){let{supported:r,mode:i,modeRef:l,voiceRef:o}=function(e){let[t,s]=(0,a.useState)(!1),[n,r]=(0,a.useState)("browser"),i=(0,a.useRef)(void 0),l=(0,a.useRef)("browser");return(0,a.useEffect)(()=>{let e=!0;return(0,e1.v)().then(t=>{e&&(l.current=t,r(t))}),()=>{e=!1}},[]),(0,a.useEffect)(()=>{let t=e3();if(!t)return;let a=()=>{let a,n,r,l=t.getVoices();a=e2[e],n=l.filter(e=>a.some(t=>e.lang.toLowerCase().startsWith(t))),r="zh"===e?/^(zh|cmn)[-_](cn|hans)/i:/^en[-_]us/i,i.current=n.find(e=>r.test(e.lang)&&e.localService)??n.find(e=>r.test(e.lang))??n[0],s(0===l.length||!!i.current)};return a(),t.addEventListener?.("voiceschanged",a),()=>t.removeEventListener?.("voiceschanged",a)},[e]),{supported:t,mode:n,modeRef:l,voiceRef:i}}(t),[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)(1),[g,h]=(0,a.useState)(!1),[x,f]=(0,a.useState)(!1),p=(0,a.useRef)(!1),v=(0,a.useRef)(!1),j=(0,a.useRef)(1),y=(0,a.useRef)(n);(0,a.useEffect)(()=>{y.current=n},[n]),(0,a.useEffect)(()=>{v.current="1"===e9(e6),d(v.current);let e=Number(e9(e7));e8.includes(e)&&(j.current=e,m(e))},[]);let b=(0,a.useRef)(null);(0,a.useEffect)(()=>{let a=b.current;a&&(a.deps.segments=e,a.deps.language=t,a.deps.enabled=v.current,a.deps.mode=l.current,a.deps.voice=o.current,a.deps.rate=j.current)}),(0,a.useEffect)(()=>{let a={segments:e,language:t,enabled:v.current,mode:l.current,voice:o.current,rate:j.current,setSpeaking:h,setHolding:f,hold:e=>{y.current(e)}},s=function(e){let t=-1,a=!1,s=null,n=0,r=null,i=!1,l=!1;function o(){i&&(i=!1,null===s&&(e.setHolding(!1),e.hold(!1)))}function c(t,n){n(),t()&&(r=null,a=!1,e.setSpeaking(!1),o(),null!==s&&(s=null,e.setHolding(!1),e.hold(!1)))}function d(t,a,s,n){if(!t()||l)return;l=!0,o();let r=e3();if(!r)return void c(t,s);let i=new SpeechSynthesisUtterance(a.text);i.lang=e.voice?.lang??("en"===e.language?"en-US":"zh-CN"),e.voice&&(i.voice=e.voice),i.rate=e.rate,i.onend=()=>c(t,s),i.onerror=()=>c(t,s),i.onstart=()=>n(tt(a.text,i.rate)),n(2500),r.speak(i)}return{update:function(u){let m=e.segments;if(!e.enabled||!m?.length||null!==s)return;if(a){let a=t+1;if(a>=m.length)return;let n=a>0?m[a].begin-m[a-1].begin:m[a].begin;if(u<m[a].begin-Math.min(.8,n/2))return;s=a,e.setHolding(!0),e.hold(!0);return}let g=ta(m,u);g<=t||(t=g,function(t){let u,m=e.segments,g=m?.[t];if(!g)return;let h=n,x={},f=()=>n===h&&r===x,p=()=>clearTimeout(u),v=e=>{clearTimeout(u),u=setTimeout(()=>c(f,p),e)};if(l=!1,r=x,a=!0,e.setSpeaking(!0),"cloud"!==e.mode)return d(f,g,p,v);let j=e.language,y=m?.[t+1];y&&(0,e1.U)(y.text,j).catch(()=>void 0);let b=setTimeout(()=>{f()&&null===s&&(i=!0,e.setHolding(!0),e.hold(!0))},300);(0,e1.U)(g.text,j).then(t=>{let a=(0,e1.l)();if(!f())return;if(!a){clearTimeout(b),d(f,g,p,v);return}let s=e=>()=>{f()&&!l&&e()};a.onplaying=s(()=>{clearTimeout(b),o(),v(tt(g.text,a.playbackRate))}),a.onended=s(()=>c(f,p)),a.onerror=s(()=>d(f,g,p,v)),a.src=t,a.playbackRate=e.rate,v(8e3),a.play().catch(s(()=>{clearTimeout(b),d(f,g,p,v)}))},()=>{clearTimeout(b),d(f,g,p,v)})}(g))},stop:function(l){n++,r=null,a=!1,e.setSpeaking(!1),(null!==s||i)&&(s=null,i=!1,e.setHolding(!1),e.hold(!1)),t=e.segments?ta(e.segments,l)-1:-1,e3()?.cancel(),"cloud"===e.mode&&(0,e1.l)()?.pause()},dispose:function(){n++,e3()?.cancel(),"cloud"===e.mode&&(0,e1.l)()?.pause()}}}(a);return b.current={playback:s,deps:a},()=>{s.dispose(),b.current=null}},[]);let w=(0,a.useCallback)(()=>b.current?.playback??null,[]);(0,a.useEffect)(()=>()=>{w()?.dispose()},[e,w]);let N=(0,a.useCallback)(e=>{w()?.stop(e)},[w]),k=(0,a.useCallback)(e=>{w()?.update(e)},[w]),S=(0,a.useCallback)(()=>{v.current&&(e5(),"cloud"===l.current&&(0,e1.p)())},[l]),A=(0,a.useCallback)((e,t)=>{p.current=!0,w()?.stop(t),v.current=e,d(e),te(e6,e?"1":"0"),S()},[w,S]),C=(0,a.useCallback)(()=>{var e;let t,a=(e=j.current,t=e8.indexOf(e),e8[(t+1)%e8.length]);if(j.current=a,m(a),"cloud"===l.current){let e=(0,e1.l)();e&&(e.playbackRate=a)}te(e7,String(a))},[l]);return(0,a.useEffect)(()=>{let e="cloud"===i&&!(0,e1.h)();if(!c||(e4||!e3())&&!e)return;let t=()=>{e5(),e&&(0,e1.p)()};return document.addEventListener("click",t,{capture:!0,once:!0}),document.addEventListener("touchend",t,{capture:!0,once:!0}),()=>{document.removeEventListener("click",t,{capture:!0}),document.removeEventListener("touchend",t,{capture:!0})}},[c,i]),(0,a.useEffect)(()=>{c&&"cloud"===i&&e?.length&&(0,e1.w)(e.map(e=>e.text),t,s).catch(()=>void 0)},[c,i,e,t,s]),(0,a.useEffect)(()=>{if("cloud"!==i||!e?.length||v.current)return;let a=!0;return(0,e1.z)(e.map(e=>e.text),t).then(e=>{a&&e&&!v.current&&!p.current&&(v.current=!0,d(!0))}),()=>{a=!1}},[i,e,t]),{supported:r||"cloud"===i,enabled:c,rate:u,speaking:g,holding:x,setEnabled:A,cycleRate:C,update:k,stop:N,prime:S}}({segments:I,language:r,errorItemId:s,holdAnimation:(0,a.useCallback)(e=>{e?o.current?.pauseAnimations():o.current?.unpauseAnimations(),T().forEach(t=>e?t.pause():t.play())},[T])}),F=E.enabled&&(E.holding||!u&&E.speaking),{stop:M,update:L,prime:z}=E,$=(0,a.useCallback)(()=>{o.current?.pauseAnimations(),T().forEach(e=>e.pause()),m(!1)},[T]),q=(0,a.useCallback)(()=>{M(o.current?.getCurrentTime()??0),$()},[$,M]),R=(0,a.useCallback)(e=>{o.current?.setCurrentTime(e),T().forEach(t=>{t.currentTime=1e3*e}),h(e),M(e)},[T,M]),V=(0,a.useCallback)(()=>{let e=o.current;e&&(w>0&&e.getCurrentTime()>=w&&R(0),e.unpauseAnimations(),T().forEach(e=>e.play()),m(!0),z())},[T,w,R,z]),O=async()=>{if(j)return void y(!1);if(document.fullscreenElement)return void await document.exitFullscreen().catch(()=>void 0);let e=i.current;if(e&&"function"==typeof e.requestFullscreen)try{await e.requestFullscreen();return}catch{}y(!0)};return(0,a.useEffect)(()=>{let e=()=>v(document.fullscreenElement===i.current);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),(0,a.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&y(!1)},t=document.body.style.overflow;return document.body.style.overflow="hidden",document.addEventListener("keydown",e),()=>{document.body.style.overflow=t,document.removeEventListener("keydown",e)}},[j]),(0,a.useEffect)(()=>{if(!u)return;let e=0,t=()=>{let a=o.current?.getCurrentTime()??0;if(L(a),w>0&&a>=w){o.current?.setCurrentTime(w),$(),h(w);return}h(a),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[u,w,$,L]),(0,t.jsxs)("div",{ref:i,className:(0,eP.f)("space-y-2",b&&"flex flex-col items-center justify-center bg-black p-4",j&&"fixed inset-0 z-50"),children:[(0,t.jsx)("iframe",{ref:l,srcDoc:k,sandbox:"allow-same-origin",title:n.svgAnimation.alt,onLoad:()=>{o.current=l.current?.contentDocument?.querySelector("svg")??null,M(0),$(),o.current?.setCurrentTime(0),T().forEach(e=>{e.currentTime=0}),C(o.current?e0(o.current):null),h(0),d(o.current?e:null)},className:(0,eP.f)("mx-auto block rounded border bg-white transition-shadow",!b&&"w-full max-w-3xl",F&&"border-primary ring-2 ring-primary/40"),style:{visibility:c===e?"visible":"hidden",...b?{aspectRatio:N,width:`min(100%, calc((100dvh - 96px) * ${N}))`}:{aspectRatio:N}}}),(0,t.jsxs)("div",{className:(0,eP.f)("mx-auto flex w-full items-center gap-2",b?"max-w-5xl text-white":"max-w-3xl"),children:[(0,t.jsx)(x.f,{variant:"outline",size:"sm",className:"h-8 w-8 shrink-0 p-0 text-foreground",onClick:u?q:V,disabled:c!==e,"aria-label":u?n.svgAnimation.pause:n.svgAnimation.play,title:u?n.svgAnimation.pause:n.svgAnimation.play,children:u?(0,t.jsx)(eR,{className:"h-4 w-4"}):(0,t.jsx)(eV.f,{className:"h-4 w-4"})}),(0,t.jsx)(x.f,{variant:"ghost",size:"sm",className:(0,eP.f)("h-8 w-8 shrink-0 p-0",b&&"text-white hover:bg-white/20 hover:text-white"),onClick:()=>{R(0),V()},disabled:c!==e,"aria-label":n.svgAnimation.replay,title:n.svgAnimation.replay,children:(0,t.jsx)(eO.f,{className:"h-4 w-4"})}),w>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{type:"range",min:0,max:w,step:.1,value:Math.min(g,w),onChange:e=>R(Number(e.target.value)),"aria-label":n.svgAnimation.progress,className:"h-2 min-w-0 flex-1 cursor-pointer accent-primary"}),(0,t.jsxs)("span",{className:(0,eP.f)("shrink-0 text-xs tabular-nums",b?"text-white/80":"text-muted-foreground"),children:[ts(g)," / ",ts(w)]})]}),(0,t.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[!!I?.length&&(0,t.jsx)(eG,{supported:E.supported,enabled:E.enabled,rate:E.rate,fullscreen:b,onToggle:()=>E.setEnabled(!E.enabled,o.current?.getCurrentTime()??0),onCycleRate:E.cycleRate}),(0,t.jsx)(x.f,{variant:"ghost",size:"sm",className:(0,eP.f)("h-8 w-8 shrink-0 p-0",b&&"text-white hover:bg-white/20 hover:text-white"),onClick:O,"aria-label":b?n.svgAnimation.exitFullscreen:n.svgAnimation.fullscreen,title:b?n.svgAnimation.exitFullscreen:n.svgAnimation.fullscreen,children:b?(0,t.jsx)(e$,{className:"h-4 w-4"}):(0,t.jsx)(eL,{className:"h-4 w-4"})})]})]})]})}function tr({svg:e,errorItemId:s,disabled:n,onBusyChange:r}){let{t:i,language:l}=(0,f.b)(),[o,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(!1),m=(0,a.useMemo)(()=>(function(e){let t=eW(e);if(t)return t;try{let t=new DOMParser().parseFromString(e,"image/svg+xml").documentElement;return"svg"===t.nodeName?e0(t):null}catch{return null}})(e),[e]);if((0,a.useEffect)(()=>{let e=!0;return(0,e1.v)().then(t=>{e&&c("cloud"===t)}),()=>{e=!1}},[]),!o||!m?.length)return null;let h=async()=>{u(!0),r(!0);try{await (0,e1.H)(m.map(e=>e.text),l,s),M.c.success(i.svgAnimation.voiceRegenerateDone)}catch(s){let e=(0,v.d)(s)||"";j.V.error("[SvgAnimation]","Failed to regenerate cloud voice",{code:e,error:(0,v.Z)(s)});let t=(0,v.L)(s),a="TTS_DISABLED"===e?i.svgAnimation.voiceRegenerateDisabled:i.svgAnimation.voiceRegenerateFailed;M.c.error(t?`${a} (${t})`:a)}finally{u(!1),r(!1)}};return(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:h,disabled:n||d,title:i.svgAnimation.voiceRegenerateHint,children:[d?(0,t.jsx)(g.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(eO.f,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:d?i.svgAnimation.voiceRegenerating:i.svgAnimation.voiceRegenerate})]})}function ti({errorItemId:e,svgAnimation:s,hasOtherLanguage:n,onChange:r}){let{t:i,language:l}=(0,f.b)(),[o,u]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!1),[y,b]=(0,a.useState)(!1),[w,N]=(0,a.useState)(!1),[k,S]=(0,a.useState)(null),A=(0,a.useMemo)(()=>!!s&&!!eW(s),[s]),C=(e,t)=>{let a=i.errors[e];return"string"==typeof a?a:t},I=async()=>{u(!0),S(null);try{let t=await p.k.post(`/api/error-items/${e}/svg-animation`,{language:l},{timeout:6e5,recoverable:!0});r(l,t.svgAnimation)}catch(t){let e=(0,v.d)(t)||"";j.V.error("[SvgAnimation]","Failed to generate SVG animation",{code:e,error:(0,v.Z)(t)}),S("NO_QUESTION_TEXT"===e?i.svgAnimation.noQuestionText:"NO_VALID_ANIMATION"===e?i.svgAnimation.invalid:C(e,i.svgAnimation.failed))}finally{u(!1)}},T=async()=>{b(!0),S(null);try{let t=await p.k.post(`/api/error-items/${e}/svg-animation/narration`,{language:l},{timeout:3e5,recoverable:!0});r(l,t.svgAnimation),M.c.success(i.svgAnimation.narrationDone)}catch(t){let e=(0,v.d)(t)||"";j.V.error("[SvgAnimation]","Failed to generate SVG narration",{code:e,error:(0,v.Z)(t)}),S("NO_VALID_NARRATION"===e?i.svgAnimation.narrationInvalid:C(e,i.svgAnimation.narrationFailed))}finally{b(!1)}},E=async()=>{if(await (0,M.u)(i.svgAnimation.confirmDelete,{destructive:!0})){h(!0);try{await p.k.delete(`/api/error-items/${e}/svg-animation?language=${l}`),r(l,null),S(null)}catch(e){j.V.error("[SvgAnimation]","Failed to delete SVG animation",{error:e instanceof Error?e.message:String(e)}),M.c.error(i.svgAnimation.deleteFailed)}finally{h(!1)}}};if(!s)return(0,t.jsxs)("div",{className:"rounded-lg border border-dashed p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(eF,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:i.svgAnimation.title})]}),(0,t.jsxs)(x.f,{variant:"outline",size:"sm",onClick:I,disabled:o,children:[o?(0,t.jsx)(g.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(eF,{className:"mr-2 h-4 w-4"}),o?i.svgAnimation.generating:i.svgAnimation.generate]})]}),k&&(0,t.jsx)("p",{className:"text-xs text-destructive mt-2",children:k}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:n?i.svgAnimation.otherLanguageAvailable:i.svgAnimation.hint})]});let F=o||m||y||w;return(0,t.jsxs)("div",{className:"rounded-lg border bg-card",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-b bg-muted/30",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i.svgAnimation.title}),F&&(0,t.jsx)(g.f,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:T,disabled:F,title:i.svgAnimation.narrationHint,children:[y?(0,t.jsx)(g.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(eT,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:y?i.svgAnimation.narrationGenerating:A?i.svgAnimation.narrationRegenerate:i.svgAnimation.narrationGenerate})]}),(0,t.jsx)(tr,{svg:s,errorItemId:e,disabled:F,onBusyChange:N}),(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:I,disabled:F,children:[o?(0,t.jsx)(g.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(c.f,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:o?i.svgAnimation.generating:i.svgAnimation.regenerate})]}),(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1 text-destructive hover:text-destructive",onClick:E,disabled:F,children:[(0,t.jsx)(d.f,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:i.svgAnimation.delete})]})]})]}),k&&(0,t.jsx)("p",{className:"px-3 pt-2 text-xs text-destructive",children:k}),(0,t.jsx)("div",{className:"p-2 sm:p-3",children:(0,t.jsx)(tn,{svg:s,errorItemId:e})})]})}var tl=e.i(912505),to=e.i(86963),tc=e.i(35209);e.s(["default",0,function(){let e=(0,n.useParams)(),i=(0,n.useRouter)(),{t:l,language:m}=(0,f.b)(),[g,h]=(0,a.useState)(null);(0,tc.f)(l.detail.title,g?.subject?.name,g?.shortId);let[v,w]=(0,a.useState)(!0),[N,k]=(0,a.useState)(null),[S,A]=(0,a.useState)(!1),[C,I]=(0,a.useState)(void 0),[T,E]=(0,a.useState)(!1),[F,L]=(0,a.useState)(!0),[$,R]=(0,a.useState)(null),[V,O]=(0,a.useState)(!1),U=(0,a.useCallback)(async e=>{try{let t=await p.k.get(`/api/error-items/${e}`);h(t)}catch(e){j.V.error("[ErrorDetail]","Failed to fetch error item",{error:e}),M.c.error(l.common?.messages?.loadFailed||"Failed to load item"),i.push("/notebooks")}finally{w(!1)}},[i,l]);(0,a.useEffect)(()=>{p.k.get("/api/user").then(e=>{e&&e.educationStage&&I(e.educationStage),E(!!e?.enableGeogebra),L(e?.enableSvgAnimation!==!1)}).catch(e=>j.V.error("[ErrorDetail]","Failed to fetch user info",{error:e})),e.id&&U(e.id)},[e.id,U]);let D=(0,a.useCallback)(e=>{h(t=>t&&{...t,...e})},[]),_=async e=>{g&&(await p.k.put(`/api/error-items/${g.id}`,e),D(e))},H=async()=>{g&&await U(g.id)},P=async e=>{if(!g)return;let t=g.difficultyStars??null;D({difficultyStars:e}),O(!0);try{let t=await p.k.put(`/api/error-items/${g.id}`,{difficultyStars:e});D({paperLevel:t.paperLevel})}catch(e){D({difficultyStars:t}),j.V.error("[ErrorDetail]","Failed to save difficulty",{error:e}),M.c.error(l.difficulty.saveFailed)}finally{O(!1)}},G=(0,a.useCallback)((e,t)=>{D({["en"===e?"svgAnimationEn":"svgAnimation"]:t})},[D]),B=async()=>{if(g&&await (0,M.u)(l.common?.messages?.confirmDelete||"Are you sure you want to delete this error item?",{destructive:!0}))try{await p.k.delete(`/api/error-items/${g.id}/delete`),M.c.success(l.common?.messages?.deleteSuccess||"Deleted successfully"),i.push(g.subjectId?`/notebooks/${g.subjectId}`:"/notebooks")}catch(e){j.V.error("[ErrorDetail]","Failed to delete error item",{error:e}),M.c.error(l.common?.messages?.deleteFailed||"Delete failed")}};return v?(0,t.jsx)(to.f,{label:l.common.loading}):g?(0,t.jsxs)("main",{className:"min-h-screen",children:[(0,t.jsxs)("div",{className:"mx-auto max-w-6xl space-y-6 px-4 py-6 md:px-8 md:py-8",children:[(0,t.jsxs)("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,t.jsx)(s.default,{href:g.subjectId?`/notebooks/${g.subjectId}`:"/notebooks",children:(0,t.jsx)(x.f,{variant:"ghost",size:"icon",className:"-ml-2",children:(0,t.jsx)(r.f,{className:"h-5 w-5"})})}),(0,t.jsx)("h1",{className:"text-2xl font-bold tracking-tight",children:l.detail.title}),(0,t.jsx)(eC,{shortId:g.shortId}),(0,t.jsx)(u.f,{size:"md",value:g.difficultyStars,onChange:P,disabled:V})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(ey,{errorItemId:g.id,fields:g,onDone:D}),(0,t.jsx)(s.default,{href:`/practice?id=${g.id}`,children:(0,t.jsxs)(x.f,{variant:"outline",size:"sm",children:[(0,t.jsx)(c.f,{className:"mr-2 h-4 w-4"}),l.detail.practice]})}),$&&(0,t.jsx)(ew.x,{status:$,className:"h-8 self-center px-3"}),(0,t.jsxs)(x.f,{variant:"ghost",size:"sm",onClick:B,className:"text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-950/40",children:[(0,t.jsx)(d.f,{className:"mr-2 h-4 w-4"}),l.detail.delete||"Delete"]})]})]}),(0,t.jsx)(ed,{item:g,educationStage:C,saveFields:_,onUpdate:D,reload:H,onEnlarge:k}),(0,t.jsx)(eb.K,{errorItemId:g.id,onMasteryStatusChange:R}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,t.jsx)(z,{title:l.detail.correctAnswer,value:g.answerText,onSave:e=>_({answerText:e}),logLabel:"answer",rows:5,placeholder:"Enter answer...",cardClassName:"border-primary/20",titleClassName:"text-primary",contentClassName:"font-semibold",headerActions:(0,t.jsx)(ek,{errorItemId:g.id,onDone:e=>D({answerText:e.answerText??"",analysis:e.analysis??""})}),children:g.referenceImageUrl&&(0,t.jsx)("div",{className:"pt-3",children:(0,t.jsx)(ec,{src:g.referenceImageUrl,alt:l.detail.referenceImageAlt,showLabel:l.detail.viewImage,hideLabel:l.detail.hideImage,visible:S,onVisibleChange:A,onEnlarge:k})})}),(0,t.jsx)(em,{item:g,saveFields:_,onEnlarge:k})]}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,t.jsx)(z,{title:l.detail.analysis,value:g.analysis,onSave:e=>_({analysis:e}),logLabel:"analysis",rows:12,placeholder:"Enter analysis..."}),(0,t.jsx)(z,{title:l.detail?.mistakeAnalysis||"Mistake Analysis",value:g.mistakeAnalysis,onSave:e=>_({mistakeAnalysis:e}),logLabel:"mistake analysis",rows:8,editorLabel:l.editor?.mistakeAnalysis||"Mistake Cause Analysis",emptyText:l.detail?.noMistakeAnalysis||"No mistake analysis yet."})]}),(0,t.jsxs)("div",{className:"space-y-6",children:[F&&(0,t.jsx)(ti,{errorItemId:g.id,svgAnimation:"en"===m?g.svgAnimationEn:g.svgAnimation,hasOtherLanguage:!!("en"===m?g.svgAnimation:g.svgAnimationEn),onChange:G},m),T&&(0,t.jsx)(y,{errorItemId:g.id,commands:g.geogebraCommands,onUpdate:D}),(0,t.jsx)(q,{item:g,onUpdate:D})]})]}),(0,t.jsx)(b,{src:N,onClose:()=>k(null)})]}):(0,t.jsx)(tl.f,{icon:o,title:l.detail.notFound||"Item not found",className:"m-4 md:m-8"})}],204573)}]);