1import{j as e}from"./vendor-query-DvnPdOMX.js";import{E as Ze}from"./EvidenceList-DwizXJrO.js";import{u as ne,r as o,L as et}from"./vendor-react-woJBpfBI.js";import{c as L}from"./vendor-utils-BNe0Xlio.js";import{ac as Ce,a6 as re,ao as X,b as tt,ap as st,aq as at,T as ee,br as nt,ab as rt,e as it,Q as lt,U as ye}from"./index-1YQNuixL.js";import{O as ot}from"./OverflowMenu-C97PGN8W.js";import{u as ie,n as ct}from"./citations-DsDiPQfa.js";import{S as dt}from"./SourceTypeTag-DN88NTrz.js";import{M as mt}from"./VideoExplorer-TUh6FyBr.js";import{a as pt,P as ut,S as xt}from"./hints-BkX-7BA4.js";import{S as _e}from"./SafeFavicon-DuM4nGSq.js";import{u as ht,N as gt,b as ft,r as bt,a as jt}from"./Citations-8ei19XCq.js";import{b as Se}from"./brandCheck-Dp2xdnG8.js";import{a as yt,B as vt,b as wt}from"./BrandCheckIndicator-EJhFCkV0.js";import{S as Nt,a as G,b as kt}from"./SegmentStrip-DccoTQnW.js";import{S as Ct}from"./FilterBar-CzWFR4Y-.js";import{ah as _t,k as St,X as Lt,_ as ve,as as Le,i as te,a0 as zt,ac as se,R as Tt,ak as Pt,C as ze,eM as Te,s as H,m as Pe,L as Rt}from"./vendor-icons-BLMEbmRV.js";import{A as le,m as oe}from"./vendor-motion-ZmH_6coE.js";import{a as Ut,m as Dt}from"./csv-LP6bvMv0.js";import{a as It,S as $t}from"./MeasureModal-DXfD5Qy5.js";import{a as Mt}from"./usePageLinks-Dh8OFkKy.js";import{a as Ft,F as At,b as qt,R as Et,S as Gt}from"./FilterBar-DUUxiXjX.js";import{J as Re}from"./JourneyRail-DYnBfzUD.js";import"./vendor-supabase-DaZXgOw0.js";import"./SourceTypeConfig-D77yiFw2.js";import"./ProviderConfig-CDkmGdlj.js";import"./PlatformBadge-C7GxNbMu.js";import"./StateNotice-CUVE_HHP.js";import"./Popover-DXn2e0w4.js";import"./useAskAgent-matxMaQa.js";import"./agent-context-BOv-FWGt.js";import"./TabBar-Bd4u7NpX.js";import"./NavigationControls-BHA2q2LU.js";import"./NoBrandState-CCIjEscW.js";import"./google-search-console-rk8koH5M.js";import"./usePageTitle-648OBlq4.js";import"./dashboard-BrkNKxNo.js";import"./tags-DYHB8UpB.js";import"./personas-C5Nz4P15.js";import"./useGateDebug-C1gY7_rA.js";import"./useBrandWriteAccess-hlIM3kPf.js";import"./usePageTracking-BbYtv5VD.js";import"./useFirstReportStatus-BwKiCf5w.js";import"./useReportSubscription-CEvvKQks.js";import"./useUserActivity-kKUC7DRe.js";import"./useRequestPresentation-5kLKxVoy.js";import"./useLocationFilter-CNATvLBP.js";import"./useBrandMarkets-CsJUUxg0.js";import"./markets-u6J7KYRb.js";import"./language-BLAQCFRL.js";import"./brandCopy-CIDCVHCL.js";import"./PageIntro-D7FGP8bx.js";import"./onboarding-constants-C9DI2pcf.js";import"./useOpportunities-CXC7tQZ9.js";import"./useActions-BX6WCJx-.js";import"./actions-aIYFuvfK.js";import"./usePagesConfig-BcS5B2j6.js";import"./useAccentColor-C9mW7toz.js";import"./SegmentedControl-CXT6J19h.js";import"./words-D3GfRrXe.js";import"./Dot-CshOUEmb.js";function Wt({topics:t,activeTopic:n,onTopicChange:i,max:l=24}){if(t.length<2&&!n)return null;const p=t.slice(0,l),z=!!n&&p.some(m=>m.topic===n),T=[{id:"__all_topics__",label:"All topics",selected:!n,onClick:()=>i(null)},...n&&!z?[{id:"__active_topic__",label:n,meta:"active",selected:!0,onClick:()=>i(null)}]:[],...p.map(m=>({id:m.topic,label:m.topic,meta:m.count.toLocaleString(),selected:n===m.topic,onClick:()=>i(n===m.topic?null:m.topic)}))],h=!!n;return e.jsx(Ce,{align:"left",width:"w-[220px]",items:T,trigger:e.jsxs("span",{className:L("h-8 px-2.5 inline-flex items-center gap-1.5 rounded border text-[12px] font-medium transition-colors duration-200 max-w-[180px]",h?"border-accent/30 bg-accent-subtle text-accent":"border-default text-secondary hover:text-primary hover:border-hover hover:bg-muted"),title:h?`Topic: ${n}`:"Filter by topic",children:[e.jsx(_t,{size:13,strokeWidth:1.5,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate",children:h?n:"Topics"}),e.jsx(St,{size:12,strokeWidth:1.5,className:"flex-shrink-0 opacity-50"})]})})}function Ot({count:t,noun:n="item",actions:i,onClear:l}){return e.jsx(le,{children:t>0&&e.jsxs(oe.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:12},transition:{duration:.18,ease:[.16,1,.3,1]},className:"fixed bottom-6 left-1/2 z-50 -translate-x-1/2 flex items-center gap-0.5 rounded-md border border-default bg-white px-2 py-1.5 shadow-[0_4px_16px_
1-4px_rgba(0,0,0,0.12)]",role:"toolbar","aria-label":"Bulk actions",children:[e.jsxs("span",{className:"px-2 text-[12px] text-secondary tabular-nums",children:[e.jsx("span",{className:"font-medium text-primary",children:t})," ",n,t===1?"":"s"," selected"]}),e.jsx("span",{className:"mx-1 self-stretch border-l border-default"}),i.map(p=>e.jsxs("button",{onClick:p.onClick,disabled:p.disabled,className:L("inline-flex items-center gap-1.5 h-7 px-2.5 rounded text-[12px] font-medium transition-colors duration-200 disabled:opacity-40 disabled:cursor-not-allowed",p.variant==="primary"?"bg-accent-subtle text-accent hover:bg-accent-subtle/70":"text-secondary hover:text-primary hover:bg-muted"),children:[p.icon,p.label]},p.id)),e.jsx("span",{className:"mx-1 self-stretch border-l border-default"}),e.jsx("button",{onClick:l,className:"inline-flex h-7 w-7 items-center justify-center rounded text-muted hover:text-secondary hover:bg-muted transition-colors duration-200",title:"Clear selection","aria-label":"Clear selection",children:e.jsx(Lt,{size:14,strokeWidth:1.5})})]})})}const Bt=[{value:"influence",label:"Most cited"},{value:"queries",label:"Most queries"},{value:"sentiment",label:"Best sentiment"},{value:"recent",label:"Recently seen"},{value:"domain",label:"Domain A-Z"}],we=[{value:"all",label:"Any time"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}],Vt=[{id:"page_title",label:"Page Title",value:t=>Ue(t)},{id:"url",label:"URL",value:t=>t.url},{id:"domain",label:"Domain",value:t=>t.domain},{id:"source_type",label:"Source Type",value:t=>t.source_type??""},{id:"cited",label:"Cited",value:t=>t.appearance_count},{id:"mentions_brand",label:"Mentions Brand",value:t=>t.mentions_brand?"yes":t.analysis_pending?"not checked":"no"},{id:"not_checked_reason",label:"Not Checked Reason",value:t=>t.analysis_pending?Se(t).shortReason??"":""},{id:"brand_quote",label:"Brand Quote",value:t=>t.mentions_brand?t.mention_evidence?.quote??"":""},{id:"sentiment",label:"Sentiment",value:t=>t.sentiment??""},{id:"queries",label:"Queries",value:t=>(t.prompts??[]).join(" | ")},{id:"competitors",label:"Competitors",value:t=>(t.competitors??[]).join(" | ")},{id:"ai_providers",label:"AI Providers",value:t=>ie(t).join(" | ")},{id:"ai_provider_counts",label:"AI Provider Counts",value:t=>Qt(t)}];function Ue(t){if(t.page_title)return t.page_title;if(t.h1)return t.h1;try{const n=new URL(t.url),i=n.pathname.replace(/\/$/,"");return!i||i===""?n.hostname:De(decodeURIComponent(i.split("/").pop()||i))}catch{return t.url}}function De(t){const n=t.replace(/\.\w+$/,"").replace(/[-_]/g," ").replace(/\s+/g," ").trim();return n?n.replace(/\b([a-z])/g,i=>i.toUpperCase()).replace(/\b(Ai|Seo|Aeo|Geo|Llm|Llms)\b/g,i=>i.toUpperCase()):t}function Ne(t){if(!t)return"-";try{return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return"-"}}function Qt(t){const n=ct(t);return ie(t).map(i=>{const l=n[i];return l?`${i}: ${l}`:null}).filter(Boolean).join(" | ")}async function ae(t,n){await lt(t)?ye.copied(n):ye.error("Couldn't copy to clipboard")}function Z(t){try{const n=new URL(t.includes("://")?t:`https://${t}`),i=n.hostname.toLowerCase().replace(/^www\./,"");let l=n.pathname;return l.length>1&&(l=l.replace(/\/+$/,"")),l==="/"&&(l=""),`https://${i}${l}`}catch{return""}}function Ht(t){try{const n=new URL(t),i=n.pathname.replace(/\/$/,"");return i?De(decodeURIComponent(i.split("/").pop()||i)):n.hostname.replace(/^www\./,"")}catch{return t}}function ke(t,n){if(!t)return!1;try{const i=new Date(t),l=new Date;return l.setDate(l.getDate()-n),i>=l}catch{return!1}}function Kt({citation:t,isExpanded:n,isFocused:i,isSelected:l,selectionActive:p,onToggleSelect:z,onToggle:T,onHover:h,onNavigateToSource:m,accentColor:R,gscStats:v,trackedPage:j,recheckState:f,onRecheck:N,brandName:U}){const g=ne(),{getPath:c}=re(),k=j?c(`/pages/${encodeURIComponent(j.slug)}`):null,q=R==="#0e9373",W=Ue(t),E=f?bt(f):null,w=Se(t,{domain:t.domain}),D=[{id:"open",label:"Open page",icon:e.jsx(se,{size:13}),onClick:()=>window.open(t.url,"_blank")},...f&&N?[{...jt(f,N),icon:e.jsx(Tt,{size:13})}]:[],{id:"copy-url",label:"Copy URL",icon:e.jsx(te,{size:13}),onClick:()=>{ae(t.url,"Page URL copied")}},{id:"copy-domain",label:"Copy domain",icon:e.jsx(te,{size:13}),onClick:()=>{ae(t.domain,"Domain copied")}},...m?[{id:"view-source",label:`View ${t.domain} in Sources`,icon:e.jsx(Pt,{size:13}),onClick:()=>m(t.domain)}]:[]];return e.jsx(rt,{items:D,triggerClassName:"w-full",children:e.jsxs("div",{onMouseEnter:()=>h(t.url),onMouseLeave:()=>h(null),children:[e.jsxs("div",{className:L("group flex items-start gap-3 px-4 sm:px-8 py-3 cursor-pointer transition-colors duration-200",n?"bg-muted/50":"hover:bg-muted/30",i&&!n&&"ring-1 ring-inset ring-accent/20"),onClick:T,children:[e.jsxs("div",{className:"relative flex h-5 w-5 flex-shrink-0 items-center justify-center",children:[e.jsx(yt,{view:w,accentColor:q?void 0:R,className:L("transition-opacity duration-150",p||l?"opacity-0":"opacity-100 group-hover:opacity-0")}),e.jsx("button",{onClick:x=>{x.stopPropagation(),z()},className:L("absolute inset-0 m-auto flex h-4 w-4 items-center justify-center transition-opacity duration-150",p||l?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":l?"De
1select page":"Select page",children:e.jsx("span",{className:L("flex h-3.5 w-3.5 items-center justify-center rounded-[3px] border transition-colors duration-150",l?"bg-accent border-accent":"bg-white border-default hover:border-hover"),children:l&&e.jsx(ze,{size:9,strokeWidth:3,className:"text-white"})})})]}),e.jsx(_e,{domain:t.domain,size:16,showContainer:!0,containerClassName:"bg-white border-default"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("p",{className:"text-[13px] text-primary truncate leading-snug",children:W}),k&&e.jsx("span",{role:"link",tabIndex:0,"aria-label":"Open page record",title:"Open page record",className:"touch-action-visible inline-flex shrink-0 cursor-pointer rounded p-0.5 text-muted opacity-0 transition-opacity hover:text-accent group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:x=>{x.stopPropagation(),g(k)},onKeyDown:x=>{x.key==="Enter"&&(x.stopPropagation(),g(k))},children:e.jsx(Te,{size:11,strokeWidth:1.5})}),j?.stages&&e.jsx(Re,{stages:j.stages,bottleneck:j.bottleneck,estimated:j.estimated_stages,hoverCard:!1,className:"shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-[11px] min-w-0",children:[e.jsx("span",{className:"text-tertiary truncate",children:t.domain}),t.source_type&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted",children:"·"}),e.jsx(dt,{type:t.source_type,className:"flex-shrink-0"})]}),e.jsx("span",{className:"text-muted",children:"·"}),e.jsx(mt,{provider:t.ai_provider,providers:t.ai_providers,showName:!0,className:"flex-shrink-0"}),w.status==="unchecked"&&w.shortReason&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted",children:"·"}),e.jsx(ee,{content:e.jsx(vt,{view:w,brandName:U,note:E}),placement:"top",className:"max-w-[320px]",delay:150,children:e.jsx("span",{className:"text-muted whitespace-nowrap cursor-help",onClick:x=>x.stopPropagation(),children:t.unchecked_reason&&t.unchecked_reason!=="queued"?`${w.label}: ${w.shortReason.toLowerCase()}`:`${w.label} yet`})})]}),t.sentiment!==void 0&&t.sentiment!==null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted",children:"·"}),e.jsx(xt,{sentiment:t.sentiment,size:"sm",className:"flex-shrink-0"})]})]})]}),e.jsx("span",{className:"self-center text-[11px] text-muted w-12 text-right flex-shrink-0",children:t.prompts.length>0&&e.jsx("span",{className:"font-mono tabular-nums",children:t.prompts.length})}),e.jsx("span",{className:"self-center text-[11px] font-mono tabular-nums text-secondary w-10 text-right flex-shrink-0",children:t.appearance_count}),e.jsx(H,{size:14,className:L("self-center text-muted transition-transform duration-200 flex-shrink-0",n&&"rotate-90")}),e.jsx(ot,{items:D,label:`Page actions for ${W}`,className:"self-center"})]}),e.jsx(le,{children:n&&e.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.16,1,.3,1]},className:"overflow-hidden",children:e.jsx("div",{className:"px-4 sm:px-8 py-4 bg-white border-t border-subtle",children:e.jsxs("div",{className:"sm:pl-[4.5rem] space-y-4",children:[e.jsx("div",{children:e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-[12px] text-accent hover:underline flex items-center gap-1 max-w-full",onClick:x=>x.stopPropagation(),children:[e.jsx("span",{className:"truncate",children:t.url}),e.jsx(se,{size:10,strokeWidth:1.5,className:"flex-shrink-0"})]})}),e.jsx(wt,{view:w,brandName:U,note:E}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t.prompts.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-2",children:"Queries citing this page"}),e.jsx(Ze,{items:t.prompts,noun:"prompts",renderItem:(x,I)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Pe,{size:11,strokeWidth:1.5,className:"text-muted mt-0.5 flex-shrink-0"}),e.jsxs("p",{className:"text-[12px] text-secondary leading-relaxed",children:["â",x,"â"]}
1)]},I)})]}),t.competitors.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-2",children:"Competitors on this page"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.competitors.map((x,I)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 bg-white border border-default rounded text-[11px] text-secondary font-medium",children:[e.jsx(it,{name:x,size:12,className:"rounded-sm"}),x]},I))})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[11px] text-tertiary pt-1",children:[t.first_seen_ts&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Le,{size:10,strokeWidth:1.5}),"First seen ",Ne(t.first_seen_ts)]}),t.last_seen_ts&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted",children:"·"}),e.jsxs("span",{children:["Last seen ",Ne(t.last_seen_ts)]})]}),e.jsx("span",{className:"text-muted",children:"·"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-mono tabular-nums font-medium text-secondary",children:t.appearance_count})," total citations"]}),v&&v.position>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted",children:"·"}),e.jsx(ee,{content:`This page's Google search performance: ${v.query_count.toLocaleString()} queries · ${v.impressions.toLocaleString()} impressions (28d), via Search Console`,placement:"top",delay:200,children:e.jsxs("span",{className:"cursor-help",children:["Google ",e.jsxs("span",{className:"font-mono tabular-nums font-medium text-secondary",children:["#",v.position.toFixed(1)]}),v.clicks>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"font-mono tabular-nums font-medium text-secondary",children:v.clicks.toLocaleString()})," clicks"]})]})})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted",children:"·"}),e.jsxs("button",{onClick:x=>{x.stopPropagation(),m(t.domain)},className:"text-accent hover:underline flex items-center gap-1",children:["View source profile",e.jsx(H,{size:10})]})]})]})]})})})})]})})}function Yt({page:t,isExpanded:n,isTracking:i,canAct:l,actionPath:p,onToggle:z,onTrack:T,onAnalyze:h,trackedPage:m}){const R=ne(),{getPath:v}=re(),j=m?v(`/pages/${encodeURIComponent(m.slug)}`):null;let f="",N=t.url;try{const c=new URL(t.url);f=c.hostname.replace(/^www\./,""),N=c.pathname||"/"}catch{}const U=Ht(t.url),g=t.gap_type==="rank1_competitor_cited";return e.jsxs("div",{children:[e.jsxs("div",{className:L("group flex items-start gap-3 px-4 sm:px-8 py-3 cursor-pointer transition-colors duration-200",n?"bg-muted/50":"hover:bg-muted/30"),onClick:z,children:[e.jsx("div",{className:"flex h-5 w-5 flex-shrink-0 items-center justify-center",children:e.jsx("span",{className:"w-2 h-2 rounded-full border border-default bg-white",title:"Never cited by AI"})}),e.jsx(_e,{domain:f,size:16,showContainer:!0,containerClassName:"bg-white border-default"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("p",{className:"text-[13px] text-primary truncate leading-snug",children:U}),m?.stages&&e.jsx(Re,{stages:m.stages,bottleneck:m.bottleneck,estimated:m.estimated_stages,hoverCard:!1,className:"shrink-0"}),j&&e.jsx("span",{role:"link",tabIndex:0,"aria-label":"Open page record",title:"Open page record",className:"touch-action-visible inline-flex shrink-0 cursor-pointer rounded p-0.5 text-muted opacity-0 transition-opacity hover:text-accent group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:c=>{c.stopPropagation(),R(j)},onKeyDown:c=>{c.key==="Enter"&&(c.stopPropagation(),R(j))},children:e.jsx(Te,{size:11,strokeWidth:1.5})})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5 text-[11px] min-w-0",children:e.jsx("span",{className:"text-tertiary truncate",children:N})})]}),e.jsxs("span",{className:"self-center text-[11px] font-mono tabular-nums text-primary flex-shrink-0",children:["#",t.position.toFixed(1)]}),e.jsx("span",{className:"self-center text-[11px] font-mono tabular-nums text-muted w-24 text-right flex-shrink-0 whitespace-nowrap",children:t.clicks>
10?`${t.clicks.toLocaleString()} clicks`:"â"}),e.jsx("span",{className:L("badge shrink-0 hidden xl:inline-flex",g?"badge-warning":"badge-neutral"),children:g?"Likely competitor cited":"Never cited"}),t.tracked_action_id&&p?e.jsxs(et,{to:p,onClick:c=>c.stopPropagation(),className:"self-center inline-flex items-center gap-1.5 text-[11px] font-medium text-muted hover:text-accent transition-colors shrink-0",children:[e.jsx(ze,{size:16,strokeWidth:1.5,className:"text-accent"}),"Tracking"]}):l?e.jsxs("button",{type:"button",disabled:i,onClick:c=>{c.stopPropagation(),T(t.url)},className:"btn btn-primary btn-sm self-center shrink-0",children:[i&&e.jsx(Rt,{size:16,strokeWidth:1.5,className:"animate-spin"}),"Track"]}):null,e.jsx(H,{size:14,className:L("self-center text-muted transition-transform duration-200 flex-shrink-0",n&&"rotate-90")})]}),e.jsx(le,{children:n&&e.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.16,1,.3,1]},className:"overflow-hidden",children:e.jsx("div",{className:"px-4 sm:px-8 py-4 bg-white border-t border-subtle",children:e.jsxs("div",{className:"sm:pl-[4.5rem] space-y-4",children:[e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-[12px] text-accent hover:underline flex items-center gap-1 max-w-full",onClick:c=>c.stopPropagation(),children:[e.jsx("span",{className:"truncate",children:t.url}),e.jsx(se,{size:10,strokeWidth:1.5,className:"flex-shrink-0"})]}),t.top_queries.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-2",children:"Top Google queries"}),e.jsx("div",{className:"space-y-1.5 max-w-[480px]",children:t.top_queries.slice(0,3).map((c,k)=>e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx(Pe,{size:11,strokeWidth:1.5,className:"text-muted self-center flex-shrink-0"}),e.jsx("p",{className:"text-[12px] text-secondary leading-relaxed truncate min-w-0 flex-1",children:c.query}),e.jsx("span",{className:"text-[11px] font-mono tabular-nums text-secondary flex-shrink-0",children:c.position>0?`#${c.position.toFixed(1)}`:"â"}),e.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted w-10 text-right flex-shrink-0",children:c.clicks.toLocaleString()})]},k))})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[11px] text-tertiary pt-1",children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-mono tabular-nums font-medium text-secondary",children:t.query_count.toLocaleString()})," Google queries"]}),e.jsx("span",{className:"text-muted",children:"·"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-mono tabular-nums font-medium text-secondary",children:t.impressions.toLocaleString()})," impressions (28d)"]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted",children:"·"}),e.jsxs("button",{onClick:c=>{c.stopPropagation(),h(t.url)},className:"text-accent hover:underline flex items-center gap-1",children:["Analyze this page",e.jsx(H,{size:10})]})]})]})]})})})})]})}function Jt(){return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden animate-pulse",children:[e.jsx("div",{className:"flex-shrink-0 px-4 sm:px-8 h-11 border-b border-default flex items-center gap-6",children:[1,2,3,4].map(t=>e.jsx("div",{className:"h-4 w-20 bg-muted rounded"},t))}),e.jsxs("div",{className:"flex-shrink-0 px-4 sm:px-8 h-12 border-b border-subtle flex items-center gap-2",children:[e.jsx("div",{className:"h-8 w-64 bg-muted rounded"}),e.jsx("div",{className:"h-8 w-20 bg-muted rounded"}),e.jsx("div",{className:"h-8 w-24 bg-muted rounded"}),e.jsx("div",{className:"ml-auto h-8 w-32 bg-muted rounded"})]}),e.jsxs("div",{className:"flex-shrink-0 px-4 sm:px-8 py-2 border-b border-subtle flex items-center gap-3",children:[e.jsx("div",{className:"h-3 w-16 bg-muted rounded"}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"h-3 w-12 bg-muted rounded"}),e.jsx("div",{className:"h-3 w-12 bg-muted rounded"}),e.jsx("div",{className:"h-3 w-12 bg-muted rounded"})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:[1,2,3,4,5,6,7,8].map(t=>e.jsxs("div",{className:"px-4 sm:px-8 py-3.5 flex items-center gap-3 border-b border-subtle/50",children:[e.jsx("div",{className:"w-2 h-2 bg-muted rounded-full"}),e.jsx("div",{className:"w-5 h-5 bg-muted rounded"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-3.5 w-3/4 bg-muted rounded"}),e.jsx("div",{className:"h-2.5 w-24 bg-muted rounded"})]}),e.jsx("div",{className:"h-3 w-6 bg-muted rounded"}),e.jsx("div",{className:"h-3 w-3 bg-muted rounded-full"}),e.jsx("div",{className:"h-3 w-8 bg-muted rounded"})]},t))})]})}function ra({citations:t,brandId:n,isLoading:i,loadError:l,hasTagScope:p=!1,onClearScope:z,onRetry:T,accentColor:h="#0e9373",accentColorSubtle:m="#e4f6f2",onNavigateToSource:R,brandWebsite:v,brandName:j,gsc:f,totalPages:N,totalDomains:U,providerFilter:g=null,onProviderFilterChange:c,canAct:k=!1,canRecheck:q=!1}){const W=ne(),E=ht(n,q),{getPath:w}
1=re(),D=It(n),[x,I]=o.useState(null),[y,ce]=o.useState(""),[b,M]=o.useState("all"),[K,Ie]=o.useState("influence"),[$,de]=o.useState(null),[C,me]=o.useState("all"),[F,pe]=o.useState(null),[O,ue]=o.useState(new Set),[A,B]=o.useState(null),[,$e]=o.useState(null),[P,Y]=o.useState(-1),J=o.useRef(null),xe=h==="#0e9373",d=o.useMemo(()=>{const s=[...t];switch(K){case"influence":return s.sort((a,r)=>r.appearance_count-a.appearance_count);case"queries":return s.sort((a,r)=>r.prompts.length-a.prompts.length);case"sentiment":return s.sort((a,r)=>(r.sentiment??50)-(a.sentiment??50));case"recent":return s.sort((a,r)=>{const u=a.last_seen_ts?new Date(a.last_seen_ts).getTime():0;return(r.last_seen_ts?new Date(r.last_seen_ts).getTime():0)-u});case"domain":return s.sort((a,r)=>a.domain.localeCompare(r.domain));default:return s}},[t,K]),Me=o.useMemo(()=>d.filter(s=>s.mentions_brand).length,[d]),Fe=o.useMemo(()=>d.filter(s=>!s.mentions_brand&&!s.analysis_pending).length,[d]),he=o.useMemo(()=>d.filter(s=>s.analysis_pending).length,[d]),Ae=o.useMemo(()=>new Set(d.map(s=>s.domain)).size,[d]),V=N!=null&&N>d.length,qe=o.useMemo(()=>d.filter(s=>s.source_type==="owned").length,[d]),Ee=o.useMemo(()=>{const s={};for(const a of d){const r=a.source_type||"other";s[r]=(s[r]||0)+1}return s},[d]),Ge=o.useMemo(()=>{const s=new Map;for(const a of t)for(const r of a.topics??[]){const u=r.trim();u&&s.set(u,(s.get(u)??0)+1)}return[...s.entries()].map(([a,r])=>({topic:a,count:r})).sort((a,r)=>r.count-a.count)},[t]),_=o.useMemo(()=>{let s=d;if(y){const a=y.toLowerCase();s=s.filter(r=>r.domain.toLowerCase().includes(a)||(r.page_title||"").toLowerCase().includes(a)||(r.h1||"").toLowerCase().includes(a)||r.url.toLowerCase().includes(a)||r.prompts.some(u=>u.toLowerCase().includes(a)))}switch(b){case"your-pages":s=s.filter(a=>a.source_type==="owned");break;case"citing":s=s.filter(a=>a.mentions_brand);break;case"gaps":s=s.filter(a=>!a.mentions_brand&&!a.analysis_pending);break;case"pending":s=s.filter(a=>a.analysis_pending);break}return $&&(s=s.filter(a=>(a.source_type||"other")===$)),g&&(s=s.filter(a=>ie(a).includes(g))),C==="7d"?s=s.filter(a=>ke(a.first_seen_ts,7)):C==="30d"&&(s=s.filter(a=>ke(a.first_seen_ts,30))),F&&(s=s.filter(a=>(a.topics??[]).includes(F))),s},[d,y,b,$,g,C,F]),S=o.useMemo(()=>{if(!f?.connected||!f.uncited_pages?.length)return[];const s=new Set(t.map(a=>Z(a.url)).filter(Boolean));return f.uncited_pages.filter(a=>!s.has(Z(a.url)))},[f,t]),We=o.useMemo(()=>S.filter(s=>s.gap_type==="rank1_competitor_cited"),[S]),Oe=o.useMemo(()=>S.filter(s=>s.gap_type!=="rank1_competitor_cited"),[S]),Be=o.useMemo(()=>[..._.map(s=>s.url),...S.map(s=>s.url)],[_,S]),{resolve:ge}=Mt(Be),fe=qe+S.length,Ve=b==="your-pages"&&S.length>0&&!y&&!$&&!g&&C==="all"&&!F,Qe=s=>{if(!(!f?.connected||!f.pages))return f.pages[Z(s)]};if(o.useEffect(()=>{const s=a=>{if(!nt(a))switch(a.key){case"ArrowDown":a.preventDefault(),Y(r=>Math.min(r+1,_.length-1));break;case"ArrowUp":a.preventDefault(),Y(r=>Math.max(r-1,0));break;case"Enter":if(P>=0&&P<_.length){const r=_[P].url;B(A===r?null:r)}break;case"Escape":B(null),Y(-1);break}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[_,P,A]),o.useEffect(()=>{if(P<0||!J.current)return;J.current.querySelectorAll("[data-page-row]")[P]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[P]),l)return e.jsx(X,{kind:"recoverable-error",scope:"section",title:"Couldn't load these pages",description:"Try loading this platform's citation pages again.",action:T?{label:"Try again",onClick:T}:void 0,className:"flex-1"});if(i)return e.jsx(Jt,{});if(t.length===0&&S.length===0)return e.jsx(X,{kind:g||p?"filtered-empty":"initial-empty",scope:"section",icon:ve,title:g||p?"No pages match this scope":"No citation pages yet",action:(g||p)&&z?{label:"Clear filters",onClick:z}:void 0,description:g||p?"Try another platform or tag to see your citation pages.":"Pages will appear here as AI models discover and cite content in your reports.",className:"flex-1"});const be=b!=="all"||y||$||g||C!=="all"||!!F,He=s=>{ue(a=>
1{const r=new Set(a);return r.has(s)?r.delete(s):r.add(s),r})},Ke=()=>ue(new Set),Ye=O.size>0,je=()=>t.filter(s=>O.has(s.url)),Je=async()=>{const s=je();s.length!==0&&await ae(s.map(a=>a.url).join(` 2`),`${s.length} page URL${s.length===1?"":"s"} copied`)},Xe=()=>{const s=je();s.length!==0&&Ut(Dt("citations-pages-selected"),s,Vt)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(Nt,{readout:e.jsx(kt,{label:"Domains",value:e.jsx(tt,{value:Ae,delay:.3}),tooltip:V&&U!=null?`Unique domains across your top ${d.length.toLocaleString()} pages. The full snapshot spans ${U.toLocaleString()} domains.`:`Unique domains across the ${d.length.toLocaleString()} pages loaded here, before search and filters.`}),children:[e.jsx(G,{active:b==="all",onClick:()=>M("all"),count:d.length,label:V?"top pages":"pages",tooltip:V?`Your ${d.length.toLocaleString()} most-cited pages, of ${(N??0).toLocaleString()} cited pages in this snapshot. CSV exports include every page.`:void 0,accentColor:h,layoutId:"citations-pages-stat-filter-line",icon:e.jsx(ve,{size:12,className:"text-muted"}),delay:0,numberDelay:.1}),(fe>0||S.length>0||b==="your-pages")&&e.jsx(G,{active:b==="your-pages",onClick:()=>M(b==="your-pages"?"all":"your-pages"),count:fe,label:"your pages",accentColor:h,layoutId:"citations-pages-stat-filter-line",dotClassName:"bg-blue-500",delay:.05,numberDelay:.15}),e.jsx(G,{active:b==="citing",onClick:()=>M(b==="citing"?"all":"citing"),count:Me,label:"citing you",accentColor:h,layoutId:"citations-pages-stat-filter-line",dotClassName:xe?"bg-accent":void 0,dotStyle:xe?void 0:{backgroundColor:h},delay:.1,numberDelay:.2}),e.jsx(G,{active:b==="gaps",onClick:()=>M(b==="gaps"?"all":"gaps"),count:Fe,label:"gaps",accentColor:h,layoutId:"citations-pages-stat-filter-line",dotClassName:"bg-warning",tooltip:pt,delay:.15,numberDelay:.25}),he>0&&e.jsx(G,{active:b==="pending",onClick:()=>M(b==="pending"?"all":"pending"),count:he,label:"not checked",accentColor:h,layoutId:"citations-pages-stat-filter-line",tooltip:ut,delay:.2,numberDelay:.3})]}),e.jsxs(Ft,{right:e.jsxs(e.Fragment,{children:[V?e.jsx("span",{className:"text-[11px] text-muted tabular-nums whitespace-nowrap",children:be?`${_.length.toLocaleString()} of top ${d.length.toLocaleString()}`:`top ${d.length.toLocaleString()} of ${(N??0).toLocaleString()} pages`}):e.jsx(Et,{shown:_.length,total:d.length}),e.jsx(Gt,{options:Bt,value:K,onChange:Ie})]}),children:[e.jsx(At,{value:y,onChange:ce,placeholder:"Search pages, domains, queries...",accentColor:h}),e.jsx(Ct,{breakdown:Ee,activeType:$,onTypeChange:de}),e.jsx(Wt,{topics:Ge,activeTopic:F,onTopicChange:pe}),e.jsx(Ce,{align:"left",items:we.map(s=>({id:s.value,label:s.label,selected:C===s.value,onClick:()=>me(s.value)})),trigger:e.jsx(qt,{label:C==="all"?"First cited":we.find(s=>s.value===C)?.label??"First cited",icon:e.jsx(Le,{size:13,strokeWidth:1.5,className:"flex-shrink-0"}),active:C!=="all",title:"Filter by when a page was first cited"})})]}),e.jsxs("div",{className:"flex-shrink-0 px-4 sm:px-8 py-1.5 border-b border-subtle bg-white flex items-center gap-3",children:[e.jsx("div",{className:"w-5 flex-shrink-0"}),e.jsx("div",{className:"w-[24px] flex-shrink-0"}),e.jsx("span",{className:"flex-1 text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Page"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted w-12 text-right",children:"Queries"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted w-10 text-right",children:"Cited"}),e.jsx("div",{className:"w-3.5 flex-shrink-0"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",ref:J,children:[_.length===0?b==="your-pages"&&!y&&!$&&!g&&C==="all"?v?e.jsx(ft,{}):e.jsx(gt,{}):e.jsx(X,{kind:y?"search-empty":"filtered-empty",scope:"section",title:y?"No matching pages":"No pages match these filters",description:y?`No citation pages match â${y}â.`:"Clear the active filters to see all citation pages.",action:be?{label:y?"Clear search and filters":"Clear filters",onClick:()=>{M("all"),ce(""),de(null),c?.(null),me("all"),pe(null)}}:void 0}):e.jsx(st,{delay:.05,stagger:"tight",direction:"up",children:e.jsx("div",{className:"divide-y divide-subtle",children:_.map((s,a)=>e.jsx(at,{children:e.jsx("div",{"data-page-row":!0,children:e.jsx(Kt,{citation:s,isExpanded:A===s.url,isFocused:P===a,isSelected:O.has(s.url),selectionActive:Ye,onToggleSelect:()=>He(s.url),onToggle:()=>B(A===s.url?null:s.url),onHover:$e,onNavigateToSource:R,accentColor:h,gscStats:s.source_type==="owned"?Qe(s.url):void 0,trackedPage:ge(s.url),recheckState:q?E.stateFor(s.url):void 0,onRecheck:q?()=>E.requestRecheck(s.url):void 0,brandName:j})})},s.url))})}),Ve&&e.jsx("div",{className:"border-t border-default",children:[{key:"likely-competitor",label:"Likely competitor cited instead",tooltip:"A fuzzy topic match suggests an AI answer may cite a competitor while your top-ranking page is absent. Treat this as a lead, not a confirmed citation match.",pages:We},{key:"never-cited",label:"Ranking on Google, never cited by AI",tooltip:"Your pages with a top-10 Google rank that have never appeared as an AI citation. Rank and clicks come from Search Console, last 28 days.",pages:Oe}].filter(s=>s.pages.length>0).map((s,a)=>{const r=s.pages.reduce((u,Q)=>u+(Q.clicks||0),0);return e.jsxs("div",{className:a>0?"border-t border-default":void 0,children:[e.jsxs("div",{className:"px-4 sm:px-8 py-2.5 border-b border-subtle flex items-center justify-between gap-3",children:[e.jsx(ee,{content:s.tooltip,placement:"bottom",delay:200,children:e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted cursor-help",children:s.label})}),e.jsxs("span",{className:"text-[11px] font-mono tabular-nums text-muted",children:[s.pages.length," ",s.pages.length===1?"page":"pages",r>
20&&e.jsxs(e.Fragment,{children:[" · ",r.toLocaleString()," clicks/28d"]})]})]}),e.jsx("div",{className:"divide-y divide-subtle",children:s.pages.map(u=>e.jsx(Yt,{page:u,isExpanded:A===u.url,isTracking:D.isPending&&D.variables?.pageUrl===u.url,canAct:k,actionPath:u.tracked_action_id?w(`/actions?actionId=${u.tracked_action_id}`):null,trackedPage:ge(u.url),onToggle:()=>B(A===u.url?null:u.url),onTrack:()=>{k&&I(u)},onAnalyze:Q=>W(w(`/optimize?url=${encodeURIComponent(Q)}`))},u.url))})]},s.key)})})]}),e.jsx($t,{brandId:n??"",page:k?x:null,onClose:()=>I(null),onStart:(s,a)=>{k&&D.mutate({pageUrl:s.url,confirmationToken:a},{onSuccess:()=>I(null)})},starting:D.isPending}),e.jsx(Ot,{count:O.size,noun:"page",onClear:Ke,actions:[{id:"copy",label:"Copy URLs",icon:e.jsx(te,{size:13,strokeWidth:1.5}),onClick:()=>{Je()}},{id:"export",label:"Export CSV",icon:e.jsx(zt,{size:13,strokeWidth:1.5}),onClick:Xe,variant:"primary"}]})]})}export{ra as PagesExplorer,ra 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.