1import{t as i,r as x,s as h,j as e,B as o,O as k,Q as y,X as w,C}from"./index-DDGD9a83.js";import{L as S}from"./life-buoy-i1N5-Tz1.js";import{S as j}from"./shield-alert-B6pBwB9b.js";import{L as A}from"./lightbulb-Cc7zjwee.js";import{C as g}from"./circle-check-DR5TkXei.js";import{C as R}from"./clock-CpuPH2st.js";const E="34690153080";function b({status:a}){const r={abierto:{icon:R,label:"Abierto",cls:"bg-amber-500/15 text-amber-400 border-amber-500/30"},escalado:{icon:j,label:"Escalado",cls:"bg-orange-500/15 text-orange-400 border-orange-500/30"},resuelto:{icon:g,label:"Resuelto",cls:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30"}}[a]??{icon:C,label:a,cls:"bg-muted text-muted-foreground border-border"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold border ${r.cls}`,children:[e.jsx(r.icon,{className:"w-3 h-3"}),r.label]})}function T({severity:a}){const r={baja:"bg-slate-400",media:"bg-amber-400",alta:"bg-orange-500",critica:"bg-red-500"}[a]??"bg-slate-400";return e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${r}`,title:a})}function M(){const a=i.useUtils(),[r,m]=x.useState("soporte"),[f,d]=x.useState(null),n=i.support.listTickets.useQuery({ticketType:r}),p=i.support.setTicketStatus.useMutation({onSuccess:(s,c)=>{a.support.listTickets.invalidate(),a.support.openCount.invalidate(),h.success(c.resolved?"Marcado como resuelto":"Reabierto")},onError:s=>h.error(s.message)}),N=i.support.markEscalated.useMutation({onSuccess:()=>a.support.listTickets.invalidate()});x.useEffect(()=>{const s=new URLSearchParams(window.location.search).get("ticket");s&&d(Number(s))},[]);const l=n.data??[],u=l.filter(s=>!s.resolvedAt).length,v=l.length-u,t=l.find(s=>s.id===f)??null;return e.jsxs("div",{className:"min-h-screen bg-background text-foreground p-4 sm:p-6",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-emerald-500/15 border border-emerald-500/30 flex items-center justify-center",children:e.jsx(S,{className:"w-5 h-5 text-emerald-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Incidencias y sugerencias"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Reportadas desde el chat de AYUDA de la plataforma"})]})]})}),e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsxs("button",{onClick:()=>m("soporte"),className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition-colors ${r==="soporte"?"bg-primary text-primary-foreground border-primary":"border-border hover:bg-accent"}`,children:[e.jsx(j,{className:"w-4 h-4"})," Soporte"]}),e.jsxs("button",{onClick:()=>m("sugerencia"),className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition-colors ${r==="sugerencia"?"bg-primary text-primary-foreground border-primary":"border-border hover:bg-accent"}`,children:[e.jsx(A,{className:"w-4 h-4"})," Sugerencias"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[u," abiertas"]}),e.jsxs("span",{children:[v," resueltas"]})]})]}),e.jsx("div",{className:"rounded-xl border border-border overflow-x-auto",children:n.isLoading?e.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:"Cargandoâ¦"}):n.error?e.jsx("div",{className:"p-8 text-center text-sm text-red-400",children:n.error.message}):l.length===0?e.jsxs("div",{className:"p-8 text-center text-sm text-muted-foreground",children:["No hay ",r==="soporte"?"incidencias":"sugerencias"," todavÃa."]}):e.jsxs("table",{className:"w-full min-w-[640px] text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-xs uppercase text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left font-medium px-3 py-2 w-14",children:"#"}),e.jsx("th",{className:"text-left font-medium px-3 py-2",children:"Asunto"}),e.jsx("th",{className:"text-left font-medium px-3 py-2 w-40",children:"Reporta"}),e.jsx("th",{className:"text-left font-medium px-3 py-2 w-28",children:"Ãrea"}),e.jsx("th",{className:"text-left font-medium px-3 py-2 w-28",children:"Estado"}),e.jsx("th",{className:"text-right font-medium px-3 py-2 w-56",children:"Acciones"})]})}),e.jsx("tbody",{children:l.map(s=>e.jsxs("tr",{className:"border-t border-border hover:bg-accent/30",children:[e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted-foreground",children:s.id}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("button",{className:"text-left hover:underline flex items-center gap-2",onClick:()=>
1d(s.id),children:[e.jsx(T,{severity:s.severity}),e.jsx("span",{className:"line-clamp-1",children:s.title})]})}),e.jsxs("td",{className:"px-3 py-2 text-xs",children:[s.reporterName,e.jsxs("span",{className:"text-muted-foreground",children:[" · ",s.reporterRole]})]}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:s.area}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(b,{status:s.ticketStatus})}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"flex items-center justify-end gap-1.5",children:s.resolvedAt?e.jsxs(o,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs",onClick:()=>p.mutate({ticketId:s.id,resolved:!1}),children:[e.jsx(k,{className:"h-3 w-3 mr-1"})," Reabrir"]}):e.jsxs(e.Fragment,{children:[e.jsxs(o,{size:"sm",className:"h-7 px-2 text-xs",onClick:()=>p.mutate({ticketId:s.id,resolved:!0}),children:[e.jsx(g,{className:"h-3 w-3 mr-1"})," Resuelto"]}),e.jsxs(o,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs border-emerald-300 text-emerald-600 hover:bg-emerald-50 dark:border-emerald-700 dark:text-emerald-400 dark:hover:bg-emerald-950",onClick:()=>{window.open(`https://wa.me/${E}?text=${encodeURIComponent(s.whatsappText)}`,"_blank"),N.mutate({ticketId:s.id})},children:[e.jsx(y,{className:"h-3 w-3 mr-1"})," Escalar"]})]})})})]},s.id))})]})}),t&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",onClick:()=>d(null),children:e.jsxs("div",{className:"bg-background border border-border rounded-2xl max-w-2xl w-full max-h-[85vh] overflow-y-auto",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start gap-3 p-4 border-b border-border sticky top-0 bg-background",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["#",t.id," · ",t.ticketType]}),e.jsx("h2",{className:"text-lg font-semibold",children:t.title})]}),e.jsx(b,{status:t.ticketStatus}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d(null),children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 space-y-4 text-sm",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Reporta:"})," ",t.reporterName," (",t.reporterRole,")"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Gravedad:"})," ",t.severity]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Ãrea:"})," ",t.area]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Ruta:"})," ",e.jsx("code",{children:t.route??"â"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Creada:"})," ",new Date(t.createdAt).toLocaleString("es-ES")]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Aviso enviado:"})," ",t.notifiedOwner?"sÃ":"no"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Descripción"}),e.jsx("p",{className:"whitespace-pre-wrap",children:t.description})]}),t.clientContext&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Entorno"}),e.jsx("pre",{className:"text-[11px] bg-muted/40 rounded-lg p-2 overflow-x-auto",children:JSON.stringify(t.clientContext,null,2)})]}),Array.isArray(t.transcript)&&t.transcript.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Conversación"}),e.jsx("div",{className:"space-y-2",children:t.transcript.map((s,c)=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("span",{className:"font-semibold",children:[s.role==="user"?"Usuario":"IA",":"]})," ",e.jsx("span",{className:"whitespace-pre-wrap",children:s.content})]},c))})]})]})]})})]})}export{M 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.