(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,8966,e=>{"use strict";var t=e.i(43476),s=e.i(71645);function a(){let[e,a]=(0,s.useState)([]),[l,i]=(0,s.useState)(0),[n,c]=(0,s.useState)(""),[d,r]=(0,s.useState)(1),[o,x]=(0,s.useState)(!0);function h(){x(!0);let e=new URLSearchParams({page:String(d)});n&&e.set("search",n),fetch(`/api/admin/bots?${e}`).then(e=>e.json()).then(e=>{a(e.bots),i(e.total)}).catch(console.error).finally(()=>x(!1))}async function m(e,t){await fetch("/api/admin/bots",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:e,status:"active"===t?"paused":"active"})}),h()}return(0,s.useEffect)(()=>{h()},[d]),(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-bold",children:"All Bots"}),(0,t.jsxs)("p",{className:"text-sm text-white/50",children:[l," total bots across all users"]})]}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)("input",{type:"text",value:n,onChange:e=>c(e.target.value),onKeyDown:e=>"Enter"===e.key&&h(),placeholder:"Search bot name...",className:"rounded-xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none placeholder:text-white/30 focus:border-[var(--color-bg-brand)]"}),(0,t.jsx)("button",{onClick:h,className:"rounded-xl bg-[var(--color-bg-brand)] px-4 py-2 text-sm font-semibold text-white",children:"Search"})]}),o?(0,t.jsx)("div",{className:"py-12 text-center text-white/30",children:"Loading..."}):(0,t.jsx)("div",{className:"overflow-x-auto rounded-2xl border border-white/10",children:(0,t.jsxs)("table",{className:"min-w-full text-sm",children:[(0,t.jsx)("thead",{className:"border-b border-white/10 bg-white/5 text-left text-white/50",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Bot Name"}),(0,t.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Owner"}),(0,t.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Goal"}),(0,t.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Conversations"}),(0,t.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Status"}),(0,t.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Created"}),(0,t.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Actions"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-white/5",children:e.map(e=>(0,t.jsxs)("tr",{className:"hover:bg-white/5",children:[(0,t.jsx)("td",{className:"px-4 py-3 font-medium",children:e.name}),(0,t.jsx)("td",{className:"px-4 py-3",children:(0,t.jsx)("p",{className:"text-xs text-white/40",children:e.userId?.email})}),(0,t.jsx)("td",{className:"px-4 py-3 text-white/50",children:e.config?.goal||"—"}),(0,t.jsx)("td",{className:"px-4 py-3 text-white/50",children:e.conversationsCount}),(0,t.jsx)("td",{className:"px-4 py-3",children:(0,t.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-semibold ${"active"===e.status?"bg-green-500/20 text-green-400":"bg-yellow-500/20 text-yellow-400"}`,children:e.status})}),(0,t.jsx)("td",{className:"px-4 py-3 text-xs text-white/40",children:new Date(e.createdAt).toLocaleDateString()}),(0,t.jsx)("td",{className:"px-4 py-3",children:(0,t.jsx)("button",{onClick:()=>m(e._id,e.status),className:"text-xs text-[var(--color-accent-green-light)] hover:text-white",children:"active"===e.status?"Disable":"Enable"})})]},e._id))})]})}),l>20&&(0,t.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,t.jsx)("button",{onClick:()=>r(e=>Math.max(1,e-1)),disabled:1===d,className:"rounded-xl border border-white/10 px-4 py-2 text-sm disabled:opacity-30",children:"Previous"}),(0,t.jsxs)("span",{className:"text-sm text-white/50",children:["Page ",d]}),(0,t.jsx)("button",{onClick:()=>r(e=>e+1),disabled:d>=Math.ceil(l/20),className:"rounded-xl border border-white/10 px-4 py-2 text-sm disabled:opacity-30",children:"Next"})]})]})}e.s(["default",()=>a])}]);