@canonry/canonry 7.32.0 → 7.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/assets/agent-workspace/skills/aero/references/agent-operations.md +9 -0
  2. package/assets/agent-workspace/skills/aero/references/site-health.md +12 -0
  3. package/assets/agent-workspace/skills/canonry/SKILL.md +9 -0
  4. package/assets/agent-workspace/skills/canonry/references/aeo-analysis.md +24 -0
  5. package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +207 -4
  6. package/assets/agent-workspace/skills/canonry/references/server-side-traffic.md +14 -2
  7. package/assets/assets/{AuditHistoryPanel-cQyVA85P.js → AuditHistoryPanel-CvANw3ds.js} +1 -1
  8. package/assets/assets/{BacklinksPage-UGZ_9N7F.js → BacklinksPage-C6x9ELjk.js} +1 -1
  9. package/assets/assets/{HistoryPage-UJVFZ5LK.js → HistoryPage-r36HX1cC.js} +1 -1
  10. package/assets/assets/{MeasurementPropertyPage-ChpOxQfx.js → MeasurementPropertyPage-ComoCzR4.js} +3 -3
  11. package/assets/assets/ProjectPage-CIeU-buk.js +8 -0
  12. package/assets/assets/RunsPage-DI6eJATZ.js +1 -0
  13. package/assets/assets/{SettingsPage-DeKxjuTr.js → SettingsPage-Bw7GdXxs.js} +1 -1
  14. package/assets/assets/{SiteHealthSection-COeVsgop.js → SiteHealthSection-C-JaNKpS.js} +3 -3
  15. package/assets/assets/{TrafficPage-DmMmeJKK.js → TrafficPage-Cnsp276v.js} +1 -1
  16. package/assets/assets/{TrafficSourceDetailPage-CUehseZe.js → TrafficSourceDetailPage-CBIaJk7e.js} +1 -1
  17. package/assets/assets/{extract-error-message-BsxdS7Po.js → extract-error-message-C_Owa0n9.js} +1 -1
  18. package/assets/assets/index-ZS9sSTMS.js +86 -0
  19. package/assets/assets/{react-sigma_core.esm.min--MbbBWzJ.js → react-sigma_core.esm.min-ugyh-ooq.js} +1 -1
  20. package/assets/assets/{v2-overview-adapter-D-IScpdp.js → v2-overview-adapter-BLSrVQ7K.js} +1 -1
  21. package/assets/index.html +1 -1
  22. package/dist/chunk-3JVF3ULD.js +550 -0
  23. package/dist/chunk-45Z5RJZW.js +562 -0
  24. package/dist/{chunk-QFXD7GR5.js → chunk-5LY7EG4U.js} +238 -20
  25. package/dist/chunk-EJRV7RBZ.js +23066 -0
  26. package/dist/{chunk-WRHA54BN.js → chunk-G47XJVAS.js} +5885 -3900
  27. package/dist/{chunk-42XUY243.js → chunk-GZ2KIONF.js} +11507 -10391
  28. package/dist/chunk-HGMYEDAQ.js +79 -0
  29. package/dist/{chunk-2C6NWFN4.js → chunk-JVBI6VBT.js} +2 -2
  30. package/dist/{chunk-ZIETXJYU.js → chunk-MPWBFKGK.js} +201 -104
  31. package/dist/{chunk-K5EGSSXC.js → chunk-QQYQDTFZ.js} +142 -47
  32. package/dist/{chunk-FW4GX2LO.js → chunk-SW54HXSZ.js} +3 -3
  33. package/dist/cli-catalog-PNJEQV5H.js +15 -0
  34. package/dist/cli-commands-4UT2CRXX.js +15 -0
  35. package/dist/cli.js +136 -22525
  36. package/dist/{demo-server-G5OK7SWE.js → demo-server-WRHR25HF.js} +5 -4
  37. package/dist/index.js +7 -6
  38. package/dist/{intelligence-service-3ZUVTIO7.js → intelligence-service-QXXRUB2G.js} +2 -2
  39. package/dist/mcp.js +30 -15
  40. package/package.json +10 -10
  41. package/assets/assets/ProjectPage-CvxuPSiC.js +0 -8
  42. package/assets/assets/RunsPage-C6U_YcDY.js +0 -1
  43. package/assets/assets/index-ahEr6Oc-.js +0 -86
@@ -1,4 +1,4 @@
1
- import{r as p,u as K,o as We,j as e,L as te,D as ze,k as Ye,l as Ge,C as Re}from"./vendor-tanstack-ZXXkndVj.js";import{dY as Ze,dZ as Xe,d_ as Je,d$ as es,e0 as ss,X as $e,e1 as ts,b9 as as,y as _,cM as ns,I,B as w,aB as rs,cv as ve,cT as is,co as os,cm as ls,cH as ds,cC as ce,e2 as cs,aX as ms,aY as hs,e3 as Ie,e4 as ke,T as V,aS as Ne,aT as we,cZ as oe,e5 as us,bX as xs,e6 as ps,e7 as fs,k as Be,s as ys,f as _e,b7 as Oe}from"./index-ahEr6Oc-.js";import{j as gs,o as js}from"./ChartPrimitives-CZ4wVBJL.js";import{i as bs,b as vs,m as Ns,a as Fe,M as ws,A as Ps}from"./v2-overview-adapter-D-IScpdp.js";import{Z as Cs}from"./vendor-lucide-Y6jANGfG.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";function Es(s){return s.normalize("NFKC").toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]}function Pe(s){return Es(s).join("\0")}function Ss(s,t){const a=Pe(s);return t.map(Pe).filter(Boolean).some(n=>n!==a&&`\0${a}\0`.includes(`\0${n}\0`))}const Ue=ss,ae={short:"target-name-short",withoutBrand:"target-name-without-brand",qualifiedWithoutName:"target-qualified-name-without-name"};function qs(s){const t=Ze(s.brandNames),a=t.length>0?Xe(t):null,n=[];return s.aliases.forEach((o,u)=>{o.trim()&&(Je(o).length<Ue?n.push({code:ae.short,field:"aliases",index:u,value:o}):a!==null&&!es(a,o)&&n.push({code:ae.withoutBrand,field:"aliases",index:u,value:o}))}),s.identityAliases?.forEach((o,u)=>{o.trim()&&(Ss(o,s.aliases)||n.push({code:ae.qualifiedWithoutName,field:"identityAliases",index:u,value:o}))}),n}function As(s){switch(s.code){case ae.short:return`"${s.value.trim()}" is too short to match safely. A name needs at least ${Ue} letters or numbers, or it can match unrelated words in an answer.`;case ae.withoutBrand:return`"${s.value.trim()}" does not include your brand name, so answers about other places with this name can count for this property.`;case ae.qualifiedWithoutName:return`"${s.value.trim()}" must include one of this property's names plus more words, such as a street or city. Publishing is refused until it does.`}}const x={heading:"Names that count as this Property",help:"An answer mentions this Property when its text contains one of these names as whole words. Source titles and source links never count, but a link in the answer whose text is one of these names does. Qualified names are longer forms, such as the name with its street or city, for a name that other places share.",names:"Names",qualifiedNames:"Qualified names",noNames:"No names are set, so answers can cite this Property but never mention it.",edit:"Edit names",save:"Save to draft",saving:"Saving…",cancel:"Cancel",namesHint:"One name per line.",qualifiedHint:"One per line. Each must include one of the names above plus more words, such as a street or city.",qualifiedNote:"With qualified names set, an answer that uses only a plain name counts as a mention only when it also cites this Property’s own page. Otherwise it is left out as not tied to one property.",draftOnly:"Saving changes the draft only. Nothing is measured differently until the setup is published.",saved:"Saved to the draft. Publish the setup to start using these names.",pending:"Name changes are saved in the draft and not published yet.",review:"Review and publish",noChanges:"No changes to save.",staleDraft:"The draft is based on an older published setup. Open measurement setup to restart it before editing names.",missingFromDraft:"This Property is not included in the current draft. Open measurement setup to review it.",conflict:"The draft changed in another session. The latest names are loaded; review them and save again.",failed:"Could not save these names. Try again."};function Ce(s){return[...new Set(s.split(`
2
- `).map(t=>t.trim()).filter(Boolean))]}function Ee(s,t){return s.length===t.length&&s.every((a,n)=>a===t[n])}function ie(s,t){return Ee(s.aliases,t.aliases)&&Ee(s.identityAliases??[],t.identityAliases??[])}function Ms(s,t,a){const{identityAliases:n,...o}=s;return a.length>0?{...o,aliases:t,identityAliases:a}:{...o,aliases:t}}function Se({label:s,names:t}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium text-heading",children:s}),e.jsx("ul",{className:"space-y-1",children:t.map(a=>e.jsx("li",{className:"text-sm text-secondary",children:a},a))})]})}function qe({id:s,issues:t}){return t.length===0?null:e.jsx("ul",{id:s,className:"mt-2 space-y-1","aria-label":"Name warnings",children:t.map(a=>e.jsx("li",{className:"text-sm text-caution",children:As(a)},`${a.field}:${a.index}`))})}function Ts({projectName:s,targetKey:t,published:a,activeRevision:n,publishedBrandNames:o,service:u=vs}){const{canWrite:m}=$e(),r=p.useId(),l=K({...ts({client:_,path:{name:s}}),enabled:m}),k=K({...as({client:_,path:{name:s}}),enabled:m}),q=l.data?.draft?.authoring.targets.find(d=>d.stableKey===t),P=a.identityAliases??[],O=q!==void 0&&l.data?.draft?.baseActiveRevision===n&&!ie(q,a),T=!l.isFetching&&!k.isPending,h=k.data,A=p.useMemo(()=>h?ns(h):o,[h,o]),[C,L]=p.useState(!1),[c,j]=p.useState(""),[M,D]=p.useState(""),[ne,v]=p.useState(a),[E,R]=p.useState(null),B=`${s}\0${t}`,[H,xe]=p.useState(B);H!==B&&(xe(B),L(!1),j(""),D(""),v(a),R(null));const re=p.useRef(B);re.current=B;const W=p.useMemo(()=>Ce(c),[c]),G=p.useMemo(()=>Ce(M),[M]),pe=p.useMemo(()=>qs({aliases:W,identityAliases:G,brandNames:A}),[W,G,A]),Z=pe.filter(d=>d.field==="aliases"),X=pe.filter(d=>d.field==="identityAliases");function z(d){j(d.aliases.join(`
1
+ import{r as p,u as K,o as We,j as e,L as te,D as ze,k as Ge,l as Ye,C as Te}from"./vendor-tanstack-ZXXkndVj.js";import{d$ as Ze,e0 as Xe,e1 as Je,e2 as es,e3 as ss,X as $e,e4 as ts,bb as as,y as _,cN as ns,I,B as w,aE as rs,cw as ve,cU as is,cp as os,cn as ls,cI as ds,cD as ce,e5 as cs,aZ as ms,a_ as hs,e6 as Ie,e7 as ke,T as V,aV as Ne,aW as we,d0 as oe,e8 as us,bY as xs,e9 as ps,ea as fs,k as Be,s as ys,f as _e,b9 as Oe}from"./index-ZS9sSTMS.js";import{j as gs,o as js}from"./ChartPrimitives-CZ4wVBJL.js";import{i as bs,b as vs,m as Ns,a as Fe,M as ws,A as Ps}from"./v2-overview-adapter-BLSrVQ7K.js";import{Z as Cs}from"./vendor-lucide-Y6jANGfG.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";function Es(s){return s.normalize("NFKC").toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]}function Pe(s){return Es(s).join("\0")}function Ss(s,t){const a=Pe(s);return t.map(Pe).filter(Boolean).some(n=>n!==a&&`\0${a}\0`.includes(`\0${n}\0`))}const Ue=ss,ae={short:"target-name-short",withoutBrand:"target-name-without-brand",qualifiedWithoutName:"target-qualified-name-without-name"};function qs(s){const t=Ze(s.brandNames),a=t.length>0?Xe(t):null,n=[];return s.aliases.forEach((o,u)=>{o.trim()&&(Je(o).length<Ue?n.push({code:ae.short,field:"aliases",index:u,value:o}):a!==null&&!es(a,o)&&n.push({code:ae.withoutBrand,field:"aliases",index:u,value:o}))}),s.identityAliases?.forEach((o,u)=>{o.trim()&&(Ss(o,s.aliases)||n.push({code:ae.qualifiedWithoutName,field:"identityAliases",index:u,value:o}))}),n}function As(s){switch(s.code){case ae.short:return`"${s.value.trim()}" is too short to match safely. A name needs at least ${Ue} letters or numbers, or it can match unrelated words in an answer.`;case ae.withoutBrand:return`"${s.value.trim()}" does not include your brand name, so answers about other places with this name can count for this property.`;case ae.qualifiedWithoutName:return`"${s.value.trim()}" must include one of this property's names plus more words, such as a street or city. Publishing is refused until it does.`}}const x={heading:"Names that count as this Property",help:"An answer mentions this Property when its text contains one of these names as whole words. Source titles and source links never count, but a link in the answer whose text is one of these names does. Qualified names are longer forms, such as the name with its street or city, for a name that other places share.",names:"Names",qualifiedNames:"Qualified names",noNames:"No names are set, so answers can cite this Property but never mention it.",edit:"Edit names",save:"Save to draft",saving:"Saving…",cancel:"Cancel",namesHint:"One name per line.",qualifiedHint:"One per line. Each must include one of the names above plus more words, such as a street or city.",qualifiedNote:"With qualified names set, an answer that uses only a plain name counts as a mention only when it also cites this Property’s own page. Otherwise it is left out as not tied to one property.",draftOnly:"Saving changes the draft only. Nothing is measured differently until the setup is published.",saved:"Saved to the draft. Publish the setup to start using these names.",pending:"Name changes are saved in the draft and not published yet.",review:"Review and publish",noChanges:"No changes to save.",staleDraft:"The draft is based on an older published setup. Open measurement setup to restart it before editing names.",missingFromDraft:"This Property is not included in the current draft. Open measurement setup to review it.",conflict:"The draft changed in another session. The latest names are loaded; review them and save again.",failed:"Could not save these names. Try again."};function Ce(s){return[...new Set(s.split(`
2
+ `).map(t=>t.trim()).filter(Boolean))]}function Ee(s,t){return s.length===t.length&&s.every((a,n)=>a===t[n])}function ie(s,t){return Ee(s.aliases,t.aliases)&&Ee(s.identityAliases??[],t.identityAliases??[])}function Ms(s,t,a){const{identityAliases:n,...o}=s;return a.length>0?{...o,aliases:t,identityAliases:a}:{...o,aliases:t}}function Se({label:s,names:t}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium text-heading",children:s}),e.jsx("ul",{className:"space-y-1",children:t.map(a=>e.jsx("li",{className:"text-sm text-secondary",children:a},a))})]})}function qe({id:s,issues:t}){return t.length===0?null:e.jsx("ul",{id:s,className:"mt-2 space-y-1","aria-label":"Name warnings",children:t.map(a=>e.jsx("li",{className:"text-sm text-caution",children:As(a)},`${a.field}:${a.index}`))})}function Ls({projectName:s,targetKey:t,published:a,activeRevision:n,publishedBrandNames:o,service:u=vs}){const{canWrite:m}=$e(),r=p.useId(),l=K({...ts({client:_,path:{name:s}}),enabled:m}),k=K({...as({client:_,path:{name:s}}),enabled:m}),q=l.data?.draft?.authoring.targets.find(d=>d.stableKey===t),P=a.identityAliases??[],O=q!==void 0&&l.data?.draft?.baseActiveRevision===n&&!ie(q,a),L=!l.isFetching&&!k.isPending,h=k.data,A=p.useMemo(()=>h?ns(h):o,[h,o]),[C,R]=p.useState(!1),[c,j]=p.useState(""),[M,D]=p.useState(""),[ne,v]=p.useState(a),[E,T]=p.useState(null),B=`${s}\0${t}`,[H,xe]=p.useState(B);H!==B&&(xe(B),R(!1),j(""),D(""),v(a),T(null));const re=p.useRef(B);re.current=B;const W=p.useMemo(()=>Ce(c),[c]),Y=p.useMemo(()=>Ce(M),[M]),pe=p.useMemo(()=>qs({aliases:W,identityAliases:Y,brandNames:A}),[W,Y,A]),Z=pe.filter(d=>d.field==="aliases"),X=pe.filter(d=>d.field==="identityAliases");function z(d){j(d.aliases.join(`
3
3
  `)),D((d.identityAliases??[]).join(`
4
- `)),v({aliases:[...d.aliases],identityAliases:[...d.identityAliases??[]]})}function g(d){return d.draft?d.draft.authoring.targets.find(S=>S.stableKey===t)??null:a}function J(){z(O?q:a),R(null),L(!0)}function y(d){d&&z(d),R({tone:"negative",text:x.conflict,review:!1})}const Y=We({mutationFn:async d=>{let S=await u.loadDraft(s);if(!S.draft){if(ie(d.names,a))return{outcome:"unchanged"};if(!ie(d.base,a))return{outcome:"conflict",latest:a};await u.createDraft(s,n),S=await u.loadDraft(s)}const U=S.draft;if(!U||!S.etag)throw new Error(x.failed);if(U.baseActiveRevision!==n)return{outcome:"stale"};const Q=U.authoring.targets.find($=>$.stableKey===t);return!Q||Q.status!=="included"?{outcome:"missing"}:ie(d.names,Q)?{outcome:"unchanged"}:ie(d.base,Q)?(await u.upsertTarget(s,S.etag,Ms(Q,d.names.aliases,d.names.identityAliases)),{outcome:"saved"}):{outcome:"conflict",latest:Q}},meta:{skipGlobalErrorToast:!0},onSuccess:(d,S)=>{if(S.openFor===re.current)switch(d.outcome){case"saved":L(!1),R({tone:"positive",text:x.saved,review:!0});return;case"unchanged":L(!1),R({tone:"positive",text:x.noChanges,review:!1});return;case"stale":R({tone:"negative",text:x.staleDraft,review:!0});return;case"missing":R({tone:"negative",text:x.missingFromDraft,review:!0});return;case"conflict":y(d.latest),l.refetch();return}},onError:(d,S)=>{if(S.openFor===re.current){if(bs(d)){y(null),l.refetch().then(U=>{U.isSuccess&&y(g(U.data))});return}R({tone:"negative",text:x.failed,review:!1})}}}),F=e.jsx(te,{to:"/projects/$projectName/portfolio",params:{projectName:s},className:"text-link underline-offset-2 hover:underline",children:x.review}),ee=a.aliases.length+P.length;return e.jsxs("section",{"aria-labelledby":"property-names",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("h2",{id:"property-names",className:"text-base font-semibold text-heading",children:x.heading}),e.jsx(I,{text:x.help})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{className:"supporting-copy",children:[ee," ",ee===1?"name":"names"]}),m&&!C?e.jsx(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",disabled:!T,onClick:J,children:x.edit}):null]})]}),E?e.jsxs("p",{role:E.tone==="negative"?"alert":"status",className:`mb-3 text-sm ${E.tone==="negative"?"text-negative":"text-positive"}`,children:[E.text,E.review?e.jsxs(e.Fragment,{children:[" ",F]}):null]}):O&&!C?e.jsxs("p",{role:"status",className:"mb-3 text-sm text-caution",children:[x.pending," ",F]}):null,C?e.jsxs("form",{className:"space-y-4","aria-label":"Edit names",onSubmit:d=>{d.preventDefault(),!Y.isPending&&Y.mutate({names:{aliases:W,identityAliases:G},base:ne,openFor:B})},children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:`${r}-names`,className:"block text-sm font-medium text-heading",children:x.names}),e.jsx("p",{id:`${r}-names-hint`,className:"text-sm text-secondary",children:x.namesHint}),e.jsx("textarea",{id:`${r}-names`,className:"mt-1 min-h-24 w-full rounded-md border border-strong bg-transparent px-3 py-2 text-sm text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400","aria-describedby":`${r}-names-hint${Z.length?` ${r}-names-issues`:""}`,value:c,onChange:d=>j(d.target.value)}),e.jsx(qe,{id:`${r}-names-issues`,issues:Z}),W.length===0?e.jsx("p",{className:"mt-2 text-sm text-caution",children:x.noNames}):null]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:`${r}-qualified`,className:"block text-sm font-medium text-heading",children:x.qualifiedNames}),e.jsx("p",{id:`${r}-qualified-hint`,className:"text-sm text-secondary",children:x.qualifiedHint}),e.jsx("textarea",{id:`${r}-qualified`,className:"mt-1 min-h-20 w-full rounded-md border border-strong bg-transparent px-3 py-2 text-sm text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400","aria-describedby":`${r}-qualified-hint ${r}-qualified-note${X.length?` ${r}-qualified-issues`:""}`,value:M,onChange:d=>D(d.target.value)}),e.jsx(qe,{id:`${r}-qualified-issues`,issues:X}),e.jsx("p",{id:`${r}-qualified-note`,className:"mt-2 max-w-3xl text-sm text-secondary",children:x.qualifiedNote})]}),e.jsx("p",{className:"text-sm text-secondary",children:x.draftOnly}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(rs,{type:"submit",className:"h-11 px-4 text-sm md:h-11",disabled:Y.isPending,children:Y.isPending?x.saving:x.save}),e.jsx(w,{type:"button",variant:"ghost",className:"h-11 px-4 text-sm md:h-11",disabled:Y.isPending,onClick:()=>{L(!1),R(null)},children:x.cancel})]})]}):ee===0?e.jsx("p",{className:"text-sm text-secondary",children:x.noNames}):e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.aliases.length>0?e.jsx(Se,{label:x.names,names:a.aliases}):null,P.length>0?e.jsx(Se,{label:x.qualifiedNames,names:P}):null]})]})}const me=50,b={branded:{headline:"When they know your name",technical:"Branded queries"},"non-brand":{headline:"When they don't",technical:"Non-brand queries"}},Ls={plan_v1:"Setup update required",no_completed_run:"No completed measurement yet",no_population:"No queries of this type are assigned",evidence_incomplete:"Source evidence is incomplete",identity_ambiguous:xs,not_applicable:"Not applicable for this Property"},Ae={complete:{label:"Measured",tone:"positive"},partial:{label:"Partly measured",tone:"caution"},running:{label:"Measuring now",tone:"neutral"},queued:{label:"Measurement queued",tone:"neutral"},failed:{label:"Measurement failed",tone:"negative"},not_measured:{label:"Not measured",tone:"neutral"}},Me={assigned:{label:"Matches this Property",tone:"positive"},sibling:{label:"Matches another Property",tone:"caution"},ownedUnmapped:{label:"Site URL not in a Property",tone:"caution"},external:{label:"External URL",tone:"neutral"},ambiguous:{label:"Matches multiple Properties",tone:"caution"},invalid:{label:"Invalid URL",tone:"negative"}};function Rs(s){return[...s].sort((t,a)=>+(a.classification==="assigned")-+(t.classification==="assigned"))}function $s(s){return`${s.expectedSlotId}:${s.usageEdgeId}`}function Is({row:s}){return s.mentioned===null?e.jsxs("span",{className:"inline-flex flex-col items-start gap-0.5",children:[e.jsx(V,{tone:"neutral",children:"Not measured"}),e.jsx("span",{className:"text-xs text-muted",children:"No mention signal for this Property"})]}):e.jsx(V,{tone:s.mentioned?"positive":"neutral",children:s.mentioned?"Mentioned":"Not mentioned"})}const ks="—";function Bs({row:s}){return s.cited===null?e.jsxs("span",{className:"inline-flex flex-col items-start gap-0.5",children:[e.jsx(V,{tone:"neutral",children:"Not measured"}),e.jsx("span",{className:"text-xs text-muted",children:"Sources were not fully captured"})]}):e.jsx(V,{tone:s.cited?"positive":"neutral",children:s.cited?"Cited":"Not cited"})}function _s({row:s}){return s.cited===null&&s.sources.length===0?e.jsx("p",{className:"py-2 text-sm text-secondary",children:"The sources for this answer were not fully captured, so none can be shown."}):s.sources.length===0?e.jsx("p",{className:"py-2 text-sm text-secondary",children:"This answer returned no source URLs at all."}):e.jsxs("details",{className:"mt-2","data-answer-sources":!0,children:[e.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-sm text-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[Fe," (",s.sources.length,")"]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsxs("caption",{className:"sr-only",children:["Source URLs for ",s.queryText]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Match"}),e.jsx("th",{children:"URL"})]})}),e.jsx("tbody",{children:Rs(s.sources).map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx(V,{tone:Me[t.classification].tone,children:Me[t.classification].label})}),e.jsx("td",{children:e.jsx(Be,{url:t.sourceUrl})})]},t.sourceUrl))})]})})]})}function Qe({project:s,targetKey:t,resultId:a}){const n=K({...fs({client:_,path:{name:s},query:{targetKey:t,resultId:a}})});if(n.isPending)return e.jsx("p",{className:"py-2 text-sm text-secondary",role:"status","aria-live":"polite",children:"Loading the answer…"});if(n.isError)return e.jsx("p",{className:"py-2 text-sm text-secondary",role:"alert",children:"Could not load this answer."});const o=n.data?.answer;return o==null||o.trim()===""?e.jsx("p",{className:"py-2 text-sm text-secondary",children:"This answer was measured, but its text was not stored."}):e.jsx("div",{className:"py-2",children:e.jsx(Ps,{headingLevel:4,copyable:!0,children:o})})}function ue(s){return Ls[s.reason]??"Not measured"}function he({metric:s,signal:t,emphasis:a=!1}){if(s.state==="unavailable")return e.jsxs("span",{className:"inline-flex flex-col gap-0.5",children:[e.jsx("span",{className:a?"text-lg font-semibold text-secondary":"text-sm font-medium text-secondary",children:"Not measured"}),e.jsx("span",{className:"text-sm text-secondary",children:ue(s)})]});const n=_e(s.value),o=s.numerator===void 0||s.denominator===void 0?null:`${s.numerator} of ${s.denominator}`,u=Oe(s,t);return e.jsxs("span",{className:"inline-flex flex-col gap-0.5 tabular-nums",children:[e.jsx("span",{className:a?"text-lg font-semibold text-heading":"text-sm font-medium text-primary",children:n}),o?e.jsx("span",{className:"text-xs text-muted",children:o}):null,u?e.jsx("span",{className:"text-xs text-muted",children:u}):null]})}function Te(s,t,a){return us({client:_,path:{name:s},query:{scope:"property",targetKey:t,queryClass:a}})}function Le(s){return s?.properties.items.at(0)}function Os({measuredAt:s,unmeasuredReason:t,queryClass:a}){const n=s===void 0?null:s===null?"No completed sweep yet":`Measured ${gs(js(s))}`;return n===null&&t===void 0?null:e.jsxs("p",{className:"supporting-copy",children:[[n,t].filter(Boolean).join(" · "),n!==null&&t===void 0?` · ${b[a].technical.toLocaleLowerCase()} only`:""]})}function Fs({project:s,groups:t}){return t.length===0?null:e.jsxs("section",{"aria-labelledby":"property-market",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Competitive comparison"}),e.jsxs("h2",{id:"property-market",className:"text-base font-semibold text-heading",children:["Measured at the market level",e.jsx(I,{text:"Competitors are attached to a market rather than to a single Property, because one building has nobody to be compared against. Share of voice and competitor pressure are reported for the market this Property sits in."})]})]}),e.jsx(w,{asChild:!0,type:"button",size:"sm",variant:"outline",children:e.jsx(te,{to:"/projects/$projectName",params:{projectName:s},search:a=>ce(oe(a),{measurementScope:"project"}),children:"Open measurement overview"})})]}),e.jsx("ul",{className:"flex flex-wrap gap-2",children:t.map(a=>e.jsxs("li",{className:"rounded-md border border-default px-3 py-1.5 text-sm text-strong",children:[a.label,e.jsxs("span",{className:"ml-2 text-xs text-muted",children:[a.competitors.length," ",a.competitors.length===1?"competitor":"competitors"]})]},a.stableKey))})]})}function de({label:s,metric:t,signal:a,failed:n=!1}){if(t===void 0)return e.jsxs("div",{className:"aeo-hero-row",children:[e.jsx("p",{className:"aeo-hero-row-label",children:s}),e.jsx("p",{className:"aeo-hero-row-value text-base font-semibold text-secondary",children:n?"Unavailable":"…"}),n?e.jsx("div",{}):e.jsx("div",{className:"aeo-hero-row-bar","aria-hidden":"true"}),e.jsx("p",{className:"aeo-hero-row-detail",children:n?"Could not be loaded":"Loading"})]});if(t.state==="unavailable"){const l=ue(t);return e.jsxs("div",{className:"aeo-hero-row",children:[e.jsx("p",{className:"aeo-hero-row-label",children:s}),e.jsx("p",{className:"aeo-hero-row-value text-base font-semibold text-secondary",children:"Not measured"}),e.jsx("div",{}),e.jsx("p",{className:"aeo-hero-row-detail",children:l==="Not measured"?"":l})]})}const{figure:o,sign:u}=ys(_e(t.value)),m=t.numerator===void 0||t.denominator===void 0?null:`${t.numerator} of ${t.denominator}`,r=Oe(t,a);return e.jsxs("div",{className:"aeo-hero-row",children:[e.jsx("p",{className:"aeo-hero-row-label",children:s}),e.jsxs("p",{className:"aeo-hero-row-value text-heading",children:[o,u?e.jsx("span",{className:"text-faint",children:u}):null]}),e.jsx("div",{className:"aeo-hero-row-bar","aria-hidden":"true",children:e.jsx("div",{className:"metric-card-bar-fill progress-fill-neutral",style:{width:`${t.value*100}%`}})}),e.jsxs("p",{className:"aeo-hero-row-detail tabular-nums",children:[m??"",r?e.jsx("span",{className:"block",children:r}):null]})]})}function Us({branded:s,nonBrand:t,brandedFailed:a=!1,nonBrandFailed:n=!1}){return e.jsxs("section",{"aria-labelledby":"property-coverage-hero",children:[e.jsx("h2",{id:"property-coverage-hero",className:"sr-only",children:"Coverage for this Property"}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Non-brand · the demand to earn"}),e.jsx(de,{label:"Mentioned",metric:t?.mentionCoverage,signal:"mentioned",failed:n}),e.jsx(de,{label:"Cited",metric:t?.citationCoverage,signal:"cited",failed:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Branded · already named"}),e.jsx(de,{label:"Mentioned",metric:s?.mentionCoverage,signal:"mentioned",failed:a}),e.jsx(de,{label:"Cited",metric:s?.citationCoverage,signal:"cited",failed:a})]})]})]})}function Qs({branded:s,nonBrand:t,brandedError:a,nonBrandError:n,onRetry:o}){const u=[{queryClass:"branded",row:s,isError:a},{queryClass:"non-brand",row:t,isError:n}];return e.jsxs("section",{"aria-labelledby":"property-brand-contrast",children:[e.jsx("div",{className:"section-head section-head-inline",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"The gap"}),e.jsxs("h2",{id:"property-brand-contrast",className:"text-base font-semibold text-heading",children:["Named versus not named",e.jsx(I,{text:"Branded queries already contain your name, so an answer engine has an easy path back to you. Non-brand queries describe the need instead, and that is the demand you have to earn. Each row is measured only over the queries assigned to this Property in that class; a class with no assigned query reads Not measured rather than 0%."})]})]})}),e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[560px]",children:[e.jsx("caption",{className:"sr-only",children:"Mention and citation coverage for this Property, split by query class"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Query type"}),e.jsx("th",{children:"Mentioned in the answer"}),e.jsx("th",{children:"Cited as a source"})]})}),e.jsx("tbody",{children:u.map(({queryClass:m,row:r,isError:l})=>e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("span",{className:"block font-medium text-heading",children:b[m].headline}),e.jsx("span",{className:"mt-0.5 block text-xs text-muted",children:b[m].technical}),r&&l?e.jsxs("span",{className:"mt-2 flex flex-wrap items-center gap-2 text-sm text-caution",children:[e.jsx("span",{role:"status",children:"Refresh failed."}),e.jsxs(w,{type:"button",size:"sm",variant:"ghost",className:"h-11 px-3 text-sm md:h-11",onClick:()=>o(m),children:["Retry ",b[m].technical.toLocaleLowerCase()]})]}):null]}),r?e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx(he,{metric:r.mentionCoverage,signal:"mentioned",emphasis:!0})}),e.jsx("td",{children:e.jsx(he,{metric:r.citationCoverage,signal:"cited",emphasis:!0})})]}):l?e.jsx("td",{colSpan:2,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsxs("span",{role:"alert",children:["Could not load ",b[m].technical.toLocaleLowerCase(),"."]}),e.jsxs(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>o(m),children:["Retry ",b[m].technical.toLocaleLowerCase()]})]})}):e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx("span",{className:"text-sm text-secondary",children:"Loading…"})}),e.jsx("td",{children:e.jsx("span",{className:"text-sm text-secondary",children:"Loading…"})})]})]},m))})]})})]})}function Ks({row:s,queryClass:t,isError:a}){return e.jsxs("section",{"aria-labelledby":"property-providers",className:"page-section-divider",children:[e.jsx("div",{className:"section-head section-head-inline",children:e.jsx("div",{children:e.jsxs("h2",{id:"property-providers",className:"text-base font-semibold text-heading",children:["Which engines answer for this Property",e.jsx(I,{text:"Each row is measured over the queries that engine actually answered for this Property, so the rows are a split of the same population rather than parts that add up to the Property total. An engine that answered nothing for this Property is absent instead of shown at 0%."})]})})}),s===void 0&&a?e.jsxs("p",{className:"text-sm text-secondary",children:["Details for ",b[t].technical.toLocaleLowerCase()," are unavailable. Retry that query type above."]}):s===void 0?e.jsx("p",{className:"text-sm text-secondary",children:"Loading…"}):s.providers.length===0?e.jsxs("p",{className:"text-sm text-secondary",children:["No answer engine has measured ",b[t].technical.toLocaleLowerCase()," for this Property.",s.mentionCoverage.state==="unavailable"?` ${ue(s.mentionCoverage)}.`:""]}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[520px]",children:[e.jsx("caption",{className:"sr-only",children:"Per-engine mention and citation coverage"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Engine"}),e.jsx("th",{children:"Mentioned"}),e.jsx("th",{children:"Cited"})]})}),e.jsx("tbody",{children:s.providers.map(n=>e.jsxs("tr",{children:[e.jsx("td",{className:"font-medium text-heading",children:n.provider}),e.jsx("td",{children:e.jsx(he,{metric:n.mentionCoverage,signal:"mentioned"})}),e.jsx("td",{children:e.jsx(he,{metric:n.citationCoverage,signal:"cited"})})]},n.provider))})]})})]})}function Vs(s){const t=s.questions.join(" · ");return s.questionsTruncated?`${t} +${s.questionTotal-s.questions.length} more`:t}function Ds({project:s,targetKey:t,queryClass:a}){const n=K({...ps({client:_,path:{name:s},query:{targetKey:t,queryClass:a}})});if(n.isPending||n.isError)return null;const o=n.data?.competitors??[],u=n.data?.basis;return e.jsxs("section",{"aria-labelledby":"property-named-instead",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsx("div",{children:e.jsxs("h2",{id:"property-named-instead",className:"text-base font-semibold text-heading",children:["Named instead of this Property",e.jsx(I,{text:"Counted from the answers that did not name this Property, so a name here is one an engine recommended in its place. Occurrences count answers, not positions: an engine naming the same rival in two answers counts twice, and one naming it twice in a single answer counts once."})]})}),o.length>0?e.jsxs("p",{className:"supporting-copy",children:[n.data?.total??o.length," named"]}):null]}),o.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"No rival was named in the answers this Property missed. Nothing to compete with here yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsx("caption",{className:"sr-only",children:"Names the engines gave instead of this Property"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Named"}),e.jsx("th",{children:"Answers"}),e.jsx("th",{children:"Engines"}),e.jsx("th",{children:"Queries"})]})}),e.jsx("tbody",{children:o.map(m=>e.jsxs("tr",{children:[e.jsx("td",{className:"text-strong",children:m.name}),e.jsx("td",{className:"tabular-nums text-secondary",children:m.occurrences}),e.jsxs("td",{className:"text-secondary",children:[m.providers.join(", "),m.providersTruncated?` +${m.providerTotal-m.providers.length}`:""]}),e.jsx("td",{className:"text-right",children:e.jsxs("span",{className:"inline-flex items-center justify-end gap-1",children:[e.jsx("span",{className:"tabular-nums text-secondary",children:m.questionTotal}),e.jsx(I,{text:Vs(m)})]})})]},m.name))})]})}),u?.state==="available"?e.jsxs("p",{className:"supporting-copy mt-2",children:[u.targetMissResults," of ",u.answeredResults," answers to ",b[a].technical.toLocaleLowerCase()," did not name this Property."]}):null]})]})}function Hs({questions:s,queryClass:t}){return e.jsxs("section",{"aria-labelledby":"property-questions",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsx("div",{children:e.jsxs("h2",{id:"property-questions",className:"text-base font-semibold text-heading",children:[b[t].technical," assigned to this Property"]})}),e.jsxs("p",{className:"supporting-copy",children:[s.length," assigned"]})]}),s.length===0?e.jsxs("p",{className:"text-sm text-secondary",children:["No ",b[t].technical.toLocaleLowerCase()," are assigned. Add one in advanced measurement setup to measure this class."]}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsx("caption",{className:"sr-only",children:"Queries assigned to this Property"}),e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("th",{children:"Query"})})}),e.jsx("tbody",{children:s.map(a=>e.jsx("tr",{children:e.jsx("td",{className:"text-secondary",children:a})},a))})]})})]})}function Ws({urls:s}){return e.jsxs("section",{"aria-labelledby":"property-urls",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsx("div",{children:e.jsxs("h2",{id:"property-urls",className:"text-base font-semibold text-heading",children:["URLs that count as this Property",e.jsx(I,{text:"A cited source URL is credited to this Property when it matches one of these. The most specific matcher wins, so a URL covered by two Properties at the same specificity is flagged for review instead of being credited to either."})]})}),e.jsxs("p",{className:"supporting-copy",children:[s.length," configured"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"No URLs are configured for this Property."}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsx("caption",{className:"sr-only",children:"URL matchers configured for this Property"}),e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("th",{children:"URL"})})}),e.jsx("tbody",{children:s.map(t=>e.jsx("tr",{children:e.jsx("td",{className:"break-all text-secondary",children:t})},t))})]})})]})}const se={heading:"Cited on other queries",help:"Answers to queries assigned to other properties that still cited one of this Property’s own pages. This Property was not measured on those queries, so these answers are not in its Mentioned or Cited rates.",notCounted:"not in this Property’s rates",empty:"No answer to a query assigned elsewhere cited this Property’s pages in the displayed measurement.",loadError:"Citations from other queries could not be loaded.",partlySaved:"Sources partly saved"};function zs({project:s,targetKey:t,queryClass:a,runId:n,targetLabels:o}){const[u,m]=p.useState(new Set),r={client:_,path:{name:s},query:{targetKey:t,queryClass:a,shape:Ie["other-queries"],limit:me,...n?{runId:n}:{}}},l=Re({...ke(r),initialPageParam:r,getNextPageParam:h=>h.otherQueries?.nextCursor?{path:r.path,query:{...r.query,cursor:h.otherQueries.nextCursor}}:void 0}),k=l.data?.pages??[];if(k[0]?.measurement.state==="not_measured")return null;const q=k.flatMap(h=>h.otherQueries?.items??[]),P=k[0]?.otherQueries?.totalEstimate??q.length,O=h=>`${h.expectedSlotId}:${h.queryClass}`,T=b[a].technical.toLocaleLowerCase();return e.jsxs("section",{"aria-labelledby":"property-other-queries",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("h2",{id:"property-other-queries",className:"text-base font-semibold text-heading",children:se.heading}),e.jsx(I,{text:se.help})]}),l.data?e.jsxs("p",{className:"supporting-copy",children:[P," ",P===1?"answer":"answers"," · ",T," · ",se.notCounted]}):null]}),l.isPending?e.jsx("p",{className:"text-sm text-secondary",children:"Loading…"}):l.isError&&q.length===0?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsx("span",{role:"alert",children:se.loadError}),e.jsx(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>{l.refetch()},children:"Retry"})]}):q.length===0?e.jsx("p",{className:"text-sm text-secondary",children:se.empty}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[640px]",children:[e.jsx("caption",{className:"sr-only",children:"Answers to other properties’ queries that cited this Property’s pages"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Query"}),e.jsx("th",{children:"Assigned to"}),e.jsx("th",{children:"Pages cited"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Answer"})})]})}),e.jsx("tbody",{children:q.map(h=>{const A=O(h),C=u.has(A),L=`property-other-query-${encodeURIComponent(A)}`;return e.jsxs(p.Fragment,{children:[e.jsxs("tr",{children:[e.jsxs("td",{className:"text-secondary",children:[e.jsx("span",{className:"block text-sm font-medium text-heading",children:h.queryText}),e.jsx("span",{className:"mt-1 block text-xs text-muted",children:[h.provider,h.location].filter(Boolean).join(" · ")})]}),e.jsx("td",{children:e.jsx("ul",{className:"space-y-1",children:h.assignedTargetKeys.map(c=>e.jsx("li",{children:e.jsx(te,{to:"/projects/$projectName/properties/$targetKey",params:{projectName:s,targetKey:c},search:oe,className:"text-sm text-link hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:o.get(c)??c})},c))})}),e.jsxs("td",{children:[e.jsx("ul",{className:"space-y-1",children:h.sources.map(c=>e.jsx("li",{className:"min-w-0",children:e.jsx(Be,{url:c.sourceUrl})},c.sourceUrl))}),h.sourcesTruncated?e.jsxs("span",{className:"mt-1 block text-xs text-muted",children:[h.sourceCount," pages in total"]}):null,h.evidenceComplete?null:e.jsx("span",{className:"mt-1 block text-xs text-muted",children:se.partlySaved})]}),e.jsx("td",{className:"text-right",children:e.jsx(w,{type:"button",size:"sm",variant:"ghost",className:"h-auto min-h-11 max-w-full whitespace-normal py-2 text-left md:h-auto","aria-expanded":C,"aria-label":C?`Hide the answer for ${h.queryText}`:`Read the answer for ${h.queryText}`,"aria-controls":C?L:void 0,onClick:()=>m(c=>{const j=new Set(c);return j.delete(A)||j.add(A),j}),children:C?"Hide answer":"Read answer"})})]}),C?e.jsx("tr",{children:e.jsx("td",{id:L,colSpan:4,className:"bg-surface-subtle px-4",children:e.jsx(Qe,{project:s,targetKey:h.assignedTargetKeys[0],resultId:h.observationId})})}):null]},A)})})]})}),l.hasNextPage?e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsxs("span",{children:["Showing ",q.length," of ",P]}),e.jsx(w,{size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",disabled:l.isFetchingNextPage,onClick:()=>{l.fetchNextPage()},children:l.isFetchingNextPage?"Loading…":`Show ${me} more`})]}):null]})]})}function Ys(s,t){const a=[s.marketKey?t??"the selected market":null,s.provider?`the ${s.provider} answer engine`:null,s.model?`the ${s.model} model`:null,s.location?`location ${s.location}`:null,s.from||s.to?"a date range":null,s.measurementRunId?"a saved sweep":null].filter(n=>n!==null);return a.length===0?null:`AI Visibility is filtered to ${a.join(", ")}. This page shows the latest measurement for ${ws.allMarkets.toLocaleLowerCase()} and answer engines.`}function rt(){const{projectName:s,targetKey:t}=ze({strict:!1}),a=Ye(),n=Ge({strict:!1}),o=p.useMemo(()=>ve(n),[n]),[u,m]=p.useState(new Set),r=s??"",l=t??"",k=!!r&&!!l,q=p.useMemo(()=>is("portfolio",os(ls())),[]),P=k&&q,{canWrite:O}=$e(),T=K({...ds({client:_,path:{name:r}}),enabled:P}),h=T.data?.active?.plan,A=h?.schemaVersion===2?h:null,C=o.queryClass==="branded"||o.queryClass==="non-brand"?o.queryClass:null,L=i=>A?.assignments.some(f=>f.targetKey===l&&f.queryClass===i)??!1,c=C??(!L("non-brand")&&L("branded")?"branded":"non-brand");p.useEffect(()=>{!A||C||a({to:".",replace:!0,search:i=>ce(i,{queryClass:c})})},[A,C,c,a]);const j=K({...Te(r,l,"branded"),enabled:P}),M=K({...Te(r,l,"non-brand"),enabled:P}),D=Le(j.data),ne=Le(M.data),v=c==="branded"?j.data:M.data,E=c==="branded"?D:ne,B=(c==="branded"?j.isError:M.isError)&&E===void 0,H=v?.measurement.displayedRunId;cs(r,{view:"property",selection:{mode:"advanced",scope:"property",scopeKey:l,queryClass:c,limit:10,...H?{runId:H}:{}}});const xe=E?.mentionCoverage.state==="unavailable"?ue(E.mentionCoverage):void 0,re=v===void 0?void 0:v.measurement.completedAt??null,W=v!==void 0&&(v.measurement.state==="not_measured"||v.nextAction.kind==="run_measurement"),G=i=>ce(oe(i),{measurementScope:"property",measurementScopeKey:l,queryClass:c,measurementRunId:void 0,measurementRevision:void 0,measurementTo:void 0}),Z=K({...ms({client:_,path:{name:r},query:hs(ve(G(n)))}),enabled:P&&W,retry:!1}).data,X=Z!==void 0&&Z.selection.measurement.measuredRevision!==null&&(Z.populations.find(i=>i.queryClass===c)?.summary.queryCount??0)>0,z={client:_,path:{name:r},query:{targetKey:l,queryClass:c,shape:Ie.answers,limit:me,...H?{runId:H}:{}}},g=Re({...ke(z),enabled:P&&v!==void 0,initialPageParam:z,getNextPageParam:i=>i.answers?.nextCursor?{path:z.path,query:{...z.query,cursor:i.answers.nextCursor}}:void 0}),J=T.data?.active??null,y=J?.plan.schemaVersion===2?J.plan:null,Y=J!==null&&y===null,F=y?.targets.find(i=>i.stableKey===l)??null,ee=Ys(o,y?.reportingScopes?.find(i=>i.stableKey===o.marketKey)?.label),d=p.useMemo(()=>{if(!y)return[];const i=new Map(y.querySnapshots.map(f=>[f.queryId,f.queryText]));return[...new Set(y.assignments.filter(f=>f.targetKey===l&&f.queryClass===c).flatMap(f=>{const N=i.get(f.queryId);return N===void 0?[]:[N]}))].sort((f,N)=>f.localeCompare(N))},[y,l,c]),S=p.useMemo(()=>F?.urlMatchers.map(Ns)??[],[F]),U=p.useMemo(()=>new Map((y?.targets??[]).map(i=>[i.stableKey,i.label])),[y]),Q=p.useMemo(()=>y?.groups.filter(i=>i.targetKeys.includes(l))??[],[y,l]),$=p.useMemo(()=>(g.data?.pages??[]).flatMap(N=>N.answers?.items??[]),[g.data]),ye=g.data?.pages[0]?.answers?.totalEstimate??$.length,Ke=(g.data?.pages??[]).length>0&&(g.data?.pages??[]).every(i=>i.answers===void 0),Ve=g.data?.pages[0]?.measurement.state,le=e.jsxs(te,{to:"/projects/$projectName",params:{projectName:r},search:oe,className:"inline-flex items-center gap-1 text-xs text-muted hover:text-strong",children:[e.jsx(Cs,{className:"size-3.5","aria-hidden":"true"}),"Back to AI Visibility"]});if(!k)return e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Missing project name or Property key in URL."})});if(!q)return e.jsxs("div",{className:"page-container space-y-3",children:[le,e.jsx("p",{className:"text-sm text-muted",children:"This view is not available here."})]});if(T.isPending&&!T.isError)return e.jsx("div",{className:"page-container",children:e.jsxs("div",{role:"status","aria-live":"polite",children:[e.jsx("span",{className:"sr-only",children:"Loading Property"}),e.jsx("div",{className:"h-32 animate-pulse rounded-md bg-surface-subtle","aria-hidden":"true"})]})});const De=T.isError&&T.data===void 0,ge=j.isError&&j.data===void 0,je=M.isError&&M.data===void 0;return De||ge&&je?e.jsxs("div",{className:"page-container space-y-3",children:[le,e.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Could not load this Property."}),e.jsx(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>{T.refetch(),j.refetch(),M.refetch()},children:"Try again"})]}):!y||!F?e.jsxs("div",{className:"page-container space-y-3",children:[le,e.jsx("p",{role:"status",className:"text-sm text-secondary",children:y?"This Property is not in the published setup. It may have been renamed or removed.":"A Property page needs a published advanced measurement setup. Republish setup from the project Portfolio tab."}),e.jsx(w,{asChild:!0,type:"button",variant:"outline",className:"h-11 px-4 text-sm md:h-11",children:e.jsx(te,{to:"/projects/$projectName/portfolio",params:{projectName:r},children:O?Y?"Republish setup":"Open measurement setup":"View measurement setup"})})]}):e.jsxs("div",{className:"page-container space-y-8",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[le,e.jsx("h1",{className:"page-title mt-2",children:F.label}),e.jsxs("p",{className:"page-subtitle",children:["Property in ",r,ee?e.jsxs(e.Fragment,{children:[" · Filters not applied ",e.jsx(I,{text:ee})]}):null]})]}),e.jsxs("div",{className:"page-header-right",children:[v?e.jsx(V,{tone:Ae[v.measurement.state].tone,children:Ae[v.measurement.state].label}):null,E&&E.flags>0?e.jsxs(V,{tone:"caution",children:[E.flags," flagged"]}):null]})]}),e.jsx(Us,{branded:D,nonBrand:ne,brandedFailed:ge,nonBrandFailed:je}),e.jsx(Qs,{branded:D,nonBrand:ne,brandedError:j.isError,nonBrandError:M.isError,onRetry:i=>{i==="branded"?j.refetch():M.refetch()}}),W?e.jsxs("section",{className:"flex flex-wrap items-center justify-between gap-3 border-y border-default py-4","aria-label":"Measurement next step",children:[e.jsx("p",{className:"text-sm text-secondary",children:we()?Ne:O?`Run a measurement from the project overview to collect this Property’s coverage and source evidence.${X?" AI Visibility still shows the last results.":""}`:"This Property needs a new measurement before coverage and source evidence are available."}),e.jsx(w,{asChild:!0,type:"button",className:"h-11 px-4 text-sm md:h-11",children:e.jsx(te,{to:"/projects/$projectName",params:{projectName:r},search:X?G:oe,children:X?"See the last results":O?"Go to AI Visibility":"View AI Visibility"})})]}):null,e.jsxs("div",{className:"flex flex-wrap items-end gap-4 border-y border-default py-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"property-query-class",className:"block text-sm font-medium text-heading",children:"Query type"}),e.jsxs("select",{id:"property-query-class",value:c,onChange:i=>{const f=i.target.value==="branded"?"branded":"non-brand";a({to:".",search:N=>ce(N,{queryClass:f})})},className:"h-11 rounded-md border border-default bg-surface px-3 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-mono-400",children:[e.jsx("option",{value:"non-brand",children:b["non-brand"].technical}),e.jsx("option",{value:"branded",children:b.branded.technical})]})]}),e.jsx(Os,{measuredAt:re,unmeasuredReason:xe,queryClass:c})]}),e.jsx(Ks,{row:E,queryClass:c,isError:B}),e.jsx(Ds,{project:r,targetKey:l,queryClass:c}),e.jsx(Hs,{questions:d,queryClass:c}),e.jsx(Ts,{projectName:r,targetKey:l,published:F,activeRevision:J.revision,publishedBrandNames:y.identities.projectBrand.names}),e.jsx(Ws,{urls:S}),e.jsx(Fs,{project:r,groups:Q}),e.jsxs("section",{"aria-labelledby":"property-evidence",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsx("div",{children:e.jsxs("h2",{id:"property-evidence",className:"text-base font-semibold text-heading",children:["Answers the engines gave",e.jsx(I,{text:"One row per answer an engine gave for the queries assigned to this Property in the displayed measurement. Mentioned and cited are independent: an answer can name this Property without linking it, or link it without naming it. Answers that did neither are listed first, because those are what a gap is made of. Where the answer text was not stored the mention reads Not measured, never a zero. Open a row to read what the engine actually said, followed by the source URLs it returned, this Property's own first. The answer is where a miss becomes actionable: a query this Property was not named in may still have named a sibling building."})]})}),$.length>0?e.jsxs("p",{className:"supporting-copy",children:[$.length," of ",ye]}):null]}),B?e.jsxs("p",{className:"text-sm text-secondary",children:["Evidence for ",b[c].technical.toLocaleLowerCase()," is unavailable. Retry that query type above."]}):g.isPending&&$.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"Loading evidence…"}):g.isError&&$.length===0?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsx("span",{role:"alert",children:"Evidence could not be loaded."}),e.jsx(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>{g.refetch()},children:"Retry evidence"})]}):Ve==="not_measured"?e.jsx("p",{className:"text-sm text-secondary",children:we()?Ne:"Not measured yet. Run a measurement to collect the answers for this Property."}):Ke?e.jsx("p",{role:"alert",className:"text-sm text-caution",children:"This measurement was returned in an older format, so the answers cannot be shown here. The numbers above are unaffected."}):$.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"No answers matched this Property in the displayed measurement."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"property-answer-table-container overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table property-evidence-table",children:[e.jsx("caption",{className:"sr-only",children:"Answers measured for this Property"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Query"}),e.jsx("th",{children:"Mentioned in the answer"}),e.jsx("th",{children:"Cited as a source"}),e.jsx("th",{children:"Sources"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Sources detail"})})]})}),e.jsx("tbody",{children:$.map(i=>{const f=$s(i),N=u.has(f),be=`property-answer-${encodeURIComponent(f)}`;return e.jsxs(p.Fragment,{children:[e.jsxs("tr",{className:"property-answer-summary",children:[e.jsxs("td",{className:"text-secondary",children:[e.jsx("h3",{className:"text-sm font-medium text-heading",children:i.queryText}),e.jsx("span",{className:"mt-1 block text-xs text-muted",children:[i.provider,i.location].filter(Boolean).join(" · ")}),i.historical||i.bridged?e.jsx("span",{className:"mt-1 flex",children:e.jsx(V,{tone:"caution",children:"Historical"})}):null]}),e.jsxs("td",{children:[e.jsx("span",{className:"property-evidence-mobile-label","aria-hidden":"true",children:"Mentioned"}),e.jsx(Is,{row:i})]}),e.jsxs("td",{children:[e.jsx("span",{className:"property-evidence-mobile-label","aria-hidden":"true",children:"Cited"}),e.jsx(Bs,{row:i})]}),e.jsxs("td",{className:"tabular-nums text-secondary",children:[e.jsx("span",{className:"property-evidence-mobile-label","aria-hidden":"true",children:Fe}),i.cited===null?ks:i.sources.length]}),e.jsx("td",{className:"text-right",children:e.jsx(w,{type:"button",size:"sm",variant:"ghost",className:"h-auto min-h-11 max-w-full whitespace-normal py-2 text-left md:h-auto","aria-expanded":N,"aria-label":N?`Hide the answer for ${i.queryText}`:`Read the answer for ${i.queryText}`,"aria-controls":N?be:void 0,onClick:()=>m(He=>{const fe=new Set(He);return fe.delete(f)||fe.add(f),fe}),children:N?"Hide answer":"Read answer"})})]}),N?e.jsx("tr",{className:"property-answer-detail",children:e.jsxs("td",{id:be,colSpan:5,className:"bg-surface-subtle px-4",children:[e.jsx(Qe,{project:r,targetKey:l,resultId:i.observationId}),e.jsx(_s,{row:i})]})}):null]},f)})})]})}),g.hasNextPage?e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsxs("span",{children:["Showing ",$.length," of ",ye]}),g.isFetchNextPageError?e.jsx("span",{role:"alert",children:"Could not load more evidence."}):null,e.jsx(w,{size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",disabled:g.isFetchingNextPage,onClick:()=>{g.fetchNextPage()},children:g.isFetchingNextPage?"Loading…":g.isFetchNextPageError?"Retry more evidence":`Show ${me} more`})]}):null]})]}),v?e.jsx(zs,{project:r,targetKey:l,queryClass:c,runId:H,targetLabels:U}):null]})}export{Me as EVIDENCE_LABELS,rt as MeasurementPropertyPage,se as OTHER_QUERIES_COPY};
4
+ `)),v({aliases:[...d.aliases],identityAliases:[...d.identityAliases??[]]})}function g(d){return d.draft?d.draft.authoring.targets.find(S=>S.stableKey===t)??null:a}function J(){z(O?q:a),T(null),R(!0)}function y(d){d&&z(d),T({tone:"negative",text:x.conflict,review:!1})}const G=We({mutationFn:async d=>{let S=await u.loadDraft(s);if(!S.draft){if(ie(d.names,a))return{outcome:"unchanged"};if(!ie(d.base,a))return{outcome:"conflict",latest:a};await u.createDraft(s,n),S=await u.loadDraft(s)}const U=S.draft;if(!U||!S.etag)throw new Error(x.failed);if(U.baseActiveRevision!==n)return{outcome:"stale"};const Q=U.authoring.targets.find($=>$.stableKey===t);return!Q||Q.status!=="included"?{outcome:"missing"}:ie(d.names,Q)?{outcome:"unchanged"}:ie(d.base,Q)?(await u.upsertTarget(s,S.etag,Ms(Q,d.names.aliases,d.names.identityAliases)),{outcome:"saved"}):{outcome:"conflict",latest:Q}},meta:{skipGlobalErrorToast:!0},onSuccess:(d,S)=>{if(S.openFor===re.current)switch(d.outcome){case"saved":R(!1),T({tone:"positive",text:x.saved,review:!0});return;case"unchanged":R(!1),T({tone:"positive",text:x.noChanges,review:!1});return;case"stale":T({tone:"negative",text:x.staleDraft,review:!0});return;case"missing":T({tone:"negative",text:x.missingFromDraft,review:!0});return;case"conflict":y(d.latest),l.refetch();return}},onError:(d,S)=>{if(S.openFor===re.current){if(bs(d)){y(null),l.refetch().then(U=>{U.isSuccess&&y(g(U.data))});return}T({tone:"negative",text:x.failed,review:!1})}}}),F=e.jsx(te,{to:"/projects/$projectName/portfolio",params:{projectName:s},className:"text-link underline-offset-2 hover:underline",children:x.review}),ee=a.aliases.length+P.length;return e.jsxs("section",{"aria-labelledby":"property-names",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("h2",{id:"property-names",className:"text-base font-semibold text-heading",children:x.heading}),e.jsx(I,{text:x.help})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{className:"supporting-copy",children:[ee," ",ee===1?"name":"names"]}),m&&!C?e.jsx(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",disabled:!L,onClick:J,children:x.edit}):null]})]}),E?e.jsxs("p",{role:E.tone==="negative"?"alert":"status",className:`mb-3 text-sm ${E.tone==="negative"?"text-negative":"text-positive"}`,children:[E.text,E.review?e.jsxs(e.Fragment,{children:[" ",F]}):null]}):O&&!C?e.jsxs("p",{role:"status",className:"mb-3 text-sm text-caution",children:[x.pending," ",F]}):null,C?e.jsxs("form",{className:"space-y-4","aria-label":"Edit names",onSubmit:d=>{d.preventDefault(),!G.isPending&&G.mutate({names:{aliases:W,identityAliases:Y},base:ne,openFor:B})},children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:`${r}-names`,className:"block text-sm font-medium text-heading",children:x.names}),e.jsx("p",{id:`${r}-names-hint`,className:"text-sm text-secondary",children:x.namesHint}),e.jsx("textarea",{id:`${r}-names`,className:"mt-1 min-h-24 w-full rounded-md border border-strong bg-transparent px-3 py-2 text-sm text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400","aria-describedby":`${r}-names-hint${Z.length?` ${r}-names-issues`:""}`,value:c,onChange:d=>j(d.target.value)}),e.jsx(qe,{id:`${r}-names-issues`,issues:Z}),W.length===0?e.jsx("p",{className:"mt-2 text-sm text-caution",children:x.noNames}):null]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:`${r}-qualified`,className:"block text-sm font-medium text-heading",children:x.qualifiedNames}),e.jsx("p",{id:`${r}-qualified-hint`,className:"text-sm text-secondary",children:x.qualifiedHint}),e.jsx("textarea",{id:`${r}-qualified`,className:"mt-1 min-h-20 w-full rounded-md border border-strong bg-transparent px-3 py-2 text-sm text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400","aria-describedby":`${r}-qualified-hint ${r}-qualified-note${X.length?` ${r}-qualified-issues`:""}`,value:M,onChange:d=>D(d.target.value)}),e.jsx(qe,{id:`${r}-qualified-issues`,issues:X}),e.jsx("p",{id:`${r}-qualified-note`,className:"mt-2 max-w-3xl text-sm text-secondary",children:x.qualifiedNote})]}),e.jsx("p",{className:"text-sm text-secondary",children:x.draftOnly}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(rs,{type:"submit",className:"h-11 px-4 text-sm md:h-11",disabled:G.isPending,children:G.isPending?x.saving:x.save}),e.jsx(w,{type:"button",variant:"ghost",className:"h-11 px-4 text-sm md:h-11",disabled:G.isPending,onClick:()=>{R(!1),T(null)},children:x.cancel})]})]}):ee===0?e.jsx("p",{className:"text-sm text-secondary",children:x.noNames}):e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.aliases.length>0?e.jsx(Se,{label:x.names,names:a.aliases}):null,P.length>0?e.jsx(Se,{label:x.qualifiedNames,names:P}):null]})]})}const me=50,b={branded:{headline:"When they know your name",technical:"Branded queries"},"non-brand":{headline:"When they don't",technical:"Non-brand queries"}},Rs={plan_v1:"Setup update required",no_completed_run:"No completed measurement yet",no_population:"No queries of this type are assigned",evidence_incomplete:"Source evidence is incomplete",identity_ambiguous:xs,not_applicable:"Not applicable for this Property"},Ae={complete:{label:"Measured",tone:"positive"},partial:{label:"Partly measured",tone:"caution"},running:{label:"Measuring now",tone:"neutral"},queued:{label:"Measurement queued",tone:"neutral"},failed:{label:"Measurement failed",tone:"negative"},not_measured:{label:"Not measured",tone:"neutral"}},Me={assigned:{label:"Matches this Property",tone:"positive"},sibling:{label:"Matches another Property",tone:"caution"},ownedUnmapped:{label:"Site URL not in a Property",tone:"caution"},external:{label:"External URL",tone:"neutral"},ambiguous:{label:"Matches multiple Properties",tone:"caution"},invalid:{label:"Invalid URL",tone:"negative"}};function Ts(s){return[...s].sort((t,a)=>+(a.classification==="assigned")-+(t.classification==="assigned"))}function $s(s){return`${s.expectedSlotId}:${s.usageEdgeId}`}function Is({row:s}){return s.mentioned===null?e.jsxs("span",{className:"inline-flex flex-col items-start gap-0.5",children:[e.jsx(V,{tone:"neutral",children:"Not measured"}),e.jsx("span",{className:"text-xs text-muted",children:"No mention signal for this Property"})]}):e.jsx(V,{tone:s.mentioned?"positive":"neutral",children:s.mentioned?"Mentioned":"Not mentioned"})}const ks="—";function Bs({row:s}){return s.cited===null?e.jsxs("span",{className:"inline-flex flex-col items-start gap-0.5",children:[e.jsx(V,{tone:"neutral",children:"Not measured"}),e.jsx("span",{className:"text-xs text-muted",children:"Sources were not fully captured"})]}):e.jsx(V,{tone:s.cited?"positive":"neutral",children:s.cited?"Cited":"Not cited"})}function _s({row:s}){return s.cited===null&&s.sources.length===0?e.jsx("p",{className:"py-2 text-sm text-secondary",children:"The sources for this answer were not fully captured, so none can be shown."}):s.sources.length===0?e.jsx("p",{className:"py-2 text-sm text-secondary",children:"This answer returned no source URLs at all."}):e.jsxs("details",{className:"mt-2","data-answer-sources":!0,children:[e.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-sm text-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[Fe," (",s.sources.length,")"]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsxs("caption",{className:"sr-only",children:["Source URLs for ",s.queryText]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Match"}),e.jsx("th",{children:"URL"})]})}),e.jsx("tbody",{children:Ts(s.sources).map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx(V,{tone:Me[t.classification].tone,children:Me[t.classification].label})}),e.jsx("td",{children:e.jsx(Be,{url:t.sourceUrl})})]},t.sourceUrl))})]})})]})}function Qe({project:s,targetKey:t,resultId:a}){const n=K({...fs({client:_,path:{name:s},query:{targetKey:t,resultId:a}})});if(n.isPending)return e.jsx("p",{className:"py-2 text-sm text-secondary",role:"status","aria-live":"polite",children:"Loading the answer…"});if(n.isError)return e.jsx("p",{className:"py-2 text-sm text-secondary",role:"alert",children:"Could not load this answer."});const o=n.data?.answer;return o==null||o.trim()===""?e.jsx("p",{className:"py-2 text-sm text-secondary",children:"This answer was measured, but its text was not stored."}):e.jsx("div",{className:"py-2",children:e.jsx(Ps,{headingLevel:4,copyable:!0,children:o})})}function ue(s){return Rs[s.reason]??"Not measured"}function he({metric:s,signal:t,emphasis:a=!1}){if(s.state==="unavailable")return e.jsxs("span",{className:"inline-flex flex-col gap-0.5",children:[e.jsx("span",{className:a?"text-lg font-semibold text-secondary":"text-sm font-medium text-secondary",children:"Not measured"}),e.jsx("span",{className:"text-sm text-secondary",children:ue(s)})]});const n=_e(s.value),o=s.numerator===void 0||s.denominator===void 0?null:`${s.numerator} of ${s.denominator}`,u=Oe(s,t);return e.jsxs("span",{className:"inline-flex flex-col gap-0.5 tabular-nums",children:[e.jsx("span",{className:a?"text-lg font-semibold text-heading":"text-sm font-medium text-primary",children:n}),o?e.jsx("span",{className:"text-xs text-muted",children:o}):null,u?e.jsx("span",{className:"text-xs text-muted",children:u}):null]})}function Le(s,t,a){return us({client:_,path:{name:s},query:{scope:"property",targetKey:t,queryClass:a}})}function Re(s){return s?.properties.items.at(0)}function Os({measuredAt:s,unmeasuredReason:t,queryClass:a}){const n=s===void 0?null:s===null?"No completed sweep yet":`Measured ${gs(js(s))}`;return n===null&&t===void 0?null:e.jsxs("p",{className:"supporting-copy",children:[[n,t].filter(Boolean).join(" · "),n!==null&&t===void 0?` · ${b[a].technical.toLocaleLowerCase()} only`:""]})}function Fs({project:s,groups:t}){return t.length===0?null:e.jsxs("section",{"aria-labelledby":"property-market",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Competitive comparison"}),e.jsxs("h2",{id:"property-market",className:"text-base font-semibold text-heading",children:["Measured at the market level",e.jsx(I,{text:"Competitors are attached to a market rather than to a single Property, because one building has nobody to be compared against. Share of voice and competitor pressure are reported for the market this Property sits in."})]})]}),e.jsx(w,{asChild:!0,type:"button",size:"sm",variant:"outline",children:e.jsx(te,{to:"/projects/$projectName",params:{projectName:s},search:a=>ce(oe(a),{measurementScope:"project"}),children:"Open measurement overview"})})]}),e.jsx("ul",{className:"flex flex-wrap gap-2",children:t.map(a=>e.jsxs("li",{className:"rounded-md border border-default px-3 py-1.5 text-sm text-strong",children:[a.label,e.jsxs("span",{className:"ml-2 text-xs text-muted",children:[a.competitors.length," ",a.competitors.length===1?"competitor":"competitors"]})]},a.stableKey))})]})}function de({label:s,metric:t,signal:a,failed:n=!1}){if(t===void 0)return e.jsxs("div",{className:"aeo-hero-row",children:[e.jsx("p",{className:"aeo-hero-row-label",children:s}),e.jsx("p",{className:"aeo-hero-row-value text-base font-semibold text-secondary",children:n?"Unavailable":"…"}),n?e.jsx("div",{}):e.jsx("div",{className:"aeo-hero-row-bar","aria-hidden":"true"}),e.jsx("p",{className:"aeo-hero-row-detail",children:n?"Could not be loaded":"Loading"})]});if(t.state==="unavailable"){const l=ue(t);return e.jsxs("div",{className:"aeo-hero-row",children:[e.jsx("p",{className:"aeo-hero-row-label",children:s}),e.jsx("p",{className:"aeo-hero-row-value text-base font-semibold text-secondary",children:"Not measured"}),e.jsx("div",{}),e.jsx("p",{className:"aeo-hero-row-detail",children:l==="Not measured"?"":l})]})}const{figure:o,sign:u}=ys(_e(t.value)),m=t.numerator===void 0||t.denominator===void 0?null:`${t.numerator} of ${t.denominator}`,r=Oe(t,a);return e.jsxs("div",{className:"aeo-hero-row",children:[e.jsx("p",{className:"aeo-hero-row-label",children:s}),e.jsxs("p",{className:"aeo-hero-row-value text-heading",children:[o,u?e.jsx("span",{className:"text-faint",children:u}):null]}),e.jsx("div",{className:"aeo-hero-row-bar","aria-hidden":"true",children:e.jsx("div",{className:"metric-card-bar-fill progress-fill-neutral",style:{width:`${t.value*100}%`}})}),e.jsxs("p",{className:"aeo-hero-row-detail tabular-nums",children:[m??"",r?e.jsx("span",{className:"block",children:r}):null]})]})}function Us({branded:s,nonBrand:t,brandedFailed:a=!1,nonBrandFailed:n=!1}){return e.jsxs("section",{"aria-labelledby":"property-coverage-hero",children:[e.jsx("h2",{id:"property-coverage-hero",className:"sr-only",children:"Coverage for this Property"}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Non-brand · the demand to earn"}),e.jsx(de,{label:"Mentioned",metric:t?.mentionCoverage,signal:"mentioned",failed:n}),e.jsx(de,{label:"Cited",metric:t?.citationCoverage,signal:"cited",failed:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Branded · already named"}),e.jsx(de,{label:"Mentioned",metric:s?.mentionCoverage,signal:"mentioned",failed:a}),e.jsx(de,{label:"Cited",metric:s?.citationCoverage,signal:"cited",failed:a})]})]})]})}function Qs({branded:s,nonBrand:t,brandedError:a,nonBrandError:n,onRetry:o}){const u=[{queryClass:"branded",row:s,isError:a},{queryClass:"non-brand",row:t,isError:n}];return e.jsxs("section",{"aria-labelledby":"property-brand-contrast",children:[e.jsx("div",{className:"section-head section-head-inline",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"The gap"}),e.jsxs("h2",{id:"property-brand-contrast",className:"text-base font-semibold text-heading",children:["Named versus not named",e.jsx(I,{text:"Branded queries already contain your name, so an answer engine has an easy path back to you. Non-brand queries describe the need instead, and that is the demand you have to earn. Each row is measured only over the queries assigned to this Property in that class; a class with no assigned query reads Not measured rather than 0%."})]})]})}),e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[560px]",children:[e.jsx("caption",{className:"sr-only",children:"Mention and citation coverage for this Property, split by query class"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Query type"}),e.jsx("th",{children:"Mentioned in the answer"}),e.jsx("th",{children:"Cited as a source"})]})}),e.jsx("tbody",{children:u.map(({queryClass:m,row:r,isError:l})=>e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("span",{className:"block font-medium text-heading",children:b[m].headline}),e.jsx("span",{className:"mt-0.5 block text-xs text-muted",children:b[m].technical}),r&&l?e.jsxs("span",{className:"mt-2 flex flex-wrap items-center gap-2 text-sm text-caution",children:[e.jsx("span",{role:"status",children:"Refresh failed."}),e.jsxs(w,{type:"button",size:"sm",variant:"ghost",className:"h-11 px-3 text-sm md:h-11",onClick:()=>o(m),children:["Retry ",b[m].technical.toLocaleLowerCase()]})]}):null]}),r?e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx(he,{metric:r.mentionCoverage,signal:"mentioned",emphasis:!0})}),e.jsx("td",{children:e.jsx(he,{metric:r.citationCoverage,signal:"cited",emphasis:!0})})]}):l?e.jsx("td",{colSpan:2,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsxs("span",{role:"alert",children:["Could not load ",b[m].technical.toLocaleLowerCase(),"."]}),e.jsxs(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>o(m),children:["Retry ",b[m].technical.toLocaleLowerCase()]})]})}):e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx("span",{className:"text-sm text-secondary",children:"Loading…"})}),e.jsx("td",{children:e.jsx("span",{className:"text-sm text-secondary",children:"Loading…"})})]})]},m))})]})})]})}function Ks({row:s,queryClass:t,isError:a}){return e.jsxs("section",{"aria-labelledby":"property-providers",className:"page-section-divider",children:[e.jsx("div",{className:"section-head section-head-inline",children:e.jsx("div",{children:e.jsxs("h2",{id:"property-providers",className:"text-base font-semibold text-heading",children:["Which engines answer for this Property",e.jsx(I,{text:"Each row is measured over the queries that engine actually answered for this Property, so the rows are a split of the same population rather than parts that add up to the Property total. An engine that answered nothing for this Property is absent instead of shown at 0%."})]})})}),s===void 0&&a?e.jsxs("p",{className:"text-sm text-secondary",children:["Details for ",b[t].technical.toLocaleLowerCase()," are unavailable. Retry that query type above."]}):s===void 0?e.jsx("p",{className:"text-sm text-secondary",children:"Loading…"}):s.providers.length===0?e.jsxs("p",{className:"text-sm text-secondary",children:["No answer engine has measured ",b[t].technical.toLocaleLowerCase()," for this Property.",s.mentionCoverage.state==="unavailable"?` ${ue(s.mentionCoverage)}.`:""]}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[520px]",children:[e.jsx("caption",{className:"sr-only",children:"Per-engine mention and citation coverage"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Engine"}),e.jsx("th",{children:"Mentioned"}),e.jsx("th",{children:"Cited"})]})}),e.jsx("tbody",{children:s.providers.map(n=>e.jsxs("tr",{children:[e.jsx("td",{className:"font-medium text-heading",children:n.provider}),e.jsx("td",{children:e.jsx(he,{metric:n.mentionCoverage,signal:"mentioned"})}),e.jsx("td",{children:e.jsx(he,{metric:n.citationCoverage,signal:"cited"})})]},n.provider))})]})})]})}function Vs(s){const t=s.questions.join(" · ");return s.questionsTruncated?`${t} +${s.questionTotal-s.questions.length} more`:t}function Ds({project:s,targetKey:t,queryClass:a}){const n=K({...ps({client:_,path:{name:s},query:{targetKey:t,queryClass:a}})});if(n.isPending||n.isError)return null;const o=n.data?.competitors??[],u=n.data?.basis;return e.jsxs("section",{"aria-labelledby":"property-named-instead",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsx("div",{children:e.jsxs("h2",{id:"property-named-instead",className:"text-base font-semibold text-heading",children:["Named instead of this Property",e.jsx(I,{text:"Counted from the answers that did not name this Property, so a name here is one an engine recommended in its place. Occurrences count answers, not positions: an engine naming the same rival in two answers counts twice, and one naming it twice in a single answer counts once."})]})}),o.length>0?e.jsxs("p",{className:"supporting-copy",children:[n.data?.total??o.length," named"]}):null]}),o.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"No rival was named in the answers this Property missed. Nothing to compete with here yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsx("caption",{className:"sr-only",children:"Names the engines gave instead of this Property"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Named"}),e.jsx("th",{children:"Answers"}),e.jsx("th",{children:"Engines"}),e.jsx("th",{children:"Queries"})]})}),e.jsx("tbody",{children:o.map(m=>e.jsxs("tr",{children:[e.jsx("td",{className:"text-strong",children:m.name}),e.jsx("td",{className:"tabular-nums text-secondary",children:m.occurrences}),e.jsxs("td",{className:"text-secondary",children:[m.providers.join(", "),m.providersTruncated?` +${m.providerTotal-m.providers.length}`:""]}),e.jsx("td",{className:"text-right",children:e.jsxs("span",{className:"inline-flex items-center justify-end gap-1",children:[e.jsx("span",{className:"tabular-nums text-secondary",children:m.questionTotal}),e.jsx(I,{text:Vs(m)})]})})]},m.name))})]})}),u?.state==="available"?e.jsxs("p",{className:"supporting-copy mt-2",children:[u.targetMissResults," of ",u.answeredResults," answers to ",b[a].technical.toLocaleLowerCase()," did not name this Property."]}):null]})]})}function Hs({questions:s,queryClass:t}){return e.jsxs("section",{"aria-labelledby":"property-questions",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsx("div",{children:e.jsxs("h2",{id:"property-questions",className:"text-base font-semibold text-heading",children:[b[t].technical," assigned to this Property"]})}),e.jsxs("p",{className:"supporting-copy",children:[s.length," assigned"]})]}),s.length===0?e.jsxs("p",{className:"text-sm text-secondary",children:["No ",b[t].technical.toLocaleLowerCase()," are assigned. Add one in advanced measurement setup to measure this class."]}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsx("caption",{className:"sr-only",children:"Queries assigned to this Property"}),e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("th",{children:"Query"})})}),e.jsx("tbody",{children:s.map(a=>e.jsx("tr",{children:e.jsx("td",{className:"text-secondary",children:a})},a))})]})})]})}function Ws({urls:s}){return e.jsxs("section",{"aria-labelledby":"property-urls",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsx("div",{children:e.jsxs("h2",{id:"property-urls",className:"text-base font-semibold text-heading",children:["URLs that count as this Property",e.jsx(I,{text:"A cited source URL is credited to this Property when it matches one of these. The most specific matcher wins, so a URL covered by two Properties at the same specificity is flagged for review instead of being credited to either."})]})}),e.jsxs("p",{className:"supporting-copy",children:[s.length," configured"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"No URLs are configured for this Property."}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsx("caption",{className:"sr-only",children:"URL matchers configured for this Property"}),e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("th",{children:"URL"})})}),e.jsx("tbody",{children:s.map(t=>e.jsx("tr",{children:e.jsx("td",{className:"break-all text-secondary",children:t})},t))})]})})]})}const se={heading:"Cited on other queries",help:"Answers to queries assigned to other properties that still cited one of this Property’s own pages. This Property was not measured on those queries, so these answers are not in its Mentioned or Cited rates.",notCounted:"not in this Property’s rates",empty:"No answer to a query assigned elsewhere cited this Property’s pages in the displayed measurement.",loadError:"Citations from other queries could not be loaded.",partlySaved:"Sources partly saved"};function zs({project:s,targetKey:t,queryClass:a,runId:n,targetLabels:o}){const[u,m]=p.useState(new Set),r={client:_,path:{name:s},query:{targetKey:t,queryClass:a,shape:Ie["other-queries"],limit:me,...n?{runId:n}:{}}},l=Te({...ke(r),initialPageParam:r,getNextPageParam:h=>h.otherQueries?.nextCursor?{path:r.path,query:{...r.query,cursor:h.otherQueries.nextCursor}}:void 0}),k=l.data?.pages??[];if(k[0]?.measurement.state==="not_measured")return null;const q=k.flatMap(h=>h.otherQueries?.items??[]),P=k[0]?.otherQueries?.totalEstimate??q.length,O=h=>`${h.expectedSlotId}:${h.queryClass}`,L=b[a].technical.toLocaleLowerCase();return e.jsxs("section",{"aria-labelledby":"property-other-queries",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("h2",{id:"property-other-queries",className:"text-base font-semibold text-heading",children:se.heading}),e.jsx(I,{text:se.help})]}),l.data?e.jsxs("p",{className:"supporting-copy",children:[P," ",P===1?"answer":"answers"," · ",L," · ",se.notCounted]}):null]}),l.isPending?e.jsx("p",{className:"text-sm text-secondary",children:"Loading…"}):l.isError&&q.length===0?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsx("span",{role:"alert",children:se.loadError}),e.jsx(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>{l.refetch()},children:"Retry"})]}):q.length===0?e.jsx("p",{className:"text-sm text-secondary",children:se.empty}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[640px]",children:[e.jsx("caption",{className:"sr-only",children:"Answers to other properties’ queries that cited this Property’s pages"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Query"}),e.jsx("th",{children:"Assigned to"}),e.jsx("th",{children:"Pages cited"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Answer"})})]})}),e.jsx("tbody",{children:q.map(h=>{const A=O(h),C=u.has(A),R=`property-other-query-${encodeURIComponent(A)}`;return e.jsxs(p.Fragment,{children:[e.jsxs("tr",{children:[e.jsxs("td",{className:"text-secondary",children:[e.jsx("span",{className:"block text-sm font-medium text-heading",children:h.queryText}),e.jsx("span",{className:"mt-1 block text-xs text-muted",children:[h.provider,h.location].filter(Boolean).join(" · ")})]}),e.jsx("td",{children:e.jsx("ul",{className:"space-y-1",children:h.assignedTargetKeys.map(c=>e.jsx("li",{children:e.jsx(te,{to:"/projects/$projectName/properties/$targetKey",params:{projectName:s,targetKey:c},search:oe,className:"text-sm text-link hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:o.get(c)??c})},c))})}),e.jsxs("td",{children:[e.jsx("ul",{className:"space-y-1",children:h.sources.map(c=>e.jsx("li",{className:"min-w-0",children:e.jsx(Be,{url:c.sourceUrl})},c.sourceUrl))}),h.sourcesTruncated?e.jsxs("span",{className:"mt-1 block text-xs text-muted",children:[h.sourceCount," pages in total"]}):null,h.evidenceComplete?null:e.jsx("span",{className:"mt-1 block text-xs text-muted",children:se.partlySaved})]}),e.jsx("td",{className:"text-right",children:e.jsx(w,{type:"button",size:"sm",variant:"ghost",className:"h-auto min-h-11 max-w-full whitespace-normal py-2 text-left md:h-auto","aria-expanded":C,"aria-label":C?`Hide the answer for ${h.queryText}`:`Read the answer for ${h.queryText}`,"aria-controls":C?R:void 0,onClick:()=>m(c=>{const j=new Set(c);return j.delete(A)||j.add(A),j}),children:C?"Hide answer":"Read answer"})})]}),C?e.jsx("tr",{children:e.jsx("td",{id:R,colSpan:4,className:"bg-surface-subtle px-4",children:e.jsx(Qe,{project:s,targetKey:h.assignedTargetKeys[0],resultId:h.observationId})})}):null]},A)})})]})}),l.hasNextPage?e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsxs("span",{children:["Showing ",q.length," of ",P]}),e.jsx(w,{size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",disabled:l.isFetchingNextPage,onClick:()=>{l.fetchNextPage()},children:l.isFetchingNextPage?"Loading…":`Show ${me} more`})]}):null]})]})}function Gs(s,t){const a=[s.marketKey?t??"the selected market":null,s.provider?`the ${s.provider} answer engine`:null,s.model?`the ${s.model} model`:null,s.location?`location ${s.location}`:null,s.from||s.to?"a date range":null,s.measurementRunId?"a saved sweep":null].filter(n=>n!==null);return a.length===0?null:`AI Visibility is filtered to ${a.join(", ")}. This page shows the latest measurement for ${ws.allMarkets.toLocaleLowerCase()} and answer engines.`}function rt(){const{projectName:s,targetKey:t}=ze({strict:!1}),a=Ge(),n=Ye({strict:!1}),o=p.useMemo(()=>ve(n),[n]),[u,m]=p.useState(new Set),r=s??"",l=t??"",k=!!r&&!!l,q=p.useMemo(()=>is("portfolio",os(ls())),[]),P=k&&q,{canWrite:O}=$e(),L=K({...ds({client:_,path:{name:r}}),enabled:P}),h=L.data?.active?.plan,A=h?.schemaVersion===2?h:null,C=o.queryClass==="branded"||o.queryClass==="non-brand"?o.queryClass:null,R=i=>A?.assignments.some(f=>f.targetKey===l&&f.queryClass===i)??!1,c=C??(!R("non-brand")&&R("branded")?"branded":"non-brand");p.useEffect(()=>{!A||C||a({to:".",replace:!0,search:i=>ce(i,{queryClass:c})})},[A,C,c,a]);const j=K({...Le(r,l,"branded"),enabled:P}),M=K({...Le(r,l,"non-brand"),enabled:P}),D=Re(j.data),ne=Re(M.data),v=c==="branded"?j.data:M.data,E=c==="branded"?D:ne,B=(c==="branded"?j.isError:M.isError)&&E===void 0,H=v?.measurement.displayedRunId;cs(r,{view:"property",selection:{mode:"advanced",scope:"property",scopeKey:l,queryClass:c,limit:10,...H?{runId:H}:{}}});const xe=E?.mentionCoverage.state==="unavailable"?ue(E.mentionCoverage):void 0,re=v===void 0?void 0:v.measurement.completedAt??null,W=v!==void 0&&(v.measurement.state==="not_measured"||v.nextAction.kind==="run_measurement"),Y=i=>ce(oe(i),{measurementScope:"property",measurementScopeKey:l,queryClass:c,measurementRunId:void 0,measurementRevision:void 0,measurementTo:void 0}),Z=K({...ms({client:_,path:{name:r},query:hs(ve(Y(n)))}),enabled:P&&W,retry:!1}).data,X=Z!==void 0&&Z.selection.measurement.measuredRevision!==null&&(Z.populations.find(i=>i.queryClass===c)?.summary.queryCount??0)>0,z={client:_,path:{name:r},query:{targetKey:l,queryClass:c,shape:Ie.answers,limit:me,...H?{runId:H}:{}}},g=Te({...ke(z),enabled:P&&v!==void 0,initialPageParam:z,getNextPageParam:i=>i.answers?.nextCursor?{path:z.path,query:{...z.query,cursor:i.answers.nextCursor}}:void 0}),J=L.data?.active??null,y=J?.plan.schemaVersion===2?J.plan:null,G=J!==null&&y===null,F=y?.targets.find(i=>i.stableKey===l)??null,ee=Gs(o,y?.reportingScopes?.find(i=>i.stableKey===o.marketKey)?.label),d=p.useMemo(()=>{if(!y)return[];const i=new Map(y.querySnapshots.map(f=>[f.queryId,f.queryText]));return[...new Set(y.assignments.filter(f=>f.targetKey===l&&f.queryClass===c).flatMap(f=>{const N=i.get(f.queryId);return N===void 0?[]:[N]}))].sort((f,N)=>f.localeCompare(N))},[y,l,c]),S=p.useMemo(()=>F?.urlMatchers.map(Ns)??[],[F]),U=p.useMemo(()=>new Map((y?.targets??[]).map(i=>[i.stableKey,i.label])),[y]),Q=p.useMemo(()=>y?.groups.filter(i=>i.targetKeys.includes(l))??[],[y,l]),$=p.useMemo(()=>(g.data?.pages??[]).flatMap(N=>N.answers?.items??[]),[g.data]),ye=g.data?.pages[0]?.answers?.totalEstimate??$.length,Ke=(g.data?.pages??[]).length>0&&(g.data?.pages??[]).every(i=>i.answers===void 0),Ve=g.data?.pages[0]?.measurement.state,le=e.jsxs(te,{to:"/projects/$projectName",params:{projectName:r},search:oe,className:"inline-flex items-center gap-1 text-xs text-muted hover:text-strong",children:[e.jsx(Cs,{className:"size-3.5","aria-hidden":"true"}),"Back to AI Visibility"]});if(!k)return e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Missing project name or Property key in URL."})});if(!q)return e.jsxs("div",{className:"page-container space-y-3",children:[le,e.jsx("p",{className:"text-sm text-muted",children:"This view is not available here."})]});if(L.isPending&&!L.isError)return e.jsx("div",{className:"page-container",children:e.jsxs("div",{role:"status","aria-live":"polite",children:[e.jsx("span",{className:"sr-only",children:"Loading Property"}),e.jsx("div",{className:"h-32 animate-pulse rounded-md bg-surface-subtle","aria-hidden":"true"})]})});const De=L.isError&&L.data===void 0,ge=j.isError&&j.data===void 0,je=M.isError&&M.data===void 0;return De||ge&&je?e.jsxs("div",{className:"page-container space-y-3",children:[le,e.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Could not load this Property."}),e.jsx(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>{L.refetch(),j.refetch(),M.refetch()},children:"Try again"})]}):!y||!F?e.jsxs("div",{className:"page-container space-y-3",children:[le,e.jsx("p",{role:"status",className:"text-sm text-secondary",children:y?"This Property is not in the published setup. It may have been renamed or removed.":"A Property page needs a published advanced measurement setup. Republish setup from the project Portfolio tab."}),e.jsx(w,{asChild:!0,type:"button",variant:"outline",className:"h-11 px-4 text-sm md:h-11",children:e.jsx(te,{to:"/projects/$projectName/portfolio",params:{projectName:r},children:O?G?"Republish setup":"Open measurement setup":"View measurement setup"})})]}):e.jsxs("div",{className:"page-container space-y-8",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[le,e.jsx("h1",{className:"page-title mt-2",children:F.label}),e.jsxs("p",{className:"page-subtitle",children:["Property in ",r,ee?e.jsxs(e.Fragment,{children:[" · Filters not applied ",e.jsx(I,{text:ee})]}):null]})]}),e.jsxs("div",{className:"page-header-right",children:[v?e.jsx(V,{tone:Ae[v.measurement.state].tone,children:Ae[v.measurement.state].label}):null,E&&E.flags>0?e.jsxs(V,{tone:"caution",children:[E.flags," flagged"]}):null]})]}),e.jsx(Us,{branded:D,nonBrand:ne,brandedFailed:ge,nonBrandFailed:je}),e.jsx(Qs,{branded:D,nonBrand:ne,brandedError:j.isError,nonBrandError:M.isError,onRetry:i=>{i==="branded"?j.refetch():M.refetch()}}),W?e.jsxs("section",{className:"flex flex-wrap items-center justify-between gap-3 border-y border-default py-4","aria-label":"Measurement next step",children:[e.jsx("p",{className:"text-sm text-secondary",children:we()?Ne:O?`Run a measurement from the project overview to collect this Property’s coverage and source evidence.${X?" AI Visibility still shows the last results.":""}`:"This Property needs a new measurement before coverage and source evidence are available."}),e.jsx(w,{asChild:!0,type:"button",className:"h-11 px-4 text-sm md:h-11",children:e.jsx(te,{to:"/projects/$projectName",params:{projectName:r},search:X?Y:oe,children:X?"See the last results":O?"Go to AI Visibility":"View AI Visibility"})})]}):null,e.jsxs("div",{className:"flex flex-wrap items-end gap-4 border-y border-default py-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"property-query-class",className:"block text-sm font-medium text-heading",children:"Query type"}),e.jsxs("select",{id:"property-query-class",value:c,onChange:i=>{const f=i.target.value==="branded"?"branded":"non-brand";a({to:".",search:N=>ce(N,{queryClass:f})})},className:"h-11 rounded-md border border-default bg-surface px-3 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-mono-400",children:[e.jsx("option",{value:"non-brand",children:b["non-brand"].technical}),e.jsx("option",{value:"branded",children:b.branded.technical})]})]}),e.jsx(Os,{measuredAt:re,unmeasuredReason:xe,queryClass:c})]}),e.jsx(Ks,{row:E,queryClass:c,isError:B}),e.jsx(Ds,{project:r,targetKey:l,queryClass:c}),e.jsx(Hs,{questions:d,queryClass:c}),e.jsx(Ls,{projectName:r,targetKey:l,published:F,activeRevision:J.revision,publishedBrandNames:y.identities.projectBrand.names}),e.jsx(Ws,{urls:S}),e.jsx(Fs,{project:r,groups:Q}),e.jsxs("section",{"aria-labelledby":"property-evidence",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsx("div",{children:e.jsxs("h2",{id:"property-evidence",className:"text-base font-semibold text-heading",children:["Answers the engines gave",e.jsx(I,{text:"One row per answer an engine gave for the queries assigned to this Property in the displayed measurement. Mentioned and cited are independent: an answer can name this Property without linking it, or link it without naming it. Answers that did neither are listed first, because those are what a gap is made of. Where the answer text was not stored the mention reads Not measured, never a zero. Open a row to read what the engine actually said, followed by the source URLs it returned, this Property's own first. The answer is where a miss becomes actionable: a query this Property was not named in may still have named a sibling building."})]})}),$.length>0?e.jsxs("p",{className:"supporting-copy",children:[$.length," of ",ye]}):null]}),B?e.jsxs("p",{className:"text-sm text-secondary",children:["Evidence for ",b[c].technical.toLocaleLowerCase()," is unavailable. Retry that query type above."]}):g.isPending&&$.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"Loading evidence…"}):g.isError&&$.length===0?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsx("span",{role:"alert",children:"Evidence could not be loaded."}),e.jsx(w,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>{g.refetch()},children:"Retry evidence"})]}):Ve==="not_measured"?e.jsx("p",{className:"text-sm text-secondary",children:we()?Ne:"Not measured yet. Run a measurement to collect the answers for this Property."}):Ke?e.jsx("p",{role:"alert",className:"text-sm text-caution",children:"This measurement was returned in an older format, so the answers cannot be shown here. The numbers above are unaffected."}):$.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"No answers matched this Property in the displayed measurement."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"property-answer-table-container overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table property-evidence-table",children:[e.jsx("caption",{className:"sr-only",children:"Answers measured for this Property"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Query"}),e.jsx("th",{children:"Mentioned in the answer"}),e.jsx("th",{children:"Cited as a source"}),e.jsx("th",{children:"Sources"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Sources detail"})})]})}),e.jsx("tbody",{children:$.map(i=>{const f=$s(i),N=u.has(f),be=`property-answer-${encodeURIComponent(f)}`;return e.jsxs(p.Fragment,{children:[e.jsxs("tr",{className:"property-answer-summary",children:[e.jsxs("td",{className:"text-secondary",children:[e.jsx("h3",{className:"text-sm font-medium text-heading",children:i.queryText}),e.jsx("span",{className:"mt-1 block text-xs text-muted",children:[i.provider,i.location].filter(Boolean).join(" · ")}),i.historical||i.bridged?e.jsx("span",{className:"mt-1 flex",children:e.jsx(V,{tone:"caution",children:"Historical"})}):null]}),e.jsxs("td",{children:[e.jsx("span",{className:"property-evidence-mobile-label","aria-hidden":"true",children:"Mentioned"}),e.jsx(Is,{row:i})]}),e.jsxs("td",{children:[e.jsx("span",{className:"property-evidence-mobile-label","aria-hidden":"true",children:"Cited"}),e.jsx(Bs,{row:i})]}),e.jsxs("td",{className:"tabular-nums text-secondary",children:[e.jsx("span",{className:"property-evidence-mobile-label","aria-hidden":"true",children:Fe}),i.cited===null?ks:i.sources.length]}),e.jsx("td",{className:"text-right",children:e.jsx(w,{type:"button",size:"sm",variant:"ghost",className:"h-auto min-h-11 max-w-full whitespace-normal py-2 text-left md:h-auto","aria-expanded":N,"aria-label":N?`Hide the answer for ${i.queryText}`:`Read the answer for ${i.queryText}`,"aria-controls":N?be:void 0,onClick:()=>m(He=>{const fe=new Set(He);return fe.delete(f)||fe.add(f),fe}),children:N?"Hide answer":"Read answer"})})]}),N?e.jsx("tr",{className:"property-answer-detail",children:e.jsxs("td",{id:be,colSpan:5,className:"bg-surface-subtle px-4",children:[e.jsx(Qe,{project:r,targetKey:l,resultId:i.observationId}),e.jsx(_s,{row:i})]})}):null]},f)})})]})}),g.hasNextPage?e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsxs("span",{children:["Showing ",$.length," of ",ye]}),g.isFetchNextPageError?e.jsx("span",{role:"alert",children:"Could not load more evidence."}):null,e.jsx(w,{size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",disabled:g.isFetchingNextPage,onClick:()=>{g.fetchNextPage()},children:g.isFetchingNextPage?"Loading…":g.isFetchNextPageError?"Retry more evidence":`Show ${me} more`})]}):null]})]}),v?e.jsx(zs,{project:r,targetKey:l,queryClass:c,runId:H,targetLabels:U}):null]})}export{Me as EVIDENCE_LABELS,rt as MeasurementPropertyPage,se as OTHER_QUERIES_COPY};