import{o as e}from"./request-xrnk7ZJV.js";import{Pr as t,t as n}from"./jsx-runtime-OfKoVykY.js";import{o as r}from"./chunk-OB3PAWPO-D_lbwNck.js";import{t as i}from"./typography-C81dpVAv.js";import{t as a}from"./tooltip-DI_m69zk.js";import{t as o}from"./space-JYtHxLjg.js";import{t as s}from"./button-DsOd0cni.js";import{t as c}from"./card-C-jMUkpS.js";import{t as l}from"./spin-CELNGCax.js";import{t as u}from"./tag-CY8tAhzO.js";import{t as d}from"./useTranslation-C4ZVtLa2.js";import{$t as f,Ht as p,bt as m,lt as h,rn as g}from"./index-DMEx4_h0.js";import{n as _,r as v}from"./agent-CGxkD5Jw.js";var y=e(t(),1),b=n(),{Title:x,Text:S,Paragraph:C}=i;function w(){let{t:e}=d(),{token:t}=h.useToken(),{message:n}=g.useApp(),i=r(),[w,T]=(0,y.useState)([]),[E,D]=(0,y.useState)(!1),O=(0,y.useCallback)(async()=>{D(!0);try{let e=await _();T(e.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)(l,{spinning:E,children:w.length>0?(0,b.jsx)(`div`,{className:`flex flex-wrap gap-6`,children:w.map(n=>(0,b.jsx)(a,{title:n.description,children:(0,b.jsxs)(c,{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)(o,{align:`center`,children:[(0,b.jsx)(p,{src:n.icon,size:32}),(0,b.jsx)(`span`,{style:{fontWeight:700,fontSize:18},children:n.name})]}),(0,b.jsx)(m,{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)(o,{size:[4,4],wrap:!0,children:n.tags?.map(e=>(0,b.jsx)(u,{color:`blue`,children:e},e))}),(0,b.jsx)(`div`,{style:{marginTop:t.marginSM},children:(0,b.jsx)(s,{type:`primary`,size:`small`,block:!0,onClick:()=>i(`/ai/chat?agent_id=${n.id}`),children:e(`ai.agent.goChat`)})})]})}))}):(0,b.jsx)(f,{description:e(`ai.agent.empty`)})})]})}export{w as default};