@canonry/canonry 7.9.0 → 7.10.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 (29) hide show
  1. package/assets/assets/{AuditHistoryPanel-D0nukTwD.js → AuditHistoryPanel-BgcvPo6g.js} +1 -1
  2. package/assets/assets/{BacklinksPage-B525ij0g.js → BacklinksPage-DZ4tauAs.js} +1 -1
  3. package/assets/assets/{HistoryPage-DvupqQDM.js → HistoryPage-DWG52dz1.js} +1 -1
  4. package/assets/assets/{MeasurementPropertyPage-CwDbi1XN.js → MeasurementPropertyPage-DTx2iQLV.js} +1 -1
  5. package/assets/assets/{ProjectPage-DmZZ2C7q.js → ProjectPage-CCf70zbI.js} +1 -1
  6. package/assets/assets/{RunsPage-DHTvHcGm.js → RunsPage-B6MhRqxN.js} +1 -1
  7. package/assets/assets/{SettingsPage-BwAFzB7A.js → SettingsPage-Bxv7OSHT.js} +1 -1
  8. package/assets/assets/SiteHealthSection-C5x7oiFL.js +4 -0
  9. package/assets/assets/{TrafficPage-BOcXASAM.js → TrafficPage-C5gyQopi.js} +1 -1
  10. package/assets/assets/{TrafficSourceDetailPage-DTq0cN6g.js → TrafficSourceDetailPage-Dv2ZRNvN.js} +1 -1
  11. package/assets/assets/{extract-error-message-BOTDI6g5.js → extract-error-message-C5pr51ph.js} +1 -1
  12. package/assets/assets/{index-BLJfGYUw.js → index-BhXHm5nG.js} +3 -3
  13. package/assets/assets/{react-sigma_core.esm.min-BEBdJNtD.js → react-sigma_core.esm.min-P5bVaYly.js} +1 -1
  14. package/assets/assets/{v2-overview-adapter-BPZ-H3VY.js → v2-overview-adapter-QtI4xO_4.js} +1 -1
  15. package/assets/index.html +1 -1
  16. package/dist/{chunk-KRFTA4I7.js → chunk-52PHEGHT.js} +89 -50
  17. package/dist/{chunk-T2V2PESH.js → chunk-5ZBN3EEK.js} +2 -2
  18. package/dist/{chunk-DO7XPDG5.js → chunk-66DVP4DN.js} +9 -1
  19. package/dist/{chunk-NU62UT2S.js → chunk-FVMWUT2R.js} +122 -21
  20. package/dist/{chunk-AAMKTL6B.js → chunk-HL3C6Z7T.js} +3 -3
  21. package/dist/{chunk-LO56QXPO.js → chunk-IKXVLT4M.js} +2 -2
  22. package/dist/{chunk-ZLB7WX5D.js → chunk-VSZJVBVR.js} +1 -1
  23. package/dist/cli.js +9 -9
  24. package/dist/{demo-server-KDMG3APY.js → demo-server-WZIB4JKJ.js} +4 -4
  25. package/dist/index.js +6 -6
  26. package/dist/{intelligence-service-LAXJFE3U.js → intelligence-service-KC62A4X5.js} +2 -2
  27. package/dist/mcp.js +4 -4
  28. package/package.json +11 -11
  29. package/assets/assets/SiteHealthSection-hi54eSIt.js +0 -4
@@ -1,4 +1,4 @@
1
- import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-hi54eSIt.js";import"./index-BLJfGYUw.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-lucide-N6vOpZmh.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-CYlrwLJs.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-C5x7oiFL.js";import"./index-BhXHm5nG.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-lucide-N6vOpZmh.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-CYlrwLJs.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ee(r,n){return qt(r)||Yt(r,n)||Tt(r,n)||Xt()}var pe={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},Ct=new Int8Array(4),be=new Int32Array(Ct.buffer,0,1),$t=new Float32Array(Ct.buffer,0,1),Kt=/^\s*rgba?\s*\(/,Jt=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Qt(r){var n=0,i=0,e=0,t=1;if(r[0]==="#")r.length===4?(n=parseInt(r.charAt(1)+r.charAt(1),16),i=parseInt(r.charAt(2)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(3),16)):(n=parseInt(r.charAt(1)+r.charAt(2),16),i=parseInt(r.charAt(3)+r.charAt(4),16),e=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(t=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(Kt.test(r)){var a=r.match(Jt);a&&(n=+a[1],i=+a[2],e=+a[3],a[4]&&(t=+a[4]))}return{r:n,g:i,b:e,a:t}}var J={};for(var le in pe)J[le]=oe(pe[le]),J[pe[le]]=J[le];function Rt(r,n,i,e,t){return be[0]=e<<24|i<<16|n<<8|r,be[0]=be[0]&4278190079,$t[0]}function oe(r){if(r=r.toLowerCase(),typeof J[r]<"u")return J[r];var n=Qt(r),i=n.r,e=n.g,t=n.b,a=n.a;a=a*255|0;var o=Rt(i,e,t,a);return J[r]=o,o}var Ee={};function _t(r){if(typeof Ee[r]<"u")return Ee[r];var n=(r&16711680)>>>16,i=(r&65280)>>>8,e=r&255,t=255,a=Rt(n,i,e,t);return Ee[r]=a,a}function We(r,n,i,e){return i+(n<<8)+(r<<16)}function Ve(r,n,i,e,t,a){var o=Math.floor(i/a*t),s=Math.floor(r.drawingBufferHeight/a-e/a*t),l=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,n),r.readPixels(o,s,1,1,r.RGBA,r.UNSIGNED_BYTE,l);var h=ee(l,4),u=h[0],d=h[1],f=h[2],g=h[3];return[u,d,f,g]}function c(r,n,i){return(n=ae(n))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,r}function je(r,n){var i=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),i.push.apply(i,e)}return i}function b(r){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?je(Object(i),!0).forEach(function(e){c(r,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):je(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function ei(r,n){for(;!{}.hasOwnProperty.call(r,n)&&(r=Q(r))!==null;);return r}function Ae(){return Ae=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,n,i){var e=ei(r,n);if(e){var t=Object.getOwnPropertyDescriptor(e,n);return t.get?t.get.call(arguments.length<3?r:i):t.value}},Ae.apply(null,arguments)}function wt(r,n,i,e){var t=Ae(Q(r.prototype),n,i);return typeof t=="function"?function(a){return t.apply(i,a)}:t}function ti(r){return r.normalized?1:r.size}function ye(r){var n=0;return r.forEach(function(i){return n+=ti(i)}),n}function xt(r,n,i){var e=r==="VERTEX"?n.VERTEX_SHADER:n.FRAGMENT_SHADER,t=n.createShader(e);if(t===null)throw new Error("loadShader: error while creating the shader");n.shaderSource(t,i),n.compileShader(t);var a=n.getShaderParameter(t,n.COMPILE_STATUS);if(!a){var o=n.getShaderInfoLog(t);throw n.deleteShader(t),new Error(`loadShader: error while compiling the shader:
3
3
  `.concat(o,`
4
4
  `).concat(i))}return t}function ii(r,n){return xt("VERTEX",r,n)}function ri(r,n){return xt("FRAGMENT",r,n)}function ni(r,n){var i=r.createProgram();if(i===null)throw new Error("loadProgram: error while creating the program.");var e,t;for(e=0,t=n.length;e<t;e++)r.attachShader(i,n[e]);r.linkProgram(i);var a=r.getProgramParameter(i,r.LINK_STATUS);if(!a){var o=r.getProgramInfoLog(i);throw r.deleteProgram(i),new Error("loadProgram: error while linking the program: ".concat(o))}return i}function Ze(r){var n=r.gl,i=r.buffer,e=r.program,t=r.vertexShader,a=r.fragmentShader;n.deleteShader(t),n.deleteShader(a),n.deleteProgram(e),n.deleteBuffer(i)}var qe=`#define PICKING_MODE
@@ -1 +1 @@
1
- import{r as j,j as i}from"./vendor-tanstack-ZXXkndVj.js";import{Q as ae,eh as oe,B as le,aZ as ue}from"./index-BLJfGYUw.js";import{M as ce}from"./vendor-markdown-B4giJcws.js";import{C as de,$ as pe,g as J}from"./vendor-lucide-N6vOpZmh.js";const Ae="Sources",B={copy:"Copy answer",copying:"Copying…",copied:"Copied",failed:"Could not copy. Select and copy the answer above."};function me({previewLength:e,highlight:r}){return o=>{if(e!==void 0&&Number.isFinite(e)){let c=Math.max(0,Math.floor(e));const d={field:"value",omitted:!1},p=n=>{if(n.type==="definition")return!0;if(n.children)return n.children=n.children.filter(p),n.children.length>0;const s=n.type==="image"||n.type==="imageReference"?"alt":"value",f=n[s];if(f===void 0)return c>0;const b=Array.from(f);if(b.length===0)return c>0;if(c===0)return d.omitted=!0,!1;const N=b.length>c,k=b.slice(0,c);if(N&&!/\s/.test(b[c])){let g=k.length-1;for(;g>=0&&!/\s/.test(k[g]);)g--;g>=0&&g>c-40&&(k.length=g)}return d.omitted||=N,n[s]=k.join(""),c=N?0:c-k.length,k.length===0?!1:(d.lastNode=n,d.field=s,!0)};p(o),d.omitted&&(d.lastNode?d.lastNode[d.field]=`${d.lastNode[d.field].trimEnd()}…`:o.children?.push({type:"paragraph",children:[{type:"text",value:"…"}]}))}if(r){const c=d=>{["link","linkReference","code","inlineCode"].includes(d.type)||(d.type==="text"&&(d.data={...d.data,hName:"span"}),d.children?.forEach(c))};c(o)}}}function fe({headingLevel:e}){return r=>{const o=[],c=p=>{p.type==="heading"&&p.depth&&o.push(p),p.children?.forEach(c)};c(r);const d=o.reduce((p,n)=>Math.min(p,n.depth),6);for(const p of o){const n=p.depth-d;p.depth=Math.min(6,e+n),p.data={...p.data,hProperties:{...p.data?.hProperties,"data-answer-heading-level":n+1}}}}}function ge({answer:e}){const[r,o]=j.useState("idle"),c=j.useRef(!1),d=async()=>{if(!c.current){c.current=!0,o("copying");try{await navigator.clipboard.writeText(e),o("copied")}catch{o("failed")}finally{c.current=!1}}};return i.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3",children:[i.jsx(le,{type:"button",variant:"ghost",className:"min-h-11 px-2","aria-disabled":r==="copying","aria-busy":r==="copying",onClick:()=>{d()},children:r==="copying"?B.copying:B.copy}),i.jsx("span",{role:"status",className:"text-sm text-secondary",children:r==="copied"?B.copied:r==="failed"?B.failed:""})]})}const Se=j.memo(function({children:r,headingLevel:o=4,copyable:c=!1,highlightGroups:d,previewLength:p}){return i.jsxs("div",{className:"answer-markdown",children:[i.jsx(ce,{remarkPlugins:[[fe,{headingLevel:o}],[me,{previewLength:p,highlight:!!d?.length}]],components:{p:({children:n})=>i.jsx("p",{className:"mb-3 whitespace-pre-wrap last:mb-0",children:n}),ul:({children:n})=>i.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1",children:n}),ol:({children:n,start:s})=>i.jsx("ol",{start:s,className:"mb-3 ml-5 list-decimal space-y-1",children:n}),pre:({children:n})=>i.jsx("pre",{className:"mb-3 overflow-x-auto whitespace-pre-wrap",children:n}),span:({children:n})=>i.jsx("span",{children:typeof n=="string"&&d?n.split(/(https?:\/\/[^\s<>]+)/i).map((s,f)=>f%2?s:i.jsx(j.Fragment,{children:oe(s,d)},f)):n}),a:({children:n,href:s})=>{const f=ae(s);return f?i.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-link underline",children:n}):i.jsx("span",{children:n})},img:({alt:n})=>i.jsx("span",{children:n})},children:r}),c&&r.trim()?i.jsx(ge,{answer:r},r):null]})}),X="min-h-11 w-full rounded-md border border-default bg-surface px-3 py-2 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",G="flex min-h-11 w-full items-center justify-between gap-3 rounded px-2 text-left text-sm text-primary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",E=e=>e.kind==="project"?"Whole site":e.label,q={allMarkets:"All markets",browse:e=>`Browse ${e}`,select:e=>`Select ${e}`,browseAll:"Browse all properties"},he=e=>e?.kind==="group"&&e.marketKeys?.length===1?e.marketKeys[0]:void 0,ee=e=>`${e} ${e===1?"property":"properties"}`;function Ke({options:e,selected:r,onSelect:o,marketKey:c,label:d="Measurement scope",labelVisibility:p="visible",allowGroupSelect:n=!0}){const s=[...e].sort((t,u)=>t.label.localeCompare(u.label,void 0,{numeric:!0})||t.id.localeCompare(u.id)),[f,b]=j.useState(""),[N,k]=j.useState([]),[g,$]=j.useState(!1),C=j.useRef(null),I=j.useRef(null),a=j.useId(),y=s.filter(t=>t.kind==="group"),h=new Map(y.map(t=>[t.id,t])),l=h.get(N.at(-1)??""),F=h.get(N.at(-2)??""),x=f.trim().toLocaleLowerCase(),ne=y.filter(t=>!t.parentGroupIds?.some(u=>h.has(u))),_=s.filter(t=>t.kind==="property"),O=t=>(t.parentGroupIds??[]).map(u=>h.get(u)?.label).filter(Boolean).join(" · "),P=t=>`${E(t)} ${O(t)}`.toLocaleLowerCase().includes(x),U=t=>{const u=[...t.parentGroupIds??[]],m=new Set;for(;u.length;){const v=u.pop();if(v===l?.id)return!0;m.has(v)||(m.add(v),u.push(...h.get(v)?.parentGroupIds??[]))}return!1},A=(g?[]:l?y.filter(t=>x?U(t):t.parentGroupIds?.includes(l.id)):x?y:ne).filter(P),S=s.find(t=>t.kind==="market"&&t.id===(c??(r.kind==="market"?r.id:void 0))),H=l&&S&&(l.marketKeys?.includes(S.id)||S.parentGroupIds?.includes(l.id))?S.id:void 0,L=n?H??he(l):void 0,V=(l?_.filter(t=>t.parentGroupIds?.includes(l.id)&&(!L||t.marketKeys?.includes(L))):x||g||y.length===0?_:[]).filter(P),W=s.filter(t=>t.kind!=="market"||g||!n&&!l&&!x&&y.length>0||n&&l?.marketKeys?.length===1&&!x?!1:(l?x?U(t):t.parentGroupIds?.includes(l.id):x||!t.parentGroupIds?.some(m=>h.has(m)))&&P(t)),Y=l||g?[]:s.filter(t=>t.kind==="project"&&P(t));j.useEffect(()=>{const t=u=>{C.current?.open&&u.target instanceof Node&&!C.current.contains(u.target)&&(C.current.open=!1)};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[]);const se=t=>{C.current&&(C.current.open=!1,C.current.querySelector("summary")?.focus());const u=n?t.kind==="property"?L:t.kind==="group"&&t.id===l?.id?H:void 0:void 0;u?o(t,u):o(t)},T=t=>{const u=[];let m=h.get(t.parentGroupIds?.[0]??"");for(;m&&!u.includes(m.id)&&m.id!==t.id;)u.unshift(m.id),m=h.get(m.parentGroupIds?.[0]??"");return[...u,t.id]},ie=()=>{const t=r.kind==="group"?h.get(r.id):void 0,u=h.get(S?.parentGroupIds?.[0]??""),m=(r.parentGroupIds??[]).flatMap(K=>{const R=h.get(K);return R?[T(R)]:[]}),v=m.find(K=>K.at(-1)===l?.id)??m.sort((K,R)=>R.length-K.length)[0]??[],Z=u?T(u):r.marketKeys?.length?[]:v;k(t?T(t):Z),$(r.kind==="property"&&Z.length===0&&y.length>0),b("")},z=t=>{k(T(t)),$(!1),b(""),I.current?.focus()},w=(t,u=E(t))=>i.jsxs("div",{className:"flex items-stretch",children:[i.jsxs("button",{type:"button",className:G,"aria-label":t.kind==="group"&&!n?q.browse(E(t)):q.select(E(t)),"aria-current":r.kind===t.kind&&r.id===t.id?"true":void 0,onClick:()=>t.kind==="group"&&!n?z(t):se(t),children:[i.jsxs("span",{className:"min-w-0 break-words",children:[u,x&&O(t)?i.jsx("span",{className:"block text-[13px] text-secondary",children:O(t)}):null]}),i.jsx("span",{className:"shrink-0 text-right text-[13px] text-secondary",children:t.kind==="market"?n?"Query context":"Market":t.kind==="property"?"Property":ee(t.targetCount)})]}),n&&t.kind==="group"&&t.id!==l?.id&&s.some(m=>m.parentGroupIds?.includes(t.id))?i.jsx("button",{type:"button","aria-label":q.browse(t.label),title:`Browse ${t.label}`,className:"flex min-h-11 min-w-11 items-center justify-center rounded text-secondary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",onClick:()=>z(t),children:i.jsx(J,{size:18,"aria-hidden":"true"})}):null]},`${t.kind}:${t.id}`),D=(t,u)=>u.length>0?i.jsxs("section",{"aria-label":t,className:"mt-2",children:[i.jsx("h3",{className:"px-2 py-2 text-[13px] font-medium text-secondary",children:t}),u.map(m=>w(m))]}):null,Q=(t,u,m)=>u.length>0?i.jsxs("details",{open:m,className:"mt-2 border-y border-default",children:[i.jsxs("summary",{className:"min-h-11 cursor-pointer px-2 py-3 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[t," (",u.length,")"]}),u.map(v=>w(v))]},`${l?.id??"root"}:${t}`):null;return i.jsxs("div",{className:"min-w-0",children:[i.jsx("span",{id:`${a}-label`,className:p==="sr-only"?"sr-only":"mb-1 block text-sm font-medium text-heading",children:d}),i.jsxs("details",{ref:C,className:"relative",onToggle:t=>{t.target===t.currentTarget&&t.currentTarget.open&&I.current?.focus()},onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),t.currentTarget.open=!1,t.currentTarget.querySelector("summary")?.focus())},children:[i.jsxs("summary",{id:`${a}-value`,"aria-labelledby":`${a}-label ${a}-value`,className:`${X} visibility-scope-trigger`,onClick:()=>{C.current?.open||ie()},children:[`${E(r)}${r.kind==="group"?` · ${ee(r.targetCount)}`:r.kind==="property"?` · ${s.find(t=>t.kind==="market"&&t.id===c)?.label??(r.marketKeys?.length?q.allMarkets:"Property")}`:r.kind==="market"?" · Market":""}`,i.jsx(de,{size:16,"aria-hidden":"true",className:"shrink-0 text-secondary"})]}),i.jsxs("div",{className:"visibility-scope-menu",children:[l||g?i.jsxs("div",{className:"mb-2 border-b border-default pb-2",children:[i.jsx("button",{type:"button",className:G,"aria-label":`Back to ${F?.label??"all groups"}`,onClick:()=>{k(N.slice(0,-1)),$(!1),b(""),I.current?.focus()},children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(pe,{size:16,"aria-hidden":"true"}),F?.label??"All groups"]})}),i.jsx("p",{className:"px-2 py-1 text-sm font-medium text-heading","aria-live":"polite",children:l?.label??"All properties"})]}):null,i.jsx("input",{ref:I,type:"search","aria-label":"Search scopes",className:X,placeholder:l?"Search within this group":g?"Search properties":"Search groups or properties",value:f,onChange:t=>b(t.target.value)}),i.jsxs("div",{className:"mt-2 max-h-80 overflow-y-auto",children:[n&&l&&!x?w(l,"All properties in this group"):null,Y.map(t=>w(t)),l&&!x?Q("Subgroups",A,!0):D(l?"Subgroups":"Groups",A),x?D("Properties",V):Q(l&&A.length>0?"All properties":"Properties",V,!l||A.length===0),D("Markets",W),!l&&!g&&!x&&y.length>0&&_.length>0?i.jsxs("button",{type:"button",className:`${G} mt-2 border-t border-default`,"aria-label":q.browseAll,onClick:()=>{$(!0),I.current?.focus()},children:[i.jsx("span",{children:"All properties"}),i.jsx(J,{size:18,"aria-hidden":"true"})]}):null,x&&A.length+V.length+W.length+Y.length===0?i.jsx("p",{className:"py-3 text-sm text-secondary",children:"No matching scopes."}):null]})]})]})]})}function Ee(e){const r=e[0];return r?e.every(o=>o.mode===r.mode&&o.scope.kind===r.scope.kind&&o.scope.key===r.scope.key&&o.queryClass===r.queryClass&&o.measurement.displayedRunId===r.measurement.displayedRunId):!0}function M(e){return e.state==="unavailable"?{numerator:null,denominator:null,reason:e.reason}:e.numerator===void 0||e.denominator===void 0||e.denominator<=0?{numerator:null,denominator:null,reason:"not_applicable"}:{numerator:e.numerator,denominator:e.denominator,...e.unattributed===void 0?{}:{unattributed:e.unattributed},...e.unchecked===void 0?{}:{unchecked:e.unchecked}}}function ye(e){return e.kind==="exact"?e.url:e.kind==="prefix"?`https://${e.host}${e.pathPrefix}/*`:`https://${e.host}/*`}function be(e){return e==="assigned"?"this-property":e==="sibling"?"another-property":e==="ownedUnmapped"?"owned-unassigned":e==="external"?"external":e==="ambiguous"?"multiple-properties":"invalid-url"}function xe(e){return e==="assigned"?"positive":e==="external"?"neutral":e==="invalid"?"negative":"caution"}function te(e){return`target:${e.targetKey}:${e.queryId}:${e.executionNodeKey}`}function ke(e,r,o){const c=new Map;if(!r)return c;const d=new Map(e.usageEdges.map(s=>[te(s),s.targetKey])),p=new Map(e.assignments.map(s=>[`${s.targetKey}:${s.queryId}`,s.queryClass])),n=new Map(e.usageEdges.map(s=>[te(s),p.get(`${s.targetKey}:${s.queryId}`)]));for(const s of r.evidence){if(o&&n.get(s.usageEdgeId)!==o)continue;const f=d.get(s.usageEdgeId);if(!f)continue;const b=c.get(f)??[];b.push({id:`${s.observationId}:${s.expectedSlotId}:${s.usageEdgeId}:${s.sourceUrl}`,kind:be(s.classification),query:s.queryText,provider:s.provider,location:s.location,url:s.sourceUrl,tone:xe(s.classification),historical:s.historical||s.bridged}),c.set(f,b)}return c}function Ce(e){if(e.flags>0)return{label:"Review",tone:"caution"};const r=[e.mentionCoverage,e.citationCoverage].filter(o=>o.state==="unavailable").map(o=>o.reason);return r.includes("no_completed_run")?{label:"Not measured",tone:"neutral"}:r.includes("plan_v1")?{label:"Update setup",tone:"caution"}:r.includes("evidence_incomplete")?{label:"Evidence incomplete",tone:"caution"}:r.includes("identity_ambiguous")?{label:ue.ambiguous,tone:"caution"}:r.includes("no_population")?{label:"No queries",tone:"neutral"}:r.includes("not_applicable")?{label:"Not applicable",tone:"neutral"}:{label:"Complete",tone:"positive"}}function je(e){return e==="complete"?{label:"Complete",tone:"positive"}:e==="partial"?{label:"Partial",tone:"caution"}:e==="queued"?{label:"Queued",tone:"neutral"}:e==="running"?{label:"Running",tone:"neutral"}:e==="failed"?{label:"Failed",tone:"negative"}:{label:"Not measured",tone:"neutral"}}function Ne(e){if(!e)return"";const r=new Date(e);return Number.isFinite(r.getTime())?r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}):""}function re(e){const r=e.nextAction.count??e.flags.total;if(e.nextAction.kind==="review_flags")return`${r} flagged ${r===1?"result needs":"results need"} review.`;if(e.nextAction.kind==="complete_setup")return"Finish setup.";if(e.nextAction.kind==="republish_setup")return"Setup update required.";if(e.nextAction.kind==="run_measurement")return"Ready to measure."}function qe({overview:e,activePlan:r,report:o,reportState:c=o?"ready":"loading",sort:d}){if(r.plan.schemaVersion!==2||e.mode!=="active-v2")throw new Error("The current overview requires an active version-two setup.");if(e.scope.kind!=="all"&&e.scope.kind!=="group")throw new Error("The current overview requires an All Properties or group scope.");const p=r.plan,n=new Map(p.targets.map(a=>[a.stableKey,a])),s=new Map(p.querySnapshots.map(a=>[a.queryId,a.queryText])),f=new Map;for(const a of p.assignments){if(e.queryClass!=="all"&&a.queryClass!==e.queryClass)continue;const y=s.get(a.queryId);if(!y)continue;const h=f.get(a.targetKey)??new Set;h.add(y),f.set(a.targetKey,h)}const b=o?.revision===r.revision&&o.run?.id===e.measurement.displayedRunId?o:null,N=e.measurement.displayedRunId===void 0||b?"ready":c==="error"||o!=null?"error":"loading",k=ke(p,b,e.queryClass==="all"?void 0:e.queryClass),g=new Map;for(const a of p.groups)for(const y of a.targetKeys)g.has(y)||g.set(y,a.label);const $=e.properties.items.map(a=>{const y=n.get(a.targetKey),h=k.get(a.targetKey)??[];return{id:a.targetKey,name:a.label,mentionCoverage:M(a.mentionCoverage),citationCoverage:M(a.citationCoverage),status:Ce(a),providers:a.providers?.map(l=>({provider:l.provider,mentionCoverage:M(l.mentionCoverage),citationCoverage:M(l.citationCoverage)})),market:g.get(a.targetKey),assignedQueries:[...f.get(a.targetKey)??[]],urls:y?.urlMatchers.map(ye)??[],evidence:h,evidenceState:N,historical:h.some(l=>l.historical)}}),C=e.namedShareOfVoice?.entries.map(a=>({name:a.label,coverage:{numerator:a.credits,denominator:e.namedShareOfVoice.denominator}})),I=e.properties.items.flatMap(a=>a.flags>0?[{id:`property:${a.targetKey}`,property:a.label,summary:`${a.flags} ${a.flags===1?"result needs":"results need"} review.`,tone:"caution",count:a.flags}]:[]);return{classReporting:"available",latestMeasurement:{status:je(e.measurement.state),completedSlots:e.measurement.completed,totalSlots:e.measurement.expected,date:Ne(e.measurement.completedAt),includesBridgedHistory:e.measurement.includesHistoricalData===!0},currentView:{scope:e.scope.kind==="group"?{kind:"group",...e.scope.key?{key:e.scope.key}:{}}:{kind:"all"},queryClass:e.queryClass,aggregate:{metrics:{propertiesMentioned:M(e.metrics.propertiesMentioned),mentionCoverage:M(e.metrics.mentionCoverage),citationCoverage:M(e.metrics.citationCoverage)},properties:$,...C?{shareOfVoice:C}:{}},propertyTotal:e.properties.totalEstimate??$.length,outcomes:e.outcomes,nextCursor:e.properties.nextCursor,...d?{sort:d}:{}},availableGroups:p.groups.map(a=>({id:a.stableKey,label:a.label})),...re(e)?{nextActionText:re(e)}:{},flaggedResultsTotal:e.flags.total,flaggedResults:I}}export{Se as A,q as M,Ke as V,Ae as a,Ee as b,qe as c,ye as m};
1
+ import{r as j,j as i}from"./vendor-tanstack-ZXXkndVj.js";import{Q as ae,eh as oe,B as le,aZ as ue}from"./index-BhXHm5nG.js";import{M as ce}from"./vendor-markdown-B4giJcws.js";import{C as de,$ as pe,g as J}from"./vendor-lucide-N6vOpZmh.js";const Ae="Sources",B={copy:"Copy answer",copying:"Copying…",copied:"Copied",failed:"Could not copy. Select and copy the answer above."};function me({previewLength:e,highlight:r}){return o=>{if(e!==void 0&&Number.isFinite(e)){let c=Math.max(0,Math.floor(e));const d={field:"value",omitted:!1},p=n=>{if(n.type==="definition")return!0;if(n.children)return n.children=n.children.filter(p),n.children.length>0;const s=n.type==="image"||n.type==="imageReference"?"alt":"value",f=n[s];if(f===void 0)return c>0;const b=Array.from(f);if(b.length===0)return c>0;if(c===0)return d.omitted=!0,!1;const N=b.length>c,k=b.slice(0,c);if(N&&!/\s/.test(b[c])){let g=k.length-1;for(;g>=0&&!/\s/.test(k[g]);)g--;g>=0&&g>c-40&&(k.length=g)}return d.omitted||=N,n[s]=k.join(""),c=N?0:c-k.length,k.length===0?!1:(d.lastNode=n,d.field=s,!0)};p(o),d.omitted&&(d.lastNode?d.lastNode[d.field]=`${d.lastNode[d.field].trimEnd()}…`:o.children?.push({type:"paragraph",children:[{type:"text",value:"…"}]}))}if(r){const c=d=>{["link","linkReference","code","inlineCode"].includes(d.type)||(d.type==="text"&&(d.data={...d.data,hName:"span"}),d.children?.forEach(c))};c(o)}}}function fe({headingLevel:e}){return r=>{const o=[],c=p=>{p.type==="heading"&&p.depth&&o.push(p),p.children?.forEach(c)};c(r);const d=o.reduce((p,n)=>Math.min(p,n.depth),6);for(const p of o){const n=p.depth-d;p.depth=Math.min(6,e+n),p.data={...p.data,hProperties:{...p.data?.hProperties,"data-answer-heading-level":n+1}}}}}function ge({answer:e}){const[r,o]=j.useState("idle"),c=j.useRef(!1),d=async()=>{if(!c.current){c.current=!0,o("copying");try{await navigator.clipboard.writeText(e),o("copied")}catch{o("failed")}finally{c.current=!1}}};return i.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3",children:[i.jsx(le,{type:"button",variant:"ghost",className:"min-h-11 px-2","aria-disabled":r==="copying","aria-busy":r==="copying",onClick:()=>{d()},children:r==="copying"?B.copying:B.copy}),i.jsx("span",{role:"status",className:"text-sm text-secondary",children:r==="copied"?B.copied:r==="failed"?B.failed:""})]})}const Se=j.memo(function({children:r,headingLevel:o=4,copyable:c=!1,highlightGroups:d,previewLength:p}){return i.jsxs("div",{className:"answer-markdown",children:[i.jsx(ce,{remarkPlugins:[[fe,{headingLevel:o}],[me,{previewLength:p,highlight:!!d?.length}]],components:{p:({children:n})=>i.jsx("p",{className:"mb-3 whitespace-pre-wrap last:mb-0",children:n}),ul:({children:n})=>i.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1",children:n}),ol:({children:n,start:s})=>i.jsx("ol",{start:s,className:"mb-3 ml-5 list-decimal space-y-1",children:n}),pre:({children:n})=>i.jsx("pre",{className:"mb-3 overflow-x-auto whitespace-pre-wrap",children:n}),span:({children:n})=>i.jsx("span",{children:typeof n=="string"&&d?n.split(/(https?:\/\/[^\s<>]+)/i).map((s,f)=>f%2?s:i.jsx(j.Fragment,{children:oe(s,d)},f)):n}),a:({children:n,href:s})=>{const f=ae(s);return f?i.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-link underline",children:n}):i.jsx("span",{children:n})},img:({alt:n})=>i.jsx("span",{children:n})},children:r}),c&&r.trim()?i.jsx(ge,{answer:r},r):null]})}),X="min-h-11 w-full rounded-md border border-default bg-surface px-3 py-2 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",G="flex min-h-11 w-full items-center justify-between gap-3 rounded px-2 text-left text-sm text-primary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",E=e=>e.kind==="project"?"Whole site":e.label,q={allMarkets:"All markets",browse:e=>`Browse ${e}`,select:e=>`Select ${e}`,browseAll:"Browse all properties"},he=e=>e?.kind==="group"&&e.marketKeys?.length===1?e.marketKeys[0]:void 0,ee=e=>`${e} ${e===1?"property":"properties"}`;function Ke({options:e,selected:r,onSelect:o,marketKey:c,label:d="Measurement scope",labelVisibility:p="visible",allowGroupSelect:n=!0}){const s=[...e].sort((t,u)=>t.label.localeCompare(u.label,void 0,{numeric:!0})||t.id.localeCompare(u.id)),[f,b]=j.useState(""),[N,k]=j.useState([]),[g,$]=j.useState(!1),C=j.useRef(null),I=j.useRef(null),a=j.useId(),y=s.filter(t=>t.kind==="group"),h=new Map(y.map(t=>[t.id,t])),l=h.get(N.at(-1)??""),F=h.get(N.at(-2)??""),x=f.trim().toLocaleLowerCase(),ne=y.filter(t=>!t.parentGroupIds?.some(u=>h.has(u))),_=s.filter(t=>t.kind==="property"),O=t=>(t.parentGroupIds??[]).map(u=>h.get(u)?.label).filter(Boolean).join(" · "),P=t=>`${E(t)} ${O(t)}`.toLocaleLowerCase().includes(x),U=t=>{const u=[...t.parentGroupIds??[]],m=new Set;for(;u.length;){const v=u.pop();if(v===l?.id)return!0;m.has(v)||(m.add(v),u.push(...h.get(v)?.parentGroupIds??[]))}return!1},A=(g?[]:l?y.filter(t=>x?U(t):t.parentGroupIds?.includes(l.id)):x?y:ne).filter(P),S=s.find(t=>t.kind==="market"&&t.id===(c??(r.kind==="market"?r.id:void 0))),H=l&&S&&(l.marketKeys?.includes(S.id)||S.parentGroupIds?.includes(l.id))?S.id:void 0,L=n?H??he(l):void 0,V=(l?_.filter(t=>t.parentGroupIds?.includes(l.id)&&(!L||t.marketKeys?.includes(L))):x||g||y.length===0?_:[]).filter(P),W=s.filter(t=>t.kind!=="market"||g||!n&&!l&&!x&&y.length>0||n&&l?.marketKeys?.length===1&&!x?!1:(l?x?U(t):t.parentGroupIds?.includes(l.id):x||!t.parentGroupIds?.some(m=>h.has(m)))&&P(t)),Y=l||g?[]:s.filter(t=>t.kind==="project"&&P(t));j.useEffect(()=>{const t=u=>{C.current?.open&&u.target instanceof Node&&!C.current.contains(u.target)&&(C.current.open=!1)};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[]);const se=t=>{C.current&&(C.current.open=!1,C.current.querySelector("summary")?.focus());const u=n?t.kind==="property"?L:t.kind==="group"&&t.id===l?.id?H:void 0:void 0;u?o(t,u):o(t)},T=t=>{const u=[];let m=h.get(t.parentGroupIds?.[0]??"");for(;m&&!u.includes(m.id)&&m.id!==t.id;)u.unshift(m.id),m=h.get(m.parentGroupIds?.[0]??"");return[...u,t.id]},ie=()=>{const t=r.kind==="group"?h.get(r.id):void 0,u=h.get(S?.parentGroupIds?.[0]??""),m=(r.parentGroupIds??[]).flatMap(K=>{const R=h.get(K);return R?[T(R)]:[]}),v=m.find(K=>K.at(-1)===l?.id)??m.sort((K,R)=>R.length-K.length)[0]??[],Z=u?T(u):r.marketKeys?.length?[]:v;k(t?T(t):Z),$(r.kind==="property"&&Z.length===0&&y.length>0),b("")},z=t=>{k(T(t)),$(!1),b(""),I.current?.focus()},w=(t,u=E(t))=>i.jsxs("div",{className:"flex items-stretch",children:[i.jsxs("button",{type:"button",className:G,"aria-label":t.kind==="group"&&!n?q.browse(E(t)):q.select(E(t)),"aria-current":r.kind===t.kind&&r.id===t.id?"true":void 0,onClick:()=>t.kind==="group"&&!n?z(t):se(t),children:[i.jsxs("span",{className:"min-w-0 break-words",children:[u,x&&O(t)?i.jsx("span",{className:"block text-[13px] text-secondary",children:O(t)}):null]}),i.jsx("span",{className:"shrink-0 text-right text-[13px] text-secondary",children:t.kind==="market"?n?"Query context":"Market":t.kind==="property"?"Property":ee(t.targetCount)})]}),n&&t.kind==="group"&&t.id!==l?.id&&s.some(m=>m.parentGroupIds?.includes(t.id))?i.jsx("button",{type:"button","aria-label":q.browse(t.label),title:`Browse ${t.label}`,className:"flex min-h-11 min-w-11 items-center justify-center rounded text-secondary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",onClick:()=>z(t),children:i.jsx(J,{size:18,"aria-hidden":"true"})}):null]},`${t.kind}:${t.id}`),D=(t,u)=>u.length>0?i.jsxs("section",{"aria-label":t,className:"mt-2",children:[i.jsx("h3",{className:"px-2 py-2 text-[13px] font-medium text-secondary",children:t}),u.map(m=>w(m))]}):null,Q=(t,u,m)=>u.length>0?i.jsxs("details",{open:m,className:"mt-2 border-y border-default",children:[i.jsxs("summary",{className:"min-h-11 cursor-pointer px-2 py-3 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[t," (",u.length,")"]}),u.map(v=>w(v))]},`${l?.id??"root"}:${t}`):null;return i.jsxs("div",{className:"min-w-0",children:[i.jsx("span",{id:`${a}-label`,className:p==="sr-only"?"sr-only":"mb-1 block text-sm font-medium text-heading",children:d}),i.jsxs("details",{ref:C,className:"relative",onToggle:t=>{t.target===t.currentTarget&&t.currentTarget.open&&I.current?.focus()},onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),t.currentTarget.open=!1,t.currentTarget.querySelector("summary")?.focus())},children:[i.jsxs("summary",{id:`${a}-value`,"aria-labelledby":`${a}-label ${a}-value`,className:`${X} visibility-scope-trigger`,onClick:()=>{C.current?.open||ie()},children:[`${E(r)}${r.kind==="group"?` · ${ee(r.targetCount)}`:r.kind==="property"?` · ${s.find(t=>t.kind==="market"&&t.id===c)?.label??(r.marketKeys?.length?q.allMarkets:"Property")}`:r.kind==="market"?" · Market":""}`,i.jsx(de,{size:16,"aria-hidden":"true",className:"shrink-0 text-secondary"})]}),i.jsxs("div",{className:"visibility-scope-menu",children:[l||g?i.jsxs("div",{className:"mb-2 border-b border-default pb-2",children:[i.jsx("button",{type:"button",className:G,"aria-label":`Back to ${F?.label??"all groups"}`,onClick:()=>{k(N.slice(0,-1)),$(!1),b(""),I.current?.focus()},children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(pe,{size:16,"aria-hidden":"true"}),F?.label??"All groups"]})}),i.jsx("p",{className:"px-2 py-1 text-sm font-medium text-heading","aria-live":"polite",children:l?.label??"All properties"})]}):null,i.jsx("input",{ref:I,type:"search","aria-label":"Search scopes",className:X,placeholder:l?"Search within this group":g?"Search properties":"Search groups or properties",value:f,onChange:t=>b(t.target.value)}),i.jsxs("div",{className:"mt-2 max-h-80 overflow-y-auto",children:[n&&l&&!x?w(l,"All properties in this group"):null,Y.map(t=>w(t)),l&&!x?Q("Subgroups",A,!0):D(l?"Subgroups":"Groups",A),x?D("Properties",V):Q(l&&A.length>0?"All properties":"Properties",V,!l||A.length===0),D("Markets",W),!l&&!g&&!x&&y.length>0&&_.length>0?i.jsxs("button",{type:"button",className:`${G} mt-2 border-t border-default`,"aria-label":q.browseAll,onClick:()=>{$(!0),I.current?.focus()},children:[i.jsx("span",{children:"All properties"}),i.jsx(J,{size:18,"aria-hidden":"true"})]}):null,x&&A.length+V.length+W.length+Y.length===0?i.jsx("p",{className:"py-3 text-sm text-secondary",children:"No matching scopes."}):null]})]})]})]})}function Ee(e){const r=e[0];return r?e.every(o=>o.mode===r.mode&&o.scope.kind===r.scope.kind&&o.scope.key===r.scope.key&&o.queryClass===r.queryClass&&o.measurement.displayedRunId===r.measurement.displayedRunId):!0}function M(e){return e.state==="unavailable"?{numerator:null,denominator:null,reason:e.reason}:e.numerator===void 0||e.denominator===void 0||e.denominator<=0?{numerator:null,denominator:null,reason:"not_applicable"}:{numerator:e.numerator,denominator:e.denominator,...e.unattributed===void 0?{}:{unattributed:e.unattributed},...e.unchecked===void 0?{}:{unchecked:e.unchecked}}}function ye(e){return e.kind==="exact"?e.url:e.kind==="prefix"?`https://${e.host}${e.pathPrefix}/*`:`https://${e.host}/*`}function be(e){return e==="assigned"?"this-property":e==="sibling"?"another-property":e==="ownedUnmapped"?"owned-unassigned":e==="external"?"external":e==="ambiguous"?"multiple-properties":"invalid-url"}function xe(e){return e==="assigned"?"positive":e==="external"?"neutral":e==="invalid"?"negative":"caution"}function te(e){return`target:${e.targetKey}:${e.queryId}:${e.executionNodeKey}`}function ke(e,r,o){const c=new Map;if(!r)return c;const d=new Map(e.usageEdges.map(s=>[te(s),s.targetKey])),p=new Map(e.assignments.map(s=>[`${s.targetKey}:${s.queryId}`,s.queryClass])),n=new Map(e.usageEdges.map(s=>[te(s),p.get(`${s.targetKey}:${s.queryId}`)]));for(const s of r.evidence){if(o&&n.get(s.usageEdgeId)!==o)continue;const f=d.get(s.usageEdgeId);if(!f)continue;const b=c.get(f)??[];b.push({id:`${s.observationId}:${s.expectedSlotId}:${s.usageEdgeId}:${s.sourceUrl}`,kind:be(s.classification),query:s.queryText,provider:s.provider,location:s.location,url:s.sourceUrl,tone:xe(s.classification),historical:s.historical||s.bridged}),c.set(f,b)}return c}function Ce(e){if(e.flags>0)return{label:"Review",tone:"caution"};const r=[e.mentionCoverage,e.citationCoverage].filter(o=>o.state==="unavailable").map(o=>o.reason);return r.includes("no_completed_run")?{label:"Not measured",tone:"neutral"}:r.includes("plan_v1")?{label:"Update setup",tone:"caution"}:r.includes("evidence_incomplete")?{label:"Evidence incomplete",tone:"caution"}:r.includes("identity_ambiguous")?{label:ue.ambiguous,tone:"caution"}:r.includes("no_population")?{label:"No queries",tone:"neutral"}:r.includes("not_applicable")?{label:"Not applicable",tone:"neutral"}:{label:"Complete",tone:"positive"}}function je(e){return e==="complete"?{label:"Complete",tone:"positive"}:e==="partial"?{label:"Partial",tone:"caution"}:e==="queued"?{label:"Queued",tone:"neutral"}:e==="running"?{label:"Running",tone:"neutral"}:e==="failed"?{label:"Failed",tone:"negative"}:{label:"Not measured",tone:"neutral"}}function Ne(e){if(!e)return"";const r=new Date(e);return Number.isFinite(r.getTime())?r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}):""}function re(e){const r=e.nextAction.count??e.flags.total;if(e.nextAction.kind==="review_flags")return`${r} flagged ${r===1?"result needs":"results need"} review.`;if(e.nextAction.kind==="complete_setup")return"Finish setup.";if(e.nextAction.kind==="republish_setup")return"Setup update required.";if(e.nextAction.kind==="run_measurement")return"Ready to measure."}function qe({overview:e,activePlan:r,report:o,reportState:c=o?"ready":"loading",sort:d}){if(r.plan.schemaVersion!==2||e.mode!=="active-v2")throw new Error("The current overview requires an active version-two setup.");if(e.scope.kind!=="all"&&e.scope.kind!=="group")throw new Error("The current overview requires an All Properties or group scope.");const p=r.plan,n=new Map(p.targets.map(a=>[a.stableKey,a])),s=new Map(p.querySnapshots.map(a=>[a.queryId,a.queryText])),f=new Map;for(const a of p.assignments){if(e.queryClass!=="all"&&a.queryClass!==e.queryClass)continue;const y=s.get(a.queryId);if(!y)continue;const h=f.get(a.targetKey)??new Set;h.add(y),f.set(a.targetKey,h)}const b=o?.revision===r.revision&&o.run?.id===e.measurement.displayedRunId?o:null,N=e.measurement.displayedRunId===void 0||b?"ready":c==="error"||o!=null?"error":"loading",k=ke(p,b,e.queryClass==="all"?void 0:e.queryClass),g=new Map;for(const a of p.groups)for(const y of a.targetKeys)g.has(y)||g.set(y,a.label);const $=e.properties.items.map(a=>{const y=n.get(a.targetKey),h=k.get(a.targetKey)??[];return{id:a.targetKey,name:a.label,mentionCoverage:M(a.mentionCoverage),citationCoverage:M(a.citationCoverage),status:Ce(a),providers:a.providers?.map(l=>({provider:l.provider,mentionCoverage:M(l.mentionCoverage),citationCoverage:M(l.citationCoverage)})),market:g.get(a.targetKey),assignedQueries:[...f.get(a.targetKey)??[]],urls:y?.urlMatchers.map(ye)??[],evidence:h,evidenceState:N,historical:h.some(l=>l.historical)}}),C=e.namedShareOfVoice?.entries.map(a=>({name:a.label,coverage:{numerator:a.credits,denominator:e.namedShareOfVoice.denominator}})),I=e.properties.items.flatMap(a=>a.flags>0?[{id:`property:${a.targetKey}`,property:a.label,summary:`${a.flags} ${a.flags===1?"result needs":"results need"} review.`,tone:"caution",count:a.flags}]:[]);return{classReporting:"available",latestMeasurement:{status:je(e.measurement.state),completedSlots:e.measurement.completed,totalSlots:e.measurement.expected,date:Ne(e.measurement.completedAt),includesBridgedHistory:e.measurement.includesHistoricalData===!0},currentView:{scope:e.scope.kind==="group"?{kind:"group",...e.scope.key?{key:e.scope.key}:{}}:{kind:"all"},queryClass:e.queryClass,aggregate:{metrics:{propertiesMentioned:M(e.metrics.propertiesMentioned),mentionCoverage:M(e.metrics.mentionCoverage),citationCoverage:M(e.metrics.citationCoverage)},properties:$,...C?{shareOfVoice:C}:{}},propertyTotal:e.properties.totalEstimate??$.length,outcomes:e.outcomes,nextCursor:e.properties.nextCursor,...d?{sort:d}:{}},availableGroups:p.groups.map(a=>({id:a.stableKey,label:a.label})),...re(e)?{nextActionText:re(e)}:{},flaggedResultsTotal:e.flags.total,flaggedResults:I}}export{Se as A,q as M,Ke as V,Ae as a,Ee as b,qe as c,ye as m};
package/assets/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
13
13
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
14
14
  <title>Canonry</title>
15
- <script type="module" crossorigin src="./assets/index-BLJfGYUw.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-BhXHm5nG.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/vendor-tanstack-ZXXkndVj.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/vendor-radix-twS1M3FF.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/vendor-recharts-D-cUuLZo.js">
@@ -807,7 +807,7 @@ import {
807
807
  wordpressSchemaDeployResultDtoSchema,
808
808
  wordpressSchemaStatusResultDtoSchema,
809
809
  wordpressStatusDtoSchema
810
- } from "./chunk-DO7XPDG5.js";
810
+ } from "./chunk-66DVP4DN.js";
811
811
 
812
812
  // src/intelligence-service.ts
813
813
  import { eq as eq84, desc as desc38, asc as asc15, and as and71, ne as ne15, or as or20, inArray as inArray34, gte as gte23, lte as lte20, isNull as isNull16, sql as sql32, exists as exists2 } from "drizzle-orm";
@@ -13751,7 +13751,8 @@ var SentimentService = class {
13751
13751
  if (disabled) for (const tally of tallies.values()) tally.counts = withheldCounts(tally.counts);
13752
13752
  return tallies;
13753
13753
  }
13754
- resolve(projectId, selection) {
13754
+ /** `selected` reuses a source selection already made for this exact selection and run. */
13755
+ resolve(projectId, selection, selected) {
13755
13756
  if (selection.runId && selection.runIds) throw validationError("Choose runId or runIds, not both.");
13756
13757
  if (selection.scope !== "project" && !selection.scopeKey) throw validationError("A scopeKey is required for property, group, and market sentiment selections.");
13757
13758
  if (selection.evaluationDefinitionId && this.repository.getSettings(projectId)?.evaluationDefinitionId !== selection.evaluationDefinitionId) {
@@ -13770,7 +13771,7 @@ var SentimentService = class {
13770
13771
  }
13771
13772
  const run = selection.runId ? this.db.select().from(runs).where(and4(eq9(runs.id, selection.runId), eq9(runs.projectId, projectId))).get() : this.db.select().from(runs).where(and4(...conditions)).orderBy(desc3(runs.createdAt)).get();
13772
13773
  if (selection.runId && !run) throw notFound("Run", selection.runId);
13773
- const source = run ? selectSentimentSources(this.db, projectId, { ...sourceFilter(selection), runId: run.id }) : emptySource();
13774
+ const source = run ? selected ?? selectSentimentSources(this.db, projectId, { ...sourceFilter(selection), runId: run.id }) : emptySource();
13774
13775
  const allowedSubjects = new Set(source.assessments.map((item2) => `${item2.snapshotId}:${item2.subject.key}`));
13775
13776
  const latest = run && !selection.evaluationDefinitionId ? this.db.select({ definitionId: sentimentWorkItems.evaluationDefinitionId, snapshotId: sentimentWorkItems.snapshotId, subjectId: sql6`json_extract(${sentimentWorkItems.input}, '$.subject.id')` }).from(sentimentWorkItems).innerJoin(sentimentJobItems, eq9(sentimentJobItems.workItemId, sentimentWorkItems.id)).innerJoin(sentimentJobs, eq9(sentimentJobs.id, sentimentJobItems.jobId)).where(and4(eq9(sentimentWorkItems.projectId, projectId), eq9(sentimentWorkItems.runId, run.id))).orderBy(desc3(sentimentJobs.createdAt), sql6`${sentimentJobs}.rowid desc`).all().find((row) => allowedSubjects.has(`${row.snapshotId}:${row.subjectId}`)) : void 0;
13776
13777
  const revision = run?.measurementPlanVersionId ? this.db.select({ revision: measurementPlanVersions.revision }).from(measurementPlanVersions).where(eq9(measurementPlanVersions.id, run.measurementPlanVersionId)).get()?.revision ?? null : null;
@@ -13976,8 +13977,18 @@ var SentimentService = class {
13976
13977
  throw validationError(incomplete ? "The target run is incomplete; no sentiment trend can be selected." : "The target run has no eligible sentiment population for this selection.", { reason: incomplete ? "target-incomplete" : "target-population-unavailable" });
13977
13978
  }
13978
13979
  const filter = sourceFilter(query);
13979
- const population = (source) => new Set(source.assessments.map((member) => comparisonUnit(sentimentClassifierIdentity({ ...member, edges: member.edges.filter((edge) => matchesSentimentEdge(edge, filter)) }))));
13980
- const targetUnits = population(selected.source);
13980
+ const unit = (member) => comparisonUnit(sentimentClassifierIdentity({ ...member, edges: member.edges.filter((edge) => matchesSentimentEdge(edge, filter)) }));
13981
+ const targetUnits = new Set(selected.source.assessments.map(unit));
13982
+ const matchesTarget = (source) => {
13983
+ if (source.assessments.length < targetUnits.size) return false;
13984
+ const units = /* @__PURE__ */ new Set();
13985
+ for (const member of source.assessments) {
13986
+ const key = unit(member);
13987
+ if (!targetUnits.has(key)) return false;
13988
+ units.add(key);
13989
+ }
13990
+ return units.size === targetUnits.size;
13991
+ };
13981
13992
  const requestedVersion = query.revision === void 0 ? void 0 : this.db.select({ id: measurementPlanVersions.id }).from(measurementPlanVersions).where(and4(eq9(measurementPlanVersions.projectId, projectId), eq9(measurementPlanVersions.revision, query.revision))).get()?.id ?? "__missing-revision__";
13982
13993
  const candidates = this.db.selectDistinct({ id: runs.id, createdAt: runs.createdAt }).from(runs).innerJoin(sentimentWorkItems, and4(eq9(sentimentWorkItems.runId, runs.id), eq9(sentimentWorkItems.projectId, projectId))).innerJoin(sentimentResults, eq9(sentimentResults.workItemId, sentimentWorkItems.id)).where(and4(
13983
13994
  eq9(runs.projectId, projectId),
@@ -13985,20 +13996,21 @@ var SentimentService = class {
13985
13996
  notProbeRun(),
13986
13997
  inArray3(sentimentResults.outcome, [...RATED_OUTCOMES]),
13987
13998
  query.evaluationDefinitionId ? eq9(sentimentWorkItems.evaluationDefinitionId, query.evaluationDefinitionId) : void 0,
13988
- query.queryClass ? sql6`exists (select 1 from json_each(${sentimentWorkItems.edges}) as edge where json_extract(edge.value, '$.queryClass') = ${query.queryClass})` : void 0,
13999
+ storedEdgeMatches(filter),
13989
14000
  requestedVersion ? eq9(runs.measurementPlanVersionId, requestedVersion) : void 0,
13990
14001
  or2(lt2(runs.createdAt, target.createdAt), and4(eq9(runs.createdAt, target.createdAt), lt2(runs.id, target.id))),
13991
14002
  target.measurementPlanVersionId ? isNotNull2(runs.measurementPlanVersionId) : isNull2(runs.measurementPlanVersionId)
13992
14003
  )).orderBy(desc3(runs.createdAt), desc3(runs.id)).limit(PREVIOUS_RATED_CANDIDATE_LIMIT + 1).all();
13993
14004
  let newestRatedRunId;
13994
14005
  for (const candidate of candidates.slice(0, PREVIOUS_RATED_CANDIDATE_LIMIT)) {
13995
- const read = this.resolve(projectId, { ...query, runId: candidate.id });
13996
- if (!read.source.assessments.length) continue;
13997
- const candidateUnits = population(read.source);
13998
- if (candidateUnits.size !== targetUnits.size || [...targetUnits].some((key) => !candidateUnits.has(key))) {
14006
+ const selection = { ...query, runId: candidate.id };
14007
+ const source = selectSentimentSources(this.db, projectId, sourceFilter(selection));
14008
+ if (!source.assessments.length) continue;
14009
+ if (!matchesTarget(source)) {
13999
14010
  newestRatedRunId ??= candidate.id;
14000
14011
  continue;
14001
14012
  }
14013
+ const read = this.resolve(projectId, selection, source);
14002
14014
  if (this.items(projectId, read.selection, read.source).some((item2) => RATED_OUTCOMES.has(item2.outcome))) return candidate.id;
14003
14015
  }
14004
14016
  if (candidates.length > PREVIOUS_RATED_CANDIDATE_LIMIT) throw validationError("No compatible rated predecessor was found within the bounded search; select an older run explicitly.", { reason: "previous-rated-search-limit", candidateLimit: PREVIOUS_RATED_CANDIDATE_LIMIT, ...newestRatedRunId ? { newestRatedRunId } : {} });
@@ -14140,6 +14152,21 @@ function sourceFilter(selection) {
14140
14152
  const extra = selection;
14141
14153
  return { mode: selection.mode, runId: selection.runId ?? void 0, runIds: selection.runId ? void 0 : extra.runIds, since: extra.from, until: extra.to, revision: selection.revision ?? void 0, queryClass: selection.queryClass, queryId: selection.queryId, executionNodeKey: selection.executionNodeKey, scope: selection.scope, scopeKey: selection.scopeKey, marketKey: selection.marketKey, provider: selection.provider, sourceModel: selection.model, location: selection.location };
14142
14154
  }
14155
+ function storedEdgeMatches(filter) {
14156
+ const field = (path8) => sql6`json_extract(edge.value, ${path8})`;
14157
+ const contains = (path8, key) => sql6`exists (select 1 from json_each(edge.value, ${path8}) as member where member.value = ${key})`;
14158
+ const conditions = [sql6`${field("$.queryClass")} = ${filter.queryClass ?? "branded"}`];
14159
+ if (filter.queryId) conditions.push(sql6`${field("$.queryKey")} = ${filter.queryId}`);
14160
+ if (filter.executionNodeKey) conditions.push(sql6`${field("$.executionNodeKey")} = ${filter.executionNodeKey}`);
14161
+ if (filter.provider) conditions.push(sql6`${field("$.provider")} = ${filter.provider}`);
14162
+ if (filter.sourceModel) conditions.push(sql6`${field("$.servedModel")} = ${filter.sourceModel}`);
14163
+ if (filter.location) conditions.push(filter.location === "none" ? sql6`${field("$.context")} is null` : sql6`${field("$.context.label")} = ${filter.location}`);
14164
+ if (filter.marketKey) conditions.push(contains("$.marketKeys", filter.marketKey));
14165
+ if (filter.scopeKey && filter.scope === "property") conditions.push(sql6`${field("$.propertyKey")} = ${filter.scopeKey}`);
14166
+ if (filter.scopeKey && filter.scope === "group") conditions.push(contains("$.groupKeys", filter.scopeKey));
14167
+ if (filter.scopeKey && filter.scope === "market") conditions.push(contains("$.marketKeys", filter.scopeKey));
14168
+ return sql6`exists (select 1 from json_each(${sentimentWorkItems.edges}) as edge where ${sql6.join(conditions, sql6` and `)})`;
14169
+ }
14143
14170
  function outcome(status, result) {
14144
14171
  return sentimentOutcomeSchema.parse(status === "completed" ? result ?? "failed" : status);
14145
14172
  }
@@ -25912,19 +25939,30 @@ function targetAnswers(plan, target, materialized, filters) {
25912
25939
  function plannedQueryCount(plan, targetKey, queryClass) {
25913
25940
  return new Set(plan.assignments.filter((assignment) => assignment.targetKey === targetKey).filter((assignment) => queryClass === "all" || assignment.queryClass === queryClass).map((assignment) => assignment.queryId)).size;
25914
25941
  }
25915
- function answerDomains(answer) {
25916
- const domains = /* @__PURE__ */ new Set();
25942
+ function createCitedHostReader() {
25943
+ const resolved = /* @__PURE__ */ new Map();
25944
+ return (raw) => {
25945
+ let cited = resolved.get(raw);
25946
+ if (cited === void 0) {
25947
+ const host = hostOf(raw);
25948
+ cited = !host || hostMatchesAnyDomain(host, AI_PROVIDER_INFRA_DOMAINS) ? null : { host, domain: registrableDomain(host) || host };
25949
+ resolved.set(raw, cited);
25950
+ }
25951
+ return cited;
25952
+ };
25953
+ }
25954
+ function answerDomains(answer, readHost) {
25955
+ const domains = /* @__PURE__ */ new Map();
25917
25956
  for (const raw of [...answer.snapshot.citedDomains, ...answer.citedUrls]) {
25918
- const host = hostOf(raw);
25919
- if (!host || hostMatchesAnyDomain(host, AI_PROVIDER_INFRA_DOMAINS)) continue;
25920
- domains.add(host);
25957
+ const cited = readHost(raw);
25958
+ if (cited) domains.set(cited.host, cited.domain);
25921
25959
  }
25922
25960
  return domains;
25923
25961
  }
25924
- function domainRows(answers, limit) {
25962
+ function domainRows(answers, limit, readHost = createCitedHostReader()) {
25925
25963
  const counts2 = /* @__PURE__ */ new Map();
25926
25964
  for (const answer of answers) {
25927
- const domains = new Set([...answerDomains(answer)].map((host) => registrableDomain(host) || host));
25965
+ const domains = new Set(answerDomains(answer, readHost).values());
25928
25966
  for (const domain of domains) counts2.set(domain, (counts2.get(domain) ?? 0) + 1);
25929
25967
  }
25930
25968
  const rows = [...counts2].map(([domain, count4]) => ({ domain, answers: count4 })).sort((left, right) => right.answers - left.answers || compareText13(left.domain, right.domain));
@@ -26415,7 +26453,7 @@ function portfolioResponse(db, active, plan, query, ownDomains) {
26415
26453
  citedDomainsTotal: domains.total
26416
26454
  };
26417
26455
  });
26418
- const tie = weakestTie(ranked);
26456
+ const tie = weakestTie(ranked, !query.compact);
26419
26457
  const engines = /* @__PURE__ */ new Set();
26420
26458
  for (const population of populations.values()) for (const provider of population.providers) engines.add(provider);
26421
26459
  const answerEvidence = query.answers !== "not-mentioned" ? void 0 : portfolioAnswerEvidence(plan, materialized, filters, targetKeys);
@@ -26438,12 +26476,7 @@ function portfolioResponse(db, active, plan, query, ownDomains) {
26438
26476
  },
26439
26477
  ...query.compact && group === void 0 ? { weakestMarkets: weakestMarkets(markets.markets, query.queryClass) } : {},
26440
26478
  weakestProperties: rows,
26441
- tiedAtWeakest: query.compact && tie.summary !== null ? {
26442
- count: tie.summary.count,
26443
- mentionRate: tie.summary.mentionRate,
26444
- citationRate: tie.summary.citationRate,
26445
- note: tie.summary.note
26446
- } : tie.summary,
26479
+ tiedAtWeakest: tie.summary,
26447
26480
  ...query.compact ? {
26448
26481
  detailsOmitted: ["weakestProperties.answerEvidence", "tiedAtWeakest.byMetro", "tiedAtWeakest.namedInstead"]
26449
26482
  } : {},
@@ -26465,7 +26498,7 @@ function portfolioResponse(db, active, plan, query, ownDomains) {
26465
26498
  };
26466
26499
  return compactPortfolioPage(response, query, active.version.id, snapshotEvidenceFingerprint([...materialized.snapshotsById.values()]), cursor);
26467
26500
  }
26468
- function weakestTie(ranked) {
26501
+ function weakestTie(ranked, detailed) {
26469
26502
  if (ranked.length === 0) return { summary: null, rows: [] };
26470
26503
  const first = ranked[0];
26471
26504
  if (first.mentionCoverage.state !== "available" || first.citationCoverage.state !== "available") {
@@ -26476,13 +26509,12 @@ function weakestTie(ranked) {
26476
26509
  if (mentionRate3 !== 0 || citationRate2 !== 0) return { summary: null, rows: [] };
26477
26510
  const rows = ranked.filter((row) => row.mentionCoverage.state === "available" && row.mentionCoverage.value === mentionRate3 && row.citationCoverage.state === "available" && row.citationCoverage.value === citationRate2);
26478
26511
  if (rows.length < 2) return { summary: null, rows: [] };
26512
+ const summary3 = { count: rows.length, mentionRate: mentionRate3, citationRate: citationRate2, note: MEASUREMENT_PORTFOLIO_TIE_NOTE };
26513
+ if (!detailed) return { summary: summary3, rows };
26479
26514
  const namedInstead = tieNamedInstead(rows);
26480
26515
  return {
26481
26516
  summary: {
26482
- count: rows.length,
26483
- mentionRate: mentionRate3,
26484
- citationRate: citationRate2,
26485
- note: MEASUREMENT_PORTFOLIO_TIE_NOTE,
26517
+ ...summary3,
26486
26518
  byMetro: tieByMetro(rows),
26487
26519
  namedInstead: namedInstead.rows,
26488
26520
  namedInsteadTotal: namedInstead.total
@@ -26527,10 +26559,11 @@ function weakestAnswerSources(rows, ownDomains) {
26527
26559
  properties.add(row.targetKey);
26528
26560
  for (const answer of row.population.sourceAnswers) answers.set(answer.snapshot.id, answer);
26529
26561
  }
26530
- const domains = domainRows([...answers.values()], MEASUREMENT_PORTFOLIO_ANSWER_SOURCES_LIMIT);
26562
+ const readHost = createCitedHostReader();
26563
+ const domains = domainRows([...answers.values()], MEASUREMENT_PORTFOLIO_ANSWER_SOURCES_LIMIT, readHost);
26531
26564
  let ownDomainAnswers = 0;
26532
26565
  for (const answer of answers.values()) {
26533
- if ([...answerDomains(answer)].some((host) => hostMatchesAnyDomain(host, ownDomains))) ownDomainAnswers++;
26566
+ if ([...answerDomains(answer, readHost).keys()].some((host) => hostMatchesAnyDomain(host, ownDomains))) ownDomainAnswers++;
26534
26567
  }
26535
26568
  return { properties: properties.size, answers: answers.size, domains: domains.rows, domainTotal: domains.total, ownDomainAnswers };
26536
26569
  }
@@ -44098,7 +44131,7 @@ var routeCatalog = [
44098
44131
  method: "get",
44099
44132
  path: "/api/v1/projects/{name}/technical-aeo",
44100
44133
  summary: "Get the Technical AEO scorecard for a project",
44101
- description: "runSelection selects a complete run on the latest UTC scan date, otherwise the largest page sample, then newest; it flags same-date candidates. Factor pagesFailing and pagesPartial are separate; a factor with failing pages is fail. Returns the latest completed/partial site-audit, or the historical audit selected by `runId`: aggregate 0\u2013100 score, page counts, the full per-factor scorecard (site-level averages with pass/partial/fail distribution), cross-cutting issues, prioritized fixes, and the delta vs the audit immediately before it. When the project has never been audited, `hasData` is false and the numeric fields are zeroed \u2014 render an onboarding state.",
44134
+ description: "runSelection selects a complete run on the latest UTC scan date, otherwise the largest page sample, then newest; it flags same-date candidates. Factor pagesFailing and pagesPartial are separate; a factor with failing pages is fail. Returns the latest completed/partial site-audit, or the historical audit selected by `runId`: aggregate 0\u2013100 score, page counts, the full per-factor scorecard (site-level averages with pass/partial/fail distribution), cross-cutting issues, prioritized fixes, and the delta vs the scan a default read returned just before this one was recorded. A default read whose preferred crawl audited no page falls back to the preferred scored crawl. When the project has never been audited, `hasData` is false and the numeric fields are zeroed \u2014 render an onboarding state.",
44102
44135
  tags: ["technical-aeo"],
44103
44136
  parameters: [
44104
44137
  nameParameter,
@@ -85829,14 +85862,16 @@ async function technicalAeoRoutes(app, opts) {
85829
85862
  matchingMonthDayTotal: countDates(matchingDates)
85830
85863
  };
85831
85864
  };
85832
- const resolveCrawl = (projectId, runId, requestedDate) => {
85865
+ const resolveCrawl = (projectId, runId, requestedDate, scope = {}) => {
85833
85866
  const filters = visibleCrawlFilters(projectId);
85867
+ if (scope.recordedBefore) filters.push(lt13(siteCrawlSnapshots.createdAt, scope.recordedBefore));
85834
85868
  if (requestedDate) {
85835
85869
  const nextDate2 = /* @__PURE__ */ new Date(`${requestedDate}T00:00:00.000Z`);
85836
85870
  nextDate2.setUTCDate(nextDate2.getUTCDate() + 1);
85837
85871
  filters.push(gte21(siteCrawlSnapshots.createdAt, requestedDate), lt13(siteCrawlSnapshots.createdAt, nextDate2.toISOString()));
85838
85872
  }
85839
- const selected = app.db.select({ snapshot: siteCrawlSnapshots, runStatus: runs.status }).from(siteCrawlSnapshots).innerJoin(runs, eq80(siteCrawlSnapshots.runId, runs.id)).where(and67(...filters, runId ? eq80(siteCrawlSnapshots.runId, runId) : void 0)).orderBy(
85873
+ const selectionFilters = scope.scoredOnly ? [...filters, sql30`exists (select 1 from ${siteAuditSnapshots} where ${siteAuditSnapshots.projectId} = ${siteCrawlSnapshots.projectId} and ${siteAuditSnapshots.runId} = ${siteCrawlSnapshots.runId})`] : filters;
85874
+ const selected = app.db.select({ snapshot: siteCrawlSnapshots, runStatus: runs.status }).from(siteCrawlSnapshots).innerJoin(runs, eq80(siteCrawlSnapshots.runId, runs.id)).where(and67(...selectionFilters, runId ? eq80(siteCrawlSnapshots.runId, runId) : void 0)).orderBy(
85840
85875
  desc36(sql30`substr(${siteCrawlSnapshots.createdAt}, 1, 10)`),
85841
85876
  desc36(siteCrawlSnapshots.complete),
85842
85877
  desc36(siteCrawlSnapshots.pagesFetched),
@@ -85865,7 +85900,7 @@ async function technicalAeoRoutes(app, opts) {
85865
85900
  desc36(siteCrawlSnapshots.runId)
85866
85901
  ).limit(10).all();
85867
85902
  const runSelection = {
85868
- reason: runId ? "explicit-run" : requestedDate ? selected.snapshot.complete ? "requested-date-complete" : "requested-date-most-pages" : selected.snapshot.complete ? "latest-date-complete" : "latest-date-most-pages",
85903
+ reason: runId ? "explicit-run" : scope.scoredOnly ? "latest-scored-scan" : requestedDate ? selected.snapshot.complete ? "requested-date-complete" : "requested-date-most-pages" : selected.snapshot.complete ? "latest-date-complete" : "latest-date-most-pages",
85869
85904
  date,
85870
85905
  sameDateRunCount,
85871
85906
  ambiguousDate: sameDateRunCount > 1,
@@ -85874,26 +85909,34 @@ async function technicalAeoRoutes(app, opts) {
85874
85909
  };
85875
85910
  return { ...selected, runSelection };
85876
85911
  };
85877
- const resolveAudit = (projectId, runId) => {
85878
- const crawl = resolveCrawl(projectId, runId);
85879
- const selectedRunId = runId ?? crawl?.snapshot.runId;
85912
+ const resolveAudit = (projectId, runId, recordedBefore) => {
85880
85913
  const filters = [
85881
85914
  eq80(siteAuditSnapshots.projectId, projectId),
85882
85915
  eq80(runs.projectId, projectId),
85883
85916
  eq80(runs.kind, RunKinds["site-audit"]),
85884
85917
  inArray32(runs.status, SURFACEABLE_STATUSES),
85885
- notProbeRun()
85918
+ notProbeRun(),
85919
+ ...recordedBefore ? [lt13(siteAuditSnapshots.createdAt, recordedBefore)] : []
85886
85920
  ];
85887
85921
  const complete = sql30`case when ${runs.status} = ${RunStatuses.completed} then 1 else 0 end`;
85888
- const selected = app.db.select({ snap: siteAuditSnapshots, runStatus: runs.status }).from(siteAuditSnapshots).innerJoin(runs, eq80(siteAuditSnapshots.runId, runs.id)).where(and67(...filters, selectedRunId ? eq80(siteAuditSnapshots.runId, selectedRunId) : void 0)).orderBy(
85922
+ const selectAudit = (pinnedRunId) => app.db.select({ snap: siteAuditSnapshots, runStatus: runs.status }).from(siteAuditSnapshots).innerJoin(runs, eq80(siteAuditSnapshots.runId, runs.id)).where(and67(...filters, pinnedRunId ? eq80(siteAuditSnapshots.runId, pinnedRunId) : void 0)).orderBy(
85889
85923
  desc36(sql30`substr(${siteAuditSnapshots.createdAt}, 1, 10)`),
85890
85924
  desc36(complete),
85891
85925
  desc36(siteAuditSnapshots.pagesAudited),
85892
85926
  desc36(siteAuditSnapshots.createdAt),
85893
85927
  desc36(siteAuditSnapshots.runId)
85894
85928
  ).limit(1).get();
85929
+ const auditOfCrawl = (target) => {
85930
+ const selected2 = target ? selectAudit(target.snapshot.runId) : void 0;
85931
+ return target && selected2 ? { ...selected2, runSelection: target.runSelection } : void 0;
85932
+ };
85933
+ const crawl = resolveCrawl(projectId, runId, void 0, { recordedBefore });
85934
+ if (crawl) {
85935
+ const scored = auditOfCrawl(crawl) ?? (runId ? void 0 : auditOfCrawl(resolveCrawl(projectId, void 0, void 0, { recordedBefore, scoredOnly: true })));
85936
+ if (scored || runId) return scored;
85937
+ }
85938
+ const selected = selectAudit(runId);
85895
85939
  if (!selected) return void 0;
85896
- if (crawl) return { ...selected, runSelection: crawl.runSelection };
85897
85940
  const date = selected.snap.createdAt.slice(0, 10);
85898
85941
  const nextDate = /* @__PURE__ */ new Date(`${date}T00:00:00.000Z`);
85899
85942
  nextDate.setUTCDate(nextDate.getUTCDate() + 1);
@@ -85915,7 +85958,8 @@ async function technicalAeoRoutes(app, opts) {
85915
85958
  desc36(siteAuditSnapshots.runId)
85916
85959
  ).limit(10).all().map((candidate) => ({ ...candidate, complete: Boolean(candidate.complete) }));
85917
85960
  const runSelection = {
85918
- reason: runId ? "explicit-run" : selected.runStatus === RunStatuses.completed ? "latest-date-complete" : "latest-date-most-pages",
85961
+ // A crawl exists here only when none stored a scorecard: this score is a fallback.
85962
+ reason: runId ? "explicit-run" : crawl ? "latest-scored-scan" : selected.runStatus === RunStatuses.completed ? "latest-date-complete" : "latest-date-most-pages",
85919
85963
  date,
85920
85964
  sameDateRunCount,
85921
85965
  ambiguousDate: sameDateRunCount > 1,
@@ -86044,13 +86088,6 @@ async function technicalAeoRoutes(app, opts) {
86044
86088
  });
86045
86089
  app.get("/projects/:name/technical-aeo", async (request) => {
86046
86090
  const project = resolveProject(app.db, request.params.name);
86047
- const baseFilters = [
86048
- eq80(siteAuditSnapshots.projectId, project.id),
86049
- eq80(runs.projectId, project.id),
86050
- eq80(runs.kind, RunKinds["site-audit"]),
86051
- inArray32(runs.status, SURFACEABLE_STATUSES),
86052
- notProbeRun()
86053
- ];
86054
86091
  const latest = resolveAudit(project.id, request.query.runId);
86055
86092
  if (!latest) {
86056
86093
  const crawl = resolveCrawl(project.id, request.query.runId);
@@ -86063,7 +86100,9 @@ async function technicalAeoRoutes(app, opts) {
86063
86100
  } : emptyScore(project.name);
86064
86101
  }
86065
86102
  const snap = latest.snap;
86066
- const previous = app.db.select({ snap: siteAuditSnapshots }).from(siteAuditSnapshots).innerJoin(runs, eq80(siteAuditSnapshots.runId, runs.id)).where(and67(...baseFilters, lt13(siteAuditSnapshots.createdAt, snap.createdAt))).orderBy(desc36(siteAuditSnapshots.createdAt)).limit(1).get()?.snap ?? null;
86103
+ const replayed = resolveAudit(project.id, void 0, snap.createdAt);
86104
+ const date = snap.createdAt.slice(0, 10);
86105
+ const previous = replayed && latest.runStatus === RunStatuses.completed && replayed.runStatus !== RunStatuses.completed && replayed.snap.createdAt.startsWith(date) ? resolveAudit(project.id, void 0, `${date}T00:00:00.000Z`)?.snap ?? null : replayed?.snap ?? null;
86067
86106
  const deltaScore = previous ? snap.aggregateScore - previous.aggregateScore : null;
86068
86107
  const trend = deltaScore == null ? null : deltaScore > 0 ? SiteAuditTrendDirections.up : deltaScore < 0 ? SiteAuditTrendDirections.down : SiteAuditTrendDirections.flat;
86069
86108
  const affectedPageRanking = {
@@ -5,7 +5,7 @@ import {
5
5
  siteCrawlGraphNodes,
6
6
  siteCrawlPages,
7
7
  siteCrawlSnapshots
8
- } from "./chunk-KRFTA4I7.js";
8
+ } from "./chunk-52PHEGHT.js";
9
9
  import {
10
10
  SITE_CRAWL_GRAPH_MAX_EDGES,
11
11
  SITE_CRAWL_GRAPH_MAX_NODES,
@@ -14,7 +14,7 @@ import {
14
14
  factorStatusFromDistribution,
15
15
  factorStatusFromScore,
16
16
  roundPreservingTotal
17
- } from "./chunk-DO7XPDG5.js";
17
+ } from "./chunk-66DVP4DN.js";
18
18
 
19
19
  // src/site-audit-factors.ts
20
20
  function recordedSharePct(factor) {
@@ -6571,7 +6571,7 @@ var siteAuditCrossCuttingIssueSchema = z14.object({
6571
6571
  topRecommendations: z14.array(z14.string()).default([])
6572
6572
  });
6573
6573
  var siteAuditRunSelectionSchema = z14.object({
6574
- reason: z14.enum(["explicit-run", "latest-date-complete", "latest-date-most-pages", "requested-date-complete", "requested-date-most-pages"]),
6574
+ reason: z14.enum(["explicit-run", "latest-date-complete", "latest-date-most-pages", "latest-scored-scan", "requested-date-complete", "requested-date-most-pages"]),
6575
6575
  date: z14.string(),
6576
6576
  /** All surfaceable scans on the selected UTC date; probes never count. */
6577
6577
  sameDateRunCount: z14.number().int().nonnegative(),
@@ -6600,6 +6600,14 @@ var siteAuditScoreSchema = z14.object({
6600
6600
  /** `aggregateScore - previousScore`, or `null` when there is no prior run. */
6601
6601
  deltaScore: z14.number().nullable(),
6602
6602
  trend: z14.union([siteAuditTrendDirectionSchema, z14.null()]),
6603
+ /**
6604
+ * The score a default read returned just before this scan was recorded: the
6605
+ * same date-first selection, applied to the scans recorded before it. A
6606
+ * complete scan is never compared with a partial scan from the same date,
6607
+ * which that selection ranks below it; it is compared with the default from
6608
+ * before that date instead. Two complete scans from one date compare with
6609
+ * each other.
6610
+ */
6603
6611
  previousScore: z14.number().nullable(),
6604
6612
  previousAuditedAt: z14.string().nullable(),
6605
6613
  runSelection: siteAuditRunSelectionSchema.optional(),