1import{r as o,j as e,d as p,h as j,T as U,e as T,f as S,ab as w,I as M,B,aC as P,aJ as D,a$ as _,b0 as H,b1 as V,b2 as W,n as J}from"./index-DwBWDKUZ.js";import{a as q}from"./AdminLayout-CUJ1KAUs.js";import{T as A,a as E,b as h,c,d as L,e as l}from"./table-Cc_Zjg_s.js";import{E as g}from"./external-link-aOCC2dcc.js";import{M as G}from"./minus-B84IBUYK.js";import"./separator-3IJlx7Jr.js";import"./radio-CYrbeFui.js";import"./shopping-cart-BS4tH7dF.js";import"./ban-2u0CnJmK.js";import"./message-square-ClqgYCnY.js";import"./globe-5NMmuIgN.js";import"./qr-code-c27LO0Y3.js";import"./zap-B9JmuJoQ.js";import"./useDebounce-Dswy9wwM.js";import"./undo-2-DrAGwRTv.js";import"./target-sTphCb1S.js";import"./gift-DTSOrbmf.js";import"./store-bkBmVJSB.js";import"./book-open-zG6yZAjB.js";import"./circle-plus-q9MabApK.js";import"./link-2-yb_9D2cc.js";import"./index-EBeZJwww.js";import"./database-CSQWWsVg.js";import"./arrow-left-right-CBpwBwL4.js";import"./layout-dashboard-Bx09MTND.js";import"./privateRealtimeChannels-LIJV5W85.js";import"./index-CvvDEDzH.js";import"./index-Cj1mIu5t.js";import"./calendar-days-D-EDctJU.js";import"./shield-86TK9aig.js";const I=7,Q="/structured-data-report.json";function y({ok:t,present:d}){return d?t?e.jsx(J,{className:"h-4 w-4 text-green-600","aria-label":"eligible"}):e.jsx(D,{className:"h-4 w-4 text-destructive","aria-label":"error"}):e.jsx(G,{className:"h-4 w-4 text-muted-foreground","aria-label":"not present"})}function F(t){return t.errors.length?"fail":t.warnings.length?"warn":"pass"}function Ce(){const[t,d]=o.useState("seo-tools"),[r,x]=o.useState(null),[u,b]=o.useState(null),[a,m]=o.useState("all"),[f,$]=o.useState("");o.useEffect(()=>{let s=!1;return(async()=>{try{const n=await fetch(`${Q}?t=${Date.now()}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);const i=await n.json();s||x(i)}catch(n){s||b(n.message)}})(),()=>{s=!0}},[]);const O=o.useMemo(()=>r?Date.now()-new Date(r.generatedAt).getTime()>I*24*60*60*1e3:!1,[r]),v=o.useMemo(()=>r?r.results.filter(s=>{const n=F(s);return!(a!=="all"&&n!==a||f&&!s.path.toLowerCase().includes(f.toLowerCase()))}):[],[r,a,f]),R=o.useMemo(()=>{if(!r)return[];const s=new Map;for(const n of r.results)for(const i of[...n.errors,...n.warnings]){const k=`${i.severity}|${i.type}|${i.message}`,C=s.get(k);C?C.count++:s.set(k,{type:i.type,message:i.message,severity:i.severity,hint:i.hint,fixIn:i.fixIn,count:1})}return Array.from(s.values()).sort((n,i)=>i.count-n.count)},[r]);return e.jsxs(q,{activeTab:t,onTabChange:d,title:"Structured Data Validator",subtitle:"AutoRental, BreadcrumbList, and FAQPage JSON-LD checked against Google Rich Results rules.",children:[u&&e.jsx(p,{className:"mb-6 border-destructive/50",children:e.jsxs(j,{className:"pt-6 text-sm",children:[e.jsx("p",{className:"font-semibold text-destructive",children:"Report not available"}),e.jsxs("p",{className:"text-muted-foreground mt-1",children:[u,". Generate one with"," ",e.jsx("code",{className:"font-mono",children:"bunx tsx scripts/validate-structured-data.ts"})," ","then redeploy."]})]})}),r&&e.jsxs(e.Fragment,{children:[O&&e.jsx(p,{className:"mb-6 border-amber-500/50 bg-amber-50/50 dark:bg-amber-950/20",children:e.jsxs(j,{className:"pt-6 text-sm flex items-start gap-3",children:[e.jsx(U,{className:"h-5 w-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Report is stale"}),e.jsxs("p",{className:"text-muted-foreground mt-1",children:["Generated ",new Date(r.generatedAt).toLocaleString()," (more than"," ",I," days old). Re-run the validator and redeploy for fresh data."]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[e.jsx(N,{label:"URLs validated",value:r.summary.total}),e.jsx(N,{label:"Passing",value:r.summary.passing,tone:"success"}),e.jsx(N,{label:"Warnings",value:r.summary.warning,tone:"warn"}),e.jsx(N,{label:"Failing",value:r.summary.failing,tone:"error"})]}),R.length>0&&e.jsxs(p,{className:"mb-6",children:[e.jsxs(T,{children:[e.jsx(S,{className:"text-base font-semibold",children:"Issues grouped by rule"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Fix the top rows first â each row affects many URLs at once."})]}),e.jsx(j,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(A,{children:[e.jsx(E,{children:e.jsxs(h,{children:[e.jsx(c,{className:"w-16 text-center",children:"URLs"}),e.jsx(c,{className:"w-24",children:"Severity"}),e.jsx(c,{className:"w-32",children:"Type"}),e.jsx(c,{children:"Rule / How to fix"})]})}),e.jsx(L,{children:R.map((s,n)=>e.jsxs(h,{children:[e.jsx(l,{className:"text-center font-mono text-sm",children:s.count}),e.jsx(l,{children:e.jsx(w,{variant:s.severity==="error"?"destructive":"outline",className:"text-[10px]",children:s.severity==="error"?"ERROR":"WARN"})}),e.jsx(l,{className:"text-xs font-mono",children:s.type}),e.jsxs(l,{className:"text-xs",children:[e.jsx("div",{children:s.message}),s.hint&&e.jsxs("div",{className:"text-muted-foreground mt-1",children:["â ",s.hint]}),s.fixIn&&e.jsxs("code",{className:"inline-block mt-1 text-[10px] bg-muted px-1.5 py-0.5 rounded",children:["Edit: ",s.fixIn]})]})]},n))})]})})})]}),e.jsxs(p,{children:[e.jsxs(T,{className:"flex flex-row items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs(S,{className:"text-base font-semibold",children:[v.length," of ",r.results.length," URLs"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Source: ",r.baseUrl," · generated"," ",new Date(r.generatedAt).toLocaleStr
1ing()]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(M,{placeholder:"Filter by path...",value:f,onChange:s=>$(s.target.value),className:"max-w-xs h-9"}),["all","fail","warn","pass"].map(s=>e.jsx(B,{size:"sm",variant:a===s?"default":"outline",onClick:()=>m(s),children:s==="all"?"All":s==="fail"?"Failing":s==="warn"?"Warning":"Passing"},s))]})]}),e.jsxs(j,{children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(A,{children:[e.jsx(E,{children:e.jsxs(h,{children:[e.jsx(c,{className:"w-[45%]",children:"URL"}),e.jsx(c,{className:"text-center",children:"AutoRental"}),e.jsx(c,{className:"text-center",children:"Breadcrumb"}),e.jsx(c,{className:"text-center",children:"FAQ"}),e.jsx(c,{className:"text-center",children:"Errors"}),e.jsx(c,{className:"text-center",children:"Warnings"}),e.jsx(c,{className:"text-right",children:"Test"})]})}),e.jsxs(L,{children:[v.map(s=>e.jsx(z,{r:s},s.path)),v.length===0&&e.jsx(h,{children:e.jsx(l,{colSpan:7,className:"text-center text-sm text-muted-foreground py-8",children:"No URLs match."})})]})]})}),e.jsxs("p",{className:"mt-4 text-xs text-muted-foreground flex items-center gap-2",children:[e.jsx(P,{className:"h-3 w-3"}),"Re-run"," ",e.jsx("code",{className:"font-mono",children:"bunx tsx scripts/validate-structured-data.ts"})," ","then redeploy to refresh this report."]})]})]})]})]})}function N({label:t,value:d,tone:r}){const x=r==="success"?"text-green-600":r==="warn"?"text-amber-600":r==="error"?"text-destructive":"text-foreground";return e.jsx(p,{children:e.jsxs(j,{className:"pt-6",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:t}),e.jsx("p",{className:`text-3xl font-semibold mt-2 ${x}`,children:d})]})})}function z({r:t}){const[d,r]=o.useState(!1),x=F(t),u=`https://search.google.com/test/rich-results?url=${encodeURIComponent(t.url)}`,b=`https://validator.schema.org/#url=${encodeURIComponent(t.url)}`;return e.jsxs(e.Fragment,{children:[e.jsxs(h,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>r(a=>!a),children:[e.jsx(l,{className:"font-mono text-xs",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:x==="pass"?"secondary":x==="warn"?"outline":"destructive",className:"text-[10px]",children:x.toUpperCase()}),e.jsx("span",{className:"truncate",children:t.path})]})}),e.jsx(l,{className:"text-center",children:e.jsx("div",{className:"inline-flex",children:e.jsx(y,{ok:t.richResultsEligible.autoRental,present:t.hasAutoRental})})}),e.jsx(l,{className:"text-center",children:e.jsx("div",{className:"inline-flex",children:e.jsx(y,{ok:t.richResultsEligible.breadcrumb,present:t.hasBreadcrumb})})}),e.jsx(l,{className:"text-center",children:e.jsx("div",{className:"inline-flex",children:e.jsx(y,{ok:t.richResultsEligible.faq,present:t.hasFaq})})}),e.jsx(l,{className:"text-center text-sm",children:t.errors.length||""}),e.jsx(l,{className:"text-center text-sm",children:t.warnings.length||""}),e.jsx(l,{className:"text-right",children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex text-muted-foreground hover:text-foreground","aria-label":"Open Rich Results Test",children:e.jsx(g,{className:"h-4 w-4"})})})]}),d&&e.jsx(h,{children:e.jsx(l,{colSpan:7,className:"bg-muted/30",children:e.jsxs("div",{className:"space-y-4 py-2",children:[t.errors.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-destructive mb-1",children:"Errors"}),e.jsx("ul",{className:"text-xs space-y-2",children:t.errors.map((a,m)=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx(D,{className:"h-3 w-3 text-destructive flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[a.type,":"]})," ",a.message]}),a.hint&&e.jsxs("div",{className:"text-muted-foreground mt-0.5",children:["â ",a.hint]}),a.fixIn&&e.jsxs("code",{className:"inline-block mt-1 text-[10px] bg-muted px-1.5 py-0.5 rounded",children:["Edit: ",a.fixIn]})]})]},m))})]}),t.warnings.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-amber-600 mb-1",children:"Warnings"}),e.jsx("ul",{className:"text-xs space-y-2",children:t.warnings.map((a,m)=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx(U,{className:"h-3 w-3 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[a.type,":"]})," ",a.message]}),a.hint&&e.jsxs("div",{className:"text-muted-foreground mt-0.5",children:["â ",a.hint]}),a.fixIn&&e.jsxs("code",{className:"inline-block mt-1 text-[10px] bg-muted px-1.5 py-0.5 rounded",children:["Edit: ",a.fixIn]})]})]},m))})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Detected types:"}),t.types.length?t.types.map((a,m)=>e.jsx(w,{variant:"outline",className:"text-[10px]",children:a},m)):e.jsx("span",{className:"text-muted-foreground italic",children:"none"})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Rich Results Test ",e.jsx(g,{className:"h-3 w-3"})]}),e.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Schema.org Validator ",e.jsx(g,{className:"h-3 w-3"})]}),e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Open page ",e.jsx(g,{className:"h-3 w-3"})]})]}),e.jsx(_,{type:"single",collapsible:!0,children:e.jsxs(H,{value:"raw",className:"border-none",children:[e.jsxs(V,{className:"text-xs py-2",children:["View raw JSON-LD (",t.blockCount," block",t.blockCount===1?"":"s",")"]}),e.jsx(W,{children:e.jsx("pre",{className:"text-[11px] bg-background border rounded p-3 overflow-auto max-h-96",children:JSON.stringify(t.blocks,null,2)})})]})})]})})})]})}export{Ce 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.