wrong-notebook 2026.11.9-2 → 2026.11.9-4

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 (172) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +6 -0
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  12. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/admin/page.js.nft.json +1 -1
  14. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/admin/user/[id]/page.js.nft.json +1 -1
  16. package/.next/server/app/admin/user/[id]/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/admin/dashboard/route.js.nft.json +1 -1
  18. package/.next/server/app/api/admin/users/[id]/detail/route.js.nft.json +1 -1
  19. package/.next/server/app/api/ai/models/route.js.nft.json +1 -1
  20. package/.next/server/app/api/ai/test/route.js.nft.json +1 -1
  21. package/.next/server/app/api/analytics/route.js.nft.json +1 -1
  22. package/.next/server/app/api/analyze/route.js.nft.json +1 -1
  23. package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
  24. package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
  25. package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
  26. package/.next/server/app/api/error-items/[id]/notes/route.js.nft.json +1 -1
  27. package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
  28. package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
  29. package/.next/server/app/api/error-items/[id]/route.js.nft.json +1 -1
  30. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
  31. package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
  32. package/.next/server/app/api/error-items/batch-delete/route.js.nft.json +1 -1
  33. package/.next/server/app/api/error-items/batch-move/route/app-paths-manifest.json +3 -0
  34. package/.next/server/app/api/error-items/batch-move/route/build-manifest.json +12 -0
  35. package/.next/server/app/api/error-items/batch-move/route/server-reference-manifest.json +4 -0
  36. package/.next/server/app/api/error-items/batch-move/route.js +18 -0
  37. package/.next/server/app/api/error-items/batch-move/route.js.map +5 -0
  38. package/.next/server/app/api/error-items/batch-move/route.js.nft.json +1 -0
  39. package/.next/server/app/api/error-items/batch-move/route_client-reference-manifest.js +3 -0
  40. package/.next/server/app/api/error-items/route.js.nft.json +1 -1
  41. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
  42. package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
  43. package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
  44. package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
  45. package/.next/server/app/api/exams/route.js.nft.json +1 -1
  46. package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
  47. package/.next/server/app/api/import/route.js.nft.json +1 -1
  48. package/.next/server/app/api/import-batches/[id]/confirm-all/route.js.nft.json +1 -1
  49. package/.next/server/app/api/import-batches/[id]/fix-text/route.js.nft.json +1 -1
  50. package/.next/server/app/api/import-batches/[id]/read/route.js.nft.json +1 -1
  51. package/.next/server/app/api/import-batches/[id]/retry/route.js.nft.json +1 -1
  52. package/.next/server/app/api/import-batches/[id]/route.js.nft.json +1 -1
  53. package/.next/server/app/api/import-batches/[id]/start/route.js.nft.json +1 -1
  54. package/.next/server/app/api/import-batches/route.js.nft.json +1 -1
  55. package/.next/server/app/api/import-tasks/[id]/confirm/route.js.nft.json +1 -1
  56. package/.next/server/app/api/import-tasks/[id]/read/route.js.nft.json +1 -1
  57. package/.next/server/app/api/import-tasks/[id]/retry/route.js.nft.json +1 -1
  58. package/.next/server/app/api/import-tasks/[id]/route.js.nft.json +1 -1
  59. package/.next/server/app/api/import-tasks/route.js.nft.json +1 -1
  60. package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
  61. package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
  62. package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
  63. package/.next/server/app/api/practice/grade/route.js.nft.json +1 -1
  64. package/.next/server/app/api/practice/record/[id]/route.js.nft.json +1 -1
  65. package/.next/server/app/api/practice/record/route.js.nft.json +1 -1
  66. package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
  67. package/.next/server/app/api/review/due/route.js.nft.json +1 -1
  68. package/.next/server/app/api/stats/repeated-mistakes/route.js.nft.json +1 -1
  69. package/.next/server/app/api/stats/weak-tags/route.js.nft.json +1 -1
  70. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  71. package/.next/server/app/api/tts/batch/route.js.nft.json +1 -1
  72. package/.next/server/app/api/user/route.js.nft.json +1 -1
  73. package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
  74. package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
  75. package/.next/server/app/eula/page.js.nft.json +1 -1
  76. package/.next/server/app/eula/page_client-reference-manifest.js +1 -1
  77. package/.next/server/app/exams/[id]/page.js.nft.json +1 -1
  78. package/.next/server/app/exams/[id]/page_client-reference-manifest.js +1 -1
  79. package/.next/server/app/exams/[id]/print/page.js.nft.json +1 -1
  80. package/.next/server/app/exams/[id]/print/page_client-reference-manifest.js +1 -1
  81. package/.next/server/app/exams/page.js.nft.json +1 -1
  82. package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
  83. package/.next/server/app/import-batches/[id]/page.js.nft.json +1 -1
  84. package/.next/server/app/import-batches/[id]/page_client-reference-manifest.js +1 -1
  85. package/.next/server/app/import-tasks/[id]/page.js.nft.json +1 -1
  86. package/.next/server/app/import-tasks/[id]/page_client-reference-manifest.js +1 -1
  87. package/.next/server/app/import-tasks/page.js.nft.json +1 -1
  88. package/.next/server/app/import-tasks/page_client-reference-manifest.js +1 -1
  89. package/.next/server/app/initialize/page.js.nft.json +1 -1
  90. package/.next/server/app/initialize/page_client-reference-manifest.js +1 -1
  91. package/.next/server/app/login/page.js.nft.json +1 -1
  92. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  93. package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
  94. package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
  95. package/.next/server/app/notebooks/[id]/page.js.nft.json +1 -1
  96. package/.next/server/app/notebooks/[id]/page_client-reference-manifest.js +1 -1
  97. package/.next/server/app/notebooks/page.js.nft.json +1 -1
  98. package/.next/server/app/notebooks/page_client-reference-manifest.js +1 -1
  99. package/.next/server/app/page.js.nft.json +1 -1
  100. package/.next/server/app/page_client-reference-manifest.js +1 -1
  101. package/.next/server/app/practice/page.js.nft.json +1 -1
  102. package/.next/server/app/practice/page_client-reference-manifest.js +1 -1
  103. package/.next/server/app/print-preview/page.js.nft.json +1 -1
  104. package/.next/server/app/print-preview/page_client-reference-manifest.js +1 -1
  105. package/.next/server/app/register/page.js.nft.json +1 -1
  106. package/.next/server/app/register/page_client-reference-manifest.js +1 -1
  107. package/.next/server/app/review/page.js.nft.json +1 -1
  108. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  109. package/.next/server/app/setup/page.js.nft.json +1 -1
  110. package/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  111. package/.next/server/app/stats/page.js.nft.json +1 -1
  112. package/.next/server/app/stats/page_client-reference-manifest.js +1 -1
  113. package/.next/server/app/tags/page.js.nft.json +1 -1
  114. package/.next/server/app/tags/page_client-reference-manifest.js +1 -1
  115. package/.next/server/app-paths-manifest.json +1 -0
  116. package/.next/server/chunks/_007ypexktdy5h._.js +3 -0
  117. package/.next/server/chunks/_02qwqg9i39x4_._.js +2 -2
  118. package/.next/server/chunks/_0431fxnqiloso._.js +1 -1
  119. package/.next/server/chunks/_0kreo-8xn80hb._.js +1 -1
  120. package/.next/server/chunks/_0tktp4y6lb9uv._.js +3 -0
  121. package/.next/server/chunks/_12xi_xqvtrn3k._.js +1 -1
  122. package/.next/server/chunks/_1csx8ckltgali._.js +2 -2
  123. package/.next/server/chunks/_1cydcmia78z15._.js +1 -1
  124. package/.next/server/chunks/_1gtuhmdu6udof._.js +2 -2
  125. package/.next/server/chunks/_1yvd01woddaxt._.js +2 -2
  126. package/.next/server/chunks/_next-internal_server_app_api_error-items_batch-move_route_actions_1usg70f6cukl0.js +3 -0
  127. package/.next/server/chunks/src_lib_1_m3-y2t3e4xi._.js +58 -22
  128. package/.next/server/chunks/src_lib_question_question-deduplication_ts_0gumctesi3szc._.js +1 -1
  129. package/.next/server/chunks/src_lib_schemas_error-items_ts_0vdof4417rd3y._.js +1 -1
  130. package/.next/server/chunks/ssr/[root-of-the-server]__0l0hz47yn1ku_._.js +3 -0
  131. package/.next/server/chunks/ssr/_02_avk2sj3zf5._.js +3 -0
  132. package/.next/server/chunks/ssr/_07igsu8xjloky._.js +3 -0
  133. package/.next/server/chunks/ssr/{_0mvuvawj5-r--._.js → _0qiirfq71m0ty._.js} +2 -2
  134. package/.next/server/chunks/ssr/_12x0l20ysatxn._.js +3 -0
  135. package/.next/server/chunks/ssr/{_19hxsrrruepym._.js → _1m7f_7kfoqzo_._.js} +2 -2
  136. package/.next/server/chunks/ssr/_1m8y_pv3jak70._.js +3 -0
  137. package/.next/server/chunks/ssr/{node_modules_16_s8zyr3620u._.js → node_modules_0nslyotwav52f._.js} +1 -1
  138. package/.next/server/chunks/ssr/{_0t-venqf7b-4q._.js → node_modules_lucide-react_dist_esm_icons_0mg8mlclupjv-._.js} +2 -2
  139. package/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_1qsyz9_vm6jfk._.js +3 -0
  140. package/.next/server/chunks/ssr/src_app_notebooks_[id]_page_tsx_08njm-5-txm8_._.js +1 -1
  141. package/.next/server/chunks/ssr/src_components_providers_tsx_09kw-mv3nb6xs._.js +2 -2
  142. package/.next/server/chunks/ssr/src_contexts_LanguageContext_tsx_0r6xucmeu1k5z._.js +1 -1
  143. package/.next/server/chunks/ssr/src_lib_i18n_en_ts_08zkpwnoqey5s._.js +1 -1
  144. package/.next/server/middleware-build-manifest.js +3 -3
  145. package/.next/server/pages/500.html +1 -1
  146. package/.next/server/preview-props.json +3 -3
  147. package/.next/server/server-reference-manifest.js +1 -1
  148. package/.next/server/server-reference-manifest.json +1 -1
  149. package/.next/static/chunks/{334z2x2rojgkd.js → 032xzuhi_gy7t.js} +1 -1
  150. package/.next/static/chunks/{0_cnc6gz9gqm8.js → 0ocb49htmlhl5.js} +3 -3
  151. package/.next/static/chunks/{0bufg6cl_1x2h.js → 142ggarrxy3ku.js} +1 -1
  152. package/.next/static/chunks/{1ziwji7xw98fj.js → 1_lxyr04qvsxk.js} +1 -1
  153. package/.next/static/chunks/{05f13kdl-5r-c.js → 1ey5h3_143nwz.js} +2 -2
  154. package/.next/static/chunks/1v01oqugf1j5g.js +1 -0
  155. package/.next/static/chunks/2secy011jtksr.js +1 -0
  156. package/.next/static/chunks/{19a04m6wxadzm.js → 321kq8xr7a6_r.js} +1 -1
  157. package/.next/static/chunks/3hft-37m4c_s4.js +1 -0
  158. package/package.json +1 -1
  159. package/prisma/seed.db +0 -0
  160. package/.next/server/chunks/ssr/[root-of-the-server]__0x4us8rfvt68s._.js +0 -3
  161. package/.next/server/chunks/ssr/[root-of-the-server]__124rb-z-nm7o5._.js +0 -3
  162. package/.next/server/chunks/ssr/[root-of-the-server]__1yhcc4i7ps6s5._.js +0 -3
  163. package/.next/server/chunks/ssr/_0ethdphoh7xqp._.js +0 -3
  164. package/.next/server/chunks/ssr/_0qbp5_0h-b69q._.js +0 -3
  165. package/.next/server/chunks/ssr/_1s3gqrczubor-._.js +0 -3
  166. package/.next/server/chunks/ssr/_1wt7hpzajqoju._.js +0 -3
  167. package/.next/static/chunks/11jjfyt0-zwcn.js +0 -1
  168. package/.next/static/chunks/209odxnq_2nok.js +0 -1
  169. package/.next/static/chunks/2hl62fuxy23ky.js +0 -1
  170. /package/.next/static/{I4Rw8GasSc6yR7HSWfSnC → SksTfjOW_RawBbtAQNssc}/_buildManifest.js +0 -0
  171. /package/.next/static/{I4Rw8GasSc6yR7HSWfSnC → SksTfjOW_RawBbtAQNssc}/_clientMiddlewareManifest.js +0 -0
  172. /package/.next/static/{I4Rw8GasSc6yR7HSWfSnC → SksTfjOW_RawBbtAQNssc}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,1661,e=>{"use strict";var t=e.i(843476),s=e.i(271645),a=e.i(111110),r=e.i(217255),i=e.i(41931),n=e.i(303163),l=e.i(201276);let c=["system","light","dark"],d="system",o="app-theme";function m(e){return"string"==typeof e&&c.includes(e)}let u=(0,s.createContext)({preference:d,theme:"light",setPreference:()=>void 0}),p="(prefers-color-scheme: dark)",x=new Set;function h(e){return x.add(e),window.addEventListener("storage",e),()=>{x.delete(e),window.removeEventListener("storage",e)}}function g(){try{let e=localStorage.getItem(o);return m(e)?e:d}catch{return d}}function f(e){try{localStorage.setItem(o,e)}catch{}x.forEach(e=>e())}function j(e){let t=window.matchMedia(p);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}let b=()=>window.matchMedia(p).matches;function y({children:e}){let{data:a,status:c}=(0,r.useSession)(),o="authenticated"===c,p=a?.user?.email,x=(0,s.useSyncExternalStore)(h,g,()=>d),v=(0,s.useSyncExternalStore)(j,b,()=>!1),w="system"===x?v?"dark":"light":x;(0,s.useEffect)(()=>{let e=document.documentElement,t=t=>{e.classList.toggle("dark","dark"===t),e.style.colorScheme=t};t(w);let s=()=>t("light"),a=()=>t(w);return window.addEventListener("beforeprint",s),window.addEventListener("afterprint",a),()=>{window.removeEventListener("beforeprint",s),window.removeEventListener("afterprint",a)}},[w]),(0,s.useEffect)(()=>{if(!o||!p)return;let e=!1;return i.k.get("/api/user").then(t=>{!e&&m(t.themePreference)&&t.themePreference!==g()&&f(t.themePreference)}).catch(e=>{l.V.warn("[Theme]","Failed to load theme preference",{error:(0,n.Z)(e)})}),()=>{e=!0}},[o,p]);let N=(0,s.useCallback)(e=>{f(e),o&&i.k.patch("/api/user",{themePreference:e}).catch(e=>{l.V.warn("[Theme]","Failed to save theme preference",{error:(0,n.Z)(e)})})},[o]),k=(0,s.useMemo)(()=>({preference:x,theme:w,setPreference:N}),[x,w,N]);return(0,t.jsx)(u.Provider,{value:k,children:e})}var v=e.i(215519),w=e.i(618566),N=e.i(632781),k=e.i(519455),S=e.i(776639),C=e.i(923512),T=e.i(749803),_=e.i(856423),A=e.i(975153),z=e.i(226091),E=e.i(456420);let D={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"]};D.node;let F=(0,E.f)(D),M=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],L=[{key:"home",href:"/",icon:F,match:e=>"/"===e},{key:"notebooks",href:"/notebooks",icon:_.f,match:e=>e.startsWith("/notebooks")||e.startsWith("/error-items")||e.startsWith("/practice")},{key:"review",href:"/review",icon:A.f,match:e=>e.startsWith("/review")},{key:"stats",href:"/stats",icon:T.f,match:e=>e.startsWith("/stats")||e.startsWith("/tags")},{key:"exams",href:"/exams",icon:z.f,match:e=>e.startsWith("/exams")}];function R(e){return M.some(t=>t.test(e))}var $=e.i(294114);let I="ai-consent-dismissed:";function G(){let{t:e,language:n}=(0,a.b)(),c=e.aiConsent,{data:d,status:o}=(0,r.useSession)(),m=(0,w.usePathname)()||"/",u="authenticated"===o?d?.user?.email??null:null,[p,x]=(0,s.useState)(null),[h,g]=(0,s.useState)(null),[f,j]=(0,s.useState)(!1);(0,s.useEffect)(()=>(0,C.y)(e=>x(t=>t??e)),[]);let b=R(m);(0,s.useEffect)(()=>{if(!u||b||function(e){try{return"1"===sessionStorage.getItem(e)}catch{return!1}}(I+u))return;let e=!1;return i.k.get("/api/user").then(t=>{e||!t||t.aiDataConsentAt||x(e=>e??"prompt")}).catch(e=>l.V.error("[AiConsentDialog]","load consent failed",{error:e})),()=>{e=!0}},[u,b]);let y=null!==p&&!!u;(0,s.useEffect)(()=>{if(!y)return;let e=!1;return i.k.get("/api/settings").then(t=>{e||g(t?.aiProvider??null)}).catch(()=>void 0),()=>{e=!0}},[y]);let v=()=>{x(null),j(!1)},T=async()=>{j(!0);try{await i.k.post("/api/user/ai-consent",{}),$.c.success("blocked"===p?c.agreedRetry:c.agreed),v()}catch(e){l.V.error("[AiConsentDialog]","save consent failed",{error:e}),$.c.error(c.failed),j(!1)}},_=()=>{u&&function(e){try{sessionStorage.setItem(e,"1")}catch{}}(I+u),$.c.info(c.declined),v()},A=(0,C.K)(h,n);return(0,t.jsx)(S.N,{open:y,onOpenChange:e=>{e||f||_()},children:(0,t.jsxs)(S.d,{className:"sm:max-w-lg",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:c.title}),(0,t.jsx)(S.C,{children:"blocked"===p?c.blocked:c.intro})]}),(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:["blocked"===p&&(0,t.jsx)("p",{children:c.intro}),(0,t.jsx)("ul",{className:"list-disc space-y-1 pl-5",children:c.items.map(e=>(0,t.jsx)("li",{children:e},e))}),(0,t.jsx)("p",{children:A?c.providerKnown.replace("{provider}",A):c.providerUnknown}),(0,t.jsxs)("p",{children:[c.policy,"en"===n?" ":"",(0,t.jsx)("a",{className:"underline underline-offset-2",href:(0,C.L)(n),target:"_blank",rel:"noopener noreferrer",children:c.policyLink}),"en"===n?".":"。"]}),(0,t.jsx)("p",{className:"text-muted-foreground",children:c.declineNote})]}),(0,t.jsxs)(S.c,{className:"gap-2",children:[(0,t.jsx)(k.f,{type:"button",variant:"outline",onClick:_,disabled:f,children:c.decline}),(0,t.jsxs)(k.f,{type:"button",onClick:T,disabled:f,children:[f&&(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}),c.agree]})]})]})})}var V=e.i(325164),O=e.i(522016),P=e.i(367784);let U={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"}]]};U.node;let q=(0,E.f)(U);var H=e.i(424553);function K({status:e,onAccept:i}){let{t:n,language:c}=(0,a.b)(),[d,o]=(0,s.useState)(!1),m="en"===c?e.changes.en:e.changes.zh,u=async()=>{o(!0);try{await i()}catch(e){l.V.error("[EulaGate]","Failed to accept EULA",{error:e}),$.c.error(n.eula.acceptFailed)}finally{o(!1)}};return(0,t.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"eula-upgrade-title",children:(0,t.jsxs)("div",{className:"max-h-[90vh] w-full max-w-lg space-y-4 overflow-y-auto rounded-lg border bg-background p-5 shadow-lg",children:[(0,t.jsx)("h2",{id:"eula-upgrade-title",className:"text-lg font-semibold",children:n.eula.upgradeTitle}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n.eula.upgradeDesc.replace("{accepted}",e.accepted??"-").replace("{current}",e.current)}),m.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:n.eula.changesTitle}),(0,t.jsx)("ul",{className:"list-disc space-y-1 pl-5 text-sm",children:m.map(e=>(0,t.jsx)("li",{children:e},e))})]}),(0,t.jsx)(H.f,{}),(0,t.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,t.jsx)(k.f,{variant:"outline",onClick:()=>(0,r.signOut)({callbackUrl:"/login"}),disabled:d,children:n.eula.logout}),(0,t.jsxs)(k.f,{onClick:u,disabled:d,children:[d&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.eula.accept]})]})]})})}var B=e.i(980105),Y=e.i(901219),W=e.i(975157);function J({className:e}){let{t:r}=(0,a.b)(),{data:i}=(0,Y.b)(),n=(0,s.useRef)(null);if((0,s.useEffect)(()=>{if(!i)return;let e=new Set([...i.tasks.filter(e=>"analyzing"===e.status||"saving"===e.status).map(e=>e.id),...(i.batches??[]).filter(e=>"splitting"===e.phase||"processing"===e.phase).map(e=>`batch:${e.id}`)]),t=new Set([...i.tasks.filter(e=>e.unread).map(e=>e.id),...(i.batches??[]).filter(e=>e.unread).map(e=>`batch:${e.id}`)]),s=n.current;s&&[...s].some(s=>!e.has(s)&&t.has(s))&&$.c.info(r.importTasks.finishedToast),n.current=e},[i,r.importTasks.finishedToast]),!i||0===i.tasks.length&&!i.batches?.length)return null;let{activeCount:l,unreadCount:c}=i,d=l>0?r.importTasks.entryActive.replace("{count}",String(l)):r.importTasks.entry;return(0,t.jsxs)(O.default,{href:"/import-tasks",className:(0,W.f)("relative flex h-9 items-center gap-1.5 rounded-full border px-3 text-sm font-medium transition-colors hover:bg-muted",c>0?"border-primary/50 text-primary":"text-muted-foreground",e),"data-testid":"import-tasks-entry","aria-label":c>0?`${d} \xb7 ${r.importTasks.entryUnread.replace("{count}",String(c))}`:d,children:[l>0?(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(B.f,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"whitespace-nowrap",children:d}),c>0&&(0,t.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:c})]})}var X=e.i(853138);let Z={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"}]]};Z.node;let Q=(0,E.f)(Z),ee={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"}]]};ee.node;let et=(0,E.f)(ee);var es=e.i(999092);let ea={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"}]]};ea.node;let er=(0,E.f)(ea),ei={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"}]]};ei.node;let en=(0,E.f)(ei);var el=e.i(901279),ec=e.i(994533),ed=e.i(677572),eo=e.i(306831),em=e.i(487486),eu=e.i(699375),ep=e.i(793479),ex=e.i(110204);let eh=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("div",{className:"relative w-full overflow-auto",children:(0,t.jsx)("table",{ref:a,className:(0,W.f)("w-full caption-bottom text-sm",e),...s})}));eh.displayName="Table";let eg=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("thead",{ref:a,className:(0,W.f)("[&_tr]:border-b",e),...s}));eg.displayName="TableHeader";let ef=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("tbody",{ref:a,className:(0,W.f)("[&_tr:last-child]:border-0",e),...s}));ef.displayName="TableBody",(s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("tfoot",{ref:a,className:(0,W.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...s}))).displayName="TableFooter";let ej=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("tr",{ref:a,className:(0,W.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...s}));ej.displayName="TableRow";let eb=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("th",{ref:a,className:(0,W.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...s}));eb.displayName="TableHead";let ey=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("td",{ref:a,className:(0,W.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...s}));ey.displayName="TableCell",(s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("caption",{ref:a,className:(0,W.f)("mt-4 text-sm text-muted-foreground",e),...s}))).displayName="TableCaption";var ev=e.i(759659);let ew={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"}]]};ew.node;let eN=(0,E.f)(ew);var ek=e.i(548161);function eS(){var e;let{t:r}=(0,a.b)(),[n,c]=(0,s.useState)(String(5)),[d,o]=(0,s.useState)(!1),m=(0,s.useCallback)(async()=>{try{let e=await i.k.get("/api/settings");c(String(e.aiConcurrencyLimit??5))}catch(e){l.V.error("[AiConcurrencyLimitSetting]","Failed to fetch config",{error:e})}},[]);(0,s.useEffect)(()=>{m()},[m]);let u=Number(n),p=""!==n.trim()&&"number"==typeof(e=u)&&Number.isInteger(e)&&e>=1&&e<=100,x=async()=>{if(p){o(!0);try{await i.k.post("/api/settings",{aiConcurrencyLimit:u}),$.c.success(r.admin.aiConcurrencyLimitSaved)}catch(e){l.V.error("[AiConcurrencyLimitSetting]","Failed to update AI concurrency limit",{error:e}),$.c.error(r.common.error)}finally{o(!1)}}};return(0,t.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,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(ex.f,{htmlFor:"ai-concurrency-limit",className:"text-base",children:r.admin.aiConcurrencyLimit}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:r.admin.aiConcurrencyLimitDesc})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(ep.f,{id:"ai-concurrency-limit",type:"number",min:1,max:100,step:1,inputMode:"numeric",value:n,onChange:e=>c(e.target.value),"aria-invalid":!p,className:"w-24"}),(0,t.jsxs)(k.f,{size:"sm",onClick:x,disabled:d||!p,children:[d&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),r.common.save]})]})]})}function eC(e,t){return new Intl.NumberFormat("zh"===t?"zh-CN":"en-US",{notation:"compact",maximumFractionDigits:1}).format(Math.max(0,e))}function eT({user:e}){let{t:s,language:r}=(0,a.b)(),i=s.admin.aiTokensDetail.replace("{input}",eC(e.aiTokensToday.input,r)).replace("{output}",eC(e.aiTokensToday.output,r));return(0,t.jsxs)(t.Fragment,{children:[s.admin.aiUsageToday,": ",e.aiUsageToday," | ",s.admin.aiTokensToday,": ",i]})}function e_(){let{timeZone:e}=(0,v.M)(),{data:c}=(0,r.useSession)(),{t:d}=(0,a.b)(),[o,m]=(0,s.useState)([]),[u,p]=(0,s.useState)(!0),[x,h]=(0,s.useState)(!1),[g,f]=(0,s.useState)(!1),[j,b]=(0,s.useState)("0"),[y,w]=(0,s.useState)(!1),S=(0,s.useCallback)(async()=>{p(!0);try{let e=await i.k.get("/api/admin/users");m(e)}catch(e){l.V.error("[UserManagement]","Failed to fetch users",{error:e})}finally{p(!1)}},[]),C=(0,s.useCallback)(async()=>{try{let e=await i.k.get("/api/settings");h(!0===e.allowRegistration),b(String(e.aiDailyLimit??0))}catch(e){l.V.error("[UserManagement]","Failed to fetch config",{error:e})}},[]);(0,s.useEffect)(()=>{S(),C()},[S,C]);let T=async e=>{f(!0);try{await i.k.post("/api/settings",{allowRegistration:e}),h(e)}catch(e){l.V.error("[UserManagement]","Failed to update registration setting",{error:e}),$.c.error(d.common.error)}finally{f(!1)}},_=Number(j),A=""!==j.trim()&&Number.isInteger(_)&&_>=0,z=async()=>{if(A){w(!0);try{await i.k.post("/api/settings",{aiDailyLimit:_}),$.c.success(d.admin.aiDailyLimitSaved)}catch(e){l.V.error("[UserManagement]","Failed to update AI daily limit",{error:e}),$.c.error(d.common.error)}finally{w(!1)}}},E=async e=>{let t=e.isActive?d.admin.confirmDisable:d.admin.confirmEnable;if(await (0,$.u)(t))try{await i.k.patch(`/api/admin/users/${e.id}`,{isActive:!e.isActive}),S()}catch(e){l.V.error("[UserManagement]","Failed to update user status",{error:e}),$.c.error(d.common.error)}},D=async e=>{if(await (0,$.u)(d.admin.confirmDelete,{destructive:!0}))try{await i.k.delete(`/api/admin/users/${e.id}`),S()}catch(t){l.V.error("[UserManagement]","Failed to delete user",{error:t});let e=(0,n.d)(t)||d.common.error;$.c.error(e)}};return u?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(N.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(ex.f,{className:"text-base",children:d.admin?.allowRegistration||"Allow New Registrations"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}),(0,t.jsx)(eu.f,{checked:x,onCheckedChange:T,disabled:g})]})]}),(0,t.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,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(ex.f,{htmlFor:"ai-daily-limit",className:"text-base",children:d.admin.aiDailyLimit}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d.admin.aiDailyLimitDesc})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(ep.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:j,onChange:e=>b(e.target.value),"aria-invalid":!A,className:"w-24"}),(0,t.jsxs)(k.f,{size:"sm",onClick:z,disabled:y||!A,children:[y&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),d.common.save]})]})]}),(0,t.jsx)(eS,{}),(0,t.jsx)("div",{className:"sm:hidden space-y-3",children:o.map(s=>(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,t.jsxs)("div",{className:"flex justify-between items-start",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium",children:s.name||"N/A"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:s.email})]}),(0,t.jsx)(em.f,{variant:"admin"===s.role?"default":"secondary",children:"admin"===s.role?d.admin.admin:d.admin.user})]}),(0,t.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,t.jsxs)("div",{className:"text-muted-foreground",children:[d.admin.errors,": ",s._count.errorItems," | ",d.admin.practiceCount,": ",s._count.practiceRecords," | ",(0,t.jsx)(eT,{user:s})]}),(0,t.jsx)(em.f,{variant:s.isActive?"default":"destructive",className:"text-xs",children:s.isActive?d.admin.active:d.admin.disabled})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,eo.r)(s.createdAt,"yyyy-MM-dd",e)}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>E(s),disabled:s.id===c?.user?.id,children:s.isActive?(0,t.jsx)(eN,{className:"h-4 w-4 text-orange-500"}):(0,t.jsx)(ek.f,{className:"h-4 w-4 text-green-500"})}),(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>D(s),disabled:s.id===c?.user?.id,children:(0,t.jsx)(ev.f,{className:"h-4 w-4 text-destructive"})})]})]})]},s.id))}),(0,t.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,t.jsxs)(eh,{children:[(0,t.jsx)(eg,{children:(0,t.jsxs)(ej,{children:[(0,t.jsx)(eb,{children:d.admin.nameEmail}),(0,t.jsx)(eb,{children:d.admin.role}),(0,t.jsx)(eb,{children:d.admin.stats}),(0,t.jsx)(eb,{children:d.admin.createdAt}),(0,t.jsx)(eb,{children:d.admin.status}),(0,t.jsx)(eb,{className:"text-right",children:d.admin.actions})]})}),(0,t.jsx)(ef,{children:o.map(s=>(0,t.jsxs)(ej,{children:[(0,t.jsxs)(ey,{children:[(0,t.jsx)("div",{className:"font-medium",children:s.name||"N/A"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:s.email})]}),(0,t.jsx)(ey,{children:(0,t.jsx)(em.f,{variant:"admin"===s.role?"default":"secondary",children:"admin"===s.role?d.admin.admin:d.admin.user})}),(0,t.jsxs)(ey,{children:[(0,t.jsxs)("div",{className:"text-sm",children:[d.admin.errors,": ",s._count.errorItems]}),(0,t.jsxs)("div",{className:"text-sm",children:[d.admin.practiceCount,": ",s._count.practiceRecords]}),(0,t.jsx)("div",{className:"text-sm",children:(0,t.jsx)(eT,{user:s})})]}),(0,t.jsx)(ey,{children:(0,eo.r)(s.createdAt,"yyyy-MM-dd",e)}),(0,t.jsx)(ey,{children:(0,t.jsx)(em.f,{variant:s.isActive?"default":"destructive",children:s.isActive?d.admin.active:d.admin.disabled})}),(0,t.jsxs)(ey,{className:"text-right space-x-2",children:[(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>E(s),disabled:s.id===c?.user?.id,title:s.isActive?d.admin.disable:d.admin.enable,children:s.isActive?(0,t.jsx)(eN,{className:"h-4 w-4 text-orange-500"}):(0,t.jsx)(ek.f,{className:"h-4 w-4 text-green-500"})}),(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>D(s),disabled:s.id===c?.user?.id,title:d.admin.delete,children:(0,t.jsx)(ev.f,{className:"h-4 w-4 text-destructive"})})]})]},s.id))})]})})]})}var eA=e.i(482022);let ez={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"}]]};ez.node;let eE=(0,E.f)(ez);function eD(e){return(0,t.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",...e,children:[(0,t.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,t.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}let eF={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"}]]};eF.node;let eM=(0,E.f)(eF);var eL=e.i(81968);let eR=()=>()=>void 0;function e$(){let{t:e}=(0,a.b)(),r=(0,s.useSyncExternalStore)(eR,eL.f,()=>null);return r?r.isStandalone?.()?(0,t.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:e.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsxs)("span",{className:"break-all",children:[e.settings?.about?.androidServer||"Server",": ",r.getServerUrl()]}),(0,t.jsxs)(k.f,{variant:"outline",className:"gap-2",onClick:()=>r.changeServer(),children:[(0,t.jsx)(eM,{className:"h-4 w-4"}),e.settings?.about?.changeServer||"Change server"]})]}):null}var eI=e.i(637691);function eG(){let{t:e}=(0,a.b)(),[r,i]=(0,s.useState)("");(0,s.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>i(e.version)).catch(()=>{})},[]);let n=[{href:eI.f,icon:eD,label:e.settings?.about?.github||"GitHub Repository"},{href:`${eI.f}/releases`,icon:eE,label:e.settings?.about?.releaseNotes||"Release Notes"},{href:`${eI.f}/issues`,icon:er,label:e.settings?.about?.feedback||"Feedback"}];return(0,t.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,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-2xl font-bold",children:e.app?.title||"Smart Error Notebook"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:e.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,t.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,t.jsx)(et,{className:"h-4 w-4"}),(0,t.jsxs)("span",{children:[e.settings?.about?.version||"Version",": v",r||"unknown"]})]}),(0,t.jsx)(e$,{}),(0,t.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:n.map(({href:e,icon:s,label:a})=>(0,t.jsx)(k.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,t.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[(0,t.jsx)(s,{className:"h-4 w-4"}),a,(0,t.jsx)(eA.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},e))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:e.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var eV=e.i(37038),eO=e.i(967489),eP=e.i(676167);let eU={name:"",email:"",educationStage:"",enrollmentYear:"",currentGrade:"",currentSemester:"",password:""};function eq(){let{t:e}=(0,a.b)(),[r,c]=(0,s.useState)(eU),[d,o]=(0,s.useState)(""),[m,u]=(0,s.useState)(!0),[p,x]=(0,s.useState)(!1),h=(0,s.useCallback)(async()=>{try{let e=await i.k.get("/api/user"),t=e.fixedGradeSemester?(0,eP.p)(e.fixedGradeSemester):null;c({name:e.name||"",email:e.email||"",educationStage:e.educationStage||"",enrollmentYear:e.enrollmentYear||"",currentGrade:t?.grade||"",currentSemester:t?.semester||"",password:""})}catch(e){l.V.error("[AccountSettings]","Failed to fetch profile",{error:e})}finally{u(!1)}},[]);(0,s.useEffect)(()=>{h()},[h]);let g=async()=>{if(r.password&&r.password!==d)return void $.c.error(e.settings?.messages?.passwordMismatch||"Passwords do not match");x(!0);try{let t={name:r.name,email:r.email,educationStage:r.educationStage};r.enrollmentYear&&(t.enrollmentYear=parseInt(r.enrollmentYear.toString())),r.password&&(t.password=r.password),r.currentGrade&&r.currentSemester?t.fixedGradeSemester=`${r.currentGrade}${r.currentSemester}`:r.currentGrade||(t.fixedGradeSemester=null),await i.k.patch("/api/user",t),$.c.success(e.settings?.messages?.profileUpdated||"Profile updated"),c(e=>({...e,password:""})),o(""),window.location.reload()}catch(t){l.V.error("[AccountSettings]","Failed to update profile",{error:(0,n.d)(t)??(0,n.Z)(t)}),$.c.error((0,n.d)(t)||e.settings?.messages?.updateFailed||"Update failed")}finally{x(!1)}};return m?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(N.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,t.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.name||"Name"}),(0,t.jsx)(ep.f,{value:r.name||"",onChange:e=>c({...r,name:e.target.value})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.email||"Email"}),(0,t.jsx)(ep.f,{value:r.email||"",onChange:e=>c({...r,email:e.target.value}),type:"email"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.educationStage||"Education Stage"}),(0,t.jsxs)(eO.d,{value:r.educationStage||"",onValueChange:e=>c({...r,educationStage:e,currentGrade:(0,eP.c)(e).includes(r.currentGrade)?r.currentGrade:"",currentSemester:(0,eP.c)(e).includes(r.currentGrade)?r.currentSemester:""}),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{placeholder:e.auth?.selectStage||"Select Stage"})}),(0,t.jsxs)(eO.r,{children:[(0,t.jsx)(eO.T,{value:"primary",children:e.auth?.primary||"Primary School"}),(0,t.jsx)(eO.T,{value:"junior_high",children:e.auth?.juniorHigh||"Junior High"}),(0,t.jsx)(eO.T,{value:"senior_high",children:e.auth?.seniorHigh||"Senior High"}),(0,t.jsx)(eO.T,{value:"university",children:e.auth?.university||"University"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.enrollmentYear||"Enrollment Year"}),(0,t.jsx)(ep.f,{type:"number",value:r.enrollmentYear||"",onChange:e=>c({...r,enrollmentYear:e.target.value}),placeholder:"YYYY"})]})]}),r.educationStage&&(0,eP.c)(r.educationStage).length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.settings?.account?.currentGrade||"Current Grade & Semester"}),(0,t.jsxs)(eO.d,{value:r.currentGrade||"",onValueChange:e=>c({...r,currentGrade:e,currentSemester:e?r.currentSemester||"上":""}),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{placeholder:e.settings?.account?.selectGrade||"Select Grade"})}),(0,t.jsx)(eO.r,{children:(0,eP.c)(r.educationStage).map(e=>(0,t.jsx)(eO.T,{value:e,children:e},e))})]})]}),r.currentGrade&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.settings?.account?.selectSemester||"Select Semester"}),(0,t.jsxs)(eO.d,{value:r.currentSemester||"",onValueChange:e=>c({...r,currentSemester:e}),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{placeholder:e.settings?.account?.selectSemester||"Select Semester"})}),(0,t.jsxs)(eO.r,{children:[(0,t.jsx)(eO.T,{value:"上",children:e.settings?.account?.firstSemester||"1st Semester"}),(0,t.jsx)(eO.T,{value:"下",children:e.settings?.account?.secondSemester||"2nd Semester"})]})]})]})]}),r.currentGrade&&r.currentSemester&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground -mt-2",children:e.settings?.account?.gradeAppliedHint||"New questions will default to this grade. You can also configure AI grade recognition in General Settings."}),(0,t.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,t.jsx)(eV.f,{value:r.password,onChange:e=>c({...r,password:e.target.value}),placeholder:"******",minLength:6})]}),r.password&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.confirmPassword||"Confirm Password"}),(0,t.jsx)(eV.f,{value:d,onChange:e=>o(e.target.value),placeholder:"******",minLength:6})]})]}),(0,t.jsxs)(k.f,{onClick:g,disabled:p,className:"w-full",children:[p&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.settings?.account?.update||"Update Profile"]})]})}var eH=e.i(10038),eK=e.i(725981),eB=e.i(411382),eY=e.i(54105),eW=e.i(978056),eJ=e.i(772325);let eX="https://github.com/xiaoyang111222/cn-math-taxonomy",eZ="https://raw.githubusercontent.com/xiaoyang111222/cn-math-taxonomy/HEAD/data/topics.json",eQ=eB.z.object({id:eY.z.string().optional(),name:eY.z.string().trim().min(1),subject:eY.z.string().nullish(),grade:eW.z.number().int(),semester:eY.z.string().nullish(),chapter:eY.z.string().nullish()}).passthrough();eJ.z.array(eQ).min(1);let e0="/api/admin/cnm-tags";function e1(){let{t:e}=(0,a.b)(),r=e.admin.cnmTags,[n,c]=(0,s.useState)(null),[d,o]=(0,s.useState)(!1),m=(0,s.useRef)(null),u=(0,s.useCallback)(async()=>{try{c(await i.k.get(e0))}catch(e){l.V.warn("[CnmTagImportSettings]","Failed to load status",{error:e})}},[]);(0,s.useEffect)(()=>{u()},[u]);let p=async e=>{if(e){o(!0);try{let t;try{t=JSON.parse(await e.text())}catch{$.c.error(r.invalidFile);return}let s=await i.k.post(e0,{topics:t},{timeout:3e5});c(s.status),$.c.success(r.imported.replace("{created}",String(s.result.created)).replace("{skipped}",String(s.result.skipped)))}catch(t){l.V.error("[CnmTagImportSettings]","Import failed",{error:t});let e=t instanceof i.a&&400===t.status;$.c.error(e?r.invalidFile:r.failed)}finally{o(!1),m.current&&(m.current.value="")}}},x=n?.knowledgePoints??0;return(0,t.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(_.f,{className:"h-4 w-4"}),r.title]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:r.desc})]}),(0,t.jsxs)("div",{className:"space-y-1 rounded-md bg-muted/50 p-3 text-xs text-muted-foreground",children:[(0,t.jsx)("p",{children:r.downloadHint}),(0,t.jsx)("a",{href:eZ,target:"_blank",rel:"noopener noreferrer",className:"block break-all text-primary underline",children:eZ}),(0,t.jsxs)("p",{children:[r.sourceLabel," ",(0,t.jsx)("a",{href:eX,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline",children:eX})]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n?x>0?r.status.replace("{count}",String(x)):r.notImported:""}),(0,t.jsx)("input",{ref:m,type:"file",accept:".json,application/json",className:"hidden",onChange:e=>p(e.target.files?.[0]),disabled:d}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:()=>m.current?.click(),disabled:d,children:[d?(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(eK.f,{className:"mr-2 h-4 w-4"}),d?r.importing:r.select]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:r.note})]})}var e2=e.i(741120);let e4={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 e3({title:e,description:s,tone:a,busy:r,icon:i,onClick:n}){let l=e4[a];return(0,t.jsxs)("div",{className:`p-4 border rounded-lg ${l.card}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:`text-sm flex items-center gap-2 ${l.title}`,children:e}),(0,t.jsx)(k.f,{variant:"info"===a?"outline":"destructive",size:"sm",onClick:n,disabled:r,className:l.button,children:r?(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}):i})]}),(0,t.jsx)("p",{className:`text-xs mt-2 ${l.desc}`,children:s})]})}function e5({isAdmin:e}){let{t:r}=(0,a.b)(),[n,c]=(0,s.useState)(null),d=async(e,t,s,a)=>{c(e);try{$.c.success(await t()),a&&window.location.reload()}catch(t){l.V.error("[DangerZoneSettings]",`${e} failed`,{error:t}),$.c.error(s)}finally{c(null)}},o=r.settings?.clearSuccess||"Success",m=r.settings?.clearError||"Failed",u=async()=>{await (0,$.u)(r.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await d("migrateTags",async()=>{let e=await i.k.post("/api/admin/migrate-tags",{});return`${o}: ${e.count||0} tags migrated.`},r.settings?.clearError||"Failed to migrate tags",!1)},p=async()=>{await (0,$.u)(r.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await d("clearPractice",async()=>(await i.k.delete("/api/stats/practice/clear"),o),m,!0)},x=async()=>{await (0,$.u)(r.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await d("clearErrors",async()=>(await i.k.delete("/api/error-items/clear"),o),m,!0)},h=async()=>{if(!await (0,$.u)(r.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let e=prompt(r.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==e){null!==e&&$.c.error(r.common?.error||"Confirmation failed");return}await d("systemReset",async()=>(await i.k.post("/api/admin/system-reset",{}),r.settings?.clearSuccess||"Success - System Reset Complete"),r.settings?.clearError||"Failed to reset system",!0)};return(0,t.jsxs)(t.Fragment,{children:[e&&(0,t.jsx)(e3,{tone:"info",title:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e2.f,{className:"h-4 w-4"}),r.settings?.migrateTags||"Migrate Tags"]}),description:r.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===n,icon:(0,t.jsx)(e2.f,{className:"h-4 w-4"}),onClick:u}),(0,t.jsx)(e3,{tone:"danger",title:r.settings?.clearData||"Clear Practice Data",description:r.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===n,icon:(0,t.jsx)(ev.f,{className:"h-4 w-4"}),onClick:p}),(0,t.jsx)(e3,{tone:"danger",title:r.settings?.clearErrorData||"Clear Error Data",description:r.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===n,icon:(0,t.jsx)(ev.f,{className:"h-4 w-4"}),onClick:x}),e&&(0,t.jsx)(e3,{tone:"critical",title:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(X.f,{className:"h-4 w-4"}),r.settings?.systemReset||"System Initialization"]}),description:r.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===n,icon:(0,t.jsx)(ev.f,{className:"h-4 w-4"}),onClick:h})]})}let e6={name:"user-x",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]};e6.node;let e8=(0,E.f)(e6);function e9({isAdmin:e}){let{t:n}=(0,a.b)(),c=n.settings.deleteAccount,[d,o]=(0,s.useState)(!1),[m,u]=(0,s.useState)(""),[p,x]=(0,s.useState)(!1),h=e=>{!p&&(o(e),e||u(""))},g=async e=>{if(e.preventDefault(),m){x(!0);try{await i.k.delete("/api/user",{body:JSON.stringify({password:m})}),$.c.success(c.success),await (0,r.signOut)({callbackUrl:"/login"})}catch(t){let e=t instanceof i.a&&400===t.status;e||l.V.error("[DeleteAccountSettings]","delete account failed",{error:t}),$.c.error(e?c.wrongPassword:c.failed),x(!1)}}};return(0,t.jsxs)("div",{className:"p-4 border rounded-lg border-red-600/50 bg-red-100/50 dark:bg-red-900/40",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"text-sm flex items-center gap-2 text-red-900 dark:text-red-200 font-bold",children:[(0,t.jsx)(e8,{className:"h-4 w-4"}),c.title]}),(0,t.jsx)(k.f,{variant:"destructive",size:"sm",className:"bg-red-700 hover:bg-red-800",disabled:e,onClick:()=>o(!0),"aria-label":c.title,children:(0,t.jsx)(e8,{className:"h-4 w-4"})})]}),(0,t.jsx)("p",{className:"text-xs mt-2 text-red-800 dark:text-red-200 font-medium",children:e?c.adminDisabled:c.desc}),(0,t.jsx)(S.N,{open:d,onOpenChange:h,children:(0,t.jsx)(S.d,{className:"sm:max-w-md",children:(0,t.jsxs)("form",{onSubmit:g,className:"space-y-4",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:c.confirmTitle}),(0,t.jsx)(S.C,{children:c.confirmDesc})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{htmlFor:"delete-account-password",children:c.passwordLabel}),(0,t.jsx)(eV.f,{id:"delete-account-password",autoComplete:"current-password",value:m,onChange:e=>u(e.target.value),disabled:p})]}),(0,t.jsxs)(S.c,{className:"gap-2",children:[(0,t.jsx)(k.f,{type:"button",variant:"outline",onClick:()=>h(!1),disabled:p,children:c.cancel}),(0,t.jsxs)(k.f,{type:"submit",variant:"destructive",disabled:!m||p,children:[p&&(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}),c.confirm]})]})]})})})]})}let e7={name:"shield-check",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"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]};e7.node;let te=(0,E.f)(e7);function tt(){let{t:e,language:r}=(0,a.b)(),n=e.aiConsent,[c,d]=(0,s.useState)(void 0),[o,m]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!1;return i.k.get("/api/user").then(t=>{e||d(t?.aiDataConsentAt??null)}).catch(e=>l.V.error("[AiConsentSetting]","load consent failed",{error:e})),()=>{e=!0}},[]);let u=async e=>{if(e||await (0,$.u)(n.revokeConfirm,{destructive:!0})){m(!0);try{let t=e?await i.k.post("/api/user/ai-consent",{}):await i.k.delete("/api/user/ai-consent");d(t.aiDataConsentAt),$.c.success(e?n.agreed:n.revoked)}catch(e){l.V.error("[AiConsentSetting]","update consent failed",{error:e}),$.c.error(n.failed)}finally{m(!1)}}};if(void 0===c)return null;let p=null!==c,x=p?new Date(c).toLocaleDateString("en"===r?"en-US":"zh-CN"):"";return(0,t.jsxs)("div",{className:"space-y-2 rounded-lg border p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(te,{className:"h-4 w-4"}),n.settingTitle]}),(0,t.jsxs)(k.f,{type:"button",size:"sm",variant:p?"outline":"default",onClick:()=>u(!p),disabled:o,children:[o&&(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}),p?n.revoke:n.grant]})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[p?n.settingGranted.replace("{date}",x):n.settingNotGranted," ",(0,t.jsx)("a",{className:"underline underline-offset-2",href:(0,C.L)(r),target:"_blank",rel:"noopener noreferrer",children:n.policyLink})]})]})}var ts=e.i(551757),ta=e.i(762368),tr=e.i(132411);async function ti(e,t){let s=await fetch(e);if(!s.ok)throw Error((await s.json().catch(()=>({}))).message||"Download failed");let a=await s.blob(),r=window.URL.createObjectURL(a),i=document.createElement("a");i.href=r;let n=s.headers.get("Content-Disposition")?.match(/filename="(.+)"/);i.download=n?n[1]:t,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(r)}function tn({isAdmin:e,userId:r}){let{t:n}=(0,a.b)(),[c,d]=(0,s.useState)(!1),[o,m]=(0,s.useState)(!1),[u,p]=(0,s.useState)(null),x=`user:${r}:data-import`,{running:h,refresh:g}=(0,tr.f)(x),f=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(h){f.current=!0;return}f.current&&(f.current=!1,window.location.reload())},[h]);let j=async e=>{if(!e||await (0,$.u)(n.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){d(!0);try{await ti(e?"/api/export?all=true":"/api/export",e?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),$.c.success(n.settings?.exportSuccess||"Export successful")}catch(t){l.V.error("[DataBackupSettings]",e?"Export all failed":"Export failed",{error:t}),$.c.error(n.settings?.exportFailed||"Export failed")}finally{d(!1)}}},b=async e=>{if(!u)return;let t=e?n.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":n.settings?.importConfirm||"Are you sure you want to import?";if(await (0,$.u)(t)){m(!0);try{let t=JSON.parse(await u.text()),{stats:s}=await i.k.post(e?"/api/import?all=true":"/api/import",t);$.c.success((n.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(s.subjectsCreated)).replace("{tags}",String(s.tagsCreated)).replace("{items}",String(s.errorItemsCreated)).replace("{schedules}",String(s.reviewSchedulesCreated)).replace("{records}",String(s.practiceRecordsCreated)).replace("{papers}",String(s.examPapersCreated??0)).replace("{voices}",String(s.ttsSpeechesImported??0)).replace("{duplicates}",String(s.duplicateErrorItems??0))),p(null),window.location.reload()}catch(t){t instanceof i.a&&409===t.status&&t.data?.code==="TASK_ALREADY_RUNNING"?($.c.info(n.errors.TASK_ALREADY_RUNNING),await g()):(l.V.error("[DataBackupSettings]",e?"Import all failed":"Import failed",{error:t}),$.c.error(n.settings?.importFailed||"Import failed"))}finally{m(!1)}}},y=(e,s)=>e?(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}):s,v=o||!!h;return(0,t.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,t.jsx)("h4",{className:"text-sm font-bold text-blue-900 dark:text-blue-200 mb-3",children:n.settings?.dataManagement||"Data Management"}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:n.settings?.exportData||"Export Data"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>j(!1),disabled:c,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:[y(c,(0,t.jsx)(ta.f,{className:"mr-2 h-4 w-4"})),n.settings?.exportData||"Export"]}),e&&(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>j(!0),disabled:c,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:[y(c,(0,t.jsx)(ta.f,{className:"mr-2 h-4 w-4"})),n.settings?.exportAllData||"Export All"]})]})]}),(0,t.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:n.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:n.settings?.importData||"Import Data"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"file",accept:".json",onChange:e=>p(e.target.files?.[0]??u),className:"hidden",id:"import-file-input",disabled:v}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:v,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:[y(v,(0,t.jsx)(eK.f,{className:"mr-2 h-4 w-4"})),u?.name||n.settings?.selectFile||"Select File"]}),u&&(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>b(!1),disabled:v,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:[y(v,(0,t.jsx)(ts.f,{className:"mr-2 h-4 w-4"})),n.settings?.importData||"Import"]}),u&&e&&(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>b(!0),disabled:v,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:[y(v,(0,t.jsx)(ts.f,{className:"mr-2 h-4 w-4"})),n.settings?.importAllData||"Import All"]})]})]}),(0,t.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:n.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}let tl={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"}]]};tl.node;let tc=(0,E.f)(tl),td="/api/admin/debug-logs";function to(){let{t:e}=(0,a.b)(),{timeZone:r}=(0,v.M)(),n=e.admin.debugLog,[c,d]=(0,s.useState)(null),[o,m]=(0,s.useState)(!1),u=(0,s.useCallback)(async()=>{try{d(await i.k.get(td))}catch(e){l.V.warn("[DebugLogSettings]","Failed to load debug status",{error:e})}},[]);(0,s.useEffect)(()=>{u()},[u]),(0,s.useEffect)(()=>{if(!c?.enabled)return;let e=setInterval(u,5e3);return()=>clearInterval(e)},[c?.enabled,u]);let p=async(e,t)=>{m(!0);try{await e(),$.c.success(t)}catch(e){l.V.error("[DebugLogSettings]","Debug log action failed",{error:e}),$.c.error(n.failed)}finally{m(!1)}},x=e=>e?(0,eo.r)(e,"yyyy-MM-dd HH:mm",r):"",h=c?.enabled?n.enabledHint.replace("{since}",x(c.enabledAt)).replace("{until}",x(c.expiresAt)):n.disabledHint,g=(c?.entryCount??0)>0;return(0,t.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)(ex.f,{htmlFor:"debug-mode-switch",className:"flex items-center gap-2 font-medium",children:[(0,t.jsx)(tc,{className:"h-4 w-4"}),n.title]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.desc})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:n.enable}),(0,t.jsx)(eu.f,{id:"debug-mode-switch",checked:!!c?.enabled,onCheckedChange:e=>p(async()=>{d(await i.k.post(td,{enabled:e}))},e?n.enabled:n.disabled),disabled:o||!c})]})]}),(0,t.jsxs)("p",{className:`text-xs ${c?.enabled?"text-orange-600":"text-muted-foreground"}`,children:[h,c&&(0,t.jsxs)(t.Fragment,{children:[" ",n.entries.replace("{count}",String(c.entryCount)),c.droppedCount>0&&n.dropped.replace("{count}",String(c.droppedCount))]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>p(async()=>{await ti(`${td}/export`,"wrong-notebook-debug.json"),await u()},n.exported),disabled:o||!g,className:"sm:flex-1",children:[o?(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(ta.f,{className:"mr-2 h-4 w-4"}),n.export]}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>p(async()=>{d(await i.k.delete(td))},n.cleared),disabled:o||!g,children:[(0,t.jsx)(ev.f,{className:"mr-2 h-4 w-4"}),n.clear]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.privacyNote})]})}var tm=e.i(307364);function tu({field:e,label:r,description:n}){let{t:c}=(0,a.b)(),[d,o]=(0,s.useState)(!1),[m,u]=(0,s.useState)(!1),[p,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null),f=`preference-${e}`;(0,s.useEffect)(()=>{i.k.get("/api/user").then(t=>o(!!t[e])).catch(()=>void 0).finally(()=>u(!0))},[e]);let j=async t=>{o(t),x(!0);try{await i.k.patch("/api/user",{[e]:t}),g(c.importFlow.preferenceSaved)}catch(s){o(!t),g(c.importFlow.preferenceSaveFailed),l.V.error("[Settings]","Failed to save user preference",{field:e,error:s instanceof Error?s.message:String(s)})}finally{x(!1)}};return(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsx)(ex.f,{htmlFor:f,children:r}),(0,t.jsx)(eu.f,{id:f,checked:d,onCheckedChange:j,disabled:!m||p})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n}),h&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:h})]})}function tp(){let{t:e}=(0,a.b)();return(0,t.jsx)(tu,{field:"enableGeogebra",label:e.importFlow.enableGeogebra,description:e.importFlow.enableGeogebraDesc})}function tx(){let{t:e}=(0,a.b)();return(0,t.jsx)(tu,{field:"confirmBeforeImport",label:e.importFlow.confirmBeforeImport,description:e.importFlow.confirmBeforeImportDesc})}var th=e.i(905110);function tg(){let{t:e}=(0,a.b)(),[r,n]=(0,s.useState)(String(th.z)),[c,d]=(0,s.useState)(null),[o,m]=(0,s.useState)(!0),[u,p]=(0,s.useState)(!1),[x,h]=(0,s.useState)(null),g=Number(r),f=""!==r.trim()&&Number.isInteger(g)&&g>=th.P&&g<=th.o,j=(0,s.useCallback)(async()=>{m(!0),h(null);try{let e=(await i.k.get("/api/user")).masteryThreshold??th.z;n(String(e)),d(e)}catch(t){h(e.mastery.thresholdLoadFailed),l.V.error("[Settings]","加载已掌握阈值失败",{error:t instanceof Error?t.message:String(t)})}finally{m(!1)}},[e.mastery.thresholdLoadFailed]);(0,s.useEffect)(()=>{j()},[j]);let b=async()=>{if(f&&null!==c){p(!0),h(null);try{let t=(await i.k.patch("/api/user",{masteryThreshold:g})).masteryThreshold??g;d(t),n(String(t)),h(e.importFlow.preferenceSaved)}catch(t){h(e.importFlow.preferenceSaveFailed),l.V.error("[Settings]","保存已掌握阈值失败",{error:t instanceof Error?t.message:String(t)})}finally{p(!1)}}};return(0,t.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,t.jsx)(ex.f,{htmlFor:"mastery-threshold",children:e.mastery.thresholdLabel}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(ep.f,{id:"mastery-threshold",type:"number",min:th.P,max:th.o,step:1,value:r,onChange:e=>{n(e.target.value),h(null)},disabled:o||u||null===c,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,t.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,t.jsxs)(k.f,{type:"button",size:"sm",variant:"outline",onClick:b,disabled:o||u||null===c||!f||g===c,children:[(o||u)&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.importFlow.saveThreshold]}),!o&&null===c&&(0,t.jsx)(k.f,{type:"button",size:"sm",variant:"outline",onClick:j,children:e.importFlow.retryLoad})]}),(0,t.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:e.mastery.thresholdDescription}),null!==c&&!f&&(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:e.mastery.thresholdInvalid}),x&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:x})]})}var tf=e.i(28342);function tj(){let{t:e}=(0,a.b)(),[r,c]=(0,s.useState)({gradeRecognitionMode:"fixed",fixedGradeSemester:null}),[d,o]=(0,s.useState)(null),[m,u]=(0,s.useState)(!0),[p,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null),f=(0,s.useRef)(0),j=(0,s.useCallback)(async()=>{let t=++f.current;u(!0),g(null);try{let e=await i.k.get("/api/user");if(t!==f.current)return;let s={gradeRecognitionMode:e.gradeRecognitionMode??"fixed",fixedGradeSemester:e.fixedGradeSemester??null};c(s),o(s)}catch(s){if(t!==f.current)return;g(e.questionGrade.loadFailed),l.V.error("[QuestionGradeSetting]","加载录入年级规则失败",{error:(0,n.Z)(s)})}finally{t===f.current&&u(!1)}},[e.questionGrade.loadFailed]);(0,s.useEffect)(()=>{j()},[j]);let b=async()=>{x(!0),g(null);try{let t=await i.k.patch("/api/user",r),s={gradeRecognitionMode:t.gradeRecognitionMode??r.gradeRecognitionMode,fixedGradeSemester:t.fixedGradeSemester??null};c(s),o(s),g(e.importFlow.preferenceSaved)}catch(t){g(e.importFlow.preferenceSaveFailed),l.V.error("[QuestionGradeSetting]","保存录入年级规则失败",{error:(0,n.Z)(t)})}finally{x(!1)}},y=m||p||null===d,v=d?.gradeRecognitionMode===r.gradeRecognitionMode&&d?.fixedGradeSemester===r.fixedGradeSemester;return(0,t.jsxs)("div",{className:"space-y-3 border-t pt-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{htmlFor:"question-grade-mode",children:e.questionGrade.label}),(0,t.jsxs)("select",{id:"question-grade-mode",value:r.gradeRecognitionMode,disabled:y,onChange:e=>{c({...r,gradeRecognitionMode:e.target.value}),g(null)},className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm disabled:opacity-50",children:[(0,t.jsx)("option",{value:"fixed",children:e.questionGrade.fixed}),(0,t.jsx)("option",{value:"ai",children:e.questionGrade.ai})]})]}),"fixed"===r.gradeRecognitionMode&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{htmlFor:"question-fixed-grade",children:e.editor.gradeSemester}),(0,t.jsx)(tf.f,{id:"question-fixed-grade",value:r.fixedGradeSemester??"",disabled:y,onChange:e=>{c({...r,fixedGradeSemester:e||null}),g(null)}})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"fixed"===r.gradeRecognitionMode?e.questionGrade.fixedDescription:e.questionGrade.aiDescription}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.questionGrade.description}),(0,t.jsxs)(k.f,{type:"button",variant:"outline",size:"sm",disabled:y||v,onClick:b,children:[(m||p)&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.questionGrade.save]}),!m&&null===d&&(0,t.jsx)(k.f,{type:"button",variant:"outline",size:"sm",onClick:j,children:e.importFlow.retryLoad}),h&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:h})]})}function tb(){let{t:e}=(0,a.b)();return(0,t.jsx)(tu,{field:"enableSvgAnimation",label:e.importFlow.enableSvgAnimation,description:e.importFlow.enableSvgAnimationDesc})}function ty({value:e,onChange:s,disabled:r}){let{t:i}=(0,a.b)();return(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsx)(ex.f,{htmlFor:"app-time-zone",children:i.settings.general.timeZoneLabel}),(0,t.jsx)(ep.f,{id:"app-time-zone",value:e,onChange:e=>s(e.target.value),disabled:r,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,t.jsx)("datalist",{id:"app-time-zones",children:["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Europe/London","America/New_York","America/Los_Angeles","UTC"].map(e=>(0,t.jsx)("option",{value:e},e))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:i.settings.general.timeZoneDesc})]})}function tv({config:e,setConfig:s,isAdmin:r,disabled:i}){let{t:n,language:l,setLanguage:c}=(0,a.b)(),{timeZone:d}=(0,v.M)(),o=e=>s(t=>({...t,timeouts:{...t.timeouts,analyze:1e3*e}}));return(0,t.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:n.settings?.language||"Language"}),(0,t.jsxs)(eO.d,{value:l,onValueChange:e=>c(e),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{})}),(0,t.jsxs)(eO.r,{children:[(0,t.jsx)(eO.T,{value:"zh",children:"中文 (Chinese)"}),(0,t.jsx)(eO.T,{value:"en",children:"English"})]})]})]}),(0,t.jsx)(ty,{value:e.timeZone??d,onChange:e=>s(t=>({...t,timeZone:e})),disabled:!r||i}),r&&(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsx)(ex.f,{children:n.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,t.jsx)(ep.f,{type:"number",value:e.timeouts?.analyze?e.timeouts.analyze/1e3:"",onChange:e=>{let t=""===e.target.value?0:parseInt(e.target.value);o(isNaN(t)?0:t)},onBlur:()=>{let t=(e.timeouts?.analyze||0)/1e3,s=Math.min(600,Math.max(120,t));s!==t&&o(s)},min:120,max:600}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,t.jsx)(tx,{}),(0,t.jsx)(tj,{}),(0,t.jsx)(tb,{}),(0,t.jsx)(tp,{}),(0,t.jsx)(tm.f,{}),(0,t.jsx)(tg,{})]})}var tw=e.i(77071),tN=e.i(515288),tk=e.i(470279);function tS(){let{t:e}=(0,a.b)(),{groups:r,loading:n,refetch:c}=(0,tk.f)(),[d,o]=(0,s.useState)(""),[m,u]=(0,s.useState)(!1),p=async()=>{let t=d.trim();if(t){u(!0);try{await i.k.post("/api/paper-groups",{name:t}),o(""),$.c.success(e.common?.messages?.saveSuccess||"Saved"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to add group",{error:t}),$.c.error(e.common?.messages?.saveFailed||"Failed to save")}finally{u(!1)}}},x=async(t,s)=>{let a=window.prompt(e.settings?.paperGroups?.renamePrompt||"Rename group",s);if(a&&a.trim()!==s)try{await i.k.patch(`/api/paper-groups/${t}`,{name:a.trim()}),$.c.success(e.common?.messages?.saveSuccess||"Saved"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to rename group",{error:t}),$.c.error(e.common?.messages?.saveFailed||"Failed to save")}},h=async(t,s)=>{try{await i.k.patch(`/api/paper-groups/${t}`,{isActive:!s}),$.c.success(e.common?.messages?.saveSuccess||"Saved"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to toggle group",{error:t}),$.c.error(e.common?.messages?.saveFailed||"Failed to save")}},g=async(t,s,a)=>{if(a>0){let r=(e.settings?.paperGroups?.deleteConfirmWithItems||'Group "{name}" has {count} questions. Deleting will clear their group assignment. Continue?').replace("{name}",s).replace("{count}",String(a));if(!await (0,$.u)(r,{destructive:!0}))return;try{await i.k.delete(`/api/paper-groups/${t}?clear=true`),$.c.success(e.common?.messages?.deleteSuccess||"Deleted"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to delete group",{error:t}),$.c.error(e.common?.messages?.deleteFailed||"Delete failed")}return}let r=(e.settings?.paperGroups?.deleteConfirm||'Delete group "{name}"?').replace("{name}",s);if(await (0,$.u)(r,{destructive:!0}))try{await i.k.delete(`/api/paper-groups/${t}`),$.c.success(e.common?.messages?.deleteSuccess||"Deleted"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to delete group",{error:t}),$.c.error(e.common?.messages?.deleteFailed||"Delete failed")}};return n?(0,t.jsx)(tN.N,{children:(0,t.jsx)(tN.O,{className:"py-12 flex items-center justify-center",children:(0,t.jsx)(N.f,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):(0,t.jsxs)(tN.N,{children:[(0,t.jsxs)(tN.Y,{children:[(0,t.jsxs)(tN.v,{className:"flex items-center gap-2 text-lg",children:[(0,t.jsx)(z.f,{className:"h-5 w-5"}),e.settings?.paperGroups?.title||"Paper Groups"]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e.settings?.paperGroups?.desc||"Customize paper groups like Unit Test, Midterm, Final. Default groups A/B/Other can be renamed but not deleted."})]}),(0,t.jsxs)(tN.O,{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(ep.f,{value:d,onChange:e=>o(e.target.value),placeholder:e.settings?.paperGroups?.addPlaceholder||"e.g. Unit Test",onKeyDown:e=>{"Enter"===e.key&&p()}}),(0,t.jsxs)(k.f,{onClick:p,disabled:m||!d.trim(),children:[m?(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(tw.f,{className:"h-4 w-4 mr-1"}),e.common?.add||"Add"]})]}),(0,t.jsx)("div",{className:"space-y-2",children:r.map(s=>(0,t.jsxs)("div",{className:`flex items-center justify-between rounded-lg border p-3 ${!s.isActive?"opacity-50":""}`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"font-medium",children:s.name}),s.key&&(0,t.jsx)(em.f,{variant:"secondary",className:"text-xs",children:e.settings?.paperGroups?.systemBadge||"Default"}),!s.isActive&&(0,t.jsx)(em.f,{variant:"outline",className:"text-xs",children:e.common?.inactive||"Inactive"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>x(s.id,s.name),children:e.common?.rename||"Rename"}),(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>h(s.id,s.isActive),children:s.isActive?e.common?.deactivate||"Deactivate":e.common?.activate||"Activate"}),!s.key&&(0,t.jsx)(k.f,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>g(s.id,s.name,s._count?.errorItems||0),children:(0,t.jsx)(ev.f,{className:"h-4 w-4"})})]})]},s.id))})]})]})}var tC=e.i(515745),tT=e.i(508734),t_=e.i(395925),tA=e.i(328623),tz=e.i(624687);async function tE(e,t){try{return await navigator.clipboard.writeText(e),!0}catch{return t(e),!1}}async function tD(){try{return await navigator.clipboard.readText()}catch{return null}}function tF({value:e,defaultValue:r,onChange:i,onReset:n,title:l,variables:c}){let{t:d}=(0,a.b)(),[o,m]=(0,s.useState)(!1),u=(0,s.useMemo)(()=>{let t=new Set(Array.from(new Set(Array.from(e.matchAll(/\{\{(\w+)\}\}/g),e=>e[1]))));return c.filter(e=>!t.has(e.name))},[e,c]),p=async()=>{await tE(e,e=>window.prompt(d.settings?.prompts?.copyManual||"Copy the template manually:",e))&&(m(!0),setTimeout(()=>m(!1),1500),$.c.success(d.settings?.prompts?.copied||"Template copied"))},x=async()=>{let t=await tD();null===t?$.c.error(d.settings?.prompts?.pasteFailed||"Cannot read the clipboard. Paste into the box manually."):t.trim()?(!e.trim()||await (0,$.u)(d.settings?.prompts?.pasteConfirm||"Replace the current template with the clipboard content?",{destructive:!0}))&&(i(t),$.c.success(d.settings?.prompts?.pasted||"Template replaced from the clipboard")):$.c.error(d.settings?.prompts?.pasteEmpty||"The clipboard is empty")},h=async()=>{await (0,$.u)(d.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&n()};return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)(ex.f,{className:"text-base font-semibold",children:l}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:p,children:[(0,t.jsx)(tT.f,{className:"w-4 h-4 mr-2"}),o?d.settings?.prompts?.copied||"Copied":d.settings?.prompts?.copy||"Copy"]}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:x,children:[(0,t.jsx)(tC.f,{className:"w-4 h-4 mr-2"}),d.settings?.prompts?.pasteReplace||"Replace with clipboard"]}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:h,children:[(0,t.jsx)(t_.f,{className:"w-4 h-4 mr-2"}),d.settings?.prompts?.reset||"Reset Default"]})]})]}),(0,t.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",children:[(0,t.jsx)(tA.f,{className:"w-4 h-4 mt-0.5 shrink-0"}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"font-medium",children:d.settings?.prompts?.customizeTitle||"Tailor the prompt to your child"}),(0,t.jsx)("p",{children:d.settings?.prompts?.customizeBody||"Copy the default template, rewrite the role, tone and analysis steps to fit your child's grade, weak points and learning habits, then paste it back. Keep the {{variables}}: they are filled with each question's data."})]})]}),(0,t.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,t.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,t.jsx)(et,{className:"h-3.5 w-3.5"}),d.settings?.prompts?.variables||"Available Variables"]}),(0,t.jsx)("div",{className:"space-y-1.5",children:c.map(e=>(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,t.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] shrink-0",children:`{{${e.name}}}`}),(0,t.jsx)("span",{className:"text-muted-foreground",children:e.description})]},e.name))}),u.length>0&&(0,t.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 pt-1",children:(d.settings?.prompts?.missingVariables||"Not referenced in this template: {names}. The app still adds the matching rules, but the data will not reach the model.").replace("{names}",u.map(e=>`{{${e.name}}}`).join("、"))})]}),(0,t.jsx)(tz.f,{value:e,onChange:e=>i(e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:r,"aria-label":l})]})}var tM=e.i(247167);let tL="[REDACTED]",tR=/api[-_]?key|password|passwd|secret|authorization|cookie|credential|private[-_]?key|^(access|refresh|id|auth|api|bearer|session|csrf|setup)?[-_]?token$/i,t$=Symbol.for("wrong-notebook.debug-log");function tI(){let e=globalThis,t=e[t$];return t||(t={enabledAt:null,entries:[],totalSize:0,dropped:0},e[t$]=t),t}function tG(e){let t=e.replace(/data:([\w.+-]+\/[\w.+-]+);base64,[A-Za-z0-9+/=]+/g,(e,t)=>`[data:${t}, ${e.length} chars]`).replace(/(Bearer\s+)[\w\-.~+/]+=*/gi,`$1${tL}`).replace(/\bsk-[A-Za-z0-9_-]{8,}/g,tL).replace(/([?&](?:key|api_key|apikey|token|access_token)=)[^&\s"']+/gi,`$1${tL}`);return t.length>1e4&&(t=`${t.slice(0,1e4)}…[truncated ${t.length-1e4} chars]`),t}function tV(e,t,s,a=new Date){if(function(e=Date.now()){let t=tI();return null!==t.enabledAt&&(!(e-t.enabledAt>=864e5)||(t.enabledAt=null,!1))}(a.getTime()))try{let r={...function e(t,s=0,a=new WeakSet){if(null==t)return t;if("string"==typeof t)return tG(t);if("number"==typeof t||"boolean"==typeof t)return t;if("bigint"==typeof t)return t.toString();if("function"==typeof t||"symbol"==typeof t)return String(t);if(t instanceof Date)return t.toISOString();if(t instanceof Error){let r={name:t.name,message:tG(t.message)};return t.stack&&(r.stack=tG(t.stack)),void 0!==t.code&&(r.code=e(t.code,s+1,a)),void 0!==t.status&&(r.status=e(t.status,s+1,a)),void 0!==t.cause&&s<8&&(r.cause=e(t.cause,s+1,a)),r}if("object"!=typeof t)return String(t);if(a.has(t))return"[Circular]";if(s>=8)return"[Object]";if(a.add(t),Array.isArray(t)){let r=t.slice(0,100).map(t=>e(t,s+1,a));return t.length>100&&r.push(`…[${t.length-100} more items]`),r}return ArrayBuffer.isView(t)||t instanceof ArrayBuffer?`[Binary ${t.byteLength} bytes]`:Object.fromEntries(Object.entries(t).map(([t,r])=>[t,tR.test(t)&&null!=r&&""!==r?tL:e(r,s+1,a)]))}(t),time:a.toISOString(),level:e,msg:tG(s)},i=JSON.stringify(r).length,n=tI();for(n.entries.push({entry:r,size:i}),n.totalSize+=i;n.entries.length>5e3||n.totalSize>0x1400000&&n.entries.length>1;){let e=n.entries.shift();if(!e)break;n.totalSize-=e.size,n.dropped+=1}}catch{}}let tO={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function tP(e,t={}){let s,a=tO[e],r=(s=tM.default.env.LOG_LEVEL?.toLowerCase())&&void 0!==tO[s]?tO[s]:tO.info;return(s,i)=>{let n,l,c=new Date;if("string"==typeof s?(n={},l=s):(n=s,l=i||""),tV(e,{...t,...n},l,c),!(a<r)){let s=JSON.stringify({level:e,time:c.toISOString(),...t,...n,msg:l});switch(e){case"error":case"fatal":console.error(s);break;case"warn":console.warn(s);break;default:console.log(s)}}}}(function e(t={}){return t.module,{trace:tP("trace",t),debug:tP("debug",t),info:tP("info",t),warn:tP("warn",t),error:tP("error",t),fatal:tP("fatal",t),child:s=>e({...t,...s}),box:(e,s,a="📋")=>{tV("info",{...t,..."string"==typeof s?{content:s}:s},e);{let a="string"==typeof s?{content:s}:s||{};console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...t,title:e,...a,msg:e}));return}},divider:(e="-")=>{}}})({env:"production"}).child({module:"ai:prompts"});let tU=`填写题目类型,只能是以下 key 之一:single_choice(单选题)、multiple_choice(多选题)、true_false(判断题)、fill_blank(填空题)、calculation(计算题)、solution(解答题)、reading(阅读理解)、cloze(完形填空)、writing(写作)、other(其他)。
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,1661,e=>{"use strict";var t=e.i(843476),s=e.i(271645),a=e.i(111110),r=e.i(217255),i=e.i(41931),n=e.i(303163),l=e.i(201276);let c=["system","light","dark"],o="system",d="app-theme";function m(e){return"string"==typeof e&&c.includes(e)}let u=(0,s.createContext)({preference:o,theme:"light",setPreference:()=>void 0}),p="(prefers-color-scheme: dark)",x=new Set;function h(e){return x.add(e),window.addEventListener("storage",e),()=>{x.delete(e),window.removeEventListener("storage",e)}}function g(){try{let e=localStorage.getItem(d);return m(e)?e:o}catch{return o}}function f(e){try{localStorage.setItem(d,e)}catch{}x.forEach(e=>e())}function j(e){let t=window.matchMedia(p);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}let b=()=>window.matchMedia(p).matches;function y({children:e}){let{data:a,status:c}=(0,r.useSession)(),d="authenticated"===c,p=a?.user?.email,x=(0,s.useSyncExternalStore)(h,g,()=>o),v=(0,s.useSyncExternalStore)(j,b,()=>!1),w="system"===x?v?"dark":"light":x;(0,s.useEffect)(()=>{let e=document.documentElement,t=t=>{e.classList.toggle("dark","dark"===t),e.style.colorScheme=t};t(w);let s=()=>t("light"),a=()=>t(w);return window.addEventListener("beforeprint",s),window.addEventListener("afterprint",a),()=>{window.removeEventListener("beforeprint",s),window.removeEventListener("afterprint",a)}},[w]),(0,s.useEffect)(()=>{if(!d||!p)return;let e=!1;return i.k.get("/api/user").then(t=>{!e&&m(t.themePreference)&&t.themePreference!==g()&&f(t.themePreference)}).catch(e=>{l.V.warn("[Theme]","Failed to load theme preference",{error:(0,n.Z)(e)})}),()=>{e=!0}},[d,p]);let N=(0,s.useCallback)(e=>{f(e),d&&i.k.patch("/api/user",{themePreference:e}).catch(e=>{l.V.warn("[Theme]","Failed to save theme preference",{error:(0,n.Z)(e)})})},[d]),k=(0,s.useMemo)(()=>({preference:x,theme:w,setPreference:N}),[x,w,N]);return(0,t.jsx)(u.Provider,{value:k,children:e})}var v=e.i(215519),w=e.i(618566),N=e.i(632781),k=e.i(519455),S=e.i(776639),C=e.i(923512),T=e.i(749803),_=e.i(856423),A=e.i(975153),z=e.i(226091),E=e.i(456420);let D={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"]};D.node;let F=(0,E.f)(D),M=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],L=[{key:"home",href:"/",icon:F,match:e=>"/"===e},{key:"notebooks",href:"/notebooks",icon:_.f,match:e=>e.startsWith("/notebooks")||e.startsWith("/error-items")||e.startsWith("/practice")},{key:"review",href:"/review",icon:A.f,match:e=>e.startsWith("/review")},{key:"stats",href:"/stats",icon:T.f,match:e=>e.startsWith("/stats")||e.startsWith("/tags")},{key:"exams",href:"/exams",icon:z.f,match:e=>e.startsWith("/exams")}];function R(e){return M.some(t=>t.test(e))}var $=e.i(294114);let I="ai-consent-dismissed:";function V(){let{t:e,language:n}=(0,a.b)(),c=e.aiConsent,{data:o,status:d}=(0,r.useSession)(),m=(0,w.usePathname)()||"/",u="authenticated"===d?o?.user?.email??null:null,[p,x]=(0,s.useState)(null),[h,g]=(0,s.useState)(null),[f,j]=(0,s.useState)(!1);(0,s.useEffect)(()=>(0,C.y)(e=>x(t=>t??e)),[]);let b=R(m);(0,s.useEffect)(()=>{if(!u||b||function(e){try{return"1"===sessionStorage.getItem(e)}catch{return!1}}(I+u))return;let e=!1;return i.k.get("/api/user").then(t=>{e||!t||t.aiDataConsentAt||x(e=>e??"prompt")}).catch(e=>l.V.error("[AiConsentDialog]","load consent failed",{error:e})),()=>{e=!0}},[u,b]);let y=null!==p&&!!u;(0,s.useEffect)(()=>{if(!y)return;let e=!1;return i.k.get("/api/settings").then(t=>{e||g(t?.aiProvider??null)}).catch(()=>void 0),()=>{e=!0}},[y]);let v=()=>{x(null),j(!1)},T=async()=>{j(!0);try{await i.k.post("/api/user/ai-consent",{}),$.c.success("blocked"===p?c.agreedRetry:c.agreed),v()}catch(e){l.V.error("[AiConsentDialog]","save consent failed",{error:e}),$.c.error(c.failed),j(!1)}},_=()=>{u&&function(e){try{sessionStorage.setItem(e,"1")}catch{}}(I+u),$.c.info(c.declined),v()},A=(0,C.K)(h,n);return(0,t.jsx)(S.N,{open:y,onOpenChange:e=>{e||f||_()},children:(0,t.jsxs)(S.d,{className:"sm:max-w-lg",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:c.title}),(0,t.jsx)(S.C,{children:"blocked"===p?c.blocked:c.intro})]}),(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:["blocked"===p&&(0,t.jsx)("p",{children:c.intro}),(0,t.jsx)("ul",{className:"list-disc space-y-1 pl-5",children:c.items.map(e=>(0,t.jsx)("li",{children:e},e))}),(0,t.jsx)("p",{children:A?c.providerKnown.replace("{provider}",A):c.providerUnknown}),(0,t.jsxs)("p",{children:[c.policy,"en"===n?" ":"",(0,t.jsx)("a",{className:"underline underline-offset-2",href:(0,C.L)(n),target:"_blank",rel:"noopener noreferrer",children:c.policyLink}),"en"===n?".":"。"]}),(0,t.jsx)("p",{className:"text-muted-foreground",children:c.declineNote})]}),(0,t.jsxs)(S.c,{className:"gap-2",children:[(0,t.jsx)(k.f,{type:"button",variant:"outline",onClick:_,disabled:f,children:c.decline}),(0,t.jsxs)(k.f,{type:"button",onClick:T,disabled:f,children:[f&&(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}),c.agree]})]})]})})}var G=e.i(325164),O=e.i(522016),P=e.i(367784);let U={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"}]]};U.node;let q=(0,E.f)(U);var H=e.i(424553);function K({status:e,onAccept:i}){let{t:n,language:c}=(0,a.b)(),[o,d]=(0,s.useState)(!1),m="en"===c?e.changes.en:e.changes.zh,u=async()=>{d(!0);try{await i()}catch(e){l.V.error("[EulaGate]","Failed to accept EULA",{error:e}),$.c.error(n.eula.acceptFailed)}finally{d(!1)}};return(0,t.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"eula-upgrade-title",children:(0,t.jsxs)("div",{className:"max-h-[90vh] w-full max-w-lg space-y-4 overflow-y-auto rounded-lg border bg-background p-5 shadow-lg",children:[(0,t.jsx)("h2",{id:"eula-upgrade-title",className:"text-lg font-semibold",children:n.eula.upgradeTitle}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n.eula.upgradeDesc.replace("{accepted}",e.accepted??"-").replace("{current}",e.current)}),m.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:n.eula.changesTitle}),(0,t.jsx)("ul",{className:"list-disc space-y-1 pl-5 text-sm",children:m.map(e=>(0,t.jsx)("li",{children:e},e))})]}),(0,t.jsx)(H.f,{}),(0,t.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,t.jsx)(k.f,{variant:"outline",onClick:()=>(0,r.signOut)({callbackUrl:"/login"}),disabled:o,children:n.eula.logout}),(0,t.jsxs)(k.f,{onClick:u,disabled:o,children:[o&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.eula.accept]})]})]})})}var B=e.i(980105),Y=e.i(901219),J=e.i(975157);function W({className:e}){let{t:r}=(0,a.b)(),{data:i}=(0,Y.b)(),n=(0,s.useRef)(null);if((0,s.useEffect)(()=>{if(!i)return;let e=new Set([...i.tasks.filter(e=>"analyzing"===e.status||"saving"===e.status).map(e=>e.id),...(i.batches??[]).filter(e=>"splitting"===e.phase||"processing"===e.phase).map(e=>`batch:${e.id}`)]),t=new Set([...i.tasks.filter(e=>e.unread).map(e=>e.id),...(i.batches??[]).filter(e=>e.unread).map(e=>`batch:${e.id}`)]),s=n.current;s&&[...s].some(s=>!e.has(s)&&t.has(s))&&$.c.info(r.importTasks.finishedToast),n.current=e},[i,r.importTasks.finishedToast]),!i||0===i.tasks.length&&!i.batches?.length)return null;let{activeCount:l,unreadCount:c}=i,o=l>0?r.importTasks.entryActive.replace("{count}",String(l)):r.importTasks.entry;return(0,t.jsxs)(O.default,{href:"/import-tasks",className:(0,J.f)("relative flex h-9 items-center gap-1.5 rounded-full border px-3 text-sm font-medium transition-colors hover:bg-muted",c>0?"border-primary/50 text-primary":"text-muted-foreground",e),"data-testid":"import-tasks-entry","aria-label":c>0?`${o} \xb7 ${r.importTasks.entryUnread.replace("{count}",String(c))}`:o,children:[l>0?(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(B.f,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"whitespace-nowrap",children:o}),c>0&&(0,t.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:c})]})}var X=e.i(853138);let Z={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"}]]};Z.node;let Q=(0,E.f)(Z),ee={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"}]]};ee.node;let et=(0,E.f)(ee);var es=e.i(999092);let ea={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"}]]};ea.node;let er=(0,E.f)(ea),ei={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"}]]};ei.node;let en=(0,E.f)(ei);var el=e.i(901279),ec=e.i(994533),eo=e.i(677572),ed=e.i(306831),em=e.i(487486),eu=e.i(699375),ep=e.i(793479),ex=e.i(110204);let eh=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("div",{className:"relative w-full overflow-auto",children:(0,t.jsx)("table",{ref:a,className:(0,J.f)("w-full caption-bottom text-sm",e),...s})}));eh.displayName="Table";let eg=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("thead",{ref:a,className:(0,J.f)("[&_tr]:border-b",e),...s}));eg.displayName="TableHeader";let ef=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("tbody",{ref:a,className:(0,J.f)("[&_tr:last-child]:border-0",e),...s}));ef.displayName="TableBody",(s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("tfoot",{ref:a,className:(0,J.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...s}))).displayName="TableFooter";let ej=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("tr",{ref:a,className:(0,J.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...s}));ej.displayName="TableRow";let eb=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("th",{ref:a,className:(0,J.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...s}));eb.displayName="TableHead";let ey=s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("td",{ref:a,className:(0,J.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...s}));ey.displayName="TableCell",(s.forwardRef(({className:e,...s},a)=>(0,t.jsx)("caption",{ref:a,className:(0,J.f)("mt-4 text-sm text-muted-foreground",e),...s}))).displayName="TableCaption";var ev=e.i(759659);let ew={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"}]]};ew.node;let eN=(0,E.f)(ew);var ek=e.i(548161);function eS(){var e;let{t:r}=(0,a.b)(),[n,c]=(0,s.useState)(String(5)),[o,d]=(0,s.useState)(!1),m=(0,s.useCallback)(async()=>{try{let e=await i.k.get("/api/settings");c(String(e.aiConcurrencyLimit??5))}catch(e){l.V.error("[AiConcurrencyLimitSetting]","Failed to fetch config",{error:e})}},[]);(0,s.useEffect)(()=>{m()},[m]);let u=Number(n),p=""!==n.trim()&&"number"==typeof(e=u)&&Number.isInteger(e)&&e>=1&&e<=100,x=async()=>{if(p){d(!0);try{await i.k.post("/api/settings",{aiConcurrencyLimit:u}),$.c.success(r.admin.aiConcurrencyLimitSaved)}catch(e){l.V.error("[AiConcurrencyLimitSetting]","Failed to update AI concurrency limit",{error:e}),$.c.error(r.common.error)}finally{d(!1)}}};return(0,t.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,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(ex.f,{htmlFor:"ai-concurrency-limit",className:"text-base",children:r.admin.aiConcurrencyLimit}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:r.admin.aiConcurrencyLimitDesc})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(ep.f,{id:"ai-concurrency-limit",type:"number",min:1,max:100,step:1,inputMode:"numeric",value:n,onChange:e=>c(e.target.value),"aria-invalid":!p,className:"w-24"}),(0,t.jsxs)(k.f,{size:"sm",onClick:x,disabled:o||!p,children:[o&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),r.common.save]})]})]})}function eC(e,t){return new Intl.NumberFormat("zh"===t?"zh-CN":"en-US",{notation:"compact",maximumFractionDigits:1}).format(Math.max(0,e))}function eT({user:e}){let{t:s,language:r}=(0,a.b)(),i=s.admin.aiTokensDetail.replace("{input}",eC(e.aiTokensToday.input,r)).replace("{output}",eC(e.aiTokensToday.output,r));return(0,t.jsxs)(t.Fragment,{children:[s.admin.aiUsageToday,": ",e.aiUsageToday," | ",s.admin.aiTokensToday,": ",i]})}function e_(){let{timeZone:e}=(0,v.M)(),{data:c}=(0,r.useSession)(),{t:o}=(0,a.b)(),[d,m]=(0,s.useState)([]),[u,p]=(0,s.useState)(!0),[x,h]=(0,s.useState)(!1),[g,f]=(0,s.useState)(!1),[j,b]=(0,s.useState)("0"),[y,w]=(0,s.useState)(!1),S=(0,s.useCallback)(async()=>{p(!0);try{let e=await i.k.get("/api/admin/users");m(e)}catch(e){l.V.error("[UserManagement]","Failed to fetch users",{error:e})}finally{p(!1)}},[]),C=(0,s.useCallback)(async()=>{try{let e=await i.k.get("/api/settings");h(!0===e.allowRegistration),b(String(e.aiDailyLimit??0))}catch(e){l.V.error("[UserManagement]","Failed to fetch config",{error:e})}},[]);(0,s.useEffect)(()=>{S(),C()},[S,C]);let T=async e=>{f(!0);try{await i.k.post("/api/settings",{allowRegistration:e}),h(e)}catch(e){l.V.error("[UserManagement]","Failed to update registration setting",{error:e}),$.c.error(o.common.error)}finally{f(!1)}},_=Number(j),A=""!==j.trim()&&Number.isInteger(_)&&_>=0,z=async()=>{if(A){w(!0);try{await i.k.post("/api/settings",{aiDailyLimit:_}),$.c.success(o.admin.aiDailyLimitSaved)}catch(e){l.V.error("[UserManagement]","Failed to update AI daily limit",{error:e}),$.c.error(o.common.error)}finally{w(!1)}}},E=async e=>{let t=e.isActive?o.admin.confirmDisable:o.admin.confirmEnable;if(await (0,$.u)(t))try{await i.k.patch(`/api/admin/users/${e.id}`,{isActive:!e.isActive}),S()}catch(e){l.V.error("[UserManagement]","Failed to update user status",{error:e}),$.c.error(o.common.error)}},D=async e=>{if(await (0,$.u)(o.admin.confirmDelete,{destructive:!0}))try{await i.k.delete(`/api/admin/users/${e.id}`),S()}catch(t){l.V.error("[UserManagement]","Failed to delete user",{error:t});let e=(0,n.d)(t)||o.common.error;$.c.error(e)}};return u?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(N.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(ex.f,{className:"text-base",children:o.admin?.allowRegistration||"Allow New Registrations"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:o.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}),(0,t.jsx)(eu.f,{checked:x,onCheckedChange:T,disabled:g})]})]}),(0,t.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,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(ex.f,{htmlFor:"ai-daily-limit",className:"text-base",children:o.admin.aiDailyLimit}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:o.admin.aiDailyLimitDesc})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(ep.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:j,onChange:e=>b(e.target.value),"aria-invalid":!A,className:"w-24"}),(0,t.jsxs)(k.f,{size:"sm",onClick:z,disabled:y||!A,children:[y&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),o.common.save]})]})]}),(0,t.jsx)(eS,{}),(0,t.jsx)("div",{className:"sm:hidden space-y-3",children:d.map(s=>(0,t.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,t.jsxs)("div",{className:"flex justify-between items-start",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium",children:s.name||"N/A"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:s.email})]}),(0,t.jsx)(em.f,{variant:"admin"===s.role?"default":"secondary",children:"admin"===s.role?o.admin.admin:o.admin.user})]}),(0,t.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,t.jsxs)("div",{className:"text-muted-foreground",children:[o.admin.errors,": ",s._count.errorItems," | ",o.admin.practiceCount,": ",s._count.practiceRecords," | ",(0,t.jsx)(eT,{user:s})]}),(0,t.jsx)(em.f,{variant:s.isActive?"default":"destructive",className:"text-xs",children:s.isActive?o.admin.active:o.admin.disabled})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,ed.r)(s.createdAt,"yyyy-MM-dd",e)}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>E(s),disabled:s.id===c?.user?.id,children:s.isActive?(0,t.jsx)(eN,{className:"h-4 w-4 text-orange-500"}):(0,t.jsx)(ek.f,{className:"h-4 w-4 text-green-500"})}),(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>D(s),disabled:s.id===c?.user?.id,children:(0,t.jsx)(ev.f,{className:"h-4 w-4 text-destructive"})})]})]})]},s.id))}),(0,t.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,t.jsxs)(eh,{children:[(0,t.jsx)(eg,{children:(0,t.jsxs)(ej,{children:[(0,t.jsx)(eb,{children:o.admin.nameEmail}),(0,t.jsx)(eb,{children:o.admin.role}),(0,t.jsx)(eb,{children:o.admin.stats}),(0,t.jsx)(eb,{children:o.admin.createdAt}),(0,t.jsx)(eb,{children:o.admin.status}),(0,t.jsx)(eb,{className:"text-right",children:o.admin.actions})]})}),(0,t.jsx)(ef,{children:d.map(s=>(0,t.jsxs)(ej,{children:[(0,t.jsxs)(ey,{children:[(0,t.jsx)("div",{className:"font-medium",children:s.name||"N/A"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:s.email})]}),(0,t.jsx)(ey,{children:(0,t.jsx)(em.f,{variant:"admin"===s.role?"default":"secondary",children:"admin"===s.role?o.admin.admin:o.admin.user})}),(0,t.jsxs)(ey,{children:[(0,t.jsxs)("div",{className:"text-sm",children:[o.admin.errors,": ",s._count.errorItems]}),(0,t.jsxs)("div",{className:"text-sm",children:[o.admin.practiceCount,": ",s._count.practiceRecords]}),(0,t.jsx)("div",{className:"text-sm",children:(0,t.jsx)(eT,{user:s})})]}),(0,t.jsx)(ey,{children:(0,ed.r)(s.createdAt,"yyyy-MM-dd",e)}),(0,t.jsx)(ey,{children:(0,t.jsx)(em.f,{variant:s.isActive?"default":"destructive",children:s.isActive?o.admin.active:o.admin.disabled})}),(0,t.jsxs)(ey,{className:"text-right space-x-2",children:[(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>E(s),disabled:s.id===c?.user?.id,title:s.isActive?o.admin.disable:o.admin.enable,children:s.isActive?(0,t.jsx)(eN,{className:"h-4 w-4 text-orange-500"}):(0,t.jsx)(ek.f,{className:"h-4 w-4 text-green-500"})}),(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>D(s),disabled:s.id===c?.user?.id,title:o.admin.delete,children:(0,t.jsx)(ev.f,{className:"h-4 w-4 text-destructive"})})]})]},s.id))})]})})]})}var eA=e.i(482022);let ez={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"}]]};ez.node;let eE=(0,E.f)(ez);function eD(e){return(0,t.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",...e,children:[(0,t.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,t.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}let eF={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"}]]};eF.node;let eM=(0,E.f)(eF);var eL=e.i(81968);let eR=()=>()=>void 0;function e$(){let{t:e}=(0,a.b)(),r=(0,s.useSyncExternalStore)(eR,eL.f,()=>null);return r?r.isStandalone?.()?(0,t.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:e.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsxs)("span",{className:"break-all",children:[e.settings?.about?.androidServer||"Server",": ",r.getServerUrl()]}),(0,t.jsxs)(k.f,{variant:"outline",className:"gap-2",onClick:()=>r.changeServer(),children:[(0,t.jsx)(eM,{className:"h-4 w-4"}),e.settings?.about?.changeServer||"Change server"]})]}):null}var eI=e.i(637691);function eV(){let{t:e}=(0,a.b)(),[r,i]=(0,s.useState)("");(0,s.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>i(e.version)).catch(()=>{})},[]);let n=[{href:eI.f,icon:eD,label:e.settings?.about?.github||"GitHub Repository"},{href:`${eI.f}/releases`,icon:eE,label:e.settings?.about?.releaseNotes||"Release Notes"},{href:`${eI.f}/issues`,icon:er,label:e.settings?.about?.feedback||"Feedback"}];return(0,t.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,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-2xl font-bold",children:e.app?.title||"Smart Error Notebook"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:e.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,t.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,t.jsx)(et,{className:"h-4 w-4"}),(0,t.jsxs)("span",{children:[e.settings?.about?.version||"Version",": v",r||"unknown"]})]}),(0,t.jsx)(e$,{}),(0,t.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:n.map(({href:e,icon:s,label:a})=>(0,t.jsx)(k.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,t.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[(0,t.jsx)(s,{className:"h-4 w-4"}),a,(0,t.jsx)(eA.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},e))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:e.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var eG=e.i(37038),eO=e.i(967489),eP=e.i(676167);let eU={name:"",email:"",educationStage:"",enrollmentYear:"",currentGrade:"",currentSemester:"",password:""};function eq(){let{t:e}=(0,a.b)(),[r,c]=(0,s.useState)(eU),[o,d]=(0,s.useState)(""),[m,u]=(0,s.useState)(!0),[p,x]=(0,s.useState)(!1),h=(0,s.useCallback)(async()=>{try{let e=await i.k.get("/api/user"),t=e.fixedGradeSemester?(0,eP.p)(e.fixedGradeSemester):null;c({name:e.name||"",email:e.email||"",educationStage:e.educationStage||"",enrollmentYear:e.enrollmentYear||"",currentGrade:t?.grade||"",currentSemester:t?.semester||"",password:""})}catch(e){l.V.error("[AccountSettings]","Failed to fetch profile",{error:e})}finally{u(!1)}},[]);(0,s.useEffect)(()=>{h()},[h]);let g=async()=>{if(r.password&&r.password!==o)return void $.c.error(e.settings?.messages?.passwordMismatch||"Passwords do not match");x(!0);try{let t={name:r.name,email:r.email,educationStage:r.educationStage};r.enrollmentYear&&(t.enrollmentYear=parseInt(r.enrollmentYear.toString())),r.password&&(t.password=r.password),r.currentGrade&&r.currentSemester?t.fixedGradeSemester=`${r.currentGrade}${r.currentSemester}`:r.currentGrade||(t.fixedGradeSemester=null),await i.k.patch("/api/user",t),$.c.success(e.settings?.messages?.profileUpdated||"Profile updated"),c(e=>({...e,password:""})),d(""),window.location.reload()}catch(t){l.V.error("[AccountSettings]","Failed to update profile",{error:(0,n.d)(t)??(0,n.Z)(t)}),$.c.error((0,n.d)(t)||e.settings?.messages?.updateFailed||"Update failed")}finally{x(!1)}};return m?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(N.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,t.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.name||"Name"}),(0,t.jsx)(ep.f,{value:r.name||"",onChange:e=>c({...r,name:e.target.value})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.email||"Email"}),(0,t.jsx)(ep.f,{value:r.email||"",onChange:e=>c({...r,email:e.target.value}),type:"email"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.educationStage||"Education Stage"}),(0,t.jsxs)(eO.d,{value:r.educationStage||"",onValueChange:e=>c({...r,educationStage:e,currentGrade:(0,eP.c)(e).includes(r.currentGrade)?r.currentGrade:"",currentSemester:(0,eP.c)(e).includes(r.currentGrade)?r.currentSemester:""}),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{placeholder:e.auth?.selectStage||"Select Stage"})}),(0,t.jsxs)(eO.r,{children:[(0,t.jsx)(eO.T,{value:"primary",children:e.auth?.primary||"Primary School"}),(0,t.jsx)(eO.T,{value:"junior_high",children:e.auth?.juniorHigh||"Junior High"}),(0,t.jsx)(eO.T,{value:"senior_high",children:e.auth?.seniorHigh||"Senior High"}),(0,t.jsx)(eO.T,{value:"university",children:e.auth?.university||"University"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.enrollmentYear||"Enrollment Year"}),(0,t.jsx)(ep.f,{type:"number",value:r.enrollmentYear||"",onChange:e=>c({...r,enrollmentYear:e.target.value}),placeholder:"YYYY"})]})]}),r.educationStage&&(0,eP.c)(r.educationStage).length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.settings?.account?.currentGrade||"Current Grade & Semester"}),(0,t.jsxs)(eO.d,{value:r.currentGrade||"",onValueChange:e=>c({...r,currentGrade:e,currentSemester:e?r.currentSemester||"上":""}),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{placeholder:e.settings?.account?.selectGrade||"Select Grade"})}),(0,t.jsx)(eO.r,{children:(0,eP.c)(r.educationStage).map(e=>(0,t.jsx)(eO.T,{value:e,children:e},e))})]})]}),r.currentGrade&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.settings?.account?.selectSemester||"Select Semester"}),(0,t.jsxs)(eO.d,{value:r.currentSemester||"",onValueChange:e=>c({...r,currentSemester:e}),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{placeholder:e.settings?.account?.selectSemester||"Select Semester"})}),(0,t.jsxs)(eO.r,{children:[(0,t.jsx)(eO.T,{value:"上",children:e.settings?.account?.firstSemester||"1st Semester"}),(0,t.jsx)(eO.T,{value:"下",children:e.settings?.account?.secondSemester||"2nd Semester"})]})]})]})]}),r.currentGrade&&r.currentSemester&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground -mt-2",children:e.settings?.account?.gradeAppliedHint||"New questions will default to this grade. You can also configure AI grade recognition in General Settings."}),(0,t.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,t.jsx)(eG.f,{value:r.password,onChange:e=>c({...r,password:e.target.value}),placeholder:"******",minLength:6})]}),r.password&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:e.auth?.confirmPassword||"Confirm Password"}),(0,t.jsx)(eG.f,{value:o,onChange:e=>d(e.target.value),placeholder:"******",minLength:6})]})]}),(0,t.jsxs)(k.f,{onClick:g,disabled:p,className:"w-full",children:[p&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.settings?.account?.update||"Update Profile"]})]})}var eH=e.i(10038),eK=e.i(725981),eB=e.i(411382),eY=e.i(54105),eJ=e.i(978056),eW=e.i(772325);let eX="https://github.com/xiaoyang111222/cn-math-taxonomy",eZ="https://raw.githubusercontent.com/xiaoyang111222/cn-math-taxonomy/HEAD/data/topics.json",eQ=eB.z.object({id:eY.z.string().optional(),name:eY.z.string().trim().min(1),subject:eY.z.string().nullish(),grade:eJ.z.number().int(),semester:eY.z.string().nullish(),chapter:eY.z.string().nullish()}).passthrough();eW.z.array(eQ).min(1);let e0="/api/admin/cnm-tags";function e1(){let{t:e}=(0,a.b)(),r=e.admin.cnmTags,[n,c]=(0,s.useState)(null),[o,d]=(0,s.useState)(!1),m=(0,s.useRef)(null),u=(0,s.useCallback)(async()=>{try{c(await i.k.get(e0))}catch(e){l.V.warn("[CnmTagImportSettings]","Failed to load status",{error:e})}},[]);(0,s.useEffect)(()=>{u()},[u]);let p=async e=>{if(e){d(!0);try{let t;try{t=JSON.parse(await e.text())}catch{$.c.error(r.invalidFile);return}let s=await i.k.post(e0,{topics:t},{timeout:3e5});c(s.status),$.c.success(r.imported.replace("{created}",String(s.result.created)).replace("{skipped}",String(s.result.skipped)))}catch(t){l.V.error("[CnmTagImportSettings]","Import failed",{error:t});let e=t instanceof i.a&&400===t.status;$.c.error(e?r.invalidFile:r.failed)}finally{d(!1),m.current&&(m.current.value="")}}},x=n?.knowledgePoints??0;return(0,t.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(_.f,{className:"h-4 w-4"}),r.title]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:r.desc})]}),(0,t.jsxs)("div",{className:"space-y-1 rounded-md bg-muted/50 p-3 text-xs text-muted-foreground",children:[(0,t.jsx)("p",{children:r.downloadHint}),(0,t.jsx)("a",{href:eZ,target:"_blank",rel:"noopener noreferrer",className:"block break-all text-primary underline",children:eZ}),(0,t.jsxs)("p",{children:[r.sourceLabel," ",(0,t.jsx)("a",{href:eX,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline",children:eX})]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n?x>0?r.status.replace("{count}",String(x)):r.notImported:""}),(0,t.jsx)("input",{ref:m,type:"file",accept:".json,application/json",className:"hidden",onChange:e=>p(e.target.files?.[0]),disabled:o}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:()=>m.current?.click(),disabled:o,children:[o?(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(eK.f,{className:"mr-2 h-4 w-4"}),o?r.importing:r.select]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:r.note})]})}var e2=e.i(741120);let e4={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 e3({title:e,description:s,tone:a,busy:r,icon:i,onClick:n}){let l=e4[a];return(0,t.jsxs)("div",{className:`p-4 border rounded-lg ${l.card}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:`text-sm flex items-center gap-2 ${l.title}`,children:e}),(0,t.jsx)(k.f,{variant:"info"===a?"outline":"destructive",size:"sm",onClick:n,disabled:r,className:l.button,children:r?(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}):i})]}),(0,t.jsx)("p",{className:`text-xs mt-2 ${l.desc}`,children:s})]})}function e5({isAdmin:e}){let{t:r}=(0,a.b)(),[n,c]=(0,s.useState)(null),o=async(e,t,s,a)=>{c(e);try{$.c.success(await t()),a&&window.location.reload()}catch(t){l.V.error("[DangerZoneSettings]",`${e} failed`,{error:t}),$.c.error(s)}finally{c(null)}},d=r.settings?.clearSuccess||"Success",m=r.settings?.clearError||"Failed",u=async()=>{await (0,$.u)(r.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await o("migrateTags",async()=>{let e=await i.k.post("/api/admin/migrate-tags",{});return`${d}: ${e.count||0} tags migrated.`},r.settings?.clearError||"Failed to migrate tags",!1)},p=async()=>{await (0,$.u)(r.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await o("clearPractice",async()=>(await i.k.delete("/api/stats/practice/clear"),d),m,!0)},x=async()=>{await (0,$.u)(r.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await o("clearErrors",async()=>(await i.k.delete("/api/error-items/clear"),d),m,!0)},h=async()=>{if(!await (0,$.u)(r.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let e=prompt(r.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==e){null!==e&&$.c.error(r.common?.error||"Confirmation failed");return}await o("systemReset",async()=>(await i.k.post("/api/admin/system-reset",{}),r.settings?.clearSuccess||"Success - System Reset Complete"),r.settings?.clearError||"Failed to reset system",!0)};return(0,t.jsxs)(t.Fragment,{children:[e&&(0,t.jsx)(e3,{tone:"info",title:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e2.f,{className:"h-4 w-4"}),r.settings?.migrateTags||"Migrate Tags"]}),description:r.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===n,icon:(0,t.jsx)(e2.f,{className:"h-4 w-4"}),onClick:u}),(0,t.jsx)(e3,{tone:"danger",title:r.settings?.clearData||"Clear Practice Data",description:r.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===n,icon:(0,t.jsx)(ev.f,{className:"h-4 w-4"}),onClick:p}),(0,t.jsx)(e3,{tone:"danger",title:r.settings?.clearErrorData||"Clear Error Data",description:r.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===n,icon:(0,t.jsx)(ev.f,{className:"h-4 w-4"}),onClick:x}),e&&(0,t.jsx)(e3,{tone:"critical",title:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(X.f,{className:"h-4 w-4"}),r.settings?.systemReset||"System Initialization"]}),description:r.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===n,icon:(0,t.jsx)(ev.f,{className:"h-4 w-4"}),onClick:h})]})}let e6={name:"user-x",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]};e6.node;let e8=(0,E.f)(e6);function e9({isAdmin:e}){let{t:n}=(0,a.b)(),c=n.settings.deleteAccount,[o,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(""),[p,x]=(0,s.useState)(!1),h=e=>{!p&&(d(e),e||u(""))},g=async e=>{if(e.preventDefault(),m){x(!0);try{await i.k.delete("/api/user",{body:JSON.stringify({password:m})}),$.c.success(c.success),await (0,r.signOut)({callbackUrl:"/login"})}catch(t){let e=t instanceof i.a&&400===t.status;e||l.V.error("[DeleteAccountSettings]","delete account failed",{error:t}),$.c.error(e?c.wrongPassword:c.failed),x(!1)}}};return(0,t.jsxs)("div",{className:"p-4 border rounded-lg border-red-600/50 bg-red-100/50 dark:bg-red-900/40",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"text-sm flex items-center gap-2 text-red-900 dark:text-red-200 font-bold",children:[(0,t.jsx)(e8,{className:"h-4 w-4"}),c.title]}),(0,t.jsx)(k.f,{variant:"destructive",size:"sm",className:"bg-red-700 hover:bg-red-800",disabled:e,onClick:()=>d(!0),"aria-label":c.title,children:(0,t.jsx)(e8,{className:"h-4 w-4"})})]}),(0,t.jsx)("p",{className:"text-xs mt-2 text-red-800 dark:text-red-200 font-medium",children:e?c.adminDisabled:c.desc}),(0,t.jsx)(S.N,{open:o,onOpenChange:h,children:(0,t.jsx)(S.d,{className:"sm:max-w-md",children:(0,t.jsxs)("form",{onSubmit:g,className:"space-y-4",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:c.confirmTitle}),(0,t.jsx)(S.C,{children:c.confirmDesc})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{htmlFor:"delete-account-password",children:c.passwordLabel}),(0,t.jsx)(eG.f,{id:"delete-account-password",autoComplete:"current-password",value:m,onChange:e=>u(e.target.value),disabled:p})]}),(0,t.jsxs)(S.c,{className:"gap-2",children:[(0,t.jsx)(k.f,{type:"button",variant:"outline",onClick:()=>h(!1),disabled:p,children:c.cancel}),(0,t.jsxs)(k.f,{type:"submit",variant:"destructive",disabled:!m||p,children:[p&&(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}),c.confirm]})]})]})})})]})}let e7={name:"shield-check",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"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]};e7.node;let te=(0,E.f)(e7);function tt(){let{t:e,language:r}=(0,a.b)(),n=e.aiConsent,[c,o]=(0,s.useState)(void 0),[d,m]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!1;return i.k.get("/api/user").then(t=>{e||o(t?.aiDataConsentAt??null)}).catch(e=>l.V.error("[AiConsentSetting]","load consent failed",{error:e})),()=>{e=!0}},[]);let u=async e=>{if(e||await (0,$.u)(n.revokeConfirm,{destructive:!0})){m(!0);try{let t=e?await i.k.post("/api/user/ai-consent",{}):await i.k.delete("/api/user/ai-consent");o(t.aiDataConsentAt),$.c.success(e?n.agreed:n.revoked)}catch(e){l.V.error("[AiConsentSetting]","update consent failed",{error:e}),$.c.error(n.failed)}finally{m(!1)}}};if(void 0===c)return null;let p=null!==c,x=p?new Date(c).toLocaleDateString("en"===r?"en-US":"zh-CN"):"";return(0,t.jsxs)("div",{className:"space-y-2 rounded-lg border p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(te,{className:"h-4 w-4"}),n.settingTitle]}),(0,t.jsxs)(k.f,{type:"button",size:"sm",variant:p?"outline":"default",onClick:()=>u(!p),disabled:d,children:[d&&(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}),p?n.revoke:n.grant]})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[p?n.settingGranted.replace("{date}",x):n.settingNotGranted," ",(0,t.jsx)("a",{className:"underline underline-offset-2",href:(0,C.L)(r),target:"_blank",rel:"noopener noreferrer",children:n.policyLink})]})]})}var ts=e.i(551757),ta=e.i(762368),tr=e.i(132411);async function ti(e,t){let s=await fetch(e);if(!s.ok)throw Error((await s.json().catch(()=>({}))).message||"Download failed");let a=await s.blob(),r=window.URL.createObjectURL(a),i=document.createElement("a");i.href=r;let n=s.headers.get("Content-Disposition")?.match(/filename="(.+)"/);i.download=n?n[1]:t,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(r)}function tn({isAdmin:e,userId:r,userEmail:n}){let{t:c}=(0,a.b)(),[o,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(!1),[p,x]=(0,s.useState)(null),h=`user:${r}:data-import`,{running:g,refresh:f}=(0,tr.f)(h),j=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(g){j.current=!0;return}j.current&&(j.current=!1,window.location.reload())},[g]);let b=async e=>{if(!e||await (0,$.u)(c.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){d(!0);try{await ti(e?"/api/export?all=true":"/api/export",e?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),$.c.success(c.settings?.exportSuccess||"Export successful")}catch(t){l.V.error("[DataBackupSettings]",e?"Export all failed":"Export failed",{error:t}),$.c.error(c.settings?.exportFailed||"Export failed")}finally{d(!1)}}},y=async e=>{let t;if(!p)return;try{t=JSON.parse(await p.text())}catch(e){l.V.error("[DataBackupSettings]","Import file is not valid JSON",{error:e}),$.c.error(c.settings?.importFailed||"Import failed");return}let s="object"==typeof t&&null!==t&&"user"in t?t.user:void 0,a="object"==typeof s&&null!==s&&"email"in s&&"string"==typeof s.email?s.email:null,r=!e&&!!a&&!!n&&a!==n,o=e?c.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":r?(c.settings?.importOtherAccountConfirm||"This backup belongs to {email}. Importing merges it into the current account without restoring that account's preferences. Continue?").replace("{email}",a??""):c.settings?.importConfirm||"Are you sure you want to import?";if(await (0,$.u)(o)){u(!0);try{let{stats:s}=await i.k.post(e?"/api/import?all=true":r?"/api/import?merge=true":"/api/import",t);$.c.success((c.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(s.subjectsCreated)).replace("{tags}",String(s.tagsCreated)).replace("{items}",String(s.errorItemsCreated)).replace("{schedules}",String(s.reviewSchedulesCreated)).replace("{records}",String(s.practiceRecordsCreated)).replace("{papers}",String(s.examPapersCreated??0)).replace("{voices}",String(s.ttsSpeechesImported??0)).replace("{duplicates}",String(s.duplicateErrorItems??0))),x(null),window.location.reload()}catch(t){t instanceof i.a&&409===t.status&&t.data?.code==="TASK_ALREADY_RUNNING"?($.c.info(c.errors.TASK_ALREADY_RUNNING),await f()):(l.V.error("[DataBackupSettings]",e?"Import all failed":r?"Merge import failed":"Import failed",{error:t}),$.c.error(c.settings?.importFailed||"Import failed"))}finally{u(!1)}}},v=(e,s)=>e?(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}):s,w=m||!!g;return(0,t.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,t.jsx)("h4",{className:"text-sm font-bold text-blue-900 dark:text-blue-200 mb-3",children:c.settings?.dataManagement||"Data Management"}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:c.settings?.exportData||"Export Data"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>b(!1),disabled:o,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:[v(o,(0,t.jsx)(ta.f,{className:"mr-2 h-4 w-4"})),c.settings?.exportData||"Export"]}),e&&(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>b(!0),disabled:o,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:[v(o,(0,t.jsx)(ta.f,{className:"mr-2 h-4 w-4"})),c.settings?.exportAllData||"Export All"]})]})]}),(0,t.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:c.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:c.settings?.importData||"Import Data"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"file",accept:".json",onChange:e=>x(e.target.files?.[0]??p),className:"hidden",id:"import-file-input",disabled:w}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:w,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:[v(w,(0,t.jsx)(eK.f,{className:"mr-2 h-4 w-4"})),p?.name||c.settings?.selectFile||"Select File"]}),p&&(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>y(!1),disabled:w,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:[v(w,(0,t.jsx)(ts.f,{className:"mr-2 h-4 w-4"})),c.settings?.importData||"Import"]}),p&&e&&(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>y(!0),disabled:w,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:[v(w,(0,t.jsx)(ts.f,{className:"mr-2 h-4 w-4"})),c.settings?.importAllData||"Import All"]})]})]}),(0,t.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:c.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}let tl={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"}]]};tl.node;let tc=(0,E.f)(tl),to="/api/admin/debug-logs";function td(){let{t:e}=(0,a.b)(),{timeZone:r}=(0,v.M)(),n=e.admin.debugLog,[c,o]=(0,s.useState)(null),[d,m]=(0,s.useState)(!1),u=(0,s.useCallback)(async()=>{try{o(await i.k.get(to))}catch(e){l.V.warn("[DebugLogSettings]","Failed to load debug status",{error:e})}},[]);(0,s.useEffect)(()=>{u()},[u]),(0,s.useEffect)(()=>{if(!c?.enabled)return;let e=setInterval(u,5e3);return()=>clearInterval(e)},[c?.enabled,u]);let p=async(e,t)=>{m(!0);try{await e(),$.c.success(t)}catch(e){l.V.error("[DebugLogSettings]","Debug log action failed",{error:e}),$.c.error(n.failed)}finally{m(!1)}},x=e=>e?(0,ed.r)(e,"yyyy-MM-dd HH:mm",r):"",h=c?.enabled?n.enabledHint.replace("{since}",x(c.enabledAt)).replace("{until}",x(c.expiresAt)):n.disabledHint,g=(c?.entryCount??0)>0;return(0,t.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)(ex.f,{htmlFor:"debug-mode-switch",className:"flex items-center gap-2 font-medium",children:[(0,t.jsx)(tc,{className:"h-4 w-4"}),n.title]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.desc})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:n.enable}),(0,t.jsx)(eu.f,{id:"debug-mode-switch",checked:!!c?.enabled,onCheckedChange:e=>p(async()=>{o(await i.k.post(to,{enabled:e}))},e?n.enabled:n.disabled),disabled:d||!c})]})]}),(0,t.jsxs)("p",{className:`text-xs ${c?.enabled?"text-orange-600":"text-muted-foreground"}`,children:[h,c&&(0,t.jsxs)(t.Fragment,{children:[" ",n.entries.replace("{count}",String(c.entryCount)),c.droppedCount>0&&n.dropped.replace("{count}",String(c.droppedCount))]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>p(async()=>{await ti(`${to}/export`,"wrong-notebook-debug.json"),await u()},n.exported),disabled:d||!g,className:"sm:flex-1",children:[d?(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(ta.f,{className:"mr-2 h-4 w-4"}),n.export]}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:()=>p(async()=>{o(await i.k.delete(to))},n.cleared),disabled:d||!g,children:[(0,t.jsx)(ev.f,{className:"mr-2 h-4 w-4"}),n.clear]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.privacyNote})]})}var tm=e.i(307364);function tu({field:e,label:r,description:n}){let{t:c}=(0,a.b)(),[o,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(!1),[p,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null),f=`preference-${e}`;(0,s.useEffect)(()=>{i.k.get("/api/user").then(t=>d(!!t[e])).catch(()=>void 0).finally(()=>u(!0))},[e]);let j=async t=>{d(t),x(!0);try{await i.k.patch("/api/user",{[e]:t}),g(c.importFlow.preferenceSaved)}catch(s){d(!t),g(c.importFlow.preferenceSaveFailed),l.V.error("[Settings]","Failed to save user preference",{field:e,error:s instanceof Error?s.message:String(s)})}finally{x(!1)}};return(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsx)(ex.f,{htmlFor:f,children:r}),(0,t.jsx)(eu.f,{id:f,checked:o,onCheckedChange:j,disabled:!m||p})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n}),h&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:h})]})}function tp(){let{t:e}=(0,a.b)();return(0,t.jsx)(tu,{field:"enableGeogebra",label:e.importFlow.enableGeogebra,description:e.importFlow.enableGeogebraDesc})}function tx(){let{t:e}=(0,a.b)();return(0,t.jsx)(tu,{field:"confirmBeforeImport",label:e.importFlow.confirmBeforeImport,description:e.importFlow.confirmBeforeImportDesc})}var th=e.i(905110);function tg(){let{t:e}=(0,a.b)(),[r,n]=(0,s.useState)(String(th.z)),[c,o]=(0,s.useState)(null),[d,m]=(0,s.useState)(!0),[u,p]=(0,s.useState)(!1),[x,h]=(0,s.useState)(null),g=Number(r),f=""!==r.trim()&&Number.isInteger(g)&&g>=th.P&&g<=th.o,j=(0,s.useCallback)(async()=>{m(!0),h(null);try{let e=(await i.k.get("/api/user")).masteryThreshold??th.z;n(String(e)),o(e)}catch(t){h(e.mastery.thresholdLoadFailed),l.V.error("[Settings]","加载已掌握阈值失败",{error:t instanceof Error?t.message:String(t)})}finally{m(!1)}},[e.mastery.thresholdLoadFailed]);(0,s.useEffect)(()=>{j()},[j]);let b=async()=>{if(f&&null!==c){p(!0),h(null);try{let t=(await i.k.patch("/api/user",{masteryThreshold:g})).masteryThreshold??g;o(t),n(String(t)),h(e.importFlow.preferenceSaved)}catch(t){h(e.importFlow.preferenceSaveFailed),l.V.error("[Settings]","保存已掌握阈值失败",{error:t instanceof Error?t.message:String(t)})}finally{p(!1)}}};return(0,t.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,t.jsx)(ex.f,{htmlFor:"mastery-threshold",children:e.mastery.thresholdLabel}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(ep.f,{id:"mastery-threshold",type:"number",min:th.P,max:th.o,step:1,value:r,onChange:e=>{n(e.target.value),h(null)},disabled:d||u||null===c,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,t.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,t.jsxs)(k.f,{type:"button",size:"sm",variant:"outline",onClick:b,disabled:d||u||null===c||!f||g===c,children:[(d||u)&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.importFlow.saveThreshold]}),!d&&null===c&&(0,t.jsx)(k.f,{type:"button",size:"sm",variant:"outline",onClick:j,children:e.importFlow.retryLoad})]}),(0,t.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:e.mastery.thresholdDescription}),null!==c&&!f&&(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:e.mastery.thresholdInvalid}),x&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:x})]})}var tf=e.i(28342);function tj(){let{t:e}=(0,a.b)(),[r,c]=(0,s.useState)({gradeRecognitionMode:"fixed",fixedGradeSemester:null}),[o,d]=(0,s.useState)(null),[m,u]=(0,s.useState)(!0),[p,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null),f=(0,s.useRef)(0),j=(0,s.useCallback)(async()=>{let t=++f.current;u(!0),g(null);try{let e=await i.k.get("/api/user");if(t!==f.current)return;let s={gradeRecognitionMode:e.gradeRecognitionMode??"fixed",fixedGradeSemester:e.fixedGradeSemester??null};c(s),d(s)}catch(s){if(t!==f.current)return;g(e.questionGrade.loadFailed),l.V.error("[QuestionGradeSetting]","加载录入年级规则失败",{error:(0,n.Z)(s)})}finally{t===f.current&&u(!1)}},[e.questionGrade.loadFailed]);(0,s.useEffect)(()=>{j()},[j]);let b=async()=>{x(!0),g(null);try{let t=await i.k.patch("/api/user",r),s={gradeRecognitionMode:t.gradeRecognitionMode??r.gradeRecognitionMode,fixedGradeSemester:t.fixedGradeSemester??null};c(s),d(s),g(e.importFlow.preferenceSaved)}catch(t){g(e.importFlow.preferenceSaveFailed),l.V.error("[QuestionGradeSetting]","保存录入年级规则失败",{error:(0,n.Z)(t)})}finally{x(!1)}},y=m||p||null===o,v=o?.gradeRecognitionMode===r.gradeRecognitionMode&&o?.fixedGradeSemester===r.fixedGradeSemester;return(0,t.jsxs)("div",{className:"space-y-3 border-t pt-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{htmlFor:"question-grade-mode",children:e.questionGrade.label}),(0,t.jsxs)("select",{id:"question-grade-mode",value:r.gradeRecognitionMode,disabled:y,onChange:e=>{c({...r,gradeRecognitionMode:e.target.value}),g(null)},className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm disabled:opacity-50",children:[(0,t.jsx)("option",{value:"fixed",children:e.questionGrade.fixed}),(0,t.jsx)("option",{value:"ai",children:e.questionGrade.ai})]})]}),"fixed"===r.gradeRecognitionMode&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{htmlFor:"question-fixed-grade",children:e.editor.gradeSemester}),(0,t.jsx)(tf.f,{id:"question-fixed-grade",value:r.fixedGradeSemester??"",disabled:y,onChange:e=>{c({...r,fixedGradeSemester:e||null}),g(null)}})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"fixed"===r.gradeRecognitionMode?e.questionGrade.fixedDescription:e.questionGrade.aiDescription}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.questionGrade.description}),(0,t.jsxs)(k.f,{type:"button",variant:"outline",size:"sm",disabled:y||v,onClick:b,children:[(m||p)&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.questionGrade.save]}),!m&&null===o&&(0,t.jsx)(k.f,{type:"button",variant:"outline",size:"sm",onClick:j,children:e.importFlow.retryLoad}),h&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:h})]})}function tb(){let{t:e}=(0,a.b)();return(0,t.jsx)(tu,{field:"enableSvgAnimation",label:e.importFlow.enableSvgAnimation,description:e.importFlow.enableSvgAnimationDesc})}function ty({value:e,onChange:s,disabled:r}){let{t:i}=(0,a.b)();return(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsx)(ex.f,{htmlFor:"app-time-zone",children:i.settings.general.timeZoneLabel}),(0,t.jsx)(ep.f,{id:"app-time-zone",value:e,onChange:e=>s(e.target.value),disabled:r,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,t.jsx)("datalist",{id:"app-time-zones",children:["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Europe/London","America/New_York","America/Los_Angeles","UTC"].map(e=>(0,t.jsx)("option",{value:e},e))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:i.settings.general.timeZoneDesc})]})}function tv({config:e,setConfig:s,isAdmin:r,disabled:i}){let{t:n,language:l,setLanguage:c}=(0,a.b)(),{timeZone:o}=(0,v.M)(),d=e=>s(t=>({...t,timeouts:{...t.timeouts,analyze:1e3*e}}));return(0,t.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:n.settings?.language||"Language"}),(0,t.jsxs)(eO.d,{value:l,onValueChange:e=>c(e),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{})}),(0,t.jsxs)(eO.r,{children:[(0,t.jsx)(eO.T,{value:"zh",children:"中文 (Chinese)"}),(0,t.jsx)(eO.T,{value:"en",children:"English"})]})]})]}),(0,t.jsx)(ty,{value:e.timeZone??o,onChange:e=>s(t=>({...t,timeZone:e})),disabled:!r||i}),r&&(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsx)(ex.f,{children:n.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,t.jsx)(ep.f,{type:"number",value:e.timeouts?.analyze?e.timeouts.analyze/1e3:"",onChange:e=>{let t=""===e.target.value?0:parseInt(e.target.value);d(isNaN(t)?0:t)},onBlur:()=>{let t=(e.timeouts?.analyze||0)/1e3,s=Math.min(600,Math.max(120,t));s!==t&&d(s)},min:120,max:600}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,t.jsx)(tx,{}),(0,t.jsx)(tj,{}),(0,t.jsx)(tb,{}),(0,t.jsx)(tp,{}),(0,t.jsx)(tm.f,{}),(0,t.jsx)(tg,{})]})}var tw=e.i(77071),tN=e.i(515288),tk=e.i(470279);function tS(){let{t:e}=(0,a.b)(),{groups:r,loading:n,refetch:c}=(0,tk.f)(),[o,d]=(0,s.useState)(""),[m,u]=(0,s.useState)(!1),p=async()=>{let t=o.trim();if(t){u(!0);try{await i.k.post("/api/paper-groups",{name:t}),d(""),$.c.success(e.common?.messages?.saveSuccess||"Saved"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to add group",{error:t}),$.c.error(e.common?.messages?.saveFailed||"Failed to save")}finally{u(!1)}}},x=async(t,s)=>{let a=window.prompt(e.settings?.paperGroups?.renamePrompt||"Rename group",s);if(a&&a.trim()!==s)try{await i.k.patch(`/api/paper-groups/${t}`,{name:a.trim()}),$.c.success(e.common?.messages?.saveSuccess||"Saved"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to rename group",{error:t}),$.c.error(e.common?.messages?.saveFailed||"Failed to save")}},h=async(t,s)=>{try{await i.k.patch(`/api/paper-groups/${t}`,{isActive:!s}),$.c.success(e.common?.messages?.saveSuccess||"Saved"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to toggle group",{error:t}),$.c.error(e.common?.messages?.saveFailed||"Failed to save")}},g=async(t,s,a)=>{if(a>0){let r=(e.settings?.paperGroups?.deleteConfirmWithItems||'Group "{name}" has {count} questions. Deleting will clear their group assignment. Continue?').replace("{name}",s).replace("{count}",String(a));if(!await (0,$.u)(r,{destructive:!0}))return;try{await i.k.delete(`/api/paper-groups/${t}?clear=true`),$.c.success(e.common?.messages?.deleteSuccess||"Deleted"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to delete group",{error:t}),$.c.error(e.common?.messages?.deleteFailed||"Delete failed")}return}let r=(e.settings?.paperGroups?.deleteConfirm||'Delete group "{name}"?').replace("{name}",s);if(await (0,$.u)(r,{destructive:!0}))try{await i.k.delete(`/api/paper-groups/${t}`),$.c.success(e.common?.messages?.deleteSuccess||"Deleted"),c()}catch(t){l.V.error("[PaperGroupSettings]","Failed to delete group",{error:t}),$.c.error(e.common?.messages?.deleteFailed||"Delete failed")}};return n?(0,t.jsx)(tN.N,{children:(0,t.jsx)(tN.O,{className:"py-12 flex items-center justify-center",children:(0,t.jsx)(N.f,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):(0,t.jsxs)(tN.N,{children:[(0,t.jsxs)(tN.Y,{children:[(0,t.jsxs)(tN.v,{className:"flex items-center gap-2 text-lg",children:[(0,t.jsx)(z.f,{className:"h-5 w-5"}),e.settings?.paperGroups?.title||"Paper Groups"]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e.settings?.paperGroups?.desc||"Customize paper groups like Unit Test, Midterm, Final. Default groups A/B/Other can be renamed but not deleted."})]}),(0,t.jsxs)(tN.O,{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(ep.f,{value:o,onChange:e=>d(e.target.value),placeholder:e.settings?.paperGroups?.addPlaceholder||"e.g. Unit Test",onKeyDown:e=>{"Enter"===e.key&&p()}}),(0,t.jsxs)(k.f,{onClick:p,disabled:m||!o.trim(),children:[m?(0,t.jsx)(N.f,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(tw.f,{className:"h-4 w-4 mr-1"}),e.common?.add||"Add"]})]}),(0,t.jsx)("div",{className:"space-y-2",children:r.map(s=>(0,t.jsxs)("div",{className:`flex items-center justify-between rounded-lg border p-3 ${!s.isActive?"opacity-50":""}`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"font-medium",children:s.name}),s.key&&(0,t.jsx)(em.f,{variant:"secondary",className:"text-xs",children:e.settings?.paperGroups?.systemBadge||"Default"}),!s.isActive&&(0,t.jsx)(em.f,{variant:"outline",className:"text-xs",children:e.common?.inactive||"Inactive"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>x(s.id,s.name),children:e.common?.rename||"Rename"}),(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:()=>h(s.id,s.isActive),children:s.isActive?e.common?.deactivate||"Deactivate":e.common?.activate||"Activate"}),!s.key&&(0,t.jsx)(k.f,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>g(s.id,s.name,s._count?.errorItems||0),children:(0,t.jsx)(ev.f,{className:"h-4 w-4"})})]})]},s.id))})]})]})}var tC=e.i(515745),tT=e.i(508734),t_=e.i(395925),tA=e.i(328623),tz=e.i(624687);async function tE(e,t){try{return await navigator.clipboard.writeText(e),!0}catch{return t(e),!1}}async function tD(){try{return await navigator.clipboard.readText()}catch{return null}}function tF({value:e,defaultValue:r,onChange:i,onReset:n,title:l,variables:c}){let{t:o}=(0,a.b)(),[d,m]=(0,s.useState)(!1),u=(0,s.useMemo)(()=>{let t=new Set(Array.from(new Set(Array.from(e.matchAll(/\{\{(\w+)\}\}/g),e=>e[1]))));return c.filter(e=>!t.has(e.name))},[e,c]),p=async()=>{await tE(e,e=>window.prompt(o.settings?.prompts?.copyManual||"Copy the template manually:",e))&&(m(!0),setTimeout(()=>m(!1),1500),$.c.success(o.settings?.prompts?.copied||"Template copied"))},x=async()=>{let t=await tD();null===t?$.c.error(o.settings?.prompts?.pasteFailed||"Cannot read the clipboard. Paste into the box manually."):t.trim()?(!e.trim()||await (0,$.u)(o.settings?.prompts?.pasteConfirm||"Replace the current template with the clipboard content?",{destructive:!0}))&&(i(t),$.c.success(o.settings?.prompts?.pasted||"Template replaced from the clipboard")):$.c.error(o.settings?.prompts?.pasteEmpty||"The clipboard is empty")},h=async()=>{await (0,$.u)(o.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&n()};return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)(ex.f,{className:"text-base font-semibold",children:l}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:p,children:[(0,t.jsx)(tT.f,{className:"w-4 h-4 mr-2"}),d?o.settings?.prompts?.copied||"Copied":o.settings?.prompts?.copy||"Copy"]}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:x,children:[(0,t.jsx)(tC.f,{className:"w-4 h-4 mr-2"}),o.settings?.prompts?.pasteReplace||"Replace with clipboard"]}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:h,children:[(0,t.jsx)(t_.f,{className:"w-4 h-4 mr-2"}),o.settings?.prompts?.reset||"Reset Default"]})]})]}),(0,t.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",children:[(0,t.jsx)(tA.f,{className:"w-4 h-4 mt-0.5 shrink-0"}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"font-medium",children:o.settings?.prompts?.customizeTitle||"Tailor the prompt to your child"}),(0,t.jsx)("p",{children:o.settings?.prompts?.customizeBody||"Copy the default template, rewrite the role, tone and analysis steps to fit your child's grade, weak points and learning habits, then paste it back. Keep the {{variables}}: they are filled with each question's data."})]})]}),(0,t.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,t.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,t.jsx)(et,{className:"h-3.5 w-3.5"}),o.settings?.prompts?.variables||"Available Variables"]}),(0,t.jsx)("div",{className:"space-y-1.5",children:c.map(e=>(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,t.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] shrink-0",children:`{{${e.name}}}`}),(0,t.jsx)("span",{className:"text-muted-foreground",children:e.description})]},e.name))}),u.length>0&&(0,t.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 pt-1",children:(o.settings?.prompts?.missingVariables||"Not referenced in this template: {names}. The app still adds the matching rules, but the data will not reach the model.").replace("{names}",u.map(e=>`{{${e.name}}}`).join("、"))})]}),(0,t.jsx)(tz.f,{value:e,onChange:e=>i(e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:r,"aria-label":l})]})}var tM=e.i(247167);let tL="[REDACTED]",tR=/api[-_]?key|password|passwd|secret|authorization|cookie|credential|private[-_]?key|^(access|refresh|id|auth|api|bearer|session|csrf|setup)?[-_]?token$/i,t$=Symbol.for("wrong-notebook.debug-log");function tI(){let e=globalThis,t=e[t$];return t||(t={enabledAt:null,entries:[],totalSize:0,dropped:0},e[t$]=t),t}function tV(e){let t=e.replace(/data:([\w.+-]+\/[\w.+-]+);base64,[A-Za-z0-9+/=]+/g,(e,t)=>`[data:${t}, ${e.length} chars]`).replace(/(Bearer\s+)[\w\-.~+/]+=*/gi,`$1${tL}`).replace(/\bsk-[A-Za-z0-9_-]{8,}/g,tL).replace(/([?&](?:key|api_key|apikey|token|access_token)=)[^&\s"']+/gi,`$1${tL}`);return t.length>1e4&&(t=`${t.slice(0,1e4)}…[truncated ${t.length-1e4} chars]`),t}function tG(e,t,s,a=new Date){if(function(e=Date.now()){let t=tI();return null!==t.enabledAt&&(!(e-t.enabledAt>=864e5)||(t.enabledAt=null,!1))}(a.getTime()))try{let r={...function e(t,s=0,a=new WeakSet){if(null==t)return t;if("string"==typeof t)return tV(t);if("number"==typeof t||"boolean"==typeof t)return t;if("bigint"==typeof t)return t.toString();if("function"==typeof t||"symbol"==typeof t)return String(t);if(t instanceof Date)return t.toISOString();if(t instanceof Error){let r={name:t.name,message:tV(t.message)};return t.stack&&(r.stack=tV(t.stack)),void 0!==t.code&&(r.code=e(t.code,s+1,a)),void 0!==t.status&&(r.status=e(t.status,s+1,a)),void 0!==t.cause&&s<8&&(r.cause=e(t.cause,s+1,a)),r}if("object"!=typeof t)return String(t);if(a.has(t))return"[Circular]";if(s>=8)return"[Object]";if(a.add(t),Array.isArray(t)){let r=t.slice(0,100).map(t=>e(t,s+1,a));return t.length>100&&r.push(`…[${t.length-100} more items]`),r}return ArrayBuffer.isView(t)||t instanceof ArrayBuffer?`[Binary ${t.byteLength} bytes]`:Object.fromEntries(Object.entries(t).map(([t,r])=>[t,tR.test(t)&&null!=r&&""!==r?tL:e(r,s+1,a)]))}(t),time:a.toISOString(),level:e,msg:tV(s)},i=JSON.stringify(r).length,n=tI();for(n.entries.push({entry:r,size:i}),n.totalSize+=i;n.entries.length>5e3||n.totalSize>0x1400000&&n.entries.length>1;){let e=n.entries.shift();if(!e)break;n.totalSize-=e.size,n.dropped+=1}}catch{}}let tO={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function tP(e,t={}){let s,a=tO[e],r=(s=tM.default.env.LOG_LEVEL?.toLowerCase())&&void 0!==tO[s]?tO[s]:tO.info;return(s,i)=>{let n,l,c=new Date;if("string"==typeof s?(n={},l=s):(n=s,l=i||""),tG(e,{...t,...n},l,c),!(a<r)){let s=JSON.stringify({level:e,time:c.toISOString(),...t,...n,msg:l});switch(e){case"error":case"fatal":console.error(s);break;case"warn":console.warn(s);break;default:console.log(s)}}}}(function e(t={}){return t.module,{trace:tP("trace",t),debug:tP("debug",t),info:tP("info",t),warn:tP("warn",t),error:tP("error",t),fatal:tP("fatal",t),child:s=>e({...t,...s}),box:(e,s,a="📋")=>{tG("info",{...t,..."string"==typeof s?{content:s}:s},e);{let a="string"==typeof s?{content:s}:s||{};console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...t,title:e,...a,msg:e}));return}},divider:(e="-")=>{}}})({env:"production"}).child({module:"ai:prompts"});let tU=`填写题目类型,只能是以下 key 之一:single_choice(单选题)、multiple_choice(多选题)、true_false(判断题)、fill_blank(填空题)、calculation(计算题)、solution(解答题)、reading(阅读理解)、cloze(完形填空)、writing(写作)、other(其他)。
2
2
  若题型不明确,填 other。`,tq=`请参考《高思学校竞赛数学导引》(每讲分兴趣篇、拓展篇、超越篇,题目左侧标 1~5 颗星)的星级标准,结合题目所在年级评定难度:
3
3
  - 1 星:课本基础题,直接套用概念、公式或简单计算即可(相当于兴趣篇前几题)。
4
4
  - 2 星:校内拔高题,需要两三步推理或简单综合(相当于兴趣篇后几题)。
@@ -195,7 +195,7 @@ ${tK}
195
195
  ${tK}
196
196
 
197
197
  {{grade_instruction}}
198
- {{provider_hints}}`,tW=`【角色与核心任务 (ROLE AND CORE TASK)】
198
+ {{provider_hints}}`,tJ=`【角色与核心任务 (ROLE AND CORE TASK)】
199
199
  你是一位经验丰富的专业教师。用户已经提供了一道**校正后的题目文本**,请你为这道题目提供正确的答案和详细的解析。
200
200
 
201
201
  {{language_instruction}}
@@ -261,4 +261,4 @@ ${tU}
261
261
  ${tK}
262
262
 
263
263
  {{grade_instruction}}
264
- {{provider_hints}}`;var tJ=e.i(113381);function tX({config:e,onUpdate:s}){let{t:r}=(0,a.b)(),i=e.prompts?.analyze||tB,n=e.prompts?.similar||tY,l=e.prompts?.reanswer||tW,c=r.settings?.prompts?.vars,d=[{name:"language_instruction",description:c?.languageInstruction||"Language instructions."},{name:"knowledge_points_list",description:c?.knowledgePointsList||"Knowledge point tags for the subject."},{name:"grade_instruction",description:c?.gradeInstruction||"Grade and semester guidance."},{name:"provider_hints",description:c?.providerHints||"Provider compatibility hints."}],o=[{name:"original_question",description:c?.originalQuestion||"The full text of the original question."},{name:"knowledge_points",description:c?.knowledgePoints||"List of knowledge points to test."},{name:"difficulty_level",description:c?.difficultyLevel||"Target difficulty level."},{name:"difficulty_instruction",description:c?.difficultyInstruction||"Specific writing instructions for the target difficulty."},{name:"language_instruction",description:c?.languageInstructionShort||"Language formatting instructions."},{name:"figure_instruction",description:c?.figureInstruction||"Instructions for redrawing the original figure."},{name:"grade_instruction",description:c?.gradeInstruction||"Grade and semester guidance."}],m=[{name:"question_text",description:c?.questionText||"The corrected question text."},{name:"subject_hint",description:c?.subjectHint||"Subject of the question."},{name:"knowledge_points_rule",description:c?.knowledgePointsRule||"Candidate knowledge points to choose from."},{name:"language_instruction",description:c?.languageInstruction||"Language instructions."},{name:"grade_instruction",description:c?.gradeInstruction||"Grade and semester guidance."},{name:"provider_hints",description:c?.providerHints||"Provider compatibility hints."}];return(0,t.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,t.jsxs)(ed.i,{defaultValue:"analyze",className:"w-full",children:[(0,t.jsxs)(ed.U,{className:"grid w-full grid-cols-3",children:[(0,t.jsx)(ed.k,{value:"analyze",className:"text-xs sm:text-sm",children:r.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,t.jsx)(ed.k,{value:"reanswer",className:"text-xs sm:text-sm",children:r.settings?.prompts?.reanswerTab||"Solving Prompt"}),(0,t.jsx)(ed.k,{value:"similar",className:"text-xs sm:text-sm",children:r.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,t.jsx)(ed.S,{value:"analyze",className:"py-4",children:(0,t.jsx)(tF,{value:i,defaultValue:tB,onChange:e=>s("analyze",e),onReset:()=>s("analyze",tB),title:r.settings?.prompts?.customAnalysis||"Custom Analysis Template",variables:d})}),(0,t.jsx)(ed.S,{value:"reanswer",className:"py-4",children:(0,t.jsx)(tF,{value:l,defaultValue:tW,onChange:e=>s("reanswer",e),onReset:()=>s("reanswer",tW),title:r.settings?.prompts?.customReanswer||"Custom Solving Template",variables:m})}),(0,t.jsx)(ed.S,{value:"similar",className:"py-4",children:(0,t.jsx)(tF,{value:n,defaultValue:tY,onChange:e=>s("similar",e),onReset:()=>s("similar",tY),title:r.settings?.prompts?.customSimilar||"Custom Similar Question Template",variables:o})})]})})}tJ.I.join("、"),tJ.r.join("、");var tZ=e.i(999593);function tQ({open:e,onOpenChange:r,onConfirm:i}){let{t:n}=(0,a.b)(),[l,c]=(0,s.useState)(!1),[d,o]=(0,s.useState)(!1),m=async()=>{o(!0);try{await i(),c(!1),r(!1)}catch{}finally{o(!1)}};return(0,t.jsx)(S.N,{open:e,onOpenChange:e=>!d&&r(e),children:(0,t.jsxs)(S.d,{className:"w-[calc(100vw-2rem)] sm:max-w-lg",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:n.eula.dialogTitle}),(0,t.jsx)(S.C,{children:n.eula.dialogDesc})]}),(0,t.jsx)(tZ.f,{checked:l,onCheckedChange:c,disabled:d}),(0,t.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,t.jsx)(k.f,{variant:"outline",onClick:()=>r(!1),disabled:d,children:n.eula.cancel}),(0,t.jsxs)(k.f,{onClick:m,disabled:!l||d,children:[d&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.eula.accept]})]})]})})}function t0({endpoint:e,retentionDays:r,disabled:i,onSave:n}){let{t:l}=(0,a.b)(),c=l.telemetrySettings,[d,o]=(0,s.useState)(""!==e),[m,u]=(0,s.useState)(e),[p,x]=(0,s.useState)(String(r)),h=Number(p),g=Number.isInteger(h)&&h>=1&&h<=365;return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(ex.f,{htmlFor:"telemetry-endpoint",children:c.endpoint}),d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ep.f,{id:"telemetry-endpoint",value:m,placeholder:c.endpointPlaceholder,disabled:i,onChange:e=>u(e.target.value)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.endpointHint})]}):(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:c.endpointDefault}),(0,t.jsx)(k.f,{variant:"link",size:"sm",className:"h-auto p-0",disabled:i,onClick:()=>o(!0),children:c.endpointCustomize})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(ex.f,{htmlFor:"telemetry-retention",children:c.retentionDays}),(0,t.jsx)(ep.f,{id:"telemetry-retention",type:"number",min:1,max:365,className:"w-32",value:p,disabled:i,onChange:e=>x(e.target.value)})]}),(0,t.jsx)(k.f,{size:"sm",variant:"outline",disabled:i||!g,onClick:()=>n({endpoint:m.trim(),retentionDays:h}),children:c.save})]})}function t1({events:e,errors:s,disabled:r,onClear:i}){let{t:n}=(0,a.b)(),{timeZone:l}=(0,v.M)(),c=n.telemetrySettings,d=e=>(0,eo.r)(e,"MM-dd HH:mm",l),o=e=>e?c.forwarded:c.notForwarded,m=0===e.length&&0===s.length;return(0,t.jsxs)("details",{className:"rounded-md border p-3 text-sm",children:[(0,t.jsx)("summary",{className:"cursor-pointer font-medium",children:c.recentTitle}),(0,t.jsxs)("div",{className:"mt-3 space-y-3",children:[m&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.recentEmpty}),e.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:c.recentEvents}),(0,t.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:e.map(e=>(0,t.jsxs)("li",{className:"break-all",children:[d(e.createdAt)," ",e.name," ",e.payload??""," · ",o(e.forwardedAt)]},e.id))})]}),s.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:c.recentErrors}),(0,t.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:s.map(e=>(0,t.jsxs)("li",{className:"break-all",children:[d(e.createdAt)," ",e.kind," ",e.scope," ",e.name," #",e.fingerprint,e.path?` ${e.path}`:"",e.message?` — ${e.message}`:""," · ",o(e.forwardedAt)]},e.id))})]}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:i,disabled:r||m,children:[(0,t.jsx)(ev.f,{className:"mr-2 h-4 w-4"}),c.clear]})]})]})}function t2({id:e,label:s,description:a,checked:r,disabled:i,onCheckedChange:n}){return(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(ex.f,{htmlFor:e,className:"font-medium",children:s}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:a})]}),(0,t.jsx)(eu.f,{id:e,checked:r,disabled:i,onCheckedChange:n,className:"shrink-0"})]})}let t4="/api/admin/telemetry";async function t3(e){return await i.k.post("/api/admin/eula/accept",{version:e}),i.k.post(t4,{forwarding:!0})}function t5(e){return i.k.post(t4,e)}var t6=e.i(983761);function t8(){let{t:e}=(0,a.b)(),{timeZone:r}=(0,v.M)(),c=e.telemetrySettings,{data:d,update:o,enableWithConsent:m,clear:u}=function(){let[e,t]=(0,s.useState)(null),a=(0,s.useCallback)(async()=>{try{t(await i.k.get(t4))}catch(e){l.V.warn("[TelemetrySettings]","Failed to load telemetry status",{error:e})}},[]);return(0,s.useEffect)(()=>{a()},[a]),{data:e,update:async e=>t(await t5(e)),enableWithConsent:async e=>t(await t3(e)),clear:async()=>t(await i.k.delete(t4))}}(),[p,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),f=async(e,t)=>{x(!0);try{await e(),$.c.success(t)}catch(e){throw l.V.error("[TelemetrySettings]","Telemetry action failed",{error:e}),$.c.error("INVALID_TELEMETRY_ENDPOINT"===(0,n.d)(e)?c.invalidEndpoint:c.failed),e}finally{x(!1)}},j=e=>f(async()=>{await o(e),(0,t6.z)("settings_changed",{section:"telemetry"})},c.saved).catch(()=>void 0);if(!d)return null;let b=d.lockedByEnv,y=p||b,w=e=>(0,eo.r)(e,"yyyy-MM-dd HH:mm",r),N=async()=>{await (0,$.u)(c.clearConfirm)&&f(u,c.cleared).catch(()=>void 0)},k=d.lastFlushAt?c.lastFlush.replace("{time}",w(d.lastFlushAt)):c.neverFlushed;return d.lastAttempt?.status==="failed"&&(k=c.lastAttemptFailed.replace("{status}",String(d.lastAttempt.httpStatus??"network"))),d.lastAttempt?.status==="stopped"&&(k=c.lastAttemptStopped),(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border p-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"flex items-center gap-2 font-medium",children:[(0,t.jsx)(te,{className:"h-4 w-4"}),c.title]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.desc})]}),b&&(0,t.jsx)("p",{className:"text-xs text-orange-600",children:c.lockedByEnv}),d.consentPending&&(0,t.jsx)("p",{className:"text-xs text-orange-600",children:c.consentPending}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[d.eula.acceptedVersion?c.eulaStatus.replace("{version}",d.eula.acceptedVersion).replace("{time}",d.eula.acceptedAt?w(d.eula.acceptedAt):"-"):c.eulaNotAccepted," ",(0,t.jsx)("a",{href:"/eula",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:c.viewEula})]}),(0,t.jsx)(t2,{id:"telemetry-forwarding",label:c.forwarding,description:c.forwardingDesc,checked:d.forwarding,disabled:y,onCheckedChange:e=>{e&&(!d.eula.acceptedVersion||d.consentPending)?g(!0):j({forwarding:e})}}),d.forwarding&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[c.pending.replace("{count}",String(d.pending))," · ",k]}),(0,t.jsx)(t2,{id:"telemetry-recording",label:c.recording,description:c.recordingDesc,checked:d.recording,disabled:y,onCheckedChange:e=>j({recording:e})}),(0,t.jsx)(t2,{id:"telemetry-errors",label:c.errors,description:c.errorsDesc,checked:d.errors,disabled:y,onCheckedChange:e=>j({errors:e})}),(0,t.jsx)(t0,{endpoint:d.endpoint,retentionDays:d.retentionDays,disabled:y,onSave:j}),(0,t.jsx)(t1,{events:d.events,errors:d.errorRecords,disabled:p,onClear:N}),(0,t.jsx)(tQ,{open:h,onOpenChange:g,onConfirm:()=>f(()=>m(d.eula.current),c.enabled)})]})}var t9=e.i(21357),t7=e.i(434901),se=e.i(753817),st=e.i(128093),ss=e.i(79058),sa=e.i(495178);function sr({config:e,setConfig:r,saving:c,onSave:d}){let{t:o,language:m}=(0,a.b)(),u=o.settings.tts,[p,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null),f=e.tts?.mode??"browser",j=(0,sa.y)(f)?f:null,b=j?e.tts?.[j]:void 0,y=(e,t)=>{j&&r(s=>({...s,tts:{...s.tts,[j]:{...s.tts?.[j],[e]:t}}}))},v=!!j&&(0,sa.S)(j),w=j?(0,sa.L)(e,j):void 0,S=v?b?.apiKey:w?.apiKey,C=async()=>{(0,ss.p)(),x(!0),g(null);try{await d();let{id:e,version:t}=await i.k.post("/api/tts",{text:u.previewText,language:m},{timeout:12e4,recoverable:!0}),s=(0,ss.l)();if(!s)return;s.src=`/api/tts/${e}?v=${t}`,s.playbackRate=1,await s.play()}catch(t){l.V.error("[TtsSettings]","Preview failed",{error:t});let e=(0,n.d)(t);$.c.error("TTS_NOT_CONFIGURED"===e?u.notConfigured:"TTS_PROVIDER_ERROR"===e?u.providerError:u.previewFailed),g((0,n.L)(t)??null)}finally{x(!1)}};return(0,t.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:u.title}),(0,t.jsxs)(eO.d,{value:f,onValueChange:e=>r(t=>({...t,tts:{...t.tts,mode:e}})),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{})}),(0,t.jsx)(eO.r,{children:sa.l.map(e=>(0,t.jsx)(eO.T,{value:e,children:u.modes[e]},e))})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:j?u.cloudHint:u.browserHint})]}),j&&(0,t.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[sa.D[j]&&(0,t.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:[u.freeTrial," ",(0,t.jsx)("a",{href:sa.D[j],target:"_blank",rel:"noopener noreferrer",className:"underline",children:u.freeTrialLink})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(t7.f,{label:"openai"===j?"OpenAI API Key":v?u.speechApiKey:`${(0,st.z)(j,m)} API Key`,href:sa.r[j].apiKey,linkText:o.settings.ai.docLinks.apiKey}),(0,t.jsx)(eV.f,{value:S||"",onChange:e=>{var t;return t=e.target.value,void(j&&(v?y("apiKey",t):r(e=>({...e,[j]:{...e[j],apiKey:t}}))))},placeholder:"qwen"===j?"sk-sp-...":v?"":"sk-..."}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u.apiKeyHint[j]})]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(t7.f,{label:u.model,href:sa.r[j].model,linkText:u.docs}),(0,t.jsx)(ep.f,{value:b?.model||"",onChange:e=>y("model",e.target.value),placeholder:sa.C[j].model})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(t7.f,{label:u.voice,href:sa.r[j].voice,linkText:u.voiceList}),(0,t.jsx)(ep.f,{value:b?.voice||"",onChange:e=>y("voice",e.target.value),placeholder:sa.C[j].voice})]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u.voiceHint[j]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(t7.f,{label:u.endpoint,href:sa.r[j].endpoint,linkText:u.docs}),(0,t.jsx)(ep.f,{value:b?.endpoint||"",onChange:e=>y("endpoint",e.target.value),placeholder:(0,sa.E)(j,w)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u.endpointHint})]})]},j),(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[j&&(0,t.jsxs)(k.f,{variant:"outline",onClick:C,disabled:c||p,className:"sm:w-auto",children:[p?(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(t9.f,{className:"mr-2 h-4 w-4"}),u.preview]}),(0,t.jsxs)(k.f,{onClick:()=>void d(),disabled:c||p,className:"flex-1",children:[c&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),u.save]})]}),j&&h&&(0,t.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,t.jsx)(se.f,{detail:h})})]})}var si=e.i(835467);function sn({value:e,icon:s,label:a}){return(0,t.jsxs)(ed.k,{value:e,className:"px-2 sm:px-3",children:[s,(0,t.jsx)("span",{className:"hidden sm:inline",children:a})]})}function sl(){let{setTimeZone:e}=(0,v.M)(),{data:n}=(0,r.useSession)(),c=n?.user?.role==="admin",d=n?.user?.id??"",{t:o}=(0,a.b)(),m=(0,w.useRouter)(),[u,p]=(0,s.useState)(!1),x=(0,s.useRef)(null),[h,g]=(0,s.useState)(!1),[f,j]=(0,s.useState)(!1),[b,y]=(0,s.useState)({aiProvider:"minimax"}),C=(0,s.useCallback)(async()=>{j(!0);try{y(await i.k.get("/api/settings"))}catch(e){l.V.error("[SettingsDialog]","Failed to fetch settings",{error:e})}finally{j(!1)}},[]);(0,s.useEffect)(()=>{u&&C()},[u,C]);let _=async t=>{let s=(0,si.f)(b,o);if(s)return void $.c.error(s);g(!0);try{let s=await i.k.post("/api/settings",b);y(s),e(s.timeZone||eo.J),$.c.success(o.settings?.messages?.saved||"Settings saved"),(0,t6.z)("settings_changed",{section:t}),x.current?.scrollTo({top:0,behavior:"smooth"})}catch(e){l.V.error("[SettingsDialog]","Failed to save settings",{error:e}),$.c.error(o.settings?.messages?.saveFailed||"Failed to save")}finally{g(!1)}},A=(e,s)=>(0,t.jsxs)(k.f,{onClick:()=>_(s),disabled:h,className:"w-full",children:[h&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),e]});return(0,t.jsxs)(S.N,{open:u,onOpenChange:p,children:[(0,t.jsx)(S.a,{asChild:!0,children:(0,t.jsxs)(k.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,t.jsx)(en,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"sr-only",children:o.settings?.title||"Settings"})]})}),(0,t.jsxs)(S.d,{ref:x,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:o.settings?.title||"Settings"}),(0,t.jsx)(S.C,{children:o.settings?.desc||"Manage your preferences and data."})]}),(0,t.jsxs)(ed.i,{defaultValue:"general",className:"w-full",children:[(0,t.jsxs)(ed.U,{className:`grid w-full grid-cols-4 ${c?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,t.jsx)(sn,{value:"general",icon:(0,t.jsx)(es.f,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.general||"General"}),(0,t.jsx)(sn,{value:"account",icon:(0,t.jsx)(el.f,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.account||"Account"}),c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(sn,{value:"ai",icon:(0,t.jsx)(Q,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.ai||"AI Provider"}),(0,t.jsx)(sn,{value:"prompts",icon:(0,t.jsx)(er,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.prompts||"Prompts"}),(0,t.jsx)(sn,{value:"admin",icon:(0,t.jsx)(q,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.admin||"User Management"})]}),(0,t.jsx)(sn,{value:"danger",icon:(0,t.jsx)(X.f,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.danger||"Danger"}),(0,t.jsx)(sn,{value:"about",icon:(0,t.jsx)(et,{className:"h-4 w-4 sm:mr-2"}),label:o.settings?.tabs?.about||"About"})]}),(0,t.jsxs)(ed.S,{value:"general",className:"space-y-4 py-4",children:[(0,t.jsx)(tv,{config:b,setConfig:y,isAdmin:c,disabled:f||h}),(0,t.jsx)(tS,{}),c&&A(o.settings?.save||"Save Settings","general")]}),(0,t.jsxs)(ed.S,{value:"account",className:"space-y-4 py-4",children:[(0,t.jsx)(eq,{}),(0,t.jsx)(tt,{})]}),(0,t.jsxs)(ed.S,{value:"ai",className:"space-y-4 py-4",children:[(0,t.jsx)(eH.f,{config:b,setConfig:y,loading:f,saving:h,onSave:()=>_("ai")}),!f&&(0,t.jsx)(sr,{config:b,setConfig:y,saving:h,onSave:()=>_("tts")})]}),(0,t.jsxs)(ed.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,t.jsx)(tX,{config:b,onUpdate:(e,t)=>y(s=>({...s,prompts:{...s.prompts,[e]:t}}))}),A(o.settings?.prompts?.save||"Save Prompt Settings","prompts")]}),c&&(0,t.jsxs)(ed.S,{value:"admin",className:"space-y-4 py-4",children:[(0,t.jsxs)(k.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{p(!1),m.push("/admin")},children:[(0,t.jsx)(T.f,{className:"h-4 w-4"}),o.admin?.dashboard?.title||"Admin Dashboard"]}),(0,t.jsxs)(k.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{p(!1),m.push("/setup")},children:[(0,t.jsx)(ec.f,{className:"h-4 w-4"}),o.setup.rerun]}),(0,t.jsx)(t8,{}),(0,t.jsx)(to,{}),(0,t.jsx)(e1,{}),(0,t.jsx)("div",{className:"border-t pt-4",children:(0,t.jsx)(e_,{})})]}),(0,t.jsx)(ed.S,{value:"danger",className:"space-y-4 py-4",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(tn,{isAdmin:c,userId:d}),(0,t.jsx)(e5,{isAdmin:c}),(0,t.jsx)(e9,{isAdmin:c})]})}),(0,t.jsx)(ed.S,{value:"about",className:"space-y-4 py-4",children:(0,t.jsx)(eG,{})})]})]})]})}var sc=e.i(263676);function sd({enabled:e}){let{t:r}=(0,a.b)(),n=r.telemetrySettings,[c,d]=(0,s.useState)(!1),[o,m]=(0,s.useState)(""),[u,p]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{if(!e)return;let t=!1;return i.k.get(`${t4}?view=notice`).then(e=>{t||(m(e.eula.current),d(e.showNotice))}).catch(e=>l.V.warn("[TelemetryNotice]","Failed to load telemetry notice",{error:e})),()=>{t=!0}},[e]),!e||!c)return null;let x=async()=>{try{await t3(o),d(!1),$.c.success(n.enabled)}catch(e){throw l.V.error("[TelemetryNotice]","Failed to enable forwarding",{error:e}),$.c.error(n.failed),e}};return(0,t.jsxs)("div",{className:"border-b bg-primary/5 print:hidden",children:[(0,t.jsxs)("div",{className:"mx-auto flex max-w-6xl flex-col gap-2 px-4 py-2 text-sm sm:flex-row sm:items-center md:px-8",children:[(0,t.jsx)("p",{className:"flex-1 text-muted-foreground",children:n.noticeText}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(k.f,{size:"sm",onClick:()=>p(!0),children:n.noticeEnable}),(0,t.jsxs)(k.f,{size:"sm",variant:"ghost",onClick:()=>{d(!1),t5({noticeDismissed:!0}).catch(e=>l.V.warn("[TelemetryNotice]","Failed to dismiss notice",{error:e}))},children:[(0,t.jsx)(sc.X,{className:"mr-1 h-4 w-4"}),n.noticeDismiss]})]})]}),(0,t.jsx)(tQ,{open:u,onOpenChange:p,onConfirm:x})]})}var so=e.i(446513);let sm={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"}]]};sm.node;let su=(0,E.f)(sm),sp={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"}]]};sp.node;let sx=(0,E.f)(sp);var sh=e.i(755146);let sg={system:so.f,light:sx,dark:su};function sf(){let{t:e}=(0,a.b)(),{preference:r,setPreference:i}=(0,s.useContext)(u),n=sg[r],l=`${e.theme.toggle}: ${e.theme[r]}`;return(0,t.jsxs)(sh.G,{children:[(0,t.jsx)(sh.X,{asChild:!0,children:(0,t.jsx)(k.f,{variant:"ghost",size:"icon",className:"rounded-full",title:l,"aria-label":l,children:(0,t.jsx)(n,{className:"h-5 w-5"})})}),(0,t.jsx)(sh.L,{align:"end",children:(0,t.jsx)(sh.O,{value:r,onValueChange:e=>{m(e)&&i(e)},children:c.map(s=>{let a=sg[s];return(0,t.jsxs)(sh.T,{value:s,className:"gap-2",children:[(0,t.jsx)(a,{className:"h-4 w-4"}),e.theme[s]]},s)})})})]})}var sj=e.i(282492),sb=e.i(213056),sy=e.i(722219),sy=sy;let sv=["gemini","openai","azure","anthropic","minimax-code",...st.U],sw=["1","2-5","6-20",">20"],sN=["0","1-50","51-500",">500"],sk=sj.z.enum(sv),sS=sb.z.boolean();Object.keys({app_installed:sy.strictObject({method:sj.z.enum(["setup-token","preset-admin"])}),eula_accepted:sy.strictObject({version:eY.z.string().regex(/^v\d{1,4}$/),trigger:sj.z.enum(["install","upgrade","settings"])}),instance_alive:sy.strictObject({platform:sj.z.enum(["docker","npm","desktop","fnos","android","other"]),aiConfigured:sb.z.boolean()}),app_opened:sy.strictObject({client:sj.z.enum(["browser","pwa","desktop","android"])}),page_viewed:sy.strictObject({page:sj.z.enum(["home","notebooks","error_detail","practice","review","stats","tags","exams","settings","admin","other"])}),ai_analyze_started:sy.strictObject({provider:sk}),ai_analyze_result:sy.strictObject({ok:sS,provider:sk,duration:sj.z.enum(["<3s","3-10s","10-30s",">30s"])}),ai_reanswer:sy.strictObject({ok:sS,provider:sk}),ai_practice_grading:sy.strictObject({ok:sS,count:sj.z.enum(sw)}),exam_paper_generation:sy.strictObject({ok:sS,count:sj.z.enum(sw)}),data_exported:sy.strictObject({scope:sj.z.enum(["user","all"]),rows:sj.z.enum(sN)}),data_imported:sy.strictObject({rows:sj.z.enum(sN)}),tts_used:sy.strictObject({mode:sj.z.enum(sa.l)}),settings_changed:sy.strictObject({section:sj.z.enum(["general","ai","tts","prompts","telemetry"])})});let sC=[[/^\/$/,"home"],[/^\/notebooks?(\/|$)/,"notebooks"],[/^\/error-items?\/[^/]+/,"error_detail"],[/^\/practice(\/|$)/,"practice"],[/^\/review(\/|$)/,"review"],[/^\/stats(\/|$)/,"stats"],[/^\/tags(\/|$)/,"tags"],[/^\/exams?(\/|$)/,"exams"],[/^\/(settings|setup)(\/|$)/,"settings"],[/^\/admin(\/|$)/,"admin"]];function sT({children:e}){var n,c;let d,o,m,u=(0,w.usePathname)()||"/",{t:p}=(0,a.b)(),{data:x,status:h}=(0,r.useSession)(),g=x?.user?.role==="admin",f=R(u);n=g&&!f,d=(0,w.useRouter)(),o=(0,s.useRef)(!1),(0,s.useEffect)(()=>{n&&!o.current&&(o.current=!0,i.k.get("/api/setup").then(e=>{e.needsSetup&&d.replace("/setup")}).catch(e=>l.V.warn("[Setup]","Failed to check setup status",{error:e})))},[n,d]),c="authenticated"===h,m=(0,s.useRef)(null),(0,s.useEffect)(()=>{(0,t6.J)()},[]),(0,s.useEffect)(()=>{let e;if(!c)return;let t=(e=u.split(/[?#]/)[0]||"/",sC.find(([t])=>t.test(e))?.[1]??"other");t!==m.current&&(m.current=t,(0,t6.z)("page_viewed",{page:t}))},[u,c]);let j=function(e){let[t,a]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!e)return;let t=!1;return i.k.get("/api/eula/status").then(e=>{t||a(e)}).catch(e=>l.V.warn("[EulaGate]","Failed to check EULA status",{error:e})),()=>{t=!0}},[e]);let r=(0,s.useCallback)(async()=>{t&&a(await i.k.post("/api/admin/eula/accept",{version:t.current}))},[t]);return{pending:e&&!!t?.pending,status:t,accept:r}}(g&&"authenticated"===h),b=j.pending&&j.status?(0,t.jsx)(K,{status:j.status,onAccept:j.accept}):null;if(f||"unauthenticated"===h)return(0,t.jsxs)(t.Fragment,{children:[e,b]});let y=x?.user?.name||x?.user?.email||"";return(0,t.jsxs)("div",{className:"min-h-screen",children:[(0,t.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,t.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,t.jsxs)(O.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(V.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,t.jsx)("span",{className:"hidden text-base font-semibold tracking-tight sm:inline",children:p.pageTitle.base})]}),(0,t.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:L.map(e=>{let s=e.match(u),a=e.icon;return(0,t.jsxs)(O.default,{href:e.href,className:(0,W.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":s?"page":void 0,children:[(0,t.jsx)(a,{className:"h-4 w-4"}),p.nav[e.key]]},e.key)})}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[y&&(0,t.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,t.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:y.slice(0,1).toUpperCase()}),(0,t.jsx)("span",{className:"truncate",children:y})]}),g&&(0,t.jsx)(O.default,{href:"/admin",title:p.nav.admin,children:(0,t.jsxs)(k.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,t.jsx)(q,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"sr-only",children:p.nav.admin})]})}),(0,t.jsx)(J,{className:"mr-1"}),(0,t.jsx)(sf,{}),(0,t.jsx)(sl,{}),(0,t.jsx)(k.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,r.signOut)({callbackUrl:"/login"}),title:p.app.logout,children:(0,t.jsx)(P.f,{className:"h-5 w-5"})})]})]})}),(0,t.jsx)(sd,{enabled:g&&"authenticated"===h&&!j.pending}),(0,t.jsx)("div",{className:"pb-20 md:pb-0",children:e}),b,(0,t.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,t.jsx)("div",{className:"grid h-16",style:{gridTemplateColumns:`repeat(${L.length}, minmax(0, 1fr))`},children:L.map(e=>{let s=e.match(u),a=e.icon;return(0,t.jsxs)(O.default,{href:e.href,className:(0,W.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",s?"text-primary":"text-muted-foreground"),"aria-current":s?"page":void 0,children:[(0,t.jsx)("span",{className:(0,W.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",s&&"bg-accent"),children:(0,t.jsx)(a,{className:"h-5 w-5"})}),p.nav[e.key]]},e.key)})})})]})}let s_={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"}]]};s_.node;let sA=(0,E.f)(s_);var sz=e.i(583967),sE=e.i(954846);let sD=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function sF(){let{t:e}=(0,a.b)(),{timeZone:n}=(0,v.M)(),{status:l}=(0,r.useSession)(),c=(0,w.usePathname)(),[d,o]=(0,s.useState)(!1),[m,u]=(0,s.useState)(()=>sE.f.getSnapshot()),[p,x]=(0,s.useState)(()=>Date.now()),h="authenticated"!==l||sD.some(e=>e.test(c||""));if((0,s.useEffect)(()=>{if(!h)return sE.f.subscribe(e=>{u(e),x(Date.now())})},[h]),h)return null;let g=m.filter(e=>"running"===e.status).length,f=m.some(e=>"running"!==e.status),j=async()=>{try{await i.k.delete("/api/tasks"),await sE.f.refresh()}catch{}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(k.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:()=>o(!0),"aria-label":e.backgroundTasks.title,title:e.backgroundTasks.title,children:[g>0?(0,t.jsx)(N.f,{className:"h-5 w-5 animate-spin"}):(0,t.jsx)(sA,{className:"h-5 w-5"}),g>0&&(0,t.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:g})]}),(0,t.jsx)(S.N,{open:d,onOpenChange:o,children:(0,t.jsxs)(S.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:e.backgroundTasks.title}),(0,t.jsx)(S.C,{children:e.backgroundTasks.description})]}),0===m.length?(0,t.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:e.backgroundTasks.empty}):(0,t.jsx)("ul",{className:"space-y-2",children:m.map(s=>{var a,r;let i;return(0,t.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,t.jsxs)("div",{className:"flex items-start gap-2",children:["running"===s.status&&(0,t.jsx)(N.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===s.status&&(0,t.jsx)(ts.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===s.status&&(0,t.jsx)(sz.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"font-medium",children:[e.backgroundTasks.kinds[s.kind],(0,t.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",e.backgroundTasks.status[s.status]]})]}),s.subject&&(0,t.jsx)("div",{className:"break-words text-muted-foreground",children:s.subject}),s.progress&&s.progress.total>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,t.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(s.progress.done/s.progress.total*100)}%`}})}),(0,t.jsxs)("div",{className:"text-xs text-muted-foreground",children:[e.backgroundTasks.progress.replace("{done}",String(s.progress.done)).replace("{total}",String(s.progress.total)),s.progress.failed>0&&` \xb7 ${e.backgroundTasks.failedCount.replace("{count}",String(s.progress.failed))}`]})]}),s.error&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:(t=>{if(!t)return null;let s=e.backgroundTasks.errors[t]??e.errors[t];return"string"==typeof s?s:t})(s.error)}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:e.backgroundTasks.startedAt.replace("{time}",(0,eo.r)(s.startedAt,"HH:mm:ss",n))}),(0,t.jsx)("span",{children:e.backgroundTasks.elapsed.replace("{time}",(a=s.startedAt,r=s.finishedAt,i=Math.max(0,Math.round(((r?Date.parse(r):p)-Date.parse(a))/1e3)),`${Math.floor(i/60)}:${String(i%60).padStart(2,"0")}`))}),s.link&&(0,t.jsx)(O.default,{href:s.link,className:"text-primary hover:underline",onClick:()=>o(!1),children:e.backgroundTasks.view})]})]})]})},s.id)})}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.backgroundTasks.retentionHint}),f&&(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:j,children:e.backgroundTasks.clearFinished})]})]})})]})}var sM=e.i(145447);function sL(){let{t:e}=(0,a.b)(),r=(0,sM.f)(),[i,n]=(0,s.useState)(!1),l=r?function(e){let t=/\bChrome\/(\d+)\./.exec(e);if(!t)return null;let s=Number(t[1]);return s>=111?null:{kind:/; wv\)/.test(e)||e.includes("WrongNotebookAndroid/")?"webview":"browser",version:s}}(navigator.userAgent):null;if(!l||i)return null;let c="webview"===l.kind?e.browserSupport.outdatedWebView:e.browserSupport.outdatedBrowser;return(0,t.jsxs)("div",{role:"alert","data-testid":"outdated-browser-notice",className:"flex items-start gap-3 border-b border-amber-300 bg-amber-100 px-4 py-2 text-sm text-amber-900",children:[(0,t.jsx)("p",{className:"flex-1",children:c.replace("{version}",String(l.version))}),(0,t.jsx)("button",{type:"button",onClick:()=>n(!0),className:"shrink-0 font-medium underline",children:e.common.close})]})}let sR={success:{icon:ts.f,className:"text-success"},error:{icon:sz.f,className:"text-destructive"},warning:{icon:X.f,className:"text-warning"},info:{icon:et,className:"text-primary"}};function s$(){let{t:e}=(0,a.b)(),[r,i]=(0,s.useState)([]),[n,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>(0,$.M)(e=>{i(e.toasts),l(e.confirm)}),[]),(0,t.jsxs)(t.Fragment,{children:[(0,t.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:r.map(s=>{let{icon:a,className:r}=sR[s.type];return(0,t.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,t.jsx)(a,{className:(0,W.f)("mt-0.5 h-4 w-4 shrink-0",r)}),(0,t.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:s.message}),(0,t.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,$.p)(s.id),"aria-label":e.common.close,children:(0,t.jsx)(sc.X,{className:"h-3.5 w-3.5"})})]},s.id)})}),(0,t.jsx)(S.N,{open:!!n,onOpenChange:e=>{e||n?.resolve(!1)},children:(0,t.jsxs)(S.d,{className:"sm:max-w-md",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsxs)(S.F,{className:"flex items-center gap-2",children:[n?.destructive&&(0,t.jsx)(X.f,{className:"h-5 w-5 text-destructive"}),n?.title||e.common.confirmTitle]}),(0,t.jsx)(S.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:n?.message})]}),(0,t.jsxs)(S.c,{className:"gap-2",children:[(0,t.jsx)(k.f,{variant:"outline",onClick:()=>n?.resolve(!1),children:n?.cancelText||e.common.cancel}),(0,t.jsx)(k.f,{variant:n?.destructive?"destructive":"default",onClick:()=>n?.resolve(!0),autoFocus:!0,children:n?.confirmText||e.common.confirm})]})]})})]})}function sI(){return(0,s.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(e=>{l.V.warn("[PWA]","Service worker registration failed",{error:String(e)})})},[]),null}e.s(["Providers",0,function({children:e,timeZone:i}){return(0,s.useEffect)(()=>(0,l.m)(),[]),(0,t.jsx)(r.SessionProvider,{children:(0,t.jsx)(y,{children:(0,t.jsx)(a.w,{children:(0,t.jsxs)(v.n,{initialTimeZone:i,children:[(0,t.jsx)(sL,{}),(0,t.jsx)(sT,{children:e}),(0,t.jsx)(sF,{}),(0,t.jsx)(G,{}),(0,t.jsx)(s$,{}),(0,t.jsx)(sI,{})]})})})})}],1661)}]);
264
+ {{provider_hints}}`;var tW=e.i(113381);function tX({config:e,onUpdate:s}){let{t:r}=(0,a.b)(),i=e.prompts?.analyze||tB,n=e.prompts?.similar||tY,l=e.prompts?.reanswer||tJ,c=r.settings?.prompts?.vars,o=[{name:"language_instruction",description:c?.languageInstruction||"Language instructions."},{name:"knowledge_points_list",description:c?.knowledgePointsList||"Knowledge point tags for the subject."},{name:"grade_instruction",description:c?.gradeInstruction||"Grade and semester guidance."},{name:"provider_hints",description:c?.providerHints||"Provider compatibility hints."}],d=[{name:"original_question",description:c?.originalQuestion||"The full text of the original question."},{name:"knowledge_points",description:c?.knowledgePoints||"List of knowledge points to test."},{name:"difficulty_level",description:c?.difficultyLevel||"Target difficulty level."},{name:"difficulty_instruction",description:c?.difficultyInstruction||"Specific writing instructions for the target difficulty."},{name:"language_instruction",description:c?.languageInstructionShort||"Language formatting instructions."},{name:"figure_instruction",description:c?.figureInstruction||"Instructions for redrawing the original figure."},{name:"grade_instruction",description:c?.gradeInstruction||"Grade and semester guidance."}],m=[{name:"question_text",description:c?.questionText||"The corrected question text."},{name:"subject_hint",description:c?.subjectHint||"Subject of the question."},{name:"knowledge_points_rule",description:c?.knowledgePointsRule||"Candidate knowledge points to choose from."},{name:"language_instruction",description:c?.languageInstruction||"Language instructions."},{name:"grade_instruction",description:c?.gradeInstruction||"Grade and semester guidance."},{name:"provider_hints",description:c?.providerHints||"Provider compatibility hints."}];return(0,t.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,t.jsxs)(eo.i,{defaultValue:"analyze",className:"w-full",children:[(0,t.jsxs)(eo.U,{className:"grid w-full grid-cols-3",children:[(0,t.jsx)(eo.k,{value:"analyze",className:"text-xs sm:text-sm",children:r.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,t.jsx)(eo.k,{value:"reanswer",className:"text-xs sm:text-sm",children:r.settings?.prompts?.reanswerTab||"Solving Prompt"}),(0,t.jsx)(eo.k,{value:"similar",className:"text-xs sm:text-sm",children:r.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,t.jsx)(eo.S,{value:"analyze",className:"py-4",children:(0,t.jsx)(tF,{value:i,defaultValue:tB,onChange:e=>s("analyze",e),onReset:()=>s("analyze",tB),title:r.settings?.prompts?.customAnalysis||"Custom Analysis Template",variables:o})}),(0,t.jsx)(eo.S,{value:"reanswer",className:"py-4",children:(0,t.jsx)(tF,{value:l,defaultValue:tJ,onChange:e=>s("reanswer",e),onReset:()=>s("reanswer",tJ),title:r.settings?.prompts?.customReanswer||"Custom Solving Template",variables:m})}),(0,t.jsx)(eo.S,{value:"similar",className:"py-4",children:(0,t.jsx)(tF,{value:n,defaultValue:tY,onChange:e=>s("similar",e),onReset:()=>s("similar",tY),title:r.settings?.prompts?.customSimilar||"Custom Similar Question Template",variables:d})})]})})}tW.I.join("、"),tW.r.join("、");var tZ=e.i(999593);function tQ({open:e,onOpenChange:r,onConfirm:i}){let{t:n}=(0,a.b)(),[l,c]=(0,s.useState)(!1),[o,d]=(0,s.useState)(!1),m=async()=>{d(!0);try{await i(),c(!1),r(!1)}catch{}finally{d(!1)}};return(0,t.jsx)(S.N,{open:e,onOpenChange:e=>!o&&r(e),children:(0,t.jsxs)(S.d,{className:"w-[calc(100vw-2rem)] sm:max-w-lg",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:n.eula.dialogTitle}),(0,t.jsx)(S.C,{children:n.eula.dialogDesc})]}),(0,t.jsx)(tZ.f,{checked:l,onCheckedChange:c,disabled:o}),(0,t.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,t.jsx)(k.f,{variant:"outline",onClick:()=>r(!1),disabled:o,children:n.eula.cancel}),(0,t.jsxs)(k.f,{onClick:m,disabled:!l||o,children:[o&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.eula.accept]})]})]})})}function t0({endpoint:e,retentionDays:r,disabled:i,onSave:n}){let{t:l}=(0,a.b)(),c=l.telemetrySettings,[o,d]=(0,s.useState)(""!==e),[m,u]=(0,s.useState)(e),[p,x]=(0,s.useState)(String(r)),h=Number(p),g=Number.isInteger(h)&&h>=1&&h<=365;return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(ex.f,{htmlFor:"telemetry-endpoint",children:c.endpoint}),o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ep.f,{id:"telemetry-endpoint",value:m,placeholder:c.endpointPlaceholder,disabled:i,onChange:e=>u(e.target.value)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.endpointHint})]}):(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:c.endpointDefault}),(0,t.jsx)(k.f,{variant:"link",size:"sm",className:"h-auto p-0",disabled:i,onClick:()=>d(!0),children:c.endpointCustomize})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(ex.f,{htmlFor:"telemetry-retention",children:c.retentionDays}),(0,t.jsx)(ep.f,{id:"telemetry-retention",type:"number",min:1,max:365,className:"w-32",value:p,disabled:i,onChange:e=>x(e.target.value)})]}),(0,t.jsx)(k.f,{size:"sm",variant:"outline",disabled:i||!g,onClick:()=>n({endpoint:m.trim(),retentionDays:h}),children:c.save})]})}function t1({events:e,errors:s,disabled:r,onClear:i}){let{t:n}=(0,a.b)(),{timeZone:l}=(0,v.M)(),c=n.telemetrySettings,o=e=>(0,ed.r)(e,"MM-dd HH:mm",l),d=e=>e?c.forwarded:c.notForwarded,m=0===e.length&&0===s.length;return(0,t.jsxs)("details",{className:"rounded-md border p-3 text-sm",children:[(0,t.jsx)("summary",{className:"cursor-pointer font-medium",children:c.recentTitle}),(0,t.jsxs)("div",{className:"mt-3 space-y-3",children:[m&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.recentEmpty}),e.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:c.recentEvents}),(0,t.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:e.map(e=>(0,t.jsxs)("li",{className:"break-all",children:[o(e.createdAt)," ",e.name," ",e.payload??""," · ",d(e.forwardedAt)]},e.id))})]}),s.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:c.recentErrors}),(0,t.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:s.map(e=>(0,t.jsxs)("li",{className:"break-all",children:[o(e.createdAt)," ",e.kind," ",e.scope," ",e.name," #",e.fingerprint,e.path?` ${e.path}`:"",e.message?` — ${e.message}`:""," · ",d(e.forwardedAt)]},e.id))})]}),(0,t.jsxs)(k.f,{variant:"outline",size:"sm",onClick:i,disabled:r||m,children:[(0,t.jsx)(ev.f,{className:"mr-2 h-4 w-4"}),c.clear]})]})]})}function t2({id:e,label:s,description:a,checked:r,disabled:i,onCheckedChange:n}){return(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(ex.f,{htmlFor:e,className:"font-medium",children:s}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:a})]}),(0,t.jsx)(eu.f,{id:e,checked:r,disabled:i,onCheckedChange:n,className:"shrink-0"})]})}let t4="/api/admin/telemetry";async function t3(e){return await i.k.post("/api/admin/eula/accept",{version:e}),i.k.post(t4,{forwarding:!0})}function t5(e){return i.k.post(t4,e)}var t6=e.i(983761);function t8(){let{t:e}=(0,a.b)(),{timeZone:r}=(0,v.M)(),c=e.telemetrySettings,{data:o,update:d,enableWithConsent:m,clear:u}=function(){let[e,t]=(0,s.useState)(null),a=(0,s.useCallback)(async()=>{try{t(await i.k.get(t4))}catch(e){l.V.warn("[TelemetrySettings]","Failed to load telemetry status",{error:e})}},[]);return(0,s.useEffect)(()=>{a()},[a]),{data:e,update:async e=>t(await t5(e)),enableWithConsent:async e=>t(await t3(e)),clear:async()=>t(await i.k.delete(t4))}}(),[p,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),f=async(e,t)=>{x(!0);try{await e(),$.c.success(t)}catch(e){throw l.V.error("[TelemetrySettings]","Telemetry action failed",{error:e}),$.c.error("INVALID_TELEMETRY_ENDPOINT"===(0,n.d)(e)?c.invalidEndpoint:c.failed),e}finally{x(!1)}},j=e=>f(async()=>{await d(e),(0,t6.z)("settings_changed",{section:"telemetry"})},c.saved).catch(()=>void 0);if(!o)return null;let b=o.lockedByEnv,y=p||b,w=e=>(0,ed.r)(e,"yyyy-MM-dd HH:mm",r),N=async()=>{await (0,$.u)(c.clearConfirm)&&f(u,c.cleared).catch(()=>void 0)},k=o.lastFlushAt?c.lastFlush.replace("{time}",w(o.lastFlushAt)):c.neverFlushed;return o.lastAttempt?.status==="failed"&&(k=c.lastAttemptFailed.replace("{status}",String(o.lastAttempt.httpStatus??"network"))),o.lastAttempt?.status==="stopped"&&(k=c.lastAttemptStopped),(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border p-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"flex items-center gap-2 font-medium",children:[(0,t.jsx)(te,{className:"h-4 w-4"}),c.title]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.desc})]}),b&&(0,t.jsx)("p",{className:"text-xs text-orange-600",children:c.lockedByEnv}),o.consentPending&&(0,t.jsx)("p",{className:"text-xs text-orange-600",children:c.consentPending}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[o.eula.acceptedVersion?c.eulaStatus.replace("{version}",o.eula.acceptedVersion).replace("{time}",o.eula.acceptedAt?w(o.eula.acceptedAt):"-"):c.eulaNotAccepted," ",(0,t.jsx)("a",{href:"/eula",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:c.viewEula})]}),(0,t.jsx)(t2,{id:"telemetry-forwarding",label:c.forwarding,description:c.forwardingDesc,checked:o.forwarding,disabled:y,onCheckedChange:e=>{e&&(!o.eula.acceptedVersion||o.consentPending)?g(!0):j({forwarding:e})}}),o.forwarding&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[c.pending.replace("{count}",String(o.pending))," · ",k]}),(0,t.jsx)(t2,{id:"telemetry-recording",label:c.recording,description:c.recordingDesc,checked:o.recording,disabled:y,onCheckedChange:e=>j({recording:e})}),(0,t.jsx)(t2,{id:"telemetry-errors",label:c.errors,description:c.errorsDesc,checked:o.errors,disabled:y,onCheckedChange:e=>j({errors:e})}),(0,t.jsx)(t0,{endpoint:o.endpoint,retentionDays:o.retentionDays,disabled:y,onSave:j}),(0,t.jsx)(t1,{events:o.events,errors:o.errorRecords,disabled:p,onClear:N}),(0,t.jsx)(tQ,{open:h,onOpenChange:g,onConfirm:()=>f(()=>m(o.eula.current),c.enabled)})]})}var t9=e.i(21357),t7=e.i(434901),se=e.i(753817),st=e.i(128093),ss=e.i(79058),sa=e.i(495178);function sr({config:e,setConfig:r,saving:c,onSave:o}){let{t:d,language:m}=(0,a.b)(),u=d.settings.tts,[p,x]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null),f=e.tts?.mode??"browser",j=(0,sa.y)(f)?f:null,b=j?e.tts?.[j]:void 0,y=(e,t)=>{j&&r(s=>({...s,tts:{...s.tts,[j]:{...s.tts?.[j],[e]:t}}}))},v=!!j&&(0,sa.S)(j),w=j?(0,sa.L)(e,j):void 0,S=v?b?.apiKey:w?.apiKey,C=async()=>{(0,ss.p)(),x(!0),g(null);try{await o();let{id:e,version:t}=await i.k.post("/api/tts",{text:u.previewText,language:m},{timeout:12e4,recoverable:!0}),s=(0,ss.l)();if(!s)return;s.src=`/api/tts/${e}?v=${t}`,s.playbackRate=1,await s.play()}catch(t){l.V.error("[TtsSettings]","Preview failed",{error:t});let e=(0,n.d)(t);$.c.error("TTS_NOT_CONFIGURED"===e?u.notConfigured:"TTS_PROVIDER_ERROR"===e?u.providerError:u.previewFailed),g((0,n.L)(t)??null)}finally{x(!1)}};return(0,t.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ex.f,{children:u.title}),(0,t.jsxs)(eO.d,{value:f,onValueChange:e=>r(t=>({...t,tts:{...t.tts,mode:e}})),children:[(0,t.jsx)(eO.P,{children:(0,t.jsx)(eO.U,{})}),(0,t.jsx)(eO.r,{children:sa.l.map(e=>(0,t.jsx)(eO.T,{value:e,children:u.modes[e]},e))})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:j?u.cloudHint:u.browserHint})]}),j&&(0,t.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[sa.D[j]&&(0,t.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:[u.freeTrial," ",(0,t.jsx)("a",{href:sa.D[j],target:"_blank",rel:"noopener noreferrer",className:"underline",children:u.freeTrialLink})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(t7.f,{label:"openai"===j?"OpenAI API Key":v?u.speechApiKey:`${(0,st.z)(j,m)} API Key`,href:sa.r[j].apiKey,linkText:d.settings.ai.docLinks.apiKey}),(0,t.jsx)(eG.f,{value:S||"",onChange:e=>{var t;return t=e.target.value,void(j&&(v?y("apiKey",t):r(e=>({...e,[j]:{...e[j],apiKey:t}}))))},placeholder:"qwen"===j?"sk-sp-...":v?"":"sk-..."}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u.apiKeyHint[j]})]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(t7.f,{label:u.model,href:sa.r[j].model,linkText:u.docs}),(0,t.jsx)(ep.f,{value:b?.model||"",onChange:e=>y("model",e.target.value),placeholder:sa.C[j].model})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(t7.f,{label:u.voice,href:sa.r[j].voice,linkText:u.voiceList}),(0,t.jsx)(ep.f,{value:b?.voice||"",onChange:e=>y("voice",e.target.value),placeholder:sa.C[j].voice})]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u.voiceHint[j]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(t7.f,{label:u.endpoint,href:sa.r[j].endpoint,linkText:u.docs}),(0,t.jsx)(ep.f,{value:b?.endpoint||"",onChange:e=>y("endpoint",e.target.value),placeholder:(0,sa.E)(j,w)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u.endpointHint})]})]},j),(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[j&&(0,t.jsxs)(k.f,{variant:"outline",onClick:C,disabled:c||p,className:"sm:w-auto",children:[p?(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(t9.f,{className:"mr-2 h-4 w-4"}),u.preview]}),(0,t.jsxs)(k.f,{onClick:()=>void o(),disabled:c||p,className:"flex-1",children:[c&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),u.save]})]}),j&&h&&(0,t.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,t.jsx)(se.f,{detail:h})})]})}var si=e.i(835467);function sn({value:e,icon:s,label:a}){return(0,t.jsxs)(eo.k,{value:e,className:"px-2 sm:px-3",children:[s,(0,t.jsx)("span",{className:"hidden sm:inline",children:a})]})}function sl(){let{setTimeZone:e}=(0,v.M)(),{data:n}=(0,r.useSession)(),c=n?.user?.role==="admin",o=n?.user?.id??"",d=n?.user?.email??"",{t:m}=(0,a.b)(),u=(0,w.useRouter)(),[p,x]=(0,s.useState)(!1),h=(0,s.useRef)(null),[g,f]=(0,s.useState)(!1),[j,b]=(0,s.useState)(!1),[y,C]=(0,s.useState)({aiProvider:"minimax"}),_=(0,s.useCallback)(async()=>{b(!0);try{C(await i.k.get("/api/settings"))}catch(e){l.V.error("[SettingsDialog]","Failed to fetch settings",{error:e})}finally{b(!1)}},[]);(0,s.useEffect)(()=>{p&&_()},[p,_]);let A=async t=>{let s=(0,si.f)(y,m);if(s)return void $.c.error(s);f(!0);try{let s=await i.k.post("/api/settings",y);C(s),e(s.timeZone||ed.J),$.c.success(m.settings?.messages?.saved||"Settings saved"),(0,t6.z)("settings_changed",{section:t}),h.current?.scrollTo({top:0,behavior:"smooth"})}catch(e){l.V.error("[SettingsDialog]","Failed to save settings",{error:e}),$.c.error(m.settings?.messages?.saveFailed||"Failed to save")}finally{f(!1)}},z=(e,s)=>(0,t.jsxs)(k.f,{onClick:()=>A(s),disabled:g,className:"w-full",children:[g&&(0,t.jsx)(N.f,{className:"mr-2 h-4 w-4 animate-spin"}),e]});return(0,t.jsxs)(S.N,{open:p,onOpenChange:x,children:[(0,t.jsx)(S.a,{asChild:!0,children:(0,t.jsxs)(k.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,t.jsx)(en,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"sr-only",children:m.settings?.title||"Settings"})]})}),(0,t.jsxs)(S.d,{ref:h,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:m.settings?.title||"Settings"}),(0,t.jsx)(S.C,{children:m.settings?.desc||"Manage your preferences and data."})]}),(0,t.jsxs)(eo.i,{defaultValue:"general",className:"w-full",children:[(0,t.jsxs)(eo.U,{className:`grid w-full grid-cols-4 ${c?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,t.jsx)(sn,{value:"general",icon:(0,t.jsx)(es.f,{className:"h-4 w-4 sm:mr-2"}),label:m.settings?.tabs?.general||"General"}),(0,t.jsx)(sn,{value:"account",icon:(0,t.jsx)(el.f,{className:"h-4 w-4 sm:mr-2"}),label:m.settings?.tabs?.account||"Account"}),c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(sn,{value:"ai",icon:(0,t.jsx)(Q,{className:"h-4 w-4 sm:mr-2"}),label:m.settings?.tabs?.ai||"AI Provider"}),(0,t.jsx)(sn,{value:"prompts",icon:(0,t.jsx)(er,{className:"h-4 w-4 sm:mr-2"}),label:m.settings?.tabs?.prompts||"Prompts"}),(0,t.jsx)(sn,{value:"admin",icon:(0,t.jsx)(q,{className:"h-4 w-4 sm:mr-2"}),label:m.settings?.tabs?.admin||"User Management"})]}),(0,t.jsx)(sn,{value:"danger",icon:(0,t.jsx)(X.f,{className:"h-4 w-4 sm:mr-2"}),label:m.settings?.tabs?.danger||"Danger"}),(0,t.jsx)(sn,{value:"about",icon:(0,t.jsx)(et,{className:"h-4 w-4 sm:mr-2"}),label:m.settings?.tabs?.about||"About"})]}),(0,t.jsxs)(eo.S,{value:"general",className:"space-y-4 py-4",children:[(0,t.jsx)(tv,{config:y,setConfig:C,isAdmin:c,disabled:j||g}),(0,t.jsx)(tS,{}),c&&z(m.settings?.save||"Save Settings","general")]}),(0,t.jsxs)(eo.S,{value:"account",className:"space-y-4 py-4",children:[(0,t.jsx)(eq,{}),(0,t.jsx)(tt,{})]}),(0,t.jsxs)(eo.S,{value:"ai",className:"space-y-4 py-4",children:[(0,t.jsx)(eH.f,{config:y,setConfig:C,loading:j,saving:g,onSave:()=>A("ai")}),!j&&(0,t.jsx)(sr,{config:y,setConfig:C,saving:g,onSave:()=>A("tts")})]}),(0,t.jsxs)(eo.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,t.jsx)(tX,{config:y,onUpdate:(e,t)=>C(s=>({...s,prompts:{...s.prompts,[e]:t}}))}),z(m.settings?.prompts?.save||"Save Prompt Settings","prompts")]}),c&&(0,t.jsxs)(eo.S,{value:"admin",className:"space-y-4 py-4",children:[(0,t.jsxs)(k.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{x(!1),u.push("/admin")},children:[(0,t.jsx)(T.f,{className:"h-4 w-4"}),m.admin?.dashboard?.title||"Admin Dashboard"]}),(0,t.jsxs)(k.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{x(!1),u.push("/setup")},children:[(0,t.jsx)(ec.f,{className:"h-4 w-4"}),m.setup.rerun]}),(0,t.jsx)(t8,{}),(0,t.jsx)(td,{}),(0,t.jsx)(e1,{}),(0,t.jsx)("div",{className:"border-t pt-4",children:(0,t.jsx)(e_,{})})]}),(0,t.jsx)(eo.S,{value:"danger",className:"space-y-4 py-4",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(tn,{isAdmin:c,userId:o,userEmail:d}),(0,t.jsx)(e5,{isAdmin:c}),(0,t.jsx)(e9,{isAdmin:c})]})}),(0,t.jsx)(eo.S,{value:"about",className:"space-y-4 py-4",children:(0,t.jsx)(eV,{})})]})]})]})}var sc=e.i(263676);function so({enabled:e}){let{t:r}=(0,a.b)(),n=r.telemetrySettings,[c,o]=(0,s.useState)(!1),[d,m]=(0,s.useState)(""),[u,p]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{if(!e)return;let t=!1;return i.k.get(`${t4}?view=notice`).then(e=>{t||(m(e.eula.current),o(e.showNotice))}).catch(e=>l.V.warn("[TelemetryNotice]","Failed to load telemetry notice",{error:e})),()=>{t=!0}},[e]),!e||!c)return null;let x=async()=>{try{await t3(d),o(!1),$.c.success(n.enabled)}catch(e){throw l.V.error("[TelemetryNotice]","Failed to enable forwarding",{error:e}),$.c.error(n.failed),e}};return(0,t.jsxs)("div",{className:"border-b bg-primary/5 print:hidden",children:[(0,t.jsxs)("div",{className:"mx-auto flex max-w-6xl flex-col gap-2 px-4 py-2 text-sm sm:flex-row sm:items-center md:px-8",children:[(0,t.jsx)("p",{className:"flex-1 text-muted-foreground",children:n.noticeText}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(k.f,{size:"sm",onClick:()=>p(!0),children:n.noticeEnable}),(0,t.jsxs)(k.f,{size:"sm",variant:"ghost",onClick:()=>{o(!1),t5({noticeDismissed:!0}).catch(e=>l.V.warn("[TelemetryNotice]","Failed to dismiss notice",{error:e}))},children:[(0,t.jsx)(sc.X,{className:"mr-1 h-4 w-4"}),n.noticeDismiss]})]})]}),(0,t.jsx)(tQ,{open:u,onOpenChange:p,onConfirm:x})]})}var sd=e.i(446513);let sm={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"}]]};sm.node;let su=(0,E.f)(sm),sp={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"}]]};sp.node;let sx=(0,E.f)(sp);var sh=e.i(755146);let sg={system:sd.f,light:sx,dark:su};function sf(){let{t:e}=(0,a.b)(),{preference:r,setPreference:i}=(0,s.useContext)(u),n=sg[r],l=`${e.theme.toggle}: ${e.theme[r]}`;return(0,t.jsxs)(sh.G,{children:[(0,t.jsx)(sh.X,{asChild:!0,children:(0,t.jsx)(k.f,{variant:"ghost",size:"icon",className:"rounded-full",title:l,"aria-label":l,children:(0,t.jsx)(n,{className:"h-5 w-5"})})}),(0,t.jsx)(sh.L,{align:"end",children:(0,t.jsx)(sh.O,{value:r,onValueChange:e=>{m(e)&&i(e)},children:c.map(s=>{let a=sg[s];return(0,t.jsxs)(sh.T,{value:s,className:"gap-2",children:[(0,t.jsx)(a,{className:"h-4 w-4"}),e.theme[s]]},s)})})})]})}var sj=e.i(282492),sb=e.i(213056),sy=e.i(722219),sy=sy;let sv=["gemini","openai","azure","anthropic","minimax-code",...st.U],sw=["1","2-5","6-20",">20"],sN=["0","1-50","51-500",">500"],sk=sj.z.enum(sv),sS=sb.z.boolean();Object.keys({app_installed:sy.strictObject({method:sj.z.enum(["setup-token","preset-admin"])}),eula_accepted:sy.strictObject({version:eY.z.string().regex(/^v\d{1,4}$/),trigger:sj.z.enum(["install","upgrade","settings"])}),instance_alive:sy.strictObject({platform:sj.z.enum(["docker","npm","desktop","fnos","android","other"]),aiConfigured:sb.z.boolean()}),app_opened:sy.strictObject({client:sj.z.enum(["browser","pwa","desktop","android"])}),page_viewed:sy.strictObject({page:sj.z.enum(["home","notebooks","error_detail","practice","review","stats","tags","exams","settings","admin","other"])}),ai_analyze_started:sy.strictObject({provider:sk}),ai_analyze_result:sy.strictObject({ok:sS,provider:sk,duration:sj.z.enum(["<3s","3-10s","10-30s",">30s"])}),ai_reanswer:sy.strictObject({ok:sS,provider:sk}),ai_practice_grading:sy.strictObject({ok:sS,count:sj.z.enum(sw)}),exam_paper_generation:sy.strictObject({ok:sS,count:sj.z.enum(sw)}),data_exported:sy.strictObject({scope:sj.z.enum(["user","all"]),rows:sj.z.enum(sN)}),data_imported:sy.strictObject({rows:sj.z.enum(sN)}),tts_used:sy.strictObject({mode:sj.z.enum(sa.l)}),settings_changed:sy.strictObject({section:sj.z.enum(["general","ai","tts","prompts","telemetry"])})});let sC=[[/^\/$/,"home"],[/^\/notebooks?(\/|$)/,"notebooks"],[/^\/error-items?\/[^/]+/,"error_detail"],[/^\/practice(\/|$)/,"practice"],[/^\/review(\/|$)/,"review"],[/^\/stats(\/|$)/,"stats"],[/^\/tags(\/|$)/,"tags"],[/^\/exams?(\/|$)/,"exams"],[/^\/(settings|setup)(\/|$)/,"settings"],[/^\/admin(\/|$)/,"admin"]];function sT({children:e}){var n,c;let o,d,m,u=(0,w.usePathname)()||"/",{t:p}=(0,a.b)(),{data:x,status:h}=(0,r.useSession)(),g=x?.user?.role==="admin",f=R(u);n=g&&!f,o=(0,w.useRouter)(),d=(0,s.useRef)(!1),(0,s.useEffect)(()=>{n&&!d.current&&(d.current=!0,i.k.get("/api/setup").then(e=>{e.needsSetup&&o.replace("/setup")}).catch(e=>l.V.warn("[Setup]","Failed to check setup status",{error:e})))},[n,o]),c="authenticated"===h,m=(0,s.useRef)(null),(0,s.useEffect)(()=>{(0,t6.J)()},[]),(0,s.useEffect)(()=>{let e;if(!c)return;let t=(e=u.split(/[?#]/)[0]||"/",sC.find(([t])=>t.test(e))?.[1]??"other");t!==m.current&&(m.current=t,(0,t6.z)("page_viewed",{page:t}))},[u,c]);let j=function(e){let[t,a]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!e)return;let t=!1;return i.k.get("/api/eula/status").then(e=>{t||a(e)}).catch(e=>l.V.warn("[EulaGate]","Failed to check EULA status",{error:e})),()=>{t=!0}},[e]);let r=(0,s.useCallback)(async()=>{t&&a(await i.k.post("/api/admin/eula/accept",{version:t.current}))},[t]);return{pending:e&&!!t?.pending,status:t,accept:r}}(g&&"authenticated"===h),b=j.pending&&j.status?(0,t.jsx)(K,{status:j.status,onAccept:j.accept}):null;if(f||"unauthenticated"===h)return(0,t.jsxs)(t.Fragment,{children:[e,b]});let y=x?.user?.name||x?.user?.email||"";return(0,t.jsxs)("div",{className:"min-h-screen",children:[(0,t.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,t.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,t.jsxs)(O.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(G.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,t.jsx)("span",{className:"hidden text-base font-semibold tracking-tight sm:inline",children:p.pageTitle.base})]}),(0,t.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:L.map(e=>{let s=e.match(u),a=e.icon;return(0,t.jsxs)(O.default,{href:e.href,className:(0,J.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":s?"page":void 0,children:[(0,t.jsx)(a,{className:"h-4 w-4"}),p.nav[e.key]]},e.key)})}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[y&&(0,t.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,t.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:y.slice(0,1).toUpperCase()}),(0,t.jsx)("span",{className:"truncate",children:y})]}),g&&(0,t.jsx)(O.default,{href:"/admin",title:p.nav.admin,children:(0,t.jsxs)(k.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,t.jsx)(q,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"sr-only",children:p.nav.admin})]})}),(0,t.jsx)(W,{className:"mr-1"}),(0,t.jsx)(sf,{}),(0,t.jsx)(sl,{}),(0,t.jsx)(k.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,r.signOut)({callbackUrl:"/login"}),title:p.app.logout,children:(0,t.jsx)(P.f,{className:"h-5 w-5"})})]})]})}),(0,t.jsx)(so,{enabled:g&&"authenticated"===h&&!j.pending}),(0,t.jsx)("div",{className:"pb-20 md:pb-0",children:e}),b,(0,t.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,t.jsx)("div",{className:"grid h-16",style:{gridTemplateColumns:`repeat(${L.length}, minmax(0, 1fr))`},children:L.map(e=>{let s=e.match(u),a=e.icon;return(0,t.jsxs)(O.default,{href:e.href,className:(0,J.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",s?"text-primary":"text-muted-foreground"),"aria-current":s?"page":void 0,children:[(0,t.jsx)("span",{className:(0,J.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",s&&"bg-accent"),children:(0,t.jsx)(a,{className:"h-5 w-5"})}),p.nav[e.key]]},e.key)})})})]})}let s_={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"}]]};s_.node;let sA=(0,E.f)(s_);var sz=e.i(583967),sE=e.i(954846);let sD=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function sF(){let{t:e}=(0,a.b)(),{timeZone:n}=(0,v.M)(),{status:l}=(0,r.useSession)(),c=(0,w.usePathname)(),[o,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(()=>sE.f.getSnapshot()),[p,x]=(0,s.useState)(()=>Date.now()),h="authenticated"!==l||sD.some(e=>e.test(c||""));if((0,s.useEffect)(()=>{if(!h)return sE.f.subscribe(e=>{u(e),x(Date.now())})},[h]),h)return null;let g=m.filter(e=>"running"===e.status).length,f=m.some(e=>"running"!==e.status),j=async()=>{try{await i.k.delete("/api/tasks"),await sE.f.refresh()}catch{}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(k.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:()=>d(!0),"aria-label":e.backgroundTasks.title,title:e.backgroundTasks.title,children:[g>0?(0,t.jsx)(N.f,{className:"h-5 w-5 animate-spin"}):(0,t.jsx)(sA,{className:"h-5 w-5"}),g>0&&(0,t.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:g})]}),(0,t.jsx)(S.N,{open:o,onOpenChange:d,children:(0,t.jsxs)(S.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsx)(S.F,{children:e.backgroundTasks.title}),(0,t.jsx)(S.C,{children:e.backgroundTasks.description})]}),0===m.length?(0,t.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:e.backgroundTasks.empty}):(0,t.jsx)("ul",{className:"space-y-2",children:m.map(s=>{var a,r;let i;return(0,t.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,t.jsxs)("div",{className:"flex items-start gap-2",children:["running"===s.status&&(0,t.jsx)(N.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===s.status&&(0,t.jsx)(ts.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===s.status&&(0,t.jsx)(sz.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"font-medium",children:[e.backgroundTasks.kinds[s.kind],(0,t.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",e.backgroundTasks.status[s.status]]})]}),s.subject&&(0,t.jsx)("div",{className:"break-words text-muted-foreground",children:s.subject}),s.progress&&s.progress.total>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,t.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(s.progress.done/s.progress.total*100)}%`}})}),(0,t.jsxs)("div",{className:"text-xs text-muted-foreground",children:[e.backgroundTasks.progress.replace("{done}",String(s.progress.done)).replace("{total}",String(s.progress.total)),s.progress.failed>0&&` \xb7 ${e.backgroundTasks.failedCount.replace("{count}",String(s.progress.failed))}`]})]}),s.error&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:(t=>{if(!t)return null;let s=e.backgroundTasks.errors[t]??e.errors[t];return"string"==typeof s?s:t})(s.error)}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:e.backgroundTasks.startedAt.replace("{time}",(0,ed.r)(s.startedAt,"HH:mm:ss",n))}),(0,t.jsx)("span",{children:e.backgroundTasks.elapsed.replace("{time}",(a=s.startedAt,r=s.finishedAt,i=Math.max(0,Math.round(((r?Date.parse(r):p)-Date.parse(a))/1e3)),`${Math.floor(i/60)}:${String(i%60).padStart(2,"0")}`))}),s.link&&(0,t.jsx)(O.default,{href:s.link,className:"text-primary hover:underline",onClick:()=>d(!1),children:e.backgroundTasks.view})]})]})]})},s.id)})}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.backgroundTasks.retentionHint}),f&&(0,t.jsx)(k.f,{variant:"ghost",size:"sm",onClick:j,children:e.backgroundTasks.clearFinished})]})]})})]})}var sM=e.i(145447);function sL(){let{t:e}=(0,a.b)(),r=(0,sM.f)(),[i,n]=(0,s.useState)(!1),l=r?function(e){let t=/\bChrome\/(\d+)\./.exec(e);if(!t)return null;let s=Number(t[1]);return s>=111?null:{kind:/; wv\)/.test(e)||e.includes("WrongNotebookAndroid/")?"webview":"browser",version:s}}(navigator.userAgent):null;if(!l||i)return null;let c="webview"===l.kind?e.browserSupport.outdatedWebView:e.browserSupport.outdatedBrowser;return(0,t.jsxs)("div",{role:"alert","data-testid":"outdated-browser-notice",className:"flex items-start gap-3 border-b border-amber-300 bg-amber-100 px-4 py-2 text-sm text-amber-900",children:[(0,t.jsx)("p",{className:"flex-1",children:c.replace("{version}",String(l.version))}),(0,t.jsx)("button",{type:"button",onClick:()=>n(!0),className:"shrink-0 font-medium underline",children:e.common.close})]})}let sR={success:{icon:ts.f,className:"text-success"},error:{icon:sz.f,className:"text-destructive"},warning:{icon:X.f,className:"text-warning"},info:{icon:et,className:"text-primary"}};function s$(){let{t:e}=(0,a.b)(),[r,i]=(0,s.useState)([]),[n,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>(0,$.M)(e=>{i(e.toasts),l(e.confirm)}),[]),(0,t.jsxs)(t.Fragment,{children:[(0,t.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:r.map(s=>{let{icon:a,className:r}=sR[s.type];return(0,t.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,t.jsx)(a,{className:(0,J.f)("mt-0.5 h-4 w-4 shrink-0",r)}),(0,t.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:s.message}),(0,t.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,$.p)(s.id),"aria-label":e.common.close,children:(0,t.jsx)(sc.X,{className:"h-3.5 w-3.5"})})]},s.id)})}),(0,t.jsx)(S.N,{open:!!n,onOpenChange:e=>{e||n?.resolve(!1)},children:(0,t.jsxs)(S.d,{className:"sm:max-w-md",children:[(0,t.jsxs)(S.s,{children:[(0,t.jsxs)(S.F,{className:"flex items-center gap-2",children:[n?.destructive&&(0,t.jsx)(X.f,{className:"h-5 w-5 text-destructive"}),n?.title||e.common.confirmTitle]}),(0,t.jsx)(S.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:n?.message})]}),(0,t.jsxs)(S.c,{className:"gap-2",children:[(0,t.jsx)(k.f,{variant:"outline",onClick:()=>n?.resolve(!1),children:n?.cancelText||e.common.cancel}),(0,t.jsx)(k.f,{variant:n?.destructive?"destructive":"default",onClick:()=>n?.resolve(!0),autoFocus:!0,children:n?.confirmText||e.common.confirm})]})]})})]})}function sI(){return(0,s.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(e=>{l.V.warn("[PWA]","Service worker registration failed",{error:String(e)})})},[]),null}e.s(["Providers",0,function({children:e,timeZone:i}){return(0,s.useEffect)(()=>(0,l.m)(),[]),(0,t.jsx)(r.SessionProvider,{children:(0,t.jsx)(y,{children:(0,t.jsx)(a.w,{children:(0,t.jsxs)(v.n,{initialTimeZone:i,children:[(0,t.jsx)(sL,{}),(0,t.jsx)(sT,{children:e}),(0,t.jsx)(sF,{}),(0,t.jsx)(V,{}),(0,t.jsx)(s$,{}),(0,t.jsx)(sI,{})]})})})})}],1661)}]);