1import{r as a,j as e}from"./vendor-react-zwv87yMD.js";import{u as _,a as F,b as E}from"./vendor-query-DYq8g7OI.js";import{T as P,a as z,b as v,c as y}from"./tabs-Dd8Qm6LV.js";import{B as N}from"./button-DlBDuKbo.js";import{B as L}from"./badge-QivbhJml.js";import{D as H,a as V,b as $,c as Q,d as G}from"./dialog-CCoQRIQ_.js";import{s as D}from"./support-qHMxzBhh.js";import{h as K}from"./knowledge-base-wqH4zyrY.js";import{u as W}from"./authStore-Bv6p2Ne2.js";import{u as U}from"./useOrgTimezone-C1UagyKl.js";import{c as A}from"./vendor-router-DimZLiZb.js";import"./vendor-charts-CtrTLS4K.js";import"./vendor-i18n-BdYkS11p.js";import"./vendor-ui-CfDMlrKu.js";import"./vendor-pdf-DQuePnfN.js";import"./vendor-state-ByI9XJey.js";import"./vendor-editor-C_dhmuey.js";import"./utils-BXSzAfFa.js";import"./vendor-icons-bLSWzydc.js";import"./api-client-wl3SCNAO.js";import"./i18n-CwjSIy0a.js";import"./employeeAuthStore-lYSKMuhw.js";const Y={urgent:"bg-red-100 text-red-800 border-red-200",high:"bg-orange-100 text-orange-800 border-orange-200",normal:"bg-blue-100 text-blue-800 border-blue-200",low:"bg-gray-100 text-gray-800 border-gray-200"},Z={open:"bg-green-100 text-green-800 border-green-200",in_progress:"bg-blue-100 text-blue-800 border-blue-200",pending:"bg-yellow-100 text-yellow-800 border-yellow-200",resolved:"bg-purple-100 text-purple-800 border-purple-200",closed:"bg-gray-100 text-gray-800 border-gray-200"},J=[{value:"billing",label:"Billing & Payments"},{value:"technical",label:"Technical Issue"},{value:"account",label:"Account Management"},{value:"feature_request",label:"Feature Request"},{value:"other",label:"General Question"}];function ye(){const c=A(),p=_(),{currentOrganizationId:n}=W(),[l,t]=a.useState("all"),[i,d]=a.useState(!1),[r,o]=a.useState({subject:"",description:"",category:"other",priority:"normal"}),[x,u]=a.useState([]),[h,C]=a.useState(!1),[g,k]=a.useState(!1),S=a.useCallback(async(s,O,I)=>{const T=`${s} ${O}`.trim();if(T.length<10){u([]);return}C(!0);try{const R=await K.searchForSupport(T,I,5);u(R)}catch{u([])}finally{C(!1)}},[]);a.useEffect(()=>{if(g||!i)return;const s=setTimeout(()=>{S(r.subject,r.description,r.category)},500);return()=>clearTimeout(s)},[r.subject,r.description,r.category,i,g,S]),a.useEffect(()=>{i&&(k(!1),u([]))},[i]);const{data:m=[],isLoading:b}=F({queryKey:["support-tickets",n],queryFn:()=>D.getMyTickets(),enabled:!!n}),f=E({mutationFn:D.createTicket,onSuccess:s=>{p.invalidateQueries({queryKey:["support-tickets",n]}),d(!1),o({subject:"",description:"",category:"general",priority:"normal"}),c(`/dashboard/support/${s.id}`)}}),q=s=>{s.preventDefault(),f.mutate(r)},j=m.filter(s=>l==="open"?["open","in_progress","pending"].includes(s.status):l==="resolved"?["resolved","closed"].includes(s.status):!0),M=m.filter(s=>["open","in_progress","pending"].includes(s.status)).length,B=m.filter(s=>["resolved","closed"].includes(s.status)).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold",children:"Support"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground mt-1",children:"View and manage your support requests"})]}),e.jsx(N,{onClick:()=>d(!0),className:"self-start",children:"+ New Ticket"})]}),e.jsxs(P,{value:l,onValueChange:s=>t(s),children:[e.jsxs(z,{children:[e.jsxs(v,{value:"all",children:["All (",m.length,")"]}),e.jsxs(v,{value:"open",children:["Open (",M,")"]}),e.jsxs(v,{value:"resolved",children:["Resolved (",B,")"]})]}),e.jsx(y,{value:"all",children:e.jsx(w,{tickets:j,isLoading:b})}),e.jsx(y,{value:"open",children:e.jsx(w,{tickets:j,isLoading:b})}),e.jsx(y,{value:"resolved",children:e.jsx(w,{tickets:j,isLoading:b})})]}),e.jsx(H,{open:i,onOpenChange:d,children:e.jsxs(V,{className:"max-w-lg",children:[e.jsx($,{children:e.jsx(Q,{children:"Create Support Ticket"})}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Subject *"}),e.jsx("input",{type:"text",value:r.subject,onChange:s=>o({...r,subject:s.target.value}),className:"w-full px-3 py-2 border rounded-md",placeholder:"Brief description of your issue",required:!0,minLength:5,maxLength:200})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Category *"}),e.jsx("select",{value:r.category,onChange:s=>o({...r,category:s.target.value}),className:"w-full px-3 py-2 border rounded-md",required:!0,children:J.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Priority"}),e.jsxs("select",{value:r.priority,onChange:s=>o({...r,priority:s.target.value}),className:"w-full px-3 py-2 border rounded-md",children:[e.jsx("option",{value:"low",children:"Low - General question"}),e.jsx("option",{value:"normal",children:"Normal - Need assistance"}),e.jsx("option",{value:"high",children:"High - Affecting my work"}),e.jsx("option",{value:"urgent",children:"Urgent - Critical issue"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Description *"}),e.jsx("textarea",{value:r.description,onChange:s=>o({...r,description:s.target.value}),className:"w-full px-3 py-2 border rounded-md",rows:5,placeholder:"Please describe your issue in detail. Include any error messages, steps to reproduce, or relevant information.",required:!0,minLength:20,maxLength:5e3})]}),!g&&(x.length>0||h)&&e.jsxs("div",{className:"border rounded-lg bg-blue-50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-5 h-5 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"font-medium text-blue-900",children:h?"Searching for helpful articles...":"These articles might help"})]}),e.jsx("button",{type:"button",onClick:()=>k(!0),className:"text-sm text-blue-600 hover:text-blue-800",children:"Dismiss"})]}),!h&&x.length>0&&e.jsxs("div",{className:"space-y-2",children:[x.map(s=>e.jsx("a",{href:`/help/articles/${s.slug}`,target:"_blank",rel:"noopener noreferrer",className:"block p-3 bg-white rounded-md border hover:border-blue-300 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-blue-500 mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-gray-900 line-clamp-1",children:s.title}),s.excerpt&&e.jsx("p",{className:"text-xs text-gray-500 mt-0.5 line-clamp-2",children:s.excerpt})]}),e.jsx("svg",{className:"w-4 h-4 text-gray-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},s.id)),e.jsx("p",{className:"text-xs text-blue-700 mt-2",children:"Found an answer? You can close this dialog. Still need help? Continue creating your ticket."})]})]}),e.jsxs(G,{children:[e.jsx(N,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsx(N,{type:"submit",disabled:f.isPending,children:f.isPending?"Creating...":"Create Ticket"})]})]})]})})]})}function w({tickets:c,isLoading:p}){const n=A(),l=U();return p?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"Loading tickets..."}):c.length===0?e.jsxs("div",{className:"py-12 text-center border rounded-lg bg-card mt-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"No tickets found"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create a new ticket to get help from our support team."})]}):e.jsx("div",{className:"space-y-3 mt-4",children:c.map(t=>e.jsxs("div",{className:"border rounded-lg bg-card p-4 hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>n(`/dashboard/support/${t.id}`),children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[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-sm text-muted-foreground",children:["#",t.ticketNumber]}),e.jsx(L,{className:Z[t.status],children:t.status.replace("_"," ")}),e.jsx(L,{variant:"outline",className:Y[t.priority],children:t.priority})]}
1),e.jsx("h3",{className:"font-medium mt-1 truncate",children:t.subject}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description})]}),e.jsx("div",{className:"text-sm text-muted-foreground whitespace-nowrap",children:new Date(t.createdAt).toLocaleDateString(void 0,{timeZone:l})})]}),t.messages&&t.messages.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Last reply:"," ",new Date(t.messages[0].createdAt).toLocaleDateString(void 0,{timeZone:l})]})})]},t.id))})}export{ye 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.