1import{r,j as e,M as T,Z as G,l as z,k as V,S as Z,J as K}from"./index-BS6_cqLd.js";import{S as W}from"./SingleStructureViewer-BOe0_mPk.js";import{U}from"./upload-DLXC0sPY.js";import{H as _}from"./hash-C2_tzNNf.js";import{L as J}from"./link-2-BaeNS-gI.js";import"./camera-Be06PsMK.js";import"./DssrAnalysisSection-Coc5T1yj.js";import"./DSSRResultsPanel-Dg41i5aZ.js";import"./chevron-down-BMKgdhBQ.js";import"./chevron-right-CrliAE0K.js";import"./chevron-up-dBcQygn9.js";const X=[{id:"1EHZ",desc:"tRNA-Phe"},{id:"4TNA",desc:"tRNA"},{id:"1GID",desc:"Group I Intron"},{id:"2GDI",desc:"Ribozyme"}],q=[{key:"all",label:"All Lines"},{key:"atom",label:"ATOM Records"},{key:"hetatm",label:"HETATM Records"},{key:"header",label:"Header Info"},{key:"nucleic",label:"Nucleic Acids Only"}];function I(o,c,p){let s=o.split(` 2`);if(c==="atom")s=s.filter(n=>n.startsWith("ATOM"));else if(c==="hetatm")s=s.filter(n=>n.startsWith("HETATM"));else if(c==="header")s=s.filter(n=>/^(HEADER|TITLE|COMPND|SOURCE|AUTHOR|REMARK)/.test(n));else if(c==="nucleic"){const n=[" A "," C "," G "," U "," T "," DA "," DC "," DG "," DT "];s=s.filter(d=>n.some(b=>d.includes(b)))}if(p){const n=p.toUpperCase();s=s.filter(d=>d.toUpperCase().includes(n))}return s.join(` 3`)}const Q=o=>o>1024?`${(o/1024).toFixed(1)} MB`:`${o.toFixed(1)} KB`;function ie({initialContext:o}={}){const[c,p]=r.useState("pdbid"),[s,n]=r.useState(""),[d,b]=r.useState(""),[m,f]=r.useState(!1),[k,i]=r.useState(null),S=r.useRef(null),[l,C]=r.useState(null),[g,D]=r.useState(""),[F,R]=r.useState("pdb"),[j,N]=r.useState("viewer"),[v,M]=r.useState("all"),[w,O]=r.useState(""),h=r.useCallback((t,a,u)=>{C(t),D(a),R(u),i(null),N("viewer")},[]),y=async t=>{if(t.length===4){f(!0),i(null);try{let a=await fetch(`https://files.rcsb.org/download/${t.toUpperCase()}.pdb`);if(a.ok){h(await a.text(),`${t.toUpperCase()}.pdb`,"pdb");return}if(a=await fetch(`https://files.rcsb.org/download/${t.toUpperCase()}.cif`),a.ok){h(await a.text(),`${t.toUpperCase()}.cif`,"cif");return}throw new Error(`PDB ${t} not found (tried PDB and CIF formats)`)}catch(a){i(a.message)}finally{f(!1)}}},x=o?.pdbId,A=r.useRef(null);r.useEffect(()=>{!x||A.current===x||(A.current=x,p("pdbid"),n(x),y(x))},[x]);const P=async t=>{if(t){f(!0),i(null);try{const a=await fetch(t);if(!a.ok)throw new Error(`Failed: ${a.status}`);const u=await a.text(),E=t.split("/").pop()||"structure.pdb";h(u,E,E.toLowerCase().includes("cif")?"cif":"pdb")}catch(a){i(a.message)}finally{f(!1)}}},L=t=>{const a=new FileReader;a.onload=()=>{const u=t.name.split(".").pop()?.toLowerCase()||"";h(a.result,t.name,["cif","mmcif"].includes(u)?"cif":"pdb")},a.readAsText(t)},H=()=>{C(null),D(""),R("pdb"),N("viewer"),n(""),b(""),i(null)},$=[{key:"pdbid",label:"PDB ID",icon:e.jsx(_,{className:"w-3.5 h-3.5"})},{key:"upload",label:"Upload",icon:e.jsx(U,{className:"w-3.5 h-3.5"})},{key:"url",label:"URL",icon:e.jsx(J,{className:"w-3.5 h-3.5"})}],B=[{key:"viewer",label:"3D Viewer & DSSR",icon:"ð¬"},{key:"content",label:"File Content",icon:"ð"}];return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-accent-cyan/10 border border-accent-cyan/20 flex items-center justify-center shrink-0",children:e.jsx(T,{className:"w-7 h-7 text-accent-cyan"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-text-primary",children:"StructureAnnotation"}),e.jsx("p",{className:"text-text-secondary text-sm mt-0.5",children:"Advanced RNA/DNA Structure Visualization & DSSR Analysis"})]}),l&&e.jsx("div",{className:"ml-auto flex items-center gap-2",children:e.jsxs("button",{onClick:H,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-medium 4 border border-border-default bg-bg-secondary text-text-muted hover:text-text-primary transition-all`,children:[e.jsx(G,{className:"w-3.5 h-3.5"})," Reset"]})})]}),e.jsxs("div",{className:"rounded-xl border border-border-default p-5 space-y-4",children:[e.jsxs("h2",{className:"text-text-primary font-semibold text-base flex items-center gap-2",children:[e.jsx("span",{className:`w-7 h-7 rounded-lg bg-accent-cyan/10 border border-accent-cyan/20 5 flex items-center justify-center text-sm font-bold text-accent-cyan`,children:"1"}),"Load Structure"]}),e.jsx("div",{className:"flex gap-2 border-b border-border-default",children:$.map(t=>e.jsxs("button",{onClick:()=>p(t.key),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-t-lg border-b-2 transition-all 6 ${c===t.key?"border-accent-cyan text-accent-cyan":"border-transparent text-text-muted hover:text-text-secondary"}`,children:[t.icon," ",t.label]},t.key))}),c==="pdbid"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:X.map(t=>e.jsxs("button",{onClick:()=>{n(t.id),y(t.id)},disabled:m,className:`px-3 py-2 rounded-xl border border-border-default bg-bg-secondary 7 text-text-secondary hover:border-accent-cyan/40 text-xs disabled:opacity-50 transition-all`,children:[e.jsx("span",{className:"font-mono font-bold",children:t.id})," · ",t.desc]},t.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:s,onChange:t=>n(t.target.value.toUpperCase()),maxLength:4,placeholder:"e.g. 1EHZ",onKeyDown:t=>t.key==="Enter"&&y(s),className:`flex-1 px-3 py-2 rounded-lg bg-bg-secondary border border-border-default 8 text-text-primary text-sm font-mono focus:outline-none focus:border-accent-cyan/50`}),e.jsx("button",{onClick:()=>y(s),disabled:m||s.length!==4,className:`px-4 py-2 rounded-lg text-sm font-medium bg-accent-cyan/10 border border-accent-cyan/30 9 text-accent-cyan hover:bg-accent-cyan/20 disabled:opacity-40 transition-all`,children:m?"Loadingâ¦":"Fetch"})]})]}),c==="upload"&&e.jsxs("div",{children:[e.jsxs("div",{onClick:()=>S.current?.click(),onDrop:t=>{t.preventDefault(),t.dataTransfer.files[0]&&L(t.dataTransfer.files[0])},onDragOver:t=>t.preventDefault(),className:`rounded-xl border-2 border-dashed border-border-default hover:border-accent-cyan/40 10 hover:bg-accent-cyan/5 flex flex-col items-center justify-center gap-1.5 py-8 cursor-pointer transition-all`,children:[e.jsx(U,{className:"w-5 h-5 text-text-muted"}),e.jsxs("p",{className:"text-text-secondary text-xs",children:["Drop ",e.jsx("span",{className:"font-mono",children:".pdb"})," / ",e.jsx("span",{className:"font-mono",children:".cif"})," or"," ",e.jsx("span",{className:"text-accent-cyan",children:"click to browse"})]})]}),e.jsx("input",{ref:S,type:"file",accept:".pdb,.cif,.ent,.mmcif",className:"sr-only",onChange:t=>{t.target.files?.[0]&&L(t.target.files[0])}})]}),c==="url"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:d,onChange:t=>b(t.target.value),placeholder:"https://files.rcsb.org/download/1EHZ.pdb",className:`flex-1 px-3 py-2 rounded-lg bg-bg-secondary border border-border-default 11 text-text-primary text-sm font-mono focus:outline-none focus:border-accent-cyan/50`}),e.jsx("button",{onClick:()=>P(d),disabled:m||!d,className:`px-4 py-2 rounded-lg text-sm font-medium bg-accent-cyan/10 border border-accent-cyan/30 12 text-accent-cyan hover:bg-accent-cyan/20 disabled:opacity-40 transition-all`,children:m?"Loadingâ¦":"Fetch"})]}),k&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-red-500/30 bg-red-500/5",children:[e.jsx(z,{className:"w-4 h-4 text-red-400 shrink-0"}),e.jsx("p",{className:"text-red-400 text-xs",children:k})]}),l&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-accent-cyan/30 bg-accent-cyan/5",children:[e.jsx(V,{className:"w-4 h-4 text-accent-cyan shrink-0"}),e.jsxs("p",{className:"text-accent-cyan text-xs font-medium",children:[g," loaded · ",Q(l.length/1024)]})]})]}),l&&e.jsxs("div",{className:"rounded-xl border border-border-default overflow-hidden",children:[e.jsx("div",{className:"flex border-b border-border-default",children:B.map(t=>e.jsxs("button",{onClick:()=>N(t.key),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2.5 text-xs font-medium transition-colors 13 ${j===t.key?"bg-accent-cyan/10 text-accent-cyan border-b-2 border-accent-cyan":"text-text-muted hover:text-text-secondary hover:bg-bg-tertiary"}`,children:[t.icon," ",t.label]},t.key))}),e.jsxs("div",{className:"p-5",children:[j==="viewer"&&e.jsx(W,{content:l,filename:g,format:F,viewerHeight:600,enableDssr:!0,dssrAccent:"teal",enableGeometry:!0}),j==="content"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-text-muted text-[10px]",children:"Filter"}
13),e.jsx("select",{value:v,onChange:t=>M(t.target.value),className:`block px-3 py-1.5 rounded-lg bg-bg-tertiary border border-border-default 14 text-text-primary text-xs`,children:q.map(t=>e.jsx("option",{value:t.key,children:t.label},t.key))})]}),e.jsxs("div",{className:"flex-1 min-w-[150px]",children:[e.jsx("label",{className:"text-text-muted text-[10px]",children:"Search"}),e.jsxs("div",{className:"relative",children:[e.jsx(Z,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted"}),e.jsx("input",{value:w,onChange:t=>O(t.target.value),placeholder:"Search contentâ¦",className:`w-full pl-8 pr-3 py-1.5 rounded-lg bg-bg-tertiary border border-border-default 15 text-text-primary text-xs focus:outline-none focus:border-accent-cyan/50`})]})]}),e.jsxs("button",{onClick:()=>{const t=I(l,v,w),a=document.createElement("a");a.href=URL.createObjectURL(new Blob([t],{type:"text/plain"})),a.download=`${g}_filtered.txt`,a.click(),URL.revokeObjectURL(a.href)},className:`flex items-center gap-1 px-3 py-1.5 rounded-lg text-xs border 16 border-border-default text-text-secondary hover:text-accent-cyan transition-all`,children:[e.jsx(K,{className:"w-3 h-3"})," Download"]})]}),(()=>{const t=I(l,v,w),a=t.split(` 17`).length;return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-text-muted text-[10px]",children:[a.toLocaleString()," lines"]}),e.jsx("pre",{className:`text-[11px] font-mono text-text-secondary bg-bg-secondary border border-border-default 18 rounded-xl p-3 overflow-auto max-h-[500px] whitespace-pre`,children:t||"No matching content."})]})})()]})]})]}),!l&&e.jsxs("div",{className:"rounded-xl border border-border-default bg-bg-secondary px-6 py-10 text-center space-y-3",children:[e.jsx(T,{className:"w-10 h-10 text-text-muted mx-auto"}),e.jsx("p",{className:"text-text-secondary text-sm font-medium",children:"Welcome to StructureAnnotation!"}),e.jsxs("div",{className:"text-xs text-text-muted space-y-1 max-w-md mx-auto text-left",children:[e.jsx("p",{children:"ð¬ Interactive 3D RNA/DNA structure visualization with chain selection"}),e.jsx("p",{children:"𧬠One-click DSSR analysis with 2D structure graph"}),e.jsx("p",{children:"ð³ Interactive JSON tree viewer for full DSSR output"}),e.jsx("p",{children:"ð Data tables for base pairs, stacking, helices, loops & more"}),e.jsx("p",{children:"ð Search and filter PDB/CIF file content"})]}),e.jsx("p",{className:"text-xs text-text-muted pt-2",children:"Load a structure above to get started."})]})]})})}export{ie 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.