PageSourceSearch

https://ui-helper--stoxra.replit.app/assets/support-agent-dashboard-C3hq_AEq.js

js ui-helper--stoxra.replit.app collected 2026-10-03 03:58:28 UTC 46,139 bytes, 1 lines download raw bytes

1import{u as Ae,r,j as e}from"./index-C8T3vEcn.js";function $(m){const n=Date.now(),C=new Date(m).getTime(),u=Math.max(0,n-C),w=Math.floor(u/1e3);if(w<60)return`${w}s ago`;const x=Math.floor(w/60);if(x<60)return`${x}m ago`;const b=Math.floor(x/60);return b<24?`${b}h ago`:`${Math.floor(b/24)}d ago`}function Ee(m){if(!m||m<=0)return"—";if(m<60)return`${Math.round(m)}s`;const n=m/60;return n<60?`${Math.round(n)}m`:`${(n/60).toFixed(1)}h`}const le={PAYMENT:"bg-rose-500/15 text-rose-400 border-rose-500/30",PREMIUM_ACCESS:"bg-amber-500/15 text-amber-400 border-amber-500/30",COINS:"bg-yellow-500/15 text-yellow-400 border-yellow-500/30",COMPETITION:"bg-purple-500/15 text-purple-400 border-purple-500/30",TECHNICAL_BUG:"bg-red-500/15 text-red-400 border-red-500/30",ACCOUNT_LOGIN:"bg-sky-500/15 text-sky-400 border-sky-500/30",AFFILIATE:"bg-teal-500/15 text-teal-400 border-teal-500/30",OTHER:"bg-slate-500/15 text-slate-400 border-slate-500/30"},Te={PAYMENT:"bg-rose-500",PREMIUM_ACCESS:"bg-amber-500",COINS:"bg-yellow-500",COMPETITION:"bg-purple-500",TECHNICAL_BUG:"bg-red-500",ACCOUNT_LOGIN:"bg-sky-500",AFFILIATE:"bg-teal-500",OTHER:"bg-slate-500"},Se=["PAYMENT","PREMIUM_ACCESS","COINS","COMPETITION","TECHNICAL_BUG","ACCOUNT_LOGIN","AFFILIATE","OTHER"],ie={URGENT:0,HIGH:1,MEDIUM:2,LOW:3},Me=["We're looking into this","Could you provide more details?","This has been escalated to our team","Your issue has been resolved","Is there anything else I can help with?"];function Re(){const[,m]=Ae(),[n,C]=r.useState(null),[u,w]=r.useState(!0),[x,b]=r.useState("dashboard"),[f,ne]=r.useState(null),[c,de]=r.useState(null),[D,oe]=r.useState([]),[B,ce]=r.useState(0),[xe,F]=r.useState(!1),[A,P]=r.useState("ALL"),[E,me]=r.useState("ALL"),[T,ue]=r.useState(""),[y,he]=r.useState("newest"),[a,j]=r.useState(null),[S,V]=r.useState([]),[i,G]=r.useState(null),[pe,Y]=r.useState(!1),[M,W]=r.useState(""),[I,J]=r.useState(!1),[Ie,be]=r.useState(null),[ge,U]=r.useState(!1),[K,q]=r.useState([]),[O,Q]=r.useState(""),[R,X]=r.useState(!1),Z=r.useRef(null),H=r.useRef(null),d=r.useCallback(async(t,s)=>{const l=localStorage.getItem("support_agent_token"),o=await fetch(`/api${t}`,{...s,headers:{"Content-Type":"application/json",...l?{Authorization:`Bearer ${l}`}:{},...s?.headers}});if(!o.ok){const p=await o.json().catch(()=>({message:"Request failed"}));throw new Error(p.message)}return o.json()},[]);r.useEffect(()=>{(async()=>{try{const s=await d("/support-agent/me");C(s)}catch{m("/_support_login")}finally{w(!1)}})()},[d,m]);const g=r.useCallback(async()=>{try{const t=await d("/support-agent/stats");ne(t)}catch(t){console.error("Failed to fetch stats:",t)}},[d]),L=r.useCallback(async()=>{try{const t=await d("/support-agent/analytics");de(t)}catch(t){console.error("Failed to fetch analytics:",t)}},[d]),h=r.useCallback(async()=>{F(!0);try{const t=A!=="ALL"?`?status=${A}`:"",s=await d(`/support-agent/tickets${t}`),l=s.tickets||[],o=s.total||l.length;oe(l),ce(o),be(p=>(p!==null&&o>p&&(U(!0),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>U(!1),5e3)),o))}catch(t){console.error("Failed to fetch tickets:",t)}finally{F(!1)}},[d,A]),v=r.useCallback(async t=>{try{const s=await d(`/support-agent/tickets/${t}`);j(s.ticket||s),V(s.messages||[]),G(s.user||null)}catch(s){console.error("Failed to fetch ticket detail:",s)}},[d]),ee=r.useCallback(async t=>{try{const s=await d(`/support-agent/tickets/${t}/notes`);q(s.notes||[])}catch(s){console.error("Failed to fetch notes:",s)}},[d]);r.useEffect(()=>{!u&&n&&(g(),h(),L())},[u,n,g,h,L]),r.useEffect(()=>{if(!u&&n&&x==="tickets"&&!a){const t=setInterval(h,8e3);return()=>clearInterval(t)}},[u,n,x,a,h]),r.useEffect(()=>{if(!u&&n){const t=setInterval(g,15e3);return()=>clearInterval(t)}},[u,n,g]),r.useEffect(()=>{if(!u&&n&&x==="dashboard"){const t=setInterval(L,3e4);return()=>clearInterval(t)}},[u,n,x,L]),r.useEffect(()=>{if(!a)return;const t=setInterval(()=>v(a.id),3e3);return()=>clearInterval(t)},[a,v]),r.useEffect(()=>{Z.current?.scrollIntoView({behavior:"smooth"})},[S]);const z=r.useMemo(()=>{let t=D;if(E!=="ALL"&&(t=t.filter(s=>s.ticket?.category===E)),T.trim()){const s=T.trim().toLowerCase();t=t.filter(l=>{const o=String(l.ticket?.id||""),p=(l.user?.email||"").toLowerCase(),Ce=(l.user?.username||"").toLowerCase();return o.includes(s)||p.includes(s)||Ce.includes(s)})}return y==="oldest"?t=[...t].sort((s,l)=>new Date(s.ticket?.createdAt||0).getTime()-new Date(l.ticket?.createdAt||0).getTime()):y==="newest"?t=[...t].sort((s,l)=>new Date(l.ticket?.createdAt||0).getTime()-new Date(s.ticket?.createdAt||0).getTime()):y==="priority"&&(t=[...t].sort((s,l)=>(ie[s.ticket?.priority]??99)-(ie[l.ticket?.priority]??99))),t},[D,E,T,y]),te=async()=>
1{if(!(!a||!M.trim()||I)){J(!0);try{await d(`/support-agent/tickets/${a.id}/messages`,{method:"POST",body:JSON.stringify({message:M.trim()})}),W(""),await v(a.id)}catch(t){alert(t.message||"Failed to send message")}finally{J(!1)}}},fe=async()=>{if(a)try{await d(`/support-agent/tickets/${a.id}/resolve`,{method:"POST"}),j(t=>t&&{...t,status:"RESOLVED",resolvedAt:new Date().toISOString()}),await v(a.id),await h(),await g()}catch(t){alert(t.message||"Failed to resolve ticket")}},je=async()=>{if(a)try{await d(`/support-agent/tickets/${a.id}/close`,{method:"POST"}),j(t=>t&&{...t,status:"CLOSED",closedAt:new Date().toISOString()}),await v(a.id),await h(),await g()}catch(t){alert(t.message||"Failed to close ticket")}},ve=async t=>{if(a)try{await d(`/support-agent/tickets/${a.id}/priority`,{method:"POST",body:JSON.stringify({priority:t})}),j(s=>s&&{...s,priority:t})}catch(s){alert(s.message||"Failed to change priority")}},se=async()=>{if(!(!a||!O.trim()||R)){X(!0);try{await d(`/support-agent/tickets/${a.id}/notes`,{method:"POST",body:JSON.stringify({content:O.trim()})}),Q(""),await ee(a.id)}catch(t){alert(t.message||"Failed to add note")}finally{X(!1)}}},Ne=()=>{localStorage.removeItem("support_agent_token"),m("/_support_login")},ke=async t=>{Y(!0);const s=t.ticket?.id||t.id;j(t.ticket||t),await v(s),await ee(s),Y(!1)},ae=t=>{const s={OPEN:"bg-blue-500/15 text-blue-400 border-blue-500/30",ESCALATED:"bg-amber-500/15 text-amber-400 border-amber-500/30",RESOLVED:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",CLOSED:"bg-slate-500/15 text-slate-400 border-slate-500/30"};return e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full font-bold uppercase border ${s[t]||s.OPEN}`,"data-testid":`status-badge-${t?.toLowerCase()}`,children:t})},re=t=>{const s={LOW:"bg-slate-500/15 text-slate-400 border-slate-500/30",MEDIUM:"bg-blue-500/15 text-blue-400 border-blue-500/30",HIGH:"bg-amber-500/15 text-amber-400 border-amber-500/30",URGENT:"bg-red-500/15 text-red-400 border-red-500/30"};return e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full font-bold uppercase border ${s[t]||s.MEDIUM}`,"data-testid":`priority-badge-${t?.toLowerCase()}`,children:t})},_=t=>{if(!t)return null;const s=le[t]||le.OTHER;return e.jsx("span",{className:`px-2 py-0.5 text-[9px] rounded-full font-bold uppercase border ${s}`,"data-testid":`category-badge-${t.toLowerCase()}`,children:t.replace(/_/g," ")})},we=t=>t==="AI"?{label:"AI Support",color:"text-cyan-400",bg:"bg-cyan-500/10 border-cyan-500/20"}:t==="AGENT"?{label:"Support Agent",color:"text-indigo-400",bg:"bg-indigo-500/10 border-indigo-500/20"}:{label:"User",color:"text-violet-400",bg:"bg-violet-500/10 border-violet-500/20"},N=t=>new Date(t).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"}),k=t=>new Date(t).toLocaleTimeString("en-IN",{hour:"2-digit",minute:"2-digit"}),ye=t=>t==="URGENT"?"border-l-4 border-l-red-500":t==="HIGH"?"border-l-4 border-l-amber-500":"",Le=t=>t==="created"||t==="CREATED"?e.jsx("div",{className:"w-7 h-7 rounded-full bg-blue-500/20 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})}):t==="escalated"||t==="ESCALATED"?e.jsx("div",{className:"w-7 h-7 rounded-full bg-amber-500/20 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126z"})})}):t==="resolved"||t==="RESOLVED"?e.jsx("div",{className:"w-7 h-7 rounded-full bg-emerald-500/20 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}):t==="closed"||t==="CLOSED"?e.jsx("div",{className:"w-7 h-7 rounded-full bg-slate-500/20 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 002.25-2.25v-6.75a2.25 2.25 0 00-2.25-2.25H6.75a2.25 2.25 0 00-2.25 2.25v6.75a2.25 2.25 0 002.25 2.25z"})})}):e.jsx("div",{className:"w-7 h-7 rounded-full bg-indigo-500/20 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})});return u?e.jsx("div",{className:"min-h-screen bg-[#0a0e1a] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-10 h-10 border-2 border-blue-500 border-t-transparent roun
1ded-full animate-spin mx-auto mb-3"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Loading dashboard..."})]})}):a?e.jsxs("div",{className:"h-screen bg-[#0a0e1a] text-white flex flex-col overflow-hidden","data-testid":"ticket-detail-view",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-3 border-b border-slate-700/50 bg-[#0d1224] flex-shrink-0",children:[e.jsx("button",{onClick:()=>{j(null),V([]),G(null),q([])},className:"p-2 rounded-lg hover:bg-slate-700/50 text-slate-400 hover:text-white transition-colors","data-testid":"button-back-to-tickets",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("h2",{className:"text-sm font-semibold","data-testid":"text-ticket-id",children:["Ticket #",a.id]}),ae(a.status),_(a.category),e.jsxs("select",{value:a.priority||"MEDIUM",onChange:t=>ve(t.target.value),className:"bg-slate-800/50 border border-slate-700/50 rounded-lg px-2 py-0.5 text-[10px] text-white focus:border-blue-500/50 focus:outline-none transition-colors appearance-none cursor-pointer font-bold uppercase","data-testid":"select-priority",children:[e.jsx("option",{value:"LOW",children:"LOW"}),e.jsx("option",{value:"MEDIUM",children:"MEDIUM"}),e.jsx("option",{value:"HIGH",children:"HIGH"}),e.jsx("option",{value:"URGENT",children:"URGENT"})]})]}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5",children:["Created ",a.createdAt?$(a.createdAt):"—"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mr-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-[10px] text-emerald-400 font-medium",children:"LIVE"})]}),a.status!=="RESOLVED"&&a.status!=="CLOSED"&&e.jsx("button",{onClick:fe,className:"px-3 py-1.5 text-xs font-medium bg-emerald-500/15 text-emerald-400 border border-emerald-500/30 rounded-lg hover:bg-emerald-500/25 transition-colors","data-testid":"button-resolve-ticket",children:"Resolve"}),a.status!=="CLOSED"&&e.jsx("button",{onClick:je,className:"px-3 py-1.5 text-xs font-medium bg-slate-500/15 text-slate-400 border border-slate-500/30 rounded-lg hover:bg-slate-500/25 transition-colors","data-testid":"button-close-ticket",children:"Close"})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col border-r border-slate-700/50 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3","data-testid":"messages-container",children:[pe&&S.length===0?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"})}):S.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-slate-500 text-sm",children:"No messages yet"}):S.map(t=>{const s=we(t.sender),l=t.sender==="USER";return e.jsx("div",{className:`flex ${l?"justify-end":"justify-start"}`,"data-testid":`message-${t.sender?.toLowerCase()}-${t.id}`,children:e.jsxs("div",{className:"max-w-[75%]",children:[!l&&e.jsx("div",{className:`flex items-center gap-1.5 mb-1 ${s.color}`,children:e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",children:s.label})}),e.jsx("div",{className:`rounded-2xl px-4 py-2.5 text-sm leading-relaxed ${l?"bg-violet-500/20 text-violet-100 border border-violet-500/20 rounded-br-md":`${s.bg} border text-slate-200 rounded-bl-md`}`,children:t.content}),e.jsx("div",{className:`text-[10px] text-slate-500 mt-1 ${l?"text-right":""}`,children:k(t.createdAt)})]})},t.id)}),e.jsx("div",{ref:Z})]}),a.status!=="RESOLVED"&&a.status!=="CLOSED"&&e.jsxs("div",{className:"p-4 border-t border-slate-700/50 bg-[#0d1224] flex-shrink-0",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2","data-testid":"canned-responses",children:Me.map((t,s)=>e.jsx("button",{onClick:()=>W(t),className:"px-2.5 py-1 text-[10px] font-medium bg-slate-700/40 text-slate-300 border border-slate-600/30 rounded-full hover:bg-blue-500/15 hover:text-blue-400 hover:border-blue-500/30 transition-all","data-testid":`canned-response-${s}`,children:t},s))}),e.jsxs("div",{className:"flex gap-2","data-testid":"reply-input-container",children:[e.jsx("input",{type:"text",value:M,onChange:t=>W(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),te())},placeholder:"Type your reply...",className:"flex-1 bg-slate-800/50 border border-slate-700/50 rounded-xl px-4 py-2.5 text-sm text-white placeholder-slate-500 focus:border-blue-500/50 focus:outline-none transition-colors",disabled:I,"data-testid":"input-reply"}),e.jsx("button",{onClick:te,disabled:!M.trim()||I,className:"px-4 py-2.5 bg-gradient-to-r from-blue-500 to-indigo-600 text-white rounded-xl hover:from-blue-600 hover:to-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed transition-all","data-testid":"button-send-reply",children:I?e.jsx("div",{className:"w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin"}):e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"})})})]})]})]}),e.jsxs("div",{className:"w-80 overflow-y-auto bg-[#0d1224] p-4 flex-shrink-0","data-testid":"user-info-panel",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider mb-4",children:"User Information"}),i?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-slate-800/30 border border-slate-700/40 rounded-xl p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Name"}
1),e.jsx("p",{className:"text-sm text-white font-medium mt-0.5","data-testid":"text-user-name",children:i.fullName||i.username||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Email"}),e.jsx("p",{className:"text-sm text-slate-300 mt-0.5","data-testid":"text-user-email",children:i.email||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Mobile"}),e.jsx("p",{className:"text-sm text-slate-300 mt-0.5","data-testid":"text-user-mobile",children:i.mobileNumber||"—"})]})]}),e.jsxs("div",{className:"bg-slate-800/30 border border-slate-700/40 rounded-xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Premium"}),e.jsx("span",{className:`px-2 py-0.5 text-[10px] rounded-full font-bold ${i.isPremium?"bg-amber-500/15 text-amber-400":"bg-slate-500/15 text-slate-400"}`,"data-testid":"text-user-premium",children:i.isPremium?"YES":"NO"})]}),i.isPremium&&i.premiumPlan&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Plan"}),e.jsx("span",{className:"text-sm text-amber-400 font-medium","data-testid":"text-user-plan",children:i.premiumPlan})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Coins"}),e.jsx("span",{className:"text-sm text-white font-medium","data-testid":"text-user-coins",children:i.stoxraCoins??"—"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Balance"}),e.jsx("span",{className:"text-sm text-white font-medium","data-testid":"text-user-balance",children:i.virtualBalance!=null?`₹${Number(i.virtualBalance).toLocaleString("en-IN")}`:"—"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Total Trades"}),e.jsx("span",{className:"text-sm text-white font-medium","data-testid":"text-user-trades",children:i.totalTrades??"—"})]}),i.totalPnl!=null&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Total P&L"}),e.jsxs("span",{className:`text-sm font-medium ${Number(i.totalPnl)>=0?"text-emerald-400":"text-red-400"}`,"data-testid":"text-user-pnl",children:[Number(i.totalPnl)>=0?"+":"","₹",Number(i.totalPnl).toLocaleString("en-IN")]})]})]}),e.jsxs("div",{className:"bg-slate-800/30 border border-slate-700/40 rounded-xl p-4",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Joined"}),e.jsx("p",{className:"text-sm text-slate-300 mt-0.5","data-testid":"text-user-joined",children:i.createdAt?N(i.createdAt):"—"})]})]}):e.jsx("div",{className:"text-sm text-slate-500",children:"No user data available"}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider mb-3",children:"Ticket Info"}),e.jsxs("div",{className:"bg-slate-800/30 border border-slate-700/40 rounded-xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Priority"}),re(a.priority)]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"AI Turns"}),e.jsx("span",{className:"text-sm text-slate-300",children:a.aiTurnCount??0})]}),e.jsxs("div",{className:"pt-2 border-t border-slate-700/30",children:[e.jsx("p",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-3",children:"Status Timeline"}),e.jsxs("div",{className:"relative pl-4","data-testid":"ticket-timeline",children:[e.jsx("div",{className:"absolute left-[7px] top-1 bottom-1 w-px bg-slate-700/50"}),e.jsxs("div",{className:"relative flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded-full bg-blue-500 border-2 border-[#0d1224] z-10 flex-shrink-0 -ml-[7px]"}),e.jsxs("div",{className:"-mt-0.5",children:[e.jsx("p",{className:"text-[10px] text-blue-400 font-semibold",children:"Created"}),e.jsx("p",{className:"text-[10px] text-slate-500",children:a.createdAt?N(a.createdAt)+" "+k(a.createdAt):"—"})]})]}),a.escalatedAt&&e.jsxs("div",{className:"relative flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded-full bg-amber-500 border-2 border-[#0d1224] z-10 flex-shrink-0 -ml-[7px]"}),e.jsxs("div",{className:"-mt-0.5",children:[e.jsx("p",{className:"text-[10px] text-amber-400 font-semibold",children:"Escalated"}),e.jsx("p",{className:"text-[10px] text-slate-500",children:N(a.escalatedAt)+" "+k(a.escalatedAt)})]})]}),a.resolvedAt&&e.jsxs("div",{className:"relative flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded-full bg-emerald-500 border-2 border-[#0d1224] z-10 flex-shrink-0 -ml-[7px]"}),e.jsxs("div",{className:"-mt-0.5",children:[e.jsx("p",{className:"text-[10px] text-emerald-400 font-semibold",children:"Resolved"}),e.jsx("p",{className:"text-[10px] text-slate-500",children:N(a.resolvedAt)+" "+k(a.resolvedAt)})]})]}),a.closedAt&&e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded-full bg-slate-500 border-2 border-[#0d1224] z-10 flex-shrink-0 -ml-[7px]"}),e.jsxs("div",{className:"-mt-0.5",children:[e.jsx("p",{className:"text-[10px] text-slate-400 font-semibold",children:"Closed"}),e.jsx("p",{className:"text-[10px] text-slate-500",children:N(a.closedAt)+" "+k(a.closedAt)})]})]}),!a.closedAt&&!a.resolvedAt&&e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx("div",{className:"w-3.5 h-3.5 rounded-full bg-slate-700 border-2 border-dashed border-slate-600 z-10 flex-shrink-0 -ml-[7px]"}),e.jsx("div",{className:"-mt-0.5",children:e.jsx("p",{className:"text-[10px] text-slate-600 font-semibold",children:"Pending..."})})]})]})]})]})]}),e.jsxs("div",{className:"mt-6","data-testid":"notes-section",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-400/80 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"})}),"Internal Notes"]}),e.jsx("div",{className:"space-y-2 mb-3 max-h-48 overflow-y-auto",children:K.length===0?e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:"No notes yet"}):K.map((t,s)=>e.jsxs("div",{className:"bg-amber-500/5 border border-amber-500/15 rounded-lg p-2.5","data-testid":`note-${t.id||s}`,children:[e.jsx("p",{className:"text-[11px] text-amber-200/80 leading-relaxed",children:t.content}),e.jsxs("p",{className:"text-[9px] text-amber-500/40 mt-1",children:[t.createdAt?N(t.createdAt)+" "+k(t.createdAt):"",t.agentUsername?` • ${t.agentUsername}`:""]})]},t.id||s))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{type:"text",value:O,onChange:t=>Q(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),se())},placeholder:"Add internal note...",className:"flex-1 bg-amber-500/5 border border-amber-500/20 rounded-lg px-3 py-1.5 text-[11px] text-amber-100 placeholder-amber-500/30 focus:border-amber-500/40 focu
1s:outline-none transition-colors",disabled:R,"data-testid":"input-note"}),e.jsx("button",{onClick:se,disabled:!O.trim()||R,className:"px-2.5 py-1.5 bg-amber-500/15 text-amber-400 border border-amber-500/30 rounded-lg hover:bg-amber-500/25 disabled:opacity-50 disabled:cursor-not-allowed transition-colors text-[10px] font-medium","data-testid":"button-add-note",children:R?"...":"Add"})]})]})]})]})]}):e.jsxs("div",{className:"min-h-screen bg-[#0a0e1a] flex","data-testid":"support-agent-dashboard",children:[e.jsxs("div",{className:"w-56 bg-[#0d1224] border-r border-slate-700/50 flex flex-col flex-shrink-0","data-testid":"sidebar",children:[e.jsx("div",{className:"p-4 border-b border-slate-700/50",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center shadow-lg shadow-blue-500/20",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.364 5.636l-3.536 3.536m0 5.656l3.536 3.536M9.172 9.172L5.636 5.636m3.536 9.192l-3.536 3.536M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-5 0a4 4 0 11-8 0 4 4 0 018 0z"})})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("h1",{className:"text-sm font-bold text-white",children:"Support"}),e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"})})]}),e.jsx("p",{className:"text-[10px] text-slate-400",children:"Agent Portal"})]})]})}),e.jsxs("nav",{className:"flex-1 p-2 space-y-1",children:[e.jsxs("button",{onClick:()=>{b("dashboard"),g(),L()},className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors ${x==="dashboard"?"bg-blue-500/15 text-blue-400":"text-slate-400 hover:bg-slate-700/30 hover:text-white"}`,"data-testid":"tab-dashboard",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z"})}),"Dashboard"]}),e.jsxs("button",{onClick:()=>{b("tickets"),h()},className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors ${x==="tickets"?"bg-blue-500/15 text-blue-400":"text-slate-400 hover:bg-slate-700/30 hover:text-white"}`,"data-testid":"tab-tickets",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 6v.75m0 3v.75m0 3v.75m0 3V18m-9-5.25h5.25M7.5 15h3M3.375 5.25c-.621 0-1.125.504-1.125 1.125v3.026a2.999 2.999 0 010 5.198v3.026c0 .621.504 1.125 1.125 1.125h17.25c.621 0 1.125-.504 1.125-1.125v-3.026a2.999 2.999 0 010-5.198V6.375c0-.621-.504-1.125-1.125-1.125H3.375z"})}),"Tickets",B>0&&e.jsx("span",{className:"ml-auto text-[10px] bg-blue-500/20 text-blue-400 px-1.5 py-0.5 rounded-full font-bold",children:B})]})]}),e.jsxs("div",{className:"p-2 border-t border-slate-700/50",children:[n&&e.jsxs("div",{className:"px-3 py-2 mb-2",children:[e.jsx("p",{className:"text-xs text-white font-medium truncate","data-testid":"text-agent-name",children:n.username||n.email}),e.jsx("p",{className:"text-[10px] text-slate-500 truncate",children:n.email})]}),e.jsxs("button",{onClick:Ne,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium text-red-400 hover:bg-red-500/10 transition-colors","data-testid":"button-logout",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15m3 0l3-3m0 0l-3-3m3 3H9"})}),"Logout"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto relative",children:[ge&&e.jsx("div",{className:"absolute top-0 left-0 right-0 z-50 flex justify-center","data-testid":"new-ticket-notification",children:e.jsxs("div",{className:"mt-4 px-5 py-2.5 bg-blue-500/20 border border-blue-500/30 rounded-xl text-sm text-blue-300 font-medium backdrop-blur-sm flex items-center gap-2 shadow-lg shadow-blue-500/10",children:[e.jsx("span",{children:"🔔"}),e.jsx("span",{children:"New ticket received!"}),e.jsx("button",{onClick:()=>U(!1),className:"ml-2 text-blue-400 hover:text-white",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),x==="dashboard"&&e.jsxs("div",{className:"p-6","data-testid":"dashboard-tab",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-lg font-bold text-white",children:"Dashboard Overview"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{b("tickets"),P("ESCALATED"),h()},className:"px-3 py-1.5 text-[11px] font-medium bg-amber-500/10 text-amber-400 border border-amber-500/25 rounded-lg hover:bg-amber-500/20 transition-colors","data-testid":"button-view-escalated",children:"View Escalated"}),e.jsx("button",{onClick:()=>{b("tickets"),P("OPEN"),h()},className:"px-3 py-1.5 text-[11px] font-medium bg-blue-500/10 text-blue-400 border border-blue-500/25 rounded-lg hover:bg-blue-500/20 transition-colors","data-testid":"button-view-open",children:"View Open"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-[10px] text-emerald-400 font-medium",children:"LIVE"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 ga
1p-4 mb-4",children:[e.jsxs("div",{className:"bg-[#0d1224] border border-blue-500/20 rounded-xl p-4","data-testid":"stat-open",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 13.5h3.86a2.25 2.25 0 012.012 1.244l.256.512a2.25 2.25 0 002.013 1.244h3.218a2.25 2.25 0 002.013-1.244l.256-.512a2.25 2.25 0 012.013-1.244h3.859"})})})}),e.jsx("p",{className:"text-2xl font-bold text-blue-400",children:f?.open??0}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"Open"})]}),e.jsxs("div",{className:"bg-[#0d1224] border border-amber-500/20 rounded-xl p-4","data-testid":"stat-escalated",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-amber-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})})}),e.jsx("p",{className:"text-2xl font-bold text-amber-400",children:f?.escalated??0}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"Escalated"})]}),e.jsxs("div",{className:"bg-[#0d1224] border border-emerald-500/20 rounded-xl p-4","data-testid":"stat-resolved",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("p",{className:"text-2xl font-bold text-emerald-400",children:f?.resolved??0}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"Resolved"})]}),e.jsxs("div",{className:"bg-[#0d1224] border border-slate-500/20 rounded-xl p-4","data-testid":"stat-closed",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-slate-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5m8.25 3v6.75m0 0l-3-3m3 3l3-3M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z"})})})}),e.jsx("p",{className:"text-2xl font-bold text-slate-400",children:f?.closed??0}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"Closed"})]}),e.jsxs("div",{className:"bg-[#0d1224] border border-indigo-500/20 rounded-xl p-4","data-testid":"stat-total",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-indigo-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"})})})}),e.jsx("p",{className:"text-2xl font-bold text-indigo-400",children:f?.total??0}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"Total"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-8",children:[e.jsxs("div",{className:"bg-[#0d1224] border border-cyan-500/20 rounded-xl p-4","data-testid":"stat-avg-response",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-cyan-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("p",{className:"text-2xl font-bold text-cyan-400",children:Ee(c?.avgResponseTime??0)}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"Avg Response"})]}),e.jsxs("div",{className:"bg-[#0d1224] border border-violet-500/20 rounded-xl p-4","data-testid":"stat-today",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-violet-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-violet-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5"})})})}),e.jsx("p",{className:"text-2xl font-bold text-violet-400",children:c?.todayTickets??0}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"Today's Tickets"})]}),e.jsxs("div",{className:"bg-[#0d1224] border border-pink-500/20 rounded-xl p-4","data-testid":"stat-week",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-pink-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-pink-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75z"})})})}),e.jsx("p",{className:"text-2xl font-bold text-pink-400",children:c?.thisWeekTickets??0}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"This Week"})]}),e.jsxs("div",{className:"bg-[#0d1224] border border-emerald-500/20 rounded-xl p-4","data-testid":"stat-resolution-rate",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-500/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 18L9 11.25l4.306 4.307a11.95 11.95 0 015.814-5.519l2.74-1.22m0 0l-5.94-2.28m5.94 2.28l-2.28 5.941"})})})}),e.jsx("p",{className:"text-2xl font-bold text-emerald-400",children:c?.resolutionRate!=null?`${Math.round(c.resolutionRate)}%`:"—"}),e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider mt-1",children:"Resolution Rate"}),c?.resolutionRate!=null&&e.jsx("div",{className:"mt-2 h-1.5 bg-slate-800 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-emerald-500 to-emerald-400 rounded-full transition-all duration-700",style:{width:`${Math.min(100,Math.round(c.resolutionRate))}%`}})})]})]}),c?.categoryBreakdown&&c.categoryBreakdown.length>0&&e.jsxs("div",{className:"bg-[#0d1224] border border-slate-700/40 rounded-xl p-5 mb-6","data-testid":"category-breakdown",children:[e.jsx("h3",{className:"text-sm font-semibold text-white mb-4",children:"Category Breakdown"}),e.jsx("div",{className:"space-y-3",children:(()=>{const t=c.categoryBreakdown,s=Math.max(...t.map(l=>l.count),1);return[...t].sort((l,o)=>o.count-l.count).map(l=>e.jsxs("div",{className:"flex items-center gap-3","data-testid":`category-bar-${l.category.toLowerCase()}`,children:[e.jsx("span",{className:"text-[10px] text-slate-400 uppercase tracking-wider w-28 text-right flex-shrink-0 truncate",children:l.category.replace(/_/g," ")}),e.jsx("div",{className:"flex-1 h-5 bg-slate-800/50 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-700 ${Te[l.category]||"bg-slate-500"}`,style:{width:`${Math.max(4,l.count/s*100)}%`,opacity:.8}})}),e.jsx("span",{className:"text-xs text-slate-300 font-medium w-8 text-right",children:l.count})]},l.category))})()})]}),c?.recentActivity&&c.recentActivity.length>0&&e.jsxs("div",{className:"bg-[#0d1224] border border-slate-700/40 rounded-xl p-5","data-testid":"recent-activity",children:[e.jsx("h3",{className:"text-sm font-semibold text-white mb-4",children:"Recent Activity"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-[13px] top-0 bottom-0 w-px bg-slate-700/40"}),e.jsx("div",{className:"space-y-4",children:c.recentActivity.slice(0,20).map((t,s)=>e.jsxs("div",{className:"relative flex items-start gap-3 pl-0","data-testid":`activity-event-${s}`,children:[Le(t.type||t.action),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-[11px] text-white font-medium",children:["Ticket #",t.ticketId]}),e.jsx("span",{className:"text-[10px] text-slate-500 capitalize",children:(t.type||t.action||"").toLowerCase()}),t.category&&_(t.category)]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.userEmail&&e.jsx("span",{className:"text-[10px] text-slate-500 truncate",children:t.userEmail}),t.timestamp&&e.jsx("span",{className:"text-[10px] text-slate-600",children:$(t.timestamp)})]})]})]},s))})]})]})]}),x==="tickets"&&e.jsxs("div",{className:"p-6","data-testid":"tickets-tab",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-bold text-white",children:"All Tickets"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-[10px] text-emerald-400 font-medium",children:"LIVE"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-5",children:[e.jsx("input",{type:"text",value:T,onChange:t=>ue(t.target.value),placeholder:"Search by email, username or ticket ID...",className:"flex-1 min-w-[200px] max-w-sm bg-slate-800/50 border border-slate-700/50 rounded-lg px-3 py-2 text-sm text-white placeholder-slate-500 focus:border-blue-500/50 focus:outline-none transition-colors","data-testid":"input-search-tickets"}),e.jsxs("select",{value:A,onChange:t=>P(t.target.value),className:"bg-slate-800/50 border border-slate-700/50 rounded-lg px-3 py-2 text-sm text-white focus:border-blue-500/50 focus:outline-none transition-colors appearance-none cursor-pointer","data-testid":"select-status-filter",children:[e.jsx("option",{value:"ALL",children:"All Status"}),e.jsx("option",{value:"OPEN",children:"Open"}),e.jsx("option",{value:"ESCALATED",children:"Escalated"}),e.jsx("option",{value:"RESOLVED",children:"Resolved"}),e.jsx("option",{value:"CLOSED",children:"Closed"})]}),e.jsxs("select",{value:E,onChange:t=>me(t.target.value),className:"bg-slate-800/50 border border-slate-700/50 rounded-lg px-3 py-2 text-sm text-white focus:border-blue-500/50 focus:outline-none transition-colors appearance-none cursor-pointer","data-testid":"select-category-filter",children:[e.jsx("option",{value:"ALL",children:"All Categories"}),Se.map(t=>e.jsx("option",{value:t,children:t.replace(/_/g," ")},t))]}),e.jsxs("select",{value:y,onChange:t=>he(t.target.value),className:"bg-slate-800/50 border border-slate-700/50 rounded-lg px-3 py-2 text-sm text-white focus:border-blue-500/50 focus:outline-none transition-colors appearance-none cursor-pointer","data-testid":"select-sort-order",children:[e.jsx("option",{value:"newest",children:"Newest First"}),e.jsx("option",{value:"oldest",children:"Oldest First"}),e.jsx("option",{value:"priority",children:"Priority (High to Low)"})]}),e.jsxs("span",{className:"text-xs text-slate-500",children:[z.length," of ",B," tickets"]})]}),xe&&D.length===0?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-2 border-blue-500 border-t-transparent roun
1ded-full animate-spin"})}):z.length===0?e.jsxs("div",{className:"text-center py-20",children:[e.jsx("svg",{className:"w-12 h-12 text-slate-600 mx-auto mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5m8.25 3v6.75m0 0l-3-3m3 3l3-3M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z"})}),e.jsx("p",{className:"text-slate-500 text-sm",children:"No tickets found"})]}):e.jsx("div",{className:"space-y-2",children:z.map(t=>{const s=t.ticket,l=t.user;if(!s)return null;const o=t.lastMessageSender==="USER"&&(s.status==="OPEN"||s.status==="ESCALATED"),p=o&&t.lastMessageAt?$(t.lastMessageAt):null;return e.jsx("button",{onClick:()=>ke(t),className:`w-full text-left bg-[#0d1224] border border-slate-700/40 rounded-xl p-4 hover:border-blue-500/30 transition-all group ${ye(s.priority)}`,"data-testid":`ticket-row-${s.id}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[o&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 flex-shrink-0","data-testid":`unread-indicator-${s.id}`}),e.jsxs("span",{className:"text-sm font-semibold text-white group-hover:text-blue-400 transition-colors",children:["#",s.id]}),ae(s.status),_(s.category),re(s.priority)]}),e.jsx("div",{className:"flex items-center gap-2 text-xs text-slate-400 mb-1.5",children:l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-slate-300","data-testid":`ticket-user-email-${s.id}`,children:l.email||"—"}),e.jsx("span",{className:"text-slate-600",children:"•"}),e.jsx("span",{"data-testid":`ticket-user-name-${s.id}`,children:l.username||"—"})]})}),t.lastMessage&&e.jsx("p",{className:"text-xs text-slate-500 truncate","data-testid":`ticket-last-message-${s.id}`,children:t.lastMessage})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[e.jsx("span",{className:"text-[10px] text-slate-500","data-testid":`ticket-time-${s.id}`,children:s.createdAt?$(s.createdAt):"—"}),p&&e.jsxs("span",{className:"text-[9px] text-blue-400 font-medium","data-testid":`ticket-waiting-${s.id}`,children:["Waiting ",p]}),e.jsx("svg",{className:"w-4 h-4 text-slate-600 group-hover:text-blue-400 transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})]})]})},s.id)})})]})]})]})}export{Re 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.