PageSourceSearch

https://higherup.ai/assets/GroupChatPage-BNcwJubt.js

js higherup.ai collected 2026-10-05 14:35:42 UTC 32,994 bytes, 1 lines download raw bytes

1import{j as e}from"./index-12DC86Qv.js";import{r as s,L as B,f as Ae,g as Oe}from"./vendor-BcCsE5pw.js";import{a as y,b as Fe,y as Ce,d as Ue,u as qe}from"./App-HVuyHYBt.js";import{g as Je,a as Ye}from"./realtime-CSsBqf3B.js";import{c as He,d as Ke,s as Ve,g as Ge}from"./moderationActions-B5E9mVBY.js";import{P as Qe}from"./PresenceIndicator-DpsdwfHj.js";function Xe(n){const{chatId:i,user:o,onMessage:p,onConnect:r,onDisconnect:l,onError:c,reconnectInterval:x=1e3,maxReconnectInterval:v=3e4}=n,[f,a]=s.useState("disconnected"),j=s.useRef(null),k=s.useRef(),h=s.useRef(x),S=s.useRef(!1),b=s.useRef(!0),C=s.useRef(null),N=s.useCallback(()=>{if(!(!i||!o||!b.current)&&C.current===i){S.current=!1,a("connecting");try{const w=new WebSocket(Je(i));j.current=w,w.onopen=()=>{!b.current||C.current!==i||(a("connected"),h.current=x,w.send(Ye(o.id,o.username,o.avatar_color)),r?.())},w.onmessage=_=>{if(!(!b.current||C.current!==i))try{const E=JSON.parse(_.data);p?.(E)}catch{}},w.onerror=_=>{!b.current||C.current!==i||(a("error"),c?.(_))},w.onclose=()=>{!b.current||C.current!==i||(a("disconnected"),l?.(),!S.current&&i&&b.current&&C.current===i&&(k.current=setTimeout(()=>{h.current=Math.min(h.current*2,v),N()},h.current)))}}catch{if(!b.current||C.current!==i)return;a("error")}}},[i,o,p,r,l,c,x,v]),R=s.useCallback(()=>{S.current=!0,k.current&&clearTimeout(k.current),j.current&&(j.current.close(),j.current=null),a("disconnected")},[]),O=s.useCallback(w=>j.current?.readyState===WebSocket.OPEN?(j.current.send(JSON.stringify(w)),!0):!1,[]);return s.useEffect(()=>(b.current=!0,C.current=i,i&&o?(k.current&&clearTimeout(k.current),N()):R(),()=>{b.current=!1,R()}),[i,o,N,R]),{connectionState:f,send:O,disconnect:R,reconnect:N}}function Ze({room:n}){const[i,o]=s.useState([]),[p,r]=s.useState(!1);return s.useEffect(()=>{p&&(async()=>{const l=await y.request(`/messages/pin?room=${encodeURIComponent(n)}`);l.success&&l.data&&o(l.data)})()},[n,p]),i.length===0&&!p?null:e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("button",{onClick:()=>r(!p),style:{fontSize:"12px",color:"var(--text-muted)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",display:"flex",alignItems:"center",gap:"4px"},children:["📌 ",i.length>0?`${i.length} pinned message${i.length!==1?"s":""}`:"Pinned messages",e.jsx("span",{style:{fontSize:"10px"},children:p?"▲":"▼"})]}),p&&i.length>0&&e.jsx("div",{style:{marginTop:"6px",padding:"8px",borderRadius:"var(--radius-sm)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:i.map(l=>e.jsxs("div",{style:{padding:"6px 0",borderBottom:"1px solid var(--border)",fontSize:"13px"},children:[e.jsxs("span",{style:{fontWeight:600,color:"var(--accent)"},children:["@",l.username]}),e.jsx("span",{style:{color:"var(--text-muted)",marginLeft:"6px",fontSize:"11px"},children:new Date(l.pinned_at*1e3).toLocaleDateString()}),e.jsx("div",{style:{color:"var(--text-secondary)",marginTop:"2px"},children:l.message_content})]},l.id))})]})}function et({messageId:n,room:i,isPinned:o,onToggle:p}){const[r,l]=s.useState(o??!1),[c,x]=s.useState(!1),v=async()=>{if(c)return;x(!0);const f=await y.request("/messages/pin",{method:"POST",body:JSON.stringify({message_id:n,chat_room:i})}),a=f.data;f.success&&(l(a?.pinned??!r),p?.(a?.pinned??!r)),x(!1)};return e.jsx("button",{onClick:v,disabled:c,title:r?"Unpin":"Pin",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 6px",opacity:r?1:.5,transition:"opacity 0.2s"},children:"📌"})}function tt({messageId:n,room:i,totalMembers:o}){const[p,r]=s.useState(0);return s.useEffect(()=>{(async()=>{const l=await y.request(`/messages/read?ids=${n}`),c=l.data;l.success&&c&&c[n]&&r(c[n]?.read_count||0)})()},[n]),p===0?null:e.jsxs("span",{style:{fontSize:"11px",color:"var(--accent)",marginLeft:"4px",whiteSpace:"nowrap"},children:["✓✓ ",p>1?p:""]})}function st(n){n.length!==0&&y.request("/messages/read",{method:"POST",body:JSON.stringify({message_ids:n})})}function rt({threadId:n,onClose:i}){const[o,p]=s.useState(null),[r,l]=s.useState([]),[c,x]=s.useState(""),[v,f]=s.useState(!0),a=s.useRef(null),{dialogProps:j}=Fe({open:!v,onClose:i,label:"Conversation thread",modal:!1,closeOnBackdrop:!1});s.useEffect(()=>{y.request(`/chat/threads?thread_id=${n}
1`).then(h=>{if(h.success&&h.data){const S=h.data;p(S.thread),l(S.messages||[])}f(!1)})},[n]),s.useEffect(()=>{a.current?.scrollIntoView({behavior:"smooth"})},[r]);const k=async()=>{if(!c.trim())return;if((await y.request("/chat/threads",{method:"POST",body:JSON.stringify({parent_message_id:o?.parent_message_id||0,chat_room:"",message:c.trim()})})).success){x("");const S=await y.request(`/chat/threads?thread_id=${n}`);S.success&&S.data&&l(S.data.messages||[])}};return v?e.jsx("div",{style:{padding:20,textAlign:"center",color:"var(--text-muted)"},children:"Loading thread..."}):e.jsxs("div",{...j,style:{position:"fixed",top:0,right:0,width:"360px",maxWidth:"100vw",height:"100vh",background:"var(--bg-primary)",borderLeft:"1px solid var(--border)",zIndex:1e3,display:"flex",flexDirection:"column",boxShadow:"-4px 0 20px rgba(0,0,0,0.15)"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontWeight:700,fontSize:"14px"},children:["Thread · ",o?.reply_count||0," replies"]}),e.jsx("button",{type:"button",onClick:i,"aria-label":"Close thread",style:{border:"none",background:"none",cursor:"pointer",fontSize:"18px",color:"var(--text-muted)"},children:"✕"})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"12px"},children:[r.map(h=>e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"10px"},children:[e.jsx("div",{className:"avatar",style:{background:h.avatar_color,width:"28px",height:"28px",fontSize:"12px",flexShrink:0,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:700},children:h.username[0]?.toUpperCase()||"?"}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"baseline"},children:[e.jsx(B,{to:`/u/${h.username}`,style:{fontSize:"12px",fontWeight:700,color:"var(--accent-hover)",textDecoration:"none"},children:h.username}),e.jsx("span",{style:{fontSize:"10px",color:"var(--text-muted)"},children:Ce(h.created_at)})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--text-primary)",lineHeight:1.4,wordBreak:"break-word"},children:h.message})]})]},h.id)),e.jsx("div",{ref:a})]}),e.jsxs("div",{style:{padding:"10px 12px",borderTop:"1px solid var(--border)",display:"flex",gap:"6px"},children:[e.jsx("input",{type:"text",value:c,onChange:h=>x(h.target.value),onKeyDown:h=>{h.key==="Enter"&&k()},placeholder:"Reply in thread...",style:{flex:1,padding:"8px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border)",background:"var(--bg-input)",color:"var(--text-primary)",fontSize:"13px"}}),e.jsx("button",{onClick:k,disabled:!c.trim(),className:"btn btn-primary btn-sm",style:{fontSize:"12px"},children:"Reply"})]})]})}function nt({chatId:n,currentUserId:i}){const[o,p]=s.useState([]),[r,l]=s.useState(!1);if(s.useEffect(()=>{const x=new EventSource(`/api/chat/typing/stream?chatId=${n}`);return x.onmessage=v=>{try{const f=JSON.parse(v.data);f.userId!==i&&p(a=>f.typing&&!a.includes(f.username)?[...a,f.username]:f.typing?a:a.filter(j=>j!==f.username))}catch{}},x.onerror=()=>x.close(),()=>x.close()},[n,i]),s.useEffect(()=>{if(o.length===0){l(!1);return}l(!0);const x=setTimeout(()=>{l(!1),setTimeout(()=>p([]),300)},3e3);return()=>clearTimeout(x)},[o]),o.length===0&&!r)return null;const c=o.length===1?`${o[0]} is typing`:o.length===2?`${o[0]} and ${o[1]} are typing`:`${o[0]} and ${o.length-1} others are typing`;return e.jsxs("div",{style:{padding:"4px 12px",fontSize:"12px",color:"var(--text-muted)",fontStyle:"italic",opacity:r?1:0,transform:r?"translateY(0)":"translateY(4px)",transition:"opacity 0.3s ease, transform 0.3s ease",maxHeight:r?"40px":"0",overflow:"hidden"},children:[e.jsx("span",{style:{display:"inline-flex",gap:"3px",marginRight:"6px",verticalAlign:"middle"},children:[0,1,2].map(x=>e.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--accent)",animation:`typing-dot 1.4s infinite ${x*.2}s`,opacity:.7}},x))}),c]})}function we(n){return new Date(n).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function ke({name:n,setName:i,desc:o,setDesc:p,isPrivate:r,setIsPrivate:l,onCreate:c,onClose:x,loading:v,error:f}){return e.jsx("div",{className:"modal-overlay",onClick:x,children:e.jsxs("div",{className:"modal fade-in",onClick:a=>a.stopPropagation(),style:{maxWidth:"420px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:800,marginBottom:"16
1px"},children:"🏰 Create a Server"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--text-muted)",marginBottom:16},children:"Your server is where you and your community hang out. Make yours and start talking."}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Server Name"}),e.jsx("input",{type:"text",value:n,onChange:a=>i(a.target.value),placeholder:"e.g. Moon Landing Investigators",onKeyDown:a=>{a.key==="Enter"&&c()},autoFocus:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Description (optional)"}),e.jsx("textarea",{value:o,onChange:a=>p(a.target.value),rows:2,placeholder:"What's this server about?",style:{resize:"vertical"}})]}),e.jsx("div",{className:"form-group",children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:r,onChange:a=>l(a.target.checked),style:{width:"auto"}}),"🔒 Private Server (invite only)"]})}),f&&e.jsx("div",{style:{padding:"8px 12px",borderRadius:"8px",background:"rgba(239,68,68,0.1)",color:"var(--danger)",fontSize:"13px",marginBottom:"8px"},children:f}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn btn-secondary",onClick:x,children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",onClick:c,disabled:!n.trim()||v,children:v?"Creating...":"Create Server"})]})]})})}function ut(){Ue({title:"Servers",description:"Community servers — real-time group conversations, battles, and collaboration. Like Discord, but decentralized.",noindex:!0});const{user:n,loading:i}=qe(),[o,p]=s.useState([]),[r,l]=s.useState(null),[c,x]=s.useState([]),[v,f]=s.useState([]),[a,j]=s.useState(""),[k,h]=s.useState(!1),[S,b]=s.useState(!0),[C,N]=s.useState(null),[R,O]=s.useState(!1),[w,_]=s.useState(null),[E,Y]=s.useState(null),[F,H]=s.useState(!1),[te,I]=s.useState(!1),[L,K]=s.useState(""),[se,V]=s.useState(""),[U,G]=s.useState(!1),[re,D]=s.useState(null),[ne,ae]=s.useState(!1),[ie,Ne]=s.useState(!0),[oe,P]=s.useState(!1),[,le]=s.useState(null),[ce,ze]=s.useState(""),[Re,de]=s.useState(""),[ue,pe]=s.useState(null),[z,xe]=s.useState(null),[q,_e]=s.useState(!1),[T,Me]=s.useState(0),[he,Ie]=s.useState(0),[$,Te]=s.useState(!1),[ge,me]=s.useState(!1),[We,fe]=s.useState(null),[Be,Ee]=s.useState("Welcome to the server!"),[J,Le]=s.useState(!1),[ve]=Ae(),{chatId:Q}=Oe(),X=Q&&/^\d+$/.test(Q)?Number(Q):null,De=s.useRef(null),Pe=s.useRef(null),M=s.useRef(0);s.useEffect(()=>{if(!n)return;b(!0),N(null),y.groupChat.list().then(g=>{if(g.success){const m=g.data||[];if(p(m),X!=null){const u=m.find(d=>d.id===X);u&&l(u)}}else N(g.error||"Failed to load servers")}).catch(()=>{N("Network error — couldn't load servers")}).finally(()=>b(!1));const t=ve.get("join");t&&y.groupChat.joinByCode(t).then(g=>{g.success&&y.groupChat.list().then(m=>{if(m.success){const u=m.data||[];p(u);const d=u.find(W=>W.invite_code===t);d&&l(d)}}).catch(()=>{})}).catch(()=>{})},[n,ve,X]);const Z=s.useCallback(async(t,g)=>{g||(O(!0),_(null));try{const m=await y.groupChat.get(t,80);if(m.success){const u=m.data,d=u.messages||[];if(!g)x(d),f(u.members||[]),d.length>0&&(M.current=d[d.length-1].id,st(d.map(W=>W.id)));else{const W=d.length>0?d[d.length-1].id:0;W>M.current&&(x(d),M.current=W),f(u.members||[])}}else g||_(m.error||"Failed to load channel messages")}catch{g||_("Network error — couldn't load messages")}finally{g||O(!1)}},[]),$e=s.useCallback(t=>{const g=t;if(g.type==="message"){const m=g.payload;x(u=>u.some(d=>d.id===m.id)?u:[...u,m]),m.id>M.current&&(M.current=m.id)}},[]),{send:ye}=Xe({chatId:r?.id??null,user:n??void 0,onMessage:$e});s.useEffect(()=>{r&&(Pe.current=r.id,Z(r.id))},[r,r?.id,Z]),s.useEffect(()=>{r&&(fe(null),y.presence.online(r.community_id??void 0).then(t=>{t?.success&&typeof t.data?.total_online=="number"&&fe(t.data.total_online)}).catch(()=>{}))},[r]),s.useEffect(()=>{const t=document.querySelector(".servers-messages");t&&(t.scrollTop=t.scrollHeight)},[c]);const be=s.useCallback(async()=>{if(L.trim()){ae(!0),D(null);try{const t=await y.groupChat.create({name:L.trim(),community_slug:void 0,is_private:U});if(t.success){const g=t.data?.invite_code;g&&le(g),y.groupChat.list().then(m=>{m.success&&p(m.data||[])}).catch(()=>{}),K(""),V(""),G(!1),I(!1)}else D(t.error||"Failed to create server")}catch{D("Network error — couldn't create server")}finally{ae(!1)}}},[L,U]),je=s.useCallback(async()=>
1{if(!a.trim()||!r)return;if(T>0){const u=(Date.now()-he)/1e3;if(u<T){const d=Math.ceil(T-u);Y(`Slow mode: wait ${d}s before sending`),h(!1);return}}h(!0),Y(null),H(!0);try{const u=await He(a.trim(),"message"),d=Ke(u);if(Ve(d)){Y(Ge(d)),h(!1),H(!1);return}d.action==="flag_for_review"&&console.warn("Message flagged for review:",d.reason)}catch(u){console.warn("Moderation check failed, allowing through:",u)}finally{H(!1)}if(!ye({type:"message",chatId:r.id,senderId:n.id,username:n.username,avatar_color:n.avatar_color,message:a.trim()})&&!(await y.groupChat.send(r.id,a.trim(),z??void 0)).success){h(!1);return}const g=Date.now(),m={id:g,chat_id:r.id,sender_id:n.id,message:a.trim(),created_at:new Date().toISOString(),username:n.username,avatar_color:n.avatar_color};x(u=>[...u,m]),g>M.current&&(M.current=g),T>0&&Ie(Date.now()),j(""),h(!1)},[a,r,n,z,T,he,ye]),Se=()=>{if(!r?.invite_code)return;const t=`${window.location.origin}/servers?join=${r.invite_code}`;navigator.clipboard.writeText(t).then(()=>{le(r.invite_code),de("✅ Copied!"),setTimeout(()=>de(""),3e3)})},A=v.filter(t=>t.role==="owner"),ee=v.filter(t=>t.role!=="owner");return i?e.jsx("div",{className:"main-container fade-in",children:e.jsx("div",{className:"content-area",children:e.jsx("div",{className:"loading-spinner",style:{minHeight:"60vh",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("div",{className:"spinner"})})})}):n?r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"servers-layout",children:[te&&e.jsx(ke,{name:L,setName:K,desc:se,setDesc:V,isPrivate:U,setIsPrivate:G,onCreate:be,onClose:()=>{I(!1),D(null)},loading:ne,error:re}),e.jsxs("div",{className:"servers-sidebar",children:[e.jsx("button",{className:"server-icon-btn",onClick:()=>l(null),title:"Server list",style:{background:"var(--bg-tertiary)",borderRadius:16,marginBottom:4},children:"🏠"}),e.jsx("div",{style:{width:32,height:2,background:"var(--border)",borderRadius:1,margin:"4px 0"}}),o.map(t=>e.jsx("button",{className:`server-icon-btn ${t.id===r.id?"active":""}`,onClick:()=>l(t),title:t.name,style:{background:t.id===r.id?"var(--accent)":"var(--bg-tertiary)"},children:t.name[0]?.toUpperCase()||"?"},t.id)),e.jsx("button",{className:"server-add-btn",onClick:()=>I(!0),title:"Create server",children:"+"})]}),e.jsxs("div",{className:"servers-channel-list",children:[e.jsxs("div",{className:"servers-channel-header",children:[r.name,r.is_private?" 🔒":""]}),e.jsxs("div",{className:"servers-channel-scroll",children:[e.jsxs("button",{className:"channel-item active",children:[e.jsx("span",{className:"channel-hash",children:"#"}),e.jsx("span",{children:"general"})]}),e.jsxs(B,{to:"/battles",className:"channel-item",style:{textDecoration:"none",color:"inherit"},children:[e.jsx("span",{style:{fontSize:"14px",opacity:.5},children:"⚔️"}),e.jsx("span",{children:"battles"})]}),e.jsxs("div",{style:{padding:"12px 16px 8px"},children:[r.invite_code&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:e.jsx("button",{className:"btn btn-ghost btn-sm",onClick:Se,style:{flex:1,fontSize:"11px",padding:"4px 8px"},children:Re||"🔗 Copy Invite"})}),e.jsx("div",{style:{display:"flex",gap:4,marginTop:6},children:e.jsx("input",{type:"text",value:ce,onChange:t=>ze(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ce.trim()&&Se()},placeholder:"@invite user",style:{flex:1,padding:"4px 8px",fontSize:"11px",background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:"6px",color:"var(--text-primary)"}})})]}),e.jsxs("div",{style:{padding:"4px 16px"},children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,color:"var(--text-muted)",marginBottom:6,textTransform:"uppercase"},children:"Admin"}),e.jsxs("button",{onClick:()=>_e(!q),style:{padding:"4px 8px",borderRadius:"12px",border:"1px solid var(--border)",background:q?"var(--accent-light)":"var(--bg-input)",color:q?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontSize:"11px",fontWeight:600,transition:"all 0.15s",width:"100%",marginBottom:4},children:["🎭 ",q?"Anonymous: ON":"Anonymous: OFF"]}),e.jsxs("select",{value:T,onChange:t=>Me(Number(t.target.value)),style:{width:"100%",padding:"4px 6px",fontSize:"11px",marginBottom:4,background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:"6px",color:"var(--text-primary)"},children:[e.jsx("option",{value:0,children:"Slow Mode: Off"}),e.jsx("option",{value:30,children:"30s"}),e.jsx("option",{value:60,children:"1m"}),e.jsx("option",{value:300,children:"5m"}),e.jsx("option",{value:900,children:"15m"}),e.jsx("option",{value:3600,children:"1h"})]}),e.jsxs("button",{onClick:()=>Te(!$),style:{padding:"4px 8px",borderRadius:"12px",border:"1px solid var(--border)",background:$?"var(--accent-light)":"var(--bg-input)",color:$?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontSize:"11px",fontWeight:600,transition:"all 0.15s",width:"100%",marginBottom:4},children:["🛡️ Anti-Spam: ",$?"ON":"OFF"]}),e.jsx("button",{onClick:()=>Le(!J),style:{padding:"4px 8px",borderRadius:"12px",border:"1px solid var(--border)",background:J?"var(--accent-light)":"var(--bg-input)",color:J?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontSize:"11px",fontWeight:600,transition:"all 0.15s",width:"100%"}
1,children:"👋 Welcome Msg"}),J&&e.jsx("div",{style:{marginTop:4},children:e.jsx("input",{type:"text",value:Be,onChange:t=>Ee(t.target.value),placeholder:"Welcome message",style:{width:"100%",padding:"4px 8px",fontSize:"11px",background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:"6px",color:"var(--text-primary)"}})})]}),e.jsxs("div",{style:{padding:"4px 16px"},children:[e.jsxs("button",{onClick:()=>xe(z?null:5),style:{padding:"4px 8px",borderRadius:"12px",border:"1px solid var(--border)",background:z?"var(--accent-light)":"var(--bg-input)",color:z?"var(--accent)":"var(--text-muted)",cursor:"pointer",fontSize:"11px",fontWeight:600,transition:"all 0.15s",width:"100%"},children:["⏳ ",z?`Ephemeral ${z}m`:"Ephemeral"]}),z&&e.jsxs("select",{value:z,onChange:t=>xe(Number(t.target.value)),style:{width:"100%",padding:"3px 4px",fontSize:"11px",marginTop:4,background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:"6px",color:"var(--text-primary)"},children:[e.jsx("option",{value:1,children:"1m"}),e.jsx("option",{value:5,children:"5m"}),e.jsx("option",{value:15,children:"15m"}),e.jsx("option",{value:30,children:"30m"}),e.jsx("option",{value:60,children:"1h"})]})]})]})]}),oe&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mobile-menu-backdrop",onClick:()=>P(!1)}),e.jsx("div",{className:"mobile-menu-drawer",style:{left:0,right:"auto",borderRight:"1px solid var(--border)",borderLeft:"none",animation:"slideInLeft 0.25s ease",width:"min(300px, 85vw)"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontWeight:800,fontSize:"15px"},children:"Servers"}),e.jsx("button",{onClick:()=>P(!1),style:{border:"none",background:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:"18px"},children:"✕"})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px 0"},children:o.map(t=>e.jsxs("button",{onClick:()=>{l(t),P(!1)},style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderRadius:8,width:"100%",textAlign:"left",cursor:"pointer",background:t.id===r.id?"var(--accent-light)":"transparent",color:t.id===r.id?"var(--accent-hover)":"var(--text-secondary)",fontWeight:t.id===r.id?700:500,border:"none",fontSize:"14px",transition:"all 0.15s",fontFamily:"inherit"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:800,color:"white",flexShrink:0},children:t.name[0]?.toUpperCase()||"?"}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),t.message_count?e.jsx("span",{style:{marginLeft:"auto",fontSize:"11px",color:"var(--text-muted)"},children:t.message_count}):null]},t.id))}),e.jsx("div",{style:{padding:"10px 16px",borderTop:"1px solid var(--border)"},children:e.jsx("button",{className:"btn btn-primary btn-sm btn-block",onClick:()=>{P(!1),I(!0)},children:"+ New Server"})})]})})]}),e.jsxs("div",{className:"servers-chat-area",children:[e.jsxs("div",{className:"servers-chat-header",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("button",{onClick:()=>P(!oe),style:{display:"none",padding:6,borderRadius:8,border:"none",background:"var(--bg-hover)",color:"var(--text-secondary)",cursor:"pointer",fontSize:"18px"},className:"servers-mobile-back","aria-label":"Server list",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}),e.jsx("span",{style:{fontSize:"16px",opacity:.4},children:"#"}),e.jsx("span",{style:{fontSize:"15px",fontWeight:700,color:"var(--text-primary)"},children:r?.name||"general"}),r&&e.jsx(Qe,{contextId:String(r.id),contextType:"chat",compact:!0})]}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>me(!ge),style:{fontSize:"12px",padding:"4px 10px"},title:"Stats",children:"📊"}),e.jsxs("button",{className:"btn btn-ghost btn-sm",onClick:()=>Ne(!ie),style:{fontSize:"12px",padding:"4px 10px"},children:["👥 ",v.length]})]})]}),e.jsx(Ze,{room:r.name}),e.jsxs("div",{className:"servers-messages",children:[R&&c.length===0&&e.jsxs("div",{style:{textAlign:"center",color:"var(--text-muted)",padding:"60px 20px"},children:[e.jsx("div",{className:"spinner",style:{margin:"0 auto 12px"}}),e.jsx("p",{style:{fontSize:"13px"},children:"Loading messages..."})]}),w&&c.length===0&&e.jsxs("div",{style:{textAlign:"center",color:"var(--text-muted)",padding:"60px 20px"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"12px",opacity:.4},children:"⚠️"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--danger)",fontWeight:600},children:w}),e.jsx("button",{className:"btn btn-secondary btn-sm",style:{marginTop:"8px"},onClick:()=>Z(r.id),children:"Retry"})]}),!R&&!w&&c.length===0&&e.jsxs("div",{style:{textAlign:"center",color:"var(--text-muted)",padding:"60px 20px"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"12px"},children:"👋"}),e.jsxs("p",{style:{fontSize:"15px",fontWeight:600},children:["Welcome to #",r.name,"!"]}),e.jsx("p",{style:{fontSize:"13px"},children:"This is the start of the conversation."})]}),$&&c.length>1&&c.slice(-20).filter((t,g,m)=>m.filter(d=>d.sender_id===t.sender_id&&d.message===t.message).length<=1).length<c.slice(-20).length&&e.jsx("div",{style:{padding:"6px 12px",borderRadius:8,background:"rgba(245,158,11,0.1)",color:"var(--warning)",fontSize:12,textAlign:"center",marginBottom:8},children:"🛡️ Spam messages filtered"}),c.map((t,g)=>{const m=c[g-1],u=!m||m.sender_id!==t.sender_id;return e.jsxs("div",{className:`servers-msg-row ${u?"msg-first":""}`,children:[e.jsx("div",{className:"servers-msg-avatar",children:u?e.jsx("div",{className:"avatar",style:{background:t.avatar_color,width:"40px",height:"40px",fontSize:"15px"},children:t.username[0]?.toUpperCase()||"?"}):e.jsx("span",{className:"servers-msg-time",style:{fontSize:"10px",o
1pacity:0,paddingTop:2},children:we(t.created_at)})}),e.jsxs("div",{className:"servers-msg-content",children:[u&&e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:2},children:[e.jsx(B,{to:`/u/${t.username}`,className:"servers-msg-name",style:{color:"var(--accent-hover)",textDecoration:"none"},children:t.username}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:we(t.created_at)})]}),e.jsxs("div",{className:"servers-msg-text",children:[t.message,t.expires_at&&e.jsx("span",{style:{marginLeft:6,fontSize:"10px",opacity:.5},children:"⏳"}),e.jsx(tt,{messageId:t.id,room:r.name,totalMembers:v.length})]}),n&&e.jsxs("div",{style:{marginTop:"2px",opacity:0,transition:"opacity 0.2s"},className:"msg-hover-actions",onMouseEnter:d=>d.currentTarget.style.opacity="1",onMouseLeave:d=>d.currentTarget.style.opacity="0",children:[e.jsx(et,{messageId:t.id,room:r.name}),e.jsx("button",{onClick:()=>pe(t.id),title:"Reply in thread",style:{background:"none",border:"none",cursor:"pointer",fontSize:"13px",padding:"2px 6px",opacity:.5,transition:"opacity 0.2s"},children:"💬"})]})]})]},t.id)}),e.jsx("div",{ref:De})]}),e.jsxs("div",{className:"servers-input-bar",children:[E&&e.jsx("div",{style:{padding:"8px 12px",marginBottom:"8px",borderRadius:"8px",background:"var(--danger)",color:"white",fontSize:"13px",fontWeight:500},children:E}),F&&!E&&e.jsx("div",{style:{padding:"8px 12px",marginBottom:"8px",borderRadius:"8px",background:"var(--accent-light)",color:"var(--accent)",fontSize:"13px",fontWeight:500},children:"🛡️ Running AI moderation check…"}),r&&n&&e.jsx(nt,{chatId:`group-${r.id}`,currentUserId:n.id}),e.jsx("input",{type:"text",value:a,onChange:t=>j(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),je())},placeholder:`Message #${r.name}`,disabled:k||F}),e.jsx("button",{onClick:je,disabled:k||F||!a.trim(),className:"btn btn-primary",children:F?"🛡️":k?"...":"Send"})]})]}),ge&&e.jsxs("div",{style:{width:240,flexShrink:0,padding:"16px",background:"var(--bg-secondary)",borderLeft:"1px solid var(--border)",overflowY:"auto"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:800,marginBottom:16},children:"📊 Server Stats"}),[{label:"Members",value:v.length,icon:"👥"},{label:"Messages Today",value:c.filter(t=>new Date(t.created_at).toDateString()===new Date().toDateString()).length,icon:"💬"},{label:"Active Now",value:We??"—",icon:"🟢"},{label:"Owner",value:A.length>0?A[0]?.username:"—",icon:"👑"},{label:"Total Messages",value:r?.message_count||c.length,icon:"📝"}].map(t=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:10,background:"var(--bg-input)",marginBottom:6},children:[e.jsx("span",{style:{fontSize:16},children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:15,fontWeight:700},children:t.value}),e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",textTransform:"uppercase"},children:t.label})]})]},t.label)),e.jsx("button",{onClick:()=>me(!1),style:{width:"100%",padding:"8px",marginTop:8,borderRadius:8,border:"1px solid var(--border)",background:"var(--bg-input)",color:"var(--text-muted)",fontSize:12,cursor:"pointer"},children:"Close Stats"})]}),ie&&e.jsxs("div",{className:"servers-members-panel",children:[A.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"member-group-title",children:["Owner — ",A.length]}),A.map(t=>e.jsxs(B,{to:`/u/${t.username}`,className:"member-row",children:[e.jsx("div",{className:"member-status"}),e.jsx("div",{className:"avatar avatar-sm",style:{background:t.avatar_color},children:t.username[0]?.toUpperCase()||"?"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:600},children:t.username}),e.jsx("span",{style:{fontSize:"10px",color:"var(--warning)"},children:"👑"})]},t.id))]}),ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"member-group-title",children:["Members — ",ee.length]}),ee.map(t=>e.jsxs(B,{to:`/u/${t.username}`,className:"member-row",children:[e.jsx("div",{className:"member-status"}),e.jsx("div",{className:"avatar avatar-sm",style:{background:t.avatar_color},children:t.username[0]?.toUpperCase()||"?"}),e.jsx("span",{style:{flex:1,fontSize:"13px"},children:t.username})]},t.id))]})]})]}),ue&&e.jsx(rt,{threadId:ue,onClose:()=>pe(null)})]}):e.jsx("div",{className:"main-container fade-in",children:e.jsxs("div",{className:"content-area",children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("h1",{style:{fontSize:"26px",fontWeight:900,margin:"0 0 4px"},children:"🏰 Servers"}),e.jsx("p",{style:{color:"var(--text-muted)",fontSize:"13px"},children:"Real-time group chats. Create a server for your community."})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsx("span",{style:{color:"var(--text-muted)",fontSize:"12px"}
1,children:S?"Loading...":`${o.length} servers`}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>I(!0),children:"+ New Server"})]}),C&&e.jsxs("div",{style:{padding:"16px",borderRadius:"12px",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)",marginBottom:"16px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",marginBottom:"8px"},children:"⚠️"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--danger)",fontWeight:600,marginBottom:"8px"},children:C}),e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>{b(!0),N(null),y.groupChat.list().then(t=>{t.success?p(t.data||[]):N(t.error||"Failed to load")}).catch(()=>N("Network error")).finally(()=>b(!1))},children:"Retry"})]}),S?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[1,2,3].map(t=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderRadius:12,background:"var(--bg-input)"},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:12,background:"var(--border)",animation:"pulse 1.5s ease-in-out infinite"}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{height:14,width:"60%",borderRadius:4,background:"var(--border)",marginBottom:6,animation:"pulse 1.5s ease-in-out infinite"}}),e.jsx("div",{style:{height:10,width:"40%",borderRadius:4,background:"var(--border)",animation:"pulse 1.5s ease-in-out infinite"}})]})]},t))}):o.length===0?e.jsxs("div",{className:"empty-state",style:{padding:"48px 20px"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:12,opacity:.4},children:"🏰"}),e.jsx("h3",{children:"No servers yet"}),e.jsx("p",{children:"Create a server to start a community!"})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:o.map(t=>e.jsxs("button",{onClick:()=>l(t),className:"server-card",children:[e.jsx("div",{style:{width:44,height:44,borderRadius:12,background:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,fontWeight:800,color:"white",flexShrink:0},children:t.name[0]?.toUpperCase()||"?"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontWeight:700,fontSize:"15px",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:6},children:[t.name,t.is_private?e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:"🔒"}):null]}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:2},children:[t.message_count||0," messages · by ",t.creator_name]})]}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:"11px",flexShrink:0},children:t.last_message_at?Ce(t.last_message_at):"New"})]},t.id))}),te&&e.jsx(ke,{name:L,setName:K,desc:se,setDesc:V,isPrivate:U,setIsPrivate:G,onCreate:be,onClose:()=>{I(!1),D(null)},loading:ne,error:re})]})}):e.jsx("div",{className:"main-container fade-in",children:e.jsx("div",{className:"content-area",children:e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"icon",children:"🏰"}),e.jsx("h3",{children:"Login to access servers"}),e.jsx("p",{children:"Join real-time group chats and community channels"}),e.jsx(B,{to:"/login",className:"btn btn-primary",style:{display:"inline-block",marginTop:16,textDecoration:"none"},children:"Log in"})]})})})}export{ut as GroupChatPage};

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.