@zhin.js/console 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +4 -4
  3. package/client/components.json +17 -0
  4. package/client/index.html +1 -1
  5. package/client/src/components/PluginConfigForm/BasicFieldRenderers.tsx +89 -180
  6. package/client/src/components/PluginConfigForm/CollectionFieldRenderers.tsx +97 -200
  7. package/client/src/components/PluginConfigForm/CompositeFieldRenderers.tsx +31 -70
  8. package/client/src/components/PluginConfigForm/FieldRenderer.tsx +27 -77
  9. package/client/src/components/PluginConfigForm/NestedFieldRenderer.tsx +33 -53
  10. package/client/src/components/PluginConfigForm/index.tsx +71 -173
  11. package/client/src/components/ui/accordion.tsx +54 -0
  12. package/client/src/components/ui/alert.tsx +62 -0
  13. package/client/src/components/ui/avatar.tsx +41 -0
  14. package/client/src/components/ui/badge.tsx +32 -0
  15. package/client/src/components/ui/button.tsx +50 -0
  16. package/client/src/components/ui/card.tsx +50 -0
  17. package/client/src/components/ui/checkbox.tsx +25 -0
  18. package/client/src/components/ui/dialog.tsx +87 -0
  19. package/client/src/components/ui/dropdown-menu.tsx +97 -0
  20. package/client/src/components/ui/input.tsx +21 -0
  21. package/client/src/components/ui/scroll-area.tsx +43 -0
  22. package/client/src/components/ui/select.tsx +127 -0
  23. package/client/src/components/ui/separator.tsx +23 -0
  24. package/client/src/components/ui/skeleton.tsx +12 -0
  25. package/client/src/components/ui/switch.tsx +26 -0
  26. package/client/src/components/ui/tabs.tsx +52 -0
  27. package/client/src/components/ui/textarea.tsx +20 -0
  28. package/client/src/components/ui/tooltip.tsx +27 -0
  29. package/client/src/layouts/dashboard.tsx +91 -221
  30. package/client/src/main.tsx +38 -42
  31. package/client/src/pages/dashboard-bots.tsx +91 -137
  32. package/client/src/pages/dashboard-home.tsx +133 -204
  33. package/client/src/pages/dashboard-logs.tsx +125 -196
  34. package/client/src/pages/dashboard-plugin-detail.tsx +261 -329
  35. package/client/src/pages/dashboard-plugins.tsx +108 -105
  36. package/client/src/style.css +156 -865
  37. package/client/src/theme/index.ts +60 -35
  38. package/client/tailwind.config.js +78 -69
  39. package/dist/client.js +1 -1
  40. package/dist/cva.js +47 -0
  41. package/dist/index.html +1 -1
  42. package/dist/index.js +6 -6
  43. package/dist/react-router.js +7121 -5585
  44. package/dist/react.js +192 -149
  45. package/dist/style.css +2 -2
  46. package/lib/bin.js +2 -2
  47. package/lib/build.js +2 -2
  48. package/lib/index.d.ts +0 -3
  49. package/lib/index.js +160 -205
  50. package/lib/transform.d.ts +26 -0
  51. package/lib/transform.js +78 -0
  52. package/lib/websocket.d.ts +0 -1
  53. package/package.json +9 -8
  54. package/dist/radix-ui-themes.js +0 -9305
  55. package/lib/dev.d.ts +0 -18
  56. package/lib/dev.js +0 -87
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import{jsx as e,jsxs as r,Fragment as me}from"./react-jsx-runtime.js";import*as G from"./react.js";import nr,{useState as z,useEffect as q,useMemo as tr,useRef as ir,PureComponent as ar,StrictMode as lr}from"./react.js";import{createRoot as or}from"./react-dom-client.js";import{Moon as cr,Sun as sr,Menu as dr,Search as hr,Bell as ur,User as gr,Users as mr,BarChart3 as pr,HelpCircle as br,LogOut as fr,AlertCircle as te,Package as K,Bot as ce,Activity as ke,TrendingUp as yr,Clock as Ce,Cpu as vr,MemoryStick as ye,FileText as se,Terminal as Se,Box as Je,Layers as pe,Database as je,Code as He,Info as be,Lock as wr,Calendar as zr,List as Ge,Trash2 as Re,Plus as xr,GitBranch as Nr,Settings as kr,ChevronDown as Cr,CheckCircle as Sr,X as jr,Save as Rr,ArrowLeft as Le,Wifi as Ir,WifiOff as $r,Zap as Or,RefreshCw as Tr,Circle as Fr,XCircle as Lr,AlertTriangle as Pr,Home as Er}from"./lucide-react.js";import{useDispatch as Br,useWebSocket as Ar,useSelector as le,cn as de,Link as _r,setActiveMenu as Mr,toggleSidebar as Dr,Outlet as Vr,useConfig as Ur,persistor as Wr,store as Jr,addPage as Hr,DynamicRouter as Gr}from"./client.js";import{Avatar as re,DropdownMenu as W,Accordion as ae}from"./radix-ui.js";import*as Te from"./radix-ui-themes.js";import{Flex as l,Box as I,Spinner as fe,Text as s,Callout as F,Heading as _,Grid as oe,Card as S,Badge as j,Button as U,TextArea as Q,TextField as E,Switch as qe,Select as T,Separator as Ie,Checkbox as qr,Theme as Zr}from"./radix-ui-themes.js";import{useNavigate as Fe,useParams as Kr}from"./react-router.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&a(h)}).observe(document,{childList:!0,subtree:!0});function i(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(o){if(o.ep)return;o.ep=!0;const c=i(o);fetch(o.href,c)}})();var ve={exports:{}},we={};var Pe;function Xr(){if(Pe)return we;Pe=1;var n=nr;function t(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var i=typeof Object.is=="function"?Object.is:t,a=n.useSyncExternalStore,o=n.useRef,c=n.useEffect,h=n.useMemo,g=n.useDebugValue;return we.useSyncExternalStoreWithSelector=function(d,u,b,w,f){var R=o(null);if(R.current===null){var N={hasValue:!1,value:null};R.current=N}else N=R.current;R=h(function(){function B(y){if(!M){if(M=!0,D=y,y=w(y),f!==void 0&&N.hasValue){var v=N.value;if(f(v,y))return A=v}return A=y}if(v=A,i(D,y))return v;var $=w(y);return f!==void 0&&f(v,$)?(D=y,v):(D=y,A=$)}var M=!1,D,A,m=b===void 0?null:b;return[function(){return B(u())},m===null?void 0:function(){return B(m())}]},[u,b,w,f]);var k=a(d,R[0],R[1]);return c(function(){N.hasValue=!0,N.value=k},[k]),g(k),k},we}var Ee;function Yr(){return Ee||(Ee=1,ve.exports=Xr()),ve.exports}Yr();function Qr(n){n()}function en(){let n=null,t=null;return{clear(){n=null,t=null},notify(){Qr(()=>{let i=n;for(;i;)i.callback(),i=i.next})},get(){const i=[];let a=n;for(;a;)i.push(a),a=a.next;return i},subscribe(i){let a=!0;const o=t={callback:i,next:null,prev:t};return o.prev?o.prev.next=o:n=o,function(){!a||n===null||(a=!1,o.next?o.next.prev=o.prev:t=o.prev,o.prev?o.prev.next=o.next:n=o.next)}}}}var Be={notify(){},get:()=>[]};function rn(n,t){let i,a=Be,o=0,c=!1;function h(k){b();const B=a.subscribe(k);let M=!1;return()=>{M||(M=!0,B(),w())}}function g(){a.notify()}function d(){N.onStateChange&&N.onStateChange()}function u(){return c}function b(){o++,i||(i=n.subscribe(d),a=en())}function w(){o--,i&&o===0&&(i(),i=void 0,a.clear(),a=Be)}function f(){c||(c=!0,b())}function R(){c&&(c=!1,w())}const N={addNestedSub:h,notifyNestedSubs:g,handleChangeWrapper:d,isSubscribed:u,trySubscribe:f,tryUnsubscribe:R,getListeners:()=>a};return N}var nn=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",tn=nn(),an=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ln=an(),on=()=>tn||ln?G.useLayoutEffect:G.useEffect,cn=on(),sn=Symbol.for("react-redux-context"),dn=typeof globalThis<"u"?globalThis:{};function hn(){if(!G.createContext)return{};const n=dn[sn]??=new Map;let t=n.get(G.createContext);return t||(t=G.createContext(null),n.set(G.createContext,t)),t}var un=hn();function gn(n){const{children:t,context:i,serverState:a,store:o}=n,c=G.useMemo(()=>{const d=rn(o);return{store:o,subscription:d,getServerState:a?()=>a:void 0}},[o,a]),h=G.useMemo(()=>o.getState(),[o]);cn(()=>{const{subscription:d}=c;return d.onStateChange=d.notifyNestedSubs,d.trySubscribe(),h!==o.getState()&&d.notifyNestedSubs(),()=>{d.tryUnsubscribe(),d.onStateChange=void 0}},[c,h]);const g=i||un;return G.createElement(g.Provider,{value:c},t)}var mn=gn;const pn={light:{background:"0 0% 100%",foreground:"222.2 84% 4.9%",card:"0 0% 100%","card-foreground":"222.2 84% 4.9%",popover:"0 0% 100%","popover-foreground":"222.2 84% 4.9%",primary:"221.2 83.2% 53.3%","primary-foreground":"210 40% 98%",secondary:"210 40% 96.1%","secondary-foreground":"222.2 47.4% 11.2%",muted:"210 40% 96.1%","muted-foreground":"215.4 16.3% 46.9%",accent:"210 40% 96.1%","accent-foreground":"222.2 47.4% 11.2%",destructive:"0 84.2% 60.2%","destructive-foreground":"210 40% 98%",border:"214.3 31.8% 91.4%",input:"214.3 31.8% 91.4%",ring:"221.2 83.2% 53.3%",radius:"0.5rem"},dark:{background:"222.2 84% 4.9%",foreground:"210 40% 98%",card:"222.2 84% 4.9%","card-foreground":"210 40% 98%",popover:"222.2 84% 4.9%","popover-foreground":"210 40% 98%",primary:"217.2 91.2% 59.8%","primary-foreground":"222.2 47.4% 11.2%",secondary:"217.2 32.6% 17.5%","secondary-foreground":"210 40% 98%",muted:"217.2 32.6% 17.5%","muted-foreground":"215 20.2% 65.1%",accent:"217.2 32.6% 17.5%","accent-foreground":"210 40% 98%",destructive:"0 62.8% 30.6%","destructive-foreground":"210 40% 98%",border:"217.2 32.6% 17.5%",input:"217.2 32.6% 17.5%",ring:"224.3 76.3% 48%",radius:"0.5rem"}};function Ze(n){const t=document.documentElement,i=pn[n];t.classList.remove("light","dark"),t.classList.add(n),Object.entries(i).forEach(([a,o])=>{t.style.setProperty(`--${a}`,o)}),localStorage.setItem("theme",n)}function Ke(){const n=localStorage.getItem("theme");return n&&(n==="light"||n==="dark")?n:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function bn(){const n=Ke();return Ze(n),n}function fn(){const[n,t]=z(Ke);return q(()=>{Ze(n)},[n]),{theme:n,setTheme:t,toggleTheme:()=>{t(a=>a==="light"?"dark":"light")}}}function yn(){const{theme:n,toggleTheme:t}=fn();return e("button",{onClick:t,className:"p-2 hover:bg-accent rounded-lg transition-colors text-foreground",title:n==="light"?"切换到暗色模式":"切换到亮色模式",children:n==="light"?e(cr,{className:"w-5 h-5"}):e(sr,{className:"w-5 h-5"})})}const{Box:ne,Flex:C,Text:J,Heading:Ae,IconButton:_e,Badge:vn,TextField:wn,ScrollArea:zn,Container:xn}=Te;function Nn(){const n=Br();Ar();const t=le(c=>c.ui.sidebarOpen),i=le(c=>c.ui.activeMenu),a=le(c=>c.route.routes),o=tr(()=>{const c=a.find(h=>h.key==="dashboard-layout");return!c||!c.children?[]:c.children.filter(h=>!h.meta?.hideInMenu&&h.key!=="dashboard-layout").map((h,g)=>({key:h.key||`menu-item-${g}`,title:h.title,index:h.index,icon:h.icon,href:h.path}))},[a]);return r(C,{className:"h-screen bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800",children:[r(C,{direction:"column",className:de("glass transition-all duration-300 shadow-xl border-r border-gray-200/50 dark:border-gray-700/50",t?"w-64":"w-20"),children:[e(ne,{p:"4",className:"border-b border-gray-200/50 dark:border-gray-700/50",children:r(C,{align:"center",className:de("transition-all duration-300",t?"gap-3":"justify-center"),children:[e(C,{align:"center",justify:"center",className:"w-11 min-w-11 h-11 rounded-xl shadow-md bg-gradient-to-br from-blue-500 to-purple-600",children:e(J,{size:"5",weight:"bold",className:"text-white",children:"Z"})}),t&&r(C,{direction:"column",gap:"0",children:[e(Ae,{size:"4",className:"text-gray-900 dark:text-gray-100",children:"Zhin.js"}),e(J,{size:"1",color:"gray",children:"管理控制台"})]})]})}),e(zn,{className:"flex-1",scrollbars:"vertical",children:e(ne,{p:"3",children:e(C,{direction:"column",gap:"2",children:o.map(c=>{const h=i===c.key;return r(_r,{to:c.href,onClick:()=>n(Mr(c.key)),className:de("menu-item",h&&"active"),children:[e("div",{className:"icon",children:c.icon}),t&&e("div",{className:"text",children:e("div",{className:"title",children:c.title})}),h&&t&&e("div",{className:"indicator"})]},c.key)})})})}),e(C,{p:"3",className:"border-t border-gray-200/50 dark:border-gray-700/50 flex-shrink-0",children:r(C,{align:"center",gap:"2",p:"2",className:de("rounded-xl bg-gray-50/50 dark:bg-gray-800/50 transition-all duration-200 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700",!t&&"justify-center"),children:[r(re.Root,{className:"w-8 h-8 min-w-8 border-2 border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e(re.Image,{src:"https://i.pravatar.cc/150?u=admin",alt:"管理员"}),e(re.Fallback,{children:"管"})]}),t&&r(C,{direction:"column",gap:"0",className:"flex-1 min-w-0",children:[e(J,{size:"2",weight:"medium",className:"truncate text-gray-900 dark:text-gray-100",children:"管理员"}),e(J,{size:"1",color:"gray",className:"truncate",children:"admin@zhin.com"})]})]})})]}),r(C,{direction:"column",className:"flex-1 overflow-hidden",children:[e(ne,{className:"glass border-b border-gray-200/50 dark:border-gray-700/50 shadow-sm",children:r(C,{justify:"between",align:"center",px:"4",className:"h-16",children:[r(C,{align:"center",gap:"3",children:[e(_e,{variant:"ghost",size:"2",onClick:()=>n(Dr()),className:"hover-lift rounded-xl",children:e(dr,{className:"w-5 h-5"})}),r(C,{direction:"column",gap:"0",children:[e(Ae,{size:"3",className:"text-gray-900 dark:text-gray-100",children:"控制台"}),e(J,{size:"1",color:"gray",children:"欢迎回来!"})]})]}),e(C,{className:"hidden md:flex flex-1 max-w-xl mx-6",children:r(ne,{className:"relative",children:[e(hr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500"}),e(wn.Root,{placeholder:"搜索功能、用户、设置...",size:"2",className:"w-full pl-10"})]})}),r(C,{align:"center",gap:"2",children:[e(yn,{}),r(ne,{className:"relative",children:[e(_e,{variant:"ghost",size:"2",className:"hover-lift rounded-xl",children:e(ur,{className:"w-5 h-5"})}),e(vn,{color:"red",variant:"solid",size:"1",className:"absolute -top-1 -right-1 min-w-5 h-5 flex items-center justify-center p-0",children:"3"})]}),r(W.Root,{children:[e(W.Trigger,{asChild:!0,children:r(C,{align:"center",gap:"2",px:"2",py:"1",className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 transition-all duration-200 rounded-xl",children:[r(re.Root,{className:"w-8 h-8 border-2 border-blue-500/20 dark:border-blue-400/30",children:[e(re.Image,{src:"https://i.pravatar.cc/150?u=admin",alt:"管理员"}),e(re.Fallback,{children:"管"})]}),r(C,{direction:"column",gap:"0",className:"hidden lg:flex",children:[e(J,{size:"2",weight:"medium",className:"text-gray-900 dark:text-gray-100",children:"管理员"}),e(J,{size:"1",color:"gray",children:"admin@zhin.com"})]})]})}),r(W.Content,{align:"end",className:"min-w-56",children:[r(ne,{p:"3",className:"border-b border-gray-200 dark:border-gray-700",children:[e(J,{size:"2",weight:"bold",className:"block",children:"登录为"}),e(J,{size:"1",color:"gray",className:"block",children:"admin@zhin.com"})]}),r(W.Item,{children:[e(gr,{className:"mr-2 h-4 w-4"}),"我的设置"]}),r(W.Item,{children:[e(mr,{className:"mr-2 h-4 w-4"}),"团队设置"]}),r(W.Item,{children:[e(pr,{className:"mr-2 h-4 w-4"}),"数据分析"]}),r(W.Item,{children:[e(br,{className:"mr-2 h-4 w-4"}),"帮助与反馈"]}),e(W.Separator,{}),r(W.Item,{color:"red",children:[e(fr,{className:"mr-2 h-4 w-4"}),"退出登录"]})]})]})]})]})}),e(C,{className:"flex-1 overflow-auto",children:e(xn,{size:"4",p:"6",children:e(Vr,{})})})]})]})}function kn(){const n=Fe(),[t,i]=z(null),[a,o]=z(null),[c,h]=z(!0),[g,d]=z(null);q(()=>{u();const f=setInterval(u,5e3);return()=>clearInterval(f)},[]);const u=async()=>{try{const[f,R]=await Promise.all([fetch("/api/stats",{credentials:"include"}),fetch("/api/system/status",{credentials:"include"})]);if(!f.ok||!R.ok)throw new Error("API 请求失败");const N=await f.json(),k=await R.json();N.success&&k.success&&(i(N.data),o(k.data),d(null))}catch(f){d(f.message)}finally{h(!1)}},b=f=>{const R=Math.floor(f/86400),N=Math.floor(f%86400/3600),k=Math.floor(f%3600/60);return`${R}天 ${N}小时 ${k}分钟`},w=f=>`${(f/1024/1024).toFixed(2)} MB`;return c?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):g?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",g]})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"6",children:[e(_,{size:"8",children:"系统概览"}),e(s,{color:"gray",children:"实时监控您的机器人框架运行状态"})]}),r(oe,{columns:{initial:"1",sm:"2",lg:"4"},gap:"4",mb:"6",children:[e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"插件总数"}),e(I,{p:"2",style:{borderRadius:"8px",backgroundColor:"var(--purple-3)"},children:e(K,{size:16,color:"var(--purple-9)"})})]}),e(_,{size:"7",children:t?.plugins.total||0}),r(l,{align:"center",gap:"1",children:[e(j,{color:"blue",children:t?.plugins.active||0}),e(s,{size:"1",color:"gray",children:"个活跃"})]})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"机器人"}),e(ce,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.bots.total||0}),r(s,{size:"1",color:"green",children:[t?.bots.online||0," 个在线"]})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"命令数量"}),e(ke,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.commands||0}),e(s,{size:"1",color:"gray",children:"可用命令"})]})}),e(S,{children:r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",children:[e(s,{size:"2",weight:"medium",color:"gray",children:"组件数量"}),e(yr,{size:16,color:"var(--gray-9)"})]}),e(_,{size:"7",children:t?.components||0}),e(s,{size:"1",color:"gray",children:"已注册组件"})]})})]}),r(oe,{columns:{initial:"1",md:"2"},gap:"4",mb:"6",children:[e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"系统信息"}),e(s,{size:"2",color:"gray",children:"服务器运行状态"})]}),r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(Ce,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"运行时间"})]}),e(j,{variant:"soft",children:a?b(a.uptime):"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(vr,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"平台"})]}),e(j,{variant:"soft",children:a?.platform||"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ke,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"Node 版本"})]}),e(j,{variant:"soft",children:a?.nodeVersion||"-"})]})]})]})}),e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"资源使用"}),e(s,{size:"2",color:"gray",children:"内存使用情况"})]}),r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"堆内存使用"})]}),e(j,{variant:"soft",children:t?`${t.memory.toFixed(2)} MB`:"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"总堆内存"})]}),e(j,{variant:"soft",children:a?w(a.memory.heapTotal):"-"})]}),r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(ye,{size:16,color:"var(--gray-9)"}),e(s,{size:"2",children:"RSS"})]}),e(j,{variant:"soft",children:a?w(a.memory.rss):"-"})]})]})]})})]}),e(S,{children:r(l,{direction:"column",gap:"4",children:[r(I,{children:[e(_,{size:"5",mb:"1",children:"快速操作"}),e(s,{size:"2",color:"gray",children:"常用功能快捷入口"})]}),r(oe,{columns:{initial:"1",md:"3"},gap:"3",children:[e(U,{variant:"outline",onClick:()=>n("/plugins"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(K,{size:20,color:"var(--blue-9)"}),e(s,{weight:"medium",children:"插件管理"}),e(s,{size:"1",color:"gray",children:"查看和管理插件"})]})}),e(U,{variant:"outline",onClick:()=>n("/bots"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(ce,{size:20,color:"var(--green-9)"}),e(s,{weight:"medium",children:"机器人状态"}),e(s,{size:"1",color:"gray",children:"监控机器人运行"})]})}),e(U,{variant:"outline",onClick:()=>n("/logs"),style:{height:"auto",padding:"16px",cursor:"pointer"},children:r(l,{direction:"column",align:"start",gap:"2",style:{width:"100%"},children:[e(se,{size:20,color:"var(--purple-9)"}),e(s,{weight:"medium",children:"系统日志"}),e(s,{size:"1",color:"gray",children:"查看运行日志"})]})})]})]})})]})}const{Flex:O,Box:Cn,Spinner:Sn,Text:L,Callout:ze,Heading:xe,Badge:Me,Grid:De,Card:Ve,Separator:jn}=Te;function Rn(){const n=Fe(),[t,i]=z([]),[a,o]=z(!0),[c,h]=z(null);q(()=>{g();const d=setInterval(g,1e4);return()=>clearInterval(d)},[]);const g=async()=>{try{const d=await fetch("/api/plugins",{credentials:"include"});if(!d.ok)throw new Error("API 请求失败");const u=await d.json();if(u.success)i(u.data),h(null);else throw new Error("数据格式错误")}catch(d){h(d.message)}finally{o(!1)}};return a?e(O,{align:"center",justify:"center",className:"h-full",children:r(O,{direction:"column",align:"center",gap:"3",children:[e(Sn,{size:"3"}),e(L,{size:"2",color:"gray",children:"加载中..."})]})}):c?e(O,{align:"center",justify:"center",className:"h-full",children:r(ze.Root,{color:"red",children:[e(ze.Icon,{children:e(te,{})}),r(ze.Text,{children:["加载失败: ",c]})]})}):r(Cn,{children:[r(O,{direction:"column",gap:"2",mb:"4",children:[e(xe,{size:"6",children:"插件管理"}),r(O,{align:"center",gap:"2",children:[r(L,{size:"2",color:"gray",children:["共 ",t.length," 个插件"]}),e(Me,{color:"green",size:"1",children:t.filter(d=>d.status==="active").length}),e(L,{size:"2",color:"gray",children:"个运行中"})]})]}),e(De,{columns:{initial:"1",sm:"2",lg:"3"},gap:"3",children:t.map((d,u)=>e(Ve,{className:"cursor-pointer hover-lift transition-smooth",onClick:()=>n(`/plugins/${encodeURIComponent(d.name)}`),children:r(O,{direction:"column",gap:"2",p:"2",children:[r(O,{justify:"between",align:"center",children:[r(O,{align:"center",gap:"2",children:[e(O,{align:"center",justify:"center",className:"w-8 h-8 rounded-lg bg-blue-500/10 dark:bg-blue-400/10",children:e(K,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e(xe,{size:"3",children:d.name})]}),e(Me,{color:d.status==="active"?"green":"gray",size:"1",children:d.status==="active"?"运行中":"已停止"})]}),e(L,{size:"1",color:"gray",className:"line-clamp-2",children:d.description||"暂无描述"}),e(jn,{size:"4",my:"1"}),r(De,{columns:{initial:"1",sm:"2",lg:"4"},gap:"1",children:[r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-blue-500/5 dark:bg-blue-400/5 p-1.5",children:[e(Se,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.commandCount}),e(L,{size:"1",color:"gray",children:"命令"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-green-500/5 dark:bg-green-400/5 p-1.5",children:[e(Je,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.componentCount}),e(L,{size:"1",color:"gray",children:"组件"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-purple-500/5 dark:bg-purple-400/5 p-1.5",children:[e(pe,{className:"w-3 h-3 text-purple-600 dark:text-purple-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.middlewareCount}),e(L,{size:"1",color:"gray",children:"中间件"})]}),r(O,{gap:"2",justify:"center",align:"center",className:"rounded-md bg-orange-500/5 dark:bg-orange-400/5 p-1.5",children:[e(je,{className:"w-3 h-3 text-orange-600 dark:text-orange-400"}),e(L,{size:"2",weight:"bold",className:"mt-0.5",children:d.contextCount}),e(L,{size:"1",color:"gray",children:"上下文"})]})]})]})},`${d.name}-${u}`))}),t.length===0&&e(Ve,{className:"mt-6",children:r(O,{direction:"column",align:"center",gap:"3",py:"8",children:[e(O,{align:"center",justify:"center",className:"w-16 h-16 rounded-full bg-gray-100 dark:bg-gray-800",children:e(K,{className:"w-8 h-8 text-gray-400"})}),r(O,{direction:"column",align:"center",gap:"1",children:[e(xe,{size:"4",children:"暂无插件"}),e(L,{size:"2",color:"gray",children:"请先安装并启用插件"})]})]})})]})}function In({field:n,value:t,onChange:i}){return n.enum?r(T.Root,{size:"2",value:t?.toString()||"",onValueChange:i,children:[e(T.Trigger,{className:"w-full hover:border-blue-500 dark:hover:border-blue-400 transition-colors"}),e(T.Content,{className:"shadow-lg",children:n.enum.map(a=>e(T.Item,{value:a.toString(),className:"hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors",children:a.toString()},a))})]}):n.description?.includes("多行")||n.key?.includes("description")?e(Q,{size:"2",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入",rows:3,className:"font-sans resize-y hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus:ring-2 focus:ring-blue-500/20"}):e(E.Root,{size:"2",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"})}function $n({field:n,value:t,onChange:i}){return e(E.Root,{size:"2",type:"number",value:t?.toString()||"",onChange:a=>i(parseFloat(a.target.value)||0),placeholder:n.description||"请输入数字",min:n.min,max:n.max,className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"})}function On({value:n,onChange:t}){return r(l,{align:"center",gap:"3",className:"p-3 rounded-lg bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-800",children:[e(qe,{size:"2",checked:n===!0,onCheckedChange:t,className:"cursor-pointer"}),r(l,{direction:"column",gap:"1",children:[e(s,{size:"2",weight:"bold",color:n?"green":"gray",children:n?"已启用":"已禁用"}),e(s,{size:"1",color:"gray",children:n?"功能当前处于开启状态":"功能当前处于关闭状态"})]})]})}function Tn({field:n,value:t,onChange:i}){const a=typeof t=="number"?t:n.default||0;return e("div",{className:"p-4 rounded-lg bg-gradient-to-br from-blue-50 to-cyan-50 dark:from-blue-900/20 dark:to-cyan-900/20 border border-blue-200 dark:border-blue-800",children:r(l,{direction:"column",gap:"3",children:[r(l,{align:"center",gap:"3",children:[e("input",{type:"range",min:n.min||0,max:n.max||1,step:n.step||.01,value:a,onChange:o=>i(parseFloat(o.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer bg-blue-200 dark:bg-blue-800 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-blue-600 dark:[&::-webkit-slider-thumb]:bg-blue-400 [&::-webkit-slider-thumb]:cursor-pointer hover:[&::-webkit-slider-thumb]:bg-blue-700 dark:hover:[&::-webkit-slider-thumb]:bg-blue-300 transition-all"}),e(E.Root,{size:"2",type:"number",value:(a*100).toFixed(0),onChange:o=>i(parseFloat(o.target.value)/100),min:(n.min||0)*100,max:(n.max||1)*100,className:"w-24",children:e(E.Slot,{side:"right",children:e(s,{size:"1",weight:"bold",className:"text-blue-600 dark:text-blue-400",children:"%"})})})]}),r(l,{align:"center",justify:"between",children:[e(s,{size:"1",color:"gray",children:"当前值"}),r(j,{color:"blue",size:"2",variant:"soft",className:"font-mono",children:[(a*100).toFixed(1),"%"]})]})]})})}function Fn({field:n,value:t,onChange:i}){const a=t instanceof Date?t.toISOString().split("T")[0]:t||"";return e("div",{className:"relative",children:e(E.Root,{size:"2",type:"date",value:a,onChange:o=>i(new Date(o.target.value)),placeholder:n.description||"选择日期",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20",children:e(E.Slot,{side:"left",children:e(zr,{className:"w-4 h-4 text-gray-500"})})})})}function Ln({field:n,value:t,onChange:i}){const a=t instanceof RegExp?t.source:typeof t=="string"?t:"";return e("div",{className:"p-3 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800",children:r(l,{direction:"column",gap:"2",children:[r(E.Root,{size:"2",value:a,onChange:o=>{try{i(new RegExp(o.target.value))}catch{i(o.target.value)}},placeholder:n.description||"请输入正则表达式",className:"font-mono text-sm hover:border-amber-500 dark:hover:border-amber-400 transition-colors",children:[e(E.Slot,{side:"left",children:e(s,{size:"1",className:"text-amber-600 dark:text-amber-400 font-bold",children:"/"})}),e(E.Slot,{side:"right",children:e(s,{size:"1",className:"text-amber-600 dark:text-amber-400 font-bold",children:"/"})})]}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-amber-600 dark:text-amber-400"}),e(s,{size:"1",className:"text-amber-700 dark:text-amber-300",children:"输入正则表达式模式 (省略斜杠)"})]})]})})}function Pn({field:n,value:t}){const i=n.default||t;return e("div",{className:"p-3 rounded-lg bg-gray-100 dark:bg-gray-900 border border-gray-300 dark:border-gray-700",children:r(l,{align:"center",gap:"3",children:[e(wr,{className:"w-4 h-4 text-gray-500 dark:text-gray-400"}),e(j,{variant:"soft",size:"2",className:"font-mono",children:String(i)}),e(s,{size:"1",color:"gray",className:"ml-auto",children:"(常量,不可修改)"})]})})}function En({field:n,value:t,onChange:i}){return e("div",{className:"p-3 rounded-lg bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800",children:r(l,{direction:"column",gap:"3",children:[r(l,{align:"center",gap:"2",children:[e(He,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(s,{size:"1",weight:"bold",className:"text-purple-700 dark:text-purple-300",children:"JSON 格式输入"})]}),e(Q,{size:"2",value:typeof t=="object"?JSON.stringify(t,null,2):String(t||""),onChange:a=>{try{i(JSON.parse(a.target.value))}catch{i(a.target.value)}},placeholder:n.description||"支持任意类型 (JSON 格式)",rows:4,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-purple-500 dark:hover:border-purple-400 transition-colors"}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-purple-600 dark:text-purple-400"}),e(s,{size:"1",className:"text-purple-700 dark:text-purple-300",children:"支持: 字符串、数字、布尔值、对象、数组"})]})]})})}function Bn({fieldName:n,field:t,value:i,onChange:a,onArrayItemChange:o,renderNestedField:c}){const h=Array.isArray(i)?i:[],g=t.inner||t.items;return g&&["string","number"].includes(g.type)?e("div",{className:"p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"2",children:[e(Ge,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(s,{size:"1",weight:"bold",className:"text-green-700 dark:text-green-300",children:"列表输入 (每行一个值)"})]}),e(Q,{size:"2",value:h.join(`
2
- `),onChange:d=>{const u=d.target.value.split(`
3
- `).filter(Boolean),b=g.type==="number"?u.map(w=>parseFloat(w)||0):u;a(b)},placeholder:`每行一个值
4
- ${t.description||""}`,rows:4,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-green-500 dark:hover:border-green-400 transition-colors"})]})}):r(l,{direction:"column",gap:"2",children:[e("div",{className:"space-y-2",children:h.map((d,u)=>e(S,{size:"1",variant:"surface",className:"border border-gray-200 dark:border-gray-800 hover:border-blue-300 dark:hover:border-blue-700 transition-colors group",children:r(l,{direction:"column",gap:"2",className:"p-3",children:[r(l,{justify:"between",align:"center",children:[e(l,{align:"center",gap:"2",children:e(j,{size:"1",variant:"soft",color:"blue",className:"font-mono",children:u+1})}),e(U,{size:"1",variant:"ghost",color:"red",onClick:()=>{const b=h.filter((w,f)=>f!==u);a(b)},className:"opacity-0 group-hover:opacity-100 transition-opacity",children:e(Re,{className:"w-3 h-3"})})]}),e("div",{className:"pl-2 border-l-2 border-blue-200 dark:border-blue-800",children:g&&c(`${n}[${u}]`,g,d,b=>{o?.(n,u,b)})})]})},u))}),r(U,{size:"2",variant:"soft",onClick:()=>{const d=g?.default||(g?.type==="object"?{}:"");a([...h,d])},className:"w-full hover:bg-blue-100 dark:hover:bg-blue-900/30 border-2 border-dashed border-blue-300 dark:border-blue-700 hover:border-blue-500 dark:hover:border-blue-500 transition-colors",children:[e(xr,{className:"w-4 h-4"}),"添加项"]})]})}function An({field:n,value:t,onChange:i}){return e("div",{className:"p-3 rounded-lg bg-cyan-50 dark:bg-cyan-900/20 border border-cyan-200 dark:border-cyan-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"2",children:[e(Ge,{className:"w-4 h-4 text-cyan-600 dark:text-cyan-400"}),e(s,{size:"1",weight:"bold",className:"text-cyan-700 dark:text-cyan-300",children:"数组输入 (每行一个值)"})]}),e(Q,{size:"2",value:Array.isArray(t)?t.join(`
5
- `):"",onChange:a=>i(a.target.value.split(`
1
+ import{jsx as e,jsxs as a,Fragment as re}from"./react-jsx-runtime.js";import*as p from"./react.js";import at,{useState as y,useEffect as D,useMemo as st,useRef as nt,PureComponent as ct,StrictMode as lt}from"./react.js";import{createRoot as it}from"./react-dom-client.js";import{Moon as ot,Sun as dt,Menu as mt,Search as ut,AlertCircle as G,Package as E,Bot as Z,Activity as me,TrendingUp as ht,Clock as pe,Cpu as ft,MemoryStick as ie,FileText as ge,Server as xe,Plug as be,Settings as Ne,Shield as _e,Database as ae,Wrench as Le,Brain as Ee,Layers as ve,Box as Fe,Terminal as Me,ChevronDown as ye,ChevronUp as pt,Check as De,Code as Ve,Info as se,Lock as gt,Calendar as xt,List as Be,Trash2 as ue,Plus as bt,GitBranch as Nt,CheckCircle as vt,X as yt,Loader2 as wt,Save as St,ArrowLeft as je,Wifi as kt,WifiOff as Ct,Zap as Rt,RefreshCw as jt,Circle as It,XCircle as Ot,AlertTriangle as At,Home as Pt}from"./lucide-react.js";import{cn as g,useDispatch as Tt,useSelector as J,Link as $t,setActiveMenu as _t,toggleSidebar as Lt,Outlet as Et,useConfig as Ft,persistor as Mt,store as Dt,useWebSocket as Vt,addPage as Bt,DynamicRouter as zt}from"./client.js";import{cva as we}from"./cva.js";import{ScrollArea as q,Separator as Ut,Switch as Ie,Select as A,Accordion as K,Checkbox as Oe,Tooltip as X}from"./radix-ui.js";import{useNavigate as Se,useParams as Jt}from"./react-router.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))n(c);new MutationObserver(c=>{for(const l of c)if(l.type==="childList")for(const o of l.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function s(c){const l={};return c.integrity&&(l.integrity=c.integrity),c.referrerPolicy&&(l.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?l.credentials="include":c.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function n(c){if(c.ep)return;c.ep=!0;const l=s(c);fetch(c.href,l)}})();var oe={exports:{}},de={};var Ae;function Wt(){if(Ae)return de;Ae=1;var r=at;function t(i,m){return i===m&&(i!==0||1/i===1/m)||i!==i&&m!==m}var s=typeof Object.is=="function"?Object.is:t,n=r.useSyncExternalStore,c=r.useRef,l=r.useEffect,o=r.useMemo,d=r.useDebugValue;return de.useSyncExternalStoreWithSelector=function(i,m,u,S,N){var C=c(null);if(C.current===null){var R={hasValue:!1,value:null};C.current=R}else R=C.current;C=o(function(){function T(x){if(!$){if($=!0,M=x,x=S(x),N!==void 0&&R.hasValue){var b=R.value;if(N(b,x))return h=b}return h=x}if(b=h,s(M,x))return b;var O=S(x);return N!==void 0&&N(b,O)?(M=x,b):(M=x,h=O)}var $=!1,M,h,f=u===void 0?null:u;return[function(){return T(m())},f===null?void 0:function(){return T(f())}]},[m,u,S,N]);var j=n(i,C[0],C[1]);return l(function(){R.hasValue=!0,R.value=j},[j]),d(j),j},de}var Pe;function Gt(){return Pe||(Pe=1,oe.exports=Wt()),oe.exports}Gt();function Ht(r){r()}function qt(){let r=null,t=null;return{clear(){r=null,t=null},notify(){Ht(()=>{let s=r;for(;s;)s.callback(),s=s.next})},get(){const s=[];let n=r;for(;n;)s.push(n),n=n.next;return s},subscribe(s){let n=!0;const c=t={callback:s,next:null,prev:t};return c.prev?c.prev.next=c:r=c,function(){!n||r===null||(n=!1,c.next?c.next.prev=c.prev:t=c.prev,c.prev?c.prev.next=c.next:r=c.next)}}}}var Te={notify(){},get:()=>[]};function Zt(r,t){let s,n=Te,c=0,l=!1;function o(j){u();const T=n.subscribe(j);let $=!1;return()=>{$||($=!0,T(),S())}}function d(){n.notify()}function i(){R.onStateChange&&R.onStateChange()}function m(){return l}function u(){c++,s||(s=r.subscribe(i),n=qt())}function S(){c--,s&&c===0&&(s(),s=void 0,n.clear(),n=Te)}function N(){l||(l=!0,u())}function C(){l&&(l=!1,S())}const R={addNestedSub:o,notifyNestedSubs:d,handleChangeWrapper:i,isSubscribed:m,trySubscribe:N,tryUnsubscribe:C,getListeners:()=>n};return R}var Kt=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Xt=Kt(),Qt=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Yt=Qt(),er=()=>Xt||Yt?p.useLayoutEffect:p.useEffect,tr=er(),rr=Symbol.for("react-redux-context"),ar=typeof globalThis<"u"?globalThis:{};function sr(){if(!p.createContext)return{};const r=ar[rr]??=new Map;let t=r.get(p.createContext);return t||(t=p.createContext(null),r.set(p.createContext,t)),t}var nr=sr();function cr(r){const{children:t,context:s,serverState:n,store:c}=r,l=p.useMemo(()=>{const i=Zt(c);return{store:c,subscription:i,getServerState:n?()=>n:void 0}},[c,n]),o=p.useMemo(()=>c.getState(),[c]);tr(()=>{const{subscription:i}=l;return i.onStateChange=i.notifyNestedSubs,i.trySubscribe(),o!==c.getState()&&i.notifyNestedSubs(),()=>{i.tryUnsubscribe(),i.onStateChange=void 0}},[l,o]);const d=s||nr;return p.createElement(d.Provider,{value:l},t)}var lr=cr;const ir={light:{background:"0 0% 100%",foreground:"240 10% 3.9%",card:"0 0% 100%","card-foreground":"240 10% 3.9%",popover:"0 0% 100%","popover-foreground":"240 10% 3.9%",primary:"240 5.9% 10%","primary-foreground":"0 0% 98%",secondary:"240 4.8% 95.9%","secondary-foreground":"240 5.9% 10%",muted:"240 4.8% 95.9%","muted-foreground":"240 3.8% 46.1%",accent:"240 4.8% 95.9%","accent-foreground":"240 5.9% 10%",destructive:"0 84.2% 60.2%","destructive-foreground":"0 0% 98%",border:"240 5.9% 90%",input:"240 5.9% 90%",ring:"240 5.9% 10%",radius:"0.5rem","chart-1":"240 5.9% 10%","chart-2":"240 3.8% 46.1%","chart-3":"240 5.9% 90%","chart-4":"240 4.8% 95.9%","chart-5":"0 0% 100%",sidebar:"0 0% 98%","sidebar-foreground":"240 5.3% 26.1%","sidebar-primary":"240 5.9% 10%","sidebar-primary-foreground":"0 0% 98%","sidebar-accent":"240 4.8% 95.9%","sidebar-accent-foreground":"240 5.9% 10%","sidebar-border":"220 13% 91%","sidebar-ring":"240 5.9% 10%"},dark:{background:"240 10% 3.9%",foreground:"0 0% 98%",card:"240 10% 3.9%","card-foreground":"0 0% 98%",popover:"240 10% 3.9%","popover-foreground":"0 0% 98%",primary:"0 0% 98%","primary-foreground":"240 5.9% 10%",secondary:"240 3.7% 15.9%","secondary-foreground":"0 0% 98%",muted:"240 3.7% 15.9%","muted-foreground":"240 5% 64.9%",accent:"240 3.7% 15.9%","accent-foreground":"0 0% 98%",destructive:"0 62.8% 30.6%","destructive-foreground":"0 0% 98%",border:"240 3.7% 15.9%",input:"240 3.7% 15.9%",ring:"240 4.9% 83.9%",radius:"0.5rem","chart-1":"0 0% 98%","chart-2":"240 5% 64.9%","chart-3":"240 3.7% 15.9%","chart-4":"240 10% 3.9%","chart-5":"240 5.9% 10%",sidebar:"240 5.9% 10%","sidebar-foreground":"240 4.8% 95.9%","sidebar-primary":"0 0% 98%","sidebar-primary-foreground":"240 5.9% 10%","sidebar-accent":"240 3.7% 15.9%","sidebar-accent-foreground":"240 4.8% 95.9%","sidebar-border":"240 3.7% 15.9%","sidebar-ring":"240 4.9% 83.9%"}};function ze(r){const t=document.documentElement,s=ir[r];t.classList.remove("light","dark"),t.classList.add(r),Object.entries(s).forEach(([n,c])=>{t.style.setProperty(`--${n}`,c)}),localStorage.setItem("theme",r)}function Ue(){const r=localStorage.getItem("theme");return r&&(r==="light"||r==="dark")?r:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function or(){const r=Ue();return ze(r),r}function dr(){const[r,t]=y(Ue);return D(()=>{ze(r)},[r]),{theme:r,setTheme:t,toggleTheme:()=>{t(n=>n==="light"?"dark":"light")}}}function mr(){const{theme:r,toggleTheme:t}=dr();return e("button",{onClick:t,className:"p-2 hover:bg-accent rounded-lg transition-colors text-foreground",title:r==="light"?"切换到暗色模式":"切换到亮色模式",children:r==="light"?e(ot,{className:"w-5 h-5"}):e(dt,{className:"w-5 h-5"})})}const ur=we("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"}}),P=p.forwardRef(({className:r,variant:t,size:s,...n},c)=>e("button",{className:g(ur({variant:t,size:s,className:r})),ref:c,...n}));P.displayName="Button";const F=p.forwardRef(({className:r,type:t,...s},n)=>e("input",{type:t,className:g("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm 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",r),ref:n,...s}));F.displayName="Input";const Je=p.forwardRef(({className:r,children:t,...s},n)=>a(q.Root,{ref:n,className:g("relative overflow-hidden",r),...s,children:[e(q.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),e(We,{}),e(q.Corner,{})]}));Je.displayName="ScrollArea";const We=p.forwardRef(({className:r,orientation:t="vertical",...s},n)=>e(q.Scrollbar,{ref:n,orientation:t,className:g("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",r),...s,children:e(q.Thumb,{className:"relative flex-1 rounded-full bg-border"})}));We.displayName="ScrollBar";function hr(){const r=Tt(),t=J(l=>l.ui.sidebarOpen),s=J(l=>l.ui.activeMenu),n=J(l=>l.route.routes),c=st(()=>{const l=n.find(o=>o.key==="dashboard-layout");return!l||!l.children?[]:l.children.filter(o=>!o.meta?.hideInMenu&&o.key!=="dashboard-layout").map((o,d)=>({key:o.key||`menu-item-${d}`,title:o.title,index:o.index,icon:o.icon,href:o.path}))},[n]);return a("div",{className:"flex h-screen bg-background",children:[a("div",{className:g("flex flex-col border-r bg-sidebar transition-all duration-300",t?"w-64":"w-16"),children:[e("div",{className:"p-4 border-b",children:a("div",{className:g("flex items-center transition-all duration-300",t?"gap-3":"justify-center"),children:[e("div",{className:"flex items-center justify-center w-9 h-9 min-w-9 rounded-lg bg-foreground text-background font-bold text-lg",children:"Z"}),t&&a("div",{className:"flex flex-col",children:[e("span",{className:"text-base font-semibold",children:"Zhin.js"}),e("span",{className:"text-xs text-muted-foreground",children:"管理控制台"})]})]})}),e(Je,{className:"flex-1",children:e("div",{className:"p-2 space-y-1",children:c.map(l=>{const o=s===l.key;return a($t,{to:l.href,onClick:()=>r(_t(l.key)),className:g("menu-item",o&&"active",!t&&"justify-center px-2"),children:[e("span",{className:"shrink-0",children:l.icon}),t&&e("span",{className:"truncate",children:l.title})]},l.key)})})})]}),a("div",{className:"flex flex-col flex-1 overflow-hidden",children:[a("header",{className:"flex items-center justify-between h-14 px-4 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:[a("div",{className:"flex items-center gap-3",children:[e(P,{variant:"ghost",size:"icon",onClick:()=>r(Lt()),children:e(mt,{className:"h-5 w-5"})}),a("div",{className:"flex flex-col",children:[e("h2",{className:"text-sm font-semibold",children:"控制台"}),e("span",{className:"text-xs text-muted-foreground",children:"欢迎回来"})]})]}),e("div",{className:"hidden md:flex flex-1 max-w-md mx-6",children:a("div",{className:"relative w-full",children:[e(ut,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e(F,{placeholder:"搜索功能、插件、设置...",className:"pl-9 bg-muted/50"})]})}),e("div",{className:"flex items-center gap-1",children:e(mr,{})})]}),e("main",{className:"flex-1 overflow-auto",children:e("div",{className:"max-w-7xl mx-auto p-6",children:e(Et,{})})})]})]})}const w=p.forwardRef(({className:r,...t},s)=>e("div",{ref:s,className:g("rounded-lg border bg-card text-card-foreground shadow-sm",r),...t}));w.displayName="Card";const _=p.forwardRef(({className:r,...t},s)=>e("div",{ref:s,className:g("flex flex-col space-y-1.5 p-6",r),...t}));_.displayName="CardHeader";const L=p.forwardRef(({className:r,...t},s)=>e("div",{ref:s,className:g("text-lg font-semibold leading-none tracking-tight",r),...t}));L.displayName="CardTitle";const Q=p.forwardRef(({className:r,...t},s)=>e("div",{ref:s,className:g("text-sm text-muted-foreground",r),...t}));Q.displayName="CardDescription";const k=p.forwardRef(({className:r,...t},s)=>e("div",{ref:s,className:g("p-6 pt-0",r),...t}));k.displayName="CardContent";const fr=p.forwardRef(({className:r,...t},s)=>e("div",{ref:s,className:g("flex items-center p-6 pt-0",r),...t}));fr.displayName="CardFooter";const pr=we("inline-flex items-center rounded-full 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",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow",outline:"text-foreground",success:"border-transparent bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-400",warning:"border-transparent bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400"}},defaultVariants:{variant:"default"}});function v({className:r,variant:t,...s}){return e("div",{className:g(pr({variant:t}),r),...s})}const gr=we("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-400 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-400",warning:"border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-800 dark:bg-amber-950/50 dark:text-amber-400 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-400"}},defaultVariants:{variant:"default"}}),V=p.forwardRef(({className:r,variant:t,...s},n)=>e("div",{ref:n,role:"alert",className:g(gr({variant:t}),r),...s}));V.displayName="Alert";const xr=p.forwardRef(({className:r,...t},s)=>e("h5",{ref:s,className:g("mb-1 font-medium leading-none tracking-tight",r),...t}));xr.displayName="AlertTitle";const B=p.forwardRef(({className:r,...t},s)=>e("div",{ref:s,className:g("text-sm [&_p]:leading-relaxed",r),...t}));B.displayName="AlertDescription";function I({className:r,...t}){return e("div",{className:g("animate-pulse rounded-md bg-primary/10",r),...t})}function br(){const r=Se(),[t,s]=y(null),[n,c]=y(null),[l,o]=y(!0),[d,i]=y(null);D(()=>{m();const N=setInterval(m,5e3);return()=>clearInterval(N)},[]);const m=async()=>{try{const[N,C]=await Promise.all([fetch("/api/stats",{credentials:"include"}),fetch("/api/system/status",{credentials:"include"})]);if(!N.ok||!C.ok)throw new Error("API 请求失败");const R=await N.json(),j=await C.json();R.success&&j.success&&(s(R.data),c(j.data),i(null))}catch(N){i(N.message)}finally{o(!1)}},u=N=>{const C=Math.floor(N/86400),R=Math.floor(N%86400/3600),j=Math.floor(N%3600/60);return`${C}天 ${R}小时 ${j}分钟`},S=N=>`${(N/1024/1024).toFixed(2)} MB`;return l?a("div",{className:"space-y-6",children:[a("div",{children:[e(I,{className:"h-8 w-48"}),e(I,{className:"h-4 w-64 mt-2"})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[...Array(4)].map((N,C)=>e(I,{className:"h-32"},C))})]}):d?e("div",{className:"flex items-center justify-center h-full",children:a(V,{variant:"destructive",className:"max-w-md",children:[e(G,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",d]})]})}):a("div",{className:"space-y-6",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:"系统概览"}),e("p",{className:"text-muted-foreground",children:"实时监控您的机器人框架运行状态"})]}),a("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[a(w,{children:[a(_,{className:"flex flex-row items-center justify-between pb-2",children:[e(L,{className:"text-sm font-medium text-muted-foreground",children:"插件总数"}),e(E,{className:"h-4 w-4 text-muted-foreground"})]}),a(k,{children:[e("div",{className:"text-3xl font-bold",children:t?.plugins.total||0}),a("p",{className:"text-xs text-muted-foreground mt-1",children:[e(v,{variant:"secondary",className:"mr-1",children:t?.plugins.active||0}),"个活跃"]})]})]}),a(w,{children:[a(_,{className:"flex flex-row items-center justify-between pb-2",children:[e(L,{className:"text-sm font-medium text-muted-foreground",children:"机器人"}),e(Z,{className:"h-4 w-4 text-muted-foreground"})]}),a(k,{children:[e("div",{className:"text-3xl font-bold",children:t?.bots.total||0}),a("p",{className:"text-xs text-muted-foreground mt-1",children:[e(v,{variant:"success",className:"mr-1",children:t?.bots.online||0}),"个在线"]})]})]}),a(w,{children:[a(_,{className:"flex flex-row items-center justify-between pb-2",children:[e(L,{className:"text-sm font-medium text-muted-foreground",children:"命令数量"}),e(me,{className:"h-4 w-4 text-muted-foreground"})]}),a(k,{children:[e("div",{className:"text-3xl font-bold",children:t?.commands||0}),e("p",{className:"text-xs text-muted-foreground mt-1",children:"可用命令"})]})]}),a(w,{children:[a(_,{className:"flex flex-row items-center justify-between pb-2",children:[e(L,{className:"text-sm font-medium text-muted-foreground",children:"组件数量"}),e(ht,{className:"h-4 w-4 text-muted-foreground"})]}),a(k,{children:[e("div",{className:"text-3xl font-bold",children:t?.components||0}),e("p",{className:"text-xs text-muted-foreground mt-1",children:"已注册组件"})]})]})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a(w,{children:[a(_,{children:[e(L,{children:"系统信息"}),e(Q,{children:"服务器运行状态"})]}),a(k,{className:"space-y-3",children:[a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(pe,{className:"h-4 w-4 text-muted-foreground"}),"运行时间"]}),e(v,{variant:"secondary",children:n?u(n.uptime):"-"})]}),a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(ft,{className:"h-4 w-4 text-muted-foreground"}),"平台"]}),e(v,{variant:"secondary",children:n?.platform||"-"})]}),a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(me,{className:"h-4 w-4 text-muted-foreground"}),"Node 版本"]}),e(v,{variant:"secondary",children:n?.nodeVersion||"-"})]})]})]}),a(w,{children:[a(_,{children:[e(L,{children:"资源使用"}),e(Q,{children:"内存使用情况"})]}),a(k,{className:"space-y-3",children:[a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(ie,{className:"h-4 w-4 text-muted-foreground"}),"堆内存使用"]}),e(v,{variant:"secondary",children:t?`${t.memory.toFixed(2)} MB`:"-"})]}),a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(ie,{className:"h-4 w-4 text-muted-foreground"}),"总堆内存"]}),e(v,{variant:"secondary",children:n?S(n.memory.heapTotal):"-"})]}),a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(ie,{className:"h-4 w-4 text-muted-foreground"}),"RSS"]}),e(v,{variant:"secondary",children:n?S(n.memory.rss):"-"})]})]})]})]}),a(w,{children:[a(_,{children:[e(L,{children:"快速操作"}),e(Q,{children:"常用功能快捷入口"})]}),e(k,{children:a("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e(P,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>r("/plugins"),children:a("div",{className:"flex flex-col items-start gap-1",children:[e(E,{className:"h-5 w-5 mb-1"}),e("span",{className:"font-medium",children:"插件管理"}),e("span",{className:"text-xs text-muted-foreground",children:"查看和管理插件"})]})}),e(P,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>r("/bots"),children:a("div",{className:"flex flex-col items-start gap-1",children:[e(Z,{className:"h-5 w-5 mb-1"}),e("span",{className:"font-medium",children:"机器人状态"}),e("span",{className:"text-xs text-muted-foreground",children:"监控机器人运行"})]})}),e(P,{variant:"outline",className:"h-auto p-4 justify-start",onClick:()=>r("/logs"),children:a("div",{className:"flex flex-col items-start gap-1",children:[e(ge,{className:"h-5 w-5 mb-1"}),e("span",{className:"font-medium",children:"系统日志"}),e("span",{className:"text-xs text-muted-foreground",children:"查看运行日志"})]})})]})})]})]})}const W=p.forwardRef(({className:r,orientation:t="horizontal",decorative:s=!0,...n},c)=>e(Ut.Root,{ref:c,decorative:s,orientation:t,className:g("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",r),...n}));W.displayName="Separator";const Nr={Terminal:Me,Box:Fe,Layers:ve,Clock:pe,Brain:Ee,Wrench:Le,Database:ae,Shield:_e,Settings:Ne,Plug:be,Server:xe};function vr(r){return Nr[r]||E}function yr(){const r=Se(),[t,s]=y([]),[n,c]=y(!0),[l,o]=y(null);D(()=>{d();const i=setInterval(d,1e4);return()=>clearInterval(i)},[]);const d=async()=>{try{const i=await fetch("/api/plugins",{credentials:"include"});if(!i.ok)throw new Error("API 请求失败");const m=await i.json();if(m.success)s(m.data),o(null);else throw new Error("数据格式错误")}catch(i){o(i.message)}finally{c(!1)}};return n?a("div",{className:"space-y-4",children:[e(I,{className:"h-8 w-48"}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[...Array(6)].map((i,m)=>e(I,{className:"h-40"},m))})]}):l?e("div",{className:"flex items-center justify-center h-full",children:a(V,{variant:"destructive",className:"max-w-md",children:[e(G,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",l]})]})}):a("div",{className:"space-y-4",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:"插件管理"}),a("div",{className:"flex items-center gap-2 mt-1",children:[a("span",{className:"text-sm text-muted-foreground",children:["共 ",t.length," 个插件"]}),e(v,{variant:"success",children:t.filter(i=>i.status==="active").length}),e("span",{className:"text-sm text-muted-foreground",children:"个运行中"})]})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map((i,m)=>e(w,{className:"cursor-pointer transition-all hover:shadow-md hover:-translate-y-0.5",onClick:()=>r(`/plugins/${encodeURIComponent(i.name)}`),children:a(k,{className:"p-4 space-y-3",children:[a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2",children:[e("div",{className:"flex items-center justify-center w-8 h-8 rounded-md bg-secondary",children:e(E,{className:"w-4 h-4"})}),e("span",{className:"font-semibold text-sm",children:i.name})]}),e(v,{variant:i.status==="active"?"success":"secondary",children:i.status==="active"?"运行中":"已停止"})]}),e("p",{className:"text-xs text-muted-foreground line-clamp-2",children:i.description||"暂无描述"}),e(W,{}),i.features.length>0?e("div",{className:"grid gap-1",style:{gridTemplateColumns:`repeat(${Math.min(i.features.length,4)}, 1fr)`},children:i.features.map(u=>{const S=vr(u.icon);return a("div",{className:"flex flex-col items-center gap-0.5 rounded-md bg-secondary/50 p-1.5",children:[e(S,{className:"w-3 h-3 text-muted-foreground"}),e("span",{className:"text-sm font-bold",children:u.count}),e("span",{className:"text-[10px] text-muted-foreground",children:u.desc})]},u.name)})}):e("p",{className:"text-xs text-muted-foreground text-center py-1",children:"无注册功能"})]})},`${i.name}-${m}`))}),t.length===0&&e(w,{className:"mt-6",children:a(k,{className:"flex flex-col items-center gap-3 py-12",children:[e("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted",children:e(E,{className:"w-8 h-8 text-muted-foreground"})}),e("h3",{className:"text-lg font-semibold",children:"暂无插件"}),e("p",{className:"text-sm text-muted-foreground",children:"请先安装并启用插件"})]})})]})}const z=p.forwardRef(({className:r,...t},s)=>e("textarea",{className:g("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",r),ref:s,...t}));z.displayName="Textarea";const ke=p.forwardRef(({className:r,...t},s)=>e(Ie.Root,{className:g("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",r),...t,ref:s,children:e(Ie.Thumb,{className:g("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")})}));ke.displayName="Switch";const Ce=A.Root;A.Group;const Re=A.Value,ne=p.forwardRef(({className:r,children:t,...s},n)=>a(A.Trigger,{ref:n,className:g("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",r),...s,children:[t,e(A.Icon,{asChild:!0,children:e(ye,{className:"h-4 w-4 opacity-50"})})]}));ne.displayName="SelectTrigger";const Ge=p.forwardRef(({className:r,...t},s)=>e(A.ScrollUpButton,{ref:s,className:g("flex cursor-default items-center justify-center py-1",r),...t,children:e(pt,{className:"h-4 w-4"})}));Ge.displayName="SelectScrollUpButton";const He=p.forwardRef(({className:r,...t},s)=>e(A.ScrollDownButton,{ref:s,className:g("flex cursor-default items-center justify-center py-1",r),...t,children:e(ye,{className:"h-4 w-4"})}));He.displayName="SelectScrollDownButton";const ce=p.forwardRef(({className:r,children:t,position:s="popper",...n},c)=>e(A.Portal,{children:a(A.Content,{ref:c,className:g("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",r),position:s,...n,children:[e(Ge,{}),e(A.Viewport,{className:g("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e(He,{})]})}));ce.displayName="SelectContent";const U=p.forwardRef(({className:r,children:t,...s},n)=>a(A.Item,{ref:n,className:g("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),...s,children:[e("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e(A.ItemIndicator,{children:e(De,{className:"h-4 w-4"})})}),e(A.ItemText,{children:t})]}));U.displayName="SelectItem";const wr=p.forwardRef(({className:r,...t},s)=>e(A.Separator,{ref:s,className:g("-mx-1 my-1 h-px bg-muted",r),...t}));wr.displayName="SelectSeparator";function Sr({field:r,value:t,onChange:s}){return r.enum?a(Ce,{value:t?.toString()||"",onValueChange:s,children:[e(ne,{children:e(Re,{placeholder:"请选择"})}),e(ce,{children:r.enum.map(n=>e(U,{value:n.toString(),children:n.toString()},n))})]}):r.description?.includes("多行")||r.key?.includes("description")?e(z,{value:t||"",onChange:n=>s(n.target.value),placeholder:r.description||"请输入",rows:3}):e(F,{value:t||"",onChange:n=>s(n.target.value),placeholder:r.description||"请输入"})}function kr({field:r,value:t,onChange:s}){return e(F,{type:"number",value:t?.toString()||"",onChange:n=>s(parseFloat(n.target.value)||0),placeholder:r.description||"请输入数字",min:r.min,max:r.max})}function Cr({value:r,onChange:t}){return a("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50 border",children:[e(ke,{checked:r===!0,onCheckedChange:t}),a("div",{className:"flex flex-col gap-0.5",children:[e("span",{className:`text-sm font-medium ${r?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:r?"已启用":"已禁用"}),e("span",{className:"text-xs text-muted-foreground",children:r?"功能当前处于开启状态":"功能当前处于关闭状态"})]})]})}function Rr({field:r,value:t,onChange:s}){const n=typeof t=="number"?t:r.default||0;return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-3",children:[a("div",{className:"flex items-center gap-3",children:[e("input",{type:"range",min:r.min||0,max:r.max||1,step:r.step||.01,value:n,onChange:c=>s(parseFloat(c.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer bg-secondary"}),a("div",{className:"flex items-center gap-1",children:[e(F,{type:"number",className:"w-20 h-8 text-xs",value:(n*100).toFixed(0),onChange:c=>s(parseFloat(c.target.value)/100),min:(r.min||0)*100,max:(r.max||1)*100}),e("span",{className:"text-xs font-bold text-muted-foreground",children:"%"})]})]}),a("div",{className:"flex items-center justify-between",children:[e("span",{className:"text-xs text-muted-foreground",children:"当前值"}),a(v,{variant:"secondary",className:"font-mono",children:[(n*100).toFixed(1),"%"]})]})]})}function jr({field:r,value:t,onChange:s}){const n=t instanceof Date?t.toISOString().split("T")[0]:t||"";return a("div",{className:"relative",children:[e(xt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none"}),e(F,{type:"date",value:n,onChange:c=>s(new Date(c.target.value)),placeholder:r.description||"选择日期",className:"pl-9"})]})}function Ir({field:r,value:t,onChange:s}){const n=t instanceof RegExp?t.source:typeof t=="string"?t:"";return a("div",{className:"p-3 rounded-lg bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-800 space-y-2",children:[a("div",{className:"flex items-center gap-1",children:[e("span",{className:"text-sm font-bold text-amber-600 dark:text-amber-400",children:"/"}),e(F,{value:n,className:"font-mono text-sm",onChange:c=>{try{s(new RegExp(c.target.value))}catch{s(c.target.value)}},placeholder:r.description||"请输入正则表达式"}),e("span",{className:"text-sm font-bold text-amber-600 dark:text-amber-400",children:"/"})]}),a("p",{className:"flex items-center gap-1 text-xs text-amber-700 dark:text-amber-300",children:[e(se,{className:"w-3 h-3"})," 输入正则表达式模式 (省略斜杠)"]})]})}function Or({field:r,value:t}){const s=r.default||t;return a("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted border",children:[e(gt,{className:"w-4 h-4 text-muted-foreground"}),e(v,{variant:"secondary",className:"font-mono",children:String(s)}),e("span",{className:"text-xs text-muted-foreground ml-auto",children:"(常量,不可修改)"})]})}function Ar({field:r,value:t,onChange:s}){return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(Ve,{className:"w-3 h-3"})," JSON 格式输入"]}),e(z,{value:typeof t=="object"?JSON.stringify(t,null,2):String(t||""),onChange:n=>{try{s(JSON.parse(n.target.value))}catch{s(n.target.value)}},placeholder:r.description||"支持任意类型 (JSON 格式)",rows:4,className:"font-mono text-sm"}),a("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e(se,{className:"w-3 h-3"})," 支持: 字符串、数字、布尔值、对象、数组"]})]})}function Pr({fieldName:r,field:t,value:s,onChange:n,onArrayItemChange:c,renderNestedField:l}){const o=Array.isArray(s)?s:[],d=t.inner||t.items;return d&&["string","number"].includes(d.type)?a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(Be,{className:"w-3 h-3"})," 列表输入 (每行一个值)"]}),e(z,{value:o.join(`
2
+ `),onChange:i=>{const m=i.target.value.split(`
3
+ `).filter(Boolean);n(d.type==="number"?m.map(u=>parseFloat(u)||0):m)},placeholder:`每行一个值
4
+ ${t.description||""}`,rows:4,className:"font-mono text-sm"})]}):a("div",{className:"space-y-2",children:[o.map((i,m)=>e(w,{className:"group",children:a("div",{className:"p-3 space-y-2",children:[a("div",{className:"flex justify-between items-center",children:[e(v,{variant:"secondary",className:"font-mono",children:m+1}),e(P,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>n(o.filter((u,S)=>S!==m)),children:e(ue,{className:"w-3 h-3"})})]}),e("div",{className:"pl-2 border-l-2",children:d&&l(`${r}[${m}]`,d,i,u=>{c?.(r,m,u)})})]})},m)),a(P,{variant:"outline",size:"sm",className:"w-full border-dashed",onClick:()=>n([...o,d?.default||(d?.type==="object"?{}:"")]),children:[e(bt,{className:"w-4 h-4 mr-1"})," 添加项"]})]})}function Tr({field:r,value:t,onChange:s}){return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(Be,{className:"w-3 h-3"})," 数组输入 (每行一个值)"]}),e(z,{value:Array.isArray(t)?t.join(`
5
+ `):"",onChange:n=>s(n.target.value.split(`
6
6
  `).filter(Boolean)),placeholder:`每行一个值
7
- ${n.description||""}`,rows:3,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-cyan-500 dark:hover:border-cyan-400 transition-colors"})]})})}function _n({fieldName:n,field:t,value:i,onArrayItemChange:a,renderNestedField:o}){const c=Array.isArray(i)?i:[],h=t.list||[];return e("div",{className:"space-y-3",children:h.map((g,d)=>e("div",{className:"p-3 rounded-lg bg-indigo-50 dark:bg-indigo-900/20 border border-indigo-200 dark:border-indigo-800 hover:border-indigo-300 dark:hover:border-indigo-700 transition-colors",children:r(l,{direction:"column",gap:"2",children:[e(l,{align:"center",gap:"2",children:r(j,{size:"1",variant:"soft",color:"indigo",className:"font-mono",children:["#",d+1]})}),g.description&&e(s,{size:"1",className:"text-indigo-700 dark:text-indigo-300",children:g.description}),e("div",{className:"mt-1",children:o(`${n}[${d}]`,g,c[d],u=>{a?.(n,d,u)})})]})},d))})}function Mn({fieldName:n,field:t,value:i,renderField:a}){const o=t.dict||t.properties||{};return r("div",{className:"rounded-lg border-2 border-blue-200 dark:border-blue-800 bg-gradient-to-br from-blue-50/50 to-cyan-50/50 dark:from-blue-900/10 dark:to-cyan-900/10 overflow-hidden",children:[e("div",{className:"px-4 py-2 bg-blue-100 dark:bg-blue-900/30 border-b border-blue-200 dark:border-blue-800",children:e(l,{align:"center",gap:"2",children:e(K,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})})}),e("div",{className:"p-4 space-y-3",children:Object.entries(o).map(([c,h],g)=>r("div",{children:[e("div",{className:"p-3 rounded-md bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"1",children:[e(s,{size:"2",weight:"bold",className:"text-gray-900 dark:text-gray-100",children:h.key||c}),h.required&&e(s,{size:"2",weight:"bold",color:"red",className:"leading-none",children:"*"})]}),h.description&&e(s,{size:"1",color:"gray",children:h.description}),e("div",{className:"mt-1",children:a(c,h,n)})]})}),g<Object.entries(o).length-1&&e(Ie,{size:"4",className:"my-2"})]},c))})]})}function Dn({field:n,value:t,onChange:i}){return e("div",{className:"p-3 rounded-lg bg-violet-50 dark:bg-violet-900/20 border border-violet-200 dark:border-violet-800",children:r(l,{direction:"column",gap:"3",children:[e(l,{align:"center",gap:"2",children:e(He,{className:"w-4 h-4 text-violet-600 dark:text-violet-400"})}),e(Q,{size:"2",value:typeof t=="object"?JSON.stringify(t,null,2):t||"{}",onChange:a=>{try{const o=JSON.parse(a.target.value);i(o)}catch{}},placeholder:n.description||"请输入 JSON 格式",rows:6,className:"font-mono text-sm bg-white dark:bg-gray-950 hover:border-violet-500 dark:hover:border-violet-400 transition-colors"}),r(l,{align:"center",gap:"2",children:[e(be,{className:"w-3 h-3 text-violet-600 dark:text-violet-400"}),e(s,{size:"1",className:"text-violet-700 dark:text-violet-300",children:'键值对格式: {"key": "value"}'})]})]})})}function Vn({field:n,value:t,onChange:i}){const a=n.list||[];if(a.length===0)return e(E.Root,{size:"2",value:t||"",onChange:c=>i(c.target.value),placeholder:n.description||"请输入值",className:"hover:border-blue-500 dark:hover:border-blue-400 transition-colors focus-within:ring-2 focus-within:ring-blue-500/20"});const o=a.map(c=>c.default||c.type);return e("div",{className:"p-3 rounded-lg bg-gradient-to-br from-pink-50 to-rose-50 dark:from-pink-900/20 dark:to-rose-900/20 border border-pink-200 dark:border-pink-800",children:r(l,{direction:"column",gap:"2",children:[e(l,{align:"center",gap:"2",children:e(Nr,{className:"w-4 h-4 text-pink-600 dark:text-pink-400"})}),r(T.Root,{size:"2",value:t?.toString()||"",onValueChange:i,children:[e(T.Trigger,{className:"w-full hover:border-pink-500 dark:hover:border-pink-400 transition-colors"}),e(T.Content,{className:"shadow-lg",children:o.map((c,h)=>e(T.Item,{value:String(c),className:"hover:bg-pink-50 dark:hover:bg-pink-900/20 transition-colors",children:e(l,{align:"center",gap:"2",children:e(s,{children:String(c)})})},h))})]})]})})}function Un({fieldName:n,field:t,value:i,onChange:a,renderNestedField:o}){const c=t.list||[];return r("div",{className:"rounded-lg border-2 border-teal-200 dark:border-teal-800 bg-gradient-to-br from-teal-50/50 to-emerald-50/50 dark:from-teal-900/10 dark:to-emerald-900/10 overflow-hidden",children:[e("div",{className:"px-4 py-2 bg-teal-100 dark:bg-teal-900/30 border-b border-teal-200 dark:border-teal-800",children:e(l,{align:"center",gap:"2",children:e(pe,{className:"w-4 h-4 text-teal-600 dark:text-teal-400"})})}),e("div",{className:"p-4 space-y-3",children:c.map((h,g)=>e("div",{className:"p-3 rounded-md bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[h.description&&e(s,{size:"1",color:"gray",children:h.description}),e("div",{className:"mt-1",children:o(`${n}[${g}]`,h,i,a)})]})},g))})]})}function Wn(n){const{field:t}=n;switch(t.type){case"string":return e(In,{...n});case"number":case"integer":return e($n,{...n});case"boolean":return e(On,{...n});case"percent":return e(Tn,{...n});case"date":return e(Fn,{...n});case"regexp":return e(Ln,{...n});case"const":return e(Pn,{...n});case"any":return e(En,{...n});case"list":return e(Bn,{...n});case"array":return e(An,{...n});case"tuple":return e(_n,{...n});case"object":return e(Mn,{...n});case"dict":return e(Dn,{...n});case"union":return e(Vn,{...n});case"intersect":return e(Un,{...n});default:return e(Q,{size:"1",value:typeof n.value=="object"?JSON.stringify(n.value,null,2):n.value||"",onChange:i=>{try{const a=JSON.parse(i.target.value);n.onChange(a)}catch{n.onChange(i.target.value)}},placeholder:t.description||"请输入 JSON 格式",rows:4,className:"font-mono text-xs"})}}function Xe({field:n,value:t,onChange:i}){switch(n.type){case"string":return e(E.Root,{size:"1",value:t||"",onChange:a=>i(a.target.value),placeholder:n.description||"请输入"});case"number":case"integer":return e(E.Root,{size:"1",type:"number",value:t?.toString()||"",onChange:a=>i(parseFloat(a.target.value)||0),placeholder:n.description||"请输入数字",min:n.min,max:n.max});case"boolean":return r(l,{align:"center",gap:"2",children:[e(qe,{checked:t===!0,onCheckedChange:i}),e(s,{size:"2",color:t?"green":"gray",children:t?"已启用":"已禁用"})]});case"object":{const a=n.dict||n.properties||{};return e(S,{size:"1",children:e(l,{direction:"column",gap:"2",p:"2",children:Object.entries(a).map(([o,c])=>r(I,{children:[e(s,{size:"1",weight:"bold",children:o}),e(Xe,{fieldName:o,field:c,value:t?.[o],onChange:h=>{i({...t,[o]:h})}})]},o))})})}default:return e(Q,{size:"1",value:typeof t=="object"?JSON.stringify(t,null,2):t||"",onChange:a=>{try{i(JSON.parse(a.target.value))}catch{i(a.target.value)}},rows:3,className:"font-mono text-xs"})}}function Jn({pluginName:n,onSuccess:t}){const[i,a]=z({}),[o,c]=z(null),[h,g]=z(void 0),{config:d,schema:u,loading:b,error:w,connected:f,setConfig:R}=Ur(n);q(()=>{d&&a(d)},[d]);const N=async()=>{if(!f){c(null);return}try{await R(i),c("配置已保存成功"),setTimeout(()=>{g(void 0),t?.(),c(null)},1500)}catch(m){console.error("保存配置失败:",m)}},k=(m,y)=>{a(v=>({...v,[m]:y}))},B=(m,y,v)=>{a($=>({...$,[m]:{...$[m]||{},[y]:v}}))},M=(m,y,v)=>{a($=>{const ee=Array.isArray($[m])?[...$[m]]:[];return ee[y]=v,{...$,[m]:ee}})},D=(m,y,v)=>{const $=v?i[v]?.[m]??y.default:i[m]??y.default;return e(Wn,{fieldName:m,field:y,value:$,onChange:v?ie=>B(v,m,ie):ie=>k(m,ie),parentPath:v,onNestedChange:B,onArrayItemChange:M,renderField:D,renderNestedField:(ie,Qe,er,rr)=>e(Xe,{fieldName:ie,field:Qe,value:er,onChange:rr})})},A=u?.properties||u?.dict||{};return!u||!A||Object.keys(A).length===0?null:e(S,{size:"2",className:"mt-4",children:e(ae.Root,{type:"single",collapsible:!0,value:h,onValueChange:g,children:r(ae.Item,{value:"config",className:"border-none",children:[e(ae.Header,{children:e(ae.Trigger,{className:"w-full group",children:r(l,{justify:"between",align:"center",className:"w-full p-3 hover:bg-gray-50 dark:hover:bg-gray-900/50 rounded-lg transition-colors",children:[r(l,{align:"center",gap:"2",children:[e(kr,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),e(s,{size:"3",weight:"bold",children:"插件配置"}),r(j,{size:"1",color:"gray",variant:"soft",children:[Object.keys(A).length," 项"]})]}),e(Cr,{className:"w-5 h-5 text-gray-500 transition-transform duration-200 group-data-[state=open]:rotate-180"})]})})}),e(ae.Content,{className:"overflow-hidden data-[state=open]:animate-accordion-down data-[state=closed]:animate-accordion-up",children:r(I,{className:"pt-2 pb-4",children:[o&&e("div",{className:"mb-3 animate-in fade-in slide-in-from-top-2 duration-300",children:r(F.Root,{color:"green",size:"1",className:"shadow-sm",children:[e(F.Icon,{children:e(Sr,{})}),e(F.Text,{className:"font-medium",children:o})]})}),w&&e("div",{className:"mb-3 animate-in fade-in slide-in-from-top-2 duration-300",children:r(F.Root,{color:"red",size:"1",className:"shadow-sm",children:[e(F.Icon,{children:e(te,{})}),e(F.Text,{className:"font-medium",children:w})]})}),e(l,{direction:"column",gap:"3",children:Object.entries(A).map(([m,y])=>{const v=y;return e("div",{className:"group p-3 rounded-lg bg-gray-50 dark:bg-gray-900/50 hover:bg-gray-100 dark:hover:bg-gray-900 transition-colors border border-gray-200 dark:border-gray-800",children:r(l,{direction:"column",gap:"2",children:[r(l,{align:"center",gap:"1",children:[e(s,{size:"2",weight:"bold",className:"text-gray-900 dark:text-gray-100",children:v.key||m}),v.required&&e(s,{size:"2",weight:"bold",color:"red",className:"leading-none",children:"*"})]}),v.description&&e(s,{size:"1",color:"gray",className:"leading-relaxed",children:v.description}),e("div",{className:"mt-1",children:D(v.key||m,v)})]})},m)})}),r(l,{gap:"2",justify:"end",className:"mt-4 pt-3 border-t border-gray-200 dark:border-gray-800",children:[r(U,{size:"2",variant:"soft",onClick:()=>g(void 0),disabled:b,className:"hover:bg-gray-200 dark:hover:bg-gray-800 transition-colors",children:[e(jr,{className:"w-4 h-4"}),"取消"]}),e(U,{size:"2",onClick:N,disabled:b,className:"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white transition-colors shadow-sm",children:b?r(me,{children:[e(fe,{}),e("span",{children:"保存中..."})]}):r(me,{children:[e(Rr,{className:"w-4 h-4"}),e("span",{children:"保存配置"})]})})]})]})})]})})})}const{Flex:p,Box:H,Spinner:Hn,Text:x,Callout:Ne,Heading:X,Badge:V,Grid:Ue,Card:P,Button:We,Code:Z,Separator:Y}=Te;function Gn(){const{name:n}=Kr(),t=Fe(),[i,a]=z(null),[o,c]=z(!0),[h,g]=z(null);q(()=>{n&&d(n)},[n]);const d=async u=>{try{const b=await fetch(`/api/plugins/${encodeURIComponent(u)}`,{credentials:"include"});if(!b.ok)throw new Error("API 请求失败");const w=await b.json();if(w.success)a(w.data),g(null);else throw new Error("数据格式错误")}catch(b){g(b.message)}finally{c(!1)}};return o?e(p,{align:"center",justify:"center",className:"h-full",children:r(p,{direction:"column",align:"center",gap:"3",children:[e(Hn,{size:"3"}),e(x,{size:"2",color:"gray",children:"加载中..."})]})}):h||!i?r(H,{children:[r(We,{variant:"ghost",onClick:()=>t("/plugins"),mb:"4",size:"2",children:[e(Le,{className:"w-4 h-4"}),"返回"]}),r(Ne.Root,{color:"red",children:[e(Ne.Icon,{children:e(te,{})}),r(Ne.Text,{children:["加载失败: ",h||"插件不存在"]})]})]}):r(H,{children:[r(p,{direction:"column",gap:"3",mb:"4",children:[r(We,{variant:"ghost",onClick:()=>t("/plugins"),size:"2",children:[e(Le,{className:"w-4 h-4"}),"返回"]}),r(p,{align:"center",gap:"3",children:[e(p,{align:"center",justify:"center",className:"w-12 h-12 rounded-xl bg-blue-500/10 dark:bg-blue-400/10",children:e(K,{className:"w-6 h-6 text-blue-600 dark:text-blue-400"})}),r(p,{direction:"column",gap:"1",children:[r(p,{align:"center",gap:"2",children:[e(X,{size:"5",children:i.name}),e(V,{color:i.status==="active"?"green":"gray",size:"1",children:i.status==="active"?"运行中":"已停止"})]}),e(x,{size:"2",color:"gray",children:i.description||"暂无描述"})]})]})]}),e(Jn,{pluginName:i.name,onSuccess:()=>{}}),e(Y,{size:"4",my:"4"}),r(Ue,{columns:{initial:"2",sm:"3",md:"6"},gap:"2",mb:"4",children:[e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Se,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.commandCount}),e(x,{size:"1",color:"gray",children:"命令"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Je,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.componentCount}),e(x,{size:"1",color:"gray",children:"组件"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(pe,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.middlewareCount}),e(x,{size:"1",color:"gray",children:"中间件"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(je,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.contextCount}),e(x,{size:"1",color:"gray",children:"上下文"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(Ce,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.cronCount}),e(x,{size:"1",color:"gray",children:"定时任务"})]})}),e(P,{size:"1",children:r(p,{direction:"column",align:"center",gap:"1",p:"2",children:[e(se,{className:"w-4 h-4 text-cyan-600 dark:text-cyan-400"}),e(x,{size:"4",weight:"bold",children:i.statistics.definitionCount}),e(x,{size:"1",color:"gray",children:"数据模型"})]})})]}),r(Ue,{columns:{initial:"1",md:"2"},gap:"3",children:[i.commands.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(Se,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e(X,{size:"3",children:"命令"}),e(V,{size:"1",children:i.commands.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.commands.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-3",children:r(p,{direction:"column",gap:"2",children:[e(Z,{size:"2",weight:"bold",children:u.name}),u.desc&&u.desc.length>0&&e(p,{direction:"column",gap:"1",children:u.desc.map((w,f)=>e(x,{size:"1",color:"gray",children:w},f))}),u.usage&&u.usage.length>0&&r(p,{direction:"column",gap:"1",children:[e(x,{size:"1",weight:"bold",color:"blue",children:"用法:"}),u.usage.map((w,f)=>e(Z,{size:"1",variant:"soft",children:w},f))]}),u.examples&&u.examples.length>0&&r(p,{direction:"column",gap:"1",children:[e(x,{size:"1",weight:"bold",color:"green",children:"示例:"}),u.examples.map((w,f)=>e(Z,{size:"1",variant:"soft",color:"green",children:w},f))]})]})},b))})]})}),i.components.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(H,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e(X,{size:"3",children:"组件"}),e(V,{size:"1",children:i.components.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.components.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[r(p,{align:"center",gap:"2",children:[e(Z,{size:"2",children:u.name}),e(V,{size:"1",variant:"soft",children:u.type})]}),r(x,{size:"1",color:"gray",children:["属性数: ",Object.keys(u.props).length]})]})},b))})]})}),i.middlewares.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(pe,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e(X,{size:"3",children:"中间件"}),e(V,{size:"1",children:i.middlewares.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.middlewares.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{align:"center",gap:"2",children:[e(Z,{size:"2",children:u.id}),e(V,{size:"1",variant:"soft",children:u.type})]})},b))})]})}),i.contexts.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(je,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"}),e(X,{size:"3",children:"上下文"}),e(V,{size:"1",children:i.contexts.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.contexts.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[e(Z,{size:"2",children:u.name}),e(x,{size:"1",color:"gray",children:u.description})]})},b))})]})}),i.crons.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(Ce,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"}),e(X,{size:"3",children:"定时任务"}),e(V,{size:"1",children:i.crons.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.crons.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{justify:"between",align:"center",children:[r(p,{direction:"column",gap:"1",children:[e(Z,{size:"2",children:u.id}),e(x,{size:"1",color:"gray",children:u.pattern})]}),e(V,{color:u.running?"green":"gray",size:"1",children:u.running?"运行中":"已停止"})]})},b))})]})}),i.definitions.length>0&&e(P,{size:"2",children:r(p,{direction:"column",gap:"2",p:"3",children:[r(p,{align:"center",gap:"2",children:[e(se,{className:"w-4 h-4 text-cyan-600 dark:text-cyan-400"}),e(X,{size:"3",children:"数据模型"}),e(V,{size:"1",children:i.definitions.length})]}),e(Y,{size:"4"}),e(p,{direction:"column",gap:"2",className:"max-h-60 overflow-y-auto",children:i.definitions.map((u,b)=>e(H,{className:"rounded-lg bg-gray-50 dark:bg-gray-900 p-2",children:r(p,{direction:"column",gap:"1",children:[e(Z,{size:"2",children:u.name}),r(x,{size:"1",color:"gray",children:["字段: ",u.fields.join(", ")]})]})},b))})]})})]})]})}function qn(){const[n,t]=z([]),[i,a]=z(!0),[o,c]=z(null);q(()=>{h();const g=setInterval(h,5e3);return()=>clearInterval(g)},[]);const h=async()=>{try{const g=await fetch("/api/bots",{credentials:"include"});if(!g.ok)throw new Error("API 请求失败");const d=await g.json();if(d.success)t(d.data),c(null);else throw new Error("数据格式错误")}catch(g){c(g.message)}finally{a(!1)}};return i?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):o?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",o]})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"6",children:[e(_,{size:"8",children:"机器人管理"}),r(l,{align:"center",gap:"2",children:[r(s,{color:"gray",children:["共 ",n.length," 个机器人,"]}),e(j,{color:"green",children:n.filter(g=>g.connected).length}),e(s,{color:"gray",children:"个在线"})]})]}),e(Ie,{size:"4",mb:"6"}),e(oe,{columns:{initial:"1",sm:"2",lg:"3"},gap:"4",children:n.map((g,d)=>e(S,{children:r(l,{direction:"column",gap:"3",children:[r(l,{justify:"between",align:"center",children:[r(l,{align:"center",gap:"2",children:[e(I,{style:{padding:"8px",borderRadius:"8px",backgroundColor:g.connected?"var(--green-3)":"var(--gray-3)"},children:e(ce,{size:20,color:g.connected?"var(--green-9)":"var(--gray-9)"})}),e(s,{size:"4",weight:"bold",children:g.name})]}),r(I,{style:{position:"relative"},children:[e(j,{color:g.connected?"green":"gray",children:e(l,{align:"center",gap:"1",children:g.connected?r(me,{children:[e(Ir,{size:12}),"在线"]}):r(me,{children:[e($r,{size:12}),"离线"]})})}),g.connected&&e(I,{style:{position:"absolute",top:"-4px",right:"-4px",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:"var(--green-9)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}})]})]}),r(l,{align:"center",gap:"2",children:[e(s,{size:"2",color:"gray",children:"适配器:"}),e(j,{variant:"outline",children:g.adapter})]}),e(Ie,{size:"4"}),r(l,{direction:"column",gap:"2",children:[r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(ke,{size:16,color:g.status==="online"?"var(--green-9)":"var(--gray-9)"}),e(s,{size:"2",color:"gray",children:"运行状态"})]}),e(j,{color:g.status==="online"?"green":"gray",children:g.status==="online"?"运行中":"已停止"})]}),r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(K,{size:16,color:"var(--blue-9)"}),e(s,{size:"2",color:"gray",children:"适配器类型"})]}),e(s,{size:"2",weight:"medium",children:g.adapter})]}),r(l,{justify:"between",align:"center",p:"2",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)"},children:[r(l,{align:"center",gap:"2",children:[e(Or,{size:16,color:"var(--purple-9)"}),e(s,{size:"2",color:"gray",children:"连接状态"})]}),e(s,{size:"2",weight:"medium",color:g.connected?"green":"gray",children:g.connected?"已连接":"未连接"})]})]})]})},`${g.adapter}-${g.name}-${d}`))}),n.length===0&&e(S,{children:r(l,{direction:"column",align:"center",gap:"4",py:"9",children:[e(ce,{size:64,color:"var(--gray-6)"}),r(l,{direction:"column",align:"center",gap:"2",children:[e(_,{size:"4",children:"暂无机器人"}),e(s,{color:"gray",children:"请先配置并启动机器人"})]})]})})]})}function Zn(){const[n,t]=z([]),[i,a]=z(null),[o,c]=z(!0),[h,g]=z(null),[d,u]=z("all"),[b,w]=z(!0),f=ir(null),[R,N]=z(0);q(()=>{k(),B();const m=setInterval(()=>{k(),B()},3e3);return()=>clearInterval(m)},[d]),q(()=>{b&&n.length>R&&f.current?.scrollIntoView({behavior:"smooth"}),N(n.length)},[n,b]);const k=async()=>{try{const m=d==="all"?"/api/logs?limit=100":`/api/logs?limit=100&level=${d}`,y=await fetch(m,{credentials:"include"});if(!y.ok)throw new Error("API 请求失败");const v=await y.json();v.success&&Array.isArray(v.data)&&(t(v.data.reverse()),g(null))}catch(m){g(m.message)}finally{c(!1)}},B=async()=>{try{const m=await fetch("/api/logs/stats",{credentials:"include"});if(!m.ok)return;const y=await m.json();y.success&&a(y.data)}catch(m){console.error("Failed to fetch stats:",m)}},M=async(m,y)=>{const v=m?`确定清理 ${m} 天前的日志吗?`:`确定只保留最近 ${y} 条日志吗?`;if(confirm(v))try{const $=await fetch("/api/logs/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({days:m,maxRecords:y}),credentials:"include"});if(!$.ok)throw new Error("清理失败");const ee=await $.json();ee.success&&(alert(`成功清理 ${ee.data.deletedCount} 条日志`),k(),B())}catch($){alert($.message)}},D=m=>{switch(m){case"info":return"blue";case"warn":return"amber";case"error":return"red";default:return"gray"}},A=m=>{switch(m){case"info":return e(be,{size:14});case"warn":return e(Pr,{size:14});case"error":return e(Lr,{size:14});default:return e(Fr,{size:14})}};return o?e(l,{align:"center",justify:"center",style:{height:"100%"},children:r(I,{children:[e(fe,{size:"3"}),e(s,{size:"2",color:"gray",style:{marginTop:"8px"},children:"加载中..."})]})}):r(I,{children:[r(l,{direction:"column",gap:"2",mb:"4",children:[e(_,{size:"8",children:"系统日志"}),e(s,{color:"gray",children:"实时查看系统运行日志"})]}),i&&r(oe,{columns:{initial:"2",sm:"4"},gap:"3",mb:"4",children:[e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",children:i.total}),e(s,{size:"1",color:"gray",children:"总日志数"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"blue",children:i.byLevel.info||0}),e(s,{size:"1",color:"gray",children:"Info"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"amber",children:i.byLevel.warn||0}),e(s,{size:"1",color:"gray",children:"Warn"})]})}),e(S,{children:r(l,{direction:"column",align:"center",gap:"1",p:"3",children:[e(s,{size:"5",weight:"bold",color:"red",children:i.byLevel.error||0}),e(s,{size:"1",color:"gray",children:"Error"})]})})]}),e(S,{mb:"4",children:r(l,{justify:"between",align:"center",p:"3",wrap:"wrap",gap:"3",children:[r(l,{align:"center",gap:"3",wrap:"wrap",children:[r(T.Root,{value:d,onValueChange:u,children:[e(T.Trigger,{style:{minWidth:"120px"}}),r(T.Content,{children:[e(T.Item,{value:"all",children:"所有级别"}),e(T.Item,{value:"info",children:"Info"}),e(T.Item,{value:"warn",children:"Warn"}),e(T.Item,{value:"error",children:"Error"})]})]}),r(l,{as:"span",children:[e(qr,{checked:b,onCheckedChange:m=>w(m)}),e(s,{size:"2",children:"自动滚动"})]})]}),r(l,{gap:"2",children:[r(U,{variant:"soft",onClick:()=>M(7),size:"2",children:[e(Re,{size:14}),"清理7天前"]}),r(U,{variant:"soft",onClick:()=>M(void 0,5e3),size:"2",children:[e(Re,{size:14}),"保留5000条"]}),r(U,{variant:"soft",onClick:()=>k(),size:"2",children:[e(Tr,{size:14}),"刷新"]})]})]})}),e(S,{children:e(I,{p:"4",style:{maxHeight:"600px",overflowY:"auto",backgroundColor:"var(--gray-1)"},children:h?r(F.Root,{color:"red",children:[e(F.Icon,{children:e(te,{})}),r(F.Text,{children:["加载失败: ",h]})]}):n.length===0?r(l,{direction:"column",align:"center",gap:"3",py:"9",children:[e(se,{size:48,color:"var(--gray-6)"}),e(s,{color:"gray",children:"暂无日志"})]}):r(l,{direction:"column",gap:"2",children:[n.map((m,y)=>e(I,{p:"3",style:{borderRadius:"6px",backgroundColor:"var(--gray-2)",borderLeft:`3px solid var(--${D(m.level)}-9)`},children:r(l,{direction:"column",gap:"1",children:[r(l,{align:"center",gap:"2",children:[e(j,{color:D(m.level),size:"1",children:r(l,{align:"center",gap:"1",children:[A(m.level),m.level.toUpperCase()]})}),e(s,{size:"1",color:"gray",children:new Date(m.timestamp).toLocaleString()}),m.source&&e(j,{variant:"soft",size:"1",children:m.source})]}),e(s,{size:"2",style:{fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:m.message})]})},`${m.timestamp}-${y}`)),e("div",{ref:f})]})})})]})}function he(n){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?he=function(i){return typeof i}:he=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},he(n)}function Kn(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function Xn(n,t){for(var i=0;i<t.length;i++){var a=t[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,a.key,a)}}function Yn(n,t,i){return t&&Xn(n.prototype,t),n}function Qn(n,t){return t&&(he(t)==="object"||typeof t=="function")?t:ue(n)}function $e(n){return $e=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},$e(n)}function ue(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function et(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&Oe(n,t)}function Oe(n,t){return Oe=Object.setPrototypeOf||function(a,o){return a.__proto__=o,a},Oe(n,t)}function ge(n,t,i){return t in n?Object.defineProperty(n,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[t]=i,n}var Ye=(function(n){et(t,n);function t(){var i,a;Kn(this,t);for(var o=arguments.length,c=new Array(o),h=0;h<o;h++)c[h]=arguments[h];return a=Qn(this,(i=$e(t)).call.apply(i,[this].concat(c))),ge(ue(a),"state",{bootstrapped:!1}),ge(ue(a),"_unsubscribe",void 0),ge(ue(a),"handlePersistorState",function(){var g=a.props.persistor,d=g.getState(),u=d.bootstrapped;u&&(a.props.onBeforeLift?Promise.resolve(a.props.onBeforeLift()).finally(function(){return a.setState({bootstrapped:!0})}):a.setState({bootstrapped:!0}),a._unsubscribe&&a._unsubscribe())}),a}return Yn(t,[{key:"componentDidMount",value:function(){this._unsubscribe=this.props.persistor.subscribe(this.handlePersistorState),this.handlePersistorState()}},{key:"componentWillUnmount",value:function(){this._unsubscribe&&this._unsubscribe()}},{key:"render",value:function(){return typeof this.props.children=="function"?this.props.children(this.state.bootstrapped):this.state.bootstrapped?this.props.children:this.props.loading}}]),t})(ar);ge(Ye,"defaultProps",{children:null,loading:null});bn();function rt(){const n=le(c=>c.script.entries),t=le(c=>c.script.loadedScripts),[i,a]=z(!1);q(()=>{[{key:"dashboard-layout",path:"/",title:"Dashboard",element:e(Nn,{}),redirect:"/dashboard",meta:{order:0},children:[{key:"dashboard-home",index:!0,path:"",title:"系统概览",icon:e(Er,{className:"w-5 h-5"}),element:e(kn,{})},{key:"dashboard-plugins",path:"/plugins",title:"插件管理",icon:e(K,{className:"w-5 h-5"}),element:e(Rn,{}),meta:{order:2}},{key:"dashboard-plugin-detail",title:"插件详情",path:"/plugins/:name",element:e(Gn,{}),meta:{hideInMenu:!0}},{key:"dashboard-bots",path:"/bots",title:"机器人",icon:e(ce,{className:"w-5 h-5"}),element:e(qn,{}),meta:{order:3}},{key:"dashboard-logs",path:"/logs",title:"系统日志",icon:e(se,{className:"w-5 h-5"}),element:e(Zn,{}),meta:{order:4}}]}].forEach(h=>{Hr(h)}),a(!0)},[]);const o=n.length===0||n.length===t.length;return!i||!o?e("div",{className:"flex items-center justify-center h-screen",children:r("div",{className:"text-center",children:[e("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"}),r("p",{className:"mt-2 text-gray-600",children:["加载中... (",t.length,"/",n.length,")"]})]})}):e(Gr,{})}or(document.getElementById("root")).render(e(lr,{children:e(Zr,{accentColor:"blue",grayColor:"slate",radius:"large",scaling:"100%",children:e(Ye,{loading:null,persistor:Wr,children:e(mn,{store:Jr,children:e(rt,{})})})})}));
7
+ ${r.description||""}`,rows:3,className:"font-mono text-sm"})]})}function $r({fieldName:r,field:t,value:s,onArrayItemChange:n,renderNestedField:c}){const l=Array.isArray(s)?s:[],o=t.list||[];return e("div",{className:"space-y-2",children:o.map((d,i)=>a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a(v,{variant:"secondary",className:"font-mono",children:["#",i+1]}),d.description&&e("p",{className:"text-xs text-muted-foreground",children:d.description}),e("div",{className:"mt-1",children:c(`${r}[${i}]`,d,l[i],m=>{n?.(r,i,m)})})]},i))})}function _r({fieldName:r,field:t,renderField:s}){const n=t.dict||t.properties||{};return a("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[a("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[e(E,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-xs font-semibold text-muted-foreground",children:"对象"})]}),e("div",{className:"p-3 space-y-2",children:Object.entries(n).map(([c,l],o)=>a("div",{children:[a("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[a("div",{className:"flex items-center gap-1",children:[e("span",{className:"text-sm font-semibold",children:l.key||c}),l.required&&e("span",{className:"text-destructive font-bold",children:"*"})]}),l.description&&e("p",{className:"text-xs text-muted-foreground",children:l.description}),e("div",{className:"mt-1",children:s(c,l,r)})]}),o<Object.entries(n).length-1&&e(W,{className:"my-2"})]},c))})]})}function Lr({field:r,value:t,onChange:s}){return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(Ve,{className:"w-3 h-3"})," 键值对编辑"]}),e(z,{value:typeof t=="object"?JSON.stringify(t,null,2):t||"{}",onChange:n=>{try{s(JSON.parse(n.target.value))}catch{}},placeholder:r.description||"请输入 JSON 格式",rows:6,className:"font-mono text-sm"}),a("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e(se,{className:"w-3 h-3"})," 键值对格式: ","{",'"key": "value"',"}"]})]})}function Er({field:r,value:t,onChange:s}){const n=r.list||[];if(n.length===0)return e(F,{value:t||"",onChange:l=>s(l.target.value),placeholder:r.description||"请输入值"});const c=n.map(l=>l.default||l.type);return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("p",{className:"flex items-center gap-1 text-xs font-semibold text-muted-foreground",children:[e(Nt,{className:"w-3 h-3"})," 联合类型"]}),a(Ce,{value:t?.toString()||"",onValueChange:s,children:[e(ne,{children:e(Re,{placeholder:"请选择"})}),e(ce,{children:c.map((l,o)=>e(U,{value:String(l),children:String(l)},o))})]})]})}function Fr({fieldName:r,field:t,value:s,onChange:n,renderNestedField:c}){const l=t.list||[];return a("div",{className:"rounded-lg border-2 bg-muted/30 overflow-hidden",children:[a("div",{className:"px-4 py-2 bg-muted border-b flex items-center gap-2",children:[e(ve,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-xs font-semibold text-muted-foreground",children:"交叉类型"})]}),e("div",{className:"p-3 space-y-2",children:l.map((o,d)=>a("div",{className:"p-3 rounded-md bg-background border space-y-1",children:[o.description&&e("p",{className:"text-xs text-muted-foreground",children:o.description}),e("div",{className:"mt-1",children:c(`${r}[${d}]`,o,s,n)})]},d))})]})}function Mr(r){const{field:t}=r;switch(t.type){case"string":return e(Sr,{...r});case"number":case"integer":return e(kr,{...r});case"boolean":return e(Cr,{...r});case"percent":return e(Rr,{...r});case"date":return e(jr,{...r});case"regexp":return e(Ir,{...r});case"const":return e(Or,{...r});case"any":return e(Ar,{...r});case"list":return e(Pr,{...r});case"array":return e(Tr,{...r});case"tuple":return e($r,{...r});case"object":return e(_r,{...r});case"dict":return e(Lr,{...r});case"union":return e(Er,{...r});case"intersect":return e(Fr,{...r});default:return e(z,{value:typeof r.value=="object"?JSON.stringify(r.value,null,2):r.value||"",onChange:s=>{try{r.onChange(JSON.parse(s.target.value))}catch{r.onChange(s.target.value)}},placeholder:t.description||"请输入 JSON 格式",rows:4,className:"font-mono text-xs"})}}function qe({field:r,value:t,onChange:s}){switch(r.type){case"string":return e(F,{value:t||"",onChange:n=>s(n.target.value),placeholder:r.description||"请输入",className:"h-8 text-sm"});case"number":case"integer":return e(F,{type:"number",value:t?.toString()||"",onChange:n=>s(parseFloat(n.target.value)||0),placeholder:r.description||"请输入数字",min:r.min,max:r.max,className:"h-8 text-sm"});case"boolean":return a("div",{className:"flex items-center gap-2",children:[e(ke,{checked:t===!0,onCheckedChange:s}),e("span",{className:`text-sm ${t?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:t?"已启用":"已禁用"})]});case"object":{const n=r.dict||r.properties||{};return e(w,{className:"p-2 space-y-2",children:Object.entries(n).map(([c,l])=>a("div",{className:"space-y-1",children:[e("span",{className:"text-xs font-semibold",children:c}),e(qe,{fieldName:c,field:l,value:t?.[c],onChange:o=>s({...t,[c]:o})})]},c))})}default:return e(z,{value:typeof t=="object"?JSON.stringify(t,null,2):t||"",onChange:n=>{try{s(JSON.parse(n.target.value))}catch{s(n.target.value)}},rows:3,className:"font-mono text-xs"})}}const Dr=K.Root,Ze=p.forwardRef(({className:r,...t},s)=>e(K.Item,{ref:s,className:g("border-b",r),...t}));Ze.displayName="AccordionItem";const Ke=p.forwardRef(({className:r,children:t,...s},n)=>e(K.Header,{className:"flex",children:a(K.Trigger,{ref:n,className:g("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",r),...s,children:[t,e(ye,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));Ke.displayName="AccordionTrigger";const Xe=p.forwardRef(({className:r,children:t,...s},n)=>e(K.Content,{ref:n,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...s,children:e("div",{className:g("pb-4 pt-0",r),children:t})}));Xe.displayName="AccordionContent";function Vr({pluginName:r,onSuccess:t}){const[s,n]=y({}),[c,l]=y(null),[o,d]=y(void 0),{config:i,schema:m,loading:u,error:S,connected:N,setConfig:C}=Ft(r);D(()=>{i&&n(i)},[i]);const R=async()=>{if(N)try{await C(s),l("配置已保存成功"),setTimeout(()=>{d(void 0),t?.(),l(null)},1500)}catch(f){console.error("保存配置失败:",f)}},j=(f,x)=>{n(b=>({...b,[f]:x}))},T=(f,x,b)=>{n(O=>({...O,[f]:{...O[f]||{},[x]:b}}))},$=(f,x,b)=>{n(O=>{const le=Array.isArray(O[f])?[...O[f]]:[];return le[x]=b,{...O,[f]:le}})},M=(f,x,b)=>{const O=b?s[b]?.[f]??x.default:s[f]??x.default;return e(Mr,{fieldName:f,field:x,value:O,onChange:b?H=>T(b,f,H):H=>j(f,H),parentPath:b,onNestedChange:T,onArrayItemChange:$,renderField:M,renderNestedField:(H,et,tt,rt)=>e(qe,{fieldName:H,field:et,value:tt,onChange:rt})})},h=m?.properties||m?.dict||{};return!m||!h||Object.keys(h).length===0?null:e(w,{className:"mt-4",children:e(Dr,{type:"single",collapsible:!0,value:o,onValueChange:d,children:a(Ze,{value:"config",className:"border-none",children:[e(Ke,{className:"px-4 hover:no-underline",children:a("div",{className:"flex items-center gap-2",children:[e(Ne,{className:"w-4 h-4"}),e("span",{className:"font-semibold",children:"插件配置"}),a(v,{variant:"secondary",children:[Object.keys(h).length," 项"]})]})}),a(Xe,{className:"px-4 pb-4",children:[c&&a(V,{variant:"success",className:"mb-3",children:[e(vt,{className:"h-4 w-4"}),e(B,{children:c})]}),S&&a(V,{variant:"destructive",className:"mb-3",children:[e(G,{className:"h-4 w-4"}),e(B,{children:S})]}),e("div",{className:"space-y-3",children:Object.entries(h).map(([f,x])=>{const b=x;return a("div",{className:"p-3 rounded-lg bg-muted/50 border space-y-2",children:[a("div",{className:"flex items-center gap-1",children:[e("span",{className:"text-sm font-semibold",children:b.key||f}),b.required&&e("span",{className:"text-destructive font-bold",children:"*"})]}),b.description&&e("p",{className:"text-xs text-muted-foreground",children:b.description}),e("div",{className:"mt-1",children:M(b.key||f,b)})]},f)})}),a("div",{className:"flex gap-2 justify-end mt-4 pt-3 border-t",children:[a(P,{variant:"outline",size:"sm",onClick:()=>d(void 0),disabled:u,children:[e(yt,{className:"w-4 h-4 mr-1"})," 取消"]}),e(P,{size:"sm",onClick:R,disabled:u,children:u?a(re,{children:[e(wt,{className:"w-4 h-4 mr-1 animate-spin"}),"保存中..."]}):a(re,{children:[e(St,{className:"w-4 h-4 mr-1"}),"保存配置"]})})]})]})]})})})}const Br={Terminal:Me,Box:Fe,Layers:ve,Clock:pe,Brain:Ee,Wrench:Le,Database:ae,Shield:_e,Settings:Ne,Plug:be,Server:xe};function $e(r){return Br[r]||E}function zr(){const{name:r}=Jt(),t=Se(),[s,n]=y(null),[c,l]=y(!0),[o,d]=y(null);D(()=>{r&&i(r)},[r]);const i=async m=>{try{const u=await fetch(`/api/plugins/${encodeURIComponent(m)}`,{credentials:"include"});if(!u.ok)throw new Error("API 请求失败");const S=await u.json();if(S.success)n(S.data),d(null);else throw new Error("数据格式错误")}catch(u){d(u.message)}finally{l(!1)}};return c?a("div",{className:"space-y-4",children:[e(I,{className:"h-8 w-24"}),a("div",{className:"flex items-center gap-3",children:[e(I,{className:"h-12 w-12 rounded-xl"}),a("div",{children:[e(I,{className:"h-6 w-48"}),e(I,{className:"h-4 w-64 mt-1"})]})]}),e("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[...Array(6)].map((m,u)=>e(I,{className:"h-20"},u))})]}):o||!s?a("div",{children:[a(P,{variant:"ghost",onClick:()=>t("/plugins"),className:"mb-4",children:[e(je,{className:"w-4 h-4 mr-1"})," 返回"]}),a(V,{variant:"destructive",children:[e(G,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",o||"插件不存在"]})]})]}):a("div",{className:"space-y-4",children:[a(P,{variant:"ghost",size:"sm",onClick:()=>t("/plugins"),children:[e(je,{className:"w-4 h-4 mr-1"})," 返回"]}),a("div",{className:"flex items-center gap-3",children:[e("div",{className:"flex items-center justify-center w-12 h-12 rounded-xl bg-secondary",children:e(E,{className:"w-6 h-6"})}),a("div",{children:[a("div",{className:"flex items-center gap-2",children:[e("h1",{className:"text-xl font-bold",children:s.name}),e(v,{variant:s.status==="active"?"success":"secondary",children:s.status==="active"?"运行中":"已停止"})]}),e("p",{className:"text-sm text-muted-foreground",children:s.description||"暂无描述"})]})]}),e(Vr,{pluginName:s.name,onSuccess:()=>{}}),e(W,{}),s.features.length>0&&a("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-6 gap-2",children:[s.features.map(m=>{const u=$e(m.icon);return e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-3",children:[e(u,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-2xl font-bold",children:m.count}),e("span",{className:"text-xs text-muted-foreground",children:m.desc})]})},m.name)}),s.contexts.length>0&&e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-3",children:[e(ae,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-2xl font-bold",children:s.contexts.length}),e("span",{className:"text-xs text-muted-foreground",children:"上下文"})]})})]}),a("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.features.map(m=>{if(m.items.length===0)return null;const u=$e(m.icon);return a(w,{children:[e(_,{className:"pb-2",children:a("div",{className:"flex items-center gap-2",children:[e(u,{className:"w-4 h-4 text-muted-foreground"}),e(L,{className:"text-base",children:m.desc}),e(v,{variant:"secondary",children:m.count})]})}),e(k,{children:e("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:m.items.map((S,N)=>e(Ur,{featureName:m.name,item:S},N))})})]},m.name)}),s.contexts.length>0&&a(w,{children:[e(_,{className:"pb-2",children:a("div",{className:"flex items-center gap-2",children:[e(ae,{className:"w-4 h-4 text-muted-foreground"}),e(L,{className:"text-base",children:"上下文"}),e(v,{variant:"secondary",children:s.contexts.length})]})}),e(k,{children:e("div",{className:"max-h-60 overflow-y-auto pr-1 space-y-2",children:s.contexts.map((m,u)=>e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:m.name})},u))})})]})]})]})}function Ur({featureName:r,item:t}){switch(r){case"command":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc?.map((s,n)=>e("p",{className:"text-xs text-muted-foreground",children:s},n)),t.usage&&t.usage.length>0&&a("div",{children:[e("span",{className:"text-xs font-semibold text-blue-600 dark:text-blue-400",children:"用法:"}),t.usage.map((s,n)=>e("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:s},n))]}),t.examples&&t.examples.length>0&&a("div",{children:[e("span",{className:"text-xs font-semibold text-emerald-600 dark:text-emerald-400",children:"示例:"}),t.examples.map((s,n)=>e("code",{className:"block text-xs bg-muted rounded px-1 py-0.5 mt-0.5",children:s},n))]})]});case"cron":return a("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[e("code",{className:"text-sm",children:t.expression}),e(v,{variant:t.running?"success":"secondary",children:t.running?"运行中":"已停止"})]});case"tool":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc&&e("p",{className:"text-xs text-muted-foreground",children:t.desc}),t.platforms&&t.platforms.length>0&&e("div",{className:"flex gap-1 flex-wrap",children:t.platforms.map((s,n)=>e(v,{variant:"outline",className:"text-[10px]",children:s},n))})]});case"skill":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[e("code",{className:"text-sm font-semibold",children:t.name}),t.desc&&e("p",{className:"text-xs text-muted-foreground",children:t.desc}),t.toolCount!=null&&a("span",{className:"text-xs text-muted-foreground",children:["工具: ",t.toolCount]})]});case"config":return a("div",{className:"flex justify-between items-center rounded-md bg-muted/50 p-2",children:[e("code",{className:"text-sm",children:t.name}),t.defaultValue!==void 0&&a("span",{className:"text-xs text-muted-foreground",children:["默认: ",JSON.stringify(t.defaultValue)]})]});case"permission":return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name})});case"database":return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name})});case"adapter":return a("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[a("div",{className:"flex items-center gap-2",children:[e(be,{className:"w-3.5 h-3.5 text-muted-foreground"}),e("code",{className:"text-sm font-semibold",children:t.name})]}),a("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[a("span",{children:["Bot: ",t.bots??0]}),a("span",{children:["在线: ",t.online??0]}),t.tools>0&&a("span",{children:["工具: ",t.tools]})]})]});case"service":return a("div",{className:"rounded-md bg-muted/50 p-2 flex items-center gap-2",children:[e(xe,{className:"w-3.5 h-3.5 text-muted-foreground"}),e("code",{className:"text-sm",children:t.name}),t.desc&&t.desc!==t.name&&a("span",{className:"text-xs text-muted-foreground",children:["- ",t.desc]})]});default:return e("div",{className:"rounded-md bg-muted/50 p-2",children:e("code",{className:"text-sm",children:t.name||JSON.stringify(t)})})}}function Jr(){const[r,t]=y([]),[s,n]=y(!0),[c,l]=y(null);D(()=>{o();const d=setInterval(o,5e3);return()=>clearInterval(d)},[]);const o=async()=>{try{const d=await fetch("/api/bots",{credentials:"include"});if(!d.ok)throw new Error("API 请求失败");const i=await d.json();if(i.success)t(i.data),l(null);else throw new Error("数据格式错误")}catch(d){l(d.message)}finally{n(!1)}};return s?a("div",{className:"space-y-6",children:[e(I,{className:"h-8 w-48"}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((d,i)=>e(I,{className:"h-48"},i))})]}):c?e("div",{className:"flex items-center justify-center h-full",children:a(V,{variant:"destructive",className:"max-w-md",children:[e(G,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",c]})]})}):a("div",{className:"space-y-6",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:"机器人管理"}),a("div",{className:"flex items-center gap-2 mt-1",children:[a("span",{className:"text-sm text-muted-foreground",children:["共 ",r.length," 个机器人,"]}),e(v,{variant:"success",children:r.filter(d=>d.connected).length}),e("span",{className:"text-sm text-muted-foreground",children:"个在线"})]})]}),e(W,{}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map((d,i)=>e(w,{children:a(k,{className:"p-5 space-y-4",children:[a("div",{className:"flex justify-between items-center",children:[a("div",{className:"flex items-center gap-2",children:[e("div",{className:`p-2 rounded-md ${d.connected?"bg-emerald-100 dark:bg-emerald-900/30":"bg-muted"}`,children:e(Z,{className:`w-5 h-5 ${d.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`})}),e("span",{className:"text-lg font-bold",children:d.name})]}),e("div",{className:"relative",children:e(v,{variant:d.connected?"success":"secondary",children:d.connected?a(re,{children:[e(kt,{className:"w-3 h-3 mr-1"}),"在线"]}):a(re,{children:[e(Ct,{className:"w-3 h-3 mr-1"}),"离线"]})})})]}),a("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-sm text-muted-foreground",children:"适配器:"}),e(v,{variant:"outline",children:d.adapter})]}),e(W,{}),a("div",{className:"space-y-2",children:[a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(me,{className:`w-4 h-4 ${d.status==="online"?"text-emerald-500":"text-muted-foreground"}`}),e("span",{className:"text-muted-foreground",children:"运行状态"})]}),e(v,{variant:d.status==="online"?"success":"secondary",children:d.status==="online"?"运行中":"已停止"})]}),a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(E,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-muted-foreground",children:"适配器类型"})]}),e("span",{className:"text-sm font-medium",children:d.adapter})]}),a("div",{className:"flex justify-between items-center p-2 rounded-md bg-muted/50",children:[a("div",{className:"flex items-center gap-2 text-sm",children:[e(Rt,{className:"w-4 h-4 text-muted-foreground"}),e("span",{className:"text-muted-foreground",children:"连接状态"})]}),e("span",{className:`text-sm font-medium ${d.connected?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"}`,children:d.connected?"已连接":"未连接"})]})]})]})},`${d.adapter}-${d.name}-${i}`))}),r.length===0&&e(w,{children:a(k,{className:"flex flex-col items-center gap-4 py-12",children:[e(Z,{className:"w-16 h-16 text-muted-foreground/30"}),a("div",{className:"text-center",children:[e("h3",{className:"text-lg font-semibold",children:"暂无机器人"}),e("p",{className:"text-sm text-muted-foreground",children:"请先配置并启动机器人"})]})]})})]})}const Qe=p.forwardRef(({className:r,...t},s)=>e(Oe.Root,{ref:s,className:g("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",r),...t,children:e(Oe.Indicator,{className:g("flex items-center justify-center text-current"),children:e(De,{className:"h-4 w-4"})})}));Qe.displayName="Checkbox";function Wr(){const[r,t]=y([]),[s,n]=y(null),[c,l]=y(!0),[o,d]=y(null),[i,m]=y("all"),[u,S]=y(!0),N=nt(null),[C,R]=y(0);D(()=>{j(),T();const h=setInterval(()=>{j(),T()},3e3);return()=>clearInterval(h)},[i]),D(()=>{u&&r.length>C&&N.current?.scrollIntoView({behavior:"smooth"}),R(r.length)},[r,u]);const j=async()=>{try{const h=i==="all"?"/api/logs?limit=100":`/api/logs?limit=100&level=${i}`,f=await fetch(h,{credentials:"include"});if(!f.ok)throw new Error("API 请求失败");const x=await f.json();x.success&&Array.isArray(x.data)&&(t(x.data.reverse()),d(null))}catch(h){d(h.message)}finally{l(!1)}},T=async()=>{try{const h=await fetch("/api/logs/stats",{credentials:"include"});if(!h.ok)return;const f=await h.json();f.success&&n(f.data)}catch(h){console.error("Failed to fetch stats:",h)}},$=async(h,f)=>{const x=h?`确定清理 ${h} 天前的日志吗?`:`确定只保留最近 ${f} 条日志吗?`;if(confirm(x))try{const b=await fetch("/api/logs/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({days:h,maxRecords:f}),credentials:"include"});if(!b.ok)throw new Error("清理失败");const O=await b.json();O.success&&(alert(`成功清理 ${O.data.deletedCount} 条日志`),j(),T())}catch(b){alert(b.message)}},M=h=>{switch(h){case"info":return{border:"border-l-blue-500",badge:"default",icon:e(se,{className:"w-3 h-3"})};case"warn":return{border:"border-l-amber-500",badge:"warning",icon:e(At,{className:"w-3 h-3"})};case"error":return{border:"border-l-red-500",badge:"destructive",icon:e(Ot,{className:"w-3 h-3"})};default:return{border:"border-l-gray-500",badge:"secondary",icon:e(It,{className:"w-3 h-3"})}}};return c?a("div",{className:"space-y-4",children:[e(I,{className:"h-8 w-48"}),e("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[...Array(4)].map((h,f)=>e(I,{className:"h-20"},f))}),e(I,{className:"h-96"})]}):a("div",{className:"space-y-4",children:[a("div",{children:[e("h1",{className:"text-2xl font-bold tracking-tight",children:"系统日志"}),e("p",{className:"text-sm text-muted-foreground",children:"实时查看系统运行日志"})]}),s&&a("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold",children:s.total}),e("span",{className:"text-xs text-muted-foreground",children:"总日志数"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400",children:s.byLevel.info||0}),e("span",{className:"text-xs text-muted-foreground",children:"Info"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-amber-600 dark:text-amber-400",children:s.byLevel.warn||0}),e("span",{className:"text-xs text-muted-foreground",children:"Warn"})]})}),e(w,{children:a(k,{className:"flex flex-col items-center gap-1 p-4",children:[e("span",{className:"text-2xl font-bold text-red-600 dark:text-red-400",children:s.byLevel.error||0}),e("span",{className:"text-xs text-muted-foreground",children:"Error"})]})})]}),e(w,{children:a(k,{className:"flex justify-between items-center p-3 flex-wrap gap-3",children:[a("div",{className:"flex items-center gap-3 flex-wrap",children:[a(Ce,{value:i,onValueChange:m,children:[e(ne,{className:"w-32",children:e(Re,{placeholder:"所有级别"})}),a(ce,{children:[e(U,{value:"all",children:"所有级别"}),e(U,{value:"info",children:"Info"}),e(U,{value:"warn",children:"Warn"}),e(U,{value:"error",children:"Error"})]})]}),a("div",{className:"flex items-center gap-2",children:[e(Qe,{id:"auto-scroll",checked:u,onCheckedChange:h=>S(h)}),e("label",{htmlFor:"auto-scroll",className:"text-sm cursor-pointer",children:"自动滚动"})]})]}),a("div",{className:"flex gap-2",children:[a(P,{variant:"outline",size:"sm",onClick:()=>$(7),children:[e(ue,{className:"w-3.5 h-3.5 mr-1"}),"清理7天前"]}),a(P,{variant:"outline",size:"sm",onClick:()=>$(void 0,5e3),children:[e(ue,{className:"w-3.5 h-3.5 mr-1"}),"保留5000条"]}),a(P,{variant:"outline",size:"sm",onClick:()=>j(),children:[e(jt,{className:"w-3.5 h-3.5 mr-1"}),"刷新"]})]})]})}),e(w,{children:e(k,{className:"p-4",children:a("div",{className:"max-h-[600px] overflow-y-auto rounded-md bg-muted/30 p-2 space-y-1.5",children:[o?a(V,{variant:"destructive",children:[e(G,{className:"h-4 w-4"}),a(B,{children:["加载失败: ",o]})]}):r.length===0?a("div",{className:"flex flex-col items-center gap-3 py-12",children:[e(ge,{className:"w-12 h-12 text-muted-foreground/30"}),e("span",{className:"text-sm text-muted-foreground",children:"暂无日志"})]}):r.map((h,f)=>{const x=M(h.level);return a("div",{className:g("p-3 rounded-md bg-background border-l-[3px]",x.border),children:[a("div",{className:"flex items-center gap-2 mb-1",children:[a(v,{variant:x.badge,className:"gap-1 text-[10px] px-1.5 py-0",children:[x.icon," ",h.level.toUpperCase()]}),e("span",{className:"text-[11px] text-muted-foreground",children:new Date(h.timestamp).toLocaleString()}),h.source&&e(v,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:h.source})]}),e("p",{className:"text-sm font-mono whitespace-pre-wrap break-words",children:h.message})]},`${h.timestamp}-${f}`)}),e("div",{ref:N})]})})})]})}function Y(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Y=function(s){return typeof s}:Y=function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Y(r)}function Gr(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function Hr(r,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function qr(r,t,s){return t&&Hr(r.prototype,t),r}function Zr(r,t){return t&&(Y(t)==="object"||typeof t=="function")?t:ee(r)}function he(r){return he=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},he(r)}function ee(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Kr(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),t&&fe(r,t)}function fe(r,t){return fe=Object.setPrototypeOf||function(n,c){return n.__proto__=c,n},fe(r,t)}function te(r,t,s){return t in r?Object.defineProperty(r,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[t]=s,r}var Ye=(function(r){Kr(t,r);function t(){var s,n;Gr(this,t);for(var c=arguments.length,l=new Array(c),o=0;o<c;o++)l[o]=arguments[o];return n=Zr(this,(s=he(t)).call.apply(s,[this].concat(l))),te(ee(n),"state",{bootstrapped:!1}),te(ee(n),"_unsubscribe",void 0),te(ee(n),"handlePersistorState",function(){var d=n.props.persistor,i=d.getState(),m=i.bootstrapped;m&&(n.props.onBeforeLift?Promise.resolve(n.props.onBeforeLift()).finally(function(){return n.setState({bootstrapped:!0})}):n.setState({bootstrapped:!0}),n._unsubscribe&&n._unsubscribe())}),n}return qr(t,[{key:"componentDidMount",value:function(){this._unsubscribe=this.props.persistor.subscribe(this.handlePersistorState),this.handlePersistorState()}},{key:"componentWillUnmount",value:function(){this._unsubscribe&&this._unsubscribe()}},{key:"render",value:function(){return typeof this.props.children=="function"?this.props.children(this.state.bootstrapped):this.state.bootstrapped?this.props.children:this.props.loading}}]),t})(ct);te(Ye,"defaultProps",{children:null,loading:null});const Xr=X.Provider;X.Root;X.Trigger;const Qr=p.forwardRef(({className:r,sideOffset:t=4,...s},n)=>e(X.Portal,{children:e(X.Content,{ref:n,sideOffset:t,className:g("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r),...s})}));Qr.displayName="TooltipContent";or();function Yr(){Vt();const r=J(o=>o.script.entries),t=J(o=>o.script.loadedScripts),s=J(o=>o.script.synced),[n,c]=y(!1);D(()=>{[{key:"dashboard-layout",path:"/",title:"Dashboard",element:e(hr,{}),redirect:"/dashboard",meta:{order:0},children:[{key:"dashboard-home",index:!0,path:"",title:"系统概览",icon:e(Pt,{className:"w-4 h-4"}),element:e(br,{})},{key:"dashboard-plugins",path:"/plugins",title:"插件管理",icon:e(E,{className:"w-4 h-4"}),element:e(yr,{}),meta:{order:2}},{key:"dashboard-plugin-detail",title:"插件详情",path:"/plugins/:name",element:e(zr,{}),meta:{hideInMenu:!0}},{key:"dashboard-bots",path:"/bots",title:"机器人",icon:e(Z,{className:"w-4 h-4"}),element:e(Jr,{}),meta:{order:3}},{key:"dashboard-logs",path:"/logs",title:"系统日志",icon:e(ge,{className:"w-4 h-4"}),element:e(Wr,{}),meta:{order:4}}]}].forEach(d=>{Bt(d)}),c(!0)},[]);const l=s&&(r.length===0||r.length===t.length);return!n||!l?e("div",{className:"flex items-center justify-center h-screen bg-background",children:a("div",{className:"text-center",children:[e("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-2 border-muted-foreground border-t-foreground"}),a("p",{className:"mt-3 text-sm text-muted-foreground",children:["加载中... (",t.length,"/",r.length,")"]})]})}):e(zt,{})}it(document.getElementById("root")).render(e(lt,{children:e(Xr,{children:e(Ye,{loading:null,persistor:Mt,children:e(lr,{store:Dt,children:e(Yr,{})})})})}));