1import{j as e}from"./index-12DC86Qv.js";import{u as I,r as d,L as E}from"./vendor-BcCsE5pw.js";import{d as A,u as C,a as j}from"./App-HVuyHYBt.js";const p=[{id:"skeptic",persona:"Skeptic",icon:"ð",color:"#ef4444",label:"The Skeptic",prompt:"Challenge this claim. Find logical fallacies, missing evidence, and counter-arguments. Be rigorous but fair."},{id:"researcher",persona:"Researcher",icon:"ð",color:"#6366f1",label:"The Researcher",prompt:"Analyze this claim with evidence. Cite sources, compare with known data, and assess factual accuracy."},{id:"optimist",persona:"Optimist",icon:"ð",color:"#10b981",label:"The Optimist",prompt:"Find the kernel of truth in this claim. Steel-man the argument, identify what's correct, and suggest improvements."},{id:"historian",persona:"Historian",icon:"ð",color:"#f59e0b",label:"The Historian",prompt:"Provide historical context. Compare this claim with similar claims in history, show patterns, and draw parallels."}],c={TRUE:{color:"#10b981",bg:"rgba(16,185,129,0.12)",icon:"â "},FALSE:{color:"#ef4444",bg:"rgba(239,68,68,0.12)",icon:"â"},MIXED:{color:"#f59e0b",bg:"rgba(245,158,11,0.12)",icon:"âï¸"},UNVERIFIABLE:{color:"#6366f1",bg:"rgba(99,102,241,0.12)",icon:"â"}};function $(){A({title:"Truth Stream â Live AI Fact-Checking",description:"Submit a claim and watch four AI agents analyse it from different angles in parallel, then synthesise a verdict."});const{user:f}=C(),x=I(),[s,b]=d.useState(""),[r,l]=d.useState(null),u="cloudflare",h="@cf/meta/llama-3.2-3b-instruct",[y,w]=d.useState(""),m=d.useRef(null);d.useEffect(()=>{m.current&&(m.current.scrollTop=m.current.scrollHeight)},[r?.responses]);const R=d.useCallback(async()=>{if(!s.trim())return;if(!f){x("/login");return}w("");const t={claim:s.trim(),responses:p.map(i=>({id:i.id,persona:i.persona,icon:i.icon,color:i.color,label:i.label,content:"",status:"pending",timestamp:0})),verdict:null,verdictScore:0,verdictSummary:null,status:"streaming",startedAt:Date.now()};l(t);const v=(await Promise.allSettled(p.map(async i=>{l(a=>a&&{...a,responses:a.responses.map(n=>n.id===i.id?{...n,status:"thinking",timestamp:Date.now()}:n)});try{const a=await j.ai.chat({messages:[{role:"system",content:`You are ${i.label}, an AI fact-checker on HigherUp. ${i.prompt} 2 3Respond in 2-4 paragraphs. Be specific, cite reasoning, and end with a confidence level (HIGH/MEDIUM/LOW).`},{role:"user",content:`Fact-check this claim: 4 5"${s.trim()}"`}],provider:u,model:h});if(a.success&&a.data)return l(n=>n&&{...n,responses:n.responses.map(o=>o.id===i.id?{...o,content:a.data.response,status:"done",timestamp:Date.now()}:o)}),a.data.response;throw new Error(a.error||"AI request failed")}catch(a){return l(n=>n&&{...n,responses:n.responses.map(o=>o.id===i.id?{...o,content:`Error: ${a instanceof Error?a.message:"Failed to get response"}`,status:"error",timestamp:Date.now()}:o)}),null}}))).filter(i=>i.status==="fulfilled"&&i.value!==null).map(i=>i.value);if(v.length>0)try{const i=await j.ai.chat({messages:[{role:"system",content:`You are the Chief Verdict Officer on HigherUp. Given multiple AI analyses of a claim, produce a final verdict. 6 7Respond in EXACTLY this format: 8VERDICT: [TRUE/FALSE/MIXED/UNVERIFIABLE] 9SCORE: [0-100] 10SUMMARY: [2-3 sentences explaining the verdict]`},{role:"user",content:`Claim: "${s.trim()}" 11 12Analyses: 13${v.map((a,n)=>`--- ${p[n]?.label||`Agent ${n+1}`} --- 14${a}`).join(` 15 16`)}`}],provider:u,model:h});if(i.success&&i.data){const a=i.data.response,n=a.match(/VERDICT:\s*(TRUE|FALSE|MIXED|UNVERIFIABLE)/i),o=a.match(/SCORE:\s*(\d+)/),k=a.match(/SUMMARY:\s*([\s\S]*)/i);l(g=>g&&{...g,verdict:n?.[1]?.toUpperCase()||"MIXED",verdictScore:parseInt(o?.[1]||"50"),verdictSummary:k?.[1]?.trim()||null,status:"complete",responses:g.responses.map(S=>({...S,content:S.content||"No response received."}))})}}catch{l(i=>i&&{...i,status:"complete",verdict:"MIXED",verdictScore:50,verdictSummary:"Insufficient data from AI agents to form a verdict."})}else l(i=>i&&{...i,status:"complete",verdict:"UNVERIFIABLE",verdictScore:0,verdictSummary:"No AI agents were able to analyze this claim. Please check your AI provider settings."})},[s,f,x,u,h]);return e.jsx("div",{className:"main-container fade-in",children:e.jsxs("div",{className:"content-area",style:{maxWidth:800},children:[e.jsxs("div",{style:{padding:"32px 24px",marginBottom:24,background:"linear-gradient(135deg, rgba(99,102,241,0.08), rgba(236,72,153,0.05), rgba(16,185,129,0.04))",border:"1px solid rgba(99,102,241,0.15)",borderRadius:16,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:48,marginBottom:8},children:"â¡"}),e.jsx("h1",{style:{fontSize:28,fontWeight:900,margin:"0 0 8px",background:"linear-gradient(135deg, #818cf8, #6366f1, #a5b4fc)",WebkitBackgroun
16dClip:"text",WebkitTextFillColor:"transparent"},children:"Truth Stream"}),e.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,maxWidth:500,margin:"0 auto 16px"},children:"Submit any claim and four AI agents analyse it in parallel â a Skeptic, a Researcher, an Optimist and a Historian â then a verdict is synthesised from their reasoning."}),e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:12,flexWrap:"wrap"},children:p.map(t=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:12,fontSize:12,fontWeight:600,background:`${t.color}15`,color:t.color,border:`1px solid ${t.color}30`},children:[t.icon," ",t.label]},t.id))})]}),!r&&e.jsxs("div",{style:{padding:24,marginBottom:24,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:12},children:[e.jsx("h3",{style:{fontSize:16,fontWeight:700,marginBottom:12},children:"ð Enter a Claim to Fact-Check"}),e.jsx("textarea",{value:s,onChange:t=>b(t.target.value),placeholder:"Paste any claim, conspiracy theory, news headline, or statement you want verified...",rows:4,style:{width:"100%",padding:"12px 16px",background:"var(--bg-input)",border:"1px solid var(--border)",borderRadius:8,color:"var(--text-primary)",fontSize:15,resize:"vertical",marginBottom:12}}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("button",{onClick:R,disabled:!s.trim(),style:{padding:"12px 24px",borderRadius:12,background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",color:"#fff",fontWeight:700,fontSize:15,cursor:s.trim()?"pointer":"not-allowed",opacity:s.trim()?1:.5,boxShadow:"0 4px 16px rgba(99,102,241,0.3)",minHeight:44},children:"â¡ Start Truth Stream"}),e.jsx("span",{style:{fontSize:12,color:"var(--text-muted)"},children:"4 AI agents will analyze in parallel (~30s)"})]}),y&&e.jsxs("div",{style:{marginTop:8,padding:"8px 12px",background:"rgba(239,68,68,0.12)",borderRadius:8,color:"#ef4444",fontSize:13},children:["â ",y]})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"16px 20px",marginBottom:16,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[e.jsx("span",{style:{fontSize:11,fontWeight:700,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:.5},children:"Claim Under Analysis"}),e.jsxs("span",{style:{padding:"2px 8px",borderRadius:8,fontSize:11,fontWeight:700,background:r.status==="streaming"?"rgba(239,68,68,0.15)":"rgba(16,185,129,0.15)",color:r.status==="streaming"?"#ef4444":"#10b981",display:"flex",alignItems:"center",gap:4},children:[r.status==="streaming"&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#ef4444",animation:"pulse 1.5s infinite"}}),r.status==="streaming"?"ANALYZING":"COMPLETE"]})]}),e.jsxs("p",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",lineHeight:1.5},children:['"',r.claim,'"']})]}),r.verdict&&r.status==="complete"&&e.jsxs("div",{style:{padding:"20px 24px",marginBottom:16,background:c[r.verdict]?.bg||"rgba(99,102,241,0.12)",border:`2px solid ${c[r.verdict]?.color||"#6366f1"}`,borderRadius:16,textAlign:"center",animation:"fadeIn 0.5s ease"},children:[e.jsx("div",{style:{fontSize:48,marginBottom:8},children:c[r.verdict]?.icon||"â"}),e.jsx("h2",{style:{fontSize:28,fontWeight:900,color:c[r.verdict]?.color,margin:"0 0 8px"},children:r.verdict}),e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8,padding:"6px 16px",borderRadius:20,background:"rgba(255,255,255,0.08)",fontSize:14,fontWeight:700},children:["Confidence: ",r.verdictScore,"/100",e.jsx("div",{style:{width:80,height:6,borderRadius:3,background:"rgba(255,255,255,0.15)",overflow:"hidden"},children:e.jsx("div",{style:{width:`${r.verdictScore}%`,height:"100%",borderRadius:3,background:c[r.verdict]?.color,transition:"width 1s ease"}})})]}),r.verdictSummary&&e.jsx("p",{style:{fontSize:14,color:"var(--text-secondary)",marginTop:12,maxWidth:500,margin:"12px auto 0",lineHeight:1.6},children:r.verdictSummary}),e.jsxs("p",{style:{fontSize:13,color:"var(--text-muted)",marginTop:8},children:["Based on ",r.responses.filter(t=>t.status==="done").length," AI agent analyses · Completed in ",Math.round((Date.now()-r.startedAt)/1e3),"s"]})]}),e.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",gap:12,marginBottom:24},children:r.responses.map(t=>e.jsxs("div",{style:{padding:"16px 20px",background:"var(--bg-card)",border:`1px solid ${t.status==="thinking"?t.color+"40":"var(--border)"}`,borderRadius:12,opacity:t.status==="pending"?.4:1,transition:"all 0.3s ease",animation:t.status==="done"?"fadeIn 0.4s ease":void 0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{width:32,height:32,borderRadius:"50%",background:`${t.color}20`,color:t.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:16},children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700,fontSize:14,color:t.color},children:t.label}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)"},children:[t.status==="pending"&&"Queued...",t.status==="thinking"&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:["Analyzing... ",e.jsx("span",{className:"spinner",style:{width:10,height:10,borderWidth:1.5}})]}),t.status==="done"&&`Completed in ${t.timestamp?Math.round((t.timestamp-r.startedAt)/1e3):"?"}s`,t.status==="error"&&"Failed â retry available"]})]}),t.status==="thinking"&&e.jsx("div",{style:{marginLeft:"auto"},children:e.jsxs("div",{className:"loading-dots",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})})]}),t.content&&e.jsx("div",{style:{fontSize:14,lineHeight:1.7,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word",padding:"8px 0",borderTop:"1px solid var(--border)"},children:t.content})]},t.id))}),r.status==="complete"&&e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center",padding:"16px 0 40px"},children:[e.jsx("button",{onClick:()=>{l(null),b("")},style:{padding:"12px 24px",borderRadius:12,background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",color:"#fff",fontWeight:700,fontSize:14,cursor:"pointer",minHeight:44},children:"â¡ New Truth Stream"}),e.jsx("button",{onClick:()=>{const t=`â¡ Truth Stream Result 17 18"${r.claim}" 19 20Verdict: ${r.verdict} (${r.verdictScore}/100) 21 22Verified by 4 AI agents on @higherup_ai 23https://higherup.ai/truth-stream`;navigator.share?navigator.share({title:"Truth Stream Result",text:t,url:window.location.href}):navigator.clipboard?.writeText(t)}
23,style:{padding:"12px 24px",borderRadius:12,background:"rgba(255,255,255,0.08)",border:"1px solid var(--border)",color:"var(--text-primary)",fontWeight:700,fontSize:14,cursor:"pointer",minHeight:44},children:"ð¤ Share Results"}),e.jsx(E,{to:"/",style:{padding:"12px 24px",borderRadius:12,background:"transparent",border:"1px solid var(--border)",color:"var(--text-secondary)",fontWeight:600,fontSize:14,textDecoration:"none",display:"flex",alignItems:"center",minHeight:44},children:"â Back to Feed"})]})]})]})})}export{$ 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.