1import{r as j,j as e,p as je}from"./vendor-react-B2RT89U9.js";import{c as U,u as oe,b as z}from"./vendor-tanstack-MRWYOJqo.js";import{C as E,a as R,b as H,c as V}from"./card-CV4rleUf.js";import{c as W,u as Z,O as Y,B as D,C as ye,ac as de}from"./index-gDpiPSoZ.js";import{B as L}from"./badge-BLy_vRrO.js";import{S as se,a as te,b as ae,c as re,d as S}from"./select-CUmIl25z.js";import{T as xe,a as me,b,c as u,d as he,e as x}from"./table-CTZWsTuc.js";import{L as q}from"./loader-circle-CCVKtMXL.js";import{T as _}from"./triangle-alert-DM6P9QYL.js";import{R as K}from"./refresh-cw-DICdVNqw.js";import{S as ie}from"./search-DYoyvokB.js";import{M as fe}from"./mouse-pointer-click-PfyHRhY4.js";import{E as Ne}from"./eye-B8C_Tsf8.js";import{T as ve}from"./target-C_CoXNWQ.js";import{C as be}from"./chevron-right-C5oNxS6D.js";import{E as we}from"./external-link-0Rj-x2I4.js";import{M as pe}from"./minus-CjpSw9OT.js";import{A as ue}from"./arrow-down-right-DpT898fm.js";import{S as ke}from"./shield-check-DNIqPaGb.js";import"./vendor-radix-PXtjYgzj.js";import"./check-DyEIay8l.js";const Ce=je("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),T=j.forwardRef(({className:t,variant:i,...a},n)=>e.jsx("div",{ref:n,role:"alert",className:W(Ce({variant:i}),t),...a}));T.displayName="Alert";const A=j.forwardRef(({className:t,...i},a)=>e.jsx("h5",{ref:a,className:W("mb-1 font-medium leading-none tracking-tight",t),...i}));A.displayName="AlertTitle";const $=j.forwardRef(({className:t,...i},a)=>e.jsx("div",{ref:a,className:W("text-sm [&_p]:leading-relaxed",t),...i}));$.displayName="AlertDescription";const F={striking_distance:{label:"Striking distance",className:"bg-amber-100 text-amber-800 border-amber-200"},low_ctr:{label:"Low CTR",className:"bg-purple-100 text-purple-800 border-purple-200"},declining:{label:"Declining",className:"bg-red-100 text-red-700 border-red-200"},cannibalization:{label:"Cannibalization",className:"bg-orange-100 text-orange-800 border-orange-200"},no_impressions:{label:"No impressions",className:"bg-gray-100 text-gray-700 border-gray-200"}},Se=["striking_distance","low_ctr","declining","cannibalization","no_impressions"],ne={home:"Home",service:"Service","city-service":"City + service",area:"Area",blog:"Blog","case-study":"Case study",project:"Project",guide:"Guide / answer",other:"Other"},Pe=["home","service","city-service","area","blog","case-study","project","guide","other"],P=50,f=t=>t.toLocaleString("en-US"),Q=t=>`${(t*100).toFixed(t>0&&t<.01?2:1)}%`,N=t=>t==null?"â":t.toFixed(1),le=t=>new Date(`${t}T00:00:00Z`).toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});function Te(t){const i=t.match(/^(https?):\/\/(www\.)?[^/]+(\/.*)?$/);return!i||i[1]==="http"||i[2]?t:i[3]||"/"}function O({value:t}
1){if(t==null)return e.jsx("span",{className:"text-xs text-gray-400",children:"new"});if(Math.abs(t)<.005)return e.jsxs("span",{className:"flex items-center text-xs text-gray-400",children:[e.jsx(pe,{className:"w-3 h-3"}),"0%"]});const i=t>0;return e.jsxs("span",{className:`flex items-center text-xs font-medium ${i?"text-emerald-600":"text-red-500"}`,children:[i?e.jsx(de,{className:"w-3 h-3"}):e.jsx(ue,{className:"w-3 h-3"}),Math.abs(t*100).toFixed(0),"%"]})}function ce({value:t}){if(t==null)return null;if(Math.abs(t)<.05)return e.jsx("span",{className:"flex items-center text-xs text-gray-400",children:e.jsx(pe,{className:"w-3 h-3"})});const i=t>0;return e.jsxs("span",{className:`flex items-center text-xs font-medium ${i?"text-emerald-600":"text-red-500"}`,children:[i?e.jsx(de,{className:"w-3 h-3"}):e.jsx(ue,{className:"w-3 h-3"}),Math.abs(t).toFixed(1)]})}function Ae({values:t,className:i}){if(t.length<2)return null;const a=Math.max(...t,1),n=120,l=28,d=t.map((c,y)=>`${y/(t.length-1)*n},${l-c/a*(l-2)-1}`).join(" ");return e.jsx("svg",{viewBox:`0 0 ${n} ${l}`,className:i,preserveAspectRatio:"none","aria-hidden":"true",children:e.jsx("polyline",{points:d,fill:"none",stroke:"currentColor",strokeWidth:"1.5",vectorEffect:"non-scaling-stroke"})})}function M({icon:t,label:i,value:a,change:n,sub:l,spark:d}){return e.jsx(E,{children:e.jsxs(R,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 mb-1",children:[t,e.jsx("span",{className:"text-xs font-medium uppercase",children:i})]}),e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:a}),n]}),l&&e.jsx("p",{className:"text-xs text-gray-400",children:l})]}),d&&e.jsx(Ae,{values:d,className:"w-24 h-7 text-[hsl(174,62%,40%)]"})]})]})})}function $e({brand:t}){const i=t.current.position,a=i!=null&&i<=3;return e.jsxs(E,{"data-testid":"card-brand-health",children:[e.jsx(H,{className:"pb-2",children:e.jsxs(V,{className:"text-base flex items-center gap-2",children:[e.jsx(ke,{className:`w-4 h-4 ${a?"text-emerald-600":"text-amber-600"}`}),"Brand health â searches containing âoriaâ"]})}),e.jsxs(R,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Avg position"}),e.jsx("p",{className:`text-xl font-bold ${a?"text-emerald-700":"text-amber-700"}`,children:N(i)}),e.jsxs("p",{className:"text-xs text-gray-400",children:["prior: ",N(t.previous.position)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Clicks"}),e.jsx("p",{className:"text-xl font-bold text-gray-900",children:f(t.current.clicks)}),e.jsxs("p",{className:"text-xs text-gray-400",children:["prior: ",f(t.previous.clicks)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Impressions"}),e.jsx("p",{className:"text-xl font-bold text-gray-900",children:f(t.current.impressions)}),e.jsxs("p",{className:"text-xs text-gray-400",children:["prior: ",f(t.previous.impressions)]})]})]}),!a&&i!=null&&e.jsx("p",{className:"text-xs text-amber-700",children:"Brand searches should land at position 1â3. Check that the home page title and Google Business Profile use the exact business name, and that the http:// and www versions redirect to https://oriabuilders.com/."}),t.queries.length===0?e.jsx("p",{className:"text-sm text-gray-500",children:"No brand searches recorded in this period."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(xe,{children:[e.jsx(me,{children:e.jsxs(b,{children:[e.jsx(u,{children:"Query"}),e.jsx(u,{className:"text-right",children:"Clicks"}),e.jsx(u,{className:"text-right",children:"Impr."}),e.jsx(u,{className:"text-right",children:"Position"}),e.jsx(u,{children:"Ranking pages"})]})}),e.jsx(he,{children:t.queries.slice(0,8).map(n=>e.jsxs(b,{children:[e.jsx(x,{className:"font-medium",children:n.query}),e.jsx(x,{className:"text-right",children:n.clicks}),e.jsx(x,{className:"text-right",children:n.impressions}),e.jsxs(x,{className:"text-right whitespace-nowrap",children:[N(n.position)," ",e.jsxs("span",{className:"text-xs text-gray-400",children:["(",N(n.prevPosition),")"]})]}),e.jsx(x,{className:"text-xs text-gray-500 max-w-[260px] truncate",title:n.pages.map(l
1=>l.page).join(` 2`),children:n.pages.map(l=>Te(l.page)).join(", ")})]},n.query))})]})})]})]})}function Ee(){const{toast:t}=Z(),i=U(),{data:a}=oe({queryKey:["/api/admin/seo/content-loop"],queryFn:async()=>{const c=await fetch("/api/admin/seo/content-loop",{credentials:"include"});if(!c.ok)throw new Error("loop status unavailable");return c.json()},staleTime:60*1e3}),n=z({mutationFn:async()=>(await Y("POST","/api/admin/seo/content-loop/run")).json(),onSuccess:c=>{t({title:"Content loop finished",description:`${c.answersDrafted.length} answer draft(s), ${c.refreshesDrafted.length} refresh draft(s)${c.errors.length?`, ${c.errors.length} error(s)`:""}. Review them before publishing.`}),i.invalidateQueries({queryKey:["/api/admin/seo/content-loop"]}),i.invalidateQueries({queryKey:["/api/admin/seo/pages-to-fix"]})},onError:c=>t({title:"Loop failed",description:c?.message,variant:"destructive"})});if(!a)return null;const l=a.drafts,d=a.publishedLast28Days;return e.jsxs(E,{"data-testid":"card-content-loop",children:[e.jsxs(H,{className:"pb-3",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[e.jsxs(V,{className:"text-base flex items-center gap-2",children:[e.jsx(K,{className:"w-4 h-4 text-[hsl(174,62%,47%)]"})," Content loop"]}),e.jsxs(D,{size:"sm",variant:"outline",onClick:()=>n.mutate(),disabled:n.isPending||a.running,"data-testid":"button-run-content-loop",children:[n.isPending||a.running?e.jsx(q,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(K,{className:"w-4 h-4 mr-2"}),"Run loop now"]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:"Measure â draft â you approve â publish â measure again. Runs weekly; it only creates drafts."})]}),e.jsxs(R,{className:"grid md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-gray-500 mb-1",children:"Measured"}),e.jsxs("p",{children:["Search data through ",e.jsx("span",{className:"font-medium",children:a.measure.gscLatestDate||"â"})]}),e.jsxs("p",{children:["AI mention score: ",e.jsx("span",{className:"font-medium",children:a.measure.visibility?`${a.measure.visibility.score}%`:"not run"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-gray-500 mb-1",children:"Waiting for your approval"}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:l.total})," draft",l.total===1?"":"s",": ",l.answers," answers · ",l.blog," posts · ",l.cityServicePages+l.areaPages," city pages · ",l.caseStudies," case studies"]}),a.curated&&a.curated.draft>0&&e.jsxs("p",{className:"text-amber-700",children:[a.curated.draft," curated answers ready to publish (SEO Content â GEO Answers)"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-gray-500 mb-1",children:"Published, last 28 days"}),e.jsxs("p",{children:[d.answers," answers · ",d.blog," posts · ",d.caseStudies," case studies"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-gray-500 mb-1",children:"Last loop run"}),a.lastRun?e.jsxs("p",{children:[new Date(a.lastRun.finishedAt).toLocaleString(),": ",a.lastRun.flaggedPages," flagged pages â ",a.lastRun.answersDrafted.length," answer + ",a.lastRun.refreshesDrafted.length," refresh draft(s)",a.lastRun.errors.length?`, ${a.lastRun.errors.length} error(s)`:""]}):e.jsx("p",{className:"text-gray-500",children:"Not run since the server started."})]})]})]})}function Re({page:t}){const{toast:i}=Z(),a=U(),[n,l]=j.useState(null),[d,c]=j.useState(null),y=z({mutationFn:async r=>(await Y("POST","/api/admin/seo/pages-to-fix/action",{path:t.path,...r})).json(),onSuccess:(r,m)=>{if(m.action==="suggest_links"){l({targets:r.targets,canApply:r.canApply});return}if(m.action==="apply_links"){c(r.applied?`Saved ${r.links.length} links to this page.`:r.reason),a.invalidateQueries({queryKey:["/api/admin/seo/pages-to-fix"]});return}if(m.action==="draft_answer"){c(r.created?`Answer drafted (${r.slug}). ${r.next}`:r.reason),a.invalidateQueries({queryKey:["/api/admin/seo/content-loop"]});return}if(m.action==="draft_refresh"){c(`Refresh drafted. ${r.next}`),a.invalidateQueries({queryKey:["/api/admin/seo/content-loop"]});return}},onError:r=>i({title:"Action failed",description:r?.message,variant:"destructive"})});if(!t.actions?.length)return null;const p=n?.targets,v=p?[p.cityHub&&{kind:"City hub",...p.cityHub},p.service&&{kind:"Service page",...p.service},p.project&&{kind:"Project",...p.project},p.caseStudy&&{kind:"Case study",...p.caseStudy},...p.answers.map(r=>({kind:"Answer",...r}
2))].filter(Boolean):[];return e.jsxs("div",{className:"space-y-2 pt-1","data-testid":`actions-${t.path}`,children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:t.actions.map(r=>e.jsxs(D,{size:"sm",variant:r.key==="review_meta"?"ghost":"outline",disabled:y.isPending,onClick:m=>{if(m.stopPropagation(),r.key==="review_meta"){c("Edit the title tag and meta description in SEO Content â Blog Posts (blog) or in the page content (city pages); put the top query first and add the location.");return}y.mutate({action:r.key,question:r.question})},"data-testid":`button-action-${r.key}`,children:[y.isPending&&y.variables?.action===r.key?e.jsx(q,{className:"w-3 h-3 mr-1 animate-spin"}):null,r.label]},r.key))}),d&&e.jsx("p",{className:"text-xs text-gray-600","data-testid":"text-action-note",children:d}),p&&e.jsxs("div",{className:"rounded-md border bg-white p-3 text-xs space-y-1","data-testid":"links-suggestion",children:[e.jsx("p",{className:"font-semibold text-gray-700",children:"Links this page should carry"}),v.length===0&&e.jsx("p",{className:"text-gray-500",children:"No real related content matched this page yet. Publish an answer, project or case study for its city or service first."}),v.map(r=>e.jsxs("p",{children:[e.jsxs("span",{className:"text-gray-500",children:[r.kind,":"]})," ",e.jsx("a",{href:r.path,target:"_blank",rel:"noopener noreferrer",className:"text-[hsl(174,62%,40%)] hover:underline",children:r.label})]},r.path)),n?.canApply&&v.length>0&&e.jsx(D,{size:"sm",variant:"outline",className:"mt-1",disabled:y.isPending,onClick:r=>{r.stopPropagation(),y.mutate({action:"apply_links"})},"data-testid":"button-apply-links",children:"Save these links to the page"}),!n?.canApply&&e.jsx("p",{className:"text-gray-500",children:"This page is code-defined: it already shows these links through the related-content resolver."})]})]})}function es({embedded:t}){const{toast:i}=Z(),a=U(),[n,l]=j.useState("flagged"),[d,c]=j.useState("all"),[y,p]=j.useState(null),[v,r]=j.useState(P),{data:m,isLoading:ge,error:J}=oe({queryKey:["/api/admin/seo/pages-to-fix"],queryFn:async()=>{const s=await fetch("/api/admin/seo/pages-to-fix",{credentials:"include"});if(!s.ok)throw new Error((await s.json().catch(()=>null))?.error||`Request failed (${s.status})`);return s.json()},staleTime:300*1e3}),B=z({mutationFn:async()=>(await Y("POST","/api/admin/seo/gsc-sync")).json(),onSuccess:()=>{i({title:"Search Console data synced"}),a.invalidateQueries({queryKey:["/api/admin/seo/pages-to-fix"]})},onError:s=>i({title:"Sync failed",description:s?.message,variant:"destructive"})}),w=j.useMemo(()=>m?m.pages.filter(s=>d!=="all"&&s.type!==d?!1:n==="flagged"?s.flags.length>0:n==="all"?!0:s.flags.some(C=>C.key===n)):[],[m,n,d]),X=t?"p-4 md:p-6 space-y-6":"container mx-auto px-4 py-8 space-y-6";if(ge)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(q,{className:"w-8 h-8 animate-spin text-[hsl(174,62%,47%)]"})});if(J||!m)return e.jsx("div",{className:X,children:e.jsxs(T,{variant:"destructive",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(A,{children:"Could not load Pages to Fix"}),e.jsx($,{children:J?.message||"Unknown error"})]})});const{summary:h,periods:k,sync:g,connection:G,brand:ee}=m,I=g.maxDate?Math.floor((Date.now()-new Date(`${g.maxDate}T00:00:00Z`).getTime())/864e5):null;return e.jsxs("div",{className:X,children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900","data-testid":"text-pages-to-fix-title",children:"Pages to Fix"}),e.jsx("p",{className:"text-sm text-gray-500",children:k?`Google Search, ${le(k.start)} â ${le(k.end)} vs the prior ${k.days} days. Ranked by estimated extra clicks.`:"Which pages perform, which don't, and what to fix â from Google Search Console."}),g.maxDate&&e.jsxs("p",{className:"text-xs text-gray-400",children:["Data ",g.minDate," â ",g.maxDate,g.lastSuccessAt&&` · last synced ${new Date(g.lastSuccessAt).toLocaleString()}`]})]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>B.mutate(),disabled:B.isPending||g.running,"data-testid":"button-gsc-sync",children:[B.isPending||g.running?e.jsx(q,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(K,{className:"w-4 h-4 mr-2"}),"Sync now"]})]}),!G.credentialsOk&&e.jsxs(T,{variant:"destructive","data-testid":"alert-gsc-not-connected",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(A,{children:"Google Search Console is not connected"}),e.jsxs($,{children:[G.error," Set GOOGLE_SERVICE_ACCOUNT_EMAIL and GOOGLE_SERVICE_ACCOUNT_KEY, and add the service account as a user on the sc-domain:oriabuilders.com property."]})]}),G.credentialsOk&&g.lastError&&e.jsxs(T,{variant:"destructive","data-testid":"alert-gsc-sync-error",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(A,{children:"Last Search Console sync failed"}),e.jsx($,{children:g.lastError})]}),I!=null&&I>5&&e.jsxs(T,{"data-testid":"alert-gsc-stale",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsxs(A,{children:["Search data is ",I," days old"]}),e.jsx($,{children:"The daily sync may not be running. Use âSync nowâ and check the server logs for [GSC Sync]."})]}),!k||!h?e.jsx(E,{children:e.jsxs(R,{className:"p-8 text-center text-gray-500 space-y-2",children:[e.jsx(ie,{className:"w-8 h-8 mx-auto text-gray-300"}),e.jsx("p",{children:"No Search Console data has been synced yet."}),e.jsxs("p",{className:"text-xs",children:["Click âSync nowâ to pull the last 30 days, or run ",e.jsx("code",{children:"scripts/backfill-gsc-pages.ts"})," for the full 16 months."]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(M,{icon:e.jsx(fe,{className:"w-4 h-4"}),label:"Clicks",value:f(h.current.clicks),change:e.jsx(O,{value:h.clicksPct}),sub:`prior: ${f(h.previous.clicks)}`,spark:h.daily.map(s=>s.clicks)}),e.jsx(M,{icon:e.jsx(Ne,{className:"w-4 h-4"}),label:"Impressions",value:f(h.current.impressions),change:e.jsx(O,{value:h.impressionsPct}),sub:`prior: ${f(h.previous.impressions)}`,spark:h.daily.map(s=>s.impressions)}),e.jsx(M,{icon:e.jsx(ve,{className:"w-4 h-4"}),label:"Avg position",value:N(h.current.position),change:e.jsx(ce,{value:h.positionDelta}),sub:`prior: ${N(h.previous.position)}
2 · impressions-weighted`}),e.jsx(M,{icon:e.jsx(ie,{className:"w-4 h-4"}),label:"CTR",value:Q(h.current.ctr),change:null,sub:`${h.pagesWithImpressions} pages seen · ${h.sitemapPages} in sitemap`})]}),e.jsx(Ee,{}),ee&&e.jsx($e,{brand:ee}),e.jsxs(E,{children:[e.jsx(H,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-3",children:[e.jsxs(V,{className:"text-base",children:["Ranked pages (",w.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(se,{value:n,onValueChange:s=>{l(s),r(P)},children:[e.jsx(te,{className:"h-8 w-[210px] text-xs","data-testid":"select-flag-filter",children:e.jsx(ae,{})}),e.jsxs(re,{children:[e.jsx(S,{value:"flagged",children:"All flagged pages"}),Se.map(s=>e.jsxs(S,{value:s,children:[F[s].label," (",m.counts.byFlag[s]||0,")"]},s)),e.jsx(S,{value:"all",children:"All pages"})]})]}),e.jsxs(se,{value:d,onValueChange:s=>{c(s),r(P)},children:[e.jsx(te,{className:"h-8 w-[180px] text-xs","data-testid":"select-type-filter",children:e.jsx(ae,{})}),e.jsxs(re,{children:[e.jsx(S,{value:"all",children:"All page types"}),Pe.filter(s=>m.counts.byType[s]).map(s=>e.jsxs(S,{value:s,children:[ne[s]," (",m.counts.byType[s],")"]},s))]})]})]})]})}),e.jsxs(R,{className:"p-0",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(xe,{children:[e.jsx(me,{children:e.jsxs(b,{children:[e.jsx(u,{className:"w-8"}),e.jsx(u,{children:"Page"}),e.jsx(u,{children:"Flags"}),e.jsx(u,{className:"text-right",children:"Clicks"}),e.jsx(u,{className:"text-right",children:"Impr."}),e.jsx(u,{className:"text-right",children:"CTR"}),e.jsx(u,{className:"text-right",children:"Position"}),e.jsx(u,{className:"text-right",title:"Estimated extra clicks per 28 days if fixed",children:"Opportunity"})]})}),e.jsxs(he,{children:[w.slice(0,v).map(s=>{const C=y===s.path;return e.jsxs(j.Fragment,{children:[e.jsxs(b,{className:"cursor-pointer",onClick:()=>p(C?null:s.path),"data-testid":`row-page-${s.path}`,children:[e.jsx(x,{className:"align-top",children:C?e.jsx(ye,{className:"w-4 h-4 text-gray-400"}):e.jsx(be,{className:"w-4 h-4 text-gray-400"})}),e.jsxs(x,{className:"align-top max-w-[360px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",onClick:o=>o.stopPropagation(),className:"font-medium text-gray-900 hover:text-[hsl(174,62%,40%)] truncate",title:s.url,children:s.path}),e.jsx(we,{className:"w-3 h-3 shrink-0 text-gray-400"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mt-1",children:[e.jsx(L,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:ne[s.type]}),!s.inSitemap&&e.jsx(L,{variant:"outline",className:"text-[10px] px-1.5 py-0 text-gray-500",children:"not in sitemap"}),s.title&&e.jsx("span",{className:"text-xs text-gray-400 truncate max-w-[220px]",children:s.title})]})]}),e.jsx(x,{className:"align-top",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:s.flags.map(o=>e.jsx(L,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${F[o.key].className}`,children:F[o.key].label},o.key))})}),e.jsxs(x,{className:"text-right align-top",children:[e.jsx("div",{className:"font-medium",children:f(s.current.clicks)}),e.jsx("div",{className:"flex justify-end",children:e.jsx(O,{value:s.previous.clicks||s.current.clicks?s.deltas.clicksPct:0})})]}),e.jsxs(x,{className:"text-right align-top",children:[e.jsx("div",{className:"font-medium",children:f(s.current.impressions)}),e.jsx("div",{className:"flex justify-end",children:e.jsx(O,{value:s.previous.impressions||s.current.impressions?s.deltas.impressionsPct:0})})]}),e.jsxs(x,{className:"text-right align-top",children:[e.jsx("div",{children:s.current.impressions?Q(s.current.ctr):"â"}),s.current.impressions>0&&s.expectedCtr>0&&e.jsxs("div",{className:"text-[10px] text-gray-400",title:"Internal heuristic for this position, not a published benchmark",children:["est. ",Q(s.expectedCtr)]})]}),e.jsxs(x,{className:"text-right align-top",children:[e.jsx("div",{children:N(s.current.position)}),e.jsx("div",{className:"flex justify-end",children:e.jsx(ce,{value:s.deltas.position})})]}
2),e.jsx(x,{className:"text-right align-top font-medium",children:s.opportunity>0?`+${s.opportunity.toFixed(1)}`:"â"})]}),C&&e.jsxs(b,{className:"bg-gray-50 hover:bg-gray-50",children:[e.jsx(x,{}),e.jsx(x,{colSpan:7,className:"py-3",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-gray-500",children:"What to do"}),s.flags.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:"No issues flagged for this page."}),s.flags.map(o=>e.jsxs("div",{className:"text-sm",children:[e.jsx(L,{variant:"outline",className:`text-[10px] px-1.5 py-0 mr-1.5 ${F[o.key].className}`,children:o.label}),e.jsx("span",{className:"text-gray-700",children:o.recommendation}),o.opportunity>0&&e.jsxs("span",{className:"text-xs text-gray-400",children:[" (â +",o.opportunity.toFixed(1)," clicks / 28 days)"]})]},o.key)),e.jsx(Re,{page:s}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Prior 28 days: ",s.previous.clicks," clicks · ",s.previous.impressions," impressions · position ",N(s.previous.position),s.publishedAt&&` · published ${new Date(s.publishedAt).toLocaleDateString()}`]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-gray-500 mb-1",children:"Top queries (28 days)"}),s.topQueries.length===0?e.jsx("p",{className:"text-sm text-gray-500",children:"No query data for this page."}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-gray-500",children:[e.jsx("th",{className:"text-left font-medium py-1",children:"Query"}),e.jsx("th",{className:"text-right font-medium",children:"Clicks"}),e.jsx("th",{className:"text-right font-medium",children:"Impr."}),e.jsx("th",{className:"text-right font-medium",children:"Pos."})]})}),e.jsx("tbody",{children:s.topQueries.map(o=>e.jsxs("tr",{className:"border-t border-gray-200",children:[e.jsx("td",{className:"py-1 pr-2",children:o.query}),e.jsx("td",{className:"text-right",children:o.clicks}),e.jsx("td",{className:"text-right",children:o.impressions}),e.jsx("td",{className:"text-right",children:N(o.position)})]},o.query))})]})]})]})})]})]},s.path)}),w.length===0&&e.jsx(b,{children:e.jsx(x,{colSpan:8,className:"text-center text-gray-500 py-8",children:"No pages match these filters."})})]})]})}),w.length>v&&e.jsx("div",{className:"p-3 text-center border-t",children:e.jsxs(D,{variant:"ghost",size:"sm",onClick:()=>r(s=>s+P),"data-testid":"button-show-more-pages",children:["Show ",Math.min(P,w.length-v)," more"]})})]})]})]})]})}export{es 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.