1import{c as w,i as v,r as y,a as j,j as e,ac as _,g as k,A as C,aT as D,s as f,a1 as N,Q as M,k as S,l as g,t as R,h,n as T,x as A,D as q,p as F,B as p,a5 as b}from"./index-C4LWZPK9.js";import{T as G}from"./textarea-G6LYtFU8.js";import{T as u}from"./tv-minimal-DJEN8ZkK.js";import{C as L}from"./circle-check-Cx31KQzm.js";import{f as V}from"./formatDistanceToNow-YrIkrO0W.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const z=[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]],I=w("MailOpen",z);function Q({msg:s,onReply:i,authorId:c}){const[a,r]=y.useState(""),[o,l]=y.useState(!1),n=S(),t=g({mutationFn:()=>h.entities.ArtistMessage.update(s.id,{artist_reply:a.trim(),status:"replied",artist_replied_at:new Date().toISOString(),replied_from_platform:"goby_tv"}),onSuccess:()=>{n.invalidateQueries({queryKey:["artist-inbox",c]}),R.success("Reply sent! The Deep Diver will see it in their portal."),l(!1),r("")}}),d=g({mutationFn:()=>h.entities.ArtistMessage.update(s.id,{status:"read"}),onSuccess:()=>n.invalidateQueries({queryKey:["artist-inbox",c]})}),m={pending:"bg-yellow-500/10 text-yellow-400",read:"bg-blue-500/10 text-blue-400",replied:"bg-accent/10 text-accent",declined:"bg-destructive/10 text-destructive"};return e.jsx(T.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},children:e.jsx(A,{className:`border-border transition-all ${s.status==="pending"?"border-primary/30 bg-primary/5":"bg-secondary/30"}`,children:e.jsxs(q,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(N,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:s.from_user_name}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(F,{className:"w-3 h-3"}),s.created_date?V(new Date(s.created_date),{addSuffix:!0}):"Recently",s.from_user_watch_hours>0&&e.jsxs("span",{className:"ml-1 text-primary",children:["· ",s.from_user_watch_hours.toFixed(1),"h watched"]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(f,{className:`text-xs ${m[s.status]||""}`,children:s.status==="pending"?"â New":s.status==="read"?"Read":s.status==="replied"?"â Replied":s.status})})]}),s.subject&&e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:s.subject}),e.jsx("p",{className:"text-sm leading-relaxed",children:s.message}),s.artist_reply&&e.jsxs("div",{className:"mt-3 bg-accent/5 border border-accent/20 rounded-lg p-3",children:[e.jsxs("p",{className:"text-xs font-semibold text-accent mb-1 flex items-center gap-1",children:[e.jsx(L,{className:"w-3 h-3"})," Your reply",s.replied_from_platform==="goby_social"&&e.jsxs(f,{className:"ml-2 text-xs px-1.5 py-0 bg-primary/10 text-primary gap-1",children:[e.jsx(u,{className:"w-2.5 h-2.5"})," Goby Social"]})]}),e.jsx("p",{className:"text-sm",children:s.artist_reply})]}),s.goby_social_notified&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(u,{className:"w-3 h-3 text-primary"}),e.jsx("span",{children:"Fan was notified on Goby Social"})]}),s.status!=="replied"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[s.status==="pending"&&e.jsxs(p,{size:"sm",variant:"ghost",className:"h-7 text-xs text-muted-foreground",onClick:()=>d.mutate(),disabled:d.isPending,children:[e.jsx(I,{className:"w-3 h-3 mr-1"})," Mark Read"]}),e.jsxs(p,{size:"sm",className:"h-7 text-xs bg-primary/90 hover:bg-primary gap-1 ml-auto",onClick:()=>l(!o),children:[e.jsx(b,{className:"w-3 h-3"})," Reply"]})]}),o&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx(G,{value:a,onChange:x=>r(x.target.value),placeholder:`Reply to ${s.from_user_name}...`,rows:3,className:"resize-none text-sm"}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(u,{className:"w-3 h-3 text-primary"}),"Reply will appear in their Deep Diver portal"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>{l(!1),r("")},children:"Cancel"}),e.jsxs(p,{size:"sm",className:"h-7 text-xs bg-primary/90 hover:bg-primary gap-1",disabled:!a.trim()||t.isPending,onClick:()=>t.mutate(),children:[e.jsx(b,{className:"w-3 h-3"}),t.isPending?"Sending...":"Send Reply"]})]})]})]})]})})})}function E(){const{user:s}=v(),[i,c]=y.useState("all"),{data:a}=j({queryKey:["my-author-record",s==null?void 0:s.id],queryFn:async()=>(await h.entities.Author.list("name",200)).find(d=>{var m,x;return((m=d.name)==null?void 0:m.toLowerCase())===((x=s==null?void 0:s.full_name)==null?void 0:x.toLowerCase())})||null,enabled:!!s}),{data:r=[],isLoading:o}=j({queryKey:["artist-inbox",a==null?void 0:a.id],queryFn:()=>h.entities.ArtistMessage.filter({to_author_id:a.id},"-created_date",100),enabled:!!(a!=null&&a.id)}),l=r.filter(t=>i==="new"?t.status==="pending":i==="replied"?t.status==="replied":!0),n=r.filter(t=>t.status==="pending").length;return s?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(_,{user:s,homeViewMode:"categories",setHomeViewMode:()=>{}}),e.jsxs("div",{className:"pt-20 pb-24 px-4 sm:px-6 lg:px-8 max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx(k,{to:"/",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(C,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("h1",{className:"text-2xl font-display font-bold flex items-center gap-2",children:[e.jsx(D,{className:"w-6 h-6 text-primary"})," Artist Inbox"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Messages from your Goby TV Deep Divers"})]}),n>0&&e.jsxs(f,{className:"bg-primary text-primary-foreground text-sm px-3 py-1",children:[n," new"]})]}),e.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-xl p-4 flex items-start gap-3 mb-6",children:[e.jsx(u,{className:"w-5 h-5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Goby TV à Goby Social"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"These messages were sent by Deep Divers on Goby TV. When you reply here, they'll see it in their Deep Diver portal. Replies from Goby Social also appear here automatically."})]})]}),!o&&!a&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx(N,{className:"w-12 h-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{className:"font-medium",children:"Artist profile not linked"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 max-w-sm mx-auto",children:["Your account doesn't have a linked artist profile yet. Ask an admin to create an Author record with your name: ",e.jsx("span",{className:"text-foreground font-medium",children:s==null?void 0:s.full_name})]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-2 mb-4",children:[{key:"all",label:"All",count:r.length},{key:"new",label:"New",count:n},{key:"replied",label:"Replied",count:r.filter(t=>t.status==="replied").length}].map(t=>e.jsxs("button",{onClick:()=>c(t.key),className:`flex items-center gap-1.5 px-4 py-1.5 rounded-full text-sm font-medium transition-colors ${i===t.key?"bg-primary text-primary-foreground":"bg-secondary/60 text-muted-foreground hover:text-foreground"}`,children:[t.label,t.count>0&&e.jsx("span",{className:`text-xs rounded-full px-1.5 ${i===t.key?"bg-white/20":"bg-border"}`,children:t.count})]},t.key))}),o?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx("div",{className:"h-32 rounded-xl bg-secondary/40 animate-pulse"},t))}):l.length===0?e.jsxs("div",{className:"text-center py-16 text-muted-foreground",children:[e.jsx(M,{className:"w-12 h-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{className:"font-medium",children:i==="new"?"No new messages":"No messages yet"}),e.jsx("p",{className:"text-sm mt-1",children:"When Deep Divers send you a message, it will appear here"})]}):e.jsx("div",{className:"space-y-3",children:l.map(t=>e.jsx(Q,{msg:t,authorId:a.id},t.id))})]})]})]}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Please log in to view your inbox."})})}export{E 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.