PageSourceSearch

https://bluerevolution-cc.manus.space/assets/ForumTopic-tNFvcF7q.js

js bluerevolution-cc.manus.space collected 2026-10-03 05:00:52 UTC 15,545 bytes, 21 lines download raw bytes

1import{j as e}from"./editor-BhGk7_S1.js";import{B as n}from"./button-CK76V7Lo.js";import{C as S,d as D}from"./card-CaSmhJ1l.js";import{R as I}from"./RichTextEditor-CU8s82Az.js";import{c as w,b as d,t as o,x as W,y as X,z as Y,u as Z,e as ee,d as se,L as C}from"./index-BjIHAQhU.js";import{b as v}from"./leaflet-DcfcX7a_.js";import{A as te}from"./arrow-left-DCV3pRgt.js";import{T as A}from"./trash-2-D_KuvKG4.js";import{P as ce}from"./pen-B2cFW0Yk.js";import"./mapbox-BPFQ-Sfv.js";import"./palette-DTyCI4bH.js";import"./trpc-DqtxhgQo.js";/**
2 * @license lucide-react v0.453.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 ae=w("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/**
7 * @license lucide-react v0.453.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const oe=w("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/**
12 * @license lucide-react v0.453.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const re=w("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
17 * @license lucide-react v0.453.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const ne=w("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),ie=["👍","❤️","🎉"];function le({messageId:c,currentUserId:b,onReactionChange:M}){const[u,y]=v.useState(!1),{data:h,refetch:m}=d.forum.getMessageReactions.useQuery({messageId:c}),k=d.forum.addReaction.useMutation({onSuccess:()=>{m(),M?.()},onError:t=>{o.error(t.message)}}),F=d.forum.removeReaction.useMutation({onSuccess:()=>{m(),M?.()},onError:t=>{o.error(t.message)}}),x=t=>{if(!b){o.error("Please login to react");return}h?.some(l=>l.emoji===t&&l.userId===b)?F.mutate({messageId:c,emoji:t}):k.mutate({messageId:c,emoji:t}),y(!1)},r=h?.reduce((t,i)=>(t[i.emoji]||(t[i.emoji]=[]),t[i.emoji].push(i),t),{});return e.jsxs("div",{"data-loc":"client/src/components/ReactionBar.tsx:67",className:"flex items-center gap-2 mt-2",children:[r&&Object.entries(r).map(([t,i])=>{const l=i.some(p=>p.userId===b),N=i.map(p=>`${p.userFirstName||""} ${p.userLastName||""}`.trim()||p.userEmail||"Unknown").join(", ");return e.jsxs(W,{"data-loc":"client/src/components/ReactionBar.tsx:77",children:[e.jsx(X,{"data-loc":"client/src/components/ReactionBar.tsx:78",asChild:!0,children:e.jsxs(n,{"data-loc":"client/src/components/ReactionBar.tsx:79",variant:l?"default":"outline",size:"sm",onClick:()=>x(t),className:`h-7 px-2 text-sm ${l?"bg-blue-500 hover:bg-blue-600":""}`,children:[e.jsx("span",{"data-loc":"client/src/components/ReactionBar.tsx:85",className:"mr-1",children:t}),e.jsx("span",{"data-loc":"client/src/components/ReactionBar.tsx:86",className:"text-xs",children:i.length})]})}),e.jsx(Y,{"data-loc":"client/src/components/ReactionBar.tsx:89",children:e.jsx("p",{"data-loc":"client/src/components/ReactionBar.tsx:90",className:"text-sm",children:N})})]},t)}),e.jsxs("div",{"data-loc":"client/src/components/ReactionBar.tsx:97",className:"relative",children:[e.jsx(n,{"data-loc":"client/src/components/ReactionBar.tsx:98",variant:"ghost",size:"sm",onClick:()=>y(!u),className:"h-7 px-2 text-sm",children:e.jsx("span",{"data-loc":"client/src/components/ReactionBar.tsx:104",className:"text-lg",children:"+"})}),u&&e.jsx("div",{"data-loc":"client/src/components/ReactionBar.tsx:108",className:"absolute bottom-full left-0 mb-1 bg-popover border border-border rounded-md shadow-lg p-2 flex gap-1 z-50",children:ie.map(t=>e.jsx("button",{"data-loc":"client/src/components/ReactionBar.tsx:110",type:"button",onClick:()=>x(t),className:"text-xl hover:scale-125 transition-transform p-1",children:t},t))})]})]})}function Ne(){const{t:c}=Z(),b=ee(),[,M]=se(),u=parseInt(b.id||"0"),[y,h]=v.useState(null),m=v.useRef(null),[k,F]=v.useState(null),x=v.useRef(null),{data:r}=d.auth.me.useQuery(),{data:t,isLoading:i,refetch:l}=d.forum.getTopic.useQuery({topicId:u}),N=d.forum.createMessage.useMutation({onSuccess:()=>{o.success(c("common.success")),m.current?.clear(),h(null),l()},onError:s=>{o.error(s.message)}}),p=d.forum.updateMessage.useMutation({onSuccess:()=>{o.success(c("common.success")),F(null),x.current?.clear(),l()},onError:s=>{o.error(s.message)}}),P=d.forum.deleteMessage.useMutation({onSuccess:()=>{o.success(c("common.success")),l()},onError:s=>{o.error(s.message)}}),E=d.forum.deleteTopic.useMutation({onSuccess:()=>{o.success(c("common.success")),M("/forum")},onError:s=>{o.error(s.message)}}),z=d.forum.togglePin.useMutation({onSuccess:()=>{o.success(t?.topic.isPinned?c("forum.unpin"):c("forum.pin")),l()},onError:s=>{o.error(s.message)}}),$=s=>{const a=new Map,R=[];
21return s.forEach(g=>{a.set(g.id,{...g,replies:[],depth:0})}),s.forEach(g=>{const j=a.get(g.id);if(g.parentMessageId===null)R.push(j);else{const T=a.get(g.parentMessageId);T?(j.depth=T.depth+1,T.replies.push(j)):R.push(j)}}),R},O=s=>{const a=m.current?.getContent()||"";if(!a.trim()){o.error("Please write a message");return}N.mutate({topicId:u,content:a,parentMessageId:s})},H=(s,a)=>{F(s)},V=s=>{const a=x.current?.getContent()||"";if(!a.trim()){o.error("Message cannot be empty");return}p.mutate({messageId:s,content:a})},Q=s=>{confirm(c("forum.confirmDelete"))&&P.mutate({messageId:s})},q=()=>{confirm(c("forum.confirmDelete"))&&E.mutate({topicId:u})},_=()=>{t?.topic&&z.mutate({topicId:u,isPinned:!t.topic.isPinned})},B=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),J=s=>r&&(r.id===s||r.role==="admin"),U=()=>r&&t&&(r.id===t.topic.userId||r.role==="admin"),L=({message:s,isFirst:a})=>{const j=Math.min(s.depth,5)*24;return e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:203",style:{marginLeft:`${j}px`},children:[e.jsx(S,{"data-loc":"client/src/pages/ForumTopic.tsx:204",className:"bg-card/80 backdrop-blur-sm border-border mb-4",children:e.jsxs(D,{"data-loc":"client/src/pages/ForumTopic.tsx:205",className:"py-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:206",className:"flex items-start gap-4",children:[e.jsx("img",{"data-loc":"client/src/pages/ForumTopic.tsx:208",src:s.profilePicture||"/default-avatar.svg",alt:`${s.userFirstName} ${s.userLastName}`,className:"w-10 h-10 rounded-full object-cover flex-shrink-0"}),e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:213",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:214",className:"flex items-center gap-2 mb-2",children:[e.jsx(C,{"data-loc":"client/src/pages/ForumTopic.tsx:215",href:`/profile/${s.userId}`,children:e.jsxs("span",{"data-loc":"client/src/pages/ForumTopic.tsx:216",className:"font-semibold text-blue-400 hover:text-blue-300 cursor-pointer",children:[s.userFirstName," ",s.userLastName]})}),e.jsx("span",{"data-loc":"client/src/pages/ForumTopic.tsx:220",className:"text-sm text-muted-foreground",children:B(s.createdAt)}),s.updatedAt&&new Date(s.updatedAt).getTime()>new Date(s.createdAt).getTime()&&e.jsxs("span",{"data-loc":"client/src/pages/ForumTopic.tsx:224",className:"text-xs text-muted-foreground italic",children:["(",c("forum.editedBy"),")"]})]}),k===s.id?e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:229",className:"space-y-2",children:[e.jsx(I,{"data-loc":"client/src/pages/ForumTopic.tsx:230",ref:x,initialContent:s.content,className:"bg-background/50"}),e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:235",className:"flex gap-2",children:[e.jsx(n,{"data-loc":"client/src/pages/ForumTopic.tsx:236",size:"sm",onClick:()=>V(s.id),disabled:p.isPending,className:"bg-blue-500 hover:bg-blue-600",children:c("forum.save")}),e.jsx(n,{"data-loc":"client/src/pages/ForumTopic.tsx:244",size:"sm",variant:"outline",onClick:()=>{F(null),x.current?.clear()},children:c("forum.cancel")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{"data-loc":"client/src/pages/ForumTopic.tsx:258",className:"prose prose-sm max-w-none text-foreground mb-3",dangerouslySetInnerHTML:{__html:s.content}}),e.jsx(le,{"data-loc":"client/src/pages/ForumTopic.tsx:264",messageId:s.id,currentUserId:r?.id,onReactionChange:()=>l()}),e.jsxs(n,{"data-loc":"client/src/pages/ForumTopic.tsx:271",variant:"ghost",size:"sm",onClick:()=>{h(s.id),m.current?.clear()},className:"text-blue-400 hover:text-blue-300",children:[e.jsx(re,{"data-loc":"client/src/pages/ForumTopic.tsx:280",className:"w-4 h-4 mr-1"}),c("forum.reply")]})]})]}),J(s.userId)&&k!==s.id&&e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:288",className:"flex gap-1 flex-shrink-0",children:[e.jsx(n,{"data-loc":"client/src/pages/ForumTopic.tsx:289",variant:"ghost",size:"sm",onClick:()=>H(s.id,s.content),children:e.jsx(ce,{"data-loc":"client/src/pages/ForumTopic.tsx:294",className:"w-4 h-4"})}
21),!a&&e.jsx(n,{"data-loc":"client/src/pages/ForumTopic.tsx:298",variant:"ghost",size:"sm",onClick:()=>Q(s.id),disabled:P.isPending,children:e.jsx(A,{"data-loc":"client/src/pages/ForumTopic.tsx:304",className:"w-4 h-4"})})]})]}),y===s.id&&e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:313",className:"mt-4 pt-4 border-t border-border",children:[e.jsx(I,{"data-loc":"client/src/pages/ForumTopic.tsx:314",ref:m,placeholder:c("forum.writeMessage"),className:"bg-background/50 mb-2"}),e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:319",className:"flex gap-2",children:[e.jsxs(n,{"data-loc":"client/src/pages/ForumTopic.tsx:320",size:"sm",onClick:()=>O(s.id),disabled:N.isPending,className:"bg-blue-500 hover:bg-blue-600",children:[e.jsx(ne,{"data-loc":"client/src/pages/ForumTopic.tsx:326",className:"w-4 h-4 mr-1"}),N.isPending?c("forum.loading"):c("forum.reply")]}),e.jsx(n,{"data-loc":"client/src/pages/ForumTopic.tsx:329",size:"sm",variant:"outline",onClick:()=>{h(null),m.current?.clear()},children:c("forum.cancel")})]})]})]})}),s.replies.map(T=>e.jsx(L,{"data-loc":"client/src/pages/ForumTopic.tsx:347",message:T,isFirst:!1},T.id))]})};if(i)return e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:355",className:"min-h-screen bg-background text-foreground flex items-center justify-center",children:[e.jsx("div",{"data-loc":"client/src/pages/ForumTopic.tsx:356",className:"starfield"}),e.jsx("p",{"data-loc":"client/src/pages/ForumTopic.tsx:357",className:"text-muted-foreground relative z-10",children:c("forum.loading")})]});if(!t)return e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:364",className:"min-h-screen bg-background text-foreground flex items-center justify-center",children:[e.jsx("div",{"data-loc":"client/src/pages/ForumTopic.tsx:365",className:"starfield"}),e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:366",className:"text-center relative z-10",children:[e.jsx("p",{"data-loc":"client/src/pages/ForumTopic.tsx:367",className:"text-muted-foreground mb-4",children:c("forum.noTopics")}),e.jsx(C,{"data-loc":"client/src/pages/ForumTopic.tsx:368",href:"/forum",children:e.jsx(n,{"data-loc":"client/src/pages/ForumTopic.tsx:369",variant:"outline",children:c("forum.backToMap")})})]})]});const{topic:f,messages:G}=t,K=$(G);return e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:380",className:"min-h-screen bg-background text-foreground",children:[e.jsx("div",{"data-loc":"client/src/pages/ForumTopic.tsx:381",className:"starfield"}),e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:383",className:"relative z-10",children:[e.jsx("header",{"data-loc":"client/src/pages/ForumTopic.tsx:385",className:"border-b border-border bg-card/50 backdrop-blur-sm",children:e.jsx("div",{"data-loc":"client/src/pages/ForumTopic.tsx:386",className:"container py-3 md:py-6",children:e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:387",className:"flex items-center justify-between gap-2",children:[e.jsx(C,{"data-loc":"client/src/pages/ForumTopic.tsx:388",href:"/forum",children:e.jsxs(n,{"data-loc":"client/src/pages/ForumTopic.tsx:389",variant:"ghost",className:"gap-1 md:gap-2 text-xs md:text-sm px-2 md:px-4",children:[e.jsx(te,{"data-loc":"client/src/pages/ForumTopic.tsx:390",className:"w-3 h-3 md:w-4 md:h-4"}),e.jsx("span",{"data-loc":"client/src/pages/ForumTopic.tsx:391",className:"hidden sm:inline",children:c("forum.backToMap")}),e.jsx("span",{"data-loc":"client/src/pages/ForumTopic.tsx:392",className:"sm:hidden",children:"Back"})]})}),e.jsx("h1",{"data-loc":"client/src/pages/ForumTopic.tsx:395",className:"text-lg md:text-2xl font-bold text-gradient-blue truncate px-4",children:f.title}),r?.role==="admin"&&e.jsx(n,{"data-loc":"client/src/pages/ForumTopic.tsx:400",variant:"ghost",size:"sm",onClick:_,className:"gap-1 md:gap-2 text-xs md:text-sm",disabled:z.isPending,children:f.isPinned?e.jsxs(e.Fragment,{children:[e.jsx(ae,{"data-loc":"client/src/pages/ForumTopic.tsx:409",className:"w-3 h-3 md:w-4 md:h-4"}),e.jsx("span",{"data-loc":"client/src/pages/ForumTopic.tsx:410",className:"hidden sm:inline",children:c("forum.unpin")})]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{"data-loc":"client/src/pages/ForumTopic.tsx:414",className:"w-3 h-3 md:w-4 md:h-4"}),e.jsx("span",{"data-loc":"client/src/pages/ForumTopic.tsx:415",className:"hidden sm:inline",children:c("forum.pin")})]})}),!r||r.role!=="admin"?e.jsx("div",{"data-loc":"client/src/pages/ForumTopic.tsx:420",className:"w-16 md:w-24"}):null]})})}),e.jsx("main",{"data-loc":"client/src/pages/ForumTopic.tsx:426",className:"container py-8 md:py-12",children:e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:427",className:"max-w-5xl mx-auto",children:[e.jsx(S,{"data-loc":"client/src/pages/ForumTopic.tsx:429",className:"bg-card/80 backdrop-blur-sm border-border mb-6",children:e.jsx(D,{"data-loc":"client/src/pages/ForumTopic.tsx:430",className:"py-4",children:e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:431",className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:432",className:"flex-1",children:[e.jsx("h2",{"data-loc":"client/src/pages/ForumTopic.tsx:433",className:"text-2xl font-bold text-foreground mb-3",children:f.title}),e.jsxs("div",{"data-loc":"client/src/pages/ForumTopic.tsx:434",className:"text-sm text-muted-foreground",children:[c("forum.postedBy")," ",f.userFirstName," ",f.userLastName," • ",B(f.createdAt)]})]}),U()&&e.jsx(n,{"data-loc":"client/src/pages/ForumTopic.tsx:439",variant:"destructive",size:"sm",onClick:q,disabled:E.isPending,children:e.jsx(A,{"data-loc":"client/src/pages/ForumTopic.tsx:445",className:"w-4 h-4"})})]})})}),e.jsx("div",{"data-loc":"client/src/pages/ForumTopic.tsx:453",children:K.map((s,a)=>e.jsx(L,{"data-loc":"client/src/pages/ForumTopic.tsx:455",message:s,isFirst:a===0},s.id))})]})})]})]})}export{Ne 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.