import{u,c as d,d as m,j as i}from"./vendor-query-Brcc40-Y.js";import{n as r,T as x,S as a}from"./Skeleton-DGpeJz1z.js";import{B as f,i as c,p}from"./index-tN-ddyeb.js";import{E as h}from"./EmptyState-DBHsSu6q.js";import"./vendor-react-DP6BW_9B.js";import"./vendor-utils-ui5PHgZB.js";import"./vendor-zustand-CVDiRiMG.js";import"./vendor-form-BQNAly2Z.js";const v={list:(e=1)=>["notifications","list",e],unread:()=>["notifications","unread-count"]};function j(e=1){return u({queryKey:v.list(e),queryFn:()=>r.list({page:e,limit:30}),staleTime:3e4})}function N(){const e=d();return m({mutationFn:r.markRead,onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]})}})}function g(){const e=d();return m({mutationFn:r.markAllRead,onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]})}})}const y={expense_added:"🧾",settlement_recorded:"💸",settlement_reminder:"⏰",member_joined:"👋",group_invite:"📨"};function k({notif:e}){const n=N(),s=y[e.type]??"🔔";return i.jsxs("button",{onClick:()=>{e.isRead||n.mutate(e.id)},className:c("flex w-full items-start gap-3 p-4 text-left transition-all hover:bg-bg-elevated",!e.isRead&&"bg-primary-subtle/30"),children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-bg-elevated text-xl",children:s}),!e.isRead&&i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full bg-primary"})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:c("text-sm font-medium leading-snug",e.isRead?"text-ink-muted":"text-ink"),children:e.title}),i.jsx("p",{className:"text-xs text-ink-muted mt-0.5 line-clamp-2",children:e.body}),i.jsx("p",{className:"text-xs text-ink-faint mt-1",children:p(e.createdAt)})]}),!e.isRead&&i.jsx("div",{className:"h-2 w-2 rounded-full bg-primary flex-shrink-0 mt-2"})]})}function b(){return i.jsxs("div",{className:"flex items-start gap-3 p-4 animate-pulse",children:[i.jsx(a,{className:"h-10 w-10 rounded-xl flex-shrink-0"}),i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx(a,{className:"h-4 w-3/4"}),i.jsx(a,{className:"h-3 w-full"}),i.jsx(a,{className:"h-3 w-20 mt-1"})]})]})}function K(){const{data:e,isLoading:n}=j(),s=g(),o=(e==null?void 0:e.data)??[],l=(e==null?void 0:e.unreadCount)??0;return i.jsxs("div",{className:"flex flex-col",children:[i.jsx(x,{title:"Notifications",subtitle:l>0?`${l} unread`:"All caught up",actions:l>0?i.jsx(f,{variant:"ghost",size:"sm",loading:s.isPending,onClick:()=>s.mutate(),children:"Mark all read"}):void 0}),i.jsx("div",{className:"mx-auto w-full max-w-2xl animate-fade-in",children:n?i.jsx("div",{className:"card divide-y divide-bg-overlay overflow-hidden m-4 lg:m-6",children:[1,2,3,4,5].map(t=>i.jsx(b,{},t))}):o.length===0?i.jsx("div",{className:"p-4 lg:p-6",children:i.jsx(h,{icon:"🔔",title:"No notifications",description:"You're all caught up! Notifications will appear here when there's activity in your groups."})}):i.jsx("div",{className:"card divide-y divide-bg-overlay overflow-hidden m-4 lg:m-6",children:o.map(t=>i.jsx(k,{notif:t},t.id))})})]})}export{K as default};
