1import{p as D,u as U,h as W,r as c,a as y,b as d,j as e,M as b,i as x,L as n,d as I,E as V,t as T,e as q,q as o,c as u}from"./index-DU7EiW5Z.js";import{C as h}from"./CommunityLayout-yLlWUrHy.js";import{A as G,t as J,E as X,a as Y,C as Z,b as _}from"./CommunityThread-CJ-Nczr4.js";import{C as ee}from"./clock-B9JnlOtD.js";import{S as te}from"./share-2-Tq0ngf2K.js";import{F as se,B as ae}from"./Header-dH_zm7gK.js";import{H as re}from"./heart-2LlUo9Lo.js";import{B as ie}from"./bell-off-BLP6ok5w.js";import{E as oe}from"./eye-CTueQISh.js";import"./Footer-CcSM9az0.js";import"./index-CUko9iY5.js";import"./mail-kXcN9TSZ.js";import"./circle-question-mark-BM3yB2OI.js";import"./lightbulb-WKC2Tcly.js";import"./house-CXnXROsz.js";import"./trophy-9c_RsmM1.js";import"./pencil-5paIu0BF.js";import"./BackToTop-DByhqIJJ.js";import"./arrow-up-Nc3LYYRG.js";import"./purify.es-D1KCXlL6.js";import"./RichTextEditor--f_IfR4f.js";import"./index-LD0K5Pxl.js";import"./index-C7yKKq-w.js";import"./link-2-Cm7kVful.js";import"./quote-D_xyye7d.js";import"./list-ordered-D7fADXnO.js";import"./play-Dg39qTJr.js";import"./FoundingMemberBadge-BDALFT0a.js";import"./CommunityManagerBadge-DpCTunL0.js";import"./CompanyBadge-D-G1FAwJ.js";import"./switch-r62tsx0m.js";import"./index-BRAnWjFy.js";import"./triangle-alert-PxngkC0j.js";import"./eye-off-ByDULLtE.js";import"./check-DnvdljkK.js";import"./index-D7TqL6Li.js";import"./index-ChbWPcUi.js";import"./badge-DAERl6XE.js";import"./Normal_(1)_1770767936075-DWlfSefL.js";import"./arrow-left-Duva7iIn.js";import"./video-CfxPEA4p.js";function ne(f){const a=document.createElement("div");return a.innerHTML=f,a.textContent||a.innerText||""}function Je(){const a=D().slug||"",{user:i,isAuthenticated:p}=U(),{toast:l}=W(),[j,N]=c.useState(""),[v,R]=c.useState("best"),[B,w]=c.useState(!1),[k,m]=c.useState(!1),{data:S,isLoading:E}=y({queryKey:[`/api/community/tool/${a}`],enabled:!!a&&p}),t=S?.thread,K=S?.relatedThreads||[],{data:C}=y({queryKey:[`/api/community/threads/${t?.id}/replies`,{sort:v}],enabled:!!t?.id&&p}),{data:r}=y({queryKey:[`/api/community/threads/${t?.id}/engagement`],enabled:!!t?.id&&!!i}),P=d({mutationFn:()=>u("POST",`/api/community/threads/${t?.id}/bookmark`),onSuccess:()=>{o.invalidateQueries({queryKey:[`/api/community/threads/${t?.id}/engagement`]}),o.invalidateQueries({queryKey:["/api/community/tool-discussion"]})}}),F=d({mutationFn:()=>u("POST",`/api/community/threads/${t?.id}/bookmark/mute`),onSuccess:()=>o.invalidateQueries({queryKey:[`/api/community/threads/${t?.id}/engagement`]})}),L=d({mutationFn:s=>u("POST",`/api/community/threads/${t?.id}/replies`,s),onSuccess:()=>{N(""),o.invalidateQueries({queryKey:[`/api/community/threads/${t?.id}/replies`]}),o.invalidateQueries({queryKey:[`/api/community/tool/${a}`]}),l({title:"Comment posted!"})},onError:()=>l({title:"Failed to post comment",variant:"destructive"})}),A=d({mutationFn:s=>u("POST",`/api/community/replies/${s}/like`),onSuccess:()=>o.invalidateQueries({queryKey:[`/api/community/threads/${t?.id}/replies`]})}),$=(s,g)=>L.mutate({body:s,parentReplyId:g});if(!p)return e.jsx(h,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[#e81b6e]/10 flex items-center justify-center mb-5",children:e.jsx(b,{className:"w-8 h-8 text-[#e81b6e]"})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:"Members only"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-6 max-w-sm",children:"Sign in to read and join this discussion. It's free and takes less than a minute."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{onClick:()=>window.location.href="/signin",className:"bg-[#e81b6e] hover:bg-[#c4155c] text-white px-6",children:"Sign in"}),e.jsx(n,{href:"/community",children:e.jsx(x,{variant:"outline",children:"Back to Community"})})]})]})});if(E)return e.jsx(h,{children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-20 bg-gray-100 rounded-2xl"}),e.jsx("div",{className:"h-6 bg-gray-200 rounded w-1/2"}),e.jsx("div",{className:"h-4 bg-gray-100 rounded w-full"})]})});if(!t)return e.jsx(h,{children:e.jsxs("div",{className:"py-16 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb
1-2",children:"Tool discussion not found"}),e.jsx(n,{href:"/community",children:e.jsx(x,{children:"Back to Community"})})]})});const Q=()=>{navigator.clipboard.writeText(window.location.href),l({title:"Link copied to clipboard!"})},H=()=>{if(!i){l({title:"Sign in required",description:"Please sign in to report content.",variant:"destructive"});return}m(!1),w(!0)},O=C?.replies||[],z=C?.userLikes||{},M=K.filter(s=>s.id!==t.id);return e.jsxs(h,{children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-6 mb-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[t.toolLogo?e.jsx("img",{src:t.toolLogo,alt:"",className:"w-12 h-12 rounded-xl object-cover flex-shrink-0",loading:"lazy",decoding:"async"}):e.jsx(G,{name:t.toolName,size:"lg"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-bold text-gray-900 leading-snug mb-2",children:I(t.toolName||t.title)}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-sm text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1 text-gray-400",children:[e.jsx(ee,{className:"w-3.5 h-3.5"}),t.createdAt&&J(t.createdAt)]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>m(!k),className:"text-gray-400 hover:text-gray-600",children:e.jsx(X,{className:"w-4 h-4"})}),k&&e.jsxs("div",{className:"absolute left-0 top-6 z-10 bg-white rounded-xl shadow-lg border border-gray-100 py-1 min-w-[140px]",onMouseLeave:()=>m(!1),children:[e.jsxs("button",{onClick:()=>{Q(),m(!1)},className:"w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2",children:[e.jsx(te,{className:"w-3.5 h-3.5"})," Share"]}),e.jsxs("button",{onClick:H,className:"w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 flex items-center gap-2",children:[e.jsx(se,{className:"w-3.5 h-3.5"})," Report"]})]})]})]}),e.jsx("div",{className:"mt-3",children:e.jsx(n,{href:T({name:t.toolName||""}),children:e.jsxs("span",{className:"text-sm text-blue-600 hover:text-blue-700 font-medium flex items-center gap-1",children:["View Full Listing ",e.jsx(V,{className:"w-3 h-3"})]})})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center w-14 h-14 rounded-xl border border-gray-200 text-gray-500",children:[e.jsx(b,{className:"w-4 h-4 mb-0.5"}),e.jsx("span",{className:"text-sm font-semibold leading-none",children:t.replyCount??0})]}),e.jsxs("button",{onClick:()=>i&&P.mutate(),title:i?r?.hasBookmarked?"Unlike":"Like":"Sign in to like",className:`flex flex-col items-center justify-center w-14 h-14 rounded-xl border transition-colors ${r?.hasBookmarked?"bg-pink-50 border-pink-200 text-pink-600":"border-gray-200 text-gray-500 hover:border-gray-300 hover:bg-gray-50"}`,children:[e.jsx(re,{className:`w-4 h-4 mb-0.5 ${r?.hasBookmarked?"fill-current":""}`}),e.jsx("span",{className:"text-sm font-semibold leading-none",children:t.bookmarkCount??0})]}),r?.hasBookmarked&&e.jsx("button",{onClick:()=>F.mutate(),title:r?.isMuted?"Unmute notifications":"Mute notifications",className:`flex flex-col items-center justify-center w-10 h-14 rounded-xl border transition-colors ${r?.isMuted?"bg-gray-100 border-gray-300 text-gray-500":"border-gray-200 text-gray-400 hover:border-gray-300 hover:bg-gray-50"}`,children:r?.isMuted?e.jsx(ie,{className:"w-4 h-4"}):e.jsx(ae,{className:"w-4 h-4"})})]})]}),t.body&&e.jsx("p",{className:"mt-4 text-[15px] text-gray-600 leading-relaxed line-clamp-3",children:t.body}),e.jsxs("div",{className:"mt-3 flex items-center gap-1.5 text-sm text-gray-400",children:[e.jsx(oe,{className:"w-4 h-4"}),e.jsxs("span",{children:[t.viewCount?.toLocaleString()||0," views"]})]})]}),e.jsx(Y,{open:B,onClose:()=>w(!1),threadId:t.id}),e.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/30 dark:to-orange-950/30 border border-amber-200 dark:border-amber-800/50 rounded-2xl p-4 sm:p-5 mb-6 flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-100 dar
1k:bg-amber-900/50 flex items-center justify-center flex-shrink-0",children:e.jsx(q,{className:"w-5 h-5 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[14px] sm:text-[15px] font-semibold text-gray-900 dark:text-white",children:["Used ",t.toolName,"? Leave a review!"]}),e.jsx("p",{className:"text-[12px] sm:text-[13px] text-gray-500 dark:text-gray-400 mt-0.5",children:"Help other educators by sharing your experience with a quick rating and review."})]}),e.jsx(n,{href:`${T({name:t.toolName||""})}#reviews`,children:e.jsxs(x,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white whitespace-nowrap gap-1.5",children:[e.jsx(q,{className:"w-3.5 h-3.5"})," Write a Review"]})})]}),e.jsx(Z,{value:j,onChange:N,onSubmit:()=>$(j),isPending:L.isPending,isLocked:t.isLocked,placeholder:`Share your experience with ${t.toolName||"this tool"}...`,user:i}),e.jsx(_,{replies:O,thread:t,onReply:$,onLike:s=>A.mutate(s),userLikes:z,user:i,replySort:v,setReplySort:R}),M.length>0&&e.jsxs("div",{className:"border-t border-gray-100 pt-8 mt-8",children:[e.jsx("h3",{className:"text-base font-bold text-gray-800 mb-4",children:"Related Discussions"}),e.jsx("div",{className:"space-y-3",children:M.map(s=>{const g=s.slug?.startsWith("tool/")?`/community/tool/${s.slug.slice(5)}`:s.slug?.startsWith("category/")?`/community/category/${s.slug.slice(9)}`:`/community/${s.slug}`;return e.jsx(n,{href:g,children:e.jsxs("div",{className:"border border-gray-200 rounded-xl p-4 hover:border-blue-200 hover:bg-blue-50/30 transition-colors cursor-pointer",children:[e.jsx("h4",{className:"font-medium text-gray-800 mb-1",children:s.title}),e.jsx("p",{className:"text-sm text-gray-500 line-clamp-2",children:ne(s.body||"").substring(0,120)}),e.jsx("div",{className:"flex items-center gap-3 mt-2 text-xs text-gray-400",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(b,{className:"w-3 h-3"})," ",s.replyCount??0]})})]})},s.id)})})]})]})}export{Je 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.