1import{r as p,j as e,L as B,R as P}from"./index-iAVlVxvB.js";import{A as f,E as T,a as c,C as j,S as o,b as C}from"./primitives-B-PYiOq8.js";import{P as y,A as I}from"./ProteinViewer-CjSM9xM2.js";import"./Sidebar-BstMbomz.js";const L="http://localhost:8000";function R(t){return t==="RECRUITING"?"#A8C979":t==="COMPLETED"?"#7FA8B8":t==="ACTIVE_NOT_RECRUITING"?"#D6B25A":"#8A8F86"}function $({query:t}){const[x,d]=p.useState("loading"),[v,S]=p.useState(null),[E,z]=p.useState("");p.useEffect(()=>{if(!t.trim()){d("error"),z("No query provided.");return}d("loading"),fetch(`${L}/api/research?q=${encodeURIComponent(t)}`).then(s=>{if(!s.ok)throw new Error(`API error ${s.status}`);return s.json()}).then(s=>{if(s.error)throw new Error(s.error);S(s),d("done")}).catch(s=>{z(s.message),d("error")})},[t]);const m=e.jsxs(B,{to:"/",search:{q:t},className:"inline-flex items-center gap-2 font-mono-pz text-[10px] tracking-[0.18em] uppercase text-pz-muted hover:text-pz-accent transition-colors",children:[e.jsx(I,{size:12})," Back to Search"]});if(x==="loading")return e.jsxs(f,{title:"Research",loading:!0,children:[m,e.jsxs("div",{className:"mt-16 flex flex-col items-center gap-5",children:[e.jsx("span",{className:"h-8 w-8 rounded-full border border-[rgba(168,201,121,0.35)] border-t-pz-accent animate-spin"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-mono-pz text-[10px] tracking-[0.28em] uppercase text-pz-accent",children:"Research agents parsing evidenceâ¦"}),e.jsx("p",{className:"mt-2 font-mono-pz text-[9px] tracking-[0.18em] uppercase text-pz-muted",children:"UniProt · Open Targets · ChEMBL · ClinicalTrials · RCSB PDB"})]}),e.jsxs("p",{className:"font-mono-pz text-[9px] tracking-[0.14em] text-pz-muted/60 mt-2",children:['"',t,'"']})]})]});if(x==="error"||!v)return e.jsxs(f,{title:"Research",loading:!1,children:[m,e.jsx("div",{className:"mt-6",children:e.jsx(T,{label:E||"Research query failed."})})]});const{normalized:r,structure:a,sources:h,signals:b,risks:w,recommendation:l}=v,n=h.openTargets,u=h.uniprot,g=h.clinicalTrials,A=l.score>=65?"#A8C979":l.score>=45?"#D6B25A":"#C98A8A",k=a.pdbId||void 0,_=a.pdbUrl||a.alphafoldUrl||void 0;return e.jsxs(f,{title:"Research",loading:!1,children:[m,e.jsxs("div",{className:"mt-5 flex flex-col gap-5",children:[e.jsx(c,{children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1.2fr_1fr] gap-6 items-start",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-mono-pz text-[10px] tracking-[0.22em] uppercase text-pz-accent",children:[r.gene_symbol,r.uniprot_accession&&e.jsxs("span",{className:"text-pz-muted",children:[" · ",r.uniprot_accession]})]}),e.jsx("h1",{className:"mt-2 font-serif-display text-[38px] leading-none text-pz-text font-normal",children:r.target_name}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(j,{label:r.modality,color:"#A8C979"}),r.indication&&e.jsx(j,{label:r.indication,color:"#7FA8B8"}),e.jsx(j,{label:l.label,color:A})]}),!!u.function&&e.jsxs("p",{className:"mt-4 text-[12.5px] leading-relaxed text-pz-soft font-light max-w-xl",children:[String(u.function).slice(0,280),String(u.function).length>280?"â¦":""]}),e.jsxs("div",{className:"mt-5 grid grid-cols-3 gap-4 border-t pz-border pt-4",children:[e.jsx(N,{label:"Rec. Score",value:`${l.score}/100`}),e.jsx(N,{label:"Confidence",value:l.confidence}),e.jsx(N,{label:"Structure",value:a.status==="experimental"?`PDB · ${k}`:a.status==="predicted"?"AlphaFold":"Fallback"})]})]}),e.jsxs("div",{className:"w-full max-w-[400px] mx-auto",children:[e.jsx(y,{pdbId:k,pdbUrl:_,height:300,mode:"cartoon"}),e.jsx("div",{className:"mt-2 flex items-center gap-2",children:e.jsx("span",{className:"font-mono-pz text-[8.5px] tracking-[0.18em] uppercase text-pz-muted",children:a.status==="experimental"?`Experimental · ${a.method??"X-ray"} · ${a.resolution?`${a.resolution}Ã
`:""}`:a.status==="predicted"?"AlphaFold · Predicted Structure":"Structure preview unavailable"})})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:[e.jsxs(c,{children:[e.jsx(o,{children:"Evidence Signals"}),e.jsxs("ul",{className:"mt-4 flex flex-col gap-2.5",children:[b.map((s,i)=>e.jsxs("li",{className:"flex gap-2.5 text-[12.5px] leading-snug text-pz-soft font-light",children:[e.jsx("span",{className:"text-pz-accent text-[7px] pt-1.5 shrink-0",children:"â"}),e.jsx("span",{children:s})]},i)),b.length===0&&e.jsx("li",{className:"text-pz-muted font-mono-pz text-[9.5px] tracking-[0.14em] uppercase",children:"No signals extracted"})]})]}),e.jsxs(c,{children:[e.jsx(o,{children:"Risk Flags"}),e.jsx("ul",{className:"mt-4 flex flex-col gap-2.5",children:w.map((s,i)=>e.jsxs("li",{className:"flex gap-2.5 text-[12.5px] leading-snug text-pz-soft font-light",children:[e.jsx("span",{className:"text-[#D6B25A] text-[7px] pt-1.5 shrink-0",children:"â²"}),e.jsx("span",{children:s})]},i))}),e.jsxs("div",{className:"mt-5 border-t pz-border pt-4",children:[e.jsx(o,{children:"Recommendation"}),e.jsx("div",{className:"mt-3 flex flex-col gap-2",children:e.jsx(C,{label:"Conviction Score",value:l.score,color:A})}),e.jsx("ul",{className:"mt-3 flex flex-col gap-1.5",children:l.rationale.map((s,i)=>e.jsx("li",{className:"text-[12px] leading-snug text-pz-soft font-light",children:s},i))})]})]})]}),n&&!n.error&&Array.isArray(n.top_diseases)&&n.top_diseases.length>0&&e.jsxs(c,{children:[e.jsxs(o,{children:["Open Targets · Disease Associations",n.association_count?` (${n.association_count} total)`:""]}),e.jsx("div",{className:"mt-4 flex flex-col gap-3",children:n.top_diseases.map(s=>e.jsx(C,{label:s.name,value:s.score*100,max:100},s.name))})]}),g&&g.length>
10&&e.jsxs(c,{children:[e.jsx(o,{children:"ClinicalTrials.gov · Trial Landscape"}),e.jsx("ul",{className:"mt-4 flex flex-col",children:g.map(s=>e.jsx("li",{className:"border-t pz-border py-3 first:border-t-0",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"mt-1 h-1.5 w-1.5 rounded-full shrink-0",style:{background:R(s.status)}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[12.5px] leading-snug text-pz-soft font-light",children:s.title}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-4 gap-y-0.5 font-mono-pz text-[9px] tracking-[0.12em] uppercase text-pz-muted",children:[e.jsx("span",{children:s.nct_id}),e.jsx("span",{children:s.phase}),e.jsx("span",{style:{color:R(s.status)},children:s.status}),s.sponsor&&e.jsx("span",{children:s.sponsor})]})]})]})},s.nct_id))})]})]})]})}function N({label:t,value:x}){return e.jsxs("div",{children:[e.jsx("div",{className:"font-mono-pz text-[9px] tracking-[0.18em] uppercase text-pz-muted",children:t}),e.jsx("div",{className:"mt-1 text-[13px] text-pz-text font-light",children:x})]})}function O(){const{q:t}=P.useSearch();return e.jsx($,{query:t})}export{O as component};
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.