From ca160f6591df3091b0cf8101f4e7560496074ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E6=A2=93=E6=9F=92?= <1787882683@qq.com> Date: Tue, 2 Dec 2025 15:48:52 +0800 Subject: [PATCH] WebUI 0.11.6 --- webui/dist/assets/{index-DuFwC87p.js => index-DJb_iiTR.js} | 2 +- webui/dist/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename webui/dist/assets/{index-DuFwC87p.js => index-DJb_iiTR.js} (92%) diff --git a/webui/dist/assets/index-DuFwC87p.js b/webui/dist/assets/index-DJb_iiTR.js similarity index 92% rename from webui/dist/assets/index-DuFwC87p.js rename to webui/dist/assets/index-DJb_iiTR.js index ee71a6a6..886bc66f 100644 --- a/webui/dist/assets/index-DuFwC87p.js +++ b/webui/dist/assets/index-DJb_iiTR.js @@ -12,7 +12,7 @@ ${c.map(([x,f])=>{const j=f.theme?.[d]||f.color;return j?` --color-${x}: ${j};` `)} } `).join(` -`)}}):null},ir=UN,ti=u.forwardRef(({active:n,payload:i,className:c,indicator:d="dot",hideLabel:h=!1,hideIndicator:x=!1,label:f,labelFormatter:j,labelClassName:p,formatter:w,color:v,nameKey:y,labelKey:S},C)=>{const{config:M}=vg(),F=u.useMemo(()=>{if(h||!i?.length)return null;const[O]=i,K=`${S||O?.dataKey||O?.name||"value"}`,H=Lu(M,O,K),A=!S&&typeof f=="string"?M[f]?.label||f:H?.label;return j?e.jsx("div",{className:$("font-medium",p),children:j(A,i)}):A?e.jsx("div",{className:$("font-medium",p),children:A}):null},[f,j,i,h,p,M,S]);if(!n||!i?.length)return null;const U=i.length===1&&d!=="dot";return e.jsxs("div",{ref:C,className:$("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",c),children:[U?null:F,e.jsx("div",{className:"grid gap-1.5",children:i.filter(O=>O.type!=="none").map((O,K)=>{const H=`${y||O.name||O.dataKey||"value"}`,A=Lu(M,O,H),V=v||O.payload.fill||O.color;return e.jsx("div",{className:$("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",d==="dot"&&"items-center"),children:w&&O?.value!==void 0&&O.name?w(O.value,O.name,O,K,O.payload):e.jsxs(e.Fragment,{children:[A?.icon?e.jsx(A.icon,{}):!x&&e.jsx("div",{className:$("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":d==="dot","w-1":d==="line","w-0 border-[1.5px] border-dashed bg-transparent":d==="dashed","my-0.5":U&&d==="dashed"}),style:{"--color-bg":V,"--color-border":V}}),e.jsxs("div",{className:$("flex flex-1 justify-between leading-none",U?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[U?F:null,e.jsx("span",{className:"text-muted-foreground",children:A?.label||O.name})]}),O.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:O.value.toLocaleString()})]})]})},O.dataKey)})})]})});ti.displayName="ChartTooltip";const ky=BN,Ng=u.forwardRef(({className:n,hideIcon:i=!1,payload:c,verticalAlign:d="bottom",nameKey:h},x)=>{const{config:f}=vg();return c?.length?e.jsx("div",{ref:x,className:$("flex items-center justify-center gap-4",d==="top"?"pb-3":"pt-3",n),children:c.filter(j=>j.type!=="none").map(j=>{const p=`${h||j.dataKey||"value"}`,w=Lu(f,j,p);return e.jsxs("div",{className:$("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[w?.icon&&!i?e.jsx(w.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:j.color}}),w?.label]},j.value)})}):null});Ng.displayName="ChartLegend";function Lu(n,i,c){if(typeof i!="object"||i===null)return;const d="payload"in i&&typeof i.payload=="object"&&i.payload!==null?i.payload:void 0;let h=c;return c in i&&typeof i[c]=="string"?h=i[c]:d&&c in d&&typeof d[c]=="string"&&(h=d[c]),h in n?n[h]:n[c]}const gr=ci("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),N=u.forwardRef(({className:n,variant:i,size:c,asChild:d=!1,...h},x)=>{const f=d?$N:"button";return e.jsx(f,{className:$(gr({variant:i,size:c,className:n})),ref:x,...h})});N.displayName="Button";const Ty=ci("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ye({className:n,variant:i,...c}){return e.jsx("div",{className:$(Ty({variant:i}),n),...c})}const Ey=5,zy=5e3;let ku=0;function Ay(){return ku=(ku+1)%Number.MAX_SAFE_INTEGER,ku.toString()}const Tu=new Map,ep=n=>{if(Tu.has(n))return;const i=setTimeout(()=>{Tu.delete(n),hr({type:"REMOVE_TOAST",toastId:n})},zy);Tu.set(n,i)},My=(n,i)=>{switch(i.type){case"ADD_TOAST":return{...n,toasts:[i.toast,...n.toasts].slice(0,Ey)};case"UPDATE_TOAST":return{...n,toasts:n.toasts.map(c=>c.id===i.toast.id?{...c,...i.toast}:c)};case"DISMISS_TOAST":{const{toastId:c}=i;return c?ep(c):n.toasts.forEach(d=>{ep(d.id)}),{...n,toasts:n.toasts.map(d=>d.id===c||c===void 0?{...d,open:!1}:d)}}case"REMOVE_TOAST":return i.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(c=>c.id!==i.toastId)}}},Kc=[];let Jc={toasts:[]};function hr(n){Jc=My(Jc,n),Kc.forEach(i=>{i(Jc)})}function Dy({...n}){const i=Ay(),c=h=>hr({type:"UPDATE_TOAST",toast:{...h,id:i}}),d=()=>hr({type:"DISMISS_TOAST",toastId:i});return hr({type:"ADD_TOAST",toast:{...n,id:i,open:!0,onOpenChange:h=>{h||d()}}}),{id:i,dismiss:d,update:c}}function Gs(){const[n,i]=u.useState(Jc);return u.useEffect(()=>(Kc.push(i),()=>{const c=Kc.indexOf(i);c>-1&&Kc.splice(c,1)}),[n]),{...n,toast:Dy,dismiss:c=>hr({type:"DISMISS_TOAST",toastId:c})}}const Oy=n=>{const i=[];for(let c=0;c{try{C(!0);const k=await Bc.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");y({hitokoto:k.data.hitokoto,from:k.data.from||k.data.from_who||"未知"})}catch(k){console.error("获取一言失败:",k),y({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{C(!1)}},[]),A=u.useCallback(async()=>{try{const k=localStorage.getItem("access-token"),se=await Bc.get("/api/webui/system/status",{headers:{Authorization:`Bearer ${k}`}});F(se.data)}catch(k){console.error("获取机器人状态失败:",k),F(null)}},[]),V=async()=>{if(!U)try{O(!0);const k=localStorage.getItem("access-token");await Bc.post("/api/webui/system/restart",{},{headers:{Authorization:`Bearer ${k}`}}),K({title:"重启中",description:"麦麦正在重启,请稍候..."}),setTimeout(()=>{A(),O(!1)},3e3)}catch(k){console.error("重启失败:",k),K({title:"重启失败",description:"无法重启麦麦,请检查控制台",variant:"destructive"}),O(!1)}},Q=u.useCallback(async()=>{try{const k=localStorage.getItem("access-token"),se=await Bc.get(`/api/webui/statistics/dashboard?hours=${f}`,{headers:{Authorization:`Bearer ${k}`}});i(se.data),d(!1),x(100)}catch(k){console.error("Failed to fetch dashboard data:",k),d(!1),x(100)}},[f]);if(u.useEffect(()=>{if(!c)return;x(0);const k=setTimeout(()=>x(15),200),se=setTimeout(()=>x(30),800),_=setTimeout(()=>x(45),2e3),ue=setTimeout(()=>x(60),4e3),ie=setTimeout(()=>x(75),6500),ae=setTimeout(()=>x(85),9e3),fe=setTimeout(()=>x(92),11e3);return()=>{clearTimeout(k),clearTimeout(se),clearTimeout(_),clearTimeout(ue),clearTimeout(ie),clearTimeout(ae),clearTimeout(fe)}},[c]),u.useEffect(()=>{Q(),H(),A()},[Q,H,A]),u.useEffect(()=>{if(!p)return;const k=setInterval(()=>{Q(),A()},3e4);return()=>clearInterval(k)},[p,Q,A]),c||!n)return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:e.jsxs("div",{className:"text-center space-y-6 w-full max-w-md px-4",children:[e.jsx(Ct,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-lg font-medium",children:"加载统计数据中..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"正在获取麦麦运行数据"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(wr,{value:h,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[h,"%"]})]})]})});const{summary:T,model_stats:D=[],hourly_data:ne=[],daily_data:xe=[],recent_activity:_e=[]}=n,Se=T??{total_requests:0,total_cost:0,total_tokens:0,online_time:0,total_messages:0,total_replies:0,avg_response_time:0,cost_per_hour:0,tokens_per_hour:0},ge=k=>{const se=Math.floor(k/3600),_=Math.floor(k%3600/60);return`${se}小时${_}分钟`},ye=k=>new Date(k).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),be=Oy(D.length),z=D.map((k,se)=>({name:k.model_name,value:k.request_count,fill:be[se]})),X={requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"},tokens:{label:"Tokens",color:"hsl(var(--chart-3))"}};return e.jsx(ss,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"实时监控面板"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"麦麦运行状态和统计数据一览"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(La,{value:f.toString(),onValueChange:k=>j(Number(k)),children:e.jsxs(wa,{className:"grid grid-cols-3 w-full sm:w-auto",children:[e.jsx(fs,{value:"24",children:"24小时"}),e.jsx(fs,{value:"168",children:"7天"}),e.jsx(fs,{value:"720",children:"30天"})]})}),e.jsxs(N,{variant:p?"default":"outline",size:"sm",onClick:()=>w(!p),className:"gap-2",children:[e.jsx(Ct,{className:`h-4 w-4 ${p?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"自动刷新"})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:Q,children:e.jsx(Ct,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg border border-dashed border-muted-foreground/30 bg-muted/20",children:[S?e.jsx(gg,{className:"h-5 flex-1"}):v?e.jsxs("p",{className:"flex-1 text-sm text-muted-foreground italic truncate",children:['"',v.hitokoto,'" —— ',v.from]}):null,e.jsx(N,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:H,disabled:S,children:e.jsx(Ct,{className:`h-3.5 w-3.5 ${S?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-3",children:[e.jsxs(Ze,{className:"lg:col-span-1",children:[e.jsx(ys,{className:"pb-3",children:e.jsxs(ws,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4"}),"麦麦状态"]})}),e.jsx(Ts,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:M?.running?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),e.jsxs(Ye,{variant:"outline",className:"text-green-600 border-green-300 bg-green-50",children:[e.jsx(fa,{className:"h-3 w-3 mr-1"}),"运行中"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-red-500"}),e.jsxs(Ye,{variant:"outline",className:"text-red-600 border-red-300 bg-red-50",children:[e.jsx(Oa,{className:"h-3 w-3 mr-1"}),"已停止"]})]})}),M&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("span",{children:["v",M.version]}),e.jsx("span",{className:"mx-2",children:"|"}),e.jsxs("span",{children:["运行 ",ge(M.uptime)]})]})]})})]}),e.jsxs(Ze,{className:"lg:col-span-2",children:[e.jsx(ys,{className:"pb-3",children:e.jsxs(ws,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"快速操作"]})}),e.jsx(Ts,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:V,disabled:U,className:"gap-2",children:[e.jsx(Zc,{className:`h-4 w-4 ${U?"animate-spin":""}`}),U?"重启中...":"重启麦麦"]}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yc,{to:"/logs",children:[e.jsx(Da,{className:"h-4 w-4"}),"查看日志"]})}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yc,{to:"/plugins",children:[e.jsx(cb,{className:"h-4 w-4"}),"插件管理"]})}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yc,{to:"/settings",children:[e.jsx(oi,{className:"h-4 w-4"}),"系统设置"]})})]})})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(ob,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsx("div",{className:"text-2xl font-bold",children:Se.total_requests.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",f<48?f+"小时":Math.floor(f/24)+"天"]})]})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"总花费"}),e.jsx(db,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Se.total_cost.toFixed(2)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Se.cost_per_hour>0?`¥${Se.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx(Ic,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(Se.total_tokens/1e3).toFixed(1),"K"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Se.tokens_per_hour>0?`${(Se.tokens_per_hour/1e3).toFixed(1)}K/小时`:"暂无数据"})]})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(cn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[Se.avg_response_time.toFixed(2),"s"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"API平均耗时"})]})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-3",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(li,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Ts,{children:e.jsx("div",{className:"text-xl font-bold",children:ge(Se.online_time)})})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsx("div",{className:"text-xl font-bold",children:Se.total_messages.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",Se.total_replies.toLocaleString()," 条"]})]})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(ub,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsx("div",{className:"text-xl font-bold",children:Se.total_messages>0?`¥${(Se.total_cost/Se.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(La,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs(wa,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[e.jsx(fs,{value:"trends",children:"趋势"}),e.jsx(fs,{value:"models",children:"模型"}),e.jsx(fs,{value:"activity",children:"活动"}),e.jsx(fs,{value:"daily",children:"日统计"})]}),e.jsxs(Ms,{value:"trends",className:"space-y-4",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"请求趋势"}),e.jsxs(ct,{children:["最近",f,"小时的请求量变化"]})]}),e.jsx(Ts,{children:e.jsx(si,{config:X,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(HN,{data:ne,children:[e.jsx(Hc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(qc,{dataKey:"timestamp",tickFormatter:k=>ye(k),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ir,{content:e.jsx(ti,{labelFormatter:k=>ye(k)})}),e.jsx(qN,{type:"monotone",dataKey:"requests",stroke:"var(--color-requests)",strokeWidth:2})]})})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"花费趋势"}),e.jsx(ct,{children:"API调用成本变化"})]}),e.jsx(Ts,{children:e.jsx(si,{config:X,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(bu,{data:ne,children:[e.jsx(Hc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(qc,{dataKey:"timestamp",tickFormatter:k=>ye(k),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ir,{content:e.jsx(ti,{labelFormatter:k=>ye(k)})}),e.jsx(Gc,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"Token消耗"}),e.jsx(ct,{children:"Token使用量变化"})]}),e.jsx(Ts,{children:e.jsx(si,{config:X,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(bu,{data:ne,children:[e.jsx(Hc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(qc,{dataKey:"timestamp",tickFormatter:k=>ye(k),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ir,{content:e.jsx(ti,{labelFormatter:k=>ye(k)})}),e.jsx(Gc,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(Ms,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"模型请求分布"}),e.jsxs(ct,{children:["各模型使用占比 (共 ",D.length," 个模型)"]})]}),e.jsx(Ts,{children:e.jsx(si,{config:Object.fromEntries(D.map((k,se)=>[k.model_name,{label:k.model_name,color:be[se]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(GN,{children:[e.jsx(ir,{content:e.jsx(ti,{})}),e.jsx(VN,{data:z,cx:"50%",cy:"50%",labelLine:!1,label:({name:k,percent:se})=>se&&se<.05?"":`${k} ${se?(se*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:z.map((k,se)=>e.jsx(FN,{fill:k.fill},`cell-${se}`))})]})})})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"模型详细统计"}),e.jsx(ct,{children:"请求数、花费和性能"})]}),e.jsx(Ts,{children:e.jsx(ss,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:D.map((k,se)=>e.jsxs("div",{className:"p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"font-semibold text-sm truncate flex-1 min-w-0",children:k.model_name}),e.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--chart-${se%5+1}))`}})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"请求数:"}),e.jsx("span",{className:"ml-1 font-medium",children:k.request_count.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1 font-medium",children:["¥",k.total_cost.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[(k.total_tokens/1e3).toFixed(1),"K"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"平均耗时:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[k.avg_response_time.toFixed(2),"s"]})]})]})]},se))})})})]})]})}),e.jsx(Ms,{value:"activity",children:e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"最近活动"}),e.jsx(ct,{children:"最新的API调用记录"})]}),e.jsx(Ts,{children:e.jsx(ss,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:_e.map((k,se)=>e.jsxs("div",{className:"p-3 sm:p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:k.model}),e.jsx("div",{className:"text-xs text-muted-foreground",children:k.request_type})]}),e.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:ye(k.timestamp)})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsx("span",{className:"ml-1",children:k.tokens})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1",children:["¥",k.cost.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"耗时:"}),e.jsxs("span",{className:"ml-1",children:[k.time_cost.toFixed(2),"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"状态:"}),e.jsx("span",{className:`ml-1 ${k.status==="success"?"text-green-600":"text-red-600"}`,children:k.status})]})]})]},se))})})})]})}),e.jsx(Ms,{value:"daily",children:e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"每日统计"}),e.jsx(ct,{children:"最近7天的数据汇总"})]}),e.jsx(Ts,{children:e.jsx(si,{config:{requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"}},className:"h-[400px] sm:h-[500px] w-full aspect-auto",children:e.jsxs(bu,{data:xe,children:[e.jsx(Hc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(qc,{dataKey:"timestamp",tickFormatter:k=>{const se=new Date(k);return`${se.getMonth()+1}/${se.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ir,{content:e.jsx(ti,{labelFormatter:k=>new Date(k).toLocaleDateString("zh-CN")})}),e.jsx(ky,{content:e.jsx(Ng,{})}),e.jsx(Gc,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(Gc,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]})]})})}const Ly={theme:"system",setTheme:()=>null},bg=u.createContext(Ly),$u=()=>{const n=u.useContext(bg);if(n===void 0)throw new Error("useTheme must be used within a ThemeProvider");return n},Uy=(n,i,c)=>{const d=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||d){i(n);return}const h=c.clientX,x=c.clientY,f=Math.hypot(Math.max(h,innerWidth-h),Math.max(x,innerHeight-x));document.startViewTransition(()=>{i(n)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${h}px ${x}px)`,`circle(${f}px at ${h}px ${x}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},yg=u.createContext(void 0),wg=()=>{const n=u.useContext(yg);if(n===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return n},Xe=u.forwardRef(({className:n,...i},c)=>e.jsx(Cp,{className:$("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n),...i,ref:c,children:e.jsx(wN,{className:$("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Xe.displayName=Cp.displayName;const By=ci("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),b=u.forwardRef(({className:n,...i},c)=>e.jsx(Hp,{ref:c,className:$(By(),n),...i}));b.displayName=Hp.displayName;const oe=u.forwardRef(({className:n,type:i,...c},d)=>e.jsx("input",{type:i,className:$("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:d,...c}));oe.displayName="Input";const Hy=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:n=>n.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:n=>/[A-Z]/.test(n)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:n=>/[a-z]/.test(n)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:n=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(n)}];function qy(n){const i=Hy.map(d=>({id:d.id,label:d.label,description:d.description,passed:d.validate(n)}));return{isValid:i.every(d=>d.passed),rules:i}}const Qu="0.11.6 Beta",Yu="MaiBot Dashboard",Gy=`${Yu} v${Qu}`,Vy=(n="v")=>`${n}${Qu}`,Ft={THEME:"maibot-ui-theme",ACCENT_COLOR:"accent-color",ENABLE_ANIMATIONS:"maibot-animations",ENABLE_WAVES_BACKGROUND:"maibot-waves-background",LOG_CACHE_SIZE:"maibot-log-cache-size",LOG_AUTO_SCROLL:"maibot-log-auto-scroll",LOG_FONT_SIZE:"maibot-log-font-size",LOG_LINE_SPACING:"maibot-log-line-spacing",DATA_SYNC_INTERVAL:"maibot-data-sync-interval",WS_RECONNECT_INTERVAL:"maibot-ws-reconnect-interval",WS_MAX_RECONNECT_ATTEMPTS:"maibot-ws-max-reconnect-attempts",COMPLETED_TOURS:"maibot-completed-tours"},Aa={theme:"system",accentColor:"blue",enableAnimations:!0,enableWavesBackground:!0,logCacheSize:1e3,logAutoScroll:!0,logFontSize:"xs",logLineSpacing:4,dataSyncInterval:30,wsReconnectInterval:3e3,wsMaxReconnectAttempts:10};function st(n){const i=_g(n),c=localStorage.getItem(i);if(c===null)return Aa[n];const d=Aa[n];if(typeof d=="boolean")return c==="true";if(typeof d=="number"){const h=parseFloat(c);return isNaN(h)?d:h}return c}function ai(n,i){const c=_g(n);localStorage.setItem(c,String(i)),window.dispatchEvent(new CustomEvent("maibot-settings-change",{detail:{key:n,value:i}}))}function Fy(){return{theme:st("theme"),accentColor:st("accentColor"),enableAnimations:st("enableAnimations"),enableWavesBackground:st("enableWavesBackground"),logCacheSize:st("logCacheSize"),logAutoScroll:st("logAutoScroll"),logFontSize:st("logFontSize"),logLineSpacing:st("logLineSpacing"),dataSyncInterval:st("dataSyncInterval"),wsReconnectInterval:st("wsReconnectInterval"),wsMaxReconnectAttempts:st("wsMaxReconnectAttempts")}}function $y(){const n=Fy(),i=localStorage.getItem(Ft.COMPLETED_TOURS),c=i?JSON.parse(i):[];return{...n,completedTours:c}}function Qy(n){const i=[],c=[];for(const[d,h]of Object.entries(n)){if(d==="completedTours"){Array.isArray(h)?(localStorage.setItem(Ft.COMPLETED_TOURS,JSON.stringify(h)),i.push("completedTours")):c.push("completedTours");continue}if(d in Aa){const x=d,f=Aa[x];if(typeof h==typeof f){if(x==="theme"&&!["light","dark","system"].includes(h)){c.push(d);continue}if(x==="logFontSize"&&!["xs","sm","base"].includes(h)){c.push(d);continue}ai(x,h),i.push(d)}else c.push(d)}else c.push(d)}return{success:i.length>0,imported:i,skipped:c}}function Yy(){for(const n of Object.keys(Aa))ai(n,Aa[n]);localStorage.removeItem(Ft.COMPLETED_TOURS),window.dispatchEvent(new CustomEvent("maibot-settings-reset"))}function Xy(){const n=[],i=[],c=[];for(let d=0;dd.size-c.size),{used:n,items:localStorage.length,details:i}}function Ky(n){if(n===0)return"0 B";const i=1024,c=["B","KB","MB"],d=Math.floor(Math.log(n)/Math.log(i));return parseFloat((n/Math.pow(i,d)).toFixed(2))+" "+c[d]}function _g(n){return{theme:Ft.THEME,accentColor:Ft.ACCENT_COLOR,enableAnimations:Ft.ENABLE_ANIMATIONS,enableWavesBackground:Ft.ENABLE_WAVES_BACKGROUND,logCacheSize:Ft.LOG_CACHE_SIZE,logAutoScroll:Ft.LOG_AUTO_SCROLL,logFontSize:Ft.LOG_FONT_SIZE,logLineSpacing:Ft.LOG_LINE_SPACING,dataSyncInterval:Ft.DATA_SYNC_INTERVAL,wsReconnectInterval:Ft.WS_RECONNECT_INTERVAL,wsMaxReconnectAttempts:Ft.WS_MAX_RECONNECT_ATTEMPTS}[n]}const Ma=u.forwardRef(({className:n,...i},c)=>e.jsxs(kp,{ref:c,className:$("relative flex w-full touch-none select-none items-center",n),...i,children:[e.jsx(_N,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(SN,{className:"absolute h-full bg-primary"})}),e.jsx(CN,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));Ma.displayName=kp.displayName;class Jy{ws=null;reconnectTimeout=null;reconnectAttempts=0;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];getMaxCacheSize(){return st("logCacheSize")}getMaxReconnectAttempts(){return st("wsMaxReconnectAttempts")}getReconnectInterval(){return st("wsReconnectInterval")}getWebSocketUrl(){{const i=window.location.protocol==="https:"?"wss:":"ws:",c=window.location.host;return`${i}//${c}/ws/logs`}}connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;const i=this.getWebSocketUrl();try{this.ws=new WebSocket(i),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=c=>{try{if(c.data==="pong")return;const d=JSON.parse(c.data);this.notifyLog(d)}catch(d){console.error("解析日志消息失败:",d)}},this.ws.onerror=c=>{console.error("❌ WebSocket 错误:",c),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(c){console.error("创建 WebSocket 连接失败:",c),this.attemptReconnect()}}attemptReconnect(){const i=this.getMaxReconnectAttempts();if(this.reconnectAttempts>=i)return;this.reconnectAttempts+=1;const c=this.getReconnectInterval(),d=Math.min(c*this.reconnectAttempts,3e4);this.reconnectTimeout=window.setTimeout(()=>{this.connect()},d)}startHeartbeat(){this.heartbeatInterval=window.setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send("ping")},3e4)}stopHeartbeat(){this.heartbeatInterval!==null&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}disconnect(){this.reconnectTimeout!==null&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.stopHeartbeat(),this.ws&&(this.ws.close(),this.ws=null),this.isConnected=!1,this.reconnectAttempts=0}onLog(i){return this.logCallbacks.add(i),()=>this.logCallbacks.delete(i)}onConnectionChange(i){return this.connectionCallbacks.add(i),i(this.isConnected),()=>this.connectionCallbacks.delete(i)}notifyLog(i){if(!this.logCache.some(d=>d.id===i.id)){this.logCache.push(i);const d=this.getMaxCacheSize();this.logCache.length>d&&(this.logCache=this.logCache.slice(-d)),this.logCallbacks.forEach(h=>{try{h(i)}catch(x){console.error("日志回调执行失败:",x)}})}}notifyConnection(i){this.connectionCallbacks.forEach(c=>{try{c(i)}catch(d){console.error("连接状态回调执行失败:",d)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const rn=new Jy;typeof window<"u"&&rn.connect();const $s=XN,Xu=KN,Zy=QN,Sg=u.forwardRef(({className:n,...i},c)=>e.jsx(qp,{ref:c,className:$("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...i}));Sg.displayName=qp.displayName;const Bs=u.forwardRef(({className:n,children:i,preventOutsideClose:c=!1,...d},h)=>e.jsxs(Zy,{children:[e.jsx(Sg,{}),e.jsxs(Gp,{ref:h,className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),onPointerDownOutside:c?x=>x.preventDefault():void 0,onInteractOutside:c?x=>x.preventDefault():void 0,...d,children:[i,e.jsxs(YN,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(dl,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Bs.displayName=Gp.displayName;const Hs=({className:n,...i})=>e.jsx("div",{className:$("flex flex-col space-y-1.5 text-center sm:text-left",n),...i});Hs.displayName="DialogHeader";const at=({className:n,...i})=>e.jsx("div",{className:$("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...i});at.displayName="DialogFooter";const qs=u.forwardRef(({className:n,...i},c)=>e.jsx(Vp,{ref:c,className:$("text-lg font-semibold leading-none tracking-tight",n),...i}));qs.displayName=Vp.displayName;const Is=u.forwardRef(({className:n,...i},c)=>e.jsx(Fp,{ref:c,className:$("text-sm text-muted-foreground",n),...i}));Is.displayName=Fp.displayName;const ps=TN,tt=EN,Iy=kN,Cg=u.forwardRef(({className:n,...i},c)=>e.jsx(Tp,{className:$("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...i,ref:c}));Cg.displayName=Tp.displayName;const is=u.forwardRef(({className:n,...i},c)=>e.jsxs(Iy,{children:[e.jsx(Cg,{}),e.jsx(Ep,{ref:c,className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...i})]}));is.displayName=Ep.displayName;const rs=({className:n,...i})=>e.jsx("div",{className:$("flex flex-col space-y-2 text-center sm:text-left",n),...i});rs.displayName="AlertDialogHeader";const cs=({className:n,...i})=>e.jsx("div",{className:$("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...i});cs.displayName="AlertDialogFooter";const os=u.forwardRef(({className:n,...i},c)=>e.jsx(zp,{ref:c,className:$("text-lg font-semibold",n),...i}));os.displayName=zp.displayName;const ds=u.forwardRef(({className:n,...i},c)=>e.jsx(Ap,{ref:c,className:$("text-sm text-muted-foreground",n),...i}));ds.displayName=Ap.displayName;const us=u.forwardRef(({className:n,...i},c)=>e.jsx(Mp,{ref:c,className:$(gr(),n),...i}));us.displayName=Mp.displayName;const ms=u.forwardRef(({className:n,...i},c)=>e.jsx(Dp,{ref:c,className:$(gr({variant:"outline"}),"mt-2 sm:mt-0",n),...i}));ms.displayName=Dp.displayName;function Py(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"系统设置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理您的应用偏好设置"})]})}),e.jsxs(La,{defaultValue:"appearance",className:"w-full",children:[e.jsxs(wa,{className:"grid w-full grid-cols-2 sm:grid-cols-4 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs(fs,{value:"appearance",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(mb,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"外观"})]}),e.jsxs(fs,{value:"security",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(hb,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"安全"})]}),e.jsxs(fs,{value:"other",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(oi,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"其他"})]}),e.jsxs(fs,{value:"about",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Ra,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(ss,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(Ms,{value:"appearance",className:"mt-0",children:e.jsx(Wy,{})}),e.jsx(Ms,{value:"security",className:"mt-0",children:e.jsx(e0,{})}),e.jsx(Ms,{value:"other",className:"mt-0",children:e.jsx(s0,{})}),e.jsx(Ms,{value:"about",className:"mt-0",children:e.jsx(t0,{})})]})]})]})}function tp(n){const i=document.documentElement,d={blue:{hsl:"221.2 83.2% 53.3%",darkHsl:"217.2 91.2% 59.8%",gradient:null},purple:{hsl:"271 91% 65%",darkHsl:"270 95% 75%",gradient:null},green:{hsl:"142 71% 45%",darkHsl:"142 76% 36%",gradient:null},orange:{hsl:"25 95% 53%",darkHsl:"20 90% 48%",gradient:null},pink:{hsl:"330 81% 60%",darkHsl:"330 85% 70%",gradient:null},red:{hsl:"0 84% 60%",darkHsl:"0 90% 70%",gradient:null},"gradient-sunset":{hsl:"15 95% 60%",darkHsl:"15 95% 65%",gradient:"linear-gradient(135deg, hsl(25 95% 53%) 0%, hsl(330 81% 60%) 100%)"},"gradient-ocean":{hsl:"200 90% 55%",darkHsl:"200 90% 60%",gradient:"linear-gradient(135deg, hsl(221.2 83.2% 53.3%) 0%, hsl(189 94% 43%) 100%)"},"gradient-forest":{hsl:"150 70% 45%",darkHsl:"150 75% 40%",gradient:"linear-gradient(135deg, hsl(142 71% 45%) 0%, hsl(158 64% 52%) 100%)"},"gradient-aurora":{hsl:"310 85% 65%",darkHsl:"310 90% 70%",gradient:"linear-gradient(135deg, hsl(271 91% 65%) 0%, hsl(330 81% 60%) 100%)"},"gradient-fire":{hsl:"15 95% 55%",darkHsl:"15 95% 60%",gradient:"linear-gradient(135deg, hsl(0 84% 60%) 0%, hsl(25 95% 53%) 100%)"},"gradient-twilight":{hsl:"250 90% 60%",darkHsl:"250 95% 65%",gradient:"linear-gradient(135deg, hsl(239 84% 67%) 0%, hsl(271 91% 65%) 100%)"}}[n];if(d)i.style.setProperty("--primary",d.hsl),d.gradient?(i.style.setProperty("--primary-gradient",d.gradient),i.classList.add("has-gradient")):(i.style.removeProperty("--primary-gradient"),i.classList.remove("has-gradient"));else if(n.startsWith("#")){const h=x=>{x=x.replace("#","");const f=parseInt(x.substring(0,2),16)/255,j=parseInt(x.substring(2,4),16)/255,p=parseInt(x.substring(4,6),16)/255,w=Math.max(f,j,p),v=Math.min(f,j,p);let y=0,S=0;const C=(w+v)/2;if(w!==v){const M=w-v;switch(S=C>.5?M/(2-w-v):M/(w+v),w){case f:y=((j-p)/M+(jlocalStorage.getItem("accent-color")||"blue");u.useEffect(()=>{const w=localStorage.getItem("accent-color")||"blue";tp(w)},[]);const p=w=>{j(w),localStorage.setItem("accent-color",w),tp(w)};return e.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题模式"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-4",children:[e.jsx(Eu,{value:"light",current:n,onChange:i,label:"浅色",description:"始终使用浅色主题"}),e.jsx(Eu,{value:"dark",current:n,onChange:i,label:"深色",description:"始终使用深色主题"}),e.jsx(Eu,{value:"system",current:n,onChange:i,label:"跟随系统",description:"根据系统设置自动切换"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题色"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"单色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(xa,{value:"blue",current:f,onChange:p,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(xa,{value:"purple",current:f,onChange:p,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(xa,{value:"green",current:f,onChange:p,label:"绿色",colorClass:"bg-green-500"}),e.jsx(xa,{value:"orange",current:f,onChange:p,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(xa,{value:"pink",current:f,onChange:p,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(xa,{value:"red",current:f,onChange:p,label:"红色",colorClass:"bg-red-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"渐变色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(xa,{value:"gradient-sunset",current:f,onChange:p,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(xa,{value:"gradient-ocean",current:f,onChange:p,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(xa,{value:"gradient-forest",current:f,onChange:p,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(xa,{value:"gradient-aurora",current:f,onChange:p,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(xa,{value:"gradient-fire",current:f,onChange:p,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(xa,{value:"gradient-twilight",current:f,onChange:p,label:"暮光",colorClass:"bg-gradient-to-r from-indigo-500 to-purple-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"自定义颜色"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsx("input",{type:"color",value:f.startsWith("#")?f:"#3b82f6",onChange:w=>p(w.target.value),className:"h-10 sm:h-12 w-full rounded-lg border-2 border-border cursor-pointer",title:"选择自定义颜色"})}),e.jsx("div",{className:"flex-1",children:e.jsx(oe,{type:"text",value:f,onChange:w=>p(w.target.value),placeholder:"#3b82f6",className:"font-mono text-sm"})})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground mt-2",children:"点击色块选择颜色,或手动输入 HEX 颜色代码"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"动画效果"}),e.jsxs("div",{className:"space-y-2 sm:space-y-3",children:[e.jsx("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(b,{htmlFor:"animations",className:"text-base font-medium cursor-pointer",children:"启用动画效果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后将禁用所有过渡动画和特效,提升性能"})]}),e.jsx(Xe,{id:"animations",checked:c,onCheckedChange:d})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(b,{htmlFor:"waves-background",className:"text-base font-medium cursor-pointer",children:"登录页波浪背景"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后登录页将使用纯色背景,适合低性能设备"})]}),e.jsx(Xe,{id:"waves-background",checked:h,onCheckedChange:x})]})})]})]})]})}function e0(){const n=ga(),[i,c]=u.useState(""),[d,h]=u.useState(""),[x,f]=u.useState(!1),[j,p]=u.useState(!1),[w,v]=u.useState(!1),[y,S]=u.useState(!1),[C,M]=u.useState(!1),[F,U]=u.useState(!1),[O,K]=u.useState(""),[H,A]=u.useState(!1),{toast:V}=Gs(),Q=u.useMemo(()=>qy(d),[d]),T=async ge=>{if(!i){V({title:"无法复制",description:"Token 存储在安全 Cookie 中,请重新生成以获取新 Token",variant:"destructive"});return}try{await navigator.clipboard.writeText(ge),M(!0),V({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>M(!1),2e3)}catch{V({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},D=async()=>{if(!d.trim()){V({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!Q.isValid){const ge=Q.rules.filter(ye=>!ye.passed).map(ye=>ye.label).join(", ");V({title:"格式错误",description:`Token 不符合要求: ${ge}`,variant:"destructive"});return}v(!0);try{const ge=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_token:d.trim()})}),ye=await ge.json();ge.ok&&ye.success?(h(""),c(d.trim()),V({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{n({to:"/auth"})},1500)):V({title:"更新失败",description:ye.message||"无法更新 Token",variant:"destructive"})}catch(ge){console.error("更新 Token 错误:",ge),V({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{v(!1)}},ne=async()=>{S(!0);try{const ge=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),ye=await ge.json();ge.ok&&ye.success?(c(ye.token),K(ye.token),U(!0),A(!1),V({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):V({title:"生成失败",description:ye.message||"无法生成新 Token",variant:"destructive"})}catch(ge){console.error("生成 Token 错误:",ge),V({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{S(!1)}},xe=async()=>{try{await navigator.clipboard.writeText(O),A(!0),V({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{V({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},_e=()=>{U(!1),setTimeout(()=>{K(""),A(!1)},300),setTimeout(()=>{n({to:"/auth"})},500)},Se=ge=>{ge||_e()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx($s,{open:F,onOpenChange:Se,children:e.jsxs(Bs,{className:"sm:max-w-md",children:[e.jsxs(Hs,{children:[e.jsxs(qs,{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"h-5 w-5 text-yellow-500"}),"新的 Access Token"]}),e.jsx(Is,{children:"这是您的新 Token,请立即保存。关闭此窗口后将跳转到登录页面。"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border-2 border-primary/20 bg-primary/5 p-4",children:[e.jsx(b,{className:"text-xs text-muted-foreground mb-2 block",children:"您的新 Token (64位安全令牌)"}),e.jsx("div",{className:"font-mono text-sm break-all select-all bg-background p-3 rounded border",children:O})]}),e.jsx("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ya,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-300 space-y-1",children:[e.jsx("p",{className:"font-semibold",children:"重要提示"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-xs",children:[e.jsx("li",{children:"此 Token 仅显示一次,关闭后无法再查看"}),e.jsx("li",{children:"请立即复制并保存到安全的位置"}),e.jsx("li",{children:"关闭窗口后将自动跳转到登录页面"}),e.jsx("li",{children:"请使用新 Token 重新登录系统"})]})]})]})})]}),e.jsxs(at,{className:"gap-2 sm:gap-0",children:[e.jsx(N,{variant:"outline",onClick:xe,className:"gap-2",children:H?e.jsxs(e.Fragment,{children:[e.jsx(sa,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pc,{className:"h-4 w-4"}),"复制 Token"]})}),e.jsx(N,{onClick:_e,children:"我已保存,关闭"})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"当前 Access Token"}),e.jsx("div",{className:"space-y-3 sm:space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"current-token",className:"text-sm",children:"您的访问令牌"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(oe,{id:"current-token",type:x?"text":"password",value:i||"••••••••••••••••••••••••••••••••",readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"Token 存储在安全 Cookie 中"}),e.jsx("button",{onClick:()=>{i?f(!x):V({title:"无法查看",description:'Token 存储在安全 Cookie 中,如需新 Token 请点击"重新生成"'})},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:x?"隐藏":"显示",children:x?e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Dt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(N,{variant:"outline",size:"icon",onClick:()=>T(i),title:"复制到剪贴板",className:"flex-shrink-0",disabled:!i,children:C?e.jsx(sa,{className:"h-4 w-4 text-green-500"}):e.jsx(Pc,{className:"h-4 w-4"})}),e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"outline",disabled:y,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(Ct,{className:$("h-4 w-4",y&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认重新生成 Token"}),e.jsx(ds,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:ne,children:"确认生成"})]})]})]})]})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground",children:"请妥善保管您的 Access Token,不要泄露给他人"})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"自定义 Access Token"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"new-token",className:"text-sm",children:"新的访问令牌"}),e.jsxs("div",{className:"relative",children:[e.jsx(oe,{id:"new-token",type:j?"text":"password",value:d,onChange:ge=>h(ge.target.value),className:"pr-10 font-mono text-sm",placeholder:"输入自定义 Token"}),e.jsx("button",{onClick:()=>p(!j),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:j?"隐藏":"显示",children:j?e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Dt,{className:"h-4 w-4 text-muted-foreground"})})]}),d&&e.jsxs("div",{className:"mt-3 space-y-2 p-3 rounded-lg bg-muted/50",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Token 安全要求:"}),e.jsx("div",{className:"space-y-1.5",children:Q.rules.map(ge=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[ge.passed?e.jsx(fa,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(ng,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:$(ge.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:ge.label})]},ge.id))}),Q.isValid&&e.jsx("div",{className:"mt-2 pt-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[e.jsx(sa,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(N,{onClick:D,disabled:w||!Q.isValid||!d,className:"w-full sm:w-auto",children:w?"更新中...":"更新自定义 Token"})]})]}),e.jsxs("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3 sm:p-4",children:[e.jsx("h4",{className:"text-sm sm:text-base font-semibold text-yellow-900 dark:text-yellow-200 mb-2",children:"安全提示"}),e.jsxs("ul",{className:"text-xs sm:text-sm text-yellow-800 dark:text-yellow-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"重新生成 Token 会创建系统随机生成的 64 位安全令牌"}),e.jsx("li",{children:"自定义 Token 必须满足所有安全要求才能使用"}),e.jsx("li",{children:"更新 Token 后,旧的 Token 将立即失效"}),e.jsx("li",{children:"请在安全的环境下查看和复制 Token"}),e.jsx("li",{children:"如果怀疑 Token 泄露,请立即重新生成或更新"}),e.jsx("li",{children:"建议使用系统生成的 Token 以获得最高安全性"})]})]})]})}function s0(){const n=ga(),{toast:i}=Gs(),[c,d]=u.useState(!1),[h,x]=u.useState(!1),[f,j]=u.useState(()=>st("logCacheSize")),[p,w]=u.useState(()=>st("wsReconnectInterval")),[v,y]=u.useState(()=>st("wsMaxReconnectAttempts")),[S,C]=u.useState(()=>st("dataSyncInterval")),[M,F]=u.useState(()=>sp()),[U,O]=u.useState(!1),[K,H]=u.useState(!1),A=u.useRef(null);if(h)throw new Error("这是一个手动触发的测试错误,用于验证错误边界组件是否正常工作。");const V=()=>{F(sp())},Q=z=>{const X=z[0];j(X),ai("logCacheSize",X)},T=z=>{const X=z[0];w(X),ai("wsReconnectInterval",X)},D=z=>{const X=z[0];y(X),ai("wsMaxReconnectAttempts",X)},ne=z=>{const X=z[0];C(X),ai("dataSyncInterval",X)},xe=()=>{rn.clearLogs(),i({title:"日志已清除",description:"日志缓存已清空"})},_e=()=>{const z=Xy();V(),i({title:"缓存已清除",description:`已清除 ${z.clearedKeys.length} 项缓存数据`})},Se=()=>{O(!0);try{const z=$y(),X=JSON.stringify(z,null,2),k=new Blob([X],{type:"application/json"}),se=URL.createObjectURL(k),_=document.createElement("a");_.href=se,_.download=`maibot-webui-settings-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(se),i({title:"导出成功",description:"设置已导出为 JSON 文件"})}catch(z){console.error("导出设置失败:",z),i({title:"导出失败",description:"无法导出设置",variant:"destructive"})}finally{O(!1)}},ge=z=>{const X=z.target.files?.[0];if(!X)return;H(!0);const k=new FileReader;k.onload=se=>{try{const _=se.target?.result,ue=JSON.parse(_),ie=Qy(ue);ie.success?(j(st("logCacheSize")),w(st("wsReconnectInterval")),y(st("wsMaxReconnectAttempts")),C(st("dataSyncInterval")),V(),i({title:"导入成功",description:`成功导入 ${ie.imported.length} 项设置${ie.skipped.length>0?`,跳过 ${ie.skipped.length} 项`:""}`}),(ie.imported.includes("theme")||ie.imported.includes("accentColor"))&&i({title:"提示",description:"部分设置需要刷新页面才能完全生效"})):i({title:"导入失败",description:"没有有效的设置项可导入",variant:"destructive"})}catch(_){console.error("导入设置失败:",_),i({title:"导入失败",description:"文件格式无效",variant:"destructive"})}finally{H(!1),A.current&&(A.current.value="")}},k.readAsText(X)},ye=()=>{Yy(),j(Aa.logCacheSize),w(Aa.wsReconnectInterval),y(Aa.wsMaxReconnectAttempts),C(Aa.dataSyncInterval),V(),i({title:"已重置",description:"所有设置已恢复为默认值,刷新页面以应用更改"})},be=async()=>{d(!0);try{const z=localStorage.getItem("access-token"),X=await fetch("/api/webui/setup/reset",{method:"POST",headers:{Authorization:`Bearer ${z}`}}),k=await X.json();X.ok&&k.success?(i({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{n({to:"/setup"})},1e3)):i({title:"重置失败",description:k.message||"无法重置配置状态",variant:"destructive"})}catch(z){console.error("重置配置状态错误:",z),i({title:"重置失败",description:"连接服务器失败",variant:"destructive"})}finally{d(!1)}};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(Ic,{className:"h-5 w-5"}),"性能与存储"]}),e.jsxs("div",{className:"space-y-4 sm:space-y-5",children:[e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 sm:p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(xb,{className:"h-4 w-4"}),"本地存储使用"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:V,className:"h-7 px-2",children:e.jsx(Ct,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"text-2xl font-bold text-primary",children:Ky(M.used)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[M.items," 个存储项"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"日志缓存大小"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f," 条"]})]}),e.jsx(Ma,{value:[f],onValueChange:Q,min:100,max:5e3,step:100,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制日志查看器最多缓存的日志条数,较大的值会占用更多内存"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"首页数据刷新间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[S," 秒"]})]}),e.jsx(Ma,{value:[S],onValueChange:ne,min:10,max:120,step:5,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制首页统计数据的自动刷新间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"WebSocket 重连间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[p/1e3," 秒"]})]}),e.jsx(Ma,{value:[p],onValueChange:T,min:1e3,max:1e4,step:500,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"日志 WebSocket 连接断开后的重连基础间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"WebSocket 最大重连次数"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[v," 次"]})]}),e.jsx(Ma,{value:[v],onValueChange:D,min:3,max:30,step:1,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"连接失败后的最大重连尝试次数"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:xe,className:"gap-2",children:[e.jsx(ls,{className:"h-4 w-4"}),"清除日志缓存"]}),e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(ls,{className:"h-4 w-4"}),"清除本地缓存"]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认清除本地缓存"}),e.jsx(ds,{children:"这将清除所有本地缓存的设置和数据(不包括登录凭证)。 您可能需要重新配置部分偏好设置。确定要继续吗?"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:_e,children:"确认清除"})]})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(rl,{className:"h-5 w-5"}),"导入/导出设置"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"导出当前的界面设置以便备份,或从之前导出的文件中恢复设置。"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(N,{variant:"outline",onClick:Se,disabled:U,className:"gap-2",children:[e.jsx(rl,{className:"h-4 w-4"}),U?"导出中...":"导出设置"]}),e.jsx("input",{ref:A,type:"file",accept:".json",onChange:ge,className:"hidden"}),e.jsxs(N,{variant:"outline",onClick:()=>A.current?.click(),disabled:K,className:"gap-2",children:[e.jsx(fr,{className:"h-4 w-4"}),K?"导入中...":"导入设置"]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",className:"gap-2 text-destructive hover:text-destructive",children:[e.jsx(Zc,{className:"h-4 w-4"}),"重置所有设置为默认值"]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认重置所有设置"}),e.jsx(ds,{children:"这将把所有界面设置恢复为默认值,包括主题、颜色、动画等偏好设置。 此操作不会影响您的登录状态。确定要继续吗?"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:ye,children:"确认重置"})]})]})]})})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"配置向导"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"重新进行初次配置向导,可以帮助您重新设置系统的基础配置。"})}),e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"outline",disabled:c,className:"gap-2",children:[e.jsx(Zc,{className:$("h-4 w-4",c&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认重新配置"}),e.jsx(ds,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:be,children:"确认重置"})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-dashed border-yellow-500/50 bg-yellow-500/5 p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(ya,{className:"h-5 w-5 text-yellow-500"}),"开发者工具"]}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"以下功能仅供开发调试使用,可能会导致页面崩溃或异常。"})}),e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"destructive",className:"gap-2",children:[e.jsx(ya,{className:"h-4 w-4"}),"触发测试错误"]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认触发错误"}),e.jsx(ds,{children:"这将手动触发一个 React 错误,用于测试错误边界组件的显示效果。 页面将显示错误界面,您可以通过刷新页面或点击返回首页来恢复。"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:()=>x(!0),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认触发"})]})]})]})]})]})]})}function t0(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx("div",{className:"rounded-lg border-2 border-primary/30 bg-gradient-to-r from-primary/5 to-primary/10 p-4 sm:p-6",children:e.jsxs("div",{className:"flex items-start gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-shrink-0 rounded-lg bg-primary/10 p-2 sm:p-3",children:e.jsx("svg",{className:"h-6 w-6 sm:h-8 sm:w-8 text-primary",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg sm:text-xl font-bold text-foreground mb-2",children:"开源项目"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground mb-3",children:"本项目在 GitHub 开源,欢迎 Star ⭐ 支持!"}),e.jsxs("a",{href:"https://github.com/Mai-with-u/MaiBot-Dashboard",target:"_blank",rel:"noopener noreferrer",className:$("inline-flex items-center gap-2 px-4 py-2 rounded-lg","bg-primary text-primary-foreground font-medium text-sm","hover:bg-primary/90 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:[e.jsx("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})}),"前往 GitHub",e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:["关于 ",Yu]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",Qu]}),e.jsx("p",{children:"麦麦(MaiBot)的现代化 Web 管理界面"})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"作者"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"MaiBot 核心"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Mai-with-u"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"WebUI"}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground",children:["Mai-with-u ",e.jsx("a",{href:"https://github.com/DrSmoothl",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"@MotricSeven"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"技术栈"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"前端框架"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"React 19.2.0"}),e.jsx("li",{children:"TypeScript 5.7.2"}),e.jsx("li",{children:"Vite 6.0.7"}),e.jsx("li",{children:"TanStack Router 1.94.2"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"UI 组件"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"shadcn/ui"}),e.jsx("li",{children:"Radix UI"}),e.jsx("li",{children:"Tailwind CSS 3.4.17"}),e.jsx("li",{children:"Lucide Icons"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"后端"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Python 3.12+"}),e.jsx("li",{children:"FastAPI"}),e.jsx("li",{children:"Uvicorn"}),e.jsx("li",{children:"WebSocket"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"构建工具"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Bun / npm"}),e.jsx("li",{children:"ESLint 9.17.0"}),e.jsx("li",{children:"PostCSS"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源库感谢"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mb-3",children:"本项目使用了以下优秀的开源库,感谢他们的贡献:"}),e.jsx(ss,{className:"h-[300px] sm:h-[400px]",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"UI 框架与组件"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(Zs,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(Zs,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(Zs,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(Zs,{name:"Lucide React",description:"精美的图标库",license:"ISC"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"路由与状态管理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(Zs,{name:"Zustand",description:"轻量级状态管理",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"表单处理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(Zs,{name:"Zod",description:"TypeScript 优先的 schema 验证",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"工具库"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(Zs,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(Zs,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(Zs,{name:"date-fns",description:"现代化日期处理库",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"动画效果"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(Zs,{name:"vaul",description:"抽屉组件动画",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"后端框架"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(Zs,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(Zs,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(Zs,{name:"python-multipart",description:"文件上传支持",license:"Apache-2.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"开发工具"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(Zs,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(Zs,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(Zs,{name:"PostCSS",description:"CSS 转换工具",license:"MIT"})]})]})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源许可"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-lg bg-primary/5 border border-primary/20 p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("div",{className:"rounded-md bg-primary/10 px-2 py-1",children:e.jsx("span",{className:"text-xs sm:text-sm font-bold text-primary",children:"GPLv3"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm sm:text-base font-semibold text-foreground mb-1",children:"MaiBot WebUI"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目采用 GNU General Public License v3.0 开源许可证。 您可以自由地使用、修改和分发本软件,但必须保持相同的开源许可。"})]})]})}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目依赖的所有开源库均遵循各自的开源许可证(MIT、Apache-2.0、BSD 等)。 感谢所有开源贡献者的无私奉献。"})]})]})]})}function Zs({name:n,description:i,license:c}){return e.jsxs("div",{className:"flex items-start justify-between gap-2 rounded-lg border bg-muted/30 p-2.5 sm:p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-foreground truncate",children:n}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:i})]}),e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary flex-shrink-0",children:c})]})}function Eu({value:n,current:i,onChange:c,label:d,description:h}){const x=i===n;return e.jsxs("button",{onClick:()=>c(n),className:$("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-2 right-2 sm:top-3 sm:right-3 h-2 w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm sm:text-base font-medium",children:d}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:h})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[n==="light"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-200"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-300"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-400"})]}),n==="dark"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-900"})]}),n==="system"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-200 to-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-300 to-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-400 to-slate-900"})]})]})]})}function xa({value:n,current:i,onChange:c,label:d,colorClass:h}){const x=i===n;return e.jsxs("button",{onClick:()=>c(n),className:$("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-1.5 right-1.5 sm:top-2 sm:right-2 h-1.5 w-1.5 sm:h-2 sm:w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5 sm:gap-2",children:[e.jsx("div",{className:$("h-8 w-8 sm:h-10 sm:w-10 rounded-full",h)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:d})]})]})}class a0{grad3;p;perm;constructor(i=0){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.p=[];for(let c=0;c<256;c++)this.p[c]=Math.floor(Math.random()*256);this.perm=[];for(let c=0;c<512;c++)this.perm[c]=this.p[c&255]}dot(i,c,d){return i[0]*c+i[1]*d}mix(i,c,d){return(1-d)*i+d*c}fade(i){return i*i*i*(i*(i*6-15)+10)}perlin2(i,c){const d=Math.floor(i)&255,h=Math.floor(c)&255;i-=Math.floor(i),c-=Math.floor(c);const x=this.fade(i),f=this.fade(c),j=this.perm[d]+h,p=this.perm[j],w=this.perm[j+1],v=this.perm[d+1]+h,y=this.perm[v],S=this.perm[v+1];return this.mix(this.mix(this.dot(this.grad3[p%12],i,c),this.dot(this.grad3[y%12],i-1,c),x),this.mix(this.dot(this.grad3[w%12],i,c-1),this.dot(this.grad3[S%12],i-1,c-1),x),f)}}function ap(){const n=u.useRef(null),i=u.useRef(null),c=u.useRef(void 0),d=u.useRef({mouse:{x:-10,y:0,lx:0,ly:0,sx:0,sy:0,v:0,vs:0,a:0,set:!1},lines:[],paths:[],noise:new a0(Math.random()),bounding:null});return u.useEffect(()=>{const h=i.current,x=n.current;if(!h||!x)return;const f=d.current,j=()=>{const F=h.getBoundingClientRect();f.bounding=F,x.style.width=`${F.width}px`,x.style.height=`${F.height}px`},p=()=>{if(!f.bounding)return;const{width:F,height:U}=f.bounding;f.lines=[],f.paths.forEach(ne=>ne.remove()),f.paths=[];const O=10,K=32,H=F+200,A=U+30,V=Math.ceil(H/O),Q=Math.ceil(A/K),T=(F-O*V)/2,D=(U-K*Q)/2;for(let ne=0;ne<=V;ne++){const xe=[];for(let Se=0;Se<=Q;Se++){const ge={x:T+O*ne,y:D+K*Se,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};xe.push(ge)}const _e=document.createElementNS("http://www.w3.org/2000/svg","path");x.appendChild(_e),f.paths.push(_e),f.lines.push(xe)}},w=F=>{const{lines:U,mouse:O,noise:K}=f;U.forEach(H=>{H.forEach(A=>{const V=K.perlin2((A.x+F*.0125)*.002,(A.y+F*.005)*.0015)*12;A.wave.x=Math.cos(V)*32,A.wave.y=Math.sin(V)*16;const Q=A.x-O.sx,T=A.y-O.sy,D=Math.hypot(Q,T),ne=Math.max(175,O.vs);if(D{const O={x:F.x+F.wave.x+(U?F.cursor.x:0),y:F.y+F.wave.y+(U?F.cursor.y:0)};return O.x=Math.round(O.x*10)/10,O.y=Math.round(O.y*10)/10,O},y=()=>{const{lines:F,paths:U}=f;F.forEach((O,K)=>{let H=v(O[0],!1),A=`M ${H.x} ${H.y}`;O.forEach((V,Q)=>{const T=Q===O.length-1;H=v(V,!T),A+=`L ${H.x} ${H.y}`}),U[K].setAttribute("d",A)})},S=F=>{const{mouse:U}=f;U.sx+=(U.x-U.sx)*.1,U.sy+=(U.y-U.sy)*.1;const O=U.x-U.lx,K=U.y-U.ly,H=Math.hypot(O,K);U.v=H,U.vs+=(H-U.vs)*.1,U.vs=Math.min(100,U.vs),U.lx=U.x,U.ly=U.y,U.a=Math.atan2(K,O),h&&(h.style.setProperty("--x",`${U.sx}px`),h.style.setProperty("--y",`${U.sy}px`)),w(F),y(),c.current=requestAnimationFrame(S)},C=F=>{if(!f.bounding)return;const{mouse:U}=f;U.x=F.pageX-f.bounding.left,U.y=F.pageY-f.bounding.top+window.scrollY,U.set||(U.sx=U.x,U.sy=U.y,U.lx=U.x,U.ly=U.y,U.set=!0)},M=()=>{j(),p()};return j(),p(),window.addEventListener("resize",M),window.addEventListener("mousemove",C),c.current=requestAnimationFrame(S),()=>{window.removeEventListener("resize",M),window.removeEventListener("mousemove",C),c.current&&cancelAnimationFrame(c.current)}},[]),e.jsxs("div",{ref:i,className:"waves-background",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"hidden",pointerEvents:"none"},children:[e.jsx("div",{className:"waves-cursor",style:{position:"absolute",top:0,left:0,width:"0.5rem",height:"0.5rem",background:"hsl(var(--primary) / 0.3)",borderRadius:"50%",transform:"translate3d(calc(var(--x, -0.5rem) - 50%), calc(var(--y, 50%) - 50%), 0)",willChange:"transform",pointerEvents:"none"}}),e.jsx("svg",{ref:n,style:{display:"block",width:"100%",height:"100%"},children:e.jsx("style",{children:` +`)}}):null},ir=UN,ti=u.forwardRef(({active:n,payload:i,className:c,indicator:d="dot",hideLabel:h=!1,hideIndicator:x=!1,label:f,labelFormatter:j,labelClassName:p,formatter:w,color:v,nameKey:y,labelKey:S},C)=>{const{config:M}=vg(),F=u.useMemo(()=>{if(h||!i?.length)return null;const[O]=i,K=`${S||O?.dataKey||O?.name||"value"}`,H=Lu(M,O,K),A=!S&&typeof f=="string"?M[f]?.label||f:H?.label;return j?e.jsx("div",{className:$("font-medium",p),children:j(A,i)}):A?e.jsx("div",{className:$("font-medium",p),children:A}):null},[f,j,i,h,p,M,S]);if(!n||!i?.length)return null;const U=i.length===1&&d!=="dot";return e.jsxs("div",{ref:C,className:$("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",c),children:[U?null:F,e.jsx("div",{className:"grid gap-1.5",children:i.filter(O=>O.type!=="none").map((O,K)=>{const H=`${y||O.name||O.dataKey||"value"}`,A=Lu(M,O,H),V=v||O.payload.fill||O.color;return e.jsx("div",{className:$("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",d==="dot"&&"items-center"),children:w&&O?.value!==void 0&&O.name?w(O.value,O.name,O,K,O.payload):e.jsxs(e.Fragment,{children:[A?.icon?e.jsx(A.icon,{}):!x&&e.jsx("div",{className:$("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":d==="dot","w-1":d==="line","w-0 border-[1.5px] border-dashed bg-transparent":d==="dashed","my-0.5":U&&d==="dashed"}),style:{"--color-bg":V,"--color-border":V}}),e.jsxs("div",{className:$("flex flex-1 justify-between leading-none",U?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[U?F:null,e.jsx("span",{className:"text-muted-foreground",children:A?.label||O.name})]}),O.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:O.value.toLocaleString()})]})]})},O.dataKey)})})]})});ti.displayName="ChartTooltip";const ky=BN,Ng=u.forwardRef(({className:n,hideIcon:i=!1,payload:c,verticalAlign:d="bottom",nameKey:h},x)=>{const{config:f}=vg();return c?.length?e.jsx("div",{ref:x,className:$("flex items-center justify-center gap-4",d==="top"?"pb-3":"pt-3",n),children:c.filter(j=>j.type!=="none").map(j=>{const p=`${h||j.dataKey||"value"}`,w=Lu(f,j,p);return e.jsxs("div",{className:$("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[w?.icon&&!i?e.jsx(w.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:j.color}}),w?.label]},j.value)})}):null});Ng.displayName="ChartLegend";function Lu(n,i,c){if(typeof i!="object"||i===null)return;const d="payload"in i&&typeof i.payload=="object"&&i.payload!==null?i.payload:void 0;let h=c;return c in i&&typeof i[c]=="string"?h=i[c]:d&&c in d&&typeof d[c]=="string"&&(h=d[c]),h in n?n[h]:n[c]}const gr=ci("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),N=u.forwardRef(({className:n,variant:i,size:c,asChild:d=!1,...h},x)=>{const f=d?$N:"button";return e.jsx(f,{className:$(gr({variant:i,size:c,className:n})),ref:x,...h})});N.displayName="Button";const Ty=ci("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ye({className:n,variant:i,...c}){return e.jsx("div",{className:$(Ty({variant:i}),n),...c})}const Ey=5,zy=5e3;let ku=0;function Ay(){return ku=(ku+1)%Number.MAX_SAFE_INTEGER,ku.toString()}const Tu=new Map,ep=n=>{if(Tu.has(n))return;const i=setTimeout(()=>{Tu.delete(n),hr({type:"REMOVE_TOAST",toastId:n})},zy);Tu.set(n,i)},My=(n,i)=>{switch(i.type){case"ADD_TOAST":return{...n,toasts:[i.toast,...n.toasts].slice(0,Ey)};case"UPDATE_TOAST":return{...n,toasts:n.toasts.map(c=>c.id===i.toast.id?{...c,...i.toast}:c)};case"DISMISS_TOAST":{const{toastId:c}=i;return c?ep(c):n.toasts.forEach(d=>{ep(d.id)}),{...n,toasts:n.toasts.map(d=>d.id===c||c===void 0?{...d,open:!1}:d)}}case"REMOVE_TOAST":return i.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(c=>c.id!==i.toastId)}}},Kc=[];let Jc={toasts:[]};function hr(n){Jc=My(Jc,n),Kc.forEach(i=>{i(Jc)})}function Dy({...n}){const i=Ay(),c=h=>hr({type:"UPDATE_TOAST",toast:{...h,id:i}}),d=()=>hr({type:"DISMISS_TOAST",toastId:i});return hr({type:"ADD_TOAST",toast:{...n,id:i,open:!0,onOpenChange:h=>{h||d()}}}),{id:i,dismiss:d,update:c}}function Gs(){const[n,i]=u.useState(Jc);return u.useEffect(()=>(Kc.push(i),()=>{const c=Kc.indexOf(i);c>-1&&Kc.splice(c,1)}),[n]),{...n,toast:Dy,dismiss:c=>hr({type:"DISMISS_TOAST",toastId:c})}}const Oy=n=>{const i=[];for(let c=0;c{try{C(!0);const k=await Bc.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");y({hitokoto:k.data.hitokoto,from:k.data.from||k.data.from_who||"未知"})}catch(k){console.error("获取一言失败:",k),y({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{C(!1)}},[]),A=u.useCallback(async()=>{try{const k=localStorage.getItem("access-token"),se=await Bc.get("/api/webui/system/status",{headers:{Authorization:`Bearer ${k}`}});F(se.data)}catch(k){console.error("获取机器人状态失败:",k),F(null)}},[]),V=async()=>{if(!U)try{O(!0);const k=localStorage.getItem("access-token");await Bc.post("/api/webui/system/restart",{},{headers:{Authorization:`Bearer ${k}`}}),K({title:"重启中",description:"麦麦正在重启,请稍候..."}),setTimeout(()=>{A(),O(!1)},3e3)}catch(k){console.error("重启失败:",k),K({title:"重启失败",description:"无法重启麦麦,请检查控制台",variant:"destructive"}),O(!1)}},Q=u.useCallback(async()=>{try{const k=localStorage.getItem("access-token"),se=await Bc.get(`/api/webui/statistics/dashboard?hours=${f}`,{headers:{Authorization:`Bearer ${k}`}});i(se.data),d(!1),x(100)}catch(k){console.error("Failed to fetch dashboard data:",k),d(!1),x(100)}},[f]);if(u.useEffect(()=>{if(!c)return;x(0);const k=setTimeout(()=>x(15),200),se=setTimeout(()=>x(30),800),_=setTimeout(()=>x(45),2e3),ue=setTimeout(()=>x(60),4e3),ie=setTimeout(()=>x(75),6500),ae=setTimeout(()=>x(85),9e3),fe=setTimeout(()=>x(92),11e3);return()=>{clearTimeout(k),clearTimeout(se),clearTimeout(_),clearTimeout(ue),clearTimeout(ie),clearTimeout(ae),clearTimeout(fe)}},[c]),u.useEffect(()=>{Q(),H(),A()},[Q,H,A]),u.useEffect(()=>{if(!p)return;const k=setInterval(()=>{Q(),A()},3e4);return()=>clearInterval(k)},[p,Q,A]),c||!n)return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:e.jsxs("div",{className:"text-center space-y-6 w-full max-w-md px-4",children:[e.jsx(Ct,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-lg font-medium",children:"加载统计数据中..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"正在获取麦麦运行数据"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(wr,{value:h,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[h,"%"]})]})]})});const{summary:T,model_stats:D=[],hourly_data:ne=[],daily_data:xe=[],recent_activity:_e=[]}=n,Se=T??{total_requests:0,total_cost:0,total_tokens:0,online_time:0,total_messages:0,total_replies:0,avg_response_time:0,cost_per_hour:0,tokens_per_hour:0},ge=k=>{const se=Math.floor(k/3600),_=Math.floor(k%3600/60);return`${se}小时${_}分钟`},ye=k=>new Date(k).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),be=Oy(D.length),z=D.map((k,se)=>({name:k.model_name,value:k.request_count,fill:be[se]})),X={requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"},tokens:{label:"Tokens",color:"hsl(var(--chart-3))"}};return e.jsx(ss,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"实时监控面板"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"麦麦运行状态和统计数据一览"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(La,{value:f.toString(),onValueChange:k=>j(Number(k)),children:e.jsxs(wa,{className:"grid grid-cols-3 w-full sm:w-auto",children:[e.jsx(fs,{value:"24",children:"24小时"}),e.jsx(fs,{value:"168",children:"7天"}),e.jsx(fs,{value:"720",children:"30天"})]})}),e.jsxs(N,{variant:p?"default":"outline",size:"sm",onClick:()=>w(!p),className:"gap-2",children:[e.jsx(Ct,{className:`h-4 w-4 ${p?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"自动刷新"})]}),e.jsx(N,{variant:"outline",size:"sm",onClick:Q,children:e.jsx(Ct,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg border border-dashed border-muted-foreground/30 bg-muted/20",children:[S?e.jsx(gg,{className:"h-5 flex-1"}):v?e.jsxs("p",{className:"flex-1 text-sm text-muted-foreground italic truncate",children:['"',v.hitokoto,'" —— ',v.from]}):null,e.jsx(N,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:H,disabled:S,children:e.jsx(Ct,{className:`h-3.5 w-3.5 ${S?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-3",children:[e.jsxs(Ze,{className:"lg:col-span-1",children:[e.jsx(ys,{className:"pb-3",children:e.jsxs(ws,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4"}),"麦麦状态"]})}),e.jsx(Ts,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:M?.running?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),e.jsxs(Ye,{variant:"outline",className:"text-green-600 border-green-300 bg-green-50",children:[e.jsx(fa,{className:"h-3 w-3 mr-1"}),"运行中"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-red-500"}),e.jsxs(Ye,{variant:"outline",className:"text-red-600 border-red-300 bg-red-50",children:[e.jsx(Oa,{className:"h-3 w-3 mr-1"}),"已停止"]})]})}),M&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("span",{children:["v",M.version]}),e.jsx("span",{className:"mx-2",children:"|"}),e.jsxs("span",{children:["运行 ",ge(M.uptime)]})]})]})})]}),e.jsxs(Ze,{className:"lg:col-span-2",children:[e.jsx(ys,{className:"pb-3",children:e.jsxs(ws,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"快速操作"]})}),e.jsx(Ts,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:V,disabled:U,className:"gap-2",children:[e.jsx(Zc,{className:`h-4 w-4 ${U?"animate-spin":""}`}),U?"重启中...":"重启麦麦"]}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yc,{to:"/logs",children:[e.jsx(Da,{className:"h-4 w-4"}),"查看日志"]})}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yc,{to:"/plugins",children:[e.jsx(cb,{className:"h-4 w-4"}),"插件管理"]})}),e.jsx(N,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yc,{to:"/settings",children:[e.jsx(oi,{className:"h-4 w-4"}),"系统设置"]})})]})})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(ob,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsx("div",{className:"text-2xl font-bold",children:Se.total_requests.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",f<48?f+"小时":Math.floor(f/24)+"天"]})]})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"总花费"}),e.jsx(db,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Se.total_cost.toFixed(2)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Se.cost_per_hour>0?`¥${Se.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx(Ic,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(Se.total_tokens/1e3).toFixed(1),"K"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Se.tokens_per_hour>0?`${(Se.tokens_per_hour/1e3).toFixed(1)}K/小时`:"暂无数据"})]})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(cn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[Se.avg_response_time.toFixed(2),"s"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"API平均耗时"})]})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-3",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(li,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Ts,{children:e.jsx("div",{className:"text-xl font-bold",children:ge(Se.online_time)})})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsx("div",{className:"text-xl font-bold",children:Se.total_messages.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",Se.total_replies.toLocaleString()," 条"]})]})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ws,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(ub,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Ts,{children:[e.jsx("div",{className:"text-xl font-bold",children:Se.total_messages>0?`¥${(Se.total_cost/Se.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(La,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs(wa,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[e.jsx(fs,{value:"trends",children:"趋势"}),e.jsx(fs,{value:"models",children:"模型"}),e.jsx(fs,{value:"activity",children:"活动"}),e.jsx(fs,{value:"daily",children:"日统计"})]}),e.jsxs(Ms,{value:"trends",className:"space-y-4",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"请求趋势"}),e.jsxs(ct,{children:["最近",f,"小时的请求量变化"]})]}),e.jsx(Ts,{children:e.jsx(si,{config:X,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(HN,{data:ne,children:[e.jsx(Hc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(qc,{dataKey:"timestamp",tickFormatter:k=>ye(k),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ir,{content:e.jsx(ti,{labelFormatter:k=>ye(k)})}),e.jsx(qN,{type:"monotone",dataKey:"requests",stroke:"var(--color-requests)",strokeWidth:2})]})})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"花费趋势"}),e.jsx(ct,{children:"API调用成本变化"})]}),e.jsx(Ts,{children:e.jsx(si,{config:X,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(bu,{data:ne,children:[e.jsx(Hc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(qc,{dataKey:"timestamp",tickFormatter:k=>ye(k),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ir,{content:e.jsx(ti,{labelFormatter:k=>ye(k)})}),e.jsx(Gc,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"Token消耗"}),e.jsx(ct,{children:"Token使用量变化"})]}),e.jsx(Ts,{children:e.jsx(si,{config:X,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(bu,{data:ne,children:[e.jsx(Hc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(qc,{dataKey:"timestamp",tickFormatter:k=>ye(k),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ir,{content:e.jsx(ti,{labelFormatter:k=>ye(k)})}),e.jsx(Gc,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(Ms,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"模型请求分布"}),e.jsxs(ct,{children:["各模型使用占比 (共 ",D.length," 个模型)"]})]}),e.jsx(Ts,{children:e.jsx(si,{config:Object.fromEntries(D.map((k,se)=>[k.model_name,{label:k.model_name,color:be[se]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(GN,{children:[e.jsx(ir,{content:e.jsx(ti,{})}),e.jsx(VN,{data:z,cx:"50%",cy:"50%",labelLine:!1,label:({name:k,percent:se})=>se&&se<.05?"":`${k} ${se?(se*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:z.map((k,se)=>e.jsx(FN,{fill:k.fill},`cell-${se}`))})]})})})]}),e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"模型详细统计"}),e.jsx(ct,{children:"请求数、花费和性能"})]}),e.jsx(Ts,{children:e.jsx(ss,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:D.map((k,se)=>e.jsxs("div",{className:"p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"font-semibold text-sm truncate flex-1 min-w-0",children:k.model_name}),e.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--chart-${se%5+1}))`}})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"请求数:"}),e.jsx("span",{className:"ml-1 font-medium",children:k.request_count.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1 font-medium",children:["¥",k.total_cost.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[(k.total_tokens/1e3).toFixed(1),"K"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"平均耗时:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[k.avg_response_time.toFixed(2),"s"]})]})]})]},se))})})})]})]})}),e.jsx(Ms,{value:"activity",children:e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"最近活动"}),e.jsx(ct,{children:"最新的API调用记录"})]}),e.jsx(Ts,{children:e.jsx(ss,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:_e.map((k,se)=>e.jsxs("div",{className:"p-3 sm:p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:k.model}),e.jsx("div",{className:"text-xs text-muted-foreground",children:k.request_type})]}),e.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:ye(k.timestamp)})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsx("span",{className:"ml-1",children:k.tokens})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1",children:["¥",k.cost.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"耗时:"}),e.jsxs("span",{className:"ml-1",children:[k.time_cost.toFixed(2),"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"状态:"}),e.jsx("span",{className:`ml-1 ${k.status==="success"?"text-green-600":"text-red-600"}`,children:k.status})]})]})]},se))})})})]})}),e.jsx(Ms,{value:"daily",children:e.jsxs(Ze,{children:[e.jsxs(ys,{children:[e.jsx(ws,{children:"每日统计"}),e.jsx(ct,{children:"最近7天的数据汇总"})]}),e.jsx(Ts,{children:e.jsx(si,{config:{requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"}},className:"h-[400px] sm:h-[500px] w-full aspect-auto",children:e.jsxs(bu,{data:xe,children:[e.jsx(Hc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(qc,{dataKey:"timestamp",tickFormatter:k=>{const se=new Date(k);return`${se.getMonth()+1}/${se.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(lr,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ir,{content:e.jsx(ti,{labelFormatter:k=>new Date(k).toLocaleDateString("zh-CN")})}),e.jsx(ky,{content:e.jsx(Ng,{})}),e.jsx(Gc,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(Gc,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]})]})})}const Ly={theme:"system",setTheme:()=>null},bg=u.createContext(Ly),$u=()=>{const n=u.useContext(bg);if(n===void 0)throw new Error("useTheme must be used within a ThemeProvider");return n},Uy=(n,i,c)=>{const d=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||d){i(n);return}const h=c.clientX,x=c.clientY,f=Math.hypot(Math.max(h,innerWidth-h),Math.max(x,innerHeight-x));document.startViewTransition(()=>{i(n)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${h}px ${x}px)`,`circle(${f}px at ${h}px ${x}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},yg=u.createContext(void 0),wg=()=>{const n=u.useContext(yg);if(n===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return n},Xe=u.forwardRef(({className:n,...i},c)=>e.jsx(Cp,{className:$("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n),...i,ref:c,children:e.jsx(wN,{className:$("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Xe.displayName=Cp.displayName;const By=ci("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),b=u.forwardRef(({className:n,...i},c)=>e.jsx(Hp,{ref:c,className:$(By(),n),...i}));b.displayName=Hp.displayName;const oe=u.forwardRef(({className:n,type:i,...c},d)=>e.jsx("input",{type:i,className:$("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:d,...c}));oe.displayName="Input";const Hy=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:n=>n.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:n=>/[A-Z]/.test(n)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:n=>/[a-z]/.test(n)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:n=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(n)}];function qy(n){const i=Hy.map(d=>({id:d.id,label:d.label,description:d.description,passed:d.validate(n)}));return{isValid:i.every(d=>d.passed),rules:i}}const Qu="0.11.6",Yu="MaiBot Dashboard",Gy=`${Yu} v${Qu}`,Vy=(n="v")=>`${n}${Qu}`,Ft={THEME:"maibot-ui-theme",ACCENT_COLOR:"accent-color",ENABLE_ANIMATIONS:"maibot-animations",ENABLE_WAVES_BACKGROUND:"maibot-waves-background",LOG_CACHE_SIZE:"maibot-log-cache-size",LOG_AUTO_SCROLL:"maibot-log-auto-scroll",LOG_FONT_SIZE:"maibot-log-font-size",LOG_LINE_SPACING:"maibot-log-line-spacing",DATA_SYNC_INTERVAL:"maibot-data-sync-interval",WS_RECONNECT_INTERVAL:"maibot-ws-reconnect-interval",WS_MAX_RECONNECT_ATTEMPTS:"maibot-ws-max-reconnect-attempts",COMPLETED_TOURS:"maibot-completed-tours"},Aa={theme:"system",accentColor:"blue",enableAnimations:!0,enableWavesBackground:!0,logCacheSize:1e3,logAutoScroll:!0,logFontSize:"xs",logLineSpacing:4,dataSyncInterval:30,wsReconnectInterval:3e3,wsMaxReconnectAttempts:10};function st(n){const i=_g(n),c=localStorage.getItem(i);if(c===null)return Aa[n];const d=Aa[n];if(typeof d=="boolean")return c==="true";if(typeof d=="number"){const h=parseFloat(c);return isNaN(h)?d:h}return c}function ai(n,i){const c=_g(n);localStorage.setItem(c,String(i)),window.dispatchEvent(new CustomEvent("maibot-settings-change",{detail:{key:n,value:i}}))}function Fy(){return{theme:st("theme"),accentColor:st("accentColor"),enableAnimations:st("enableAnimations"),enableWavesBackground:st("enableWavesBackground"),logCacheSize:st("logCacheSize"),logAutoScroll:st("logAutoScroll"),logFontSize:st("logFontSize"),logLineSpacing:st("logLineSpacing"),dataSyncInterval:st("dataSyncInterval"),wsReconnectInterval:st("wsReconnectInterval"),wsMaxReconnectAttempts:st("wsMaxReconnectAttempts")}}function $y(){const n=Fy(),i=localStorage.getItem(Ft.COMPLETED_TOURS),c=i?JSON.parse(i):[];return{...n,completedTours:c}}function Qy(n){const i=[],c=[];for(const[d,h]of Object.entries(n)){if(d==="completedTours"){Array.isArray(h)?(localStorage.setItem(Ft.COMPLETED_TOURS,JSON.stringify(h)),i.push("completedTours")):c.push("completedTours");continue}if(d in Aa){const x=d,f=Aa[x];if(typeof h==typeof f){if(x==="theme"&&!["light","dark","system"].includes(h)){c.push(d);continue}if(x==="logFontSize"&&!["xs","sm","base"].includes(h)){c.push(d);continue}ai(x,h),i.push(d)}else c.push(d)}else c.push(d)}return{success:i.length>0,imported:i,skipped:c}}function Yy(){for(const n of Object.keys(Aa))ai(n,Aa[n]);localStorage.removeItem(Ft.COMPLETED_TOURS),window.dispatchEvent(new CustomEvent("maibot-settings-reset"))}function Xy(){const n=[],i=[],c=[];for(let d=0;dd.size-c.size),{used:n,items:localStorage.length,details:i}}function Ky(n){if(n===0)return"0 B";const i=1024,c=["B","KB","MB"],d=Math.floor(Math.log(n)/Math.log(i));return parseFloat((n/Math.pow(i,d)).toFixed(2))+" "+c[d]}function _g(n){return{theme:Ft.THEME,accentColor:Ft.ACCENT_COLOR,enableAnimations:Ft.ENABLE_ANIMATIONS,enableWavesBackground:Ft.ENABLE_WAVES_BACKGROUND,logCacheSize:Ft.LOG_CACHE_SIZE,logAutoScroll:Ft.LOG_AUTO_SCROLL,logFontSize:Ft.LOG_FONT_SIZE,logLineSpacing:Ft.LOG_LINE_SPACING,dataSyncInterval:Ft.DATA_SYNC_INTERVAL,wsReconnectInterval:Ft.WS_RECONNECT_INTERVAL,wsMaxReconnectAttempts:Ft.WS_MAX_RECONNECT_ATTEMPTS}[n]}const Ma=u.forwardRef(({className:n,...i},c)=>e.jsxs(kp,{ref:c,className:$("relative flex w-full touch-none select-none items-center",n),...i,children:[e.jsx(_N,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(SN,{className:"absolute h-full bg-primary"})}),e.jsx(CN,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));Ma.displayName=kp.displayName;class Jy{ws=null;reconnectTimeout=null;reconnectAttempts=0;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];getMaxCacheSize(){return st("logCacheSize")}getMaxReconnectAttempts(){return st("wsMaxReconnectAttempts")}getReconnectInterval(){return st("wsReconnectInterval")}getWebSocketUrl(){{const i=window.location.protocol==="https:"?"wss:":"ws:",c=window.location.host;return`${i}//${c}/ws/logs`}}connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;const i=this.getWebSocketUrl();try{this.ws=new WebSocket(i),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=c=>{try{if(c.data==="pong")return;const d=JSON.parse(c.data);this.notifyLog(d)}catch(d){console.error("解析日志消息失败:",d)}},this.ws.onerror=c=>{console.error("❌ WebSocket 错误:",c),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(c){console.error("创建 WebSocket 连接失败:",c),this.attemptReconnect()}}attemptReconnect(){const i=this.getMaxReconnectAttempts();if(this.reconnectAttempts>=i)return;this.reconnectAttempts+=1;const c=this.getReconnectInterval(),d=Math.min(c*this.reconnectAttempts,3e4);this.reconnectTimeout=window.setTimeout(()=>{this.connect()},d)}startHeartbeat(){this.heartbeatInterval=window.setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send("ping")},3e4)}stopHeartbeat(){this.heartbeatInterval!==null&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}disconnect(){this.reconnectTimeout!==null&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.stopHeartbeat(),this.ws&&(this.ws.close(),this.ws=null),this.isConnected=!1,this.reconnectAttempts=0}onLog(i){return this.logCallbacks.add(i),()=>this.logCallbacks.delete(i)}onConnectionChange(i){return this.connectionCallbacks.add(i),i(this.isConnected),()=>this.connectionCallbacks.delete(i)}notifyLog(i){if(!this.logCache.some(d=>d.id===i.id)){this.logCache.push(i);const d=this.getMaxCacheSize();this.logCache.length>d&&(this.logCache=this.logCache.slice(-d)),this.logCallbacks.forEach(h=>{try{h(i)}catch(x){console.error("日志回调执行失败:",x)}})}}notifyConnection(i){this.connectionCallbacks.forEach(c=>{try{c(i)}catch(d){console.error("连接状态回调执行失败:",d)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const rn=new Jy;typeof window<"u"&&rn.connect();const $s=XN,Xu=KN,Zy=QN,Sg=u.forwardRef(({className:n,...i},c)=>e.jsx(qp,{ref:c,className:$("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...i}));Sg.displayName=qp.displayName;const Bs=u.forwardRef(({className:n,children:i,preventOutsideClose:c=!1,...d},h)=>e.jsxs(Zy,{children:[e.jsx(Sg,{}),e.jsxs(Gp,{ref:h,className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),onPointerDownOutside:c?x=>x.preventDefault():void 0,onInteractOutside:c?x=>x.preventDefault():void 0,...d,children:[i,e.jsxs(YN,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(dl,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Bs.displayName=Gp.displayName;const Hs=({className:n,...i})=>e.jsx("div",{className:$("flex flex-col space-y-1.5 text-center sm:text-left",n),...i});Hs.displayName="DialogHeader";const at=({className:n,...i})=>e.jsx("div",{className:$("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...i});at.displayName="DialogFooter";const qs=u.forwardRef(({className:n,...i},c)=>e.jsx(Vp,{ref:c,className:$("text-lg font-semibold leading-none tracking-tight",n),...i}));qs.displayName=Vp.displayName;const Is=u.forwardRef(({className:n,...i},c)=>e.jsx(Fp,{ref:c,className:$("text-sm text-muted-foreground",n),...i}));Is.displayName=Fp.displayName;const ps=TN,tt=EN,Iy=kN,Cg=u.forwardRef(({className:n,...i},c)=>e.jsx(Tp,{className:$("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...i,ref:c}));Cg.displayName=Tp.displayName;const is=u.forwardRef(({className:n,...i},c)=>e.jsxs(Iy,{children:[e.jsx(Cg,{}),e.jsx(Ep,{ref:c,className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...i})]}));is.displayName=Ep.displayName;const rs=({className:n,...i})=>e.jsx("div",{className:$("flex flex-col space-y-2 text-center sm:text-left",n),...i});rs.displayName="AlertDialogHeader";const cs=({className:n,...i})=>e.jsx("div",{className:$("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...i});cs.displayName="AlertDialogFooter";const os=u.forwardRef(({className:n,...i},c)=>e.jsx(zp,{ref:c,className:$("text-lg font-semibold",n),...i}));os.displayName=zp.displayName;const ds=u.forwardRef(({className:n,...i},c)=>e.jsx(Ap,{ref:c,className:$("text-sm text-muted-foreground",n),...i}));ds.displayName=Ap.displayName;const us=u.forwardRef(({className:n,...i},c)=>e.jsx(Mp,{ref:c,className:$(gr(),n),...i}));us.displayName=Mp.displayName;const ms=u.forwardRef(({className:n,...i},c)=>e.jsx(Dp,{ref:c,className:$(gr({variant:"outline"}),"mt-2 sm:mt-0",n),...i}));ms.displayName=Dp.displayName;function Py(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"系统设置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理您的应用偏好设置"})]})}),e.jsxs(La,{defaultValue:"appearance",className:"w-full",children:[e.jsxs(wa,{className:"grid w-full grid-cols-2 sm:grid-cols-4 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs(fs,{value:"appearance",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(mb,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"外观"})]}),e.jsxs(fs,{value:"security",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(hb,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"安全"})]}),e.jsxs(fs,{value:"other",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(oi,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"其他"})]}),e.jsxs(fs,{value:"about",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Ra,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(ss,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(Ms,{value:"appearance",className:"mt-0",children:e.jsx(Wy,{})}),e.jsx(Ms,{value:"security",className:"mt-0",children:e.jsx(e0,{})}),e.jsx(Ms,{value:"other",className:"mt-0",children:e.jsx(s0,{})}),e.jsx(Ms,{value:"about",className:"mt-0",children:e.jsx(t0,{})})]})]})]})}function tp(n){const i=document.documentElement,d={blue:{hsl:"221.2 83.2% 53.3%",darkHsl:"217.2 91.2% 59.8%",gradient:null},purple:{hsl:"271 91% 65%",darkHsl:"270 95% 75%",gradient:null},green:{hsl:"142 71% 45%",darkHsl:"142 76% 36%",gradient:null},orange:{hsl:"25 95% 53%",darkHsl:"20 90% 48%",gradient:null},pink:{hsl:"330 81% 60%",darkHsl:"330 85% 70%",gradient:null},red:{hsl:"0 84% 60%",darkHsl:"0 90% 70%",gradient:null},"gradient-sunset":{hsl:"15 95% 60%",darkHsl:"15 95% 65%",gradient:"linear-gradient(135deg, hsl(25 95% 53%) 0%, hsl(330 81% 60%) 100%)"},"gradient-ocean":{hsl:"200 90% 55%",darkHsl:"200 90% 60%",gradient:"linear-gradient(135deg, hsl(221.2 83.2% 53.3%) 0%, hsl(189 94% 43%) 100%)"},"gradient-forest":{hsl:"150 70% 45%",darkHsl:"150 75% 40%",gradient:"linear-gradient(135deg, hsl(142 71% 45%) 0%, hsl(158 64% 52%) 100%)"},"gradient-aurora":{hsl:"310 85% 65%",darkHsl:"310 90% 70%",gradient:"linear-gradient(135deg, hsl(271 91% 65%) 0%, hsl(330 81% 60%) 100%)"},"gradient-fire":{hsl:"15 95% 55%",darkHsl:"15 95% 60%",gradient:"linear-gradient(135deg, hsl(0 84% 60%) 0%, hsl(25 95% 53%) 100%)"},"gradient-twilight":{hsl:"250 90% 60%",darkHsl:"250 95% 65%",gradient:"linear-gradient(135deg, hsl(239 84% 67%) 0%, hsl(271 91% 65%) 100%)"}}[n];if(d)i.style.setProperty("--primary",d.hsl),d.gradient?(i.style.setProperty("--primary-gradient",d.gradient),i.classList.add("has-gradient")):(i.style.removeProperty("--primary-gradient"),i.classList.remove("has-gradient"));else if(n.startsWith("#")){const h=x=>{x=x.replace("#","");const f=parseInt(x.substring(0,2),16)/255,j=parseInt(x.substring(2,4),16)/255,p=parseInt(x.substring(4,6),16)/255,w=Math.max(f,j,p),v=Math.min(f,j,p);let y=0,S=0;const C=(w+v)/2;if(w!==v){const M=w-v;switch(S=C>.5?M/(2-w-v):M/(w+v),w){case f:y=((j-p)/M+(jlocalStorage.getItem("accent-color")||"blue");u.useEffect(()=>{const w=localStorage.getItem("accent-color")||"blue";tp(w)},[]);const p=w=>{j(w),localStorage.setItem("accent-color",w),tp(w)};return e.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题模式"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-4",children:[e.jsx(Eu,{value:"light",current:n,onChange:i,label:"浅色",description:"始终使用浅色主题"}),e.jsx(Eu,{value:"dark",current:n,onChange:i,label:"深色",description:"始终使用深色主题"}),e.jsx(Eu,{value:"system",current:n,onChange:i,label:"跟随系统",description:"根据系统设置自动切换"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题色"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"单色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(xa,{value:"blue",current:f,onChange:p,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(xa,{value:"purple",current:f,onChange:p,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(xa,{value:"green",current:f,onChange:p,label:"绿色",colorClass:"bg-green-500"}),e.jsx(xa,{value:"orange",current:f,onChange:p,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(xa,{value:"pink",current:f,onChange:p,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(xa,{value:"red",current:f,onChange:p,label:"红色",colorClass:"bg-red-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"渐变色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(xa,{value:"gradient-sunset",current:f,onChange:p,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(xa,{value:"gradient-ocean",current:f,onChange:p,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(xa,{value:"gradient-forest",current:f,onChange:p,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(xa,{value:"gradient-aurora",current:f,onChange:p,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(xa,{value:"gradient-fire",current:f,onChange:p,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(xa,{value:"gradient-twilight",current:f,onChange:p,label:"暮光",colorClass:"bg-gradient-to-r from-indigo-500 to-purple-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"自定义颜色"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsx("input",{type:"color",value:f.startsWith("#")?f:"#3b82f6",onChange:w=>p(w.target.value),className:"h-10 sm:h-12 w-full rounded-lg border-2 border-border cursor-pointer",title:"选择自定义颜色"})}),e.jsx("div",{className:"flex-1",children:e.jsx(oe,{type:"text",value:f,onChange:w=>p(w.target.value),placeholder:"#3b82f6",className:"font-mono text-sm"})})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground mt-2",children:"点击色块选择颜色,或手动输入 HEX 颜色代码"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"动画效果"}),e.jsxs("div",{className:"space-y-2 sm:space-y-3",children:[e.jsx("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(b,{htmlFor:"animations",className:"text-base font-medium cursor-pointer",children:"启用动画效果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后将禁用所有过渡动画和特效,提升性能"})]}),e.jsx(Xe,{id:"animations",checked:c,onCheckedChange:d})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(b,{htmlFor:"waves-background",className:"text-base font-medium cursor-pointer",children:"登录页波浪背景"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后登录页将使用纯色背景,适合低性能设备"})]}),e.jsx(Xe,{id:"waves-background",checked:h,onCheckedChange:x})]})})]})]})]})}function e0(){const n=ga(),[i,c]=u.useState(""),[d,h]=u.useState(""),[x,f]=u.useState(!1),[j,p]=u.useState(!1),[w,v]=u.useState(!1),[y,S]=u.useState(!1),[C,M]=u.useState(!1),[F,U]=u.useState(!1),[O,K]=u.useState(""),[H,A]=u.useState(!1),{toast:V}=Gs(),Q=u.useMemo(()=>qy(d),[d]),T=async ge=>{if(!i){V({title:"无法复制",description:"Token 存储在安全 Cookie 中,请重新生成以获取新 Token",variant:"destructive"});return}try{await navigator.clipboard.writeText(ge),M(!0),V({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>M(!1),2e3)}catch{V({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},D=async()=>{if(!d.trim()){V({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!Q.isValid){const ge=Q.rules.filter(ye=>!ye.passed).map(ye=>ye.label).join(", ");V({title:"格式错误",description:`Token 不符合要求: ${ge}`,variant:"destructive"});return}v(!0);try{const ge=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_token:d.trim()})}),ye=await ge.json();ge.ok&&ye.success?(h(""),c(d.trim()),V({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{n({to:"/auth"})},1500)):V({title:"更新失败",description:ye.message||"无法更新 Token",variant:"destructive"})}catch(ge){console.error("更新 Token 错误:",ge),V({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{v(!1)}},ne=async()=>{S(!0);try{const ge=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),ye=await ge.json();ge.ok&&ye.success?(c(ye.token),K(ye.token),U(!0),A(!1),V({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):V({title:"生成失败",description:ye.message||"无法生成新 Token",variant:"destructive"})}catch(ge){console.error("生成 Token 错误:",ge),V({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{S(!1)}},xe=async()=>{try{await navigator.clipboard.writeText(O),A(!0),V({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{V({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},_e=()=>{U(!1),setTimeout(()=>{K(""),A(!1)},300),setTimeout(()=>{n({to:"/auth"})},500)},Se=ge=>{ge||_e()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx($s,{open:F,onOpenChange:Se,children:e.jsxs(Bs,{className:"sm:max-w-md",children:[e.jsxs(Hs,{children:[e.jsxs(qs,{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"h-5 w-5 text-yellow-500"}),"新的 Access Token"]}),e.jsx(Is,{children:"这是您的新 Token,请立即保存。关闭此窗口后将跳转到登录页面。"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border-2 border-primary/20 bg-primary/5 p-4",children:[e.jsx(b,{className:"text-xs text-muted-foreground mb-2 block",children:"您的新 Token (64位安全令牌)"}),e.jsx("div",{className:"font-mono text-sm break-all select-all bg-background p-3 rounded border",children:O})]}),e.jsx("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ya,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-300 space-y-1",children:[e.jsx("p",{className:"font-semibold",children:"重要提示"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-xs",children:[e.jsx("li",{children:"此 Token 仅显示一次,关闭后无法再查看"}),e.jsx("li",{children:"请立即复制并保存到安全的位置"}),e.jsx("li",{children:"关闭窗口后将自动跳转到登录页面"}),e.jsx("li",{children:"请使用新 Token 重新登录系统"})]})]})]})})]}),e.jsxs(at,{className:"gap-2 sm:gap-0",children:[e.jsx(N,{variant:"outline",onClick:xe,className:"gap-2",children:H?e.jsxs(e.Fragment,{children:[e.jsx(sa,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pc,{className:"h-4 w-4"}),"复制 Token"]})}),e.jsx(N,{onClick:_e,children:"我已保存,关闭"})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"当前 Access Token"}),e.jsx("div",{className:"space-y-3 sm:space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"current-token",className:"text-sm",children:"您的访问令牌"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(oe,{id:"current-token",type:x?"text":"password",value:i||"••••••••••••••••••••••••••••••••",readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"Token 存储在安全 Cookie 中"}),e.jsx("button",{onClick:()=>{i?f(!x):V({title:"无法查看",description:'Token 存储在安全 Cookie 中,如需新 Token 请点击"重新生成"'})},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:x?"隐藏":"显示",children:x?e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Dt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(N,{variant:"outline",size:"icon",onClick:()=>T(i),title:"复制到剪贴板",className:"flex-shrink-0",disabled:!i,children:C?e.jsx(sa,{className:"h-4 w-4 text-green-500"}):e.jsx(Pc,{className:"h-4 w-4"})}),e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"outline",disabled:y,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(Ct,{className:$("h-4 w-4",y&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认重新生成 Token"}),e.jsx(ds,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:ne,children:"确认生成"})]})]})]})]})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground",children:"请妥善保管您的 Access Token,不要泄露给他人"})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"自定义 Access Token"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"new-token",className:"text-sm",children:"新的访问令牌"}),e.jsxs("div",{className:"relative",children:[e.jsx(oe,{id:"new-token",type:j?"text":"password",value:d,onChange:ge=>h(ge.target.value),className:"pr-10 font-mono text-sm",placeholder:"输入自定义 Token"}),e.jsx("button",{onClick:()=>p(!j),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:j?"隐藏":"显示",children:j?e.jsx(xr,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Dt,{className:"h-4 w-4 text-muted-foreground"})})]}),d&&e.jsxs("div",{className:"mt-3 space-y-2 p-3 rounded-lg bg-muted/50",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Token 安全要求:"}),e.jsx("div",{className:"space-y-1.5",children:Q.rules.map(ge=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[ge.passed?e.jsx(fa,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(ng,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:$(ge.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:ge.label})]},ge.id))}),Q.isValid&&e.jsx("div",{className:"mt-2 pt-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[e.jsx(sa,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(N,{onClick:D,disabled:w||!Q.isValid||!d,className:"w-full sm:w-auto",children:w?"更新中...":"更新自定义 Token"})]})]}),e.jsxs("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3 sm:p-4",children:[e.jsx("h4",{className:"text-sm sm:text-base font-semibold text-yellow-900 dark:text-yellow-200 mb-2",children:"安全提示"}),e.jsxs("ul",{className:"text-xs sm:text-sm text-yellow-800 dark:text-yellow-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"重新生成 Token 会创建系统随机生成的 64 位安全令牌"}),e.jsx("li",{children:"自定义 Token 必须满足所有安全要求才能使用"}),e.jsx("li",{children:"更新 Token 后,旧的 Token 将立即失效"}),e.jsx("li",{children:"请在安全的环境下查看和复制 Token"}),e.jsx("li",{children:"如果怀疑 Token 泄露,请立即重新生成或更新"}),e.jsx("li",{children:"建议使用系统生成的 Token 以获得最高安全性"})]})]})]})}function s0(){const n=ga(),{toast:i}=Gs(),[c,d]=u.useState(!1),[h,x]=u.useState(!1),[f,j]=u.useState(()=>st("logCacheSize")),[p,w]=u.useState(()=>st("wsReconnectInterval")),[v,y]=u.useState(()=>st("wsMaxReconnectAttempts")),[S,C]=u.useState(()=>st("dataSyncInterval")),[M,F]=u.useState(()=>sp()),[U,O]=u.useState(!1),[K,H]=u.useState(!1),A=u.useRef(null);if(h)throw new Error("这是一个手动触发的测试错误,用于验证错误边界组件是否正常工作。");const V=()=>{F(sp())},Q=z=>{const X=z[0];j(X),ai("logCacheSize",X)},T=z=>{const X=z[0];w(X),ai("wsReconnectInterval",X)},D=z=>{const X=z[0];y(X),ai("wsMaxReconnectAttempts",X)},ne=z=>{const X=z[0];C(X),ai("dataSyncInterval",X)},xe=()=>{rn.clearLogs(),i({title:"日志已清除",description:"日志缓存已清空"})},_e=()=>{const z=Xy();V(),i({title:"缓存已清除",description:`已清除 ${z.clearedKeys.length} 项缓存数据`})},Se=()=>{O(!0);try{const z=$y(),X=JSON.stringify(z,null,2),k=new Blob([X],{type:"application/json"}),se=URL.createObjectURL(k),_=document.createElement("a");_.href=se,_.download=`maibot-webui-settings-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(se),i({title:"导出成功",description:"设置已导出为 JSON 文件"})}catch(z){console.error("导出设置失败:",z),i({title:"导出失败",description:"无法导出设置",variant:"destructive"})}finally{O(!1)}},ge=z=>{const X=z.target.files?.[0];if(!X)return;H(!0);const k=new FileReader;k.onload=se=>{try{const _=se.target?.result,ue=JSON.parse(_),ie=Qy(ue);ie.success?(j(st("logCacheSize")),w(st("wsReconnectInterval")),y(st("wsMaxReconnectAttempts")),C(st("dataSyncInterval")),V(),i({title:"导入成功",description:`成功导入 ${ie.imported.length} 项设置${ie.skipped.length>0?`,跳过 ${ie.skipped.length} 项`:""}`}),(ie.imported.includes("theme")||ie.imported.includes("accentColor"))&&i({title:"提示",description:"部分设置需要刷新页面才能完全生效"})):i({title:"导入失败",description:"没有有效的设置项可导入",variant:"destructive"})}catch(_){console.error("导入设置失败:",_),i({title:"导入失败",description:"文件格式无效",variant:"destructive"})}finally{H(!1),A.current&&(A.current.value="")}},k.readAsText(X)},ye=()=>{Yy(),j(Aa.logCacheSize),w(Aa.wsReconnectInterval),y(Aa.wsMaxReconnectAttempts),C(Aa.dataSyncInterval),V(),i({title:"已重置",description:"所有设置已恢复为默认值,刷新页面以应用更改"})},be=async()=>{d(!0);try{const z=localStorage.getItem("access-token"),X=await fetch("/api/webui/setup/reset",{method:"POST",headers:{Authorization:`Bearer ${z}`}}),k=await X.json();X.ok&&k.success?(i({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{n({to:"/setup"})},1e3)):i({title:"重置失败",description:k.message||"无法重置配置状态",variant:"destructive"})}catch(z){console.error("重置配置状态错误:",z),i({title:"重置失败",description:"连接服务器失败",variant:"destructive"})}finally{d(!1)}};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(Ic,{className:"h-5 w-5"}),"性能与存储"]}),e.jsxs("div",{className:"space-y-4 sm:space-y-5",children:[e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 sm:p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(xb,{className:"h-4 w-4"}),"本地存储使用"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:V,className:"h-7 px-2",children:e.jsx(Ct,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"text-2xl font-bold text-primary",children:Ky(M.used)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[M.items," 个存储项"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"日志缓存大小"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f," 条"]})]}),e.jsx(Ma,{value:[f],onValueChange:Q,min:100,max:5e3,step:100,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制日志查看器最多缓存的日志条数,较大的值会占用更多内存"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"首页数据刷新间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[S," 秒"]})]}),e.jsx(Ma,{value:[S],onValueChange:ne,min:10,max:120,step:5,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制首页统计数据的自动刷新间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"WebSocket 重连间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[p/1e3," 秒"]})]}),e.jsx(Ma,{value:[p],onValueChange:T,min:1e3,max:1e4,step:500,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"日志 WebSocket 连接断开后的重连基础间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"text-sm font-medium",children:"WebSocket 最大重连次数"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[v," 次"]})]}),e.jsx(Ma,{value:[v],onValueChange:D,min:3,max:30,step:1,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"连接失败后的最大重连尝试次数"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsxs(N,{variant:"outline",size:"sm",onClick:xe,className:"gap-2",children:[e.jsx(ls,{className:"h-4 w-4"}),"清除日志缓存"]}),e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(ls,{className:"h-4 w-4"}),"清除本地缓存"]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认清除本地缓存"}),e.jsx(ds,{children:"这将清除所有本地缓存的设置和数据(不包括登录凭证)。 您可能需要重新配置部分偏好设置。确定要继续吗?"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:_e,children:"确认清除"})]})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(rl,{className:"h-5 w-5"}),"导入/导出设置"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"导出当前的界面设置以便备份,或从之前导出的文件中恢复设置。"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(N,{variant:"outline",onClick:Se,disabled:U,className:"gap-2",children:[e.jsx(rl,{className:"h-4 w-4"}),U?"导出中...":"导出设置"]}),e.jsx("input",{ref:A,type:"file",accept:".json",onChange:ge,className:"hidden"}),e.jsxs(N,{variant:"outline",onClick:()=>A.current?.click(),disabled:K,className:"gap-2",children:[e.jsx(fr,{className:"h-4 w-4"}),K?"导入中...":"导入设置"]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"outline",size:"sm",className:"gap-2 text-destructive hover:text-destructive",children:[e.jsx(Zc,{className:"h-4 w-4"}),"重置所有设置为默认值"]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认重置所有设置"}),e.jsx(ds,{children:"这将把所有界面设置恢复为默认值,包括主题、颜色、动画等偏好设置。 此操作不会影响您的登录状态。确定要继续吗?"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:ye,children:"确认重置"})]})]})]})})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"配置向导"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"重新进行初次配置向导,可以帮助您重新设置系统的基础配置。"})}),e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"outline",disabled:c,className:"gap-2",children:[e.jsx(Zc,{className:$("h-4 w-4",c&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认重新配置"}),e.jsx(ds,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:be,children:"确认重置"})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-dashed border-yellow-500/50 bg-yellow-500/5 p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(ya,{className:"h-5 w-5 text-yellow-500"}),"开发者工具"]}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"以下功能仅供开发调试使用,可能会导致页面崩溃或异常。"})}),e.jsxs(ps,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(N,{variant:"destructive",className:"gap-2",children:[e.jsx(ya,{className:"h-4 w-4"}),"触发测试错误"]})}),e.jsxs(is,{children:[e.jsxs(rs,{children:[e.jsx(os,{children:"确认触发错误"}),e.jsx(ds,{children:"这将手动触发一个 React 错误,用于测试错误边界组件的显示效果。 页面将显示错误界面,您可以通过刷新页面或点击返回首页来恢复。"})]}),e.jsxs(cs,{children:[e.jsx(ms,{children:"取消"}),e.jsx(us,{onClick:()=>x(!0),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认触发"})]})]})]})]})]})]})}function t0(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx("div",{className:"rounded-lg border-2 border-primary/30 bg-gradient-to-r from-primary/5 to-primary/10 p-4 sm:p-6",children:e.jsxs("div",{className:"flex items-start gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-shrink-0 rounded-lg bg-primary/10 p-2 sm:p-3",children:e.jsx("svg",{className:"h-6 w-6 sm:h-8 sm:w-8 text-primary",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg sm:text-xl font-bold text-foreground mb-2",children:"开源项目"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground mb-3",children:"本项目在 GitHub 开源,欢迎 Star ⭐ 支持!"}),e.jsxs("a",{href:"https://github.com/Mai-with-u/MaiBot-Dashboard",target:"_blank",rel:"noopener noreferrer",className:$("inline-flex items-center gap-2 px-4 py-2 rounded-lg","bg-primary text-primary-foreground font-medium text-sm","hover:bg-primary/90 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:[e.jsx("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})}),"前往 GitHub",e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:["关于 ",Yu]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",Qu]}),e.jsx("p",{children:"麦麦(MaiBot)的现代化 Web 管理界面"})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"作者"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"MaiBot 核心"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Mai-with-u"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"WebUI"}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground",children:["Mai-with-u ",e.jsx("a",{href:"https://github.com/DrSmoothl",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"@MotricSeven"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"技术栈"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"前端框架"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"React 19.2.0"}),e.jsx("li",{children:"TypeScript 5.7.2"}),e.jsx("li",{children:"Vite 6.0.7"}),e.jsx("li",{children:"TanStack Router 1.94.2"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"UI 组件"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"shadcn/ui"}),e.jsx("li",{children:"Radix UI"}),e.jsx("li",{children:"Tailwind CSS 3.4.17"}),e.jsx("li",{children:"Lucide Icons"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"后端"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Python 3.12+"}),e.jsx("li",{children:"FastAPI"}),e.jsx("li",{children:"Uvicorn"}),e.jsx("li",{children:"WebSocket"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"构建工具"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Bun / npm"}),e.jsx("li",{children:"ESLint 9.17.0"}),e.jsx("li",{children:"PostCSS"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源库感谢"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mb-3",children:"本项目使用了以下优秀的开源库,感谢他们的贡献:"}),e.jsx(ss,{className:"h-[300px] sm:h-[400px]",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"UI 框架与组件"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(Zs,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(Zs,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(Zs,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(Zs,{name:"Lucide React",description:"精美的图标库",license:"ISC"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"路由与状态管理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(Zs,{name:"Zustand",description:"轻量级状态管理",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"表单处理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(Zs,{name:"Zod",description:"TypeScript 优先的 schema 验证",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"工具库"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(Zs,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(Zs,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(Zs,{name:"date-fns",description:"现代化日期处理库",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"动画效果"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(Zs,{name:"vaul",description:"抽屉组件动画",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"后端框架"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(Zs,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(Zs,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(Zs,{name:"python-multipart",description:"文件上传支持",license:"Apache-2.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"开发工具"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Zs,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(Zs,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(Zs,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(Zs,{name:"PostCSS",description:"CSS 转换工具",license:"MIT"})]})]})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源许可"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-lg bg-primary/5 border border-primary/20 p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("div",{className:"rounded-md bg-primary/10 px-2 py-1",children:e.jsx("span",{className:"text-xs sm:text-sm font-bold text-primary",children:"GPLv3"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm sm:text-base font-semibold text-foreground mb-1",children:"MaiBot WebUI"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目采用 GNU General Public License v3.0 开源许可证。 您可以自由地使用、修改和分发本软件,但必须保持相同的开源许可。"})]})]})}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目依赖的所有开源库均遵循各自的开源许可证(MIT、Apache-2.0、BSD 等)。 感谢所有开源贡献者的无私奉献。"})]})]})]})}function Zs({name:n,description:i,license:c}){return e.jsxs("div",{className:"flex items-start justify-between gap-2 rounded-lg border bg-muted/30 p-2.5 sm:p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-foreground truncate",children:n}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:i})]}),e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary flex-shrink-0",children:c})]})}function Eu({value:n,current:i,onChange:c,label:d,description:h}){const x=i===n;return e.jsxs("button",{onClick:()=>c(n),className:$("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-2 right-2 sm:top-3 sm:right-3 h-2 w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm sm:text-base font-medium",children:d}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:h})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[n==="light"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-200"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-300"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-400"})]}),n==="dark"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-900"})]}),n==="system"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-200 to-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-300 to-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-400 to-slate-900"})]})]})]})}function xa({value:n,current:i,onChange:c,label:d,colorClass:h}){const x=i===n;return e.jsxs("button",{onClick:()=>c(n),className:$("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-1.5 right-1.5 sm:top-2 sm:right-2 h-1.5 w-1.5 sm:h-2 sm:w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5 sm:gap-2",children:[e.jsx("div",{className:$("h-8 w-8 sm:h-10 sm:w-10 rounded-full",h)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:d})]})]})}class a0{grad3;p;perm;constructor(i=0){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.p=[];for(let c=0;c<256;c++)this.p[c]=Math.floor(Math.random()*256);this.perm=[];for(let c=0;c<512;c++)this.perm[c]=this.p[c&255]}dot(i,c,d){return i[0]*c+i[1]*d}mix(i,c,d){return(1-d)*i+d*c}fade(i){return i*i*i*(i*(i*6-15)+10)}perlin2(i,c){const d=Math.floor(i)&255,h=Math.floor(c)&255;i-=Math.floor(i),c-=Math.floor(c);const x=this.fade(i),f=this.fade(c),j=this.perm[d]+h,p=this.perm[j],w=this.perm[j+1],v=this.perm[d+1]+h,y=this.perm[v],S=this.perm[v+1];return this.mix(this.mix(this.dot(this.grad3[p%12],i,c),this.dot(this.grad3[y%12],i-1,c),x),this.mix(this.dot(this.grad3[w%12],i,c-1),this.dot(this.grad3[S%12],i-1,c-1),x),f)}}function ap(){const n=u.useRef(null),i=u.useRef(null),c=u.useRef(void 0),d=u.useRef({mouse:{x:-10,y:0,lx:0,ly:0,sx:0,sy:0,v:0,vs:0,a:0,set:!1},lines:[],paths:[],noise:new a0(Math.random()),bounding:null});return u.useEffect(()=>{const h=i.current,x=n.current;if(!h||!x)return;const f=d.current,j=()=>{const F=h.getBoundingClientRect();f.bounding=F,x.style.width=`${F.width}px`,x.style.height=`${F.height}px`},p=()=>{if(!f.bounding)return;const{width:F,height:U}=f.bounding;f.lines=[],f.paths.forEach(ne=>ne.remove()),f.paths=[];const O=10,K=32,H=F+200,A=U+30,V=Math.ceil(H/O),Q=Math.ceil(A/K),T=(F-O*V)/2,D=(U-K*Q)/2;for(let ne=0;ne<=V;ne++){const xe=[];for(let Se=0;Se<=Q;Se++){const ge={x:T+O*ne,y:D+K*Se,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};xe.push(ge)}const _e=document.createElementNS("http://www.w3.org/2000/svg","path");x.appendChild(_e),f.paths.push(_e),f.lines.push(xe)}},w=F=>{const{lines:U,mouse:O,noise:K}=f;U.forEach(H=>{H.forEach(A=>{const V=K.perlin2((A.x+F*.0125)*.002,(A.y+F*.005)*.0015)*12;A.wave.x=Math.cos(V)*32,A.wave.y=Math.sin(V)*16;const Q=A.x-O.sx,T=A.y-O.sy,D=Math.hypot(Q,T),ne=Math.max(175,O.vs);if(D{const O={x:F.x+F.wave.x+(U?F.cursor.x:0),y:F.y+F.wave.y+(U?F.cursor.y:0)};return O.x=Math.round(O.x*10)/10,O.y=Math.round(O.y*10)/10,O},y=()=>{const{lines:F,paths:U}=f;F.forEach((O,K)=>{let H=v(O[0],!1),A=`M ${H.x} ${H.y}`;O.forEach((V,Q)=>{const T=Q===O.length-1;H=v(V,!T),A+=`L ${H.x} ${H.y}`}),U[K].setAttribute("d",A)})},S=F=>{const{mouse:U}=f;U.sx+=(U.x-U.sx)*.1,U.sy+=(U.y-U.sy)*.1;const O=U.x-U.lx,K=U.y-U.ly,H=Math.hypot(O,K);U.v=H,U.vs+=(H-U.vs)*.1,U.vs=Math.min(100,U.vs),U.lx=U.x,U.ly=U.y,U.a=Math.atan2(K,O),h&&(h.style.setProperty("--x",`${U.sx}px`),h.style.setProperty("--y",`${U.sy}px`)),w(F),y(),c.current=requestAnimationFrame(S)},C=F=>{if(!f.bounding)return;const{mouse:U}=f;U.x=F.pageX-f.bounding.left,U.y=F.pageY-f.bounding.top+window.scrollY,U.set||(U.sx=U.x,U.sy=U.y,U.lx=U.x,U.ly=U.y,U.set=!0)},M=()=>{j(),p()};return j(),p(),window.addEventListener("resize",M),window.addEventListener("mousemove",C),c.current=requestAnimationFrame(S),()=>{window.removeEventListener("resize",M),window.removeEventListener("mousemove",C),c.current&&cancelAnimationFrame(c.current)}},[]),e.jsxs("div",{ref:i,className:"waves-background",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"hidden",pointerEvents:"none"},children:[e.jsx("div",{className:"waves-cursor",style:{position:"absolute",top:0,left:0,width:"0.5rem",height:"0.5rem",background:"hsl(var(--primary) / 0.3)",borderRadius:"50%",transform:"translate3d(calc(var(--x, -0.5rem) - 50%), calc(var(--y, 50%) - 50%), 0)",willChange:"transform",pointerEvents:"none"}}),e.jsx("svg",{ref:n,style:{display:"block",width:"100%",height:"100%"},children:e.jsx("style",{children:` path { fill: none; stroke: hsl(var(--primary) / 0.20); diff --git a/webui/dist/index.html b/webui/dist/index.html index 6aa56064..66ce72c0 100644 --- a/webui/dist/index.html +++ b/webui/dist/index.html @@ -7,7 +7,7 @@ MaiBot Dashboard - +