PageSourceSearch

https://kconect.vercel.app/assets/LiveChat-B_LRr_nn.js

js kconect.vercel.app collected 2026-10-03 07:10:42 UTC 6,800 bytes, 1 lines download raw bytes

1import{h as U,r as x,k as m,j as e,O as _,C as b,f as N,U as S,d as A,e as D,A as I}from"./index-IxvR3ybE.js";import{A as L,a as T,b as q}from"./avatar-BaQ7HthH.js";import{C as F}from"./ChatMessage-XKdvGdHv.js";import{F as P}from"./FloatingDidYouKnow-CupRzAB-.js";import"./quote-Dvx7cJ9b.js";import"./index-PqXJKzHr.js";import"./external-link-DjtQGYET.js";import"./user-plus-DKb_O1Pc.js";import"./message-square-D78-i2rO.js";import"./trash-2-DklbPQfi.js";import"./formatDistanceToNow-DkEgaWgB.js";import"./constructNow-BxmPnzq9.js";import"./en-US-CujKlCMr.js";import"./endOfMonth-CemvPxiU.js";function Z(){const{eventId:l}=U(),[g,E]=x.useState(null),[f,p]=x.useState([]),[k,j]=x.useState(!0);x.useEffect(()=>{let d=!1;return(async()=>{if(!l)return;const{data:i,error:s}=await m.from("events").select("id, name, description, logo_url, start_time, end_time").eq("id",l).single();s&&console.error("Error fetching event:",s),d||E(i??null)})(),()=>{d=!0}},[l]),x.useEffect(()=>{let d=!1;return(async()=>{if(!l)return;j(!0);const{data:i,error:s}=await m.from("chat_messages").select("*").eq("event_id",l).order("created_at",{ascending:!0}).limit(200);if(s){console.error("Error fetching chat messages:",s),j(!1);return}const o=i||[],v=[...new Set(o.map(r=>r.user_id))];let c=new Map;if(v.length>0){const{data:r}=await m.from("profiles").select("id, name, photo_url, role").in("id",v);(r||[]).forEach(t=>c.set(t.id,t))}const a=[...new Set(o.map(r=>r.quoted_message_id).filter(Boolean))];let w=new Map;if(a.length>0){const{data:r}=await m.from("chat_messages").select("*").in("id",a);if(r&&r.length){const t=[...new Set(r.map(h=>h.user_id))].filter(h=>!c.has(h));if(t.length>0){const{data:h}=await m.from("profiles").select("id, name, photo_url, role").in("id",t);(h||[]).forEach(n=>c.set(n.id,n))}r.forEach(h=>{const n=c.get(h.user_id);w.set(h.id,{...h,user_profile:{id:n==null?void 0:n.id,name:(n==null?void 0:n.name)||"Unknown User",role:(n==null?void 0:n.role)||void 0,photo_url:(n==null?void 0:n.photo_url)||null}})})}}const M=o.map(r=>{const t=c.get(r.user_id);return{...r,user_profile:{id:t==null?void 0:t.id,name:(t==null?void 0:t.name)||"Unknown User",role:(t==null?void 0:t.role)||void 0,photo_url:(t==null?void 0:t.photo_url)||null},quoted_message:r.quoted_message_id&&w.get(r.quoted_message_id)||null}});d||(p(M),j(!1))})(),()=>{d=!0}},[l]),x.useEffect(()=>{if(!l)return;const d=m.channel(`live-chat-${l}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"chat_messages",filter:`event_id=eq.${l}`},async u=>{const i=u.new,{data:s}=await m.from("profiles").select("id, name, photo_url, role").eq("id",i.user_id).single();let o=null;if(i.quoted_message_id){const{data:c}=await m.from("chat_messages").select("*").eq("id",i.quoted_message_id).single();if(c){const{data:a}=await m.from("profiles").select("id, name, photo_url, role").eq("id",c.user_id).single();o={...c,user_profile:{id:a==null?void 0:a.id,name:(a==null?void 0:a.name)||"Unknown User",photo_url:(a==null?void 0:a.photo_url)||null,role:(a==null?void 0:a.role)||void 0}}}}const v={...i,user_profile:{id:s==null?void 0:s.id,name:(s==null?void 0:s.name)||"Unknown User",photo_url:(s==null?void 0:s.photo_url)||null,role:(s==null?void 0:s.role)||void 0},quoted_message:o};p(c=>[...c,v])}).on("postgres_changes",{event:"DELETE",schema:"public",table:"chat_messages",filter:`event_id=eq.${l}`},u=>{const i=u.old;p(s=>s.filter(o=>o.id!==i.id))}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"chat_messages",filter:`event_id=eq.${l}`},u=>{const i=u.new;p(s=>s.map(o=>o.id===i.id?{...o,...i}:o))}).subscribe();return()=>{m.removeChannel(d)}},[l]);const y=f.length,C=x.useMemo(()=>new Set(f.map(u=>u.user_id)).size,[f]);return k?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading live chat..."})]})})})}):g?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(P,{}),e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[g.logo_url&&e.jsxs(L,{className:"h-16 w-16",children:[e.jsx(T,{src:g.logo_url,alt:g.name}),e.jsx(q,{children:g.name.charAt(0)})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:g.name}),e.jsx("p",{className:"text-muted-foreground",children:"Live Chat"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[e.jsx(b,{children:e.jsx(N,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-100 dar
1k:bg-blue-900/20",children:e.jsx(_,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Messages"})]})]})})}),e.jsx(b,{children:e.jsx(N,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-green-100 dark:bg-green-900/20",children:e.jsx(S,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:C}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Participants"})]})]})})})]})]}),e.jsxs(b,{children:[e.jsxs(A,{children:[e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-5 w-5"}),"Live Chat Stream"]}),e.jsx(I,{children:"Updates in real-time as attendees interact"})]}),e.jsx(N,{children:e.jsx("div",{className:"h-[70vh] overflow-y-auto p-2 bg-muted/30 rounded-md",children:f.length===0?e.jsx("div",{className:"text-center py-10 text-muted-foreground",children:"No messages yet. Waiting for attendees to start the conversation..."}):e.jsx("div",{className:"space-y-3",children:f.map(d=>e.jsx(F,{message:d,isOwn:!1,onQuote:void 0,onDelete:void 0,points:void 0},d.id))})})})]})]})]}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"p-4 rounded-full bg-destructive/10 inline-block mb-4",children:e.jsx(_,{className:"h-8 w-8 text-destructive"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Event Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The event you're looking for doesn't exist or has been removed."})]})})})}export{Z 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.