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

//# sourceMappingURL=src_app_%28admin%29_thisistheaeyesecretlogin_bots_page_tsx_caffe002._.js.map