1import{j as s}from"./vendor-radix-D0djaOx0.js";import{R as U,a as D,e as N,l as x,b as c,t as w,S as v,C as y,ao as C,B as k}from"./index-skmeOq4o.js";import{a as d,Q as O,aJ as S,V as p,aF as A,cc as T,cd as L}from"./vendor-icons-BA50XFRQ.js";import{U as G,a as H}from"./UserHeader-DfQx-Bh6.js";import{N as J}from"./NewTicketDialog-WBEkwN9h.js";import{C as B,S as q,T as V}from"./TicketCategoryBadge-zHCIotZS.js";import{k as z}from"./keyboardActivate-Cz_cvm8v.js";import"./vendor-motion-BnvVrkNg.js";import"./customerLinkStats-B5aHlkky.js";import"./useNewCouponsCount-joMGR1xK.js";import"./dialog-5oLsv4Ur.js";import"./textarea-D6Ew7r2j.js";import"./badge-DulfYeZx.js";const W=[{key:"all",label:"×××"},{key:"notifications",label:"××××¢×ת ×××צע××",icon:p},{key:"support",label:"×¤× ××ת ת××××",icon:A}];function de(){return s.jsx(U,{children:s.jsx(X,{})})}function X(){const g=typeof window<"u"?new URLSearchParams(window.location.search).get("new"):null,[M,l]=d.useState(g==="api_access"),[E,h]=d.useState(null),[n,$]=d.useState("all"),m=D(),{data:a}=N({queryKey:["current_user"],queryFn:()=>c.auth.me()}),{data:o=[],isLoading:F}=N({queryKey:["my_tickets"],queryFn:async()=>(await c.entities.SupportTicket.list("-created_date")).filter(t=>t.customer_email===(a==null?void 0:a.email)),enabled:!!(a!=null&&a.email)}),r=o.find(e=>e.id===E),f=d.useMemo(()=>n==="notifications"?o.filter(e=>e.ticket_type==="notification"||e.category==="promotion"||e.category==="system_notice"):n==="support"?o.filter(e=>e.ticket_type!=="notification"&&e.category!=="promotion"&&e.category!=="system_notice"):o,[o,n]),I=o.filter(e=>(e.ticket_type==="notification"||e.category==="promotion"||e.category==="system_notice")&&e.unread_by_customer).length,P=o.filter(e=>e.ticket_type!=="notification"&&e.category!=="promotion"&&e.category!=="system_notice"&&e.unread_by_customer).length,Q=x({mutationFn:e=>c.entities.SupportTicket.update(e,{unread_by_customer:!1}),onSuccess:()=>{m.invalidateQueries({queryKey:["my_tickets"]}),m.invalidateQueries({queryKey:["unread_tickets_count"]})}}),j=x({mutationFn:async({category:e,subject:t,message:i})=>{await c.entities.SupportTicket.create({customer_email:a.email,customer_name:a.full_name,subject:t,category:e,ticket_type:"support",status:"open",unread_by_admin:!0,unread_by_customer:!1,messages:[{sender:a.email,sender_role:"customer",text:i,date:new Date().toISOString()}]})},onSuccess:(e,t)=>{m.invalidateQueries({queryKey:["my_tickets"]}),l(!1),w.success((t==null?void 0:t.category)==="api_access"?"×××§×©× ××××©× ×-API × ×©××× â × ×¢××× ×ת×× ×ש××××©× ×ª×פע×":"××¤× ××× × ×©××× â × ×××ר ××××× ×××§××")},onError:e=>w.error("××¤× ××× ×× × ×©×××: "+((e==null?void 0:e.message)||"× ×¡× ×©××"))}),_=x({mutationFn:async e=>{const t=r,i=[...t.messages||[],{sender:a.email,sender_role:"customer",text:e,date:new Date().toISOString()}];await c.entities.SupportTicket.update(t.id,{messages:i,status:"awaiting_admin",unread_by_admin:!0,unread_by_customer:!1})},onSuccess:()=>m.invalidateQueries({queryKey:["my_tickets"]})}),K=e=>{h(e.id),e.unread_by_customer&&Q.mutate(e.id)},R=o.filter(e=>e.unread_by_customer).length;if(!a)return s.jsxs("div",{className:"flex min-h-screen bg-[#f5f6fa]",dir:"rtl",children:[s.jsx("main",{className:"flex-1 p-8",children:s.jsx(v,{className:"h-96 rounded-2xl"})}),s.jsx("div",{className:"w-60 bg-white"})]});const u=r&&(r.ticket_type==="notification"||r.category==="promotion"||r.category==="system_notice");return s.jsxs("div",{className:"flex min-h-screen bg-[#f5f6fa]",dir:"rtl",children:[s.jsx(G,{user:a,currentPage:"SupportTickets"}),s.jsxs("main",{className:"flex-1",children:[s.jsx(H,{user:a,title:"ת×××× ×××××¢×ת"}),s.jsx("div",{className:"px-6 pb-8 max-w-4xl mx-auto",children:r?s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>h(null),className:"flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-700 mb-4 transition-colors",children:[s.jsx(O,{className:"w-4 h-4"}),"×××¨× ×רש×××"]}),s.jsxs(y,{className:"rounded-2xl border-0 shadow-sm overflow-hidden",children:[s.jsx("div",{className:`p-4 border-b border-gray-100 ${u?"bg-gradient-to-l from-emerald-50 to-white":"bg-gray-50/50"}`,children:s.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[u&&(r.category==="promotion"?s.jsx(S,{className:"w-5 h-5 text-emerald-600"}):s.jsx(p,{className:"w-5 h-5 text-sky-600"})),s.jsx("h3",{className:"font-bold text-gray-900",children:r.subject})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx(B,{category:r.category}),s.jsx(q,{status:r.status})]})]}),s.jsx("span",{className:"text-xs text-gray-400",children:C(r.created_date)})]})}),s.jsx(V,{messages:r.messages||[],onSend:e=>_.mutate(e),isSending:_.isPending,currentUserEmail:a.email,readOnly:u&&r.status==="closed"})]})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-5 flex-wrap",children:[s.jsx("div",{className:"flex items-center bg-white rounded-xl border border-gray-200 p-1 gap-0.5",children:W.map(e=>
1{const t=n===e.key,i=e.key==="notifications"?I:e.key==="support"?P:R;return s.jsxs("button",{onClick:()=>$(e.key),className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium transition-all ${t?"bg-[#2B8C8C] text-white shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:[e.icon&&s.jsx(e.icon,{className:"w-4 h-4"}),e.label,i>0&&s.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded-full min-w-[18px] text-center ${t?"bg-white/20 text-white":"bg-red-600 text-white"}`,children:i})]},e.key)})}),s.jsx("div",{className:"mr-auto",children:s.jsxs(k,{onClick:()=>l(!0),className:"bg-[#2B8C8C] hover:bg-[#1A5E5E] rounded-xl gap-2",children:[s.jsx(T,{className:"w-4 h-4"}),"×¤× ××× ××ש×"]})})]}),F?s.jsx("div",{className:"space-y-3",children:Array(3).fill(0).map((e,t)=>s.jsx(v,{className:"h-20 rounded-xl"},t))}):f.length===0?s.jsxs(y,{className:"rounded-2xl border-0 shadow-sm p-12 text-center",children:[s.jsx(L,{className:"w-12 h-12 mx-auto mb-3 text-gray-200"}),s.jsx("p",{className:"text-gray-500 font-medium",children:n==="notifications"?"××× ××××¢×ת ×¢××××":n==="support"?"××× ×¤× ××ת ת××××":"××× ×¤× ××ת ×¢××××"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:n==="notifications"?"××× ××פ××¢× ××צע××, ×§×פ×× ×× ×××××¢×ת ×ער×ת":"×ש ×× ×©×××? ×¤×ª× ×¤× ××× ×× ×××ר ×××× ×××§××"}),n!=="notifications"&&s.jsxs(k,{onClick:()=>l(!0),className:"mt-4 bg-[#2B8C8C] hover:bg-[#1A5E5E] rounded-xl gap-2",children:[s.jsx(T,{className:"w-4 h-4"}),"×¤× ××× ××ש×"]})]}):s.jsx("div",{className:"space-y-2.5",children:f.map(e=>{var b;const t=(b=e.messages)==null?void 0:b[e.messages.length-1],i=e.ticket_type==="notification"||e.category==="promotion"||e.category==="system_notice";return s.jsx(y,{...z(()=>K(e)),className:`rounded-2xl border shadow-sm p-4 cursor-pointer hover:shadow-md transition-all ${e.unread_by_customer?i?"border-emerald-300 bg-emerald-50/40":"border-[#2B8C8C]/40 bg-[#E6F5F5]/30":"border-gray-100"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center shrink-0 ${i?e.unread_by_customer?"bg-emerald-100":"bg-emerald-50":e.unread_by_customer?"bg-[#2B8C8C]/10":"bg-gray-100"}`,children:i?e.category==="promotion"?s.jsx(S,{className:`w-5 h-5 ${e.unread_by_customer?"text-emerald-600":"text-emerald-400"}`}):s.jsx(p,{className:`w-5 h-5 ${e.unread_by_customer?"text-sky-600":"text-sky-400"}`}):s.jsx(A,{className:`w-5 h-5 ${e.unread_by_customer?"text-[#2B8C8C]":"text-gray-400"}`})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h4",{className:"font-bold text-gray-900 text-sm truncate",children:e.subject}),e.unread_by_customer&&s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${i?"bg-emerald-500":"bg-[#2B8C8C]"}`})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx(B,{category:e.category}),!i&&s.jsx(q,{status:e.status})]}),t&&s.jsxs("p",{className:"text-xs text-gray-500 mt-1.5 truncate",children:[t.sender_role==="admin"?"ð¡ï¸ צ××ת BuyPost: ":"×ת×: ",t.text]})]})]}),s.jsx("span",{className:"text-[11px] text-gray-400 shrink-0",children:C(e.created_date,{includeTime:!1})})]})},e.id)})})]})}),s.jsx(J,{open:M,onOpenChange:l,initialCategory:g==="api_access"?"api_access":"general",onSubmit:e=>j.mutate(e),isSubmitting:j.isPending})]})]})}export{de 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.