1import{c as E,R,u as k,p as L,r as u,j as e,A,L as j,g as N,d as P,C as T,P as D,E as F,a as I,b as M,e as $}from"./index-DCkA9xGt.js";import{S as G}from"./ScanIdBadge-CET6J2bi.js";import{f as O}from"./datetime-DEDbLob7.js";import{T as q}from"./TimeAgo-C3vNZBYS.js";import{S as H}from"./search-W01wNVRD.js";import{H as _}from"./history-Caa7FakQ.js";const B=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Q=E("arrow-left",B),v=25,z=["All","A+","A","B","C","D","F"];function U(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}}function re(){const{q:t}=R.useSearch(),{data:n,error:r}=k(L),o=n?.rows??null,i=n?.total??null,m=r?r.message:null,[l,g]=u.useState(t??""),[h,w]=u.useState("All"),[d,a]=u.useState(0);u.useEffect(()=>{t!==void 0&&g(t)},[t]);const f=u.useMemo(()=>{if(!o)return[];const s=[...o].sort((x,b)=>new Date(b.createdAt).getTime()-new Date(x.createdAt).getTime()),c=new Map;for(const x of s){const b=U(x.url),S=c.get(b);S?S.history.push(x):c.set(b,{host:b,latest:x,history:[x]})}return[...c.values()]},[o]),p=u.useMemo(()=>{const s=l.trim().toLowerCase();return f.filter(c=>!(s&&!c.host.toLowerCase().includes(s)||h!=="All"&&(c.latest.grade||"").trim()!==h))},[f,l,h]);u.useEffect(()=>{a(0)},[l,h]);const y=Math.max(1,Math.ceil(p.length/v)),C=p.slice(d*v,(d+1)*v);return e.jsxs("main",{className:"mx-auto w-full min-w-0 max-w-6xl px-4 py-10 [overflow-x:clip]",children:[e.jsxs("header",{className:"mb-6",children:[e.jsx("h1",{className:"font-display text-3xl sm:text-4xl",children:"All public scans"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Each domain appears once with its most recent scan. Expand a row to see scan history.",i!==null&&o&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"font-mono",children:f.length})," domains across the latest ",e.jsx("span",{className:"font-mono",children:o.length})," scans"]})]})]}),e.jsxs("div",{className:"surface mb-4 flex flex-wrap items-center gap-3 p-3",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(H,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Filter by domainâ¦",value:l,onChange:s=>g(s.target.value),className:"w-full rounded-lg border border-border bg-background py-2 pl-9 pr-3 text-sm outline-none transition focus:ring-soft"})]}),e.jsx("div",{className:"inline-flex shrink-0 items-center gap-1 rounded-lg border border-border bg-card p-1",children:z.map(s=>{const c=h===s,x=s==="All"?void 0:N(s);return e.jsx("button",{type:"button",onClick:()=>w(s),className:"rounded-md px-2.5 py-1 font-mono text-[11px] font-bold transition "+(c?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),style:c||s==="All"?void 0:{color:x},children:s},s)})})]}),m?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Couldn't load scans right now."}):o?p.length===0?e.jsx("p",{className:"surface p-8 text-center text-sm text-muted-foreground",children:"No matching scans."}):e.jsxs(e.Fragment,{children:[e.jsx(V,{groups:C}),y>1&&e.jsxs("nav",{className:"mt-8 flex items-center justify-center gap-3","aria-label":"Pagination",children:[e.jsxs("button",{type:"button",onClick:()=>a(s=>Math.max(0,s-1)),disabled:d===0,className:"inline-flex items-center gap-1.5 rounded-lg border border-border bg-card px-3 py-2 text-sm text-foreground transition hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(Q,{className:"h-3.5 w-3.5"})," Prev"]}),e.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Page ",d+1," of ",y]}),e.jsxs("button",{type:"button",onClick:()=>a(s=>Math.min(y-1,s+1)),disabled:d>
1=y-1,className:"inline-flex items-center gap-1.5 rounded-lg border border-border bg-card px-3 py-2 text-sm text-foreground transition hover:bg-secondary disabled:cursor-not-allowed disabled:opacity-40",children:["Next ",e.jsx(A,{className:"h-3.5 w-3.5"})]})]})]}):e.jsx("div",{className:"surface overflow-hidden p-0",children:Array.from({length:10}).map((s,c)=>e.jsx("div",{className:"h-12 animate-pulse border-b border-border/50 bg-muted/20 last:border-0"},c))}),e.jsx(K,{}),e.jsx("div",{className:"mt-12 text-center",children:e.jsxs(j,{to:"/",className:"inline-flex items-center gap-2 rounded-xl bg-foreground px-5 py-3 text-sm font-medium text-background transition hover:opacity-90",children:["Scan your own site ",e.jsx(A,{className:"h-4 w-4"})]})})]})}function V({groups:t}){return e.jsx("div",{className:"surface overflow-hidden p-0",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-muted/20 text-left font-mono text-[10px] uppercase tracking-widest text-muted-foreground",children:[e.jsx("th",{className:"px-4 py-2.5 font-normal",children:"Site"}),e.jsx("th",{className:"px-3 py-2.5 font-normal",children:"Grade"}),e.jsx("th",{className:"hidden px-3 py-2.5 font-normal sm:table-cell",children:"Score"}),e.jsx("th",{className:"hidden px-3 py-2.5 font-normal md:table-cell",children:"Platform"}),e.jsx("th",{className:"px-3 py-2.5 font-normal",children:"Scanned"}),e.jsx("th",{className:"px-3 py-2.5 text-right font-normal",children:e.jsx("span",{className:"sr-only",children:"Action"})})]})}),e.jsx("tbody",{children:t.map((n,r)=>e.jsx(Z,{group:n,zebra:r%2===1},n.host))})]})})}function Z({group:t,zebra:n}){const[r,o]=u.useState(!1),i=t.latest,m=(i.grade||"F").trim(),l=N(m),g=i.platform??"unknown",h=D[g]??"Custom",w=`https://www.google.com/s2/favicons?domain=${encodeURIComponent(t.host)}&sz=64`,d=t.history.length;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`group border-b border-border/50 transition hover:bg-muted/30 ${n?"bg-muted/10":""}`,children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs(j,{to:"/site/$domain",params:{domain:t.host},className:"flex min-w-0 items-center gap-2.5 font-medium text-foreground hover:underline",children:[e.jsx("img",{src:w,alt:"",width:24,height:24,loading:"lazy",className:"h-6 w-6 shrink-0 rounded",onError:a=>{a.target.style.visibility="hidden"}}),e.jsx("span",{className:"truncate",children:t.host})]}),d>1&&e.jsxs("button",{type:"button",onClick:()=>o(a=>!a),"aria-expanded":r,"aria-label":`Toggle scan history for ${t.host}`,className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-border bg-card/60 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground transition hover:border-foreground
1/30 hover:text-foreground",children:[e.jsx(_,{className:"h-3 w-3","aria-hidden":"true"}),"scanned ",d,"Ã",e.jsx(T,{className:`h-3 w-3 transition-transform ${r?"rotate-180":""}`,"aria-hidden":"true"})]})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:"inline-flex items-center rounded-md border px-1.5 py-0.5 font-mono text-[11px] font-bold",style:{color:l,borderColor:l,background:"color-mix(in oklab, "+l+" 14%, transparent)"},children:m})}),e.jsxs("td",{className:"hidden px-3 py-2.5 tabular-nums text-muted-foreground sm:table-cell",children:[i.score,e.jsx("span",{className:"opacity-50",children:"/100"})]}),e.jsx("td",{className:"hidden px-3 py-2.5 text-muted-foreground md:table-cell",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(F,{className:"h-3 w-3","aria-hidden":"true"}),h]})}),e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 text-muted-foreground",children:e.jsx(q,{iso:i.createdAt})}),e.jsx("td",{className:"px-3 py-2.5 text-right",children:e.jsx(J,{url:i.url})})]}),r&&d>1&&e.jsx("tr",{className:n?"bg-muted/10":"",children:e.jsx("td",{colSpan:6,className:"border-b border-border/50 px-4 py-3",children:e.jsxs("div",{className:"rounded-lg border border-border bg-card/40 p-3",children:[e.jsxs("div",{className:"mb-2 font-mono text-[10px] uppercase tracking-widest text-muted-foreground",children:["Scan history · ",d," scans"]}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-muted-foreground",children:[e.jsx("th",{className:"py-1 pr-3 font-normal",children:"Date"}),e.jsx("th",{className:"py-1 pr-3 font-normal",children:"Grade"}),e.jsx("th",{className:"py-1 pr-3 font-normal",children:"Score"}),e.jsx("th",{className:"py-1 pr-3 text-right font-normal",children:"Report"})]})}),e.jsx("tbody",{children:t.history.map(a=>{const f=(a.grade||"F").trim(),p=N(f);return e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsx("td",{className:"py-1.5 pr-3 text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:O(a.createdAt)}),e.jsx(G,{id:a.id})]})}),e.jsx("td",{className:"py-1.5 pr-3",children:e.jsx("span",{className:"inline-flex items-center rounded-md border px-1.5 py-0.5 font-mono text-[10px] font-bold",style:{color:p,borderColor:p,background:"color-mix(in oklab, "+p+" 14%, transparent)"},children:f})}),e.jsxs("td",{className:"py-1.5 pr-3 tabular-nums text-muted-foreground",children:[a.score,e.jsx("span",{className:"opacity-50",children:"/100"})]}),e.jsx("td",{className:"py-1.5 pr-3 text-right",children:e.jsx(j,{to:"/scan/$id",params:{id:a.id},className:"text-xs font-medium text-foreground hover:underline",children:"View â"})})]},a.id)})})]})]})})})]})}function J({url:t}){const n=I(),o=M({select:m=>m.location.pathname})==="/",i=m=>{if(m.preventDefault(),m.stopPropagation(),o){window.history.replaceState(null,"",`/?url=${encodeURIComponent(t)}`);const l=document.querySelector('#scan-form input[type="text"]');l&&(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set?.call(l,t),l.dispatchEvent(new Event("input",{bubbles:!0}))),document.getElementById("scan-form")?.scrollIntoView({behavior:"smooth",block:"start"}),setTimeout(()=>{document.querySelector("#scan-form form")?.requestSubmit()},120)}else n({to:"/",search:{url:t,autoscan:"1",fresh:"1"}})};return e.jsx("button",{type:"button",onClick:i,title:"Re-test","aria-label":`Re-test ${t}`,className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border bg-card/60 text-muted-foreground transition hover:border-foreground
1/30 hover:text-foreground",children:e.jsx($,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}function K(){const{data:t}=k(P),n=t??[];return n.length===0?null:e.jsxs("section",{className:"mt-12",children:[e.jsx("h2",{className:"font-display text-xl",children:"Directory of every scanned site"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["All ",e.jsx("span",{className:"font-mono",children:n.length})," domains with a public report, AâZ."," ",e.jsx(j,{to:"/scans/all",className:"underline hover:text-foreground",children:"Open the full directory"}),"."]}),e.jsx("ul",{className:"surface mt-3 grid grid-cols-1 gap-1 p-3 sm:grid-cols-2 lg:grid-cols-3",children:n.map(r=>{const o=(r.grade||"F").trim();return e.jsx("li",{className:"min-w-0",children:e.jsxs(j,{to:"/site/$domain",params:{domain:r.host},className:"flex items-center justify-between gap-2 rounded-lg px-2 py-1.5 text-sm transition hover:bg-secondary",children:[e.jsx("span",{className:"truncate text-foreground",children:r.host}),e.jsx("span",{className:"shrink-0 font-mono text-xs",style:{color:N(o)},children:r.grade||r.score})]})},r.host)})})]})}export{re 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.