import{Or as e,Tr as t,t as n}from"./jsx-runtime-NwRKtVrk.js";import{r}from"./statusUtils-G17j4Ng-.js";import{t as i}from"./button-CM-rzMOH.js";import{t as a}from"./space-Dvitgohy.js";import{t as o}from"./card-D7XvzVif.js";import{t as s}from"./spin-DV35Mdw9.js";import{t as c}from"./tag-C0Yg14A-.js";import{$ as l,W as u,Y as d,_ as f,g as p,h as m,it as h,s as g}from"./index-B7MUL4ct.js";import{n as _,r as v}from"./agent-D8tKYnoa.js";var y=e(t(),1),b=n(),{Title:x,Text:S,Paragraph:C}=m;function w(){let{t:e}=g(),{token:t}=p.useToken(),{message:n}=l.useApp(),m=h(),[w,T]=(0,y.useState)([]),[E,D]=(0,y.useState)(!1),O=(0,y.useCallback)(async()=>{D(!0);try{T((await _()).data.data??[])}finally{D(!1)}},[]);(0,y.useEffect)(()=>{O()},[O]);let k=async(t,r)=>{try{await v(t,{enabled:r}),T(e=>e.map(e=>e.id===t?{...e,enabled:r}:e)),n.success(e(`ai.agent.update.success`))}catch{n.error(e(`ai.agent.update.failed`))}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,marginBottom:t.marginLG},children:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(x,{level:3,style:{marginBottom:t.marginXS},children:e(`ai.agent.page.title`)}),(0,b.jsx)(S,{type:`secondary`,children:e(`ai.agent.page.description`)})]})}),(0,b.jsx)(s,{spinning:E,children:w.length>0?(0,b.jsx)(`div`,{className:`flex flex-wrap gap-6`,children:w.map(n=>(0,b.jsx)(r,{title:n.description,children:(0,b.jsxs)(o,{hoverable:!0,variant:`borderless`,styles:{body:{width:300,padding:20,overflow:`hidden`}},children:[(0,b.jsxs)(`div`,{className:`flex justify-between items-center mb-2.5`,children:[(0,b.jsxs)(a,{align:`center`,children:[(0,b.jsx)(d,{src:n.icon,size:32}),(0,b.jsx)(`span`,{style:{fontWeight:700,fontSize:18},children:n.name})]}),(0,b.jsx)(f,{checked:n.enabled,size:`small`,onChange:e=>k(n.id,e)})]}),(0,b.jsx)(C,{type:`secondary`,ellipsis:{rows:2},style:{marginBottom:t.marginSM},children:n.description}),(0,b.jsx)(a,{size:[4,4],wrap:!0,children:n.tags?.map(e=>(0,b.jsx)(c,{color:`blue`,children:e},e))}),(0,b.jsx)(`div`,{style:{marginTop:t.marginSM},children:(0,b.jsx)(i,{type:`primary`,size:`small`,block:!0,onClick:()=>m(`/ai/chat?agent_id=${n.id}`),children:e(`ai.agent.goChat`)})})]})}))}):(0,b.jsx)(u,{description:e(`ai.agent.empty`)})})]})}export{w as default};