wrong-notebook 2026.11.4-1 → 2026.11.4-2

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 (209) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/server/app/_global-error.html +1 -1
  4. package/.next/server/app/_global-error.rsc +1 -1
  5. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  6. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  8. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  9. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/admin/page.js.nft.json +1 -1
  11. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/admin/user/[id]/page.js.nft.json +1 -1
  13. package/.next/server/app/admin/user/[id]/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/admin/cnm-tags/route.js.nft.json +1 -1
  15. package/.next/server/app/api/admin/dashboard/route.js.nft.json +1 -1
  16. package/.next/server/app/api/admin/debug-logs/export/route.js.nft.json +1 -1
  17. package/.next/server/app/api/admin/debug-logs/route.js.nft.json +1 -1
  18. package/.next/server/app/api/admin/migrate-tags/route.js.nft.json +1 -1
  19. package/.next/server/app/api/admin/system-reset/route.js.nft.json +1 -1
  20. package/.next/server/app/api/admin/users/[id]/detail/route.js.nft.json +1 -1
  21. package/.next/server/app/api/admin/users/[id]/route.js.nft.json +1 -1
  22. package/.next/server/app/api/admin/users/route.js.nft.json +1 -1
  23. package/.next/server/app/api/ai/models/route.js.nft.json +1 -1
  24. package/.next/server/app/api/ai/test/route.js.nft.json +1 -1
  25. package/.next/server/app/api/analytics/route.js.nft.json +1 -1
  26. package/.next/server/app/api/analyze/route.js.nft.json +1 -1
  27. package/.next/server/app/api/auth/[...nextauth]/route.js.nft.json +1 -1
  28. package/.next/server/app/api/error-items/[id]/delete/route.js.nft.json +1 -1
  29. package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
  30. package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
  31. package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
  32. package/.next/server/app/api/error-items/[id]/image/route.js.nft.json +1 -1
  33. package/.next/server/app/api/error-items/[id]/notes/route.js.nft.json +1 -1
  34. package/.next/server/app/api/error-items/[id]/practice-records/route.js.nft.json +1 -1
  35. package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
  36. package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
  37. package/.next/server/app/api/error-items/[id]/route.js.nft.json +1 -1
  38. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
  39. package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
  40. package/.next/server/app/api/error-items/answer-space/route.js.nft.json +1 -1
  41. package/.next/server/app/api/error-items/batch-delete/route.js.nft.json +1 -1
  42. package/.next/server/app/api/error-items/clear/route.js.nft.json +1 -1
  43. package/.next/server/app/api/error-items/list/route.js.nft.json +1 -1
  44. package/.next/server/app/api/error-items/route.js.nft.json +1 -1
  45. package/.next/server/app/api/error-items/short/[shortId]/route.js.nft.json +1 -1
  46. package/.next/server/app/api/error-items/similarity/route.js.nft.json +1 -1
  47. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
  48. package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
  49. package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
  50. package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
  51. package/.next/server/app/api/exams/route.js.nft.json +1 -1
  52. package/.next/server/app/api/export/route.js +4 -4
  53. package/.next/server/app/api/export/route.js.nft.json +1 -1
  54. package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
  55. package/.next/server/app/api/health/route.js.nft.json +1 -1
  56. package/.next/server/app/api/import/route.js +9 -9
  57. package/.next/server/app/api/import/route.js.nft.json +1 -1
  58. package/.next/server/app/api/import-batches/[id]/confirm-all/route.js.nft.json +1 -1
  59. package/.next/server/app/api/import-batches/[id]/fix-text/route.js.nft.json +1 -1
  60. package/.next/server/app/api/import-batches/[id]/read/route.js.nft.json +1 -1
  61. package/.next/server/app/api/import-batches/[id]/retry/route.js.nft.json +1 -1
  62. package/.next/server/app/api/import-batches/[id]/route.js.nft.json +1 -1
  63. package/.next/server/app/api/import-batches/[id]/start/route.js.nft.json +1 -1
  64. package/.next/server/app/api/import-batches/route.js.nft.json +1 -1
  65. package/.next/server/app/api/import-tasks/[id]/confirm/route.js.nft.json +1 -1
  66. package/.next/server/app/api/import-tasks/[id]/read/route.js.nft.json +1 -1
  67. package/.next/server/app/api/import-tasks/[id]/retry/route.js.nft.json +1 -1
  68. package/.next/server/app/api/import-tasks/[id]/route.js.nft.json +1 -1
  69. package/.next/server/app/api/import-tasks/route.js.nft.json +1 -1
  70. package/.next/server/app/api/initialize/route.js.nft.json +1 -1
  71. package/.next/server/app/api/logs/frontend/route.js.nft.json +1 -1
  72. package/.next/server/app/api/minimax-code/checkin/route.js.nft.json +1 -1
  73. package/.next/server/app/api/minimax-code/login/route.js.nft.json +1 -1
  74. package/.next/server/app/api/minimax-code/route.js.nft.json +1 -1
  75. package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
  76. package/.next/server/app/api/notebooks/[id]/route.js.nft.json +1 -1
  77. package/.next/server/app/api/notebooks/route.js.nft.json +1 -1
  78. package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
  79. package/.next/server/app/api/paper-groups/[id]/route.js.nft.json +1 -1
  80. package/.next/server/app/api/paper-groups/route.js.nft.json +1 -1
  81. package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
  82. package/.next/server/app/api/practice/grade/route.js.nft.json +1 -1
  83. package/.next/server/app/api/practice/record/[id]/route.js.nft.json +1 -1
  84. package/.next/server/app/api/practice/record/route.js.nft.json +1 -1
  85. package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
  86. package/.next/server/app/api/register/route.js.nft.json +1 -1
  87. package/.next/server/app/api/register/status/route.js.nft.json +1 -1
  88. package/.next/server/app/api/requests/[id]/route.js.nft.json +1 -1
  89. package/.next/server/app/api/review/due/route.js.nft.json +1 -1
  90. package/.next/server/app/api/settings/route.js.nft.json +1 -1
  91. package/.next/server/app/api/setup/route.js.nft.json +1 -1
  92. package/.next/server/app/api/stats/activity/route.js.nft.json +1 -1
  93. package/.next/server/app/api/stats/practice/clear/route.js.nft.json +1 -1
  94. package/.next/server/app/api/stats/practice/route.js.nft.json +1 -1
  95. package/.next/server/app/api/stats/repeated-mistakes/route.js.nft.json +1 -1
  96. package/.next/server/app/api/stats/weak-tags/route.js.nft.json +1 -1
  97. package/.next/server/app/api/tags/route.js.nft.json +1 -1
  98. package/.next/server/app/api/tags/stats/route.js.nft.json +1 -1
  99. package/.next/server/app/api/tags/suggestions/route.js.nft.json +1 -1
  100. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  101. package/.next/server/app/api/tts/[id]/route.js.nft.json +1 -1
  102. package/.next/server/app/api/tts/batch/route.js.nft.json +1 -1
  103. package/.next/server/app/api/tts/route.js.nft.json +1 -1
  104. package/.next/server/app/api/tts/status/route.js.nft.json +1 -1
  105. package/.next/server/app/api/user/route.js.nft.json +1 -1
  106. package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
  107. package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
  108. package/.next/server/app/exams/[id]/page.js.nft.json +1 -1
  109. package/.next/server/app/exams/[id]/page_client-reference-manifest.js +1 -1
  110. package/.next/server/app/exams/[id]/print/page.js.nft.json +1 -1
  111. package/.next/server/app/exams/[id]/print/page_client-reference-manifest.js +1 -1
  112. package/.next/server/app/exams/page.js.nft.json +1 -1
  113. package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
  114. package/.next/server/app/import-batches/[id]/page.js.nft.json +1 -1
  115. package/.next/server/app/import-batches/[id]/page_client-reference-manifest.js +1 -1
  116. package/.next/server/app/import-tasks/[id]/page.js.nft.json +1 -1
  117. package/.next/server/app/import-tasks/[id]/page_client-reference-manifest.js +1 -1
  118. package/.next/server/app/import-tasks/page.js.nft.json +1 -1
  119. package/.next/server/app/import-tasks/page_client-reference-manifest.js +1 -1
  120. package/.next/server/app/initialize/page.js.nft.json +1 -1
  121. package/.next/server/app/initialize/page_client-reference-manifest.js +1 -1
  122. package/.next/server/app/login/page.js.nft.json +1 -1
  123. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  124. package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
  125. package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
  126. package/.next/server/app/notebooks/[id]/page.js.nft.json +1 -1
  127. package/.next/server/app/notebooks/[id]/page_client-reference-manifest.js +1 -1
  128. package/.next/server/app/notebooks/page.js.nft.json +1 -1
  129. package/.next/server/app/notebooks/page_client-reference-manifest.js +1 -1
  130. package/.next/server/app/page.js.nft.json +1 -1
  131. package/.next/server/app/page_client-reference-manifest.js +1 -1
  132. package/.next/server/app/practice/page.js.nft.json +1 -1
  133. package/.next/server/app/practice/page_client-reference-manifest.js +1 -1
  134. package/.next/server/app/print-preview/page.js.nft.json +1 -1
  135. package/.next/server/app/print-preview/page_client-reference-manifest.js +1 -1
  136. package/.next/server/app/register/page.js.nft.json +1 -1
  137. package/.next/server/app/register/page_client-reference-manifest.js +1 -1
  138. package/.next/server/app/review/page.js.nft.json +1 -1
  139. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  140. package/.next/server/app/setup/page.js.nft.json +1 -1
  141. package/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app/stats/page.js.nft.json +1 -1
  143. package/.next/server/app/stats/page_client-reference-manifest.js +1 -1
  144. package/.next/server/app/tags/page.js.nft.json +1 -1
  145. package/.next/server/app/tags/page_client-reference-manifest.js +1 -1
  146. package/.next/server/chunks/[root-of-the-server]__0p5_lv_pjxr5f._.js +3 -0
  147. package/.next/server/chunks/{[root-of-the-server]__0wj82qshtrskw._.js → [root-of-the-server]__1y0n2tg-0l636._.js} +1 -1
  148. package/.next/server/chunks/_03ovgh1-4xf3f._.js +1 -1
  149. package/.next/server/chunks/_07amw8ha9rney._.js +1 -1
  150. package/.next/server/chunks/_0_rhee7wb6tcg._.js +1 -1
  151. package/.next/server/chunks/_0d66myj_8567o._.js +1 -1
  152. package/.next/server/chunks/_0ge95_bkwrkmc._.js +1 -1
  153. package/.next/server/chunks/_12w5k19rc45j_._.js +1 -1
  154. package/.next/server/chunks/_1ex6ovo_j2jzv._.js +1 -1
  155. package/.next/server/chunks/src_lib_0rb6u4i7kn30r._.js +3 -0
  156. package/.next/server/chunks/src_lib_1chbt4n9_vpoj._.js +3 -0
  157. package/.next/server/chunks/src_lib_exam_ts_0d3a4q4r41hcf._.js +1 -1
  158. package/.next/server/chunks/ssr/[root-of-the-server]__01z2m5q6l60fn._.js +3 -0
  159. package/.next/server/chunks/ssr/{[root-of-the-server]__1z2o77biewl3j._.js → [root-of-the-server]__0sb3jhytba2xr._.js} +1 -1
  160. package/.next/server/chunks/ssr/_0qgs--x99c558._.js +3 -0
  161. package/.next/server/chunks/ssr/_0zacgi5-qgqwr._.js +3 -0
  162. package/.next/server/chunks/ssr/_11820i-k62560._.js +3 -0
  163. package/.next/server/chunks/ssr/_1a4u3f5sc05kb._.js +3 -0
  164. package/.next/server/chunks/ssr/_1ujx-n3muyaxs._.js +1 -1
  165. package/.next/server/chunks/ssr/{node_modules_1d2ueqm41z04k._.js → node_modules_02k42jp0_uoqr._.js} +1 -1
  166. package/.next/server/chunks/ssr/{node_modules_heic-to_dist_csp_heic-to_1_wfmqq00b4vx.js → node_modules_heic-to_dist_csp_heic-to_0byqh-lbfcigr.js} +1 -1
  167. package/.next/server/chunks/ssr/{node_modules_heic-to_dist_csp_heic-to_1myi81wrj4gw4.js → node_modules_heic-to_dist_csp_heic-to_19_dv9gdzg_e7.js} +1 -1
  168. package/.next/server/chunks/ssr/src_0z149pjrheeb7._.js +3 -0
  169. package/.next/server/chunks/ssr/src_app_exams_[id]_page_tsx_0xcjflkgkwzgd._.js +1 -1
  170. package/.next/server/chunks/ssr/src_app_exams_page_tsx_17_d4_gy2i1ds._.js +1 -1
  171. package/.next/server/chunks/ssr/src_app_notebooks_[id]_page_tsx_08njm-5-txm8_._.js +1 -1
  172. package/.next/server/chunks/ssr/src_app_print-preview_page_tsx_001yt-fzrj7tf._.js +1 -1
  173. package/.next/server/chunks/ssr/src_components_providers_tsx_09kw-mv3nb6xs._.js +10 -10
  174. package/.next/server/middleware-build-manifest.js +3 -3
  175. package/.next/server/pages/500.html +1 -1
  176. package/.next/static/chunks/0e6ximjg-pqgt.js +1 -0
  177. package/.next/static/chunks/17-num1x7o1m2.js +1 -0
  178. package/.next/static/chunks/1egd1e1483_lj.js +1 -0
  179. package/.next/static/chunks/1o_q928xcfjs3.js +1 -0
  180. package/.next/static/chunks/25flylmb_qz91.js +1 -0
  181. package/.next/static/chunks/2924d0kl-68z7.js +193 -0
  182. package/.next/static/chunks/2cpsg6e2vg7fx.css +3 -0
  183. package/.next/static/chunks/3s_fq__cff-ps.js +2 -0
  184. package/.next/static/chunks/42rupczfyygo1.js +1 -0
  185. package/package.json +1 -1
  186. package/prisma/migrations/20261103231825_exam_paper_mode/migration.sql +25 -0
  187. package/prisma/schema.prisma +1 -0
  188. package/prisma/seed.db +0 -0
  189. package/.next/server/chunks/[root-of-the-server]__0xnu_7ck-z9do._.js +0 -3
  190. package/.next/server/chunks/src_lib_1xdguwkq8k_gz._.js +0 -3
  191. package/.next/server/chunks/src_lib_tag-hierarchy_ts_1illun--8v3_9._.js +0 -3
  192. package/.next/server/chunks/ssr/[root-of-the-server]__0vgnixmnie9dg._.js +0 -3
  193. package/.next/server/chunks/ssr/_0wculltrlnokg._.js +0 -3
  194. package/.next/server/chunks/ssr/_1-5vj-nfmgwz8._.js +0 -3
  195. package/.next/server/chunks/ssr/_18dt93-y95n-0._.js +0 -3
  196. package/.next/server/chunks/ssr/_1b3pell8an7q7._.js +0 -3
  197. package/.next/server/chunks/ssr/_1gbbaroe3f8p2._.js +0 -3
  198. package/.next/static/chunks/081x3sje_s-_s.js +0 -1
  199. package/.next/static/chunks/093fbi_f_vb46.js +0 -1
  200. package/.next/static/chunks/0nq5_ne_bugdp.js +0 -1
  201. package/.next/static/chunks/1a9_ien1xt883.js +0 -1
  202. package/.next/static/chunks/1b5jj8zk0mtzk.js +0 -1
  203. package/.next/static/chunks/2ic9ath-r3jvf.js +0 -193
  204. package/.next/static/chunks/38fux_rbsoiif.js +0 -1
  205. package/.next/static/chunks/3ayhhtp8n8w82.css +0 -3
  206. package/.next/static/chunks/3kr4ynzxd4_6d.js +0 -2
  207. /package/.next/static/{0_A8rshkxRGdIAt8Ht93Q → E10D9dv115hLNvX7vE6qA}/_buildManifest.js +0 -0
  208. /package/.next/static/{0_A8rshkxRGdIAt8Ht93Q → E10D9dv115hLNvX7vE6qA}/_clientMiddlewareManifest.js +0 -0
  209. /package/.next/static/{0_A8rshkxRGdIAt8Ht93Q → E10D9dv115hLNvX7vE6qA}/_ssgManifest.js +0 -0
@@ -1,19 +1,19 @@
1
- module.exports=[418175,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(550194),e=a.i(875003),f=a.i(291938),g=a.i(960927),h=a.i(630534);let i=["system","light","dark"],j="system",k="app-theme";function l(a){return"string"==typeof a&&i.includes(a)}let m=(0,c.createContext)({preference:j,theme:"light",setPreference:()=>void 0}),n="(prefers-color-scheme: dark)",o=new Set;function p(a){return o.add(a),window.addEventListener("storage",a),()=>{o.delete(a),window.removeEventListener("storage",a)}}function q(){try{let a=localStorage.getItem(k);return l(a)?a:j}catch{return j}}function r(a){try{localStorage.setItem(k,a)}catch{}o.forEach(a=>a())}function s(a){let b=window.matchMedia(n);return b.addEventListener("change",a),()=>b.removeEventListener("change",a)}let t=()=>window.matchMedia(n).matches;function u({children:a}){let{data:d,status:i}=(0,e.useSession)(),k="authenticated"===i,n=d?.user?.email,o=(0,c.useSyncExternalStore)(p,q,()=>j),v=(0,c.useSyncExternalStore)(s,t,()=>!1),w="system"===o?v?"dark":"light":o;(0,c.useEffect)(()=>{let a=document.documentElement,b=b=>{a.classList.toggle("dark","dark"===b),a.style.colorScheme=b};b(w);let c=()=>b("light"),d=()=>b(w);return window.addEventListener("beforeprint",c),window.addEventListener("afterprint",d),()=>{window.removeEventListener("beforeprint",c),window.removeEventListener("afterprint",d)}},[w]),(0,c.useEffect)(()=>{if(!k||!n)return;let a=!1;return f.k.get("/api/user").then(b=>{!a&&l(b.themePreference)&&b.themePreference!==q()&&r(b.themePreference)}).catch(a=>{h.V.warn("[Theme]","Failed to load theme preference",{error:(0,g.Z)(a)})}),()=>{a=!0}},[k,n]);let x=(0,c.useCallback)(a=>{r(a),k&&f.k.patch("/api/user",{themePreference:a}).catch(a=>{h.V.warn("[Theme]","Failed to save theme preference",{error:(0,g.Z)(a)})})},[k]),y=(0,c.useMemo)(()=>({preference:o,theme:w,setPreference:x}),[o,w,x]);return(0,b.jsx)(m.Provider,{value:y,children:a})}var v=a.i(529759),w=a.i(16644),x=a.i(238246),y=a.i(50944),z=a.i(283248),A=a.i(118688),B=a.i(895605),C=a.i(483138),D=a.i(557230),E=a.i(164831);let F={name:"circle-plus",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],aliases:["plus-circle"]};F.node;let G=(0,E.f)(F),H={name:"shield",size:24,node:[["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"}]]};H.node;let I=(0,E.f)(H);var J=a.i(875160),K=a.i(780767),L=a.i(710302),M=a.i(659361),N=a.i(368114);function O({className:a}){let{t:e}=(0,d.b)(),{data:f}=(0,M.b)(),g=(0,c.useRef)(null);if((0,c.useEffect)(()=>{if(!f)return;let a=new Set([...f.tasks.filter(a=>"analyzing"===a.status||"saving"===a.status).map(a=>a.id),...(f.batches??[]).filter(a=>"splitting"===a.phase||"processing"===a.phase).map(a=>`batch:${a.id}`)]),b=new Set([...f.tasks.filter(a=>a.unread).map(a=>a.id),...(f.batches??[]).filter(a=>a.unread).map(a=>`batch:${a.id}`)]),c=g.current;c&&[...c].some(c=>!a.has(c)&&b.has(c))&&L.c.info(e.importTasks.finishedToast),g.current=a},[f,e.importTasks.finishedToast]),!f||0===f.tasks.length&&!f.batches?.length)return null;let{activeCount:h,unreadCount:i}=f,j=h>0?e.importTasks.entryActive.replace("{count}",String(h)):e.importTasks.entry;return(0,b.jsxs)(x.default,{href:"/import-tasks",className:(0,N.f)("relative flex h-9 items-center gap-1.5 rounded-full border px-3 text-sm font-medium transition-colors hover:bg-muted",i>0?"border-primary/50 text-primary":"text-muted-foreground",a),"data-testid":"import-tasks-entry","aria-label":i>0?`${j} \xb7 ${e.importTasks.entryUnread.replace("{count}",String(i))}`:j,children:[h>0?(0,b.jsx)(J.f,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(K.f,{className:"h-4 w-4"}),(0,b.jsx)("span",{className:"whitespace-nowrap",children:j}),i>0&&(0,b.jsx)("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-xs text-white","data-testid":"import-tasks-unread",children:i})]})}var P=a.i(390702);let Q={name:"bot",size:24,node:[["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"}]]};Q.node;let R=(0,E.f)(Q),S={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};S.node;let T=(0,E.f)(S);var U=a.i(357204);let V={name:"message-square-text",size:24,node:[["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"}]]};V.node;let W=(0,E.f)(V),X={name:"settings",size:24,node:[["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"}]]};X.node;let Y=(0,E.f)(X);var Z=a.i(344451),$=a.i(930363),_=a.i(699570),aa=a.i(814574),ab=a.i(875083),ac=a.i(986705),ad=a.i(786304),ae=a.i(563658),af=a.i(866718),ag=a.i(870430);let ah=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("div",{className:"relative w-full overflow-auto",children:(0,b.jsx)("table",{ref:d,className:(0,N.f)("w-full caption-bottom text-sm",a),...c})}));ah.displayName="Table";let ai=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("thead",{ref:d,className:(0,N.f)("[&_tr]:border-b",a),...c}));ai.displayName="TableHeader";let aj=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tbody",{ref:d,className:(0,N.f)("[&_tr:last-child]:border-0",a),...c}));aj.displayName="TableBody",(c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tfoot",{ref:d,className:(0,N.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...c}))).displayName="TableFooter";let ak=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tr",{ref:d,className:(0,N.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),...c}));ak.displayName="TableRow";let al=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("th",{ref:d,className:(0,N.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",a),...c}));al.displayName="TableHead";let am=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("td",{ref:d,className:(0,N.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",a),...c}));am.displayName="TableCell",(c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("caption",{ref:d,className:(0,N.f)("mt-4 text-sm text-muted-foreground",a),...c}))).displayName="TableCaption";var an=a.i(951675);let ao={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};ao.node;let ap=(0,E.f)(ao);var aq=a.i(79362);function ar(){var a;let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(String(5)),[j,k]=(0,c.useState)(!1),l=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/settings");i(String(a.aiConcurrencyLimit??5))}catch(a){h.V.error("[AiConcurrencyLimitSetting]","Failed to fetch config",{error:a})}},[]);(0,c.useEffect)(()=>{l()},[l]);let m=Number(g),n=""!==g.trim()&&"number"==typeof(a=m)&&Number.isInteger(a)&&a>=1&&a<=100,o=async()=>{if(n){k(!0);try{await f.k.post("/api/settings",{aiConcurrencyLimit:m}),L.c.success(e.admin.aiConcurrencyLimitSaved)}catch(a){h.V.error("[AiConcurrencyLimitSetting]","Failed to update AI concurrency limit",{error:a}),L.c.error(e.common.error)}finally{k(!1)}}};return(0,b.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,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ag.f,{htmlFor:"ai-concurrency-limit",className:"text-base",children:e.admin.aiConcurrencyLimit}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:e.admin.aiConcurrencyLimitDesc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(af.f,{id:"ai-concurrency-limit",type:"number",min:1,max:100,step:1,inputMode:"numeric",value:g,onChange:a=>i(a.target.value),"aria-invalid":!n,className:"w-24"}),(0,b.jsxs)(_.f,{size:"sm",onClick:o,disabled:j||!n,children:[j&&(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.common.save]})]})]})}function as(){let{timeZone:a}=(0,v.M)(),{data:i}=(0,e.useSession)(),{t:j}=(0,d.b)(),[k,l]=(0,c.useState)([]),[m,n]=(0,c.useState)(!0),[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)("0"),[u,w]=(0,c.useState)(!1),x=(0,c.useCallback)(async()=>{n(!0);try{let a=await f.k.get("/api/admin/users");l(a)}catch(a){h.V.error("[UserManagement]","Failed to fetch users",{error:a})}finally{n(!1)}},[]),y=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/settings");p(!0===a.allowRegistration),t(String(a.aiDailyLimit??0))}catch(a){h.V.error("[UserManagement]","Failed to fetch config",{error:a})}},[]);(0,c.useEffect)(()=>{x(),y()},[x,y]);let z=async a=>{r(!0);try{await f.k.post("/api/settings",{allowRegistration:a}),p(a)}catch(a){h.V.error("[UserManagement]","Failed to update registration setting",{error:a}),L.c.error(j.common.error)}finally{r(!1)}},A=Number(s),B=""!==s.trim()&&Number.isInteger(A)&&A>=0,C=async()=>{if(B){w(!0);try{await f.k.post("/api/settings",{aiDailyLimit:A}),L.c.success(j.admin.aiDailyLimitSaved)}catch(a){h.V.error("[UserManagement]","Failed to update AI daily limit",{error:a}),L.c.error(j.common.error)}finally{w(!1)}}},D=async a=>{let b=a.isActive?j.admin.confirmDisable:j.admin.confirmEnable;if(await (0,L.u)(b))try{await f.k.patch(`/api/admin/users/${a.id}`,{isActive:!a.isActive}),x()}catch(a){h.V.error("[UserManagement]","Failed to update user status",{error:a}),L.c.error(j.common.error)}},E=async a=>{if(await (0,L.u)(j.admin.confirmDelete,{destructive:!0}))try{await f.k.delete(`/api/admin/users/${a.id}`),x()}catch(b){h.V.error("[UserManagement]","Failed to delete user",{error:b});let a=(0,g.d)(b)||j.common.error;L.c.error(a)}};return m?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(J.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ag.f,{className:"text-base",children:j.admin?.allowRegistration||"Allow New Registrations"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[q&&(0,b.jsx)(J.f,{className:"h-4 w-4 animate-spin"}),(0,b.jsx)(ae.f,{checked:o,onCheckedChange:z,disabled:q})]})]}),(0,b.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,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ag.f,{htmlFor:"ai-daily-limit",className:"text-base",children:j.admin.aiDailyLimit}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j.admin.aiDailyLimitDesc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(af.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:s,onChange:a=>t(a.target.value),"aria-invalid":!B,className:"w-24"}),(0,b.jsxs)(_.f,{size:"sm",onClick:C,disabled:u||!B,children:[u&&(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}),j.common.save]})]})]}),(0,b.jsx)(ar,{}),(0,b.jsx)("div",{className:"sm:hidden space-y-3",children:k.map(c=>(0,b.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,b.jsxs)("div",{className:"flex justify-between items-start",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"font-medium",children:c.name||"N/A"}),(0,b.jsx)("div",{className:"text-sm text-muted-foreground",children:c.email})]}),(0,b.jsx)(ad.f,{variant:"admin"===c.role?"default":"secondary",children:"admin"===c.role?j.admin.admin:j.admin.user})]}),(0,b.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,b.jsxs)("div",{className:"text-muted-foreground",children:[j.admin.errors,": ",c._count.errorItems," | ",j.admin.practiceCount,": ",c._count.practiceRecords," | ",j.admin.aiUsageToday,": ",c.aiUsageToday]}),(0,b.jsx)(ad.f,{variant:c.isActive?"default":"destructive",className:"text-xs",children:c.isActive?j.admin.active:j.admin.disabled})]}),(0,b.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,ac.r)(c.createdAt,"yyyy-MM-dd",a)}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)(_.f,{variant:"ghost",size:"sm",onClick:()=>D(c),disabled:c.id===i?.user?.id,children:c.isActive?(0,b.jsx)(ap,{className:"h-4 w-4 text-orange-500"}):(0,b.jsx)(aq.f,{className:"h-4 w-4 text-green-500"})}),(0,b.jsx)(_.f,{variant:"ghost",size:"sm",onClick:()=>E(c),disabled:c.id===i?.user?.id,children:(0,b.jsx)(an.f,{className:"h-4 w-4 text-destructive"})})]})]})]},c.id))}),(0,b.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,b.jsxs)(ah,{children:[(0,b.jsx)(ai,{children:(0,b.jsxs)(ak,{children:[(0,b.jsx)(al,{children:j.admin.nameEmail}),(0,b.jsx)(al,{children:j.admin.role}),(0,b.jsx)(al,{children:j.admin.stats}),(0,b.jsx)(al,{children:j.admin.createdAt}),(0,b.jsx)(al,{children:j.admin.status}),(0,b.jsx)(al,{className:"text-right",children:j.admin.actions})]})}),(0,b.jsx)(aj,{children:k.map(c=>(0,b.jsxs)(ak,{children:[(0,b.jsxs)(am,{children:[(0,b.jsx)("div",{className:"font-medium",children:c.name||"N/A"}),(0,b.jsx)("div",{className:"text-sm text-muted-foreground",children:c.email})]}),(0,b.jsx)(am,{children:(0,b.jsx)(ad.f,{variant:"admin"===c.role?"default":"secondary",children:"admin"===c.role?j.admin.admin:j.admin.user})}),(0,b.jsxs)(am,{children:[(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.errors,": ",c._count.errorItems]}),(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.practiceCount,": ",c._count.practiceRecords]}),(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.aiUsageToday,": ",c.aiUsageToday]})]}),(0,b.jsx)(am,{children:(0,ac.r)(c.createdAt,"yyyy-MM-dd",a)}),(0,b.jsx)(am,{children:(0,b.jsx)(ad.f,{variant:c.isActive?"default":"destructive",children:c.isActive?j.admin.active:j.admin.disabled})}),(0,b.jsxs)(am,{className:"text-right space-x-2",children:[(0,b.jsx)(_.f,{variant:"ghost",size:"sm",onClick:()=>D(c),disabled:c.id===i?.user?.id,title:c.isActive?j.admin.disable:j.admin.enable,children:c.isActive?(0,b.jsx)(ap,{className:"h-4 w-4 text-orange-500"}):(0,b.jsx)(aq.f,{className:"h-4 w-4 text-green-500"})}),(0,b.jsx)(_.f,{variant:"ghost",size:"sm",onClick:()=>E(c),disabled:c.id===i?.user?.id,title:j.admin.delete,children:(0,b.jsx)(an.f,{className:"h-4 w-4 text-destructive"})})]})]},c.id))})]})})]})}var at=a.i(168370);let au={name:"scroll-text",size:24,node:[["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"}]]};au.node;let av=(0,E.f)(au);function aw(a){return(0,b.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a,children:[(0,b.jsx)("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"}),(0,b.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}let ax={name:"server",size:24,node:[["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"}]]};ax.node;let ay=(0,E.f)(ax);var az=a.i(540553);let aA=()=>()=>void 0;function aB(){let{t:a}=(0,d.b)(),e=(0,c.useSyncExternalStore)(aA,az.f,()=>null);return e?e.isStandalone?.()?(0,b.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:a.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,b.jsxs)("span",{className:"break-all",children:[a.settings?.about?.androidServer||"Server",": ",e.getServerUrl()]}),(0,b.jsxs)(_.f,{variant:"outline",className:"gap-2",onClick:()=>e.changeServer(),children:[(0,b.jsx)(ay,{className:"h-4 w-4"}),a.settings?.about?.changeServer||"Change server"]})]}):null}var aC=a.i(424235);function aD(){let{t:a}=(0,d.b)(),[e,f]=(0,c.useState)("");(0,c.useEffect)(()=>{fetch("/api/version").then(a=>a.json()).then(a=>f(a.version)).catch(()=>{})},[]);let g=[{href:aC.f,icon:aw,label:a.settings?.about?.github||"GitHub Repository"},{href:`${aC.f}/releases`,icon:av,label:a.settings?.about?.releaseNotes||"Release Notes"},{href:`${aC.f}/issues`,icon:W,label:a.settings?.about?.feedback||"Feedback"}];return(0,b.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,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-2xl font-bold",children:a.app?.title||"Smart Error Notebook"}),(0,b.jsx)("p",{className:"text-muted-foreground",children:a.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,b.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,b.jsx)(T,{className:"h-4 w-4"}),(0,b.jsxs)("span",{children:[a.settings?.about?.version||"Version",": v",e||"unknown"]})]}),(0,b.jsx)(aB,{}),(0,b.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:g.map(({href:a,icon:c,label:d})=>(0,b.jsx)(_.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,b.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[(0,b.jsx)(c,{className:"h-4 w-4"}),d,(0,b.jsx)(at.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:a.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var aE=a.i(152679),aF=a.i(580701),aG=a.i(348966);let aH={name:"",email:"",educationStage:"",enrollmentYear:"",currentGrade:"",currentSemester:"",password:""};function aI(){let{t:a}=(0,d.b)(),[e,i]=(0,c.useState)(aH),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),p=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/user"),b=a.fixedGradeSemester?(0,aG.p)(a.fixedGradeSemester):null;i({name:a.name||"",email:a.email||"",educationStage:a.educationStage||"",enrollmentYear:a.enrollmentYear||"",currentGrade:b?.grade||"",currentSemester:b?.semester||"",password:""})}catch(a){h.V.error("[AccountSettings]","Failed to fetch profile",{error:a})}finally{m(!1)}},[]);(0,c.useEffect)(()=>{p()},[p]);let q=async()=>{if(e.password&&e.password!==j)return void L.c.error(a.settings?.messages?.passwordMismatch||"Passwords do not match");o(!0);try{let b={name:e.name,email:e.email,educationStage:e.educationStage};e.enrollmentYear&&(b.enrollmentYear=parseInt(e.enrollmentYear.toString())),e.password&&(b.password=e.password),e.currentGrade&&e.currentSemester?b.fixedGradeSemester=`${e.currentGrade}${e.currentSemester}`:e.currentGrade||(b.fixedGradeSemester=null),await f.k.patch("/api/user",b),L.c.success(a.settings?.messages?.profileUpdated||"Profile updated"),i(a=>({...a,password:""})),k(""),window.location.reload()}catch(b){h.V.error("[AccountSettings]","Failed to update profile",{error:(0,g.d)(b)??(0,g.Z)(b)}),L.c.error((0,g.d)(b)||a.settings?.messages?.updateFailed||"Update failed")}finally{o(!1)}};return l?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(J.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:a.auth?.name||"Name"}),(0,b.jsx)(af.f,{value:e.name||"",onChange:a=>i({...e,name:a.target.value})})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:a.auth?.email||"Email"}),(0,b.jsx)(af.f,{value:e.email||"",onChange:a=>i({...e,email:a.target.value}),type:"email"})]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:a.auth?.educationStage||"Education Stage"}),(0,b.jsxs)(aF.d,{value:e.educationStage||"",onValueChange:a=>i({...e,educationStage:a,currentGrade:(0,aG.c)(a).includes(e.currentGrade)?e.currentGrade:"",currentSemester:(0,aG.c)(a).includes(e.currentGrade)?e.currentSemester:""}),children:[(0,b.jsx)(aF.P,{children:(0,b.jsx)(aF.U,{placeholder:a.auth?.selectStage||"Select Stage"})}),(0,b.jsxs)(aF.r,{children:[(0,b.jsx)(aF.T,{value:"primary",children:a.auth?.primary||"Primary School"}),(0,b.jsx)(aF.T,{value:"junior_high",children:a.auth?.juniorHigh||"Junior High"}),(0,b.jsx)(aF.T,{value:"senior_high",children:a.auth?.seniorHigh||"Senior High"}),(0,b.jsx)(aF.T,{value:"university",children:a.auth?.university||"University"})]})]})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:a.auth?.enrollmentYear||"Enrollment Year"}),(0,b.jsx)(af.f,{type:"number",value:e.enrollmentYear||"",onChange:a=>i({...e,enrollmentYear:a.target.value}),placeholder:"YYYY"})]})]}),e.educationStage&&(0,aG.c)(e.educationStage).length>0&&(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:a.settings?.account?.currentGrade||"Current Grade & Semester"}),(0,b.jsxs)(aF.d,{value:e.currentGrade||"",onValueChange:a=>i({...e,currentGrade:a,currentSemester:a?e.currentSemester||"上":""}),children:[(0,b.jsx)(aF.P,{children:(0,b.jsx)(aF.U,{placeholder:a.settings?.account?.selectGrade||"Select Grade"})}),(0,b.jsx)(aF.r,{children:(0,aG.c)(e.educationStage).map(a=>(0,b.jsx)(aF.T,{value:a,children:a},a))})]})]}),e.currentGrade&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:a.settings?.account?.selectSemester||"Select Semester"}),(0,b.jsxs)(aF.d,{value:e.currentSemester||"",onValueChange:a=>i({...e,currentSemester:a}),children:[(0,b.jsx)(aF.P,{children:(0,b.jsx)(aF.U,{placeholder:a.settings?.account?.selectSemester||"Select Semester"})}),(0,b.jsxs)(aF.r,{children:[(0,b.jsx)(aF.T,{value:"上",children:a.settings?.account?.firstSemester||"1st Semester"}),(0,b.jsx)(aF.T,{value:"下",children:a.settings?.account?.secondSemester||"2nd Semester"})]})]})]})]}),e.currentGrade&&e.currentSemester&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground -mt-2",children:a.settings?.account?.gradeAppliedHint||"New questions will default to this grade. You can also configure AI grade recognition in General Settings."}),(0,b.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:a.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,b.jsx)(aE.f,{value:e.password,onChange:a=>i({...e,password:a.target.value}),placeholder:"******",minLength:6})]}),e.password&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:a.auth?.confirmPassword||"Confirm Password"}),(0,b.jsx)(aE.f,{value:j,onChange:a=>k(a.target.value),placeholder:"******",minLength:6})]})]}),(0,b.jsxs)(_.f,{onClick:q,disabled:n,className:"w-full",children:[n&&(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.settings?.account?.update||"Update Profile"]})]})}var aJ=a.i(151304);let aK={name:"upload",size:24,node:[["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"}]]};aK.node;let aL=(0,E.f)(aK);var aM=a.i(246059),aN=a.i(998868),aO=a.i(332485),aP=a.i(861954);let aQ="https://github.com/xiaoyang111222/cn-math-taxonomy",aR="https://raw.githubusercontent.com/xiaoyang111222/cn-math-taxonomy/HEAD/data/topics.json",aS=aM.z.object({id:aN.z.string().optional(),name:aN.z.string().trim().min(1),subject:aN.z.string().nullish(),grade:aO.z.number().int(),semester:aN.z.string().nullish(),chapter:aN.z.string().nullish()}).passthrough();aP.z.array(aS).min(1);let aT="/api/admin/cnm-tags";function aU(){let{t:a}=(0,d.b)(),e=a.admin.cnmTags,[g,i]=(0,c.useState)(null),[j,k]=(0,c.useState)(!1),l=(0,c.useRef)(null),m=(0,c.useCallback)(async()=>{try{i(await f.k.get(aT))}catch(a){h.V.warn("[CnmTagImportSettings]","Failed to load status",{error:a})}},[]);(0,c.useEffect)(()=>{m()},[m]);let n=async a=>{if(a){k(!0);try{let b;try{b=JSON.parse(await a.text())}catch{L.c.error(e.invalidFile);return}let c=await f.k.post(aT,{topics:b},{timeout:3e5});i(c.status),L.c.success(e.imported.replace("{created}",String(c.result.created)).replace("{skipped}",String(c.result.skipped)))}catch(b){h.V.error("[CnmTagImportSettings]","Import failed",{error:b});let a=b instanceof f.a&&400===b.status;L.c.error(a?e.invalidFile:e.failed)}finally{k(!1),l.current&&(l.current.value="")}}},o=g?.knowledgePoints??0;return(0,b.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,b.jsx)(A.f,{className:"h-4 w-4"}),e.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:e.desc})]}),(0,b.jsxs)("div",{className:"space-y-1 rounded-md bg-muted/50 p-3 text-xs text-muted-foreground",children:[(0,b.jsx)("p",{children:e.downloadHint}),(0,b.jsx)("a",{href:aR,target:"_blank",rel:"noopener noreferrer",className:"block break-all text-primary underline",children:aR}),(0,b.jsxs)("p",{children:[e.sourceLabel," ",(0,b.jsx)("a",{href:aQ,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline",children:aQ})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g?o>0?e.status.replace("{count}",String(o)):e.notImported:""}),(0,b.jsx)("input",{ref:l,type:"file",accept:".json,application/json",className:"hidden",onChange:a=>n(a.target.files?.[0]),disabled:j}),(0,b.jsxs)(_.f,{variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:()=>l.current?.click(),disabled:j,children:[j?(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(aL,{className:"mr-2 h-4 w-4"}),j?e.importing:e.select]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:e.note})]})}var aV=a.i(519783);let aW={info:{card:"border-blue-200 dark:border-blue-900 bg-blue-50 dark:bg-blue-950/40",title:"text-blue-900 dark:text-blue-200 font-bold",desc:"text-blue-800 dark:text-blue-200 font-medium",button:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800"},danger:{card:"border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40",title:"text-red-700 dark:text-red-300 font-medium",desc:"text-red-600 dark:text-red-400",button:""},critical:{card:"border-red-600/50 bg-red-100/50 dark:bg-red-900/40",title:"text-red-900 dark:text-red-200 font-bold",desc:"text-red-800 dark:text-red-200 font-medium",button:"bg-red-700 hover:bg-red-800"}};function aX({title:a,description:c,tone:d,busy:e,icon:f,onClick:g}){let h=aW[d];return(0,b.jsxs)("div",{className:`p-4 border rounded-lg ${h.card}`,children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("span",{className:`text-sm flex items-center gap-2 ${h.title}`,children:a}),(0,b.jsx)(_.f,{variant:"info"===d?"outline":"destructive",size:"sm",onClick:g,disabled:e,className:h.button,children:e?(0,b.jsx)(J.f,{className:"h-4 w-4 animate-spin"}):f})]}),(0,b.jsx)("p",{className:`text-xs mt-2 ${h.desc}`,children:c})]})}function aY({isAdmin:a}){let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(null),j=async(a,b,c,d)=>{i(a);try{L.c.success(await b()),d&&window.location.reload()}catch(b){h.V.error("[DangerZoneSettings]",`${a} failed`,{error:b}),L.c.error(c)}finally{i(null)}},k=e.settings?.clearSuccess||"Success",l=e.settings?.clearError||"Failed",m=async()=>{await (0,L.u)(e.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await j("migrateTags",async()=>{let a=await f.k.post("/api/admin/migrate-tags",{});return`${k}: ${a.count||0} tags migrated.`},e.settings?.clearError||"Failed to migrate tags",!1)},n=async()=>{await (0,L.u)(e.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await j("clearPractice",async()=>(await f.k.delete("/api/stats/practice/clear"),k),l,!0)},o=async()=>{await (0,L.u)(e.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await j("clearErrors",async()=>(await f.k.delete("/api/error-items/clear"),k),l,!0)},p=async()=>{if(!await (0,L.u)(e.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let a=prompt(e.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==a){null!==a&&L.c.error(e.common?.error||"Confirmation failed");return}await j("systemReset",async()=>(await f.k.post("/api/admin/system-reset",{}),e.settings?.clearSuccess||"Success - System Reset Complete"),e.settings?.clearError||"Failed to reset system",!0)};return(0,b.jsxs)(b.Fragment,{children:[a&&(0,b.jsx)(aX,{tone:"info",title:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aV.f,{className:"h-4 w-4"}),e.settings?.migrateTags||"Migrate Tags"]}),description:e.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===g,icon:(0,b.jsx)(aV.f,{className:"h-4 w-4"}),onClick:m}),(0,b.jsx)(aX,{tone:"danger",title:e.settings?.clearData||"Clear Practice Data",description:e.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===g,icon:(0,b.jsx)(an.f,{className:"h-4 w-4"}),onClick:n}),(0,b.jsx)(aX,{tone:"danger",title:e.settings?.clearErrorData||"Clear Error Data",description:e.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===g,icon:(0,b.jsx)(an.f,{className:"h-4 w-4"}),onClick:o}),a&&(0,b.jsx)(aX,{tone:"critical",title:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(P.f,{className:"h-4 w-4"}),e.settings?.systemReset||"System Initialization"]}),description:e.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===g,icon:(0,b.jsx)(an.f,{className:"h-4 w-4"}),onClick:p})]})}var aZ=a.i(613412),a$=a.i(536670);async function a_(a,b){let c=await fetch(a);if(!c.ok)throw Error((await c.json().catch(()=>({}))).message||"Download failed");let d=await c.blob(),e=window.URL.createObjectURL(d),f=document.createElement("a");f.href=e;let g=c.headers.get("Content-Disposition")?.match(/filename="(.+)"/);f.download=g?g[1]:b,document.body.appendChild(f),f.click(),document.body.removeChild(f),window.URL.revokeObjectURL(e)}function a0({isAdmin:a}){let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(!1),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(null),n=async a=>{if(!a||await (0,L.u)(e.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){i(!0);try{await a_(a?"/api/export?all=true":"/api/export",a?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),L.c.success(e.settings?.exportSuccess||"Export successful")}catch(b){h.V.error("[DataBackupSettings]",a?"Export all failed":"Export failed",{error:b}),L.c.error(e.settings?.exportFailed||"Export failed")}finally{i(!1)}}},o=async a=>{if(!l)return;let b=a?e.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":e.settings?.importConfirm||"Are you sure you want to import?";if(await (0,L.u)(b)){k(!0);try{let b=JSON.parse(await l.text()),{stats:c}=await f.k.post(a?"/api/import?all=true":"/api/import",b);L.c.success((e.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(c.subjectsCreated)).replace("{tags}",String(c.tagsCreated)).replace("{items}",String(c.errorItemsCreated)).replace("{schedules}",String(c.reviewSchedulesCreated)).replace("{records}",String(c.practiceRecordsCreated)).replace("{papers}",String(c.examPapersCreated??0)).replace("{voices}",String(c.ttsSpeechesImported??0)).replace("{duplicates}",String(c.duplicateErrorItems??0))),m(null),window.location.reload()}catch(b){h.V.error("[DataBackupSettings]",a?"Import all failed":"Import failed",{error:b}),L.c.error(e.settings?.importFailed||"Import failed")}finally{k(!1)}}},p=(a,c)=>a?(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}):c;return(0,b.jsxs)("div",{className:"p-4 border border-blue-200 dark:border-blue-900 rounded-lg bg-blue-50 dark:bg-blue-950/40",children:[(0,b.jsx)("h4",{className:"text-sm font-bold text-blue-900 dark:text-blue-200 mb-3",children:e.settings?.dataManagement||"Data Management"}),(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:e.settings?.exportData||"Export Data"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>n(!1),disabled:g,className:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800",children:[p(g,(0,b.jsx)(a$.f,{className:"mr-2 h-4 w-4"})),e.settings?.exportData||"Export"]}),a&&(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>n(!0),disabled:g,className:"bg-orange-100 dark:bg-orange-900/40 hover:bg-orange-200 dark:hover:bg-orange-900/60 text-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-800",children:[p(g,(0,b.jsx)(a$.f,{className:"mr-2 h-4 w-4"})),e.settings?.exportAllData||"Export All"]})]})]}),(0,b.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:e.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:e.settings?.importData||"Import Data"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("input",{type:"file",accept:".json",onChange:a=>m(a.target.files?.[0]??l),className:"hidden",id:"import-file-input",disabled:j}),(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:j,className:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800",children:[p(j,(0,b.jsx)(aL,{className:"mr-2 h-4 w-4"})),l?.name||e.settings?.selectFile||"Select File"]}),l&&(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>o(!1),disabled:j,className:"bg-green-100 dark:bg-green-900/40 hover:bg-green-200 dark:hover:bg-green-900/60 text-green-900 dark:text-green-200 border-green-300 dark:border-green-800",children:[p(j,(0,b.jsx)(aZ.f,{className:"mr-2 h-4 w-4"})),e.settings?.importData||"Import"]}),l&&a&&(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>o(!0),disabled:j,className:"bg-orange-100 dark:bg-orange-900/40 hover:bg-orange-200 dark:hover:bg-orange-900/60 text-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-800",children:[p(j,(0,b.jsx)(aZ.f,{className:"mr-2 h-4 w-4"})),e.settings?.importAllData||"Import All"]})]})]}),(0,b.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:e.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}let a1={name:"bug",size:24,node:[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]]};a1.node;let a2=(0,E.f)(a1),a3="/api/admin/debug-logs";function a4(){let{t:a}=(0,d.b)(),{timeZone:e}=(0,v.M)(),g=a.admin.debugLog,[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!1),m=(0,c.useCallback)(async()=>{try{j(await f.k.get(a3))}catch(a){h.V.warn("[DebugLogSettings]","Failed to load debug status",{error:a})}},[]);(0,c.useEffect)(()=>{m()},[m]),(0,c.useEffect)(()=>{if(!i?.enabled)return;let a=setInterval(m,5e3);return()=>clearInterval(a)},[i?.enabled,m]);let n=async(a,b)=>{l(!0);try{await a(),L.c.success(b)}catch(a){h.V.error("[DebugLogSettings]","Debug log action failed",{error:a}),L.c.error(g.failed)}finally{l(!1)}},o=a=>a?(0,ac.r)(a,"yyyy-MM-dd HH:mm",e):"",p=i?.enabled?g.enabledHint.replace("{since}",o(i.enabledAt)).replace("{until}",o(i.expiresAt)):g.disabledHint,q=(i?.entryCount??0)>0;return(0,b.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)(ag.f,{htmlFor:"debug-mode-switch",className:"flex items-center gap-2 font-medium",children:[(0,b.jsx)(a2,{className:"h-4 w-4"}),g.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.desc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)("span",{className:"text-sm text-muted-foreground",children:g.enable}),(0,b.jsx)(ae.f,{id:"debug-mode-switch",checked:!!i?.enabled,onCheckedChange:a=>n(async()=>{j(await f.k.post(a3,{enabled:a}))},a?g.enabled:g.disabled),disabled:k||!i})]})]}),(0,b.jsxs)("p",{className:`text-xs ${i?.enabled?"text-orange-600":"text-muted-foreground"}`,children:[p,i&&(0,b.jsxs)(b.Fragment,{children:[" ",g.entries.replace("{count}",String(i.entryCount)),i.droppedCount>0&&g.dropped.replace("{count}",String(i.droppedCount))]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>n(async()=>{await a_(`${a3}/export`,"wrong-notebook-debug.json"),await m()},g.exported),disabled:k||!q,className:"sm:flex-1",children:[k?(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(a$.f,{className:"mr-2 h-4 w-4"}),g.export]}),(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>n(async()=>{j(await f.k.delete(a3))},g.cleared),disabled:k||!q,children:[(0,b.jsx)(an.f,{className:"mr-2 h-4 w-4"}),g.clear]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.privacyNote})]})}var a5=a.i(225949);function a6({field:a,label:e,description:g}){let{t:i}=(0,d.b)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=`preference-${a}`;(0,c.useEffect)(()=>{f.k.get("/api/user").then(b=>k(!!b[a])).catch(()=>void 0).finally(()=>m(!0))},[a]);let s=async b=>{k(b),o(!0);try{await f.k.patch("/api/user",{[a]:b}),q(i.importFlow.preferenceSaved)}catch(c){k(!b),q(i.importFlow.preferenceSaveFailed),h.V.error("[Settings]","Failed to save user preference",{field:a,error:c instanceof Error?c.message:String(c)})}finally{o(!1)}};return(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,b.jsx)(ag.f,{htmlFor:r,children:e}),(0,b.jsx)(ae.f,{id:r,checked:j,onCheckedChange:s,disabled:!l||n})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),p&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:p})]})}function a7(){let{t:a}=(0,d.b)();return(0,b.jsx)(a6,{field:"enableGeogebra",label:a.importFlow.enableGeogebra,description:a.importFlow.enableGeogebraDesc})}function a8(){let{t:a}=(0,d.b)();return(0,b.jsx)(a6,{field:"confirmBeforeImport",label:a.importFlow.confirmBeforeImport,description:a.importFlow.confirmBeforeImportDesc})}var a9=a.i(249479);function ba(){let{t:a}=(0,d.b)(),[e,g]=(0,c.useState)(String(a9.z)),[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)(null),q=Number(e),r=""!==e.trim()&&Number.isInteger(q)&&q>=a9.P&&q<=a9.o,s=(0,c.useCallback)(async()=>{l(!0),p(null);try{let a=(await f.k.get("/api/user")).masteryThreshold??a9.z;g(String(a)),j(a)}catch(b){p(a.mastery.thresholdLoadFailed),h.V.error("[Settings]","加载已掌握阈值失败",{error:b instanceof Error?b.message:String(b)})}finally{l(!1)}},[a.mastery.thresholdLoadFailed]);(0,c.useEffect)(()=>{s()},[s]);let t=async()=>{if(r&&null!==i){n(!0),p(null);try{let b=(await f.k.patch("/api/user",{masteryThreshold:q})).masteryThreshold??q;j(b),g(String(b)),p(a.importFlow.preferenceSaved)}catch(b){p(a.importFlow.preferenceSaveFailed),h.V.error("[Settings]","保存已掌握阈值失败",{error:b instanceof Error?b.message:String(b)})}finally{n(!1)}}};return(0,b.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,b.jsx)(ag.f,{htmlFor:"mastery-threshold",children:a.mastery.thresholdLabel}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(af.f,{id:"mastery-threshold",type:"number",min:a9.P,max:a9.o,step:1,value:e,onChange:a=>{g(a.target.value),p(null)},disabled:k||m||null===i,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,b.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,b.jsxs)(_.f,{type:"button",size:"sm",variant:"outline",onClick:t,disabled:k||m||null===i||!r||q===i,children:[(k||m)&&(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.importFlow.saveThreshold]}),!k&&null===i&&(0,b.jsx)(_.f,{type:"button",size:"sm",variant:"outline",onClick:s,children:a.importFlow.retryLoad})]}),(0,b.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:a.mastery.thresholdDescription}),null!==i&&!r&&(0,b.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:a.mastery.thresholdInvalid}),o&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:o})]})}var bb=a.i(393045);function bc(){let{t:a}=(0,d.b)(),[e,i]=(0,c.useState)({gradeRecognitionMode:"fixed",fixedGradeSemester:null}),[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=(0,c.useRef)(0),s=(0,c.useCallback)(async()=>{let b=++r.current;m(!0),q(null);try{let a=await f.k.get("/api/user");if(b!==r.current)return;let c={gradeRecognitionMode:a.gradeRecognitionMode??"fixed",fixedGradeSemester:a.fixedGradeSemester??null};i(c),k(c)}catch(c){if(b!==r.current)return;q(a.questionGrade.loadFailed),h.V.error("[QuestionGradeSetting]","加载录入年级规则失败",{error:(0,g.Z)(c)})}finally{b===r.current&&m(!1)}},[a.questionGrade.loadFailed]);(0,c.useEffect)(()=>{s()},[s]);let t=async()=>{o(!0),q(null);try{let b=await f.k.patch("/api/user",e),c={gradeRecognitionMode:b.gradeRecognitionMode??e.gradeRecognitionMode,fixedGradeSemester:b.fixedGradeSemester??null};i(c),k(c),q(a.importFlow.preferenceSaved)}catch(b){q(a.importFlow.preferenceSaveFailed),h.V.error("[QuestionGradeSetting]","保存录入年级规则失败",{error:(0,g.Z)(b)})}finally{o(!1)}},u=l||n||null===j,v=j?.gradeRecognitionMode===e.gradeRecognitionMode&&j?.fixedGradeSemester===e.fixedGradeSemester;return(0,b.jsxs)("div",{className:"space-y-3 border-t pt-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{htmlFor:"question-grade-mode",children:a.questionGrade.label}),(0,b.jsxs)("select",{id:"question-grade-mode",value:e.gradeRecognitionMode,disabled:u,onChange:a=>{i({...e,gradeRecognitionMode:a.target.value}),q(null)},className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm disabled:opacity-50",children:[(0,b.jsx)("option",{value:"fixed",children:a.questionGrade.fixed}),(0,b.jsx)("option",{value:"ai",children:a.questionGrade.ai})]})]}),"fixed"===e.gradeRecognitionMode&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{htmlFor:"question-fixed-grade",children:a.editor.gradeSemester}),(0,b.jsx)(bb.f,{id:"question-fixed-grade",value:e.fixedGradeSemester??"",disabled:u,onChange:a=>{i({...e,fixedGradeSemester:a||null}),q(null)}})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"fixed"===e.gradeRecognitionMode?a.questionGrade.fixedDescription:a.questionGrade.aiDescription}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:a.questionGrade.description}),(0,b.jsxs)(_.f,{type:"button",variant:"outline",size:"sm",disabled:u||v,onClick:t,children:[(l||n)&&(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.questionGrade.save]}),!l&&null===j&&(0,b.jsx)(_.f,{type:"button",variant:"outline",size:"sm",onClick:s,children:a.importFlow.retryLoad}),p&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:p})]})}function bd(){let{t:a}=(0,d.b)();return(0,b.jsx)(a6,{field:"enableSvgAnimation",label:a.importFlow.enableSvgAnimation,description:a.importFlow.enableSvgAnimationDesc})}function be({value:a,onChange:c,disabled:e}){let{t:f}=(0,d.b)();return(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsx)(ag.f,{htmlFor:"app-time-zone",children:f.settings.general.timeZoneLabel}),(0,b.jsx)(af.f,{id:"app-time-zone",value:a,onChange:a=>c(a.target.value),disabled:e,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,b.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(a=>(0,b.jsx)("option",{value:a},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:f.settings.general.timeZoneDesc})]})}function bf({config:a,setConfig:c,isAdmin:e,disabled:f}){let{t:g,language:h,setLanguage:i}=(0,d.b)(),{timeZone:j}=(0,v.M)(),k=a=>c(b=>({...b,timeouts:{...b.timeouts,analyze:1e3*a}}));return(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:g.settings?.language||"Language"}),(0,b.jsxs)(aF.d,{value:h,onValueChange:a=>i(a),children:[(0,b.jsx)(aF.P,{children:(0,b.jsx)(aF.U,{})}),(0,b.jsxs)(aF.r,{children:[(0,b.jsx)(aF.T,{value:"zh",children:"中文 (Chinese)"}),(0,b.jsx)(aF.T,{value:"en",children:"English"})]})]})]}),(0,b.jsx)(be,{value:a.timeZone??j,onChange:a=>c(b=>({...b,timeZone:a})),disabled:!e||f}),e&&(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsx)(ag.f,{children:g.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,b.jsx)(af.f,{type:"number",value:a.timeouts?.analyze?a.timeouts.analyze/1e3:"",onChange:a=>{let b=""===a.target.value?0:parseInt(a.target.value);k(isNaN(b)?0:b)},onBlur:()=>{let b=(a.timeouts?.analyze||0)/1e3,c=Math.min(600,Math.max(120,b));c!==b&&k(c)},min:120,max:600}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,b.jsx)(a8,{}),(0,b.jsx)(bc,{}),(0,b.jsx)(bd,{}),(0,b.jsx)(a7,{}),(0,b.jsx)(a5.f,{}),(0,b.jsx)(ba,{})]})}var bg=a.i(403512),bh=a.i(591119),bi=a.i(515108);function bj(){let{t:a}=(0,d.b)(),{groups:e,loading:g,refetch:i}=(0,bi.f)(),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(!1),n=async()=>{let b=j.trim();if(b){m(!0);try{await f.k.post("/api/paper-groups",{name:b}),k(""),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to add group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}finally{m(!1)}}},o=async(b,c)=>{let d=window.prompt(a.settings?.paperGroups?.renamePrompt||"Rename group",c);if(d&&d.trim()!==c)try{await f.k.patch(`/api/paper-groups/${b}`,{name:d.trim()}),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to rename group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}},p=async(b,c)=>{try{await f.k.patch(`/api/paper-groups/${b}`,{isActive:!c}),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to toggle group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}},q=async(b,c,d)=>{if(d>0){let e=(a.settings?.paperGroups?.deleteConfirmWithItems||'Group "{name}" has {count} questions. Deleting will clear their group assignment. Continue?').replace("{name}",c).replace("{count}",String(d));if(!await (0,L.u)(e,{destructive:!0}))return;try{await f.k.delete(`/api/paper-groups/${b}?clear=true`),L.c.success(a.common?.messages?.deleteSuccess||"Deleted"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to delete group",{error:b}),L.c.error(a.common?.messages?.deleteFailed||"Delete failed")}return}let e=(a.settings?.paperGroups?.deleteConfirm||'Delete group "{name}"?').replace("{name}",c);if(await (0,L.u)(e,{destructive:!0}))try{await f.k.delete(`/api/paper-groups/${b}`),L.c.success(a.common?.messages?.deleteSuccess||"Deleted"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to delete group",{error:b}),L.c.error(a.common?.messages?.deleteFailed||"Delete failed")}};return g?(0,b.jsx)(bh.N,{children:(0,b.jsx)(bh.O,{className:"py-12 flex items-center justify-center",children:(0,b.jsx)(J.f,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):(0,b.jsxs)(bh.N,{children:[(0,b.jsxs)(bh.Y,{children:[(0,b.jsxs)(bh.v,{className:"flex items-center gap-2 text-lg",children:[(0,b.jsx)(C.f,{className:"h-5 w-5"}),a.settings?.paperGroups?.title||"Paper Groups"]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:a.settings?.paperGroups?.desc||"Customize paper groups like Unit Test, Midterm, Final. Default groups A/B/Other can be renamed but not deleted."})]}),(0,b.jsxs)(bh.O,{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)(af.f,{value:j,onChange:a=>k(a.target.value),placeholder:a.settings?.paperGroups?.addPlaceholder||"e.g. Unit Test",onKeyDown:a=>{"Enter"===a.key&&n()}}),(0,b.jsxs)(_.f,{onClick:n,disabled:l||!j.trim(),children:[l?(0,b.jsx)(J.f,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(bg.f,{className:"h-4 w-4 mr-1"}),a.common?.add||"Add"]})]}),(0,b.jsx)("div",{className:"space-y-2",children:e.map(c=>(0,b.jsxs)("div",{className:`flex items-center justify-between rounded-lg border p-3 ${!c.isActive?"opacity-50":""}`,children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("span",{className:"font-medium",children:c.name}),c.key&&(0,b.jsx)(ad.f,{variant:"secondary",className:"text-xs",children:a.settings?.paperGroups?.systemBadge||"Default"}),!c.isActive&&(0,b.jsx)(ad.f,{variant:"outline",className:"text-xs",children:a.common?.inactive||"Inactive"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsx)(_.f,{variant:"ghost",size:"sm",onClick:()=>o(c.id,c.name),children:a.common?.rename||"Rename"}),(0,b.jsx)(_.f,{variant:"ghost",size:"sm",onClick:()=>p(c.id,c.isActive),children:c.isActive?a.common?.deactivate||"Deactivate":a.common?.activate||"Activate"}),!c.key&&(0,b.jsx)(_.f,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>q(c.id,c.name,c._count?.errorItems||0),children:(0,b.jsx)(an.f,{className:"h-4 w-4"})})]})]},c.id))})]})]})}var bk=a.i(429246);let bl="[REDACTED]",bm=/api[-_]?key|password|passwd|secret|authorization|cookie|credential|private[-_]?key|^(access|refresh|id|auth|api|bearer|session|csrf|setup)?[-_]?token$/i,bn=Symbol.for("wrong-notebook.debug-log");function bo(){let a=globalThis,b=a[bn];return b||(b={enabledAt:null,entries:[],totalSize:0,dropped:0},a[bn]=b),b}function bp(a){let b=a.replace(/data:([\w.+-]+\/[\w.+-]+);base64,[A-Za-z0-9+/=]+/g,(a,b)=>`[data:${b}, ${a.length} chars]`).replace(/(Bearer\s+)[\w\-.~+/]+=*/gi,`$1${bl}`).replace(/\bsk-[A-Za-z0-9_-]{8,}/g,bl).replace(/([?&](?:key|api_key|apikey|token|access_token)=)[^&\s"']+/gi,`$1${bl}`);return b.length>1e4&&(b=`${b.slice(0,1e4)}…[truncated ${b.length-1e4} chars]`),b}function bq(a,b,c,d=new Date){if(function(a=Date.now()){let b=bo();return null!==b.enabledAt&&(!(a-b.enabledAt>=864e5)||(b.enabledAt=null,!1))}(d.getTime()))try{let e={...function a(b,c=0,d=new WeakSet){if(null==b)return b;if("string"==typeof b)return bp(b);if("number"==typeof b||"boolean"==typeof b)return b;if("bigint"==typeof b)return b.toString();if("function"==typeof b||"symbol"==typeof b)return String(b);if(b instanceof Date)return b.toISOString();if(b instanceof Error){let e={name:b.name,message:bp(b.message)};return b.stack&&(e.stack=bp(b.stack)),void 0!==b.code&&(e.code=a(b.code,c+1,d)),void 0!==b.status&&(e.status=a(b.status,c+1,d)),void 0!==b.cause&&c<8&&(e.cause=a(b.cause,c+1,d)),e}if("object"!=typeof b)return String(b);if(d.has(b))return"[Circular]";if(c>=8)return"[Object]";if(d.add(b),Array.isArray(b)){let e=b.slice(0,100).map(b=>a(b,c+1,d));return b.length>100&&e.push(`…[${b.length-100} more items]`),e}return ArrayBuffer.isView(b)||b instanceof ArrayBuffer?`[Binary ${b.byteLength} bytes]`:Object.fromEntries(Object.entries(b).map(([b,e])=>[b,bm.test(b)&&null!=e&&""!==e?bl:a(e,c+1,d)]))}(b),time:d.toISOString(),level:a,msg:bp(c)},f=JSON.stringify(e).length,g=bo();for(g.entries.push({entry:e,size:f}),g.totalSize+=f;g.entries.length>5e3||g.totalSize>0x1400000&&g.entries.length>1;){let a=g.entries.shift();if(!a)break;g.totalSize-=a.size,g.dropped+=1}}catch{}}let br={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function bs(a,b={}){let c,d=br[a],e=(c=process.env.LOG_LEVEL?.toLowerCase())&&void 0!==br[c]?br[c]:br.info;return(c,f)=>{let g,h,i=new Date;if("string"==typeof c?(g={},h=c):(g=c,h=f||""),bq(a,{...b,...g},h,i),!(d<e)){let c=JSON.stringify({level:a,time:i.toISOString(),...b,...g,msg:h});switch(a){case"error":case"fatal":console.error(c);break;case"warn":console.warn(c);break;default:console.log(c)}}}}let bt=function a(b={}){return b.module,{trace:bs("trace",b),debug:bs("debug",b),info:bs("info",b),warn:bs("warn",b),error:bs("error",b),fatal:bs("fatal",b),child:c=>a({...b,...c}),box:(a,c,d="📋")=>{bq("info",{...b,..."string"==typeof c?{content:c}:c},a);{let d="string"==typeof c?{content:c}:c||{};console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...b,title:a,...d,msg:a}));return}},divider:(a="-")=>{}}}({env:"production"});var bu=a.i(62832);bt.child({module:"ai:prompts"});let bv=`请参考《高思学校竞赛数学导引》(每讲分兴趣篇、拓展篇、超越篇,题目左侧标 1~5 颗星)的星级标准,结合题目所在年级评定难度:
1
+ module.exports=[418175,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(550194),e=a.i(875003),f=a.i(291938),g=a.i(960927),h=a.i(630534);let i=["system","light","dark"],j="system",k="app-theme";function l(a){return"string"==typeof a&&i.includes(a)}let m=(0,c.createContext)({preference:j,theme:"light",setPreference:()=>void 0}),n="(prefers-color-scheme: dark)",o=new Set;function p(a){return o.add(a),window.addEventListener("storage",a),()=>{o.delete(a),window.removeEventListener("storage",a)}}function q(){try{let a=localStorage.getItem(k);return l(a)?a:j}catch{return j}}function r(a){try{localStorage.setItem(k,a)}catch{}o.forEach(a=>a())}function s(a){let b=window.matchMedia(n);return b.addEventListener("change",a),()=>b.removeEventListener("change",a)}let t=()=>window.matchMedia(n).matches;function u({children:a}){let{data:d,status:i}=(0,e.useSession)(),k="authenticated"===i,n=d?.user?.email,o=(0,c.useSyncExternalStore)(p,q,()=>j),v=(0,c.useSyncExternalStore)(s,t,()=>!1),w="system"===o?v?"dark":"light":o;(0,c.useEffect)(()=>{let a=document.documentElement,b=b=>{a.classList.toggle("dark","dark"===b),a.style.colorScheme=b};b(w);let c=()=>b("light"),d=()=>b(w);return window.addEventListener("beforeprint",c),window.addEventListener("afterprint",d),()=>{window.removeEventListener("beforeprint",c),window.removeEventListener("afterprint",d)}},[w]),(0,c.useEffect)(()=>{if(!k||!n)return;let a=!1;return f.k.get("/api/user").then(b=>{!a&&l(b.themePreference)&&b.themePreference!==q()&&r(b.themePreference)}).catch(a=>{h.V.warn("[Theme]","Failed to load theme preference",{error:(0,g.Z)(a)})}),()=>{a=!0}},[k,n]);let x=(0,c.useCallback)(a=>{r(a),k&&f.k.patch("/api/user",{themePreference:a}).catch(a=>{h.V.warn("[Theme]","Failed to save theme preference",{error:(0,g.Z)(a)})})},[k]),y=(0,c.useMemo)(()=>({preference:o,theme:w,setPreference:x}),[o,w,x]);return(0,b.jsx)(m.Provider,{value:y,children:a})}var v=a.i(529759),w=a.i(16644),x=a.i(238246),y=a.i(50944),z=a.i(557230),A=a.i(164831);let B={name:"shield",size:24,node:[["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"}]]};B.node;let C=(0,A.f)(B);var D=a.i(875160),E=a.i(780767),F=a.i(710302),G=a.i(659361),H=a.i(368114);function I({className:a}){let{t:e}=(0,d.b)(),{data:f}=(0,G.b)(),g=(0,c.useRef)(null);if((0,c.useEffect)(()=>{if(!f)return;let a=new Set([...f.tasks.filter(a=>"analyzing"===a.status||"saving"===a.status).map(a=>a.id),...(f.batches??[]).filter(a=>"splitting"===a.phase||"processing"===a.phase).map(a=>`batch:${a.id}`)]),b=new Set([...f.tasks.filter(a=>a.unread).map(a=>a.id),...(f.batches??[]).filter(a=>a.unread).map(a=>`batch:${a.id}`)]),c=g.current;c&&[...c].some(c=>!a.has(c)&&b.has(c))&&F.c.info(e.importTasks.finishedToast),g.current=a},[f,e.importTasks.finishedToast]),!f||0===f.tasks.length&&!f.batches?.length)return null;let{activeCount:h,unreadCount:i}=f,j=h>0?e.importTasks.entryActive.replace("{count}",String(h)):e.importTasks.entry;return(0,b.jsxs)(x.default,{href:"/import-tasks",className:(0,H.f)("relative flex h-9 items-center gap-1.5 rounded-full border px-3 text-sm font-medium transition-colors hover:bg-muted",i>0?"border-primary/50 text-primary":"text-muted-foreground",a),"data-testid":"import-tasks-entry","aria-label":i>0?`${j} \xb7 ${e.importTasks.entryUnread.replace("{count}",String(i))}`:j,children:[h>0?(0,b.jsx)(D.f,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(E.f,{className:"h-4 w-4"}),(0,b.jsx)("span",{className:"whitespace-nowrap",children:j}),i>0&&(0,b.jsx)("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-xs text-white","data-testid":"import-tasks-unread",children:i})]})}var J=a.i(390702),K=a.i(283248);let L={name:"bot",size:24,node:[["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"}]]};L.node;let M=(0,A.f)(L),N={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};N.node;let O=(0,A.f)(N);var P=a.i(357204);let Q={name:"message-square-text",size:24,node:[["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"}]]};Q.node;let R=(0,A.f)(Q),S={name:"settings",size:24,node:[["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"}]]};S.node;let T=(0,A.f)(S);var U=a.i(344451),V=a.i(930363),W=a.i(699570),X=a.i(814574),Y=a.i(875083),Z=a.i(986705),$=a.i(786304),_=a.i(563658),aa=a.i(866718),ab=a.i(870430);let ac=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("div",{className:"relative w-full overflow-auto",children:(0,b.jsx)("table",{ref:d,className:(0,H.f)("w-full caption-bottom text-sm",a),...c})}));ac.displayName="Table";let ad=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("thead",{ref:d,className:(0,H.f)("[&_tr]:border-b",a),...c}));ad.displayName="TableHeader";let ae=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tbody",{ref:d,className:(0,H.f)("[&_tr:last-child]:border-0",a),...c}));ae.displayName="TableBody",(c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tfoot",{ref:d,className:(0,H.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...c}))).displayName="TableFooter";let af=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tr",{ref:d,className:(0,H.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),...c}));af.displayName="TableRow";let ag=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("th",{ref:d,className:(0,H.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",a),...c}));ag.displayName="TableHead";let ah=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("td",{ref:d,className:(0,H.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",a),...c}));ah.displayName="TableCell",(c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("caption",{ref:d,className:(0,H.f)("mt-4 text-sm text-muted-foreground",a),...c}))).displayName="TableCaption";var ai=a.i(951675);let aj={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};aj.node;let ak=(0,A.f)(aj);var al=a.i(79362);function am(){var a;let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(String(5)),[j,k]=(0,c.useState)(!1),l=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/settings");i(String(a.aiConcurrencyLimit??5))}catch(a){h.V.error("[AiConcurrencyLimitSetting]","Failed to fetch config",{error:a})}},[]);(0,c.useEffect)(()=>{l()},[l]);let m=Number(g),n=""!==g.trim()&&"number"==typeof(a=m)&&Number.isInteger(a)&&a>=1&&a<=100,o=async()=>{if(n){k(!0);try{await f.k.post("/api/settings",{aiConcurrencyLimit:m}),F.c.success(e.admin.aiConcurrencyLimitSaved)}catch(a){h.V.error("[AiConcurrencyLimitSetting]","Failed to update AI concurrency limit",{error:a}),F.c.error(e.common.error)}finally{k(!1)}}};return(0,b.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,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ab.f,{htmlFor:"ai-concurrency-limit",className:"text-base",children:e.admin.aiConcurrencyLimit}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:e.admin.aiConcurrencyLimitDesc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(aa.f,{id:"ai-concurrency-limit",type:"number",min:1,max:100,step:1,inputMode:"numeric",value:g,onChange:a=>i(a.target.value),"aria-invalid":!n,className:"w-24"}),(0,b.jsxs)(W.f,{size:"sm",onClick:o,disabled:j||!n,children:[j&&(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.common.save]})]})]})}function an(){let{timeZone:a}=(0,v.M)(),{data:i}=(0,e.useSession)(),{t:j}=(0,d.b)(),[k,l]=(0,c.useState)([]),[m,n]=(0,c.useState)(!0),[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)("0"),[u,w]=(0,c.useState)(!1),x=(0,c.useCallback)(async()=>{n(!0);try{let a=await f.k.get("/api/admin/users");l(a)}catch(a){h.V.error("[UserManagement]","Failed to fetch users",{error:a})}finally{n(!1)}},[]),y=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/settings");p(!0===a.allowRegistration),t(String(a.aiDailyLimit??0))}catch(a){h.V.error("[UserManagement]","Failed to fetch config",{error:a})}},[]);(0,c.useEffect)(()=>{x(),y()},[x,y]);let z=async a=>{r(!0);try{await f.k.post("/api/settings",{allowRegistration:a}),p(a)}catch(a){h.V.error("[UserManagement]","Failed to update registration setting",{error:a}),F.c.error(j.common.error)}finally{r(!1)}},A=Number(s),B=""!==s.trim()&&Number.isInteger(A)&&A>=0,C=async()=>{if(B){w(!0);try{await f.k.post("/api/settings",{aiDailyLimit:A}),F.c.success(j.admin.aiDailyLimitSaved)}catch(a){h.V.error("[UserManagement]","Failed to update AI daily limit",{error:a}),F.c.error(j.common.error)}finally{w(!1)}}},E=async a=>{let b=a.isActive?j.admin.confirmDisable:j.admin.confirmEnable;if(await (0,F.u)(b))try{await f.k.patch(`/api/admin/users/${a.id}`,{isActive:!a.isActive}),x()}catch(a){h.V.error("[UserManagement]","Failed to update user status",{error:a}),F.c.error(j.common.error)}},G=async a=>{if(await (0,F.u)(j.admin.confirmDelete,{destructive:!0}))try{await f.k.delete(`/api/admin/users/${a.id}`),x()}catch(b){h.V.error("[UserManagement]","Failed to delete user",{error:b});let a=(0,g.d)(b)||j.common.error;F.c.error(a)}};return m?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(D.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ab.f,{className:"text-base",children:j.admin?.allowRegistration||"Allow New Registrations"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[q&&(0,b.jsx)(D.f,{className:"h-4 w-4 animate-spin"}),(0,b.jsx)(_.f,{checked:o,onCheckedChange:z,disabled:q})]})]}),(0,b.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,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ab.f,{htmlFor:"ai-daily-limit",className:"text-base",children:j.admin.aiDailyLimit}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j.admin.aiDailyLimitDesc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(aa.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:s,onChange:a=>t(a.target.value),"aria-invalid":!B,className:"w-24"}),(0,b.jsxs)(W.f,{size:"sm",onClick:C,disabled:u||!B,children:[u&&(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}),j.common.save]})]})]}),(0,b.jsx)(am,{}),(0,b.jsx)("div",{className:"sm:hidden space-y-3",children:k.map(c=>(0,b.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,b.jsxs)("div",{className:"flex justify-between items-start",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"font-medium",children:c.name||"N/A"}),(0,b.jsx)("div",{className:"text-sm text-muted-foreground",children:c.email})]}),(0,b.jsx)($.f,{variant:"admin"===c.role?"default":"secondary",children:"admin"===c.role?j.admin.admin:j.admin.user})]}),(0,b.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,b.jsxs)("div",{className:"text-muted-foreground",children:[j.admin.errors,": ",c._count.errorItems," | ",j.admin.practiceCount,": ",c._count.practiceRecords," | ",j.admin.aiUsageToday,": ",c.aiUsageToday]}),(0,b.jsx)($.f,{variant:c.isActive?"default":"destructive",className:"text-xs",children:c.isActive?j.admin.active:j.admin.disabled})]}),(0,b.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,Z.r)(c.createdAt,"yyyy-MM-dd",a)}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)(W.f,{variant:"ghost",size:"sm",onClick:()=>E(c),disabled:c.id===i?.user?.id,children:c.isActive?(0,b.jsx)(ak,{className:"h-4 w-4 text-orange-500"}):(0,b.jsx)(al.f,{className:"h-4 w-4 text-green-500"})}),(0,b.jsx)(W.f,{variant:"ghost",size:"sm",onClick:()=>G(c),disabled:c.id===i?.user?.id,children:(0,b.jsx)(ai.f,{className:"h-4 w-4 text-destructive"})})]})]})]},c.id))}),(0,b.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,b.jsxs)(ac,{children:[(0,b.jsx)(ad,{children:(0,b.jsxs)(af,{children:[(0,b.jsx)(ag,{children:j.admin.nameEmail}),(0,b.jsx)(ag,{children:j.admin.role}),(0,b.jsx)(ag,{children:j.admin.stats}),(0,b.jsx)(ag,{children:j.admin.createdAt}),(0,b.jsx)(ag,{children:j.admin.status}),(0,b.jsx)(ag,{className:"text-right",children:j.admin.actions})]})}),(0,b.jsx)(ae,{children:k.map(c=>(0,b.jsxs)(af,{children:[(0,b.jsxs)(ah,{children:[(0,b.jsx)("div",{className:"font-medium",children:c.name||"N/A"}),(0,b.jsx)("div",{className:"text-sm text-muted-foreground",children:c.email})]}),(0,b.jsx)(ah,{children:(0,b.jsx)($.f,{variant:"admin"===c.role?"default":"secondary",children:"admin"===c.role?j.admin.admin:j.admin.user})}),(0,b.jsxs)(ah,{children:[(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.errors,": ",c._count.errorItems]}),(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.practiceCount,": ",c._count.practiceRecords]}),(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.aiUsageToday,": ",c.aiUsageToday]})]}),(0,b.jsx)(ah,{children:(0,Z.r)(c.createdAt,"yyyy-MM-dd",a)}),(0,b.jsx)(ah,{children:(0,b.jsx)($.f,{variant:c.isActive?"default":"destructive",children:c.isActive?j.admin.active:j.admin.disabled})}),(0,b.jsxs)(ah,{className:"text-right space-x-2",children:[(0,b.jsx)(W.f,{variant:"ghost",size:"sm",onClick:()=>E(c),disabled:c.id===i?.user?.id,title:c.isActive?j.admin.disable:j.admin.enable,children:c.isActive?(0,b.jsx)(ak,{className:"h-4 w-4 text-orange-500"}):(0,b.jsx)(al.f,{className:"h-4 w-4 text-green-500"})}),(0,b.jsx)(W.f,{variant:"ghost",size:"sm",onClick:()=>G(c),disabled:c.id===i?.user?.id,title:j.admin.delete,children:(0,b.jsx)(ai.f,{className:"h-4 w-4 text-destructive"})})]})]},c.id))})]})})]})}var ao=a.i(168370);let ap={name:"scroll-text",size:24,node:[["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"}]]};ap.node;let aq=(0,A.f)(ap);function ar(a){return(0,b.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a,children:[(0,b.jsx)("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"}),(0,b.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}let as={name:"server",size:24,node:[["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"}]]};as.node;let at=(0,A.f)(as);var au=a.i(540553);let av=()=>()=>void 0;function aw(){let{t:a}=(0,d.b)(),e=(0,c.useSyncExternalStore)(av,au.f,()=>null);return e?e.isStandalone?.()?(0,b.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:a.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,b.jsxs)("span",{className:"break-all",children:[a.settings?.about?.androidServer||"Server",": ",e.getServerUrl()]}),(0,b.jsxs)(W.f,{variant:"outline",className:"gap-2",onClick:()=>e.changeServer(),children:[(0,b.jsx)(at,{className:"h-4 w-4"}),a.settings?.about?.changeServer||"Change server"]})]}):null}var ax=a.i(424235);function ay(){let{t:a}=(0,d.b)(),[e,f]=(0,c.useState)("");(0,c.useEffect)(()=>{fetch("/api/version").then(a=>a.json()).then(a=>f(a.version)).catch(()=>{})},[]);let g=[{href:ax.f,icon:ar,label:a.settings?.about?.github||"GitHub Repository"},{href:`${ax.f}/releases`,icon:aq,label:a.settings?.about?.releaseNotes||"Release Notes"},{href:`${ax.f}/issues`,icon:R,label:a.settings?.about?.feedback||"Feedback"}];return(0,b.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,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-2xl font-bold",children:a.app?.title||"Smart Error Notebook"}),(0,b.jsx)("p",{className:"text-muted-foreground",children:a.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,b.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,b.jsx)(O,{className:"h-4 w-4"}),(0,b.jsxs)("span",{children:[a.settings?.about?.version||"Version",": v",e||"unknown"]})]}),(0,b.jsx)(aw,{}),(0,b.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:g.map(({href:a,icon:c,label:d})=>(0,b.jsx)(W.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,b.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[(0,b.jsx)(c,{className:"h-4 w-4"}),d,(0,b.jsx)(ao.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:a.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var az=a.i(152679),aA=a.i(580701),aB=a.i(348966);let aC={name:"",email:"",educationStage:"",enrollmentYear:"",currentGrade:"",currentSemester:"",password:""};function aD(){let{t:a}=(0,d.b)(),[e,i]=(0,c.useState)(aC),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),p=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/user"),b=a.fixedGradeSemester?(0,aB.p)(a.fixedGradeSemester):null;i({name:a.name||"",email:a.email||"",educationStage:a.educationStage||"",enrollmentYear:a.enrollmentYear||"",currentGrade:b?.grade||"",currentSemester:b?.semester||"",password:""})}catch(a){h.V.error("[AccountSettings]","Failed to fetch profile",{error:a})}finally{m(!1)}},[]);(0,c.useEffect)(()=>{p()},[p]);let q=async()=>{if(e.password&&e.password!==j)return void F.c.error(a.settings?.messages?.passwordMismatch||"Passwords do not match");o(!0);try{let b={name:e.name,email:e.email,educationStage:e.educationStage};e.enrollmentYear&&(b.enrollmentYear=parseInt(e.enrollmentYear.toString())),e.password&&(b.password=e.password),e.currentGrade&&e.currentSemester?b.fixedGradeSemester=`${e.currentGrade}${e.currentSemester}`:e.currentGrade||(b.fixedGradeSemester=null),await f.k.patch("/api/user",b),F.c.success(a.settings?.messages?.profileUpdated||"Profile updated"),i(a=>({...a,password:""})),k(""),window.location.reload()}catch(b){h.V.error("[AccountSettings]","Failed to update profile",{error:(0,g.d)(b)??(0,g.Z)(b)}),F.c.error((0,g.d)(b)||a.settings?.messages?.updateFailed||"Update failed")}finally{o(!1)}};return l?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(D.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:a.auth?.name||"Name"}),(0,b.jsx)(aa.f,{value:e.name||"",onChange:a=>i({...e,name:a.target.value})})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:a.auth?.email||"Email"}),(0,b.jsx)(aa.f,{value:e.email||"",onChange:a=>i({...e,email:a.target.value}),type:"email"})]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:a.auth?.educationStage||"Education Stage"}),(0,b.jsxs)(aA.d,{value:e.educationStage||"",onValueChange:a=>i({...e,educationStage:a,currentGrade:(0,aB.c)(a).includes(e.currentGrade)?e.currentGrade:"",currentSemester:(0,aB.c)(a).includes(e.currentGrade)?e.currentSemester:""}),children:[(0,b.jsx)(aA.P,{children:(0,b.jsx)(aA.U,{placeholder:a.auth?.selectStage||"Select Stage"})}),(0,b.jsxs)(aA.r,{children:[(0,b.jsx)(aA.T,{value:"primary",children:a.auth?.primary||"Primary School"}),(0,b.jsx)(aA.T,{value:"junior_high",children:a.auth?.juniorHigh||"Junior High"}),(0,b.jsx)(aA.T,{value:"senior_high",children:a.auth?.seniorHigh||"Senior High"}),(0,b.jsx)(aA.T,{value:"university",children:a.auth?.university||"University"})]})]})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:a.auth?.enrollmentYear||"Enrollment Year"}),(0,b.jsx)(aa.f,{type:"number",value:e.enrollmentYear||"",onChange:a=>i({...e,enrollmentYear:a.target.value}),placeholder:"YYYY"})]})]}),e.educationStage&&(0,aB.c)(e.educationStage).length>0&&(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:a.settings?.account?.currentGrade||"Current Grade & Semester"}),(0,b.jsxs)(aA.d,{value:e.currentGrade||"",onValueChange:a=>i({...e,currentGrade:a,currentSemester:a?e.currentSemester||"上":""}),children:[(0,b.jsx)(aA.P,{children:(0,b.jsx)(aA.U,{placeholder:a.settings?.account?.selectGrade||"Select Grade"})}),(0,b.jsx)(aA.r,{children:(0,aB.c)(e.educationStage).map(a=>(0,b.jsx)(aA.T,{value:a,children:a},a))})]})]}),e.currentGrade&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:a.settings?.account?.selectSemester||"Select Semester"}),(0,b.jsxs)(aA.d,{value:e.currentSemester||"",onValueChange:a=>i({...e,currentSemester:a}),children:[(0,b.jsx)(aA.P,{children:(0,b.jsx)(aA.U,{placeholder:a.settings?.account?.selectSemester||"Select Semester"})}),(0,b.jsxs)(aA.r,{children:[(0,b.jsx)(aA.T,{value:"上",children:a.settings?.account?.firstSemester||"1st Semester"}),(0,b.jsx)(aA.T,{value:"下",children:a.settings?.account?.secondSemester||"2nd Semester"})]})]})]})]}),e.currentGrade&&e.currentSemester&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground -mt-2",children:a.settings?.account?.gradeAppliedHint||"New questions will default to this grade. You can also configure AI grade recognition in General Settings."}),(0,b.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:a.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,b.jsx)(az.f,{value:e.password,onChange:a=>i({...e,password:a.target.value}),placeholder:"******",minLength:6})]}),e.password&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:a.auth?.confirmPassword||"Confirm Password"}),(0,b.jsx)(az.f,{value:j,onChange:a=>k(a.target.value),placeholder:"******",minLength:6})]})]}),(0,b.jsxs)(W.f,{onClick:q,disabled:n,className:"w-full",children:[n&&(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.settings?.account?.update||"Update Profile"]})]})}var aE=a.i(151304),aF=a.i(118688);let aG={name:"upload",size:24,node:[["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"}]]};aG.node;let aH=(0,A.f)(aG);var aI=a.i(246059),aJ=a.i(998868),aK=a.i(332485),aL=a.i(861954);let aM="https://github.com/xiaoyang111222/cn-math-taxonomy",aN="https://raw.githubusercontent.com/xiaoyang111222/cn-math-taxonomy/HEAD/data/topics.json",aO=aI.z.object({id:aJ.z.string().optional(),name:aJ.z.string().trim().min(1),subject:aJ.z.string().nullish(),grade:aK.z.number().int(),semester:aJ.z.string().nullish(),chapter:aJ.z.string().nullish()}).passthrough();aL.z.array(aO).min(1);let aP="/api/admin/cnm-tags";function aQ(){let{t:a}=(0,d.b)(),e=a.admin.cnmTags,[g,i]=(0,c.useState)(null),[j,k]=(0,c.useState)(!1),l=(0,c.useRef)(null),m=(0,c.useCallback)(async()=>{try{i(await f.k.get(aP))}catch(a){h.V.warn("[CnmTagImportSettings]","Failed to load status",{error:a})}},[]);(0,c.useEffect)(()=>{m()},[m]);let n=async a=>{if(a){k(!0);try{let b;try{b=JSON.parse(await a.text())}catch{F.c.error(e.invalidFile);return}let c=await f.k.post(aP,{topics:b},{timeout:3e5});i(c.status),F.c.success(e.imported.replace("{created}",String(c.result.created)).replace("{skipped}",String(c.result.skipped)))}catch(b){h.V.error("[CnmTagImportSettings]","Import failed",{error:b});let a=b instanceof f.a&&400===b.status;F.c.error(a?e.invalidFile:e.failed)}finally{k(!1),l.current&&(l.current.value="")}}},o=g?.knowledgePoints??0;return(0,b.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,b.jsx)(aF.f,{className:"h-4 w-4"}),e.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:e.desc})]}),(0,b.jsxs)("div",{className:"space-y-1 rounded-md bg-muted/50 p-3 text-xs text-muted-foreground",children:[(0,b.jsx)("p",{children:e.downloadHint}),(0,b.jsx)("a",{href:aN,target:"_blank",rel:"noopener noreferrer",className:"block break-all text-primary underline",children:aN}),(0,b.jsxs)("p",{children:[e.sourceLabel," ",(0,b.jsx)("a",{href:aM,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline",children:aM})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g?o>0?e.status.replace("{count}",String(o)):e.notImported:""}),(0,b.jsx)("input",{ref:l,type:"file",accept:".json,application/json",className:"hidden",onChange:a=>n(a.target.files?.[0]),disabled:j}),(0,b.jsxs)(W.f,{variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:()=>l.current?.click(),disabled:j,children:[j?(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(aH,{className:"mr-2 h-4 w-4"}),j?e.importing:e.select]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:e.note})]})}var aR=a.i(519783);let aS={info:{card:"border-blue-200 dark:border-blue-900 bg-blue-50 dark:bg-blue-950/40",title:"text-blue-900 dark:text-blue-200 font-bold",desc:"text-blue-800 dark:text-blue-200 font-medium",button:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800"},danger:{card:"border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40",title:"text-red-700 dark:text-red-300 font-medium",desc:"text-red-600 dark:text-red-400",button:""},critical:{card:"border-red-600/50 bg-red-100/50 dark:bg-red-900/40",title:"text-red-900 dark:text-red-200 font-bold",desc:"text-red-800 dark:text-red-200 font-medium",button:"bg-red-700 hover:bg-red-800"}};function aT({title:a,description:c,tone:d,busy:e,icon:f,onClick:g}){let h=aS[d];return(0,b.jsxs)("div",{className:`p-4 border rounded-lg ${h.card}`,children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("span",{className:`text-sm flex items-center gap-2 ${h.title}`,children:a}),(0,b.jsx)(W.f,{variant:"info"===d?"outline":"destructive",size:"sm",onClick:g,disabled:e,className:h.button,children:e?(0,b.jsx)(D.f,{className:"h-4 w-4 animate-spin"}):f})]}),(0,b.jsx)("p",{className:`text-xs mt-2 ${h.desc}`,children:c})]})}function aU({isAdmin:a}){let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(null),j=async(a,b,c,d)=>{i(a);try{F.c.success(await b()),d&&window.location.reload()}catch(b){h.V.error("[DangerZoneSettings]",`${a} failed`,{error:b}),F.c.error(c)}finally{i(null)}},k=e.settings?.clearSuccess||"Success",l=e.settings?.clearError||"Failed",m=async()=>{await (0,F.u)(e.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await j("migrateTags",async()=>{let a=await f.k.post("/api/admin/migrate-tags",{});return`${k}: ${a.count||0} tags migrated.`},e.settings?.clearError||"Failed to migrate tags",!1)},n=async()=>{await (0,F.u)(e.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await j("clearPractice",async()=>(await f.k.delete("/api/stats/practice/clear"),k),l,!0)},o=async()=>{await (0,F.u)(e.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await j("clearErrors",async()=>(await f.k.delete("/api/error-items/clear"),k),l,!0)},p=async()=>{if(!await (0,F.u)(e.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let a=prompt(e.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==a){null!==a&&F.c.error(e.common?.error||"Confirmation failed");return}await j("systemReset",async()=>(await f.k.post("/api/admin/system-reset",{}),e.settings?.clearSuccess||"Success - System Reset Complete"),e.settings?.clearError||"Failed to reset system",!0)};return(0,b.jsxs)(b.Fragment,{children:[a&&(0,b.jsx)(aT,{tone:"info",title:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(aR.f,{className:"h-4 w-4"}),e.settings?.migrateTags||"Migrate Tags"]}),description:e.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===g,icon:(0,b.jsx)(aR.f,{className:"h-4 w-4"}),onClick:m}),(0,b.jsx)(aT,{tone:"danger",title:e.settings?.clearData||"Clear Practice Data",description:e.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===g,icon:(0,b.jsx)(ai.f,{className:"h-4 w-4"}),onClick:n}),(0,b.jsx)(aT,{tone:"danger",title:e.settings?.clearErrorData||"Clear Error Data",description:e.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===g,icon:(0,b.jsx)(ai.f,{className:"h-4 w-4"}),onClick:o}),a&&(0,b.jsx)(aT,{tone:"critical",title:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(J.f,{className:"h-4 w-4"}),e.settings?.systemReset||"System Initialization"]}),description:e.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===g,icon:(0,b.jsx)(ai.f,{className:"h-4 w-4"}),onClick:p})]})}var aV=a.i(613412),aW=a.i(536670);async function aX(a,b){let c=await fetch(a);if(!c.ok)throw Error((await c.json().catch(()=>({}))).message||"Download failed");let d=await c.blob(),e=window.URL.createObjectURL(d),f=document.createElement("a");f.href=e;let g=c.headers.get("Content-Disposition")?.match(/filename="(.+)"/);f.download=g?g[1]:b,document.body.appendChild(f),f.click(),document.body.removeChild(f),window.URL.revokeObjectURL(e)}function aY({isAdmin:a}){let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(!1),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(null),n=async a=>{if(!a||await (0,F.u)(e.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){i(!0);try{await aX(a?"/api/export?all=true":"/api/export",a?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),F.c.success(e.settings?.exportSuccess||"Export successful")}catch(b){h.V.error("[DataBackupSettings]",a?"Export all failed":"Export failed",{error:b}),F.c.error(e.settings?.exportFailed||"Export failed")}finally{i(!1)}}},o=async a=>{if(!l)return;let b=a?e.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":e.settings?.importConfirm||"Are you sure you want to import?";if(await (0,F.u)(b)){k(!0);try{let b=JSON.parse(await l.text()),{stats:c}=await f.k.post(a?"/api/import?all=true":"/api/import",b);F.c.success((e.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(c.subjectsCreated)).replace("{tags}",String(c.tagsCreated)).replace("{items}",String(c.errorItemsCreated)).replace("{schedules}",String(c.reviewSchedulesCreated)).replace("{records}",String(c.practiceRecordsCreated)).replace("{papers}",String(c.examPapersCreated??0)).replace("{voices}",String(c.ttsSpeechesImported??0)).replace("{duplicates}",String(c.duplicateErrorItems??0))),m(null),window.location.reload()}catch(b){h.V.error("[DataBackupSettings]",a?"Import all failed":"Import failed",{error:b}),F.c.error(e.settings?.importFailed||"Import failed")}finally{k(!1)}}},p=(a,c)=>a?(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}):c;return(0,b.jsxs)("div",{className:"p-4 border border-blue-200 dark:border-blue-900 rounded-lg bg-blue-50 dark:bg-blue-950/40",children:[(0,b.jsx)("h4",{className:"text-sm font-bold text-blue-900 dark:text-blue-200 mb-3",children:e.settings?.dataManagement||"Data Management"}),(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:e.settings?.exportData||"Export Data"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>n(!1),disabled:g,className:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800",children:[p(g,(0,b.jsx)(aW.f,{className:"mr-2 h-4 w-4"})),e.settings?.exportData||"Export"]}),a&&(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>n(!0),disabled:g,className:"bg-orange-100 dark:bg-orange-900/40 hover:bg-orange-200 dark:hover:bg-orange-900/60 text-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-800",children:[p(g,(0,b.jsx)(aW.f,{className:"mr-2 h-4 w-4"})),e.settings?.exportAllData||"Export All"]})]})]}),(0,b.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:e.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:e.settings?.importData||"Import Data"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("input",{type:"file",accept:".json",onChange:a=>m(a.target.files?.[0]??l),className:"hidden",id:"import-file-input",disabled:j}),(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:j,className:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800",children:[p(j,(0,b.jsx)(aH,{className:"mr-2 h-4 w-4"})),l?.name||e.settings?.selectFile||"Select File"]}),l&&(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>o(!1),disabled:j,className:"bg-green-100 dark:bg-green-900/40 hover:bg-green-200 dark:hover:bg-green-900/60 text-green-900 dark:text-green-200 border-green-300 dark:border-green-800",children:[p(j,(0,b.jsx)(aV.f,{className:"mr-2 h-4 w-4"})),e.settings?.importData||"Import"]}),l&&a&&(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>o(!0),disabled:j,className:"bg-orange-100 dark:bg-orange-900/40 hover:bg-orange-200 dark:hover:bg-orange-900/60 text-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-800",children:[p(j,(0,b.jsx)(aV.f,{className:"mr-2 h-4 w-4"})),e.settings?.importAllData||"Import All"]})]})]}),(0,b.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:e.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}let aZ={name:"bug",size:24,node:[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]]};aZ.node;let a$=(0,A.f)(aZ),a_="/api/admin/debug-logs";function a0(){let{t:a}=(0,d.b)(),{timeZone:e}=(0,v.M)(),g=a.admin.debugLog,[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!1),m=(0,c.useCallback)(async()=>{try{j(await f.k.get(a_))}catch(a){h.V.warn("[DebugLogSettings]","Failed to load debug status",{error:a})}},[]);(0,c.useEffect)(()=>{m()},[m]),(0,c.useEffect)(()=>{if(!i?.enabled)return;let a=setInterval(m,5e3);return()=>clearInterval(a)},[i?.enabled,m]);let n=async(a,b)=>{l(!0);try{await a(),F.c.success(b)}catch(a){h.V.error("[DebugLogSettings]","Debug log action failed",{error:a}),F.c.error(g.failed)}finally{l(!1)}},o=a=>a?(0,Z.r)(a,"yyyy-MM-dd HH:mm",e):"",p=i?.enabled?g.enabledHint.replace("{since}",o(i.enabledAt)).replace("{until}",o(i.expiresAt)):g.disabledHint,q=(i?.entryCount??0)>0;return(0,b.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)(ab.f,{htmlFor:"debug-mode-switch",className:"flex items-center gap-2 font-medium",children:[(0,b.jsx)(a$,{className:"h-4 w-4"}),g.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.desc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)("span",{className:"text-sm text-muted-foreground",children:g.enable}),(0,b.jsx)(_.f,{id:"debug-mode-switch",checked:!!i?.enabled,onCheckedChange:a=>n(async()=>{j(await f.k.post(a_,{enabled:a}))},a?g.enabled:g.disabled),disabled:k||!i})]})]}),(0,b.jsxs)("p",{className:`text-xs ${i?.enabled?"text-orange-600":"text-muted-foreground"}`,children:[p,i&&(0,b.jsxs)(b.Fragment,{children:[" ",g.entries.replace("{count}",String(i.entryCount)),i.droppedCount>0&&g.dropped.replace("{count}",String(i.droppedCount))]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>n(async()=>{await aX(`${a_}/export`,"wrong-notebook-debug.json"),await m()},g.exported),disabled:k||!q,className:"sm:flex-1",children:[k?(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(aW.f,{className:"mr-2 h-4 w-4"}),g.export]}),(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>n(async()=>{j(await f.k.delete(a_))},g.cleared),disabled:k||!q,children:[(0,b.jsx)(ai.f,{className:"mr-2 h-4 w-4"}),g.clear]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.privacyNote})]})}var a1=a.i(225949);function a2({field:a,label:e,description:g}){let{t:i}=(0,d.b)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=`preference-${a}`;(0,c.useEffect)(()=>{f.k.get("/api/user").then(b=>k(!!b[a])).catch(()=>void 0).finally(()=>m(!0))},[a]);let s=async b=>{k(b),o(!0);try{await f.k.patch("/api/user",{[a]:b}),q(i.importFlow.preferenceSaved)}catch(c){k(!b),q(i.importFlow.preferenceSaveFailed),h.V.error("[Settings]","Failed to save user preference",{field:a,error:c instanceof Error?c.message:String(c)})}finally{o(!1)}};return(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,b.jsx)(ab.f,{htmlFor:r,children:e}),(0,b.jsx)(_.f,{id:r,checked:j,onCheckedChange:s,disabled:!l||n})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),p&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:p})]})}function a3(){let{t:a}=(0,d.b)();return(0,b.jsx)(a2,{field:"enableGeogebra",label:a.importFlow.enableGeogebra,description:a.importFlow.enableGeogebraDesc})}function a4(){let{t:a}=(0,d.b)();return(0,b.jsx)(a2,{field:"confirmBeforeImport",label:a.importFlow.confirmBeforeImport,description:a.importFlow.confirmBeforeImportDesc})}var a5=a.i(249479);function a6(){let{t:a}=(0,d.b)(),[e,g]=(0,c.useState)(String(a5.z)),[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)(null),q=Number(e),r=""!==e.trim()&&Number.isInteger(q)&&q>=a5.P&&q<=a5.o,s=(0,c.useCallback)(async()=>{l(!0),p(null);try{let a=(await f.k.get("/api/user")).masteryThreshold??a5.z;g(String(a)),j(a)}catch(b){p(a.mastery.thresholdLoadFailed),h.V.error("[Settings]","加载已掌握阈值失败",{error:b instanceof Error?b.message:String(b)})}finally{l(!1)}},[a.mastery.thresholdLoadFailed]);(0,c.useEffect)(()=>{s()},[s]);let t=async()=>{if(r&&null!==i){n(!0),p(null);try{let b=(await f.k.patch("/api/user",{masteryThreshold:q})).masteryThreshold??q;j(b),g(String(b)),p(a.importFlow.preferenceSaved)}catch(b){p(a.importFlow.preferenceSaveFailed),h.V.error("[Settings]","保存已掌握阈值失败",{error:b instanceof Error?b.message:String(b)})}finally{n(!1)}}};return(0,b.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,b.jsx)(ab.f,{htmlFor:"mastery-threshold",children:a.mastery.thresholdLabel}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(aa.f,{id:"mastery-threshold",type:"number",min:a5.P,max:a5.o,step:1,value:e,onChange:a=>{g(a.target.value),p(null)},disabled:k||m||null===i,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,b.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,b.jsxs)(W.f,{type:"button",size:"sm",variant:"outline",onClick:t,disabled:k||m||null===i||!r||q===i,children:[(k||m)&&(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.importFlow.saveThreshold]}),!k&&null===i&&(0,b.jsx)(W.f,{type:"button",size:"sm",variant:"outline",onClick:s,children:a.importFlow.retryLoad})]}),(0,b.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:a.mastery.thresholdDescription}),null!==i&&!r&&(0,b.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:a.mastery.thresholdInvalid}),o&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:o})]})}var a7=a.i(393045);function a8(){let{t:a}=(0,d.b)(),[e,i]=(0,c.useState)({gradeRecognitionMode:"fixed",fixedGradeSemester:null}),[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=(0,c.useRef)(0),s=(0,c.useCallback)(async()=>{let b=++r.current;m(!0),q(null);try{let a=await f.k.get("/api/user");if(b!==r.current)return;let c={gradeRecognitionMode:a.gradeRecognitionMode??"fixed",fixedGradeSemester:a.fixedGradeSemester??null};i(c),k(c)}catch(c){if(b!==r.current)return;q(a.questionGrade.loadFailed),h.V.error("[QuestionGradeSetting]","加载录入年级规则失败",{error:(0,g.Z)(c)})}finally{b===r.current&&m(!1)}},[a.questionGrade.loadFailed]);(0,c.useEffect)(()=>{s()},[s]);let t=async()=>{o(!0),q(null);try{let b=await f.k.patch("/api/user",e),c={gradeRecognitionMode:b.gradeRecognitionMode??e.gradeRecognitionMode,fixedGradeSemester:b.fixedGradeSemester??null};i(c),k(c),q(a.importFlow.preferenceSaved)}catch(b){q(a.importFlow.preferenceSaveFailed),h.V.error("[QuestionGradeSetting]","保存录入年级规则失败",{error:(0,g.Z)(b)})}finally{o(!1)}},u=l||n||null===j,v=j?.gradeRecognitionMode===e.gradeRecognitionMode&&j?.fixedGradeSemester===e.fixedGradeSemester;return(0,b.jsxs)("div",{className:"space-y-3 border-t pt-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{htmlFor:"question-grade-mode",children:a.questionGrade.label}),(0,b.jsxs)("select",{id:"question-grade-mode",value:e.gradeRecognitionMode,disabled:u,onChange:a=>{i({...e,gradeRecognitionMode:a.target.value}),q(null)},className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm disabled:opacity-50",children:[(0,b.jsx)("option",{value:"fixed",children:a.questionGrade.fixed}),(0,b.jsx)("option",{value:"ai",children:a.questionGrade.ai})]})]}),"fixed"===e.gradeRecognitionMode&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{htmlFor:"question-fixed-grade",children:a.editor.gradeSemester}),(0,b.jsx)(a7.f,{id:"question-fixed-grade",value:e.fixedGradeSemester??"",disabled:u,onChange:a=>{i({...e,fixedGradeSemester:a||null}),q(null)}})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"fixed"===e.gradeRecognitionMode?a.questionGrade.fixedDescription:a.questionGrade.aiDescription}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:a.questionGrade.description}),(0,b.jsxs)(W.f,{type:"button",variant:"outline",size:"sm",disabled:u||v,onClick:t,children:[(l||n)&&(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.questionGrade.save]}),!l&&null===j&&(0,b.jsx)(W.f,{type:"button",variant:"outline",size:"sm",onClick:s,children:a.importFlow.retryLoad}),p&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:p})]})}function a9(){let{t:a}=(0,d.b)();return(0,b.jsx)(a2,{field:"enableSvgAnimation",label:a.importFlow.enableSvgAnimation,description:a.importFlow.enableSvgAnimationDesc})}function ba({value:a,onChange:c,disabled:e}){let{t:f}=(0,d.b)();return(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsx)(ab.f,{htmlFor:"app-time-zone",children:f.settings.general.timeZoneLabel}),(0,b.jsx)(aa.f,{id:"app-time-zone",value:a,onChange:a=>c(a.target.value),disabled:e,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,b.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(a=>(0,b.jsx)("option",{value:a},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:f.settings.general.timeZoneDesc})]})}function bb({config:a,setConfig:c,isAdmin:e,disabled:f}){let{t:g,language:h,setLanguage:i}=(0,d.b)(),{timeZone:j}=(0,v.M)(),k=a=>c(b=>({...b,timeouts:{...b.timeouts,analyze:1e3*a}}));return(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:g.settings?.language||"Language"}),(0,b.jsxs)(aA.d,{value:h,onValueChange:a=>i(a),children:[(0,b.jsx)(aA.P,{children:(0,b.jsx)(aA.U,{})}),(0,b.jsxs)(aA.r,{children:[(0,b.jsx)(aA.T,{value:"zh",children:"中文 (Chinese)"}),(0,b.jsx)(aA.T,{value:"en",children:"English"})]})]})]}),(0,b.jsx)(ba,{value:a.timeZone??j,onChange:a=>c(b=>({...b,timeZone:a})),disabled:!e||f}),e&&(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsx)(ab.f,{children:g.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,b.jsx)(aa.f,{type:"number",value:a.timeouts?.analyze?a.timeouts.analyze/1e3:"",onChange:a=>{let b=""===a.target.value?0:parseInt(a.target.value);k(isNaN(b)?0:b)},onBlur:()=>{let b=(a.timeouts?.analyze||0)/1e3,c=Math.min(600,Math.max(120,b));c!==b&&k(c)},min:120,max:600}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,b.jsx)(a4,{}),(0,b.jsx)(a8,{}),(0,b.jsx)(a9,{}),(0,b.jsx)(a3,{}),(0,b.jsx)(a1.f,{}),(0,b.jsx)(a6,{})]})}var bc=a.i(483138),bd=a.i(403512),be=a.i(591119),bf=a.i(515108);function bg(){let{t:a}=(0,d.b)(),{groups:e,loading:g,refetch:i}=(0,bf.f)(),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(!1),n=async()=>{let b=j.trim();if(b){m(!0);try{await f.k.post("/api/paper-groups",{name:b}),k(""),F.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to add group",{error:b}),F.c.error(a.common?.messages?.saveFailed||"Failed to save")}finally{m(!1)}}},o=async(b,c)=>{let d=window.prompt(a.settings?.paperGroups?.renamePrompt||"Rename group",c);if(d&&d.trim()!==c)try{await f.k.patch(`/api/paper-groups/${b}`,{name:d.trim()}),F.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to rename group",{error:b}),F.c.error(a.common?.messages?.saveFailed||"Failed to save")}},p=async(b,c)=>{try{await f.k.patch(`/api/paper-groups/${b}`,{isActive:!c}),F.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to toggle group",{error:b}),F.c.error(a.common?.messages?.saveFailed||"Failed to save")}},q=async(b,c,d)=>{if(d>0){let e=(a.settings?.paperGroups?.deleteConfirmWithItems||'Group "{name}" has {count} questions. Deleting will clear their group assignment. Continue?').replace("{name}",c).replace("{count}",String(d));if(!await (0,F.u)(e,{destructive:!0}))return;try{await f.k.delete(`/api/paper-groups/${b}?clear=true`),F.c.success(a.common?.messages?.deleteSuccess||"Deleted"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to delete group",{error:b}),F.c.error(a.common?.messages?.deleteFailed||"Delete failed")}return}let e=(a.settings?.paperGroups?.deleteConfirm||'Delete group "{name}"?').replace("{name}",c);if(await (0,F.u)(e,{destructive:!0}))try{await f.k.delete(`/api/paper-groups/${b}`),F.c.success(a.common?.messages?.deleteSuccess||"Deleted"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to delete group",{error:b}),F.c.error(a.common?.messages?.deleteFailed||"Delete failed")}};return g?(0,b.jsx)(be.N,{children:(0,b.jsx)(be.O,{className:"py-12 flex items-center justify-center",children:(0,b.jsx)(D.f,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):(0,b.jsxs)(be.N,{children:[(0,b.jsxs)(be.Y,{children:[(0,b.jsxs)(be.v,{className:"flex items-center gap-2 text-lg",children:[(0,b.jsx)(bc.f,{className:"h-5 w-5"}),a.settings?.paperGroups?.title||"Paper Groups"]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:a.settings?.paperGroups?.desc||"Customize paper groups like Unit Test, Midterm, Final. Default groups A/B/Other can be renamed but not deleted."})]}),(0,b.jsxs)(be.O,{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)(aa.f,{value:j,onChange:a=>k(a.target.value),placeholder:a.settings?.paperGroups?.addPlaceholder||"e.g. Unit Test",onKeyDown:a=>{"Enter"===a.key&&n()}}),(0,b.jsxs)(W.f,{onClick:n,disabled:l||!j.trim(),children:[l?(0,b.jsx)(D.f,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(bd.f,{className:"h-4 w-4 mr-1"}),a.common?.add||"Add"]})]}),(0,b.jsx)("div",{className:"space-y-2",children:e.map(c=>(0,b.jsxs)("div",{className:`flex items-center justify-between rounded-lg border p-3 ${!c.isActive?"opacity-50":""}`,children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("span",{className:"font-medium",children:c.name}),c.key&&(0,b.jsx)($.f,{variant:"secondary",className:"text-xs",children:a.settings?.paperGroups?.systemBadge||"Default"}),!c.isActive&&(0,b.jsx)($.f,{variant:"outline",className:"text-xs",children:a.common?.inactive||"Inactive"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsx)(W.f,{variant:"ghost",size:"sm",onClick:()=>o(c.id,c.name),children:a.common?.rename||"Rename"}),(0,b.jsx)(W.f,{variant:"ghost",size:"sm",onClick:()=>p(c.id,c.isActive),children:c.isActive?a.common?.deactivate||"Deactivate":a.common?.activate||"Activate"}),!c.key&&(0,b.jsx)(W.f,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>q(c.id,c.name,c._count?.errorItems||0),children:(0,b.jsx)(ai.f,{className:"h-4 w-4"})})]})]},c.id))})]})]})}var bh=a.i(429246);let bi="[REDACTED]",bj=/api[-_]?key|password|passwd|secret|authorization|cookie|credential|private[-_]?key|^(access|refresh|id|auth|api|bearer|session|csrf|setup)?[-_]?token$/i,bk=Symbol.for("wrong-notebook.debug-log");function bl(){let a=globalThis,b=a[bk];return b||(b={enabledAt:null,entries:[],totalSize:0,dropped:0},a[bk]=b),b}function bm(a){let b=a.replace(/data:([\w.+-]+\/[\w.+-]+);base64,[A-Za-z0-9+/=]+/g,(a,b)=>`[data:${b}, ${a.length} chars]`).replace(/(Bearer\s+)[\w\-.~+/]+=*/gi,`$1${bi}`).replace(/\bsk-[A-Za-z0-9_-]{8,}/g,bi).replace(/([?&](?:key|api_key|apikey|token|access_token)=)[^&\s"']+/gi,`$1${bi}`);return b.length>1e4&&(b=`${b.slice(0,1e4)}…[truncated ${b.length-1e4} chars]`),b}function bn(a,b,c,d=new Date){if(function(a=Date.now()){let b=bl();return null!==b.enabledAt&&(!(a-b.enabledAt>=864e5)||(b.enabledAt=null,!1))}(d.getTime()))try{let e={...function a(b,c=0,d=new WeakSet){if(null==b)return b;if("string"==typeof b)return bm(b);if("number"==typeof b||"boolean"==typeof b)return b;if("bigint"==typeof b)return b.toString();if("function"==typeof b||"symbol"==typeof b)return String(b);if(b instanceof Date)return b.toISOString();if(b instanceof Error){let e={name:b.name,message:bm(b.message)};return b.stack&&(e.stack=bm(b.stack)),void 0!==b.code&&(e.code=a(b.code,c+1,d)),void 0!==b.status&&(e.status=a(b.status,c+1,d)),void 0!==b.cause&&c<8&&(e.cause=a(b.cause,c+1,d)),e}if("object"!=typeof b)return String(b);if(d.has(b))return"[Circular]";if(c>=8)return"[Object]";if(d.add(b),Array.isArray(b)){let e=b.slice(0,100).map(b=>a(b,c+1,d));return b.length>100&&e.push(`…[${b.length-100} more items]`),e}return ArrayBuffer.isView(b)||b instanceof ArrayBuffer?`[Binary ${b.byteLength} bytes]`:Object.fromEntries(Object.entries(b).map(([b,e])=>[b,bj.test(b)&&null!=e&&""!==e?bi:a(e,c+1,d)]))}(b),time:d.toISOString(),level:a,msg:bm(c)},f=JSON.stringify(e).length,g=bl();for(g.entries.push({entry:e,size:f}),g.totalSize+=f;g.entries.length>5e3||g.totalSize>0x1400000&&g.entries.length>1;){let a=g.entries.shift();if(!a)break;g.totalSize-=a.size,g.dropped+=1}}catch{}}let bo={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function bp(a,b={}){let c,d=bo[a],e=(c=process.env.LOG_LEVEL?.toLowerCase())&&void 0!==bo[c]?bo[c]:bo.info;return(c,f)=>{let g,h,i=new Date;if("string"==typeof c?(g={},h=c):(g=c,h=f||""),bn(a,{...b,...g},h,i),!(d<e)){let c=JSON.stringify({level:a,time:i.toISOString(),...b,...g,msg:h});switch(a){case"error":case"fatal":console.error(c);break;case"warn":console.warn(c);break;default:console.log(c)}}}}let bq=function a(b={}){return b.module,{trace:bp("trace",b),debug:bp("debug",b),info:bp("info",b),warn:bp("warn",b),error:bp("error",b),fatal:bp("fatal",b),child:c=>a({...b,...c}),box:(a,c,d="📋")=>{bn("info",{...b,..."string"==typeof c?{content:c}:c},a);{let d="string"==typeof c?{content:c}:c||{};console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...b,title:a,...d,msg:a}));return}},divider:(a="-")=>{}}}({env:"production"});var br=a.i(62832);bq.child({module:"ai:prompts"});let bs=`请参考《高思学校竞赛数学导引》(每讲分兴趣篇、拓展篇、超越篇,题目左侧标 1~5 颗星)的星级标准,结合题目所在年级评定难度:
2
2
  - 1 星:课本基础题,直接套用概念、公式或简单计算即可(相当于兴趣篇前几题)。
3
3
  - 2 星:校内拔高题,需要两三步推理或简单综合(相当于兴趣篇后几题)。
4
4
  - 3 星:常规奥数题,小升初、杯赛常见难度,需要掌握该专题的典型方法(相当于拓展篇)。
5
5
  - 4 星:较难奥数题,需要构造、分类讨论、转化或多种方法综合(相当于拓展篇末题、超越篇前几题)。
6
6
  - 5 星:竞赛压轴题,集训队水平,思路巧妙、步骤长(相当于超越篇难题)。
7
- 非数学学科按同样的 1~5 级划分:1 星为基础识记,3 星为综合应用,5 星为竞赛或压轴难度。`,bw=`- 输出一个完整的 <svg> 元素,包含 xmlns="http://www.w3.org/2000/svg" 和 viewBox(建议宽 400~600),不要用 Markdown 代码块包裹。
7
+ 非数学学科按同样的 1~5 级划分:1 星为基础识记,3 星为综合应用,5 星为竞赛或压轴难度。`,bt=`- 输出一个完整的 <svg> 元素,包含 xmlns="http://www.w3.org/2000/svg" 和 viewBox(建议宽 400~600),不要用 Markdown 代码块包裹。
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>、外部链接、外部字体或事件属性。`,bx=String.raw`- 行内公式用 $...$,独立公式用 $$...$$;不要用 \(...\) 或 \[...\],每个 $ 必须成对出现。
11
+ - 严禁使用 <image>、<script>、<foreignObject>、外部链接、外部字体或事件属性。`,bu=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{...} 必须对应。
15
15
  - 公式中的中文写在 \text{...} 里,或放到公式外;百分号写成 \%,美元符号写成 \$。
16
- - 反斜杠只写一个(\frac),不要写成 \\frac;换行符 \\ 只能用在 cases、aligned 等环境里。`,by=`【角色与核心任务 (ROLE AND CORE TASK)】
16
+ - 反斜杠只写一个(\frac),不要写成 \\frac;换行符 \\ 只能用在 cases、aligned 等环境里。`,bv=`【角色与核心任务 (ROLE AND CORE TASK)】
17
17
  你是一位世界顶尖的、经验丰富的、专业的跨学科考试分析专家(Interdisciplinary Exam Analysis Expert)。你的核心任务是极致准确地分析用户提供的考试题目图片,全面理解所有文本、图表和隐含约束,并提供一个完整、高度结构化且专业的解决方案。
18
18
 
19
19
  {{language_instruction}}
@@ -41,7 +41,7 @@ module.exports=[418175,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(55
41
41
 
42
42
  <figure_svg>
43
43
  如果 has_figure 为 true,用 SVG 重新绘制题目配图:
44
- ${bw}
44
+ ${bt}
45
45
  如果 has_figure 为 false,请留空。
46
46
  </figure_svg>
47
47
 
@@ -55,7 +55,7 @@ ${bw}
55
55
 
56
56
  <difficulty_stars>
57
57
  只填写 1 到 5 之间的一个整数,表示题目难度星级。
58
- ${bv}
58
+ ${bs}
59
59
  </difficulty_stars>
60
60
 
61
61
  <mistake_analysis>
@@ -132,10 +132,10 @@ ${bv}
132
132
  3. **内容完整**:如果包含子问题,请在 question_text 中完整列出。
133
133
  4. **禁止图片**:严禁包含任何图片链接或 markdown 图片语法。
134
134
  5. **LaTeX 规范**:
135
- ${bx}
135
+ ${bu}
136
136
 
137
137
  {{grade_instruction}}
138
- {{provider_hints}}`,bz=`你是一位资深的K12教育题目生成专家,具备跨学科的题目创作能力。你的核心任务是**根据以下原题和知识点,举一反三生成高质量教学题目**,帮助学生巩固知识并拓展解题思路。
138
+ {{provider_hints}}`,bw=`你是一位资深的K12教育题目生成专家,具备跨学科的题目创作能力。你的核心任务是**根据以下原题和知识点,举一反三生成高质量教学题目**,帮助学生巩固知识并拓展解题思路。
139
139
  ### 角色定义
140
140
  1. **学科全能专家**
141
141
  - 精通K12阶段所有学科(数学/语文/英语/物理/化学/生物/历史/地理/政治)
@@ -187,9 +187,9 @@ ${bx}
187
187
  ###关键格式与内容约束 (CRITICAL RULES) !!!
188
188
  1. **纯文本**:内容作为纯文本处理,**不要转义反斜杠**。
189
189
  2. **LaTeX 规范**:
190
- ${bx}
190
+ ${bu}
191
191
 
192
192
  {{grade_instruction}}
193
- {{provider_hints}}`;bu.I.join("、"),bu.r.join("、");var bA=a.i(533838);function bB({name:a,description:c}){return(0,b.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,b.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-primary shrink-0 w-fit",children:`{{${a}}}`}),(0,b.jsx)("span",{className:"text-muted-foreground",children:c})]})}function bC(){let{t:a}=(0,d.b)();return(0,b.jsxs)("div",{className:"bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-900 rounded-md p-3 flex items-start gap-3 text-amber-900 dark:text-amber-200 text-sm mb-4",children:[(0,b.jsx)(P.f,{className:"h-5 w-5 shrink-0 text-amber-600"}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"font-medium",children:a.settings?.prompts?.caution||"Modify with Caution"}),(0,b.jsx)("p",{className:"text-amber-800/90 dark:text-amber-200 text-xs",children:a.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 bD({config:a,onUpdate:c}){let{t:e}=(0,d.b)(),f=a.prompts?.analyze||by,g=a.prompts?.similar||bz,h=async a=>{await (0,L.u)(e.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&c(a,"analyze"===a?by:bz)},i=(a,b)=>{c(a,b)};return(0,b.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,b.jsxs)(ab.i,{defaultValue:"analyze",className:"w-full",children:[(0,b.jsxs)(ab.U,{className:"grid w-full grid-cols-2",children:[(0,b.jsx)(ab.k,{value:"analyze",children:e.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,b.jsx)(ab.k,{value:"similar",children:e.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,b.jsx)(ab.S,{value:"analyze",className:"space-y-4 py-4",children:(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex justify-between items-center",children:[(0,b.jsx)(ag.f,{className:"text-base font-semibold",children:e.settings?.prompts?.customAnalysis||"Custom Analysis Template"}),(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>h("analyze"),children:[(0,b.jsx)(bA.f,{className:"w-4 h-4 mr-2"}),e.settings?.prompts?.reset||"Reset Default"]})]}),(0,b.jsx)(bC,{}),(0,b.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,b.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,b.jsx)(T,{className:"h-3.5 w-3.5"}),e.settings?.prompts?.variables||"Available Variables"]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(bB,{name:"language_instruction",description:e.settings?.prompts?.vars?.languageInstruction||"Injects instructions based on target language (e.g., keep English questions in English but analysis in Chinese)."}),(0,b.jsx)(bB,{name:"knowledge_points_list",description:e.settings?.prompts?.vars?.knowledgePointsList||"Injects the standard list of knowledge point tags for the specific subject."}),(0,b.jsx)(bB,{name:"provider_hints",description:e.settings?.prompts?.vars?.providerHints||"Provider compatibility hints that follow the application output contract."})]})]}),(0,b.jsx)(bk.f,{value:f,onChange:a=>i("analyze",a.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:by})]})}),(0,b.jsx)(ab.S,{value:"similar",className:"space-y-4 py-4",children:(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex justify-between items-center",children:[(0,b.jsx)(ag.f,{className:"text-base font-semibold",children:e.settings?.prompts?.customSimilar||"Custom Similar Question Template"}),(0,b.jsxs)(_.f,{variant:"outline",size:"sm",onClick:()=>h("similar"),children:[(0,b.jsx)(bA.f,{className:"w-4 h-4 mr-2"}),e.settings?.prompts?.reset||"Reset Default"]})]}),(0,b.jsx)(bC,{}),(0,b.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,b.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,b.jsx)(T,{className:"h-3.5 w-3.5"}),e.settings?.prompts?.variables||"Available Variables"]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(bB,{name:"difficulty_level",description:e.settings?.prompts?.vars?.difficultyLevel||"Target difficulty level."}),(0,b.jsx)(bB,{name:"difficulty_instruction",description:e.settings?.prompts?.vars?.difficultyInstruction||"Specific writing instructions for the target difficulty."}),(0,b.jsx)(bB,{name:"original_question",description:e.settings?.prompts?.vars?.originalQuestion||"The full text of the original question."}),(0,b.jsx)(bB,{name:"knowledge_points",description:e.settings?.prompts?.vars?.knowledgePoints||"List of knowledge points to test."}),(0,b.jsx)(bB,{name:"language_instruction",description:e.settings?.prompts?.vars?.languageInstructionShort||"Language formatting instructions."})]})]}),(0,b.jsx)(bk.f,{value:g,onChange:a=>i("similar",a.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:bz})]})})]})})}var bE=a.i(738835),bF=a.i(676330),bG=a.i(206194),bH=a.i(190622),bI=a.i(975484);let bJ=["browser","minimax","qwen","glm","stepfun","volcengine","volcengine-agent","openai"];bJ.filter(a=>"browser"!==a);let bK={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"}},bL={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"}},bM={volcengine:"https://docs.volcengine.com/docs/ark/free-inference-quota?lang=zh"};function bN({config:a,setConfig:e,saving:i,onSave:j}){var k;let{t:l,language:m}=(0,d.b)(),n=l.settings.tts,[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(null),s=a.tts?.mode??"browser",t="browser"!==s&&"string"==typeof(k=s)&&bJ.includes(k)?s:null,u=t?a.tts?.[t]:void 0,v=(a,b)=>{t&&e(c=>({...c,tts:{...c.tts,[t]:{...c.tts?.[t],[a]:b}}}))},w=!!t&&("volcengine"===t||"openai"===t),x=t?function(a,b){if("openai"===b){let b=a.openai?.instances?.find(b=>b.id===a.openai?.activeInstanceId);return b?{apiKey:b.apiKey,baseUrl:b.baseUrl}:void 0}return a[b]}(a,t):void 0,y=w?u?.apiKey:x?.apiKey,z=async()=>{(0,bI.p)(),p(!0),r(null);try{await j();let{id:a,version:b}=await f.k.post("/api/tts",{text:n.previewText,language:m},{timeout:12e4,recoverable:!0}),c=(0,bI.l)();if(!c)return;c.src=`/api/tts/${a}?v=${b}`,c.playbackRate=1,await c.play()}catch(b){h.V.error("[TtsSettings]","Preview failed",{error:b});let a=(0,g.d)(b);L.c.error("TTS_NOT_CONFIGURED"===a?n.notConfigured:"TTS_PROVIDER_ERROR"===a?n.providerError:n.previewFailed),r((0,g.L)(b)??null)}finally{p(!1)}};return(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ag.f,{children:n.title}),(0,b.jsxs)(aF.d,{value:s,onValueChange:a=>e(b=>({...b,tts:{...b.tts,mode:a}})),children:[(0,b.jsx)(aF.P,{children:(0,b.jsx)(aF.U,{})}),(0,b.jsx)(aF.r,{children:bJ.map(a=>(0,b.jsx)(aF.T,{value:a,children:n.modes[a]},a))})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:t?n.cloudHint:n.browserHint})]}),t&&(0,b.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[bM[t]&&(0,b.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:[n.freeTrial," ",(0,b.jsx)("a",{href:bM[t],target:"_blank",rel:"noopener noreferrer",className:"underline",children:n.freeTrialLink})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(bF.f,{label:"openai"===t?"OpenAI API Key":w?n.speechApiKey:`${(0,bH.z)(t,m)} API Key`,href:bL[t].apiKey,linkText:l.settings.ai.docLinks.apiKey}),(0,b.jsx)(aE.f,{value:y||"",onChange:a=>{var b;return b=a.target.value,void(t&&(w?v("apiKey",b):e(a=>({...a,[t]:{...a[t],apiKey:b}}))))},placeholder:"qwen"===t?"sk-sp-...":w?"":"sk-..."}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:n.apiKeyHint[t]})]}),(0,b.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(bF.f,{label:n.model,href:bL[t].model,linkText:n.docs}),(0,b.jsx)(af.f,{value:u?.model||"",onChange:a=>v("model",a.target.value),placeholder:bK[t].model})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(bF.f,{label:n.voice,href:bL[t].voice,linkText:n.voiceList}),(0,b.jsx)(af.f,{value:u?.voice||"",onChange:a=>v("voice",a.target.value),placeholder:bK[t].voice})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:n.voiceHint[t]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(bF.f,{label:n.endpoint,href:bL[t].endpoint,linkText:n.docs}),(0,b.jsx)(af.f,{value:u?.endpoint||"",onChange:a=>v("endpoint",a.target.value),placeholder:function(a,b){if("volcengine"===a)return"https://openspeech.bytedance.com/api/v3/tts/unidirectional";if("volcengine-agent"===a)return"https://openspeech.bytedance.com/api/v3/plan/tts/unidirectional";if("openai"===a)return`${(b?.baseUrl||"https://api.openai.com/v1").replace(/\/+$/,"")}/audio/speech`;let{baseUrl:c}=(0,bH.k)(a,b);if("minimax"===a)return`${c.replace(/\/+$/,"")}/t2a_v2`;if("glm"===a||"stepfun"===a)return`${c.replace(/\/+$/,"")}/audio/speech`;try{return`${new URL(c).origin}/api/v1/services/audio/tts/SpeechSynthesizer`}catch{return""}}(t,x)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:n.endpointHint})]})]},t),(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t&&(0,b.jsxs)(_.f,{variant:"outline",onClick:z,disabled:i||o,className:"sm:w-auto",children:[o?(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(bE.f,{className:"mr-2 h-4 w-4"}),n.preview]}),(0,b.jsxs)(_.f,{onClick:()=>void j(),disabled:i||o,className:"flex-1",children:[i&&(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.save]})]}),t&&q&&(0,b.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,b.jsx)(bG.f,{detail:q})})]})}var bO=a.i(439830);function bP({value:a,icon:c,label:d}){return(0,b.jsxs)(ab.k,{value:a,className:"px-2 sm:px-3",children:[c,(0,b.jsx)("span",{className:"hidden sm:inline",children:d})]})}function bQ(){let{setTimeZone:a}=(0,v.M)(),{data:g}=(0,e.useSession)(),i=g?.user?.role==="admin",{t:j}=(0,d.b)(),k=(0,y.useRouter)(),[l,m]=(0,c.useState)(!1),n=(0,c.useRef)(null),[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)({aiProvider:"minimax"}),u=(0,c.useCallback)(async()=>{r(!0);try{t(await f.k.get("/api/settings"))}catch(a){h.V.error("[SettingsDialog]","Failed to fetch settings",{error:a})}finally{r(!1)}},[]);(0,c.useEffect)(()=>{l&&u()},[l,u]);let w=async()=>{let b=(0,bO.f)(s,j);if(b)return void L.c.error(b);p(!0);try{let b=await f.k.post("/api/settings",s);t(b),a(b.timeZone||ac.J),L.c.success(j.settings?.messages?.saved||"Settings saved"),n.current?.scrollTo({top:0,behavior:"smooth"})}catch(a){h.V.error("[SettingsDialog]","Failed to save settings",{error:a}),L.c.error(j.settings?.messages?.saveFailed||"Failed to save")}finally{p(!1)}},x=a=>(0,b.jsxs)(_.f,{onClick:w,disabled:o,className:"w-full",children:[o&&(0,b.jsx)(J.f,{className:"mr-2 h-4 w-4 animate-spin"}),a]});return(0,b.jsxs)(aa.N,{open:l,onOpenChange:m,children:[(0,b.jsx)(aa.a,{asChild:!0,children:(0,b.jsxs)(_.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,b.jsx)(Y,{className:"h-5 w-5"}),(0,b.jsx)("span",{className:"sr-only",children:j.settings?.title||"Settings"})]})}),(0,b.jsxs)(aa.d,{ref:n,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,b.jsxs)(aa.s,{children:[(0,b.jsx)(aa.F,{children:j.settings?.title||"Settings"}),(0,b.jsx)(aa.C,{children:j.settings?.desc||"Manage your preferences and data."})]}),(0,b.jsxs)(ab.i,{defaultValue:"general",className:"w-full",children:[(0,b.jsxs)(ab.U,{className:`grid w-full grid-cols-4 ${i?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,b.jsx)(bP,{value:"general",icon:(0,b.jsx)(U.f,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.general||"General"}),(0,b.jsx)(bP,{value:"account",icon:(0,b.jsx)(Z.f,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.account||"Account"}),i&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bP,{value:"ai",icon:(0,b.jsx)(R,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.ai||"AI Provider"}),(0,b.jsx)(bP,{value:"prompts",icon:(0,b.jsx)(W,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.prompts||"Prompts"}),(0,b.jsx)(bP,{value:"admin",icon:(0,b.jsx)(I,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.admin||"User Management"})]}),(0,b.jsx)(bP,{value:"danger",icon:(0,b.jsx)(P.f,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.danger||"Danger"}),(0,b.jsx)(bP,{value:"about",icon:(0,b.jsx)(T,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.about||"About"})]}),(0,b.jsxs)(ab.S,{value:"general",className:"space-y-4 py-4",children:[(0,b.jsx)(bf,{config:s,setConfig:t,isAdmin:i,disabled:q||o}),(0,b.jsx)(bj,{}),i&&x(j.settings?.save||"Save Settings")]}),(0,b.jsx)(ab.S,{value:"account",className:"space-y-4 py-4",children:(0,b.jsx)(aI,{})}),(0,b.jsxs)(ab.S,{value:"ai",className:"space-y-4 py-4",children:[(0,b.jsx)(aJ.f,{config:s,setConfig:t,loading:q,saving:o,onSave:w}),!q&&(0,b.jsx)(bN,{config:s,setConfig:t,saving:o,onSave:w})]}),(0,b.jsxs)(ab.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,b.jsx)(bD,{config:s,onUpdate:(a,b)=>t(c=>({...c,prompts:{...c.prompts,[a]:b}}))}),x(j.settings?.prompts?.save||"Save Prompt Settings")]}),i&&(0,b.jsxs)(ab.S,{value:"admin",className:"space-y-4 py-4",children:[(0,b.jsxs)(_.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{m(!1),k.push("/admin")},children:[(0,b.jsx)(z.f,{className:"h-4 w-4"}),j.admin?.dashboard?.title||"Admin Dashboard"]}),(0,b.jsxs)(_.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{m(!1),k.push("/setup")},children:[(0,b.jsx)($.f,{className:"h-4 w-4"}),j.setup.rerun]}),(0,b.jsx)(a4,{}),(0,b.jsx)(aU,{}),(0,b.jsx)("div",{className:"border-t pt-4",children:(0,b.jsx)(as,{})})]}),(0,b.jsx)(ab.S,{value:"danger",className:"space-y-4 py-4",children:(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)(a0,{isAdmin:i}),(0,b.jsx)(aY,{isAdmin:i})]})}),(0,b.jsx)(ab.S,{value:"about",className:"space-y-4 py-4",children:(0,b.jsx)(aD,{})})]})]})]})}var bR=a.i(505004);let bS={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};bS.node;let bT=(0,E.f)(bS),bU={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};bU.node;let bV=(0,E.f)(bU);var bW=a.i(335732);let bX={system:bR.f,light:bV,dark:bT};function bY(){let{t:a}=(0,d.b)(),{preference:e,setPreference:f}=(0,c.useContext)(m),g=bX[e],h=`${a.theme.toggle}: ${a.theme[e]}`;return(0,b.jsxs)(bW.G,{children:[(0,b.jsx)(bW.X,{asChild:!0,children:(0,b.jsx)(_.f,{variant:"ghost",size:"icon",className:"rounded-full",title:h,"aria-label":h,children:(0,b.jsx)(g,{className:"h-5 w-5"})})}),(0,b.jsx)(bW.L,{align:"end",children:(0,b.jsx)(bW.O,{value:e,onValueChange:a=>{l(a)&&f(a)},children:i.map(c=>{let d=bX[c];return(0,b.jsxs)(bW.T,{value:c,className:"gap-2",children:[(0,b.jsx)(d,{className:"h-4 w-4"}),a.theme[c]]},c)})})})]})}let bZ=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],b$=[{key:"home",href:"/",icon:G,match:a=>"/"===a},{key:"notebooks",href:"/notebooks",icon:A.f,match:a=>a.startsWith("/notebooks")||a.startsWith("/error-items")||a.startsWith("/practice")},{key:"review",href:"/review",icon:B.f,match:a=>a.startsWith("/review")},{key:"stats",href:"/stats",icon:z.f,match:a=>a.startsWith("/stats")||a.startsWith("/tags")},{key:"exams",href:"/exams",icon:C.f,match:a=>a.startsWith("/exams")}];function b_({children:a}){var g;let i,j,k=(0,y.usePathname)()||"/",{t:l}=(0,d.b)(),{data:m,status:n}=(0,e.useSession)(),o=m?.user?.role==="admin",p=bZ.some(a=>a.test(k));if(g=o&&!p,i=(0,y.useRouter)(),j=(0,c.useRef)(!1),(0,c.useEffect)(()=>{g&&!j.current&&(j.current=!0,f.k.get("/api/setup").then(a=>{a.needsSetup&&i.replace("/setup")}).catch(a=>h.V.warn("[Setup]","Failed to check setup status",{error:a})))},[g,i]),p||"unauthenticated"===n)return(0,b.jsx)(b.Fragment,{children:a});let q=m?.user?.name||m?.user?.email||"";return(0,b.jsxs)("div",{className:"min-h-screen",children:[(0,b.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,b.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,b.jsxs)(x.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(w.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,b.jsx)("span",{className:"hidden text-base font-semibold tracking-tight sm:inline",children:l.pageTitle.base})]}),(0,b.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:b$.map(a=>{let c=a.match(k),d=a.icon;return(0,b.jsxs)(x.default,{href:a.href,className:(0,N.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",c?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":c?"page":void 0,children:[(0,b.jsx)(d,{className:"h-4 w-4"}),l.nav[a.key]]},a.key)})}),(0,b.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[q&&(0,b.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,b.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:q.slice(0,1).toUpperCase()}),(0,b.jsx)("span",{className:"truncate",children:q})]}),o&&(0,b.jsx)(x.default,{href:"/admin",title:l.nav.admin,children:(0,b.jsxs)(_.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,b.jsx)(I,{className:"h-5 w-5"}),(0,b.jsx)("span",{className:"sr-only",children:l.nav.admin})]})}),(0,b.jsx)(O,{className:"mr-1"}),(0,b.jsx)(bY,{}),(0,b.jsx)(bQ,{}),(0,b.jsx)(_.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,e.signOut)({callbackUrl:"/login"}),title:l.app.logout,children:(0,b.jsx)(D.f,{className:"h-5 w-5"})})]})]})}),(0,b.jsx)("div",{className:"pb-20 md:pb-0",children:a}),(0,b.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,b.jsx)("div",{className:"grid h-16 grid-cols-5",children:b$.map(a=>{let c=a.match(k),d=a.icon;return(0,b.jsxs)(x.default,{href:a.href,className:(0,N.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",c?"text-primary":"text-muted-foreground"),"aria-current":c?"page":void 0,children:[(0,b.jsx)("span",{className:(0,N.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",c&&"bg-accent"),children:(0,b.jsx)(d,{className:"h-5 w-5"})}),l.nav[a.key]]},a.key)})})})]})}let b0={name:"list-todo",size:24,node:[["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"}]]};b0.node;let b1=(0,E.f)(b0);var b2=a.i(211134);let b3=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function b4(){let{t:a}=(0,d.b)(),{timeZone:g}=(0,v.M)(),{status:h}=(0,e.useSession)(),i=(0,y.usePathname)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)([]),[n,o]=(0,c.useState)(()=>Date.now()),p="authenticated"!==h||b3.some(a=>a.test(i||"")),q=(0,c.useCallback)(async()=>{if("u"<typeof document||"hidden"!==document.visibilityState)try{let a=await f.k.get("/api/tasks");m(a.tasks),o(Date.now())}catch{}},[]);if((0,c.useEffect)(()=>{if(p)return;let a=setTimeout(q,0),b=setInterval(q,j?2e3:15e3);return()=>{clearTimeout(a),clearInterval(b)}},[p,j,q]),p)return null;let r=l.filter(a=>"running"===a.status).length,s=l.some(a=>"running"!==a.status),t=async()=>{try{let a=await f.k.delete("/api/tasks");m(a.tasks)}catch{}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(_.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:()=>k(!0),"aria-label":a.backgroundTasks.title,title:a.backgroundTasks.title,children:[r>0?(0,b.jsx)(J.f,{className:"h-5 w-5 animate-spin"}):(0,b.jsx)(b1,{className:"h-5 w-5"}),r>0&&(0,b.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:r})]}),(0,b.jsx)(aa.N,{open:j,onOpenChange:k,children:(0,b.jsxs)(aa.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,b.jsxs)(aa.s,{children:[(0,b.jsx)(aa.F,{children:a.backgroundTasks.title}),(0,b.jsx)(aa.C,{children:a.backgroundTasks.description})]}),0===l.length?(0,b.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:a.backgroundTasks.empty}):(0,b.jsx)("ul",{className:"space-y-2",children:l.map(c=>{var d,e;let f;return(0,b.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,b.jsxs)("div",{className:"flex items-start gap-2",children:["running"===c.status&&(0,b.jsx)(J.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===c.status&&(0,b.jsx)(aZ.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===c.status&&(0,b.jsx)(b2.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,b.jsxs)("div",{className:"font-medium",children:[a.backgroundTasks.kinds[c.kind],(0,b.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",a.backgroundTasks.status[c.status]]})]}),c.subject&&(0,b.jsx)("div",{className:"break-words text-muted-foreground",children:c.subject}),c.progress&&c.progress.total>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,b.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(c.progress.done/c.progress.total*100)}%`}})}),(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a.backgroundTasks.progress.replace("{done}",String(c.progress.done)).replace("{total}",String(c.progress.total)),c.progress.failed>0&&` \xb7 ${a.backgroundTasks.failedCount.replace("{count}",String(c.progress.failed))}`]})]}),c.error&&(0,b.jsx)("div",{className:"text-xs text-destructive",children:(b=>{if(!b)return null;let c=a.backgroundTasks.errors[b]??a.errors[b];return"string"==typeof c?c:b})(c.error)}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{children:a.backgroundTasks.startedAt.replace("{time}",(0,ac.r)(c.startedAt,"HH:mm:ss",g))}),(0,b.jsx)("span",{children:a.backgroundTasks.elapsed.replace("{time}",(d=c.startedAt,e=c.finishedAt,f=Math.max(0,Math.round(((e?Date.parse(e):n)-Date.parse(d))/1e3)),`${Math.floor(f/60)}:${String(f%60).padStart(2,"0")}`))}),c.link&&(0,b.jsx)(x.default,{href:c.link,className:"text-primary hover:underline",onClick:()=>k(!1),children:a.backgroundTasks.view})]})]})]})},c.id)})}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:a.backgroundTasks.retentionHint}),s&&(0,b.jsx)(_.f,{variant:"ghost",size:"sm",onClick:t,children:a.backgroundTasks.clearFinished})]})]})})]})}var b5=a.i(474215);let b6={success:{icon:aZ.f,className:"text-success"},error:{icon:b2.f,className:"text-destructive"},warning:{icon:P.f,className:"text-warning"},info:{icon:T,className:"text-primary"}};function b7(){let{t:a}=(0,d.b)(),[e,f]=(0,c.useState)([]),[g,h]=(0,c.useState)(null);return(0,c.useEffect)(()=>(0,L.M)(a=>{f(a.toasts),h(a.confirm)}),[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.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:e.map(c=>{let{icon:d,className:e}=b6[c.type];return(0,b.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,b.jsx)(d,{className:(0,N.f)("mt-0.5 h-4 w-4 shrink-0",e)}),(0,b.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:c.message}),(0,b.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,L.p)(c.id),"aria-label":a.common.close,children:(0,b.jsx)(b5.X,{className:"h-3.5 w-3.5"})})]},c.id)})}),(0,b.jsx)(aa.N,{open:!!g,onOpenChange:a=>{a||g?.resolve(!1)},children:(0,b.jsxs)(aa.d,{className:"sm:max-w-md",children:[(0,b.jsxs)(aa.s,{children:[(0,b.jsxs)(aa.F,{className:"flex items-center gap-2",children:[g?.destructive&&(0,b.jsx)(P.f,{className:"h-5 w-5 text-destructive"}),g?.title||a.common.confirmTitle]}),(0,b.jsx)(aa.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:g?.message})]}),(0,b.jsxs)(aa.c,{className:"gap-2",children:[(0,b.jsx)(_.f,{variant:"outline",onClick:()=>g?.resolve(!1),children:g?.cancelText||a.common.cancel}),(0,b.jsx)(_.f,{variant:g?.destructive?"destructive":"default",onClick:()=>g?.resolve(!0),autoFocus:!0,children:g?.confirmText||a.common.confirm})]})]})})]})}function b8(){return(0,c.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(a=>{h.V.warn("[PWA]","Service worker registration failed",{error:String(a)})})},[]),null}a.s(["Providers",0,function({children:a,timeZone:f}){return(0,c.useEffect)(()=>(0,h.m)(),[]),(0,b.jsx)(e.SessionProvider,{children:(0,b.jsx)(u,{children:(0,b.jsx)(d.w,{children:(0,b.jsxs)(v.n,{initialTimeZone:f,children:[(0,b.jsx)(b_,{children:a}),(0,b.jsx)(b4,{}),(0,b.jsx)(b7,{}),(0,b.jsx)(b8,{})]})})})})}],418175)}];
193
+ {{provider_hints}}`;br.I.join("、"),br.r.join("、");var bx=a.i(533838);function by({name:a,description:c}){return(0,b.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,b.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-primary shrink-0 w-fit",children:`{{${a}}}`}),(0,b.jsx)("span",{className:"text-muted-foreground",children:c})]})}function bz(){let{t:a}=(0,d.b)();return(0,b.jsxs)("div",{className:"bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-900 rounded-md p-3 flex items-start gap-3 text-amber-900 dark:text-amber-200 text-sm mb-4",children:[(0,b.jsx)(J.f,{className:"h-5 w-5 shrink-0 text-amber-600"}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"font-medium",children:a.settings?.prompts?.caution||"Modify with Caution"}),(0,b.jsx)("p",{className:"text-amber-800/90 dark:text-amber-200 text-xs",children:a.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 bA({config:a,onUpdate:c}){let{t:e}=(0,d.b)(),f=a.prompts?.analyze||bv,g=a.prompts?.similar||bw,h=async a=>{await (0,F.u)(e.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&c(a,"analyze"===a?bv:bw)},i=(a,b)=>{c(a,b)};return(0,b.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,b.jsxs)(Y.i,{defaultValue:"analyze",className:"w-full",children:[(0,b.jsxs)(Y.U,{className:"grid w-full grid-cols-2",children:[(0,b.jsx)(Y.k,{value:"analyze",children:e.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,b.jsx)(Y.k,{value:"similar",children:e.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,b.jsx)(Y.S,{value:"analyze",className:"space-y-4 py-4",children:(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex justify-between items-center",children:[(0,b.jsx)(ab.f,{className:"text-base font-semibold",children:e.settings?.prompts?.customAnalysis||"Custom Analysis Template"}),(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>h("analyze"),children:[(0,b.jsx)(bx.f,{className:"w-4 h-4 mr-2"}),e.settings?.prompts?.reset||"Reset Default"]})]}),(0,b.jsx)(bz,{}),(0,b.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,b.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,b.jsx)(O,{className:"h-3.5 w-3.5"}),e.settings?.prompts?.variables||"Available Variables"]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(by,{name:"language_instruction",description:e.settings?.prompts?.vars?.languageInstruction||"Injects instructions based on target language (e.g., keep English questions in English but analysis in Chinese)."}),(0,b.jsx)(by,{name:"knowledge_points_list",description:e.settings?.prompts?.vars?.knowledgePointsList||"Injects the standard list of knowledge point tags for the specific subject."}),(0,b.jsx)(by,{name:"provider_hints",description:e.settings?.prompts?.vars?.providerHints||"Provider compatibility hints that follow the application output contract."})]})]}),(0,b.jsx)(bh.f,{value:f,onChange:a=>i("analyze",a.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:bv})]})}),(0,b.jsx)(Y.S,{value:"similar",className:"space-y-4 py-4",children:(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex justify-between items-center",children:[(0,b.jsx)(ab.f,{className:"text-base font-semibold",children:e.settings?.prompts?.customSimilar||"Custom Similar Question Template"}),(0,b.jsxs)(W.f,{variant:"outline",size:"sm",onClick:()=>h("similar"),children:[(0,b.jsx)(bx.f,{className:"w-4 h-4 mr-2"}),e.settings?.prompts?.reset||"Reset Default"]})]}),(0,b.jsx)(bz,{}),(0,b.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,b.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,b.jsx)(O,{className:"h-3.5 w-3.5"}),e.settings?.prompts?.variables||"Available Variables"]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(by,{name:"difficulty_level",description:e.settings?.prompts?.vars?.difficultyLevel||"Target difficulty level."}),(0,b.jsx)(by,{name:"difficulty_instruction",description:e.settings?.prompts?.vars?.difficultyInstruction||"Specific writing instructions for the target difficulty."}),(0,b.jsx)(by,{name:"original_question",description:e.settings?.prompts?.vars?.originalQuestion||"The full text of the original question."}),(0,b.jsx)(by,{name:"knowledge_points",description:e.settings?.prompts?.vars?.knowledgePoints||"List of knowledge points to test."}),(0,b.jsx)(by,{name:"language_instruction",description:e.settings?.prompts?.vars?.languageInstructionShort||"Language formatting instructions."})]})]}),(0,b.jsx)(bh.f,{value:g,onChange:a=>i("similar",a.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:bw})]})})]})})}var bB=a.i(738835),bC=a.i(676330),bD=a.i(206194),bE=a.i(190622),bF=a.i(975484);let bG=["browser","minimax","qwen","glm","stepfun","volcengine","volcengine-agent","openai"];bG.filter(a=>"browser"!==a);let bH={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"}},bI={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"}},bJ={volcengine:"https://docs.volcengine.com/docs/ark/free-inference-quota?lang=zh"};function bK({config:a,setConfig:e,saving:i,onSave:j}){var k;let{t:l,language:m}=(0,d.b)(),n=l.settings.tts,[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(null),s=a.tts?.mode??"browser",t="browser"!==s&&"string"==typeof(k=s)&&bG.includes(k)?s:null,u=t?a.tts?.[t]:void 0,v=(a,b)=>{t&&e(c=>({...c,tts:{...c.tts,[t]:{...c.tts?.[t],[a]:b}}}))},w=!!t&&("volcengine"===t||"openai"===t),x=t?function(a,b){if("openai"===b){let b=a.openai?.instances?.find(b=>b.id===a.openai?.activeInstanceId);return b?{apiKey:b.apiKey,baseUrl:b.baseUrl}:void 0}return a[b]}(a,t):void 0,y=w?u?.apiKey:x?.apiKey,z=async()=>{(0,bF.p)(),p(!0),r(null);try{await j();let{id:a,version:b}=await f.k.post("/api/tts",{text:n.previewText,language:m},{timeout:12e4,recoverable:!0}),c=(0,bF.l)();if(!c)return;c.src=`/api/tts/${a}?v=${b}`,c.playbackRate=1,await c.play()}catch(b){h.V.error("[TtsSettings]","Preview failed",{error:b});let a=(0,g.d)(b);F.c.error("TTS_NOT_CONFIGURED"===a?n.notConfigured:"TTS_PROVIDER_ERROR"===a?n.providerError:n.previewFailed),r((0,g.L)(b)??null)}finally{p(!1)}};return(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ab.f,{children:n.title}),(0,b.jsxs)(aA.d,{value:s,onValueChange:a=>e(b=>({...b,tts:{...b.tts,mode:a}})),children:[(0,b.jsx)(aA.P,{children:(0,b.jsx)(aA.U,{})}),(0,b.jsx)(aA.r,{children:bG.map(a=>(0,b.jsx)(aA.T,{value:a,children:n.modes[a]},a))})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:t?n.cloudHint:n.browserHint})]}),t&&(0,b.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[bJ[t]&&(0,b.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:[n.freeTrial," ",(0,b.jsx)("a",{href:bJ[t],target:"_blank",rel:"noopener noreferrer",className:"underline",children:n.freeTrialLink})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(bC.f,{label:"openai"===t?"OpenAI API Key":w?n.speechApiKey:`${(0,bE.z)(t,m)} API Key`,href:bI[t].apiKey,linkText:l.settings.ai.docLinks.apiKey}),(0,b.jsx)(az.f,{value:y||"",onChange:a=>{var b;return b=a.target.value,void(t&&(w?v("apiKey",b):e(a=>({...a,[t]:{...a[t],apiKey:b}}))))},placeholder:"qwen"===t?"sk-sp-...":w?"":"sk-..."}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:n.apiKeyHint[t]})]}),(0,b.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(bC.f,{label:n.model,href:bI[t].model,linkText:n.docs}),(0,b.jsx)(aa.f,{value:u?.model||"",onChange:a=>v("model",a.target.value),placeholder:bH[t].model})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(bC.f,{label:n.voice,href:bI[t].voice,linkText:n.voiceList}),(0,b.jsx)(aa.f,{value:u?.voice||"",onChange:a=>v("voice",a.target.value),placeholder:bH[t].voice})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:n.voiceHint[t]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(bC.f,{label:n.endpoint,href:bI[t].endpoint,linkText:n.docs}),(0,b.jsx)(aa.f,{value:u?.endpoint||"",onChange:a=>v("endpoint",a.target.value),placeholder:function(a,b){if("volcengine"===a)return"https://openspeech.bytedance.com/api/v3/tts/unidirectional";if("volcengine-agent"===a)return"https://openspeech.bytedance.com/api/v3/plan/tts/unidirectional";if("openai"===a)return`${(b?.baseUrl||"https://api.openai.com/v1").replace(/\/+$/,"")}/audio/speech`;let{baseUrl:c}=(0,bE.k)(a,b);if("minimax"===a)return`${c.replace(/\/+$/,"")}/t2a_v2`;if("glm"===a||"stepfun"===a)return`${c.replace(/\/+$/,"")}/audio/speech`;try{return`${new URL(c).origin}/api/v1/services/audio/tts/SpeechSynthesizer`}catch{return""}}(t,x)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:n.endpointHint})]})]},t),(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t&&(0,b.jsxs)(W.f,{variant:"outline",onClick:z,disabled:i||o,className:"sm:w-auto",children:[o?(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(bB.f,{className:"mr-2 h-4 w-4"}),n.preview]}),(0,b.jsxs)(W.f,{onClick:()=>void j(),disabled:i||o,className:"flex-1",children:[i&&(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.save]})]}),t&&q&&(0,b.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,b.jsx)(bD.f,{detail:q})})]})}var bL=a.i(439830);function bM({value:a,icon:c,label:d}){return(0,b.jsxs)(Y.k,{value:a,className:"px-2 sm:px-3",children:[c,(0,b.jsx)("span",{className:"hidden sm:inline",children:d})]})}function bN(){let{setTimeZone:a}=(0,v.M)(),{data:g}=(0,e.useSession)(),i=g?.user?.role==="admin",{t:j}=(0,d.b)(),k=(0,y.useRouter)(),[l,m]=(0,c.useState)(!1),n=(0,c.useRef)(null),[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)({aiProvider:"minimax"}),u=(0,c.useCallback)(async()=>{r(!0);try{t(await f.k.get("/api/settings"))}catch(a){h.V.error("[SettingsDialog]","Failed to fetch settings",{error:a})}finally{r(!1)}},[]);(0,c.useEffect)(()=>{l&&u()},[l,u]);let w=async()=>{let b=(0,bL.f)(s,j);if(b)return void F.c.error(b);p(!0);try{let b=await f.k.post("/api/settings",s);t(b),a(b.timeZone||Z.J),F.c.success(j.settings?.messages?.saved||"Settings saved"),n.current?.scrollTo({top:0,behavior:"smooth"})}catch(a){h.V.error("[SettingsDialog]","Failed to save settings",{error:a}),F.c.error(j.settings?.messages?.saveFailed||"Failed to save")}finally{p(!1)}},x=a=>(0,b.jsxs)(W.f,{onClick:w,disabled:o,className:"w-full",children:[o&&(0,b.jsx)(D.f,{className:"mr-2 h-4 w-4 animate-spin"}),a]});return(0,b.jsxs)(X.N,{open:l,onOpenChange:m,children:[(0,b.jsx)(X.a,{asChild:!0,children:(0,b.jsxs)(W.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,b.jsx)(T,{className:"h-5 w-5"}),(0,b.jsx)("span",{className:"sr-only",children:j.settings?.title||"Settings"})]})}),(0,b.jsxs)(X.d,{ref:n,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,b.jsxs)(X.s,{children:[(0,b.jsx)(X.F,{children:j.settings?.title||"Settings"}),(0,b.jsx)(X.C,{children:j.settings?.desc||"Manage your preferences and data."})]}),(0,b.jsxs)(Y.i,{defaultValue:"general",className:"w-full",children:[(0,b.jsxs)(Y.U,{className:`grid w-full grid-cols-4 ${i?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,b.jsx)(bM,{value:"general",icon:(0,b.jsx)(P.f,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.general||"General"}),(0,b.jsx)(bM,{value:"account",icon:(0,b.jsx)(U.f,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.account||"Account"}),i&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bM,{value:"ai",icon:(0,b.jsx)(M,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.ai||"AI Provider"}),(0,b.jsx)(bM,{value:"prompts",icon:(0,b.jsx)(R,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.prompts||"Prompts"}),(0,b.jsx)(bM,{value:"admin",icon:(0,b.jsx)(C,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.admin||"User Management"})]}),(0,b.jsx)(bM,{value:"danger",icon:(0,b.jsx)(J.f,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.danger||"Danger"}),(0,b.jsx)(bM,{value:"about",icon:(0,b.jsx)(O,{className:"h-4 w-4 sm:mr-2"}),label:j.settings?.tabs?.about||"About"})]}),(0,b.jsxs)(Y.S,{value:"general",className:"space-y-4 py-4",children:[(0,b.jsx)(bb,{config:s,setConfig:t,isAdmin:i,disabled:q||o}),(0,b.jsx)(bg,{}),i&&x(j.settings?.save||"Save Settings")]}),(0,b.jsx)(Y.S,{value:"account",className:"space-y-4 py-4",children:(0,b.jsx)(aD,{})}),(0,b.jsxs)(Y.S,{value:"ai",className:"space-y-4 py-4",children:[(0,b.jsx)(aE.f,{config:s,setConfig:t,loading:q,saving:o,onSave:w}),!q&&(0,b.jsx)(bK,{config:s,setConfig:t,saving:o,onSave:w})]}),(0,b.jsxs)(Y.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,b.jsx)(bA,{config:s,onUpdate:(a,b)=>t(c=>({...c,prompts:{...c.prompts,[a]:b}}))}),x(j.settings?.prompts?.save||"Save Prompt Settings")]}),i&&(0,b.jsxs)(Y.S,{value:"admin",className:"space-y-4 py-4",children:[(0,b.jsxs)(W.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{m(!1),k.push("/admin")},children:[(0,b.jsx)(K.f,{className:"h-4 w-4"}),j.admin?.dashboard?.title||"Admin Dashboard"]}),(0,b.jsxs)(W.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{m(!1),k.push("/setup")},children:[(0,b.jsx)(V.f,{className:"h-4 w-4"}),j.setup.rerun]}),(0,b.jsx)(a0,{}),(0,b.jsx)(aQ,{}),(0,b.jsx)("div",{className:"border-t pt-4",children:(0,b.jsx)(an,{})})]}),(0,b.jsx)(Y.S,{value:"danger",className:"space-y-4 py-4",children:(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)(aY,{isAdmin:i}),(0,b.jsx)(aU,{isAdmin:i})]})}),(0,b.jsx)(Y.S,{value:"about",className:"space-y-4 py-4",children:(0,b.jsx)(ay,{})})]})]})]})}var bO=a.i(505004);let bP={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};bP.node;let bQ=(0,A.f)(bP),bR={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};bR.node;let bS=(0,A.f)(bR);var bT=a.i(335732);let bU={system:bO.f,light:bS,dark:bQ};function bV(){let{t:a}=(0,d.b)(),{preference:e,setPreference:f}=(0,c.useContext)(m),g=bU[e],h=`${a.theme.toggle}: ${a.theme[e]}`;return(0,b.jsxs)(bT.G,{children:[(0,b.jsx)(bT.X,{asChild:!0,children:(0,b.jsx)(W.f,{variant:"ghost",size:"icon",className:"rounded-full",title:h,"aria-label":h,children:(0,b.jsx)(g,{className:"h-5 w-5"})})}),(0,b.jsx)(bT.L,{align:"end",children:(0,b.jsx)(bT.O,{value:e,onValueChange:a=>{l(a)&&f(a)},children:i.map(c=>{let d=bU[c];return(0,b.jsxs)(bT.T,{value:c,className:"gap-2",children:[(0,b.jsx)(d,{className:"h-4 w-4"}),a.theme[c]]},c)})})})]})}var bW=a.i(895605);let bX={name:"circle-plus",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],aliases:["plus-circle"]};bX.node;let bY=(0,A.f)(bX),bZ=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],b$=[{key:"home",href:"/",icon:bY,match:a=>"/"===a},{key:"notebooks",href:"/notebooks",icon:aF.f,match:a=>a.startsWith("/notebooks")||a.startsWith("/error-items")||a.startsWith("/practice")},{key:"review",href:"/review",icon:bW.f,match:a=>a.startsWith("/review")},{key:"stats",href:"/stats",icon:K.f,match:a=>a.startsWith("/stats")||a.startsWith("/tags")},{key:"exams",href:"/exams",icon:bc.f,match:a=>a.startsWith("/exams")}];function b_({children:a}){var g;let i,j,k=(0,y.usePathname)()||"/",{t:l}=(0,d.b)(),{data:m,status:n}=(0,e.useSession)(),o=m?.user?.role==="admin",p=bZ.some(a=>a.test(k));if(g=o&&!p,i=(0,y.useRouter)(),j=(0,c.useRef)(!1),(0,c.useEffect)(()=>{g&&!j.current&&(j.current=!0,f.k.get("/api/setup").then(a=>{a.needsSetup&&i.replace("/setup")}).catch(a=>h.V.warn("[Setup]","Failed to check setup status",{error:a})))},[g,i]),p||"unauthenticated"===n)return(0,b.jsx)(b.Fragment,{children:a});let q=m?.user?.name||m?.user?.email||"";return(0,b.jsxs)("div",{className:"min-h-screen",children:[(0,b.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,b.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,b.jsxs)(x.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(w.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,b.jsx)("span",{className:"hidden text-base font-semibold tracking-tight sm:inline",children:l.pageTitle.base})]}),(0,b.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:b$.map(a=>{let c=a.match(k),d=a.icon;return(0,b.jsxs)(x.default,{href:a.href,className:(0,H.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",c?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":c?"page":void 0,children:[(0,b.jsx)(d,{className:"h-4 w-4"}),l.nav[a.key]]},a.key)})}),(0,b.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[q&&(0,b.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,b.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:q.slice(0,1).toUpperCase()}),(0,b.jsx)("span",{className:"truncate",children:q})]}),o&&(0,b.jsx)(x.default,{href:"/admin",title:l.nav.admin,children:(0,b.jsxs)(W.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,b.jsx)(C,{className:"h-5 w-5"}),(0,b.jsx)("span",{className:"sr-only",children:l.nav.admin})]})}),(0,b.jsx)(I,{className:"mr-1"}),(0,b.jsx)(bV,{}),(0,b.jsx)(bN,{}),(0,b.jsx)(W.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,e.signOut)({callbackUrl:"/login"}),title:l.app.logout,children:(0,b.jsx)(z.f,{className:"h-5 w-5"})})]})]})}),(0,b.jsx)("div",{className:"pb-20 md:pb-0",children:a}),(0,b.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,b.jsx)("div",{className:"grid h-16",style:{gridTemplateColumns:`repeat(${b$.length}, minmax(0, 1fr))`},children:b$.map(a=>{let c=a.match(k),d=a.icon;return(0,b.jsxs)(x.default,{href:a.href,className:(0,H.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",c?"text-primary":"text-muted-foreground"),"aria-current":c?"page":void 0,children:[(0,b.jsx)("span",{className:(0,H.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",c&&"bg-accent"),children:(0,b.jsx)(d,{className:"h-5 w-5"})}),l.nav[a.key]]},a.key)})})})]})}let b0={name:"list-todo",size:24,node:[["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"}]]};b0.node;let b1=(0,A.f)(b0);var b2=a.i(211134);let b3=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function b4(){let{t:a}=(0,d.b)(),{timeZone:g}=(0,v.M)(),{status:h}=(0,e.useSession)(),i=(0,y.usePathname)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)([]),[n,o]=(0,c.useState)(()=>Date.now()),p="authenticated"!==h||b3.some(a=>a.test(i||"")),q=(0,c.useCallback)(async()=>{if("u"<typeof document||"hidden"!==document.visibilityState)try{let a=await f.k.get("/api/tasks");m(a.tasks),o(Date.now())}catch{}},[]);if((0,c.useEffect)(()=>{if(p)return;let a=setTimeout(q,0),b=setInterval(q,j?2e3:15e3);return()=>{clearTimeout(a),clearInterval(b)}},[p,j,q]),p)return null;let r=l.filter(a=>"running"===a.status).length,s=l.some(a=>"running"!==a.status),t=async()=>{try{let a=await f.k.delete("/api/tasks");m(a.tasks)}catch{}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(W.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:()=>k(!0),"aria-label":a.backgroundTasks.title,title:a.backgroundTasks.title,children:[r>0?(0,b.jsx)(D.f,{className:"h-5 w-5 animate-spin"}):(0,b.jsx)(b1,{className:"h-5 w-5"}),r>0&&(0,b.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:r})]}),(0,b.jsx)(X.N,{open:j,onOpenChange:k,children:(0,b.jsxs)(X.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,b.jsxs)(X.s,{children:[(0,b.jsx)(X.F,{children:a.backgroundTasks.title}),(0,b.jsx)(X.C,{children:a.backgroundTasks.description})]}),0===l.length?(0,b.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:a.backgroundTasks.empty}):(0,b.jsx)("ul",{className:"space-y-2",children:l.map(c=>{var d,e;let f;return(0,b.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,b.jsxs)("div",{className:"flex items-start gap-2",children:["running"===c.status&&(0,b.jsx)(D.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===c.status&&(0,b.jsx)(aV.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===c.status&&(0,b.jsx)(b2.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,b.jsxs)("div",{className:"font-medium",children:[a.backgroundTasks.kinds[c.kind],(0,b.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",a.backgroundTasks.status[c.status]]})]}),c.subject&&(0,b.jsx)("div",{className:"break-words text-muted-foreground",children:c.subject}),c.progress&&c.progress.total>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,b.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(c.progress.done/c.progress.total*100)}%`}})}),(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a.backgroundTasks.progress.replace("{done}",String(c.progress.done)).replace("{total}",String(c.progress.total)),c.progress.failed>0&&` \xb7 ${a.backgroundTasks.failedCount.replace("{count}",String(c.progress.failed))}`]})]}),c.error&&(0,b.jsx)("div",{className:"text-xs text-destructive",children:(b=>{if(!b)return null;let c=a.backgroundTasks.errors[b]??a.errors[b];return"string"==typeof c?c:b})(c.error)}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{children:a.backgroundTasks.startedAt.replace("{time}",(0,Z.r)(c.startedAt,"HH:mm:ss",g))}),(0,b.jsx)("span",{children:a.backgroundTasks.elapsed.replace("{time}",(d=c.startedAt,e=c.finishedAt,f=Math.max(0,Math.round(((e?Date.parse(e):n)-Date.parse(d))/1e3)),`${Math.floor(f/60)}:${String(f%60).padStart(2,"0")}`))}),c.link&&(0,b.jsx)(x.default,{href:c.link,className:"text-primary hover:underline",onClick:()=>k(!1),children:a.backgroundTasks.view})]})]})]})},c.id)})}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:a.backgroundTasks.retentionHint}),s&&(0,b.jsx)(W.f,{variant:"ghost",size:"sm",onClick:t,children:a.backgroundTasks.clearFinished})]})]})})]})}var b5=a.i(474215);let b6={success:{icon:aV.f,className:"text-success"},error:{icon:b2.f,className:"text-destructive"},warning:{icon:J.f,className:"text-warning"},info:{icon:O,className:"text-primary"}};function b7(){let{t:a}=(0,d.b)(),[e,f]=(0,c.useState)([]),[g,h]=(0,c.useState)(null);return(0,c.useEffect)(()=>(0,F.M)(a=>{f(a.toasts),h(a.confirm)}),[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.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:e.map(c=>{let{icon:d,className:e}=b6[c.type];return(0,b.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,b.jsx)(d,{className:(0,H.f)("mt-0.5 h-4 w-4 shrink-0",e)}),(0,b.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:c.message}),(0,b.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,F.p)(c.id),"aria-label":a.common.close,children:(0,b.jsx)(b5.X,{className:"h-3.5 w-3.5"})})]},c.id)})}),(0,b.jsx)(X.N,{open:!!g,onOpenChange:a=>{a||g?.resolve(!1)},children:(0,b.jsxs)(X.d,{className:"sm:max-w-md",children:[(0,b.jsxs)(X.s,{children:[(0,b.jsxs)(X.F,{className:"flex items-center gap-2",children:[g?.destructive&&(0,b.jsx)(J.f,{className:"h-5 w-5 text-destructive"}),g?.title||a.common.confirmTitle]}),(0,b.jsx)(X.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:g?.message})]}),(0,b.jsxs)(X.c,{className:"gap-2",children:[(0,b.jsx)(W.f,{variant:"outline",onClick:()=>g?.resolve(!1),children:g?.cancelText||a.common.cancel}),(0,b.jsx)(W.f,{variant:g?.destructive?"destructive":"default",onClick:()=>g?.resolve(!0),autoFocus:!0,children:g?.confirmText||a.common.confirm})]})]})})]})}function b8(){return(0,c.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(a=>{h.V.warn("[PWA]","Service worker registration failed",{error:String(a)})})},[]),null}a.s(["Providers",0,function({children:a,timeZone:f}){return(0,c.useEffect)(()=>(0,h.m)(),[]),(0,b.jsx)(e.SessionProvider,{children:(0,b.jsx)(u,{children:(0,b.jsx)(d.w,{children:(0,b.jsxs)(v.n,{initialTimeZone:f,children:[(0,b.jsx)(b_,{children:a}),(0,b.jsx)(b4,{}),(0,b.jsx)(b7,{}),(0,b.jsx)(b8,{})]})})})})}],418175)}];
194
194
 
195
195
  //# sourceMappingURL=src_components_providers_tsx_09kw-mv3nb6xs._.js.map
@@ -7,9 +7,9 @@ globalThis.__BUILD_MANIFEST = {
7
7
  "static/chunks/0cz1d0mv5g_q7.js"
8
8
  ],
9
9
  "lowPriorityFiles": [
10
- "static/0_A8rshkxRGdIAt8Ht93Q/_buildManifest.js",
11
- "static/0_A8rshkxRGdIAt8Ht93Q/_ssgManifest.js",
12
- "static/0_A8rshkxRGdIAt8Ht93Q/_clientMiddlewareManifest.js"
10
+ "static/E10D9dv115hLNvX7vE6qA/_buildManifest.js",
11
+ "static/E10D9dv115hLNvX7vE6qA/_ssgManifest.js",
12
+ "static/E10D9dv115hLNvX7vE6qA/_clientMiddlewareManifest.js"
13
13
  ],
14
14
  "rootMainFiles": [
15
15
  "static/chunks/263d57goy87o4.js",