PageSourceSearch

https://live-avatar-chat.replit.app/assets/AgencyAdmin-CB7sz9pW.js

js live-avatar-chat.replit.app collected 2026-10-03 03:56:09 UTC 19,586 bytes, 1 lines download raw bytes

1import{c as i,u as F,r as a,a as o,j as e,S as A,M as J}from"./index-C34IO7n8.js";import{A as N}from"./arrow-left-Fk18GDpL.js";const G=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],j=i("bot",G);const K=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],W=i("chart-column",K);const X=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Y=i("log-out",X);const Z=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],M=i("plus",Z);const ee=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],te=i("search",ee);const se=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ae=i("shield",se);const re=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],le=i("square-pen",re);const ie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ne=i("target",ie);const ce=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],oe=i("trash-2",ce);const de=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],u=i("users",de);function me(){const[,f]=F(),[b,T]=a.useState(null),[_,w]=a.useState(!0),[v,k]=a.useState(null),[d,r]=a.useState("dashboard"),[h,$]=a.useState(null),[y,B]=a.useState([]),[E,L]=a.useState(0),[q,D]=a.useState(""),[l,V]=a.useState(null),[m,z]=a.useState([]),[H,x]=a.useState("dashboard"),[s,c]=a.useState({companyName:"",ownerName:"",email:"",password:"",planType:"starter",creditsTotal:1e3});a.useEffect(()=>{O()},[]);async function O(){try{if(!(await o("/auth/user")).user){k("not_authenticated"),w(!1);return}const n=await o("/agency/setup");T(n.agency),w(!1),g(),p()}catch(t){k(t.message),w(!1)}}async function g(){try{const t=await o("/agency/dashboard");$(t)}catch{}}async function p(t){try{const n=t?`?search=${encodeURIComponent(t)}`:"",S=await o(`/agency/clients${n}`);B(S.clients),L(S.total)}catch{}}async function C(t){V(t),r("client-detail"),x("clients");try{const n=await o(`/agency/clients/${t.id}`);z(n.bots||[])}catch{}}async function P(t){t.preventDefault();try{await o("/agency/clients",{method:"POST",body:JSON.stringify(s)}),c({companyName:"",ownerName:"",email:"",password:"",planType:"starter",creditsTotal:1e3}),r("clients"),p(),g()}catch(n){alert(n.message)}}async function U(t){if(confirm("Are you sure you want to deactivate this client?"))try{await o(`/agency/clients/${t}`,{method:"DELETE"}),p(),g(),r("clients")}catch(n){alert(n.message)}}function I(){window.location.href=`/api/login?returnTo=${encodeURIComponent("/agency")}`}function R(){window.location.href="/api/logout"}if(_)return e.jsx("div",{className:"min-h-screen bg-[#0a0a1a] flex items-center justify-center",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary border-t-transparent rounded-full"})});if(v==="not_authenticated"||v?.includes("Authentication"))return e.jsx("div",{className:"min-h-screen bg-[#0a0a1a] flex items-center justify-center",children:e.jsxs("div",{className:"bg-[#12122a] rounded-2xl p-8 border border-white/10 max-w-md w-full mx-4 text-center",children:[e.jsx(ae,{className:"w-12 h-12 text-primary mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"Agency Admin"}),e.jsx("p",{className:"text-white/60 mb-6",children:"Sign in with your Replit account to access the agency dashboard."}),e.jsx("button",{onClick:I,className:"w-full px-6 py-3 rounded-xl bg-primary text-primary-foreground font-semibold hover:bg-primary/90 transition-colors",children:"Sign In with Replit"}),e.jsx("button",{onClick:()=>f("/"),className:"mt-4 text-white/50 hover:text-white/70 text-sm transition-colors",children:"Back to Home"})]})});const Q=[{id:"dashboard",label:"Dashboard",icon:W},{id:"clients",label:"Clients",icon:u},{id:"settings",label:"Settings",icon:A}];return e.jsxs("div",{className:"min-h-screen bg-[#0a0a1a] flex",children:[e.jsxs("aside",{className:"w-64 bg-[#0d0d20] border-r border-white/5 flex flex-col",children:[e.jsxs("div",{className:"p-6 border-b border-white/5",children:[e.jsxs("button",{onClick:()=>f("/"),className:"flex items-center gap-2 text-white/50 hover:text-white/70 text-sm mb-3 transition-colors",children:[e.jsx(N,{className:"w-4 h-4"})," Back to Site"]}),e.jsx("h2",{className:"text-lg font-bold text-transparent bg-clip-text bg-gradient-to-r from-primary to-cyan-300",children:"Agency Admin"}),e.jsx("p",{className:"text-xs text-white/40 mt-1 truncate",children:b?.ownerEmail})]}),e.jsx("nav",{className:"flex-1 p-4 space-y-1",children:Q.map(t=>e.jsxs("button",{onClick:()=>{x(t.id),r(t.id)},className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition-colors ${H===t.id?"bg-primary/10 text-primary":"text-white/60 hover:text-white hover:bg-white/5"}`,children:[e.jsx(t.icon,{className:"w-4 h-4"}),t.label]},t.id))}),e.jsx("div",{className:"p-4 border-t border-white/5",children:e.jsxs("button",{onClick:R,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm text-white/60 hover:text-red-400 hover:bg-red-400/5 transition-colors",children:[e.jsx(Y,{className:"w-4 h-4"})," Sign Out"]})})]}),e.jsxs("main",{className:"flex-1 overflow-auto",children:[d==="dashboard"&&e.jsxs("div",{className:"p-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-white mb-8",children:"Dashboard"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:[{label:"Total Clients",value:h?.totalClients??0,icon:u,color:"text-blue-400"},{label:"Active Bots",value:h?.activeBots??0,icon:j,color:"text-green-400"},{label:"Conversations Today",value:h?.conversationsToday??0,icon:J,color:"text-purple-400"},{label:"Total Leads",value:h?.totalLeads??0,icon:ne,color:"text-orange-400"}
1].map(t=>e.jsxs("div",{className:"bg-[#12122a] rounded-xl p-6 border border-white/5",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx(t.icon,{className:`w-5 h-5 ${t.color}`})}),e.jsx("p",{className:"text-3xl font-bold text-white",children:t.value}),e.jsx("p",{className:"text-sm text-white/50 mt-1",children:t.label})]},t.label))}),e.jsxs("div",{className:"bg-[#12122a] rounded-xl border border-white/5 p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Quick Actions"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("button",{onClick:()=>{x("clients"),r("create-client")},className:"flex items-center gap-3 p-4 rounded-lg bg-primary/10 border border-primary/20 text-primary hover:bg-primary/20 transition-colors",children:[e.jsx(M,{className:"w-5 h-5"})," Add New Client"]}),e.jsxs("button",{onClick:()=>{x("clients"),r("clients")},className:"flex items-center gap-3 p-4 rounded-lg bg-white/5 border border-white/10 text-white/70 hover:bg-white/10 transition-colors",children:[e.jsx(u,{className:"w-5 h-5"})," View All Clients"]}),e.jsxs("button",{onClick:()=>{x("settings"),r("settings")},className:"flex items-center gap-3 p-4 rounded-lg bg-white/5 border border-white/10 text-white/70 hover:bg-white/10 transition-colors",children:[e.jsx(A,{className:"w-5 h-5"})," Agency Settings"]})]})]})]}),d==="clients"&&e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Clients"}),e.jsxs("button",{onClick:()=>r("create-client"),className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-primary text-primary-foreground text-sm font-semibold hover:bg-primary/90 transition-colors",children:[e.jsx(M,{className:"w-4 h-4"})," Add Client"]})]}),e.jsxs("div",{className:"relative mb-6",children:[e.jsx(te,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-white/40"}),e.jsx("input",{type:"text",placeholder:"Search clients...",value:q,onChange:t=>{D(t.target.value),p(t.target.value)},className:"w-full pl-10 pr-4 py-2.5 rounded-lg bg-[#12122a] border border-white/10 text-white text-sm placeholder:text-white/30 focus:outline-none focus:border-primary/50"})]}),y.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(u,{className:"w-12 h-12 text-white/20 mx-auto mb-4"}),e.jsx("p",{className:"text-white/50",children:"No clients found"}),e.jsx("button",{onClick:()=>r("create-client"),className:"mt-4 text-primary hover:text-primary/80 text-sm",children:"Create your first client"})]}):e.jsxs("div",{className:"bg-[#12122a] rounded-xl border border-white/5 overflow-hidden",children:[e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("th",{className:"text-left px-6 py-3 text-xs font-medium text-white/40 uppercase",children:"Company"}),e.jsx("th",{className:"text-left px-6 py-3 text-xs font-medium text-white/40 uppercase",children:"Owner"}),e.jsx("th",{className:"text-left px-6 py-3 text-xs font-medium text-white/40 uppercase",children:"Plan"}),e.jsx("th",{className:"text-left px-6 py-3 text-xs font-medium text-white/40 uppercase",children:"Status"}),e.jsx("th",{className:"text-left px-6 py-3 text-xs font-medium text-white/40 uppercase",children:"Credits"}),e.jsx("th",{className:"text-right px-6 py-3 text-xs font-medium text-white/40 uppercase",children:"Actions"})]})}),e.jsx("tbody",{children:y.map(t=>e.jsxs("tr",{className:"border-b border-white/5 hover:bg-white/[0.02] transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("button",{onClick:()=>C(t),className:"text-white hover:text-primary transition-colors font-medium text-sm",children:t.companyName})}),e.jsx("td",{className:"px-6 py-4 text-sm text-white/60",children:t.ownerName}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"px-2 py-1 rounded-md bg-primary/10 text-primary text-xs font-medium capitalize",children:t.planType})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`px-2 py-1 rounded-md text-xs font-medium capitalize ${t.planStatus==="active"?"bg-green-500/10 text-green-400":t.planStatus==="trial"?"bg-yellow-500/10 text-yellow-400":"bg-red-500/10 text-red-400"}`,children:t.planStatus})}),e.jsxs("td",{className:"px-6 py-4 text-sm text-white/60",children:[t.creditsUsed," / ",t.creditsTotal]}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>C(t),className:"p-1.5 rounded hover:bg-white/10 text-white/40 hover:text-white transition-colors",children:e.jsx(le,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>U(t.id),className:"p-1.5 rounded hover:bg-red-500/10 text-white/40 hover:text-red-400 transition-colors",children:e.jsx(oe,{className:"w-4 h-4"})})]})})]},t.id))})]}),e.jsxs("div",{className:"px-6 py-3 border-t border-white/5 text-xs text-white/40",children:["Showing ",y.length," of ",E," clients"]})]})]}),d==="create-client"&&e.jsxs("div",{className:"p-8 max-w-2xl",children:[e.jsxs("button",{onClick:()=>r("clients"),className:"flex items-center gap-2 text-white/50 hover:text-white/70 text-sm mb-6 transition-colors",children:[e.jsx(N,{className:"w-4 h-4"})," Back to Clients"]}),e.jsx("h1",{className:"text-2xl font-bold text-white mb-6",children:"Add New Client"}),e.jsxs("form",{onSubmit:P,className:"bg-[#12122a] rounded-xl border border-white/5 p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-white/60 mb-1.5",children:"Company Name"}),e.jsx("input",{type:"text",required:!0,value:s.companyName,onChange:t=>c({...s,companyName:t.target.value}),className:"w-full px-4 py-2.5 rounded-lg bg-[#0a0a1a] border border-white/10 text-white text-sm focus:outline-none focus:border-primary/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-white/60 mb-1.5",children:"Owner Name"}),e.jsx("input",{type:"text",required:!0,value:s.ownerName,onChange:t=>c({...s,ownerName:t.target.value}),className:"w-full px-4 py-2.5 rounded-lg bg-[#0a0a1a] border border-white/10 text-white text-sm focus:outline-none focus:border-primary/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-white/60 mb-1.5",children:"Email"}),e.jsx("input",{type:"email",required:!0,value:s.email,onChange:t=>c({...s,email:t.target.value}),className:"w-full px-4 py-2.5 rounded-lg bg-[#0a0a1a] border border-white/10 text-white text-sm focus:outline-none focus:border-primary/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-white/60 mb-1.5",children:"Password"}),e.jsx("input",{type:"password",required:!0,minLength:6,value:s.password,onChange:t=>c({...s,password:t.target.value}),className:"w-full px-4 py-2.5 rounded-lg bg-[#0a0a1a] border border-white/10 text-white text-sm focus:outline-none focus:border-primary/50"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-white/60 mb-1.5",children:"Plan Type"}
1),e.jsxs("select",{value:s.planType,onChange:t=>c({...s,planType:t.target.value}),className:"w-full px-4 py-2.5 rounded-lg bg-[#0a0a1a] border border-white/10 text-white text-sm focus:outline-none focus:border-primary/50",children:[e.jsx("option",{value:"starter",children:"Starter"}),e.jsx("option",{value:"professional",children:"Professional"}),e.jsx("option",{value:"enterprise",children:"Enterprise"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-white/60 mb-1.5",children:"Credits"}),e.jsx("input",{type:"number",value:s.creditsTotal,onChange:t=>c({...s,creditsTotal:Number(t.target.value)}),className:"w-full px-4 py-2.5 rounded-lg bg-[#0a0a1a] border border-white/10 text-white text-sm focus:outline-none focus:border-primary/50"})]})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"submit",className:"px-6 py-2.5 rounded-lg bg-primary text-primary-foreground text-sm font-semibold hover:bg-primary/90 transition-colors",children:"Create Client"}),e.jsx("button",{type:"button",onClick:()=>r("clients"),className:"px-6 py-2.5 rounded-lg bg-white/5 text-white/70 text-sm hover:bg-white/10 transition-colors",children:"Cancel"})]})]})]}),d==="client-detail"&&l&&e.jsxs("div",{className:"p-8",children:[e.jsxs("button",{onClick:()=>r("clients"),className:"flex items-center gap-2 text-white/50 hover:text-white/70 text-sm mb-6 transition-colors",children:[e.jsx(N,{className:"w-4 h-4"})," Back to Clients"]}),e.jsxs("div",{className:"flex items-start justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:l.companyName}),e.jsxs("p",{className:"text-white/50 mt-1",children:[l.ownerName," · ",l.email]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium capitalize ${l.planStatus==="active"?"bg-green-500/10 text-green-400 border border-green-500/20":l.planStatus==="trial"?"bg-yellow-500/10 text-yellow-400 border border-yellow-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:l.planStatus}),e.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-medium capitalize bg-primary/10 text-primary border border-primary/20",children:l.planType})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-8",children:[e.jsxs("div",{className:"bg-[#12122a] rounded-xl p-5 border border-white/5",children:[e.jsx("p",{className:"text-xs text-white/40 uppercase mb-1",children:"Credits Used"}),e.jsxs("p",{className:"text-2xl font-bold text-white",children:[l.creditsUsed," ",e.jsxs("span",{className:"text-sm text-white/40",children:["/ ",l.creditsTotal]})]}),e.jsx("div",{className:"mt-2 h-1.5 bg-white/5 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full",style:{width:`${Math.min(100,l.creditsUsed/l.creditsTotal*100)}%`}})})]}),e.jsxs("div",{className:"bg-[#12122a] rounded-xl p-5 border border-white/5",children:[e.jsx("p",{className:"text-xs text-white/40 uppercase mb-1",children:"Active Bots"}),e.jsx("p",{className:"text-2xl font-bold text-white",children:m.filter(t=>t.isActive).length})]}),e.jsxs("div",{className:"bg-[#12122a] rounded-xl p-5 border border-white/5",children:[e.jsx("p",{className:"text-xs text-white/40 uppercase mb-1",children:"Total Bots"}),e.jsx("p",{className:"text-2xl font-bold text-white",children:m.length})]})]}),e.jsxs("div",{className:"bg-[#12122a] rounded-xl border border-white/5",children:[e.jsx("div",{className:"px-6 py-4 border-b border-white/5 flex items-center justify-between",children:e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Bots"})}),m.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(j,{className:"w-10 h-10 text-white/20 mx-auto mb-3"}),e.jsx("p",{className:"text-white/50 text-sm",children:"No bots created yet"})]}):e.jsx("div",{className:"divide-y divide-white/5",children:m.map(t=>e.jsxs("div",{className:"px-6 py-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-sm font-medium",children:t.botName}),e.jsxs("p",{className:"text-white/40 text-xs",children:[t.botRole," · ",t.avatarType]})]})]}),e.jsx("span",{className:`px-2 py-1 rounded text-xs ${t.isActive?"bg-green-500/10 text-green-400":"bg-white/5 text-white/40"}`,children:t.isActive?"Active":"Inactive"})]},t.id))})]})]}),d==="settings"&&e.jsxs("div",{className:"p-8 max-w-2xl",children:[e.jsx("h1",{className:"text-2xl font-bold text-white mb-6",children:"Agency Settings"}),e.jsxs("div",{className:"bg-[#12122a] rounded-xl border border-white/5 p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-white/60 mb-1.5",children:"Agency Name"}),e.jsx("input",{type:"text",defaultValue:b?.name,className:"w-full px-4 py-2.5 rounded-lg bg-[#0a0a1a] border border-white/10 text-white text-sm focus:outline-none focus:border-primary/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-white/60 mb-1.5",children:"Owner Email"}),e.jsx("input",{type:"email",disabled:!0,value:b?.ownerEmail,className:"w-full px-4 py-2.5 rounded-lg bg-[#0a0a1a] border border-white/10 text-white/50 text-sm cursor-not-allowed"})]}),e.jsx("p",{className:"text-white/30 text-xs",children:"More settings coming soon."})]})]})]})]})}export{me as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.