(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,24877,e=>{"use strict";var t=e.i(43476),s=e.i(71645);function a(){let[e,a]=(0,s.useState)([]),[l,n]=(0,s.useState)(0),[i,r]=(0,s.useState)(""),[c,d]=(0,s.useState)(""),[o,x]=(0,s.useState)(1),[h,p]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{let e;p(!0),e=new URLSearchParams({page:String(o)}),i&&e.set("channel",i),c&&e.set("hasLead",c),fetch(`/api/admin/conversations?${e}`).then(e=>e.json()).then(e=>{a(e.conversations),n(e.total)}).catch(console.error).finally(()=>p(!1))},[o,i,c]),(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 Conversations"}),(0,t.jsxs)("p",{className:"text-sm text-white/50",children:[l," total conversations"]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,t.jsxs)("select",{value:i,onChange:e=>{r(e.target.value),x(1)},className:"rounded-xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white",children:[(0,t.jsx)("option",{value:"",children:"All channels"}),(0,t.jsx)("option",{value:"web",children:"Web"}),(0,t.jsx)("option",{value:"whatsapp",children:"WhatsApp"})]}),(0,t.jsxs)("select",{value:c,onChange:e=>{d(e.target.value),x(1)},className:"rounded-xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white",children:[(0,t.jsx)("option",{value:"",children:"All conversations"}),(0,t.jsx)("option",{value:"true",children:"With leads only"})]})]}),h?(0,t.jsx)("div",{className:"py-12 text-center text-white/30",children:"Loading..."}):(0,t.jsxs)("div",{className:"space-y-2",children:[e.map(e=>(0,t.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-white/5 p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:`rounded-full px-2 py-0.5 text-xs font-semibold ${"whatsapp"===e.channel?"bg-green-500/20 text-green-400":"bg-[var(--color-bg-brand)]/20 text-[var(--color-accent-green-light)]"}`,children:e.channel}),(0,t.jsx)("span",{className:"text-sm font-medium",children:e.bot?.name||"Unknown bot"}),(0,t.jsxs)("span",{className:"text-xs text-white/30",children:[e.messageCount," msgs"]}),e.lead?.email&&(0,t.jsx)("span",{className:"rounded-full bg-yellow-500/20 px-2 py-0.5 text-xs text-yellow-400",children:e.lead.email}),(0,t.jsx)("span",{className:"ml-auto text-xs text-white/30",children:new Date(e.updatedAt).toLocaleString()})]}),(0,t.jsx)("p",{className:"mt-2 text-sm text-white/50",children:e.lastMessage||"No messages"})]},e._id)),0===e.length&&(0,t.jsx)("div",{className:"py-12 text-center text-white/30",children:"No conversations found"})]}),l>20&&(0,t.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,t.jsx)("button",{onClick:()=>x(e=>Math.max(1,e-1)),disabled:1===o,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 ",o]}),(0,t.jsx)("button",{onClick:()=>x(e=>e+1),disabled:o>=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])}]);