wrong-notebook 2026.10.30-4 → 2026.10.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/admin/page.js.nft.json +1 -1
- package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
- package/.next/server/app/admin/user/[id]/page.js.nft.json +1 -1
- package/.next/server/app/admin/user/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tts/[id]/route.js.nft.json +1 -1
- package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
- package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/exams/[id]/page.js.nft.json +1 -1
- package/.next/server/app/exams/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/exams/[id]/print/page.js.nft.json +1 -1
- package/.next/server/app/exams/[id]/print/page_client-reference-manifest.js +1 -1
- package/.next/server/app/exams/page.js.nft.json +1 -1
- package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login/page.js.nft.json +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
- package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
- package/.next/server/app/notebooks/[id]/page.js.nft.json +1 -1
- package/.next/server/app/notebooks/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/notebooks/page.js.nft.json +1 -1
- package/.next/server/app/notebooks/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/practice/page.js.nft.json +1 -1
- package/.next/server/app/practice/page_client-reference-manifest.js +1 -1
- package/.next/server/app/print-preview/page.js.nft.json +1 -1
- package/.next/server/app/print-preview/page_client-reference-manifest.js +1 -1
- package/.next/server/app/register/page.js.nft.json +1 -1
- package/.next/server/app/register/page_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page.js.nft.json +1 -1
- package/.next/server/app/review/page_client-reference-manifest.js +1 -1
- package/.next/server/app/setup/page.js.nft.json +1 -1
- package/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/.next/server/app/stats/page.js.nft.json +1 -1
- package/.next/server/app/stats/page_client-reference-manifest.js +1 -1
- package/.next/server/app/tags/page.js.nft.json +1 -1
- package/.next/server/app/tags/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/_1j8kqz21_i728._.js +1 -1
- package/.next/server/chunks/ssr/_00np6xqvkg6u-._.js +1 -1
- package/.next/server/chunks/ssr/src_components_providers_tsx_09kw-mv3nb6xs._.js +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/pages/500.html +1 -1
- package/.next/server/preview-props.json +3 -3
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{2ctc1xbp8lz8e.js → 00o1s_nir_tbc.js} +2 -2
- package/.next/static/chunks/2r4ddp7izc9sh.js +1 -0
- package/package.json +1 -1
- package/prisma/seed.db +0 -0
- package/.next/static/chunks/1l46v858ieavc.js +0 -1
- /package/.next/static/{X3NzguYsDSEVWQKJ6r_e7 → 4KSCavDaw8kyhSyGiE86P}/_buildManifest.js +0 -0
- /package/.next/static/{X3NzguYsDSEVWQKJ6r_e7 → 4KSCavDaw8kyhSyGiE86P}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{X3NzguYsDSEVWQKJ6r_e7 → 4KSCavDaw8kyhSyGiE86P}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,1661,e=>{"use strict";var s=e.i(843476),t=e.i(111110),a=e.i(217255),i=e.i(215519),r=e.i(325164),n=e.i(522016),l=e.i(618566),o=e.i(217923),c=e.i(810980),d=e.i(551804),m=e.i(178583),u=e.i(292270),p=e.i(475254);let h=(0,p.f)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),x=(0,p.f)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);var g=e.i(271645);let f=(0,p.f)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),j=(0,p.f)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),v=(0,p.f)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var y=e.i(763639),b=e.i(531278);let w=(0,p.f)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),N=(0,p.f)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var k=e.i(284614),S=e.i(733060),C=e.i(519455),T=e.i(776639),A=e.i(677572),E=e.i(306831),_=e.i(487486),z=e.i(699375),D=e.i(793479),M=e.i(110204),F=e.i(975157);let R=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("div",{className:"relative w-full overflow-auto",children:(0,s.jsx)("table",{ref:a,className:(0,F.f)("w-full caption-bottom text-sm",e),...t})}));R.displayName="Table";let I=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("thead",{ref:a,className:(0,F.f)("[&_tr]:border-b",e),...t}));I.displayName="TableHeader";let L=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tbody",{ref:a,className:(0,F.f)("[&_tr:last-child]:border-0",e),...t}));L.displayName="TableBody",(g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tfoot",{ref:a,className:(0,F.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}))).displayName="TableFooter";let $=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tr",{ref:a,className:(0,F.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));$.displayName="TableRow";let U=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("th",{ref:a,className:(0,F.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));U.displayName="TableHead";let P=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("td",{ref:a,className:(0,F.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));P.displayName="TableCell",(g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("caption",{ref:a,className:(0,F.f)("mt-4 text-sm text-muted-foreground",e),...t}))).displayName="TableCaption";var q=e.i(727612);let O=(0,p.f)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var K=e.i(269638),B=e.i(41931),H=e.i(294114),V=e.i(201276),Y=e.i(303163);function W(){let{timeZone:e}=(0,i.M)(),{data:r}=(0,a.useSession)(),{t:n}=(0,t.b)(),[l,o]=(0,g.useState)([]),[c,d]=(0,g.useState)(!0),[m,u]=(0,g.useState)(!1),[p,h]=(0,g.useState)(!1),[x,f]=(0,g.useState)("0"),[j,v]=(0,g.useState)(!1),y=(0,g.useCallback)(async()=>{d(!0);try{let e=await B.f.get("/api/admin/users");o(e)}catch(e){V.f.error("[UserManagement]","Failed to fetch users",{error:e})}finally{d(!1)}},[]),w=(0,g.useCallback)(async()=>{try{let e=await B.f.get("/api/settings");u(!0===e.allowRegistration),f(String(e.aiDailyLimit??0))}catch(e){V.f.error("[UserManagement]","Failed to fetch config",{error:e})}},[]);(0,g.useEffect)(()=>{y(),w()},[y,w]);let N=async e=>{h(!0);try{await B.f.post("/api/settings",{allowRegistration:e}),u(e)}catch(e){V.f.error("[UserManagement]","Failed to update registration setting",{error:e}),H.c.error(n.common.error)}finally{h(!1)}},k=Number(x),S=""!==x.trim()&&Number.isInteger(k)&&k>=0,T=async()=>{if(S){v(!0);try{await B.f.post("/api/settings",{aiDailyLimit:k}),H.c.success(n.admin.aiDailyLimitSaved)}catch(e){V.f.error("[UserManagement]","Failed to update AI daily limit",{error:e}),H.c.error(n.common.error)}finally{v(!1)}}},A=async e=>{let s=e.isActive?n.admin.confirmDisable:n.admin.confirmEnable;if(await (0,H.u)(s))try{await B.f.patch(`/api/admin/users/${e.id}`,{isActive:!e.isActive}),y()}catch(e){V.f.error("[UserManagement]","Failed to update user status",{error:e}),H.c.error(n.common.error)}},F=async e=>{if(await (0,H.u)(n.admin.confirmDelete,{destructive:!0}))try{await B.f.delete(`/api/admin/users/${e.id}`),y()}catch(s){V.f.error("[UserManagement]","Failed to delete user",{error:s});let e=(0,Y.d)(s)||n.common.error;H.c.error(e)}};return c?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(b.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(M.f,{className:"text-base",children:n.admin?.allowRegistration||"Allow New Registrations"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:n.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,s.jsx)(b.f,{className:"h-4 w-4 animate-spin"}),(0,s.jsx)(z.f,{checked:m,onCheckedChange:N,disabled:p})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 p-4 border rounded-lg bg-muted/30 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(M.f,{htmlFor:"ai-daily-limit",className:"text-base",children:n.admin.aiDailyLimit}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:n.admin.aiDailyLimitDesc})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(D.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:x,onChange:e=>f(e.target.value),"aria-invalid":!S,className:"w-24"}),(0,s.jsxs)(C.f,{size:"sm",onClick:T,disabled:j||!S,children:[j&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.common.save]})]})]}),(0,s.jsx)("div",{className:"sm:hidden space-y-3",children:l.map(t=>(0,s.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium",children:t.name||"N/A"}),(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:t.email})]}),(0,s.jsx)(_.f,{variant:"admin"===t.role?"default":"secondary",children:"admin"===t.role?n.admin.admin:n.admin.user})]}),(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsxs)("div",{className:"text-muted-foreground",children:[n.admin.errors,": ",t._count.errorItems," | ",n.admin.practiceCount,": ",t._count.practiceRecords," | ",n.admin.aiUsageToday,": ",t.aiUsageToday]}),(0,s.jsx)(_.f,{variant:t.isActive?"default":"destructive",className:"text-xs",children:t.isActive?n.admin.active:n.admin.disabled})]}),(0,s.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,E.r)(t.createdAt,"yyyy-MM-dd",e)}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>A(t),disabled:t.id===r?.user?.id,children:t.isActive?(0,s.jsx)(O,{className:"h-4 w-4 text-orange-500"}):(0,s.jsx)(K.f,{className:"h-4 w-4 text-green-500"})}),(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>F(t),disabled:t.id===r?.user?.id,children:(0,s.jsx)(q.f,{className:"h-4 w-4 text-destructive"})})]})]})]},t.id))}),(0,s.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,s.jsxs)(R,{children:[(0,s.jsx)(I,{children:(0,s.jsxs)($,{children:[(0,s.jsx)(U,{children:n.admin.nameEmail}),(0,s.jsx)(U,{children:n.admin.role}),(0,s.jsx)(U,{children:n.admin.stats}),(0,s.jsx)(U,{children:n.admin.createdAt}),(0,s.jsx)(U,{children:n.admin.status}),(0,s.jsx)(U,{className:"text-right",children:n.admin.actions})]})}),(0,s.jsx)(L,{children:l.map(t=>(0,s.jsxs)($,{children:[(0,s.jsxs)(P,{children:[(0,s.jsx)("div",{className:"font-medium",children:t.name||"N/A"}),(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:t.email})]}),(0,s.jsx)(P,{children:(0,s.jsx)(_.f,{variant:"admin"===t.role?"default":"secondary",children:"admin"===t.role?n.admin.admin:n.admin.user})}),(0,s.jsxs)(P,{children:[(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.errors,": ",t._count.errorItems]}),(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.practiceCount,": ",t._count.practiceRecords]}),(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.aiUsageToday,": ",t.aiUsageToday]})]}),(0,s.jsx)(P,{children:(0,E.r)(t.createdAt,"yyyy-MM-dd",e)}),(0,s.jsx)(P,{children:(0,s.jsx)(_.f,{variant:t.isActive?"default":"destructive",children:t.isActive?n.admin.active:n.admin.disabled})}),(0,s.jsxs)(P,{className:"text-right space-x-2",children:[(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>A(t),disabled:t.id===r?.user?.id,title:t.isActive?n.admin.disable:n.admin.enable,children:t.isActive?(0,s.jsx)(O,{className:"h-4 w-4 text-orange-500"}):(0,s.jsx)(K.f,{className:"h-4 w-4 text-green-500"})}),(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>F(t),disabled:t.id===r?.user?.id,title:n.admin.delete,children:(0,s.jsx)(q.f,{className:"h-4 w-4 text-destructive"})})]})]},t.id))})]})})]})}var J=e.i(778917);let X=(0,p.f)("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),G=(0,p.f)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),Z=(0,p.f)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Q(){return window.WrongNotebookAndroid??null}let ee=()=>()=>void 0;function es(){let{t:e}=(0,t.b)(),a=(0,g.useSyncExternalStore)(ee,Q,()=>null);return a?a.isStandalone?.()?(0,s.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:e.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsxs)("span",{className:"break-all",children:[e.settings?.about?.androidServer||"Server",": ",a.getServerUrl()]}),(0,s.jsxs)(C.f,{variant:"outline",className:"gap-2",onClick:()=>a.changeServer(),children:[(0,s.jsx)(Z,{className:"h-4 w-4"}),e.settings?.about?.changeServer||"Change server"]})]}):null}let et="https://github.com/margrop/wrong-notebook";function ea(){let{t:e}=(0,t.b)(),[a,i]=(0,g.useState)("");(0,g.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>i(e.version)).catch(()=>{})},[]);let r=[{href:et,icon:X,label:e.settings?.about?.github||"GitHub Repository"},{href:`${et}/releases`,icon:G,label:e.settings?.about?.releaseNotes||"Release Notes"},{href:`${et}/issues`,icon:w,label:e.settings?.about?.feedback||"Feedback"}];return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-6 py-8 text-center bg-muted/30 rounded-lg border",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-2xl font-bold",children:e.app?.title||"Smart Error Notebook"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:e.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground border px-4 py-2 rounded-full bg-background",children:[(0,s.jsx)(v,{className:"h-4 w-4"}),(0,s.jsxs)("span",{children:[e.settings?.about?.version||"Version",": v",a||"unknown"]})]}),(0,s.jsx)(es,{}),(0,s.jsx)("div",{className:"flex flex-col sm:flex-row flex-wrap justify-center gap-4 w-full sm:w-auto px-4 sm:px-0",children:r.map(({href:e,icon:t,label:a})=>(0,s.jsx)(C.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,s.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[(0,s.jsx)(t,{className:"h-4 w-4"}),a,(0,s.jsx)(J.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},e))}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:e.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var ei=e.i(37038),er=e.i(967489);let en={name:"",email:"",educationStage:"",enrollmentYear:"",password:""};function el(){let{t:e}=(0,t.b)(),[a,i]=(0,g.useState)(en),[r,n]=(0,g.useState)(""),[l,o]=(0,g.useState)(!0),[c,d]=(0,g.useState)(!1),m=(0,g.useCallback)(async()=>{try{let e=await B.f.get("/api/user");i({name:e.name||"",email:e.email||"",educationStage:e.educationStage||"",enrollmentYear:e.enrollmentYear||"",password:""})}catch(e){V.f.error("[AccountSettings]","Failed to fetch profile",{error:e})}finally{o(!1)}},[]);(0,g.useEffect)(()=>{m()},[m]);let u=async()=>{if(a.password&&a.password!==r)return void H.c.error(e.settings?.messages?.passwordMismatch||"Passwords do not match");d(!0);try{let s={name:a.name,email:a.email,educationStage:a.educationStage};a.enrollmentYear&&(s.enrollmentYear=parseInt(a.enrollmentYear.toString())),a.password&&(s.password=a.password),await B.f.patch("/api/user",s),H.c.success(e.settings?.messages?.profileUpdated||"Profile updated"),i(e=>({...e,password:""})),n(""),window.location.reload()}catch(s){V.f.error("[AccountSettings]","Failed to update profile",{error:(0,Y.d)(s)??(0,Y.Z)(s)}),H.c.error((0,Y.d)(s)||e.settings?.messages?.updateFailed||"Update failed")}finally{d(!1)}};return l?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(b.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.name||"Name"}),(0,s.jsx)(D.f,{value:a.name||"",onChange:e=>i({...a,name:e.target.value})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.email||"Email"}),(0,s.jsx)(D.f,{value:a.email||"",onChange:e=>i({...a,email:e.target.value}),type:"email"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.educationStage||"Education Stage"}),(0,s.jsxs)(er.d,{value:a.educationStage||"",onValueChange:e=>i({...a,educationStage:e}),children:[(0,s.jsx)(er.P,{children:(0,s.jsx)(er.U,{placeholder:e.auth?.selectStage||"Select Stage"})}),(0,s.jsxs)(er.r,{children:[(0,s.jsx)(er.T,{value:"primary",children:e.auth?.primary||"Primary School"}),(0,s.jsx)(er.T,{value:"junior_high",children:e.auth?.juniorHigh||"Junior High"}),(0,s.jsx)(er.T,{value:"senior_high",children:e.auth?.seniorHigh||"Senior High"}),(0,s.jsx)(er.T,{value:"university",children:e.auth?.university||"University"})]})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.enrollmentYear||"Enrollment Year"}),(0,s.jsx)(D.f,{type:"number",value:a.enrollmentYear||"",onChange:e=>i({...a,enrollmentYear:e.target.value}),placeholder:"YYYY"})]})]}),(0,s.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,s.jsx)(ei.f,{value:a.password,onChange:e=>i({...a,password:e.target.value}),placeholder:"******",minLength:6})]}),a.password&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.confirmPassword||"Confirm Password"}),(0,s.jsx)(ei.f,{value:r,onChange:e=>n(e.target.value),placeholder:"******",minLength:6})]})]}),(0,s.jsxs)(C.f,{onClick:u,disabled:c,className:"w-full",children:[c&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.settings?.account?.update||"Update Profile"]})]})}var eo=e.i(10038),ec=e.i(16715);let ed={info:{card:"border-blue-200 bg-blue-50",title:"text-blue-900 font-bold",desc:"text-blue-800 font-medium",button:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300"},danger:{card:"border-red-200 bg-red-50",title:"text-red-700 font-medium",desc:"text-red-600",button:""},critical:{card:"border-red-600/50 bg-red-100/50",title:"text-red-900 font-bold",desc:"text-red-800 font-medium",button:"bg-red-700 hover:bg-red-800"}};function em({title:e,description:t,tone:a,busy:i,icon:r,onClick:n}){let l=ed[a];return(0,s.jsxs)("div",{className:`p-4 border rounded-lg ${l.card}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:`text-sm flex items-center gap-2 ${l.title}`,children:e}),(0,s.jsx)(C.f,{variant:"info"===a?"outline":"destructive",size:"sm",onClick:n,disabled:i,className:l.button,children:i?(0,s.jsx)(b.f,{className:"h-4 w-4 animate-spin"}):r})]}),(0,s.jsx)("p",{className:`text-xs mt-2 ${l.desc}`,children:t})]})}function eu({isAdmin:e}){let{t:a}=(0,t.b)(),[i,r]=(0,g.useState)(null),n=async(e,s,t,a)=>{r(e);try{H.c.success(await s()),a&&window.location.reload()}catch(s){V.f.error("[DangerZoneSettings]",`${e} failed`,{error:s}),H.c.error(t)}finally{r(null)}},l=a.settings?.clearSuccess||"Success",o=a.settings?.clearError||"Failed",c=async()=>{await (0,H.u)(a.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await n("migrateTags",async()=>{let e=await B.f.post("/api/admin/migrate-tags",{});return`${l}: ${e.count||0} tags migrated.`},a.settings?.clearError||"Failed to migrate tags",!1)},d=async()=>{await (0,H.u)(a.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await n("clearPractice",async()=>(await B.f.delete("/api/stats/practice/clear"),l),o,!0)},m=async()=>{await (0,H.u)(a.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await n("clearErrors",async()=>(await B.f.delete("/api/error-items/clear"),l),o,!0)},u=async()=>{if(!await (0,H.u)(a.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let e=prompt(a.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==e){null!==e&&H.c.error(a.common?.error||"Confirmation failed");return}await n("systemReset",async()=>(await B.f.post("/api/admin/system-reset",{}),a.settings?.clearSuccess||"Success - System Reset Complete"),a.settings?.clearError||"Failed to reset system",!0)};return(0,s.jsxs)(s.Fragment,{children:[e&&(0,s.jsx)(em,{tone:"info",title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ec.f,{className:"h-4 w-4"}),a.settings?.migrateTags||"Migrate Tags"]}),description:a.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===i,icon:(0,s.jsx)(ec.f,{className:"h-4 w-4"}),onClick:c}),(0,s.jsx)(em,{tone:"danger",title:a.settings?.clearData||"Clear Practice Data",description:a.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===i,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:d}),(0,s.jsx)(em,{tone:"danger",title:a.settings?.clearErrorData||"Clear Error Data",description:a.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===i,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:m}),e&&(0,s.jsx)(em,{tone:"critical",title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f,{className:"h-4 w-4"}),a.settings?.systemReset||"System Initialization"]}),description:a.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===i,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:u})]})}var ep=e.i(595468),eh=e.i(440160);let ex=(0,p.f)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);async function eg(e,s){let t=await fetch(e);if(!t.ok)throw Error((await t.json().catch(()=>({}))).message||"Export failed");let a=await t.blob(),i=window.URL.createObjectURL(a),r=document.createElement("a");r.href=i;let n=t.headers.get("Content-Disposition")?.match(/filename="(.+)"/);r.download=n?n[1]:s,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(i)}function ef({isAdmin:e}){let{t:a}=(0,t.b)(),[i,r]=(0,g.useState)(!1),[n,l]=(0,g.useState)(!1),[o,c]=(0,g.useState)(null),d=async e=>{if(!e||await (0,H.u)(a.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){r(!0);try{await eg(e?"/api/export?all=true":"/api/export",e?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),H.c.success(a.settings?.exportSuccess||"Export successful")}catch(s){V.f.error("[DataBackupSettings]",e?"Export all failed":"Export failed",{error:s}),H.c.error(a.settings?.exportFailed||"Export failed")}finally{r(!1)}}},m=async e=>{if(!o)return;let s=e?a.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":a.settings?.importConfirm||"Are you sure you want to import?";if(await (0,H.u)(s)){l(!0);try{let s=JSON.parse(await o.text()),{stats:t}=await B.f.post(e?"/api/import?all=true":"/api/import",s);H.c.success((a.settings?.importResultDesc||"Imported {subjects} notebooks, {tags} tags, {items} error items, {schedules} review schedules, {records} practice records, {papers} exam papers and {voices} cloud voice clips.").replace("{subjects}",String(t.subjectsCreated)).replace("{tags}",String(t.tagsCreated)).replace("{items}",String(t.errorItemsCreated)).replace("{schedules}",String(t.reviewSchedulesCreated)).replace("{records}",String(t.practiceRecordsCreated)).replace("{papers}",String(t.examPapersCreated??0)).replace("{voices}",String(t.ttsSpeechesImported??0)).replace("{duplicates}",String(t.duplicateErrorItems??0))),c(null),window.location.reload()}catch(s){V.f.error("[DataBackupSettings]",e?"Import all failed":"Import failed",{error:s}),H.c.error(a.settings?.importFailed||"Import failed")}finally{l(!1)}}},u=(e,t)=>e?(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}):t;return(0,s.jsxs)("div",{className:"p-4 border border-blue-200 rounded-lg bg-blue-50",children:[(0,s.jsx)("h4",{className:"text-sm font-bold text-blue-900 mb-3",children:a.settings?.dataManagement||"Data Management"}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm text-blue-800 font-medium",children:a.settings?.exportData||"Export Data"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>d(!1),disabled:i,className:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300",children:[u(i,(0,s.jsx)(eh.f,{className:"mr-2 h-4 w-4"})),a.settings?.exportData||"Export"]}),e&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:i,className:"bg-orange-100 hover:bg-orange-200 text-orange-900 border-orange-300",children:[u(i,(0,s.jsx)(eh.f,{className:"mr-2 h-4 w-4"})),a.settings?.exportAllData||"Export All"]})]})]}),(0,s.jsx)("p",{className:"text-xs text-blue-700",children:a.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm text-blue-800 font-medium",children:a.settings?.importData||"Import Data"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"file",accept:".json",onChange:e=>c(e.target.files?.[0]??o),className:"hidden",id:"import-file-input",disabled:n}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:n,className:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300",children:[u(n,(0,s.jsx)(ex,{className:"mr-2 h-4 w-4"})),o?.name||a.settings?.selectFile||"Select File"]}),o&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>m(!1),disabled:n,className:"bg-green-100 hover:bg-green-200 text-green-900 border-green-300",children:[u(n,(0,s.jsx)(ep.f,{className:"mr-2 h-4 w-4"})),a.settings?.importData||"Import"]}),o&&e&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:n,className:"bg-orange-100 hover:bg-orange-200 text-orange-900 border-orange-300",children:[u(n,(0,s.jsx)(ep.f,{className:"mr-2 h-4 w-4"})),a.settings?.importAllData||"Import All"]})]})]}),(0,s.jsx)("p",{className:"text-xs text-blue-700",children:a.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}var ej=e.i(307364);function ev({field:e,label:a,description:i}){let{t:r}=(0,t.b)(),[n,l]=(0,g.useState)(!1),[o,c]=(0,g.useState)(!1),[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)(null),h=`preference-${e}`;(0,g.useEffect)(()=>{B.f.get("/api/user").then(s=>l(!!s[e])).catch(()=>void 0).finally(()=>c(!0))},[e]);let x=async s=>{l(s),m(!0);try{await B.f.patch("/api/user",{[e]:s}),p(r.importFlow.preferenceSaved)}catch(t){l(!s),p(r.importFlow.preferenceSaveFailed),V.f.error("[Settings]","Failed to save user preference",{field:e,error:t instanceof Error?t.message:String(t)})}finally{m(!1)}};return(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,s.jsx)(M.f,{htmlFor:h,children:a}),(0,s.jsx)(z.f,{id:h,checked:n,onCheckedChange:x,disabled:!o||d})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),u&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:u})]})}function ey(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"enableGeogebra",label:e.importFlow.enableGeogebra,description:e.importFlow.enableGeogebraDesc})}function eb(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"confirmBeforeImport",label:e.importFlow.confirmBeforeImport,description:e.importFlow.confirmBeforeImportDesc})}var ew=e.i(905110);function eN(){let{t:e}=(0,t.b)(),[a,i]=(0,g.useState)(String(ew.z)),[r,n]=(0,g.useState)(null),[l,o]=(0,g.useState)(!0),[c,d]=(0,g.useState)(!1),[m,u]=(0,g.useState)(null),p=Number(a),h=""!==a.trim()&&Number.isInteger(p)&&p>=ew.P&&p<=ew.o,x=(0,g.useCallback)(async()=>{o(!0),u(null);try{let e=(await B.f.get("/api/user")).masteryThreshold??ew.z;i(String(e)),n(e)}catch(s){u(e.mastery.thresholdLoadFailed),V.f.error("[Settings]","加载已掌握阈值失败",{error:s instanceof Error?s.message:String(s)})}finally{o(!1)}},[e.mastery.thresholdLoadFailed]);(0,g.useEffect)(()=>{x()},[x]);let f=async()=>{if(h&&null!==r){d(!0),u(null);try{let s=(await B.f.patch("/api/user",{masteryThreshold:p})).masteryThreshold??p;n(s),i(String(s)),u(e.importFlow.preferenceSaved)}catch(s){u(e.importFlow.preferenceSaveFailed),V.f.error("[Settings]","保存已掌握阈值失败",{error:s instanceof Error?s.message:String(s)})}finally{d(!1)}}};return(0,s.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,s.jsx)(M.f,{htmlFor:"mastery-threshold",children:e.mastery.thresholdLabel}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(D.f,{id:"mastery-threshold",type:"number",min:ew.P,max:ew.o,step:1,value:a,onChange:e=>{i(e.target.value),u(null)},disabled:l||c||null===r,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,s.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,s.jsxs)(C.f,{type:"button",size:"sm",variant:"outline",onClick:f,disabled:l||c||null===r||!h||p===r,children:[(l||c)&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.importFlow.saveThreshold]}),!l&&null===r&&(0,s.jsx)(C.f,{type:"button",size:"sm",variant:"outline",onClick:x,children:e.importFlow.retryLoad})]}),(0,s.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:e.mastery.thresholdDescription}),null!==r&&!h&&(0,s.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:e.mastery.thresholdInvalid}),m&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:m})]})}function ek(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"enableSvgAnimation",label:e.importFlow.enableSvgAnimation,description:e.importFlow.enableSvgAnimationDesc})}function eS({value:e,onChange:a,disabled:i}){let{t:r}=(0,t.b)();return(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsx)(M.f,{htmlFor:"app-time-zone",children:r.settings.general.timeZoneLabel}),(0,s.jsx)(D.f,{id:"app-time-zone",value:e,onChange:e=>a(e.target.value),disabled:i,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,s.jsx)("datalist",{id:"app-time-zones",children:["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Europe/London","America/New_York","America/Los_Angeles","UTC"].map(e=>(0,s.jsx)("option",{value:e},e))}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:r.settings.general.timeZoneDesc})]})}function eC({config:e,setConfig:a,isAdmin:r,disabled:n}){let{t:l,language:o,setLanguage:c}=(0,t.b)(),{timeZone:d}=(0,i.M)(),m=e=>a(s=>({...s,timeouts:{...s.timeouts,analyze:1e3*e}}));return(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:l.settings?.language||"Language"}),(0,s.jsxs)(er.d,{value:o,onValueChange:e=>c(e),children:[(0,s.jsx)(er.P,{children:(0,s.jsx)(er.U,{})}),(0,s.jsxs)(er.r,{children:[(0,s.jsx)(er.T,{value:"zh",children:"中文 (Chinese)"}),(0,s.jsx)(er.T,{value:"en",children:"English"})]})]})]}),(0,s.jsx)(eS,{value:e.timeZone??d,onChange:e=>a(s=>({...s,timeZone:e})),disabled:!r||n}),r&&(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsx)(M.f,{children:l.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,s.jsx)(D.f,{type:"number",value:e.timeouts?.analyze?e.timeouts.analyze/1e3:"",onChange:e=>{let s=""===e.target.value?0:parseInt(e.target.value);m(isNaN(s)?0:s)},onBlur:()=>{let s=(e.timeouts?.analyze||0)/1e3,t=Math.min(600,Math.max(120,s));t!==s&&m(t)},min:120,max:600}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:l.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,s.jsx)(eb,{}),(0,s.jsx)(ek,{}),(0,s.jsx)(ey,{}),(0,s.jsx)(ej.f,{}),(0,s.jsx)(eN,{})]})}var eT=e.i(624687),eA=e.i(247167);let eE={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function e_(e,s={}){let t,a=eE[e],i=(t=eA.default.env.LOG_LEVEL?.toLowerCase())&&void 0!==eE[t]?eE[t]:eE.info;return(t,r)=>{let n,l;if(a<i)return;let o=new Date;"string"==typeof t?(n={},l=t):(n=t,l=r||"");{let t=JSON.stringify({level:e,time:o.toISOString(),...s,...n,msg:l});switch(e){case"error":case"fatal":console.error(t);break;case"warn":console.warn(t);break;default:console.log(t)}}}}(function e(s={}){return s.module,{trace:e_("trace",s),debug:e_("debug",s),info:e_("info",s),warn:e_("warn",s),error:e_("error",s),fatal:e_("fatal",s),child:t=>e({...s,...t}),box:(e,t,a="📋")=>{console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...s,title:e,..."string"==typeof t?{content:t}:t||{},msg:e}))},divider:(e="-")=>{}}})({env:"production"}).child({module:"ai:prompts"});let ez=`请参考《高思学校竞赛数学导引》(每讲分兴趣篇、拓展篇、超越篇,题目左侧标 1~5 颗星)的星级标准,结合题目所在年级评定难度:
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,1661,e=>{"use strict";var s=e.i(843476),t=e.i(111110),a=e.i(217255),r=e.i(215519),i=e.i(325164),n=e.i(522016),l=e.i(618566),o=e.i(217923),c=e.i(810980),d=e.i(551804),m=e.i(178583),u=e.i(292270),p=e.i(475254);let h=(0,p.f)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),x=(0,p.f)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);var g=e.i(271645);let f=(0,p.f)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),j=(0,p.f)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),v=(0,p.f)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var y=e.i(763639),b=e.i(531278);let w=(0,p.f)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),N=(0,p.f)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var k=e.i(284614),S=e.i(733060),C=e.i(519455),T=e.i(776639),A=e.i(677572),E=e.i(306831),_=e.i(487486),z=e.i(699375),D=e.i(793479),M=e.i(110204),F=e.i(975157);let R=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("div",{className:"relative w-full overflow-auto",children:(0,s.jsx)("table",{ref:a,className:(0,F.f)("w-full caption-bottom text-sm",e),...t})}));R.displayName="Table";let I=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("thead",{ref:a,className:(0,F.f)("[&_tr]:border-b",e),...t}));I.displayName="TableHeader";let L=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tbody",{ref:a,className:(0,F.f)("[&_tr:last-child]:border-0",e),...t}));L.displayName="TableBody",(g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tfoot",{ref:a,className:(0,F.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}))).displayName="TableFooter";let $=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("tr",{ref:a,className:(0,F.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));$.displayName="TableRow";let U=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("th",{ref:a,className:(0,F.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));U.displayName="TableHead";let P=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("td",{ref:a,className:(0,F.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));P.displayName="TableCell",(g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("caption",{ref:a,className:(0,F.f)("mt-4 text-sm text-muted-foreground",e),...t}))).displayName="TableCaption";var q=e.i(727612);let O=(0,p.f)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var K=e.i(269638),B=e.i(41931),H=e.i(294114),V=e.i(201276),Y=e.i(303163);function W(){let{timeZone:e}=(0,r.M)(),{data:i}=(0,a.useSession)(),{t:n}=(0,t.b)(),[l,o]=(0,g.useState)([]),[c,d]=(0,g.useState)(!0),[m,u]=(0,g.useState)(!1),[p,h]=(0,g.useState)(!1),[x,f]=(0,g.useState)("0"),[j,v]=(0,g.useState)(!1),y=(0,g.useCallback)(async()=>{d(!0);try{let e=await B.f.get("/api/admin/users");o(e)}catch(e){V.f.error("[UserManagement]","Failed to fetch users",{error:e})}finally{d(!1)}},[]),w=(0,g.useCallback)(async()=>{try{let e=await B.f.get("/api/settings");u(!0===e.allowRegistration),f(String(e.aiDailyLimit??0))}catch(e){V.f.error("[UserManagement]","Failed to fetch config",{error:e})}},[]);(0,g.useEffect)(()=>{y(),w()},[y,w]);let N=async e=>{h(!0);try{await B.f.post("/api/settings",{allowRegistration:e}),u(e)}catch(e){V.f.error("[UserManagement]","Failed to update registration setting",{error:e}),H.c.error(n.common.error)}finally{h(!1)}},k=Number(x),S=""!==x.trim()&&Number.isInteger(k)&&k>=0,T=async()=>{if(S){v(!0);try{await B.f.post("/api/settings",{aiDailyLimit:k}),H.c.success(n.admin.aiDailyLimitSaved)}catch(e){V.f.error("[UserManagement]","Failed to update AI daily limit",{error:e}),H.c.error(n.common.error)}finally{v(!1)}}},A=async e=>{let s=e.isActive?n.admin.confirmDisable:n.admin.confirmEnable;if(await (0,H.u)(s))try{await B.f.patch(`/api/admin/users/${e.id}`,{isActive:!e.isActive}),y()}catch(e){V.f.error("[UserManagement]","Failed to update user status",{error:e}),H.c.error(n.common.error)}},F=async e=>{if(await (0,H.u)(n.admin.confirmDelete,{destructive:!0}))try{await B.f.delete(`/api/admin/users/${e.id}`),y()}catch(s){V.f.error("[UserManagement]","Failed to delete user",{error:s});let e=(0,Y.d)(s)||n.common.error;H.c.error(e)}};return c?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(b.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(M.f,{className:"text-base",children:n.admin?.allowRegistration||"Allow New Registrations"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:n.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,s.jsx)(b.f,{className:"h-4 w-4 animate-spin"}),(0,s.jsx)(z.f,{checked:m,onCheckedChange:N,disabled:p})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 p-4 border rounded-lg bg-muted/30 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)(M.f,{htmlFor:"ai-daily-limit",className:"text-base",children:n.admin.aiDailyLimit}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:n.admin.aiDailyLimitDesc})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(D.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:x,onChange:e=>f(e.target.value),"aria-invalid":!S,className:"w-24"}),(0,s.jsxs)(C.f,{size:"sm",onClick:T,disabled:j||!S,children:[j&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.common.save]})]})]}),(0,s.jsx)("div",{className:"sm:hidden space-y-3",children:l.map(t=>(0,s.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"font-medium",children:t.name||"N/A"}),(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:t.email})]}),(0,s.jsx)(_.f,{variant:"admin"===t.role?"default":"secondary",children:"admin"===t.role?n.admin.admin:n.admin.user})]}),(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsxs)("div",{className:"text-muted-foreground",children:[n.admin.errors,": ",t._count.errorItems," | ",n.admin.practiceCount,": ",t._count.practiceRecords," | ",n.admin.aiUsageToday,": ",t.aiUsageToday]}),(0,s.jsx)(_.f,{variant:t.isActive?"default":"destructive",className:"text-xs",children:t.isActive?n.admin.active:n.admin.disabled})]}),(0,s.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,E.r)(t.createdAt,"yyyy-MM-dd",e)}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>A(t),disabled:t.id===i?.user?.id,children:t.isActive?(0,s.jsx)(O,{className:"h-4 w-4 text-orange-500"}):(0,s.jsx)(K.f,{className:"h-4 w-4 text-green-500"})}),(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>F(t),disabled:t.id===i?.user?.id,children:(0,s.jsx)(q.f,{className:"h-4 w-4 text-destructive"})})]})]})]},t.id))}),(0,s.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,s.jsxs)(R,{children:[(0,s.jsx)(I,{children:(0,s.jsxs)($,{children:[(0,s.jsx)(U,{children:n.admin.nameEmail}),(0,s.jsx)(U,{children:n.admin.role}),(0,s.jsx)(U,{children:n.admin.stats}),(0,s.jsx)(U,{children:n.admin.createdAt}),(0,s.jsx)(U,{children:n.admin.status}),(0,s.jsx)(U,{className:"text-right",children:n.admin.actions})]})}),(0,s.jsx)(L,{children:l.map(t=>(0,s.jsxs)($,{children:[(0,s.jsxs)(P,{children:[(0,s.jsx)("div",{className:"font-medium",children:t.name||"N/A"}),(0,s.jsx)("div",{className:"text-sm text-muted-foreground",children:t.email})]}),(0,s.jsx)(P,{children:(0,s.jsx)(_.f,{variant:"admin"===t.role?"default":"secondary",children:"admin"===t.role?n.admin.admin:n.admin.user})}),(0,s.jsxs)(P,{children:[(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.errors,": ",t._count.errorItems]}),(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.practiceCount,": ",t._count.practiceRecords]}),(0,s.jsxs)("div",{className:"text-sm",children:[n.admin.aiUsageToday,": ",t.aiUsageToday]})]}),(0,s.jsx)(P,{children:(0,E.r)(t.createdAt,"yyyy-MM-dd",e)}),(0,s.jsx)(P,{children:(0,s.jsx)(_.f,{variant:t.isActive?"default":"destructive",children:t.isActive?n.admin.active:n.admin.disabled})}),(0,s.jsxs)(P,{className:"text-right space-x-2",children:[(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>A(t),disabled:t.id===i?.user?.id,title:t.isActive?n.admin.disable:n.admin.enable,children:t.isActive?(0,s.jsx)(O,{className:"h-4 w-4 text-orange-500"}):(0,s.jsx)(K.f,{className:"h-4 w-4 text-green-500"})}),(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:()=>F(t),disabled:t.id===i?.user?.id,title:n.admin.delete,children:(0,s.jsx)(q.f,{className:"h-4 w-4 text-destructive"})})]})]},t.id))})]})})]})}var J=e.i(778917);let X=(0,p.f)("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]),G=(0,p.f)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),Z=(0,p.f)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function Q(){return window.WrongNotebookAndroid??null}let ee=()=>()=>void 0;function es(){let{t:e}=(0,t.b)(),a=(0,g.useSyncExternalStore)(ee,Q,()=>null);return a?a.isStandalone?.()?(0,s.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:e.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsxs)("span",{className:"break-all",children:[e.settings?.about?.androidServer||"Server",": ",a.getServerUrl()]}),(0,s.jsxs)(C.f,{variant:"outline",className:"gap-2",onClick:()=>a.changeServer(),children:[(0,s.jsx)(Z,{className:"h-4 w-4"}),e.settings?.about?.changeServer||"Change server"]})]}):null}let et="https://github.com/margrop/wrong-notebook";function ea(){let{t:e}=(0,t.b)(),[a,r]=(0,g.useState)("");(0,g.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>r(e.version)).catch(()=>{})},[]);let i=[{href:et,icon:X,label:e.settings?.about?.github||"GitHub Repository"},{href:`${et}/releases`,icon:G,label:e.settings?.about?.releaseNotes||"Release Notes"},{href:`${et}/issues`,icon:w,label:e.settings?.about?.feedback||"Feedback"}];return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-6 py-8 text-center bg-muted/30 rounded-lg border",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-2xl font-bold",children:e.app?.title||"Smart Error Notebook"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:e.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground border px-4 py-2 rounded-full bg-background",children:[(0,s.jsx)(v,{className:"h-4 w-4"}),(0,s.jsxs)("span",{children:[e.settings?.about?.version||"Version",": v",a||"unknown"]})]}),(0,s.jsx)(es,{}),(0,s.jsx)("div",{className:"flex flex-col sm:flex-row flex-wrap justify-center gap-4 w-full sm:w-auto px-4 sm:px-0",children:i.map(({href:e,icon:t,label:a})=>(0,s.jsx)(C.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,s.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[(0,s.jsx)(t,{className:"h-4 w-4"}),a,(0,s.jsx)(J.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},e))}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:e.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var er=e.i(37038),ei=e.i(967489);let en={name:"",email:"",educationStage:"",enrollmentYear:"",password:""};function el(){let{t:e}=(0,t.b)(),[a,r]=(0,g.useState)(en),[i,n]=(0,g.useState)(""),[l,o]=(0,g.useState)(!0),[c,d]=(0,g.useState)(!1),m=(0,g.useCallback)(async()=>{try{let e=await B.f.get("/api/user");r({name:e.name||"",email:e.email||"",educationStage:e.educationStage||"",enrollmentYear:e.enrollmentYear||"",password:""})}catch(e){V.f.error("[AccountSettings]","Failed to fetch profile",{error:e})}finally{o(!1)}},[]);(0,g.useEffect)(()=>{m()},[m]);let u=async()=>{if(a.password&&a.password!==i)return void H.c.error(e.settings?.messages?.passwordMismatch||"Passwords do not match");d(!0);try{let s={name:a.name,email:a.email,educationStage:a.educationStage};a.enrollmentYear&&(s.enrollmentYear=parseInt(a.enrollmentYear.toString())),a.password&&(s.password=a.password),await B.f.patch("/api/user",s),H.c.success(e.settings?.messages?.profileUpdated||"Profile updated"),r(e=>({...e,password:""})),n(""),window.location.reload()}catch(s){V.f.error("[AccountSettings]","Failed to update profile",{error:(0,Y.d)(s)??(0,Y.Z)(s)}),H.c.error((0,Y.d)(s)||e.settings?.messages?.updateFailed||"Update failed")}finally{d(!1)}};return l?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(b.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.name||"Name"}),(0,s.jsx)(D.f,{value:a.name||"",onChange:e=>r({...a,name:e.target.value})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.email||"Email"}),(0,s.jsx)(D.f,{value:a.email||"",onChange:e=>r({...a,email:e.target.value}),type:"email"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.educationStage||"Education Stage"}),(0,s.jsxs)(ei.d,{value:a.educationStage||"",onValueChange:e=>r({...a,educationStage:e}),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{placeholder:e.auth?.selectStage||"Select Stage"})}),(0,s.jsxs)(ei.r,{children:[(0,s.jsx)(ei.T,{value:"primary",children:e.auth?.primary||"Primary School"}),(0,s.jsx)(ei.T,{value:"junior_high",children:e.auth?.juniorHigh||"Junior High"}),(0,s.jsx)(ei.T,{value:"senior_high",children:e.auth?.seniorHigh||"Senior High"}),(0,s.jsx)(ei.T,{value:"university",children:e.auth?.university||"University"})]})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.enrollmentYear||"Enrollment Year"}),(0,s.jsx)(D.f,{type:"number",value:a.enrollmentYear||"",onChange:e=>r({...a,enrollmentYear:e.target.value}),placeholder:"YYYY"})]})]}),(0,s.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,s.jsx)(er.f,{value:a.password,onChange:e=>r({...a,password:e.target.value}),placeholder:"******",minLength:6})]}),a.password&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:e.auth?.confirmPassword||"Confirm Password"}),(0,s.jsx)(er.f,{value:i,onChange:e=>n(e.target.value),placeholder:"******",minLength:6})]})]}),(0,s.jsxs)(C.f,{onClick:u,disabled:c,className:"w-full",children:[c&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.settings?.account?.update||"Update Profile"]})]})}var eo=e.i(10038),ec=e.i(16715);let ed={info:{card:"border-blue-200 bg-blue-50",title:"text-blue-900 font-bold",desc:"text-blue-800 font-medium",button:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300"},danger:{card:"border-red-200 bg-red-50",title:"text-red-700 font-medium",desc:"text-red-600",button:""},critical:{card:"border-red-600/50 bg-red-100/50",title:"text-red-900 font-bold",desc:"text-red-800 font-medium",button:"bg-red-700 hover:bg-red-800"}};function em({title:e,description:t,tone:a,busy:r,icon:i,onClick:n}){let l=ed[a];return(0,s.jsxs)("div",{className:`p-4 border rounded-lg ${l.card}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:`text-sm flex items-center gap-2 ${l.title}`,children:e}),(0,s.jsx)(C.f,{variant:"info"===a?"outline":"destructive",size:"sm",onClick:n,disabled:r,className:l.button,children:r?(0,s.jsx)(b.f,{className:"h-4 w-4 animate-spin"}):i})]}),(0,s.jsx)("p",{className:`text-xs mt-2 ${l.desc}`,children:t})]})}function eu({isAdmin:e}){let{t:a}=(0,t.b)(),[r,i]=(0,g.useState)(null),n=async(e,s,t,a)=>{i(e);try{H.c.success(await s()),a&&window.location.reload()}catch(s){V.f.error("[DangerZoneSettings]",`${e} failed`,{error:s}),H.c.error(t)}finally{i(null)}},l=a.settings?.clearSuccess||"Success",o=a.settings?.clearError||"Failed",c=async()=>{await (0,H.u)(a.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await n("migrateTags",async()=>{let e=await B.f.post("/api/admin/migrate-tags",{});return`${l}: ${e.count||0} tags migrated.`},a.settings?.clearError||"Failed to migrate tags",!1)},d=async()=>{await (0,H.u)(a.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await n("clearPractice",async()=>(await B.f.delete("/api/stats/practice/clear"),l),o,!0)},m=async()=>{await (0,H.u)(a.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await n("clearErrors",async()=>(await B.f.delete("/api/error-items/clear"),l),o,!0)},u=async()=>{if(!await (0,H.u)(a.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let e=prompt(a.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==e){null!==e&&H.c.error(a.common?.error||"Confirmation failed");return}await n("systemReset",async()=>(await B.f.post("/api/admin/system-reset",{}),a.settings?.clearSuccess||"Success - System Reset Complete"),a.settings?.clearError||"Failed to reset system",!0)};return(0,s.jsxs)(s.Fragment,{children:[e&&(0,s.jsx)(em,{tone:"info",title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ec.f,{className:"h-4 w-4"}),a.settings?.migrateTags||"Migrate Tags"]}),description:a.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===r,icon:(0,s.jsx)(ec.f,{className:"h-4 w-4"}),onClick:c}),(0,s.jsx)(em,{tone:"danger",title:a.settings?.clearData||"Clear Practice Data",description:a.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===r,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:d}),(0,s.jsx)(em,{tone:"danger",title:a.settings?.clearErrorData||"Clear Error Data",description:a.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===r,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:m}),e&&(0,s.jsx)(em,{tone:"critical",title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f,{className:"h-4 w-4"}),a.settings?.systemReset||"System Initialization"]}),description:a.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===r,icon:(0,s.jsx)(q.f,{className:"h-4 w-4"}),onClick:u})]})}var ep=e.i(595468),eh=e.i(440160);let ex=(0,p.f)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);async function eg(e,s){let t=await fetch(e);if(!t.ok)throw Error((await t.json().catch(()=>({}))).message||"Export failed");let a=await t.blob(),r=window.URL.createObjectURL(a),i=document.createElement("a");i.href=r;let n=t.headers.get("Content-Disposition")?.match(/filename="(.+)"/);i.download=n?n[1]:s,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(r)}function ef({isAdmin:e}){let{t:a}=(0,t.b)(),[r,i]=(0,g.useState)(!1),[n,l]=(0,g.useState)(!1),[o,c]=(0,g.useState)(null),d=async e=>{if(!e||await (0,H.u)(a.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){i(!0);try{await eg(e?"/api/export?all=true":"/api/export",e?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),H.c.success(a.settings?.exportSuccess||"Export successful")}catch(s){V.f.error("[DataBackupSettings]",e?"Export all failed":"Export failed",{error:s}),H.c.error(a.settings?.exportFailed||"Export failed")}finally{i(!1)}}},m=async e=>{if(!o)return;let s=e?a.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":a.settings?.importConfirm||"Are you sure you want to import?";if(await (0,H.u)(s)){l(!0);try{let s=JSON.parse(await o.text()),{stats:t}=await B.f.post(e?"/api/import?all=true":"/api/import",s);H.c.success((a.settings?.importResultDesc||"Imported {subjects} notebooks, {tags} tags, {items} error items, {schedules} review schedules, {records} practice records, {papers} exam papers and {voices} cloud voice clips.").replace("{subjects}",String(t.subjectsCreated)).replace("{tags}",String(t.tagsCreated)).replace("{items}",String(t.errorItemsCreated)).replace("{schedules}",String(t.reviewSchedulesCreated)).replace("{records}",String(t.practiceRecordsCreated)).replace("{papers}",String(t.examPapersCreated??0)).replace("{voices}",String(t.ttsSpeechesImported??0)).replace("{duplicates}",String(t.duplicateErrorItems??0))),c(null),window.location.reload()}catch(s){V.f.error("[DataBackupSettings]",e?"Import all failed":"Import failed",{error:s}),H.c.error(a.settings?.importFailed||"Import failed")}finally{l(!1)}}},u=(e,t)=>e?(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}):t;return(0,s.jsxs)("div",{className:"p-4 border border-blue-200 rounded-lg bg-blue-50",children:[(0,s.jsx)("h4",{className:"text-sm font-bold text-blue-900 mb-3",children:a.settings?.dataManagement||"Data Management"}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm text-blue-800 font-medium",children:a.settings?.exportData||"Export Data"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>d(!1),disabled:r,className:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300",children:[u(r,(0,s.jsx)(eh.f,{className:"mr-2 h-4 w-4"})),a.settings?.exportData||"Export"]}),e&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:r,className:"bg-orange-100 hover:bg-orange-200 text-orange-900 border-orange-300",children:[u(r,(0,s.jsx)(eh.f,{className:"mr-2 h-4 w-4"})),a.settings?.exportAllData||"Export All"]})]})]}),(0,s.jsx)("p",{className:"text-xs text-blue-700",children:a.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm text-blue-800 font-medium",children:a.settings?.importData||"Import Data"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"file",accept:".json",onChange:e=>c(e.target.files?.[0]??o),className:"hidden",id:"import-file-input",disabled:n}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:n,className:"bg-blue-100 hover:bg-blue-200 text-blue-900 border-blue-300",children:[u(n,(0,s.jsx)(ex,{className:"mr-2 h-4 w-4"})),o?.name||a.settings?.selectFile||"Select File"]}),o&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>m(!1),disabled:n,className:"bg-green-100 hover:bg-green-200 text-green-900 border-green-300",children:[u(n,(0,s.jsx)(ep.f,{className:"mr-2 h-4 w-4"})),a.settings?.importData||"Import"]}),o&&e&&(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:n,className:"bg-orange-100 hover:bg-orange-200 text-orange-900 border-orange-300",children:[u(n,(0,s.jsx)(ep.f,{className:"mr-2 h-4 w-4"})),a.settings?.importAllData||"Import All"]})]})]}),(0,s.jsx)("p",{className:"text-xs text-blue-700",children:a.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}var ej=e.i(307364);function ev({field:e,label:a,description:r}){let{t:i}=(0,t.b)(),[n,l]=(0,g.useState)(!1),[o,c]=(0,g.useState)(!1),[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)(null),h=`preference-${e}`;(0,g.useEffect)(()=>{B.f.get("/api/user").then(s=>l(!!s[e])).catch(()=>void 0).finally(()=>c(!0))},[e]);let x=async s=>{l(s),m(!0);try{await B.f.patch("/api/user",{[e]:s}),p(i.importFlow.preferenceSaved)}catch(t){l(!s),p(i.importFlow.preferenceSaveFailed),V.f.error("[Settings]","Failed to save user preference",{field:e,error:t instanceof Error?t.message:String(t)})}finally{m(!1)}};return(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,s.jsx)(M.f,{htmlFor:h,children:a}),(0,s.jsx)(z.f,{id:h,checked:n,onCheckedChange:x,disabled:!o||d})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:r}),u&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:u})]})}function ey(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"enableGeogebra",label:e.importFlow.enableGeogebra,description:e.importFlow.enableGeogebraDesc})}function eb(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"confirmBeforeImport",label:e.importFlow.confirmBeforeImport,description:e.importFlow.confirmBeforeImportDesc})}var ew=e.i(905110);function eN(){let{t:e}=(0,t.b)(),[a,r]=(0,g.useState)(String(ew.z)),[i,n]=(0,g.useState)(null),[l,o]=(0,g.useState)(!0),[c,d]=(0,g.useState)(!1),[m,u]=(0,g.useState)(null),p=Number(a),h=""!==a.trim()&&Number.isInteger(p)&&p>=ew.P&&p<=ew.o,x=(0,g.useCallback)(async()=>{o(!0),u(null);try{let e=(await B.f.get("/api/user")).masteryThreshold??ew.z;r(String(e)),n(e)}catch(s){u(e.mastery.thresholdLoadFailed),V.f.error("[Settings]","加载已掌握阈值失败",{error:s instanceof Error?s.message:String(s)})}finally{o(!1)}},[e.mastery.thresholdLoadFailed]);(0,g.useEffect)(()=>{x()},[x]);let f=async()=>{if(h&&null!==i){d(!0),u(null);try{let s=(await B.f.patch("/api/user",{masteryThreshold:p})).masteryThreshold??p;n(s),r(String(s)),u(e.importFlow.preferenceSaved)}catch(s){u(e.importFlow.preferenceSaveFailed),V.f.error("[Settings]","保存已掌握阈值失败",{error:s instanceof Error?s.message:String(s)})}finally{d(!1)}}};return(0,s.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,s.jsx)(M.f,{htmlFor:"mastery-threshold",children:e.mastery.thresholdLabel}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(D.f,{id:"mastery-threshold",type:"number",min:ew.P,max:ew.o,step:1,value:a,onChange:e=>{r(e.target.value),u(null)},disabled:l||c||null===i,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,s.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,s.jsxs)(C.f,{type:"button",size:"sm",variant:"outline",onClick:f,disabled:l||c||null===i||!h||p===i,children:[(l||c)&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.importFlow.saveThreshold]}),!l&&null===i&&(0,s.jsx)(C.f,{type:"button",size:"sm",variant:"outline",onClick:x,children:e.importFlow.retryLoad})]}),(0,s.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:e.mastery.thresholdDescription}),null!==i&&!h&&(0,s.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:e.mastery.thresholdInvalid}),m&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:m})]})}function ek(){let{t:e}=(0,t.b)();return(0,s.jsx)(ev,{field:"enableSvgAnimation",label:e.importFlow.enableSvgAnimation,description:e.importFlow.enableSvgAnimationDesc})}function eS({value:e,onChange:a,disabled:r}){let{t:i}=(0,t.b)();return(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsx)(M.f,{htmlFor:"app-time-zone",children:i.settings.general.timeZoneLabel}),(0,s.jsx)(D.f,{id:"app-time-zone",value:e,onChange:e=>a(e.target.value),disabled:r,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,s.jsx)("datalist",{id:"app-time-zones",children:["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Europe/London","America/New_York","America/Los_Angeles","UTC"].map(e=>(0,s.jsx)("option",{value:e},e))}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:i.settings.general.timeZoneDesc})]})}function eC({config:e,setConfig:a,isAdmin:i,disabled:n}){let{t:l,language:o,setLanguage:c}=(0,t.b)(),{timeZone:d}=(0,r.M)(),m=e=>a(s=>({...s,timeouts:{...s.timeouts,analyze:1e3*e}}));return(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:l.settings?.language||"Language"}),(0,s.jsxs)(ei.d,{value:o,onValueChange:e=>c(e),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{})}),(0,s.jsxs)(ei.r,{children:[(0,s.jsx)(ei.T,{value:"zh",children:"中文 (Chinese)"}),(0,s.jsx)(ei.T,{value:"en",children:"English"})]})]})]}),(0,s.jsx)(eS,{value:e.timeZone??d,onChange:e=>a(s=>({...s,timeZone:e})),disabled:!i||n}),i&&(0,s.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,s.jsx)(M.f,{children:l.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,s.jsx)(D.f,{type:"number",value:e.timeouts?.analyze?e.timeouts.analyze/1e3:"",onChange:e=>{let s=""===e.target.value?0:parseInt(e.target.value);m(isNaN(s)?0:s)},onBlur:()=>{let s=(e.timeouts?.analyze||0)/1e3,t=Math.min(600,Math.max(120,s));t!==s&&m(t)},min:120,max:600}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:l.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,s.jsx)(eb,{}),(0,s.jsx)(ek,{}),(0,s.jsx)(ey,{}),(0,s.jsx)(ej.f,{}),(0,s.jsx)(eN,{})]})}var eT=e.i(624687),eA=e.i(247167);let eE={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function e_(e,s={}){let t,a=eE[e],r=(t=eA.default.env.LOG_LEVEL?.toLowerCase())&&void 0!==eE[t]?eE[t]:eE.info;return(t,i)=>{let n,l;if(a<r)return;let o=new Date;"string"==typeof t?(n={},l=t):(n=t,l=i||"");{let t=JSON.stringify({level:e,time:o.toISOString(),...s,...n,msg:l});switch(e){case"error":case"fatal":console.error(t);break;case"warn":console.warn(t);break;default:console.log(t)}}}}(function e(s={}){return s.module,{trace:e_("trace",s),debug:e_("debug",s),info:e_("info",s),warn:e_("warn",s),error:e_("error",s),fatal:e_("fatal",s),child:t=>e({...s,...t}),box:(e,t,a="📋")=>{console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...s,title:e,..."string"==typeof t?{content:t}:t||{},msg:e}))},divider:(e="-")=>{}}})({env:"production"}).child({module:"ai:prompts"});let ez=`请参考《高思学校竞赛数学导引》(每讲分兴趣篇、拓展篇、超越篇,题目左侧标 1~5 颗星)的星级标准,结合题目所在年级评定难度:
|
|
2
2
|
- 1 星:课本基础题,直接套用概念、公式或简单计算即可(相当于兴趣篇前几题)。
|
|
3
3
|
- 2 星:校内拔高题,需要两三步推理或简单综合(相当于兴趣篇后几题)。
|
|
4
4
|
- 3 星:常规奥数题,小升初、杯赛常见难度,需要掌握该专题的典型方法(相当于拓展篇)。
|
|
@@ -188,4 +188,4 @@ ${eM}
|
|
|
188
188
|
${eM}
|
|
189
189
|
|
|
190
190
|
{{grade_instruction}}
|
|
191
|
-
{{provider_hints}}`;var eI=e.i(367240);function eL({name:e,description:t}){return(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,s.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-primary shrink-0 w-fit",children:`{{${e}}}`}),(0,s.jsx)("span",{className:"text-muted-foreground",children:t})]})}function e$(){let{t:e}=(0,t.b)();return(0,s.jsxs)("div",{className:"bg-amber-50 border border-amber-200 rounded-md p-3 flex items-start gap-3 text-amber-900 text-sm mb-4",children:[(0,s.jsx)(f,{className:"h-5 w-5 shrink-0 text-amber-600"}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"font-medium",children:e.settings?.prompts?.caution||"Modify with Caution"}),(0,s.jsx)("p",{className:"text-amber-800/90 text-xs",children:e.settings?.prompts?.warning||"Variables in {{brackets}} are used to inject dynamic content. Please preserve these variables, otherwise the AI providing may fail to get question context or return invalid formats."})]})]})}function eU({config:e,onUpdate:a}){let{t:i}=(0,t.b)(),r=e.prompts?.analyze||eF,n=e.prompts?.similar||eR,l=async e=>{await (0,H.u)(i.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&a(e,"analyze"===e?eF:eR)},o=(e,s)=>{a(e,s)};return(0,s.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,s.jsxs)(A.i,{defaultValue:"analyze",className:"w-full",children:[(0,s.jsxs)(A.U,{className:"grid w-full grid-cols-2",children:[(0,s.jsx)(A.k,{value:"analyze",children:i.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,s.jsx)(A.k,{value:"similar",children:i.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,s.jsx)(A.S,{value:"analyze",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.f,{className:"text-base font-semibold",children:i.settings?.prompts?.customAnalysis||"Custom Analysis Template"}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>l("analyze"),children:[(0,s.jsx)(eI.f,{className:"w-4 h-4 mr-2"}),i.settings?.prompts?.reset||"Reset Default"]})]}),(0,s.jsx)(e$,{}),(0,s.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,s.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),i.settings?.prompts?.variables||"Available Variables"]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(eL,{name:"language_instruction",description:i.settings?.prompts?.vars?.languageInstruction||"Injects instructions based on target language (e.g., keep English questions in English but analysis in Chinese)."}),(0,s.jsx)(eL,{name:"knowledge_points_list",description:i.settings?.prompts?.vars?.knowledgePointsList||"Injects the standard list of knowledge point tags for the specific subject."}),(0,s.jsx)(eL,{name:"provider_hints",description:i.settings?.prompts?.vars?.providerHints||"System-injected hints (e.g., enforcing JSON format)."})]})]}),(0,s.jsx)(eT.f,{value:r,onChange:e=>o("analyze",e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:eF})]})}),(0,s.jsx)(A.S,{value:"similar",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.f,{className:"text-base font-semibold",children:i.settings?.prompts?.customSimilar||"Custom Similar Question Template"}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>l("similar"),children:[(0,s.jsx)(eI.f,{className:"w-4 h-4 mr-2"}),i.settings?.prompts?.reset||"Reset Default"]})]}),(0,s.jsx)(e$,{}),(0,s.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,s.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),i.settings?.prompts?.variables||"Available Variables"]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(eL,{name:"difficulty_level",description:i.settings?.prompts?.vars?.difficultyLevel||"Target difficulty level."}),(0,s.jsx)(eL,{name:"difficulty_instruction",description:i.settings?.prompts?.vars?.difficultyInstruction||"Specific writing instructions for the target difficulty."}),(0,s.jsx)(eL,{name:"original_question",description:i.settings?.prompts?.vars?.originalQuestion||"The full text of the original question."}),(0,s.jsx)(eL,{name:"knowledge_points",description:i.settings?.prompts?.vars?.knowledgePoints||"List of knowledge points to test."}),(0,s.jsx)(eL,{name:"language_instruction",description:i.settings?.prompts?.vars?.languageInstructionShort||"Language formatting instructions."})]})]}),(0,s.jsx)(eT.f,{value:n,onChange:e=>o("similar",e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:eR})]})})]})})}var eP=e.i(431343),eq=e.i(434901),eO=e.i(753817),eK=e.i(128093),eB=e.i(79058);let eH=["browser","minimax","qwen","glm","stepfun","volcengine","volcengine-agent","openai"];eH.filter(e=>"browser"!==e);let eV={minimax:{model:"speech-2.8-hd",voice:"male-qn-jingying"},qwen:{model:"qwen-audio-3.0-tts-plus",voice:"longanlufeng"},glm:{model:"glm-tts",voice:"xiaochen"},stepfun:{model:"stepaudio-2.5-tts",voice:"qingniandaxuesheng"},volcengine:{model:"seed-tts-2.0",voice:"zh_male_yangguangqingnian_uranus_bigtts"},"volcengine-agent":{model:"seed-tts-2.0",voice:"zh_male_yangguangqingnian_uranus_bigtts"},openai:{model:"gpt-4o-mini-tts",voice:"cedar"}},eY={minimax:{apiKey:"https://platform.minimax.cn/docs/guides/quickstart-preparation",model:"https://platform.minimax.cn/docs/api-reference/speech-t2a-http",voice:"https://platform.minimax.cn/docs/faq/system-voice-id",endpoint:"https://platform.minimax.cn/docs/api-reference/speech-t2a-http"},qwen:{apiKey:"https://help.aliyun.com/zh/model-studio/token-plan-personal-quick-start",model:"https://help.aliyun.com/zh/model-studio/non-realtime-tts-user-guide",voice:"https://help.aliyun.com/zh/model-studio/qwen-audio-tts-voice-list",endpoint:"https://help.aliyun.com/zh/model-studio/non-realtime-tts-user-guide"},glm:{apiKey:"https://docs.bigmodel.cn/cn/guide/start/quick-start",model:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3",voice:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3",endpoint:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3"},stepfun:{apiKey:"https://platform.stepfun.com/docs/zh/step-plan/integrations/audio-api",model:"https://platform.stepfun.com/docs/zh/api-reference/audio/create-audio",voice:"https://platform.stepfun.com/docs/zh/guides/developer/tts",endpoint:"https://platform.stepfun.com/docs/zh/api-reference/audio/create-audio"},volcengine:{apiKey:"https://www.volcengine.com/docs/6561/196768",model:"https://www.volcengine.com/docs/6561/1598757",voice:"https://www.volcengine.com/docs/6561/1257544",endpoint:"https://www.volcengine.com/docs/6561/1598757"},openai:{apiKey:"https://platform.openai.com/docs/quickstart",model:"https://developers.openai.com/api/docs/guides/text-to-speech",voice:"https://developers.openai.com/api/docs/guides/text-to-speech",endpoint:"https://developers.openai.com/api/docs/guides/text-to-speech"},"volcengine-agent":{apiKey:"https://ark.volcengine.com/region:cn-beijing/docs/82379/2160841?lang=zh",model:"https://docs.volcengine.com/docs/ark/agent-plan-personal-voice-model?lang=zh",voice:"https://www.volcengine.com/docs/6561/1257544",endpoint:"https://docs.volcengine.com/docs/ark/agent-plan-personal-voice-model?lang=zh"}};function eW({config:e,setConfig:a,saving:i,onSave:r}){var n;let{t:l,language:o}=(0,t.b)(),c=l.settings.tts,[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)(null),h=e.tts?.mode??"browser",x="browser"!==h&&"string"==typeof(n=h)&&eH.includes(n)?h:null,f=x?e.tts?.[x]:void 0,j=(e,s)=>{x&&a(t=>({...t,tts:{...t.tts,[x]:{...t.tts?.[x],[e]:s}}}))},v=!!x&&("volcengine"===x||"openai"===x),y=x?function(e,s){if("openai"===s){let s=e.openai?.instances?.find(s=>s.id===e.openai?.activeInstanceId);return s?{apiKey:s.apiKey,baseUrl:s.baseUrl}:void 0}return e[s]}(e,x):void 0,w=v?f?.apiKey:y?.apiKey,N=async()=>{(0,eB.p)(),m(!0),p(null);try{await r();let{id:e,version:s}=await B.f.post("/api/tts",{text:c.previewText,language:o},{timeout:12e4,recoverable:!0}),t=(0,eB.l)();if(!t)return;t.src=`/api/tts/${e}?v=${s}`,t.playbackRate=1,await t.play()}catch(s){V.f.error("[TtsSettings]","Preview failed",{error:s});let e=(0,Y.d)(s);H.c.error("TTS_NOT_CONFIGURED"===e?c.notConfigured:"TTS_PROVIDER_ERROR"===e?c.providerError:c.previewFailed),p((0,Y.L)(s)??null)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:c.title}),(0,s.jsxs)(er.d,{value:h,onValueChange:e=>a(s=>({...s,tts:{...s.tts,mode:e}})),children:[(0,s.jsx)(er.P,{children:(0,s.jsx)(er.U,{})}),(0,s.jsx)(er.r,{children:eH.map(e=>(0,s.jsx)(er.T,{value:e,children:c.modes[e]},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:x?c.cloudHint:c.browserHint})]}),x&&(0,s.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:"openai"===x?"OpenAI API Key":v?c.speechApiKey:`${(0,eK.z)(x,o)} API Key`,href:eY[x].apiKey,linkText:l.settings.ai.docLinks.apiKey}),(0,s.jsx)(ei.f,{value:w||"",onChange:e=>{var s;return s=e.target.value,void(x&&(v?j("apiKey",s):a(e=>({...e,[x]:{...e[x],apiKey:s}}))))},placeholder:"qwen"===x?"sk-sp-...":v?"":"sk-..."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.apiKeyHint[x]})]}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.model,href:eY[x].model,linkText:c.docs}),(0,s.jsx)(D.f,{value:f?.model||"",onChange:e=>j("model",e.target.value),placeholder:eV[x].model})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.voice,href:eY[x].voice,linkText:c.voiceList}),(0,s.jsx)(D.f,{value:f?.voice||"",onChange:e=>j("voice",e.target.value),placeholder:eV[x].voice})]})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.voiceHint[x]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.endpoint,href:eY[x].endpoint,linkText:c.docs}),(0,s.jsx)(D.f,{value:f?.endpoint||"",onChange:e=>j("endpoint",e.target.value),placeholder:function(e,s){if("volcengine"===e)return"https://openspeech.bytedance.com/api/v3/tts/unidirectional";if("volcengine-agent"===e)return"https://openspeech.bytedance.com/api/v3/plan/tts/unidirectional";if("openai"===e)return`${(s?.baseUrl||"https://api.openai.com/v1").replace(/\/+$/,"")}/audio/speech`;let{baseUrl:t}=(0,eK.k)(e,s);if("minimax"===e)return`${t.replace(/\/+$/,"")}/t2a_v2`;if("glm"===e||"stepfun"===e)return`${t.replace(/\/+$/,"")}/audio/speech`;try{return`${new URL(t).origin}/api/v1/services/audio/tts/SpeechSynthesizer`}catch{return""}}(x,y)}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.endpointHint})]})]},x),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[x&&(0,s.jsxs)(C.f,{variant:"outline",onClick:N,disabled:i||d,className:"sm:w-auto",children:[d?(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eP.f,{className:"mr-2 h-4 w-4"}),c.preview]}),(0,s.jsxs)(C.f,{onClick:()=>void r(),disabled:i||d,className:"flex-1",children:[i&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),c.save]})]}),x&&u&&(0,s.jsx)("div",{className:"rounded-md border border-red-200 bg-red-50 p-2 dark:border-red-900 dark:bg-red-950/40",children:(0,s.jsx)(eO.f,{detail:u})})]})}var eJ=e.i(835467);function eX({value:e,icon:t,label:a}){return(0,s.jsxs)(A.k,{value:e,className:"px-2 sm:px-3",children:[t,(0,s.jsx)("span",{className:"hidden sm:inline",children:a})]})}function eG(){let{setTimeZone:e}=(0,i.M)(),{data:r}=(0,a.useSession)(),n=r?.user?.role==="admin",{t:c}=(0,t.b)(),d=(0,l.useRouter)(),[m,u]=(0,g.useState)(!1),p=(0,g.useRef)(null),[h,_]=(0,g.useState)(!1),[z,D]=(0,g.useState)(!1),[M,F]=(0,g.useState)({aiProvider:"minimax"}),R=(0,g.useCallback)(async()=>{D(!0);try{F(await B.f.get("/api/settings"))}catch(e){V.f.error("[SettingsDialog]","Failed to fetch settings",{error:e})}finally{D(!1)}},[]);(0,g.useEffect)(()=>{m&&R()},[m,R]);let I=async()=>{let s=(0,eJ.f)(M,c);if(s)return void H.c.error(s);_(!0);try{let s=await B.f.post("/api/settings",M);F(s),e(s.timeZone||E.J),H.c.success(c.settings?.messages?.saved||"Settings saved"),p.current?.scrollTo({top:0,behavior:"smooth"})}catch(e){V.f.error("[SettingsDialog]","Failed to save settings",{error:e}),H.c.error(c.settings?.messages?.saveFailed||"Failed to save")}finally{_(!1)}},L=e=>(0,s.jsxs)(C.f,{onClick:I,disabled:h,className:"w-full",children:[h&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e]});return(0,s.jsxs)(T.N,{open:m,onOpenChange:u,children:[(0,s.jsx)(T.a,{asChild:!0,children:(0,s.jsxs)(C.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,s.jsx)(N,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:c.settings?.title||"Settings"})]})}),(0,s.jsxs)(T.d,{ref:p,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsx)(T.F,{children:c.settings?.title||"Settings"}),(0,s.jsx)(T.C,{children:c.settings?.desc||"Manage your preferences and data."})]}),(0,s.jsxs)(A.i,{defaultValue:"general",className:"w-full",children:[(0,s.jsxs)(A.U,{className:`grid w-full grid-cols-4 ${n?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,s.jsx)(eX,{value:"general",icon:(0,s.jsx)(y.f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.general||"General"}),(0,s.jsx)(eX,{value:"account",icon:(0,s.jsx)(k.f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.account||"Account"}),n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eX,{value:"ai",icon:(0,s.jsx)(j,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.ai||"AI Provider"}),(0,s.jsx)(eX,{value:"prompts",icon:(0,s.jsx)(w,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.prompts||"Prompts"}),(0,s.jsx)(eX,{value:"admin",icon:(0,s.jsx)(x,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.admin||"User Management"})]}),(0,s.jsx)(eX,{value:"danger",icon:(0,s.jsx)(f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.danger||"Danger"}),(0,s.jsx)(eX,{value:"about",icon:(0,s.jsx)(v,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.about||"About"})]}),(0,s.jsxs)(A.S,{value:"general",className:"space-y-4 py-4",children:[(0,s.jsx)(eC,{config:M,setConfig:F,isAdmin:n,disabled:z||h}),n&&L(c.settings?.save||"Save Settings")]}),(0,s.jsx)(A.S,{value:"account",className:"space-y-4 py-4",children:(0,s.jsx)(el,{})}),(0,s.jsxs)(A.S,{value:"ai",className:"space-y-4 py-4",children:[(0,s.jsx)(eo.f,{config:M,setConfig:F,loading:z,saving:h,onSave:I}),!z&&(0,s.jsx)(eW,{config:M,setConfig:F,saving:h,onSave:I})]}),(0,s.jsxs)(A.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,s.jsx)(eU,{config:M,onUpdate:(e,s)=>F(t=>({...t,prompts:{...t.prompts,[e]:s}}))}),L(c.settings?.prompts?.save||"Save Prompt Settings")]}),n&&(0,s.jsxs)(A.S,{value:"admin",className:"space-y-4 py-4",children:[(0,s.jsxs)(C.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{u(!1),d.push("/admin")},children:[(0,s.jsx)(o.f,{className:"h-4 w-4"}),c.admin?.dashboard?.title||"Admin Dashboard"]}),(0,s.jsxs)(C.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{u(!1),d.push("/setup")},children:[(0,s.jsx)(S.f,{className:"h-4 w-4"}),c.setup.rerun]}),(0,s.jsx)("div",{className:"border-t pt-4",children:(0,s.jsx)(W,{})})]}),(0,s.jsx)(A.S,{value:"danger",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(ef,{isAdmin:n}),(0,s.jsx)(eu,{isAdmin:n})]})}),(0,s.jsx)(A.S,{value:"about",className:"space-y-4 py-4",children:(0,s.jsx)(ea,{})})]})]})]})}let eZ=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],eQ=[{key:"home",href:"/",icon:h,match:e=>"/"===e},{key:"notebooks",href:"/notebooks",icon:c.f,match:e=>e.startsWith("/notebooks")||e.startsWith("/error-items")||e.startsWith("/practice")},{key:"review",href:"/review",icon:d.f,match:e=>e.startsWith("/review")},{key:"stats",href:"/stats",icon:o.f,match:e=>e.startsWith("/stats")||e.startsWith("/tags")},{key:"exams",href:"/exams",icon:m.f,match:e=>e.startsWith("/exams")}];function e0({children:e}){var i;let o,c,d=(0,l.usePathname)()||"/",{t:m}=(0,t.b)(),{data:p,status:h}=(0,a.useSession)(),f=p?.user?.role==="admin",j=eZ.some(e=>e.test(d));if(i=f&&!j,o=(0,l.useRouter)(),c=(0,g.useRef)(!1),(0,g.useEffect)(()=>{i&&!c.current&&(c.current=!0,B.f.get("/api/setup").then(e=>{e.needsSetup&&o.replace("/setup")}).catch(e=>V.f.warn("[Setup]","Failed to check setup status",{error:e})))},[i,o]),j||"unauthenticated"===h)return(0,s.jsx)(s.Fragment,{children:e});let v=p?.user?.name||p?.user?.email||"";return(0,s.jsxs)("div",{className:"min-h-screen",children:[(0,s.jsx)("header",{className:"sticky top-0 z-40 border-b bg-card/80 backdrop-blur-md supports-[backdrop-filter]:bg-card/70 print:hidden",children:(0,s.jsxs)("div",{className:"mx-auto flex h-14 max-w-6xl items-center gap-3 px-4 md:h-16 md:px-8",children:[(0,s.jsxs)(n.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(r.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,s.jsx)("span",{className:"text-base font-semibold tracking-tight",children:m.pageTitle.base})]}),(0,s.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:eQ.map(e=>{let t=e.match(d),a=e.icon;return(0,s.jsxs)(n.default,{href:e.href,className:(0,F.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",t?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":t?"page":void 0,children:[(0,s.jsx)(a,{className:"h-4 w-4"}),m.nav[e.key]]},e.key)})}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[v&&(0,s.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:v.slice(0,1).toUpperCase()}),(0,s.jsx)("span",{className:"truncate",children:v})]}),f&&(0,s.jsx)(n.default,{href:"/admin",title:m.nav.admin,children:(0,s.jsxs)(C.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,s.jsx)(x,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:m.nav.admin})]})}),(0,s.jsx)(eG,{}),(0,s.jsx)(C.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,a.signOut)({callbackUrl:"/login"}),title:m.app.logout,children:(0,s.jsx)(u.f,{className:"h-5 w-5"})})]})]})}),(0,s.jsx)("div",{className:"pb-20 md:pb-0",children:e}),(0,s.jsx)("nav",{className:"pb-safe fixed inset-x-0 bottom-0 z-40 border-t bg-card/90 backdrop-blur-md md:hidden print:hidden",children:(0,s.jsx)("div",{className:"grid h-16 grid-cols-5",children:eQ.map(e=>{let t=e.match(d),a=e.icon;return(0,s.jsxs)(n.default,{href:e.href,className:(0,F.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",t?"text-primary":"text-muted-foreground"),"aria-current":t?"page":void 0,children:[(0,s.jsx)("span",{className:(0,F.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",t&&"bg-accent"),children:(0,s.jsx)(a,{className:"h-5 w-5"})}),m.nav[e.key]]},e.key)})})})]})}let e1=(0,p.f)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]);var e2=e.i(373884);let e4=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function e3(){let{t:e}=(0,t.b)(),{timeZone:r}=(0,i.M)(),{status:o}=(0,a.useSession)(),c=(0,l.usePathname)(),[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)([]),[h,x]=(0,g.useState)(()=>Date.now()),f="authenticated"!==o||e4.some(e=>e.test(c||"")),j=(0,g.useCallback)(async()=>{if("u"<typeof document||"hidden"!==document.visibilityState)try{let e=await B.f.get("/api/tasks");p(e.tasks),x(Date.now())}catch{}},[]);if((0,g.useEffect)(()=>{if(f)return;let e=setTimeout(j,0),s=setInterval(j,d?2e3:15e3);return()=>{clearTimeout(e),clearInterval(s)}},[f,d,j]),f)return null;let v=u.filter(e=>"running"===e.status).length,y=u.some(e=>"running"!==e.status),w=async()=>{try{let e=await B.f.delete("/api/tasks");p(e.tasks)}catch{}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(C.f,{variant:"outline",size:"icon",className:"fixed bottom-20 right-4 z-40 h-11 w-11 rounded-full shadow-lg md:bottom-6 md:right-6 print:hidden",onClick:()=>m(!0),"aria-label":e.backgroundTasks.title,title:e.backgroundTasks.title,children:[v>0?(0,s.jsx)(b.f,{className:"h-5 w-5 animate-spin"}):(0,s.jsx)(e1,{className:"h-5 w-5"}),v>0&&(0,s.jsx)("span",{className:"absolute -right-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs text-primary-foreground",children:v})]}),(0,s.jsx)(T.N,{open:d,onOpenChange:m,children:(0,s.jsxs)(T.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsx)(T.F,{children:e.backgroundTasks.title}),(0,s.jsx)(T.C,{children:e.backgroundTasks.description})]}),0===u.length?(0,s.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:e.backgroundTasks.empty}):(0,s.jsx)("ul",{className:"space-y-2",children:u.map(t=>{var a,i;let l;return(0,s.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:["running"===t.status&&(0,s.jsx)(b.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===t.status&&(0,s.jsx)(ep.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===t.status&&(0,s.jsx)(e2.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,s.jsxs)("div",{className:"font-medium",children:[e.backgroundTasks.kinds[t.kind],(0,s.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",e.backgroundTasks.status[t.status]]})]}),t.subject&&(0,s.jsx)("div",{className:"break-words text-muted-foreground",children:t.subject}),t.progress&&t.progress.total>0&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,s.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(t.progress.done/t.progress.total*100)}%`}})}),(0,s.jsxs)("div",{className:"text-xs text-muted-foreground",children:[e.backgroundTasks.progress.replace("{done}",String(t.progress.done)).replace("{total}",String(t.progress.total)),t.progress.failed>0&&` \xb7 ${e.backgroundTasks.failedCount.replace("{count}",String(t.progress.failed))}`]})]}),t.error&&(0,s.jsx)("div",{className:"text-xs text-destructive",children:(s=>{if(!s)return null;let t=e.backgroundTasks.errors[s]??e.errors[s];return"string"==typeof t?t:s})(t.error)}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:e.backgroundTasks.startedAt.replace("{time}",(0,E.r)(t.startedAt,"HH:mm:ss",r))}),(0,s.jsx)("span",{children:e.backgroundTasks.elapsed.replace("{time}",(a=t.startedAt,i=t.finishedAt,l=Math.max(0,Math.round(((i?Date.parse(i):h)-Date.parse(a))/1e3)),`${Math.floor(l/60)}:${String(l%60).padStart(2,"0")}`))}),t.link&&(0,s.jsx)(n.default,{href:t.link,className:"text-primary hover:underline",onClick:()=>m(!1),children:e.backgroundTasks.view})]})]})]})},t.id)})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.backgroundTasks.retentionHint}),y&&(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:w,children:e.backgroundTasks.clearFinished})]})]})})]})}var e5=e.i(37727);let e6={success:{icon:ep.f,className:"text-success"},error:{icon:e2.f,className:"text-destructive"},warning:{icon:f,className:"text-warning"},info:{icon:v,className:"text-primary"}};function e8(){let{t:e}=(0,t.b)(),[a,i]=(0,g.useState)([]),[r,n]=(0,g.useState)(null);return(0,g.useEffect)(()=>(0,H.M)(e=>{i(e.toasts),n(e.confirm)}),[]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4 print:hidden",role:"status","aria-live":"polite",children:a.map(t=>{let{icon:a,className:i}=e6[t.type];return(0,s.jsxs)("div",{className:"pointer-events-auto flex w-full max-w-sm items-start gap-3 rounded-xl border bg-card/95 px-4 py-3 text-sm shadow-lg backdrop-blur animate-in fade-in slide-in-from-top-2 duration-200",children:[(0,s.jsx)(a,{className:(0,F.f)("mt-0.5 h-4 w-4 shrink-0",i)}),(0,s.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:t.message}),(0,s.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,H.p)(t.id),"aria-label":e.common.close,children:(0,s.jsx)(e5.X,{className:"h-3.5 w-3.5"})})]},t.id)})}),(0,s.jsx)(T.N,{open:!!r,onOpenChange:e=>{e||r?.resolve(!1)},children:(0,s.jsxs)(T.d,{className:"sm:max-w-md",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsxs)(T.F,{className:"flex items-center gap-2",children:[r?.destructive&&(0,s.jsx)(f,{className:"h-5 w-5 text-destructive"}),r?.title||e.common.confirmTitle]}),(0,s.jsx)(T.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:r?.message})]}),(0,s.jsxs)(T.c,{className:"gap-2",children:[(0,s.jsx)(C.f,{variant:"outline",onClick:()=>r?.resolve(!1),children:r?.cancelText||e.common.cancel}),(0,s.jsx)(C.f,{variant:r?.destructive?"destructive":"default",onClick:()=>r?.resolve(!0),autoFocus:!0,children:r?.confirmText||e.common.confirm})]})]})})]})}function e7(){return(0,g.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(e=>{V.f.warn("[PWA]","Service worker registration failed",{error:String(e)})})},[]),null}e.s(["Providers",0,function({children:e,timeZone:r}){return(0,s.jsx)(a.SessionProvider,{children:(0,s.jsx)(t.w,{children:(0,s.jsxs)(i.n,{initialTimeZone:r,children:[(0,s.jsx)(e0,{children:e}),(0,s.jsx)(e3,{}),(0,s.jsx)(e8,{}),(0,s.jsx)(e7,{})]})})})}],1661)}]);
|
|
191
|
+
{{provider_hints}}`;var eI=e.i(367240);function eL({name:e,description:t}){return(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,s.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-primary shrink-0 w-fit",children:`{{${e}}}`}),(0,s.jsx)("span",{className:"text-muted-foreground",children:t})]})}function e$(){let{t:e}=(0,t.b)();return(0,s.jsxs)("div",{className:"bg-amber-50 border border-amber-200 rounded-md p-3 flex items-start gap-3 text-amber-900 text-sm mb-4",children:[(0,s.jsx)(f,{className:"h-5 w-5 shrink-0 text-amber-600"}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"font-medium",children:e.settings?.prompts?.caution||"Modify with Caution"}),(0,s.jsx)("p",{className:"text-amber-800/90 text-xs",children:e.settings?.prompts?.warning||"Variables in {{brackets}} are used to inject dynamic content. Please preserve these variables, otherwise the AI providing may fail to get question context or return invalid formats."})]})]})}function eU({config:e,onUpdate:a}){let{t:r}=(0,t.b)(),i=e.prompts?.analyze||eF,n=e.prompts?.similar||eR,l=async e=>{await (0,H.u)(r.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&a(e,"analyze"===e?eF:eR)},o=(e,s)=>{a(e,s)};return(0,s.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,s.jsxs)(A.i,{defaultValue:"analyze",className:"w-full",children:[(0,s.jsxs)(A.U,{className:"grid w-full grid-cols-2",children:[(0,s.jsx)(A.k,{value:"analyze",children:r.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,s.jsx)(A.k,{value:"similar",children:r.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,s.jsx)(A.S,{value:"analyze",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.f,{className:"text-base font-semibold",children:r.settings?.prompts?.customAnalysis||"Custom Analysis Template"}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>l("analyze"),children:[(0,s.jsx)(eI.f,{className:"w-4 h-4 mr-2"}),r.settings?.prompts?.reset||"Reset Default"]})]}),(0,s.jsx)(e$,{}),(0,s.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,s.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),r.settings?.prompts?.variables||"Available Variables"]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(eL,{name:"language_instruction",description:r.settings?.prompts?.vars?.languageInstruction||"Injects instructions based on target language (e.g., keep English questions in English but analysis in Chinese)."}),(0,s.jsx)(eL,{name:"knowledge_points_list",description:r.settings?.prompts?.vars?.knowledgePointsList||"Injects the standard list of knowledge point tags for the specific subject."}),(0,s.jsx)(eL,{name:"provider_hints",description:r.settings?.prompts?.vars?.providerHints||"System-injected hints (e.g., enforcing JSON format)."})]})]}),(0,s.jsx)(eT.f,{value:i,onChange:e=>o("analyze",e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:eF})]})}),(0,s.jsx)(A.S,{value:"similar",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)(M.f,{className:"text-base font-semibold",children:r.settings?.prompts?.customSimilar||"Custom Similar Question Template"}),(0,s.jsxs)(C.f,{variant:"outline",size:"sm",onClick:()=>l("similar"),children:[(0,s.jsx)(eI.f,{className:"w-4 h-4 mr-2"}),r.settings?.prompts?.reset||"Reset Default"]})]}),(0,s.jsx)(e$,{}),(0,s.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,s.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),r.settings?.prompts?.variables||"Available Variables"]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(eL,{name:"difficulty_level",description:r.settings?.prompts?.vars?.difficultyLevel||"Target difficulty level."}),(0,s.jsx)(eL,{name:"difficulty_instruction",description:r.settings?.prompts?.vars?.difficultyInstruction||"Specific writing instructions for the target difficulty."}),(0,s.jsx)(eL,{name:"original_question",description:r.settings?.prompts?.vars?.originalQuestion||"The full text of the original question."}),(0,s.jsx)(eL,{name:"knowledge_points",description:r.settings?.prompts?.vars?.knowledgePoints||"List of knowledge points to test."}),(0,s.jsx)(eL,{name:"language_instruction",description:r.settings?.prompts?.vars?.languageInstructionShort||"Language formatting instructions."})]})]}),(0,s.jsx)(eT.f,{value:n,onChange:e=>o("similar",e.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:eR})]})})]})})}var eP=e.i(431343),eq=e.i(434901),eO=e.i(753817),eK=e.i(128093),eB=e.i(79058);let eH=["browser","minimax","qwen","glm","stepfun","volcengine","volcengine-agent","openai"];eH.filter(e=>"browser"!==e);let eV={minimax:{model:"speech-2.8-hd",voice:"male-qn-jingying"},qwen:{model:"qwen-audio-3.0-tts-plus",voice:"longanlufeng"},glm:{model:"glm-tts",voice:"xiaochen"},stepfun:{model:"stepaudio-2.5-tts",voice:"qingniandaxuesheng"},volcengine:{model:"seed-tts-2.0",voice:"zh_male_yangguangqingnian_uranus_bigtts"},"volcengine-agent":{model:"seed-tts-2.0",voice:"zh_male_yangguangqingnian_uranus_bigtts"},openai:{model:"gpt-4o-mini-tts",voice:"cedar"}},eY={minimax:{apiKey:"https://platform.minimax.cn/docs/guides/quickstart-preparation",model:"https://platform.minimax.cn/docs/api-reference/speech-t2a-http",voice:"https://platform.minimax.cn/docs/faq/system-voice-id",endpoint:"https://platform.minimax.cn/docs/api-reference/speech-t2a-http"},qwen:{apiKey:"https://help.aliyun.com/zh/model-studio/token-plan-personal-quick-start",model:"https://help.aliyun.com/zh/model-studio/non-realtime-tts-user-guide",voice:"https://help.aliyun.com/zh/model-studio/qwen-audio-tts-voice-list",endpoint:"https://help.aliyun.com/zh/model-studio/non-realtime-tts-user-guide"},glm:{apiKey:"https://docs.bigmodel.cn/cn/guide/start/quick-start",model:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3",voice:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3",endpoint:"https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3"},stepfun:{apiKey:"https://platform.stepfun.com/docs/zh/step-plan/integrations/audio-api",model:"https://platform.stepfun.com/docs/zh/api-reference/audio/create-audio",voice:"https://platform.stepfun.com/docs/zh/guides/developer/tts",endpoint:"https://platform.stepfun.com/docs/zh/api-reference/audio/create-audio"},volcengine:{apiKey:"https://www.volcengine.com/docs/6561/196768",model:"https://www.volcengine.com/docs/6561/1598757",voice:"https://www.volcengine.com/docs/6561/1257544",endpoint:"https://www.volcengine.com/docs/6561/1598757"},openai:{apiKey:"https://platform.openai.com/docs/quickstart",model:"https://developers.openai.com/api/docs/guides/text-to-speech",voice:"https://developers.openai.com/api/docs/guides/text-to-speech",endpoint:"https://developers.openai.com/api/docs/guides/text-to-speech"},"volcengine-agent":{apiKey:"https://ark.volcengine.com/region:cn-beijing/docs/82379/2160841?lang=zh",model:"https://docs.volcengine.com/docs/ark/agent-plan-personal-voice-model?lang=zh",voice:"https://www.volcengine.com/docs/6561/1257544",endpoint:"https://docs.volcengine.com/docs/ark/agent-plan-personal-voice-model?lang=zh"}},eW={volcengine:"https://docs.volcengine.com/docs/ark/free-inference-quota?lang=zh"};function eJ({config:e,setConfig:a,saving:r,onSave:i}){var n;let{t:l,language:o}=(0,t.b)(),c=l.settings.tts,[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)(null),h=e.tts?.mode??"browser",x="browser"!==h&&"string"==typeof(n=h)&&eH.includes(n)?h:null,f=x?e.tts?.[x]:void 0,j=(e,s)=>{x&&a(t=>({...t,tts:{...t.tts,[x]:{...t.tts?.[x],[e]:s}}}))},v=!!x&&("volcengine"===x||"openai"===x),y=x?function(e,s){if("openai"===s){let s=e.openai?.instances?.find(s=>s.id===e.openai?.activeInstanceId);return s?{apiKey:s.apiKey,baseUrl:s.baseUrl}:void 0}return e[s]}(e,x):void 0,w=v?f?.apiKey:y?.apiKey,N=async()=>{(0,eB.p)(),m(!0),p(null);try{await i();let{id:e,version:s}=await B.f.post("/api/tts",{text:c.previewText,language:o},{timeout:12e4,recoverable:!0}),t=(0,eB.l)();if(!t)return;t.src=`/api/tts/${e}?v=${s}`,t.playbackRate=1,await t.play()}catch(s){V.f.error("[TtsSettings]","Preview failed",{error:s});let e=(0,Y.d)(s);H.c.error("TTS_NOT_CONFIGURED"===e?c.notConfigured:"TTS_PROVIDER_ERROR"===e?c.providerError:c.previewFailed),p((0,Y.L)(s)??null)}finally{m(!1)}};return(0,s.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(M.f,{children:c.title}),(0,s.jsxs)(ei.d,{value:h,onValueChange:e=>a(s=>({...s,tts:{...s.tts,mode:e}})),children:[(0,s.jsx)(ei.P,{children:(0,s.jsx)(ei.U,{})}),(0,s.jsx)(ei.r,{children:eH.map(e=>(0,s.jsx)(ei.T,{value:e,children:c.modes[e]},e))})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:x?c.cloudHint:c.browserHint})]}),x&&(0,s.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[eW[x]&&(0,s.jsxs)("div",{className:"rounded-md border border-green-200 bg-green-50 p-3 text-xs text-green-800 dark:border-green-900 dark:bg-green-950/40 dark:text-green-300",children:[c.freeTrial," ",(0,s.jsx)("a",{href:eW[x],target:"_blank",rel:"noopener noreferrer",className:"underline",children:c.freeTrialLink})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:"openai"===x?"OpenAI API Key":v?c.speechApiKey:`${(0,eK.z)(x,o)} API Key`,href:eY[x].apiKey,linkText:l.settings.ai.docLinks.apiKey}),(0,s.jsx)(er.f,{value:w||"",onChange:e=>{var s;return s=e.target.value,void(x&&(v?j("apiKey",s):a(e=>({...e,[x]:{...e[x],apiKey:s}}))))},placeholder:"qwen"===x?"sk-sp-...":v?"":"sk-..."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.apiKeyHint[x]})]}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.model,href:eY[x].model,linkText:c.docs}),(0,s.jsx)(D.f,{value:f?.model||"",onChange:e=>j("model",e.target.value),placeholder:eV[x].model})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.voice,href:eY[x].voice,linkText:c.voiceList}),(0,s.jsx)(D.f,{value:f?.voice||"",onChange:e=>j("voice",e.target.value),placeholder:eV[x].voice})]})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.voiceHint[x]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eq.f,{label:c.endpoint,href:eY[x].endpoint,linkText:c.docs}),(0,s.jsx)(D.f,{value:f?.endpoint||"",onChange:e=>j("endpoint",e.target.value),placeholder:function(e,s){if("volcengine"===e)return"https://openspeech.bytedance.com/api/v3/tts/unidirectional";if("volcengine-agent"===e)return"https://openspeech.bytedance.com/api/v3/plan/tts/unidirectional";if("openai"===e)return`${(s?.baseUrl||"https://api.openai.com/v1").replace(/\/+$/,"")}/audio/speech`;let{baseUrl:t}=(0,eK.k)(e,s);if("minimax"===e)return`${t.replace(/\/+$/,"")}/t2a_v2`;if("glm"===e||"stepfun"===e)return`${t.replace(/\/+$/,"")}/audio/speech`;try{return`${new URL(t).origin}/api/v1/services/audio/tts/SpeechSynthesizer`}catch{return""}}(x,y)}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:c.endpointHint})]})]},x),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[x&&(0,s.jsxs)(C.f,{variant:"outline",onClick:N,disabled:r||d,className:"sm:w-auto",children:[d?(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eP.f,{className:"mr-2 h-4 w-4"}),c.preview]}),(0,s.jsxs)(C.f,{onClick:()=>void i(),disabled:r||d,className:"flex-1",children:[r&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),c.save]})]}),x&&u&&(0,s.jsx)("div",{className:"rounded-md border border-red-200 bg-red-50 p-2 dark:border-red-900 dark:bg-red-950/40",children:(0,s.jsx)(eO.f,{detail:u})})]})}var eX=e.i(835467);function eG({value:e,icon:t,label:a}){return(0,s.jsxs)(A.k,{value:e,className:"px-2 sm:px-3",children:[t,(0,s.jsx)("span",{className:"hidden sm:inline",children:a})]})}function eZ(){let{setTimeZone:e}=(0,r.M)(),{data:i}=(0,a.useSession)(),n=i?.user?.role==="admin",{t:c}=(0,t.b)(),d=(0,l.useRouter)(),[m,u]=(0,g.useState)(!1),p=(0,g.useRef)(null),[h,_]=(0,g.useState)(!1),[z,D]=(0,g.useState)(!1),[M,F]=(0,g.useState)({aiProvider:"minimax"}),R=(0,g.useCallback)(async()=>{D(!0);try{F(await B.f.get("/api/settings"))}catch(e){V.f.error("[SettingsDialog]","Failed to fetch settings",{error:e})}finally{D(!1)}},[]);(0,g.useEffect)(()=>{m&&R()},[m,R]);let I=async()=>{let s=(0,eX.f)(M,c);if(s)return void H.c.error(s);_(!0);try{let s=await B.f.post("/api/settings",M);F(s),e(s.timeZone||E.J),H.c.success(c.settings?.messages?.saved||"Settings saved"),p.current?.scrollTo({top:0,behavior:"smooth"})}catch(e){V.f.error("[SettingsDialog]","Failed to save settings",{error:e}),H.c.error(c.settings?.messages?.saveFailed||"Failed to save")}finally{_(!1)}},L=e=>(0,s.jsxs)(C.f,{onClick:I,disabled:h,className:"w-full",children:[h&&(0,s.jsx)(b.f,{className:"mr-2 h-4 w-4 animate-spin"}),e]});return(0,s.jsxs)(T.N,{open:m,onOpenChange:u,children:[(0,s.jsx)(T.a,{asChild:!0,children:(0,s.jsxs)(C.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,s.jsx)(N,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:c.settings?.title||"Settings"})]})}),(0,s.jsxs)(T.d,{ref:p,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsx)(T.F,{children:c.settings?.title||"Settings"}),(0,s.jsx)(T.C,{children:c.settings?.desc||"Manage your preferences and data."})]}),(0,s.jsxs)(A.i,{defaultValue:"general",className:"w-full",children:[(0,s.jsxs)(A.U,{className:`grid w-full grid-cols-4 ${n?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,s.jsx)(eG,{value:"general",icon:(0,s.jsx)(y.f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.general||"General"}),(0,s.jsx)(eG,{value:"account",icon:(0,s.jsx)(k.f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.account||"Account"}),n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eG,{value:"ai",icon:(0,s.jsx)(j,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.ai||"AI Provider"}),(0,s.jsx)(eG,{value:"prompts",icon:(0,s.jsx)(w,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.prompts||"Prompts"}),(0,s.jsx)(eG,{value:"admin",icon:(0,s.jsx)(x,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.admin||"User Management"})]}),(0,s.jsx)(eG,{value:"danger",icon:(0,s.jsx)(f,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.danger||"Danger"}),(0,s.jsx)(eG,{value:"about",icon:(0,s.jsx)(v,{className:"h-4 w-4 sm:mr-2"}),label:c.settings?.tabs?.about||"About"})]}),(0,s.jsxs)(A.S,{value:"general",className:"space-y-4 py-4",children:[(0,s.jsx)(eC,{config:M,setConfig:F,isAdmin:n,disabled:z||h}),n&&L(c.settings?.save||"Save Settings")]}),(0,s.jsx)(A.S,{value:"account",className:"space-y-4 py-4",children:(0,s.jsx)(el,{})}),(0,s.jsxs)(A.S,{value:"ai",className:"space-y-4 py-4",children:[(0,s.jsx)(eo.f,{config:M,setConfig:F,loading:z,saving:h,onSave:I}),!z&&(0,s.jsx)(eJ,{config:M,setConfig:F,saving:h,onSave:I})]}),(0,s.jsxs)(A.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,s.jsx)(eU,{config:M,onUpdate:(e,s)=>F(t=>({...t,prompts:{...t.prompts,[e]:s}}))}),L(c.settings?.prompts?.save||"Save Prompt Settings")]}),n&&(0,s.jsxs)(A.S,{value:"admin",className:"space-y-4 py-4",children:[(0,s.jsxs)(C.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{u(!1),d.push("/admin")},children:[(0,s.jsx)(o.f,{className:"h-4 w-4"}),c.admin?.dashboard?.title||"Admin Dashboard"]}),(0,s.jsxs)(C.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{u(!1),d.push("/setup")},children:[(0,s.jsx)(S.f,{className:"h-4 w-4"}),c.setup.rerun]}),(0,s.jsx)("div",{className:"border-t pt-4",children:(0,s.jsx)(W,{})})]}),(0,s.jsx)(A.S,{value:"danger",className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(ef,{isAdmin:n}),(0,s.jsx)(eu,{isAdmin:n})]})}),(0,s.jsx)(A.S,{value:"about",className:"space-y-4 py-4",children:(0,s.jsx)(ea,{})})]})]})]})}let eQ=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],e0=[{key:"home",href:"/",icon:h,match:e=>"/"===e},{key:"notebooks",href:"/notebooks",icon:c.f,match:e=>e.startsWith("/notebooks")||e.startsWith("/error-items")||e.startsWith("/practice")},{key:"review",href:"/review",icon:d.f,match:e=>e.startsWith("/review")},{key:"stats",href:"/stats",icon:o.f,match:e=>e.startsWith("/stats")||e.startsWith("/tags")},{key:"exams",href:"/exams",icon:m.f,match:e=>e.startsWith("/exams")}];function e1({children:e}){var r;let o,c,d=(0,l.usePathname)()||"/",{t:m}=(0,t.b)(),{data:p,status:h}=(0,a.useSession)(),f=p?.user?.role==="admin",j=eQ.some(e=>e.test(d));if(r=f&&!j,o=(0,l.useRouter)(),c=(0,g.useRef)(!1),(0,g.useEffect)(()=>{r&&!c.current&&(c.current=!0,B.f.get("/api/setup").then(e=>{e.needsSetup&&o.replace("/setup")}).catch(e=>V.f.warn("[Setup]","Failed to check setup status",{error:e})))},[r,o]),j||"unauthenticated"===h)return(0,s.jsx)(s.Fragment,{children:e});let v=p?.user?.name||p?.user?.email||"";return(0,s.jsxs)("div",{className:"min-h-screen",children:[(0,s.jsx)("header",{className:"sticky top-0 z-40 border-b bg-card/80 backdrop-blur-md supports-[backdrop-filter]:bg-card/70 print:hidden",children:(0,s.jsxs)("div",{className:"mx-auto flex h-14 max-w-6xl items-center gap-3 px-4 md:h-16 md:px-8",children:[(0,s.jsxs)(n.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(i.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,s.jsx)("span",{className:"text-base font-semibold tracking-tight",children:m.pageTitle.base})]}),(0,s.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:e0.map(e=>{let t=e.match(d),a=e.icon;return(0,s.jsxs)(n.default,{href:e.href,className:(0,F.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",t?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":t?"page":void 0,children:[(0,s.jsx)(a,{className:"h-4 w-4"}),m.nav[e.key]]},e.key)})}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[v&&(0,s.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:v.slice(0,1).toUpperCase()}),(0,s.jsx)("span",{className:"truncate",children:v})]}),f&&(0,s.jsx)(n.default,{href:"/admin",title:m.nav.admin,children:(0,s.jsxs)(C.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,s.jsx)(x,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:m.nav.admin})]})}),(0,s.jsx)(eZ,{}),(0,s.jsx)(C.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,a.signOut)({callbackUrl:"/login"}),title:m.app.logout,children:(0,s.jsx)(u.f,{className:"h-5 w-5"})})]})]})}),(0,s.jsx)("div",{className:"pb-20 md:pb-0",children:e}),(0,s.jsx)("nav",{className:"pb-safe fixed inset-x-0 bottom-0 z-40 border-t bg-card/90 backdrop-blur-md md:hidden print:hidden",children:(0,s.jsx)("div",{className:"grid h-16 grid-cols-5",children:e0.map(e=>{let t=e.match(d),a=e.icon;return(0,s.jsxs)(n.default,{href:e.href,className:(0,F.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",t?"text-primary":"text-muted-foreground"),"aria-current":t?"page":void 0,children:[(0,s.jsx)("span",{className:(0,F.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",t&&"bg-accent"),children:(0,s.jsx)(a,{className:"h-5 w-5"})}),m.nav[e.key]]},e.key)})})})]})}let e2=(0,p.f)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]);var e4=e.i(373884);let e3=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function e5(){let{t:e}=(0,t.b)(),{timeZone:i}=(0,r.M)(),{status:o}=(0,a.useSession)(),c=(0,l.usePathname)(),[d,m]=(0,g.useState)(!1),[u,p]=(0,g.useState)([]),[h,x]=(0,g.useState)(()=>Date.now()),f="authenticated"!==o||e3.some(e=>e.test(c||"")),j=(0,g.useCallback)(async()=>{if("u"<typeof document||"hidden"!==document.visibilityState)try{let e=await B.f.get("/api/tasks");p(e.tasks),x(Date.now())}catch{}},[]);if((0,g.useEffect)(()=>{if(f)return;let e=setTimeout(j,0),s=setInterval(j,d?2e3:15e3);return()=>{clearTimeout(e),clearInterval(s)}},[f,d,j]),f)return null;let v=u.filter(e=>"running"===e.status).length,y=u.some(e=>"running"!==e.status),w=async()=>{try{let e=await B.f.delete("/api/tasks");p(e.tasks)}catch{}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(C.f,{variant:"outline",size:"icon",className:"fixed bottom-20 right-4 z-40 h-11 w-11 rounded-full shadow-lg md:bottom-6 md:right-6 print:hidden",onClick:()=>m(!0),"aria-label":e.backgroundTasks.title,title:e.backgroundTasks.title,children:[v>0?(0,s.jsx)(b.f,{className:"h-5 w-5 animate-spin"}):(0,s.jsx)(e2,{className:"h-5 w-5"}),v>0&&(0,s.jsx)("span",{className:"absolute -right-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs text-primary-foreground",children:v})]}),(0,s.jsx)(T.N,{open:d,onOpenChange:m,children:(0,s.jsxs)(T.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsx)(T.F,{children:e.backgroundTasks.title}),(0,s.jsx)(T.C,{children:e.backgroundTasks.description})]}),0===u.length?(0,s.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:e.backgroundTasks.empty}):(0,s.jsx)("ul",{className:"space-y-2",children:u.map(t=>{var a,r;let l;return(0,s.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:["running"===t.status&&(0,s.jsx)(b.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===t.status&&(0,s.jsx)(ep.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===t.status&&(0,s.jsx)(e4.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,s.jsxs)("div",{className:"font-medium",children:[e.backgroundTasks.kinds[t.kind],(0,s.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",e.backgroundTasks.status[t.status]]})]}),t.subject&&(0,s.jsx)("div",{className:"break-words text-muted-foreground",children:t.subject}),t.progress&&t.progress.total>0&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,s.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(t.progress.done/t.progress.total*100)}%`}})}),(0,s.jsxs)("div",{className:"text-xs text-muted-foreground",children:[e.backgroundTasks.progress.replace("{done}",String(t.progress.done)).replace("{total}",String(t.progress.total)),t.progress.failed>0&&` \xb7 ${e.backgroundTasks.failedCount.replace("{count}",String(t.progress.failed))}`]})]}),t.error&&(0,s.jsx)("div",{className:"text-xs text-destructive",children:(s=>{if(!s)return null;let t=e.backgroundTasks.errors[s]??e.errors[s];return"string"==typeof t?t:s})(t.error)}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:e.backgroundTasks.startedAt.replace("{time}",(0,E.r)(t.startedAt,"HH:mm:ss",i))}),(0,s.jsx)("span",{children:e.backgroundTasks.elapsed.replace("{time}",(a=t.startedAt,r=t.finishedAt,l=Math.max(0,Math.round(((r?Date.parse(r):h)-Date.parse(a))/1e3)),`${Math.floor(l/60)}:${String(l%60).padStart(2,"0")}`))}),t.link&&(0,s.jsx)(n.default,{href:t.link,className:"text-primary hover:underline",onClick:()=>m(!1),children:e.backgroundTasks.view})]})]})]})},t.id)})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.backgroundTasks.retentionHint}),y&&(0,s.jsx)(C.f,{variant:"ghost",size:"sm",onClick:w,children:e.backgroundTasks.clearFinished})]})]})})]})}var e6=e.i(37727);let e8={success:{icon:ep.f,className:"text-success"},error:{icon:e4.f,className:"text-destructive"},warning:{icon:f,className:"text-warning"},info:{icon:v,className:"text-primary"}};function e7(){let{t:e}=(0,t.b)(),[a,r]=(0,g.useState)([]),[i,n]=(0,g.useState)(null);return(0,g.useEffect)(()=>(0,H.M)(e=>{r(e.toasts),n(e.confirm)}),[]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4 print:hidden",role:"status","aria-live":"polite",children:a.map(t=>{let{icon:a,className:r}=e8[t.type];return(0,s.jsxs)("div",{className:"pointer-events-auto flex w-full max-w-sm items-start gap-3 rounded-xl border bg-card/95 px-4 py-3 text-sm shadow-lg backdrop-blur animate-in fade-in slide-in-from-top-2 duration-200",children:[(0,s.jsx)(a,{className:(0,F.f)("mt-0.5 h-4 w-4 shrink-0",r)}),(0,s.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:t.message}),(0,s.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,H.p)(t.id),"aria-label":e.common.close,children:(0,s.jsx)(e6.X,{className:"h-3.5 w-3.5"})})]},t.id)})}),(0,s.jsx)(T.N,{open:!!i,onOpenChange:e=>{e||i?.resolve(!1)},children:(0,s.jsxs)(T.d,{className:"sm:max-w-md",children:[(0,s.jsxs)(T.s,{children:[(0,s.jsxs)(T.F,{className:"flex items-center gap-2",children:[i?.destructive&&(0,s.jsx)(f,{className:"h-5 w-5 text-destructive"}),i?.title||e.common.confirmTitle]}),(0,s.jsx)(T.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:i?.message})]}),(0,s.jsxs)(T.c,{className:"gap-2",children:[(0,s.jsx)(C.f,{variant:"outline",onClick:()=>i?.resolve(!1),children:i?.cancelText||e.common.cancel}),(0,s.jsx)(C.f,{variant:i?.destructive?"destructive":"default",onClick:()=>i?.resolve(!0),autoFocus:!0,children:i?.confirmText||e.common.confirm})]})]})})]})}function e9(){return(0,g.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(e=>{V.f.warn("[PWA]","Service worker registration failed",{error:String(e)})})},[]),null}e.s(["Providers",0,function({children:e,timeZone:i}){return(0,s.jsx)(a.SessionProvider,{children:(0,s.jsx)(t.w,{children:(0,s.jsxs)(r.n,{initialTimeZone:i,children:[(0,s.jsx)(e1,{children:e}),(0,s.jsx)(e5,{}),(0,s.jsx)(e7,{}),(0,s.jsx)(e9,{})]})})})}],1661)}]);
|