wrong-notebook 2026.10.30-3 → 2026.10.30

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 (265) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +2 -0
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +12 -0
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  12. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/admin/page.js.nft.json +1 -1
  14. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/admin/user/[id]/page.js.nft.json +1 -1
  16. package/.next/server/app/admin/user/[id]/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/admin/dashboard/route.js +9 -9
  18. package/.next/server/app/api/admin/dashboard/route.js.nft.json +1 -1
  19. package/.next/server/app/api/admin/users/[id]/detail/route.js +9 -9
  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 +9 -9
  24. package/.next/server/app/api/ai/models/route.js.nft.json +1 -1
  25. package/.next/server/app/api/ai/test/route.js +11 -11
  26. package/.next/server/app/api/ai/test/route.js.nft.json +1 -1
  27. package/.next/server/app/api/analytics/route.js +10 -10
  28. package/.next/server/app/api/analytics/route.js.nft.json +1 -1
  29. package/.next/server/app/api/analyze/route.js +11 -11
  30. package/.next/server/app/api/analyze/route.js.nft.json +1 -1
  31. package/.next/server/app/api/error-items/[id]/figure/route.js +9 -9
  32. package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
  33. package/.next/server/app/api/error-items/[id]/fix-latex/route.js +10 -10
  34. package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
  35. package/.next/server/app/api/error-items/[id]/geogebra/route.js +11 -11
  36. package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
  37. package/.next/server/app/api/error-items/[id]/reanswer/route.js +9 -9
  38. package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
  39. package/.next/server/app/api/error-items/[id]/retag/route.js +12 -12
  40. package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
  41. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js +9 -9
  42. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
  43. package/.next/server/app/api/error-items/[id]/svg-animation/route.js +9 -9
  44. package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
  45. package/.next/server/app/api/error-items/list/route.js.nft.json +1 -1
  46. package/.next/server/app/api/error-items/route.js +9 -9
  47. package/.next/server/app/api/error-items/route.js.nft.json +1 -1
  48. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js +11 -11
  49. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
  50. package/.next/server/app/api/exams/[id]/results/route.js +9 -9
  51. package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
  52. package/.next/server/app/api/exams/[id]/retry/route.js +7 -7
  53. package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
  54. package/.next/server/app/api/exams/[id]/route.js +7 -7
  55. package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
  56. package/.next/server/app/api/exams/route.js +12 -12
  57. package/.next/server/app/api/exams/route.js.nft.json +1 -1
  58. package/.next/server/app/api/export/route.js.nft.json +1 -1
  59. package/.next/server/app/api/geogebra-analyze/route.js +11 -11
  60. package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
  61. package/.next/server/app/api/import/route.js +9 -9
  62. package/.next/server/app/api/import/route.js.nft.json +1 -1
  63. package/.next/server/app/api/minimax-code/checkin/route.js +2 -2
  64. package/.next/server/app/api/minimax-code/checkin/route.js.nft.json +1 -1
  65. package/.next/server/app/api/minimax-code/login/route.js.nft.json +1 -1
  66. package/.next/server/app/api/minimax-code/route.js +2 -2
  67. package/.next/server/app/api/minimax-code/route.js.nft.json +1 -1
  68. package/.next/server/app/api/notebooks/[id]/retag/route.js +7 -7
  69. package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
  70. package/.next/server/app/api/openclaw/batch-upload/route.js +7 -7
  71. package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
  72. package/.next/server/app/api/practice/generate/route.js +10 -10
  73. package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
  74. package/.next/server/app/api/practice/grade/route.js +9 -9
  75. package/.next/server/app/api/practice/grade/route.js.nft.json +1 -1
  76. package/.next/server/app/api/practice/record/[id]/route.js +10 -10
  77. package/.next/server/app/api/practice/record/[id]/route.js.nft.json +1 -1
  78. package/.next/server/app/api/practice/record/route.js +9 -9
  79. package/.next/server/app/api/practice/record/route.js.nft.json +1 -1
  80. package/.next/server/app/api/reanswer/route.js +8 -8
  81. package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
  82. package/.next/server/app/api/register/route.js +2 -2
  83. package/.next/server/app/api/register/route.js.nft.json +1 -1
  84. package/.next/server/app/api/register/status/route.js +2 -2
  85. package/.next/server/app/api/register/status/route.js.nft.json +1 -1
  86. package/.next/server/app/api/review/due/route.js +8 -8
  87. package/.next/server/app/api/review/due/route.js.nft.json +1 -1
  88. package/.next/server/app/api/settings/route.js +4 -4
  89. package/.next/server/app/api/settings/route.js.nft.json +1 -1
  90. package/.next/server/app/api/setup/route.js +1 -1
  91. package/.next/server/app/api/setup/route.js.nft.json +1 -1
  92. package/.next/server/app/api/stats/practice/route.js.nft.json +1 -1
  93. package/.next/server/app/api/tts/[id]/route.js.nft.json +1 -1
  94. package/.next/server/app/api/tts/batch/route/app-paths-manifest.json +3 -0
  95. package/.next/server/app/api/tts/batch/route/build-manifest.json +12 -0
  96. package/.next/server/app/api/tts/batch/route/server-reference-manifest.json +4 -0
  97. package/.next/server/app/api/tts/batch/route.js +17 -0
  98. package/.next/server/app/api/tts/batch/route.js.map +5 -0
  99. package/.next/server/app/api/tts/batch/route.js.nft.json +1 -0
  100. package/.next/server/app/api/tts/batch/route_client-reference-manifest.js +3 -0
  101. package/.next/server/app/api/tts/route.js +8 -7
  102. package/.next/server/app/api/tts/route.js.nft.json +1 -1
  103. package/.next/server/app/api/tts/status/route/app-paths-manifest.json +3 -0
  104. package/.next/server/app/api/tts/status/route/build-manifest.json +12 -0
  105. package/.next/server/app/api/tts/status/route/server-reference-manifest.json +4 -0
  106. package/.next/server/app/api/tts/status/route.js +16 -0
  107. package/.next/server/app/api/tts/status/route.js.map +5 -0
  108. package/.next/server/app/api/tts/status/route.js.nft.json +1 -0
  109. package/.next/server/app/api/tts/status/route_client-reference-manifest.js +3 -0
  110. package/.next/server/app/api/user/route.js +11 -11
  111. package/.next/server/app/api/user/route.js.nft.json +1 -1
  112. package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
  113. package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
  114. package/.next/server/app/exams/[id]/page.js.nft.json +1 -1
  115. package/.next/server/app/exams/[id]/page_client-reference-manifest.js +1 -1
  116. package/.next/server/app/exams/[id]/print/page.js.nft.json +1 -1
  117. package/.next/server/app/exams/[id]/print/page_client-reference-manifest.js +1 -1
  118. package/.next/server/app/exams/page.js.nft.json +1 -1
  119. package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
  120. package/.next/server/app/login/page.js.nft.json +1 -1
  121. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  122. package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
  123. package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
  124. package/.next/server/app/notebooks/[id]/page.js.nft.json +1 -1
  125. package/.next/server/app/notebooks/[id]/page_client-reference-manifest.js +1 -1
  126. package/.next/server/app/notebooks/page.js.nft.json +1 -1
  127. package/.next/server/app/notebooks/page_client-reference-manifest.js +1 -1
  128. package/.next/server/app/page.js.nft.json +1 -1
  129. package/.next/server/app/page_client-reference-manifest.js +1 -1
  130. package/.next/server/app/practice/page.js.nft.json +1 -1
  131. package/.next/server/app/practice/page_client-reference-manifest.js +1 -1
  132. package/.next/server/app/print-preview/page.js.nft.json +1 -1
  133. package/.next/server/app/print-preview/page_client-reference-manifest.js +1 -1
  134. package/.next/server/app/register/page.js.nft.json +1 -1
  135. package/.next/server/app/register/page_client-reference-manifest.js +1 -1
  136. package/.next/server/app/review/page.js.nft.json +1 -1
  137. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  138. package/.next/server/app/setup/page.js.nft.json +1 -1
  139. package/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  140. package/.next/server/app/stats/page.js.nft.json +1 -1
  141. package/.next/server/app/stats/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app/tags/page.js.nft.json +1 -1
  143. package/.next/server/app/tags/page_client-reference-manifest.js +1 -1
  144. package/.next/server/app-paths-manifest.json +2 -0
  145. package/.next/server/chunks/[root-of-the-server]__003ii50e63ws5._.js +1 -1
  146. package/.next/server/chunks/[root-of-the-server]__02bjw2uriv5fd._.js +3 -0
  147. package/.next/server/chunks/[root-of-the-server]__03ru8t856rgvl._.js +3 -0
  148. package/.next/server/chunks/[root-of-the-server]__06j_-j4ftb5db._.js +3 -0
  149. package/.next/server/chunks/[root-of-the-server]__0duevucfb62_h._.js +3 -0
  150. package/.next/server/chunks/[root-of-the-server]__0gvvuk0avtpy9._.js +3 -3
  151. package/.next/server/chunks/[root-of-the-server]__0iq2agc-dlcyc._.js +3 -0
  152. package/.next/server/chunks/{[root-of-the-server]__0a-iuqynn3h9d._.js → [root-of-the-server]__0lgsw0kfw-jqc._.js} +1 -1
  153. package/.next/server/chunks/[root-of-the-server]__0orbb3gvf9h5l._.js +1 -1
  154. package/.next/server/chunks/[root-of-the-server]__0rt84iswe-353._.js +3 -3
  155. package/.next/server/chunks/[root-of-the-server]__0uvuljzm78r8b._.js +3 -0
  156. package/.next/server/chunks/[root-of-the-server]__1-jk6umz3qs6r._.js +3 -0
  157. package/.next/server/chunks/[root-of-the-server]__10ffg2l-u0zof._.js +3 -0
  158. package/.next/server/chunks/[root-of-the-server]__1_fxjdqa7fwwc._.js +3 -0
  159. package/.next/server/chunks/[root-of-the-server]__1g038brpx-jta._.js +3 -0
  160. package/.next/server/chunks/[root-of-the-server]__1gx-b_vxyk--4._.js +1 -1
  161. package/.next/server/chunks/[root-of-the-server]__1ixfwffo1gqy1._.js +3 -0
  162. package/.next/server/chunks/[root-of-the-server]__1jcp2-lix6if6._.js +3 -0
  163. package/.next/server/chunks/[root-of-the-server]__1kff0rbt3ym95._.js +3 -0
  164. package/.next/server/chunks/[root-of-the-server]__1n2uvss8wfueo._.js +3 -0
  165. package/.next/server/chunks/[root-of-the-server]__1nsrbw9jntgo8._.js +1 -1
  166. package/.next/server/chunks/[root-of-the-server]__1onv3pfwsqytl._.js +3 -0
  167. package/.next/server/chunks/[root-of-the-server]__1q9pzdlt18lp0._.js +1 -1
  168. package/.next/server/chunks/[root-of-the-server]__1uz66pjshld-e._.js +3 -0
  169. package/.next/server/chunks/_076-jjzrfdsdk._.js +1 -1
  170. package/.next/server/chunks/_09o9zamz75n5d._.js +1 -1
  171. package/.next/server/chunks/{_0t4hmii1np2ho._.js → _0a7_sds_l6vgw._.js} +3 -3
  172. package/.next/server/chunks/{_1oy0tspjrakxd._.js → _0b7ljlcl6h_ro._.js} +3 -3
  173. package/.next/server/chunks/_0gxi3zrkhyvx_._.js +1 -1
  174. package/.next/server/chunks/_0hk9z9rqga4x-._.js +3 -0
  175. package/.next/server/chunks/_0lob14xk0ko5z._.js +1 -1
  176. package/.next/server/chunks/_0p-sas2zxy3iv._.js +3 -0
  177. package/.next/server/chunks/_0z0zrluul2idw._.js +1 -1
  178. package/.next/server/chunks/_11_p1ahjjply_._.js +1 -1
  179. package/.next/server/chunks/_13ffmxv8qrwi0._.js +1 -1
  180. package/.next/server/chunks/_16jdov0rxh99d._.js +1 -1
  181. package/.next/server/chunks/_1a1udq0c4_6ad._.js +1 -1
  182. package/.next/server/chunks/_1ahi8466v1b3l._.js +1 -1
  183. package/.next/server/chunks/_1b7qjlv0nxovi._.js +1 -1
  184. package/.next/server/chunks/_1e8w9uuebtrcb._.js +1 -1
  185. package/.next/server/chunks/_1hp9mnz19v199._.js +1 -1
  186. package/.next/server/chunks/_1j8kqz21_i728._.js +1 -1
  187. package/.next/server/chunks/_1m-yyz-pl9-03._.js +1 -1
  188. package/.next/server/chunks/_next-internal_server_app_api_tts_batch_route_actions_1jmuawkcgxmae.js +3 -0
  189. package/.next/server/chunks/_next-internal_server_app_api_tts_status_route_actions_1udk0hbf96zdl.js +3 -0
  190. package/.next/server/chunks/src_lib_1csf8_0vpeenu._.js +3 -0
  191. package/.next/server/chunks/src_lib_1mno8g5cqmaet._.js +1 -1
  192. package/.next/server/chunks/src_lib_1p0k3ud1vrwmg._.js +3 -0
  193. package/.next/server/chunks/src_lib_1qy5aajgog9r2._.js +1 -1
  194. package/.next/server/chunks/src_lib_auth-utils_ts_20i7biv4dj8pm._.js +1 -1
  195. package/.next/server/chunks/src_lib_minimax-code_checkin_ts_1j1mpuxc1vgoz._.js +1 -1
  196. package/.next/server/chunks/src_lib_tts_19zri-v8-l_4u._.js +6 -6
  197. package/.next/server/chunks/ssr/[root-of-the-server]__0x_ihemma9171._.js +3 -0
  198. package/.next/server/chunks/ssr/_00np6xqvkg6u-._.js +1 -1
  199. package/.next/server/chunks/ssr/_08fq-uch-l1g6._.js +1 -1
  200. package/.next/server/chunks/ssr/_0n_xmfdlu07f9._.js +3 -0
  201. package/.next/server/chunks/ssr/_0xyykn-ar3ujn._.js +3 -0
  202. package/.next/server/chunks/ssr/_17edi6l2a0p76._.js +1 -1
  203. package/.next/server/chunks/ssr/_20-x85_onge5x._.js +3 -0
  204. package/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_play_0upz8-7p5gttr.js +4 -0
  205. package/.next/server/chunks/ssr/src_1gayunqs8u2e2._.js +1 -1
  206. package/.next/server/chunks/ssr/src_app_error-items_[id]_page_tsx_04xwwdmyh7_9q._.js +1 -1
  207. package/.next/server/chunks/ssr/src_app_exams_[id]_page_tsx_0xcjflkgkwzgd._.js +1 -1
  208. package/.next/server/chunks/ssr/src_app_exams_[id]_print_page_tsx_1i-xvhk8ul1l1._.js +1 -1
  209. package/.next/server/chunks/ssr/src_app_print-preview_page_tsx_001yt-fzrj7tf._.js +1 -1
  210. package/.next/server/chunks/ssr/src_components_difficulty-stars_tsx_1af9qqfurq7_t._.js +1 -1
  211. package/.next/server/chunks/ssr/src_components_providers_tsx_09kw-mv3nb6xs._.js +1 -1
  212. package/.next/server/middleware-build-manifest.js +3 -3
  213. package/.next/server/middleware-manifest.json +5 -5
  214. package/.next/server/pages/500.html +1 -1
  215. package/.next/server/preview-props.json +3 -3
  216. package/.next/server/server-reference-manifest.js +1 -1
  217. package/.next/server/server-reference-manifest.json +1 -1
  218. package/.next/static/chunks/00n2-r3ac3dh5.js +2 -0
  219. package/.next/static/chunks/{0ebem2w42rgm6.js → 00o1s_nir_tbc.js} +7 -7
  220. package/.next/static/chunks/0kh-fx3tssh5w.js +1 -0
  221. package/.next/static/chunks/0p2fh98qaki45.js +1 -0
  222. package/.next/static/chunks/{314x1g250-zss.js → 1c46asvnosb8-.js} +1 -1
  223. package/.next/static/chunks/1cdwoh8b2ub-t.js +1 -0
  224. package/.next/static/chunks/1epmdj8kqwbz4.js +1 -0
  225. package/.next/static/chunks/1r7yfcltcmwkh.js +1 -0
  226. package/.next/static/chunks/24gum0cmhhv7z.js +1 -0
  227. package/.next/static/chunks/26qq8907b9j3d.js +1 -0
  228. package/.next/static/chunks/2cf27aonkij9_.css +3 -0
  229. package/.next/static/chunks/{2rgflf9-3s4ud.js → 2fr8ktozrvacg.js} +1 -1
  230. package/.next/static/chunks/{0oe2-jjx_8ol-.js → 2mawf08h1jfc8.js} +1 -1
  231. package/.next/static/chunks/2r4ddp7izc9sh.js +1 -0
  232. package/.next/static/chunks/2uobd1ff4vknn.js +33 -0
  233. package/.next/static/chunks/341etzsqr_b1v.js +6 -0
  234. package/package.json +1 -1
  235. package/prisma/seed.db +0 -0
  236. package/.next/server/chunks/[root-of-the-server]__0ergl3gmxvrz3._.js +0 -3
  237. package/.next/server/chunks/[root-of-the-server]__0lqng_pqv30ts._.js +0 -3
  238. package/.next/server/chunks/[root-of-the-server]__0ozf21hrh_433._.js +0 -3
  239. package/.next/server/chunks/[root-of-the-server]__0s0eusp3mojnx._.js +0 -3
  240. package/.next/server/chunks/[root-of-the-server]__0wm4req5e6m88._.js +0 -3
  241. package/.next/server/chunks/[root-of-the-server]__114quo-_-qi9w._.js +0 -3
  242. package/.next/server/chunks/[root-of-the-server]__16-d6bl8bbqvy._.js +0 -3
  243. package/.next/server/chunks/[root-of-the-server]__1_04f-bpuf75t._.js +0 -3
  244. package/.next/server/chunks/[root-of-the-server]__1_hpgx5rlxpya._.js +0 -3
  245. package/.next/server/chunks/[root-of-the-server]__1mj__r5f_o6lo._.js +0 -3
  246. package/.next/server/chunks/[root-of-the-server]__20m7u7lg4e5q8._.js +0 -3
  247. package/.next/server/chunks/ssr/[root-of-the-server]__1w4rew5br9_b8._.js +0 -3
  248. package/.next/server/chunks/ssr/_04ziy8_ak_olr._.js +0 -3
  249. package/.next/server/chunks/ssr/_09gyxodn5bpsw._.js +0 -4
  250. package/.next/server/chunks/ssr/_0oksf3a6pbj88._.js +0 -3
  251. package/.next/static/chunks/0-_s_oel8jb5s.js +0 -1
  252. package/.next/static/chunks/0dizg7xu7sle2.js +0 -1
  253. package/.next/static/chunks/0h8aoqx7182md.js +0 -1
  254. package/.next/static/chunks/0pvlg-25ddo6e.js +0 -33
  255. package/.next/static/chunks/188s0rumoz5yj.js +0 -1
  256. package/.next/static/chunks/1c_3by-e4c6ix.js +0 -2
  257. package/.next/static/chunks/1qa6rlj01hnl5.js +0 -1
  258. package/.next/static/chunks/2q9n-d4_9bhp2.js +0 -1
  259. package/.next/static/chunks/2x1y8v15sfol3.css +0 -3
  260. package/.next/static/chunks/37jrjuqt8f_ee.js +0 -1
  261. package/.next/static/chunks/3oygizhwo77gr.js +0 -6
  262. package/.next/static/chunks/3zt-rwod7li6h.js +0 -1
  263. /package/.next/static/{x6fwUxfhT4hZ2tYr6cKl_ → 4KSCavDaw8kyhSyGiE86P}/_buildManifest.js +0 -0
  264. /package/.next/static/{x6fwUxfhT4hZ2tYr6cKl_ → 4KSCavDaw8kyhSyGiE86P}/_clientMiddlewareManifest.js +0 -0
  265. /package/.next/static/{x6fwUxfhT4hZ2tYr6cKl_ → 4KSCavDaw8kyhSyGiE86P}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,1661,e=>{"use strict";var s=e.i(843476),t=e.i(111110),a=e.i(217255),r=e.i(215519),i=e.i(325164),n=e.i(522016),l=e.i(618566),c=e.i(217923),o=e.i(810980),d=e.i(551804),m=e.i(178583),u=e.i(292270),x=e.i(475254);let h=(0,x.f)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),p=(0,x.f)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);var f=e.i(271645);let g=(0,x.f)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),j=(0,x.f)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),v=(0,x.f)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var y=e.i(763639),b=e.i(531278);let w=(0,x.f)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),N=(0,x.f)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var k=e.i(284614),S=e.i(733060),C=e.i(519455),T=e.i(776639),A=e.i(677572),_=e.i(306831),E=e.i(487486),M=e.i(699375),D=e.i(793479),R=e.i(110204),F=e.i(975157);let z=f.forwardRef(({className:e,...t},a)=>(0,s.jsx)("div",{className:"relative w-full overflow-auto",children:(0,s.jsx)("table",{ref:a,className:(0,F.f)("w-full caption-bottom text-sm",e),...t})}));z.displayName="Table";let I=f.forwardRef(({className:e,...t},a)=>(0,s.jsx)("thead",{ref:a,className:(0,F.f)("[&_tr]:border-b",e),...t}));I.displayName="TableHeader";let L=f.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tbody",{ref:a,className:(0,F.f)("[&_tr:last-child]:border-0",e),...t}));L.displayName="TableBody",(f.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tfoot",{ref:a,className:(0,F.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}))).displayName="TableFooter";let $=f.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tr",{ref:a,className:(0,F.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));$.displayName="TableRow";let U=f.forwardRef(({className:e,...t},a)=>(0,s.jsx)("th",{ref:a,className:(0,F.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));U.displayName="TableHead";let P=f.forwardRef(({className:e,...t},a)=>(0,s.jsx)("td",{ref:a,className:(0,F.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));P.displayName="TableCell",(f.forwardRef(({className:e,...t},a)=>(0,s.jsx)("caption",{ref:a,className:(0,F.f)("mt-4 text-sm text-muted-foreground",e),...t}))).displayName="TableCaption";var O=e.i(727612);let q=(0,x.f)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var H=e.i(269638),V=e.i(41931),Y=e.i(294114),W=e.i(201276),B=e.i(303163);function J(){let{timeZone:e}=(0,r.M)(),{data:i}=(0,a.useSession)(),{t:n}=(0,t.b)(),[l,c]=(0,f.useState)([]),[o,d]=(0,f.useState)(!0),[m,u]=(0,f.useState)(!1),[x,h]=(0,f.useState)(!1),[p,g]=(0,f.useState)("0"),[j,v]=(0,f.useState)(!1),y=(0,f.useCallback)(async()=>{d(!0);try{let e=await V.f.get("/api/admin/users");c(e)}catch(e){W.f.error("[UserManagement]","Failed to fetch users",{error:e})}finally{d(!1)}},[]),w=(0,f.useCallback)(async()=>{try{let e=await V.f.get("/api/settings");u(!0===e.allowRegistration),g(String(e.aiDailyLimit??0))}catch(e){W.f.error("[UserManagement]","Failed to fetch config",{error:e})}},[]);(0,f.useEffect)(()=>{y(),w()},[y,w]);let N=async e=>{h(!0);try{await V.f.post("/api/settings",{allowRegistration:e}),u(e)}catch(e){W.f.error("[UserManagement]","Failed to update registration setting",{error:e}),Y.c.error(n.common.error)}finally{h(!1)}},k=Number(p),S=""!==p.trim()&&Number.isInteger(k)&&k>=0,T=async()=>{if(S){v(!0);try{await V.f.post("/api/settings",{aiDailyLimit:k}),Y.c.success(n.admin.aiDailyLimitSaved)}catch(e){W.f.error("[UserManagement]","Failed to update AI daily limit",{error:e}),Y.c.error(n.common.error)}finally{v(!1)}}},A=async e=>{let s=e.isActive?n.admin.confirmDisable:n.admin.confirmEnable;if(await (0,Y.u)(s))try{await V.f.patch(`/api/admin/users/${e.id}`,{isActive:!e.isActive}),y()}catch(e){W.f.error("[UserManagement]","Failed to update user status",{error:e}),Y.c.error(n.common.error)}},F=async e=>{if(await (0,Y.u)(n.admin.confirmDelete,{destructive:!0}))try{await V.f.delete(`/api/admin/users/${e.id}`),y()}catch(s){W.f.error("[UserManagement]","Failed to delete user",{error:s});let e=(0,B.d)(s)||n.common.error;Y.c.error(e)}};return o?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(b.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(R.f,{className:"text-base",children:n.admin?.allowRegistration||"Allow New Registrations"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:n.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[x&&(0,s.jsx)(b.f,{className:"h-4 w-4 animate-spin"}),(0,s.jsx)(M.f,{checked:m,onCheckedChange:N,disabled:x})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 p-4 border rounded-lg bg-muted/30 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(R.f,{htmlFor:"ai-daily-limit",className:"text-base",children:n.admin.aiDailyLimit}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:n.admin.aiDailyLimitDesc})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(D.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:p,onChange:e=>g(e.target.value),"aria-invalid":!S,className:"w-24"}),(0,s.jsxs)(C.f,{size:"sm",onClick:T,disabled:j||!S,children:[j&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.common.save]})]})]}),(0,s.jsx)("div",{className:"sm:hidden space-y-3",children:l.map(t=>(0,s.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium",children:t.name||"N/A"}),(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:t.email})]}),(0,s.jsx)(E.f,{variant:"admin"===t.role?"default":"secondary",children:"admin"===t.role?n.admin.admin:n.admin.user})]}),(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsxs)("div",{className:"text-muted-foreground",children:[n.admin.errors,": ",t._count.errorItems," | ",n.admin.practiceCount,": ",t._count.practiceRecords," | ",n.admin.aiUsageToday,": ",t.aiUsageToday]}),(0,s.jsx)(E.f,{variant:t.isActive?"default":"destructive",className:"text-xs",children:t.isActive?n.admin.active:n.admin.disabled})]}),(0,s.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,_.r)(t.createdAt,"yyyy-MM-dd",e)}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>A(t),disabled:t.id===i?.user?.id,children:t.isActive?(0,s.jsx)(q,{className:"h-4 w-4 text-orange-500"}):(0,s.jsx)(H.f,{className:"h-4 w-4 text-green-500"})}),(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>F(t),disabled:t.id===i?.user?.id,children:(0,s.jsx)(O.f,{className:"h-4 w-4 text-destructive"})})]})]})]},t.id))}),(0,s.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,s.jsxs)(z,{children:[(0,s.jsx)(I,{children:(0,s.jsxs)($,{children:[(0,s.jsx)(U,{children:n.admin.nameEmail}),(0,s.jsx)(U,{children:n.admin.role}),(0,s.jsx)(U,{children:n.admin.stats}),(0,s.jsx)(U,{children:n.admin.createdAt}),(0,s.jsx)(U,{children:n.admin.status}),(0,s.jsx)(U,{className:"text-right",children:n.admin.actions})]})}),(0,s.jsx)(L,{children:l.map(t=>(0,s.jsxs)($,{children:[(0,s.jsxs)(P,{children:[(0,s.jsx)("div",{className:"font-medium",children:t.name||"N/A"}),(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:t.email})]}),(0,s.jsx)(P,{children:(0,s.jsx)(E.f,{variant:"admin"===t.role?"default":"secondary",children:"admin"===t.role?n.admin.admin:n.admin.user})}),(0,s.jsxs)(P,{children:[(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.errors,": ",t._count.errorItems]}),(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.practiceCount,": ",t._count.practiceRecords]}),(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.aiUsageToday,": ",t.aiUsageToday]})]}),(0,s.jsx)(P,{children:(0,_.r)(t.createdAt,"yyyy-MM-dd",e)}),(0,s.jsx)(P,{children:(0,s.jsx)(E.f,{variant:t.isActive?"default":"destructive",children:t.isActive?n.admin.active:n.admin.disabled})}),(0,s.jsxs)(P,{className:"text-right space-x-2",children:[(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>A(t),disabled:t.id===i?.user?.id,title:t.isActive?n.admin.disable:n.admin.enable,children:t.isActive?(0,s.jsx)(q,{className:"h-4 w-4 text-orange-500"}):(0,s.jsx)(H.f,{className:"h-4 w-4 text-green-500"})}),(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>F(t),disabled:t.id===i?.user?.id,title:n.admin.delete,children:(0,s.jsx)(O.f,{className:"h-4 w-4 text-destructive"})})]})]},t.id))})]})})]})}var K=e.i(778917);let X=(0,x.f)("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),G=(0,x.f)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),Z=(0,x.f)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Q(){return window.WrongNotebookAndroid??null}let ee=()=>()=>void 0;function es(){let{t:e}=(0,t.b)(),a=(0,f.useSyncExternalStore)(ee,Q,()=>null);return a?a.isStandalone?.()?(0,s.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:e.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsxs)("span",{className:"break-all",children:[e.settings?.about?.androidServer||"Server",": ",a.getServerUrl()]}),(0,s.jsxs)(C.f,{variant:"outline",className:"gap-2",onClick:()=>a.changeServer(),children:[(0,s.jsx)(Z,{className:"h-4 w-4"}),e.settings?.about?.changeServer||"Change server"]})]}):null}let et="https://github.com/margrop/wrong-notebook";function ea(){let{t:e}=(0,t.b)(),[a,r]=(0,f.useState)("");(0,f.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>r(e.version)).catch(()=>{})},[]);let i=[{href:et,icon:X,label:e.settings?.about?.github||"GitHub Repository"},{href:`${et}/releases`,icon:G,label:e.settings?.about?.releaseNotes||"Release Notes"},{href:`${et}/issues`,icon:w,label:e.settings?.about?.feedback||"Feedback"}];return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-6 py-8 text-center bg-muted/30 rounded-lg border",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-2xl font-bold",children:e.app?.title||"Smart Error Notebook"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:e.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground border px-4 py-2 rounded-full bg-background",children:[(0,s.jsx)(v,{className:"h-4 w-4"}),(0,s.jsxs)("span",{children:[e.settings?.about?.version||"Version",": v",a||"unknown"]})]}),(0,s.jsx)(es,{}),(0,s.jsx)("div",{className:"flex flex-col sm:flex-row flex-wrap justify-center gap-4 w-full sm:w-auto px-4 sm:px-0",children:i.map(({href:e,icon:t,label:a})=>(0,s.jsx)(C.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,s.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[(0,s.jsx)(t,{className:"h-4 w-4"}),a,(0,s.jsx)(K.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},e))}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:e.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var er=e.i(37038),ei=e.i(967489);let en={name:"",email:"",educationStage:"",enrollmentYear:"",password:""};function el(){let{t:e}=(0,t.b)(),[a,r]=(0,f.useState)(en),[i,n]=(0,f.useState)(""),[l,c]=(0,f.useState)(!0),[o,d]=(0,f.useState)(!1),m=(0,f.useCallback)(async()=>{try{let e=await V.f.get("/api/user");r({name:e.name||"",email:e.email||"",educationStage:e.educationStage||"",enrollmentYear:e.enrollmentYear||"",password:""})}catch(e){W.f.error("[AccountSettings]","Failed to fetch profile",{error:e})}finally{c(!1)}},[]);(0,f.useEffect)(()=>{m()},[m]);let u=async()=>{if(a.password&&a.password!==i)return void Y.c.error(e.settings?.messages?.passwordMismatch||"Passwords do not match");d(!0);try{let s={name:a.name,email:a.email,educationStage:a.educationStage};a.enrollmentYear&&(s.enrollmentYear=parseInt(a.enrollmentYear.toString())),a.password&&(s.password=a.password),await V.f.patch("/api/user",s),Y.c.success(e.settings?.messages?.profileUpdated||"Profile updated"),r(e=>({...e,password:""})),n(""),window.location.reload()}catch(s){W.f.error("[AccountSettings]","Failed to update profile",{error:(0,B.d)(s)??(0,B.Z)(s)}),Y.c.error((0,B.d)(s)||e.settings?.messages?.updateFailed||"Update failed")}finally{d(!1)}};return l?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(b.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:e.auth?.name||"Name"}),(0,s.jsx)(D.f,{value:a.name||"",onChange:e=>r({...a,name:e.target.value})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:e.auth?.email||"Email"}),(0,s.jsx)(D.f,{value:a.email||"",onChange:e=>r({...a,email:e.target.value}),type:"email"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:e.auth?.educationStage||"Education Stage"}),(0,s.jsxs)(ei.d,{value:a.educationStage||"",onValueChange:e=>r({...a,educationStage:e}),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{placeholder:e.auth?.selectStage||"Select Stage"})}),(0,s.jsxs)(ei.r,{children:[(0,s.jsx)(ei.T,{value:"primary",children:e.auth?.primary||"Primary School"}),(0,s.jsx)(ei.T,{value:"junior_high",children:e.auth?.juniorHigh||"Junior High"}),(0,s.jsx)(ei.T,{value:"senior_high",children:e.auth?.seniorHigh||"Senior High"}),(0,s.jsx)(ei.T,{value:"university",children:e.auth?.university||"University"})]})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:e.auth?.enrollmentYear||"Enrollment Year"}),(0,s.jsx)(D.f,{type:"number",value:a.enrollmentYear||"",onChange:e=>r({...a,enrollmentYear:e.target.value}),placeholder:"YYYY"})]})]}),(0,s.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:e.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,s.jsx)(er.f,{value:a.password,onChange:e=>r({...a,password:e.target.value}),placeholder:"******",minLength:6})]}),a.password&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:e.auth?.confirmPassword||"Confirm Password"}),(0,s.jsx)(er.f,{value:i,onChange:e=>n(e.target.value),placeholder:"******",minLength:6})]})]}),(0,s.jsxs)(C.f,{onClick:u,disabled:o,className:"w-full",children:[o&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.settings?.account?.update||"Update Profile"]})]})}var ec=e.i(10038),eo=e.i(16715);let ed={info:{card:"border-blue-200 bg-blue-50",title:"text-blue-900 font-bold",desc:"text-blue-800 font-medium",button:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300"},danger:{card:"border-red-200 bg-red-50",title:"text-red-700 font-medium",desc:"text-red-600",button:""},critical:{card:"border-red-600/50 bg-red-100/50",title:"text-red-900 font-bold",desc:"text-red-800 font-medium",button:"bg-red-700 hover:bg-red-800"}};function em({title:e,description:t,tone:a,busy:r,icon:i,onClick:n}){let l=ed[a];return(0,s.jsxs)("div",{className:`p-4 border rounded-lg ${l.card}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:`text-sm flex items-center gap-2 ${l.title}`,children:e}),(0,s.jsx)(C.f,{variant:"info"===a?"outline":"destructive",size:"sm",onClick:n,disabled:r,className:l.button,children:r?(0,s.jsx)(b.f,{className:"h-4 w-4 animate-spin"}):i})]}),(0,s.jsx)("p",{className:`text-xs mt-2 ${l.desc}`,children:t})]})}function eu({isAdmin:e}){let{t:a}=(0,t.b)(),[r,i]=(0,f.useState)(null),n=async(e,s,t,a)=>{i(e);try{Y.c.success(await s()),a&&window.location.reload()}catch(s){W.f.error("[DangerZoneSettings]",`${e} failed`,{error:s}),Y.c.error(t)}finally{i(null)}},l=a.settings?.clearSuccess||"Success",c=a.settings?.clearError||"Failed",o=async()=>{await (0,Y.u)(a.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await n("migrateTags",async()=>{let e=await V.f.post("/api/admin/migrate-tags",{});return`${l}: ${e.count||0} tags migrated.`},a.settings?.clearError||"Failed to migrate tags",!1)},d=async()=>{await (0,Y.u)(a.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await n("clearPractice",async()=>(await V.f.delete("/api/stats/practice/clear"),l),c,!0)},m=async()=>{await (0,Y.u)(a.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await n("clearErrors",async()=>(await V.f.delete("/api/error-items/clear"),l),c,!0)},u=async()=>{if(!await (0,Y.u)(a.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let e=prompt(a.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==e){null!==e&&Y.c.error(a.common?.error||"Confirmation failed");return}await n("systemReset",async()=>(await V.f.post("/api/admin/system-reset",{}),a.settings?.clearSuccess||"Success - System Reset Complete"),a.settings?.clearError||"Failed to reset system",!0)};return(0,s.jsxs)(s.Fragment,{children:[e&&(0,s.jsx)(em,{tone:"info",title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eo.f,{className:"h-4 w-4"}),a.settings?.migrateTags||"Migrate Tags"]}),description:a.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===r,icon:(0,s.jsx)(eo.f,{className:"h-4 w-4"}),onClick:o}),(0,s.jsx)(em,{tone:"danger",title:a.settings?.clearData||"Clear Practice Data",description:a.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===r,icon:(0,s.jsx)(O.f,{className:"h-4 w-4"}),onClick:d}),(0,s.jsx)(em,{tone:"danger",title:a.settings?.clearErrorData||"Clear Error Data",description:a.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===r,icon:(0,s.jsx)(O.f,{className:"h-4 w-4"}),onClick:m}),e&&(0,s.jsx)(em,{tone:"critical",title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g,{className:"h-4 w-4"}),a.settings?.systemReset||"System Initialization"]}),description:a.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===r,icon:(0,s.jsx)(O.f,{className:"h-4 w-4"}),onClick:u})]})}var ex=e.i(595468),eh=e.i(440160);let ep=(0,x.f)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);async function ef(e,s){let t=await fetch(e);if(!t.ok)throw Error((await t.json().catch(()=>({}))).message||"Export failed");let a=await t.blob(),r=window.URL.createObjectURL(a),i=document.createElement("a");i.href=r;let n=t.headers.get("Content-Disposition")?.match(/filename="(.+)"/);i.download=n?n[1]:s,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(r)}function eg({isAdmin:e}){let{t:a}=(0,t.b)(),[r,i]=(0,f.useState)(!1),[n,l]=(0,f.useState)(!1),[c,o]=(0,f.useState)(null),d=async e=>{if(!e||await (0,Y.u)(a.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){i(!0);try{await ef(e?"/api/export?all=true":"/api/export",e?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),Y.c.success(a.settings?.exportSuccess||"Export successful")}catch(s){W.f.error("[DataBackupSettings]",e?"Export all failed":"Export failed",{error:s}),Y.c.error(a.settings?.exportFailed||"Export failed")}finally{i(!1)}}},m=async e=>{if(!c)return;let s=e?a.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":a.settings?.importConfirm||"Are you sure you want to import?";if(await (0,Y.u)(s)){l(!0);try{let s=JSON.parse(await c.text()),{stats:t}=await V.f.post(e?"/api/import?all=true":"/api/import",s);Y.c.success((a.settings?.importResultDesc||"Imported {subjects} notebooks, {tags} tags, {items} error items, {schedules} review schedules, {records} practice records, {papers} exam papers and {voices} cloud voice clips.").replace("{subjects}",String(t.subjectsCreated)).replace("{tags}",String(t.tagsCreated)).replace("{items}",String(t.errorItemsCreated)).replace("{schedules}",String(t.reviewSchedulesCreated)).replace("{records}",String(t.practiceRecordsCreated)).replace("{papers}",String(t.examPapersCreated??0)).replace("{voices}",String(t.ttsSpeechesImported??0)).replace("{duplicates}",String(t.duplicateErrorItems??0))),o(null),window.location.reload()}catch(s){W.f.error("[DataBackupSettings]",e?"Import all failed":"Import failed",{error:s}),Y.c.error(a.settings?.importFailed||"Import failed")}finally{l(!1)}}},u=(e,t)=>e?(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}):t;return(0,s.jsxs)("div",{className:"p-4 border border-blue-200 rounded-lg bg-blue-50",children:[(0,s.jsx)("h4",{className:"text-sm font-bold text-blue-900 mb-3",children:a.settings?.dataManagement||"Data Management"}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm text-blue-800 font-medium",children:a.settings?.exportData||"Export Data"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>d(!1),disabled:r,className:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300",children:[u(r,(0,s.jsx)(eh.f,{className:"mr-2 h-4 w-4"})),a.settings?.exportData||"Export"]}),e&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:r,className:"bg-orange-100 hover:bg-orange-200 text-orange-900 border-orange-300",children:[u(r,(0,s.jsx)(eh.f,{className:"mr-2 h-4 w-4"})),a.settings?.exportAllData||"Export All"]})]})]}),(0,s.jsx)("p",{className:"text-xs text-blue-700",children:a.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm text-blue-800 font-medium",children:a.settings?.importData||"Import Data"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"file",accept:".json",onChange:e=>o(e.target.files?.[0]??c),className:"hidden",id:"import-file-input",disabled:n}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:n,className:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300",children:[u(n,(0,s.jsx)(ep,{className:"mr-2 h-4 w-4"})),c?.name||a.settings?.selectFile||"Select File"]}),c&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>m(!1),disabled:n,className:"bg-green-100 hover:bg-green-200 text-green-900 border-green-300",children:[u(n,(0,s.jsx)(ex.f,{className:"mr-2 h-4 w-4"})),a.settings?.importData||"Import"]}),c&&e&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:n,className:"bg-orange-100 hover:bg-orange-200 text-orange-900 border-orange-300",children:[u(n,(0,s.jsx)(ex.f,{className:"mr-2 h-4 w-4"})),a.settings?.importAllData||"Import All"]})]})]}),(0,s.jsx)("p",{className:"text-xs text-blue-700",children:a.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}var ej=e.i(307364);function ev({field:e,label:a,description:r}){let{t:i}=(0,t.b)(),[n,l]=(0,f.useState)(!1),[c,o]=(0,f.useState)(!1),[d,m]=(0,f.useState)(!1),[u,x]=(0,f.useState)(null),h=`preference-${e}`;(0,f.useEffect)(()=>{V.f.get("/api/user").then(s=>l(!!s[e])).catch(()=>void 0).finally(()=>o(!0))},[e]);let p=async s=>{l(s),m(!0);try{await V.f.patch("/api/user",{[e]:s}),x(i.importFlow.preferenceSaved)}catch(t){l(!s),x(i.importFlow.preferenceSaveFailed),W.f.error("[Settings]","Failed to save user preference",{field:e,error:t instanceof Error?t.message:String(t)})}finally{m(!1)}};return(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,s.jsx)(R.f,{htmlFor:h,children:a}),(0,s.jsx)(M.f,{id:h,checked:n,onCheckedChange:p,disabled:!c||d})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:r}),u&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:u})]})}function ey(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"enableGeogebra",label:e.importFlow.enableGeogebra,description:e.importFlow.enableGeogebraDesc})}function eb(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"confirmBeforeImport",label:e.importFlow.confirmBeforeImport,description:e.importFlow.confirmBeforeImportDesc})}var ew=e.i(905110);function eN(){let{t:e}=(0,t.b)(),[a,r]=(0,f.useState)(String(ew.z)),[i,n]=(0,f.useState)(null),[l,c]=(0,f.useState)(!0),[o,d]=(0,f.useState)(!1),[m,u]=(0,f.useState)(null),x=Number(a),h=""!==a.trim()&&Number.isInteger(x)&&x>=ew.P&&x<=ew.o,p=(0,f.useCallback)(async()=>{c(!0),u(null);try{let e=(await V.f.get("/api/user")).masteryThreshold??ew.z;r(String(e)),n(e)}catch(s){u(e.mastery.thresholdLoadFailed),W.f.error("[Settings]","加载已掌握阈值失败",{error:s instanceof Error?s.message:String(s)})}finally{c(!1)}},[e.mastery.thresholdLoadFailed]);(0,f.useEffect)(()=>{p()},[p]);let g=async()=>{if(h&&null!==i){d(!0),u(null);try{let s=(await V.f.patch("/api/user",{masteryThreshold:x})).masteryThreshold??x;n(s),r(String(s)),u(e.importFlow.preferenceSaved)}catch(s){u(e.importFlow.preferenceSaveFailed),W.f.error("[Settings]","保存已掌握阈值失败",{error:s instanceof Error?s.message:String(s)})}finally{d(!1)}}};return(0,s.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,s.jsx)(R.f,{htmlFor:"mastery-threshold",children:e.mastery.thresholdLabel}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(D.f,{id:"mastery-threshold",type:"number",min:ew.P,max:ew.o,step:1,value:a,onChange:e=>{r(e.target.value),u(null)},disabled:l||o||null===i,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,s.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,s.jsxs)(C.f,{type:"button",size:"sm",variant:"outline",onClick:g,disabled:l||o||null===i||!h||x===i,children:[(l||o)&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.importFlow.saveThreshold]}),!l&&null===i&&(0,s.jsx)(C.f,{type:"button",size:"sm",variant:"outline",onClick:p,children:e.importFlow.retryLoad})]}),(0,s.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:e.mastery.thresholdDescription}),null!==i&&!h&&(0,s.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:e.mastery.thresholdInvalid}),m&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:m})]})}function ek(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"enableSvgAnimation",label:e.importFlow.enableSvgAnimation,description:e.importFlow.enableSvgAnimationDesc})}function eS({value:e,onChange:a,disabled:r}){let{t:i}=(0,t.b)();return(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsx)(R.f,{htmlFor:"app-time-zone",children:i.settings.general.timeZoneLabel}),(0,s.jsx)(D.f,{id:"app-time-zone",value:e,onChange:e=>a(e.target.value),disabled:r,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,s.jsx)("datalist",{id:"app-time-zones",children:["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Europe/London","America/New_York","America/Los_Angeles","UTC"].map(e=>(0,s.jsx)("option",{value:e},e))}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:i.settings.general.timeZoneDesc})]})}function eC({config:e,setConfig:a,isAdmin:i,disabled:n}){let{t:l,language:c,setLanguage:o}=(0,t.b)(),{timeZone:d}=(0,r.M)(),m=e=>a(s=>({...s,timeouts:{...s.timeouts,analyze:1e3*e}}));return(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:l.settings?.language||"Language"}),(0,s.jsxs)(ei.d,{value:c,onValueChange:e=>o(e),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{})}),(0,s.jsxs)(ei.r,{children:[(0,s.jsx)(ei.T,{value:"zh",children:"中文 (Chinese)"}),(0,s.jsx)(ei.T,{value:"en",children:"English"})]})]})]}),(0,s.jsx)(eS,{value:e.timeZone??d,onChange:e=>a(s=>({...s,timeZone:e})),disabled:!i||n}),i&&(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsx)(R.f,{children:l.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,s.jsx)(D.f,{type:"number",value:e.timeouts?.analyze?e.timeouts.analyze/1e3:"",onChange:e=>{let s=""===e.target.value?0:parseInt(e.target.value);m(isNaN(s)?0:s)},onBlur:()=>{let s=(e.timeouts?.analyze||0)/1e3,t=Math.min(600,Math.max(120,s));t!==s&&m(t)},min:120,max:600}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:l.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,s.jsx)(eb,{}),(0,s.jsx)(ek,{}),(0,s.jsx)(ey,{}),(0,s.jsx)(ej.f,{}),(0,s.jsx)(eN,{})]})}var eT=e.i(624687),eA=e.i(247167);let e_={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function eE(e,s={}){let t,a=e_[e],r=(t=eA.default.env.LOG_LEVEL?.toLowerCase())&&void 0!==e_[t]?e_[t]:e_.info;return(t,i)=>{let n,l;if(a<r)return;let c=new Date;"string"==typeof t?(n={},l=t):(n=t,l=i||"");{let t=JSON.stringify({level:e,time:c.toISOString(),...s,...n,msg:l});switch(e){case"error":case"fatal":console.error(t);break;case"warn":console.warn(t);break;default:console.log(t)}}}}(function e(s={}){return s.module,{trace:eE("trace",s),debug:eE("debug",s),info:eE("info",s),warn:eE("warn",s),error:eE("error",s),fatal:eE("fatal",s),child:t=>e({...s,...t}),box:(e,t,a="📋")=>{console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...s,title:e,..."string"==typeof t?{content:t}:t||{},msg:e}))},divider:(e="-")=>{}}})({env:"production"}).child({module:"ai:prompts"});let eM=`请参考《高思学校竞赛数学导引》(每讲分兴趣篇、拓展篇、超越篇,题目左侧标 1~5 颗星)的星级标准,结合题目所在年级评定难度:
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,1661,e=>{"use strict";var s=e.i(843476),t=e.i(111110),a=e.i(217255),r=e.i(215519),i=e.i(325164),n=e.i(522016),l=e.i(618566),o=e.i(217923),c=e.i(810980),d=e.i(551804),m=e.i(178583),u=e.i(292270),p=e.i(475254);let h=(0,p.f)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),x=(0,p.f)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);var g=e.i(271645);let f=(0,p.f)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),j=(0,p.f)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),v=(0,p.f)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var y=e.i(763639),b=e.i(531278);let w=(0,p.f)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),N=(0,p.f)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var k=e.i(284614),S=e.i(733060),C=e.i(519455),T=e.i(776639),A=e.i(677572),E=e.i(306831),_=e.i(487486),z=e.i(699375),D=e.i(793479),M=e.i(110204),F=e.i(975157);let R=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("div",{className:"relative w-full overflow-auto",children:(0,s.jsx)("table",{ref:a,className:(0,F.f)("w-full caption-bottom text-sm",e),...t})}));R.displayName="Table";let I=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("thead",{ref:a,className:(0,F.f)("[&_tr]:border-b",e),...t}));I.displayName="TableHeader";let L=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tbody",{ref:a,className:(0,F.f)("[&_tr:last-child]:border-0",e),...t}));L.displayName="TableBody",(g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tfoot",{ref:a,className:(0,F.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}))).displayName="TableFooter";let $=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tr",{ref:a,className:(0,F.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));$.displayName="TableRow";let U=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("th",{ref:a,className:(0,F.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));U.displayName="TableHead";let P=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("td",{ref:a,className:(0,F.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));P.displayName="TableCell",(g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("caption",{ref:a,className:(0,F.f)("mt-4 text-sm text-muted-foreground",e),...t}))).displayName="TableCaption";var q=e.i(727612);let O=(0,p.f)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var K=e.i(269638),B=e.i(41931),H=e.i(294114),V=e.i(201276),Y=e.i(303163);function W(){let{timeZone:e}=(0,r.M)(),{data:i}=(0,a.useSession)(),{t:n}=(0,t.b)(),[l,o]=(0,g.useState)([]),[c,d]=(0,g.useState)(!0),[m,u]=(0,g.useState)(!1),[p,h]=(0,g.useState)(!1),[x,f]=(0,g.useState)("0"),[j,v]=(0,g.useState)(!1),y=(0,g.useCallback)(async()=>{d(!0);try{let e=await B.f.get("/api/admin/users");o(e)}catch(e){V.f.error("[UserManagement]","Failed to fetch users",{error:e})}finally{d(!1)}},[]),w=(0,g.useCallback)(async()=>{try{let e=await B.f.get("/api/settings");u(!0===e.allowRegistration),f(String(e.aiDailyLimit??0))}catch(e){V.f.error("[UserManagement]","Failed to fetch config",{error:e})}},[]);(0,g.useEffect)(()=>{y(),w()},[y,w]);let N=async e=>{h(!0);try{await B.f.post("/api/settings",{allowRegistration:e}),u(e)}catch(e){V.f.error("[UserManagement]","Failed to update registration setting",{error:e}),H.c.error(n.common.error)}finally{h(!1)}},k=Number(x),S=""!==x.trim()&&Number.isInteger(k)&&k>=0,T=async()=>{if(S){v(!0);try{await B.f.post("/api/settings",{aiDailyLimit:k}),H.c.success(n.admin.aiDailyLimitSaved)}catch(e){V.f.error("[UserManagement]","Failed to update AI daily limit",{error:e}),H.c.error(n.common.error)}finally{v(!1)}}},A=async e=>{let s=e.isActive?n.admin.confirmDisable:n.admin.confirmEnable;if(await (0,H.u)(s))try{await B.f.patch(`/api/admin/users/${e.id}`,{isActive:!e.isActive}),y()}catch(e){V.f.error("[UserManagement]","Failed to update user status",{error:e}),H.c.error(n.common.error)}},F=async e=>{if(await (0,H.u)(n.admin.confirmDelete,{destructive:!0}))try{await B.f.delete(`/api/admin/users/${e.id}`),y()}catch(s){V.f.error("[UserManagement]","Failed to delete user",{error:s});let e=(0,Y.d)(s)||n.common.error;H.c.error(e)}};return c?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(b.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(M.f,{className:"text-base",children:n.admin?.allowRegistration||"Allow New Registrations"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:n.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,s.jsx)(b.f,{className:"h-4 w-4 animate-spin"}),(0,s.jsx)(z.f,{checked:m,onCheckedChange:N,disabled:p})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 p-4 border rounded-lg bg-muted/30 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(M.f,{htmlFor:"ai-daily-limit",className:"text-base",children:n.admin.aiDailyLimit}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:n.admin.aiDailyLimitDesc})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(D.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:x,onChange:e=>f(e.target.value),"aria-invalid":!S,className:"w-24"}),(0,s.jsxs)(C.f,{size:"sm",onClick:T,disabled:j||!S,children:[j&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.common.save]})]})]}),(0,s.jsx)("div",{className:"sm:hidden space-y-3",children:l.map(t=>(0,s.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium",children:t.name||"N/A"}),(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:t.email})]}),(0,s.jsx)(_.f,{variant:"admin"===t.role?"default":"secondary",children:"admin"===t.role?n.admin.admin:n.admin.user})]}),(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsxs)("div",{className:"text-muted-foreground",children:[n.admin.errors,": ",t._count.errorItems," | ",n.admin.practiceCount,": ",t._count.practiceRecords," | ",n.admin.aiUsageToday,": ",t.aiUsageToday]}),(0,s.jsx)(_.f,{variant:t.isActive?"default":"destructive",className:"text-xs",children:t.isActive?n.admin.active:n.admin.disabled})]}),(0,s.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,E.r)(t.createdAt,"yyyy-MM-dd",e)}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>A(t),disabled:t.id===i?.user?.id,children:t.isActive?(0,s.jsx)(O,{className:"h-4 w-4 text-orange-500"}):(0,s.jsx)(K.f,{className:"h-4 w-4 text-green-500"})}),(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>F(t),disabled:t.id===i?.user?.id,children:(0,s.jsx)(q.f,{className:"h-4 w-4 text-destructive"})})]})]})]},t.id))}),(0,s.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,s.jsxs)(R,{children:[(0,s.jsx)(I,{children:(0,s.jsxs)($,{children:[(0,s.jsx)(U,{children:n.admin.nameEmail}),(0,s.jsx)(U,{children:n.admin.role}),(0,s.jsx)(U,{children:n.admin.stats}),(0,s.jsx)(U,{children:n.admin.createdAt}),(0,s.jsx)(U,{children:n.admin.status}),(0,s.jsx)(U,{className:"text-right",children:n.admin.actions})]})}),(0,s.jsx)(L,{children:l.map(t=>(0,s.jsxs)($,{children:[(0,s.jsxs)(P,{children:[(0,s.jsx)("div",{className:"font-medium",children:t.name||"N/A"}),(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:t.email})]}),(0,s.jsx)(P,{children:(0,s.jsx)(_.f,{variant:"admin"===t.role?"default":"secondary",children:"admin"===t.role?n.admin.admin:n.admin.user})}),(0,s.jsxs)(P,{children:[(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.errors,": ",t._count.errorItems]}),(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.practiceCount,": ",t._count.practiceRecords]}),(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.aiUsageToday,": ",t.aiUsageToday]})]}),(0,s.jsx)(P,{children:(0,E.r)(t.createdAt,"yyyy-MM-dd",e)}),(0,s.jsx)(P,{children:(0,s.jsx)(_.f,{variant:t.isActive?"default":"destructive",children:t.isActive?n.admin.active:n.admin.disabled})}),(0,s.jsxs)(P,{className:"text-right space-x-2",children:[(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>A(t),disabled:t.id===i?.user?.id,title:t.isActive?n.admin.disable:n.admin.enable,children:t.isActive?(0,s.jsx)(O,{className:"h-4 w-4 text-orange-500"}):(0,s.jsx)(K.f,{className:"h-4 w-4 text-green-500"})}),(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>F(t),disabled:t.id===i?.user?.id,title:n.admin.delete,children:(0,s.jsx)(q.f,{className:"h-4 w-4 text-destructive"})})]})]},t.id))})]})})]})}var J=e.i(778917);let X=(0,p.f)("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),G=(0,p.f)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),Z=(0,p.f)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Q(){return window.WrongNotebookAndroid??null}let ee=()=>()=>void 0;function es(){let{t:e}=(0,t.b)(),a=(0,g.useSyncExternalStore)(ee,Q,()=>null);return a?a.isStandalone?.()?(0,s.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:e.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsxs)("span",{className:"break-all",children:[e.settings?.about?.androidServer||"Server",": ",a.getServerUrl()]}),(0,s.jsxs)(C.f,{variant:"outline",className:"gap-2",onClick:()=>a.changeServer(),children:[(0,s.jsx)(Z,{className:"h-4 w-4"}),e.settings?.about?.changeServer||"Change server"]})]}):null}let et="https://github.com/margrop/wrong-notebook";function ea(){let{t:e}=(0,t.b)(),[a,r]=(0,g.useState)("");(0,g.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>r(e.version)).catch(()=>{})},[]);let i=[{href:et,icon:X,label:e.settings?.about?.github||"GitHub Repository"},{href:`${et}/releases`,icon:G,label:e.settings?.about?.releaseNotes||"Release Notes"},{href:`${et}/issues`,icon:w,label:e.settings?.about?.feedback||"Feedback"}];return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-6 py-8 text-center bg-muted/30 rounded-lg border",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-2xl font-bold",children:e.app?.title||"Smart Error Notebook"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:e.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground border px-4 py-2 rounded-full bg-background",children:[(0,s.jsx)(v,{className:"h-4 w-4"}),(0,s.jsxs)("span",{children:[e.settings?.about?.version||"Version",": v",a||"unknown"]})]}),(0,s.jsx)(es,{}),(0,s.jsx)("div",{className:"flex flex-col sm:flex-row flex-wrap justify-center gap-4 w-full sm:w-auto px-4 sm:px-0",children:i.map(({href:e,icon:t,label:a})=>(0,s.jsx)(C.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,s.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[(0,s.jsx)(t,{className:"h-4 w-4"}),a,(0,s.jsx)(J.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},e))}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:e.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var er=e.i(37038),ei=e.i(967489);let en={name:"",email:"",educationStage:"",enrollmentYear:"",password:""};function el(){let{t:e}=(0,t.b)(),[a,r]=(0,g.useState)(en),[i,n]=(0,g.useState)(""),[l,o]=(0,g.useState)(!0),[c,d]=(0,g.useState)(!1),m=(0,g.useCallback)(async()=>{try{let e=await B.f.get("/api/user");r({name:e.name||"",email:e.email||"",educationStage:e.educationStage||"",enrollmentYear:e.enrollmentYear||"",password:""})}catch(e){V.f.error("[AccountSettings]","Failed to fetch profile",{error:e})}finally{o(!1)}},[]);(0,g.useEffect)(()=>{m()},[m]);let u=async()=>{if(a.password&&a.password!==i)return void H.c.error(e.settings?.messages?.passwordMismatch||"Passwords do not match");d(!0);try{let s={name:a.name,email:a.email,educationStage:a.educationStage};a.enrollmentYear&&(s.enrollmentYear=parseInt(a.enrollmentYear.toString())),a.password&&(s.password=a.password),await B.f.patch("/api/user",s),H.c.success(e.settings?.messages?.profileUpdated||"Profile updated"),r(e=>({...e,password:""})),n(""),window.location.reload()}catch(s){V.f.error("[AccountSettings]","Failed to update profile",{error:(0,Y.d)(s)??(0,Y.Z)(s)}),H.c.error((0,Y.d)(s)||e.settings?.messages?.updateFailed||"Update failed")}finally{d(!1)}};return l?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(b.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.name||"Name"}),(0,s.jsx)(D.f,{value:a.name||"",onChange:e=>r({...a,name:e.target.value})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.email||"Email"}),(0,s.jsx)(D.f,{value:a.email||"",onChange:e=>r({...a,email:e.target.value}),type:"email"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.educationStage||"Education Stage"}),(0,s.jsxs)(ei.d,{value:a.educationStage||"",onValueChange:e=>r({...a,educationStage:e}),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{placeholder:e.auth?.selectStage||"Select Stage"})}),(0,s.jsxs)(ei.r,{children:[(0,s.jsx)(ei.T,{value:"primary",children:e.auth?.primary||"Primary School"}),(0,s.jsx)(ei.T,{value:"junior_high",children:e.auth?.juniorHigh||"Junior High"}),(0,s.jsx)(ei.T,{value:"senior_high",children:e.auth?.seniorHigh||"Senior High"}),(0,s.jsx)(ei.T,{value:"university",children:e.auth?.university||"University"})]})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.enrollmentYear||"Enrollment Year"}),(0,s.jsx)(D.f,{type:"number",value:a.enrollmentYear||"",onChange:e=>r({...a,enrollmentYear:e.target.value}),placeholder:"YYYY"})]})]}),(0,s.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,s.jsx)(er.f,{value:a.password,onChange:e=>r({...a,password:e.target.value}),placeholder:"******",minLength:6})]}),a.password&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.confirmPassword||"Confirm Password"}),(0,s.jsx)(er.f,{value:i,onChange:e=>n(e.target.value),placeholder:"******",minLength:6})]})]}),(0,s.jsxs)(C.f,{onClick:u,disabled:c,className:"w-full",children:[c&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.settings?.account?.update||"Update Profile"]})]})}var eo=e.i(10038),ec=e.i(16715);let ed={info:{card:"border-blue-200 bg-blue-50",title:"text-blue-900 font-bold",desc:"text-blue-800 font-medium",button:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300"},danger:{card:"border-red-200 bg-red-50",title:"text-red-700 font-medium",desc:"text-red-600",button:""},critical:{card:"border-red-600/50 bg-red-100/50",title:"text-red-900 font-bold",desc:"text-red-800 font-medium",button:"bg-red-700 hover:bg-red-800"}};function em({title:e,description:t,tone:a,busy:r,icon:i,onClick:n}){let l=ed[a];return(0,s.jsxs)("div",{className:`p-4 border rounded-lg ${l.card}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:`text-sm flex items-center gap-2 ${l.title}`,children:e}),(0,s.jsx)(C.f,{variant:"info"===a?"outline":"destructive",size:"sm",onClick:n,disabled:r,className:l.button,children:r?(0,s.jsx)(b.f,{className:"h-4 w-4 animate-spin"}):i})]}),(0,s.jsx)("p",{className:`text-xs mt-2 ${l.desc}`,children:t})]})}function eu({isAdmin:e}){let{t:a}=(0,t.b)(),[r,i]=(0,g.useState)(null),n=async(e,s,t,a)=>{i(e);try{H.c.success(await s()),a&&window.location.reload()}catch(s){V.f.error("[DangerZoneSettings]",`${e} failed`,{error:s}),H.c.error(t)}finally{i(null)}},l=a.settings?.clearSuccess||"Success",o=a.settings?.clearError||"Failed",c=async()=>{await (0,H.u)(a.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await n("migrateTags",async()=>{let e=await B.f.post("/api/admin/migrate-tags",{});return`${l}: ${e.count||0} tags migrated.`},a.settings?.clearError||"Failed to migrate tags",!1)},d=async()=>{await (0,H.u)(a.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await n("clearPractice",async()=>(await B.f.delete("/api/stats/practice/clear"),l),o,!0)},m=async()=>{await (0,H.u)(a.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await n("clearErrors",async()=>(await B.f.delete("/api/error-items/clear"),l),o,!0)},u=async()=>{if(!await (0,H.u)(a.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let e=prompt(a.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==e){null!==e&&H.c.error(a.common?.error||"Confirmation failed");return}await n("systemReset",async()=>(await B.f.post("/api/admin/system-reset",{}),a.settings?.clearSuccess||"Success - System Reset Complete"),a.settings?.clearError||"Failed to reset system",!0)};return(0,s.jsxs)(s.Fragment,{children:[e&&(0,s.jsx)(em,{tone:"info",title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ec.f,{className:"h-4 w-4"}),a.settings?.migrateTags||"Migrate Tags"]}),description:a.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===r,icon:(0,s.jsx)(ec.f,{className:"h-4 w-4"}),onClick:c}),(0,s.jsx)(em,{tone:"danger",title:a.settings?.clearData||"Clear Practice Data",description:a.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===r,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:d}),(0,s.jsx)(em,{tone:"danger",title:a.settings?.clearErrorData||"Clear Error Data",description:a.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===r,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:m}),e&&(0,s.jsx)(em,{tone:"critical",title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f,{className:"h-4 w-4"}),a.settings?.systemReset||"System Initialization"]}),description:a.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===r,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:u})]})}var ep=e.i(595468),eh=e.i(440160);let ex=(0,p.f)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);async function eg(e,s){let t=await fetch(e);if(!t.ok)throw Error((await t.json().catch(()=>({}))).message||"Export failed");let a=await t.blob(),r=window.URL.createObjectURL(a),i=document.createElement("a");i.href=r;let n=t.headers.get("Content-Disposition")?.match(/filename="(.+)"/);i.download=n?n[1]:s,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(r)}function ef({isAdmin:e}){let{t:a}=(0,t.b)(),[r,i]=(0,g.useState)(!1),[n,l]=(0,g.useState)(!1),[o,c]=(0,g.useState)(null),d=async e=>{if(!e||await (0,H.u)(a.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){i(!0);try{await eg(e?"/api/export?all=true":"/api/export",e?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),H.c.success(a.settings?.exportSuccess||"Export successful")}catch(s){V.f.error("[DataBackupSettings]",e?"Export all failed":"Export failed",{error:s}),H.c.error(a.settings?.exportFailed||"Export failed")}finally{i(!1)}}},m=async e=>{if(!o)return;let s=e?a.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":a.settings?.importConfirm||"Are you sure you want to import?";if(await (0,H.u)(s)){l(!0);try{let s=JSON.parse(await o.text()),{stats:t}=await B.f.post(e?"/api/import?all=true":"/api/import",s);H.c.success((a.settings?.importResultDesc||"Imported {subjects} notebooks, {tags} tags, {items} error items, {schedules} review schedules, {records} practice records, {papers} exam papers and {voices} cloud voice clips.").replace("{subjects}",String(t.subjectsCreated)).replace("{tags}",String(t.tagsCreated)).replace("{items}",String(t.errorItemsCreated)).replace("{schedules}",String(t.reviewSchedulesCreated)).replace("{records}",String(t.practiceRecordsCreated)).replace("{papers}",String(t.examPapersCreated??0)).replace("{voices}",String(t.ttsSpeechesImported??0)).replace("{duplicates}",String(t.duplicateErrorItems??0))),c(null),window.location.reload()}catch(s){V.f.error("[DataBackupSettings]",e?"Import all failed":"Import failed",{error:s}),H.c.error(a.settings?.importFailed||"Import failed")}finally{l(!1)}}},u=(e,t)=>e?(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}):t;return(0,s.jsxs)("div",{className:"p-4 border border-blue-200 rounded-lg bg-blue-50",children:[(0,s.jsx)("h4",{className:"text-sm font-bold text-blue-900 mb-3",children:a.settings?.dataManagement||"Data Management"}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm text-blue-800 font-medium",children:a.settings?.exportData||"Export Data"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>d(!1),disabled:r,className:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300",children:[u(r,(0,s.jsx)(eh.f,{className:"mr-2 h-4 w-4"})),a.settings?.exportData||"Export"]}),e&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:r,className:"bg-orange-100 hover:bg-orange-200 text-orange-900 border-orange-300",children:[u(r,(0,s.jsx)(eh.f,{className:"mr-2 h-4 w-4"})),a.settings?.exportAllData||"Export All"]})]})]}),(0,s.jsx)("p",{className:"text-xs text-blue-700",children:a.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm text-blue-800 font-medium",children:a.settings?.importData||"Import Data"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"file",accept:".json",onChange:e=>c(e.target.files?.[0]??o),className:"hidden",id:"import-file-input",disabled:n}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:n,className:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300",children:[u(n,(0,s.jsx)(ex,{className:"mr-2 h-4 w-4"})),o?.name||a.settings?.selectFile||"Select File"]}),o&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>m(!1),disabled:n,className:"bg-green-100 hover:bg-green-200 text-green-900 border-green-300",children:[u(n,(0,s.jsx)(ep.f,{className:"mr-2 h-4 w-4"})),a.settings?.importData||"Import"]}),o&&e&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:n,className:"bg-orange-100 hover:bg-orange-200 text-orange-900 border-orange-300",children:[u(n,(0,s.jsx)(ep.f,{className:"mr-2 h-4 w-4"})),a.settings?.importAllData||"Import All"]})]})]}),(0,s.jsx)("p",{className:"text-xs text-blue-700",children:a.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}var ej=e.i(307364);function ev({field:e,label:a,description:r}){let{t:i}=(0,t.b)(),[n,l]=(0,g.useState)(!1),[o,c]=(0,g.useState)(!1),[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)(null),h=`preference-${e}`;(0,g.useEffect)(()=>{B.f.get("/api/user").then(s=>l(!!s[e])).catch(()=>void 0).finally(()=>c(!0))},[e]);let x=async s=>{l(s),m(!0);try{await B.f.patch("/api/user",{[e]:s}),p(i.importFlow.preferenceSaved)}catch(t){l(!s),p(i.importFlow.preferenceSaveFailed),V.f.error("[Settings]","Failed to save user preference",{field:e,error:t instanceof Error?t.message:String(t)})}finally{m(!1)}};return(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,s.jsx)(M.f,{htmlFor:h,children:a}),(0,s.jsx)(z.f,{id:h,checked:n,onCheckedChange:x,disabled:!o||d})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:r}),u&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:u})]})}function ey(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"enableGeogebra",label:e.importFlow.enableGeogebra,description:e.importFlow.enableGeogebraDesc})}function eb(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"confirmBeforeImport",label:e.importFlow.confirmBeforeImport,description:e.importFlow.confirmBeforeImportDesc})}var ew=e.i(905110);function eN(){let{t:e}=(0,t.b)(),[a,r]=(0,g.useState)(String(ew.z)),[i,n]=(0,g.useState)(null),[l,o]=(0,g.useState)(!0),[c,d]=(0,g.useState)(!1),[m,u]=(0,g.useState)(null),p=Number(a),h=""!==a.trim()&&Number.isInteger(p)&&p>=ew.P&&p<=ew.o,x=(0,g.useCallback)(async()=>{o(!0),u(null);try{let e=(await B.f.get("/api/user")).masteryThreshold??ew.z;r(String(e)),n(e)}catch(s){u(e.mastery.thresholdLoadFailed),V.f.error("[Settings]","加载已掌握阈值失败",{error:s instanceof Error?s.message:String(s)})}finally{o(!1)}},[e.mastery.thresholdLoadFailed]);(0,g.useEffect)(()=>{x()},[x]);let f=async()=>{if(h&&null!==i){d(!0),u(null);try{let s=(await B.f.patch("/api/user",{masteryThreshold:p})).masteryThreshold??p;n(s),r(String(s)),u(e.importFlow.preferenceSaved)}catch(s){u(e.importFlow.preferenceSaveFailed),V.f.error("[Settings]","保存已掌握阈值失败",{error:s instanceof Error?s.message:String(s)})}finally{d(!1)}}};return(0,s.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,s.jsx)(M.f,{htmlFor:"mastery-threshold",children:e.mastery.thresholdLabel}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(D.f,{id:"mastery-threshold",type:"number",min:ew.P,max:ew.o,step:1,value:a,onChange:e=>{r(e.target.value),u(null)},disabled:l||c||null===i,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,s.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,s.jsxs)(C.f,{type:"button",size:"sm",variant:"outline",onClick:f,disabled:l||c||null===i||!h||p===i,children:[(l||c)&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.importFlow.saveThreshold]}),!l&&null===i&&(0,s.jsx)(C.f,{type:"button",size:"sm",variant:"outline",onClick:x,children:e.importFlow.retryLoad})]}),(0,s.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:e.mastery.thresholdDescription}),null!==i&&!h&&(0,s.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:e.mastery.thresholdInvalid}),m&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:m})]})}function ek(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"enableSvgAnimation",label:e.importFlow.enableSvgAnimation,description:e.importFlow.enableSvgAnimationDesc})}function eS({value:e,onChange:a,disabled:r}){let{t:i}=(0,t.b)();return(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsx)(M.f,{htmlFor:"app-time-zone",children:i.settings.general.timeZoneLabel}),(0,s.jsx)(D.f,{id:"app-time-zone",value:e,onChange:e=>a(e.target.value),disabled:r,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,s.jsx)("datalist",{id:"app-time-zones",children:["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Europe/London","America/New_York","America/Los_Angeles","UTC"].map(e=>(0,s.jsx)("option",{value:e},e))}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:i.settings.general.timeZoneDesc})]})}function eC({config:e,setConfig:a,isAdmin:i,disabled:n}){let{t:l,language:o,setLanguage:c}=(0,t.b)(),{timeZone:d}=(0,r.M)(),m=e=>a(s=>({...s,timeouts:{...s.timeouts,analyze:1e3*e}}));return(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:l.settings?.language||"Language"}),(0,s.jsxs)(ei.d,{value:o,onValueChange:e=>c(e),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{})}),(0,s.jsxs)(ei.r,{children:[(0,s.jsx)(ei.T,{value:"zh",children:"中文 (Chinese)"}),(0,s.jsx)(ei.T,{value:"en",children:"English"})]})]})]}),(0,s.jsx)(eS,{value:e.timeZone??d,onChange:e=>a(s=>({...s,timeZone:e})),disabled:!i||n}),i&&(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsx)(M.f,{children:l.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,s.jsx)(D.f,{type:"number",value:e.timeouts?.analyze?e.timeouts.analyze/1e3:"",onChange:e=>{let s=""===e.target.value?0:parseInt(e.target.value);m(isNaN(s)?0:s)},onBlur:()=>{let s=(e.timeouts?.analyze||0)/1e3,t=Math.min(600,Math.max(120,s));t!==s&&m(t)},min:120,max:600}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:l.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,s.jsx)(eb,{}),(0,s.jsx)(ek,{}),(0,s.jsx)(ey,{}),(0,s.jsx)(ej.f,{}),(0,s.jsx)(eN,{})]})}var eT=e.i(624687),eA=e.i(247167);let eE={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function e_(e,s={}){let t,a=eE[e],r=(t=eA.default.env.LOG_LEVEL?.toLowerCase())&&void 0!==eE[t]?eE[t]:eE.info;return(t,i)=>{let n,l;if(a<r)return;let o=new Date;"string"==typeof t?(n={},l=t):(n=t,l=i||"");{let t=JSON.stringify({level:e,time:o.toISOString(),...s,...n,msg:l});switch(e){case"error":case"fatal":console.error(t);break;case"warn":console.warn(t);break;default:console.log(t)}}}}(function e(s={}){return s.module,{trace:e_("trace",s),debug:e_("debug",s),info:e_("info",s),warn:e_("warn",s),error:e_("error",s),fatal:e_("fatal",s),child:t=>e({...s,...t}),box:(e,t,a="📋")=>{console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...s,title:e,..."string"==typeof t?{content:t}:t||{},msg:e}))},divider:(e="-")=>{}}})({env:"production"}).child({module:"ai:prompts"});let ez=`请参考《高思学校竞赛数学导引》(每讲分兴趣篇、拓展篇、超越篇,题目左侧标 1~5 颗星)的星级标准,结合题目所在年级评定难度:
2
2
  - 1 星:课本基础题,直接套用概念、公式或简单计算即可(相当于兴趣篇前几题)。
3
3
  - 2 星:校内拔高题,需要两三步推理或简单综合(相当于兴趣篇后几题)。
4
4
  - 3 星:常规奥数题,小升初、杯赛常见难度,需要掌握该专题的典型方法(相当于拓展篇)。
@@ -8,7 +8,7 @@
8
8
  - 白色背景、黑色线条(stroke="#000",线宽 1.5~2),需要区分的区域可用浅灰填充;不要使用彩色装饰。
9
9
  - 按原图比例和相对位置绘制,保留所有标注:顶点字母、数字、长度、角度、单位、箭头和虚线等,文字用 <text>(font-size 14~18)。
10
10
  - 只使用基本图形元素:line、polyline、polygon、rect、circle、ellipse、path、text、g、defs、marker。
11
- - 严禁使用 <image>、<script>、<foreignObject>、外部链接、外部字体或事件属性。`,eR=String.raw`- 行内公式用 $...$,独立公式用 $$...$$;不要用 \(...\) 或 \[...\],每个 $ 必须成对出现。
11
+ - 严禁使用 <image>、<script>、<foreignObject>、外部链接、外部字体或事件属性。`,eM=String.raw`- 行内公式用 $...$,独立公式用 $$...$$;不要用 \(...\) 或 \[...\],每个 $ 必须成对出现。
12
12
  - 所有 LaTeX 命令(如 \frac、\sqrt、\times、\angle)都必须写在 $...$ 内,公式外不能出现反斜杠命令。
13
13
  - 只使用 KaTeX 支持的命令和环境:方程组用 \begin{cases}...\end{cases},多行推导用 \begin{aligned}...\end{aligned}(放在 $$...$$ 中),不要用 align、eqnarray、\newcommand、\usepackage、\label、\tag 等。
14
14
  - 大括号 {} 必须成对,\left 与 \right 必须成对,\begin{...} 与 \end{...} 必须对应。
@@ -55,7 +55,7 @@ ${eD}
55
55
 
56
56
  <difficulty_stars>
57
57
  只填写 1 到 5 之间的一个整数,表示题目难度星级。
58
- ${eM}
58
+ ${ez}
59
59
  </difficulty_stars>
60
60
 
61
61
  <mistake_analysis>
@@ -130,10 +130,10 @@ ${eM}
130
130
  3. **内容完整**:如果包含子问题,请在 question_text 中完整列出。
131
131
  4. **禁止图片**:严禁包含任何图片链接或 markdown 图片语法。
132
132
  5. **LaTeX 规范**:
133
- ${eR}
133
+ ${eM}
134
134
 
135
135
  {{grade_instruction}}
136
- {{provider_hints}}`,ez=`你是一位资深的K12教育题目生成专家,具备跨学科的题目创作能力。你的核心任务是**根据以下原题和知识点,举一反三生成高质量教学题目**,帮助学生巩固知识并拓展解题思路。
136
+ {{provider_hints}}`,eR=`你是一位资深的K12教育题目生成专家,具备跨学科的题目创作能力。你的核心任务是**根据以下原题和知识点,举一反三生成高质量教学题目**,帮助学生巩固知识并拓展解题思路。
137
137
  ### 角色定义
138
138
  1. **学科全能专家**
139
139
  - 精通K12阶段所有学科(数学/语文/英语/物理/化学/生物/历史/地理/政治)
@@ -185,7 +185,7 @@ ${eR}
185
185
  ###关键格式与内容约束 (CRITICAL RULES) !!!
186
186
  1. **纯文本**:内容作为纯文本处理,**不要转义反斜杠**。
187
187
  2. **LaTeX 规范**:
188
- ${eR}
188
+ ${eM}
189
189
 
190
190
  {{grade_instruction}}
191
- {{provider_hints}}`;var eI=e.i(367240);function eL({name:e,description:t}){return(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,s.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-primary shrink-0 w-fit",children:`{{${e}}}`}),(0,s.jsx)("span",{className:"text-muted-foreground",children:t})]})}function e$(){let{t:e}=(0,t.b)();return(0,s.jsxs)("div",{className:"bg-amber-50 border border-amber-200 rounded-md p-3 flex items-start gap-3 text-amber-900 text-sm mb-4",children:[(0,s.jsx)(g,{className:"h-5 w-5 shrink-0 text-amber-600"}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"font-medium",children:e.settings?.prompts?.caution||"Modify with Caution"}),(0,s.jsx)("p",{className:"text-amber-800/90 text-xs",children:e.settings?.prompts?.warning||"Variables in {{brackets}} are used to inject dynamic content. Please preserve these variables, otherwise the AI providing may fail to get question context or return invalid formats."})]})]})}function eU({config:e,onUpdate:a}){let{t:r}=(0,t.b)(),i=e.prompts?.analyze||eF,n=e.prompts?.similar||ez,l=async e=>{await (0,Y.u)(r.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&a(e,"analyze"===e?eF:ez)},c=(e,s)=>{a(e,s)};return(0,s.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,s.jsxs)(A.i,{defaultValue:"analyze",className:"w-full",children:[(0,s.jsxs)(A.U,{className:"grid w-full grid-cols-2",children:[(0,s.jsx)(A.k,{value:"analyze",children:r.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,s.jsx)(A.k,{value:"similar",children:r.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,s.jsx)(A.S,{value:"analyze",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(R.f,{className:"text-base font-semibold",children:r.settings?.prompts?.customAnalysis||"Custom Analysis Template"}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>l("analyze"),children:[(0,s.jsx)(eI.f,{className:"w-4 h-4 mr-2"}),r.settings?.prompts?.reset||"Reset Default"]})]}),(0,s.jsx)(e$,{}),(0,s.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,s.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),r.settings?.prompts?.variables||"Available Variables"]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(eL,{name:"language_instruction",description:r.settings?.prompts?.vars?.languageInstruction||"Injects instructions based on target language (e.g., keep English questions in English but analysis in Chinese)."}),(0,s.jsx)(eL,{name:"knowledge_points_list",description:r.settings?.prompts?.vars?.knowledgePointsList||"Injects the standard list of knowledge point tags for the specific subject."}),(0,s.jsx)(eL,{name:"provider_hints",description:r.settings?.prompts?.vars?.providerHints||"System-injected hints (e.g., enforcing JSON format)."})]})]}),(0,s.jsx)(eT.f,{value:i,onChange:e=>c("analyze",e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:eF})]})}),(0,s.jsx)(A.S,{value:"similar",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(R.f,{className:"text-base font-semibold",children:r.settings?.prompts?.customSimilar||"Custom Similar Question Template"}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>l("similar"),children:[(0,s.jsx)(eI.f,{className:"w-4 h-4 mr-2"}),r.settings?.prompts?.reset||"Reset Default"]})]}),(0,s.jsx)(e$,{}),(0,s.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,s.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),r.settings?.prompts?.variables||"Available Variables"]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(eL,{name:"difficulty_level",description:r.settings?.prompts?.vars?.difficultyLevel||"Target difficulty level."}),(0,s.jsx)(eL,{name:"difficulty_instruction",description:r.settings?.prompts?.vars?.difficultyInstruction||"Specific writing instructions for the target difficulty."}),(0,s.jsx)(eL,{name:"original_question",description:r.settings?.prompts?.vars?.originalQuestion||"The full text of the original question."}),(0,s.jsx)(eL,{name:"knowledge_points",description:r.settings?.prompts?.vars?.knowledgePoints||"List of knowledge points to test."}),(0,s.jsx)(eL,{name:"language_instruction",description:r.settings?.prompts?.vars?.languageInstructionShort||"Language formatting instructions."})]})]}),(0,s.jsx)(eT.f,{value:n,onChange:e=>c("similar",e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:ez})]})})]})})}var eP=e.i(431343),eO=e.i(128093),eq=e.i(79058);let eH=["browser","minimax","qwen"],eV={minimax:{model:"speech-2.8-hd",voice:"male-qn-jingying"},qwen:{model:"qwen-audio-3.0-tts-plus",voice:"longanlufeng"}};function eY({config:e,setConfig:a,saving:r,onSave:i}){let{t:n,language:l}=(0,t.b)(),c=n.settings.tts,[o,d]=(0,f.useState)(!1),m=e.tts?.mode??"browser",u="minimax"===m||"qwen"===m?m:null,x=u?e.tts?.[u]:void 0,h=(e,s)=>{u&&a(t=>({...t,tts:{...t.tts,[u]:{...t.tts?.[u],[e]:s}}}))},p=async()=>{(0,eq.p)(),d(!0);try{await i();let{id:e}=await V.f.post("/api/tts",{text:c.previewText,language:l},{timeout:12e4,recoverable:!0}),s=(0,eq.l)();if(!s)return;s.src=`/api/tts/${e}`,s.playbackRate=1,await s.play()}catch(s){W.f.error("[TtsSettings]","Preview failed",{error:s});let e=(0,B.d)(s);Y.c.error("TTS_NOT_CONFIGURED"===e?c.notConfigured:"TTS_PROVIDER_ERROR"===e?c.providerError:c.previewFailed)}finally{d(!1)}};return(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:c.title}),(0,s.jsxs)(ei.d,{value:m,onValueChange:e=>a(s=>({...s,tts:{...s.tts,mode:e}})),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{})}),(0,s.jsx)(ei.r,{children:eH.map(e=>(0,s.jsx)(ei.T,{value:e,children:c.modes[e]},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:u?c.cloudHint:c.browserHint})]}),u&&(0,s.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(R.f,{children:[eO.$[u].name," API Key"]}),(0,s.jsx)(er.f,{value:e[u]?.apiKey||"",onChange:e=>{var s;return s=e.target.value,void(u&&a(e=>({...e,[u]:{...e[u],apiKey:s}})))},placeholder:"qwen"===u?"sk-sp-...":"sk-..."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.apiKeyHint[u]})]}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:c.model}),(0,s.jsx)(D.f,{value:x?.model||"",onChange:e=>h("model",e.target.value),placeholder:eV[u].model})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:c.voice}),(0,s.jsx)(D.f,{value:x?.voice||"",onChange:e=>h("voice",e.target.value),placeholder:eV[u].voice})]})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.voiceHint[u]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(R.f,{children:c.endpoint}),(0,s.jsx)(D.f,{value:x?.endpoint||"",onChange:e=>h("endpoint",e.target.value),placeholder:function(e,s){let{baseUrl:t}=(0,eO.k)(e,s);if("minimax"===e)return`${t.replace(/\/+$/,"")}/t2a_v2`;try{return`${new URL(t).origin}/api/v1/services/audio/tts/SpeechSynthesizer`}catch{return""}}(u,e[u])}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.endpointHint})]})]},u),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[u&&(0,s.jsxs)(C.f,{variant:"outline",onClick:p,disabled:r||o,className:"sm:w-auto",children:[o?(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eP.f,{className:"mr-2 h-4 w-4"}),c.preview]}),(0,s.jsxs)(C.f,{onClick:()=>void i(),disabled:r||o,className:"flex-1",children:[r&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),c.save]})]})]})}var eW=e.i(835467);function eB({value:e,icon:t,label:a}){return(0,s.jsxs)(A.k,{value:e,className:"px-2 sm:px-3",children:[t,(0,s.jsx)("span",{className:"hidden sm:inline",children:a})]})}function eJ(){let{setTimeZone:e}=(0,r.M)(),{data:i}=(0,a.useSession)(),n=i?.user?.role==="admin",{t:o}=(0,t.b)(),d=(0,l.useRouter)(),[m,u]=(0,f.useState)(!1),x=(0,f.useRef)(null),[h,E]=(0,f.useState)(!1),[M,D]=(0,f.useState)(!1),[R,F]=(0,f.useState)({aiProvider:"minimax"}),z=(0,f.useCallback)(async()=>{D(!0);try{F(await V.f.get("/api/settings"))}catch(e){W.f.error("[SettingsDialog]","Failed to fetch settings",{error:e})}finally{D(!1)}},[]);(0,f.useEffect)(()=>{m&&z()},[m,z]);let I=async()=>{let s=(0,eW.f)(R,o);if(s)return void Y.c.error(s);E(!0);try{let s=await V.f.post("/api/settings",R);F(s),e(s.timeZone||_.J),Y.c.success(o.settings?.messages?.saved||"Settings saved"),x.current?.scrollTo({top:0,behavior:"smooth"})}catch(e){W.f.error("[SettingsDialog]","Failed to save settings",{error:e}),Y.c.error(o.settings?.messages?.saveFailed||"Failed to save")}finally{E(!1)}},L=e=>(0,s.jsxs)(C.f,{onClick:I,disabled:h,className:"w-full",children:[h&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e]});return(0,s.jsxs)(T.N,{open:m,onOpenChange:u,children:[(0,s.jsx)(T.a,{asChild:!0,children:(0,s.jsxs)(C.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,s.jsx)(N,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:o.settings?.title||"Settings"})]})}),(0,s.jsxs)(T.d,{ref:x,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsx)(T.F,{children:o.settings?.title||"Settings"}),(0,s.jsx)(T.C,{children:o.settings?.desc||"Manage your preferences and data."})]}),(0,s.jsxs)(A.i,{defaultValue:"general",className:"w-full",children:[(0,s.jsxs)(A.U,{className:`grid w-full grid-cols-4 ${n?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,s.jsx)(eB,{value:"general",icon:(0,s.jsx)(y.f,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.general||"General"}),(0,s.jsx)(eB,{value:"account",icon:(0,s.jsx)(k.f,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.account||"Account"}),n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eB,{value:"ai",icon:(0,s.jsx)(j,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.ai||"AI Provider"}),(0,s.jsx)(eB,{value:"prompts",icon:(0,s.jsx)(w,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.prompts||"Prompts"}),(0,s.jsx)(eB,{value:"admin",icon:(0,s.jsx)(p,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.admin||"User Management"})]}),(0,s.jsx)(eB,{value:"danger",icon:(0,s.jsx)(g,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.danger||"Danger"}),(0,s.jsx)(eB,{value:"about",icon:(0,s.jsx)(v,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.about||"About"})]}),(0,s.jsxs)(A.S,{value:"general",className:"space-y-4 py-4",children:[(0,s.jsx)(eC,{config:R,setConfig:F,isAdmin:n,disabled:M||h}),n&&L(o.settings?.save||"Save Settings")]}),(0,s.jsx)(A.S,{value:"account",className:"space-y-4 py-4",children:(0,s.jsx)(el,{})}),(0,s.jsxs)(A.S,{value:"ai",className:"space-y-4 py-4",children:[(0,s.jsx)(ec.f,{config:R,setConfig:F,loading:M,saving:h,onSave:I}),!M&&(0,s.jsx)(eY,{config:R,setConfig:F,saving:h,onSave:I})]}),(0,s.jsxs)(A.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,s.jsx)(eU,{config:R,onUpdate:(e,s)=>F(t=>({...t,prompts:{...t.prompts,[e]:s}}))}),L(o.settings?.prompts?.save||"Save Prompt Settings")]}),n&&(0,s.jsxs)(A.S,{value:"admin",className:"space-y-4 py-4",children:[(0,s.jsxs)(C.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{u(!1),d.push("/admin")},children:[(0,s.jsx)(c.f,{className:"h-4 w-4"}),o.admin?.dashboard?.title||"Admin Dashboard"]}),(0,s.jsxs)(C.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{u(!1),d.push("/setup")},children:[(0,s.jsx)(S.f,{className:"h-4 w-4"}),o.setup.rerun]}),(0,s.jsx)("div",{className:"border-t pt-4",children:(0,s.jsx)(J,{})})]}),(0,s.jsx)(A.S,{value:"danger",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(eg,{isAdmin:n}),(0,s.jsx)(eu,{isAdmin:n})]})}),(0,s.jsx)(A.S,{value:"about",className:"space-y-4 py-4",children:(0,s.jsx)(ea,{})})]})]})]})}let eK=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],eX=[{key:"home",href:"/",icon:h,match:e=>"/"===e},{key:"notebooks",href:"/notebooks",icon:o.f,match:e=>e.startsWith("/notebooks")||e.startsWith("/error-items")||e.startsWith("/practice")},{key:"review",href:"/review",icon:d.f,match:e=>e.startsWith("/review")},{key:"stats",href:"/stats",icon:c.f,match:e=>e.startsWith("/stats")||e.startsWith("/tags")},{key:"exams",href:"/exams",icon:m.f,match:e=>e.startsWith("/exams")}];function eG({children:e}){var r;let c,o,d=(0,l.usePathname)()||"/",{t:m}=(0,t.b)(),{data:x,status:h}=(0,a.useSession)(),g=x?.user?.role==="admin",j=eK.some(e=>e.test(d));if(r=g&&!j,c=(0,l.useRouter)(),o=(0,f.useRef)(!1),(0,f.useEffect)(()=>{r&&!o.current&&(o.current=!0,V.f.get("/api/setup").then(e=>{e.needsSetup&&c.replace("/setup")}).catch(e=>W.f.warn("[Setup]","Failed to check setup status",{error:e})))},[r,c]),j||"unauthenticated"===h)return(0,s.jsx)(s.Fragment,{children:e});let v=x?.user?.name||x?.user?.email||"";return(0,s.jsxs)("div",{className:"min-h-screen",children:[(0,s.jsx)("header",{className:"sticky top-0 z-40 border-b bg-card/80 backdrop-blur-md supports-[backdrop-filter]:bg-card/70 print:hidden",children:(0,s.jsxs)("div",{className:"mx-auto flex h-14 max-w-6xl items-center gap-3 px-4 md:h-16 md:px-8",children:[(0,s.jsxs)(n.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(i.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,s.jsx)("span",{className:"text-base font-semibold tracking-tight",children:m.pageTitle.base})]}),(0,s.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:eX.map(e=>{let t=e.match(d),a=e.icon;return(0,s.jsxs)(n.default,{href:e.href,className:(0,F.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",t?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":t?"page":void 0,children:[(0,s.jsx)(a,{className:"h-4 w-4"}),m.nav[e.key]]},e.key)})}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[v&&(0,s.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:v.slice(0,1).toUpperCase()}),(0,s.jsx)("span",{className:"truncate",children:v})]}),g&&(0,s.jsx)(n.default,{href:"/admin",title:m.nav.admin,children:(0,s.jsxs)(C.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,s.jsx)(p,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:m.nav.admin})]})}),(0,s.jsx)(eJ,{}),(0,s.jsx)(C.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,a.signOut)({callbackUrl:"/login"}),title:m.app.logout,children:(0,s.jsx)(u.f,{className:"h-5 w-5"})})]})]})}),(0,s.jsx)("div",{className:"pb-20 md:pb-0",children:e}),(0,s.jsx)("nav",{className:"pb-safe fixed inset-x-0 bottom-0 z-40 border-t bg-card/90 backdrop-blur-md md:hidden print:hidden",children:(0,s.jsx)("div",{className:"grid h-16 grid-cols-5",children:eX.map(e=>{let t=e.match(d),a=e.icon;return(0,s.jsxs)(n.default,{href:e.href,className:(0,F.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",t?"text-primary":"text-muted-foreground"),"aria-current":t?"page":void 0,children:[(0,s.jsx)("span",{className:(0,F.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",t&&"bg-accent"),children:(0,s.jsx)(a,{className:"h-5 w-5"})}),m.nav[e.key]]},e.key)})})})]})}let eZ=(0,x.f)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]);var eQ=e.i(373884);let e0=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function e1(){let{t:e}=(0,t.b)(),{timeZone:i}=(0,r.M)(),{status:c}=(0,a.useSession)(),o=(0,l.usePathname)(),[d,m]=(0,f.useState)(!1),[u,x]=(0,f.useState)([]),[h,p]=(0,f.useState)(()=>Date.now()),g="authenticated"!==c||e0.some(e=>e.test(o||"")),j=(0,f.useCallback)(async()=>{if("u"<typeof document||"hidden"!==document.visibilityState)try{let e=await V.f.get("/api/tasks");x(e.tasks),p(Date.now())}catch{}},[]);if((0,f.useEffect)(()=>{if(g)return;let e=setTimeout(j,0),s=setInterval(j,d?2e3:15e3);return()=>{clearTimeout(e),clearInterval(s)}},[g,d,j]),g)return null;let v=u.filter(e=>"running"===e.status).length,y=u.some(e=>"running"!==e.status),w=async()=>{try{let e=await V.f.delete("/api/tasks");x(e.tasks)}catch{}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(C.f,{variant:"outline",size:"icon",className:"fixed bottom-20 right-4 z-40 h-11 w-11 rounded-full shadow-lg md:bottom-6 md:right-6 print:hidden",onClick:()=>m(!0),"aria-label":e.backgroundTasks.title,title:e.backgroundTasks.title,children:[v>0?(0,s.jsx)(b.f,{className:"h-5 w-5 animate-spin"}):(0,s.jsx)(eZ,{className:"h-5 w-5"}),v>0&&(0,s.jsx)("span",{className:"absolute -right-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs text-primary-foreground",children:v})]}),(0,s.jsx)(T.N,{open:d,onOpenChange:m,children:(0,s.jsxs)(T.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsx)(T.F,{children:e.backgroundTasks.title}),(0,s.jsx)(T.C,{children:e.backgroundTasks.description})]}),0===u.length?(0,s.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:e.backgroundTasks.empty}):(0,s.jsx)("ul",{className:"space-y-2",children:u.map(t=>{var a,r;let l;return(0,s.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:["running"===t.status&&(0,s.jsx)(b.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===t.status&&(0,s.jsx)(ex.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===t.status&&(0,s.jsx)(eQ.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,s.jsxs)("div",{className:"font-medium",children:[e.backgroundTasks.kinds[t.kind],(0,s.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",e.backgroundTasks.status[t.status]]})]}),t.subject&&(0,s.jsx)("div",{className:"break-words text-muted-foreground",children:t.subject}),t.progress&&t.progress.total>0&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,s.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(t.progress.done/t.progress.total*100)}%`}})}),(0,s.jsxs)("div",{className:"text-xs text-muted-foreground",children:[e.backgroundTasks.progress.replace("{done}",String(t.progress.done)).replace("{total}",String(t.progress.total)),t.progress.failed>0&&` \xb7 ${e.backgroundTasks.failedCount.replace("{count}",String(t.progress.failed))}`]})]}),t.error&&(0,s.jsx)("div",{className:"text-xs text-destructive",children:(s=>{if(!s)return null;let t=e.backgroundTasks.errors[s]??e.errors[s];return"string"==typeof t?t:s})(t.error)}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:e.backgroundTasks.startedAt.replace("{time}",(0,_.r)(t.startedAt,"HH:mm:ss",i))}),(0,s.jsx)("span",{children:e.backgroundTasks.elapsed.replace("{time}",(a=t.startedAt,r=t.finishedAt,l=Math.max(0,Math.round(((r?Date.parse(r):h)-Date.parse(a))/1e3)),`${Math.floor(l/60)}:${String(l%60).padStart(2,"0")}`))}),t.link&&(0,s.jsx)(n.default,{href:t.link,className:"text-primary hover:underline",onClick:()=>m(!1),children:e.backgroundTasks.view})]})]})]})},t.id)})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.backgroundTasks.retentionHint}),y&&(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:w,children:e.backgroundTasks.clearFinished})]})]})})]})}var e2=e.i(37727);let e4={success:{icon:ex.f,className:"text-success"},error:{icon:eQ.f,className:"text-destructive"},warning:{icon:g,className:"text-warning"},info:{icon:v,className:"text-primary"}};function e3(){let{t:e}=(0,t.b)(),[a,r]=(0,f.useState)([]),[i,n]=(0,f.useState)(null);return(0,f.useEffect)(()=>(0,Y.M)(e=>{r(e.toasts),n(e.confirm)}),[]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4 print:hidden",role:"status","aria-live":"polite",children:a.map(t=>{let{icon:a,className:r}=e4[t.type];return(0,s.jsxs)("div",{className:"pointer-events-auto flex w-full max-w-sm items-start gap-3 rounded-xl border bg-card/95 px-4 py-3 text-sm shadow-lg backdrop-blur animate-in fade-in slide-in-from-top-2 duration-200",children:[(0,s.jsx)(a,{className:(0,F.f)("mt-0.5 h-4 w-4 shrink-0",r)}),(0,s.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:t.message}),(0,s.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,Y.p)(t.id),"aria-label":e.common.close,children:(0,s.jsx)(e2.X,{className:"h-3.5 w-3.5"})})]},t.id)})}),(0,s.jsx)(T.N,{open:!!i,onOpenChange:e=>{e||i?.resolve(!1)},children:(0,s.jsxs)(T.d,{className:"sm:max-w-md",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsxs)(T.F,{className:"flex items-center gap-2",children:[i?.destructive&&(0,s.jsx)(g,{className:"h-5 w-5 text-destructive"}),i?.title||e.common.confirmTitle]}),(0,s.jsx)(T.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:i?.message})]}),(0,s.jsxs)(T.c,{className:"gap-2",children:[(0,s.jsx)(C.f,{variant:"outline",onClick:()=>i?.resolve(!1),children:i?.cancelText||e.common.cancel}),(0,s.jsx)(C.f,{variant:i?.destructive?"destructive":"default",onClick:()=>i?.resolve(!0),autoFocus:!0,children:i?.confirmText||e.common.confirm})]})]})})]})}function e5(){return(0,f.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(e=>{W.f.warn("[PWA]","Service worker registration failed",{error:String(e)})})},[]),null}e.s(["Providers",0,function({children:e,timeZone:i}){return(0,s.jsx)(a.SessionProvider,{children:(0,s.jsx)(t.w,{children:(0,s.jsxs)(r.n,{initialTimeZone:i,children:[(0,s.jsx)(eG,{children:e}),(0,s.jsx)(e1,{}),(0,s.jsx)(e3,{}),(0,s.jsx)(e5,{})]})})})}],1661)}]);
191
+ {{provider_hints}}`;var eI=e.i(367240);function eL({name:e,description:t}){return(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,s.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-primary shrink-0 w-fit",children:`{{${e}}}`}),(0,s.jsx)("span",{className:"text-muted-foreground",children:t})]})}function e$(){let{t:e}=(0,t.b)();return(0,s.jsxs)("div",{className:"bg-amber-50 border border-amber-200 rounded-md p-3 flex items-start gap-3 text-amber-900 text-sm mb-4",children:[(0,s.jsx)(f,{className:"h-5 w-5 shrink-0 text-amber-600"}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"font-medium",children:e.settings?.prompts?.caution||"Modify with Caution"}),(0,s.jsx)("p",{className:"text-amber-800/90 text-xs",children:e.settings?.prompts?.warning||"Variables in {{brackets}} are used to inject dynamic content. Please preserve these variables, otherwise the AI providing may fail to get question context or return invalid formats."})]})]})}function eU({config:e,onUpdate:a}){let{t:r}=(0,t.b)(),i=e.prompts?.analyze||eF,n=e.prompts?.similar||eR,l=async e=>{await (0,H.u)(r.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&a(e,"analyze"===e?eF:eR)},o=(e,s)=>{a(e,s)};return(0,s.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,s.jsxs)(A.i,{defaultValue:"analyze",className:"w-full",children:[(0,s.jsxs)(A.U,{className:"grid w-full grid-cols-2",children:[(0,s.jsx)(A.k,{value:"analyze",children:r.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,s.jsx)(A.k,{value:"similar",children:r.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,s.jsx)(A.S,{value:"analyze",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.f,{className:"text-base font-semibold",children:r.settings?.prompts?.customAnalysis||"Custom Analysis Template"}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>l("analyze"),children:[(0,s.jsx)(eI.f,{className:"w-4 h-4 mr-2"}),r.settings?.prompts?.reset||"Reset Default"]})]}),(0,s.jsx)(e$,{}),(0,s.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,s.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),r.settings?.prompts?.variables||"Available Variables"]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(eL,{name:"language_instruction",description:r.settings?.prompts?.vars?.languageInstruction||"Injects instructions based on target language (e.g., keep English questions in English but analysis in Chinese)."}),(0,s.jsx)(eL,{name:"knowledge_points_list",description:r.settings?.prompts?.vars?.knowledgePointsList||"Injects the standard list of knowledge point tags for the specific subject."}),(0,s.jsx)(eL,{name:"provider_hints",description:r.settings?.prompts?.vars?.providerHints||"System-injected hints (e.g., enforcing JSON format)."})]})]}),(0,s.jsx)(eT.f,{value:i,onChange:e=>o("analyze",e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:eF})]})}),(0,s.jsx)(A.S,{value:"similar",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.f,{className:"text-base font-semibold",children:r.settings?.prompts?.customSimilar||"Custom Similar Question Template"}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>l("similar"),children:[(0,s.jsx)(eI.f,{className:"w-4 h-4 mr-2"}),r.settings?.prompts?.reset||"Reset Default"]})]}),(0,s.jsx)(e$,{}),(0,s.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,s.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),r.settings?.prompts?.variables||"Available Variables"]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(eL,{name:"difficulty_level",description:r.settings?.prompts?.vars?.difficultyLevel||"Target difficulty level."}),(0,s.jsx)(eL,{name:"difficulty_instruction",description:r.settings?.prompts?.vars?.difficultyInstruction||"Specific writing instructions for the target difficulty."}),(0,s.jsx)(eL,{name:"original_question",description:r.settings?.prompts?.vars?.originalQuestion||"The full text of the original question."}),(0,s.jsx)(eL,{name:"knowledge_points",description:r.settings?.prompts?.vars?.knowledgePoints||"List of knowledge points to test."}),(0,s.jsx)(eL,{name:"language_instruction",description:r.settings?.prompts?.vars?.languageInstructionShort||"Language formatting instructions."})]})]}),(0,s.jsx)(eT.f,{value:n,onChange:e=>o("similar",e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:eR})]})})]})})}var eP=e.i(431343),eq=e.i(434901),eO=e.i(753817),eK=e.i(128093),eB=e.i(79058);let eH=["browser","minimax","qwen","glm","stepfun","volcengine","volcengine-agent","openai"];eH.filter(e=>"browser"!==e);let eV={minimax:{model:"speech-2.8-hd",voice:"male-qn-jingying"},qwen:{model:"qwen-audio-3.0-tts-plus",voice:"longanlufeng"},glm:{model:"glm-tts",voice:"xiaochen"},stepfun:{model:"stepaudio-2.5-tts",voice:"qingniandaxuesheng"},volcengine:{model:"seed-tts-2.0",voice:"zh_male_yangguangqingnian_uranus_bigtts"},"volcengine-agent":{model:"seed-tts-2.0",voice:"zh_male_yangguangqingnian_uranus_bigtts"},openai:{model:"gpt-4o-mini-tts",voice:"cedar"}},eY={minimax:{apiKey:"https://platform.minimax.cn/docs/guides/quickstart-preparation",model:"https://platform.minimax.cn/docs/api-reference/speech-t2a-http",voice:"https://platform.minimax.cn/docs/faq/system-voice-id",endpoint:"https://platform.minimax.cn/docs/api-reference/speech-t2a-http"},qwen:{apiKey:"https://help.aliyun.com/zh/model-studio/token-plan-personal-quick-start",model:"https://help.aliyun.com/zh/model-studio/non-realtime-tts-user-guide",voice:"https://help.aliyun.com/zh/model-studio/qwen-audio-tts-voice-list",endpoint:"https://help.aliyun.com/zh/model-studio/non-realtime-tts-user-guide"},glm:{apiKey:"https://docs.bigmodel.cn/cn/guide/start/quick-start",model:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3",voice:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3",endpoint:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3"},stepfun:{apiKey:"https://platform.stepfun.com/docs/zh/step-plan/integrations/audio-api",model:"https://platform.stepfun.com/docs/zh/api-reference/audio/create-audio",voice:"https://platform.stepfun.com/docs/zh/guides/developer/tts",endpoint:"https://platform.stepfun.com/docs/zh/api-reference/audio/create-audio"},volcengine:{apiKey:"https://www.volcengine.com/docs/6561/196768",model:"https://www.volcengine.com/docs/6561/1598757",voice:"https://www.volcengine.com/docs/6561/1257544",endpoint:"https://www.volcengine.com/docs/6561/1598757"},openai:{apiKey:"https://platform.openai.com/docs/quickstart",model:"https://developers.openai.com/api/docs/guides/text-to-speech",voice:"https://developers.openai.com/api/docs/guides/text-to-speech",endpoint:"https://developers.openai.com/api/docs/guides/text-to-speech"},"volcengine-agent":{apiKey:"https://ark.volcengine.com/region:cn-beijing/docs/82379/2160841?lang=zh",model:"https://docs.volcengine.com/docs/ark/agent-plan-personal-voice-model?lang=zh",voice:"https://www.volcengine.com/docs/6561/1257544",endpoint:"https://docs.volcengine.com/docs/ark/agent-plan-personal-voice-model?lang=zh"}},eW={volcengine:"https://docs.volcengine.com/docs/ark/free-inference-quota?lang=zh"};function eJ({config:e,setConfig:a,saving:r,onSave:i}){var n;let{t:l,language:o}=(0,t.b)(),c=l.settings.tts,[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)(null),h=e.tts?.mode??"browser",x="browser"!==h&&"string"==typeof(n=h)&&eH.includes(n)?h:null,f=x?e.tts?.[x]:void 0,j=(e,s)=>{x&&a(t=>({...t,tts:{...t.tts,[x]:{...t.tts?.[x],[e]:s}}}))},v=!!x&&("volcengine"===x||"openai"===x),y=x?function(e,s){if("openai"===s){let s=e.openai?.instances?.find(s=>s.id===e.openai?.activeInstanceId);return s?{apiKey:s.apiKey,baseUrl:s.baseUrl}:void 0}return e[s]}(e,x):void 0,w=v?f?.apiKey:y?.apiKey,N=async()=>{(0,eB.p)(),m(!0),p(null);try{await i();let{id:e,version:s}=await B.f.post("/api/tts",{text:c.previewText,language:o},{timeout:12e4,recoverable:!0}),t=(0,eB.l)();if(!t)return;t.src=`/api/tts/${e}?v=${s}`,t.playbackRate=1,await t.play()}catch(s){V.f.error("[TtsSettings]","Preview failed",{error:s});let e=(0,Y.d)(s);H.c.error("TTS_NOT_CONFIGURED"===e?c.notConfigured:"TTS_PROVIDER_ERROR"===e?c.providerError:c.previewFailed),p((0,Y.L)(s)??null)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:c.title}),(0,s.jsxs)(ei.d,{value:h,onValueChange:e=>a(s=>({...s,tts:{...s.tts,mode:e}})),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{})}),(0,s.jsx)(ei.r,{children:eH.map(e=>(0,s.jsx)(ei.T,{value:e,children:c.modes[e]},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:x?c.cloudHint:c.browserHint})]}),x&&(0,s.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[eW[x]&&(0,s.jsxs)("div",{className:"rounded-md border border-green-200 bg-green-50 p-3 text-xs text-green-800 dark:border-green-900 dark:bg-green-950/40 dark:text-green-300",children:[c.freeTrial," ",(0,s.jsx)("a",{href:eW[x],target:"_blank",rel:"noopener noreferrer",className:"underline",children:c.freeTrialLink})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:"openai"===x?"OpenAI API Key":v?c.speechApiKey:`${(0,eK.z)(x,o)} API Key`,href:eY[x].apiKey,linkText:l.settings.ai.docLinks.apiKey}),(0,s.jsx)(er.f,{value:w||"",onChange:e=>{var s;return s=e.target.value,void(x&&(v?j("apiKey",s):a(e=>({...e,[x]:{...e[x],apiKey:s}}))))},placeholder:"qwen"===x?"sk-sp-...":v?"":"sk-..."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.apiKeyHint[x]})]}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.model,href:eY[x].model,linkText:c.docs}),(0,s.jsx)(D.f,{value:f?.model||"",onChange:e=>j("model",e.target.value),placeholder:eV[x].model})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.voice,href:eY[x].voice,linkText:c.voiceList}),(0,s.jsx)(D.f,{value:f?.voice||"",onChange:e=>j("voice",e.target.value),placeholder:eV[x].voice})]})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.voiceHint[x]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.endpoint,href:eY[x].endpoint,linkText:c.docs}),(0,s.jsx)(D.f,{value:f?.endpoint||"",onChange:e=>j("endpoint",e.target.value),placeholder:function(e,s){if("volcengine"===e)return"https://openspeech.bytedance.com/api/v3/tts/unidirectional";if("volcengine-agent"===e)return"https://openspeech.bytedance.com/api/v3/plan/tts/unidirectional";if("openai"===e)return`${(s?.baseUrl||"https://api.openai.com/v1").replace(/\/+$/,"")}/audio/speech`;let{baseUrl:t}=(0,eK.k)(e,s);if("minimax"===e)return`${t.replace(/\/+$/,"")}/t2a_v2`;if("glm"===e||"stepfun"===e)return`${t.replace(/\/+$/,"")}/audio/speech`;try{return`${new URL(t).origin}/api/v1/services/audio/tts/SpeechSynthesizer`}catch{return""}}(x,y)}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.endpointHint})]})]},x),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[x&&(0,s.jsxs)(C.f,{variant:"outline",onClick:N,disabled:r||d,className:"sm:w-auto",children:[d?(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eP.f,{className:"mr-2 h-4 w-4"}),c.preview]}),(0,s.jsxs)(C.f,{onClick:()=>void i(),disabled:r||d,className:"flex-1",children:[r&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),c.save]})]}),x&&u&&(0,s.jsx)("div",{className:"rounded-md border border-red-200 bg-red-50 p-2 dark:border-red-900 dark:bg-red-950/40",children:(0,s.jsx)(eO.f,{detail:u})})]})}var eX=e.i(835467);function eG({value:e,icon:t,label:a}){return(0,s.jsxs)(A.k,{value:e,className:"px-2 sm:px-3",children:[t,(0,s.jsx)("span",{className:"hidden sm:inline",children:a})]})}function eZ(){let{setTimeZone:e}=(0,r.M)(),{data:i}=(0,a.useSession)(),n=i?.user?.role==="admin",{t:c}=(0,t.b)(),d=(0,l.useRouter)(),[m,u]=(0,g.useState)(!1),p=(0,g.useRef)(null),[h,_]=(0,g.useState)(!1),[z,D]=(0,g.useState)(!1),[M,F]=(0,g.useState)({aiProvider:"minimax"}),R=(0,g.useCallback)(async()=>{D(!0);try{F(await B.f.get("/api/settings"))}catch(e){V.f.error("[SettingsDialog]","Failed to fetch settings",{error:e})}finally{D(!1)}},[]);(0,g.useEffect)(()=>{m&&R()},[m,R]);let I=async()=>{let s=(0,eX.f)(M,c);if(s)return void H.c.error(s);_(!0);try{let s=await B.f.post("/api/settings",M);F(s),e(s.timeZone||E.J),H.c.success(c.settings?.messages?.saved||"Settings saved"),p.current?.scrollTo({top:0,behavior:"smooth"})}catch(e){V.f.error("[SettingsDialog]","Failed to save settings",{error:e}),H.c.error(c.settings?.messages?.saveFailed||"Failed to save")}finally{_(!1)}},L=e=>(0,s.jsxs)(C.f,{onClick:I,disabled:h,className:"w-full",children:[h&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e]});return(0,s.jsxs)(T.N,{open:m,onOpenChange:u,children:[(0,s.jsx)(T.a,{asChild:!0,children:(0,s.jsxs)(C.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,s.jsx)(N,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:c.settings?.title||"Settings"})]})}),(0,s.jsxs)(T.d,{ref:p,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsx)(T.F,{children:c.settings?.title||"Settings"}),(0,s.jsx)(T.C,{children:c.settings?.desc||"Manage your preferences and data."})]}),(0,s.jsxs)(A.i,{defaultValue:"general",className:"w-full",children:[(0,s.jsxs)(A.U,{className:`grid w-full grid-cols-4 ${n?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,s.jsx)(eG,{value:"general",icon:(0,s.jsx)(y.f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.general||"General"}),(0,s.jsx)(eG,{value:"account",icon:(0,s.jsx)(k.f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.account||"Account"}),n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eG,{value:"ai",icon:(0,s.jsx)(j,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.ai||"AI Provider"}),(0,s.jsx)(eG,{value:"prompts",icon:(0,s.jsx)(w,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.prompts||"Prompts"}),(0,s.jsx)(eG,{value:"admin",icon:(0,s.jsx)(x,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.admin||"User Management"})]}),(0,s.jsx)(eG,{value:"danger",icon:(0,s.jsx)(f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.danger||"Danger"}),(0,s.jsx)(eG,{value:"about",icon:(0,s.jsx)(v,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.about||"About"})]}),(0,s.jsxs)(A.S,{value:"general",className:"space-y-4 py-4",children:[(0,s.jsx)(eC,{config:M,setConfig:F,isAdmin:n,disabled:z||h}),n&&L(c.settings?.save||"Save Settings")]}),(0,s.jsx)(A.S,{value:"account",className:"space-y-4 py-4",children:(0,s.jsx)(el,{})}),(0,s.jsxs)(A.S,{value:"ai",className:"space-y-4 py-4",children:[(0,s.jsx)(eo.f,{config:M,setConfig:F,loading:z,saving:h,onSave:I}),!z&&(0,s.jsx)(eJ,{config:M,setConfig:F,saving:h,onSave:I})]}),(0,s.jsxs)(A.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,s.jsx)(eU,{config:M,onUpdate:(e,s)=>F(t=>({...t,prompts:{...t.prompts,[e]:s}}))}),L(c.settings?.prompts?.save||"Save Prompt Settings")]}),n&&(0,s.jsxs)(A.S,{value:"admin",className:"space-y-4 py-4",children:[(0,s.jsxs)(C.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{u(!1),d.push("/admin")},children:[(0,s.jsx)(o.f,{className:"h-4 w-4"}),c.admin?.dashboard?.title||"Admin Dashboard"]}),(0,s.jsxs)(C.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{u(!1),d.push("/setup")},children:[(0,s.jsx)(S.f,{className:"h-4 w-4"}),c.setup.rerun]}),(0,s.jsx)("div",{className:"border-t pt-4",children:(0,s.jsx)(W,{})})]}),(0,s.jsx)(A.S,{value:"danger",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(ef,{isAdmin:n}),(0,s.jsx)(eu,{isAdmin:n})]})}),(0,s.jsx)(A.S,{value:"about",className:"space-y-4 py-4",children:(0,s.jsx)(ea,{})})]})]})]})}let eQ=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],e0=[{key:"home",href:"/",icon:h,match:e=>"/"===e},{key:"notebooks",href:"/notebooks",icon:c.f,match:e=>e.startsWith("/notebooks")||e.startsWith("/error-items")||e.startsWith("/practice")},{key:"review",href:"/review",icon:d.f,match:e=>e.startsWith("/review")},{key:"stats",href:"/stats",icon:o.f,match:e=>e.startsWith("/stats")||e.startsWith("/tags")},{key:"exams",href:"/exams",icon:m.f,match:e=>e.startsWith("/exams")}];function e1({children:e}){var r;let o,c,d=(0,l.usePathname)()||"/",{t:m}=(0,t.b)(),{data:p,status:h}=(0,a.useSession)(),f=p?.user?.role==="admin",j=eQ.some(e=>e.test(d));if(r=f&&!j,o=(0,l.useRouter)(),c=(0,g.useRef)(!1),(0,g.useEffect)(()=>{r&&!c.current&&(c.current=!0,B.f.get("/api/setup").then(e=>{e.needsSetup&&o.replace("/setup")}).catch(e=>V.f.warn("[Setup]","Failed to check setup status",{error:e})))},[r,o]),j||"unauthenticated"===h)return(0,s.jsx)(s.Fragment,{children:e});let v=p?.user?.name||p?.user?.email||"";return(0,s.jsxs)("div",{className:"min-h-screen",children:[(0,s.jsx)("header",{className:"sticky top-0 z-40 border-b bg-card/80 backdrop-blur-md supports-[backdrop-filter]:bg-card/70 print:hidden",children:(0,s.jsxs)("div",{className:"mx-auto flex h-14 max-w-6xl items-center gap-3 px-4 md:h-16 md:px-8",children:[(0,s.jsxs)(n.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(i.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,s.jsx)("span",{className:"text-base font-semibold tracking-tight",children:m.pageTitle.base})]}),(0,s.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:e0.map(e=>{let t=e.match(d),a=e.icon;return(0,s.jsxs)(n.default,{href:e.href,className:(0,F.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",t?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":t?"page":void 0,children:[(0,s.jsx)(a,{className:"h-4 w-4"}),m.nav[e.key]]},e.key)})}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[v&&(0,s.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:v.slice(0,1).toUpperCase()}),(0,s.jsx)("span",{className:"truncate",children:v})]}),f&&(0,s.jsx)(n.default,{href:"/admin",title:m.nav.admin,children:(0,s.jsxs)(C.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,s.jsx)(x,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:m.nav.admin})]})}),(0,s.jsx)(eZ,{}),(0,s.jsx)(C.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,a.signOut)({callbackUrl:"/login"}),title:m.app.logout,children:(0,s.jsx)(u.f,{className:"h-5 w-5"})})]})]})}),(0,s.jsx)("div",{className:"pb-20 md:pb-0",children:e}),(0,s.jsx)("nav",{className:"pb-safe fixed inset-x-0 bottom-0 z-40 border-t bg-card/90 backdrop-blur-md md:hidden print:hidden",children:(0,s.jsx)("div",{className:"grid h-16 grid-cols-5",children:e0.map(e=>{let t=e.match(d),a=e.icon;return(0,s.jsxs)(n.default,{href:e.href,className:(0,F.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",t?"text-primary":"text-muted-foreground"),"aria-current":t?"page":void 0,children:[(0,s.jsx)("span",{className:(0,F.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",t&&"bg-accent"),children:(0,s.jsx)(a,{className:"h-5 w-5"})}),m.nav[e.key]]},e.key)})})})]})}let e2=(0,p.f)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]);var e4=e.i(373884);let e3=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function e5(){let{t:e}=(0,t.b)(),{timeZone:i}=(0,r.M)(),{status:o}=(0,a.useSession)(),c=(0,l.usePathname)(),[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)([]),[h,x]=(0,g.useState)(()=>Date.now()),f="authenticated"!==o||e3.some(e=>e.test(c||"")),j=(0,g.useCallback)(async()=>{if("u"<typeof document||"hidden"!==document.visibilityState)try{let e=await B.f.get("/api/tasks");p(e.tasks),x(Date.now())}catch{}},[]);if((0,g.useEffect)(()=>{if(f)return;let e=setTimeout(j,0),s=setInterval(j,d?2e3:15e3);return()=>{clearTimeout(e),clearInterval(s)}},[f,d,j]),f)return null;let v=u.filter(e=>"running"===e.status).length,y=u.some(e=>"running"!==e.status),w=async()=>{try{let e=await B.f.delete("/api/tasks");p(e.tasks)}catch{}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(C.f,{variant:"outline",size:"icon",className:"fixed bottom-20 right-4 z-40 h-11 w-11 rounded-full shadow-lg md:bottom-6 md:right-6 print:hidden",onClick:()=>m(!0),"aria-label":e.backgroundTasks.title,title:e.backgroundTasks.title,children:[v>0?(0,s.jsx)(b.f,{className:"h-5 w-5 animate-spin"}):(0,s.jsx)(e2,{className:"h-5 w-5"}),v>0&&(0,s.jsx)("span",{className:"absolute -right-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs text-primary-foreground",children:v})]}),(0,s.jsx)(T.N,{open:d,onOpenChange:m,children:(0,s.jsxs)(T.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsx)(T.F,{children:e.backgroundTasks.title}),(0,s.jsx)(T.C,{children:e.backgroundTasks.description})]}),0===u.length?(0,s.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:e.backgroundTasks.empty}):(0,s.jsx)("ul",{className:"space-y-2",children:u.map(t=>{var a,r;let l;return(0,s.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:["running"===t.status&&(0,s.jsx)(b.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===t.status&&(0,s.jsx)(ep.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===t.status&&(0,s.jsx)(e4.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,s.jsxs)("div",{className:"font-medium",children:[e.backgroundTasks.kinds[t.kind],(0,s.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",e.backgroundTasks.status[t.status]]})]}),t.subject&&(0,s.jsx)("div",{className:"break-words text-muted-foreground",children:t.subject}),t.progress&&t.progress.total>0&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,s.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(t.progress.done/t.progress.total*100)}%`}})}),(0,s.jsxs)("div",{className:"text-xs text-muted-foreground",children:[e.backgroundTasks.progress.replace("{done}",String(t.progress.done)).replace("{total}",String(t.progress.total)),t.progress.failed>0&&` \xb7 ${e.backgroundTasks.failedCount.replace("{count}",String(t.progress.failed))}`]})]}),t.error&&(0,s.jsx)("div",{className:"text-xs text-destructive",children:(s=>{if(!s)return null;let t=e.backgroundTasks.errors[s]??e.errors[s];return"string"==typeof t?t:s})(t.error)}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:e.backgroundTasks.startedAt.replace("{time}",(0,E.r)(t.startedAt,"HH:mm:ss",i))}),(0,s.jsx)("span",{children:e.backgroundTasks.elapsed.replace("{time}",(a=t.startedAt,r=t.finishedAt,l=Math.max(0,Math.round(((r?Date.parse(r):h)-Date.parse(a))/1e3)),`${Math.floor(l/60)}:${String(l%60).padStart(2,"0")}`))}),t.link&&(0,s.jsx)(n.default,{href:t.link,className:"text-primary hover:underline",onClick:()=>m(!1),children:e.backgroundTasks.view})]})]})]})},t.id)})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.backgroundTasks.retentionHint}),y&&(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:w,children:e.backgroundTasks.clearFinished})]})]})})]})}var e6=e.i(37727);let e8={success:{icon:ep.f,className:"text-success"},error:{icon:e4.f,className:"text-destructive"},warning:{icon:f,className:"text-warning"},info:{icon:v,className:"text-primary"}};function e7(){let{t:e}=(0,t.b)(),[a,r]=(0,g.useState)([]),[i,n]=(0,g.useState)(null);return(0,g.useEffect)(()=>(0,H.M)(e=>{r(e.toasts),n(e.confirm)}),[]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4 print:hidden",role:"status","aria-live":"polite",children:a.map(t=>{let{icon:a,className:r}=e8[t.type];return(0,s.jsxs)("div",{className:"pointer-events-auto flex w-full max-w-sm items-start gap-3 rounded-xl border bg-card/95 px-4 py-3 text-sm shadow-lg backdrop-blur animate-in fade-in slide-in-from-top-2 duration-200",children:[(0,s.jsx)(a,{className:(0,F.f)("mt-0.5 h-4 w-4 shrink-0",r)}),(0,s.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:t.message}),(0,s.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,H.p)(t.id),"aria-label":e.common.close,children:(0,s.jsx)(e6.X,{className:"h-3.5 w-3.5"})})]},t.id)})}),(0,s.jsx)(T.N,{open:!!i,onOpenChange:e=>{e||i?.resolve(!1)},children:(0,s.jsxs)(T.d,{className:"sm:max-w-md",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsxs)(T.F,{className:"flex items-center gap-2",children:[i?.destructive&&(0,s.jsx)(f,{className:"h-5 w-5 text-destructive"}),i?.title||e.common.confirmTitle]}),(0,s.jsx)(T.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:i?.message})]}),(0,s.jsxs)(T.c,{className:"gap-2",children:[(0,s.jsx)(C.f,{variant:"outline",onClick:()=>i?.resolve(!1),children:i?.cancelText||e.common.cancel}),(0,s.jsx)(C.f,{variant:i?.destructive?"destructive":"default",onClick:()=>i?.resolve(!0),autoFocus:!0,children:i?.confirmText||e.common.confirm})]})]})})]})}function e9(){return(0,g.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(e=>{V.f.warn("[PWA]","Service worker registration failed",{error:String(e)})})},[]),null}e.s(["Providers",0,function({children:e,timeZone:i}){return(0,s.jsx)(a.SessionProvider,{children:(0,s.jsx)(t.w,{children:(0,s.jsxs)(r.n,{initialTimeZone:i,children:[(0,s.jsx)(e1,{children:e}),(0,s.jsx)(e5,{}),(0,s.jsx)(e7,{}),(0,s.jsx)(e9,{})]})})})}],1661)}]);
@@ -0,0 +1 @@
1
+ (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,871689,e=>{let t=(0,e.i(475254).f)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);e.s(["f",0,t],871689)},463059,e=>{let t=(0,e.i(475254).f)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);e.s(["f",0,t],463059)},503116,e=>{let t=(0,e.i(475254).f)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);e.s(["f",0,t],503116)},63804,e=>{let t=(0,e.i(475254).f)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]);e.s(["f",0,t],63804)},303281,e=>{let t=(0,e.i(475254).f)("printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);e.s(["f",0,t],303281)},283086,e=>{let t=(0,e.i(475254).f)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);e.s(["f",0,t],283086)},469937,62825,e=>{var t=e.i(843476);let r=(0,e.i(475254).f)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);var n=e.i(111110),s=e.i(975157);let i=[1,2,3,4,5];function a(e){return"not_attempted"===e||"wrong_attempt"===e||"unknown"===e?e:"unknown"}e.s(["f",0,function({value:e,onChange:a,disabled:l,size:c="sm",showUnrated:o=!0,className:d}){let{t:u}=(0,n.b)(),f=e??0,m="sm"===c?"h-3.5 w-3.5":"h-5 w-5",h=f?u.difficulty.starsLabel.replace("{n}",String(f)):u.difficulty.unrated;return a?(0,t.jsxs)("span",{className:(0,s.f)("inline-flex items-center gap-0.5",d),role:"group","aria-label":`${u.difficulty.label}${u.common.colon}${h}`,title:u.difficulty.clearHint,children:[i.map(e=>(0,t.jsx)("button",{type:"button",disabled:l,onClick:()=>a(e===f?null:e),"aria-label":u.difficulty.setStars.replace("{n}",String(e)),"aria-pressed":e<=f,className:"rounded p-0.5 hover:bg-muted disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(r,{className:(0,s.f)(m,e<=f?"fill-amber-400 text-amber-400":"text-muted-foreground/40")})},e)),!f&&o&&(0,t.jsx)("span",{className:"ml-1 text-xs text-muted-foreground",children:u.difficulty.unrated})]}):f?(0,t.jsx)("span",{className:(0,s.f)("inline-flex items-center",d),role:"img","aria-label":`${u.difficulty.label}${u.common.colon}${h}`,title:h,children:i.map(e=>(0,t.jsx)(r,{className:(0,s.f)(m,e<=f?"fill-amber-400 text-amber-400":"text-muted-foreground/30"),"aria-hidden":!0},e))}):o?(0,t.jsx)("span",{className:(0,s.f)("text-xs text-muted-foreground",d),children:u.difficulty.unrated}):null}],469937),e.s(["i",0,function(e,t="zh"){return("en"===t?{not_attempted:"Not attempted",wrong_attempt:"Wrong attempt",unknown:"Unknown"}:{not_attempted:"不会做",wrong_attempt:"做错了",unknown:"未判断"})[a(e)]},"h",0,a,"x",0,function(e,t){return(t||"").trim()?"wrong_attempt":a(e)}],62825)},846968,e=>{var t=e.i(843476),r=e.i(269638),n=e.i(503116),s=e.i(16715),i=e.i(487486),a=e.i(111110);let l={new:{className:"bg-warning/15 text-amber-700 dark:text-warning",icon:n.f},reviewing:{className:"bg-primary/10 text-primary",icon:s.f},mastered:{className:"bg-success/15 text-success",icon:r.f}};e.s(["o",0,{new:"border-l-warning/70",reviewing:"border-l-primary/60",mastered:"border-l-success/70"},"x",0,function({status:e,className:r=""}){let{t:n}=(0,a.b)(),{className:s,icon:c}=l[e],o="mastered"===e?n.notebook.mastered:"reviewing"===e?n.notebook.reviewing:n.notebook.review;return(0,t.jsx)(i.f,{variant:"secondary",className:`${s} ${r}`,children:(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(c,{className:"h-3 w-3"})," ",o]})})}])},709830,76824,e=>{var t=e.i(843476),r=e.i(111110),n=e.i(952122);let s=["primary","junior_high","senior_high"],i="primary",a=["math","english","chinese","physics","chemistry","biology","history","geography","politics"];function l(e){return"string"==typeof e&&a.includes(e)}function c(e){var t;let r=l(e.subjectKey)?e.subjectKey:(0,n.f)(e.name);return{stage:"string"==typeof(t=e.stage)&&s.includes(t)?e.stage:i,subject:r&&l(r)?r:null}}function o(){let{t:e}=(0,r.b)();return{stageLabel:t=>({primary:e.auth.primary,junior_high:e.auth.juniorHigh,senior_high:e.auth.seniorHigh})[t],subjectLabel:t=>e.tags.subjects[t]}}e.s(["j",0,i,"c",0,s,"W",0,{primary:["math","english"],junior_high:a,senior_high:a},"v",0,c],76824),e.s(["E",0,function({notebook:e,className:r}){let{stageLabel:n,subjectLabel:s}=o(),i=c(e);return(0,t.jsxs)("span",{className:r,children:[n(i.stage),i.subject?` \xb7 ${s(i.subject)}`:""]})},"O",0,o],709830)},590546,e=>{var t=e.i(843476),r=e.i(618566),n=e.i(519455),s=e.i(871689);e.s(["f",0,function({fallbackUrl:e,className:i}){let a=(0,r.useRouter)();return(0,t.jsx)(n.f,{variant:"ghost",size:"icon",onClick:()=>{a.push(e)},className:i,children:(0,t.jsx)(s.f,{className:"h-5 w-5"})})}])},515288,e=>{var t=e.i(843476),r=e.i(975157);e.s(["N",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card",className:(0,r.f)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...n})},"O",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,r.f)("px-6",e),...n})},"u",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,r.f)("text-muted-foreground text-sm",e),...n})},"Y",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,r.f)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...n})},"v",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,r.f)("leading-none font-semibold",e),...n})}])},257428,e=>{var t=e.i(843476),r=e.i(271645),n=e.i(820783),s=e.i(30030),i=e.i(981140),a=e.i(369340),l=e.i(635804),c=e.i(296626),o=e.i(248425),d=Object.defineProperty,u=(e,t)=>d(e,"name",{value:t,configurable:!0}),f="Checkbox",[m,h]=(0,s.f)(f),[p,g]=m(f);function x(e){let{__scopeCheckbox:n,checked:s,children:i,defaultChecked:l,disabled:c,form:o,name:d,onCheckedChange:u,required:m,value:h="on",internal_do_not_use_render:g}=e,[x,b]=(0,a.f)({prop:s,defaultProp:l??!1,onChange:u,caller:f}),[y,k]=r.useState(null),[j,N]=r.useState(null),[C,_]=r.useState(null),R=!y||!!o||!!y.closest("form"),E={checked:x,disabled:c,setChecked:b,control:y,setControl:k,name:d,form:o,value:h,userClick:C,onUserClick:_,required:m,defaultChecked:!w(l)&&l,isFormControl:R,bubbleInput:j,setBubbleInput:N};return(0,t.jsx)(p,{scope:n,...E,children:v(g)?g(E):i})}u(x,"CheckboxProvider");var b=r.forwardRef(u(function({__scopeCheckbox:e,onKeyDown:s,onClick:a,...l},c){let{control:d,value:f,disabled:m,checked:h,required:p,setControl:x,setChecked:b,onUserClick:y,isFormControl:k,bubbleInput:j}=g("CheckboxTrigger",e),v=(0,n.f)(c,x),C=r.useRef(h);return r.useEffect(()=>{let e=d?.form;if(e){let t=u(()=>b(C.current),"reset");return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)}},[d,b]),(0,t.jsx)(o.V.button,{type:"button",role:"checkbox","aria-checked":w(h)?"mixed":h,"aria-required":p,"data-state":N(h),"data-disabled":m?"":void 0,disabled:m,value:f,...l,ref:v,onKeyDown:(0,i.f)(s,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:(0,i.f)(a,e=>{let t=e.isPropagationStopped();y({requestedChecked:!!w(h)||!h,hasConsumerStoppedPropagation:t}),b(e=>!!w(e)||!e),j&&k&&!t&&e.stopPropagation()})})},"CheckboxTrigger")),y=r.forwardRef(u(function(e,r){let{__scopeCheckbox:n,name:s,checked:i,defaultChecked:a,required:l,disabled:c,value:o,onCheckedChange:d,form:u,...f}=e;return(0,t.jsx)(x,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:c,required:l,onCheckedChange:d,name:s,form:u,value:o,internal_do_not_use_render:({isFormControl:e})=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(b,{...f,ref:r,__scopeCheckbox:n}),e&&(0,t.jsx)(j,{__scopeCheckbox:n})]})})},"Checkbox")),k=r.forwardRef(u(function(e,r){let{__scopeCheckbox:n,forceMount:s,...i}=e,a=g("CheckboxIndicator",n);return(0,t.jsx)(c.f,{present:s||w(a.checked)||!0===a.checked,children:(0,t.jsx)(o.V.span,{"data-state":N(a.checked),"data-disabled":a.disabled?"":void 0,...i,ref:r,style:{pointerEvents:"none",...e.style}})})},"CheckboxIndicator")),j=r.forwardRef(u(function({__scopeCheckbox:e,onClick:s,...a},c){let{control:d,userClick:u,checked:f,defaultChecked:m,required:h,disabled:p,name:x,value:b,form:y,bubbleInput:k,setBubbleInput:j}=g("CheckboxBubbleInput",e),v=(0,n.f)(c,j),N=(0,l.f)(d),C=r.useRef(!1),_=r.useRef(f),R=r.useRef(u),E=r.useRef(null);r.useEffect(()=>{if(!k)return;let e=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(!e)return;let t=_.current!==f;_.current=f;let r=null!==u&&u!==R.current;if(R.current=u,r)E.current=t?null:u,t&&(k.indeterminate=w(f),e.call(k,!w(f)&&f)),k.dispatchEvent(new Event("click",{bubbles:!u.hasConsumerStoppedPropagation}));else if(t){let t=E.current;E.current=null;let r=t?.requestedChecked===f;C.current=!0,k.indeterminate=w(f),e.call(k,!w(f)&&f),k.dispatchEvent(new Event("click",{bubbles:!(r&&t.hasConsumerStoppedPropagation)})),C.current=!1}},[k,f,u]);let P=r.useRef(!w(f)&&f);return(0,t.jsx)(o.V.input,{type:"checkbox","aria-hidden":!0,defaultChecked:m??P.current,required:h,disabled:p,name:x,value:b,form:y,...a,tabIndex:-1,ref:v,onClick:(0,i.f)(s,e=>{C.current&&e.stopPropagation()}),style:{...a.style,...N,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function v(e){return"function"==typeof e}function w(e){return"indeterminate"===e}function N(e){return w(e)?"indeterminate":e?"checked":"unchecked"}u(v,"isFunction"),u(w,"isIndeterminate"),u(N,"getState");var C=e.i(643531),_=e.i(975157);let R=r.forwardRef(({className:e,...r},n)=>(0,t.jsx)(y,{ref:n,className:(0,_.f)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...r,children:(0,t.jsx)(k,{className:(0,_.f)("flex items-center justify-center text-current"),children:(0,t.jsx)(C.f,{className:"h-4 w-4"})})}));R.displayName=y.displayName,e.s(["f",0,R],257428)},912505,e=>{var t=e.i(843476),r=e.i(975157);e.s(["f",0,function({icon:e,title:n,description:s,action:i,className:a}){return(0,t.jsxs)("div",{className:(0,r.f)("flex flex-col items-center justify-center rounded-2xl border border-dashed bg-card/50 px-6 py-14 text-center",a),children:[(0,t.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-accent text-accent-foreground",children:(0,t.jsx)(e,{className:"h-7 w-7"})}),(0,t.jsx)("p",{className:"font-medium",children:n}),s&&(0,t.jsx)("p",{className:"mt-1 max-w-sm text-sm text-muted-foreground",children:s}),i&&(0,t.jsx)("div",{className:"mt-5",children:i})]})}])},393842,e=>{var t=e.i(843476),r=e.i(590546),n=e.i(975157);e.s(["f",0,function({title:e,description:s,backHref:i,actions:a,titleAddon:l,className:c}){return(0,t.jsxs)("div",{className:(0,n.f)("flex items-start gap-3",c),children:[i&&(0,t.jsx)(r.f,{fallbackUrl:i,className:"-ml-2 shrink-0"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("h1",{className:"truncate text-2xl font-bold tracking-tight sm:text-3xl",children:e}),l]}),s&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground sm:text-base",children:s})]}),a&&(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:a})]})}])},86963,e=>{var t=e.i(843476),r=e.i(531278);e.s(["f",0,function({label:e}){return(0,t.jsxs)("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,t.jsx)(r.f,{className:"h-7 w-7 animate-spin text-primary"}),e&&(0,t.jsx)("p",{className:"text-sm",children:e})]})}])},469817,e=>{e.s(["$",0,18,"u",0,5,"A",0,200])},990745,e=>{e.s(["f",0,function(e){if(e.tags&&e.tags.length>0)return e.tags.map(e=>e.name);if(!e.knowledgePoints)return[];try{let t=JSON.parse(e.knowledgePoints);return Array.isArray(t)?t.filter(e=>"string"==typeof e):[]}catch{return[]}}])},952122,e=>{e.i(306831),e.s(["f",0,function(e){if(!e)return null;let t=e.toLowerCase();return t.includes("math")||t.includes("数学")?"math":t.includes("physics")||t.includes("物理")?"physics":t.includes("chemistry")||t.includes("化学")?"chemistry":t.includes("biology")||t.includes("生物")?"biology":t.includes("english")||t.includes("英语")?"english":t.includes("chinese")||t.includes("语文")?"chinese":t.includes("history")||t.includes("历史")?"history":t.includes("geography")||t.includes("地理")?"geography":t.includes("politics")||t.includes("政治")?"politics":null}])},35209,e=>{var t=e.i(271645),r=e.i(111110);e.s(["f",0,function(...e){let{t:n}=(0,r.b)(),s=[n.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,t.useEffect)(()=>{document.title=s},[s])}])},833547,747279,e=>{var t=e.i(41931);async function r(e){try{return(await t.f.get(`/api/error-items/short/${encodeURIComponent(e)}`)).id}catch{return null}}e.s(["f",0,r],833547);let n=RegExp("^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{6}$");e.s(["f",0,function(e){return"string"==typeof e&&n.test(e)}],747279)}])})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,871689,e=>{let t=(0,e.i(475254).f)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);e.s(["f",0,t],871689)},503116,e=>{let t=(0,e.i(475254).f)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);e.s(["f",0,t],503116)},356909,e=>{let t=(0,e.i(475254).f)("save",[["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"}]]);e.s(["f",0,t],356909)},283086,e=>{let t=(0,e.i(475254).f)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);e.s(["f",0,t],283086)},469937,62825,e=>{var t=e.i(843476);let s=(0,e.i(475254).f)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);var a=e.i(111110),r=e.i(975157);let i=[1,2,3,4,5];function n(e){return"not_attempted"===e||"wrong_attempt"===e||"unknown"===e?e:"unknown"}e.s(["f",0,function({value:e,onChange:n,disabled:l,size:c="sm",showUnrated:d=!0,className:o}){let{t:m}=(0,a.b)(),u=e??0,x="sm"===c?"h-3.5 w-3.5":"h-5 w-5",f=u?m.difficulty.starsLabel.replace("{n}",String(u)):m.difficulty.unrated;return n?(0,t.jsxs)("span",{className:(0,r.f)("inline-flex items-center gap-0.5",o),role:"group","aria-label":`${m.difficulty.label}${m.common.colon}${f}`,title:m.difficulty.clearHint,children:[i.map(e=>(0,t.jsx)("button",{type:"button",disabled:l,onClick:()=>n(e===u?null:e),"aria-label":m.difficulty.setStars.replace("{n}",String(e)),"aria-pressed":e<=u,className:"rounded p-0.5 hover:bg-muted disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(s,{className:(0,r.f)(x,e<=u?"fill-amber-400 text-amber-400":"text-muted-foreground/40")})},e)),!u&&d&&(0,t.jsx)("span",{className:"ml-1 text-xs text-muted-foreground",children:m.difficulty.unrated})]}):u?(0,t.jsx)("span",{className:(0,r.f)("inline-flex items-center",o),role:"img","aria-label":`${m.difficulty.label}${m.common.colon}${f}`,title:f,children:i.map(e=>(0,t.jsx)(s,{className:(0,r.f)(x,e<=u?"fill-amber-400 text-amber-400":"text-muted-foreground/30"),"aria-hidden":!0},e))}):d?(0,t.jsx)("span",{className:(0,r.f)("text-xs text-muted-foreground",o),children:m.difficulty.unrated}):null}],469937),e.s(["i",0,function(e,t="zh"){return("en"===t?{not_attempted:"Not attempted",wrong_attempt:"Wrong attempt",unknown:"Unknown"}:{not_attempted:"不会做",wrong_attempt:"做错了",unknown:"未判断"})[n(e)]},"h",0,n,"x",0,function(e,t){return(t||"").trim()?"wrong_attempt":n(e)}],62825)},991686,868983,e=>{var t=e.i(843476),s=e.i(271645),a=e.i(522016),r=e.i(215519),i=e.i(306831),n=e.i(664659),l=e.i(655900),c=e.i(531278),d=e.i(107233),o=e.i(283086),m=e.i(727612),u=e.i(487486),x=e.i(519455),f=e.i(515288),h=e.i(511445),p=e.i(356909),g=e.i(793479),y=e.i(393733),b=e.i(111110),v=e.i(41931);function j({errorItemId:e,onSaved:a,onCancel:n}){let{t:l}=(0,b.b)(),{timeZone:d}=(0,r.M)(),o=(0,i.r)(new Date,"yyyy-MM-dd",d),[m,u]=(0,s.useState)(null),[f,h]=(0,s.useState)(o),[N,w]=(0,s.useState)(!1),[k,$]=(0,s.useState)(null),S=async()=>{if(m&&f){w(!0),$(null);try{await v.f.post("/api/practice/record",{errorItemId:e,result:m,source:"manual",takenAt:(0,i.$)(f,d)}),a()}catch{$(l.mastery.resultSaveFailed)}finally{w(!1)}}};return(0,t.jsxs)("div",{className:"space-y-3 rounded-md border bg-muted/30 p-3",children:[(0,t.jsx)(y.f,{value:m,onChange:u,disabled:N}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,t.jsx)("label",{htmlFor:`practice-date-${e}`,className:"text-sm font-medium",children:l.mastery.recordDate}),(0,t.jsx)(g.f,{id:`practice-date-${e}`,type:"date",value:f,max:o,onChange:e=>h(e.target.value),className:"sm:w-48"}),(0,t.jsxs)("div",{className:"flex gap-2 sm:ml-auto",children:[(0,t.jsx)(x.f,{variant:"outline",size:"sm",onClick:n,disabled:N,className:"flex-1 sm:flex-none",children:l.exam.cancel}),(0,t.jsxs)(x.f,{size:"sm",onClick:S,disabled:N||!m||!f,className:"flex-1 sm:flex-none",children:[N?(0,t.jsx)(c.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(p.f,{className:"mr-2 h-4 w-4"}),l.mastery.saveResult]})]})]}),k&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:k})]})}var N=e.i(149704),w=e.i(294114),k=e.i(905110);let $={correct:"bg-green-100 text-green-700 border-green-200",wrong:"bg-red-100 text-red-700 border-red-200",not_attempted:"bg-amber-100 text-amber-700 border-amber-200"};e.s(["K",0,function({errorItemId:e,onMasteryStatusChange:p}){let{timeZone:g}=(0,r.M)(),{t:y}=(0,b.b)(),[S,M]=(0,s.useState)(null),[C,T]=(0,s.useState)(null),[A,E]=(0,s.useState)(0),[R,_]=(0,s.useState)(!1),z=(0,s.useCallback)(()=>{v.f.get(`/api/error-items/${e}/practice-records`).then(e=>{M(e),p?.(e.masteryStatus)}).catch(()=>void 0)},[e,p]);(0,s.useEffect)(z,[z]);let D=()=>{E(0),z()},H=async e=>{if(await (0,w.u)(y.mastery.deleteRecordConfirm,{destructive:!0}))try{await v.f.delete(`/api/practice/record/${e}`),D()}catch{w.c.error(y.mastery.deleteRecordFailed)}},U=S?.records[0],q=!!U&&(!S?.masteryEvaluatedAt||new Date(U.createdAt)>new Date(S.masteryEvaluatedAt));if((0,s.useEffect)(()=>{if(!q||A>=20)return;let e=setTimeout(()=>{E(e=>e+1),z()},4e3);return()=>clearTimeout(e)},[q,A,z]),!S)return null;let I=S.masteryProbability,L=null===I?null:Math.round(100*I),P=null===L?"":(0,k.m)(I,S.masteryThreshold)?"bg-green-500":L>=30?"bg-amber-500":"bg-red-500",F=y.practice.difficulty;return(0,t.jsxs)(f.N,{children:[(0,t.jsx)(f.Y,{children:(0,t.jsxs)(f.v,{className:"flex items-center gap-2 text-base",children:[(0,t.jsx)(o.f,{className:"h-4 w-4 text-primary"}),y.mastery.probability]})}),(0,t.jsxs)(f.O,{className:"space-y-4",children:[null===L?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:q?y.mastery.pending:y.mastery.notEvaluated}):(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,t.jsxs)("span",{className:"text-3xl font-bold",children:[L,"%"]}),(0,t.jsxs)("span",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[q&&(0,t.jsx)(c.f,{className:"h-3 w-3 animate-spin"}),(0,t.jsx)(u.f,{variant:"outline",children:"ai"===S.masterySource?y.mastery.aiEvaluated:y.mastery.estimated})]})]}),(0,t.jsx)("div",{className:"h-2 w-full rounded-full bg-muted overflow-hidden",children:(0,t.jsx)("div",{className:`h-full ${P} transition-all`,style:{width:`${L}%`}})}),S.masteryReason&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:S.masteryReason}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:y.mastery.thresholdHint.replace("{threshold}",String(S.masteryThreshold))})]}),(0,t.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("h4",{className:"text-sm font-semibold",children:y.mastery.history}),!R&&(0,t.jsxs)(x.f,{variant:"outline",size:"sm",onClick:()=>_(!0),children:[(0,t.jsx)(d.f,{className:"mr-1 h-4 w-4"}),y.mastery.addRecord]})]}),R&&(0,t.jsx)(j,{errorItemId:e,onCancel:()=>_(!1),onSaved:()=>{_(!1),D()}}),0===S.records.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:y.mastery.noHistory}):(0,t.jsx)("ul",{className:"divide-y rounded-md border",children:S.records.map(e=>(0,t.jsxs)("li",{className:"p-3 text-sm space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 flex-wrap items-center gap-2 text-left",onClick:()=>T(C===e.id?null:e.id),children:[(0,t.jsx)("span",{className:"text-muted-foreground tabular-nums",children:(0,i.r)(e.createdAt,"yyyy-MM-dd HH:mm",g)}),(0,t.jsx)(u.f,{variant:"outline",className:$[e.result]||"",children:y.mastery.results[e.result]||e.result}),e.difficulty&&(0,t.jsx)(u.f,{variant:"secondary",children:F[e.difficulty]||e.difficulty}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:e.exam?`${y.mastery.sources.exam} \xb7 ${e.exam.title}`:y.mastery.sources[e.source]||y.mastery.sources.practice}),e.questionText&&(0,t.jsx)("span",{className:"ml-auto text-muted-foreground",children:C===e.id?(0,t.jsx)(l.f,{className:"h-4 w-4"}):(0,t.jsx)(n.f,{className:"h-4 w-4"})})]}),(0,t.jsx)("button",{type:"button","aria-label":y.mastery.deleteRecord,title:y.mastery.deleteRecord,className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-red-50 hover:text-red-600",onClick:()=>H(e.id),children:(0,t.jsx)(m.f,{className:"h-4 w-4"})})]}),C===e.id&&e.questionText&&(0,t.jsxs)("div",{className:"space-y-2 rounded-md bg-muted/40 p-3",children:[(0,t.jsx)(h.f,{content:e.questionText}),(0,t.jsx)(N.f,{svg:e.figureSvg}),e.wrongAnswerText&&(0,t.jsxs)("div",{className:"border-t pt-2",children:[(0,t.jsx)("p",{className:"mb-1 font-medium",children:y.editor.wrongAnswerText}),(0,t.jsx)(h.f,{content:e.wrongAnswerText})]}),e.mistakeAnalysis&&(0,t.jsxs)("div",{className:"border-t pt-2",children:[(0,t.jsx)("p",{className:"mb-1 font-medium",children:y.editor.mistakeAnalysis}),(0,t.jsx)(h.f,{content:e.mistakeAnalysis})]}),e.originalImageUrl&&(0,t.jsx)("img",{src:e.originalImageUrl,alt:y.editor.wrongAnswerText,className:"max-h-96 max-w-full rounded object-contain"}),e.answerText&&(0,t.jsx)("div",{className:"border-t pt-2",children:(0,t.jsx)(h.f,{content:e.answerText,className:"font-semibold"})}),e.exam&&(0,t.jsx)(a.default,{href:`/exams/${e.exam.paperId}`,className:"text-xs text-primary hover:underline",children:e.exam.title})]})]},e.id))})]})]})]})},"x",0,$],991686);var S=e.i(908821);e.s(["f",()=>S.f],868983)},846968,e=>{var t=e.i(843476),s=e.i(269638),a=e.i(503116),r=e.i(16715),i=e.i(487486),n=e.i(111110);let l={new:{className:"bg-warning/15 text-amber-700 dark:text-warning",icon:a.f},reviewing:{className:"bg-primary/10 text-primary",icon:r.f},mastered:{className:"bg-success/15 text-success",icon:s.f}};e.s(["o",0,{new:"border-l-warning/70",reviewing:"border-l-primary/60",mastered:"border-l-success/70"},"x",0,function({status:e,className:s=""}){let{t:a}=(0,n.b)(),{className:r,icon:c}=l[e],d="mastered"===e?a.notebook.mastered:"reviewing"===e?a.notebook.reviewing:a.notebook.review;return(0,t.jsx)(i.f,{variant:"secondary",className:`${r} ${s}`,children:(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(c,{className:"h-3 w-3"})," ",d]})})}])},393733,e=>{var t=e.i(843476),s=e.i(269638);let a=(0,e.i(475254).f)("circle-question-mark",[["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"}]]);var r=e.i(373884),i=e.i(111110);let n=[{value:"correct",icon:s.f,active:"border-green-600 bg-green-50 text-green-700"},{value:"wrong",icon:r.f,active:"border-red-600 bg-red-50 text-red-700"},{value:"not_attempted",icon:a,active:"border-amber-600 bg-amber-50 text-amber-700"}];e.s(["f",0,function({value:e,onChange:s,disabled:a,size:r="md"}){let{t:l}=(0,i.b)(),c="sm"===r?"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:()=>s(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"===r?"h-3 w-3":"h-4 w-4"}),l.mastery.results[i]]},i))})}],393733)},149704,e=>{var t=e.i(843476),s=e.i(111110),a=e.i(975157);e.s(["f",0,function({svg:e,className:r}){let{t:i}=(0,s.b)();return e?(0,t.jsx)("figure",{className:(0,a.f)("question-figure my-3",r),children:(0,t.jsx)("img",{src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,alt:i.figure.alt,className:"mx-auto block h-auto max-w-full rounded border bg-white p-2",style:{maxHeight:360}})}):null}],149704)},574041,e=>{var t=e.i(843476),s=e.i(271645),a=e.i(37727),r=e.i(487486),i=e.i(793479),n=e.i(41931),l=e.i(201276);e.s(["f",0,function({value:e=[],onChange:c,placeholder:d="Enter tags...",className:o="",enterHint:m,subject:u,gradeStage:x}){let[f,h]=(0,s.useState)(""),[p,g]=(0,s.useState)([]),[y,b]=(0,s.useState)(!1),[v,j]=(0,s.useState)(0),N=(0,s.useRef)(null),w=(0,s.useRef)(null),k=(0,s.useCallback)(async t=>{try{let s=new URLSearchParams({q:t});u&&s.append("subject",u),x&&s.append("stage",x);let a=((await n.f.get(`/api/tags/suggestions?${s.toString()}`)).suggestions||[]).filter(t=>!e.includes(t));g(a.slice(0,20)),b(a.length>0),j(0)}catch(e){l.f.error("[TagInput]","Failed to fetch suggestions",{error:e})}},[u,x,e]);(0,s.useEffect)(()=>{f.trim()&&k(f)},[f,k]);let $=t=>{t.trim()&&!e.includes(t.trim())&&(c([...e,t.trim()]),h(""),g([]),b(!1),j(0))},S=t=>{c(e.filter(e=>e!==t))};return(0,s.useEffect)(()=>{let e=e=>{!w.current||w.current.contains(e.target)||N.current?.contains(e.target)||b(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{className:`relative ${o}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 border rounded-lg bg-background min-h-[42px]",children:[e.map(e=>(0,t.jsxs)(r.f,{variant:"secondary",className:"flex items-center gap-1 px-2 py-1",children:[e,(0,t.jsx)("button",{type:"button",onClick:()=>S(e),className:"hover:text-destructive ml-1",children:(0,t.jsx)(a.X,{className:"h-3 w-3"})})]},e)),(0,t.jsx)(i.f,{ref:N,type:"text",value:f,onChange:e=>{h(e.target.value),e.target.value.trim()||(g([]),b(!1))},onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),v>=0&&p[v]?$(p[v]):f.trim()&&$(f)):"ArrowDown"===t.key?(t.preventDefault(),j(e=>Math.min(e+1,p.length-1))):"ArrowUp"===t.key?(t.preventDefault(),j(e=>Math.max(e-1,0))):"Escape"===t.key?(b(!1),j(0)):"Backspace"===t.key&&!f&&e.length>0&&S(e[e.length-1])},onFocus:()=>{p.length>0&&b(!0)},placeholder:0===e.length?d:"",className:"flex-1 min-w-[120px] border-none focus-visible:ring-0 focus-visible:ring-offset-0 h-8 px-0"})]}),y&&p.length>0&&(0,t.jsx)("div",{ref:w,className:"absolute z-50 w-full mt-1 bg-popover border rounded-md shadow-md max-h-48 overflow-y-auto",children:p.map((e,s)=>(0,t.jsx)("div",{className:`px-3 py-2 cursor-pointer hover:bg-accent ${s===v?"bg-accent":""}`,onClick:()=>$(e),onMouseEnter:()=>j(s),children:e},e))}),f&&!y&&(0,t.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:m?`${m} "${f}"`:`Press Enter to create "${f}"`})]})}])},515288,e=>{var t=e.i(843476),s=e.i(975157);e.s(["N",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card",className:(0,s.f)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...a})},"O",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,s.f)("px-6",e),...a})},"u",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,s.f)("text-muted-foreground text-sm",e),...a})},"Y",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,s.f)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...a})},"v",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,s.f)("leading-none font-semibold",e),...a})}])},912505,e=>{var t=e.i(843476),s=e.i(975157);e.s(["f",0,function({icon:e,title:a,description:r,action:i,className:n}){return(0,t.jsxs)("div",{className:(0,s.f)("flex flex-col items-center justify-center rounded-2xl border border-dashed bg-card/50 px-6 py-14 text-center",n),children:[(0,t.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-accent text-accent-foreground",children:(0,t.jsx)(e,{className:"h-7 w-7"})}),(0,t.jsx)("p",{className:"font-medium",children:a}),r&&(0,t.jsx)("p",{className:"mt-1 max-w-sm text-sm text-muted-foreground",children:r}),i&&(0,t.jsx)("div",{className:"mt-5",children:i})]})}])},86963,e=>{var t=e.i(843476),s=e.i(531278);e.s(["f",0,function({label:e}){return(0,t.jsxs)("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,t.jsx)(s.f,{className:"h-7 w-7 animate-spin text-primary"}),e&&(0,t.jsx)("p",{className:"text-sm",children:e})]})}])},990745,e=>{e.s(["f",0,function(e){if(e.tags&&e.tags.length>0)return e.tags.map(e=>e.name);if(!e.knowledgePoints)return[];try{let t=JSON.parse(e.knowledgePoints);return Array.isArray(t)?t.filter(e=>"string"==typeof e):[]}catch{return[]}}])},952122,e=>{e.i(306831),e.s(["f",0,function(e){if(!e)return null;let t=e.toLowerCase();return t.includes("math")||t.includes("数学")?"math":t.includes("physics")||t.includes("物理")?"physics":t.includes("chemistry")||t.includes("化学")?"chemistry":t.includes("biology")||t.includes("生物")?"biology":t.includes("english")||t.includes("英语")?"english":t.includes("chinese")||t.includes("语文")?"chinese":t.includes("history")||t.includes("历史")?"history":t.includes("geography")||t.includes("地理")?"geography":t.includes("politics")||t.includes("政治")?"politics":null}])},35209,e=>{var t=e.i(271645),s=e.i(111110);e.s(["f",0,function(...e){let{t:a}=(0,s.b)(),r=[a.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,t.useEffect)(()=>{document.title=r},[r])}])}])})();
@@ -1 +1 @@
1
- (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63804,e=>{let t=(0,e.i(475254).f)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]);e.s(["f",0,t],63804)},356909,e=>{let t=(0,e.i(475254).f)("save",[["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"}]]);e.s(["f",0,t],356909)},283086,e=>{let t=(0,e.i(475254).f)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);e.s(["f",0,t],283086)},620278,e=>{let t=(0,e.i(475254).f)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);e.s(["f",0,t],620278)},952683,e=>{var t=e.i(843476),s=e.i(271645),a=e.i(618566),i=e.i(968553),n=e.i(674558),r=e.i(283086),l=e.i(747819),o=e.i(178119),c=e.i(515288),d=e.i(519455),u=e.i(624687),m=e.i(110204),h=e.i(356909),x=e.i(531278),p=e.i(286536),f=e.i(185873),f=f,g=e.i(367240),v=e.i(111110),y=e.i(511445),b=e.i(574041),j=e.i(438465),w=e.i(967489),k=e.i(952122),N=e.i(294114);function S({onSubmit:e,defaultNotebookId:a,defaultNotebookName:i,isSaving:r}){let{t:l}=(0,v.b)(),[o,C]=(0,s.useState)(null),[E,A]=(0,s.useState)(""),[T,P]=(0,s.useState)(""),[I,H]=(0,s.useState)(""),[M,$]=(0,s.useState)(""),[z,q]=(0,s.useState)(""),[D,L]=(0,s.useState)("unknown"),[_,B]=(0,s.useState)([]),[U,F]=(0,s.useState)(a||""),[R,K]=(0,s.useState)(""),[O,V]=(0,s.useState)("a"),W=async()=>{if(E.trim()){if(!U)return void N.c.warning(l.editor.messages?.selectNotebook||"Please select a notebook");await e({questionText:E.trim(),answerText:T.trim(),analysis:I.trim(),wrongAnswerText:M.trim(),mistakeAnalysis:z.trim(),mistakeStatus:D,knowledgePoints:_,subjectId:U,gradeSemester:R||void 0,paperLevel:O})}},Q=e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),E.trim()&&U&&!r&&W())},G=[{key:"question",label:l.editor?.question||"Question Text",value:E,setter:A,placeholder:l.directEntry.questionPlaceholder,minHeight:"min-h-[180px]",required:!0},{key:"answer",label:l.editor?.answer||"Answer",value:T,setter:P,placeholder:l.directEntry.answerPlaceholder,minHeight:"min-h-[120px]"},{key:"analysis",label:l.editor?.analysis||"Analysis / Explanation",value:I,setter:H,placeholder:l.directEntry.analysisPlaceholder,minHeight:"min-h-[150px]"},{key:"wrongAnswer",label:l.editor?.wrongAnswerText||"Wrong Answer / Work",value:M,setter:$,placeholder:l.directEntry.wrongAnswerPlaceholder,minHeight:"min-h-[100px]"},{key:"mistakeAnalysis",label:l.editor?.mistakeAnalysis||"Mistake Cause Analysis",value:z,setter:q,placeholder:l.directEntry.mistakeAnalysisPlaceholder,minHeight:"min-h-[100px]"}];return(0,t.jsx)(c.N,{className:"rounded-2xl",children:(0,t.jsxs)(c.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)(n.f,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:l.directEntry.title})]}),(0,t.jsxs)(d.f,{variant:"ghost",size:"sm",onClick:()=>{A(""),P(""),H(""),$(""),q(""),L("unknown"),B([]),K(""),V("a")},disabled:r,className:"text-muted-foreground hover:text-destructive",children:[(0,t.jsx)(g.f,{className:"h-4 w-4 mr-1"}),l.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)(m.f,{children:[l.editor?.selectNotebook||"Select Notebook"," *"]}),(0,t.jsx)(j.f,{value:U,onChange:F})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(m.f,{children:l.editor?.gradeSemester||"Grade/Semester"}),(0,t.jsx)("input",{type:"text",value:R,onChange:e=>K(e.target.value),placeholder:l.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)(m.f,{children:l.editor?.paperLevel||"Paper Level"}),(0,t.jsxs)(w.d,{value:O,onValueChange:V,children:[(0,t.jsx)(w.P,{children:(0,t.jsx)(w.U,{})}),(0,t.jsxs)(w.r,{children:[(0,t.jsx)(w.T,{value:"a",children:l.editor?.paperLevels?.a||"Paper A"}),(0,t.jsx)(w.T,{value:"b",children:l.editor?.paperLevels?.b||"Paper B"}),(0,t.jsx)(w.T,{value:"other",children:l.editor?.paperLevels?.other||"Other"})]})]})]})]}),G.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)(m.f,{className:e.required?"text-primary font-semibold":"",children:[e.label," ",e.required&&"*"]}),(0,t.jsx)(d.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>C(o===e.key?null:e.key),disabled:!e.value,children:o===e.key?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(f.f,{className:"h-3 w-3 mr-1"}),l.directEntry.edit]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.f,{className:"h-3 w-3 mr-1"}),l.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:()=>C(null),children:(0,t.jsx)(y.f,{content:e.value})}):(0,t.jsx)(u.f,{value:e.value,onChange:t=>e.setter(t.target.value),onKeyDown:Q,placeholder:e.placeholder,className:`${e.minHeight} font-mono text-sm resize-y`,disabled:r})]},e.key)),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(m.f,{children:l.editor?.mistakeStatus||"Attempt Status"}),(0,t.jsxs)(w.d,{value:D,onValueChange:e=>L(e),children:[(0,t.jsx)(w.P,{className:"w-[200px]",children:(0,t.jsx)(w.U,{})}),(0,t.jsxs)(w.r,{children:[(0,t.jsx)(w.T,{value:"not_attempted",children:l.editor?.mistakeStatuses?.notAttempted||"Not attempted"}),(0,t.jsx)(w.T,{value:"wrong_attempt",children:l.editor?.mistakeStatuses?.wrongAttempt||"Wrong attempt"}),(0,t.jsx)(w.T,{value:"unknown",children:l.editor?.mistakeStatuses?.unknown||"Unknown"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(m.f,{children:l.editor?.tags||"Knowledge Points (Press Enter to add)"}),(0,t.jsx)(b.f,{value:_,onChange:B,placeholder:l.editor?.tagsPlaceholder||"Enter knowledge tags, select from suggestions...",enterHint:l.editor?.createTagHint,subject:(0,k.f)(i||null)||void 0}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:l.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)(d.f,{onClick:W,disabled:!E.trim()||!U||r,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:r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),l.directEntry.saving]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h.f,{className:"mr-2 h-4 w-4"}),l.directEntry.save]})}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground text-center",children:l.directEntry.hint})]})]})})}var C=e.i(522016),E=e.i(217255),A=e.i(810980),T=e.i(551804),P=e.i(63804),I=e.i(620278);let H=()=>()=>{};function M({href:e,icon:s,label:a,value:i}){return(0,t.jsxs)(C.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)(s,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:a})]}),(0,t.jsx)("div",{className:"mt-1 text-2xl font-bold tabular-nums",children:i??"–"})]})}function $({notebookCount:e,itemCount:a,dueCount:i,targetNotebook:n}){let{t:r,language:l}=(0,v.b)(),{data:o}=(0,E.useSession)(),c=(0,s.useSyncExternalStore)(H,()=>new Date().getHours(),()=>null),d=null===c?r.common.welcome.replace(/[,,\s]+$/,""):c<12?r.home.greetingMorning:c<18?r.home.greetingAfternoon:r.home.greetingEvening,u=o?.user?.name||o?.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,u&&`${"zh"===l?",":", "}${u}`]}),(0,t.jsx)("p",{className:"max-w-md text-sm text-white/80",children:r.home.heroSubtitle}),n&&(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)(I.f,{className:"h-3.5 w-3.5"}),r.home.targetNotebook.replace("{name}",n)]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-3 md:w-96",children:[(0,t.jsx)(M,{href:"/notebooks",icon:A.f,label:r.home.notebookCount,value:e}),(0,t.jsx)(M,{href:"/notebooks",icon:P.f,label:r.home.itemCount,value:a}),(0,t.jsx)(M,{href:"/review",icon:T.f,label:r.home.dueCount,value:i})]})]})]})}var z=e.i(12130),q=e.i(430634),D=e.i(717448),L=e.i(798469),_=e.i(86963),B=e.i(956738),U=e.i(185592),F=e.i(41931),R=e.i(201276),K=e.i(35209),O=e.i(267275);function V(){let{t:e}=(0,v.b)();(0,K.f)(e.pageTitle.home);let c=(0,a.useSearchParams)().get("notebook"),[d,u]=(0,s.useState)([]),[m,h]=(0,s.useState)(null),[x,p]=(0,s.useState)(null),[f,g]=(0,s.useState)("image"),y=c||m,b=y?d.find(e=>e.id===y):void 0,j=(0,O.f)({logPrefix:"[Home]",analyzeSubjectId:y,importSubjectId:c,textNotebook:b&&{id:b.id,name:b.name},onParsed:e=>{let t=e.subject&&d.find(t=>t.name.includes(e.subject)||e.subject.includes(t.name));t&&h(t.id)}});(0,s.useEffect)(()=>{F.f.get("/api/notebooks").then(e=>u(e)).catch(e=>R.f.error("[Home]","Failed to fetch notebooks",{error:e})),F.f.get("/api/review/due?pageSize=1").then(e=>p(e.total)).catch(e=>R.f.error("[Home]","Failed to fetch due reviews",{error:e}))},[]);let w=async e=>{j.setAnalysisStep("saving"),await j.saveQuestion({...e,wrongAnswerText:e.wrongAnswerText||null,mistakeAnalysis:e.mistakeAnalysis||null,mistakeStatus:e.mistakeStatus||"unknown",originalImageUrl:""}),j.setAnalysisStep("idle")},k=d.reduce((e,t)=>e+(t._count?.errorItems||0),0),N=[{value:"image",icon:i.f,label:e.app?.uploadImage||"Take Photo"},{value:"text",icon:r.f,label:e.app?.manualInput||"Manual Input"},{value:"direct",icon:n.f,label:e.app?.directInput||"Manual Entry"}];return(0,t.jsxs)("main",{className:"min-h-screen",children:[(0,t.jsx)(B.f,{status:j.analysisStep}),(0,t.jsxs)("div",{className:`mx-auto space-y-6 px-4 py-6 md:px-8 md:py-8 ${"review"===j.step?"max-w-6xl":"max-w-4xl"}`,children:["upload"===j.step&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)($,{notebookCount:d.length,itemCount:k,dueCount:x,targetNotebook:c?b?.name:void 0}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(U.f,{options:N,value:f,onChange:g}),j.lastImported&&(0,t.jsx)(q.f,{imported:j.lastImported,onDismiss:j.dismissImported}),j.batchBlobs?(0,t.jsx)(l.f,{blobs:j.batchBlobs,subjectId:c,timeout:j.aiTimeout,onClose:j.closeBatch}):"image"===f?(0,t.jsx)(L.f,{onImageSelect:j.selectImage,isAnalyzing:j.isBusy}):"text"===f?(0,t.jsx)(D.f,{onSubmit:j.submitText,isAnalyzing:j.isBusy,defaultNotebookName:b?.name}):(0,t.jsx)(S,{onSubmit:w,defaultNotebookId:y||void 0,defaultNotebookName:b?.name,isSaving:"saving"===j.analysisStep})]})]}),j.croppingImage&&(0,t.jsx)(z.f,{imageSrc:j.croppingImage,open:j.isCropperOpen,onClose:j.closeCropper,onCropComplete:j.cropComplete,onMultiCropComplete:j.startBatch}),"review"===j.step&&j.parsedData&&(0,t.jsx)(o.f,{initialData:j.parsedData,onSave:j.saveReviewed,onCancel:j.cancelReview,imagePreview:j.currentImage,initialSubjectId:y||void 0,aiTimeout:j.aiTimeout})]})]})}e.s(["default",0,function(){return(0,t.jsx)(s.Suspense,{fallback:(0,t.jsx)(_.f,{}),children:(0,t.jsx)(V,{})})}],952683)},469937,62825,e=>{var t=e.i(843476);let s=(0,e.i(475254).f)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);var a=e.i(111110),i=e.i(975157);let n=[1,2,3,4,5];function r(e){return"not_attempted"===e||"wrong_attempt"===e||"unknown"===e?e:"unknown"}e.s(["f",0,function({value:e,onChange:r,disabled:l,size:o="sm",showUnrated:c=!0,className:d}){let{t:u}=(0,a.b)(),m=e??0,h="sm"===o?"h-3.5 w-3.5":"h-5 w-5",x=m?u.difficulty.starsLabel.replace("{n}",String(m)):u.difficulty.unrated;return r?(0,t.jsxs)("span",{className:(0,i.f)("inline-flex items-center gap-0.5",d),role:"group","aria-label":`${u.difficulty.label}:${x}`,title:u.difficulty.clearHint,children:[n.map(e=>(0,t.jsx)("button",{type:"button",disabled:l,onClick:()=>r(e===m?null:e),"aria-label":u.difficulty.setStars.replace("{n}",String(e)),"aria-pressed":e<=m,className:"rounded p-0.5 hover:bg-muted disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(s,{className:(0,i.f)(h,e<=m?"fill-amber-400 text-amber-400":"text-muted-foreground/40")})},e)),!m&&c&&(0,t.jsx)("span",{className:"ml-1 text-xs text-muted-foreground",children:u.difficulty.unrated})]}):m?(0,t.jsx)("span",{className:(0,i.f)("inline-flex items-center",d),role:"img","aria-label":`${u.difficulty.label}:${x}`,title:x,children:n.map(e=>(0,t.jsx)(s,{className:(0,i.f)(h,e<=m?"fill-amber-400 text-amber-400":"text-muted-foreground/30"),"aria-hidden":!0},e))}):c?(0,t.jsx)("span",{className:(0,i.f)("text-xs text-muted-foreground",d),children:u.difficulty.unrated}):null}],469937),e.s(["i",0,function(e,t="zh"){return("en"===t?{not_attempted:"Not attempted",wrong_attempt:"Wrong attempt",unknown:"Unknown"}:{not_attempted:"不会做",wrong_attempt:"做错了",unknown:"未判断"})[r(e)]},"h",0,r,"x",0,function(e,t){return(t||"").trim()?"wrong_attempt":r(e)}],62825)},149704,e=>{var t=e.i(843476),s=e.i(111110),a=e.i(975157);e.s(["f",0,function({svg:e,className:i}){let{t:n}=(0,s.b)();return e?(0,t.jsx)("figure",{className:(0,a.f)("question-figure my-3",i),children:(0,t.jsx)("img",{src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,alt:n.figure.alt,className:"mx-auto block h-auto max-w-full rounded border bg-white p-2",style:{maxHeight:360}})}):null}],149704)},574041,e=>{var t=e.i(843476),s=e.i(271645),a=e.i(37727),i=e.i(487486),n=e.i(793479),r=e.i(41931),l=e.i(201276);e.s(["f",0,function({value:e=[],onChange:o,placeholder:c="Enter tags...",className:d="",enterHint:u,subject:m,gradeStage:h}){let[x,p]=(0,s.useState)(""),[f,g]=(0,s.useState)([]),[v,y]=(0,s.useState)(!1),[b,j]=(0,s.useState)(0),w=(0,s.useRef)(null),k=(0,s.useRef)(null),N=(0,s.useCallback)(async t=>{try{let s=new URLSearchParams({q:t});m&&s.append("subject",m),h&&s.append("stage",h);let a=((await r.f.get(`/api/tags/suggestions?${s.toString()}`)).suggestions||[]).filter(t=>!e.includes(t));g(a.slice(0,20)),y(a.length>0),j(0)}catch(e){l.f.error("[TagInput]","Failed to fetch suggestions",{error:e})}},[m,h,e]);(0,s.useEffect)(()=>{x.trim()&&N(x)},[x,N]);let S=t=>{t.trim()&&!e.includes(t.trim())&&(o([...e,t.trim()]),p(""),g([]),y(!1),j(0))},C=t=>{o(e.filter(e=>e!==t))};return(0,s.useEffect)(()=>{let e=e=>{!k.current||k.current.contains(e.target)||w.current?.contains(e.target)||y(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{className:`relative ${d}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 border rounded-lg bg-background min-h-[42px]",children:[e.map(e=>(0,t.jsxs)(i.f,{variant:"secondary",className:"flex items-center gap-1 px-2 py-1",children:[e,(0,t.jsx)("button",{type:"button",onClick:()=>C(e),className:"hover:text-destructive ml-1",children:(0,t.jsx)(a.X,{className:"h-3 w-3"})})]},e)),(0,t.jsx)(n.f,{ref:w,type:"text",value:x,onChange:e=>{p(e.target.value),e.target.value.trim()||(g([]),y(!1))},onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),b>=0&&f[b]?S(f[b]):x.trim()&&S(x)):"ArrowDown"===t.key?(t.preventDefault(),j(e=>Math.min(e+1,f.length-1))):"ArrowUp"===t.key?(t.preventDefault(),j(e=>Math.max(e-1,0))):"Escape"===t.key?(y(!1),j(0)):"Backspace"===t.key&&!x&&e.length>0&&C(e[e.length-1])},onFocus:()=>{f.length>0&&y(!0)},placeholder:0===e.length?c:"",className:"flex-1 min-w-[120px] border-none focus-visible:ring-0 focus-visible:ring-offset-0 h-8 px-0"})]}),v&&f.length>0&&(0,t.jsx)("div",{ref:k,className:"absolute z-50 w-full mt-1 bg-popover border rounded-md shadow-md max-h-48 overflow-y-auto",children:f.map((e,s)=>(0,t.jsx)("div",{className:`px-3 py-2 cursor-pointer hover:bg-accent ${s===b?"bg-accent":""}`,onClick:()=>S(e),onMouseEnter:()=>j(s),children:e},e))}),x&&!v&&(0,t.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:u?`${u} "${x}"`:`Press Enter to create "${x}"`})]})}])},515288,e=>{var t=e.i(843476),s=e.i(975157);e.s(["N",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card",className:(0,s.f)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...a})},"O",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,s.f)("px-6",e),...a})},"u",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,s.f)("text-muted-foreground text-sm",e),...a})},"Y",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,s.f)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...a})},"v",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,s.f)("leading-none font-semibold",e),...a})}])},86963,e=>{var t=e.i(843476),s=e.i(531278);e.s(["f",0,function({label:e}){return(0,t.jsxs)("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,t.jsx)(s.f,{className:"h-7 w-7 animate-spin text-primary"}),e&&(0,t.jsx)("p",{className:"text-sm",children:e})]})}])},952122,e=>{e.i(306831),e.s(["f",0,function(e){if(!e)return null;let t=e.toLowerCase();return t.includes("math")||t.includes("数学")?"math":t.includes("physics")||t.includes("物理")?"physics":t.includes("chemistry")||t.includes("化学")?"chemistry":t.includes("biology")||t.includes("生物")?"biology":t.includes("english")||t.includes("英语")?"english":t.includes("chinese")||t.includes("语文")?"chinese":t.includes("history")||t.includes("历史")?"history":t.includes("geography")||t.includes("地理")?"geography":t.includes("politics")||t.includes("政治")?"politics":null}])},35209,e=>{var t=e.i(271645),s=e.i(111110);e.s(["f",0,function(...e){let{t:a}=(0,s.b)(),i=[a.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,t.useEffect)(()=>{document.title=i},[i])}])}])})();
1
+ (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63804,e=>{let t=(0,e.i(475254).f)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]);e.s(["f",0,t],63804)},356909,e=>{let t=(0,e.i(475254).f)("save",[["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"}]]);e.s(["f",0,t],356909)},283086,e=>{let t=(0,e.i(475254).f)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);e.s(["f",0,t],283086)},620278,e=>{let t=(0,e.i(475254).f)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);e.s(["f",0,t],620278)},952683,e=>{var t=e.i(843476),s=e.i(271645),a=e.i(618566),i=e.i(968553),n=e.i(674558),r=e.i(283086),l=e.i(747819),o=e.i(178119),c=e.i(515288),d=e.i(519455),u=e.i(624687),m=e.i(110204),h=e.i(356909),x=e.i(531278),p=e.i(286536),f=e.i(185873),f=f,g=e.i(367240),v=e.i(111110),y=e.i(511445),b=e.i(574041),j=e.i(438465),w=e.i(967489),k=e.i(952122),N=e.i(294114);function S({onSubmit:e,defaultNotebookId:a,defaultNotebookName:i,isSaving:r}){let{t:l}=(0,v.b)(),[o,C]=(0,s.useState)(null),[E,A]=(0,s.useState)(""),[T,P]=(0,s.useState)(""),[I,$]=(0,s.useState)(""),[H,M]=(0,s.useState)(""),[z,q]=(0,s.useState)(""),[D,L]=(0,s.useState)("unknown"),[_,B]=(0,s.useState)([]),[U,F]=(0,s.useState)(a||""),[R,K]=(0,s.useState)(""),[O,V]=(0,s.useState)("a"),W=async()=>{if(E.trim()){if(!U)return void N.c.warning(l.editor.messages?.selectNotebook||"Please select a notebook");await e({questionText:E.trim(),answerText:T.trim(),analysis:I.trim(),wrongAnswerText:H.trim(),mistakeAnalysis:z.trim(),mistakeStatus:D,knowledgePoints:_,subjectId:U,gradeSemester:R||void 0,paperLevel:O})}},Q=e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),E.trim()&&U&&!r&&W())},G=[{key:"question",label:l.editor?.question||"Question Text",value:E,setter:A,placeholder:l.directEntry.questionPlaceholder,minHeight:"min-h-[180px]",required:!0},{key:"answer",label:l.editor?.answer||"Answer",value:T,setter:P,placeholder:l.directEntry.answerPlaceholder,minHeight:"min-h-[120px]"},{key:"analysis",label:l.editor?.analysis||"Analysis / Explanation",value:I,setter:$,placeholder:l.directEntry.analysisPlaceholder,minHeight:"min-h-[150px]"},{key:"wrongAnswer",label:l.editor?.wrongAnswerText||"Wrong Answer / Work",value:H,setter:M,placeholder:l.directEntry.wrongAnswerPlaceholder,minHeight:"min-h-[100px]"},{key:"mistakeAnalysis",label:l.editor?.mistakeAnalysis||"Mistake Cause Analysis",value:z,setter:q,placeholder:l.directEntry.mistakeAnalysisPlaceholder,minHeight:"min-h-[100px]"}];return(0,t.jsx)(c.N,{className:"rounded-2xl",children:(0,t.jsxs)(c.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)(n.f,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:l.directEntry.title})]}),(0,t.jsxs)(d.f,{variant:"ghost",size:"sm",onClick:()=>{A(""),P(""),$(""),M(""),q(""),L("unknown"),B([]),K(""),V("a")},disabled:r,className:"text-muted-foreground hover:text-destructive",children:[(0,t.jsx)(g.f,{className:"h-4 w-4 mr-1"}),l.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)(m.f,{children:[l.editor?.selectNotebook||"Select Notebook"," *"]}),(0,t.jsx)(j.f,{value:U,onChange:F})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(m.f,{children:l.editor?.gradeSemester||"Grade/Semester"}),(0,t.jsx)("input",{type:"text",value:R,onChange:e=>K(e.target.value),placeholder:l.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)(m.f,{children:l.editor?.paperLevel||"Paper Level"}),(0,t.jsxs)(w.d,{value:O,onValueChange:V,children:[(0,t.jsx)(w.P,{children:(0,t.jsx)(w.U,{})}),(0,t.jsxs)(w.r,{children:[(0,t.jsx)(w.T,{value:"a",children:l.editor?.paperLevels?.a||"Paper A"}),(0,t.jsx)(w.T,{value:"b",children:l.editor?.paperLevels?.b||"Paper B"}),(0,t.jsx)(w.T,{value:"other",children:l.editor?.paperLevels?.other||"Other"})]})]})]})]}),G.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)(m.f,{className:e.required?"text-primary font-semibold":"",children:[e.label," ",e.required&&"*"]}),(0,t.jsx)(d.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>C(o===e.key?null:e.key),disabled:!e.value,children:o===e.key?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(f.f,{className:"h-3 w-3 mr-1"}),l.directEntry.edit]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.f,{className:"h-3 w-3 mr-1"}),l.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:()=>C(null),children:(0,t.jsx)(y.f,{content:e.value})}):(0,t.jsx)(u.f,{value:e.value,onChange:t=>e.setter(t.target.value),onKeyDown:Q,placeholder:e.placeholder,className:`${e.minHeight} font-mono text-sm resize-y`,disabled:r})]},e.key)),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(m.f,{children:l.editor?.mistakeStatus||"Attempt Status"}),(0,t.jsxs)(w.d,{value:D,onValueChange:e=>L(e),children:[(0,t.jsx)(w.P,{className:"w-[200px]",children:(0,t.jsx)(w.U,{})}),(0,t.jsxs)(w.r,{children:[(0,t.jsx)(w.T,{value:"not_attempted",children:l.editor?.mistakeStatuses?.notAttempted||"Not attempted"}),(0,t.jsx)(w.T,{value:"wrong_attempt",children:l.editor?.mistakeStatuses?.wrongAttempt||"Wrong attempt"}),(0,t.jsx)(w.T,{value:"unknown",children:l.editor?.mistakeStatuses?.unknown||"Unknown"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(m.f,{children:l.editor?.tags||"Knowledge Points (Press Enter to add)"}),(0,t.jsx)(b.f,{value:_,onChange:B,placeholder:l.editor?.tagsPlaceholder||"Enter knowledge tags, select from suggestions...",enterHint:l.editor?.createTagHint,subject:(0,k.f)(i||null)||void 0}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:l.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)(d.f,{onClick:W,disabled:!E.trim()||!U||r,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:r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),l.directEntry.saving]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h.f,{className:"mr-2 h-4 w-4"}),l.directEntry.save]})}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground text-center",children:l.directEntry.hint})]})]})})}var C=e.i(522016),E=e.i(217255),A=e.i(810980),T=e.i(551804),P=e.i(63804),I=e.i(620278);let $=()=>()=>{};function H({href:e,icon:s,label:a,value:i}){return(0,t.jsxs)(C.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)(s,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:a})]}),(0,t.jsx)("div",{className:"mt-1 text-2xl font-bold tabular-nums",children:i??"–"})]})}function M({notebookCount:e,itemCount:a,dueCount:i,targetNotebook:n}){let{t:r,language:l}=(0,v.b)(),{data:o}=(0,E.useSession)(),c=(0,s.useSyncExternalStore)($,()=>new Date().getHours(),()=>null),d=null===c?r.common.welcome.replace(/[,,\s]+$/,""):c<12?r.home.greetingMorning:c<18?r.home.greetingAfternoon:r.home.greetingEvening,u=o?.user?.name||o?.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,u&&`${"zh"===l?",":", "}${u}`]}),(0,t.jsx)("p",{className:"max-w-md text-sm text-white/80",children:r.home.heroSubtitle}),n&&(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)(I.f,{className:"h-3.5 w-3.5"}),r.home.targetNotebook.replace("{name}",n)]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-3 md:w-96",children:[(0,t.jsx)(H,{href:"/notebooks",icon:A.f,label:r.home.notebookCount,value:e}),(0,t.jsx)(H,{href:"/notebooks",icon:P.f,label:r.home.itemCount,value:a}),(0,t.jsx)(H,{href:"/review",icon:T.f,label:r.home.dueCount,value:i})]})]})]})}var z=e.i(12130),q=e.i(430634),D=e.i(717448),L=e.i(798469),_=e.i(86963),B=e.i(956738),U=e.i(185592),F=e.i(41931),R=e.i(201276),K=e.i(35209),O=e.i(267275);function V(){let{t:e}=(0,v.b)();(0,K.f)(e.pageTitle.home);let c=(0,a.useSearchParams)().get("notebook"),[d,u]=(0,s.useState)([]),[m,h]=(0,s.useState)(null),[x,p]=(0,s.useState)(null),[f,g]=(0,s.useState)("image"),y=c||m,b=y?d.find(e=>e.id===y):void 0,j=(0,O.f)({logPrefix:"[Home]",analyzeSubjectId:y,importSubjectId:c,textNotebook:b&&{id:b.id,name:b.name},onParsed:e=>{let t=e.subject&&d.find(t=>t.name.includes(e.subject)||e.subject.includes(t.name));t&&h(t.id)}});(0,s.useEffect)(()=>{F.f.get("/api/notebooks").then(e=>u(e)).catch(e=>R.f.error("[Home]","Failed to fetch notebooks",{error:e})),F.f.get("/api/review/due?pageSize=1").then(e=>p(e.total)).catch(e=>R.f.error("[Home]","Failed to fetch due reviews",{error:e}))},[]);let w=async e=>{j.setAnalysisStep("saving"),await j.saveQuestion({...e,wrongAnswerText:e.wrongAnswerText||null,mistakeAnalysis:e.mistakeAnalysis||null,mistakeStatus:e.mistakeStatus||"unknown",originalImageUrl:""}),j.setAnalysisStep("idle")},k=d.reduce((e,t)=>e+(t._count?.errorItems||0),0),N=[{value:"image",icon:i.f,label:e.app?.uploadImage||"Take Photo"},{value:"text",icon:r.f,label:e.app?.manualInput||"Manual Input"},{value:"direct",icon:n.f,label:e.app?.directInput||"Manual Entry"}];return(0,t.jsxs)("main",{className:"min-h-screen",children:[(0,t.jsx)(B.f,{status:j.analysisStep}),(0,t.jsxs)("div",{className:`mx-auto space-y-6 px-4 py-6 md:px-8 md:py-8 ${"review"===j.step?"max-w-6xl":"max-w-4xl"}`,children:["upload"===j.step&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(M,{notebookCount:d.length,itemCount:k,dueCount:x,targetNotebook:c?b?.name:void 0}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(U.f,{options:N,value:f,onChange:g}),j.lastImported&&(0,t.jsx)(q.f,{imported:j.lastImported,onDismiss:j.dismissImported}),j.batchBlobs?(0,t.jsx)(l.f,{blobs:j.batchBlobs,subjectId:c,timeout:j.aiTimeout,onClose:j.closeBatch}):"image"===f?(0,t.jsx)(L.f,{onImageSelect:j.selectImage,isAnalyzing:j.isBusy}):"text"===f?(0,t.jsx)(D.f,{onSubmit:j.submitText,isAnalyzing:j.isBusy,defaultNotebookName:b?.name}):(0,t.jsx)(S,{onSubmit:w,defaultNotebookId:y||void 0,defaultNotebookName:b?.name,isSaving:"saving"===j.analysisStep})]})]}),j.croppingImage&&(0,t.jsx)(z.f,{imageSrc:j.croppingImage,open:j.isCropperOpen,onClose:j.closeCropper,onCropComplete:j.cropComplete,onMultiCropComplete:j.startBatch}),"review"===j.step&&j.parsedData&&(0,t.jsx)(o.f,{initialData:j.parsedData,onSave:j.saveReviewed,onCancel:j.cancelReview,imagePreview:j.currentImage,initialSubjectId:y||void 0,aiTimeout:j.aiTimeout})]})]})}e.s(["default",0,function(){return(0,t.jsx)(s.Suspense,{fallback:(0,t.jsx)(_.f,{}),children:(0,t.jsx)(V,{})})}],952683)},469937,62825,e=>{var t=e.i(843476);let s=(0,e.i(475254).f)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);var a=e.i(111110),i=e.i(975157);let n=[1,2,3,4,5];function r(e){return"not_attempted"===e||"wrong_attempt"===e||"unknown"===e?e:"unknown"}e.s(["f",0,function({value:e,onChange:r,disabled:l,size:o="sm",showUnrated:c=!0,className:d}){let{t:u}=(0,a.b)(),m=e??0,h="sm"===o?"h-3.5 w-3.5":"h-5 w-5",x=m?u.difficulty.starsLabel.replace("{n}",String(m)):u.difficulty.unrated;return r?(0,t.jsxs)("span",{className:(0,i.f)("inline-flex items-center gap-0.5",d),role:"group","aria-label":`${u.difficulty.label}${u.common.colon}${x}`,title:u.difficulty.clearHint,children:[n.map(e=>(0,t.jsx)("button",{type:"button",disabled:l,onClick:()=>r(e===m?null:e),"aria-label":u.difficulty.setStars.replace("{n}",String(e)),"aria-pressed":e<=m,className:"rounded p-0.5 hover:bg-muted disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(s,{className:(0,i.f)(h,e<=m?"fill-amber-400 text-amber-400":"text-muted-foreground/40")})},e)),!m&&c&&(0,t.jsx)("span",{className:"ml-1 text-xs text-muted-foreground",children:u.difficulty.unrated})]}):m?(0,t.jsx)("span",{className:(0,i.f)("inline-flex items-center",d),role:"img","aria-label":`${u.difficulty.label}${u.common.colon}${x}`,title:x,children:n.map(e=>(0,t.jsx)(s,{className:(0,i.f)(h,e<=m?"fill-amber-400 text-amber-400":"text-muted-foreground/30"),"aria-hidden":!0},e))}):c?(0,t.jsx)("span",{className:(0,i.f)("text-xs text-muted-foreground",d),children:u.difficulty.unrated}):null}],469937),e.s(["i",0,function(e,t="zh"){return("en"===t?{not_attempted:"Not attempted",wrong_attempt:"Wrong attempt",unknown:"Unknown"}:{not_attempted:"不会做",wrong_attempt:"做错了",unknown:"未判断"})[r(e)]},"h",0,r,"x",0,function(e,t){return(t||"").trim()?"wrong_attempt":r(e)}],62825)},149704,e=>{var t=e.i(843476),s=e.i(111110),a=e.i(975157);e.s(["f",0,function({svg:e,className:i}){let{t:n}=(0,s.b)();return e?(0,t.jsx)("figure",{className:(0,a.f)("question-figure my-3",i),children:(0,t.jsx)("img",{src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,alt:n.figure.alt,className:"mx-auto block h-auto max-w-full rounded border bg-white p-2",style:{maxHeight:360}})}):null}],149704)},574041,e=>{var t=e.i(843476),s=e.i(271645),a=e.i(37727),i=e.i(487486),n=e.i(793479),r=e.i(41931),l=e.i(201276);e.s(["f",0,function({value:e=[],onChange:o,placeholder:c="Enter tags...",className:d="",enterHint:u,subject:m,gradeStage:h}){let[x,p]=(0,s.useState)(""),[f,g]=(0,s.useState)([]),[v,y]=(0,s.useState)(!1),[b,j]=(0,s.useState)(0),w=(0,s.useRef)(null),k=(0,s.useRef)(null),N=(0,s.useCallback)(async t=>{try{let s=new URLSearchParams({q:t});m&&s.append("subject",m),h&&s.append("stage",h);let a=((await r.f.get(`/api/tags/suggestions?${s.toString()}`)).suggestions||[]).filter(t=>!e.includes(t));g(a.slice(0,20)),y(a.length>0),j(0)}catch(e){l.f.error("[TagInput]","Failed to fetch suggestions",{error:e})}},[m,h,e]);(0,s.useEffect)(()=>{x.trim()&&N(x)},[x,N]);let S=t=>{t.trim()&&!e.includes(t.trim())&&(o([...e,t.trim()]),p(""),g([]),y(!1),j(0))},C=t=>{o(e.filter(e=>e!==t))};return(0,s.useEffect)(()=>{let e=e=>{!k.current||k.current.contains(e.target)||w.current?.contains(e.target)||y(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{className:`relative ${d}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 border rounded-lg bg-background min-h-[42px]",children:[e.map(e=>(0,t.jsxs)(i.f,{variant:"secondary",className:"flex items-center gap-1 px-2 py-1",children:[e,(0,t.jsx)("button",{type:"button",onClick:()=>C(e),className:"hover:text-destructive ml-1",children:(0,t.jsx)(a.X,{className:"h-3 w-3"})})]},e)),(0,t.jsx)(n.f,{ref:w,type:"text",value:x,onChange:e=>{p(e.target.value),e.target.value.trim()||(g([]),y(!1))},onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),b>=0&&f[b]?S(f[b]):x.trim()&&S(x)):"ArrowDown"===t.key?(t.preventDefault(),j(e=>Math.min(e+1,f.length-1))):"ArrowUp"===t.key?(t.preventDefault(),j(e=>Math.max(e-1,0))):"Escape"===t.key?(y(!1),j(0)):"Backspace"===t.key&&!x&&e.length>0&&C(e[e.length-1])},onFocus:()=>{f.length>0&&y(!0)},placeholder:0===e.length?c:"",className:"flex-1 min-w-[120px] border-none focus-visible:ring-0 focus-visible:ring-offset-0 h-8 px-0"})]}),v&&f.length>0&&(0,t.jsx)("div",{ref:k,className:"absolute z-50 w-full mt-1 bg-popover border rounded-md shadow-md max-h-48 overflow-y-auto",children:f.map((e,s)=>(0,t.jsx)("div",{className:`px-3 py-2 cursor-pointer hover:bg-accent ${s===b?"bg-accent":""}`,onClick:()=>S(e),onMouseEnter:()=>j(s),children:e},e))}),x&&!v&&(0,t.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:u?`${u} "${x}"`:`Press Enter to create "${x}"`})]})}])},515288,e=>{var t=e.i(843476),s=e.i(975157);e.s(["N",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card",className:(0,s.f)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...a})},"O",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,s.f)("px-6",e),...a})},"u",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,s.f)("text-muted-foreground text-sm",e),...a})},"Y",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,s.f)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...a})},"v",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,s.f)("leading-none font-semibold",e),...a})}])},86963,e=>{var t=e.i(843476),s=e.i(531278);e.s(["f",0,function({label:e}){return(0,t.jsxs)("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,t.jsx)(s.f,{className:"h-7 w-7 animate-spin text-primary"}),e&&(0,t.jsx)("p",{className:"text-sm",children:e})]})}])},952122,e=>{e.i(306831),e.s(["f",0,function(e){if(!e)return null;let t=e.toLowerCase();return t.includes("math")||t.includes("数学")?"math":t.includes("physics")||t.includes("物理")?"physics":t.includes("chemistry")||t.includes("化学")?"chemistry":t.includes("biology")||t.includes("生物")?"biology":t.includes("english")||t.includes("英语")?"english":t.includes("chinese")||t.includes("语文")?"chinese":t.includes("history")||t.includes("历史")?"history":t.includes("geography")||t.includes("地理")?"geography":t.includes("politics")||t.includes("政治")?"politics":null}])},35209,e=>{var t=e.i(271645),s=e.i(111110);e.s(["f",0,function(...e){let{t:a}=(0,s.b)(),i=[a.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,t.useEffect)(()=>{document.title=i},[i])}])}])})();