PageSourceSearch

https://higherup.ai/assets/PostDetailPage-D0xTiU9B.js

js higherup.ai collected 2026-10-05 14:35:15 UTC 72,992 bytes, 57 lines download raw bytes

1import{j as e}from"./index-12DC86Qv.js";import{r as l,u as _e,L as P,g as kt,f as Ct}from"./vendor-BcCsE5pw.js";import{u as te,a as _,j as We,y as Se,U as Le,b as Nt,t as Tt,k as ie,W as de,d as Rt,X as Ye}from"./App-HVuyHYBt.js";import{R as it,P as _t,L as zt,a as Et}from"./LinkPreviewCard-Dd2f011T.js";import{D as It,a as Bt}from"./ai-defaults-nhDdXnH_.js";import{B as $t}from"./Breadcrumbs-Br0qbXHQ.js";import{F as At}from"./SkeletonLoaders-Bz6YYVRQ.js";import{L as Pt}from"./LoadingSkeleton-BVu6Aw9L.js";function Wt({code:t,language:n}){const r=l.useRef(null);return l.useEffect(()=>{if(!r.current)return;const i=window.hljs;i&&i.highlightElement(r.current)},[t,n]),e.jsxs("div",{style:{position:"relative",margin:"10px 0",borderRadius:"var(--radius-sm)",overflow:"hidden",background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[n&&e.jsx("div",{style:{position:"absolute",top:0,right:0,padding:"2px 8px",fontSize:"10px",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.5px",background:"var(--bg-primary)",borderBottomLeftRadius:"var(--radius-sm)"},children:n}),e.jsx("pre",{style:{margin:0,padding:"14px",overflow:"auto",fontSize:"13px",lineHeight:"1.5",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",color:"var(--text-primary)"},children:e.jsx("code",{ref:r,className:n?`language-${n}`:"",children:t})})]})}function Lt(t){const n=[],r=/```(\w*)\n([\s\S]*?)```/g;let i=0,s=0,o;for(;(o=r.exec(t))!==null;)o&&(o.index!=null&&o.index>i&&n.push(t.slice(i,o.index)),n.push(e.jsx(Wt,{code:o[2]?.trim()??"",language:o[1]??void 0},s++)),i=(o.index??0)+o[0].length);return i<t.length&&n.push(t.slice(i)),n}function De({entityType:t,entityId:n,initialVote:r,initialScore:i,size:s="mini"}){const{user:o}=te(),d=_e(),[c,a]=l.useState(r),[x,p]=l.useState(i),[b,g]=l.useState(!1),w=async h=>{if(!o){d("/login");return}if(b)return;g(!0);const v=c===h?0:h,y=await _.vote({entity_type:t,entity_id:n,vote_type:v});if(y.success){let S=0;v===0?S=c===1?-1:1:v===1?S=c===-1?2:1:S=c===1?-2:-1,p(j=>j+S),a(y.data?.vote??null)}g(!1)};return s==="mini"?e.jsx("div",{className:"comment-actions",children:e.jsxs("div",{className:"vote-mini",children:[e.jsx("button",{className:`vote-btn upvote ${c===1?"active":""}`,"aria-label":"Upvote",onClick:()=>w(1),disabled:b,children:"▲"}),e.jsx("span",{className:`vote-score ${c===1?"upvoted":c===-1?"downvoted":""}`,children:x}),e.jsx("button",{className:`vote-btn downvote ${c===-1?"active":""}`,"aria-label":"Downvote",onClick:()=>w(-1),disabled:b,children:"▼"})]})}):e.jsxs("div",{className:"post-votes",children:[e.jsx("button",{className:`vote-btn upvote ${c===1?"active":""}`,"aria-label":"Upvote",onClick:()=>w(1),disabled:b,children:"▲"}),e.jsx("span",{className:`vote-score ${c===1?"upvoted":c===-1?"downvoted":""}`,children:x}),e.jsx("button",{className:`vote-btn downvote ${c===-1?"active":""}`,"aria-label":"Downvote",onClick:()=>w(-1),disabled:b,children:"▼"})]})}function Xe(){return l.useEffect(()=>{if(document.getElementById("swarm-keyframes"))return;const t=document.createElement("style");t.id="swarm-keyframes",t.textContent=`
2      @keyframes swarm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
3      @keyframes swarm-fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
4    `,document.head.appendChild(t)},[]),null}const we={Skeptic:{icon:"🧐",color:"#ef4444",bg:"rgba(239,68,68,0.08)",label:"The Skeptic",desc:"Questions everything, demands evidence, plays devil's advocate"},Researcher:{icon:"📚",color:"#6366f1",bg:"rgba(99,102,241,0.08)",label:"The Researcher",desc:"Evidence-focused, cites sources, acknowledges uncertainty"},Optimist:{icon:"🌟",color:"#10b981",bg:"rgba(16,185,129,0.08)",label:"The Optimist",desc:"Finds common ground, proposes synthesis, bridges divides"}};function Dt({persona:t,compact:n=!1,onLearnMore:r}){const[i,s]=l.useState(!1),o=we[t]||{icon:"🤖",color:"#6366f1",bg:"rgba(99,102,241,0.08)",label:t,desc:"AI persona"};return n?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 8px",borderRadius:10,fontSize:10,fontWeight:700,background:o.bg,color:o.color,border:`1px solid ${o.color}22`,whiteSpace:"nowrap",cursor:"help",position:"relative"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-label":`Swarm AI persona: ${o.label}`,children:[e.jsx("span",{children:o.icon}),e.jsx("span",{children:o.label}),e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o.color,display:"inline-block",animation:"swarm-pulse 2s infinite"}}),i&&e.jsxs("span",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:6,padding:"8px 12px",borderRadius:8,background:"var(--bg-elevated)",border:"1px solid var(--border)",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",fontSize:11,color:"var(--text-secondary)",whiteSpace:"normal",width:200,textAlign:"center",zIndex:50,animation:"swarm-fadeIn 0.15s ease-out"},children:[o.desc,e.jsx("span",{style:{position:"absolute",bottom:-4,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:8,height:8,background:"var(--bg-elevated)",borderRight:"1px solid var(--border)",borderBottom:"1px solid var(--border)"}}
4)]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xe,{}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",borderRadius:12,background:o.bg,border:`1px solid ${o.color}22`,marginBottom:8},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:"50%",background:o.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,flexShrink:0},children:o.icon}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:700,color:o.color},children:[o.label,e.jsx("span",{style:{marginLeft:6,fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:6,background:`${o.color}15`,color:o.color},children:"SWARM AI"})]}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:o.desc})]}),r&&e.jsx("button",{onClick:r,"aria-label":"Learn about Swarm Debates",style:{padding:"4px 10px",borderRadius:8,fontSize:11,fontWeight:600,background:"transparent",border:`1px solid ${o.color}33`,color:o.color,cursor:"pointer"},children:"Learn more"})]})]})}function Ut(t){const n=Object.keys(we).find(r=>r.toLowerCase()===t.toLowerCase());return n?we[n]??null:null}function Mt({comments:t,postId:n,onReply:r}){return e.jsx("div",{className:"comment-section",children:t.map(i=>e.jsx(ot,{comment:i,postId:n,onReply:r},i.id))})}function ot({comment:t,postId:n,onReply:r,depth:i=0}){const{user:s}=te(),o=_e(),[d,c]=l.useState(!1),[a,x]=l.useState(""),[p,b]=l.useState(!1),[g,w]=l.useState(""),h=Ut(t.username),v=async()=>{if(!s){o("/login");return}if(!a.trim())return;b(!0),w("");const y=await _.comments.create({post_id:n,body:a.trim(),parent_comment_id:t.id});y.success?(x(""),c(!1),_.achievements.check(),r?.()):w(y.error||"Failed to post reply"),b(!1)};return e.jsxs("div",{className:"comment",style:{marginLeft:i>0?24:0,borderLeft:h?`2px solid ${h.color}33`:void 0,paddingLeft:h?12:void 0},children:[h&&e.jsx("div",{style:{marginBottom:6},children:e.jsx(Dt,{persona:t.username,compact:!0})}),e.jsxs("div",{className:"comment-header",children:[e.jsx("div",{className:"avatar avatar-sm",style:{background:t.user_avatar_color||h?.color,display:"inline-flex",verticalAlign:"middle",marginRight:"4px"},children:h?h.icon:We(t.username)}),e.jsx(P,{to:`/u/${t.username}`,className:"username",style:{color:h?.color},children:h?h.label:`u/${t.username}`}),e.jsx("span",{children:"•"}),e.jsx("span",{children:Se(t.created_at)})]}),e.jsx("div",{className:"comment-body",dangerouslySetInnerHTML:{__html:Le(t.body)}}),e.jsxs("div",{className:"comment-actions",children:[e.jsx(De,{entityType:"comment",entityId:t.id,initialVote:t.user_vote,initialScore:t.score}),e.jsx("button",{className:"comment-reply-btn",onClick:()=>{if(!s){o("/login");return}c(!d)},children:"↩ Reply"}),e.jsx("div",{style:{display:"inline-flex",marginLeft:"4px"},children:e.jsx(it,{entityType:"comment",entityId:t.id,compact:!0})})]}),d&&e.jsxs("div",{className:"fade-in",style:{marginTop:"8px"},children:[g&&e.jsx("div",{className:"alert alert-error",style:{padding:"6px 10px",marginBottom:"8px"},children:g}),e.jsx("textarea",{value:a,onChange:y=>x(y.target.value),placeholder:"Write your reply...",rows:3,style:{width:"100%",padding:"8px 12px",background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text-primary)",resize:"vertical"}}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"6px"},children:[e.jsx("button",{className:"btn btn-primary btn-sm",onClick:v,disabled:p||!a.trim(),children:p?"Posting...":"Post Reply"}),e.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>c(!1),children:"Cancel"})]})]}),t.children&&t.children.length>0&&e.jsx("div",{className:"comment-children",children:t.children.map(y=>e.jsx(ot,{comment:y,postId:n,onReply:r,depth:i+1},y.id))})]})}function at({comment:t,postId:n,onRefresh:r,depth:i=0,isThreadRoot:s=!1,threadCount:o=0}){const{user:d}=te(),c=_e(),[a,x]=l.useState(!1),[p,b]=l.useState(""),[g,w]=l.useState(!1),[h,v]=l.useState(""),[y,S]=l.useState(!1),[j,C]=l.useState(!1),E=t.children?.length||0;t.children?.some(N=>N.children&&N.children.length>0);const A=i>=3,z=async()=>
4{if(!d){c("/login");return}if(!p.trim())return;w(!0),v("");const N=await _.comments.create({post_id:n,body:p.trim(),parent_comment_id:t.id});N.success?(b(""),x(!1),_.achievements.check(),r?.()):v(N.error||"Failed to post reply"),w(!1)};return e.jsxs("div",{className:`thread-node ${s?"thread-root":""}`,style:{marginLeft:i>0?Math.min(i*20,80):0,borderLeft:i>0?"2px solid var(--border)":"none",paddingLeft:i>0?"12px":0,marginBottom:"2px",position:"relative"},children:[y&&E>0&&e.jsx("div",{className:"thread-collapse-indicator",style:{position:"absolute",left:"-1px",top:"28px",bottom:"0",width:"2px",background:"var(--accent)",opacity:.5}}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[E>0&&e.jsx("button",{onClick:()=>S(!y),className:"btn-ghost",style:{padding:"2px 6px",fontSize:"11px",color:"var(--accent)",minWidth:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",marginTop:"4px",flexShrink:0},title:y?`Show ${E} replies`:"Collapse thread",children:y?"▸":"▾"}),E===0&&e.jsx("div",{style:{width:"24px",flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"},children:[e.jsx(P,{to:`/u/${t.username}`,children:e.jsx("div",{className:"avatar avatar-sm",style:{background:t.user_avatar_color,display:"inline-flex",verticalAlign:"middle",width:"24px",height:"24px",fontSize:"10px"},children:We(t.username)})}),e.jsxs(P,{to:`/u/${t.username}`,style:{fontWeight:700,fontSize:"13px",color:"var(--text-primary)",textDecoration:"none"},children:["u/",t.username]}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"·"}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:Se(t.created_at)}),s&&o>0&&e.jsxs("span",{className:"thread-count-badge",style:{background:"var(--accent)",color:"#fff",borderRadius:"10px",padding:"1px 8px",fontSize:"10px",fontWeight:700,marginLeft:"4px"},children:[o," ",o===1?"reply":"replies"," in thread"]})]}),e.jsx("div",{className:"comment-body",style:{fontSize:"14px",lineHeight:1.6,marginBottom:"6px"},dangerouslySetInnerHTML:{__html:Le(t.body)}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",flexWrap:"wrap"},children:[e.jsx(De,{entityType:"comment",entityId:t.id,initialVote:t.user_vote,initialScore:t.score}),e.jsx("button",{className:"btn-ghost",onClick:()=>{if(!d){c("/login");return}x(!a)},style:{fontSize:"12px",padding:"2px 8px",color:"var(--text-muted)",display:"flex",alignItems:"center",gap:"4px"},children:"↩ Reply"}),e.jsx("div",{style:{display:"inline-flex"},children:e.jsx(it,{entityType:"comment",entityId:t.id,compact:!0})})]}),a&&e.jsxs("div",{className:"fade-in",style:{marginTop:"8px",marginBottom:"8px"},children:[h&&e.jsx("div",{style:{padding:"6px 10px",marginBottom:"8px",borderRadius:"6px",background:"rgba(239,68,68,0.1)",color:"var(--danger)",fontSize:"12px"},children:h}),e.jsx("textarea",{value:p,onChange:N=>b(N.target.value),placeholder:"Write your reply...",rows:3,style:{width:"100%",padding:"8px 12px",background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text-primary)",fontSize:"13px",resize:"vertical"}}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"6px"},children:[e.jsx("button",{className:"btn btn-primary btn-sm",onClick:z,disabled:g||!p.trim(),style:{fontSize:"12px",padding:"4px 12px"},children:g?"Posting...":"Reply"}),e.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>x(!1),style:{fontSize:"12px",padding:"4px 12px"},children:"Cancel"})]})]})]})]}),t.children&&t.children.length>0&&!y&&e.jsx("div",{className:"thread-children",style:{animation:"fadeIn 0.2s ease"},children:t.children.map(N=>e.jsx(at,{comment:N,postId:n,onRefresh:r,depth:A?i:i+1,threadCount:N.children?.length||0},N.id))}),y&&E>0&&e.jsxs("button",{onClick:()=>S(!1),className:"thread-show-btn",style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",marginLeft:"32px",marginTop:"4px",background:"var(--accent)",color:"#fff",border:"none",borderRadius:"16px",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.2s"},children:[e.jsx("span",{children:"🧵"}),"Show ",E," ",E===1?"reply":"replies"," in thread"]})]})}function Vt({comments:t,postId:n,onRefresh:r}){return e.jsxs("div",{className:"thread-view",style:{position:"relative"},children:[e.jsx("style",{children:`
5        @keyframes fadeIn {
6          from { opacity: 0; transform: translateY(-4px); }
7          to { opacity: 1; transform: translateY(0); }
8        }
9        .thread-node:hover > .thread-collapse-indicator {
10          opacity: 1 !important;
11        }
12        .thread-show-btn:hover {
13          transform: scale(1.02);
14          box-shadow: 0 2px 8px rgba(0,0,0,0.15);
15        }
16        .thread-root {
17          padding: 12px;
18          border-radius: 8px;
19          background: var(--bg-secondary);
20          border: 1px solid var(--border);
21        }
22      `}),t.length===0?e.jsx("div",{style:{textAlign:"center",padding:"24px",color:"var(--text-muted)",fontSize:"14px"},children:"No threads yet. Start the conversation!"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(i=>e.jsx(at,{comment:i,postId:n,onRefresh:r,isThreadRoot:!0,threadCount:i.children?.length||0},i.id))})]})}function Ht({claim:t,verdict:n,response:r,username:i,postUrl:s,onClose:o}){const[d,c]=l.useState(""),{dialogProps:a,backdropProps:x}=Nt({open:!0,onClose:o,labelledBy:"share-card-title"}
22),p=r.split(/\n\n|\n/).filter(y=>y.trim()&&!y.startsWith("**VERDICT")).slice(0,3).join(`
23
24`),b=r.replace(/\*\*/g,"").split(/\n\n|\n/).filter(y=>y.trim()&&!y.toUpperCase().includes("VERDICT")).slice(0,2).join(" ").slice(0,280),g=`🔬 AI verified this claim:
25
26"${t.slice(0,100)}${t.length>100?"...":""}"
27
28Verdict: ${n}
29
30${b.slice(0,200)}
31
32Verified on HigherUp by u/${i}`,w=`**Claim:** "${t}"
33
34**AI Verdict:** ${n}
35
36**Analysis:**
37${p}
38
39*Verified on [HigherUp](https://higherup.ai) — AI-powered community platform*`,h=(y,S)=>{navigator.clipboard?.writeText(y).then(()=>{c(S),setTimeout(()=>c(""),2e3)})},v=y=>{const S=y.toLowerCase();return S.includes("true")?"var(--success)":S.includes("false")?"var(--danger)":S.includes("mixed")?"var(--warning)":"var(--text-muted)"};return e.jsx("div",{...a,...x,className:"fade-in",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"20px"},children:e.jsxs("div",{style:{background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:"var(--radius-lg)",padding:"24px",maxWidth:"500px",width:"100%",maxHeight:"80vh",overflow:"auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e.jsx("h3",{id:"share-card-title",style:{fontSize:"18px",fontWeight:700},children:"📤 Share This Debunk"}),e.jsx("button",{onClick:o,"aria-label":"Close",style:{fontSize:"20px",opacity:.6,cursor:"pointer"},children:"✕"})]}),e.jsxs("div",{style:{background:"linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.05))",border:"1px solid var(--border-light)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"20px"},children:"🔬"}),e.jsx("span",{style:{fontWeight:700,fontSize:"14px"},children:"HigherUp Analysis"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--text-secondary)",marginBottom:"8px",fontStyle:"italic"},children:['"',t.slice(0,150),t.length>150?"...":"",'"']}),e.jsx("span",{style:{display:"inline-block",padding:"3px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:700,background:`${v(n)}20`,color:v(n)},children:n}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"8px"},children:["Verified by u/",i," on HigherUp"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("button",{className:"btn btn-secondary btn-block",onClick:()=>h(g,"twitter"),style:{justifyContent:"flex-start",padding:"10px 14px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:"𝕏"})," Copy for Twitter/X",d==="twitter"&&e.jsx("span",{style:{color:"var(--success)",marginLeft:"auto"},children:"✓ Copied!"})]}),e.jsxs("button",{className:"btn btn-secondary btn-block",onClick:()=>h(w,"reddit"),style:{justifyContent:"flex-start",padding:"10px 14px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🤖"})," Copy for Reddit",d==="reddit"&&e.jsx("span",{style:{color:"var(--success)",marginLeft:"auto"},children:"✓ Copied!"})]}),e.jsxs("button",{className:"btn btn-secondary btn-block",onClick:()=>{const y=s||window.location.href;h(y,"link")},style:{justifyContent:"flex-start",padding:"10px 14px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"})," Copy Link",d==="link"&&e.jsx("span",{style:{color:"var(--success)",marginLeft:"auto"},children:"✓ Copied!"})]})]}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"12px",textAlign:"center"},children:"Help HigherUp grow — share your analysis and tag us!"})]})})}const Ze=["🎉","🏆","⭐","🔥","💪","🚀","✨","🎯","💎","👑"],Ge=["#6366f1","#ec4899","#f59e0b","#10b981","#06b6d4","#ef4444","#8b5cf6"];function Ot({onComplete:t}){const[n,r]=l.useState([]),[i,s]=l.useState(!0);return l.useEffect(()=>{const o=[];for(let c=0;c<30;c++)o.push({id:c,x:Math.random()*100,y:-10-Math.random()*20,color:Ge[Math.floor(Math.random()*Ge.length)],rotation:Math.random()*360,scale:.6+Math.random()*1.4,delay:Math.random()*.5,emoji:Ze[Math.floor(Math.random()*Ze.length)]});r(o);const d=setTimeout(()=>{s(!1),t?.()},3500);return()=>clearTimeout(d)},[t]),i?e.jsx("div",{className:"confetti-overlay",children:n.map(o=>e.jsx("span",{className:"confetti-piece",style:{left:`${o.x}%`,top:`${o.y}%`,transform:`rotate(${o.rotation}deg) scale(${o.scale})`,color:o.color,animationDelay:`${o.delay}s`,fontSize:`${14+o.scale*8}px`},children:o.emoji},o.id))}):null}let Ie=null;function Ft(){return Ie||(Ie=new AudioContext),Ie}function $(t,n,r="sine",i=.1){try{const s=Ft(),o=s.createOscillator(),d=s.createGain();o.type=r,o.frequency.setValueAtTime(t,s.currentTime),d.gain.setValueAtTime(i,s.currentTime),d.gain.exponentialRampToValueAtTime(.001,s.currentTime+n),o.connect(d),d.connect(s.destination),o.start(s.currentTime),o.stop(s.currentTime+n)}catch{}}const Kt={achievement:()=>{$(523,.15,"sine",.08),setTimeout(()=>$(659,.15,"sine",.08),100),setTimeout(()=>$(784,.3,"sine",.08),200)},streak:()=>{$(400,.08,"sawtooth",.05),setTimeout(()=>$(600,.08,"sawtooth",.05),60),setTimeout(()=>$(800,.15,"sawtooth",.06),120),setTimeout(()=>$(1200,.2,"sine",.07),180)},upvote:()=>{$(880,.06,"sine",.04)},levelUp:()=>{$(523,.12,"sine",.06),setTimeout(()=>$(659,.12,"sine",.06),100),setTimeout(()=>$(784,.12,"sine",.06),200),setTimeout(()=>$(1047,.4,"triangle",.08),300)},notification:()=>{$(800,.1,"sine",.05),setTimeout(()=>$(1e3,.15,"sine",.05),100)},share:()=>{$(660,.08,"sine",.04),setTimeout(()=>$(880,.08,"sine",.04),80),setTimeout(()=>$(1100,.15,"sine",.05),160)}};let Yt=localStorage.getItem("consperisy_sound_muted")==="true";function Xt(t){Yt||Kt[t]()}function Zt({claim:t,postId:n}){const{user:r}=te(),i=_e(),[s,o]=l.useState([]),[d,c]=l.useState([]),[a,x]=l.useState(It),[p,b]=l.useState(Bt),[g,w]=l.useState(t||""),[h,v]=l.useState(""),[y,S]=l.useState(""),[j,C]=l.useState(!1),[E,A]=l.useState(""),[z,N]=l.useState(!1),[se,M]=l.useState([]),[ne,k]=l.useState(!1),[W,re]=l.useState(!1),[F,V]=l.useState(""),[K,ye]=l.useState(!1);l.useEffect(()=>{_.ai.providers({lazy:!0,free_only:!0}).then(m=>{m.success&&m.data&&(o(m.data.providers||[]),c(m.data.free_models||[]),ye(!0))}),r&&(_.ai.keys.list().then(m=>{m.success&&m.data&&M(m.data.map(I=>I.provider))}),_.ai.preferences.get().then(m=>{m.success&&m.data&&(x(m.data.preferred_provider),b(m.data.preferred_model),N(m.data.allow_uncensored===1))}))},[r]);const oe=l.useMemo(()=>{const m=F.trim().toLowerCase();return d.filter(I=>!z&&I.is_uncensored||I.provider!==a?!1:m.length===0?!0:I.id.toLowerCase().includes(m)||I.name.toLowerCase().includes(m)||(I.description||"").toLowerCase().includes(m))},[d,a,z,F]);l.useEffect(()=>{K&&_.ai.providers({lazy:!0,free_only:!0,uncensored:!!z}).then(m=>{m.success&&m.data&&c(m.data.free_models||[])})},[z,K]);const ae=async()=>
39{if(!r){i("/login");return}if(!g.trim()){A("Please enter a claim to debunk");return}C(!0),A(""),v(""),S("");const m=await _.ai.debunk({claim:g.trim(),provider:a,model:p,post_id:n});if(m.success&&m.data){v(m.data.response),S(m.data.verdict);const I=await _.achievements.check();I.success&&I.data&&I.data.newlyEarned.length>0&&(re(!0),Xt("achievement"))}else A(m.error||"Failed to debunk claim");C(!1)},be=m=>{const I=m.toLowerCase();return I.includes("true")?"verdict-true":I.includes("false")?"verdict-false":I.includes("mixed")?"verdict-mixed":"verdict-unverifiable"};return e.jsxs("div",{className:"debunk-box",children:[e.jsx("h3",{children:"🔬 AI Conspiracy Debunker"}),!r&&e.jsxs("div",{className:"alert alert-info",children:[e.jsx(P,{to:"/login",children:"Login"})," or ",e.jsx(P,{to:"/signup",children:"sign up"})," to use the AI debunking engine."]}),r&&se.length===0&&a!=="cloudflare"&&a!=="github-models"&&e.jsxs("div",{className:"alert alert-info",children:["No API key found for ",s.find(m=>m.id===a)?.name,". ",e.jsx(P,{to:"/settings",children:"Add your free API key →"})," or pick a no-key provider like ",e.jsx("strong",{children:"Cloudflare"})," or ",e.jsx("strong",{children:"GitHub Models"}),"."]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"12px"},children:[e.jsxs("div",{className:"form-group mb-0",children:[e.jsx("label",{children:"AI Provider"}),e.jsx("select",{value:a,onChange:m=>{const I=m.target.value;x(I);const ve=d.filter(le=>le.provider===I);ve.length>0&&b(ve[0].id)},children:s.map(m=>e.jsxs("option",{value:m.id,children:[m.name," ",m.requires_key&&se.includes(m.id)?" ✓":m.requires_key?" (key)":" (free)"]},m.id))})]}),e.jsxs("div",{className:"form-group mb-0",children:[e.jsx("label",{children:"Model"}),e.jsx("input",{type:"text",placeholder:"🔍 Search models…",value:F,onChange:m=>V(m.target.value),style:{marginBottom:"6px",fontSize:"13px"}}),e.jsxs("select",{value:p,onChange:m=>b(m.target.value),children:[oe.length===0&&e.jsx("option",{value:p,children:"No models match — clearing?"}),oe.map(m=>e.jsx("option",{value:m.id,children:m.name},m.id))]}),e.jsxs("div",{className:"hint",children:[oe.length," models available for ",s.find(m=>m.id===a)?.name]})]})]}),e.jsxs("div",{className:"form-group mb-2",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:z,onChange:m=>N(m.target.checked),style:{marginRight:"6px",width:"auto"}}),"Show uncensored / unrestricted models"]}),e.jsx("div",{className:"hint",children:"Uncensored models won't refuse to analyze any topic"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Claim or Conspiracy Theory to Debunk"}),e.jsx("textarea",{value:g,onChange:m=>w(m.target.value),placeholder:"Paste the claim you want fact-checked...",rows:4,style:{resize:"vertical"}})]}),E&&e.jsx("div",{className:"alert alert-error",children:E}),e.jsx("button",{className:"btn btn-primary",onClick:ae,disabled:j||!g.trim(),children:j?e.jsxs(e.Fragment,{children:["Analyzing with AI",e.jsxs("span",{className:"loading-dots",style:{marginLeft:"4px"},children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})]}):e.jsx(e.Fragment,{children:"🔬 Debunk This Claim"})}),y&&e.jsxs("div",{style:{marginTop:"16px",display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[e.jsx("span",{className:`verdict-badge ${be(y)}`,children:y}),e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>k(!0),children:"📤 Share This Debunk"})]}),y&&e.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",margin:"8px 0 0",lineHeight:1.5},children:"AI-generated from a single model. Sources are not verified — check the cited evidence yourself before relying on this."}),h&&e.jsx("div",{className:"ai-response fade-in",dangerouslySetInnerHTML:{__html:Le(h)}}),j&&!h&&e.jsxs("div",{className:"ai-response",style:{color:"var(--text-muted)",textAlign:"center"},children:[e.jsx("div",{className:"spinner",style:{margin:"20px auto"}}),e.jsx("p",{children:"AI is analyzing the claim..."})]}),ne&&h&&y&&e.jsx(Ht,{claim:g.trim(),verdict:y,response:h,username:r?.username||"anonymous",postUrl:n?`${window.location.origin}/post/${n}`:void 0,onClose:()=>k(!1)}),W&&e.jsx(Ot,{onComplete:()=>re(!1)})]})}function Gt({postId:t}){const[n,r]=l.useState([]);if(l.useEffect(()=>{_.related(t).then(s=>{s.success&&s.data&&r(s.data)}).catch(()=>{})},[t]),n.length===0)return null;
39const i={TRUE:"#10b981",FALSE:"#ef4444",MIXED:"#f59e0b"};return e.jsxs("div",{className:"related-debunks fade-in",style:{marginTop:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",fontWeight:700,marginBottom:"12px",color:"var(--text-primary)"},children:"🔗 People Also Debunked"}),e.jsx("div",{className:"related-grid",children:n.map(s=>e.jsxs(P,{to:"/debunks",className:"related-card",style:{display:"block",padding:"12px",background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",transition:"all var(--transition)",textDecoration:"none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"},children:[e.jsx("div",{className:"avatar avatar-sm",style:{background:s.avatar_color},children:s.username[0]?.toUpperCase()}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-muted)"},children:s.username})]}),e.jsxs("p",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",marginBottom:"6px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["“",s.claim_text.slice(0,70),"...”"]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"10px",fontWeight:700,padding:"1px 6px",borderRadius:"6px",background:`${i[s.verdict]||"var(--text-muted)"}20`,color:i[s.verdict]||"var(--text-muted)",textTransform:"uppercase"},children:s.verdict}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:[s.upvotes,"⬆"]})]})]},s.id))})]})}function qt(){return e.jsx("div",{style:{display:"flex",gap:"12px",overflowX:"auto",paddingBottom:"8px",scrollSnapType:"x mandatory"},children:Array.from({length:4}).map((t,n)=>e.jsx("div",{style:{minWidth:"260px",maxWidth:"300px",flexShrink:0,scrollSnapAlign:"start"},children:e.jsxs("div",{className:"skeleton-card",style:{padding:"14px",height:"180px"},children:[e.jsx("div",{className:"skeleton skeleton-text",style:{width:"40%",height:"10px"}}),e.jsx("div",{className:"skeleton skeleton-text",style:{width:"90%",height:"16px",marginTop:"8px"}}),e.jsx("div",{className:"skeleton skeleton-text",style:{width:"75%",height:"12px",marginTop:"6px"}}),e.jsx("div",{className:"skeleton skeleton-text",style:{width:"60%",height:"12px",marginTop:"4px"}}),e.jsxs("div",{className:"skeleton-row",style:{marginTop:"12px"},children:[e.jsx("div",{className:"skeleton skeleton-text",style:{width:"20%"}}),e.jsx("div",{className:"skeleton skeleton-text",style:{width:"15%"}})]})]})},n))})}function Jt(t,n){let r=0;const i=[],o=(t.tags||[]).filter(a=>n.includes(a));o.length>0&&(r+=o.length*30,i.push(`${o.length} tag match${o.length>1?"es":""}`)),r+=Math.min(25,Math.log2(Math.max(1,t.score))*5),t.score>50&&i.push("popular");const c=(Date.now()-new Date(t.created_at).getTime())/(1e3*60*60*24);return c<1?(r+=15,i.push("fresh")):c<7&&(r+=8,i.push("this week")),{score:r,reason:i[0]||"related"}}function Qt({postId:t,tags:n=[]}){const[r,i]=l.useState([]),[s,o]=l.useState(!0),[d,c]=l.useState("");return l.useEffect(()=>{let a=!1;return o(!0),c(""),(async()=>{try{const p=await _.recommendations?.get(t,n);if(!a&&p?.success&&p.data){i(p.data),o(!1);return}}catch{}try{const p=await _.related(t);if(a)return;if(p.success&&p.data){const b=p.data.map(g=>{const{score:w,reason:h}=Jt({tags:[],score:g.upvotes||0,comment_count:0,created_at:g.created_at},n);return{id:g.id,title:g.claim_text,score:g.upvotes,comment_count:0,created_at:g.created_at,community_slug:"debunks",community_icon:"#ef4444",username:g.username,user_avatar_color:g.avatar_color,tags:[],matchReason:h,_relevanceScore:w}}).sort((g,w)=>w._relevanceScore-g._relevanceScore).slice(0,8);i(b)}}catch{a||c("Could not load recommendations")}a||o(!1)})(),()=>{a=!0}},[t,n]),s?e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",fontWeight:700,marginBottom:"12px",color:"var(--text-primary)"},children:"✨ Related Debunks"}),e.jsx(qt,{})]}):d||r.length===0?null:e.jsxs("div",{className:"fade-in",style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[e.jsx("h3",{style:{fontSize:"16px",fontWeight:700,color:"var(--text-primary)",margin:0},children:"✨ Related Debunks"}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"AI-suggested"})]}),e.jsx("div",{style:{display:"flex",gap:"12px",overflowX:"auto",paddingBottom:"8px",scrollSnapType:"x mandatory",WebkitOverflowScrolling:"touch"},children:r.map(a=>e.jsxs(P,{to:`/post/${a.id}`,style:{minWidth:"260px",maxWidth:"300px",flexShrink:0,scrollSnapAlign:"start",display:"block",padding:"14px",background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",textDecoration:"none",transition:"all var(--transition)"},className:"hover:border-accent",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("div",{className:"avatar avatar-sm",style:{background:a.user_avatar_color,width:"20px",height:"20px",fontSize:"10px"},children:a.username[0]?.toUpperCase()}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:["u/",a.username]}),e.jsxs("span",{style:{fontSize:"10px",color:"var(--text-muted)",marginLeft:"auto"},children:["c/",a.community_slug]})]}),e.jsx("p",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",marginBottom:"8px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",lineHeight:1.4},children:a.title}),a.body&&e.jsx("p",{style:{fontSize:"12px",color:"var(--text-muted)",marginBottom:"8px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.body.slice(0,100)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"10px",fontWeight:700,padding:"1px 6px",borderRadius:"6px",background:"var(--accent-light)",color:"var(--accent)"},children:a.matchReason}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:[a.score," ⬆"]}),a.comment_count>0&&e.jsxs("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:["💬 ",a.comment_count]})]}),a.tags.length>0&&e.jsx("div",{style:{display:"flex",gap:"4px",marginTop:"8px",flexWrap:"wrap"},children:a.tags.slice(0,3).map(x=>e.jsxs("span",{style:{fontSize:"10px",padding:"1px 5px",borderRadius:"4px",background:"var(--bg-input)",color:"var(--text-muted)"},children:["#",x]},x))})]},a.id))})]})}function es({title:t,url:n,text:r}){const i=encodeURIComponent(t),s=encodeURIComponent(n),d={twitter:`https://twitter.com/intent/tweet?text=${(r?encodeURIComponent(r.slice(0,200)):"")||i}&url=${s}&via=higherup_ai`,facebook:`https://www.facebook.com/sharer/sharer.php?u=${s}`,reddit:`https://www.reddit.com/submit?url=${s}&title=${i}`,whatsapp:`https://wa.me/?text=${i}%20${s}`,telegram:`https://t.me/share/url?url=${s}&text=${i}`,linkedin:`https://www.linkedin.com/sharing/share-offsite/?url=${s}`};return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-muted)",fontWeight:600},children:"Share:"}),Object.entries(d).map(([c,a])=>e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"btn btn-ghost btn-sm tap-scale","aria-label":`Share on ${c}`,title:`Share on ${c}`,style:{padding:"8px 12px",fontSize:"16px",minHeight:"44px",minWidth:"44px"},children:[c==="twitter"&&"𝕏",c==="facebook"&&"📘",c==="reddit"&&"🤖",c==="whatsapp"&&"💬",c==="telegram"&&"✈️",c==="linkedin"&&"💼"]},c))]})}/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const lt=Object.freeze({p:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,n:0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,h:1n,a:0n,b:7n,Gx:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Gy:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n}),{p:G,n:q,Gx:ts,Gy:ss,b:ct}=lt,L=32,ue=64,xe={publicKey:L+1,publicKeyUncompressed:ue+1,signature:ue,seed:L+L/2},R=(t="",n=Error)=>{const r=new n(t),{captureStackTrace:i}=Error;throw typeof i=="function"&&i(r,R),r},ns=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&t.BYTES_PER_ELEMENT===1,U=(t,n,r="")=>{const i=ns(t),s=t?.length,o=n!==void 0;if(!i||o&&s!==n){const d=r&&`"${r}" `,c=o?` of length ${n}`:"",a=i?`length=${s}`:`type=${typeof t}`,x=d+"expected Uint8Array"+c+", got "+a;return i?R(x,RangeError):R(x,TypeError)}return t},X=t=>new Uint8Array(t),dt=(t,n)=>t.toString(16).padStart(n,"0"),Ue=t=>{let n="";for(const r of U(t))n+=dt(r,2);return n},H={_0:48,_9:57,A:65,F:70,a:97,f:102},qe=t=>t>=H._0&&t<=H._9?t-H._0:t>=H.A&&t<=H.F?t-(H.A-10):t>=H.a&&t<=H.f?t-(H.a-10):void 0,Me=t=>
39{const n="hex invalid";if(typeof t!="string")return R(n);const r=t.length,i=r/2;if(r%2)return R(n);const s=X(i);for(let o=0,d=0;o<i;o++,d+=2){const c=qe(t.charCodeAt(d)),a=qe(t.charCodeAt(d+1));if(c===void 0||a===void 0)return R(n);s[o]=c*16+a}return s},Je=()=>globalThis?.crypto?.subtle??R("crypto.subtle must be defined, consider polyfill"),J=(...t)=>{let n=0;for(const s of t)n+=U(s).length;const r=X(n);let i=0;for(const s of t)r.set(s,i),i+=s.length;return r},Ve=(t=L)=>(globalThis?.crypto).getRandomValues(X(t)),ke=BigInt,he=(t,n,r,i="bad number: out of range")=>typeof t!="bigint"?R(i,TypeError):n<=t&&t<r?t:R(i,RangeError),f=(t,n=G)=>{const r=t%n;return r>=0n?r:n+r},pe=t=>f(t,q),He=(t,n)=>{(t===0n||n<=0n)&&R("no inverse n="+t+" mod="+n);let r=f(t,n),i=n,s=0n,o=1n;for(;r!==0n;){const d=i/r,c=i%r,a=s-o*d;i=r,r=c,s=o,o=a}return i===1n?f(s,n):R("no inverse")},pt=t=>{const n=fs[t];return typeof n!="function"&&R("hashes."+t+" not set"),n},rs=(t,n,r)=>U(pt(t)(n,r),L,"digest"),ut=(t,n,r)=>Promise.resolve(pt(t)(n,r)).then(i=>U(i,L,"digest")),Be=t=>t instanceof D?t:R("Point expected"),xt=t=>f(f(t*t)*t+ct),Qe=t=>he(t,0n,G),je=t=>he(t,1n,G),$e=t=>he(t,1n,q),ft=t=>!(t&1n),me=t=>Uint8Array.of(t),is=t=>me(ft(t)?2:3),os=t=>{const n=xt(je(t));let r=1n;for(let i=n,s=(G+1n)/4n;s>0n;s>>=1n)s&1n&&(r=r*i%G),i=i*i%G;return f(r*r)!==n&&R("sqrt invalid"),ft(r)?r:f(-r)};class D{static BASE;static ZERO;X;Y;Z;constructor(n,r,i){this.X=Qe(n),this.Y=je(r),this.Z=Qe(i),Object.freeze(this)}static CURVE(){return lt}static fromAffine(n){const{x:r,y:i}=n;return r===0n&&i===0n?Z:new D(r,i,1n)}static fromBytes(n){U(n);const{publicKey:r,publicKeyUncompressed:i}=xe;let s;const o=n.length,d=n[0],c=n.subarray(1),a=Ce(c,0,L);if(o===r&&(d===2||d===3)){let x=os(a);d===3&&(x=f(-x)),s=new D(a,x,1n)}return o===i&&d===4&&(s=new D(a,Ce(c,L,ue),1n)),s?s.assertValidity():R("bad point: not on curve")}static fromHex(n){return D.fromBytes(Me(n))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(n){const{X:r,Y:i,Z:s}=this,{X:o,Y:d,Z:c}=Be(n),a=f(r*c),x=f(o*s),p=f(i*c),b=f(d*s);return a===x&&p===b}is0(){return this.equals(Z)}negate(){return new D(this.X,f(-this.Y),this.Z)}double(){return this.add(this)}add(n){const{X:r,Y:i,Z:s}=this,{X:o,Y:d,Z:c}=Be(n),a=0n,x=ct;let p=0n,b=0n,g=0n;const w=f(x*3n);let h=f(r*o),v=f(i*d),y=f(s*c),S=f(r+i),j=f(o+d);S=f(S*j),j=f(h+v),S=f(S-j),j=f(r+s);let C=f(o+c);return j=f(j*C),C=f(h+y),j=f(j-C),C=f(i+s),p=f(d+c),C=f(C*p),p=f(v+y),C=f(C-p),g=f(a*j),p=f(w*y),g=f(p+g),p=f(v-g),g=f(v+g),b=f(p*g),v=f(h+h),v=f(v+h),y=f(a*y),j=f(w*j),v=f(v+y),y=f(h-y),y=f(a*y),j=f(j+y),h=f(v*j),b=f(b+h),h=f(C*j),p=f(S*p),p=f(p-h),h=f(S*v),g=f(C*g),g=f(g+h),new D(p,b,g)}subtract(n){return this.add(Be(n).negate())}multiply(n,r=!0){if(!r&&n===0n)return Z;if($e(n),n===1n)return this;if(this.equals(Q))return _s(n).p;let i=Z,s=Q;for(let o=this;n>0n;o=o.double(),n>>=1n)n&1n?i=i.add(o):r&&(s=s.add(o));return i}multiplyUnsafe(n){return this.multiply(n,!1)}toAffine(){const{X:n,Y:r,Z:i}=this;if(this.equals(Z))return{x:0n,y:0n};if(i===1n)return{x:n,y:r};const s=He(i,G);return f(i*s)!==1n&&R("inverse invalid"),{x:f(n*s),y:f(r*s)}}assertValidity(){const{x:n,y:r}=this.toAffine();return je(n),je(r),f(r*r)===xt(n)?this:R("bad point: not on curve")}toBytes(n=!0){const{x:r,y:i}=this.assertValidity().toAffine(),s=ee(r);return n?J(is(i),s):J(me(4),s,ee(i))}toHex(n){return Ue(this.toBytes(n))}}const Q=new D(ts,ss,1n),Z=new D(0n,1n,0n);D.BASE=Q;D.ZERO=Z;const ge=t=>ke("0x"+(Ue(t)||"0")),Ce=(t,n,r)=>ge(t.subarray(n,r)),as=2n**256n,ee=t=>Me(dt(he(t,0n,as),ue)),ze=t=>{const n=ge(U(t,L,"secret key"));return he(n,1n,q,"invalid secret key: outside of range")},ht=t=>t>q>>1n,ls=(t,n=!0)=>Q.multiply(ze(t)).toBytes(n),cs=t=>{try{return!!ze(t)}catch{return!1}},ds=(t,n)=>{const{publicKey:r,publicKeyUncompressed:i}=xe;try{const s=t.length;return n===!0&&s!==r||n===!1&&s!==i?!1:!!D.fromBytes(t)}catch{return!1}},et=t=>[0,1,2,3].includes(t)?t:R("invalid recovery id"),Oe=t=>{t===xs&&R('Signature format "der" is not supported: switch to noble-curves'),t!=null&&t!==fe&&t!==Te&&R("Signature format must be one of: compact, recovered, der")},ps=(t,n=fe)=>{Oe(n);const r=xe.signature+ +(n===Te);t.length!==r&&R(`Signature format "${n}" expects Uint8Array with length ${r}`)};class Ne{r;s;recovery;constructor(n,r,i){this.r=$e(n),this.s=$e(r),i!=null&&(this.recovery=et(i)),Object.freeze(this)}static fromBytes(n,r=fe){ps(n,r);let i;r===Te&&(i=n[0],n=n.subarray(1));const s=Ce(n,0,L),o=Ce(n,L,ue);return new Ne(s,o,i)}addRecoveryBit(n){return new Ne(this.r,this.s,n)}hasHighS(){return ht(this.s)}toBytes(n=fe){Oe(n);const{r,s:i,recovery:s}=this,o=J(ee(r),ee(i));return n===Te?J(me(et(s)),o):o}}const mt=t=>{t.length>8192&&R("input is too large");
39const n=t.length*8-256,r=ge(t);return n>0?r>>ke(n):r},us=t=>pe(mt(U(t))),fe="compact",Te="recovered",xs="der",tt="SHA-256",fs={hmacSha256Async:async(t,n)=>{const r=Je(),i="HMAC",s=await r.importKey("raw",t,{name:i,hash:{name:tt}},!1,["sign"]);return X(await r.sign(i,s,n))},hmacSha256:void 0,sha256Async:async t=>X(await Je().digest(tt,t)),sha256:void 0},hs=(t,n,r)=>{const i=U(t,void 0,"message");return n.prehash?r?ut("sha256Async",i):rs("sha256",i):i},ms=X(0),gs=me(0),ys=me(1),bs=1e3,vs="drbg: tried max amount of iterations",js=async(t,n)=>{let r=X(L),i=X(L),s=0;const o=()=>{r.fill(1),i.fill(0)},d=(...p)=>ut("hmacSha256Async",i,J(r,...p)),c=async(p=ms)=>{i=await d(gs,p),r=await d(),p.length!==0&&(i=await d(ys,p),r=await d())},a=async()=>(s++>=bs&&R(vs),r=await d(),r);o(),await c(t);let x;for(;!(x=n(await a()));)await c();return o(),x},Ss=(t,n,r,i)=>{let{lowS:s,extraEntropy:o}=r;const d=ee,c=us(t),a=d(c),x=ze(n),p=[d(x),a];if(o!=null&&o!==!1){const h=o===!0?Ve(L):o;p.push(U(h,void 0,"extraEntropy"))}const b=J(...p),g=c;return i(b,h=>{const v=mt(h);if(!(1n<=v&&v<q))return;const y=He(v,q),S=Q.multiply(v).toAffine(),j=pe(S.x);if(j===0n)return;const C=pe(y*pe(g+j*x));if(C===0n)return;let E=(S.x===j?0:2)|Number(S.y&1n),A=C;return s&&ht(C)&&(A=pe(-C),E^=1),new Ne(j,A,E).toBytes(r.format)})},ws=t=>({lowS:t.lowS??!0,prehash:t.prehash??!0,format:t.format??fe,extraEntropy:t.extraEntropy??!1}),ks=async(t,n,r={})=>{r=ws(r),Oe(r.format);const i=await hs(t,r,!0);return Ss(i,n,r,js)},Cs=t=>{if(t=t===void 0?Ve(xe.seed):t,U(t),t.length<xe.seed||t.length>1024)return R("expected 48-1024b",RangeError);const n=f(ge(t),q-1n);return ee(n+1n)},Ae=Object.freeze({hexToBytes:Me,bytesToHex:Ue,concatBytes:J,bytesToNumberBE:ge,numberToBytesBE:ee,mod:f,invert:He,randomBytes:Ve,secretKeyToScalar:ze,abytes:U}),Ns=Object.freeze({isValidSecretKey:cs,isValidPublicKey:ds,randomSecretKey:Cs}),Re=8,Ts=256,gt=Math.ceil(Ts/Re)+1,Pe=2**(Re-1),Rs=()=>{const t=[];let n=Q,r=n;for(let i=0;i<gt;i++){r=n,t.push(r);for(let s=1;s<Pe;s++)r=r.add(n),t.push(r);n=r.double()}return t};let st;const nt=(t,n)=>{const r=n.negate();return t?r:n},_s=t=>{const n=st||(st=Rs());let r=Z,i=Q;const s=2**Re,o=s,d=ke(s-1),c=ke(Re);for(let a=0;a<gt;a++){let x=Number(t&d);t>>=c,x>Pe&&(x-=o,t+=1n);const p=a*Pe,b=p,g=p+Math.abs(x)-1,w=a%2!==0,h=x<0;x===0?i=i.add(nt(w,n[b])):r=r.add(nt(h,n[g]))}return t!==0n&&R("invalid wnaf"),{p:r,f:i}},zs=[{url:"wss://relay.damus.io",read:!0,write:!0},{url:"wss://relay.nostr.band",read:!0,write:!0},{url:"wss://nos.lol",read:!0,write:!0},{url:"wss://relay.higherup.ai",read:!0,write:!0},{url:"wss://purplepag.es",read:!0,write:!1}],rt="higherup_nostr_keys";function Es(t){return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("")}function Fe(t){if(t.length%2!==0)throw new Error("Invalid hex string");const n=new Uint8Array(t.length/2);for(let r=0;r<n.length;r++)n[r]=parseInt(t.substring(r*2,r*2+2),16);return n}const Is="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Bs=[996825010,642813549,513874426,1027748829,705979059];function $s(t){let n=1;for(const r of t){const i=n>>25;n=(n&33554431)<<5^r;for(let s=0;s<5;s++)i>>s&1&&(n^=Bs[s])}return n}function As(t){const n=[];for(let r=0;r<t.length;r++)n.push(t.charCodeAt(r)>>5);n.push(0);for(let r=0;r<t.length;r++)n.push(t.charCodeAt(r)&31);return n}function yt(t,n){const r=[...As(t),...n,0,0,0,0,0,0],i=$s(r)^1,s=[];for(let o=0;o<6;o++)s.push(i>>5*(5-o)&31);return t+"1"+[...n,...s].map(o=>Is[o]).join("")}function bt(t,n,r,i){let s=0,o=0;const d=[],c=(1<<r)-1;for(const a of t)for(s=s<<n|a,o+=n;o>=r;)o-=r,d.push(s>>o&c);return o>0&&d.push(s<<r-o&c),d}function Ps(t){const n=Fe(t);return yt("npub",bt(n,8,5))}function Ws(t){const n=Fe(t);return yt("nsec",bt(n,8,5))}async function Ls(t){const n=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(n)}async function Ds(t){const n=sessionStorage.getItem(rt);if(n)return JSON.parse(n);let r;try{const{fingerprint:d}=await Tt(t),c=new TextEncoder,a=c.encode(`nostr-derivation-${d}-${t}`),x=c.encode("higherup-nostr-v1"),p=await crypto.subtle.importKey("raw",a,"HKDF",!1,["deriveBits"]),b=await crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:x,info:c.encode("secp256k1-key")},p,256);r=new Uint8Array(b)}catch{r=Ns.randomSecretKey()}const i=Ae.bytesToHex(r),s=Ae.bytesToHex(ls(r)),o={publicKey:s,privateKey:i,npub:Ps(s),nsec:Ws(i)};return sessionStorage.setItem(rt,JSON.stringify(o)),o}async function Us(t,n){const r=JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content]),i=await Ls(new TextEncoder().encode(r)),s=Es(i),o=Fe(n),d=await ks(i,o),c=Ae.bytesToHex(d);return{...t,id:s,sig:c}}async function Ms(t,n,r,i=[]){const s=await Ds(t),o={pubkey:s.publicKey,created_at:Math.floor(Date.now()/1e3),kind:n,tags:i,content:r};return Us(o,s.privateKey)}async function Vs(t,n,r=[]){const i=await Ms(t,1,n,r),s=[];return await Promise.allSettled(zs.filter(o=>o.write).map(async o=>
39{try{const d=await Os(o.url,i);s.push(`${o.url}: ${d}`)}catch(d){s.push(`${o.url}: ${d instanceof Error?d.message:"failed"}`)}})),{event:i,relayResponses:s}}async function Hs(t,n,r){try{return{success:!0,eventId:(await Vs(t,`${n}
40
41Posted via HigherUp.ai — Think Together. Earn Together.`)).event.id}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Failed to cross-post"}}}async function Os(t,n){const r=t.replace("wss://","https://").replace("ws://","http://"),i=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(["EVENT",n])});if(!i.ok)throw new Error(`Relay responded with ${i.status}`);const s=await i.json();return s[0]==="OK"&&s[2]?"published":s[3]||"unknown"}function Fs({postId:t,title:n}){const{user:r}=te(),[i,s]=l.useState(!1),[o,d]=l.useState(""),[c,a]=l.useState(""),[x,p]=l.useState(!1),[b,g]=l.useState(""),w=async()=>{if(!o||!c.trim())return;if(p(!0),o==="nostr"&&r){const v=await Hs(r.id,n,c.trim());p(!1),v.success?(g(`✓ Published to Nostr! ${v.eventId?.slice(0,8)}...`),setTimeout(()=>{g(""),s(!1)},2e3)):g(v.error||"Nostr publish failed");return}const h=await _.request("/posts/syndicate",{method:"POST",body:JSON.stringify({post_id:t,platform:o,original_url:c.trim()})});p(!1),h.success?(g("✓ Syndicated!"),setTimeout(()=>{g(""),s(!1)},1500)):g(h.error||"Failed")};return i?e.jsxs("div",{style:{padding:"10px",borderRadius:"var(--radius-sm)",background:"var(--bg-secondary)",border:"1px solid var(--border)",marginTop:"6px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:700,marginBottom:"8px"},children:"🔄 Cross-post to another platform"}),e.jsxs("select",{value:o,onChange:h=>d(h.target.value),style:{width:"100%",padding:"6px 10px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border)",background:"var(--bg-input)",color:"var(--text-primary)",fontSize:"13px",marginBottom:"6px"},children:[e.jsx("option",{value:"",children:"Select platform..."}),e.jsx("option",{value:"twitter",children:"Twitter / X"}),e.jsx("option",{value:"reddit",children:"Reddit"}),e.jsx("option",{value:"mastodon",children:"Mastodon"}),e.jsx("option",{value:"nostr",children:"Nostr"}),e.jsx("option",{value:"bluesky",children:"Bluesky"}),e.jsx("option",{value:"other",children:"Other"})]}),e.jsx("input",{placeholder:"Original URL (if reposting)",value:c,onChange:h=>a(h.target.value),style:{width:"100%",padding:"6px 10px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border)",background:"var(--bg-input)",color:"var(--text-primary)",fontSize:"13px",marginBottom:"6px"}}),e.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[e.jsx("button",{className:"btn btn-primary btn-sm",onClick:w,disabled:x||!o,style:{fontSize:"12px"},children:x?"...":"Syndicate"}),e.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>s(!1),style:{fontSize:"12px"},children:"Cancel"}),b&&e.jsx("span",{style:{fontSize:"12px",color:b.startsWith("✓")?"#10b981":"var(--danger)"},children:b})]})]}):e.jsxs("button",{className:"post-action",onClick:()=>s(!0),children:[e.jsx("span",{className:"icon",children:"🔄"}),e.jsx("span",{children:"Cross-post"})]})}const Ks=[{id:"nsfw",label:"NSFW",icon:"🔞"},{id:"spoiler",label:"Spoiler",icon:"⚠️"},{id:"violence",label:"Violence",icon:"🩸"},{id:"sensitive",label:"Sensitive",icon:"🔒"}];function Ys({postId:t,children:n}){const[r,i]=l.useState([]),[s,o]=l.useState(!1),[d,c]=l.useState(!0);if(l.useEffect(()=>{fetch(`/api/posts/${t}`).then(x=>x.json()).then(x=>{const p=x;p.data?.warnings&&i(p.data.warnings),c(!1)}).catch(()=>c(!1))},[t]),d||r.length===0||s)return e.jsx(e.Fragment,{children:n});const a=r.map(x=>{const p=Ks.find(b=>b.id===x.warning_type);return p?`${p.icon} ${p.label}`:x.warning_type});return e.jsxs("div",{style:{borderRadius:"var(--radius)",border:"1px solid var(--warning, #f59e0b)",background:"rgba(245, 158, 11, 0.05)",padding:"16px",textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:700,marginBottom:"6px"},children:["⚠️ Content Warning: ",a.join(", ")]}),r.some(x=>x.description)&&e.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginBottom:"8px"},children:r.find(x=>x.description)?.description}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>o(!0),style:{fontSize:"13px"},children:"Reveal Content"})]})}const O={true:{label:"TRUE",color:"#10b981",icon:"✅",bg:"rgba(16,185,129,0.12)"},false:{label:"FALSE",color:"#ef4444",icon:"❌",bg:"rgba(239,68,68,0.12)"},mixed:{label:"MIXED",color:"#f59e0b",icon:"⚖️",bg:"rgba(245,158,11,0.12)"}};function Xs({postId:t,postTitle:n,compact:r}){const{user:i}=te(),[s,o]=l.useState(null),[d,c]=l.useState(!0),[a,x]=l.useState(null),[p,b]=l.useState(25),[g,w]=l.useState(!1),[h,v]=l.useState(!1),[y,S]=l.useState(null),[j,C]=l.useState(null),E=l.useCallback(async()=>{try{const k=await _.request(`/truth-stakes?post_id=${t}`);k.success&&o(k.data)}catch{}finally{c(!1)}},[t]);l.useEffect(()=>{E()},[E]);const A=async()=>
41{if(!(!i||!a)){w(!0),S(null);try{const k=await _.request("/truth-stakes",{method:"POST",body:JSON.stringify({post_id:t,position:a,stake_amount:p})});k.success?(C(`Staked ${p} karma on ${a.toUpperCase()}!`),de("medium"),v(!1),x(null),E(),setTimeout(()=>C(null),3e3)):S(k.error||"Failed to place stake")}catch{S("Network error")}finally{w(!1)}}};if(d)return e.jsx("div",{style:{padding:"12px",color:"var(--text-muted)",fontSize:"12px"},children:"Loading stakes..."});if(!s)return null;const z=s.pool,N=s.total_pool;z.resolution;const se=N>0?z.total_true/N*100:33,M=N>0?z.total_false/N*100:33,ne=N>0?z.total_mixed/N*100:34;return r?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"rgba(99,102,241,0.06)",borderRadius:"10px",border:"1px solid rgba(99,102,241,0.15)",fontSize:"12px"},children:[e.jsxs("span",{style:{fontWeight:700,color:"#6366f1"},children:["🎯 ",N," karma staked"]}),e.jsxs("span",{style:{color:"#10b981"},children:["✅ ",z.total_true]}),e.jsxs("span",{style:{color:"#ef4444"},children:["❌ ",z.total_false]}),e.jsxs("span",{style:{color:"#f59e0b"},children:["⚖️ ",z.total_mixed]}),e.jsxs("span",{style:{color:"var(--text-muted)"},children:["· ",z.total_stakers," stakers"]})]}):e.jsxs("div",{style:{background:"linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.04))",border:"1px solid rgba(99,102,241,0.2)",borderRadius:"12px",padding:"16px",marginTop:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🎯"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700,fontSize:"14px"},children:"Truth Stakes"}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"Stake karma on whether this claim is true or false"})]})]}),e.jsxs("div",{style:{padding:"4px 10px",borderRadius:"12px",fontSize:"12px",fontWeight:700,background:"rgba(99,102,241,0.15)",color:"#6366f1"},children:[ie(N)," karma pool"]})]}),e.jsxs("div",{style:{display:"flex",height:"8px",borderRadius:"4px",overflow:"hidden",background:"rgba(255,255,255,0.05)",marginBottom:"8px"},children:[e.jsx("div",{style:{width:`${se}%`,background:"#10b981",transition:"width 0.5s"}}),e.jsx("div",{style:{width:`${ne}%`,background:"#f59e0b",transition:"width 0.5s"}}),e.jsx("div",{style:{width:`${M}%`,background:"#ef4444",transition:"width 0.5s"}})]}),e.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:["true","false","mixed"].map(k=>{const W=O[k],re=k==="true"?z.total_true:k==="false"?z.total_false:z.total_mixed,F=s.odds[k],V=a===k,K=s.my_stake?.position===k;return e.jsxs("button",{onClick:()=>{x(k),v(!0)},style:{flex:1,padding:"10px",borderRadius:"10px",border:"none",background:V?W.bg:K?`${W.bg}`:"rgba(255,255,255,0.04)",cursor:"pointer",transition:"all 0.2s",outline:V?`2px solid ${W.color}`:K?`1px solid ${W.color}55`:"1px solid var(--border)",minHeight:"44px"},children:[e.jsx("div",{style:{fontSize:"16px"},children:W.icon}),e.jsx("div",{style:{fontSize:"11px",fontWeight:700,color:W.color},children:W.label}),e.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:"var(--text-primary)"},children:ie(re)}),e.jsxs("div",{style:{fontSize:"10px",color:"var(--text-muted)"},children:[F,"x odds"]}),K&&e.jsx("div",{style:{fontSize:"9px",color:W.color,marginTop:"2px"},children:"YOUR BET"})]},k)})}),s.my_stake&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"rgba(255,255,255,0.03)",borderRadius:"8px",marginBottom:"12px",fontSize:"12px"},children:[e.jsxs("span",{style:{color:"var(--text-muted)"},children:["Your stake: ",e.jsxs("strong",{style:{color:O[s.my_stake.position]?.color},children:[s.my_stake.stake_amount," karma on ",s.my_stake.position?.toUpperCase()]})]}),e.jsx("span",{style:{padding:"2px 8px",borderRadius:"8px",fontSize:"10px",fontWeight:700,background:s.my_stake.status==="active"?"rgba(99,102,241,0.15)":"rgba(16,185,129,0.15)",color:s.my_stake.status==="active"?"#6366f1":"#10b981"},children:s.my_stake.status.toUpperCase()})]}),h&&a&&!s.my_stake&&e.jsxs("div",{style:{padding:"12px",background:"rgba(255,255,255,0.03)",borderRadius:"10px",border:`1px solid ${O[a].color}33`},children:[e.jsxs("div",{style:{fontSize:"12px",fontWeight:700,marginBottom:"8px",color:O[a].color},children:[O[a].icon," Betting ",a.toUpperCase()]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"10px"},children:[e.jsx("input",{type:"range",min:5,max:500,step:5,value:p,onChange:k=>b(Number(k.target.value)),style:{flex:1,accentColor:O[a].color}}),e.jsxs("span",{style:{fontWeight:700,fontSize:"16px",minWidth:"60px",textAlign:"right"},children:[p," ⭐"]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:A,disabled:g||!i,style:{flex:1,padding:"10px",borderRadius:"8px",border:"none",background:O[a].color,color:"#fff",fontWeight:700,fontSize:"13px",cursor:"pointer",minHeight:"44px",opacity:g?.6:1},children:g?"Placing...":`Stake ${p} Karma`}),e.jsx("button",{onClick:()=>{v(!1),x(null)},style:{padding:"10px 16px",borderRadius:"8px",border:"1px solid var(--border)",background:"transparent",color:"var(--text-secondary)",fontSize:"13px",cursor:"pointer",minHeight:"44px"},children:"Cancel"})]}),!i&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",marginTop:"8px",textAlign:"center"},children:"Login to stake karma on claims"})]}),j&&e.jsxs("div",{style:{padding:"8px 12px",background:"rgba(16,185,129,0.12)",borderRadius:"8px",color:"#10b981",fontSize:"12px",fontWeight:600,marginTop:"8px"},children:["✅ ",j]}),y&&e.jsxs("div",{style:{padding:"8px 12px",background:"rgba(239,68,68,0.12)",borderRadius:"8px",color:"#ef4444",fontSize:"12px",fontWeight:600,marginTop:"8px"},children:["❌ ",y]}),s.stakes.length>0&&e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,color:"var(--text-muted)",marginBottom:"6px"},children:"Recent Stakers"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:s.stakes.slice(0,10).map((k,W)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"3px 8px",borderRadius:"12px",fontSize:"10px",background:O[k.position]?.bg||"rgba(255,255,255,0.04)",border:`1px solid ${O[k.position]?.color||"#6366f1"}33`},children:[e.jsx("div",{style:{width:"16px",height:"16px",borderRadius:"50%",background:k.avatar_color||"#6366f1",fontSize:"8px",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontWeight:700},children:k.username?.slice(0,1).toUpperCase()}),e.jsx("span",{style:{fontWeight:600},children:k.username}),e.jsxs("span",{style:{color:"var(--text-muted)"},children:[k.stake_amount,"⭐"]})]},W))})]})]})}function nn(){const{id:t}=kt(),[n]=Ct(),r=n.get("debunk")==="true";Rt({title:"Post",description:"View post and join the discussion on HigherUp."});const{user:i}=te(),[s,o]=l.useState(null),[d,c]=l.useState([]),[a,x]=l.useState(!0),[p,b]=l.useState(""),[g,w]=l.useState(!1),[h,v]=l.useState(""),[y,S]=l.useState(null),[j,C]=l.useState(""),E=l.useRef(!1),[A,z]=l.useState([]),[N,se]=l.useState(0),[M,ne]=l.useState("thread"),[k,W]=l.useState(0),[re,F]=l.useState([]),[V,K]=l.useState(!1),[ye,oe]=l.useState([]),[ae,be]=l.useState([]),m=l.useRef(null),I=l.useRef(0),ve=l.useRef(null);l.useEffect(()=>{const u=()=>{const T=window.scrollY,B=document.documentElement.scrollHeight-window.innerHeight;W(B>0?Math.min(T/B*100,100):0)};return window.addEventListener("scroll",u,{passive:!0}),()=>window.removeEventListener("scroll",u)},[]),l.useEffect(()=>{t&&_.related(Number(t)).then(u=>{u.success&&u.data&&oe((Array.isArray(u.data)?u.data:[]).slice(0,4))}).catch(()=>{})},[t]);const le=u=>{const T={id:I.current++,emoji:u,x:Math.random()*60+20,y:100};F(B=>[...B,T]),setTimeout(()=>{F(B=>B.filter(ce=>ce.id!==T.id))},1500)},vt=()=>{const u=`${window.location.origin}/post/${s?.id}`;navigator.share?navigator.share({title:s?.title,url:u}):(navigator.clipboard.writeText(u),le("📋"))},jt=()=>{K(!V),le(V?"🔖":"✅")},St=()=>{m.current?.scrollIntoView({behavior:"smooth",block:"start"})},Ke=l.useCallback(async()=>{try{const u=await _.posts.get(Number(t));u.success&&u.data&&o(u.data)}catch{}},[t]),Y=l.useCallback(async()=>{try{const u=await _.comments.list(Number(t));u.success&&u.data&&c(u.data)}catch{}},[t]);l.useEffect(()=>{Promise.all([Ke(),Y()]).finally(()=>x(!1))},[Ke,Y]);const Ee=l.useRef(!1);l.useEffect(()=>{const u=setInterval(async()=>
41{if(!(document.hidden||Ee.current)){Ee.current=!0;try{await Y()}finally{Ee.current=!1}}},1e4);return()=>clearInterval(u)},[Y]),l.useEffect(()=>{t&&_.reposts.getForPost(Number(t)).then(u=>{u.success&&u.data&&(z(u.data.recentQuotes||[]),se(u.data.totalReposts||0))}).catch(()=>{})},[t]),l.useEffect(()=>{if(!s)return;const u=document.createElement("script");return u.type="application/ld+json",u.text=JSON.stringify({"@context":"https://schema.org","@type":"Article",headline:s.title,author:s.username,datePublished:s.created_at,description:(s.body||"").slice(0,160)}),document.head.appendChild(u),()=>{document.head.removeChild(u)}},[s]),l.useEffect(()=>{if(!s||!s.signature||!s.sig_fingerprint||E.current||!i)return;E.current=!0;const u=[s.title,s.body||"",s.link_url||""].filter(Boolean).join(`
42`);Ye(u,s.signature,s.user_id,s.sig_fingerprint).then(({valid:T,reason:B})=>{S(T),C(B||"")}).catch(()=>{S(!1),C("Verification error")}).finally(()=>{E.current=!1})},[s,i]);const wt=async()=>{if(!p.trim())return;w(!0),v("");const u=await _.comments.create({post_id:Number(t),body:p.trim()});if(u.success){const T=u.data;if(b(""),_.achievements.check(),Y(),T?.swarm_triggered&&T.personas?.length){be(T.personas);let B=0;const ce=setInterval(()=>{B++,Y(),B>=3&&(clearInterval(ce),be([]))},5e3)}}else v(u.error||"Failed to post comment");w(!1)};return a?e.jsx("div",{className:"main-container fade-in",children:e.jsxs("div",{className:"content-area",children:[e.jsx(At,{count:1}),e.jsx("div",{className:"card",style:{padding:"16px",marginBottom:"16px"},children:e.jsx(Pt,{type:"comment",count:4})})]})}):s?e.jsxs("div",{className:"main-container fade-in",children:[e.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,height:"3px",zIndex:100,background:"var(--bg-tertiary)"},children:e.jsx("div",{style:{height:"100%",width:`${k}%`,background:"linear-gradient(90deg, var(--color-indigo, #6366f1), var(--color-pink, #ec4899), var(--color-amber, #f59e0b))",transition:"width 0.1s ease-out",borderRadius:"0 2px 2px 0"}})}),re.map(u=>e.jsx("div",{style:{position:"fixed",left:`${u.x}%`,bottom:`${u.y}%`,fontSize:"32px",zIndex:200,pointerEvents:"none",animation:"floatUp 1.5s ease-out forwards"},children:u.emoji},u.id)),e.jsx("style",{children:`
43        @keyframes floatUp {
44          0% { opacity: 1; transform: translateY(0) scale(1); }
45          50% { opacity: 1; transform: translateY(-80px) scale(1.3); }
46          100% { opacity: 0; transform: translateY(-160px) scale(0.8); }
47        }
48        @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
49        @media (max-width: 768px) {
50          .sticky-comment-input { position: fixed; bottom: 60px; left: 0; right: 0; z-index: 40; padding: 8px 16px; background: var(--bg-primary); backdrop-filter: blur(20px); border-top: 1px solid var(--border); }
51        }
52      `}),e.jsxs("div",{className:"content-area",children:[s&&e.jsx($t,{crumbs:[{label:"Home",to:"/"},{label:"Communities",to:"/"},...s.community_slug?[{label:`c/${s.community_slug}`,to:`/c/${s.community_slug}`}]:[],{label:"Post"}]}),r&&e.jsx(Zt,{claim:s.title+(s.body?`
53
54`+s.body:""),postId:s.id}),e.jsx("div",{className:"post-detail fade-in",children:e.jsxs("div",{style:{display:"flex"},children:[e.jsx(De,{entityType:"post",entityId:s.id,initialVote:s.user_vote,initialScore:s.score,size:"full"}),e.jsxs("div",{className:"post-detail-header",style:{flex:1},children:[e.jsxs("div",{className:"post-meta",children:[e.jsxs(P,{to:`/c/${s.community_slug}`,className:"community-badge",children:[e.jsx("span",{className:"dot",style:{background:s.community_icon}}),"c/",s.community_slug]}),e.jsx("span",{className:"separator",children:"•"}),e.jsx("span",{children:"Posted by"}),e.jsxs(P,{to:`/u/${s.username}`,children:[e.jsx("div",{className:"avatar avatar-sm",style:{background:s.user_avatar_color,display:"inline-flex",verticalAlign:"middle",marginRight:"2px"},children:We(s.username)}),"u/",s.username]}),s.signature&&y===!0&&e.jsx("span",{style:{background:"var(--success)",color:"white",borderRadius:"4px",padding:"1px 6px",fontSize:"11px",fontWeight:700,marginLeft:"4px"},title:`Cryptographically signed by @${s.username}
55Fingerprint: ${s.sig_fingerprint||"unknown"}`,children:"🔐 Verified Author"}),s.signature&&y===!1&&j&&j.includes("not found")&&e.jsx("span",{style:{background:"var(--warning)",color:"var(--text-primary)",borderRadius:"4px",padding:"1px 6px",fontSize:"11px",fontWeight:700,marginLeft:"4px",cursor:"help"},title:`Signature exists but author's public key is not available locally. Exchange keys with @${s.username} to verify.`,children:"🔐 Signed (unverified)"}),s.signature&&y===!1&&(!j||!j.includes("not found"))&&e.jsx("span",{style:{background:"var(--danger)",color:"white",borderRadius:"4px",padding:"1px 6px",fontSize:"11px",fontWeight:700,marginLeft:"4px",cursor:"pointer"},title:`Signature verification failed: ${j||"tampered or wrong key"}
56Click to retry`,onClick:async()=>
56{if(!i)return;const u=[s.title,s.body||"",s.link_url||""].filter(Boolean).join(`
57`),{valid:T,reason:B}=await Ye(u,s.signature,s.user_id,s.sig_fingerprint);S(T),C(B||"")},children:"⚠️ Signature Invalid"}),s.signature&&y===null&&e.jsx("span",{style:{background:"var(--warning)",color:"white",borderRadius:"4px",padding:"1px 6px",fontSize:"11px",fontWeight:700,marginLeft:"4px"},children:"🔐 Verifying…"}),s.is_streamer===1&&e.jsx("span",{className:"streamer-badge",children:"🎙️ Streamer"}),e.jsx("span",{className:"separator",children:"•"}),e.jsx("span",{children:Se(s.created_at)})]}),e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,marginBottom:"8px"},children:s.title}),e.jsxs(Ys,{postId:s.id,children:[s.link_url&&e.jsxs("a",{href:s.link_url,target:"_blank",rel:"noopener",className:"post-link-preview",style:{marginBottom:"12px"},children:["🔗 ",s.link_url]}),s.body&&e.jsx("div",{className:"post-content-full",children:Lt(s.body)}),e.jsx(_t,{postId:s.id})]}),s.body&&(()=>{const u=/https?:\/\/[^\s<>"{}|\\^`\[\]]+/g,T=[...new Set((s.body.match(u)||[]).filter(B=>!B.match(/\.(jpg|jpeg|png|gif|webp|svg)$/i)))];return T.length>0?T.slice(0,2).map((B,ce)=>e.jsx(zt,{url:B},ce)):null})(),e.jsxs("div",{className:"post-actions",style:{marginTop:"12px",marginBottom:"8px"},children:[e.jsxs("span",{className:"post-action",children:[e.jsx("span",{className:"icon",children:"💬"})," ",s.comment_count," Comments"]}),e.jsx(Et,{postId:s.id,initialCount:N}),e.jsx(Fs,{postId:s.id,title:s.title}),e.jsxs("button",{className:"post-action","aria-label":"Debunk with AI",onClick:()=>{const u=`${window.location.origin}/post/${s.id}?debunk=true`;window.location.href=u},children:[e.jsx("span",{className:"icon",children:"🔬"})," Debunk with AI"]})]}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(es,{title:s.title,url:`${window.location.origin}/post/${s.id}`,text:`AI is verifying this claim on HigherUp: ${s.title}`})})]})]})}),e.jsxs("div",{ref:m,className:"card sticky-comment-input",style:{padding:"16px",marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"14px",marginBottom:"12px"},children:"Add a comment"}),i?e.jsxs(e.Fragment,{children:[h&&e.jsx("div",{className:"alert alert-error",style:{marginBottom:"8px"},children:h}),e.jsx("textarea",{ref:ve,value:p,onChange:u=>b(u.target.value),placeholder:"Share your thoughts, evidence, or analysis...","aria-label":"Write a comment",rows:3,style:{width:"100%",padding:"10px 14px",background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text-primary)",resize:"vertical",marginBottom:"8px"}}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:wt,disabled:g||!p.trim(),children:g?"Posting...":"Post Comment"})]}):e.jsxs("div",{className:"alert alert-info",children:[e.jsx(P,{to:"/login",children:"Login"})," to join the discussion."]})]}),e.jsxs("div",{className:"card",style:{padding:"16px",marginBottom:"16px"},"aria-live":"polite",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[e.jsxs("h3",{style:{fontSize:"14px",margin:0},children:[s.comment_count," Comments"]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx("button",{onClick:()=>ne("thread"),className:"btn-ghost",style:{padding:"4px 10px",borderRadius:"6px",fontSize:"12px",background:M==="thread"?"var(--accent)":"transparent",color:M==="thread"?"#fff":"var(--text-muted)",border:"none",cursor:"pointer"},children:"🧵 Thread"}),e.jsx("button",{onClick:()=>ne("flat"),className:"btn-ghost",style:{padding:"4px 10px",borderRadius:"6px",fontSize:"12px",background:M==="flat"?"var(--accent)":"transparent",color:M==="flat"?"#fff":"var(--text-muted)",border:"none",cursor:"pointer"},children:"📋 Flat"})]})]}),ae.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:16},children:[ae.map(u=>{const T=we[u]||{icon:"🤖",color:"#6366f1",label:u};return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",borderRadius:12,background:`${T.color}08`,border:`1px solid ${T.color}22`,animation:"swarm-thinking 1.5s ease-in-out infinite"},children:[e.jsx("span",{style:{fontSize:18},children:T.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:T.color},children:T.label||`The ${u}`}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:"is analyzing and composing a response..."})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx("div",{className:"spinner",style:{width:16,height:16}})})]},u)}),e.jsx("style",{children:"@keyframes swarm-thinking { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }"})]}),d.length===0&&ae.length===0?e.jsx("p",{className:"text-muted",style:{fontSize:"14px"},children:"No comments yet. Start the conversation!"}):M==="thread"?e.jsx(Vt,{comments:d,postId:s.id,onRefresh:Y}):e.jsx(Mt,{comments:d,postId:s.id,onReply:Y})]}),A.length>0&&e.jsxs("div",{className:"card",style:{padding:"16px",marginBottom:"16
57px"},children:[e.jsxs("h3",{style:{fontSize:"14px",marginBottom:"12px"},children:["🔄 ",A.length," Quote Repost",A.length!==1?"s":""]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:A.map(u=>e.jsxs("div",{style:{display:"flex",gap:"10px",padding:"10px 12px",background:"var(--bg-input)",borderRadius:"8px"},children:[e.jsx(P,{to:`/u/${u.user.username}`,children:e.jsx("div",{className:"avatar avatar-sm",style:{background:u.user.avatar_color},children:(u.user.username[0]||"?").toUpperCase()})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",marginBottom:"4px"},children:[e.jsx(P,{to:`/u/${u.user.username}`,style:{fontWeight:700,fontSize:"13px",color:"var(--text-primary)",textDecoration:"none"},children:u.user.username}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:Se(u.created_at)})]}),e.jsx("p",{style:{margin:0,fontSize:"14px",color:"var(--text-primary)",lineHeight:1.5},children:u.quote_text})]})]},u.id))})]}),e.jsx(Xs,{postId:s.id,postTitle:s.title}),e.jsx(Gt,{postId:s.id}),e.jsx(Qt,{postId:s.id,tags:s.body?s.body.match(/#(\w+)/g)?.map(u=>u.slice(1))||[]:[]}),ye.length>0&&e.jsxs("div",{className:"card fade-in",style:{padding:"16px",marginTop:"16px",marginBottom:"80px"},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:700,marginBottom:"12px"},children:"📰 Related Posts"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:ye.map(u=>e.jsxs(P,{to:`/post/${u.id}`,style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px",background:"var(--bg-input)",borderRadius:"var(--radius-sm)",textDecoration:"none",color:"inherit",border:"1px solid var(--border)",transition:"border-color 0.15s"},onMouseEnter:T=>T.currentTarget.style.borderColor="var(--accent)",onMouseLeave:T=>T.currentTarget.style.borderColor="var(--border)",children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:"var(--text-primary)",marginBottom:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.title}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:["c/",u.community_slug," · u/",u.username]})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"var(--text-muted)",flexShrink:0,marginLeft:"12px"},children:[e.jsxs("span",{children:["▲ ",ie(u.score)]}),e.jsxs("span",{children:["💬 ",ie(u.comment_count)]})]})]},u.id))})]})]}),e.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:50,background:"var(--bg-primary)",backdropFilter:"blur(20px)",borderTop:"1px solid var(--border)",padding:"10px 16px",display:"flex",justifyContent:"space-around",alignItems:"center"},children:[e.jsxs("button",{onClick:()=>{le("❤️"),de("light")},style:{background:"none",border:"none",color:"var(--text-primary)",fontSize:"13px",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",minHeight:"44px",padding:"6px 12px"},children:["❤️ ",e.jsx("span",{style:{fontSize:"10px"},children:ie(s.score)})]}),e.jsxs("button",{onClick:()=>{St(),de("light")},style:{background:"none",border:"none",color:"var(--text-primary)",fontSize:"13px",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",minHeight:"44px",padding:"6px 12px"},children:["💬 ",e.jsx("span",{style:{fontSize:"10px"},children:ie(s.comment_count)})]}),e.jsxs("button",{onClick:()=>{vt(),de("light")},style:{background:"none",border:"none",color:"var(--text-primary)",fontSize:"13px",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",minHeight:"44px",padding:"6px 12px"},children:["🔗 ",e.jsx("span",{style:{fontSize:"10px"},children:"Share"})]}),e.jsxs("button",{onClick:()=>{jt(),de("light")},style:{background:"none",border:"none",color:V?"var(--color-amber, #f59e0b)":"var(--text-primary)",fontSize:"13px",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",minHeight:"44px",padding:"6px 12px"},children:[V?"🔖":"📑"," ",e.jsx("span",{style:{fontSize:"10px"},children:"Save"})]})]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"icon",children:"🔍"}),e.jsx("h3",{children:"Post not found"}),e.jsx(P,{to:"/",className:"btn btn-primary mt-2",children:"Back to Home"})]})}
57export{nn as PostDetailPage};

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.