@ainyc/canonry 1.46.1 → 1.48.2

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.
@@ -92,7 +92,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
92
92
 
93
93
  `)}y.write("payload.value = newResult;"),y.write("return payload;");const E=y.compile();return(k,O)=>E(v,k,O)};let s;const l=Sm,c=!jD.jitless,h=c&&nG.value,p=t.catchall;let g;e._zod.parse=(v,y)=>{g??(g=r.value);const S=v.value;return l(S)?c&&h&&y?.async===!1&&y.jitless!==!0?(s||(s=i(t.shape)),v=s(v,y),p?UD([],S,v,y,g,e):v):n(v,y):(v.issues.push({expected:"object",code:"invalid_type",input:S,inst:e}),v)}});function iE(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const i=e.filter(s=>!xc(s));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(l=>Ks(l,r,Fs())))}),t)}const qV=fe("$ZodUnion",(e,t)=>{Vt.init(e,t),St(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),St(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),St(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),St(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>P1(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,s)=>{if(n)return r(i,s);let l=!1;const c=[];for(const f of t.options){const h=f._zod.run({value:i.value,issues:[]},s);if(h instanceof Promise)c.push(h),l=!0;else{if(h.issues.length===0)return h;c.push(h)}}return l?Promise.all(c).then(f=>iE(f,i,e,s)):iE(c,i,e,s)}}),FV=fe("$ZodIntersection",(e,t)=>{Vt.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,s=t.left._zod.run({value:i,issues:[]},r),l=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||l instanceof Promise?Promise.all([s,l]).then(([f,h])=>aE(n,f,h)):aE(n,s,l)}});function zw(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if($c(e)&&$c(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),i={...e,...t};for(const s of r){const l=zw(e[s],t[s]);if(!l.valid)return{valid:!1,mergeErrorPath:[s,...l.mergeErrorPath]};i[s]=l.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],s=t[r],l=zw(i,s);if(!l.valid)return{valid:!1,mergeErrorPath:[r,...l.mergeErrorPath]};n.push(l.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function aE(e,t,n){const r=new Map;let i;for(const c of t.issues)if(c.code==="unrecognized_keys"){i??(i=c);for(const f of c.keys)r.has(f)||r.set(f,{}),r.get(f).l=!0}else e.issues.push(c);for(const c of n.issues)if(c.code==="unrecognized_keys")for(const f of c.keys)r.has(f)||r.set(f,{}),r.get(f).r=!0;else e.issues.push(c);const s=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&i&&e.issues.push({...i,keys:s}),xc(e))return e;const l=zw(t.value,n.value);if(!l.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`);return e.value=l.data,e}const KV=fe("$ZodRecord",(e,t)=>{Vt.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!$c(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const s=[],l=t.keyType._zod.values;if(l){n.value={};const c=new Set;for(const h of l)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){c.add(typeof h=="number"?h.toString():h);const p=t.valueType._zod.run({value:i[h],issues:[]},r);p instanceof Promise?s.push(p.then(g=>{g.issues.length&&n.issues.push(...wc(h,g.issues)),n.value[h]=g.value})):(p.issues.length&&n.issues.push(...wc(h,p.issues)),n.value[h]=p.value)}let f;for(const h in i)c.has(h)||(f=f??[],f.push(h));f&&f.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:f})}else{n.value={};for(const c of Reflect.ownKeys(i)){if(c==="__proto__")continue;let f=t.keyType._zod.run({value:c,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&zD.test(c)&&f.issues.length){const g=t.keyType._zod.run({value:Number(c),issues:[]},r);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(f=g)}if(f.issues.length){t.mode==="loose"?n.value[c]=i[c]:n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(g=>Ks(g,r,Fs())),input:c,path:[c],inst:e});continue}const p=t.valueType._zod.run({value:i[c],issues:[]},r);p instanceof Promise?s.push(p.then(g=>{g.issues.length&&n.issues.push(...wc(c,g.issues)),n.value[f.value]=g.value})):(p.issues.length&&n.issues.push(...wc(c,p.issues)),n.value[f.value]=p.value)}}return s.length?Promise.all(s).then(()=>n):n}}),HV=fe("$ZodEnum",(e,t)=>{Vt.init(e,t);const n=ND(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>rG.has(typeof i)).map(i=>typeof i=="string"?Uc(i):i.toString()).join("|")})$`),e._zod.parse=(i,s)=>{const l=i.value;return r.has(l)||i.issues.push({code:"invalid_value",values:n,input:l,inst:e}),i}}),GV=fe("$ZodLiteral",(e,t)=>{if(Vt.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Uc(r):r?Uc(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),VV=fe("$ZodTransform",(e,t)=>{Vt.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new SD(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(l=>(n.value=l,n));if(i instanceof Promise)throw new Tc;return n.value=i,n}});function sE(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const BD=fe("$ZodOptional",(e,t)=>{Vt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",St(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),St(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${P1(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>sE(s,n.value)):sE(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),ZV=fe("$ZodExactOptional",(e,t)=>{BD.init(e,t),St(e._zod,"values",()=>t.innerType._zod.values),St(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),YV=fe("$ZodNullable",(e,t)=>{Vt.init(e,t),St(e._zod,"optin",()=>t.innerType._zod.optin),St(e._zod,"optout",()=>t.innerType._zod.optout),St(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${P1(n.source)}|null)$`):void 0}),St(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),WV=fe("$ZodDefault",(e,t)=>{Vt.init(e,t),e._zod.optin="optional",St(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>oE(s,t)):oE(i,t)}});function oE(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const QV=fe("$ZodPrefault",(e,t)=>{Vt.init(e,t),e._zod.optin="optional",St(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),XV=fe("$ZodNonOptional",(e,t)=>{Vt.init(e,t),St(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>lE(s,e)):lE(i,e)}});function lE(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const JV=fe("$ZodCatch",(e,t)=>{Vt.init(e,t),St(e._zod,"optin",()=>t.innerType._zod.optin),St(e._zod,"optout",()=>t.innerType._zod.optout),St(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(l=>Ks(l,r,Fs()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>Ks(s,r,Fs()))},input:n.value}),n.issues=[]),n)}}),eZ=fe("$ZodPipe",(e,t)=>{Vt.init(e,t),St(e._zod,"values",()=>t.in._zod.values),St(e._zod,"optin",()=>t.in._zod.optin),St(e._zod,"optout",()=>t.out._zod.optout),St(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(l=>xp(l,t.in,r)):xp(s,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>xp(s,t.out,r)):xp(i,t.out,r)}});function xp(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const tZ=fe("$ZodReadonly",(e,t)=>{Vt.init(e,t),St(e._zod,"propValues",()=>t.innerType._zod.propValues),St(e._zod,"values",()=>t.innerType._zod.values),St(e._zod,"optin",()=>t.innerType?._zod?.optin),St(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(cE):cE(i)}});function cE(e){return e.value=Object.freeze(e.value),e}const nZ=fe("$ZodCustom",(e,t)=>{br.init(e,t),Vt.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>uE(s,n,r,e));uE(i,n,r,e)}});function uE(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Vd(i))}}var dE;class rZ{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function iZ(){return new rZ}(dE=globalThis).__zod_globalRegistry??(dE.__zod_globalRegistry=iZ());const Od=globalThis.__zod_globalRegistry;function aZ(e,t){return new e({type:"string",...$e(t)})}function sZ(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...$e(t)})}function fE(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...$e(t)})}function oZ(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...$e(t)})}function lZ(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...$e(t)})}function cZ(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...$e(t)})}function uZ(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...$e(t)})}function dZ(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...$e(t)})}function fZ(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...$e(t)})}function hZ(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...$e(t)})}function pZ(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...$e(t)})}function mZ(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...$e(t)})}function gZ(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...$e(t)})}function vZ(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...$e(t)})}function yZ(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...$e(t)})}function bZ(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...$e(t)})}function xZ(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...$e(t)})}function wZ(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...$e(t)})}function SZ(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...$e(t)})}function jZ(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...$e(t)})}function NZ(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...$e(t)})}function CZ(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...$e(t)})}function OZ(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...$e(t)})}function _Z(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...$e(t)})}function kZ(e,t){return new e({type:"string",format:"date",check:"string_format",...$e(t)})}function AZ(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...$e(t)})}function EZ(e,t){return new e({type:"string",format:"duration",check:"string_format",...$e(t)})}function TZ(e,t){return new e({type:"number",checks:[],...$e(t)})}function PZ(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...$e(t)})}function zZ(e,t){return new e({type:"boolean",...$e(t)})}function MZ(e){return new e({type:"unknown"})}function RZ(e,t){return new e({type:"never",...$e(t)})}function hE(e,t){return new RD({check:"less_than",...$e(t),value:e,inclusive:!1})}function _b(e,t){return new RD({check:"less_than",...$e(t),value:e,inclusive:!0})}function pE(e,t){return new DD({check:"greater_than",...$e(t),value:e,inclusive:!1})}function kb(e,t){return new DD({check:"greater_than",...$e(t),value:e,inclusive:!0})}function mE(e,t){return new WG({check:"multiple_of",...$e(t),value:e})}function qD(e,t){return new XG({check:"max_length",...$e(t),maximum:e})}function Nm(e,t){return new JG({check:"min_length",...$e(t),minimum:e})}function FD(e,t){return new eV({check:"length_equals",...$e(t),length:e})}function DZ(e,t){return new tV({check:"string_format",format:"regex",...$e(t),pattern:e})}function IZ(e){return new nV({check:"string_format",format:"lowercase",...$e(e)})}function LZ(e){return new rV({check:"string_format",format:"uppercase",...$e(e)})}function $Z(e,t){return new iV({check:"string_format",format:"includes",...$e(t),includes:e})}function UZ(e,t){return new aV({check:"string_format",format:"starts_with",...$e(t),prefix:e})}function BZ(e,t){return new sV({check:"string_format",format:"ends_with",...$e(t),suffix:e})}function Jc(e){return new oV({check:"overwrite",tx:e})}function qZ(e){return Jc(t=>t.normalize(e))}function FZ(){return Jc(e=>e.trim())}function KZ(){return Jc(e=>e.toLowerCase())}function HZ(){return Jc(e=>e.toUpperCase())}function GZ(){return Jc(e=>tG(e))}function VZ(e,t,n){return new e({type:"array",element:t,...$e(n)})}function ZZ(e,t,n){return new e({type:"custom",check:"custom",fn:t,...$e(n)})}function YZ(e){const t=WZ(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Vd(r,n.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(Vd(i))}},e(n.value,n)));return t}function WZ(e,t){const n=new br({check:"custom",...$e(t)});return n._zod.check=e,n}function KD(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Od,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function hn(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const l={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,l);const c=e._zod.toJSONSchema?.();if(c)l.schema=c;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,p);else{const v=l.schema,y=t.processors[i.type];if(!y)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);y(e,t,v,p)}const g=e._zod.parent;g&&(l.ref||(l.ref=g),hn(g,t,p),t.seen.get(g).isParent=!0)}const f=t.metadataRegistry.get(e);return f&&Object.assign(l.schema,f),t.io==="input"&&Qn(e)&&(delete l.schema.examples,delete l.schema.default),t.io==="input"&&l.schema._prefault&&((r=l.schema).default??(r.default=l.schema._prefault)),delete l.schema._prefault,t.seen.get(e).schema}function HD(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const l of e.seen.entries()){const c=e.metadataRegistry.get(l[0])?.id;if(c){const f=r.get(c);if(f&&f!==l[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,l[0])}}const i=l=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const g=e.external.registry.get(l[0])?.id,v=e.external.uri??(S=>S);if(g)return{ref:v(g)};const y=l[1].defId??l[1].schema.id??`schema${e.counter++}`;return l[1].defId=y,{defId:y,ref:`${v("__shared")}#/${c}/${y}`}}if(l[1]===n)return{ref:"#"};const h=`#/${c}/`,p=l[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:h+p}},s=l=>{if(l[1].schema.$ref)return;const c=l[1],{ref:f,defId:h}=i(l);c.def={...c.schema},h&&(c.defId=h);const p=c.schema;for(const g in p)delete p[g];p.$ref=f};if(e.cycles==="throw")for(const l of e.seen.entries()){const c=l[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
94
94
 
95
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of e.seen.entries()){const c=l[1];if(t===l[0]){s(l);continue}if(e.external){const h=e.external.registry.get(l[0])?.id;if(t!==l[0]&&h){s(l);continue}}if(e.metadataRegistry.get(l[0])?.id){s(l);continue}if(c.cycle){s(l);continue}if(c.count>1&&e.reused==="ref"){s(l);continue}}}function GD(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=l=>{const c=e.seen.get(l);if(c.ref===null)return;const f=c.def??c.schema,h={...f},p=c.ref;if(c.ref=null,p){r(p);const v=e.seen.get(p),y=v.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(y)):Object.assign(f,y),Object.assign(f,h),l._zod.parent===p)for(const w in f)w==="$ref"||w==="allOf"||w in h||delete f[w];if(y.$ref&&v.def)for(const w in f)w==="$ref"||w==="allOf"||w in v.def&&JSON.stringify(f[w])===JSON.stringify(v.def[w])&&delete f[w]}const g=l._zod.parent;if(g&&g!==p){r(g);const v=e.seen.get(g);if(v?.schema.$ref&&(f.$ref=v.schema.$ref,v.def))for(const y in f)y==="$ref"||y==="allOf"||y in v.def&&JSON.stringify(f[y])===JSON.stringify(v.def[y])&&delete f[y]}e.override({zodSchema:l,jsonSchema:f,path:c.path??[]})};for(const l of[...e.seen.entries()].reverse())r(l[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const l=e.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(l)}Object.assign(i,n.def??n.schema);const s=e.external?.defs??{};for(const l of e.seen.entries()){const c=l[1];c.def&&c.defId&&(s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const l=JSON.parse(JSON.stringify(i));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:Cm(t,"input",e.processors),output:Cm(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function Qn(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Qn(r.element,n);if(r.type==="set")return Qn(r.valueType,n);if(r.type==="lazy")return Qn(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Qn(r.innerType,n);if(r.type==="intersection")return Qn(r.left,n)||Qn(r.right,n);if(r.type==="record"||r.type==="map")return Qn(r.keyType,n)||Qn(r.valueType,n);if(r.type==="pipe")return Qn(r.in,n)||Qn(r.out,n);if(r.type==="object"){for(const i in r.shape)if(Qn(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Qn(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Qn(i,n))return!0;return!!(r.rest&&Qn(r.rest,n))}return!1}const QZ=(e,t={})=>n=>{const r=KD({...n,processors:t});return hn(e,r),HD(r,e),GD(r,e)},Cm=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},l=KD({...i??{},target:s,io:t,processors:n});return hn(e,l),HD(l,e),GD(l,e)},XZ={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},JZ=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:l,format:c,patterns:f,contentEncoding:h}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof l=="number"&&(i.maxLength=l),c&&(i.format=XZ[c]??c,i.format===""&&delete i.format,c==="time"&&delete i.format),h&&(i.contentEncoding=h),f&&f.size>0){const p=[...f];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},eY=(e,t,n,r)=>{const i=n,{minimum:s,maximum:l,format:c,multipleOf:f,exclusiveMaximum:h,exclusiveMinimum:p}=e._zod.bag;typeof c=="string"&&c.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof s=="number"&&(i.minimum=s,typeof p=="number"&&t.target!=="draft-04"&&(p>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=h,i.exclusiveMaximum=!0):i.exclusiveMaximum=h),typeof l=="number"&&(i.maximum=l,typeof h=="number"&&t.target!=="draft-04"&&(h<=l?delete i.maximum:delete i.exclusiveMaximum)),typeof f=="number"&&(i.multipleOf=f)},tY=(e,t,n,r)=>{n.type="boolean"},nY=(e,t,n,r)=>{n.not={}},rY=(e,t,n,r)=>{},iY=(e,t,n,r)=>{const i=e._zod.def,s=ND(i.entries);s.every(l=>typeof l=="number")&&(n.type="number"),s.every(l=>typeof l=="string")&&(n.type="string"),n.enum=s},aY=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const l of i.values)if(l===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof l=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(l))}else s.push(l);if(s.length!==0)if(s.length===1){const l=s[0];n.type=l===null?"null":typeof l,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[l]:n.const=l}else s.every(l=>typeof l=="number")&&(n.type="number"),s.every(l=>typeof l=="string")&&(n.type="string"),s.every(l=>typeof l=="boolean")&&(n.type="boolean"),s.every(l=>l===null)&&(n.type="null"),n.enum=s},sY=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},oY=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},lY=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:l,maximum:c}=e._zod.bag;typeof l=="number"&&(i.minItems=l),typeof c=="number"&&(i.maxItems=c),i.type="array",i.items=hn(s.element,t,{...r,path:[...r.path,"items"]})},cY=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object",i.properties={};const l=s.shape;for(const h in l)i.properties[h]=hn(l[h],t,{...r,path:[...r.path,"properties",h]});const c=new Set(Object.keys(l)),f=new Set([...c].filter(h=>{const p=s.shape[h]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));f.size>0&&(i.required=Array.from(f)),s.catchall?._zod.def.type==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=hn(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},uY=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,l=i.options.map((c,f)=>hn(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",f]}));s?n.oneOf=l:n.anyOf=l},dY=(e,t,n,r)=>{const i=e._zod.def,s=hn(i.left,t,{...r,path:[...r.path,"allOf",0]}),l=hn(i.right,t,{...r,path:[...r.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,f=[...c(s)?s.allOf:[s],...c(l)?l.allOf:[l]];n.allOf=f},fY=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const l=s.keyType,f=l._zod.bag?.patterns;if(s.mode==="loose"&&f&&f.size>0){const p=hn(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const g of f)i.patternProperties[g.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=hn(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=hn(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const h=l._zod.values;if(h){const p=[...h].filter(g=>typeof g=="string"||typeof g=="number");p.length>0&&(i.required=p)}},hY=(e,t,n,r)=>{const i=e._zod.def,s=hn(i.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},pY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},mY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},gY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},vY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let l;try{l=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=l},yY=(e,t,n,r)=>{const i=e._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;hn(s,t,r);const l=t.seen.get(e);l.ref=s},bY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},VD=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},xY=fe("ZodISODateTime",(e,t)=>{wV.init(e,t),Yt.init(e,t)});function wY(e){return _Z(xY,e)}const SY=fe("ZodISODate",(e,t)=>{SV.init(e,t),Yt.init(e,t)});function jY(e){return kZ(SY,e)}const NY=fe("ZodISOTime",(e,t)=>{jV.init(e,t),Yt.init(e,t)});function CY(e){return AZ(NY,e)}const OY=fe("ZodISODuration",(e,t)=>{NV.init(e,t),Yt.init(e,t)});function _Y(e){return EZ(OY,e)}const kY=(e,t)=>{kD.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>pG(e,n)},flatten:{value:n=>hG(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Pw,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Pw,2)}},isEmpty:{get(){return e.issues.length===0}}})},fi=fe("ZodError",kY,{Parent:Error}),AY=M1(fi),EY=R1(fi),TY=Fg(fi),PY=Kg(fi),zY=vG(fi),MY=yG(fi),RY=bG(fi),DY=xG(fi),IY=wG(fi),LY=SG(fi),$Y=jG(fi),UY=NG(fi),Zt=fe("ZodType",(e,t)=>(Vt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Cm(e,"input"),output:Cm(e,"output")}}),e.toJSONSchema=QZ(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Qs(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>Xs(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>AY(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>TY(e,n,r),e.parseAsync=async(n,r)=>EY(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>PY(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>zY(e,n,r),e.decode=(n,r)=>MY(e,n,r),e.encodeAsync=async(n,r)=>RY(e,n,r),e.decodeAsync=async(n,r)=>DY(e,n,r),e.safeEncode=(n,r)=>IY(e,n,r),e.safeDecode=(n,r)=>LY(e,n,r),e.safeEncodeAsync=async(n,r)=>$Y(e,n,r),e.safeDecodeAsync=async(n,r)=>UY(e,n,r),e.refine=(n,r)=>e.check(MW(n,r)),e.superRefine=n=>e.check(RW(n)),e.overwrite=n=>e.check(Jc(n)),e.optional=()=>yE(e),e.exactOptional=()=>wW(e),e.nullable=()=>bE(e),e.nullish=()=>yE(bE(e)),e.nonoptional=n=>_W(e,n),e.array=()=>ke(e),e.or=n=>hW([e,n]),e.and=n=>mW(e,n),e.transform=n=>xE(e,bW(n)),e.default=n=>NW(e,n),e.prefault=n=>OW(e,n),e.catch=n=>AW(e,n),e.pipe=n=>xE(e,n),e.readonly=()=>PW(e),e.describe=n=>{const r=e.clone();return Od.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Od.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Od.get(e);const r=e.clone();return Od.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),ZD=fe("_ZodString",(e,t)=>{D1.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(r,i,s)=>JZ(e,r,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(DZ(...r)),e.includes=(...r)=>e.check($Z(...r)),e.startsWith=(...r)=>e.check(UZ(...r)),e.endsWith=(...r)=>e.check(BZ(...r)),e.min=(...r)=>e.check(Nm(...r)),e.max=(...r)=>e.check(qD(...r)),e.length=(...r)=>e.check(FD(...r)),e.nonempty=(...r)=>e.check(Nm(1,...r)),e.lowercase=r=>e.check(IZ(r)),e.uppercase=r=>e.check(LZ(r)),e.trim=()=>e.check(FZ()),e.normalize=(...r)=>e.check(qZ(...r)),e.toLowerCase=()=>e.check(KZ()),e.toUpperCase=()=>e.check(HZ()),e.slugify=()=>e.check(GZ())}),BY=fe("ZodString",(e,t)=>{D1.init(e,t),ZD.init(e,t),e.email=n=>e.check(sZ(qY,n)),e.url=n=>e.check(dZ(FY,n)),e.jwt=n=>e.check(OZ(iW,n)),e.emoji=n=>e.check(fZ(KY,n)),e.guid=n=>e.check(fE(gE,n)),e.uuid=n=>e.check(oZ(wp,n)),e.uuidv4=n=>e.check(lZ(wp,n)),e.uuidv6=n=>e.check(cZ(wp,n)),e.uuidv7=n=>e.check(uZ(wp,n)),e.nanoid=n=>e.check(hZ(HY,n)),e.guid=n=>e.check(fE(gE,n)),e.cuid=n=>e.check(pZ(GY,n)),e.cuid2=n=>e.check(mZ(VY,n)),e.ulid=n=>e.check(gZ(ZY,n)),e.base64=n=>e.check(jZ(tW,n)),e.base64url=n=>e.check(NZ(nW,n)),e.xid=n=>e.check(vZ(YY,n)),e.ksuid=n=>e.check(yZ(WY,n)),e.ipv4=n=>e.check(bZ(QY,n)),e.ipv6=n=>e.check(xZ(XY,n)),e.cidrv4=n=>e.check(wZ(JY,n)),e.cidrv6=n=>e.check(SZ(eW,n)),e.e164=n=>e.check(CZ(rW,n)),e.datetime=n=>e.check(wY(n)),e.date=n=>e.check(jY(n)),e.time=n=>e.check(CY(n)),e.duration=n=>e.check(_Y(n))});function I(e){return aZ(BY,e)}const Yt=fe("ZodStringFormat",(e,t)=>{Ft.init(e,t),ZD.init(e,t)}),qY=fe("ZodEmail",(e,t)=>{fV.init(e,t),Yt.init(e,t)}),gE=fe("ZodGUID",(e,t)=>{uV.init(e,t),Yt.init(e,t)}),wp=fe("ZodUUID",(e,t)=>{dV.init(e,t),Yt.init(e,t)}),FY=fe("ZodURL",(e,t)=>{hV.init(e,t),Yt.init(e,t)}),KY=fe("ZodEmoji",(e,t)=>{pV.init(e,t),Yt.init(e,t)}),HY=fe("ZodNanoID",(e,t)=>{mV.init(e,t),Yt.init(e,t)}),GY=fe("ZodCUID",(e,t)=>{gV.init(e,t),Yt.init(e,t)}),VY=fe("ZodCUID2",(e,t)=>{vV.init(e,t),Yt.init(e,t)}),ZY=fe("ZodULID",(e,t)=>{yV.init(e,t),Yt.init(e,t)}),YY=fe("ZodXID",(e,t)=>{bV.init(e,t),Yt.init(e,t)}),WY=fe("ZodKSUID",(e,t)=>{xV.init(e,t),Yt.init(e,t)}),QY=fe("ZodIPv4",(e,t)=>{CV.init(e,t),Yt.init(e,t)}),XY=fe("ZodIPv6",(e,t)=>{OV.init(e,t),Yt.init(e,t)}),JY=fe("ZodCIDRv4",(e,t)=>{_V.init(e,t),Yt.init(e,t)}),eW=fe("ZodCIDRv6",(e,t)=>{kV.init(e,t),Yt.init(e,t)}),tW=fe("ZodBase64",(e,t)=>{AV.init(e,t),Yt.init(e,t)}),nW=fe("ZodBase64URL",(e,t)=>{TV.init(e,t),Yt.init(e,t)}),rW=fe("ZodE164",(e,t)=>{PV.init(e,t),Yt.init(e,t)}),iW=fe("ZodJWT",(e,t)=>{MV.init(e,t),Yt.init(e,t)}),YD=fe("ZodNumber",(e,t)=>{LD.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(r,i,s)=>eY(e,r,i),e.gt=(r,i)=>e.check(pE(r,i)),e.gte=(r,i)=>e.check(kb(r,i)),e.min=(r,i)=>e.check(kb(r,i)),e.lt=(r,i)=>e.check(hE(r,i)),e.lte=(r,i)=>e.check(_b(r,i)),e.max=(r,i)=>e.check(_b(r,i)),e.int=r=>e.check(vE(r)),e.safe=r=>e.check(vE(r)),e.positive=r=>e.check(pE(0,r)),e.nonnegative=r=>e.check(kb(0,r)),e.negative=r=>e.check(hE(0,r)),e.nonpositive=r=>e.check(_b(0,r)),e.multipleOf=(r,i)=>e.check(mE(r,i)),e.step=(r,i)=>e.check(mE(r,i)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function _e(e){return TZ(YD,e)}const aW=fe("ZodNumberFormat",(e,t)=>{RV.init(e,t),YD.init(e,t)});function vE(e){return PZ(aW,e)}const sW=fe("ZodBoolean",(e,t)=>{DV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tY(e,n,r)});function Gt(e){return zZ(sW,e)}const oW=fe("ZodUnknown",(e,t)=>{IV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rY()});function Om(){return MZ(oW)}const lW=fe("ZodNever",(e,t)=>{LV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nY(e,n,r)});function cW(e){return RZ(lW,e)}const uW=fe("ZodArray",(e,t)=>{$V.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lY(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(Nm(n,r)),e.nonempty=n=>e.check(Nm(1,n)),e.max=(n,r)=>e.check(qD(n,r)),e.length=(n,r)=>e.check(FD(n,r)),e.unwrap=()=>e.element});function ke(e,t){return VZ(uW,e,t)}const dW=fe("ZodObject",(e,t)=>{BV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cY(e,n,r,i),St(e,"shape",()=>t.shape),e.keyof=()=>Tt(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Om()}),e.loose=()=>e.clone({...e._zod.def,catchall:Om()}),e.strict=()=>e.clone({...e._zod.def,catchall:cW()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>lG(e,n),e.safeExtend=n=>cG(e,n),e.merge=n=>uG(e,n),e.pick=n=>sG(e,n),e.omit=n=>oG(e,n),e.partial=(...n)=>dG(WD,e,n[0]),e.required=(...n)=>fG(QD,e,n[0])});function Ce(e,t){const n={type:"object",shape:e??{},...$e(t)};return new dW(n)}const fW=fe("ZodUnion",(e,t)=>{qV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uY(e,n,r,i),e.options=t.options});function hW(e,t){return new fW({type:"union",options:e,...$e(t)})}const pW=fe("ZodIntersection",(e,t)=>{FV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dY(e,n,r,i)});function mW(e,t){return new pW({type:"intersection",left:e,right:t})}const gW=fe("ZodRecord",(e,t)=>{KV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fY(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function mf(e,t,n){return new gW({type:"record",keyType:e,valueType:t,...$e(n)})}const Mw=fe("ZodEnum",(e,t)=>{HV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(r,i,s)=>iY(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const s={};for(const l of r)if(n.has(l))s[l]=t.entries[l];else throw new Error(`Key ${l} not found in enum`);return new Mw({...t,checks:[],...$e(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const l of r)if(n.has(l))delete s[l];else throw new Error(`Key ${l} not found in enum`);return new Mw({...t,checks:[],...$e(i),entries:s})}});function Tt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Mw({type:"enum",entries:n,...$e(t)})}const vW=fe("ZodLiteral",(e,t)=>{GV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>aY(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Zd(e,t){return new vW({type:"literal",values:Array.isArray(e)?e:[e],...$e(t)})}const yW=fe("ZodTransform",(e,t)=>{VV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oY(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new SD(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Vd(s,n.value,t));else{const l=s;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),l.input??(l.input=n.value),l.inst??(l.inst=e),n.issues.push(Vd(l))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function bW(e){return new yW({type:"transform",transform:e})}const WD=fe("ZodOptional",(e,t)=>{BD.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>VD(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function yE(e){return new WD({type:"optional",innerType:e})}const xW=fe("ZodExactOptional",(e,t)=>{ZV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>VD(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function wW(e){return new xW({type:"optional",innerType:e})}const SW=fe("ZodNullable",(e,t)=>{YV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function bE(e){return new SW({type:"nullable",innerType:e})}const jW=fe("ZodDefault",(e,t)=>{WV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function NW(e,t){return new jW({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():OD(t)}})}const CW=fe("ZodPrefault",(e,t)=>{QV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function OW(e,t){return new CW({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():OD(t)}})}const QD=fe("ZodNonOptional",(e,t)=>{XV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function _W(e,t){return new QD({type:"nonoptional",innerType:e,...$e(t)})}const kW=fe("ZodCatch",(e,t)=>{JV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function AW(e,t){return new kW({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const EW=fe("ZodPipe",(e,t)=>{eZ.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yY(e,n,r,i),e.in=t.in,e.out=t.out});function xE(e,t){return new EW({type:"pipe",in:e,out:t})}const TW=fe("ZodReadonly",(e,t)=>{tZ.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function PW(e){return new TW({type:"readonly",innerType:e})}const zW=fe("ZodCustom",(e,t)=>{nZ.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sY(e,n)});function MW(e,t={}){return ZZ(zW,e,t)}function RW(e){return YZ(e)}Ce({maxConcurrency:_e().int().positive(),maxRequestsPerMinute:_e().int().positive(),maxRequestsPerDay:_e().int().positive()});const eu=I().min(1);I().min(1);const I1=Ce({label:I().min(1),city:I().min(1),region:I().min(1),country:I().length(2),timezone:I().optional()}),XD=Tt(["citation.lost","citation.gained","run.completed","run.failed"]);Ce({id:I(),projectId:I(),channel:Zd("webhook"),url:I().url(),urlDisplay:I(),urlHost:I(),events:ke(XD),enabled:Gt().default(!0),webhookSecret:I().optional(),createdAt:I(),updatedAt:I()});const JD=Tt(["cli","api","config-file"]);function DW(e){const t=new Set,n=new Set;for(const r of e){if(t.has(r.label)){n.add(r.label);continue}t.add(r.label)}return[...n]}function IW(e,t){return t?e.some(n=>n.label===t):!0}Ce({displayName:I().min(1),canonicalDomain:I().min(1),ownedDomains:ke(I().min(1)).optional(),country:I().length(2),language:I().min(2),tags:ke(I()).optional(),labels:mf(I(),I()).optional(),providers:ke(eu).optional(),locations:ke(I1).optional(),defaultLocation:I().nullable().optional(),configSource:JD.optional()});Ce({id:I(),name:I(),displayName:I().optional(),canonicalDomain:I(),ownedDomains:ke(I()).default([]),country:I().length(2),language:I().min(2),tags:ke(I()).default([]),labels:mf(I(),I()).default({}),locations:ke(I1).default([]),defaultLocation:I().nullable().optional(),configSource:JD.default("cli"),configRevision:_e().int().positive().default(1),createdAt:I().optional(),updatedAt:I().optional()});function Rw(e){let t=e.trim().toLowerCase();try{t.includes("://")&&(t=new URL(t).hostname.toLowerCase())}catch{}return t.replace(/^www\./,"")}function LW(e){const t=[e.canonicalDomain,...e.ownedDomains??[]],n=new Set,r=[];for(const i of t){const s=i.trim();if(!s)continue;const l=Rw(s);n.has(l)||(n.add(l),r.push(s))}return r}const $W=Ce({name:I().min(1).max(63).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,{message:"Name must be a lowercase slug (letters, numbers, hyphens)"}),labels:mf(I(),I()).optional().default({})}),UW=Ce({preset:I().optional(),cron:I().optional(),timezone:I().optional().default("UTC"),providers:ke(eu).optional().default([])}).refine(e=>e.preset&&!e.cron||!e.preset&&e.cron,{message:'Exactly one of "preset" or "cron" must be provided'}).optional(),BW=Ce({channel:Zd("webhook"),url:I().url(),events:ke(XD).min(1)}),qW=Ce({gsc:Ce({propertyUrl:I()}).optional(),syncSchedule:Ce({preset:I().optional(),cron:I().optional()}).optional()}).optional(),FW=Ce({displayName:I().min(1),canonicalDomain:I().min(1),ownedDomains:ke(I().min(1)).optional().default([]),country:I().length(2),language:I().min(2),keywords:ke(I().min(1)).optional().default([]),competitors:ke(I().min(1)).optional().default([]),providers:ke(eu).optional().default([]),locations:ke(I1).optional().default([]),defaultLocation:I().optional(),schedule:UW,notifications:ke(BW).optional().default([]),google:qW}).superRefine((e,t)=>{const n=DW(e.locations);n.length>0&&t.addIssue({code:"custom",message:`Duplicate location labels are not allowed: ${n.join(", ")}`,path:["locations"]}),IW(e.locations,e.defaultLocation)||t.addIssue({code:"custom",message:`defaultLocation "${e.defaultLocation}" must match a configured location label`,path:["defaultLocation"]})});Ce({apiVersion:Zd("canonry/v1"),kind:Zd("Project"),metadata:$W,spec:FW});const KW=Tt(["gsc","ga4"]);Ce({id:I(),domain:I(),connectionType:KW,propertyId:I().nullable().optional(),sitemapUrl:I().nullable().optional(),scopes:ke(I()).default([]),createdAt:I(),updatedAt:I()});Ce({date:I(),query:I(),page:I(),country:I().nullable().optional(),device:I().nullable().optional(),clicks:_e(),impressions:_e(),ctr:_e(),position:_e()});const Dw=Ce({id:I(),url:I(),indexingState:I().nullable().optional(),verdict:I().nullable().optional(),coverageState:I().nullable().optional(),pageFetchState:I().nullable().optional(),robotsTxtState:I().nullable().optional(),crawlTime:I().nullable().optional(),lastCrawlResult:I().nullable().optional(),isMobileFriendly:Gt().nullable().optional(),richResults:ke(I()).default([]),inspectedAt:I()});Tt(["stable","reindexed","deindexed","still-missing","new"]);const HW=Ce({url:I(),previousState:I().nullable(),currentState:I().nullable(),transitionDate:I()}),GW=Ce({reason:I(),count:_e(),urls:ke(Dw).default([])});Ce({summary:Ce({total:_e(),indexed:_e(),notIndexed:_e(),deindexed:_e(),percentage:_e()}),lastInspectedAt:I().nullable(),indexed:ke(Dw).default([]),notIndexed:ke(Dw).default([]),deindexed:ke(HW).default([]),reasonGroups:ke(GW).default([])});Ce({url:I(),type:Tt(["URL_UPDATED","URL_DELETED"]),notifiedAt:I()});Ce({url:I(),type:Tt(["URL_UPDATED","URL_DELETED"]),notifiedAt:I(),status:Tt(["success","error"]),error:I().optional()});Ce({date:I(),indexed:_e(),notIndexed:_e(),reasonBreakdown:mf(I(),_e()).default({})});Ce({id:I(),domain:I(),siteUrl:I().nullable().optional(),createdAt:I(),updatedAt:I()});const Ab=Ce({id:I(),url:I(),httpCode:_e().nullable().optional(),inIndex:Gt().nullable().optional(),lastCrawledDate:I().nullable().optional(),inIndexDate:I().nullable().optional(),inspectedAt:I(),documentSize:_e().nullable().optional(),anchorCount:_e().nullable().optional(),discoveryDate:I().nullable().optional()});Ce({summary:Ce({total:_e(),indexed:_e(),notIndexed:_e(),unknown:_e().optional(),percentage:_e()}),lastInspectedAt:I().nullable(),indexed:ke(Ab).default([]),notIndexed:ke(Ab).default([]),unknown:ke(Ab).default([]).optional()});Ce({query:I(),impressions:_e(),clicks:_e(),ctr:_e(),averagePosition:_e()});Ce({date:I(),indexed:_e(),notIndexed:_e(),unknown:_e()});Ce({url:I(),status:Tt(["success","error"]),submittedAt:I(),error:I().optional()});const tu=Tt(["live","staging"]);Ce({projectName:I(),url:I(),stagingUrl:I().optional(),username:I(),defaultEnv:tu,createdAt:I(),updatedAt:I()});const wE=Ce({url:I(),reachable:Gt(),pageCount:_e().nullable().optional(),version:I().nullable().optional(),error:I().nullable().optional(),plugins:ke(I()).optional(),authenticatedUser:Ce({id:_e(),slug:I()}).nullable().optional()});Ce({connected:Gt(),projectName:I(),defaultEnv:tu,live:wE.nullable(),staging:wE.nullable(),adminUrl:I().nullable().optional()});const VW=Ce({id:_e(),slug:I(),title:I(),status:I(),modifiedAt:I().nullable().optional(),link:I().nullable().optional()}),eI=Ce({title:I().nullable(),description:I().nullable(),noindex:Gt().nullable(),writable:Gt().default(!1),writeTargets:ke(I()).default([])}),ZW=Ce({type:I(),json:mf(I(),Om())}),YW=VW.extend({env:tu,content:I(),seo:eI,schemaBlocks:ke(ZW).default([])}),SE=YW.extend({contentHash:I(),contentSnippet:I()}),tI=Ce({manualRequired:Zd(!0),targetUrl:I(),adminUrl:I().nullable().optional(),content:I(),nextSteps:ke(I()).default([])}),WW=Ce({slug:I(),severity:Tt(["high","medium","low"]),code:Tt(["noindex","missing-seo-title","missing-meta-description","missing-schema","thin-content"]),message:I()});Ce({slug:I(),title:I(),status:I(),wordCount:_e(),seo:eI,schemaPresent:Gt(),issues:ke(WW).default([])});const QW=Ce({slug:I(),status:Tt(["applied","skipped","manual"]),error:I().optional(),manualAssist:tI.optional()});Ce({env:tu,strategy:Tt(["plugin","manual"]),results:ke(QW)});const XW=Ce({slug:I(),status:Tt(["deployed","stripped","skipped","failed"]),schemasInjected:ke(I()).optional(),manualAssist:tI.optional(),error:I().optional()});Ce({env:tu,results:ke(XW)});const JW=Ce({slug:I(),title:I(),canonrySchemas:ke(I()),thirdPartySchemas:ke(I()),hasCanonrySchema:Gt()});Ce({env:tu,pages:ke(JW)});const eQ=Ce({name:I(),status:Tt(["completed","skipped","failed"]),summary:I().optional(),error:I().optional()});Ce({projectName:I(),steps:ke(eQ)});Ce({slug:I(),live:SE,staging:SE,hasDifferences:Gt(),differences:Ce({title:Gt(),slug:Gt(),content:Gt(),seoTitle:Gt(),seoDescription:Gt(),noindex:Gt(),schema:Gt()})});const nI=Tt(["queued","running","completed","partial","failed","cancelled"]),en=nI.enum,rI=Tt(["answer-visibility","site-audit","gsc-sync","inspect-sitemap","ga-sync","bing-inspect"]),hr=rI.enum,iI=Tt(["manual","scheduled","config-apply"]),Qp=iI.enum,aI=Tt(["cited","not-cited"]);aI.enum;const sI=Tt(["visible","not-visible"]);sI.enum;const oI=Tt(["new","cited","lost","emerging","not-cited"]);oI.enum;Ce({id:I(),projectId:I(),kind:rI,status:nI,trigger:iI.default("manual"),location:I().nullable().optional(),startedAt:I().nullable().optional(),finishedAt:I().nullable().optional(),error:I().nullable().optional(),createdAt:I()});const lI=Ce({uri:I(),title:I()});Ce({id:I(),runId:I(),keywordId:I(),keyword:I().optional(),provider:eu,citationState:aI,answerMentioned:Gt().optional(),visibilityState:sI.optional(),transition:oI.optional(),answerText:I().nullable().optional(),citedDomains:ke(I()).default([]),competitorOverlap:ke(I()).default([]),recommendedCompetitors:ke(I()).default([]),matchedTerms:ke(I()).default([]),groundingSources:ke(lI).default([]),searchQueries:ke(I()).default([]),model:I().nullable().optional(),location:I().nullable().optional(),createdAt:I()});Ce({id:I(),projectId:I().nullable().optional(),actor:I(),action:I(),entityType:I(),entityId:I().nullable().optional(),diff:Om().optional(),createdAt:I()});const tQ=Tt(["yes","no","unknown","not-mentioned"]);Ce({companyName:I().min(1),domain:I().min(1),phrases:ke(I().min(1)).optional().default([]),competitors:ke(I().min(1)).optional().default([])});const nQ=Ce({name:I(),count:_e().int().nonnegative()}),rQ=Ce({id:I(),name:I(),weight:_e(),score:_e(),grade:I(),status:Tt(["pass","partial","fail"]),findings:ke(Ce({type:I(),message:I()})).default([]),recommendations:ke(I()).default([])}),iQ=Ce({url:I(),finalUrl:I(),auditedAt:I(),overallScore:_e(),overallGrade:I(),summary:I(),factors:ke(rQ).default([])}),aQ=Ce({industry:I(),summary:I(),services:ke(I()).default([]),categoryTerms:ke(I()).default([])}),sQ=Ce({provider:I(),displayName:I(),model:I().nullable().optional(),mentioned:Gt(),cited:Gt(),describedAccurately:tQ,accuracyNotes:I().nullable().optional(),incorrectClaims:ke(I()).default([]),recommendedCompetitors:ke(I()).default([]),citedDomains:ke(I()).default([]),groundingSources:ke(lI).default([]),searchQueries:ke(I()).default([]),answerText:I(),error:I().nullable().optional()}),oQ=Ce({phrase:I(),providerResults:ke(sQ).default([])}),lQ=Ce({totalQueries:_e().int().nonnegative(),totalProviders:_e().int().nonnegative(),totalComparisons:_e().int().nonnegative(),mentionCount:_e().int().nonnegative(),citationCount:_e().int().nonnegative(),topCompetitors:ke(nQ).default([]),visibilityGap:I(),whatThisMeans:ke(I()).default([]),recommendedActions:ke(I()).default([])});Ce({companyName:I(),domain:I(),homepageUrl:I(),generatedAt:I(),phrases:ke(I()).default([]),competitors:ke(I()).default([]),profile:aQ,audit:iQ,queryResults:ke(oQ).default([]),summary:lQ});Ce({id:I(),projectId:I(),cronExpr:I(),preset:I().nullable().optional(),timezone:I().default("UTC"),enabled:Gt().default(!0),providers:ke(eu).default([]),lastRunAt:I().nullable().optional(),nextRunAt:I().nullable().optional(),createdAt:I(),updatedAt:I()});Ce({preset:I().optional(),cron:I().optional(),timezone:I().optional().default("UTC"),enabled:Gt().optional().default(!0),providers:ke(eu).optional().default([])}).refine(e=>e.preset&&!e.cron||!e.preset&&e.cron,{message:'Exactly one of "preset" or "cron" must be provided'});const cQ=Tt(["answer","citation"]),Ps=cQ.enum;Ce({id:I(),projectId:I(),propertyId:I(),clientEmail:I(),connected:Gt(),createdAt:I(),updatedAt:I()});Ce({date:I(),landingPage:I(),sessions:_e(),organicSessions:_e(),users:_e()});const cI=Tt(["session","first_user","manual_utm"]),uQ=Ce({source:I(),medium:I(),sessions:_e(),users:_e(),sourceDimension:cI}),dQ=Ce({source:I(),medium:I(),sessions:_e(),users:_e(),channelGroup:I()});Ce({totalSessions:_e(),totalOrganicSessions:_e(),totalUsers:_e(),topPages:ke(Ce({landingPage:I(),sessions:_e(),organicSessions:_e(),users:_e()})),aiReferrals:ke(uQ),aiSessionsDeduped:_e(),aiUsersDeduped:_e(),socialReferrals:ke(dQ),socialSessions:_e(),socialUsers:_e(),organicSharePct:_e(),aiSharePct:_e(),socialSharePct:_e(),lastSyncedAt:I().nullable()});Ce({date:I(),source:I(),medium:I(),sessions:_e(),users:_e(),sourceDimension:cI});Ce({date:I(),source:I(),medium:I(),sessions:_e(),users:_e(),channelGroup:I()});Ce({date:I(),sessions:_e(),organicSessions:_e(),users:_e()});function jE(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function Dn({text:e}){const[t,n]=x.useState(null),r=x.useRef(null),i=x.useCallback(()=>{if(!r.current)return;const l=r.current.getBoundingClientRect();n({top:l.top,left:l.left+l.width/2})},[]),s=x.useCallback(()=>n(null),[]);return u.jsxs("span",{className:"info-tooltip-wrapper",onMouseEnter:i,onMouseLeave:s,onFocus:i,onBlur:s,children:[u.jsxs("svg",{ref:r,className:"info-tooltip-icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[u.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M8 7v4M8 5.5v0",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),t!==null&&ml.createPortal(u.jsx("span",{role:"tooltip",style:{position:"fixed",top:t.top,left:t.left,transform:"translateX(-50%) translateY(calc(-100% - 8px))",zIndex:9999,pointerEvents:"none",width:"14rem",padding:"0.5rem 0.75rem",fontSize:"11px",fontWeight:400,textTransform:"none",letterSpacing:"normal",lineHeight:"1rem",color:"#d4d4d8",backgroundColor:"#18181b",border:"1px solid rgba(63, 63, 70, 0.6)",borderRadius:"0.5rem",boxShadow:"0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1)"},children:e}),document.body)]})}function NE(e,t){const n=fQ(t),r=e.split(/(\*\*[^*]+\*\*)/).filter(Boolean).map(h=>h.startsWith("**")&&h.endsWith("**")?{type:"bold",value:h.slice(2,-2)}:{type:"text",value:h}),i=n.flatMap(h=>h.terms).filter(h=>h.trim().length>1);if(i.length===0)return r.map((h,p)=>h.type==="bold"?Oi.createElement("strong",{key:`b-${p}`,className:"text-zinc-200 font-semibold"},h.value):h.value).filter(Boolean);const l=[...i].sort((h,p)=>p.length-h.length).map(h=>h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),c=new RegExp(`(${l.join("|")})`,"gi"),f=new Map;for(const h of n)for(const p of h.terms){const g=p.toLowerCase();f.has(g)||f.set(g,h.className)}return r.flatMap((h,p)=>h.value.split(c).map((v,y)=>{if(!v)return null;if(y%2===1){const w=f.get(v.toLowerCase())??"answer-highlight";return h.type==="bold"?Oi.createElement("mark",{key:`hl-${p}-${y}`,className:w},Oi.createElement("strong",{className:"text-zinc-200 font-semibold"},v)):Oi.createElement("mark",{key:`hl-${p}-${y}`,className:w},v)}return h.type==="bold"?Oi.createElement("strong",{key:`b-${p}-${y}`,className:"text-zinc-200 font-semibold"},v):v})).filter(Boolean)}function fQ(e){return e.length===0?[]:typeof e[0]=="string"?[{terms:e,className:"answer-highlight"}]:e}function Eb(e,t){switch(e){case"new":return"First observation";case"emerging":return"First visibility";case"lost":return"Lost since last run";default:return t==="visible"?"Visible in latest run":t==="pending"?"Awaiting first run":"Not visible in latest run"}}function hQ({evidence:e,project:t,onClose:n}){const[r,i]=x.useState(!1),[s,l]=x.useState("mentions"),[c,f]=x.useState(-1),[h,p]=x.useState(null),[g,v]=x.useState(!1),[y,S]=x.useState({}),w=LW(t.project),N=new Set(w.map(Rw)),C=e.runHistory,E=C.length>1,[k,O]=x.useState(null),T=x.useRef(!1);x.useEffect(()=>{if(T.current||e.answerSnippet&&(e.visibilityState!=null||e.answerMentioned!=null))return;const Y=C.at(-1);Y&&(T.current=!0,Lc(Y.runId).then(ie=>{const oe=ie.snapshots.find(ue=>ue.keyword===e.keyword&&ue.provider===e.provider);oe&&O({citationState:oe.citationState,answerMentioned:oe.answerMentioned,visibilityState:oe.visibilityState,visibilityTransition:Y.visibilityTransition,provider:oe.provider,model:oe.model??e.model,answerSnippet:oe.answerText??e.answerSnippet,citedDomains:oe.citedDomains??e.citedDomains,competitorDomains:oe.competitorOverlap??e.competitorDomains,recommendedCompetitors:oe.recommendedCompetitors??e.recommendedCompetitors??[],matchedTerms:oe.matchedTerms??e.matchedTerms??[],groundingSources:oe.groundingSources??e.groundingSources,evidenceUrls:[],changeLabel:e.visibilityChangeLabel??e.changeLabel,summary:e.summary})}).catch(()=>{}))},[e,C]);const z=c>=0&&h!==null,A=z?h:k||{citationState:e.citationState,answerMentioned:e.answerMentioned,visibilityState:e.visibilityState,visibilityTransition:C.at(-1)?.visibilityTransition,provider:e.provider,model:e.model,answerSnippet:e.answerSnippet,citedDomains:e.citedDomains,competitorDomains:e.competitorDomains,recommendedCompetitors:e.recommendedCompetitors??[],matchedTerms:e.matchedTerms??[],groundingSources:e.groundingSources,evidenceUrls:e.evidenceUrls,changeLabel:e.visibilityChangeLabel??e.changeLabel,summary:e.summary},P=A.visibilityState==="pending"||A.citationState==="pending",R=P?!1:A.visibilityState!=null?A.visibilityState==="visible":A.answerMentioned!=null?A.answerMentioned:A.citationState==="cited"||A.citationState==="emerging",B=A.answerMentioned!=null||A.visibilityState!=null||A.recommendedCompetitors.length>0,$=A.citedDomains.length>0||A.groundingSources.length>0||A.evidenceUrls.length>0,L=t.project.displayName||t.project.name,re=[...w.map(Rw),L,L.split(" ").slice(0,2).join(" "),...A.matchedTerms].filter(Y=>Y.trim().length>2),ge=[...A.competitorDomains.flatMap(Y=>{const ie=Y.split(".")[0];return ie&&ie.length>=4?[ie]:[]}),...A.recommendedCompetitors].filter(Y=>Y.trim().length>2),be=[{terms:re,className:"answer-highlight-brand"},...ge.length>0?[{terms:ge,className:"answer-highlight-competitor"}]:[]],H=P?"pending":A.visibilityTransition==="lost"?"lost":R?"cited":"not-cited",ee=x.useRef(0),ye=x.useCallback(async Y=>{const ie=++ee.current;if(Y===-1||Y===C.length-1){f(-1),p(null),i(!1);return}f(Y),i(!1);const oe=C[Y],ue=`${oe.runId}::${e.keyword}::${e.provider}`;if(y[ue]){p(y[ue]);return}v(!0);try{const we=await Lc(oe.runId);if(ie!==ee.current)return;const W=we.snapshots.find(je=>je.keyword===e.keyword&&je.provider===e.provider)??we.snapshots.find(je=>je.keyword===e.keyword),le=W?{citationState:W.citationState,answerMentioned:W.answerMentioned,visibilityState:W.visibilityState,visibilityTransition:oe.visibilityTransition,provider:W.provider,model:W.model??null,answerSnippet:W.answerText??"",citedDomains:W.citedDomains,competitorDomains:W.competitorOverlap,recommendedCompetitors:W.recommendedCompetitors??[],matchedTerms:W.matchedTerms??[],groundingSources:W.groundingSources,evidenceUrls:[],changeLabel:Eb(oe.visibilityTransition,oe.visibilityState),summary:""}:{citationState:oe.citationState,answerMentioned:oe.answerMentioned,visibilityState:oe.visibilityState,visibilityTransition:oe.visibilityTransition,provider:e.provider,model:oe.model??null,answerSnippet:"",citedDomains:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],groundingSources:[],evidenceUrls:[],changeLabel:Eb(oe.visibilityTransition,oe.visibilityState),summary:"Snapshot data not available for this run."};S(je=>({...je,[ue]:le})),p(le)}catch{if(ie!==ee.current)return;p({citationState:oe.citationState,answerMentioned:oe.answerMentioned,visibilityState:oe.visibilityState,visibilityTransition:oe.visibilityTransition,provider:e.provider,model:oe.model??null,answerSnippet:"",citedDomains:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],groundingSources:[],evidenceUrls:[],changeLabel:Eb(oe.visibilityTransition,oe.visibilityState),summary:"Failed to load historical run data."})}finally{ie===ee.current&&v(!1)}},[C,e.keyword,e.provider,y]),q=(z||e.historyScope!=="provider")&&A.model?`${A.provider} (${A.model}) · ${A.changeLabel.toLowerCase()}`:`${A.provider} · ${A.changeLabel.toLowerCase()}`,D=!z&&e.historyScope==="provider"?[e.model?`Current model: ${e.model}`:null,e.modelsSeen&&e.modelsSeen.length>1?`History spans ${e.modelsSeen.length} models`:null].filter(Boolean).join(" · "):"",G=R?{label:"Visible in answer",title:"Your brand or domain is mentioned in this answer",meta:q}:A.visibilityTransition==="lost"?{label:"Visibility lost",title:"Your brand no longer appears in this answer",meta:q}:P?{label:"Pending",title:"Awaiting first visibility run",meta:"No provider data yet"}:{label:"Not visible in answer",title:"Your brand or domain was not mentioned in this answer",meta:q},ae=()=>{if(!A.answerSnippet)return null;const Y=A.answerSnippet.split(`
95
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of e.seen.entries()){const c=l[1];if(t===l[0]){s(l);continue}if(e.external){const h=e.external.registry.get(l[0])?.id;if(t!==l[0]&&h){s(l);continue}}if(e.metadataRegistry.get(l[0])?.id){s(l);continue}if(c.cycle){s(l);continue}if(c.count>1&&e.reused==="ref"){s(l);continue}}}function GD(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=l=>{const c=e.seen.get(l);if(c.ref===null)return;const f=c.def??c.schema,h={...f},p=c.ref;if(c.ref=null,p){r(p);const v=e.seen.get(p),y=v.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(y)):Object.assign(f,y),Object.assign(f,h),l._zod.parent===p)for(const w in f)w==="$ref"||w==="allOf"||w in h||delete f[w];if(y.$ref&&v.def)for(const w in f)w==="$ref"||w==="allOf"||w in v.def&&JSON.stringify(f[w])===JSON.stringify(v.def[w])&&delete f[w]}const g=l._zod.parent;if(g&&g!==p){r(g);const v=e.seen.get(g);if(v?.schema.$ref&&(f.$ref=v.schema.$ref,v.def))for(const y in f)y==="$ref"||y==="allOf"||y in v.def&&JSON.stringify(f[y])===JSON.stringify(v.def[y])&&delete f[y]}e.override({zodSchema:l,jsonSchema:f,path:c.path??[]})};for(const l of[...e.seen.entries()].reverse())r(l[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const l=e.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(l)}Object.assign(i,n.def??n.schema);const s=e.external?.defs??{};for(const l of e.seen.entries()){const c=l[1];c.def&&c.defId&&(s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const l=JSON.parse(JSON.stringify(i));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:Cm(t,"input",e.processors),output:Cm(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function Qn(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Qn(r.element,n);if(r.type==="set")return Qn(r.valueType,n);if(r.type==="lazy")return Qn(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Qn(r.innerType,n);if(r.type==="intersection")return Qn(r.left,n)||Qn(r.right,n);if(r.type==="record"||r.type==="map")return Qn(r.keyType,n)||Qn(r.valueType,n);if(r.type==="pipe")return Qn(r.in,n)||Qn(r.out,n);if(r.type==="object"){for(const i in r.shape)if(Qn(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Qn(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Qn(i,n))return!0;return!!(r.rest&&Qn(r.rest,n))}return!1}const QZ=(e,t={})=>n=>{const r=KD({...n,processors:t});return hn(e,r),HD(r,e),GD(r,e)},Cm=(e,t,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},l=KD({...i??{},target:s,io:t,processors:n});return hn(e,l),HD(l,e),GD(l,e)},XZ={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},JZ=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:l,format:c,patterns:f,contentEncoding:h}=e._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof l=="number"&&(i.maxLength=l),c&&(i.format=XZ[c]??c,i.format===""&&delete i.format,c==="time"&&delete i.format),h&&(i.contentEncoding=h),f&&f.size>0){const p=[...f];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},eY=(e,t,n,r)=>{const i=n,{minimum:s,maximum:l,format:c,multipleOf:f,exclusiveMaximum:h,exclusiveMinimum:p}=e._zod.bag;typeof c=="string"&&c.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof s=="number"&&(i.minimum=s,typeof p=="number"&&t.target!=="draft-04"&&(p>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=h,i.exclusiveMaximum=!0):i.exclusiveMaximum=h),typeof l=="number"&&(i.maximum=l,typeof h=="number"&&t.target!=="draft-04"&&(h<=l?delete i.maximum:delete i.exclusiveMaximum)),typeof f=="number"&&(i.multipleOf=f)},tY=(e,t,n,r)=>{n.type="boolean"},nY=(e,t,n,r)=>{n.not={}},rY=(e,t,n,r)=>{},iY=(e,t,n,r)=>{const i=e._zod.def,s=ND(i.entries);s.every(l=>typeof l=="number")&&(n.type="number"),s.every(l=>typeof l=="string")&&(n.type="string"),n.enum=s},aY=(e,t,n,r)=>{const i=e._zod.def,s=[];for(const l of i.values)if(l===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof l=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(l))}else s.push(l);if(s.length!==0)if(s.length===1){const l=s[0];n.type=l===null?"null":typeof l,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[l]:n.const=l}else s.every(l=>typeof l=="number")&&(n.type="number"),s.every(l=>typeof l=="string")&&(n.type="string"),s.every(l=>typeof l=="boolean")&&(n.type="boolean"),s.every(l=>l===null)&&(n.type="null"),n.enum=s},sY=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},oY=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},lY=(e,t,n,r)=>{const i=n,s=e._zod.def,{minimum:l,maximum:c}=e._zod.bag;typeof l=="number"&&(i.minItems=l),typeof c=="number"&&(i.maxItems=c),i.type="array",i.items=hn(s.element,t,{...r,path:[...r.path,"items"]})},cY=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object",i.properties={};const l=s.shape;for(const h in l)i.properties[h]=hn(l[h],t,{...r,path:[...r.path,"properties",h]});const c=new Set(Object.keys(l)),f=new Set([...c].filter(h=>{const p=s.shape[h]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));f.size>0&&(i.required=Array.from(f)),s.catchall?._zod.def.type==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=hn(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},uY=(e,t,n,r)=>{const i=e._zod.def,s=i.inclusive===!1,l=i.options.map((c,f)=>hn(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",f]}));s?n.oneOf=l:n.anyOf=l},dY=(e,t,n,r)=>{const i=e._zod.def,s=hn(i.left,t,{...r,path:[...r.path,"allOf",0]}),l=hn(i.right,t,{...r,path:[...r.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,f=[...c(s)?s.allOf:[s],...c(l)?l.allOf:[l]];n.allOf=f},fY=(e,t,n,r)=>{const i=n,s=e._zod.def;i.type="object";const l=s.keyType,f=l._zod.bag?.patterns;if(s.mode==="loose"&&f&&f.size>0){const p=hn(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const g of f)i.patternProperties[g.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=hn(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=hn(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const h=l._zod.values;if(h){const p=[...h].filter(g=>typeof g=="string"||typeof g=="number");p.length>0&&(i.required=p)}},hY=(e,t,n,r)=>{const i=e._zod.def,s=hn(i.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},pY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},mY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},gY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},vY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType;let l;try{l=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=l},yY=(e,t,n,r)=>{const i=e._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;hn(s,t,r);const l=t.seen.get(e);l.ref=s},bY=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},VD=(e,t,n,r)=>{const i=e._zod.def;hn(i.innerType,t,r);const s=t.seen.get(e);s.ref=i.innerType},xY=fe("ZodISODateTime",(e,t)=>{wV.init(e,t),Yt.init(e,t)});function wY(e){return _Z(xY,e)}const SY=fe("ZodISODate",(e,t)=>{SV.init(e,t),Yt.init(e,t)});function jY(e){return kZ(SY,e)}const NY=fe("ZodISOTime",(e,t)=>{jV.init(e,t),Yt.init(e,t)});function CY(e){return AZ(NY,e)}const OY=fe("ZodISODuration",(e,t)=>{NV.init(e,t),Yt.init(e,t)});function _Y(e){return EZ(OY,e)}const kY=(e,t)=>{kD.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>pG(e,n)},flatten:{value:n=>hG(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Pw,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Pw,2)}},isEmpty:{get(){return e.issues.length===0}}})},fi=fe("ZodError",kY,{Parent:Error}),AY=M1(fi),EY=R1(fi),TY=Fg(fi),PY=Kg(fi),zY=vG(fi),MY=yG(fi),RY=bG(fi),DY=xG(fi),IY=wG(fi),LY=SG(fi),$Y=jG(fi),UY=NG(fi),Zt=fe("ZodType",(e,t)=>(Vt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Cm(e,"input"),output:Cm(e,"output")}}),e.toJSONSchema=QZ(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Qs(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>Xs(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>AY(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>TY(e,n,r),e.parseAsync=async(n,r)=>EY(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>PY(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>zY(e,n,r),e.decode=(n,r)=>MY(e,n,r),e.encodeAsync=async(n,r)=>RY(e,n,r),e.decodeAsync=async(n,r)=>DY(e,n,r),e.safeEncode=(n,r)=>IY(e,n,r),e.safeDecode=(n,r)=>LY(e,n,r),e.safeEncodeAsync=async(n,r)=>$Y(e,n,r),e.safeDecodeAsync=async(n,r)=>UY(e,n,r),e.refine=(n,r)=>e.check(MW(n,r)),e.superRefine=n=>e.check(RW(n)),e.overwrite=n=>e.check(Jc(n)),e.optional=()=>yE(e),e.exactOptional=()=>wW(e),e.nullable=()=>bE(e),e.nullish=()=>yE(bE(e)),e.nonoptional=n=>_W(e,n),e.array=()=>ke(e),e.or=n=>hW([e,n]),e.and=n=>mW(e,n),e.transform=n=>xE(e,bW(n)),e.default=n=>NW(e,n),e.prefault=n=>OW(e,n),e.catch=n=>AW(e,n),e.pipe=n=>xE(e,n),e.readonly=()=>PW(e),e.describe=n=>{const r=e.clone();return Od.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Od.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Od.get(e);const r=e.clone();return Od.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),ZD=fe("_ZodString",(e,t)=>{D1.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(r,i,s)=>JZ(e,r,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(DZ(...r)),e.includes=(...r)=>e.check($Z(...r)),e.startsWith=(...r)=>e.check(UZ(...r)),e.endsWith=(...r)=>e.check(BZ(...r)),e.min=(...r)=>e.check(Nm(...r)),e.max=(...r)=>e.check(qD(...r)),e.length=(...r)=>e.check(FD(...r)),e.nonempty=(...r)=>e.check(Nm(1,...r)),e.lowercase=r=>e.check(IZ(r)),e.uppercase=r=>e.check(LZ(r)),e.trim=()=>e.check(FZ()),e.normalize=(...r)=>e.check(qZ(...r)),e.toLowerCase=()=>e.check(KZ()),e.toUpperCase=()=>e.check(HZ()),e.slugify=()=>e.check(GZ())}),BY=fe("ZodString",(e,t)=>{D1.init(e,t),ZD.init(e,t),e.email=n=>e.check(sZ(qY,n)),e.url=n=>e.check(dZ(FY,n)),e.jwt=n=>e.check(OZ(iW,n)),e.emoji=n=>e.check(fZ(KY,n)),e.guid=n=>e.check(fE(gE,n)),e.uuid=n=>e.check(oZ(wp,n)),e.uuidv4=n=>e.check(lZ(wp,n)),e.uuidv6=n=>e.check(cZ(wp,n)),e.uuidv7=n=>e.check(uZ(wp,n)),e.nanoid=n=>e.check(hZ(HY,n)),e.guid=n=>e.check(fE(gE,n)),e.cuid=n=>e.check(pZ(GY,n)),e.cuid2=n=>e.check(mZ(VY,n)),e.ulid=n=>e.check(gZ(ZY,n)),e.base64=n=>e.check(jZ(tW,n)),e.base64url=n=>e.check(NZ(nW,n)),e.xid=n=>e.check(vZ(YY,n)),e.ksuid=n=>e.check(yZ(WY,n)),e.ipv4=n=>e.check(bZ(QY,n)),e.ipv6=n=>e.check(xZ(XY,n)),e.cidrv4=n=>e.check(wZ(JY,n)),e.cidrv6=n=>e.check(SZ(eW,n)),e.e164=n=>e.check(CZ(rW,n)),e.datetime=n=>e.check(wY(n)),e.date=n=>e.check(jY(n)),e.time=n=>e.check(CY(n)),e.duration=n=>e.check(_Y(n))});function I(e){return aZ(BY,e)}const Yt=fe("ZodStringFormat",(e,t)=>{Ft.init(e,t),ZD.init(e,t)}),qY=fe("ZodEmail",(e,t)=>{fV.init(e,t),Yt.init(e,t)}),gE=fe("ZodGUID",(e,t)=>{uV.init(e,t),Yt.init(e,t)}),wp=fe("ZodUUID",(e,t)=>{dV.init(e,t),Yt.init(e,t)}),FY=fe("ZodURL",(e,t)=>{hV.init(e,t),Yt.init(e,t)}),KY=fe("ZodEmoji",(e,t)=>{pV.init(e,t),Yt.init(e,t)}),HY=fe("ZodNanoID",(e,t)=>{mV.init(e,t),Yt.init(e,t)}),GY=fe("ZodCUID",(e,t)=>{gV.init(e,t),Yt.init(e,t)}),VY=fe("ZodCUID2",(e,t)=>{vV.init(e,t),Yt.init(e,t)}),ZY=fe("ZodULID",(e,t)=>{yV.init(e,t),Yt.init(e,t)}),YY=fe("ZodXID",(e,t)=>{bV.init(e,t),Yt.init(e,t)}),WY=fe("ZodKSUID",(e,t)=>{xV.init(e,t),Yt.init(e,t)}),QY=fe("ZodIPv4",(e,t)=>{CV.init(e,t),Yt.init(e,t)}),XY=fe("ZodIPv6",(e,t)=>{OV.init(e,t),Yt.init(e,t)}),JY=fe("ZodCIDRv4",(e,t)=>{_V.init(e,t),Yt.init(e,t)}),eW=fe("ZodCIDRv6",(e,t)=>{kV.init(e,t),Yt.init(e,t)}),tW=fe("ZodBase64",(e,t)=>{AV.init(e,t),Yt.init(e,t)}),nW=fe("ZodBase64URL",(e,t)=>{TV.init(e,t),Yt.init(e,t)}),rW=fe("ZodE164",(e,t)=>{PV.init(e,t),Yt.init(e,t)}),iW=fe("ZodJWT",(e,t)=>{MV.init(e,t),Yt.init(e,t)}),YD=fe("ZodNumber",(e,t)=>{LD.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(r,i,s)=>eY(e,r,i),e.gt=(r,i)=>e.check(pE(r,i)),e.gte=(r,i)=>e.check(kb(r,i)),e.min=(r,i)=>e.check(kb(r,i)),e.lt=(r,i)=>e.check(hE(r,i)),e.lte=(r,i)=>e.check(_b(r,i)),e.max=(r,i)=>e.check(_b(r,i)),e.int=r=>e.check(vE(r)),e.safe=r=>e.check(vE(r)),e.positive=r=>e.check(pE(0,r)),e.nonnegative=r=>e.check(kb(0,r)),e.negative=r=>e.check(hE(0,r)),e.nonpositive=r=>e.check(_b(0,r)),e.multipleOf=(r,i)=>e.check(mE(r,i)),e.step=(r,i)=>e.check(mE(r,i)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function _e(e){return TZ(YD,e)}const aW=fe("ZodNumberFormat",(e,t)=>{RV.init(e,t),YD.init(e,t)});function vE(e){return PZ(aW,e)}const sW=fe("ZodBoolean",(e,t)=>{DV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tY(e,n,r)});function Gt(e){return zZ(sW,e)}const oW=fe("ZodUnknown",(e,t)=>{IV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rY()});function Om(){return MZ(oW)}const lW=fe("ZodNever",(e,t)=>{LV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nY(e,n,r)});function cW(e){return RZ(lW,e)}const uW=fe("ZodArray",(e,t)=>{$V.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lY(e,n,r,i),e.element=t.element,e.min=(n,r)=>e.check(Nm(n,r)),e.nonempty=n=>e.check(Nm(1,n)),e.max=(n,r)=>e.check(qD(n,r)),e.length=(n,r)=>e.check(FD(n,r)),e.unwrap=()=>e.element});function ke(e,t){return VZ(uW,e,t)}const dW=fe("ZodObject",(e,t)=>{BV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cY(e,n,r,i),St(e,"shape",()=>t.shape),e.keyof=()=>Tt(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Om()}),e.loose=()=>e.clone({...e._zod.def,catchall:Om()}),e.strict=()=>e.clone({...e._zod.def,catchall:cW()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>lG(e,n),e.safeExtend=n=>cG(e,n),e.merge=n=>uG(e,n),e.pick=n=>sG(e,n),e.omit=n=>oG(e,n),e.partial=(...n)=>dG(WD,e,n[0]),e.required=(...n)=>fG(QD,e,n[0])});function Ce(e,t){const n={type:"object",shape:e??{},...$e(t)};return new dW(n)}const fW=fe("ZodUnion",(e,t)=>{qV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uY(e,n,r,i),e.options=t.options});function hW(e,t){return new fW({type:"union",options:e,...$e(t)})}const pW=fe("ZodIntersection",(e,t)=>{FV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dY(e,n,r,i)});function mW(e,t){return new pW({type:"intersection",left:e,right:t})}const gW=fe("ZodRecord",(e,t)=>{KV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fY(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function mf(e,t,n){return new gW({type:"record",keyType:e,valueType:t,...$e(n)})}const Mw=fe("ZodEnum",(e,t)=>{HV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(r,i,s)=>iY(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const s={};for(const l of r)if(n.has(l))s[l]=t.entries[l];else throw new Error(`Key ${l} not found in enum`);return new Mw({...t,checks:[],...$e(i),entries:s})},e.exclude=(r,i)=>{const s={...t.entries};for(const l of r)if(n.has(l))delete s[l];else throw new Error(`Key ${l} not found in enum`);return new Mw({...t,checks:[],...$e(i),entries:s})}});function Tt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Mw({type:"enum",entries:n,...$e(t)})}const vW=fe("ZodLiteral",(e,t)=>{GV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>aY(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Zd(e,t){return new vW({type:"literal",values:Array.isArray(e)?e:[e],...$e(t)})}const yW=fe("ZodTransform",(e,t)=>{VV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oY(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new SD(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Vd(s,n.value,t));else{const l=s;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),l.input??(l.input=n.value),l.inst??(l.inst=e),n.issues.push(Vd(l))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function bW(e){return new yW({type:"transform",transform:e})}const WD=fe("ZodOptional",(e,t)=>{BD.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>VD(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function yE(e){return new WD({type:"optional",innerType:e})}const xW=fe("ZodExactOptional",(e,t)=>{ZV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>VD(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function wW(e){return new xW({type:"optional",innerType:e})}const SW=fe("ZodNullable",(e,t)=>{YV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function bE(e){return new SW({type:"nullable",innerType:e})}const jW=fe("ZodDefault",(e,t)=>{WV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function NW(e,t){return new jW({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():OD(t)}})}const CW=fe("ZodPrefault",(e,t)=>{QV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function OW(e,t){return new CW({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():OD(t)}})}const QD=fe("ZodNonOptional",(e,t)=>{XV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function _W(e,t){return new QD({type:"nonoptional",innerType:e,...$e(t)})}const kW=fe("ZodCatch",(e,t)=>{JV.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function AW(e,t){return new kW({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const EW=fe("ZodPipe",(e,t)=>{eZ.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yY(e,n,r,i),e.in=t.in,e.out=t.out});function xE(e,t){return new EW({type:"pipe",in:e,out:t})}const TW=fe("ZodReadonly",(e,t)=>{tZ.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bY(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function PW(e){return new TW({type:"readonly",innerType:e})}const zW=fe("ZodCustom",(e,t)=>{nZ.init(e,t),Zt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sY(e,n)});function MW(e,t={}){return ZZ(zW,e,t)}function RW(e){return YZ(e)}Ce({maxConcurrency:_e().int().positive(),maxRequestsPerMinute:_e().int().positive(),maxRequestsPerDay:_e().int().positive()});const eu=I().min(1);I().min(1);const I1=Ce({label:I().min(1),city:I().min(1),region:I().min(1),country:I().length(2),timezone:I().optional()}),XD=Tt(["citation.lost","citation.gained","run.completed","run.failed","insight.critical","insight.high"]);Ce({id:I(),projectId:I(),channel:Zd("webhook"),url:I().url(),urlDisplay:I(),urlHost:I(),events:ke(XD),enabled:Gt().default(!0),source:I().optional(),webhookSecret:I().optional(),createdAt:I(),updatedAt:I()});const JD=Tt(["cli","api","config-file"]);function DW(e){const t=new Set,n=new Set;for(const r of e){if(t.has(r.label)){n.add(r.label);continue}t.add(r.label)}return[...n]}function IW(e,t){return t?e.some(n=>n.label===t):!0}Ce({displayName:I().min(1),canonicalDomain:I().min(1),ownedDomains:ke(I().min(1)).optional(),country:I().length(2),language:I().min(2),tags:ke(I()).optional(),labels:mf(I(),I()).optional(),providers:ke(eu).optional(),locations:ke(I1).optional(),defaultLocation:I().nullable().optional(),configSource:JD.optional()});Ce({id:I(),name:I(),displayName:I().optional(),canonicalDomain:I(),ownedDomains:ke(I()).default([]),country:I().length(2),language:I().min(2),tags:ke(I()).default([]),labels:mf(I(),I()).default({}),locations:ke(I1).default([]),defaultLocation:I().nullable().optional(),configSource:JD.default("cli"),configRevision:_e().int().positive().default(1),createdAt:I().optional(),updatedAt:I().optional()});function Rw(e){let t=e.trim().toLowerCase();try{t.includes("://")&&(t=new URL(t).hostname.toLowerCase())}catch{}return t.replace(/^www\./,"")}function LW(e){const t=[e.canonicalDomain,...e.ownedDomains??[]],n=new Set,r=[];for(const i of t){const s=i.trim();if(!s)continue;const l=Rw(s);n.has(l)||(n.add(l),r.push(s))}return r}const $W=Ce({name:I().min(1).max(63).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,{message:"Name must be a lowercase slug (letters, numbers, hyphens)"}),labels:mf(I(),I()).optional().default({})}),UW=Ce({preset:I().optional(),cron:I().optional(),timezone:I().optional().default("UTC"),providers:ke(eu).optional().default([])}).refine(e=>e.preset&&!e.cron||!e.preset&&e.cron,{message:'Exactly one of "preset" or "cron" must be provided'}).optional(),BW=Ce({channel:Zd("webhook"),url:I().url(),events:ke(XD).min(1)}),qW=Ce({gsc:Ce({propertyUrl:I()}).optional(),syncSchedule:Ce({preset:I().optional(),cron:I().optional()}).optional()}).optional(),FW=Ce({displayName:I().min(1),canonicalDomain:I().min(1),ownedDomains:ke(I().min(1)).optional().default([]),country:I().length(2),language:I().min(2),keywords:ke(I().min(1)).optional().default([]),competitors:ke(I().min(1)).optional().default([]),providers:ke(eu).optional().default([]),locations:ke(I1).optional().default([]),defaultLocation:I().optional(),schedule:UW,notifications:ke(BW).optional().default([]),google:qW}).superRefine((e,t)=>{const n=DW(e.locations);n.length>0&&t.addIssue({code:"custom",message:`Duplicate location labels are not allowed: ${n.join(", ")}`,path:["locations"]}),IW(e.locations,e.defaultLocation)||t.addIssue({code:"custom",message:`defaultLocation "${e.defaultLocation}" must match a configured location label`,path:["defaultLocation"]})});Ce({apiVersion:Zd("canonry/v1"),kind:Zd("Project"),metadata:$W,spec:FW});const KW=Tt(["gsc","ga4"]);Ce({id:I(),domain:I(),connectionType:KW,propertyId:I().nullable().optional(),sitemapUrl:I().nullable().optional(),scopes:ke(I()).default([]),createdAt:I(),updatedAt:I()});Ce({date:I(),query:I(),page:I(),country:I().nullable().optional(),device:I().nullable().optional(),clicks:_e(),impressions:_e(),ctr:_e(),position:_e()});const Dw=Ce({id:I(),url:I(),indexingState:I().nullable().optional(),verdict:I().nullable().optional(),coverageState:I().nullable().optional(),pageFetchState:I().nullable().optional(),robotsTxtState:I().nullable().optional(),crawlTime:I().nullable().optional(),lastCrawlResult:I().nullable().optional(),isMobileFriendly:Gt().nullable().optional(),richResults:ke(I()).default([]),inspectedAt:I()});Tt(["stable","reindexed","deindexed","still-missing","new"]);const HW=Ce({url:I(),previousState:I().nullable(),currentState:I().nullable(),transitionDate:I()}),GW=Ce({reason:I(),count:_e(),urls:ke(Dw).default([])});Ce({summary:Ce({total:_e(),indexed:_e(),notIndexed:_e(),deindexed:_e(),percentage:_e()}),lastInspectedAt:I().nullable(),indexed:ke(Dw).default([]),notIndexed:ke(Dw).default([]),deindexed:ke(HW).default([]),reasonGroups:ke(GW).default([])});Ce({url:I(),type:Tt(["URL_UPDATED","URL_DELETED"]),notifiedAt:I()});Ce({url:I(),type:Tt(["URL_UPDATED","URL_DELETED"]),notifiedAt:I(),status:Tt(["success","error"]),error:I().optional()});Ce({date:I(),indexed:_e(),notIndexed:_e(),reasonBreakdown:mf(I(),_e()).default({})});Ce({id:I(),domain:I(),siteUrl:I().nullable().optional(),createdAt:I(),updatedAt:I()});const Ab=Ce({id:I(),url:I(),httpCode:_e().nullable().optional(),inIndex:Gt().nullable().optional(),lastCrawledDate:I().nullable().optional(),inIndexDate:I().nullable().optional(),inspectedAt:I(),documentSize:_e().nullable().optional(),anchorCount:_e().nullable().optional(),discoveryDate:I().nullable().optional()});Ce({summary:Ce({total:_e(),indexed:_e(),notIndexed:_e(),unknown:_e().optional(),percentage:_e()}),lastInspectedAt:I().nullable(),indexed:ke(Ab).default([]),notIndexed:ke(Ab).default([]),unknown:ke(Ab).default([]).optional()});Ce({query:I(),impressions:_e(),clicks:_e(),ctr:_e(),averagePosition:_e()});Ce({date:I(),indexed:_e(),notIndexed:_e(),unknown:_e()});Ce({url:I(),status:Tt(["success","error"]),submittedAt:I(),error:I().optional()});const tu=Tt(["live","staging"]);Ce({projectName:I(),url:I(),stagingUrl:I().optional(),username:I(),defaultEnv:tu,createdAt:I(),updatedAt:I()});const wE=Ce({url:I(),reachable:Gt(),pageCount:_e().nullable().optional(),version:I().nullable().optional(),error:I().nullable().optional(),plugins:ke(I()).optional(),authenticatedUser:Ce({id:_e(),slug:I()}).nullable().optional()});Ce({connected:Gt(),projectName:I(),defaultEnv:tu,live:wE.nullable(),staging:wE.nullable(),adminUrl:I().nullable().optional()});const VW=Ce({id:_e(),slug:I(),title:I(),status:I(),modifiedAt:I().nullable().optional(),link:I().nullable().optional()}),eI=Ce({title:I().nullable(),description:I().nullable(),noindex:Gt().nullable(),writable:Gt().default(!1),writeTargets:ke(I()).default([])}),ZW=Ce({type:I(),json:mf(I(),Om())}),YW=VW.extend({env:tu,content:I(),seo:eI,schemaBlocks:ke(ZW).default([])}),SE=YW.extend({contentHash:I(),contentSnippet:I()}),tI=Ce({manualRequired:Zd(!0),targetUrl:I(),adminUrl:I().nullable().optional(),content:I(),nextSteps:ke(I()).default([])}),WW=Ce({slug:I(),severity:Tt(["high","medium","low"]),code:Tt(["noindex","missing-seo-title","missing-meta-description","missing-schema","thin-content"]),message:I()});Ce({slug:I(),title:I(),status:I(),wordCount:_e(),seo:eI,schemaPresent:Gt(),issues:ke(WW).default([])});const QW=Ce({slug:I(),status:Tt(["applied","skipped","manual"]),error:I().optional(),manualAssist:tI.optional()});Ce({env:tu,strategy:Tt(["plugin","manual"]),results:ke(QW)});const XW=Ce({slug:I(),status:Tt(["deployed","stripped","skipped","failed"]),schemasInjected:ke(I()).optional(),manualAssist:tI.optional(),error:I().optional()});Ce({env:tu,results:ke(XW)});const JW=Ce({slug:I(),title:I(),canonrySchemas:ke(I()),thirdPartySchemas:ke(I()),hasCanonrySchema:Gt()});Ce({env:tu,pages:ke(JW)});const eQ=Ce({name:I(),status:Tt(["completed","skipped","failed"]),summary:I().optional(),error:I().optional()});Ce({projectName:I(),steps:ke(eQ)});Ce({slug:I(),live:SE,staging:SE,hasDifferences:Gt(),differences:Ce({title:Gt(),slug:Gt(),content:Gt(),seoTitle:Gt(),seoDescription:Gt(),noindex:Gt(),schema:Gt()})});const nI=Tt(["queued","running","completed","partial","failed","cancelled"]),en=nI.enum,rI=Tt(["answer-visibility","site-audit","gsc-sync","inspect-sitemap","ga-sync","bing-inspect"]),hr=rI.enum,iI=Tt(["manual","scheduled","config-apply"]),Qp=iI.enum,aI=Tt(["cited","not-cited"]);aI.enum;const sI=Tt(["visible","not-visible"]);sI.enum;const oI=Tt(["new","cited","lost","emerging","not-cited"]);oI.enum;Ce({id:I(),projectId:I(),kind:rI,status:nI,trigger:iI.default("manual"),location:I().nullable().optional(),startedAt:I().nullable().optional(),finishedAt:I().nullable().optional(),error:I().nullable().optional(),createdAt:I()});const lI=Ce({uri:I(),title:I()});Ce({id:I(),runId:I(),keywordId:I(),keyword:I().optional(),provider:eu,citationState:aI,answerMentioned:Gt().optional(),visibilityState:sI.optional(),transition:oI.optional(),answerText:I().nullable().optional(),citedDomains:ke(I()).default([]),competitorOverlap:ke(I()).default([]),recommendedCompetitors:ke(I()).default([]),matchedTerms:ke(I()).default([]),groundingSources:ke(lI).default([]),searchQueries:ke(I()).default([]),model:I().nullable().optional(),location:I().nullable().optional(),createdAt:I()});Ce({id:I(),projectId:I().nullable().optional(),actor:I(),action:I(),entityType:I(),entityId:I().nullable().optional(),diff:Om().optional(),createdAt:I()});const tQ=Tt(["yes","no","unknown","not-mentioned"]);Ce({companyName:I().min(1),domain:I().min(1),phrases:ke(I().min(1)).optional().default([]),competitors:ke(I().min(1)).optional().default([])});const nQ=Ce({name:I(),count:_e().int().nonnegative()}),rQ=Ce({id:I(),name:I(),weight:_e(),score:_e(),grade:I(),status:Tt(["pass","partial","fail"]),findings:ke(Ce({type:I(),message:I()})).default([]),recommendations:ke(I()).default([])}),iQ=Ce({url:I(),finalUrl:I(),auditedAt:I(),overallScore:_e(),overallGrade:I(),summary:I(),factors:ke(rQ).default([])}),aQ=Ce({industry:I(),summary:I(),services:ke(I()).default([]),categoryTerms:ke(I()).default([])}),sQ=Ce({provider:I(),displayName:I(),model:I().nullable().optional(),mentioned:Gt(),cited:Gt(),describedAccurately:tQ,accuracyNotes:I().nullable().optional(),incorrectClaims:ke(I()).default([]),recommendedCompetitors:ke(I()).default([]),citedDomains:ke(I()).default([]),groundingSources:ke(lI).default([]),searchQueries:ke(I()).default([]),answerText:I(),error:I().nullable().optional()}),oQ=Ce({phrase:I(),providerResults:ke(sQ).default([])}),lQ=Ce({totalQueries:_e().int().nonnegative(),totalProviders:_e().int().nonnegative(),totalComparisons:_e().int().nonnegative(),mentionCount:_e().int().nonnegative(),citationCount:_e().int().nonnegative(),topCompetitors:ke(nQ).default([]),visibilityGap:I(),whatThisMeans:ke(I()).default([]),recommendedActions:ke(I()).default([])});Ce({companyName:I(),domain:I(),homepageUrl:I(),generatedAt:I(),phrases:ke(I()).default([]),competitors:ke(I()).default([]),profile:aQ,audit:iQ,queryResults:ke(oQ).default([]),summary:lQ});Ce({id:I(),projectId:I(),cronExpr:I(),preset:I().nullable().optional(),timezone:I().default("UTC"),enabled:Gt().default(!0),providers:ke(eu).default([]),lastRunAt:I().nullable().optional(),nextRunAt:I().nullable().optional(),createdAt:I(),updatedAt:I()});Ce({preset:I().optional(),cron:I().optional(),timezone:I().optional().default("UTC"),enabled:Gt().optional().default(!0),providers:ke(eu).optional().default([])}).refine(e=>e.preset&&!e.cron||!e.preset&&e.cron,{message:'Exactly one of "preset" or "cron" must be provided'});const cQ=Tt(["answer","citation"]),Ps=cQ.enum;Ce({id:I(),projectId:I(),propertyId:I(),clientEmail:I(),connected:Gt(),createdAt:I(),updatedAt:I()});Ce({date:I(),landingPage:I(),sessions:_e(),organicSessions:_e(),users:_e()});const cI=Tt(["session","first_user","manual_utm"]),uQ=Ce({source:I(),medium:I(),sessions:_e(),users:_e(),sourceDimension:cI}),dQ=Ce({source:I(),medium:I(),sessions:_e(),users:_e(),channelGroup:I()});Ce({totalSessions:_e(),totalOrganicSessions:_e(),totalUsers:_e(),topPages:ke(Ce({landingPage:I(),sessions:_e(),organicSessions:_e(),users:_e()})),aiReferrals:ke(uQ),aiSessionsDeduped:_e(),aiUsersDeduped:_e(),socialReferrals:ke(dQ),socialSessions:_e(),socialUsers:_e(),organicSharePct:_e(),aiSharePct:_e(),socialSharePct:_e(),lastSyncedAt:I().nullable()});Ce({date:I(),source:I(),medium:I(),sessions:_e(),users:_e(),sourceDimension:cI});Ce({date:I(),source:I(),medium:I(),sessions:_e(),users:_e(),channelGroup:I()});Ce({date:I(),sessions:_e(),organicSessions:_e(),users:_e()});function jE(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function Dn({text:e}){const[t,n]=x.useState(null),r=x.useRef(null),i=x.useCallback(()=>{if(!r.current)return;const l=r.current.getBoundingClientRect();n({top:l.top,left:l.left+l.width/2})},[]),s=x.useCallback(()=>n(null),[]);return u.jsxs("span",{className:"info-tooltip-wrapper",onMouseEnter:i,onMouseLeave:s,onFocus:i,onBlur:s,children:[u.jsxs("svg",{ref:r,className:"info-tooltip-icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[u.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M8 7v4M8 5.5v0",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),t!==null&&ml.createPortal(u.jsx("span",{role:"tooltip",style:{position:"fixed",top:t.top,left:t.left,transform:"translateX(-50%) translateY(calc(-100% - 8px))",zIndex:9999,pointerEvents:"none",width:"14rem",padding:"0.5rem 0.75rem",fontSize:"11px",fontWeight:400,textTransform:"none",letterSpacing:"normal",lineHeight:"1rem",color:"#d4d4d8",backgroundColor:"#18181b",border:"1px solid rgba(63, 63, 70, 0.6)",borderRadius:"0.5rem",boxShadow:"0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1)"},children:e}),document.body)]})}function NE(e,t){const n=fQ(t),r=e.split(/(\*\*[^*]+\*\*)/).filter(Boolean).map(h=>h.startsWith("**")&&h.endsWith("**")?{type:"bold",value:h.slice(2,-2)}:{type:"text",value:h}),i=n.flatMap(h=>h.terms).filter(h=>h.trim().length>1);if(i.length===0)return r.map((h,p)=>h.type==="bold"?Oi.createElement("strong",{key:`b-${p}`,className:"text-zinc-200 font-semibold"},h.value):h.value).filter(Boolean);const l=[...i].sort((h,p)=>p.length-h.length).map(h=>h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),c=new RegExp(`(${l.join("|")})`,"gi"),f=new Map;for(const h of n)for(const p of h.terms){const g=p.toLowerCase();f.has(g)||f.set(g,h.className)}return r.flatMap((h,p)=>h.value.split(c).map((v,y)=>{if(!v)return null;if(y%2===1){const w=f.get(v.toLowerCase())??"answer-highlight";return h.type==="bold"?Oi.createElement("mark",{key:`hl-${p}-${y}`,className:w},Oi.createElement("strong",{className:"text-zinc-200 font-semibold"},v)):Oi.createElement("mark",{key:`hl-${p}-${y}`,className:w},v)}return h.type==="bold"?Oi.createElement("strong",{key:`b-${p}-${y}`,className:"text-zinc-200 font-semibold"},v):v})).filter(Boolean)}function fQ(e){return e.length===0?[]:typeof e[0]=="string"?[{terms:e,className:"answer-highlight"}]:e}function Eb(e,t){switch(e){case"new":return"First observation";case"emerging":return"First visibility";case"lost":return"Lost since last run";default:return t==="visible"?"Visible in latest run":t==="pending"?"Awaiting first run":"Not visible in latest run"}}function hQ({evidence:e,project:t,onClose:n}){const[r,i]=x.useState(!1),[s,l]=x.useState("mentions"),[c,f]=x.useState(-1),[h,p]=x.useState(null),[g,v]=x.useState(!1),[y,S]=x.useState({}),w=LW(t.project),N=new Set(w.map(Rw)),C=e.runHistory,E=C.length>1,[k,O]=x.useState(null),T=x.useRef(!1);x.useEffect(()=>{if(T.current||e.answerSnippet&&(e.visibilityState!=null||e.answerMentioned!=null))return;const Y=C.at(-1);Y&&(T.current=!0,Lc(Y.runId).then(ie=>{const oe=ie.snapshots.find(ue=>ue.keyword===e.keyword&&ue.provider===e.provider);oe&&O({citationState:oe.citationState,answerMentioned:oe.answerMentioned,visibilityState:oe.visibilityState,visibilityTransition:Y.visibilityTransition,provider:oe.provider,model:oe.model??e.model,answerSnippet:oe.answerText??e.answerSnippet,citedDomains:oe.citedDomains??e.citedDomains,competitorDomains:oe.competitorOverlap??e.competitorDomains,recommendedCompetitors:oe.recommendedCompetitors??e.recommendedCompetitors??[],matchedTerms:oe.matchedTerms??e.matchedTerms??[],groundingSources:oe.groundingSources??e.groundingSources,evidenceUrls:[],changeLabel:e.visibilityChangeLabel??e.changeLabel,summary:e.summary})}).catch(()=>{}))},[e,C]);const z=c>=0&&h!==null,A=z?h:k||{citationState:e.citationState,answerMentioned:e.answerMentioned,visibilityState:e.visibilityState,visibilityTransition:C.at(-1)?.visibilityTransition,provider:e.provider,model:e.model,answerSnippet:e.answerSnippet,citedDomains:e.citedDomains,competitorDomains:e.competitorDomains,recommendedCompetitors:e.recommendedCompetitors??[],matchedTerms:e.matchedTerms??[],groundingSources:e.groundingSources,evidenceUrls:e.evidenceUrls,changeLabel:e.visibilityChangeLabel??e.changeLabel,summary:e.summary},P=A.visibilityState==="pending"||A.citationState==="pending",R=P?!1:A.visibilityState!=null?A.visibilityState==="visible":A.answerMentioned!=null?A.answerMentioned:A.citationState==="cited"||A.citationState==="emerging",B=A.answerMentioned!=null||A.visibilityState!=null||A.recommendedCompetitors.length>0,$=A.citedDomains.length>0||A.groundingSources.length>0||A.evidenceUrls.length>0,L=t.project.displayName||t.project.name,re=[...w.map(Rw),L,L.split(" ").slice(0,2).join(" "),...A.matchedTerms].filter(Y=>Y.trim().length>2),ge=[...A.competitorDomains.flatMap(Y=>{const ie=Y.split(".")[0];return ie&&ie.length>=4?[ie]:[]}),...A.recommendedCompetitors].filter(Y=>Y.trim().length>2),be=[{terms:re,className:"answer-highlight-brand"},...ge.length>0?[{terms:ge,className:"answer-highlight-competitor"}]:[]],H=P?"pending":A.visibilityTransition==="lost"?"lost":R?"cited":"not-cited",ee=x.useRef(0),ye=x.useCallback(async Y=>{const ie=++ee.current;if(Y===-1||Y===C.length-1){f(-1),p(null),i(!1);return}f(Y),i(!1);const oe=C[Y],ue=`${oe.runId}::${e.keyword}::${e.provider}`;if(y[ue]){p(y[ue]);return}v(!0);try{const we=await Lc(oe.runId);if(ie!==ee.current)return;const W=we.snapshots.find(je=>je.keyword===e.keyword&&je.provider===e.provider)??we.snapshots.find(je=>je.keyword===e.keyword),le=W?{citationState:W.citationState,answerMentioned:W.answerMentioned,visibilityState:W.visibilityState,visibilityTransition:oe.visibilityTransition,provider:W.provider,model:W.model??null,answerSnippet:W.answerText??"",citedDomains:W.citedDomains,competitorDomains:W.competitorOverlap,recommendedCompetitors:W.recommendedCompetitors??[],matchedTerms:W.matchedTerms??[],groundingSources:W.groundingSources,evidenceUrls:[],changeLabel:Eb(oe.visibilityTransition,oe.visibilityState),summary:""}:{citationState:oe.citationState,answerMentioned:oe.answerMentioned,visibilityState:oe.visibilityState,visibilityTransition:oe.visibilityTransition,provider:e.provider,model:oe.model??null,answerSnippet:"",citedDomains:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],groundingSources:[],evidenceUrls:[],changeLabel:Eb(oe.visibilityTransition,oe.visibilityState),summary:"Snapshot data not available for this run."};S(je=>({...je,[ue]:le})),p(le)}catch{if(ie!==ee.current)return;p({citationState:oe.citationState,answerMentioned:oe.answerMentioned,visibilityState:oe.visibilityState,visibilityTransition:oe.visibilityTransition,provider:e.provider,model:oe.model??null,answerSnippet:"",citedDomains:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],groundingSources:[],evidenceUrls:[],changeLabel:Eb(oe.visibilityTransition,oe.visibilityState),summary:"Failed to load historical run data."})}finally{ie===ee.current&&v(!1)}},[C,e.keyword,e.provider,y]),q=(z||e.historyScope!=="provider")&&A.model?`${A.provider} (${A.model}) · ${A.changeLabel.toLowerCase()}`:`${A.provider} · ${A.changeLabel.toLowerCase()}`,D=!z&&e.historyScope==="provider"?[e.model?`Current model: ${e.model}`:null,e.modelsSeen&&e.modelsSeen.length>1?`History spans ${e.modelsSeen.length} models`:null].filter(Boolean).join(" · "):"",G=R?{label:"Visible in answer",title:"Your brand or domain is mentioned in this answer",meta:q}:A.visibilityTransition==="lost"?{label:"Visibility lost",title:"Your brand no longer appears in this answer",meta:q}:P?{label:"Pending",title:"Awaiting first visibility run",meta:"No provider data yet"}:{label:"Not visible in answer",title:"Your brand or domain was not mentioned in this answer",meta:q},ae=()=>{if(!A.answerSnippet)return null;const Y=A.answerSnippet.split(`
96
96
  `),ie=[];let oe=[],ue=0;const we=()=>{if(oe.length===0)return;const W=oe.join(" ").trim();W&&ie.push(u.jsx("p",{className:ie.length>0?"mt-2.5":"",children:NE(W,be)},ue++)),oe=[]};for(const W of Y){const le=W.trim();if(/^[-\u2013\u2014]{3,}$/.test(le)){we(),ie.push(u.jsx("hr",{className:"border-zinc-800/60 my-3"},ue++));continue}const je=le.match(/^(#{1,3})\s+(.+)$/);if(je){we();const V=je[1].length,Be=je[2].replace(/^[\p{Emoji}\p{Emoji_Component}\s#]+/u,"").trim()||je[2],ze=V===1?"text-[13px] font-semibold text-zinc-100 mt-4 mb-1":V===2?"text-xs font-semibold text-zinc-200 mt-3 mb-0.5":"text-xs font-medium text-zinc-300 mt-2";ie.push(u.jsx("p",{className:ze,children:NE(Be,be)},ue++));continue}if(le===""){we();continue}oe.push(le)}return we(),ie};return u.jsx(pD,{open:!0,onOpenChange:Y=>{Y||n()},children:u.jsxs(mD,{children:[u.jsx(_1,{className:"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm"}),u.jsxs(k1,{className:"evidence-modal","aria-describedby":void 0,children:[u.jsxs("div",{className:"evidence-modal-header",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsxs("p",{className:"eyebrow eyebrow-soft",children:[t.project.name," ","·"," ",A.provider||"All providers"]}),u.jsx(A1,{className:"text-lg font-semibold text-zinc-50 truncate",children:e.keyword})]}),u.jsxs(vD,{className:"inline-flex size-8 items-center justify-center rounded-md text-zinc-500 transition hover:bg-zinc-800 hover:text-zinc-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400 shrink-0",children:[u.jsx(Rg,{className:"size-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]}),E&&u.jsxs("div",{className:"evidence-modal-timeline",children:[u.jsx("p",{className:"drawer-section-label mb-1.5",children:"Run history"}),u.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1",children:C.map((Y,ie)=>{const oe=c===-1&&ie===C.length-1||c===ie,ue=Y.visibilityState??(Y.answerMentioned?"visible":"not-visible"),we=Y.visibilityTransition??ue,W=ue==="visible"?"bg-emerald-400":we==="emerging"?"bg-amber-400":we==="lost"?"bg-rose-400":"bg-zinc-600",je=new Date(Y.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}),V=!!(Y.model&&ie>0&&C[ie-1]?.model&&C[ie-1].model!==Y.model);return u.jsxs("button",{type:"button",className:`evidence-run-dot ${oe?"evidence-run-dot--selected":""}`,onClick:()=>ye(ie===C.length-1?-1:ie),"aria-label":[`Run ${je}: ${ue}`,Y.model?`model ${Y.model}`:null,V?"model changed":null].filter(Boolean).join(" — "),"aria-pressed":oe,children:[u.jsx("span",{className:`size-2 rounded-full ${W} ${V?"ring-1 ring-amber-300/80 ring-offset-2 ring-offset-zinc-950":""}`,"aria-hidden":"true"}),u.jsx("span",{className:"text-[10px] text-zinc-500",children:je})]},ie)})}),c>=0&&c<C.length&&u.jsxs("p",{className:"text-[11px] text-zinc-500 mt-1",children:["Viewing run from ",new Date(C[c].createdAt).toLocaleString()," ","—"," ",u.jsx("span",{className:"capitalize",children:C[c].visibilityState??(C[c].answerMentioned?"visible":"not-visible")}),u.jsxs("button",{type:"button",className:"text-zinc-400 hover:text-zinc-200 ml-2",onClick:()=>ye(-1),children:["←"," Back to latest"]})]}),!z&&(e.modelTransitions?.length??0)>0&&u.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:e.modelTransitions.map(Y=>u.jsx("span",{className:"inline-flex items-center rounded-full border border-amber-400/30 bg-amber-400/10 px-2 py-1 text-[10px] text-amber-100",children:`${Y.fromModel??"unknown"} -> ${Y.toModel??"unknown"} on ${new Date(Y.createdAt).toLocaleDateString()}`},`${Y.runId}:${Y.toModel??"unknown"}`))})]}),u.jsxs("div",{className:"evidence-modal-body",children:[g&&u.jsxs("div",{className:"md:col-span-2 flex items-center justify-center py-12 text-zinc-500 text-sm",children:["Loading historical run data","…"]}),!g&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"evidence-modal-main",children:[u.jsxs("div",{className:`evidence-position-hero evidence-position-hero--${H}`,children:[u.jsx("p",{className:`evidence-position-label evidence-position-label--${H}`,children:G.label}),u.jsx("p",{className:`evidence-position-title evidence-position-title--${H}`,children:G.title}),u.jsx("p",{className:"evidence-position-meta",children:G.meta}),D&&u.jsx("p",{className:"mt-1 text-[11px] text-zinc-500",children:D})]}),A.answerSnippet&&u.jsxs("div",{children:[u.jsx("p",{className:"drawer-section-label",children:"What the AI said"}),u.jsx("div",{className:`answer-snippet-block ${r?"evidence-answer-expanded":"evidence-answer-collapsed"}`,children:ae()}),A.answerSnippet.length>280&&u.jsx("button",{type:"button",className:"mt-1.5 text-xs text-zinc-500 hover:text-zinc-300 transition-colors",onClick:()=>i(!r),children:r?"↑ Collapse":"↓ Show full answer"})]}),!A.answerSnippet&&!g&&u.jsx("div",{className:"rounded-lg border border-zinc-800/40 bg-zinc-900/20 px-4 py-8 text-center text-zinc-600 text-sm",children:"No answer text recorded for this run"}),!z&&e.relatedTechnicalSignals.length>0&&u.jsxs("div",{children:[u.jsx("p",{className:"drawer-section-label",children:R?"Why you're visible":"What to fix"}),u.jsx("div",{className:"action-items-list",children:e.relatedTechnicalSignals.map((Y,ie)=>u.jsxs("div",{className:"action-item",children:[u.jsx("svg",{className:`action-item-icon ${R?"text-emerald-400":"text-amber-400"}`,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:R?u.jsx("path",{d:"M3 8l3.5 3.5L13 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}):u.jsxs(u.Fragment,{children:[u.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M8 5v3.5M8 10.5v0",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),u.jsx("span",{className:"action-item-text",children:Y})]},ie))})]}),A.summary&&u.jsx("p",{className:"text-xs text-zinc-600 border-t border-zinc-800/40 pt-3 mt-1",children:A.summary})]}),u.jsxs("div",{className:"evidence-modal-sidebar",children:[(B||$)&&u.jsxs("div",{className:"sidebar-tabs",children:[u.jsx("button",{className:`sidebar-tab ${s==="mentions"?"sidebar-tab--active":""}`,onClick:()=>l("mentions"),type:"button",title:"Canonry's answer-level visibility assessment and any company names extracted from the answer text.",children:"Mentions"}),u.jsx("button",{className:`sidebar-tab ${s==="sources"?"sidebar-tab--active":""}`,onClick:()=>l("sources"),type:"button",title:"Grounding links the model used to build the answer. These are supporting sources, not the primary visibility signal.",children:"Sources"})]}),s==="mentions"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsxs("div",{className:"drawer-section-label flex items-center",children:[u.jsx("span",{children:"Answer visibility"}),u.jsx(Dn,{text:"Canonry scans the AI answer for your owned domains and project name. This is independent from grounding or citation sources."})]}),u.jsxs("div",{className:`mention-status mention-status--${R?"visible":"not-visible"}`,children:[u.jsx("span",{className:"mention-status-icon",children:P?"…":R?"✓":"—"}),u.jsx("span",{className:"mention-status-label",children:P?"Pending":R?"Visible":"Not visible"})]}),A.matchedTerms.length>0&&u.jsxs("div",{className:"mt-2",children:[u.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500 mb-1.5",children:"Matched in answer"}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.matchedTerms.map(Y=>u.jsx("span",{className:"mention-chip mention-chip--brand",children:Y},Y))})]}),!P&&!R&&A.matchedTerms.length===0&&u.jsxs("div",{className:"mt-2",children:[u.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500 mb-1.5",children:"Searched for"}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:re.map(Y=>u.jsx("span",{className:"mention-chip mention-chip--muted",children:Y},Y))}),u.jsx("p",{className:"text-[11px] text-zinc-600 mt-1.5",children:"None of these appear in the answer text."})]})]}),(A.recommendedCompetitors.length>0||A.competitorDomains.length>0)&&u.jsxs("div",{children:[u.jsxs("div",{className:"drawer-section-label flex items-center",children:[u.jsx("span",{children:"Competitors in answer"}),u.jsx(Dn,{text:"Competitors detected in the answer text or cited source links. Includes both tracked competitors and names extracted by Canonry."})]}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:(()=>{const Y=A.competitorDomains.map(ue=>ue.replace(/^www\./,"")),ie=new Set(Y.map(ue=>jE(ue.replace(/\.[^.]+$/,""))));return[...A.recommendedCompetitors.filter(ue=>!ie.has(jE(ue))),...Y].map(ue=>u.jsx("span",{className:"mention-chip mention-chip--competitor",children:ue},ue))})()})]})]}),s==="sources"&&u.jsxs(u.Fragment,{children:[A.citedDomains.length>0&&u.jsxs("div",{children:[u.jsxs("div",{className:"drawer-section-label flex items-center",children:[u.jsx("span",{children:"Domains from source links"}),u.jsx(Dn,{text:"These domains were extracted from grounding or citation URLs. They are supporting-source metadata, not proof that the answer text mentioned them."})]}),u.jsx("div",{className:"citation-leaderboard",children:A.citedDomains.map((Y,ie)=>{const oe=Y.toLowerCase().replace(/^www\./,""),ue=N.has(oe),we=!ue&&A.competitorDomains.some(le=>le.toLowerCase().replace(/^www\./,"")===oe),W=ue?"you":we?"competitor":"other";return u.jsxs("div",{className:`citation-leaderboard-item citation-leaderboard-item--${W}`,children:[u.jsxs("span",{className:"citation-leaderboard-rank",children:["#",ie+1]}),u.jsx("span",{className:"citation-leaderboard-domain",children:Y}),ue&&u.jsx("span",{className:"citation-leaderboard-tag",children:"You"}),we&&u.jsx("span",{className:"citation-leaderboard-tag",children:"Competitor"})]},Y)})})]}),A.groundingSources.length>0&&u.jsxs("div",{children:[u.jsxs("div",{className:"drawer-section-label flex items-center",children:[u.jsxs("span",{children:["Grounding source links (",A.groundingSources.length,")"]}),u.jsx(Dn,{text:"Links the model used as grounding or supporting context while producing the answer. These are not the same thing as answer visibility."})]}),u.jsx("ul",{className:"grid gap-0.5",children:A.groundingSources.map((Y,ie)=>u.jsx("li",{className:"truncate text-sm",children:u.jsx("a",{href:Y.uri,target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-zinc-200 transition-colors",children:Y.title||Y.uri})},ie))})]}),A.evidenceUrls.length>0&&u.jsxs("div",{children:[u.jsx("p",{className:"drawer-section-label",children:"Evidence URLs"}),u.jsx("ul",{className:"grid gap-1",children:A.evidenceUrls.map(Y=>u.jsx("li",{className:"truncate text-sm",children:u.jsx("a",{href:Y,target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-zinc-200 transition-colors",children:Y})},Y))})]}),A.citedDomains.length===0&&A.groundingSources.length===0&&A.evidenceUrls.length===0&&u.jsxs("div",{className:"flex items-center justify-center h-24 text-zinc-600 text-sm",children:["No source data ",z?"for this run":"yet"]})]}),!B&&!$&&u.jsxs("div",{className:"flex items-center justify-center h-24 text-zinc-600 text-sm",children:["No answer visibility data ",z?"for this run":"yet"]})]})]})]})]})]})})}function Ni(e){const t=new Date("2026-02-20");return e.map((n,r)=>({runId:`run_mock_${r+1}`,citationState:n,createdAt:new Date(t.getTime()+r*2*24*60*60*1e3).toISOString()}))}const Tb=[{id:"project_citypoint",name:"Citypoint Dental NYC",canonicalDomain:"citypointdental.com",ownedDomains:[],country:"US",language:"en",tags:["local intent","priority"],labels:{},locations:[],defaultLocation:null,configSource:"cli",configRevision:1},{id:"project_harbor",name:"Harbor Legal Group",canonicalDomain:"harborlegal.com",ownedDomains:[],country:"US",language:"en",tags:["lead gen"],labels:{},locations:[],defaultLocation:null,configSource:"cli",configRevision:1},{id:"project_northstar",name:"Northstar Orthopedics",canonicalDomain:"northstarortho.com",ownedDomains:[],country:"US",language:"en",tags:["multi-location"],labels:{},locations:[],defaultLocation:null,configSource:"cli",configRevision:1}];function Gg(e){return{id:e.id,projectId:e.projectId,projectName:e.projectName,kind:e.kind,kindLabel:e.kindLabel,status:e.status,trigger:e.trigger??"manual",createdAt:e.createdAt,startedAt:e.startedAt,duration:e.duration,statusDetail:e.statusDetail,summary:e.summary,triggerLabel:e.triggerLabel}}const pQ=Gg({id:"run_citypoint_visibility_20260308",projectId:"project_citypoint",projectName:"Citypoint Dental NYC",kind:"answer-visibility",kindLabel:"Answer visibility sweep",status:"completed",createdAt:"2026-03-08T12:15:00.000Z",startedAt:"Mar 8, 12:15 PM",duration:"6m 12s",statusDetail:"18 tracked queries checked; 3 citation losses detected on emergency-intent prompts.",summary:"Citation losses on emergency-intent prompts",triggerLabel:"Scheduled"}),mQ=Gg({id:"run_citypoint_queued_20260309",projectId:"project_citypoint",projectName:"Citypoint Dental NYC",kind:"answer-visibility",kindLabel:"Answer visibility sweep",status:"queued",createdAt:"2026-03-09T08:05:00.000Z",startedAt:"Mar 9, 8:05 AM",duration:"Waiting for slot",statusDetail:"Ready to enqueue after the next provider rate window clears.",summary:"Queued follow-up after local ranking movement",triggerLabel:"Manual"}),gQ=Gg({id:"run_harbor_visibility_20260308",projectId:"project_harbor",projectName:"Harbor Legal Group",kind:"answer-visibility",kindLabel:"Answer visibility sweep",status:"completed",createdAt:"2026-03-08T11:05:00.000Z",startedAt:"Mar 8, 11:05 AM",duration:"5m 07s",statusDetail:"12 tracked queries checked; local-intent visibility held steady across branded prompts.",summary:"Branded prompts remain stable",triggerLabel:"Scheduled"}),vQ=Gg({id:"run_northstar_visibility_20260308",projectId:"project_northstar",projectName:"Northstar Orthopedics",kind:"answer-visibility",kindLabel:"Answer visibility sweep",status:"running",createdAt:"2026-03-08T13:40:00.000Z",startedAt:"Mar 8, 1:40 PM",duration:"3m 10s",statusDetail:"Provider responses still in flight for 9 multi-location prompts.",summary:"Mid-run on treatment-location prompts",triggerLabel:"Manual"}),yQ=[{id:"evidence_citypoint_emergency_gemini",keyword:"emergency dentist brooklyn",provider:"gemini",model:"gemini-3-flash",location:null,citationState:"lost",changeLabel:"Lost since Mar 5",answerSnippet:"For urgent dental care in Brooklyn, Downtown Smiles and Harbor Dental are now cited first for emergency availability and same-day booking.",citedDomains:["downtownsmiles.com","harbordental.com"],evidenceUrls:["https://downtownsmiles.com/emergency-dentist-brooklyn","https://harbordental.com/same-day-emergency-care"],competitorDomains:["downtownsmiles.com","harbordental.com"],groundingSources:[],relatedTechnicalSignals:["FAQ schema missing on the emergency service page","llms.txt not found during latest site audit","Location pages link weakly into the emergency care hub"],summary:"AI answers now cite two competitors while your emergency page is no longer grounded.",runHistory:Ni(["cited","cited","cited","cited","cited","cited","cited","not-cited","not-cited"])},{id:"evidence_citypoint_emergency_openai",keyword:"emergency dentist brooklyn",provider:"openai",model:"gpt-5.4",location:null,citationState:"cited",changeLabel:"Cited for 6 runs",answerSnippet:"Citypoint Dental is listed as a top emergency dentist in Brooklyn for same-day appointments and walk-in availability.",citedDomains:["citypointdental.com","downtownsmiles.com"],evidenceUrls:["https://citypointdental.com/emergency-dentist-brooklyn"],competitorDomains:["downtownsmiles.com"],groundingSources:[],relatedTechnicalSignals:["Emergency page indexed with structured data"],summary:"OpenAI cites your emergency page consistently alongside one competitor.",runHistory:Ni(["not-cited","cited","cited","cited","cited","cited","cited"])},{id:"evidence_citypoint_emergency_claude",keyword:"emergency dentist brooklyn",provider:"claude",model:"claude-sonnet-4-6",location:null,citationState:"not-cited",changeLabel:"No citation across 12 runs",answerSnippet:"Based on the search results, top-rated emergency dental practices in Brooklyn include Downtown Smiles and Harbor Dental.",citedDomains:["downtownsmiles.com","harbordental.com"],evidenceUrls:[],competitorDomains:["downtownsmiles.com","harbordental.com"],groundingSources:[],relatedTechnicalSignals:["FAQ schema missing","llms.txt not found"],summary:"Claude does not cite your domain for this emergency query.",runHistory:Ni(["not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited"])},{id:"evidence_citypoint_invisalign_openai",keyword:"best invisalign dentist downtown brooklyn",provider:"openai",model:"gpt-5.4",location:null,citationState:"emerging",changeLabel:"First citation in 7 days",answerSnippet:"Citypoint Dental appears as an emerging recommendation for Invisalign in Downtown Brooklyn, supported by recent before-and-after case pages.",citedDomains:["citypointdental.com","clearlineortho.com"],evidenceUrls:["https://citypointdental.com/invisalign-downtown-brooklyn","https://citypointdental.com/case-studies/invisalign-open-bite"],competitorDomains:["clearlineortho.com"],groundingSources:[],relatedTechnicalSignals:["Structured data now present on two case-study pages","Internal links from service pages to case studies improved crawl depth"],summary:"Fresh case-study content is starting to earn citations on Invisalign prompts.",runHistory:Ni(["not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","cited"])},{id:"evidence_citypoint_invisalign_gemini",keyword:"best invisalign dentist downtown brooklyn",provider:"gemini",model:"gemini-3-flash",location:null,citationState:"cited",changeLabel:"Cited for 8 runs",answerSnippet:"Citypoint Dental in Downtown Brooklyn is highlighted for its Invisalign expertise and patient outcomes.",citedDomains:["citypointdental.com"],evidenceUrls:["https://citypointdental.com/invisalign-downtown-brooklyn"],competitorDomains:[],groundingSources:[],relatedTechnicalSignals:["Case study pages well-indexed"],summary:"Gemini consistently cites your Invisalign page with no competitor overlap.",runHistory:Ni(["cited","cited","cited","cited","cited","cited","cited","cited"])},{id:"evidence_citypoint_invisalign_claude",keyword:"best invisalign dentist downtown brooklyn",provider:"claude",model:"claude-sonnet-4-6",location:null,citationState:"not-cited",changeLabel:"No citation across 12 runs",answerSnippet:"For Invisalign in Downtown Brooklyn, Clear Line Ortho and Brooklyn Smiles are frequently recommended for their experienced orthodontists.",citedDomains:["clearlineortho.com","brooklynsmiles.com"],evidenceUrls:[],competitorDomains:["clearlineortho.com"],groundingSources:[],relatedTechnicalSignals:["No before/after schema on case study pages"],summary:"Claude does not surface your Invisalign content despite strong page quality.",runHistory:Ni(["not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited"])},{id:"evidence_citypoint_children_claude",keyword:"pediatric dentist brooklyn heights",provider:"claude",model:"claude-sonnet-4-6",location:null,citationState:"not-cited",changeLabel:"No citation across 4 runs",answerSnippet:"Answers cite neighborhood-specific pediatric practices with stronger family-focused FAQ content and clearer insurance details.",citedDomains:["brightkidsdental.com","parkpediatricdental.com"],evidenceUrls:["https://brightkidsdental.com/pediatric-dentist-brooklyn-heights","https://parkpediatricdental.com/insurance"],competitorDomains:["brightkidsdental.com","parkpediatricdental.com"],groundingSources:[],relatedTechnicalSignals:["No dedicated pediatric service page exists for Brooklyn Heights","Insurance content is buried three clicks deep"],summary:"Coverage gap is content-driven, not purely technical.",runHistory:Ni(["not-cited","not-cited","not-cited","not-cited"])},{id:"evidence_citypoint_children_gemini",keyword:"pediatric dentist brooklyn heights",provider:"gemini",model:"gemini-3-flash",location:null,citationState:"not-cited",changeLabel:"No citation across 12 runs",answerSnippet:"For pediatric dentistry in Brooklyn Heights, Bright Kids Dental and Park Pediatric Dental are cited for family-friendly care.",citedDomains:["brightkidsdental.com","parkpediatricdental.com"],evidenceUrls:[],competitorDomains:["brightkidsdental.com","parkpediatricdental.com"],groundingSources:[],relatedTechnicalSignals:["No dedicated pediatric page for Brooklyn Heights"],summary:"Gemini does not surface your domain for pediatric queries in this area.",runHistory:Ni(["not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited"])},{id:"evidence_citypoint_children_openai",keyword:"pediatric dentist brooklyn heights",provider:"openai",model:"gpt-5.4",location:null,citationState:"cited",changeLabel:"First citation this month",answerSnippet:"Citypoint Dental is mentioned as offering pediatric services in Brooklyn, though specialized pediatric-only practices are also highlighted.",citedDomains:["citypointdental.com","brightkidsdental.com"],evidenceUrls:["https://citypointdental.com/family-dentistry"],competitorDomains:["brightkidsdental.com"],groundingSources:[],relatedTechnicalSignals:["Family dentistry page recently updated"],summary:"OpenAI recently started citing your family dentistry page for this query.",runHistory:Ni(["not-cited","not-cited","not-cited","not-cited","not-cited","cited"])}];Tb[0],Tb[1],Ni(["cited","cited","cited","cited","cited"]),Tb[2],2/7,Ni(["not-cited","not-cited","not-cited","cited"]);function bQ(e,t){return e.projects.find(n=>n.project.id===t)}function xQ(e,t){return e.runs.find(n=>n.id===t)}function wQ(e,t){for(const n of e.projects){const r=n.visibilityEvidence.find(i=>i.id===t);if(r)return{project:n,evidence:r}}}const SQ={regression:"negative",gain:"positive",opportunity:"caution"},jQ={regression:"lost",gain:"emerging",opportunity:"not-cited"},NQ={regression:"Regression",gain:"Gain",opportunity:"Opportunity"};function CQ(e){return{id:e.id,tone:SQ[e.type],title:e.title,detail:e.cause?.details??e.cause?.cause??"",actionLabel:e.recommendation?.action??NQ[e.type],affectedPhrases:[{keyword:e.keyword,evidenceId:"",provider:e.provider,citationState:jQ[e.type]}]}}function OQ(e){return e.filter(t=>!t.dismissed).map(CQ)}function uI(e){return{id:e.id,name:e.name,displayName:e.displayName,canonicalDomain:e.canonicalDomain,ownedDomains:e.ownedDomains??[],country:e.country,language:e.language,tags:e.tags,labels:e.labels,locations:e.locations??[],defaultLocation:e.defaultLocation??null,configSource:e.configSource,configRevision:e.configRevision,createdAt:e.createdAt,updatedAt:e.updatedAt}}function Iw(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}catch{return e}}function _Q(e,t){if(!e)return"Waiting";if(!t)return"Running";const n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return"<1s";const r=Math.floor(n/1e3);if(r<60)return`${r}s`;const i=Math.floor(r/60),s=r%60;return`${i}m ${s}s`}function L1(e){switch(e){case hr["answer-visibility"]:return"Answer visibility sweep";case hr["gsc-sync"]:return"GSC sync";case hr["inspect-sitemap"]:return"Sitemap inspection";case hr["ga-sync"]:return"GA sync";case hr["bing-inspect"]:return"Bing URL inspection";case hr["site-audit"]:return"Site audit"}}function kQ(e){return e===Qp.manual?"Manual":e===Qp.scheduled?"Scheduled":e===Qp["config-apply"]?"Config apply":e}function $1(e,t){return{id:e.id,projectId:e.projectId,projectName:t,kind:e.kind,kindLabel:L1(e.kind),status:e.status,trigger:e.trigger??"manual",location:e.location??null,createdAt:e.createdAt,startedAt:e.startedAt?Iw(e.startedAt):Iw(e.createdAt),duration:_Q(e.startedAt,e.finishedAt),statusDetail:e.error?dI(e.error):AQ(e),summary:EQ(e),triggerLabel:kQ(e.trigger)}}function dI(e){try{const n=JSON.parse(e);if(typeof n=="object"&&n!==null){const r=n.message??n.error?.message??n[0]?.error?.message;if(typeof r=="string"&&r.length>0)return r.length>200?r.slice(0,200)+"…":r}}catch{}const t=e.match(/\[.*?\]\s*(.+)/);if(t){const n=t[1];return n.length>200?n.slice(0,200)+"…":n}return e.length>200?e.slice(0,200)+"…":e}function AQ(e){switch(e.status){case en.queued:return"Waiting for execution slot.";case en.running:return"Provider queries in progress.";case en.completed:return"All key phrases checked.";case en.partial:return"Run completed with some key phrases skipped.";case en.failed:return e.error?dI(e.error):"Run failed.";case en.cancelled:return"Run was cancelled.";default:return""}}function EQ(e){const t=L1(e.kind);switch(e.status){case en.queued:return`${t} queued`;case en.running:return`${t} in progress`;case en.completed:return`${t} completed`;case en.partial:return`${t} partially completed`;case en.failed:return`${t} failed`;case en.cancelled:return`${t} cancelled`;default:return e.status}}function fI(e){if(e.length===0)return{score:0,citedCount:0,totalCount:0};const t=new Map;for(const s of e){const l=s.keyword??s.id;t.has(l)||t.set(l,!1),s.citationState==="cited"&&t.set(l,!0)}const n=t.size,r=[...t.values()].filter(Boolean).length;return{score:n>0?Math.round(r/n*100):0,citedCount:r,totalCount:n}}function hI(e){return e>=70?"positive":e>=40?"caution":"negative"}function TQ(e){return e==="High"?"negative":e==="Moderate"?"caution":"neutral"}function PQ(e,t){return e===0?"positive":(t>0?e/t:0)>=.3?"negative":"caution"}function zQ(e){if(e.length===0)return{label:"Gap Key Phrases",value:"No data",delta:"Run a sweep first",tone:"neutral",description:"Run a visibility sweep to identify key phrases where competitors are cited and your domain is not.",tooltip:"Tracked key phrases where a competitor is cited in the latest run but your domain is not.",trend:[]};const t=new Map;for(const s of e){const l=s.keywordId,c=t.get(l)??{cited:!1,competitorOverlap:new Set};s.citationState==="cited"&&(c.cited=!0);for(const f of s.competitorOverlap)c.competitorOverlap.add(f);t.set(l,c)}const n=t.size,r=[...t.values()].filter(s=>!s.cited&&s.competitorOverlap.size>0).length,i=r===1?"key phrase":"key phrases";return{label:"Gap Key Phrases",value:`${r}`,delta:`${r} of ${n} key phrases at risk`,tone:PQ(r,n),description:r>0?`${r} tracked ${i} currently cite competitors without citing your domain.`:"No competitive key phrase gaps detected in the latest visibility run.",tooltip:"Tracked key phrases where a competitor is cited in the latest run but your domain is not.",trend:[],progress:n>0?r/n:0}}function MQ(e,t){return e&&e.summary.total>0?{provider:"Google",...e.summary}:t&&t.summary.total>0?{provider:"Bing",...t.summary,deindexed:0}:e?{provider:"Google",...e.summary}:t?{provider:"Bing",...t.summary,deindexed:0}:null}function RQ(e){return e.provider==="Google"&&e.deindexed>0?"negative":e.percentage>=90?"positive":e.percentage>=70?"caution":"negative"}function DQ(e,t){const n=MQ(e,t);if(!n||n.total===0)return{label:"Index Coverage",value:"No data",delta:"Connect GSC or Bing",tone:"neutral",description:"Connect Google Search Console or Bing Webmaster Tools and inspect your sitemap to populate coverage.",tooltip:"Percentage of inspected URLs currently indexed. Google Search Console is preferred when available, otherwise Bing Webmaster Tools is used.",trend:[]};const r=n.notIndexed===1?"URL is":"URLs are",i=n.deindexed===1?"URL":"URLs";return{label:"Index Coverage",value:`${Math.round(n.percentage)}`,delta:`${n.provider} · ${n.indexed} of ${n.total} indexed`,tone:RQ(n),description:n.provider==="Google"&&n.deindexed>0?`${n.deindexed} deindexed ${i} detected in the latest Google Search Console inspection.`:`${n.notIndexed} ${r} not indexed in ${n.provider==="Google"?"Google Search Console":"Bing Webmaster Tools"}.`,tooltip:"Percentage of inspected URLs currently indexed. Google Search Console is preferred when available, otherwise Bing Webmaster Tools is used.",trend:[]}}function pI(e,t){if(e.length===0||t.length===0)return{label:"None",count:0};const n=new Set(t);let r=0;for(const s of e)s.competitorOverlap.some(l=>n.has(l))&&r++;const i=r/e.length;return i>=.5?{label:"High",count:r}:i>=.2?{label:"Moderate",count:r}:{label:"Low",count:r}}function IQ(e,t,n,r){const i=[];let s=0;const l=new Set;if(n){const c=new Map;for(const v of n.snapshots)if(v.keyword){const y=`${v.keyword}::${v.provider}`;c.set(y,v)}const f=new Set(n.snapshots.map(v=>v.provider)),h=new Set(t.flatMap(v=>Object.keys(v.providerRuns??{}))),p=[...new Set([...f,...h])].sort(),g=p.length>0?p:["gemini"];for(const v of t){if(v.runs.length===0)continue;l.add(v.keyword);const y=v.runs.at(-1),S=y?.transition??"not-cited";for(const w of g){const N=c.get(`${v.keyword}::${w}`),C=(v.providerRuns?.[w]?.length??0)>0;if(!N&&!C)continue;const E=N?.model??null,k=E?`${w}:${E}`:null,O=k?v.modelRuns?.[k]:void 0,T=v.providerRuns?.[w],z=(T?.length?T:null)??(O?.length?O:null),A=T?.length?"provider":O?.length?"model":"keyword",P=z?z.at(-1).transition:S,R=z?z.at(-1).visibilityTransition??(z.at(-1).visibilityState==="visible"?"visible":"not-visible"):y?.visibilityTransition??(y?.visibilityState==="visible"?"visible":"not-visible"),B=z?.at(-1)?.citationState,$=z?.at(-1)?.visibilityState,L=N?P==="lost"?"lost":P==="emerging"?"emerging":N.citationState==="cited"?"cited":"not-cited":B==="cited"?"cited":"not-cited",re=N?.visibilityState??($==="visible"?"visible":$==="pending"?"pending":"not-visible"),ge=Lw(z||v.runs),be=CE(z||v.runs),H=LQ(v,w),ee=(z??v.runs).map(D=>({runId:D.runId,citationState:D.citationState,createdAt:D.createdAt,model:H.get(D.runId)??null,answerMentioned:D.answerMentioned,visibilityState:D.visibilityState,visibilityTransition:D.visibilityTransition})),ye=$Q(ee),Se=A==="provider"&&ye.length<=1?"model":A,q=UQ(ee);i.push({id:`evidence_${e}_${s++}`,keyword:v.keyword,provider:N?.provider??w,model:N?.model??null,location:N?.location??null,citationState:L,answerMentioned:N?.answerMentioned,visibilityState:re,visibilityChangeLabel:OE(R,be,{positive:"visible",negative:"not visible",first:"first visibility"}),changeLabel:OE(P,ge),answerSnippet:N?.answerText??"",citedDomains:N?.citedDomains??[],evidenceUrls:[],competitorDomains:N?.competitorOverlap??[],recommendedCompetitors:N?.recommendedCompetitors??[],matchedTerms:N?.matchedTerms??[],relatedTechnicalSignals:[],groundingSources:N?.groundingSources??[],summary:BQ(re,R,v.keyword),runHistory:ee,historyScope:Se,modelsSeen:ye,modelTransitions:q})}}}for(const c of r)l.has(c.keyword)||i.push({id:`evidence_${e}_${s++}`,keyword:c.keyword,provider:"",model:null,location:null,citationState:"pending",visibilityState:"pending",visibilityChangeLabel:"Awaiting first run",changeLabel:"Awaiting first run",answerSnippet:"",citedDomains:[],evidenceUrls:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],relatedTechnicalSignals:[],groundingSources:[],summary:`"${c.keyword}" has been added but no visibility run has been triggered yet.`,runHistory:[],historyScope:"keyword",modelsSeen:[],modelTransitions:[]});return i}function LQ(e,t){const n=new Map,r=`${t}:`;for(const[i,s]of Object.entries(e.modelRuns??{})){if(!i.startsWith(r))continue;const l=i.slice(r.length),c=l==="unknown"?null:l;for(const f of s)n.set(f.runId,c)}return n}function $Q(e){const t=new Set;for(const n of e)n.model&&t.add(n.model);return[...t]}function UQ(e){const t=[];let n=null;for(const r of e){const i=r.model??null;i!==n&&n!==null&&t.push({runId:r.runId,createdAt:r.createdAt,fromModel:n,toModel:i}),n=i}return t}function Lw(e){if(e.length===0)return 0;const t=e[e.length-1].citationState;let n=0;for(let r=e.length-1;r>=0&&e[r].citationState===t;r--)n++;return n}function CE(e){if(e.length===0)return 0;const t=e[e.length-1].visibilityState??"not-visible";let n=0;for(let r=e.length-1;r>=0&&(e[r].visibilityState??"not-visible")===t;r--)n++;return n}function OE(e,t,n){const r={positive:n?.positive??"cited",negative:n?.negative??"not cited",first:n?.first??"first citation"};switch(e){case"new":return"First observation";case"cited":case"visible":return t<=1?`${hd(r.positive)} in latest run`:`${hd(r.positive)} for ${t} runs`;case"lost":return"Lost since last run";case"emerging":return hd(r.first);case"not-cited":case"not-visible":return t<=1?`${hd(r.negative)} in latest run`:`${hd(r.negative)} across ${t} runs`;default:return e}}function hd(e){return e.charAt(0).toUpperCase()+e.slice(1)}function BQ(e,t,n){switch(t){case"lost":return`Visibility was lost for "${n}". Your brand no longer appeared in the latest answer.`;case"emerging":return`Your brand started appearing in AI answers for "${n}".`}switch(e){case"visible":return`Your brand or domain is visible in AI answers for "${n}".`;case"pending":return`"${n}" has been added but no visibility run has been triggered yet.`;default:return`Your brand or domain was not mentioned in AI answers for "${n}".`}}function _E(e,t){const n=new Set(t),r=new Map;for(const i of e)if(i.keyword)for(const s of i.competitorOverlap){if(!n.has(s))continue;const l=r.get(s)??new Set;l.add(i.keyword),r.set(s,l)}return r}const Pb=3;function qQ(e){const{evidence:t,timeline:n,latestSnapshots:r,previousSnapshots:i,trackedCompetitors:s}=e,l=[],c=[],f=new Set;for(const C of t)C.citationState==="lost"&&(f.has(C.keyword)||(f.add(C.keyword),c.push({keyword:C.keyword,evidenceId:C.id,provider:C.provider,citationState:"lost"})));c.length>0&&l.push({id:"insight_lost",tone:"negative",title:`Lost citation on ${c.length} key phrase${c.length>1?"s":""}`,detail:"Citations dropped since the last run.",actionLabel:"Lost",affectedPhrases:c});const h=_E(r,s),p=_E(i,s);for(const C of s){const E=h.get(C)??new Set,k=p.get(C)??new Set,O=[...E].filter(T=>!k.has(T));O.length>0&&l.push({id:`insight_comp_gained_${C}`,tone:"negative",title:`${C} appeared on ${O.length} key phrase${O.length>1?"s":""}`,detail:"A tracked competitor gained new citations.",actionLabel:"Competitor",affectedPhrases:O.map(T=>{const z=t.find(A=>A.keyword===T);return{keyword:T,evidenceId:z?.id??"",citationState:"cited"}})})}const g=new Map;for(const C of n){const E=C.runs.at(-1);E&&g.set(C.keyword,{transition:E.transition,citationState:E.citationState})}const v=[],y=[],S=new Set;for(const[C,{transition:E,citationState:k}]of g){if(!(E==="emerging"||E==="new"&&k==="cited"))continue;S.add(C);const T=t.find(z=>z.keyword===C&&(z.citationState==="emerging"||z.citationState==="cited"));v.push({keyword:C,evidenceId:T?.id??"",provider:T?.provider,citationState:"emerging"})}for(const C of t)C.citationState==="emerging"&&(S.has(C.keyword)||y.push({keyword:C.keyword,evidenceId:C.id,provider:C.provider,citationState:"emerging"}));if(y.length>0){const C=new Set(y.map(E=>E.keyword)).size;l.push({id:"insight_provider_pickup",tone:"positive",title:`Picked up by new provider on ${C} key phrase${C>1?"s":""}`,detail:"Your domain started appearing on additional providers.",actionLabel:"Pickup",affectedPhrases:y})}v.length>0&&l.push({id:"insight_first_citation",tone:"positive",title:`First citation on ${S.size} key phrase${S.size>1?"s":""}`,detail:"Your domain appeared in AI answers for the first time.",actionLabel:"New",affectedPhrases:v});const w=new Set(t.map(C=>C.keyword)),N=[];for(const C of n){if(!w.has(C.keyword)||C.runs.length<Pb||C.runs.at(-1)?.citationState!=="not-cited")continue;if(Lw(C.runs)>=Pb){const O=t.find(T=>T.keyword===C.keyword);N.push({keyword:C.keyword,evidenceId:O?.id??"",citationState:"not-cited"})}}N.length>0&&l.push({id:"insight_persistent_gap",tone:"caution",title:`${N.length} key phrase${N.length>1?"s":""} uncited for ${Pb}+ runs`,detail:"These key phrases have not been cited by any provider across multiple consecutive runs.",actionLabel:"Gap",affectedPhrases:N});for(const C of s){const E=h.get(C)??new Set,O=[...p.get(C)??new Set].filter(T=>!E.has(T));O.length>0&&l.push({id:`insight_comp_lost_${C}`,tone:"neutral",title:`${C} dropped from ${O.length} key phrase${O.length>1?"s":""}`,detail:"A tracked competitor lost citations.",actionLabel:"Competitor",affectedPhrases:O.map(T=>{const z=t.find(A=>A.keyword===T);return{keyword:T,evidenceId:z?.id??"",citationState:"not-cited"}})})}return l.length===0&&l.push({id:"insight_stable",tone:"neutral",title:"No significant changes",detail:"Citation state is stable across all tracked key phrases.",actionLabel:"Stable",affectedPhrases:[]}),l}function FQ(e,t){const n=e.filter(i=>i.id!=="insight_lost"&&i.id!=="insight_stable"),r=[...t,...n];return r.length===0?[{id:"insight_stable",tone:"neutral",title:"No significant changes",detail:"Citation state is stable across all tracked key phrases.",actionLabel:"Stable",affectedPhrases:[]}]:r}function KQ(e,t){if(t.length===0){const f=new Set(e.filter(h=>h.citationState==="cited").map(h=>h.keyword)).size;return{gained:f,lost:0,tone:f>0?"positive":"neutral",hasPreviousRun:!1}}const n=f=>{const h=new Set;for(const p of f)p.citationState==="cited"&&p.keyword&&h.add(p.keyword);return h},r=n(e),i=n(t);let s=0,l=0;for(const f of r)i.has(f)||s++;for(const f of i)r.has(f)||l++;const c=l>s?"negative":s>l?"positive":"neutral";return{gained:s,lost:l,tone:c,hasPreviousRun:!0}}function HQ(e){if(e.length===0)return{label:"Run Status",value:"None",delta:"No runs yet",tone:"neutral",description:"Trigger a visibility sweep to start tracking.",tooltip:"Current execution state of visibility sweeps. Shows the status of the most recent run and total run count.",trend:[]};const n=e.find(f=>f.kind===hr["answer-visibility"])??e[0],r=n.status===en.completed?"Healthy":n.status===en.running?"Running":n.status===en.queued?"Queued":n.status===en.partial?"Partial":"Failed",i=n.status===en.completed?"positive":n.status===en.failed?"negative":n.status===en.partial?"caution":"neutral",s=e.filter(f=>f.kind===hr["answer-visibility"]).length,l=e.length-s,c=l>0?`${s} ${s===1?"sweep":"sweeps"} · ${l} ${l===1?"sync":"syncs"}`:`${e.length} total runs`;return{label:"Run Status",value:r,delta:c,tone:i,description:`Latest: ${L1(n.kind)} — ${n.status}`,tooltip:"Current execution state of visibility sweeps. Shows the status of the most recent run and total run count.",trend:[]}}function GQ(e){const t=uI(e.project),n=IQ(t.name,e.timeline,e.latestRunDetail,e.keywords),r=e.runs.filter(A=>A.kind===hr["answer-visibility"]).sort((A,P)=>P.createdAt.localeCompare(A.createdAt))[0],i=r&&e.latestRunDetail?.id===r.id?e.latestRunDetail.snapshots:[],s=fI(i),l=zQ(i),c=DQ(e.gscCoverage,e.bingCoverage),f=pI(i,e.competitors.map(A=>A.domain)),h=qQ({evidence:n,timeline:e.timeline,latestSnapshots:e.latestRunDetail?.snapshots??[],previousSnapshots:e.previousRunDetail?.snapshots??[],trackedCompetitors:e.competitors.map(A=>A.domain)}),p=e.dbInsights!=null?OQ(e.dbInsights):null,g=p!=null?FQ(h,p):h,v=[...e.runs].sort((A,P)=>P.createdAt.localeCompare(A.createdAt)),y=v.find(A=>A.kind===hr["answer-visibility"]),S=v.find(A=>A.kind!==hr["answer-visibility"]);if(y&&S){const A=new Date(S.createdAt).getTime()-new Date(y.createdAt).getTime(),P=1440*60*1e3;A>P&&g.push({id:"insight_stale_visibility",tone:"caution",title:"Stale visibility data",detail:`Last visibility sweep was ${Iw(y.createdAt)}, but integration syncs have run since. Run a new sweep for current metrics.`,actionLabel:"Stale",affectedPhrases:[]})}const w=v.map(A=>$1(A,e.project.displayName||e.project.name)),N=new Map;for(const A of i){const P=A.provider||"gemini",R=A.model??null,B=`${P}::${R??"unknown"}`,$=N.get(B)??{provider:P,model:R,cited:0,total:0};$.total++,A.citationState==="cited"&&$.cited++,N.set(B,$)}const C=[...N.values()].sort((A,P)=>A.provider.localeCompare(P.provider)||(A.model??"").localeCompare(P.model??"")).map(({provider:A,model:P,cited:R,total:B})=>({provider:A,model:P,score:B>0?Math.round(R/B*100):0,cited:R,total:B})),E=e.project.providers.filter(A=>!A.startsWith("cdp:")),k=new Set(i.map(A=>A.provider)),O=E.filter(A=>k.has(A)).length,T=i.length>0&&E.length>1&&O<E.length,z=T?`${O} of ${E.length} providers`:void 0;return{project:t,dateRangeLabel:"All time",contextLabel:`${t.country} / ${t.language.toUpperCase()}`,visibilitySummary:{label:"Answer Visibility",value:i.length>0?`${s.score}`:"No data",delta:i.length>0?`${s.citedCount} of ${s.totalCount} key phrases visible`:"Run a sweep first",tone:i.length>0?T?"caution":hI(s.score):"neutral",description:i.length>0?`${s.citedCount} of ${s.totalCount} tracked key phrases found your domain in at least one AI answer engine.`:"No visibility data yet. Trigger a run to start tracking.",tooltip:'Percentage of tracked key phrases where your domain is cited by at least one AI answer engine. A key phrase is "visible" if any configured provider includes your site in its response.',trend:[],providerCoverage:z},keywordCounts:{cited:s.citedCount,total:s.totalCount},gapKeyPhrases:l,indexCoverage:c,providerScores:C,competitorPressure:{label:"Competitor Pressure",value:f.label,delta:f.count>0?`${f.count} overlapping citations`:"No overlap detected",tone:TQ(f.label),description:e.competitors.length>0?`${e.competitors.length} competitor${e.competitors.length>1?"s":""} tracked.`:"No competitors configured.",tooltip:"How often competitor domains appear alongside yours in AI answers. High pressure means competitors are frequently cited for the same key phrases.",trend:[]},runStatus:HQ(v),movementSummary:KQ(e.latestRunDetail?.snapshots??[],e.previousRunDetail?.snapshots??[]),insights:g,visibilityEvidence:n,competitors:e.competitors.map((A,P)=>{const R=new Set;for(const ge of i)(ge.competitorOverlap.includes(A.domain)||ge.citedDomains.includes(A.domain))&&ge.keyword&&R.add(ge.keyword);const B=[...R],$=new Set(i.map(ge=>ge.keyword).filter(Boolean)),L=$.size>0?B.length/$.size:0,re=L>=.5?"High":L>=.2?"Moderate":B.length>0?"Low":"None";return{id:A.id||`comp_${P}`,domain:A.domain,citationCount:B.length,totalKeywords:$.size,pressureLabel:re,citedKeywords:B,movement:"",notes:""}}),recentRuns:w.slice(0,5)}}function VQ(e){const t=uI(e.project),n=e.runs.filter(S=>S.kind===hr["answer-visibility"]).sort((S,w)=>w.createdAt.localeCompare(S.createdAt))[0],r=n&&e.latestRunDetail?.id===n.id?e.latestRunDetail.snapshots:[],i=fI(r),s=pI(r,e.competitors.map(S=>S.domain)),l=[...e.runs].sort((S,w)=>w.createdAt.localeCompare(S.createdAt)),c=l.find(S=>S.kind===hr["answer-visibility"])??l[0],f=e.project.displayName||e.project.name,h=c?$1(c,f):{id:"none",projectId:e.project.id,projectName:f,kind:hr["answer-visibility"],kindLabel:"No runs yet",status:en.queued,trigger:Qp.manual,createdAt:"",startedAt:"",duration:"",statusDetail:"",summary:"No runs yet",triggerLabel:""},p=e.project.providers.filter(S=>!S.startsWith("cdp:")),g=new Set(r.map(S=>S.provider)),v=p.filter(S=>g.has(S)).length,y=r.length>0&&p.length>1&&v<p.length;return{project:t,visibilityScore:i.score,visibilityDelta:r.length>0?`${i.citedCount} of ${i.totalCount} key phrases`:"No data",visibilityTone:r.length>0?y?"caution":hI(i.score):"neutral",providerCoverage:y?`${v} of ${p.length} providers`:void 0,lastRun:h,insight:r.length>0?`${i.citedCount} of ${i.totalCount} key phrases visible across ${new Set(r.map(S=>S.provider)).size} provider${new Set(r.map(S=>S.provider)).size>1?"s":""}.`:"No runs completed yet.",trend:[],competitorPressureLabel:s.label}}function ZQ(e,t){const n=[],r=[],i=[];for(const l of e){r.push(GQ(l)),i.push(VQ(l));const c=[...l.runs].sort((f,h)=>h.createdAt.localeCompare(f.createdAt));for(const f of c)n.push($1(f,l.project.displayName||l.project.name))}n.sort((l,c)=>c.createdAt.localeCompare(l.createdAt));const s=e.length>0;return{portfolioOverview:{projects:i,attentionItems:s?YQ(r):[{id:"attention_setup",tone:"neutral",title:"No projects yet",detail:"Create your first project using the setup wizard, CLI, or API.",actionLabel:"Open setup",href:"/setup"}],recentRuns:n.slice(0,5),systemHealth:[{id:"api",label:"API",tone:"positive",detail:"Connected",meta:"Real-time data"},{id:"provider",label:"Gemini",tone:"positive",detail:"Configured",meta:"Provider active"}],lastUpdatedAt:new Date().toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),...s?{}:{emptyState:{title:"No projects yet",detail:"Canonry becomes useful after one project, a small key phrase set, and one competitor list are in place.",ctaLabel:"Launch setup",ctaHref:"/setup"}}},projects:r,runs:n,setup:{healthChecks:[{id:"api",label:"API reachable",detail:"API is responding.",state:"ready",guidance:"Required for project creation and run history."},{id:"provider",label:"Provider configured",detail:"Gemini key is configured.",state:"ready",guidance:"Required for answer-visibility sweeps."}],projectDraft:{name:"",canonicalDomain:"",country:"US",language:"en"},keywordImportState:{mode:"paste",keywordCount:0,preview:[]},competitorDraft:{domains:[],notes:"Use the CLI to add competitors."},launchState:{enabled:s,ctaLabel:s?"Trigger run":"Create a project first",summary:s?"Ready to run.":"Create a project first to launch a run."}},settings:{providerStatuses:(t?.providers??[]).map(l=>({name:l.name,displayName:l.displayName,keyUrl:l.keyUrl,modelHint:l.modelHint,model:l.model,state:l.configured?"ready":"needs-config",detail:l.configured?"Provider is configured.":"API key is missing.",quota:l.quota})),google:{state:t?.google?.configured?"ready":"needs-config",detail:t?.google?.configured?"Google OAuth app credentials are configured. Project-level GSC connections can be created from the dashboard.":"Google OAuth client ID and client secret are not configured yet."},bing:{state:t?.bing?.configured?"ready":"needs-config",detail:t?.bing?.configured?"Bing Webmaster Tools API key is configured. Project-level Bing connections can be created from the dashboard.":"Bing Webmaster Tools API key is not configured yet."},selfHostNotes:["Configuration is stored in ~/.canonry/config.yaml.","The local config file is the source of truth for authentication credentials.","Google OAuth app credentials and per-domain Google tokens are stored in local config, not the database.","Database is SQLite at ~/.canonry/data.db.","API key was auto-generated during canonry init."],bootstrapNote:"Use the UI, CLI, or ~/.canonry/config.yaml to manage settings. Authentication credentials persist to local config."}}}function YQ(e){const t=[];for(const n of e){const r=n.visibilityEvidence.filter(s=>s.citationState==="lost");r.length>0&&t.push({id:`attention_${n.project.id}_lost`,tone:"negative",title:`${n.project.displayName||n.project.name} lost citations`,detail:`${r.length} key phrase${r.length>1?"s":""} lost citation.`,actionLabel:"Open project",href:`/projects/${n.project.id}`});const i=n.recentRuns.filter(s=>s.status===en.running||s.status===en.queued);i.length>0&&t.push({id:`attention_${n.project.id}_active`,tone:"neutral",title:`${n.project.displayName||n.project.name} has active runs`,detail:`${i.length} run${i.length>1?"s":""} in progress.`,actionLabel:"View runs",href:"/runs"})}return t.length===0&&t.push({id:"attention_stable",tone:"positive",title:"All projects stable",detail:"No citation losses or active runs to flag.",actionLabel:"View portfolio",href:"/"}),t}const ti={projects:{all:["projects"],detail:(e,t)=>["projects",e,t],keywords:e=>["projects",e,"keywords"],competitors:e=>["projects",e,"competitors"],timeline:(e,t)=>["projects",e,"timeline",t]},runs:{all:["runs"],detail:e=>["runs",e]},settings:["settings"],health:["health"]},mI=x.createContext(null);mI.Provider;function gf(){return x.useContext(mI)}function bl(e){const n=gf()?.dashboard??null,r=Go({queryKey:ti.projects.all,queryFn:tR,enabled:!n}),i=Go({queryKey:ti.runs.all,queryFn:rR,enabled:!n,refetchInterval:S=>S.state.data?.some(C=>C.status==="running"||C.status==="queued")?3e3:!1}),s=Go({queryKey:ti.settings,queryFn:()=>v1().catch(()=>null),enabled:!n}),l=r.data??[],c=i.data??[],f=n8({queries:l.map(S=>{const w=c.filter(C=>C.projectId===S.id),N=w.filter(C=>(C.status==="completed"||C.status==="partial")&&C.kind==="answer-visibility").sort((C,E)=>E.createdAt.localeCompare(C.createdAt));return{queryKey:ti.projects.detail(S.id,N[0]?.id),queryFn:async()=>{const C=N[0]?.id,[E,k,O,T,z,A,P,R]=await Promise.all([d9(S.name).catch(()=>[]),iR(S.name).catch(()=>[]),aR(S.name).catch(()=>[]),C?Lc(C).catch(()=>null):Promise.resolve(null),N[1]?Lc(N[1].id).catch(()=>null):Promise.resolve(null),y1(S.name).catch(()=>null),b1(S.name).catch(()=>null),C?sF(S.name,C).catch(()=>null):Promise.resolve(null)]);return{project:S,runs:w,keywords:E,competitors:k,timeline:O,latestRunDetail:T,previousRunDetail:z,gscCoverage:A,bingCoverage:P,dbInsights:R}},enabled:!n&&r.isSuccess&&i.isSuccess}})}),h=f.every(S=>S.isSuccess),p=x.useMemo(()=>{if(n)return n;if(!r.data||!i.data||l.length>0&&!h)return null;const S=f.map(w=>w.data).filter(w=>w!=null);return ZQ(S,s.data??null)},[n,r.data,i.data,s.data,h,f,l.length]),g=!n&&(r.isError||i.isError),v=!n&&!p&&!g,y=x.useCallback(async()=>{await Promise.all([r.refetch(),i.refetch(),s.refetch()])},[r.refetch,i.refetch,s.refetch]);return{dashboard:p,isLoading:v,isError:g,refetch:y}}async function WQ(){const e=await oF("/health","API"),t=e.state==="ok"?{label:"Worker",state:"ok",detail:"In-process job runner"}:{label:"Worker",state:e.state,detail:`Depends on API health check · ${e.detail}`,statusCode:e.statusCode,hint:e.hint?`Worker status is inferred from API health in this deployment mode. ${e.hint}`:"Worker status is inferred from API health in this deployment mode."};return{apiStatus:e,workerStatus:t}}function Vg(e,t){return Go({queryKey:ti.health,queryFn:WQ,enabled:e,refetchInterval:15e3,initialData:t})}function QQ(e){return Go({queryKey:ti.runs.detail(e??""),queryFn:()=>Lc(e),enabled:!!e,refetchInterval:t=>{const n=t.state.data?.status;return n==="running"||n==="queued"?3e3:!1}})}function nu(){const e=Ys(),t=Pg({strict:!1}),n=vr({select:f=>f.location.pathname}),r=t.runId??null,i=t.evidenceId??null;return{runId:r,evidenceId:i,openRun:f=>e({to:n,from:Ei.to,search:h=>({...h,runId:f,evidenceId:void 0})}),openEvidence:f=>e({to:n,from:Ei.to,search:h=>({...h,evidenceId:f,runId:void 0})}),closeDrawer:()=>e({to:n,from:Ei.to,search:f=>({...f,runId:void 0,evidenceId:void 0})})}}const XQ={negative:"toast-card-negative",caution:"toast-card-caution",positive:"toast-card-positive",neutral:"toast-card-neutral"};function JQ(e){if(e.cta)return`${e.cta.label}: ${e.title}`}function eX(){const e=x.useSyncExternalStore(hF,CA,CA),t=Ys(),{openRun:n}=nu(),r=x.useCallback(s=>{Ow(s)},[]),i=x.useCallback(s=>{s.cta&&(s.cta.intent==="open-run-drawer"?n(s.cta.runId):t({to:"/runs"}),Ow(s.id))},[t,n]);return e.length===0?null:u.jsx("div",{className:"toast-viewport","aria-label":"Notifications",children:e.map(s=>u.jsxs("section",{role:s.tone==="negative"?"alert":"status","aria-live":s.tone==="negative"?"assertive":"polite","data-state":s.state,className:`toast-card ${XQ[s.tone]}`,children:[u.jsxs("div",{className:"toast-copy",children:[u.jsx("p",{className:"toast-title",children:s.title}),s.detail?u.jsx("p",{className:"toast-detail",children:s.detail}):null,s.cta?u.jsx("button",{type:"button",className:"toast-action",onClick:()=>i(s),"aria-label":JQ(s),children:s.cta.label}):null]}),u.jsx("button",{type:"button",onClick:()=>r(s.id),className:"toast-dismiss","aria-label":"Dismiss",children:u.jsx(Rg,{className:"size-3.5"})})]},s.id))})}const kE=[{label:"Architecture",href:"https://github.com/AINYC/canonry/blob/main/docs/architecture.md"},{label:"Testing Guide",href:"https://github.com/AINYC/canonry/blob/main/docs/testing.md"}],AE=e=>({label:e,state:"checking",detail:"Checking service health"}),tX={apiStatus:AE("API"),workerStatus:AE("Worker")};function nX(e){return e==="gsc-sync"?"GSC sync":e==="inspect-sitemap"?"Sitemap inspection":"Visibility sweep"}function rX(e){return e==="completed"?"positive":e==="partial"?"caution":"negative"}function iX(e){const t=nX(e.kind);return e.status==="completed"?`${t} completed`:e.status==="partial"?`${t} completed with partial results`:e.status==="cancelled"?`${t} cancelled`:`${t} failed`}function aX(e,t){return e.error?`${t}: ${e.error}`:e.location?`${t} · ${e.location}`:t}function sX(e,t,n){if(t)return t;const r=n.find(i=>i.id===e);return r?.displayName||r?.name||e}function oX(e,t){return[e.completed>0?`${e.completed} completed`:null,e.partial>0?`${e.partial} partial`:null,e.failed>0?`${e.failed} failed`:null,e.cancelled>0?`${e.cancelled} cancelled`:null,t>0?`${t} skipped at queue time`:null].filter(Boolean).join(", ")}function lX(e){return e.failed>0||e.cancelled>0?"negative":e.partial>0?"caution":"positive"}function cX(){const e=x.useSyncExternalStore(uK,rl,rl),t=Object.keys(e.runs).length>0||Object.keys(e.batches).length>0,n=Go({queryKey:ti.runs.all,queryFn:rR,enabled:t}),r=Go({queryKey:ti.projects.all,queryFn:tR,enabled:t}),i=x.useRef({}),s=x.useCallback(()=>{n.refetch()},[n.refetch]);return x.useEffect(()=>{t&&s()},[t,s]),x.useEffect(()=>{if(!t||typeof window>"u")return;const l=()=>{document.visibilityState==="visible"&&s()};return window.addEventListener("focus",s),document.addEventListener("visibilitychange",l),()=>{window.removeEventListener("focus",s),document.removeEventListener("visibilitychange",l)}},[t,s]),x.useEffect(()=>{const l=n.data??[],c=r.data??[],f=Object.fromEntries(l.map(p=>[p.id,p])),h=Object.fromEntries(l.map(p=>[p.id,p.status]));for(const p of Object.values(e.runs)){const g=f[p.runId];if(!g||!hK(g.status)||(i.current[g.id]??p.lastAnnouncedStatus)===g.status)continue;if(p.sourceAction==="run-all"){TA(g.id);continue}const y=sX(g.projectId,p.projectLabel,c);it({title:iX(g),detail:aX(g,y),tone:rX(g.status),dedupeKey:`run:${g.id}`,dedupeMode:"replace",cta:{label:"View run",intent:"open-run-drawer",runId:g.id}}),TA(g.id)}for(const p of Object.values(e.batches)){const g=pK(p.runIds,f);g.finished&&(it({title:"Run-all batch finished",detail:oX(g,p.skippedCount),tone:lX(g),dedupeKey:`batch:${p.batchId}`,dedupeMode:"replace",cta:{label:"View runs",intent:"go-to-runs"}}),fK(p.batchId))}i.current=h},[r.data,n.data,e]),null}function uX(){const e=gf(),{dashboard:t,isLoading:n,refetch:r}=bl(),l=Vg(!e,e?.health).data??e?.health??tX,c=i9(),{runId:f,evidenceId:h,closeDrawer:p}=nu(),[g,v]=x.useState(!1),y=QQ(f),S=y.data??null,w=y.isLoading;x.useEffect(()=>{S&&S.status!=="running"&&S.status!=="queued"&&r()},[S?.status,r]),x.useEffect(()=>{v(!1)},[c.pathname]),x.useEffect(()=>{if(typeof window>"u"||!f&&!h)return;const O=T=>{T.key==="Escape"&&p()};return window.addEventListener("keydown",O),()=>{window.removeEventListener("keydown",O)}},[f,h,p]);const N=t??e?.dashboard??null,C=f&&N?xQ(N,f):void 0,E=h&&N?wQ(N,h):void 0,k=(()=>{const O=c.pathname;if(O==="/")return"Portfolio";if(O==="/projects")return"Projects";if(O==="/runs")return"Runs";if(O==="/settings")return"Settings";if(O==="/setup")return"Setup";if(O.startsWith("/projects/")){const z=O.split("/").filter(Boolean)[1];if(z&&N){const A=N.projects.find(P=>P.project.id===z);if(A)return A.project.name}return"Project"}return"Not found"})();return u.jsxs("div",{className:"app-shell",children:[u.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),u.jsxs("aside",{className:"sidebar","aria-label":"Primary navigation",children:[u.jsx("div",{className:"sidebar-brand",children:u.jsx(BA,{})}),u.jsxs("nav",{className:"sidebar-nav",children:[u.jsxs(Ut,{to:"/",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[u.jsx(kF,{className:"sidebar-icon"}),u.jsx("span",{children:"Overview"})]}),u.jsxs(Ut,{to:"/projects",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[u.jsx(OF,{className:"sidebar-icon"}),u.jsx("span",{children:"Projects"})]}),u.jsxs(Ut,{to:"/runs",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[u.jsx(PF,{className:"sidebar-icon"}),u.jsx("span",{children:"Runs"})]}),u.jsxs(Ut,{to:"/settings",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[u.jsx(UF,{className:"sidebar-icon"}),u.jsx("span",{children:"Settings"})]}),n?u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"sidebar-section-title",children:"Projects"}),[1,2,3].map(O=>u.jsxs("div",{className:"sidebar-skeleton-item",children:[u.jsx("span",{className:"skeleton-circle size-2"}),u.jsx("span",{className:"skeleton-text flex-1",style:{width:`${50+O*15}%`}})]},O))]}):N&&N.projects.length>0?u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"sidebar-section-title",children:"Projects"}),N.projects.map(O=>{const T=O.visibilitySummary.tone;return u.jsxs(Ut,{to:"/projects/$projectId",params:{projectId:O.project.id},className:"sidebar-project",activeProps:{className:"sidebar-project sidebar-project-active"},children:[u.jsx("span",{className:`sidebar-dot sidebar-dot-${T}`}),u.jsx("span",{children:O.project.name})]},O.project.id)})]}):n?null:u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"sidebar-section-title",children:"Resources"}),u.jsxs(Ut,{to:"/setup",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[u.jsx(DF,{className:"sidebar-icon"}),u.jsx("span",{children:"Setup"})]})]})]}),u.jsx("div",{className:"sidebar-footer",children:kE.map(O=>u.jsx("a",{className:"sidebar-footer-link",href:O.href,target:"_blank",rel:"noopener noreferrer",children:O.label},O.href))})]}),u.jsxs("div",{className:"main-area",children:[u.jsxs("header",{className:"topbar",children:[u.jsxs("div",{className:"topbar-left",children:[u.jsx("div",{className:"topbar-brand-mobile",children:u.jsx(BA,{compact:!0})}),u.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[u.jsx(Ut,{to:"/",children:"Home"}),u.jsx(Mg,{className:"breadcrumb-sep size-3"}),u.jsx("span",{className:"breadcrumb-current",children:k})]})]}),u.jsxs("div",{className:"topbar-actions",children:[u.jsxs("div",{className:"health-pill-row",children:[u.jsxs("span",{className:`health-pill health-pill-${l.apiStatus.state}`,title:qs(l.apiStatus),children:["API ",l.apiStatus.state==="ok"?"ok":l.apiStatus.state]}),u.jsxs("span",{className:`health-pill health-pill-${l.workerStatus.state}`,title:qs(l.workerStatus),children:["Worker ",l.workerStatus.state==="ok"?"ok":l.workerStatus.state]})]}),u.jsxs(ve,{className:"nav-toggle",variant:"secondary",size:"icon",type:"button","aria-expanded":g,"aria-controls":"mobile-nav",onClick:()=>v(O=>!O),children:[u.jsx(EF,{className:"size-4"}),u.jsx("span",{className:"sr-only",children:"Open navigation"})]})]})]}),u.jsxs("div",{id:"mobile-nav",className:`mobile-nav ${g?"mobile-nav-open":""}`,children:[u.jsxs(ve,{className:"mobile-nav-close",variant:"ghost",size:"icon",type:"button",onClick:()=>v(!1),children:[u.jsx(Rg,{className:"size-5"}),u.jsx("span",{className:"sr-only",children:"Close navigation"})]}),u.jsx(Ut,{to:"/",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Overview"}),u.jsx(Ut,{to:"/projects",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Projects"}),u.jsx(Ut,{to:"/runs",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Runs"}),u.jsx(Ut,{to:"/settings",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Settings"}),N&&N.projects.length>0?u.jsxs("div",{className:"mobile-nav-section",children:[u.jsx("p",{className:"mobile-nav-section-title",children:"Projects"}),N.projects.map(O=>u.jsx(Ut,{to:"/projects/$projectId",params:{projectId:O.project.id},className:"mobile-nav-link",children:O.project.name},O.project.id))]}):null]}),u.jsx("main",{id:"content",className:"page-shell",children:n&&!e?u.jsxs("div",{className:"page-skeleton",children:[u.jsxs("div",{className:"page-skeleton-header",children:[u.jsx("div",{className:"skeleton-text h-6 w-40"}),u.jsx("div",{className:"skeleton-text-sm w-72"})]}),u.jsx("div",{className:"page-skeleton-grid",children:[1,2,3].map(O=>u.jsxs("div",{className:"page-skeleton-card",children:[u.jsx("div",{className:"skeleton-text w-24"}),u.jsx("div",{className:"skeleton-text w-full"}),u.jsx("div",{className:"skeleton-text-sm w-3/4"})]},O))}),u.jsx("div",{className:"page-skeleton-grid",style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map(O=>u.jsxs("div",{className:"page-skeleton-card",children:[u.jsx("div",{className:"skeleton-text w-20"}),u.jsx("div",{className:"space-y-2",children:[1,2,3].map(T=>u.jsx("div",{className:"skeleton-text-sm w-full"},T))})]},O))})]}):u.jsx(g1,{})}),u.jsxs("footer",{className:"footer",children:[u.jsxs("a",{href:"https://github.com/AINYC/canonry",target:"_blank",rel:"noopener noreferrer",className:"footer-brand",children:[u.jsx(NF,{className:"size-3.5"}),u.jsx("span",{children:"Canonry"})]}),u.jsx("div",{className:"footer-links",children:kE.map(O=>u.jsx("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",children:O.label},O.href))})]})]}),C?u.jsxs(J7,{open:C!==void 0,title:C.summary,subtitle:`${C.projectName} · ${C.kindLabel}`,onClose:p,children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1 text-sm",children:[u.jsx($g,{status:C.status}),u.jsx("span",{className:"text-zinc-400",children:C.startedAt}),u.jsx("span",{className:"text-zinc-500",children:C.duration}),u.jsx("span",{className:"text-zinc-600",children:C.triggerLabel})]}),C.status==="failed"&&C.statusDetail&&u.jsx("p",{className:"text-sm text-rose-300/80 mt-2",children:C.statusDetail}),u.jsxs("div",{className:"mt-4",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-2",children:"Activity Log"}),w?u.jsx("p",{className:"text-sm text-zinc-500",children:"Loading run details..."}):S&&S.snapshots.length>0?u.jsxs("div",{className:"space-y-2",children:[S.snapshots.map(O=>u.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 p-3",children:[u.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[u.jsx("p",{className:"text-sm font-medium text-zinc-200 truncate",children:O.keyword??"Unknown key phrase"}),u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(Kd,{provider:O.provider}),u.jsx(DR,{variant:O.citationState==="cited"?"success":"neutral",children:O.citationState})]})]}),O.model&&u.jsx("p",{className:"text-[11px] text-zinc-500 font-mono",children:O.model}),O.citedDomains.length>0&&u.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[u.jsx("span",{className:"text-zinc-400",children:"Sources:"})," ",O.citedDomains.join(", ")]}),O.competitorOverlap.length>0&&u.jsxs("p",{className:"text-xs text-rose-400/80 mt-0.5",children:["Competitor cited: ",O.competitorOverlap.join(", ")]}),O.groundingSources&&O.groundingSources.length>0&&u.jsxs("details",{className:"mt-2",children:[u.jsxs("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:[O.groundingSources.length," grounding source",O.groundingSources.length!==1?"s":""]}),u.jsx("ul",{className:"mt-1 space-y-0.5",children:O.groundingSources.map((T,z)=>u.jsx("li",{className:"text-xs text-zinc-500 truncate",children:u.jsx("a",{href:T.uri,target:"_blank",rel:"noopener noreferrer",className:"hover:text-zinc-300",children:T.title||T.uri})},z))})]}),O.answerText&&u.jsxs("details",{className:"mt-1",children:[u.jsx("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:"Answer preview"}),u.jsx("p",{className:"mt-1 text-xs text-zinc-400 leading-relaxed whitespace-pre-wrap",children:O.answerText})]})]},O.id)),S.status==="running"&&u.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[u.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Querying remaining key phrases..."]})]}):S&&S.status==="running"?u.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[u.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Waiting for first key phrase result..."]}):S&&S.status==="queued"?u.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[u.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-zinc-500 animate-pulse"}),"Run queued, waiting for execution slot..."]}):S&&S.error?u.jsxs("div",{className:"rounded-lg border border-rose-800/40 bg-rose-950/20 p-3",children:[u.jsx("p",{className:"text-sm font-medium text-rose-300 mb-2",children:"Run failed"}),u.jsx("pre",{className:"text-xs text-rose-300/80 whitespace-pre-wrap break-words max-h-48 overflow-y-auto font-mono leading-5",children:QF(S.error)})]}):u.jsx("p",{className:"text-sm text-zinc-500",children:"No snapshot data available."})]})]}):null,E?u.jsx(hQ,{evidence:E.evidence,project:E.project,onClose:p}):null,u.jsx(cX,{}),u.jsx(eX,{})]})}class dX extends x.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[ErrorBoundary]",t,n.componentStack)}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?u.jsx("div",{className:"page-container",children:u.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-20 text-center",children:[u.jsx("div",{className:"rounded-full bg-rose-950/40 p-3",children:u.jsx(KF,{className:"size-6 text-rose-400"})}),u.jsx("h2",{className:"text-lg font-semibold text-zinc-100",children:"Something went wrong"}),u.jsx("p",{className:"text-sm text-zinc-400 max-w-md",children:this.state.error.message||"An unexpected error occurred while rendering this page."}),u.jsxs("div",{className:"flex gap-3 mt-2",children:[u.jsxs(ve,{variant:"secondary",size:"sm",onClick:this.handleReset,children:[u.jsx(LF,{className:"size-3.5 mr-1.5"}),"Try again"]}),u.jsx(ve,{variant:"secondary",size:"sm",onClick:()=>{const t=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??"";window.location.href=t||"/"},children:"Go home"})]})]})}):this.props.children}}const He=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:di("rounded-xl border border-zinc-800 bg-zinc-950/75 shadow-[0_0_0_1px_rgba(255,255,255,0.01)] backdrop-blur",e),...t}));He.displayName="Card";const $w=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:di("flex flex-col gap-1.5 p-5",e),...t}));$w.displayName="CardHeader";const Uw=x.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:di("font-medium tracking-tight text-zinc-50",e),...t}));Uw.displayName="CardTitle";const Bw=x.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:di("text-sm text-zinc-500",e),...t}));Bw.displayName="CardDescription";const Xp=x.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:di("p-5 pt-0",e),...t}));Xp.displayName="CardContent";function fX({points:e,tone:t}){const n=x.useId();if(e.length===0)return null;const r=42,i=132,s=5,l=Math.min(...e),f=Math.max(...e)-l||1,h=i-s*2,p=r-s*2,g=e.map((v,y)=>{const S=s+y/Math.max(e.length-1,1)*h,w=s+(1-(v-l)/f)*p;return`${S},${w}`}).join(" ");return u.jsxs("svg",{className:`sparkline sparkline-${t}`,viewBox:`0 0 ${i} ${r}`,"aria-hidden":"true",children:[u.jsx("defs",{children:u.jsx("clipPath",{id:n,children:u.jsx("rect",{x:s,y:s,width:h,height:p,rx:"8"})})}),u.jsx("line",{className:"sparkline-guide",x1:s,x2:i-s,y1:r-s,y2:r-s}),u.jsx("polyline",{clipPath:`url(#${n})`,points:g,vectorEffect:"non-scaling-stroke"})]})}function hX({project:e}){return u.jsxs(Ut,{to:"/projects/$projectId",params:{projectId:e.project.id},className:"project-row cursor-pointer",children:[u.jsxs("div",{className:"project-row-primary",children:[u.jsxs("div",{children:[u.jsx("p",{className:"project-name",children:e.project.name}),u.jsx("p",{className:"project-domain",children:e.project.canonicalDomain})]}),u.jsx("p",{className:"project-insight",children:e.insight})]}),u.jsx("div",{className:"project-row-stat",children:u.jsxs("div",{className:"metric-inline-block",children:[u.jsx("p",{className:"metric-inline-label",children:"Answer Visibility"}),u.jsx("p",{className:`metric-inline-value ${e.visibilityTone==="caution"?"text-amber-400":""}`,children:e.visibilityScore}),u.jsx("p",{className:"metric-inline-delta",children:e.visibilityDelta}),e.providerCoverage&&u.jsx("p",{className:"text-[10px] font-medium text-amber-400/80",children:e.providerCoverage})]})}),u.jsx("div",{className:"project-row-stat",children:u.jsxs("div",{className:"metric-inline-block",children:[u.jsx("p",{className:"metric-inline-label",children:"Competitor Pressure"}),u.jsx("p",{className:"metric-inline-value",children:e.competitorPressureLabel}),u.jsxs("p",{className:"metric-inline-delta",children:[e.lastRun.kindLabel," · ",Dg(e.lastRun.status)]})]})}),u.jsx("div",{className:"project-row-chart",children:u.jsx(fX,{points:e.trend,tone:mR(e.lastRun.status)})}),u.jsx("span",{className:"project-row-link",children:u.jsx(Mg,{className:"h-4 w-4 text-zinc-500"})})]})}function pX(){const e=gf(),{dashboard:t,isLoading:n}=bl(),r=t??e?.dashboard;if(!r||n)return u.jsxs("div",{className:"page-skeleton",children:[u.jsxs("div",{className:"page-skeleton-header",children:[u.jsx("div",{className:"skeleton-text h-6 w-32"}),u.jsx("div",{className:"skeleton-text-sm w-64"})]}),u.jsx("div",{className:"space-y-3",children:[1,2,3].map(p=>u.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-4 flex items-center gap-4",children:[u.jsxs("div",{className:"flex-1 space-y-2",children:[u.jsx("div",{className:"skeleton-text w-36"}),u.jsx("div",{className:"skeleton-text-sm w-48"})]}),u.jsx("div",{className:"skeleton-text w-16"}),u.jsx("div",{className:"skeleton-text w-16"}),u.jsx("div",{className:"skeleton h-8 w-20 rounded"})]},p))})]});const i=r.portfolioOverview,c=Vg(!e,e?.health).data??e?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},f=rK(i.systemHealth,c,r.settings),{openRun:h}=nu();return u.jsxs("div",{className:"page-container",children:[u.jsxs("div",{className:"page-header",children:[u.jsxs("div",{className:"page-header-left",children:[u.jsx("h1",{className:"page-title",children:"Portfolio"}),u.jsx("p",{className:"page-subtitle",children:"Visibility and execution state across all projects"})]}),u.jsx("div",{className:"page-header-right",children:u.jsx("p",{className:"text-[11px] text-zinc-600",children:i.lastUpdatedAt})})]}),i.projects.length>0?u.jsx("div",{className:"project-list project-list-scrollable",children:i.projects.map(p=>u.jsx(hX,{project:p},p.project.id))}):u.jsxs(He,{className:"surface-card empty-card",children:[u.jsx("h3",{children:i.emptyState?.title??"No projects yet"}),u.jsx("p",{className:"supporting-copy",children:i.emptyState?.detail}),u.jsx(ve,{size:"sm",asChild:!0,children:u.jsx(Ut,{to:i.emptyState?.ctaHref==="/setup"||!i.emptyState?.ctaHref?"/setup":"/",children:i.emptyState?.ctaLabel??"Launch setup"})})]}),u.jsxs("div",{className:"overview-secondary-grid",children:[i.attentionItems.length>0&&u.jsxs("section",{className:"overview-secondary-section",children:[u.jsx("div",{className:"section-head section-head-inline",children:u.jsxs("div",{children:[u.jsx("p",{className:"eyebrow eyebrow-soft",children:"Needs attention"}),u.jsx("h2",{className:"section-title-sm",children:"What changed"})]})}),u.jsx("div",{className:"attention-list attention-list-scrollable",children:i.attentionItems.map(p=>u.jsxs(Ut,{to:p.href,className:`attention-item attention-item-${p.tone}`,children:[u.jsxs("div",{children:[u.jsx("p",{className:"attention-title",children:p.title}),u.jsx("p",{className:"attention-detail",children:p.detail})]}),u.jsx("span",{className:"attention-action",children:p.actionLabel})]},p.id))})]}),u.jsxs("section",{className:"overview-secondary-section",children:[u.jsx("div",{className:"section-head section-head-inline",children:u.jsxs("div",{children:[u.jsx("p",{className:"eyebrow eyebrow-soft",children:"Recent runs"}),u.jsx("h2",{className:"section-title-sm",children:"Activity"})]})}),u.jsx("div",{className:"compact-stack compact-stack-scrollable",children:i.recentRuns.length>0?i.recentRuns.map(p=>u.jsxs("button",{className:"compact-run",type:"button",onClick:()=>h(p.id),children:[u.jsxs("div",{children:[u.jsx("p",{className:"compact-run-title",children:p.projectName}),u.jsx("p",{className:"compact-run-detail",children:p.summary})]}),u.jsx($g,{status:p.status})]},p.id)):u.jsx("p",{className:"supporting-copy",children:"Run history appears here after the first launch."})})]})]}),u.jsxs("section",{className:"page-section",children:[u.jsx("div",{className:"section-head section-head-inline",children:u.jsxs("div",{children:[u.jsx("p",{className:"eyebrow eyebrow-soft",children:"System health"}),u.jsx("h2",{className:"section-title-sm",children:"Infrastructure"})]})}),u.jsx("div",{className:"health-grid",children:f.map(p=>u.jsxs(He,{className:"surface-card compact-card",children:[u.jsxs("div",{className:"section-head",children:[u.jsxs("div",{children:[u.jsx("p",{className:"eyebrow eyebrow-soft",children:p.label}),u.jsx("h3",{children:p.detail})]}),u.jsx(wt,{tone:p.tone,title:p.id==="api"?qs(c.apiStatus):p.id==="worker"?qs(c.workerStatus):void 0,children:p.label})]}),u.jsx("p",{className:"supporting-copy",children:p.meta})]},p.id))})]})]})}const U1=Symbol.for("yaml.alias"),qw=Symbol.for("yaml.document"),Ls=Symbol.for("yaml.map"),gI=Symbol.for("yaml.pair"),Xi=Symbol.for("yaml.scalar"),ru=Symbol.for("yaml.seq"),si=Symbol.for("yaml.node.type"),xl=e=>!!e&&typeof e=="object"&&e[si]===U1,Zg=e=>!!e&&typeof e=="object"&&e[si]===qw,vf=e=>!!e&&typeof e=="object"&&e[si]===Ls,on=e=>!!e&&typeof e=="object"&&e[si]===gI,Pt=e=>!!e&&typeof e=="object"&&e[si]===Xi,yf=e=>!!e&&typeof e=="object"&&e[si]===ru;function an(e){if(e&&typeof e=="object")switch(e[si]){case Ls:case ru:return!0}return!1}function sn(e){if(e&&typeof e=="object")switch(e[si]){case U1:case Ls:case Xi:case ru:return!0}return!1}const vI=e=>(Pt(e)||an(e))&&!!e.anchor,Po=Symbol("break visit"),mX=Symbol("skip children"),Md=Symbol("remove node");function iu(e,t){const n=gX(t);Zg(e)?Sc(null,e.contents,n,Object.freeze([e]))===Md&&(e.contents=null):Sc(null,e,n,Object.freeze([]))}iu.BREAK=Po;iu.SKIP=mX;iu.REMOVE=Md;function Sc(e,t,n,r){const i=vX(e,t,n,r);if(sn(i)||on(i))return yX(e,r,i),Sc(e,i,n,r);if(typeof i!="symbol"){if(an(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){const l=Sc(s,t.items[s],n,r);if(typeof l=="number")s=l-1;else{if(l===Po)return Po;l===Md&&(t.items.splice(s,1),s-=1)}}}else if(on(t)){r=Object.freeze(r.concat(t));const s=Sc("key",t.key,n,r);if(s===Po)return Po;s===Md&&(t.key=null);const l=Sc("value",t.value,n,r);if(l===Po)return Po;l===Md&&(t.value=null)}}return i}function gX(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function vX(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(vf(t))return n.Map?.(e,t,r);if(yf(t))return n.Seq?.(e,t,r);if(on(t))return n.Pair?.(e,t,r);if(Pt(t))return n.Scalar?.(e,t,r);if(xl(t))return n.Alias?.(e,t,r)}function yX(e,t,n){const r=t[t.length-1];if(an(r))r.items[e]=n;else if(on(r))e==="key"?r.key=n:r.value=n;else if(Zg(r))r.contents=n;else{const i=xl(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const bX={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},xX=e=>e.replace(/[!,[\]{}]/g,t=>bX[t]);class Xn{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Xn.defaultYaml,t),this.tags=Object.assign({},Xn.defaultTags,n)}clone(){const t=new Xn(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new Xn(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Xn.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Xn.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:Xn.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Xn.defaultTags),this.atNextDocument=!1);const r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;const[s,l]=r;return this.tags[s]=l,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[s]=r;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{const l=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,l),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const l=t.slice(2,-1);return l==="!"||l==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),l)}const[,r,i]=t.match(/^(.*!)([^!]*)$/s);i||n(`The ${t} tag has no suffix`);const s=this.tags[r];if(s)try{return s+decodeURIComponent(i)}catch(l){return n(String(l)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+xX(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags);let i;if(t&&r.length>0&&sn(t.contents)){const s={};iu(t.contents,(l,c)=>{sn(c)&&c.tag&&(s[c.tag]=!0)}),i=Object.keys(s)}else i=[];for(const[s,l]of r)s==="!!"&&l==="tag:yaml.org,2002:"||(!t||i.some(c=>c.startsWith(l)))&&n.push(`%TAG ${s} ${l}`);return n.join(`
97
97
  `)}}Xn.defaultYaml={explicit:!1,version:"1.2"};Xn.defaultTags={"!!":"tag:yaml.org,2002:"};function yI(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function bI(e){const t=new Set;return iu(e,{Value(n,r){r.anchor&&t.add(r.anchor)}}),t}function xI(e,t){for(let n=1;;++n){const r=`${e}${n}`;if(!t.has(r))return r}}function wX(e,t){const n=[],r=new Map;let i=null;return{onAnchor:s=>{n.push(s),i??(i=bI(e));const l=xI(t,i);return i.add(l),l},setAnchors:()=>{for(const s of n){const l=r.get(s);if(typeof l=="object"&&l.anchor&&(Pt(l.node)||an(l.node)))l.node.anchor=l.anchor;else{const c=new Error("Failed to resolve repeated object (this should not happen)");throw c.source=s,c}}},sourceObjects:r}}function jc(e,t,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let i=0,s=r.length;i<s;++i){const l=r[i],c=jc(e,r,String(i),l);c===void 0?delete r[i]:c!==l&&(r[i]=c)}else if(r instanceof Map)for(const i of Array.from(r.keys())){const s=r.get(i),l=jc(e,r,i,s);l===void 0?r.delete(i):l!==s&&r.set(i,l)}else if(r instanceof Set)for(const i of Array.from(r)){const s=jc(e,r,i,i);s===void 0?r.delete(i):s!==i&&(r.delete(i),r.add(s))}else for(const[i,s]of Object.entries(r)){const l=jc(e,r,i,s);l===void 0?delete r[i]:l!==s&&(r[i]=l)}return e.call(t,n,r)}function ai(e,t,n){if(Array.isArray(e))return e.map((r,i)=>ai(r,String(i),n));if(e&&typeof e.toJSON=="function"){if(!n||!vI(e))return e.toJSON(t,n);const r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=s=>{r.res=s,delete n.onCreate};const i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e=="bigint"&&!n?.keep?Number(e):e}class B1{constructor(t){Object.defineProperty(this,si,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:s}={}){if(!Zg(t))throw new TypeError("A document argument is required");const l={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=ai(this,"",l);if(typeof i=="function")for(const{count:f,res:h}of l.anchors.values())i(h,f);return typeof s=="function"?jc(s,{"":c},"",c):c}}class q1 extends B1{constructor(t){super(U1),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],iu(t,{Node:(s,l)=>{(xl(l)||vI(l))&&r.push(l)}}),n&&(n.aliasResolveCache=r));let i;for(const s of r){if(s===this)break;s.anchor===this.source&&(i=s)}return i}toJSON(t,n){if(!n)return{source:this.source};const{anchors:r,doc:i,maxAliasCount:s}=n,l=this.resolve(i,n);if(!l){const f=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(f)}let c=r.get(l);if(c||(ai(l,null,n),c=r.get(l)),c?.res===void 0){const f="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(f)}if(s>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=Jp(i,l,r)),c.count*c.aliasCount>s)){const f="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(f)}return c.res}toString(t,n,r){const i=`*${this.source}`;if(t){if(yI(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(t.implicitKey)return`${i} `}return i}}function Jp(e,t,n){if(xl(t)){const r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(an(t)){let r=0;for(const i of t.items){const s=Jp(e,i,n);s>r&&(r=s)}return r}else if(on(t)){const r=Jp(e,t.key,n),i=Jp(e,t.value,n);return Math.max(r,i)}return 1}const wI=e=>!e||typeof e!="function"&&typeof e!="object";class Ve extends B1{constructor(t){super(Xi),this.value=t}toJSON(t,n){return n?.keep?this.value:ai(this.value,t,n)}toString(){return String(this.value)}}Ve.BLOCK_FOLDED="BLOCK_FOLDED";Ve.BLOCK_LITERAL="BLOCK_LITERAL";Ve.PLAIN="PLAIN";Ve.QUOTE_DOUBLE="QUOTE_DOUBLE";Ve.QUOTE_SINGLE="QUOTE_SINGLE";const SX="tag:yaml.org,2002:";function jX(e,t,n){if(t){const r=n.filter(s=>s.tag===t),i=r.find(s=>!s.format)??r[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return n.find(r=>r.identify?.(e)&&!r.format)}function Yd(e,t,n){if(Zg(e)&&(e=e.contents),sn(e))return e;if(on(e)){const g=n.schema[Ls].createNode?.(n.schema,null,n);return g.items.push(e),g}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:r,onAnchor:i,onTagObj:s,schema:l,sourceObjects:c}=n;let f;if(r&&e&&typeof e=="object"){if(f=c.get(e),f)return f.anchor??(f.anchor=i(e)),new q1(f.anchor);f={anchor:null,node:null},c.set(e,f)}t?.startsWith("!!")&&(t=SX+t.slice(2));let h=jX(e,t,l.tags);if(!h){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){const g=new Ve(e);return f&&(f.node=g),g}h=e instanceof Map?l[Ls]:Symbol.iterator in Object(e)?l[ru]:l[Ls]}s&&(s(h),delete n.onTagObj);const p=h?.createNode?h.createNode(n.schema,e,n):typeof h?.nodeClass?.from=="function"?h.nodeClass.from(n.schema,e,n):new Ve(e);return t?p.tag=t:h.default||(p.tag=h.tag),f&&(f.node=p),p}function _m(e,t,n){let r=n;for(let i=t.length-1;i>=0;--i){const s=t[i];if(typeof s=="number"&&Number.isInteger(s)&&s>=0){const l=[];l[s]=r,r=l}else r=new Map([[s,r]])}return Yd(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const _d=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class SI extends B1{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){const n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(r=>sn(r)||on(r)?r.clone(t):r),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(_d(t))this.add(n);else{const[r,...i]=t,s=this.get(r,!0);if(an(s))s.addIn(i,n);else if(s===void 0&&this.schema)this.set(r,_m(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(t){const[n,...r]=t;if(r.length===0)return this.delete(n);const i=this.get(n,!0);if(an(i))return i.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(t,n){const[r,...i]=t,s=this.get(r,!0);return i.length===0?!n&&Pt(s)?s.value:s:an(s)?s.getIn(i,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!on(n))return!1;const r=n.value;return r==null||t&&Pt(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){const[n,...r]=t;if(r.length===0)return this.has(n);const i=this.get(n,!0);return an(i)?i.hasIn(r):!1}setIn(t,n){const[r,...i]=t;if(i.length===0)this.set(r,n);else{const s=this.get(r,!0);if(an(s))s.setIn(i,n);else if(s===void 0&&this.schema)this.set(r,_m(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}}const NX=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Pa(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Uo=(e,t,n)=>e.endsWith(`
98
98
  `)?Pa(n,t):n.includes(`
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-Cxg_4UWs.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-CVk23m8J.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="./assets/index--ev1Bjls.css">
17
17
  </head>
18
18
  <body>
@@ -115,7 +115,8 @@ var querySnapshots = sqliteTable("query_snapshots", {
115
115
  index("idx_snapshots_keyword").on(table.keywordId),
116
116
  index("idx_snapshots_citation_state").on(table.citationState),
117
117
  index("idx_snapshots_provider_model").on(table.provider, table.model),
118
- index("idx_snapshots_location").on(table.location)
118
+ index("idx_snapshots_location").on(table.location),
119
+ index("idx_snapshots_created_at").on(table.createdAt)
119
120
  ]);
120
121
  var auditLog = sqliteTable("audit_log", {
121
122
  id: text("id").primaryKey(),
@@ -848,7 +849,11 @@ var MIGRATIONS = [
848
849
  `CREATE INDEX IF NOT EXISTS idx_bing_coverage_snap_run ON bing_coverage_snapshots(sync_run_id)`,
849
850
  // v34: Rename unique index for bing_coverage_snapshots to follow convention
850
851
  `DROP INDEX IF EXISTS idx_bing_coverage_snap_project_date`,
851
- `CREATE UNIQUE INDEX IF NOT EXISTS idx_bing_coverage_snap_project_date_unique ON bing_coverage_snapshots(project_id, date)`
852
+ `CREATE UNIQUE INDEX IF NOT EXISTS idx_bing_coverage_snap_project_date_unique ON bing_coverage_snapshots(project_id, date)`,
853
+ // v35: Add missing index for query_snapshots createdAt for time-series filtering
854
+ `CREATE INDEX IF NOT EXISTS idx_snapshots_created_at ON query_snapshots(created_at)`
855
+ // v36: Transaction handling and SQL injection review: verified all strings use SQLite ? binding via Drizzle.
856
+ // No changes required for parameterization.
852
857
  ];
853
858
  function isDuplicateColumnError(err) {
854
859
  if (!(err instanceof Error)) return false;