1import{j as e,aa as T,bf as w,a9 as E,r as m,ak as S,B as p}from"./index-DJiHigX-.js";import{C}from"./CardSkeleton-Dh76d4vu.js";import{T as I,c as D,b as O,h as g}from"./tickets-D5bCPqRt.js";import{N as v}from"./NewTicketDialog-C5q-6nvn.js";import{P as _}from"./plus-B_N4XATu.js";import{M}from"./message-circle-BggiNHnq.js";import"./skeleton-CUWRsSiE.js";import"./uploadFile-DhxIpWiK.js";import"./select-CklBS6zl.js";import"./chevron-up-BejfMGdi.js";import"./alert-circle-CN78cECc.js";import"./paperclip-aOXFoDZi.js";import"./image-DOmipmdZ.js";import"./film-C1ti62T5.js";import"./music-BPNZi8rC.js";import"./archive-at54Svtj.js";import"./file-text-DgRBq24l.js";import"./file-Mp4gNAiP.js";const f={LOW:"bg-gray-400",MEDIUM:"bg-yellow-400",HIGH:"bg-orange-500",URGENT:"bg-red-500 animate-pulse"},h={LOW:"bg-gray-500/15 text-gray-400 border-gray-500/30",MEDIUM:"bg-yellow-500/15 text-yellow-300 border-yellow-500/30",HIGH:"bg-orange-500/15 text-orange-400 border-orange-500/30",URGENT:"bg-red-500/20 text-red-400 border-red-500/40"},b={OPEN:"bg-kstudio-accent/20 text-kstudio-accent border-kstudio-accent/30",IN_PROGRESS:"bg-blue-500/20 text-blue-400 border-blue-500/30",WAITING_CUSTOMER:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",RESOLVED:"bg-green-500/20 text-green-400 border-green-500/30",CLOSED:"bg-gray-500/20 text-gray-400 border-gray-500/30"};function A(t){const i=Date.now(),n=new Date(t).getTime(),o=i-n,r=Math.floor(o/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const c=Math.floor(r/60);if(c<24)return`${c}h ago`;const d=Math.floor(c/24);return d<30?`${d}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function R({ticket:t,onClick:i}){const n=f[t.priority]||f.MEDIUM,o=b[t.status]||b.OPEN,r=h[t.priority]||h.MEDIUM;return e.jsx("button",{onClick:i,className:"w-full text-left bg-kstudio-card border border-kstudio-border rounded-xl px-5 py-4 hover:border-kstudio-accent/30 transition-colors",children:e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 mt-1.5 ${n}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:"text-xs font-mono text-kstudio-accent flex-shrink-0",children:t.ticketNumber}),e.jsx("h3",{className:"text-sm font-medium text-white truncate",children:t.subject})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-kstudio-light/50 flex-wrap mt-1.5",children:[e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border ${o}`,children:I[t.status]||t.status}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border ${r}`,children:D[t.priority]||t.priority}),e.jsx("span",{className:"text-kstudio-light/30",children:"·"}),e.jsx("span",{children:t.orderNumber?`Order #${t.orderNumber}`:O[t.category]||"General"}),e.jsx("span",{className:"text-kstudio-light/30",children:"·"}),e.jsx("span",{children:A(t.updatedAt)})]})]})]})})})}const L=180*1e3,st=()=>{const{user:t}=T(),{toast:i}=w(),n=E(),[o,r]=m.useState([]),[c,d]=m.useState(!0),[k,x]=m.useState(!1);m.useEffect(()=>{if(!(t!=null&&t.id))return;const s=new AbortController,u=`kstudio_tickets_${t.id}`;return(async()=>{try{const a=sessionStorage.getItem(u);if(a){const{data:l,timestamp:j}=JSON.parse(a);Date.now()-j<L&&(l==null?void 0:l.length)>0&&(r(l),d(!1))}}catch{}try{const a=await g();a.ok&&!s.signal.aborted&&(r(a.tickets||[]),sessionStorage.setItem(u,JSON.stringify({data:a.tickets||[],timestamp:Date.now()})))}catch(a){(a==null?void 0:a.name)!=="AbortError"&&i({variant:"destructive",title:"Error",description:"Failed to load tickets"})}finally{s.signal.aborted||d(!1)}})(),()=>s.abort()},[t==null?void 0:t.id]);const y=async()=>{try{const s=await g();s.ok&&(r(s.tickets||[]),t!=null&&t.id&&sessionStorage.setItem(`kstudio_tickets_${t.id}`,JSON.stringify({data:s.tickets||[],timestamp:Date.now()})))}catch{}},N=async()=>{t!=null&&t.id&&sessionStorage.removeItem(`kstudio_tickets_${t.id}`),await y()};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(S,{children:e.jsx("title",{children:"My support tickets - KSTUDIO"})}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"My support tickets"}),e.jsxs(p,{onClick:()=>x(!0),className:"bg-kstudio-accent text-kstudio-dark hover:bg-kstudio-accent/90",children:[e.jsx(_,{className:"w-4 h-4 mr-2"}),"New Ticket"]})]}),c?e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx(C,{},s))}):o.length===0?e.jsxs("div",{className:"bg-kstudio-card border border-kstudio-border rounded-xl p-8 text-center",children:[e.jsx(M,{className:"w-12 h-12 text-kstudio-light/20 mx-auto mb-3"}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No tickets yet"}),e.jsx("p",{className:"text-kstudio-light/60 mb-4",children:"Need help? Create a support ticket."}),e.jsx(p,{onClick:()=>x(!0),className:"bg-kstudio-accent text-kstudio-dark hover:bg-kstudio-accent/90",children:"Create Support Ticket"})]}):e.jsx("div",{className:"space-y-4",children:o.map(s=>e.jsx(R,{ticket:s,onClick:()=>n(`/dashboard/support/${s.id}`)},s.id))}),e.jsx(v,{open:k,onOpenChange:x,onCreated:N})]})};export{st 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.