@ainyc/canonry 5.4.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/agent-workspace/skills/aero/references/portfolio-analysis.md +1 -1
- package/assets/agent-workspace/skills/canonry/references/aeo-analysis.md +10 -0
- package/assets/assets/{AuditHistoryPanel-DNSskBJN.js → AuditHistoryPanel-DVUbjx1M.js} +1 -1
- package/assets/assets/{BacklinksPage-COtLVzT8.js → BacklinksPage-D01VTDAp.js} +1 -1
- package/assets/assets/ChartPrimitives-BQC2VH0O.js +1 -0
- package/assets/assets/{HistoryPage-D9e6cGrq.js → HistoryPage-Bk1gsXe5.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-BSs4ba4N.js → MeasurementPropertyPage-D7p5vpY_.js} +1 -1
- package/assets/assets/ProjectPage-Dv3USEIE.js +8 -0
- package/assets/assets/{RunRow-DRjXGgeI.js → RunRow-Dpa0kAip.js} +1 -1
- package/assets/assets/{RunsPage-BXyqLNMQ.js → RunsPage-B59z7DQ_.js} +1 -1
- package/assets/assets/{SettingsPage-DKmzGwx3.js → SettingsPage-HJDgmQi9.js} +1 -1
- package/assets/assets/{SiteHealthSection-DuSY6jzY.js → SiteHealthSection-BnJA-zvQ.js} +3 -3
- package/assets/assets/TrafficPage-C8na59q_.js +40 -0
- package/assets/assets/{TrafficSourceDetailPage-Bw8PCVl9.js → TrafficSourceDetailPage-B2fO8bDc.js} +1 -1
- package/assets/assets/{extract-error-message-rTGTNN_D.js → extract-error-message-670MySRM.js} +1 -1
- package/assets/assets/index-DTrkuKOh.js +86 -0
- package/assets/assets/index-PT4UiPTM.css +1 -0
- package/assets/assets/{react-sigma_core.esm.min-Xwhtf0bv.js → react-sigma_core.esm.min-DOhuYLQj.js} +1 -1
- package/assets/assets/v2-overview-adapter-CQyDNkXa.js +1 -0
- package/assets/assets/vendor-lucide-CneDbhOr.js +1 -0
- package/assets/assets/{vendor-recharts-D-cUuLZo.js → vendor-recharts-llkUFBGR.js} +1 -1
- package/assets/index.html +4 -4
- package/dist/{chunk-SLOTTXIL.js → chunk-C4KBR4H6.js} +6 -6
- package/dist/{chunk-Z6RA7LWY.js → chunk-D3DKDTXP.js} +1027 -70
- package/dist/{chunk-L3FG66O7.js → chunk-GHAUT7XJ.js} +2 -2
- package/dist/{chunk-67OM5KEH.js → chunk-I4AHG7K3.js} +3 -3
- package/dist/{chunk-P5YYRGFS.js → chunk-KZYOJ4F5.js} +2 -2
- package/dist/{chunk-2P52FD5B.js → chunk-TM2NQMJA.js} +803 -777
- package/dist/cli.js +10 -9
- package/dist/{demo-server-6QU77ZMV.js → demo-server-JEGVGOPQ.js} +7 -3
- package/dist/index.js +5 -5
- package/dist/{intelligence-service-PHCK6A35.js → intelligence-service-5P62KKG6.js} +2 -2
- package/dist/mcp.js +3 -3
- package/package.json +13 -13
- package/assets/assets/ChartPrimitives-Bxa_vFmq.js +0 -1
- package/assets/assets/ProjectPage-BbpGgwgd.js +0 -8
- package/assets/assets/TrafficPage-Bc9NGm4L.js +0 -1
- package/assets/assets/index-CVK43vax.js +0 -86
- package/assets/assets/index-Hmnj0RO5.css +0 -1
- package/assets/assets/v2-overview-adapter-BgGH6oLq.js +0 -1
- package/assets/assets/vendor-lucide-CBIL4Nkq.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./react-sigma_core.esm.min-
|
|
2
|
-
import{r as w,j as s,u as me,C as Cn}from"./vendor-tanstack-ZXXkndVj.js";import{dT as Os,dU as zs,B as M,dV as He,dW as Fs,T as X,w as Dn,dX as $t,aa as Ke,dY as Us,dZ as Bs,d_ as Hs,b2 as Ks,d$ as Pn,ac as Ws,ad as hn,Q as Pt,e0 as Rn,e1 as In,f as qs,j as zt,af as Ft,I as fe,i as le,e2 as Vs,e3 as fn,k as Ys,cK as Qs,e4 as Xs,e5 as Zs,e6 as Js,e7 as ei,e8 as ti,e9 as ni,ea as si,eb as pn,ec as ii,ed as ai,ee as Ut,cN as ri,ef as oi,eg as li,eh as di,ei as Ye,ej as ci,ek as ui}from"./index-CVK43vax.js";import{S as Yt,q as hi,J as fi,c as pi,f as Lt,X as mi,Y as gi,L as je,T as Bt,x as Rt,Z as mn,P as Ht,C as Mn,_ as xi,E as bi}from"./vendor-lucide-CBIL4Nkq.js";import{C as yi,a as gn,b as xn,d as wi,h as bn,i as vi,j as Ni,o as On}from"./ChartPrimitives-Bxa_vFmq.js";import{R as ji,C as ki,a as Si,X as Ei,Y as Ai,T as _i,d as $i}from"./vendor-recharts-D-cUuLZo.js";const Li=/^www\./i;function zn(n){if(!n)return null;try{return new URL(n).hostname}catch{return null}}function yn(n){return n.trim().toLowerCase().replace(Li,"")}function Ti(n,e){if(!e)return!1;try{return yn(new URL(n).hostname)===yn(e)}catch{return!1}}function Fn(n,e){if(!n)return"";if(!Ti(n,e))return n;const t=new URL(n),i=`${t.pathname}${t.search}${t.hash}`;return i===""?"/":i}function Gi(n,e){return Fn(n.url,e)||n.path||"/"}var kt={exports:{}},wn;function Ci(){if(wn)return kt.exports;wn=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(m,b,N){return Function.prototype.apply.call(m,b,N)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(m){return Object.getOwnPropertyNames(m).concat(Object.getOwnPropertySymbols(m))}:t=function(m){return Object.getOwnPropertyNames(m)};function i(g){console&&console.warn&&console.warn(g)}var a=Number.isNaN||function(m){return m!==m};function r(){r.init.call(this)}kt.exports=r,kt.exports.once=C,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var o=10;function l(g){if(typeof g!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof g)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(g){if(typeof g!="number"||g<0||a(g))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+g+".");o=g}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(m){if(typeof m!="number"||m<0||a(m))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+m+".");return this._maxListeners=m,this};function c(g){return g._maxListeners===void 0?r.defaultMaxListeners:g._maxListeners}r.prototype.getMaxListeners=function(){return c(this)},r.prototype.emit=function(m){for(var b=[],N=1;N<arguments.length;N++)b.push(arguments[N]);var _=m==="error",G=this._events;if(G!==void 0)_=_&&G.error===void 0;else if(!_)return!1;if(_){var P;if(b.length>0&&(P=b[0]),P instanceof Error)throw P;var U=new Error("Unhandled error."+(P?" ("+P.message+")":""));throw U.context=P,U}var Q=G[m];if(Q===void 0)return!1;if(typeof Q=="function")e(Q,this,b);else for(var Y=Q.length,se=A(Q,Y),N=0;N<Y;++N)e(se[N],this,b);return!0};function d(g,m,b,N){var _,G,P;if(l(b),G=g._events,G===void 0?(G=g._events=Object.create(null),g._eventsCount=0):(G.newListener!==void 0&&(g.emit("newListener",m,b.listener?b.listener:b),G=g._events),P=G[m]),P===void 0)P=G[m]=b,++g._eventsCount;else if(typeof P=="function"?P=G[m]=N?[b,P]:[P,b]:N?P.unshift(b):P.push(b),_=c(g),_>0&&P.length>_&&!P.warned){P.warned=!0;var U=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+String(m)+" listeners added. Use emitter.setMaxListeners() to increase limit");U.name="MaxListenersExceededWarning",U.emitter=g,U.type=m,U.count=P.length,i(U)}return g}r.prototype.addListener=function(m,b){return d(this,m,b,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(m,b){return d(this,m,b,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(g,m,b){var N={fired:!1,wrapFn:void 0,target:g,type:m,listener:b},_=f.bind(N);return _.listener=b,N.wrapFn=_,_}r.prototype.once=function(m,b){return l(b),this.on(m,u(this,m,b)),this},r.prototype.prependOnceListener=function(m,b){return l(b),this.prependListener(m,u(this,m,b)),this},r.prototype.removeListener=function(m,b){var N,_,G,P,U;if(l(b),_=this._events,_===void 0)return this;if(N=_[m],N===void 0)return this;if(N===b||N.listener===b)--this._eventsCount===0?this._events=Object.create(null):(delete _[m],_.removeListener&&this.emit("removeListener",m,N.listener||b));else if(typeof N!="function"){for(G=-1,P=N.length-1;P>=0;P--)if(N[P]===b||N[P].listener===b){U=N[P].listener,G=P;break}if(G<0)return this;G===0?N.shift():j(N,G),N.length===1&&(_[m]=N[0]),_.removeListener!==void 0&&this.emit("removeListener",m,U||b)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(m){var b,N,_;if(N=this._events,N===void 0)return this;if(N.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):N[m]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete N[m]),this;if(arguments.length===0){var G=Object.keys(N),P;for(_=0;_<G.length;++_)P=G[_],P!=="removeListener"&&this.removeAllListeners(P);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(b=N[m],typeof b=="function")this.removeListener(m,b);else if(b!==void 0)for(_=b.length-1;_>=0;_--)this.removeListener(m,b[_]);return this};function h(g,m,b){var N=g._events;if(N===void 0)return[];var _=N[m];return _===void 0?[]:typeof _=="function"?b?[_.listener||_]:[_]:b?D(_):A(_,_.length)}r.prototype.listeners=function(m){return h(this,m,!0)},r.prototype.rawListeners=function(m){return h(this,m,!1)},r.listenerCount=function(g,m){return typeof g.listenerCount=="function"?g.listenerCount(m):x.call(g,m)},r.prototype.listenerCount=x;function x(g){var m=this._events;if(m!==void 0){var b=m[g];if(typeof b=="function")return 1;if(b!==void 0)return b.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function A(g,m){for(var b=new Array(m),N=0;N<m;++N)b[N]=g[N];return b}function j(g,m){for(;m+1<g.length;m++)g[m]=g[m+1];g.pop()}function D(g){for(var m=new Array(g.length),b=0;b<m.length;++b)m[b]=g[b].listener||g[b];return m}function C(g,m){return new Promise(function(b,N){function _(P){g.removeListener(m,G),N(P)}function G(){typeof g.removeListener=="function"&&g.removeListener("error",_),b([].slice.call(arguments))}R(g,m,G,{once:!0}),m!=="error"&&F(g,_,{once:!0})})}function F(g,m,b){typeof g.on=="function"&&R(g,"error",m,b)}function R(g,m,b,N){if(typeof g.on=="function")N.once?g.once(m,b):g.on(m,b);else if(typeof g.addEventListener=="function")g.addEventListener(m,function _(G){N.once&&g.removeEventListener(m,_),b(G)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof g)}return kt.exports}var Di=Ci();function Pi(){const n=arguments[0];for(let e=1,t=arguments.length;e<t;e++)if(arguments[e])for(const i in arguments[e])n[i]=arguments[e][i];return n}let Z=Pi;typeof Object.assign=="function"&&(Z=Object.assign);function Se(n,e,t,i){const a=n._nodes.get(e);let r=null;return a&&(i==="mixed"?r=a.out&&a.out[t]||a.undirected&&a.undirected[t]:i==="directed"?r=a.out&&a.out[t]:r=a.undirected&&a.undirected[t]),r}function de(n){return typeof n=="object"&&n!==null}function Un(n){let e;for(e in n)return!1;return!0}function Ne(n,e,t){Object.defineProperty(n,e,{enumerable:!1,configurable:!1,writable:!0,value:t})}function $e(n,e,t){const i={enumerable:!0,configurable:!0};typeof t=="function"?i.get=t:(i.value=t,i.writable=!1),Object.defineProperty(n,e,i)}function vn(n){return!(!de(n)||n.attributes&&!Array.isArray(n.attributes))}function Ri(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function De(){const n=arguments;let e=null,t=-1;return{[Symbol.iterator](){return this},next(){let i=null;do{if(e===null){if(t++,t>=n.length)return{done:!0};e=n[t][Symbol.iterator]()}if(i=e.next(),i.done){e=null;continue}break}while(!0);return i}}}function st(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Qt extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class S extends Qt{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,S.prototype.constructor)}}class v extends Qt{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,v.prototype.constructor)}}class $ extends Qt{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,$.prototype.constructor)}}function Bn(n,e){this.key=n,this.attributes=e,this.clear()}Bn.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Hn(n,e){this.key=n,this.attributes=e,this.clear()}Hn.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Kn(n,e){this.key=n,this.attributes=e,this.clear()}Kn.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function it(n,e,t,i,a){this.key=e,this.attributes=a,this.undirected=n,this.source=t,this.target=i}it.prototype.attach=function(){let n="out",e="in";this.undirected&&(n=e="undirected");const t=this.source.key,i=this.target.key;this.source[n][i]=this,!(this.undirected&&t===i)&&(this.target[e][t]=this)};it.prototype.attachMulti=function(){let n="out",e="in";const t=this.source.key,i=this.target.key;this.undirected&&(n=e="undirected");const a=this.source[n],r=a[i];if(typeof r>"u"){a[i]=this,this.undirected&&t===i||(this.target[e][t]=this);return}r.previous=this,this.next=r,a[i]=this,this.target[e][t]=this};it.prototype.detach=function(){const n=this.source.key,e=this.target.key;let t="out",i="in";this.undirected&&(t=i="undirected"),delete this.source[t][e],delete this.target[i][n]};it.prototype.detachMulti=function(){const n=this.source.key,e=this.target.key;let t="out",i="in";this.undirected&&(t=i="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[i][n]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[i][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Wn=0,qn=1,Ii=2,Vn=3;function Pe(n,e,t,i,a,r,o){let l,c,d,f;if(i=""+i,t===Wn){if(l=n._nodes.get(i),!l)throw new v(`Graph.${e}: could not find the "${i}" node in the graph.`);d=a,f=r}else if(t===Vn){if(a=""+a,c=n._edges.get(a),!c)throw new v(`Graph.${e}: could not find the "${a}" edge in the graph.`);const u=c.source.key,h=c.target.key;if(i===u)l=c.target;else if(i===h)l=c.source;else throw new v(`Graph.${e}: the "${i}" node is not attached to the "${a}" edge (${u}, ${h}).`);d=r,f=o}else{if(c=n._edges.get(i),!c)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`);t===qn?l=c.source:l=c.target,d=a,f=r}return[l,d,f]}function Mi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);return o.attributes[l]}}function Oi(n,e,t){n.prototype[e]=function(i,a){const[r]=Pe(this,e,t,i,a);return r.attributes}}function zi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);return o.attributes.hasOwnProperty(l)}}function Fi(n,e,t){n.prototype[e]=function(i,a,r,o){const[l,c,d]=Pe(this,e,t,i,a,r,o);return l.attributes[c]=d,this.emit("nodeAttributesUpdated",{key:l.key,type:"set",attributes:l.attributes,name:c}),this}}function Ui(n,e,t){n.prototype[e]=function(i,a,r,o){const[l,c,d]=Pe(this,e,t,i,a,r,o);if(typeof d!="function")throw new S(`Graph.${e}: updater should be a function.`);const f=l.attributes,u=d(f[c]);return f[c]=u,this.emit("nodeAttributesUpdated",{key:l.key,type:"set",attributes:l.attributes,name:c}),this}}function Bi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);return delete o.attributes[l],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:l}),this}}function Hi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);if(!de(l))throw new S(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=l,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ki(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);if(!de(l))throw new S(`Graph.${e}: provided attributes are not a plain object.`);return Z(o.attributes,l),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:l}),this}}function Wi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);if(typeof l!="function")throw new S(`Graph.${e}: provided updater is not a function.`);return o.attributes=l(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const qi=[{name:n=>`get${n}Attribute`,attacher:Mi},{name:n=>`get${n}Attributes`,attacher:Oi},{name:n=>`has${n}Attribute`,attacher:zi},{name:n=>`set${n}Attribute`,attacher:Fi},{name:n=>`update${n}Attribute`,attacher:Ui},{name:n=>`remove${n}Attribute`,attacher:Bi},{name:n=>`replace${n}Attributes`,attacher:Hi},{name:n=>`merge${n}Attributes`,attacher:Ki},{name:n=>`update${n}Attributes`,attacher:Wi}];function Vi(n){qi.forEach(function({name:e,attacher:t}){t(n,e("Node"),Wn),t(n,e("Source"),qn),t(n,e("Target"),Ii),t(n,e("Opposite"),Vn)})}function Yi(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return r.attributes[a]}}function Qi(n,e,t){n.prototype[e]=function(i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const r=""+i,o=""+arguments[1];if(a=Se(this,r,o,t),!a)throw new v(`Graph.${e}: could not find an edge for the given path ("${r}" - "${o}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,a=this._edges.get(i),!a)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return a.attributes}}function Xi(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return r.attributes.hasOwnProperty(a)}}function Zi(n,e,t){n.prototype[e]=function(i,a,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const l=""+i,c=""+a;if(a=arguments[2],r=arguments[3],o=Se(this,l,c,t),!o)throw new v(`Graph.${e}: could not find an edge for the given path ("${l}" - "${c}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return o.attributes[a]=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:a}),this}}function Ji(n,e,t){n.prototype[e]=function(i,a,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const l=""+i,c=""+a;if(a=arguments[2],r=arguments[3],o=Se(this,l,c,t),!o)throw new v(`Graph.${e}: could not find an edge for the given path ("${l}" - "${c}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(typeof r!="function")throw new S(`Graph.${e}: updater should be a function.`);return o.attributes[a]=r(o.attributes[a]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:a}),this}}function ea(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return delete r.attributes[a],this.emit("edgeAttributesUpdated",{key:r.key,type:"remove",attributes:r.attributes,name:a}),this}}function ta(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(!de(a))throw new S(`Graph.${e}: provided attributes are not a plain object.`);return r.attributes=a,this.emit("edgeAttributesUpdated",{key:r.key,type:"replace",attributes:r.attributes}),this}}function na(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(!de(a))throw new S(`Graph.${e}: provided attributes are not a plain object.`);return Z(r.attributes,a),this.emit("edgeAttributesUpdated",{key:r.key,type:"merge",attributes:r.attributes,data:a}),this}}function sa(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(typeof a!="function")throw new S(`Graph.${e}: provided updater is not a function.`);return r.attributes=a(r.attributes),this.emit("edgeAttributesUpdated",{key:r.key,type:"update",attributes:r.attributes}),this}}const ia=[{name:n=>`get${n}Attribute`,attacher:Yi},{name:n=>`get${n}Attributes`,attacher:Qi},{name:n=>`has${n}Attribute`,attacher:Xi},{name:n=>`set${n}Attribute`,attacher:Zi},{name:n=>`update${n}Attribute`,attacher:Ji},{name:n=>`remove${n}Attribute`,attacher:ea},{name:n=>`replace${n}Attributes`,attacher:ta},{name:n=>`merge${n}Attributes`,attacher:na},{name:n=>`update${n}Attributes`,attacher:sa}];function aa(n){ia.forEach(function({name:e,attacher:t}){t(n,e("Edge"),"mixed"),t(n,e("DirectedEdge"),"directed"),t(n,e("UndirectedEdge"),"undirected")})}const ra=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function oa(n,e,t,i){let a=!1;for(const r in e){if(r===i)continue;const o=e[r];if(a=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),n&&a)return o.key}}function la(n,e,t,i){let a,r,o,l=!1;for(const c in e)if(c!==i){a=e[c];do{if(r=a.source,o=a.target,l=t(a.key,a.attributes,r.key,o.key,r.attributes,o.attributes,a.undirected),n&&l)return a.key;a=a.next}while(a!==void 0)}}function It(n,e){const t=Object.keys(n),i=t.length;let a,r=0;return{[Symbol.iterator](){return this},next(){do if(a)a=a.next;else{if(r>=i)return{done:!0};const o=t[r++];if(o===e){a=void 0;continue}a=n[o]}while(!a);return{done:!1,value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected}}}}}function da(n,e,t,i){const a=e[t];if(!a)return;const r=a.source,o=a.target;if(i(a.key,a.attributes,r.key,o.key,r.attributes,o.attributes,a.undirected)&&n)return a.key}function ca(n,e,t,i){let a=e[t];if(!a)return;let r=!1;do{if(r=i(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),n&&r)return a.key;a=a.next}while(a!==void 0)}function Mt(n,e){let t=n[e];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const a={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:a}}};let i=!1;return{[Symbol.iterator](){return this},next(){return i===!0?{done:!0}:(i=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function ua(n,e){if(n.size===0)return[];if(e==="mixed"||e===n.type)return Array.from(n._edges.keys());const t=e==="undirected"?n.undirectedSize:n.directedSize,i=new Array(t),a=e==="undirected",r=n._edges.values();let o=0,l,c;for(;l=r.next(),l.done!==!0;)c=l.value,c.undirected===a&&(i[o++]=c.key);return i}function Yn(n,e,t,i){if(e.size===0)return;const a=t!=="mixed"&&t!==e.type,r=t==="undirected";let o,l,c=!1;const d=e._edges.values();for(;o=d.next(),o.done!==!0;){if(l=o.value,a&&l.undirected!==r)continue;const{key:f,attributes:u,source:h,target:x}=l;if(c=i(f,u,h.key,x.key,h.attributes,x.attributes,l.undirected),n&&c)return f}}function ha(n,e){if(n.size===0)return st();const t=e!=="mixed"&&e!==n.type,i=e==="undirected",a=n._edges.values();return{[Symbol.iterator](){return this},next(){let r,o;for(;;){if(r=a.next(),r.done)return r;if(o=r.value,!(t&&o.undirected!==i))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function Xt(n,e,t,i,a,r){const o=e?la:oa;let l;if(t!=="undirected"&&(i!=="out"&&(l=o(n,a.in,r),n&&l)||i!=="in"&&(l=o(n,a.out,r,i?void 0:a.key),n&&l))||t!=="directed"&&(l=o(n,a.undirected,r),n&&l))return l}function fa(n,e,t,i){const a=[];return Xt(!1,n,e,t,i,function(r){a.push(r)}),a}function pa(n,e,t){let i=st();return n!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(i=De(i,It(t.in))),e!=="in"&&typeof t.out<"u"&&(i=De(i,It(t.out,e?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(i=De(i,It(t.undirected))),i}function Zt(n,e,t,i,a,r,o){const l=t?ca:da;let c;if(e!=="undirected"&&(typeof a.in<"u"&&i!=="out"&&(c=l(n,a.in,r,o),n&&c)||typeof a.out<"u"&&i!=="in"&&(i||a.key!==r)&&(c=l(n,a.out,r,o),n&&c))||e!=="directed"&&typeof a.undirected<"u"&&(c=l(n,a.undirected,r,o),n&&c))return c}function ma(n,e,t,i,a){const r=[];return Zt(!1,n,e,t,i,a,function(o){r.push(o)}),r}function ga(n,e,t,i){let a=st();return n!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&i in t.in&&(a=De(a,Mt(t.in,i))),typeof t.out<"u"&&e!=="in"&&i in t.out&&(e||t.key!==i)&&(a=De(a,Mt(t.out,i)))),n!=="directed"&&typeof t.undirected<"u"&&i in t.undirected&&(a=De(a,Mt(t.undirected,i))),a}function xa(n,e){const{name:t,type:i,direction:a}=e;n.prototype[t]=function(r,o){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];if(!arguments.length)return ua(this,i);if(arguments.length===1){r=""+r;const l=this._nodes.get(r);if(typeof l>"u")throw new v(`Graph.${t}: could not find the "${r}" node in the graph.`);return fa(this.multi,i==="mixed"?this.type:i,a,l)}if(arguments.length===2){r=""+r,o=""+o;const l=this._nodes.get(r);if(!l)throw new v(`Graph.${t}: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(o))throw new v(`Graph.${t}: could not find the "${o}" target node in the graph.`);return ma(i,this.multi,a,l,o)}throw new S(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function ba(n,e){const{name:t,type:i,direction:a}=e,r="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[r]=function(d,f,u){if(!(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)){if(arguments.length===1)return u=d,Yn(!1,this,i,u);if(arguments.length===2){d=""+d,u=f;const h=this._nodes.get(d);if(typeof h>"u")throw new v(`Graph.${r}: could not find the "${d}" node in the graph.`);return Xt(!1,this.multi,i==="mixed"?this.type:i,a,h,u)}if(arguments.length===3){d=""+d,f=""+f;const h=this._nodes.get(d);if(!h)throw new v(`Graph.${r}: could not find the "${d}" source node in the graph.`);if(!this._nodes.has(f))throw new v(`Graph.${r}: could not find the "${f}" target node in the graph.`);return Zt(!1,i,this.multi,a,h,f,u)}throw new S(`Graph.${r}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(){const d=Array.prototype.slice.call(arguments),f=d.pop();let u;if(d.length===0){let h=0;i!=="directed"&&(h+=this.undirectedSize),i!=="undirected"&&(h+=this.directedSize),u=new Array(h);let x=0;d.push((A,j,D,C,F,R,g)=>{u[x++]=f(A,j,D,C,F,R,g)})}else u=[],d.push((h,x,A,j,D,C,F)=>{u.push(f(h,x,A,j,D,C,F))});return this[r].apply(this,d),u};const l="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[l]=function(){const d=Array.prototype.slice.call(arguments),f=d.pop(),u=[];return d.push((h,x,A,j,D,C,F)=>{f(h,x,A,j,D,C,F)&&u.push(h)}),this[r].apply(this,d),u};const c="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[c]=function(){let d=Array.prototype.slice.call(arguments);if(d.length<2||d.length>4)throw new S(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${d.length}).`);if(typeof d[d.length-1]=="function"&&typeof d[d.length-2]!="function")throw new S(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let f,u;d.length===2?(f=d[0],u=d[1],d=[]):d.length===3?(f=d[1],u=d[2],d=[d[0]]):d.length===4&&(f=d[2],u=d[3],d=[d[0],d[1]]);let h=u;return d.push((x,A,j,D,C,F,R)=>{h=f(h,x,A,j,D,C,F,R)}),this[r].apply(this,d),h}}function ya(n,e){const{name:t,type:i,direction:a}=e,r="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[r]=function(c,d,f){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return!1;if(arguments.length===1)return f=c,Yn(!0,this,i,f);if(arguments.length===2){c=""+c,f=d;const u=this._nodes.get(c);if(typeof u>"u")throw new v(`Graph.${r}: could not find the "${c}" node in the graph.`);return Xt(!0,this.multi,i==="mixed"?this.type:i,a,u,f)}if(arguments.length===3){c=""+c,d=""+d;const u=this._nodes.get(c);if(!u)throw new v(`Graph.${r}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(d))throw new v(`Graph.${r}: could not find the "${d}" target node in the graph.`);return Zt(!0,i,this.multi,a,u,d,f)}throw new S(`Graph.${r}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(){const c=Array.prototype.slice.call(arguments),d=c.pop();return c.push((u,h,x,A,j,D,C)=>d(u,h,x,A,j,D,C)),!!this[r].apply(this,c)};const l="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[l]=function(){const c=Array.prototype.slice.call(arguments),d=c.pop();return c.push((u,h,x,A,j,D,C)=>!d(u,h,x,A,j,D,C)),!this[r].apply(this,c)}}function wa(n,e){const{name:t,type:i,direction:a}=e,r=t.slice(0,-1)+"Entries";n.prototype[r]=function(o,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return st();if(!arguments.length)return ha(this,i);if(arguments.length===1){o=""+o;const c=this._nodes.get(o);if(!c)throw new v(`Graph.${r}: could not find the "${o}" node in the graph.`);return pa(i,a,c)}if(arguments.length===2){o=""+o,l=""+l;const c=this._nodes.get(o);if(!c)throw new v(`Graph.${r}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(l))throw new v(`Graph.${r}: could not find the "${l}" target node in the graph.`);return ga(i,a,c,l)}throw new S(`Graph.${r}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function va(n){ra.forEach(e=>{xa(n,e),ba(n,e),ya(n,e),wa(n,e)})}const Na=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Tt(){this.A=null,this.B=null}Tt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};Tt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function ut(n,e,t,i,a){for(const r in i){const o=i[r],l=o.source,c=o.target,d=l===t?c:l;if(e&&e.has(d.key))continue;const f=a(d.key,d.attributes);if(n&&f)return d.key}}function Jt(n,e,t,i,a){if(e!=="mixed"){if(e==="undirected")return ut(n,null,i,i.undirected,a);if(typeof t=="string")return ut(n,null,i,i[t],a)}const r=new Tt;let o;if(e!=="undirected"){if(t!=="out"){if(o=ut(n,null,i,i.in,a),n&&o)return o;r.wrap(i.in)}if(t!=="in"){if(o=ut(n,r,i,i.out,a),n&&o)return o;r.wrap(i.out)}}if(e!=="directed"&&(o=ut(n,r,i,i.undirected,a),n&&o))return o}function ja(n,e,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const i=[];return Jt(!1,n,e,t,function(a){i.push(a)}),i}function ht(n,e,t){const i=Object.keys(t),a=i.length;let r=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(r>=a)return n&&n.wrap(t),{done:!0};const l=t[i[r++]],c=l.source,d=l.target;if(o=c===e?d:c,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function ka(n,e,t){if(n!=="mixed"){if(n==="undirected")return ht(null,t,t.undirected);if(typeof e=="string")return ht(null,t,t[e])}let i=st();const a=new Tt;return n!=="undirected"&&(e!=="out"&&(i=De(i,ht(a,t,t.in))),e!=="in"&&(i=De(i,ht(a,t,t.out)))),n!=="directed"&&(i=De(i,ht(a,t,t.undirected))),i}function Sa(n,e){const{name:t,type:i,direction:a}=e;n.prototype[t]=function(r){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];r=""+r;const o=this._nodes.get(r);if(typeof o>"u")throw new v(`Graph.${t}: could not find the "${r}" node in the graph.`);return ja(i==="mixed"?this.type:i,a,o)}}function Ea(n,e){const{name:t,type:i,direction:a}=e,r="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[r]=function(d,f){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;d=""+d;const u=this._nodes.get(d);if(typeof u>"u")throw new v(`Graph.${r}: could not find the "${d}" node in the graph.`);Jt(!1,i==="mixed"?this.type:i,a,u,f)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(d,f){const u=[];return this[r](d,(h,x)=>{u.push(f(h,x))}),u};const l="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[l]=function(d,f){const u=[];return this[r](d,(h,x)=>{f(h,x)&&u.push(h)}),u};const c="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[c]=function(d,f,u){if(arguments.length<3)throw new S(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h=u;return this[r](d,(x,A)=>{h=f(h,x,A)}),h}}function Aa(n,e){const{name:t,type:i,direction:a}=e,r=t[0].toUpperCase()+t.slice(1,-1),o="find"+r;n.prototype[o]=function(d,f){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;d=""+d;const u=this._nodes.get(d);if(typeof u>"u")throw new v(`Graph.${o}: could not find the "${d}" node in the graph.`);return Jt(!0,i==="mixed"?this.type:i,a,u,f)};const l="some"+r;n.prototype[l]=function(d,f){return!!this[o](d,f)};const c="every"+r;n.prototype[c]=function(d,f){return!this[o](d,(h,x)=>!f(h,x))}}function _a(n,e){const{name:t,type:i,direction:a}=e,r=t.slice(0,-1)+"Entries";n.prototype[r]=function(o){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return st();o=""+o;const l=this._nodes.get(o);if(typeof l>"u")throw new v(`Graph.${r}: could not find the "${o}" node in the graph.`);return ka(i==="mixed"?this.type:i,a,l)}}function $a(n){Na.forEach(e=>{Sa(n,e),Ea(n,e),Aa(n,e),_a(n,e)})}function St(n,e,t,i,a){const r=i._nodes.values(),o=i.type;let l,c,d,f,u,h;for(;l=r.next(),l.done!==!0;){let x=!1;if(c=l.value,o!=="undirected"){f=c.out;for(d in f){u=f[d];do h=u.target,x=!0,a(c.key,h.key,c.attributes,h.attributes,u.key,u.attributes,u.undirected),u=u.next;while(u)}}if(o!=="directed"){f=c.undirected;for(d in f)if(!(e&&c.key>d)){u=f[d];do h=u.target,h.key!==d&&(h=u.source),x=!0,a(c.key,h.key,c.attributes,h.attributes,u.key,u.attributes,u.undirected),u=u.next;while(u)}}t&&!x&&a(c.key,null,c.attributes,null,null,null,null)}}function La(n,e){const t={key:n};return Un(e.attributes)||(t.attributes=Z({},e.attributes)),t}function Ta(n,e,t){const i={key:e,source:t.source.key,target:t.target.key};return Un(t.attributes)||(i.attributes=Z({},t.attributes)),n==="mixed"&&t.undirected&&(i.undirected=!0),i}function Ga(n){if(!de(n))throw new S('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in n))throw new S("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!de(n.attributes)||n.attributes===null))throw new S("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Ca(n){if(!de(n))throw new S('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in n))throw new S("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new S("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!de(n.attributes)||n.attributes===null))throw new S("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new S("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Da=Ri(),Pa=new Set(["directed","undirected","mixed"]),Nn=new Set(["domain","_events","_eventsCount","_maxListeners"]),Ra=[{name:n=>`${n}Edge`,generateKey:!0},{name:n=>`${n}DirectedEdge`,generateKey:!0,type:"directed"},{name:n=>`${n}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:n=>`${n}EdgeWithKey`},{name:n=>`${n}DirectedEdgeWithKey`,type:"directed"},{name:n=>`${n}UndirectedEdgeWithKey`,type:"undirected"}],Ia={allowSelfLoops:!0,multi:!1,type:"mixed"};function Ma(n,e,t){if(t&&!de(t))throw new S(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},n._nodes.has(e))throw new $(`Graph.addNode: the "${e}" node already exist in the graph.`);const i=new n.NodeDataClass(e,t);return n._nodes.set(e,i),n.emit("nodeAdded",{key:e,attributes:t}),i}function jn(n,e,t){const i=new n.NodeDataClass(e,t);return n._nodes.set(e,i),n.emit("nodeAdded",{key:e,attributes:t}),i}function Qn(n,e,t,i,a,r,o,l){if(!i&&n.type==="undirected")throw new $(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(i&&n.type==="directed")throw new $(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(l&&!de(l))throw new S(`Graph.${e}: invalid attributes. Expecting an object but got "${l}"`);if(r=""+r,o=""+o,l=l||{},!n.allowSelfLoops&&r===o)throw new $(`Graph.${e}: source & target are the same ("${r}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=n._nodes.get(r),d=n._nodes.get(o);if(!c)throw new v(`Graph.${e}: source node "${r}" not found.`);if(!d)throw new v(`Graph.${e}: target node "${o}" not found.`);const f={key:null,undirected:i,source:r,target:o,attributes:l};if(t)a=n._edgeKeyGenerator();else if(a=""+a,n._edges.has(a))throw new $(`Graph.${e}: the "${a}" edge already exists in the graph.`);if(!n.multi&&(i?typeof c.undirected[o]<"u":typeof c.out[o]<"u"))throw new $(`Graph.${e}: an edge linking "${r}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const u=new it(i,a,c,d,l);n._edges.set(a,u);const h=r===o;return i?(c.undirectedDegree++,d.undirectedDegree++,h&&(c.undirectedLoops++,n._undirectedSelfLoopCount++)):(c.outDegree++,d.inDegree++,h&&(c.directedLoops++,n._directedSelfLoopCount++)),n.multi?u.attachMulti():u.attach(),i?n._undirectedSize++:n._directedSize++,f.key=a,n.emit("edgeAdded",f),a}function Oa(n,e,t,i,a,r,o,l,c){if(!i&&n.type==="undirected")throw new $(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&n.type==="directed")throw new $(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(l){if(c){if(typeof l!="function")throw new S(`Graph.${e}: invalid updater function. Expecting a function but got "${l}"`)}else if(!de(l))throw new S(`Graph.${e}: invalid attributes. Expecting an object but got "${l}"`)}r=""+r,o=""+o;let d;if(c&&(d=l,l=void 0),!n.allowSelfLoops&&r===o)throw new $(`Graph.${e}: source & target are the same ("${r}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let f=n._nodes.get(r),u=n._nodes.get(o),h,x;if(!t&&(h=n._edges.get(a),h)){if((h.source.key!==r||h.target.key!==o)&&(!i||h.source.key!==o||h.target.key!==r))throw new $(`Graph.${e}: inconsistency detected when attempting to merge the "${a}" edge with "${r}" source & "${o}" target vs. ("${h.source.key}", "${h.target.key}").`);x=h}if(!x&&!n.multi&&f&&(x=i?f.undirected[o]:f.out[o]),x){const F=[x.key,!1,!1,!1];if(c?!d:!l)return F;if(c){const R=x.attributes;x.attributes=d(R),n.emit("edgeAttributesUpdated",{type:"replace",key:x.key,attributes:x.attributes})}else Z(x.attributes,l),n.emit("edgeAttributesUpdated",{type:"merge",key:x.key,attributes:x.attributes,data:l});return F}l=l||{},c&&d&&(l=d(l));const A={key:null,undirected:i,source:r,target:o,attributes:l};if(t)a=n._edgeKeyGenerator();else if(a=""+a,n._edges.has(a))throw new $(`Graph.${e}: the "${a}" edge already exists in the graph.`);let j=!1,D=!1;f||(f=jn(n,r,{}),j=!0,r===o&&(u=f,D=!0)),u||(u=jn(n,o,{}),D=!0),h=new it(i,a,f,u,l),n._edges.set(a,h);const C=r===o;return i?(f.undirectedDegree++,u.undirectedDegree++,C&&(f.undirectedLoops++,n._undirectedSelfLoopCount++)):(f.outDegree++,u.inDegree++,C&&(f.directedLoops++,n._directedSelfLoopCount++)),n.multi?h.attachMulti():h.attach(),i?n._undirectedSize++:n._directedSize++,A.key=a,n.emit("edgeAdded",A),[a,!0,j,D]}function Qe(n,e){n._edges.delete(e.key);const{source:t,target:i,attributes:a}=e,r=e.undirected,o=t===i;r?(t.undirectedDegree--,i.undirectedDegree--,o&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,i.inDegree--,o&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?e.detachMulti():e.detach(),r?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:e.key,attributes:a,source:t.key,target:i.key,undirected:r})}class z extends Di.EventEmitter{constructor(e){if(super(),e=Z({},Ia,e),typeof e.multi!="boolean")throw new S(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Pa.has(e.type))throw new S(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new S(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?Bn:e.type==="directed"?Hn:Kn;Ne(this,"NodeDataClass",t);const i="geid_"+Da()+"_";let a=0;const r=()=>{let o;do o=i+a++;while(this._edges.has(o));return o};Ne(this,"_attributes",{}),Ne(this,"_nodes",new Map),Ne(this,"_edges",new Map),Ne(this,"_directedSize",0),Ne(this,"_undirectedSize",0),Ne(this,"_directedSelfLoopCount",0),Ne(this,"_undirectedSelfLoopCount",0),Ne(this,"_edgeKeyGenerator",r),Ne(this,"_options",e),Nn.forEach(o=>Ne(this,o,this[o])),$e(this,"order",()=>this._nodes.size),$e(this,"size",()=>this._edges.size),$e(this,"directedSize",()=>this._directedSize),$e(this,"undirectedSize",()=>this._undirectedSize),$e(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),$e(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),$e(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),$e(this,"multi",this._options.multi),$e(this,"type",this._options.type),$e(this,"allowSelfLoops",this._options.allowSelfLoops),$e(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){const i=""+e,a=this._edges.get(i);return!!a&&!a.undirected}else if(arguments.length===2){e=""+e,t=""+t;const i=this._nodes.get(e);return i?i.out.hasOwnProperty(t):!1}throw new S(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){const i=""+e,a=this._edges.get(i);return!!a&&a.undirected}else if(arguments.length===2){e=""+e,t=""+t;const i=this._nodes.get(e);return i?i.undirected.hasOwnProperty(t):!1}throw new S(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){const i=""+e;return this._edges.has(i)}else if(arguments.length===2){e=""+e,t=""+t;const i=this._nodes.get(e);return i?typeof i.out<"u"&&i.out.hasOwnProperty(t)||typeof i.undirected<"u"&&i.undirected.hasOwnProperty(t):!1}throw new S(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new $("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const i=this._nodes.get(e);if(!i)throw new v(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new v(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const a=i.out&&i.out[t]||void 0;if(a)return a.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new $("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const i=this._nodes.get(e);if(!i)throw new v(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new v(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const a=i.undirected&&i.undirected[t]||void 0;if(a)return a.key}edge(e,t){if(this.multi)throw new $("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new v(`Graph.edge: could not find the "${t}" target node in the graph.`);const a=i.out&&i.out[t]||i.undirected&&i.undirected[t]||void 0;if(a)return a.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.in||t in i.out}areOutNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.out}areInNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in i.undirected}areNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in i.in||t in i.out)||this.type!=="directed"&&t in i.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in i.in||this.type!=="directed"&&t in i.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in i.out||this.type!=="directed"&&t in i.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.inDegree),i}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.outDegree),i}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.degree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.inDegree+t.outDegree),i}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,a=0;return this.type!=="directed"&&(i+=t.undirectedDegree,a+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.inDegree,a+=t.directedLoops),i-a}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,a=0;return this.type!=="directed"&&(i+=t.undirectedDegree,a+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.outDegree,a+=t.directedLoops),i-a}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,a=0;return this.type!=="directed"&&(i+=t.undirectedDegree,a+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.inDegree+t.outDegree,a+=t.directedLoops*2),i-a}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const i=this._edges.get(t);if(!i)throw new v(`Graph.opposite: could not find the "${t}" edge in the graph.`);const a=i.source.key,r=i.target.key;if(e===a)return r;if(e===r)return a;throw new v(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${a}, ${r}).`)}hasExtremity(e,t){e=""+e,t=""+t;const i=this._edges.get(e);if(!i)throw new v(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return i.source.key===t||i.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return Ma(this,e,t).key}mergeNode(e,t){if(t&&!de(t))throw new S(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let i=this._nodes.get(e);return i?(t&&(Z(i.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:i.attributes,data:t})),[e,!1]):(i=new this.NodeDataClass(e,t),this._nodes.set(e,i),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new S(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let i=this._nodes.get(e);if(i){if(t){const r=i.attributes;i.attributes=t(r),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:i.attributes})}return[e,!1]}const a=t?t({}):{};return i=new this.NodeDataClass(e,a),this._nodes.set(e,i),this.emit("nodeAdded",{key:e,attributes:a}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.dropNode: could not find the "${e}" node in the graph.`);let i;if(this.type!=="undirected"){for(const a in t.out){i=t.out[a];do Qe(this,i),i=i.next;while(i)}for(const a in t.in){i=t.in[a];do Qe(this,i),i=i.next;while(i)}}if(this.type!=="directed")for(const a in t.undirected){i=t.undirected[a];do Qe(this,i),i=i.next;while(i)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const i=""+arguments[0],a=""+arguments[1];if(t=Se(this,i,a,this.type),!t)throw new v(`Graph.dropEdge: could not find the "${i}" -> "${a}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new v(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Qe(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new $("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new $("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;const i=Se(this,e,t,"directed");if(!i)throw new v(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Qe(this,i),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new $("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new $("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const i=Se(this,e,t,"undirected");if(!i)throw new v(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Qe(this,i),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new S("Graph.updateAttribute: updater should be a function.");const i=this._attributes[e];return this._attributes[e]=t(i),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!de(e))throw new S("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!de(e))throw new S("Graph.mergeAttributes: provided attributes are not a plain object.");return Z(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new S("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new S("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!vn(t))throw new S("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._nodes.values();let a,r;for(;a=i.next(),a.done!==!0;)r=a.value,r.attributes=e(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new S("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!vn(t))throw new S("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._edges.values();let a,r,o,l;for(;a=i.next(),a.done!==!0;)r=a.value,o=r.source,l=r.target,r.attributes=e(r.key,r.attributes,o.key,l.key,o.attributes,l.attributes,r.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new S("Graph.forEachAdjacencyEntry: expecting a callback.");St(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new S("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");St(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new S("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");St(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new S("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");St(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new S("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let i,a;for(;i=t.next(),i.done!==!0;)a=i.value,e(a.key,a.attributes)}findNode(e){if(typeof e!="function")throw new S("Graph.findNode: expecting a callback.");const t=this._nodes.values();let i,a;for(;i=t.next(),i.done!==!0;)if(a=i.value,e(a.key,a.attributes))return a.key}mapNodes(e){if(typeof e!="function")throw new S("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let i,a;const r=new Array(this.order);let o=0;for(;i=t.next(),i.done!==!0;)a=i.value,r[o++]=e(a.key,a.attributes);return r}someNode(e){if(typeof e!="function")throw new S("Graph.someNode: expecting a callback.");const t=this._nodes.values();let i,a;for(;i=t.next(),i.done!==!0;)if(a=i.value,e(a.key,a.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new S("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let i,a;for(;i=t.next(),i.done!==!0;)if(a=i.value,!e(a.key,a.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new S("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let i,a;const r=[];for(;i=t.next(),i.done!==!0;)a=i.value,e(a.key,a.attributes)&&r.push(a.key);return r}reduceNodes(e,t){if(typeof e!="function")throw new S("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new S("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let i=t;const a=this._nodes.values();let r,o;for(;r=a.next(),r.done!==!0;)o=r.value,i=e(i,o.key,o.attributes);return i}nodeEntries(){const e=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return t;const i=t.value;return{value:{node:i.key,attributes:i.attributes},done:!1}}}}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((a,r)=>{e[t++]=La(r,a)});const i=new Array(this._edges.size);return t=0,this._edges.forEach((a,r)=>{i[t++]=Ta(this.type,r,a)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:i}}import(e,t=!1){if(e instanceof z)return e.forEachNode((c,d)=>{t?this.mergeNode(c,d):this.addNode(c,d)}),e.forEachEdge((c,d,f,u,h,x,A)=>{t?A?this.mergeUndirectedEdgeWithKey(c,f,u,d):this.mergeDirectedEdgeWithKey(c,f,u,d):A?this.addUndirectedEdgeWithKey(c,f,u,d):this.addDirectedEdgeWithKey(c,f,u,d)}),this;if(!de(e))throw new S("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!de(e.attributes))throw new S("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let i,a,r,o,l;if(e.nodes){if(r=e.nodes,!Array.isArray(r))throw new S("Graph.import: invalid nodes. Expecting an array.");for(i=0,a=r.length;i<a;i++){o=r[i],Ga(o);const{key:c,attributes:d}=o;t?this.mergeNode(c,d):this.addNode(c,d)}}if(e.edges){let c=!1;if(this.type==="undirected"&&(c=!0),r=e.edges,!Array.isArray(r))throw new S("Graph.import: invalid edges. Expecting an array.");for(i=0,a=r.length;i<a;i++){l=r[i],Ca(l);const{source:d,target:f,attributes:u,undirected:h=c}=l;let x;"key"in l?(x=t?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,x.call(this,l.key,d,f,u)):(x=t?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,x.call(this,d,f,u))}}return this}nullCopy(e){const t=new z(Z({},this._options,e));return t.replaceAttributes(Z({},this.getAttributes())),t}emptyCopy(e){const t=this.nullCopy(e);return this._nodes.forEach((i,a)=>{const r=Z({},i.attributes);i=new t.NodeDataClass(a,r),t._nodes.set(a,i)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new $(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new $("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new $("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),i=this._edges.values();let a,r;for(;a=i.next(),a.done!==!0;)r=a.value,Qn(t,"copy",!1,r.undirected,r.key,r.source.key,r.target.key,Z({},r.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((r,o)=>{e[o]=r.attributes});const t={},i={};this._edges.forEach((r,o)=>{const l=r.undirected?"--":"->";let c="",d=r.source.key,f=r.target.key,u;r.undirected&&d>f&&(u=d,d=f,f=u);const h=`(${d})${l}(${f})`;o.startsWith("geid_")?this.multi&&(typeof i[h]>"u"?i[h]=0:i[h]++,c+=`${i[h]}. `):c+=`[${o}]: `,c+=h,t[c]=r.attributes});const a={};for(const r in this)this.hasOwnProperty(r)&&!Nn.has(r)&&typeof this[r]!="function"&&typeof r!="symbol"&&(a[r]=this[r]);return a.attributes=this._attributes,a.nodes=e,a.edges=t,Ne(a,"constructor",this.constructor),a}}typeof Symbol<"u"&&(z.prototype[Symbol.for("nodejs.util.inspect.custom")]=z.prototype.inspect);Ra.forEach(n=>{["add","merge","update"].forEach(e=>{const t=n.name(e),i=e==="add"?Qn:Oa;n.generateKey?z.prototype[t]=function(a,r,o){return i(this,t,!0,(n.type||this.type)==="undirected",null,a,r,o,e==="update")}:z.prototype[t]=function(a,r,o,l){return i(this,t,!1,(n.type||this.type)==="undirected",a,r,o,l,e==="update")}})});Vi(z);aa(z);va(z);$a(z);class Xn extends z{constructor(e){const t=Z({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new S("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new S('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Zn extends z{constructor(e){const t=Z({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new S("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new S('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Jn extends z{constructor(e){const t=Z({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class en extends z{constructor(e){const t=Z({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new S('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class es extends z{constructor(e){const t=Z({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new S('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function at(n){n.from=function(e,t){const i=Z({},e.options,t),a=new n(i);return a.import(e),a}}at(z);at(Xn);at(Zn);at(Jn);at(en);at(es);z.Graph=z;z.DirectedGraph=Xn;z.UndirectedGraph=Zn;z.MultiGraph=Jn;z.MultiDirectedGraph=en;z.MultiUndirectedGraph=es;z.InvalidArgumentsGraphError=S;z.NotFoundGraphError=v;z.UsageGraphError=$;const Oe={eligible:{property:"--chart-site-health-eligible",fallback:"#56b4e9"},hidden:{property:"--chart-site-health-hidden",fallback:"#e69f00"},resource:{property:"--chart-site-health-resource",fallback:"#d4d4d8"},redirect:{property:"--chart-site-health-redirect",fallback:"#9aa7b8"},failed:{property:"--chart-site-health-failed",fallback:"#d55e00"},unchecked:{property:"--chart-site-health-unchecked",fallback:"#a1a1aa"}},za={property:"--chart-neutral-text-dim",fallback:"#71717a"},kn=2.5,Fa=9,Sn=200,Ua=3,Ba=1.6;function ts(n){const e=Sn/Math.max(Sn,n);return Math.max(Ua,Fa*e**.25)}function Ha(n){return ts(n)*Ba}const Ka={eligible:Oe.eligible,hidden:Oe.hidden,resource:Oe.resource,redirect:Oe.redirect,failed:Oe.failed,unchecked:Oe.unchecked,dimmedNode:{property:"--chart-neutral-text-dim",fallback:"#71717a"},edge:za,edgeDimmed:{property:"--chart-neutral-text-faint",fallback:"#52525b"},edgeActive:{property:"--chart-neutral-text",fallback:"#a1a1aa"},label:{property:"--chart-tooltip-label",fallback:"#e4e4e7"},background:{property:"--chart-tooltip-bg",fallback:"#18181b"}},Wa=/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i,qa=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)$/;function En(n){return Wa.test(n)||qa.test(n)}const An=50,Va=8,gt=.75,Ya=[{maxRatio:.2,budget:Number.POSITIVE_INFINITY},{maxRatio:.45,budget:60},{maxRatio:gt,budget:24}],Qa=1;function Kt(n){for(const e of Ya)if(n<=e.maxRatio)return e.budget;return Qa}function nt(n,e){return n<e?-1:n>e?1:0}function Xa(n){return Math.max(0,Math.min(1,n.linkScoreNormalized??0))}function et(n){return n.healthState?n.healthState:Os(n)}function Wt(n){switch(n){case"eligible":return"Indexable";case"hidden":return"Hidden";case"resource":return"Not a page";case"redirect":return"Moved";case"failed":return"Broken";case"unchecked":return"Not checked"}}function Za(n){switch(n){case"eligible":return"Indexable";case"hidden":return"Hidden or points elsewhere";case"resource":return"Not a page";case"redirect":return"Moved";case"failed":return"Broken";case"unchecked":return"Not checked"}}function tt(n){switch(n){case"eligible":return"AI and search engines are allowed to index this page";case"hidden":return"This page tells them not to index it, or points them to another page";case"resource":return"A file rather than a page, such as a text file or a PDF. Answer engines can still read it";case"redirect":return"This address sends visitors to another page";case"failed":return"This page could not be loaded";case"unchecked":return"This page was found but not checked"}}function qt(n){switch(n){case"eligible":return"●";case"hidden":return"◆";case"resource":return"▪";case"redirect":return"↗";case"failed":return"×";case"unchecked":return"○"}}function Ja(n,e){return!!e&&n.nodeKey===e}function er(n,e=!1,t=1){const i=ts(t),a=kn+Math.sqrt(Xa(n))*(i-kn);return e?Math.max(Ha(t),a):a}function tr(n,e){switch(n){case"eligible":return e.eligible;case"hidden":return e.hidden;case"resource":return e.resource;case"redirect":return e.redirect;case"failed":return e.failed;case"unchecked":return e.unchecked}}function nr(n){return .35+Math.min(1.65,Math.log2(Math.max(1,n)+1)*.28)}function ns(n){return Number.isFinite(n.x)&&Number.isFinite(n.y)}function sr(n,e,t,i=null){const a=new en({allowSelfLoops:!0}),r=new Map;for(const l of n)r.has(l.nodeKey)||r.set(l.nodeKey,l);for(const l of[...r.values()].sort((c,d)=>nt(c.nodeKey,d.nodeKey))){if(!ns(l))continue;const c=et(l),d=tr(c,t),f=qt(c),u=Ja(l,i);a.addNode(l.nodeKey,{x:l.x,y:l.y,size:er(l,u,r.size),color:d,baseColor:d,label:`${f} ${l.path||"/"}`,nodeKey:l.nodeKey,url:l.url,path:l.path,depth:l.depth,status:c,glyph:f,forceLabel:u||l.depth===0||l.path.trim()==="/",zIndex:u?2:l.depth===0?1:0,isRoot:u})}const o=new Set;for(const l of[...e].sort((c,d)=>nt(c.edgeKey,d.edgeKey)))o.has(l.edgeKey)||!l.targetNodeKey||!a.hasNode(l.sourceNodeKey)||!a.hasNode(l.targetNodeKey)||(o.add(l.edgeKey),a.addDirectedEdgeWithKey(l.edgeKey,l.sourceNodeKey,l.targetNodeKey,{size:nr(l.occurrences),color:t.edge,baseColor:t.edge,followable:l.followable,occurrences:l.occurrences,isTemplate:l.isTemplate===!0,type:"line",zIndex:0}));return{graph:a,layoutAvailable:n.length===0||a.order>0,omittedNodes:Math.max(0,n.length-a.order),omittedEdges:Math.max(0,e.length-a.size)}}function ir(n,e,t=An){const i=e.trim().toLocaleLowerCase(),a=Math.max(0,Math.min(An,Math.floor(t)));return[...n].sort((r,o)=>nt(r.path||r.url,o.path||o.url)||nt(r.nodeKey,o.nodeKey)).filter(r=>ns(r)?i?`${r.path}
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./react-sigma_core.esm.min-DOhuYLQj.js","./vendor-tanstack-ZXXkndVj.js","./index-DTrkuKOh.js","./vendor-radix-twS1M3FF.js","./vendor-recharts-llkUFBGR.js","./vendor-lucide-CneDbhOr.js","./vendor-markdown-B-Oq2NYq.js","./vendor-yaml-GWJz5H2G.js","./index-PT4UiPTM.css","./ChartPrimitives-BQC2VH0O.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as w,j as s,u as me,C as Cn}from"./vendor-tanstack-ZXXkndVj.js";import{fc as Os,fd as zs,B as M,fe as He,ff as Fs,T as X,x as Dn,fg as $t,ac as Ke,fh as Us,fi as Bs,fj as Hs,ba as Ks,fk as Pn,ae as Ws,af as hn,U as Pt,fl as Rn,fm as In,f as qs,k as zt,ah as Ft,I as fe,j as le,fn as Vs,fo as fn,l as Ys,e2 as Qs,fp as Xs,fq as Zs,fr as Js,fs as ei,ft as ti,fu as ni,fv as si,fw as pn,fx as ii,fy as ai,fz as Ut,e6 as ri,fA as oi,fB as li,fC as di,fD as Ye,fE as ci,fF as ui}from"./index-DTrkuKOh.js";import{S as Yt,q as hi,J as fi,c as pi,f as Lt,X as mi,_ as gi,L as je,T as Bt,x as Rt,$ as mn,P as Ht,C as Mn,a0 as xi,E as bi}from"./vendor-lucide-CneDbhOr.js";import{C as yi,a as gn,b as xn,d as wi,h as bn,i as vi,j as Ni,o as On}from"./ChartPrimitives-BQC2VH0O.js";import{R as ji,C as ki,a as Si,X as Ei,Y as Ai,T as _i,d as $i}from"./vendor-recharts-llkUFBGR.js";const Li=/^www\./i;function zn(n){if(!n)return null;try{return new URL(n).hostname}catch{return null}}function yn(n){return n.trim().toLowerCase().replace(Li,"")}function Ti(n,e){if(!e)return!1;try{return yn(new URL(n).hostname)===yn(e)}catch{return!1}}function Fn(n,e){if(!n)return"";if(!Ti(n,e))return n;const t=new URL(n),i=`${t.pathname}${t.search}${t.hash}`;return i===""?"/":i}function Gi(n,e){return Fn(n.url,e)||n.path||"/"}var kt={exports:{}},wn;function Ci(){if(wn)return kt.exports;wn=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(m,b,N){return Function.prototype.apply.call(m,b,N)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(m){return Object.getOwnPropertyNames(m).concat(Object.getOwnPropertySymbols(m))}:t=function(m){return Object.getOwnPropertyNames(m)};function i(g){console&&console.warn&&console.warn(g)}var a=Number.isNaN||function(m){return m!==m};function r(){r.init.call(this)}kt.exports=r,kt.exports.once=C,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var o=10;function l(g){if(typeof g!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof g)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(g){if(typeof g!="number"||g<0||a(g))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+g+".");o=g}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(m){if(typeof m!="number"||m<0||a(m))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+m+".");return this._maxListeners=m,this};function c(g){return g._maxListeners===void 0?r.defaultMaxListeners:g._maxListeners}r.prototype.getMaxListeners=function(){return c(this)},r.prototype.emit=function(m){for(var b=[],N=1;N<arguments.length;N++)b.push(arguments[N]);var _=m==="error",G=this._events;if(G!==void 0)_=_&&G.error===void 0;else if(!_)return!1;if(_){var P;if(b.length>0&&(P=b[0]),P instanceof Error)throw P;var U=new Error("Unhandled error."+(P?" ("+P.message+")":""));throw U.context=P,U}var Q=G[m];if(Q===void 0)return!1;if(typeof Q=="function")e(Q,this,b);else for(var Y=Q.length,se=A(Q,Y),N=0;N<Y;++N)e(se[N],this,b);return!0};function d(g,m,b,N){var _,G,P;if(l(b),G=g._events,G===void 0?(G=g._events=Object.create(null),g._eventsCount=0):(G.newListener!==void 0&&(g.emit("newListener",m,b.listener?b.listener:b),G=g._events),P=G[m]),P===void 0)P=G[m]=b,++g._eventsCount;else if(typeof P=="function"?P=G[m]=N?[b,P]:[P,b]:N?P.unshift(b):P.push(b),_=c(g),_>0&&P.length>_&&!P.warned){P.warned=!0;var U=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+String(m)+" listeners added. Use emitter.setMaxListeners() to increase limit");U.name="MaxListenersExceededWarning",U.emitter=g,U.type=m,U.count=P.length,i(U)}return g}r.prototype.addListener=function(m,b){return d(this,m,b,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(m,b){return d(this,m,b,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(g,m,b){var N={fired:!1,wrapFn:void 0,target:g,type:m,listener:b},_=f.bind(N);return _.listener=b,N.wrapFn=_,_}r.prototype.once=function(m,b){return l(b),this.on(m,u(this,m,b)),this},r.prototype.prependOnceListener=function(m,b){return l(b),this.prependListener(m,u(this,m,b)),this},r.prototype.removeListener=function(m,b){var N,_,G,P,U;if(l(b),_=this._events,_===void 0)return this;if(N=_[m],N===void 0)return this;if(N===b||N.listener===b)--this._eventsCount===0?this._events=Object.create(null):(delete _[m],_.removeListener&&this.emit("removeListener",m,N.listener||b));else if(typeof N!="function"){for(G=-1,P=N.length-1;P>=0;P--)if(N[P]===b||N[P].listener===b){U=N[P].listener,G=P;break}if(G<0)return this;G===0?N.shift():j(N,G),N.length===1&&(_[m]=N[0]),_.removeListener!==void 0&&this.emit("removeListener",m,U||b)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(m){var b,N,_;if(N=this._events,N===void 0)return this;if(N.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):N[m]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete N[m]),this;if(arguments.length===0){var G=Object.keys(N),P;for(_=0;_<G.length;++_)P=G[_],P!=="removeListener"&&this.removeAllListeners(P);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(b=N[m],typeof b=="function")this.removeListener(m,b);else if(b!==void 0)for(_=b.length-1;_>=0;_--)this.removeListener(m,b[_]);return this};function h(g,m,b){var N=g._events;if(N===void 0)return[];var _=N[m];return _===void 0?[]:typeof _=="function"?b?[_.listener||_]:[_]:b?D(_):A(_,_.length)}r.prototype.listeners=function(m){return h(this,m,!0)},r.prototype.rawListeners=function(m){return h(this,m,!1)},r.listenerCount=function(g,m){return typeof g.listenerCount=="function"?g.listenerCount(m):x.call(g,m)},r.prototype.listenerCount=x;function x(g){var m=this._events;if(m!==void 0){var b=m[g];if(typeof b=="function")return 1;if(b!==void 0)return b.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function A(g,m){for(var b=new Array(m),N=0;N<m;++N)b[N]=g[N];return b}function j(g,m){for(;m+1<g.length;m++)g[m]=g[m+1];g.pop()}function D(g){for(var m=new Array(g.length),b=0;b<m.length;++b)m[b]=g[b].listener||g[b];return m}function C(g,m){return new Promise(function(b,N){function _(P){g.removeListener(m,G),N(P)}function G(){typeof g.removeListener=="function"&&g.removeListener("error",_),b([].slice.call(arguments))}R(g,m,G,{once:!0}),m!=="error"&&F(g,_,{once:!0})})}function F(g,m,b){typeof g.on=="function"&&R(g,"error",m,b)}function R(g,m,b,N){if(typeof g.on=="function")N.once?g.once(m,b):g.on(m,b);else if(typeof g.addEventListener=="function")g.addEventListener(m,function _(G){N.once&&g.removeEventListener(m,_),b(G)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof g)}return kt.exports}var Di=Ci();function Pi(){const n=arguments[0];for(let e=1,t=arguments.length;e<t;e++)if(arguments[e])for(const i in arguments[e])n[i]=arguments[e][i];return n}let Z=Pi;typeof Object.assign=="function"&&(Z=Object.assign);function Se(n,e,t,i){const a=n._nodes.get(e);let r=null;return a&&(i==="mixed"?r=a.out&&a.out[t]||a.undirected&&a.undirected[t]:i==="directed"?r=a.out&&a.out[t]:r=a.undirected&&a.undirected[t]),r}function de(n){return typeof n=="object"&&n!==null}function Un(n){let e;for(e in n)return!1;return!0}function Ne(n,e,t){Object.defineProperty(n,e,{enumerable:!1,configurable:!1,writable:!0,value:t})}function $e(n,e,t){const i={enumerable:!0,configurable:!0};typeof t=="function"?i.get=t:(i.value=t,i.writable=!1),Object.defineProperty(n,e,i)}function vn(n){return!(!de(n)||n.attributes&&!Array.isArray(n.attributes))}function Ri(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function De(){const n=arguments;let e=null,t=-1;return{[Symbol.iterator](){return this},next(){let i=null;do{if(e===null){if(t++,t>=n.length)return{done:!0};e=n[t][Symbol.iterator]()}if(i=e.next(),i.done){e=null;continue}break}while(!0);return i}}}function st(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Qt extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class S extends Qt{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,S.prototype.constructor)}}class v extends Qt{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,v.prototype.constructor)}}class $ extends Qt{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,$.prototype.constructor)}}function Bn(n,e){this.key=n,this.attributes=e,this.clear()}Bn.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Hn(n,e){this.key=n,this.attributes=e,this.clear()}Hn.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Kn(n,e){this.key=n,this.attributes=e,this.clear()}Kn.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function it(n,e,t,i,a){this.key=e,this.attributes=a,this.undirected=n,this.source=t,this.target=i}it.prototype.attach=function(){let n="out",e="in";this.undirected&&(n=e="undirected");const t=this.source.key,i=this.target.key;this.source[n][i]=this,!(this.undirected&&t===i)&&(this.target[e][t]=this)};it.prototype.attachMulti=function(){let n="out",e="in";const t=this.source.key,i=this.target.key;this.undirected&&(n=e="undirected");const a=this.source[n],r=a[i];if(typeof r>"u"){a[i]=this,this.undirected&&t===i||(this.target[e][t]=this);return}r.previous=this,this.next=r,a[i]=this,this.target[e][t]=this};it.prototype.detach=function(){const n=this.source.key,e=this.target.key;let t="out",i="in";this.undirected&&(t=i="undirected"),delete this.source[t][e],delete this.target[i][n]};it.prototype.detachMulti=function(){const n=this.source.key,e=this.target.key;let t="out",i="in";this.undirected&&(t=i="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[i][n]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[i][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Wn=0,qn=1,Ii=2,Vn=3;function Pe(n,e,t,i,a,r,o){let l,c,d,f;if(i=""+i,t===Wn){if(l=n._nodes.get(i),!l)throw new v(`Graph.${e}: could not find the "${i}" node in the graph.`);d=a,f=r}else if(t===Vn){if(a=""+a,c=n._edges.get(a),!c)throw new v(`Graph.${e}: could not find the "${a}" edge in the graph.`);const u=c.source.key,h=c.target.key;if(i===u)l=c.target;else if(i===h)l=c.source;else throw new v(`Graph.${e}: the "${i}" node is not attached to the "${a}" edge (${u}, ${h}).`);d=r,f=o}else{if(c=n._edges.get(i),!c)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`);t===qn?l=c.source:l=c.target,d=a,f=r}return[l,d,f]}function Mi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);return o.attributes[l]}}function Oi(n,e,t){n.prototype[e]=function(i,a){const[r]=Pe(this,e,t,i,a);return r.attributes}}function zi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);return o.attributes.hasOwnProperty(l)}}function Fi(n,e,t){n.prototype[e]=function(i,a,r,o){const[l,c,d]=Pe(this,e,t,i,a,r,o);return l.attributes[c]=d,this.emit("nodeAttributesUpdated",{key:l.key,type:"set",attributes:l.attributes,name:c}),this}}function Ui(n,e,t){n.prototype[e]=function(i,a,r,o){const[l,c,d]=Pe(this,e,t,i,a,r,o);if(typeof d!="function")throw new S(`Graph.${e}: updater should be a function.`);const f=l.attributes,u=d(f[c]);return f[c]=u,this.emit("nodeAttributesUpdated",{key:l.key,type:"set",attributes:l.attributes,name:c}),this}}function Bi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);return delete o.attributes[l],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:l}),this}}function Hi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);if(!de(l))throw new S(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=l,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ki(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);if(!de(l))throw new S(`Graph.${e}: provided attributes are not a plain object.`);return Z(o.attributes,l),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:l}),this}}function Wi(n,e,t){n.prototype[e]=function(i,a,r){const[o,l]=Pe(this,e,t,i,a,r);if(typeof l!="function")throw new S(`Graph.${e}: provided updater is not a function.`);return o.attributes=l(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const qi=[{name:n=>`get${n}Attribute`,attacher:Mi},{name:n=>`get${n}Attributes`,attacher:Oi},{name:n=>`has${n}Attribute`,attacher:zi},{name:n=>`set${n}Attribute`,attacher:Fi},{name:n=>`update${n}Attribute`,attacher:Ui},{name:n=>`remove${n}Attribute`,attacher:Bi},{name:n=>`replace${n}Attributes`,attacher:Hi},{name:n=>`merge${n}Attributes`,attacher:Ki},{name:n=>`update${n}Attributes`,attacher:Wi}];function Vi(n){qi.forEach(function({name:e,attacher:t}){t(n,e("Node"),Wn),t(n,e("Source"),qn),t(n,e("Target"),Ii),t(n,e("Opposite"),Vn)})}function Yi(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return r.attributes[a]}}function Qi(n,e,t){n.prototype[e]=function(i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const r=""+i,o=""+arguments[1];if(a=Se(this,r,o,t),!a)throw new v(`Graph.${e}: could not find an edge for the given path ("${r}" - "${o}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,a=this._edges.get(i),!a)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return a.attributes}}function Xi(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return r.attributes.hasOwnProperty(a)}}function Zi(n,e,t){n.prototype[e]=function(i,a,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const l=""+i,c=""+a;if(a=arguments[2],r=arguments[3],o=Se(this,l,c,t),!o)throw new v(`Graph.${e}: could not find an edge for the given path ("${l}" - "${c}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return o.attributes[a]=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:a}),this}}function Ji(n,e,t){n.prototype[e]=function(i,a,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const l=""+i,c=""+a;if(a=arguments[2],r=arguments[3],o=Se(this,l,c,t),!o)throw new v(`Graph.${e}: could not find an edge for the given path ("${l}" - "${c}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,o=this._edges.get(i),!o)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(typeof r!="function")throw new S(`Graph.${e}: updater should be a function.`);return o.attributes[a]=r(o.attributes[a]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:a}),this}}function ea(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}return delete r.attributes[a],this.emit("edgeAttributesUpdated",{key:r.key,type:"remove",attributes:r.attributes,name:a}),this}}function ta(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(!de(a))throw new S(`Graph.${e}: provided attributes are not a plain object.`);return r.attributes=a,this.emit("edgeAttributesUpdated",{key:r.key,type:"replace",attributes:r.attributes}),this}}function na(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(!de(a))throw new S(`Graph.${e}: provided attributes are not a plain object.`);return Z(r.attributes,a),this.emit("edgeAttributesUpdated",{key:r.key,type:"merge",attributes:r.attributes,data:a}),this}}function sa(n,e,t){n.prototype[e]=function(i,a){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+i,l=""+a;if(a=arguments[2],r=Se(this,o,l,t),!r)throw new v(`Graph.${e}: could not find an edge for the given path ("${o}" - "${l}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(i=""+i,r=this._edges.get(i),!r)throw new v(`Graph.${e}: could not find the "${i}" edge in the graph.`)}if(typeof a!="function")throw new S(`Graph.${e}: provided updater is not a function.`);return r.attributes=a(r.attributes),this.emit("edgeAttributesUpdated",{key:r.key,type:"update",attributes:r.attributes}),this}}const ia=[{name:n=>`get${n}Attribute`,attacher:Yi},{name:n=>`get${n}Attributes`,attacher:Qi},{name:n=>`has${n}Attribute`,attacher:Xi},{name:n=>`set${n}Attribute`,attacher:Zi},{name:n=>`update${n}Attribute`,attacher:Ji},{name:n=>`remove${n}Attribute`,attacher:ea},{name:n=>`replace${n}Attributes`,attacher:ta},{name:n=>`merge${n}Attributes`,attacher:na},{name:n=>`update${n}Attributes`,attacher:sa}];function aa(n){ia.forEach(function({name:e,attacher:t}){t(n,e("Edge"),"mixed"),t(n,e("DirectedEdge"),"directed"),t(n,e("UndirectedEdge"),"undirected")})}const ra=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function oa(n,e,t,i){let a=!1;for(const r in e){if(r===i)continue;const o=e[r];if(a=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),n&&a)return o.key}}function la(n,e,t,i){let a,r,o,l=!1;for(const c in e)if(c!==i){a=e[c];do{if(r=a.source,o=a.target,l=t(a.key,a.attributes,r.key,o.key,r.attributes,o.attributes,a.undirected),n&&l)return a.key;a=a.next}while(a!==void 0)}}function It(n,e){const t=Object.keys(n),i=t.length;let a,r=0;return{[Symbol.iterator](){return this},next(){do if(a)a=a.next;else{if(r>=i)return{done:!0};const o=t[r++];if(o===e){a=void 0;continue}a=n[o]}while(!a);return{done:!1,value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected}}}}}function da(n,e,t,i){const a=e[t];if(!a)return;const r=a.source,o=a.target;if(i(a.key,a.attributes,r.key,o.key,r.attributes,o.attributes,a.undirected)&&n)return a.key}function ca(n,e,t,i){let a=e[t];if(!a)return;let r=!1;do{if(r=i(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),n&&r)return a.key;a=a.next}while(a!==void 0)}function Mt(n,e){let t=n[e];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const a={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:a}}};let i=!1;return{[Symbol.iterator](){return this},next(){return i===!0?{done:!0}:(i=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function ua(n,e){if(n.size===0)return[];if(e==="mixed"||e===n.type)return Array.from(n._edges.keys());const t=e==="undirected"?n.undirectedSize:n.directedSize,i=new Array(t),a=e==="undirected",r=n._edges.values();let o=0,l,c;for(;l=r.next(),l.done!==!0;)c=l.value,c.undirected===a&&(i[o++]=c.key);return i}function Yn(n,e,t,i){if(e.size===0)return;const a=t!=="mixed"&&t!==e.type,r=t==="undirected";let o,l,c=!1;const d=e._edges.values();for(;o=d.next(),o.done!==!0;){if(l=o.value,a&&l.undirected!==r)continue;const{key:f,attributes:u,source:h,target:x}=l;if(c=i(f,u,h.key,x.key,h.attributes,x.attributes,l.undirected),n&&c)return f}}function ha(n,e){if(n.size===0)return st();const t=e!=="mixed"&&e!==n.type,i=e==="undirected",a=n._edges.values();return{[Symbol.iterator](){return this},next(){let r,o;for(;;){if(r=a.next(),r.done)return r;if(o=r.value,!(t&&o.undirected!==i))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function Xt(n,e,t,i,a,r){const o=e?la:oa;let l;if(t!=="undirected"&&(i!=="out"&&(l=o(n,a.in,r),n&&l)||i!=="in"&&(l=o(n,a.out,r,i?void 0:a.key),n&&l))||t!=="directed"&&(l=o(n,a.undirected,r),n&&l))return l}function fa(n,e,t,i){const a=[];return Xt(!1,n,e,t,i,function(r){a.push(r)}),a}function pa(n,e,t){let i=st();return n!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(i=De(i,It(t.in))),e!=="in"&&typeof t.out<"u"&&(i=De(i,It(t.out,e?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(i=De(i,It(t.undirected))),i}function Zt(n,e,t,i,a,r,o){const l=t?ca:da;let c;if(e!=="undirected"&&(typeof a.in<"u"&&i!=="out"&&(c=l(n,a.in,r,o),n&&c)||typeof a.out<"u"&&i!=="in"&&(i||a.key!==r)&&(c=l(n,a.out,r,o),n&&c))||e!=="directed"&&typeof a.undirected<"u"&&(c=l(n,a.undirected,r,o),n&&c))return c}function ma(n,e,t,i,a){const r=[];return Zt(!1,n,e,t,i,a,function(o){r.push(o)}),r}function ga(n,e,t,i){let a=st();return n!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&i in t.in&&(a=De(a,Mt(t.in,i))),typeof t.out<"u"&&e!=="in"&&i in t.out&&(e||t.key!==i)&&(a=De(a,Mt(t.out,i)))),n!=="directed"&&typeof t.undirected<"u"&&i in t.undirected&&(a=De(a,Mt(t.undirected,i))),a}function xa(n,e){const{name:t,type:i,direction:a}=e;n.prototype[t]=function(r,o){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];if(!arguments.length)return ua(this,i);if(arguments.length===1){r=""+r;const l=this._nodes.get(r);if(typeof l>"u")throw new v(`Graph.${t}: could not find the "${r}" node in the graph.`);return fa(this.multi,i==="mixed"?this.type:i,a,l)}if(arguments.length===2){r=""+r,o=""+o;const l=this._nodes.get(r);if(!l)throw new v(`Graph.${t}: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(o))throw new v(`Graph.${t}: could not find the "${o}" target node in the graph.`);return ma(i,this.multi,a,l,o)}throw new S(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function ba(n,e){const{name:t,type:i,direction:a}=e,r="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[r]=function(d,f,u){if(!(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)){if(arguments.length===1)return u=d,Yn(!1,this,i,u);if(arguments.length===2){d=""+d,u=f;const h=this._nodes.get(d);if(typeof h>"u")throw new v(`Graph.${r}: could not find the "${d}" node in the graph.`);return Xt(!1,this.multi,i==="mixed"?this.type:i,a,h,u)}if(arguments.length===3){d=""+d,f=""+f;const h=this._nodes.get(d);if(!h)throw new v(`Graph.${r}: could not find the "${d}" source node in the graph.`);if(!this._nodes.has(f))throw new v(`Graph.${r}: could not find the "${f}" target node in the graph.`);return Zt(!1,i,this.multi,a,h,f,u)}throw new S(`Graph.${r}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(){const d=Array.prototype.slice.call(arguments),f=d.pop();let u;if(d.length===0){let h=0;i!=="directed"&&(h+=this.undirectedSize),i!=="undirected"&&(h+=this.directedSize),u=new Array(h);let x=0;d.push((A,j,D,C,F,R,g)=>{u[x++]=f(A,j,D,C,F,R,g)})}else u=[],d.push((h,x,A,j,D,C,F)=>{u.push(f(h,x,A,j,D,C,F))});return this[r].apply(this,d),u};const l="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[l]=function(){const d=Array.prototype.slice.call(arguments),f=d.pop(),u=[];return d.push((h,x,A,j,D,C,F)=>{f(h,x,A,j,D,C,F)&&u.push(h)}),this[r].apply(this,d),u};const c="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[c]=function(){let d=Array.prototype.slice.call(arguments);if(d.length<2||d.length>4)throw new S(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${d.length}).`);if(typeof d[d.length-1]=="function"&&typeof d[d.length-2]!="function")throw new S(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let f,u;d.length===2?(f=d[0],u=d[1],d=[]):d.length===3?(f=d[1],u=d[2],d=[d[0]]):d.length===4&&(f=d[2],u=d[3],d=[d[0],d[1]]);let h=u;return d.push((x,A,j,D,C,F,R)=>{h=f(h,x,A,j,D,C,F,R)}),this[r].apply(this,d),h}}function ya(n,e){const{name:t,type:i,direction:a}=e,r="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[r]=function(c,d,f){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return!1;if(arguments.length===1)return f=c,Yn(!0,this,i,f);if(arguments.length===2){c=""+c,f=d;const u=this._nodes.get(c);if(typeof u>"u")throw new v(`Graph.${r}: could not find the "${c}" node in the graph.`);return Xt(!0,this.multi,i==="mixed"?this.type:i,a,u,f)}if(arguments.length===3){c=""+c,d=""+d;const u=this._nodes.get(c);if(!u)throw new v(`Graph.${r}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(d))throw new v(`Graph.${r}: could not find the "${d}" target node in the graph.`);return Zt(!0,i,this.multi,a,u,d,f)}throw new S(`Graph.${r}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(){const c=Array.prototype.slice.call(arguments),d=c.pop();return c.push((u,h,x,A,j,D,C)=>d(u,h,x,A,j,D,C)),!!this[r].apply(this,c)};const l="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[l]=function(){const c=Array.prototype.slice.call(arguments),d=c.pop();return c.push((u,h,x,A,j,D,C)=>!d(u,h,x,A,j,D,C)),!this[r].apply(this,c)}}function wa(n,e){const{name:t,type:i,direction:a}=e,r=t.slice(0,-1)+"Entries";n.prototype[r]=function(o,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return st();if(!arguments.length)return ha(this,i);if(arguments.length===1){o=""+o;const c=this._nodes.get(o);if(!c)throw new v(`Graph.${r}: could not find the "${o}" node in the graph.`);return pa(i,a,c)}if(arguments.length===2){o=""+o,l=""+l;const c=this._nodes.get(o);if(!c)throw new v(`Graph.${r}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(l))throw new v(`Graph.${r}: could not find the "${l}" target node in the graph.`);return ga(i,a,c,l)}throw new S(`Graph.${r}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function va(n){ra.forEach(e=>{xa(n,e),ba(n,e),ya(n,e),wa(n,e)})}const Na=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Tt(){this.A=null,this.B=null}Tt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};Tt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function ut(n,e,t,i,a){for(const r in i){const o=i[r],l=o.source,c=o.target,d=l===t?c:l;if(e&&e.has(d.key))continue;const f=a(d.key,d.attributes);if(n&&f)return d.key}}function Jt(n,e,t,i,a){if(e!=="mixed"){if(e==="undirected")return ut(n,null,i,i.undirected,a);if(typeof t=="string")return ut(n,null,i,i[t],a)}const r=new Tt;let o;if(e!=="undirected"){if(t!=="out"){if(o=ut(n,null,i,i.in,a),n&&o)return o;r.wrap(i.in)}if(t!=="in"){if(o=ut(n,r,i,i.out,a),n&&o)return o;r.wrap(i.out)}}if(e!=="directed"&&(o=ut(n,r,i,i.undirected,a),n&&o))return o}function ja(n,e,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const i=[];return Jt(!1,n,e,t,function(a){i.push(a)}),i}function ht(n,e,t){const i=Object.keys(t),a=i.length;let r=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(r>=a)return n&&n.wrap(t),{done:!0};const l=t[i[r++]],c=l.source,d=l.target;if(o=c===e?d:c,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function ka(n,e,t){if(n!=="mixed"){if(n==="undirected")return ht(null,t,t.undirected);if(typeof e=="string")return ht(null,t,t[e])}let i=st();const a=new Tt;return n!=="undirected"&&(e!=="out"&&(i=De(i,ht(a,t,t.in))),e!=="in"&&(i=De(i,ht(a,t,t.out)))),n!=="directed"&&(i=De(i,ht(a,t,t.undirected))),i}function Sa(n,e){const{name:t,type:i,direction:a}=e;n.prototype[t]=function(r){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];r=""+r;const o=this._nodes.get(r);if(typeof o>"u")throw new v(`Graph.${t}: could not find the "${r}" node in the graph.`);return ja(i==="mixed"?this.type:i,a,o)}}function Ea(n,e){const{name:t,type:i,direction:a}=e,r="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[r]=function(d,f){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;d=""+d;const u=this._nodes.get(d);if(typeof u>"u")throw new v(`Graph.${r}: could not find the "${d}" node in the graph.`);Jt(!1,i==="mixed"?this.type:i,a,u,f)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(d,f){const u=[];return this[r](d,(h,x)=>{u.push(f(h,x))}),u};const l="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[l]=function(d,f){const u=[];return this[r](d,(h,x)=>{f(h,x)&&u.push(h)}),u};const c="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[c]=function(d,f,u){if(arguments.length<3)throw new S(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h=u;return this[r](d,(x,A)=>{h=f(h,x,A)}),h}}function Aa(n,e){const{name:t,type:i,direction:a}=e,r=t[0].toUpperCase()+t.slice(1,-1),o="find"+r;n.prototype[o]=function(d,f){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;d=""+d;const u=this._nodes.get(d);if(typeof u>"u")throw new v(`Graph.${o}: could not find the "${d}" node in the graph.`);return Jt(!0,i==="mixed"?this.type:i,a,u,f)};const l="some"+r;n.prototype[l]=function(d,f){return!!this[o](d,f)};const c="every"+r;n.prototype[c]=function(d,f){return!this[o](d,(h,x)=>!f(h,x))}}function _a(n,e){const{name:t,type:i,direction:a}=e,r=t.slice(0,-1)+"Entries";n.prototype[r]=function(o){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return st();o=""+o;const l=this._nodes.get(o);if(typeof l>"u")throw new v(`Graph.${r}: could not find the "${o}" node in the graph.`);return ka(i==="mixed"?this.type:i,a,l)}}function $a(n){Na.forEach(e=>{Sa(n,e),Ea(n,e),Aa(n,e),_a(n,e)})}function St(n,e,t,i,a){const r=i._nodes.values(),o=i.type;let l,c,d,f,u,h;for(;l=r.next(),l.done!==!0;){let x=!1;if(c=l.value,o!=="undirected"){f=c.out;for(d in f){u=f[d];do h=u.target,x=!0,a(c.key,h.key,c.attributes,h.attributes,u.key,u.attributes,u.undirected),u=u.next;while(u)}}if(o!=="directed"){f=c.undirected;for(d in f)if(!(e&&c.key>d)){u=f[d];do h=u.target,h.key!==d&&(h=u.source),x=!0,a(c.key,h.key,c.attributes,h.attributes,u.key,u.attributes,u.undirected),u=u.next;while(u)}}t&&!x&&a(c.key,null,c.attributes,null,null,null,null)}}function La(n,e){const t={key:n};return Un(e.attributes)||(t.attributes=Z({},e.attributes)),t}function Ta(n,e,t){const i={key:e,source:t.source.key,target:t.target.key};return Un(t.attributes)||(i.attributes=Z({},t.attributes)),n==="mixed"&&t.undirected&&(i.undirected=!0),i}function Ga(n){if(!de(n))throw new S('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in n))throw new S("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!de(n.attributes)||n.attributes===null))throw new S("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Ca(n){if(!de(n))throw new S('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in n))throw new S("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new S("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!de(n.attributes)||n.attributes===null))throw new S("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new S("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Da=Ri(),Pa=new Set(["directed","undirected","mixed"]),Nn=new Set(["domain","_events","_eventsCount","_maxListeners"]),Ra=[{name:n=>`${n}Edge`,generateKey:!0},{name:n=>`${n}DirectedEdge`,generateKey:!0,type:"directed"},{name:n=>`${n}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:n=>`${n}EdgeWithKey`},{name:n=>`${n}DirectedEdgeWithKey`,type:"directed"},{name:n=>`${n}UndirectedEdgeWithKey`,type:"undirected"}],Ia={allowSelfLoops:!0,multi:!1,type:"mixed"};function Ma(n,e,t){if(t&&!de(t))throw new S(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},n._nodes.has(e))throw new $(`Graph.addNode: the "${e}" node already exist in the graph.`);const i=new n.NodeDataClass(e,t);return n._nodes.set(e,i),n.emit("nodeAdded",{key:e,attributes:t}),i}function jn(n,e,t){const i=new n.NodeDataClass(e,t);return n._nodes.set(e,i),n.emit("nodeAdded",{key:e,attributes:t}),i}function Qn(n,e,t,i,a,r,o,l){if(!i&&n.type==="undirected")throw new $(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(i&&n.type==="directed")throw new $(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(l&&!de(l))throw new S(`Graph.${e}: invalid attributes. Expecting an object but got "${l}"`);if(r=""+r,o=""+o,l=l||{},!n.allowSelfLoops&&r===o)throw new $(`Graph.${e}: source & target are the same ("${r}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=n._nodes.get(r),d=n._nodes.get(o);if(!c)throw new v(`Graph.${e}: source node "${r}" not found.`);if(!d)throw new v(`Graph.${e}: target node "${o}" not found.`);const f={key:null,undirected:i,source:r,target:o,attributes:l};if(t)a=n._edgeKeyGenerator();else if(a=""+a,n._edges.has(a))throw new $(`Graph.${e}: the "${a}" edge already exists in the graph.`);if(!n.multi&&(i?typeof c.undirected[o]<"u":typeof c.out[o]<"u"))throw new $(`Graph.${e}: an edge linking "${r}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const u=new it(i,a,c,d,l);n._edges.set(a,u);const h=r===o;return i?(c.undirectedDegree++,d.undirectedDegree++,h&&(c.undirectedLoops++,n._undirectedSelfLoopCount++)):(c.outDegree++,d.inDegree++,h&&(c.directedLoops++,n._directedSelfLoopCount++)),n.multi?u.attachMulti():u.attach(),i?n._undirectedSize++:n._directedSize++,f.key=a,n.emit("edgeAdded",f),a}function Oa(n,e,t,i,a,r,o,l,c){if(!i&&n.type==="undirected")throw new $(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&n.type==="directed")throw new $(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(l){if(c){if(typeof l!="function")throw new S(`Graph.${e}: invalid updater function. Expecting a function but got "${l}"`)}else if(!de(l))throw new S(`Graph.${e}: invalid attributes. Expecting an object but got "${l}"`)}r=""+r,o=""+o;let d;if(c&&(d=l,l=void 0),!n.allowSelfLoops&&r===o)throw new $(`Graph.${e}: source & target are the same ("${r}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let f=n._nodes.get(r),u=n._nodes.get(o),h,x;if(!t&&(h=n._edges.get(a),h)){if((h.source.key!==r||h.target.key!==o)&&(!i||h.source.key!==o||h.target.key!==r))throw new $(`Graph.${e}: inconsistency detected when attempting to merge the "${a}" edge with "${r}" source & "${o}" target vs. ("${h.source.key}", "${h.target.key}").`);x=h}if(!x&&!n.multi&&f&&(x=i?f.undirected[o]:f.out[o]),x){const F=[x.key,!1,!1,!1];if(c?!d:!l)return F;if(c){const R=x.attributes;x.attributes=d(R),n.emit("edgeAttributesUpdated",{type:"replace",key:x.key,attributes:x.attributes})}else Z(x.attributes,l),n.emit("edgeAttributesUpdated",{type:"merge",key:x.key,attributes:x.attributes,data:l});return F}l=l||{},c&&d&&(l=d(l));const A={key:null,undirected:i,source:r,target:o,attributes:l};if(t)a=n._edgeKeyGenerator();else if(a=""+a,n._edges.has(a))throw new $(`Graph.${e}: the "${a}" edge already exists in the graph.`);let j=!1,D=!1;f||(f=jn(n,r,{}),j=!0,r===o&&(u=f,D=!0)),u||(u=jn(n,o,{}),D=!0),h=new it(i,a,f,u,l),n._edges.set(a,h);const C=r===o;return i?(f.undirectedDegree++,u.undirectedDegree++,C&&(f.undirectedLoops++,n._undirectedSelfLoopCount++)):(f.outDegree++,u.inDegree++,C&&(f.directedLoops++,n._directedSelfLoopCount++)),n.multi?h.attachMulti():h.attach(),i?n._undirectedSize++:n._directedSize++,A.key=a,n.emit("edgeAdded",A),[a,!0,j,D]}function Qe(n,e){n._edges.delete(e.key);const{source:t,target:i,attributes:a}=e,r=e.undirected,o=t===i;r?(t.undirectedDegree--,i.undirectedDegree--,o&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,i.inDegree--,o&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?e.detachMulti():e.detach(),r?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:e.key,attributes:a,source:t.key,target:i.key,undirected:r})}class z extends Di.EventEmitter{constructor(e){if(super(),e=Z({},Ia,e),typeof e.multi!="boolean")throw new S(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Pa.has(e.type))throw new S(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new S(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?Bn:e.type==="directed"?Hn:Kn;Ne(this,"NodeDataClass",t);const i="geid_"+Da()+"_";let a=0;const r=()=>{let o;do o=i+a++;while(this._edges.has(o));return o};Ne(this,"_attributes",{}),Ne(this,"_nodes",new Map),Ne(this,"_edges",new Map),Ne(this,"_directedSize",0),Ne(this,"_undirectedSize",0),Ne(this,"_directedSelfLoopCount",0),Ne(this,"_undirectedSelfLoopCount",0),Ne(this,"_edgeKeyGenerator",r),Ne(this,"_options",e),Nn.forEach(o=>Ne(this,o,this[o])),$e(this,"order",()=>this._nodes.size),$e(this,"size",()=>this._edges.size),$e(this,"directedSize",()=>this._directedSize),$e(this,"undirectedSize",()=>this._undirectedSize),$e(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),$e(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),$e(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),$e(this,"multi",this._options.multi),$e(this,"type",this._options.type),$e(this,"allowSelfLoops",this._options.allowSelfLoops),$e(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){const i=""+e,a=this._edges.get(i);return!!a&&!a.undirected}else if(arguments.length===2){e=""+e,t=""+t;const i=this._nodes.get(e);return i?i.out.hasOwnProperty(t):!1}throw new S(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){const i=""+e,a=this._edges.get(i);return!!a&&a.undirected}else if(arguments.length===2){e=""+e,t=""+t;const i=this._nodes.get(e);return i?i.undirected.hasOwnProperty(t):!1}throw new S(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){const i=""+e;return this._edges.has(i)}else if(arguments.length===2){e=""+e,t=""+t;const i=this._nodes.get(e);return i?typeof i.out<"u"&&i.out.hasOwnProperty(t)||typeof i.undirected<"u"&&i.undirected.hasOwnProperty(t):!1}throw new S(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new $("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const i=this._nodes.get(e);if(!i)throw new v(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new v(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const a=i.out&&i.out[t]||void 0;if(a)return a.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new $("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const i=this._nodes.get(e);if(!i)throw new v(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new v(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const a=i.undirected&&i.undirected[t]||void 0;if(a)return a.key}edge(e,t){if(this.multi)throw new $("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new v(`Graph.edge: could not find the "${t}" target node in the graph.`);const a=i.out&&i.out[t]||i.undirected&&i.undirected[t]||void 0;if(a)return a.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.in||t in i.out}areOutNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.out}areInNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in i.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in i.undirected}areNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in i.in||t in i.out)||this.type!=="directed"&&t in i.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in i.in||this.type!=="directed"&&t in i.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const i=this._nodes.get(e);if(!i)throw new v(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in i.out||this.type!=="directed"&&t in i.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.inDegree),i}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.outDegree),i}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.degree: could not find the "${e}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=t.undirectedDegree),this.type!=="undirected"&&(i+=t.inDegree+t.outDegree),i}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,a=0;return this.type!=="directed"&&(i+=t.undirectedDegree,a+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.inDegree,a+=t.directedLoops),i-a}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,a=0;return this.type!=="directed"&&(i+=t.undirectedDegree,a+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.outDegree,a+=t.directedLoops),i-a}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let i=0,a=0;return this.type!=="directed"&&(i+=t.undirectedDegree,a+=t.undirectedLoops*2),this.type!=="undirected"&&(i+=t.inDegree+t.outDegree,a+=t.directedLoops*2),i-a}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const i=this._edges.get(t);if(!i)throw new v(`Graph.opposite: could not find the "${t}" edge in the graph.`);const a=i.source.key,r=i.target.key;if(e===a)return r;if(e===r)return a;throw new v(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${a}, ${r}).`)}hasExtremity(e,t){e=""+e,t=""+t;const i=this._edges.get(e);if(!i)throw new v(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return i.source.key===t||i.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new v(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return Ma(this,e,t).key}mergeNode(e,t){if(t&&!de(t))throw new S(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let i=this._nodes.get(e);return i?(t&&(Z(i.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:i.attributes,data:t})),[e,!1]):(i=new this.NodeDataClass(e,t),this._nodes.set(e,i),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new S(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let i=this._nodes.get(e);if(i){if(t){const r=i.attributes;i.attributes=t(r),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:i.attributes})}return[e,!1]}const a=t?t({}):{};return i=new this.NodeDataClass(e,a),this._nodes.set(e,i),this.emit("nodeAdded",{key:e,attributes:a}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new v(`Graph.dropNode: could not find the "${e}" node in the graph.`);let i;if(this.type!=="undirected"){for(const a in t.out){i=t.out[a];do Qe(this,i),i=i.next;while(i)}for(const a in t.in){i=t.in[a];do Qe(this,i),i=i.next;while(i)}}if(this.type!=="directed")for(const a in t.undirected){i=t.undirected[a];do Qe(this,i),i=i.next;while(i)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const i=""+arguments[0],a=""+arguments[1];if(t=Se(this,i,a,this.type),!t)throw new v(`Graph.dropEdge: could not find the "${i}" -> "${a}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new v(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Qe(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new $("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new $("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;const i=Se(this,e,t,"directed");if(!i)throw new v(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Qe(this,i),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new $("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new $("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const i=Se(this,e,t,"undirected");if(!i)throw new v(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Qe(this,i),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new S("Graph.updateAttribute: updater should be a function.");const i=this._attributes[e];return this._attributes[e]=t(i),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!de(e))throw new S("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!de(e))throw new S("Graph.mergeAttributes: provided attributes are not a plain object.");return Z(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new S("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new S("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!vn(t))throw new S("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._nodes.values();let a,r;for(;a=i.next(),a.done!==!0;)r=a.value,r.attributes=e(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new S("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!vn(t))throw new S("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._edges.values();let a,r,o,l;for(;a=i.next(),a.done!==!0;)r=a.value,o=r.source,l=r.target,r.attributes=e(r.key,r.attributes,o.key,l.key,o.attributes,l.attributes,r.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new S("Graph.forEachAdjacencyEntry: expecting a callback.");St(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new S("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");St(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new S("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");St(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new S("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");St(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new S("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let i,a;for(;i=t.next(),i.done!==!0;)a=i.value,e(a.key,a.attributes)}findNode(e){if(typeof e!="function")throw new S("Graph.findNode: expecting a callback.");const t=this._nodes.values();let i,a;for(;i=t.next(),i.done!==!0;)if(a=i.value,e(a.key,a.attributes))return a.key}mapNodes(e){if(typeof e!="function")throw new S("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let i,a;const r=new Array(this.order);let o=0;for(;i=t.next(),i.done!==!0;)a=i.value,r[o++]=e(a.key,a.attributes);return r}someNode(e){if(typeof e!="function")throw new S("Graph.someNode: expecting a callback.");const t=this._nodes.values();let i,a;for(;i=t.next(),i.done!==!0;)if(a=i.value,e(a.key,a.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new S("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let i,a;for(;i=t.next(),i.done!==!0;)if(a=i.value,!e(a.key,a.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new S("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let i,a;const r=[];for(;i=t.next(),i.done!==!0;)a=i.value,e(a.key,a.attributes)&&r.push(a.key);return r}reduceNodes(e,t){if(typeof e!="function")throw new S("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new S("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let i=t;const a=this._nodes.values();let r,o;for(;r=a.next(),r.done!==!0;)o=r.value,i=e(i,o.key,o.attributes);return i}nodeEntries(){const e=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return t;const i=t.value;return{value:{node:i.key,attributes:i.attributes},done:!1}}}}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((a,r)=>{e[t++]=La(r,a)});const i=new Array(this._edges.size);return t=0,this._edges.forEach((a,r)=>{i[t++]=Ta(this.type,r,a)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:i}}import(e,t=!1){if(e instanceof z)return e.forEachNode((c,d)=>{t?this.mergeNode(c,d):this.addNode(c,d)}),e.forEachEdge((c,d,f,u,h,x,A)=>{t?A?this.mergeUndirectedEdgeWithKey(c,f,u,d):this.mergeDirectedEdgeWithKey(c,f,u,d):A?this.addUndirectedEdgeWithKey(c,f,u,d):this.addDirectedEdgeWithKey(c,f,u,d)}),this;if(!de(e))throw new S("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!de(e.attributes))throw new S("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let i,a,r,o,l;if(e.nodes){if(r=e.nodes,!Array.isArray(r))throw new S("Graph.import: invalid nodes. Expecting an array.");for(i=0,a=r.length;i<a;i++){o=r[i],Ga(o);const{key:c,attributes:d}=o;t?this.mergeNode(c,d):this.addNode(c,d)}}if(e.edges){let c=!1;if(this.type==="undirected"&&(c=!0),r=e.edges,!Array.isArray(r))throw new S("Graph.import: invalid edges. Expecting an array.");for(i=0,a=r.length;i<a;i++){l=r[i],Ca(l);const{source:d,target:f,attributes:u,undirected:h=c}=l;let x;"key"in l?(x=t?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,x.call(this,l.key,d,f,u)):(x=t?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,x.call(this,d,f,u))}}return this}nullCopy(e){const t=new z(Z({},this._options,e));return t.replaceAttributes(Z({},this.getAttributes())),t}emptyCopy(e){const t=this.nullCopy(e);return this._nodes.forEach((i,a)=>{const r=Z({},i.attributes);i=new t.NodeDataClass(a,r),t._nodes.set(a,i)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new $(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new $("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new $("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),i=this._edges.values();let a,r;for(;a=i.next(),a.done!==!0;)r=a.value,Qn(t,"copy",!1,r.undirected,r.key,r.source.key,r.target.key,Z({},r.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((r,o)=>{e[o]=r.attributes});const t={},i={};this._edges.forEach((r,o)=>{const l=r.undirected?"--":"->";let c="",d=r.source.key,f=r.target.key,u;r.undirected&&d>f&&(u=d,d=f,f=u);const h=`(${d})${l}(${f})`;o.startsWith("geid_")?this.multi&&(typeof i[h]>"u"?i[h]=0:i[h]++,c+=`${i[h]}. `):c+=`[${o}]: `,c+=h,t[c]=r.attributes});const a={};for(const r in this)this.hasOwnProperty(r)&&!Nn.has(r)&&typeof this[r]!="function"&&typeof r!="symbol"&&(a[r]=this[r]);return a.attributes=this._attributes,a.nodes=e,a.edges=t,Ne(a,"constructor",this.constructor),a}}typeof Symbol<"u"&&(z.prototype[Symbol.for("nodejs.util.inspect.custom")]=z.prototype.inspect);Ra.forEach(n=>{["add","merge","update"].forEach(e=>{const t=n.name(e),i=e==="add"?Qn:Oa;n.generateKey?z.prototype[t]=function(a,r,o){return i(this,t,!0,(n.type||this.type)==="undirected",null,a,r,o,e==="update")}:z.prototype[t]=function(a,r,o,l){return i(this,t,!1,(n.type||this.type)==="undirected",a,r,o,l,e==="update")}})});Vi(z);aa(z);va(z);$a(z);class Xn extends z{constructor(e){const t=Z({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new S("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new S('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Zn extends z{constructor(e){const t=Z({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new S("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new S('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Jn extends z{constructor(e){const t=Z({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class en extends z{constructor(e){const t=Z({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new S('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class es extends z{constructor(e){const t=Z({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new S('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function at(n){n.from=function(e,t){const i=Z({},e.options,t),a=new n(i);return a.import(e),a}}at(z);at(Xn);at(Zn);at(Jn);at(en);at(es);z.Graph=z;z.DirectedGraph=Xn;z.UndirectedGraph=Zn;z.MultiGraph=Jn;z.MultiDirectedGraph=en;z.MultiUndirectedGraph=es;z.InvalidArgumentsGraphError=S;z.NotFoundGraphError=v;z.UsageGraphError=$;const Oe={eligible:{property:"--chart-site-health-eligible",fallback:"#56b4e9"},hidden:{property:"--chart-site-health-hidden",fallback:"#e69f00"},resource:{property:"--chart-site-health-resource",fallback:"#d4d4d8"},redirect:{property:"--chart-site-health-redirect",fallback:"#9aa7b8"},failed:{property:"--chart-site-health-failed",fallback:"#d55e00"},unchecked:{property:"--chart-site-health-unchecked",fallback:"#a1a1aa"}},za={property:"--chart-neutral-text-dim",fallback:"#71717a"},kn=2.5,Fa=9,Sn=200,Ua=3,Ba=1.6;function ts(n){const e=Sn/Math.max(Sn,n);return Math.max(Ua,Fa*e**.25)}function Ha(n){return ts(n)*Ba}const Ka={eligible:Oe.eligible,hidden:Oe.hidden,resource:Oe.resource,redirect:Oe.redirect,failed:Oe.failed,unchecked:Oe.unchecked,dimmedNode:{property:"--chart-neutral-text-dim",fallback:"#71717a"},edge:za,edgeDimmed:{property:"--chart-neutral-text-faint",fallback:"#52525b"},edgeActive:{property:"--chart-neutral-text",fallback:"#a1a1aa"},label:{property:"--chart-tooltip-label",fallback:"#e4e4e7"},background:{property:"--chart-tooltip-bg",fallback:"#18181b"}},Wa=/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i,qa=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)$/;function En(n){return Wa.test(n)||qa.test(n)}const An=50,Va=8,gt=.75,Ya=[{maxRatio:.2,budget:Number.POSITIVE_INFINITY},{maxRatio:.45,budget:60},{maxRatio:gt,budget:24}],Qa=1;function Kt(n){for(const e of Ya)if(n<=e.maxRatio)return e.budget;return Qa}function nt(n,e){return n<e?-1:n>e?1:0}function Xa(n){return Math.max(0,Math.min(1,n.linkScoreNormalized??0))}function et(n){return n.healthState?n.healthState:Os(n)}function Wt(n){switch(n){case"eligible":return"Indexable";case"hidden":return"Hidden";case"resource":return"Not a page";case"redirect":return"Moved";case"failed":return"Broken";case"unchecked":return"Not checked"}}function Za(n){switch(n){case"eligible":return"Indexable";case"hidden":return"Hidden or points elsewhere";case"resource":return"Not a page";case"redirect":return"Moved";case"failed":return"Broken";case"unchecked":return"Not checked"}}function tt(n){switch(n){case"eligible":return"AI and search engines are allowed to index this page";case"hidden":return"This page tells them not to index it, or points them to another page";case"resource":return"A file rather than a page, such as a text file or a PDF. Answer engines can still read it";case"redirect":return"This address sends visitors to another page";case"failed":return"This page could not be loaded";case"unchecked":return"This page was found but not checked"}}function qt(n){switch(n){case"eligible":return"●";case"hidden":return"◆";case"resource":return"▪";case"redirect":return"↗";case"failed":return"×";case"unchecked":return"○"}}function Ja(n,e){return!!e&&n.nodeKey===e}function er(n,e=!1,t=1){const i=ts(t),a=kn+Math.sqrt(Xa(n))*(i-kn);return e?Math.max(Ha(t),a):a}function tr(n,e){switch(n){case"eligible":return e.eligible;case"hidden":return e.hidden;case"resource":return e.resource;case"redirect":return e.redirect;case"failed":return e.failed;case"unchecked":return e.unchecked}}function nr(n){return .35+Math.min(1.65,Math.log2(Math.max(1,n)+1)*.28)}function ns(n){return Number.isFinite(n.x)&&Number.isFinite(n.y)}function sr(n,e,t,i=null){const a=new en({allowSelfLoops:!0}),r=new Map;for(const l of n)r.has(l.nodeKey)||r.set(l.nodeKey,l);for(const l of[...r.values()].sort((c,d)=>nt(c.nodeKey,d.nodeKey))){if(!ns(l))continue;const c=et(l),d=tr(c,t),f=qt(c),u=Ja(l,i);a.addNode(l.nodeKey,{x:l.x,y:l.y,size:er(l,u,r.size),color:d,baseColor:d,label:`${f} ${l.path||"/"}`,nodeKey:l.nodeKey,url:l.url,path:l.path,depth:l.depth,status:c,glyph:f,forceLabel:u||l.depth===0||l.path.trim()==="/",zIndex:u?2:l.depth===0?1:0,isRoot:u})}const o=new Set;for(const l of[...e].sort((c,d)=>nt(c.edgeKey,d.edgeKey)))o.has(l.edgeKey)||!l.targetNodeKey||!a.hasNode(l.sourceNodeKey)||!a.hasNode(l.targetNodeKey)||(o.add(l.edgeKey),a.addDirectedEdgeWithKey(l.edgeKey,l.sourceNodeKey,l.targetNodeKey,{size:nr(l.occurrences),color:t.edge,baseColor:t.edge,followable:l.followable,occurrences:l.occurrences,isTemplate:l.isTemplate===!0,type:"line",zIndex:0}));return{graph:a,layoutAvailable:n.length===0||a.order>0,omittedNodes:Math.max(0,n.length-a.order),omittedEdges:Math.max(0,e.length-a.size)}}function ir(n,e,t=An){const i=e.trim().toLocaleLowerCase(),a=Math.max(0,Math.min(An,Math.floor(t)));return[...n].sort((r,o)=>nt(r.path||r.url,o.path||o.url)||nt(r.nodeKey,o.nodeKey)).filter(r=>ns(r)?i?`${r.path}
|
|
3
3
|
${r.url}
|
|
4
|
-
${r.nodeKey}`.toLocaleLowerCase().includes(i):!0:!1).slice(0,a)}function ar(n,e,t,i,a=!0){const o=!!(e&&n.hasNode(e))?e:null,l=typeof t=="function"?t:()=>t,c=n.nodes().sort((u,h)=>{const x=n.getNodeAttributes(u),A=n.getNodeAttributes(h);return Number(A.isRoot)-Number(x.isRoot)||A.size-x.size||(x.depth??Number.MAX_SAFE_INTEGER)-(A.depth??Number.MAX_SAFE_INTEGER)||nt(x.path,A.path)||nt(u,h)}),d=new Map(c.map((u,h)=>[u,h])),f=new Set(o?n.neighbors(o).filter(u=>u!==o).sort((u,h)=>(d.get(u)??0)-(d.get(h)??0)).slice(0,Va):[]);return{nodeReducer:(u,h)=>{const x=l(),A=x>gt;if(h.isRoot)return u===o?{...h,size:h.size*1.35,forceLabel:!0,zIndex:3}:{...h,forceLabel:!0};if(o)return u===o?{...h,size:h.size*1.35,forceLabel:!0,zIndex:3}:n.areNeighbors(u,o)?A?f.has(u)?{...h,forceLabel:!1}:{...h,forceLabel:!1,label:""}:h:{...h,color:i.dimmedNode,forceLabel:!1,label:"",zIndex:0};const j=Kt(x);return j===Number.POSITIVE_INFINITY?h:(d.get(u)??Number.MAX_SAFE_INTEGER)<j?{...h,forceLabel:!0}:{...h,forceLabel:!1,label:""}},edgeReducer:(u,h)=>{if(h.isTemplate&&!a)return{...h,hidden:!0};const x=l()>gt,[A,j]=n.extremities(u);return o&&(A===o||j===o)?{...h,color:i.edgeActive,size:Math.max(1.4,h.size),zIndex:2}:x?{...h,hidden:!0}:o?{...h,color:i.edgeDimmed,size:Math.min(.45,h.size),zIndex:0}:h}}}const _n={"layout-failed":{heading:"Map could not be built",detail:"The map could not be created for this scan. Run a new scan to try again."},"no-crawl":{heading:"No map yet",detail:"This scan has no map yet. Run a new scan to create one."},"legacy-snapshot":{heading:"No map yet",detail:"This scan has no map yet. Run a new scan to create one."},"details-unavailable":{heading:"No map yet",detail:"This scan has no map yet. Run a new scan to create one."},"empty-crawl":{heading:"No pages to map",detail:"This scan found no pages to put on a map. Run a new scan to try again."}};function rr(n){return(n&&_n[n])??_n["no-crawl"]}class or extends w.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error("[SiteGraphSigma] the map failed to render",e,t.componentStack)}componentDidUpdate(e){this.state.failed&&e.resetToken!==this.props.resetToken&&this.setState({failed:!1})}render(){return this.state.failed?this.props.fallback:this.props.children}}const lr=220;function dr(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:lr}function ft(n,e,t=`${e}s`){return`${n.toLocaleString()} ${n===1?e:t}`}function cr(n,e,t){const a=window.getComputedStyle(n).getPropertyValue(e).trim();if(a&&!a.includes("var(")&&En(a))return a;const r=document.createElement("span");r.style.position="absolute",r.style.visibility="hidden",r.style.color=`var(${e})`,n.appendChild(r);const o=window.getComputedStyle(r).color.trim();return r.remove(),o&&!o.includes("var(")&&En(o)?o:t}function ur(n){const e=t=>{const i=Ka[t];return cr(n,i.property,i.fallback)};return{eligible:e("eligible"),hidden:e("hidden"),resource:e("resource"),redirect:e("redirect"),failed:e("failed"),unchecked:e("unchecked"),dimmedNode:e("dimmedNode"),edge:e("edge"),edgeDimmed:e("edgeDimmed"),edgeActive:e("edgeActive"),label:e("label"),background:e("background")}}function hr(n){return(e,t,i)=>{t.label&&(e.save(),e.fillStyle=i.labelColor.color??n.label,e.font=`${i.labelWeight} ${i.labelSize}px ${i.labelFont}`,e.fillText(t.label,t.x+t.size+3,t.y+i.labelSize/3),e.restore())}}function fr(n,e,t,i,a,r){const o=Math.min(r,i/2,a/2);n.beginPath(),n.moveTo(e+o,t),n.lineTo(e+i-o,t),n.arcTo(e+i,t,e+i,t+o,o),n.lineTo(e+i,t+a-o),n.arcTo(e+i,t+a,e+i-o,t+a,o),n.lineTo(e+o,t+a),n.arcTo(e,t+a,e,t+a-o,o),n.lineTo(e,t+o),n.arcTo(e,t,e+o,t,o),n.closePath()}function pr(n){return(e,t,i)=>{const a=typeof t.label=="string"?t.label:null,r=i.labelSize+10,o=t.x+t.size+7,l=t.y-r/2;if(e.save(),e.font=`${i.labelWeight} ${i.labelSize}px ${i.labelFont}`,e.fillStyle=n.background,e.strokeStyle=n.edgeActive,e.lineWidth=1.5,e.beginPath(),e.arc(t.x,t.y,t.size+3,0,Math.PI*2),e.fill(),e.stroke(),e.fillStyle=t.color,e.beginPath(),e.arc(t.x,t.y,t.size,0,Math.PI*2),e.fill(),a){const c=Math.ceil(e.measureText(a).width)+16;fr(e,o,l,c,r,5),e.fillStyle=n.background,e.fill(),e.strokeStyle=n.edgeActive,e.lineWidth=1,e.stroke(),e.fillStyle=n.label,e.textBaseline="middle",e.fillText(a,o+8,t.y)}e.restore()}}function mr(){if(typeof document>"u")return!1;try{const n=document.createElement("canvas");return!!(n.getContext("webgl2")||n.getContext("webgl"))}catch{return!1}}function gr({onOpenInventory:n}){return s.jsx("div",{className:"flex h-full min-h-80 items-center justify-center px-6 text-center",children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:"Interactive map unavailable"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"This browser could not start WebGL. The page inventory remains available for the complete crawl."}),n&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",className:"mt-4",onClick:n,children:"Open page inventory"})]})})}function xr({onRetry:n}){return s.jsx("div",{className:"flex h-full min-h-80 items-center justify-center px-6 text-center",role:"alert",children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:"The map could not be drawn"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Something went wrong while drawing this map. The page inventory below is unaffected."}),s.jsx(M,{variant:"secondary",size:"sm",className:"mt-4",onClick:n,children:"Try again"})]})})}function br({reactSigma:n,graph:e,theme:t,selectedNodeKey:i,showTemplateLinks:a,onSelectNodeKey:r,onHoverNode:o,onCameraReady:l}){const{useSigma:c,useRegisterEvents:d,useCamera:f}=n,u=c(),h=d(),{zoomIn:x,zoomOut:A,reset:j,gotoNode:D}=f(),[C,F]=w.useState(null),R=C??i,g=w.useRef(null),m=w.useRef({overview:!0,budget:Number.NaN});return w.useEffect(()=>()=>{g.current!==null&&cancelAnimationFrame(g.current)},[]),w.useEffect(()=>{const b=dr();return l({zoomIn:()=>x({duration:b}),zoomOut:()=>A({duration:b}),reset:()=>j({duration:b}),gotoNode:N=>D(N,{duration:b})}),()=>l(null)},[D,l,j,x,A]),w.useEffect(()=>{h({enterNode:({node:b,event:N})=>{F(b),o({nodeKey:b,left:Number.isFinite(N.x)?N.x+14:20,top:Number.isFinite(N.y)?N.y+14:20})},leaveNode:()=>{F(null),o(null)},clickNode:({node:b})=>r(b),clickStage:()=>o(null),updated:()=>{g.current===null&&(g.current=requestAnimationFrame(()=>{g.current=null;const b=u.getCamera().getState().ratio>gt,N=Kt(u.getCamera().getState().ratio);b===m.current.overview&&N===m.current.budget||(m.current={overview:b,budget:N},u.refresh())}))}})},[o,r,h,u]),w.useEffect(()=>{if(u.getGraph()!==e)return;const b=ar(e,R,()=>u.getCamera().getState().ratio,t,a);u.setSetting("nodeReducer",b.nodeReducer),u.setSetting("edgeReducer",b.edgeReducer);const N=u.getCamera().getState().ratio;m.current={overview:N>gt,budget:Kt(N)},u.refresh()},[R,e,a,u,t]),null}function yr({nodes:n,edges:e,layoutState:t="ready",layoutUnavailableReason:i,rootNodeKey:a=null,showTemplateLinks:r=!0,selectedNodeKey:o,onSelectNode:l,onOpenInventory:c,ariaLabel:d,className:f}){const u=w.useRef(null),h=w.useRef(null),x=w.useRef(null),A=w.useId(),j=w.useId(),D=w.useId(),[C,F]=w.useState(null),[R,g]=w.useState(null),[m,b]=w.useState("checking"),[N,_]=w.useState(!1),[G,P]=w.useState(null),[U,Q]=w.useState(null),[Y,se]=w.useState(""),[L,ge]=w.useState(!1),[ze,ce]=w.useState(0),[E,pe]=w.useState(""),[ie,ae]=w.useState(0),Ee=w.useRef(null),ue=w.useDeferredValue(Y),he=o===void 0?G:o,xe=w.useMemo(()=>new Map(n.map(k=>[k.nodeKey,k])),[n]),J=w.useMemo(()=>zn(a?xe.get(a)?.url:null),[xe,a]),ee=w.useCallback(k=>Gi(k,J),[J]),B=he?xe.get(he)??null:null,re=U?xe.get(U.nodeKey)??null:null,Le=w.useMemo(()=>ir(n,ue),[ue,n]),oe=n.some(k=>Number.isFinite(k.x)&&Number.isFinite(k.y)),Ae=w.useMemo(()=>C?sr(n,e,C,a):null,[e,n,a,C]),rt=w.useMemo(()=>C?{allowInvalidContainer:!0,defaultNodeColor:C.unchecked,defaultEdgeColor:C.edge,defaultEdgeType:"line",enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!0,hideLabelsOnMove:!0,itemSizesReference:"screen",defaultDrawNodeHover:pr(C),defaultDrawNodeLabel:hr(C),labelColor:{color:C.label},labelDensity:.07,labelGridCellSize:140,labelFont:"Geist Variable, Geist, sans-serif",labelRenderedSizeThreshold:8,labelSize:13,labelWeight:"600",maxCameraRatio:12,minCameraRatio:.04,minEdgeThickness:.35,renderEdgeLabels:!1,renderLabels:!0,stagePadding:42,zIndex:!0}:null,[C]);w.useEffect(()=>{const k=u.current;if(!k)return;const W=()=>F(ur(k));if(W(),typeof MutationObserver>"u")return;const q=new MutationObserver(W);return q.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>q.disconnect()},[]),w.useEffect(()=>{if(n.length===0||t==="unavailable"||!oe){b("checking");return}b(mr()?"ready":"unavailable")},[oe,t,n.length]),w.useEffect(()=>{if(m!=="ready"){g(null);return}let k=!0;return zs(()=>import("./react-sigma_core.esm.min-Xwhtf0bv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url).then(W=>{k&&g(W)}).catch(()=>{k&&b("unavailable")}),()=>{k=!1}},[m]),w.useEffect(()=>{ce(0)},[ue]);const We=w.useCallback(k=>{x.current=k,_(!!k)},[]),Fe=w.useCallback(k=>{Q(k)},[]),Te=w.useCallback((k,W)=>{const q=xe.get(k);q&&(o===void 0&&P(k),l?.(q),W&&x.current?.gotoNode(k),pe(`Focused ${ee(q)}`))},[xe,l,ee,o]),Ue=w.useCallback(k=>{Te(k,!1)},[Te]);w.useEffect(()=>{if(!N||!o||!xe.has(o)){o||(Ee.current=null);return}Ee.current!==o&&(x.current?.gotoNode(o),Ee.current=o)},[N,xe,o]);const p=k=>{Te(k.nodeKey,!0),se(ee(k)),ge(!1)},H=()=>{window.setTimeout(()=>{document.activeElement!==h.current&&ge(!1)},0)},T=`Interactive site map showing ${ft(n.length,"page")} and ${ft(e.length,"internal link")}`,K=k=>`${j}-${k.replaceAll(/[^\w-]/g,"-")}`,te=rr(i);if(t==="unavailable")return s.jsx("section",{ref:u,role:"group","aria-label":d??T,className:He("flex min-h-80 items-center justify-center rounded-lg border border-default bg-surface-inset px-6 text-center",f),children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:te.heading}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:te.detail}),c&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",className:"mt-4",onClick:c,children:"Open page inventory"})]})});if(n.length===0)return s.jsx("section",{ref:u,role:"group","aria-label":d??T,className:He("flex min-h-80 items-center justify-center rounded-lg border border-default bg-surface-inset px-6 text-center",f),children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm text-secondary",children:"No page graph is available for this scan."}),c&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",className:"mt-4",onClick:c,children:"Open page inventory"})]})});if(!oe)return s.jsx("section",{ref:u,role:"group","aria-label":d??T,className:He("flex min-h-80 items-center justify-center rounded-lg border border-default bg-surface-inset px-6 text-center",f),children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:te.heading}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:te.detail}),c&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",className:"mt-4",onClick:c,children:"Open page inventory"})]})});const ye=Le.at(ze),we=s.jsx(xr,{onRetry:()=>ae(k=>k+1)}),O=R?.SigmaContainer;return s.jsxs("section",{ref:u,role:"group","aria-label":d??T,"aria-describedby":D,className:He("flex h-[clamp(460px,62vh,680px)] min-h-[460px] flex-col overflow-hidden rounded-lg border border-default bg-surface-inset",f),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-subtle bg-bg-elevated/70 px-3 py-2",children:[s.jsx("label",{htmlFor:A,className:"sr-only",children:"Focus a page in the site map"}),s.jsxs("div",{className:"relative min-w-56 max-w-lg flex-1",children:[s.jsx(Yt,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted","aria-hidden":"true"}),s.jsx("input",{id:A,ref:h,role:"combobox",type:"search",autoComplete:"off","aria-label":"Focus a page in the site map","aria-autocomplete":"list","aria-controls":j,"aria-expanded":L,"aria-activedescendant":L&&ye?K(ye.nodeKey):void 0,value:Y,placeholder:B?`Focused: ${ee(B)}`:"Find a page",className:"h-10 w-full rounded-md border border-base bg-bg py-2 pl-9 pr-3 text-sm text-primary placeholder-mono-600 outline-none focus-visible:ring-2 focus-visible:ring-mono-400",onFocus:()=>ge(!0),onBlur:H,onChange:k=>{se(k.target.value),ge(!0)},onKeyDown:k=>{k.key==="ArrowDown"?(k.preventDefault(),ge(!0),ce(W=>Math.max(0,Math.min(Le.length-1,W+1)))):k.key==="ArrowUp"?(k.preventDefault(),ce(W=>Math.max(0,W-1))):k.key==="Enter"&&L&&ye?(k.preventDefault(),p(ye)):k.key==="Escape"&&ge(!1)}}),L&&s.jsxs("div",{className:"absolute left-0 right-0 top-[calc(100%+0.25rem)] z-30 overflow-hidden rounded-md border border-base bg-bg shadow-lg",children:[s.jsx("div",{id:j,role:"listbox","aria-label":"Matching pages",className:"max-h-72 overflow-auto py-1",children:Le.length>0?Le.map((k,W)=>{const q=et(k);return s.jsxs("button",{id:K(k.nodeKey),type:"button",role:"option","aria-selected":W===ze,tabIndex:-1,className:He("flex min-h-11 w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-none",W===ze?"bg-surface-active text-primary":"text-secondary hover:bg-surface-hover hover:text-primary"),onPointerDown:ot=>ot.preventDefault(),onMouseDown:ot=>ot.preventDefault(),onMouseEnter:()=>ce(W),onClick:()=>p(k),children:[s.jsx("span",{className:"min-w-0 truncate font-mono",children:ee(k)}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[13px] text-muted",children:[s.jsx("span",{className:"font-mono font-semibold",style:{color:`var(${Oe[q].property})`},"aria-hidden":"true",children:qt(q)}),s.jsx("span",{title:tt(q),children:Wt(q)})]})]},k.nodeKey)}):s.jsx("p",{className:"px-3 py-4 text-sm text-secondary",children:"No rendered pages match."})}),Le.length===50&&s.jsx("p",{className:"border-t border-subtle px-3 py-2 text-[13px] text-muted",children:"First 50 matches. Refine the search or use the full page inventory."})]})]}),s.jsxs("span",{className:"text-[13px] tabular-nums text-muted",children:[ft(n.length,"page")," · ",ft(e.length,"link")]})]}),s.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden",children:m==="unavailable"?s.jsx(gr,{onOpenInventory:c}):m==="checking"||!C||!Ae||!rt||!R||!O?s.jsx("div",{className:"flex h-full min-h-80 items-center justify-center px-6 text-center",role:"status",children:s.jsx("p",{className:"text-sm text-secondary",children:"Preparing the interactive site map..."})}):s.jsxs(or,{fallback:we,resetToken:ie,children:[s.jsx("div",{"aria-hidden":"true",className:"absolute inset-0",children:s.jsx(O,{graph:Ae.graph,className:"relative size-full bg-bg [&_.sigma-container]:size-full",style:{width:"100%",height:"100%",background:C.background},settings:rt,children:s.jsx(br,{reactSigma:R,graph:Ae.graph,theme:C,selectedNodeKey:he,showTemplateLinks:r,onSelectNodeKey:Ue,onHoverNode:Fe,onCameraReady:We})})}),s.jsxs("div",{className:"absolute right-3 top-3 z-20 flex flex-col overflow-hidden rounded-md border border-base bg-bg shadow-lg",children:[s.jsx(M,{type:"button",variant:"ghost",size:"icon",className:"rounded-none border-b border-subtle","aria-label":"Zoom in",disabled:!N,onClick:()=>x.current?.zoomIn(),children:s.jsx(hi,{className:"size-4","aria-hidden":"true"})}),s.jsx(M,{type:"button",variant:"ghost",size:"icon",className:"rounded-none border-b border-subtle","aria-label":"Zoom out",disabled:!N,onClick:()=>x.current?.zoomOut(),children:s.jsx(fi,{className:"size-4","aria-hidden":"true"})}),s.jsx(M,{type:"button",variant:"ghost",size:"icon",className:"rounded-none","aria-label":"Fit site map",disabled:!N,onClick:()=>x.current?.reset(),children:s.jsx(pi,{className:"size-4","aria-hidden":"true"})})]}),re&&U&&s.jsxs("div",{role:"tooltip",className:"pointer-events-none absolute z-20 max-w-64 rounded-md border border-base bg-bg/95 px-3 py-2 shadow-lg",style:{left:U.left,top:U.top},children:[s.jsx("p",{className:"truncate font-mono text-[13px] font-medium text-heading",children:ee(re)}),s.jsx("p",{className:"mt-1 text-[13px] font-medium text-heading",children:Wt(et(re))}),s.jsx("p",{className:"mt-0.5 text-[13px] text-secondary",children:tt(et(re))}),re.depth!=null&&s.jsxs("p",{className:"mt-1 text-[13px] text-secondary",children:[ft(re.depth,"click")," from home"]}),re.auditScore!=null&&s.jsxs("p",{className:"mt-1 text-[13px] tabular-nums text-heading",children:["Score ",Math.round(re.auditScore),"/100"]})]})]})}),s.jsxs("div",{"aria-label":"Site map legend",className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-subtle bg-bg-elevated/50 px-3 py-2 text-[13px] text-secondary",children:[Fs.map(k=>s.jsxs("span",{className:"inline-flex items-center gap-1.5",title:tt(k),children:[s.jsx("span",{className:"w-3 text-center font-mono text-[15px] font-semibold leading-none",style:{color:`var(${Oe[k].property})`},"aria-hidden":"true",children:qt(k)}),Za(k)]},k)),s.jsx("span",{className:"ml-auto",children:"Bigger = more linked"}),Ae&&(Ae.omittedNodes>0||Ae.omittedEdges>0)&&s.jsx("span",{className:"text-caution",children:"Some records lacked valid layout data."})]}),s.jsx("p",{id:D,className:"sr-only",children:"The WebGL map supports pointer, wheel, and touch navigation. Use the page search to focus a rendered page. Use the full page inventory for an accessible list of every crawled page and its links."}),s.jsx("p",{role:"status","aria-live":"polite",className:"sr-only",children:E})]})}function wr(n){return n>=70?"positive":n>=40?"caution":"negative"}function vr(n){return n>=70?"pass":n>=40?"partial":"fail"}function Nr(n){return n==="pass"?"positive":n==="partial"?"caution":"negative"}function $n(n){return n==="pass"?"Pass":n==="partial"?"Partial":"Fail"}function ss({audit:n,isLoading:e,error:t,onRetry:i}){return s.jsxs("section",{className:"border-t border-default pt-5","aria-labelledby":"site-health-page-audit-heading",children:[s.jsx("div",{children:s.jsx("h3",{id:"site-health-page-audit-heading",className:"text-base font-semibold text-heading",children:"Findings and fixes for this page"})}),e?s.jsx("p",{className:"mt-4 text-sm text-secondary",role:"status",children:"Loading findings..."}):t?s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3 border-y border-negative bg-negative-soft px-4 py-3",role:"alert",children:[s.jsx("p",{className:"text-sm text-negative",children:"Findings could not be loaded."}),s.jsx(M,{type:"button",variant:"secondary",size:"sm",onClick:i,children:"Try again"})]}):n?n.state==="no-crawl"?s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"No Site Health scan is available."}):n.state==="details-unavailable"?s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"This scan saved its summary, but not the findings for each page."}):n.state==="not-found"?s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"This page is not present in the selected scan."}):n.state==="not-audited"?s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"This page was found, but it was not scored."}):s.jsx(jr,{audit:n}):s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"No findings are available for this page."})]})}function jr({audit:n}){const e=n.factors.filter(t=>t.applicable!==!1&&(t.status!=="pass"||t.findings.some(i=>i.type==="missing"||i.type==="timeout"||i.type==="unreachable")));return s.jsxs("div",{className:"mt-4",children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[s.jsxs("span",{"aria-label":`Score ${Math.round(n.auditScore)} out of 100`,className:"text-2xl font-semibold tabular-nums text-heading",children:[Math.round(n.auditScore),s.jsx("span",{className:"text-sm text-muted",children:"/100"})]}),s.jsx(X,{tone:wr(n.auditScore),children:$n(vr(n.auditScore))})]}),n.evidenceState==="scores-only"&&s.jsx("p",{className:"mt-3 border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"This older scan saved only the scores, not the findings or fixes."}),n.criticalDefects.length>0&&s.jsxs("section",{className:"mt-5","aria-labelledby":"site-health-critical-defects-heading",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h4",{id:"site-health-critical-defects-heading",className:"text-sm font-semibold text-heading",children:"Problems outside the score"}),s.jsx(X,{tone:n.criticalDefects.some(t=>t.severity==="critical")?"negative":"caution",children:n.criticalDefects.length}),s.jsx("span",{className:"text-xs text-muted",children:"Not counted in the score"})]}),s.jsx("ul",{className:"mt-2 divide-y divide-default border-y border-default",children:n.criticalDefects.map(t=>s.jsxs("li",{className:"py-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:t.detail}),s.jsx(X,{tone:t.severity==="critical"?"negative":"caution",children:t.severity==="critical"?"Critical":"Warning"})]}),s.jsxs("p",{className:"mt-1 text-sm text-secondary",children:[s.jsx("span",{className:"font-medium text-heading",children:"Fix:"})," ",t.recommendation]})]},t.id))})]}),e.length>0?s.jsx("div",{className:"mt-5 divide-y divide-default border-y border-default",children:e.map(t=>s.jsxs("details",{className:"group py-1",children:[s.jsxs("summary",{className:"flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 rounded-sm px-1 py-2 outline-none marker:hidden focus-visible:ring-2 focus-visible:ring-mono-400 [&::-webkit-details-marker]:hidden",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-sm font-medium text-heading",children:[s.jsx(Lt,{className:"size-4 shrink-0 text-muted transition-transform group-open:rotate-90","aria-hidden":"true"}),t.name]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs("span",{className:"text-sm tabular-nums text-heading",children:[Math.round(t.score),"/100"]}),s.jsx(X,{tone:Nr(t.status),children:$n(t.status)})]})]}),s.jsxs("div",{className:"grid gap-4 px-1 pb-4 pt-1 md:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Evidence"}),t.findings.length>0?s.jsx("ul",{className:"mt-2 space-y-1.5 text-sm text-secondary",children:t.findings.map((i,a)=>s.jsx("li",{children:i.message},`${i.code}:${a}`))}):s.jsx("p",{className:"mt-2 text-sm text-secondary",children:n.evidenceState==="scores-only"?"This scan did not save the findings here.":"Nothing to report here."})]}),s.jsxs("div",{children:[s.jsx("h5",{className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Recommended fix"}),t.recommendations.length>0?s.jsx("ol",{className:"mt-2 list-decimal space-y-1.5 pl-5 text-sm text-secondary marker:text-muted",children:t.recommendations.map(i=>s.jsx("li",{children:i},i))}):s.jsx("p",{className:"mt-2 text-sm text-secondary",children:n.evidenceState==="scores-only"?"This scan did not save a fix here.":"No fix suggested here."}),s.jsxs("p",{className:"mt-3 text-xs text-muted",children:["Worth ",t.weight,"% of the page score"]})]})]})]},t.id))}):n.criticalDefects.length===0&&n.evidenceState==="complete"?s.jsx("p",{className:"mt-4 border-y border-positive bg-positive-soft px-4 py-3 text-sm text-positive",children:"Nothing needs attention on this page."}):n.criticalDefects.length===0?s.jsx("p",{className:"mt-4 border-y border-default px-4 py-3 text-sm text-secondary",children:"This scan saved only the score. Run a new scan to see findings."}):null]})}const is=25;function kr(n){return n.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean)}function Sr(n){let e=n;try{e=decodeURIComponent(n.replace(/\+/g," "))}catch{}let t="";const i=n.indexOf("?");return i>=0&&new URLSearchParams(n.slice(i+1)).forEach((r,o)=>{t+=` ${o} ${r}`}),`${n} ${e}${t}`}function Er(n,e=36,t=18){const i=[...n];return i.length<=e+t+1?n:`${i.slice(0,e).join("")}…${i.slice(-t).join("")}`}function Ar({value:n,headLength:e,tailLength:t,className:i,title:a}){const r=Er(n,e,t);return s.jsx("span",{className:i,title:a??n,children:r===n?n:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sr-only",children:n}),s.jsx("span",{"aria-hidden":"true",children:r})]})})}function _r({rows:n,getSearchText:e,pageSize:t=is}){const[i,a]=w.useState(""),[r,o]=w.useState(1),l=w.useMemo(()=>kr(i),[i]),c=w.useMemo(()=>l.length===0||!e?n:n.filter(j=>{const D=e(j).toLocaleLowerCase();return l.every(C=>D.includes(C))}),[e,n,l]),d=Math.max(1,Math.ceil(c.length/t)),f=Math.min(Math.max(1,r),d),u=(f-1)*t,h=w.useMemo(()=>c.slice(u,u+t),[c,t,u]),x=w.useCallback(j=>{a(j),o(1)},[]),A=w.useCallback(j=>{o(Math.max(1,j))},[]);return{query:i,setQuery:x,page:f,setPage:A,rows:h,filteredRows:c,totalRows:c.length,totalPages:d,pageSize:t,rangeStart:c.length===0?0:u+1,rangeEnd:u+h.length,hasQuery:i.trim().length>0}}function $r({value:n,onChange:e,label:t,placeholder:i="Filter rows",className:a}){return s.jsxs("div",{className:`relative ${a??""}`,children:[s.jsx(Yt,{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted"}),s.jsx("input",{type:"search",value:n,onChange:r=>e(r.target.value),"aria-label":t,placeholder:i,autoComplete:"off",spellCheck:!1,className:"h-9 w-full rounded-md border border-default bg-surface/50 pl-9 pr-9 text-sm text-strong placeholder:text-muted outline-none transition focus:border-mono-500 focus:ring-1 focus:ring-mono-500 [&::-webkit-search-cancel-button]:appearance-none"}),n.trim().length>0?s.jsx("button",{type:"button",onClick:()=>e(""),"aria-label":`Clear ${t.toLocaleLowerCase()}`,className:"absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded text-muted transition-colors hover:bg-surface-hover hover:text-strong focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-mono-500",children:s.jsx(mi,{"aria-hidden":"true",className:"size-3.5"})}):null]})}function Lr({page:n,pageSize:e=is,visibleRows:t,totalRows:i,hasNextPage:a,onPageChange:r,itemLabel:o="rows",className:l,disabled:c=!1}){if(t===0)return null;const d=(n-1)*e+1,f=d+t-1,u=i===void 0?void 0:Math.max(1,Math.ceil(i/e)),h=a??(u!==void 0&&n<u),x=n>1||h;return s.jsxs("div",{className:`mt-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-secondary ${l??""}`,children:[s.jsxs("p",{className:"tabular-nums",children:[d.toLocaleString("en-US"),"–",f.toLocaleString("en-US"),i===void 0?`${h?"+":""} ${o}`:` of ${i.toLocaleString("en-US")} ${o}`]}),x?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>r(n-1),disabled:c||n<=1,className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:[s.jsx(gi,{"aria-hidden":"true",className:"size-3.5"}),"Previous"]}),s.jsx("span",{className:"tabular-nums",children:u===void 0?`Page ${n}`:`Page ${n} of ${u}`}),s.jsxs("button",{type:"button",onClick:()=>r(n+1),disabled:c||!h,className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:["Next",s.jsx(Lt,{"aria-hidden":"true",className:"size-3.5"})]})]}):null]})}const Tr=100,Ot=12,Gr=[];function Cr(n){return Sr(n.url)}function pt(n){return n>=70?"positive":n>=40?"caution":"negative"}function Et(n){return n>=70?"text-positive-400":n>=40?"text-caution-400":"text-negative-400"}function Dr(n){return n==="pass"?"positive":n==="partial"?"caution":"negative"}function mt(n){return n>=70?"Pass":n>=40?"Partial":"Fail"}function Pr(n){return vi(On(String(n)))}function Rr(n){return Ni(On(String(n)))}function Ir({projectName:n,projectId:e,runId:t,integrated:i=!1,compactCopy:a=!1,afterSummary:r,unavailableFooter:o}){const{isAdmin:l}=Dn(),c=$t(Ke["site-audit"])&&!l,[d,f]=w.useState(!1),[u,h]=w.useState(null),[x,A]=w.useState(null),j=t===void 0?x:t,[D,C]=w.useState(!1),F=w.useRef(null),R=me(Us({client:le,path:{name:n},...j?{query:{runId:j}}:{}})),g=me({...Bs({client:le,path:{name:n},query:{limit:30}}),enabled:!i}),m=me(Hs({client:le,path:{name:n},query:{limit:Tr,sort:"score-asc",...j?{runId:j}:{}}})),b=me({...Ks({client:le,path:{name:n},query:{kind:Ke["site-audit"],limit:10}}),enabled:!i,refetchOnWindowFocus:"always",refetchInterval:p=>p.state.data?.some(T=>T.status==="queued"||T.status==="running")?3e3:1e4}),N=Pn(),_=w.useSyncExternalStore(Ws,hn,hn),G=Object.values(_.runs).find(p=>p.kind===Ke["site-audit"]&&p.projectId===e),P=b.data??[],U=P.find(p=>p.status==="queued"||p.status==="running"),Q=P.at(-1),Y=N.isPending||!!G||!!U,se=N.isPending?"starting":U?.status??G?.lastAnnouncedStatus,L=w.useCallback(async()=>{const p=await Promise.all([R.refetch(),m.refetch(),...i?[]:[g.refetch()]]),H=p.find(T=>T.error);if(H?.error)throw H.error;return p[0]},[i,m.refetch,R.refetch,g.refetch]);w.useEffect(()=>{i||j||!Q||Q.status!=="completed"&&Q.status!=="partial"||R.data?.runId===Q.id||F.current===Q.id||(F.current=Q.id,L().catch(p=>{Pt({title:"Technical AEO auto-refresh failed",detail:p instanceof Error?p.message:"Could not load the completed audit.",tone:"negative",dedupeKey:`technical-aeo:auto-refresh:${n}`,dedupeMode:"replace"})}))},[j,i,Q?.id,Q?.status,n,L,R.data?.runId]);const ge=async()=>{C(!0);try{const p=await L();Pt({title:"Technical AEO refreshed",detail:Y?"The audit is still running. This view will refresh again when it finishes.":p.data?.hasData?`Latest score is ${p.data.aggregateScore}/100 from ${p.data.pagesAudited} audited page${p.data.pagesAudited===1?"":"s"}.`:"No audit data yet. Run an audit to crawl the sitemap.",tone:p.data?.hasData?"positive":"caution",dedupeKey:`technical-aeo:refresh:${n}`,dedupeMode:"replace"})}catch(p){Pt({title:"Technical AEO refresh failed",detail:p instanceof Error?p.message:"Could not reload technical audit data.",tone:"negative",dedupeKey:`technical-aeo:refresh:${n}`,dedupeMode:"replace"})}finally{C(!1)}},ze=()=>{$t(Ke["site-audit"])&&!l||N.mutate({projectName:n,projectId:e})},ce=se==="running"?"Audit running":se==="queued"?"Audit queued":"Starting audit",E=R.data,pe=m.data?.pages??Gr,ie=a?pe.find(p=>p.status==="success"&&p.overallScore<70)??pe.find(p=>p.status==="success"):void 0,ae=!!(ie&&ie.overallScore<70),Ee=me({...Rn({client:le,path:{name:n},query:{...j?{runId:j}:{},url:ie?.url??""}}),enabled:a&&!!ie}),ue=(E?.pagesErrored??0)>0,he=d&&ue,xe=w.useMemo(()=>he?pe.filter(p=>p.status==="error"):pe,[pe,he]),J=_r({rows:xe,getSearchText:Cr}),ee=E?E.pagesAudited>pe.length:!1;if(w.useEffect(()=>{f(!1),h(null)},[a,j,i]),R.isLoading)return s.jsxs("div",{className:`flex min-h-40 items-center justify-center gap-2 text-sm text-secondary ${i?"":"mt-6"}`,role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading page health..."]});if(R.error)return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:`flex flex-col gap-4 rounded-lg border border-negative bg-negative-soft px-5 py-5 sm:flex-row sm:items-center sm:justify-between ${i?"":"mt-6"}`,role:"alert",children:[s.jsxs("div",{className:"flex min-w-0 gap-3",children:[s.jsx(Bt,{className:"mt-0.5 size-4 shrink-0 text-negative","aria-hidden":"true"}),s.jsxs("div",{children:[i?s.jsx("h3",{className:"font-semibold text-negative",children:"Page health could not load"}):s.jsx("h2",{className:"font-semibold text-negative",children:"Page health could not load"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"The saved audit could not be read. Try loading it again."})]})]}),s.jsxs(M,{type:"button",variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{ge()},disabled:D,children:[s.jsx(Rt,{className:`size-4 ${D?"motion-safe:animate-spin":""}`,"aria-hidden":"true"}),D?"Trying again...":"Try again"]})]}),o]});if(!E||!E.hasData)return i?s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"rounded-lg border border-default bg-surface-subtle px-5 py-7 text-center",children:[s.jsx(mn,{className:"mx-auto size-7 text-muted","aria-hidden":"true"}),s.jsx("h2",{className:"mt-3 text-base font-semibold text-heading",children:"Page health unavailable"}),s.jsx("p",{className:"mx-auto mt-2 max-w-md text-sm text-secondary",children:c?In:"Run a new Site Health scan to calculate page-level technical findings."})]}),o]}):s.jsxs(qs,{className:"surface-card mt-6 p-8 text-center",children:[s.jsx(mn,{className:"mx-auto mb-3 h-8 w-8 text-muted","aria-hidden":"true"}),s.jsx("h2",{className:"text-base font-semibold text-heading",children:"No technical audit yet"}),s.jsx("p",{className:"supporting-copy mx-auto mt-2 max-w-md",children:"A technical AEO audit crawls your sitemap and scores every page for structured data, AI-readable content, crawler access, freshness, and more, then rolls it up into one site score."}),!zt()&&!c&&s.jsx("div",{className:"mt-5 flex items-center justify-center gap-3",children:s.jsxs(Ft,{type:"button",onClick:ze,disabled:Y,children:[Y?s.jsx(je,{className:"mr-1.5 h-4 w-4 motion-safe:animate-spin","aria-hidden":"true"}):s.jsx(Ht,{className:"mr-1.5 h-4 w-4","aria-hidden":"true"}),Y?ce:"Run first audit"]})}),Y?s.jsx("p",{className:"mt-3 text-xs text-muted",role:"status","aria-live":"polite",children:"The dashboard will refresh automatically when the audit finishes."}):null]});const B=E.deltaScore==null?null:`${E.deltaScore>=0?"+":""}${E.deltaScore} vs previous`,re=E.trend==="up"?"positive":E.trend==="down"?"negative":"neutral",Le=g.data?.points??[],oe=Le.map(p=>({runId:p.runId,date:p.auditedAt,score:p.aggregateScore})),Ae=t===void 0&&x!==null,rt=pe.filter(p=>p.status==="success"),We=E.factors.filter(p=>p.pagesPartial+p.pagesFailing>0).length,Fe=E.runStatus==="partial",Te=E.crossCuttingIssues.some(p=>p.topRecommendations.length>0);function Ue(p){const H=[];for(const T of rt){const K=T.factors.find(te=>te.id===p);K&&K.score<70&&H.push({url:T.url,score:K.score})}return H.sort((T,K)=>T.score-K.score)}return s.jsxs("div",{className:i?"":"mt-6",children:[i?s.jsxs("section",{className:"flex flex-col gap-3 border-b border-default pb-5 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-secondary",children:Fe?"Score so far":"Site score"}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[s.jsxs("span",{"aria-label":Fe?`Score so far ${E.aggregateScore} out of 100, from a scan that did not cover the whole site`:`Site score ${E.aggregateScore} out of 100`,className:`inline-flex items-baseline gap-1 font-mono tabular-nums ${Et(E.aggregateScore)}`,children:[s.jsx("span",{className:"text-3xl font-semibold",children:E.aggregateScore}),s.jsx("span",{className:"text-sm text-muted",children:"/100"})]}),s.jsx(X,{tone:pt(E.aggregateScore),children:mt(E.aggregateScore)}),Fe?s.jsx(X,{tone:"caution",children:"Part of the site"}):null,B?s.jsx(X,{tone:re,children:B}):null]})]}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm tabular-nums text-secondary",children:[s.jsxs("span",{children:[E.pagesAudited," page",E.pagesAudited===1?"":"s"," checked"]}),s.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"·"}),s.jsxs("span",{children:[We," check",We===1?"":"s"," with pages below pass"]}),E.pagesErrored>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"·"}),s.jsxs("span",{className:"text-negative",children:[E.pagesErrored," crawl error",E.pagesErrored===1?"":"s"]})]}):null]})]}):s.jsxs("section",{className:"surface-card flex flex-wrap items-start justify-between gap-6 rounded-lg border border-default bg-surface p-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:Ae?"Technical AEO history":"Technical AEO"}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-baseline gap-3",children:[s.jsx("span",{className:`text-4xl font-semibold tabular-nums ${Et(E.aggregateScore)}`,children:E.aggregateScore}),s.jsx("span",{className:"text-lg text-muted",children:"/ 100"}),s.jsx(X,{tone:pt(E.aggregateScore),children:mt(E.aggregateScore)}),B?s.jsx(X,{tone:re,children:B}):null,Y?s.jsx(X,{tone:"neutral",children:ce}):null]}),s.jsxs("p",{className:"supporting-copy mt-2 tabular-nums",children:[E.pagesDiscovered," URL",E.pagesDiscovered===1?"":"s"," in sitemap · ",E.pagesAudited," audited · ",E.pagesSkipped," skipped · ",E.pagesErrored," errored"]}),s.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 text-xs text-muted",children:[s.jsx("span",{className:"text-faint",children:"Sitemap:"}),s.jsx("a",{href:E.sitemapUrl??"#",target:"_blank",rel:"noreferrer",className:"max-w-[22rem] truncate text-secondary underline decoration-mono-700 underline-offset-2 hover:text-strong",children:E.sitemapUrl}),s.jsx(fe,{text:"Every audit re-reads this sitemap, so pages you add or remove are picked up on the next run. Discovered/audited counts and the score reflect the sitemap at the time of the latest run. Override it with `canonry technical-aeo run <project> --sitemap-url <url>`."})]}),E.auditedAt?s.jsxs("p",{className:"mt-0.5 text-xs text-faint",children:["Audited ",new Date(E.auditedAt).toLocaleString()]}):null,Y?s.jsx("p",{className:"mt-1 text-xs text-muted",role:"status","aria-live":"polite",children:"Results refresh automatically when this audit finishes."}):null]}),s.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[t===void 0&&Le.length>1?s.jsxs("select",{"aria-label":"View a Technical AEO audit",value:x??"",onChange:p=>A(p.target.value||null),className:"min-h-11 rounded-md border border-base bg-bg px-3 text-sm text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[s.jsx("option",{value:"",children:"Latest audit"}),[...Le].reverse().slice(1).map(p=>s.jsxs("option",{value:p.runId,children:[new Date(p.auditedAt).toLocaleDateString()," · ",p.aggregateScore,"/100"]},p.runId))]}):null,s.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:()=>{ge()},disabled:D,children:[s.jsx(Rt,{className:`mr-1.5 h-4 w-4 ${D?"motion-safe:animate-spin":""}`,"aria-hidden":"true"}),D?"Refreshing…":"Refresh"]}),!zt()&&!c&&s.jsxs(Ft,{type:"button",size:"sm",onClick:ze,disabled:Y,children:[Y?s.jsx(je,{className:"mr-1.5 h-4 w-4 motion-safe:animate-spin","aria-hidden":"true"}):s.jsx(Ht,{className:"mr-1.5 h-4 w-4","aria-hidden":"true"}),Y?ce:"Re-run audit"]})]})]}),r,!i&&oe.length>=2?s.jsxs("section",{className:"page-section-divider",children:[s.jsxs("div",{className:"section-head",children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:"Trend"}),s.jsx("h2",{children:"Site score over time"})]}),s.jsxs("div",{className:"mt-3 h-56",children:[s.jsxs("p",{className:"sr-only",children:["Technical AEO scores range from ",Math.min(...oe.map(p=>p.score))," to ",Math.max(...oe.map(p=>p.score))," across ",oe.length," audits. Use the audit selector to inspect a previous scorecard."]}),s.jsx("div",{className:"h-full","aria-hidden":"true",children:s.jsx(ji,{width:"100%",height:"100%",children:s.jsxs(ki,{data:oe,margin:{top:8,right:8,bottom:0,left:0},children:[s.jsx(Si,{stroke:yi,vertical:!1}),s.jsx(Ei,{dataKey:"date",tick:xn,tickLine:!1,axisLine:{stroke:gn},tickFormatter:Pr,minTickGap:24}),s.jsx(Ai,{domain:[0,100],ticks:[0,25,50,75,100],tick:xn,tickLine:!1,axisLine:!1,width:32}),s.jsx(_i,{...wi,cursor:{stroke:gn,strokeWidth:1},labelFormatter:Rr,formatter:p=>[`${p}/100`,"Site score"]}),s.jsx($i,{type:"monotone",dataKey:"score",name:"score",stroke:bn.positive,strokeWidth:2.5,dot:{r:2.5,fill:bn.positive,strokeWidth:0},isAnimationActive:!1})]})})})]})]}):null,s.jsxs("section",{className:i?"pt-5":"page-section-divider",children:[i?s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold text-heading",children:a?"Checks":"Technical findings"}),s.jsx("p",{className:"mt-1 max-w-2xl text-sm text-secondary",children:a?Te?"Open a check to see affected pages and recommended fixes.":ie?ae?"Open a check to see affected pages. Page-level evidence for the first page to fix appears below.":"Open a check to see affected pages. Page-level evidence for one audited page appears below.":"Open a check to see affected pages and score details.":Te?"Select a check to see affected pages and recommended fixes.":"Select a check to see affected pages and score details."})]}):s.jsxs("div",{className:"section-head",children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:"Scorecard"}),s.jsxs("h2",{className:"inline-flex items-center gap-1.5",children:["Ranking factors",s.jsx(fe,{text:"Each factor is scored 0–100 per page (via the aeo-audit engine), then averaged across all successfully-audited pages. Pass ≥70, partial 40–69, fail <40. Expand a row to see which pages fall short and how to fix it."})]})]}),s.jsx("div",{className:"evidence-table-wrap mt-3",children:s.jsxs("table",{className:`evidence-table ${i?"min-w-[42rem]":""}`,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:i?"Technical check":"Factor"}),i?null:s.jsx("th",{className:"text-right",children:"Weight"}),s.jsx("th",{className:"text-right",children:i?"Score":"Avg"}),s.jsx("th",{children:"Status"}),s.jsx("th",{children:i?"Pages affected":"Pass / Partial / Fail"})]})}),s.jsx("tbody",{children:E.factors.map(p=>{const H=u===p.id,T=E.crossCuttingIssues.find(k=>k.factorId===p.id),K=H?Ue(p.id):[],te=p.pagesPartial+p.pagesFailing,ye=p.pagesPassing+te,we=!!T?.topRecommendations.length,O=we&&te>0;return s.jsxs(w.Fragment,{children:[s.jsxs("tr",{className:H?"bg-surface-subtle":void 0,children:[s.jsx("td",{children:s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 text-left font-medium text-strong outline-none hover:text-primary focus-visible:text-primary focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-mono-400","aria-expanded":H,onClick:()=>h(H?null:p.id),children:[H?s.jsx(Mn,{className:"size-4 shrink-0 text-muted","aria-hidden":"true"}):s.jsx(Lt,{className:"size-4 shrink-0 text-muted","aria-hidden":"true"}),p.name]})}),i?null:s.jsxs("td",{className:"text-right tabular-nums text-muted",children:[p.weight,"%"]}),s.jsxs("td",{className:"text-right font-mono tabular-nums text-strong",children:[p.avgScore,i?s.jsx("span",{className:"text-muted",children:"/100"}):null]}),s.jsx("td",{children:s.jsx(X,{tone:Dr(p.status),children:mt(p.avgScore)})}),i?s.jsxs("td",{className:`tabular-nums ${te>0?"text-strong":"text-muted"}`,children:[te," of ",ye]}):s.jsxs("td",{className:"tabular-nums text-secondary",children:[s.jsx("span",{className:"text-positive-400",children:p.pagesPassing})," / ",s.jsx("span",{className:"text-caution-400",children:p.pagesPartial})," / ",s.jsx("span",{className:"text-negative-400",children:p.pagesFailing})]})]}),H?s.jsx("tr",{className:"bg-surface-subtle",children:s.jsx("td",{colSpan:i?4:5,className:"px-4 pb-5 pt-0",children:s.jsxs("div",{className:`grid gap-5 border-t border-subtle pt-4 ${O?"lg:grid-cols-2":""}`,children:[we&&T?s.jsxs("section",{"aria-labelledby":`technical-finding-${p.id}-fixes`,children:[s.jsx("h4",{id:`technical-finding-${p.id}-fixes`,className:"text-sm font-semibold text-heading",children:"Recommended fixes"}),s.jsx("ol",{className:"mt-2 list-decimal space-y-1.5 pl-5 marker:text-muted",children:T.topRecommendations.map((k,W)=>s.jsx("li",{className:"pl-1 text-sm text-secondary",children:k},W))}),i?s.jsxs("p",{className:"mt-3 text-xs text-muted",children:["Weight: ",p.weight,"% of the site score"]}):null]}):te===0?s.jsx("p",{className:"text-sm text-secondary",children:"Every audited page passes this check."}):null,te>0?s.jsxs("section",{"aria-labelledby":`technical-finding-${p.id}-pages`,children:[s.jsxs("h4",{id:`technical-finding-${p.id}-pages`,className:"text-sm font-semibold text-heading",children:["Affected pages (",te,")"]}),i&&m.isLoading?s.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-secondary",role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading affected pages..."]}):i&&m.error?s.jsxs("div",{className:"mt-3",role:"alert",children:[s.jsx("p",{className:"text-sm font-medium text-negative",children:"Affected pages could not load"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Try the page-level audit read again."}),s.jsxs(M,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:()=>{m.refetch()},disabled:m.isFetching,children:[m.isFetching?s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}):s.jsx(Rt,{className:"size-4","aria-hidden":"true"}),m.isFetching?"Retrying affected pages...":"Retry affected pages"]})]}):K.length>0?s.jsx("ul",{className:"mt-2 space-y-1.5",children:K.slice(0,Ot).map(k=>s.jsxs("li",{className:"flex min-w-0 items-center gap-2 text-sm",children:[s.jsx("span",{className:`w-8 shrink-0 text-right font-mono tabular-nums ${Et(k.score)}`,children:k.score}),s.jsx("a",{href:k.url,target:"_blank",rel:"noreferrer",className:"min-w-0 truncate text-link outline-none hover:text-heading focus-visible:ring-2 focus-visible:ring-mono-400",title:k.url,children:k.url})]},k.url))}):s.jsx("p",{className:"mt-2 text-sm text-secondary",children:"Page details are not available in the loaded audit sample."}),K.length>Ot?s.jsxs("p",{className:"mt-2 text-xs text-muted",children:["+ ",K.length-Ot," more below pass"]}):null,ee&&(!i||!m.isLoading&&!m.error)?s.jsxs("p",{className:"mt-2 text-xs text-muted",children:["Showing the worst ",pe.length," audited pages."]}):null]}):null]})})}):null]},p.id)})})]})})]}),a&&ie?s.jsxs("section",{className:"border-t border-default pt-5","aria-labelledby":"onboarding-page-evidence-heading",children:[s.jsxs("div",{className:"flex flex-col justify-between gap-3 sm:flex-row sm:items-start",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{id:"onboarding-page-evidence-heading",className:"text-base font-semibold text-heading",children:ae?"First page to fix":"Example audited page"}),s.jsx("a",{href:ie.url,target:"_blank",rel:"noreferrer",className:"mt-1 block max-w-2xl truncate font-mono text-sm text-link outline-none hover:text-heading focus-visible:ring-2 focus-visible:ring-mono-400",title:ie.url,children:ie.url})]}),s.jsxs(X,{tone:pt(ie.overallScore),children:[Math.round(ie.overallScore),"/100"]})]}),s.jsx(ss,{audit:Ee.data,isLoading:Ee.isLoading,error:Ee.error,onRetry:()=>{Ee.refetch()}})]}):null,!i&&E.crossCuttingIssues.length>0?s.jsxs("section",{className:"page-section-divider",children:[s.jsxs("div",{className:"section-head",children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:"Opportunities"}),s.jsxs("h2",{className:"inline-flex items-center gap-1.5",children:["Prioritized fixes",s.jsx(fe,{text:"Factors scoring below pass across the most pages, ranked by site-wide impact. Fixing one of these typically lifts many pages at once."})]})]}),s.jsx("div",{className:"mt-3 divide-y divide-mono-800/60 overflow-hidden rounded-lg border border-default",children:E.crossCuttingIssues.map(p=>s.jsxs("div",{className:"p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("span",{className:"text-sm font-medium text-heading",children:p.factorName}),s.jsx(X,{tone:pt(p.avgScore),children:mt(p.avgScore)}),s.jsxs("span",{className:"text-xs tabular-nums text-muted",children:["avg ",p.avgScore," · affects ",p.affectedPages," of ",p.totalPages," pages (",p.affectedPct,"%)"]})]}),p.topRecommendations.length>0?s.jsx("ul",{className:"mt-2 space-y-1",children:p.topRecommendations.map((H,T)=>s.jsxs("li",{className:"flex gap-2 text-sm text-secondary",children:[s.jsx("span",{className:"select-none text-faint",children:"→"}),s.jsx("span",{children:H})]},T))}):null]},p.factorId))})]}):null,i?null:s.jsxs("section",{className:"page-section-divider",children:[s.jsxs("div",{className:"section-head section-head-inline",children:[s.jsxs("div",{children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:"Pages"}),s.jsx("h2",{children:"Per-page breakdown"})]}),ue?s.jsxs("div",{className:"segmented",role:"group","aria-label":"Filter pages",children:[s.jsxs("button",{type:"button",onClick:()=>{f(!1),J.setPage(1)},"aria-pressed":!he,className:`segmented-option min-h-11 tabular-nums ${he?"":"segmented-option-active"}`,children:["All ",E.pagesAudited]}),s.jsxs("button",{type:"button",onClick:()=>{f(!0),J.setPage(1)},"aria-pressed":he,className:`segmented-option min-h-11 tabular-nums ${he?"segmented-option-active text-negative":""}`,children:["Errors ",E.pagesErrored]})]}):null]}),pe.length>0?s.jsx($r,{value:J.query,onChange:J.setQuery,label:"Filter audited page URLs",placeholder:"Filter page URL or query parameters",className:"mt-3 max-w-md"}):null,J.totalRows===0?s.jsx("p",{className:"supporting-copy mt-3",children:J.hasQuery?"No pages match this filter.":"No pages recorded."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"evidence-table-wrap mt-3",children:s.jsxs("table",{className:"evidence-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-right",children:"Score"}),s.jsx("th",{children:"Status"}),s.jsx("th",{className:"w-full",children:"URL"})]})}),s.jsx("tbody",{children:J.rows.map(p=>s.jsxs("tr",{children:[s.jsx("td",{className:"text-right tabular-nums",children:p.status==="error"?s.jsxs("span",{className:"inline-flex items-center gap-1 text-negative-400",children:[s.jsx(Bt,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"err"]}):s.jsx("span",{className:Et(p.overallScore),children:p.overallScore})}),s.jsx("td",{children:p.status==="error"?s.jsx(X,{tone:"negative",children:"Error"}):s.jsx(X,{tone:pt(p.overallScore),children:mt(p.overallScore)})}),s.jsx("td",{className:"w-full max-w-0",children:s.jsx("a",{href:p.url,target:"_blank",rel:"noreferrer",className:"block truncate text-neutral hover:text-heading",title:p.status==="error"?p.error??p.url:p.url,children:s.jsx(Ar,{value:p.url,headLength:54,tailLength:20,title:p.status==="error"?p.error??p.url:p.url})})})]},p.url))})]})}),s.jsx(Lr,{page:J.page,pageSize:J.pageSize,visibleRows:J.rows.length,totalRows:J.totalRows,onPageChange:J.setPage,itemLabel:J.hasQuery?"matches":"rows"}),ee?s.jsxs("p",{className:"mt-2 text-xs text-faint",children:["Showing the worst ",pe.length," of ",E.pagesAudited," audited pages."]}):null]})]})]})}const Xe=[{id:"map",label:"Map"},{id:"inventory",label:"Pages"},{id:"technical",label:"Page health"}],as={map:"Explore how pages, site sections, and internal links fit together.",inventory:"Review discovered pages and the links that shape their visibility.",technical:"Prioritize audit findings and inspect the pages that need work."},rs=[{id:"all",label:"All",healthState:void 0},{id:"hidden",label:"Hidden pages",healthState:ti.hidden}],Mr={[Ye.metaRobotsNoindex]:"Hidden by meta robots tag",[Ye.xRobotsNoindex]:"Hidden by X-Robots-Tag header",[Ye.robotsDisallow]:"Blocked by robots.txt",[Ye.redirectTerminal]:"Redirects to another page",[Ye.canonicalToOther]:"Points to another page as canonical",[Ye.notHtmlOrUnavailable]:"Not an HTML page, so it was not scored"},Or=new Map(Object.entries(Mr));function zr(n){return Or.get(n)??n}const Fr=20,Ur=200,Br=100,os=100,Hr=50,Kr=ui,Wr=ci,qr=2e4,Vr=3,ke=new Intl.NumberFormat,Yr=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}),Qr={eligible:"positive",hidden:"caution",resource:"neutral",redirect:"neutral",failed:"negative",unchecked:"neutral"};function ls(n){if(!n)return"Date unavailable";const e=new Date(n);return Number.isNaN(e.getTime())?"Date unavailable":Yr.format(e)}function Xr(n){return n.replaceAll("_"," ").replaceAll("-"," ").replace(/\b\w/g,e=>e.toUpperCase())}function ds(n){const e=et(n);return{label:Wt(e),tone:Qr[e]}}function cs(n){if(n==null)return"Not scored";const e=n<=1?n*100:n;return`${Math.round(e)}%`}function Zr(n){return n.auditScore==null?"Not checked":`${Math.round(n.auditScore)}/100`}function I(n){return n==null?"Not available":ke.format(n)}const Jr={clicksFromHome:"How many clicks it takes to reach this page from the home page, following links.",linksIn:"How many other pages link to this page.",linksOut:"How many other pages this page links to.",linkImportance:"How much link value flows to this page, based on how many pages link to it and how important those pages are. Shown relative to the highest page on this site, which is 100%.",technicalScore:"How well this page is set up for AI and search engines to read, from 0 to 100. Open a page to see what it is marked down for.",linkTimes:"How many times this link appears on the page it comes from.",pagesFound:"How many pages this scan discovered, whether or not it could load them.",pagesChecked:"How many of the pages it found this scan actually loaded.",internalLinks:"How many links between pages on this site the scan recorded."},eo=new Set(["clicksFromHome","linkImportance","internalLinks","pagesFound","pagesChecked"]);function Ce(n,e){const t=Jr[n];return eo.has(n)?`${t} This always counts every link, including menu and footer.`:n==="technicalScore"||n==="linkTimes"?t:e?`${t} Right now this counts only links written in your page text. Menu and footer links are hidden.`:`${t} This counts every link, including menu and footer.`}function us(n,e){return`${ke.format(n)} ${e}${n===1?"":"s"}`}function to(n,e){if(!n||!e)return null;try{const t=new URL(n),i=new URL(e),a=r=>r.hostname.toLowerCase().replace(/\.$/,"").replace(/^www\./,"");return a(t)!==a(i)?{requested:t.host,effective:i.host}:null}catch{return null}}function no(n){return n==="completed"?"positive":n==="partial"||n==="queued"||n==="running"?"caution":n==="failed"||n==="cancelled"?"negative":"neutral"}function so(n){const e=ls(n.finishedAt??n.startedAt??n.createdAt),t=n.hasCrawlData?"":" · Score only";return`${e} · ${Xr(n.status)}${t}`}const io={complete:"This scan finished on its own.",unknown:"This scan stopped before it checked every page it found.","max-pages":"This scan stopped at the page limit, so some pages were not checked.","max-edges":"This scan stopped at the link limit, so some links are missing.","max-fetches":"This scan stopped after checking as many pages as it could.","max-duration":"This scan ran out of time, so some pages were not checked.","max-bytes":"This scan stopped at the data limit, so some pages were not checked.","max-page-bytes":"This scan skipped a page that was too large to read.","max-depth":"This scan stopped at the depth limit, so deeper pages were not checked.","max-links-per-page":"This scan stopped reading links on pages that had too many.","max-query-variants":"This scan stopped at the limit for pages that differ only by a query string.","max-sitemap-fanout":"This scan stopped at the sitemap limit, so some sitemaps were not read.","max-sitemap-urls":"This scan stopped at the sitemap page limit, so some pages were not found.","root-host-redirect":"The site moved to another address during this scan."},ao=new Map(Object.entries(io)),ro=[{value:null,label:`Default (${li.toLocaleString()} pages)`},{value:Ut,label:"100 pages (quick look)"},{value:500,label:"500 pages"},{value:2500,label:"2,500 pages"},{value:1e4,label:"10,000 pages"}],hs=[{value:null,label:`Default (${Vs} clicks)`},{value:1,label:"1 click from the home page"},{value:2,label:"2 clicks"},{value:3,label:"3 clicks"},{value:5,label:"5 clicks"},{value:20,label:"20 clicks"},{value:50,label:"50 clicks"},{value:100,label:"100 clicks (maximum)"}],oo={"max-pages":"Raise the page budget in Scan settings.","max-edges":"Raise the page budget in Scan settings.","max-fetches":"Raise the page budget in Scan settings.","max-duration":"Try a smaller scan in Scan settings.","max-depth":"Raise the crawl depth in Scan settings."};function lo(n,e=!1){if(!n)return null;const t=oo[n]??null;return t&&e?`${t.replace(/ in Scan settings\.$/,"")} in Site Health's Scan settings after setup.`:t}function co(n){return n?ao.get(n)??`This scan stopped early: ${n}.`:"This scan stopped before it checked every page it found."}const tn={applied:"This scan told menu and footer links apart by how often the same link repeats across pages. It cannot spot a link written into the page text when its wording matches the menu. Run a new scan to read the page layout instead.","applied-placement":"This scan read where each link sits in the page, so links in the page text are separated from the menu, header, and footer even when they use the same wording.","applied-placement-with-ubiquity":"This scan read where each link sits in the page. Some pages mark out no menu or main area, so those links fall back to how often the link repeats across pages, which can miss a link written into the page text.","applied-placement-partial":`This scan read where each link sits in the page. Some pages mark out no menu or main area, and this scan found fewer than ${fn} pages, so nothing could tell those links apart. They are counted as links in your page text, which is what a link no rule marked as menu, header, or footer means here.`,"unavailable-too-few-pages":`This scan found fewer than ${fn} pages and did not read where each link sits in the page. On a site that small every link is on most pages, so menu and footer links cannot be told apart from the rest.`,"unavailable-legacy-scan":"This scan ran before menu and footer links were separated. Run a new scan to split them out."},uo=new Map(Object.entries(tn));function fs(n){return n===null?"":uo.get(n)??tn["unavailable-legacy-scan"]}const ps="Scroll to zoom. Click a page to inspect it.",ms="Observed links to and from this page in the selected scan.",gs="Page positions on this map were set before menu and footer links were separated. Run a new scan to update them.";function xs(n){if(n.filterUnavailable)return`All ${us(n.totalEdgeCount,"link")} shown.`;const e=`${ke.format(n.contentEdgeCount)} link${n.contentEdgeCount===1?"":"s"} in your page text`,t=ke.format(n.templateEdgeCount);return n.showTemplateLinks?`${e}, ${t} menu and footer.`:`${e}. ${t} menu and footer link${n.templateEdgeCount===1?"":"s"} hidden.`}const bs="Menu, header, and footer links repeat on every page, so they say nothing about which pages relate to each other. Links written in your page text do.";function ys(n,e){const t=[bs,fs(n)];return e.staleLayout&&t.push(gs),t.filter(Boolean).join(" ")}function ho(n,e,t){if(n==="disabled")return{label:"Broken links: not checked",tone:"neutral"};const i=t??0,a=i>0?`, ${ke.format(i)} unchecked`:"";return n==="complete"?e?{label:`Broken links: ${ke.format(e)} found${a}`,tone:"negative"}:i>0?{label:`Broken links: none found, ${ke.format(i)} unchecked`,tone:"caution"}:{label:"Broken links: none found",tone:"positive"}:n==="partial"?{label:`Broken links: ${ke.format(e??0)} found so far${a}`,tone:"caution"}:{label:"Broken links: not checked",tone:"neutral"}}function Vt(n){return n.showTemplateLinks||!n.known?{value:I(n.total),hiddenNote:null,filtered:!1}:{filtered:!0,value:n.truncated?`${I(n.visible)}+`:I(n.visible),hiddenNote:n.hidden===0?null:n.truncated?`At least ${I(n.hidden)} menu and footer hidden`:`${I(n.hidden)} menu and footer hidden`}}function At({label:n,value:e,hiddenNote:t,help:i}){return s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("dt",{className:"flex items-center gap-1 text-xs text-muted",children:[n,s.jsx(fe,{text:i})]}),s.jsx("dd",{className:"mt-1 text-sm font-medium tabular-nums text-heading",children:e}),t&&s.jsx("dd",{className:"mt-0.5 text-xs text-muted",children:t})]})}function fo({page:n,inbound:e,outbound:t}){return s.jsx(s.Fragment,{children:s.jsxs("dl",{className:"grid grid-cols-2 divide-x divide-y divide-default rounded-lg border border-default sm:grid-cols-4 sm:divide-y-0",children:[s.jsx(At,{label:"Clicks from home",value:String(n.depth??"Not reached"),help:Ce("clicksFromHome",!1)}),s.jsx(At,{label:"Links in",value:e.value,hiddenNote:e.hiddenNote,help:Ce("linksIn",e.filtered)}),s.jsx(At,{label:"Links out",value:t.value,hiddenNote:t.hiddenNote,help:Ce("linksOut",t.filtered)}),s.jsx(At,{label:"Link importance",value:cs(n.linkScoreNormalized),help:Ce("linkImportance",!1)})]})})}function ws(n,e,t){if(e===0)return n==="inbound"?"Nothing links to this page.":"This page links to nothing.";const i=n==="inbound"?"No links in the page text point here.":"No links in the page text lead away from here.",a=t?`At least ${I(e)} menu and footer links hidden.`:`${us(e,"menu and footer link")} hidden.`;return`${i} ${a}`}function Je({label:n,metric:e}){return s.jsxs("span",{className:"inline-flex items-center gap-1",children:[n,s.jsx(fe,{text:Ce(e,!1)})]})}function Ln({direction:n,edges:e,truncated:t,rootHost:i,hiddenTemplateCount:a}){const r=n==="inbound"?"Links in":"Links out";return s.jsxs("section",{className:"min-w-0","aria-labelledby":`site-health-${n}-heading`,children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsxs("h4",{id:`site-health-${n}-heading`,className:"text-sm font-medium text-heading",children:[r," (",I(e.length),")"]}),t&&s.jsxs("span",{className:"text-xs text-muted",children:["First ",os]})]}),e.length===0?s.jsx("p",{className:"rounded-lg border border-subtle bg-surface-subtle px-3 py-4 text-sm text-secondary",children:ws(n,a,t)}):s.jsx("div",{className:"evidence-table-wrap max-h-64 overflow-auto",children:s.jsxs("table",{className:"evidence-table site-health-table min-w-[420px]",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{scope:"col",children:"Page"}),s.jsx("th",{scope:"col",children:"Anchor text"}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Times",metric:"linkTimes"})})]})}),s.jsx("tbody",{children:e.map(o=>{const l=n==="inbound"?o.sourceUrl:o.targetUrl;return s.jsxs("tr",{children:[s.jsx("td",{className:"max-w-64 truncate font-mono",title:l,children:Fn(l,i)}),s.jsx("td",{className:"max-w-52 truncate",title:o.anchors.join(", ")||void 0,children:o.anchors.join(", ")||"No anchor text"}),s.jsx("td",{className:"tabular-nums",children:I(o.occurrences)})]},o.edgeKey)})})]})})]})}function po(n){return n&&"indexabilityReasons"in n?n.indexabilityReasons:[]}function Tn({page:n,isLoading:e,error:t,inbound:i,outbound:a,inboundTruncated:r,outboundTruncated:o,audit:l,auditLoading:c,auditError:d,onRetryAudit:f,rootHost:u,reasonSource:h,reasonsState:x,onRetryReasons:A,showTemplateLinks:j}){if(!n)return s.jsxs("section",{className:"border-t border-default pt-5","aria-label":"Selected page details",children:[s.jsx("h3",{className:"text-base font-medium text-heading",children:"Page links"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Select a page to inspect its internal links and crawl signals."})]});const D=ds(n),C=po(h??n),F=j?i:i.filter(G=>!G.isTemplate),R=j?a:a.filter(G=>!G.isTemplate),g=!e&&!t,m=i.length-F.length,b=a.length-R.length,N=Vt({total:n.inboundUniqueEdges,visible:F.length,hidden:m,truncated:r,showTemplateLinks:j,known:g}),_=Vt({total:n.outboundUniqueEdges,visible:R.length,hidden:b,truncated:o,showTemplateLinks:j,known:g});return s.jsxs("section",{className:"border-t border-default pt-5","aria-labelledby":"site-health-page-inspector-title",children:[s.jsxs("div",{className:"flex flex-col justify-between gap-3 sm:flex-row sm:items-start",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h3",{id:"site-health-page-inspector-title",className:"break-words font-mono text-base font-semibold text-heading",children:n.path}),s.jsx(X,{tone:D.tone,children:D.label})]}),s.jsx("p",{className:"mt-1 break-all text-sm text-secondary",children:n.url}),x==="loading"?s.jsx("p",{className:"mt-2 text-sm text-secondary",role:"status",children:"Loading page details..."}):x==="error"?s.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-2 text-sm text-negative",role:"alert",children:["Page details could not be loaded, so any reason this page is hidden is unknown.",s.jsx(M,{type:"button",variant:"secondary",size:"sm",onClick:A,children:"Try again"})]}):C.length>0?s.jsx("ul",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-sm text-secondary","aria-label":"Why this page is hidden",children:C.map(G=>s.jsx("li",{children:zr(G)},G))}):null]}),s.jsx(M,{asChild:!0,variant:"secondary",size:"sm",children:s.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",children:["Open page ",s.jsx(bi,{className:"size-3.5","aria-hidden":"true"})]})})]}),s.jsx("div",{className:"mt-4",children:s.jsx(ss,{audit:l,isLoading:c,error:d,onRetry:f})}),s.jsxs("section",{className:"mt-5 border-t border-default pt-5","aria-labelledby":"site-health-page-links-heading",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("h3",{id:"site-health-page-links-heading",className:"text-base font-semibold text-heading",children:"Internal links"}),s.jsx(fe,{text:ms})]}),s.jsx("div",{className:"mt-4",children:s.jsx(fo,{page:n,inbound:N,outbound:_})}),s.jsx("div",{className:"mt-5",children:e?s.jsxs("div",{className:"flex items-center gap-2 py-6 text-sm text-secondary",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading page links..."]}):t?s.jsx("p",{className:"rounded-lg border border-negative bg-negative-soft px-4 py-3 text-sm text-negative",role:"alert",children:"Page links could not be loaded."}):s.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[s.jsx(Ln,{direction:"inbound",edges:F,truncated:r,rootHost:u,hiddenTemplateCount:m}),s.jsx(Ln,{direction:"outbound",edges:R,truncated:o,rootHost:u,hiddenTemplateCount:b})]})})]})]})}function mo({pages:n,total:e,selectedNodeKey:t,onSelect:i,hasNextPage:a,isFetchingNextPage:r,onLoadMore:o,filter:l,onFilterChange:c,filterUnavailable:d}){const[f,u]=w.useState(""),h=f.trim().toLowerCase(),x=w.useMemo(()=>h?n.filter(j=>`${j.path} ${j.url}`.toLowerCase().includes(h)):n,[h,n]),A=h.length>0&&(a||n.length<e);return s.jsxs("section",{"aria-labelledby":"site-health-inventory-heading",children:[s.jsxs("div",{className:"mb-3 flex flex-col justify-between gap-3 sm:flex-row sm:items-end",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"site-health-inventory-heading",className:"text-base font-semibold text-heading",children:"Pages"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:l==="all"?`Showing ${I(n.length)} of ${I(e)} pages found.`:`Showing ${I(n.length)} of ${I(e)} hidden pages.`})]}),s.jsxs("label",{className:"relative block w-full sm:w-72",children:[s.jsx("span",{className:"sr-only",children:"Search loaded pages"}),s.jsx(Yt,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted","aria-hidden":"true"}),s.jsx("input",{type:"search",value:f,onChange:j=>u(j.target.value),placeholder:"Search loaded pages",className:"h-9 w-full rounded-md border border-base bg-bg pl-9 pr-3 text-sm text-primary outline-none placeholder-mono-600 focus:border-strong focus:ring-2 focus:ring-mono-600"})]})]}),s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",role:"group","aria-label":"Filter pages",children:rs.map(j=>s.jsx("button",{type:"button","aria-pressed":l===j.id,onClick:()=>c(j.id),className:`filter-chip ${l===j.id?"filter-chip-active":""}`,children:j.label},j.id))}),s.jsx("div",{className:"evidence-table-wrap",children:s.jsxs("table",{className:"evidence-table site-health-table min-w-[800px]",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{scope:"col",children:"Page"}),s.jsx("th",{scope:"col",title:tt("eligible"),children:"Status"}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Clicks from home",metric:"clicksFromHome"})}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Links in",metric:"linksIn"})}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Links out",metric:"linksOut"})}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Link importance",metric:"linkImportance"})}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Score",metric:"technicalScore"})})]})}),s.jsx("tbody",{children:x.map(j=>{const D=ds(j);return s.jsxs("tr",{className:t===j.nodeKey?"bg-surface-active":void 0,children:[s.jsx("td",{className:"max-w-80",children:s.jsx("button",{type:"button",onClick:()=>i(j.nodeKey),className:"block max-w-full truncate rounded-sm font-mono text-sm font-medium text-link outline-none focus-visible:ring-2 focus-visible:ring-mono-400",title:j.url,children:j.path})}),s.jsx("td",{title:tt(et(j)),children:s.jsx(X,{tone:D.tone,children:D.label})}),s.jsx("td",{className:"tabular-nums",children:j.depth??"Not reached"}),s.jsx("td",{className:"tabular-nums",children:I(j.inboundUniqueEdges)}),s.jsx("td",{className:"tabular-nums",children:I(j.outboundUniqueEdges)}),s.jsx("td",{className:"tabular-nums",children:cs(j.linkScoreNormalized)}),s.jsx("td",{className:"tabular-nums",children:Zr(j)})]},j.nodeKey)})})]})}),x.length===0&&s.jsx("p",{className:"border-x border-b border-default px-4 py-8 text-center text-sm text-secondary",children:h.length===0?d?"This scan cannot be filtered. Run a new scan to filter its pages.":l==="hidden"?"No hidden pages were found in this scan.":"No pages are available.":A?`No matches in the ${I(n.length)} loaded pages. Load more pages to continue searching.`:"No pages match this search."}),a&&s.jsx("div",{className:"flex justify-center border-x border-b border-default px-4 py-3",children:s.jsxs(M,{variant:"secondary",size:"sm",disabled:r,onClick:o,children:[r&&s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),r?"Loading more pages":"Load more pages"]})})]})}function go({projectName:n,runId:e,section:t,onSelect:i}){const[a,r]=w.useState(!1),l=t.pageCount-(t.hasPage?1:0)>0;return s.jsxs("li",{children:[s.jsxs("div",{className:"flex min-h-11 items-center gap-1 px-2 py-1",children:[l?s.jsx("button",{type:"button","aria-label":`${a?"Collapse":"Expand"} ${t.path}`,"aria-expanded":a,onClick:()=>r(c=>!c),className:"flex size-8 shrink-0 items-center justify-center rounded-sm text-muted outline-none hover:bg-surface-hover hover:text-heading focus-visible:ring-2 focus-visible:ring-mono-400",children:a?s.jsx(Mn,{className:"size-3.5","aria-hidden":"true"}):s.jsx(Lt,{className:"size-3.5","aria-hidden":"true"})}):s.jsx("span",{className:"block size-8 shrink-0","aria-hidden":"true"}),s.jsx("button",{type:"button",onClick:()=>i(t.path),className:"min-w-0 flex-1 break-all rounded-sm py-2 text-left font-mono text-sm text-heading outline-none hover:text-link focus-visible:ring-2 focus-visible:ring-mono-400",children:t.path}),s.jsx("span",{className:"shrink-0 px-2 font-mono text-xs text-muted",children:I(t.pageCount)})]}),a&&s.jsx("div",{className:"ml-6 border-l border-default pl-1",children:s.jsx(vs,{projectName:n,runId:e,parentPath:t.path,onSelect:i})})]})}function xo({page:n,onSelect:e}){return s.jsx("li",{className:"bg-surface-subtle",children:s.jsxs("div",{className:"flex min-h-11 items-center gap-1 px-2 py-1",children:[s.jsx("span",{className:"block size-8 shrink-0","aria-hidden":"true"}),s.jsx("button",{type:"button",onClick:()=>e(n.nodeKey),className:"min-w-0 flex-1 break-all rounded-sm py-2 text-left font-mono text-sm font-semibold text-heading outline-none hover:text-link focus-visible:ring-2 focus-visible:ring-mono-400",children:n.path||"/"}),s.jsx("span",{className:"shrink-0 px-2 font-mono text-xs text-muted",children:I(1)})]})})}function vs({projectName:n,runId:e,parentPath:t,onSelect:i,rootPage:a,onSelectRootPage:r}){const o={client:le,path:{name:n},query:{runId:e,parentPath:t,limit:Br}},l=Cn({...di(o),initialPageParam:o,getNextPageParam:d=>d.nextCursor?{path:o.path,query:{...o.query,cursor:d.nextCursor}}:void 0}),c=l.data?.pages.flatMap(d=>d.children)??[];return l.isLoading?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-sm text-secondary",role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," Loading sections..."]}):l.error?s.jsx("p",{className:"px-3 py-4 text-sm text-negative",role:"alert",children:"Site sections could not be loaded."}):c.length===0&&!a?s.jsx("p",{className:"px-3 py-4 text-sm text-secondary",children:"No nested sections were found."}):s.jsxs(s.Fragment,{children:[s.jsxs("ul",{className:"divide-y divide-default",children:[a&&r&&s.jsx(xo,{page:a,onSelect:r}),c.map(d=>s.jsx(go,{projectName:n,runId:e,section:d,onSelect:i},d.path))]}),l.hasNextPage&&s.jsx("div",{className:"px-3 py-2",children:s.jsx(M,{variant:"ghost",size:"sm",disabled:l.isFetchingNextPage,onClick:()=>{l.fetchNextPage()},children:l.isFetchingNextPage?"Loading more sections":"Load more sections"})})]})}function bo(){return s.jsx("div",{role:"status",className:"flex min-h-[420px] items-center justify-center rounded-lg border border-default bg-surface-inset px-6 text-center lg:min-h-[520px]",children:s.jsxs("div",{className:"max-w-sm",children:[s.jsx(je,{className:"mx-auto size-5 motion-safe:animate-spin text-muted","aria-hidden":"true"}),s.jsx("p",{className:"mt-3 text-sm font-medium text-heading",children:"Preparing the interactive site map"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Page and link data is ready for the graph renderer."})]})})}function Gn(n){return n==="discovering"?"Discovering pages":n==="checking"?"Checking pages":n==="arranging-map"?"Arranging map":n==="queued"?"Waiting to start":"Preparing scan"}function yo(n){return n!=="completed"&&n!=="partial"&&n!=="failed"&&n!=="cancelled"}function wo(n){return n==="queued"||n==="discovering"||n==="checking"||n==="arranging-map"}function vo(n){return n==="completed"||n==="partial"||n==="failed"||n==="cancelled"}function No(n){if(!n||typeof n!="object")return null;const e=n;if(typeof e.code=="string")return e.code;if(e.error&&typeof e.error=="object"){const t=e.error;return typeof t.code=="string"?t.code:null}return null}function jo(n){if(!n)return null;const e=Date.parse(n);return!Number.isFinite(e)||e>Date.now()?null:e+qr}function ko({active:n,runId:e,createdAt:t}){const i=jo(t),[a,r]=w.useState(null);return w.useEffect(()=>{if(!n||!e||i==null){r(null);return}const o=i-Date.now();if(o<=0){r({runId:e,deadline:i});return}r(null);const l=window.setTimeout(()=>r({runId:e,deadline:i}),o);return()=>window.clearTimeout(l)},[n,i,e]),n&&e!=null&&i!=null&&(Date.now()>=i||a?.runId===e&&a.deadline===i)}function So({onContinueOnboarding:n,onSkipOnboarding:e}){return s.jsxs("section",{"aria-labelledby":"site-health-continuation-heading",className:"mt-5 flex flex-col gap-3 border-t border-default pt-5 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h3",{id:"site-health-continuation-heading",className:"text-base font-semibold text-heading",children:"Continue while Site Health finishes"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Canonry will finish this scan locally. Saved results will appear in Site Health."})]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[s.jsx(M,{type:"button",onClick:n,children:"Set up AI Visibility"}),s.jsx(M,{type:"button",variant:"secondary",onClick:e,children:"Skip for now"})]})]})}function Ze({view:n,tabbed:e=!0,children:t}){return s.jsx("div",{id:e?`site-health-${n}-panel`:void 0,role:e?"tabpanel":void 0,"aria-labelledby":e?`site-health-${n}-tab`:void 0,className:"min-w-0",children:t})}function Eo({status:n,progress:e,progressError:t,onRetryProgress:i,pageHealthDestination:a=!1,firstLook:r=!1,boundedPageLimit:o,livePageHealthPreview:l,livePageHealthError:c=!1,livePageHealthRunId:d=null,continuation:f}){const u=e?.attempt??null,h=e?.phase??n,x=h==="arranging-map";return s.jsxs("section",{"aria-label":"Current scan progress",className:"rounded-lg border border-caution bg-caution-soft px-5 py-6",children:[s.jsx("h2",{className:"min-h-6 text-base font-semibold text-heading",children:x&&a?"Preparing page health":x?"Preparing site map":"Scanning site"}),s.jsx("p",{"aria-atomic":"true","aria-label":"Current scan progress","aria-live":"polite",role:"status",className:"mt-1 min-h-[4.5rem] text-sm text-secondary sm:min-h-10",children:a?x?"Finalizing page health. The scan is complete and its findings are being published.":`${Gn(h)}. Page health appears after the scan finishes.`:x?"Arranging map. The scan is complete and its map is being published.":`${Gn(h)}. The map appears after the scan finishes.`}),r?s.jsxs("p",{className:"mt-3 flex items-center gap-1.5 rounded-lg border border-default bg-bg px-4 py-2 text-sm text-primary",children:["A quick scan to find your first fixes.",s.jsx(fe,{text:o?`Reads up to ${o} pages, or stops sooner at the time limit, so results come back fast. You can run a larger scan from Site Health later.`:"Stops at its page budget or the time limit, so results come back fast. You can run a larger scan from Site Health later."})]}):null,s.jsxs("dl",{"aria-label":"Live scan counters",className:"mt-5 grid grid-cols-2 divide-x divide-y divide-default rounded-lg border border-default bg-surface-subtle sm:grid-cols-4 sm:divide-y-0",children:[s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("dt",{className:"text-sm text-secondary",children:"Pages found"}),s.jsx("dd",{className:"mt-1 font-mono text-lg font-semibold tabular-nums text-heading",children:u?I(u.pagesDiscovered):"—"})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("dt",{className:"text-sm text-secondary",children:"Pages checked"}),s.jsx("dd",{className:"mt-1 font-mono text-lg font-semibold tabular-nums text-heading",children:u?I(u.pagesFetched):"—"})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("dt",{className:"text-sm text-secondary",children:"Links found"}),s.jsx("dd",{className:"mt-1 font-mono text-lg font-semibold tabular-nums text-heading",children:u?I(u.edgesDiscovered):"—"})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("dt",{className:"text-sm text-secondary",children:"Pages failed"}),s.jsx("dd",{className:"mt-1 font-mono text-lg font-semibold tabular-nums text-heading",children:u?I(u.pagesErrored):"—"})]})]}),t&&s.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 text-sm text-secondary",children:[s.jsx("span",{children:x?a?"Page health publishing status could not load.":"Map publishing status could not load.":"Live scan counts could not load. The scan is still running."}),i&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",onClick:i,children:"Retry progress"})]}),a?s.jsx(Ns,{runId:d,preview:l,error:c}):null,f]})}function _t(){return Array.from({length:Vr},()=>null)}function Ao(n,e){return n===e||n!=null&&e!=null&&n.nodeKey===e.nodeKey&&n.url===e.url&&n.auditScore===e.auditScore&&n.checksNeedingAttention===e.checksNeedingAttention}function _o(n,e){return n.length===e.length&&n.every((t,i)=>Ao(t,e[i]??null))}function $o(n,e){const t=[...n];for(const i of e){const a=t.findIndex(o=>o?.nodeKey===i.nodeKey);if(a>=0){t[a]=i;continue}const r=t.findIndex(o=>o==null);if(r<0)break;t[r]=i}return t}function Ns({runId:n,preview:e,error:t=!1}){const[i,a]=w.useState(()=>({runId:n,slots:_t()})),r=e?.state==="terminal",o=r||i.runId!==n?_t():i.slots;w.useEffect(()=>{a(d=>{const f=d.runId===n?d.slots:_t(),u=r?_t():$o(f,e?.examples??[]);return d.runId===n&&_o(d.slots,u)?d:{runId:n,slots:u}})},[e?.examples,n,r]);const l=e?.pagesAudited??0,c=o.some(d=>d!=null);return s.jsxs("section",{"aria-labelledby":"live-page-health-findings-heading",className:"mt-5 border-t border-default pt-5",children:[s.jsx("h3",{id:"live-page-health-findings-heading",className:"text-base font-semibold text-heading",children:"Findings so far"}),s.jsxs("div",{className:"relative mt-1 min-h-[5.25rem] text-sm text-secondary sm:min-h-[3.5rem]",children:[s.jsxs("p",{children:["Based on ",ke.format(l)," audited pages. Results may change until the scan finishes."]}),s.jsx("p",{className:He("absolute bottom-0 text-caution",t?"visible":"invisible"),children:"Live findings paused. The scan is still running."})]}),s.jsx("ul",{"aria-label":"Live Page Health findings",className:"mt-3 grid h-[10.5rem] grid-rows-3 divide-y divide-default overflow-hidden rounded-lg border border-default bg-surface-subtle",children:o.map((d,f)=>{const u=d==null&&f===0&&!c,h=d==null&&!u;return s.jsx("li",{"aria-hidden":h||void 0,"data-testid":"live-page-health-slot",className:"grid h-14 min-h-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 px-4 sm:gap-4",children:d?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-strong",title:d.url,children:d.url}),s.jsxs("span",{className:"shrink-0 whitespace-nowrap text-sm tabular-nums text-secondary",children:[s.jsxs("span",{"aria-hidden":"true",className:"sm:hidden",children:[ke.format(d.checksNeedingAttention)," checks"]}),s.jsxs("span",{className:"hidden sm:inline",children:[ke.format(d.checksNeedingAttention)," checks need attention"]}),s.jsxs("span",{className:"sr-only sm:hidden",children:[ke.format(d.checksNeedingAttention)," checks need attention"]})]})]}):u?s.jsx("span",{className:"text-sm text-secondary",children:"Checks that need attention will appear here."}):null},`live-page-health-slot-${f}`)})})]})}function Lo({phase:n,progress:e,onRunAgain:t,pageHealthDestination:i=!1}){const a=n==="cancelled",r=e?.error??e?.attempt?.error;return s.jsxs("section",{"aria-label":"Site scan recovery",role:"alert",className:"rounded-lg border border-negative bg-negative-soft px-5 py-6",children:[s.jsx("h2",{className:"text-base font-semibold text-negative",children:a?"Scan cancelled":"Scan failed"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:i?a?"The scan was cancelled before Canonry could publish page health results.":"The scan did not complete, so page health results are unavailable.":a?"The scan was cancelled before Canonry could publish a site map.":"The scan did not complete, so there is no site map for this run."}),r&&s.jsx("p",{className:"mt-3 text-sm text-negative",children:r}),t&&s.jsx(M,{type:"button",className:"mt-4",onClick:t,children:"Run scan again"})]})}function To({projectName:n,projectId:e,initialRunId:t,onReleaseInitialRun:i,showOnboardingActions:a=!1,onContinueOnboarding:r,onSkipOnboarding:o}){const[l,c]=w.useState("map"),d=w.useRef([]),[f,u]=w.useState(()=>t??null),h=w.useRef(t),[x,A]=w.useState(null),[j,D]=w.useState(!1),[C,F]=w.useState(null),[R,g]=w.useState(null),[m,b]=w.useState(!1),[N,_]=w.useState("all"),[G,P]=w.useState(!1),U=zt(),{isAdmin:Q}=Dn(),Y=Ys(),se=(Y||$t(Ke["site-audit"]))&&!Q,L=a&&!U,ge=Pn();w.useEffect(()=>{const y=h.current;y!==t&&(h.current=t,u(ne=>t??(ne===y?null:ne)),A(null))},[t]);const ce=me({...Qs({client:le,path:{name:n},query:{limit:Fr}}),refetchOnWindowFocus:"always",refetchInterval:y=>y.state.data?.scans.some(ne=>ne.status==="queued"||ne.status==="running")?3e3:15e3}).data?.scans??[],E=ce.find(y=>y.status==="queued"||y.status==="running"),pe=ce.find(y=>y.status==="completed"||y.status==="partial"),ie=L?ge.data?.runId??null:null,ae=f??(L?ie??E?.runId??pe?.runId:pe?.runId??E?.runId)??null,Ee=E?.runId===ae?E:null,ue=ae?ce.find(y=>y.runId===ae):void 0,he=!!(t&&ae===t),xe=!!(ie&&ae===ie),J=xe&&!ue,ee=Ee?.runId??(he||J?ae:null),B=me({...Xs({client:le,path:{name:n,runId:ee??""}}),enabled:!!ee,refetchInterval:y=>yo(y.state.data?.phase)?3e3:!1,refetchIntervalInBackground:!0});w.useEffect(()=>{!he||!B.isError||No(B.error)==="NOT_FOUND"&&(u(null),A(null),i?.())},[B.error,B.isError,he,i]);const re=wo(B.data?.phase),oe=vo(B.data?.phase)?null:Ee,Ae=!!(ee&&B.isPending),We=!!(!!((he||xe)&&!ue)&&B.isError),Fe=!!(L&&ee&&(oe?.runId===ee||re)),Te=me({...Zs({client:le,path:{name:n,runId:ee??""}}),enabled:Fe,refetchInterval:y=>y.state.data?.state==="terminal"?!1:3e3,refetchIntervalInBackground:!0}),Ue=!!(oe||re||Ae||We),p=B.data?.phase==="failed"||B.data?.phase==="cancelled"?B.data.phase:(he||xe)&&(ue?.status==="failed"||ue?.status==="cancelled")?ue.status:null,H=me({...Js({client:le,path:{name:n},...ae?{query:{runId:ae}}:{}}),enabled:!Ue}),T=H.data,K=ae??T?.runId??null,te=!!(K&&T?.hasCrawlData&&T.detailsAvailable),ye=te&&!L,we=K?{runId:K}:{},O=me({...ei({client:le,path:{name:n},query:{...we,maxNodes:Kr,maxEdges:Wr}}),enabled:ye&&!Ue}),k=rs.find(y=>y.id===N)?.healthState,W={client:le,path:{name:n},query:{...we,...k?{healthState:k}:{},limit:Ur,sort:"path"}},q=Cn({...ni(W),enabled:ye,initialPageParam:W,getNextPageParam:y=>y.nextCursor?{path:W.path,query:{...W.query,cursor:y.nextCursor}}:void 0}),ot=ye&&(T?.deadLinks.state==="complete"||T?.deadLinks.state==="partial"),js=me({...si({client:le,path:{name:n},query:{...we,limit:Hr}}),enabled:ot}),lt=O.data?.nodes??[],ks=O.data?.layout.state==="ready"?O.data.totalEdges:null,Ge=O.data?.edges??[],nn=w.useMemo(()=>Ge.filter(y=>y.isTemplate).length,[Ge]),Ss=Ge.length-nn,xt=O.data?.templateDetection??null,_e=xt===null||!oi(xt),Es=w.useMemo(()=>G||_e?Ge:Ge.filter(y=>!y.isTemplate),[Ge,G,_e]),As=O.data?.layout.state==="ready"&&!O.data.layout.templateLinksExcluded,bt=w.useMemo(()=>q.data?.pages.flatMap(y=>y.pages)??[],[q.data]),_s=q.data?.pages[0]?.total??bt.length,sn=w.useMemo(()=>bt.find(y=>y.nodeKey===x)??null,[bt,x]),Gt=!!(te&&x&&!sn),Re=me({...pn({client:le,path:{name:n},query:{...we,...k?{healthState:k}:{},nodeKey:x??void 0,limit:1}}),enabled:Gt}),dt=sn??Re.data?.pages[0]??null,yt=!!(x&&k&&Gt&&Re.isSuccess&&Re.data.healthStateFilter==="applied"&&Re.data.pages.length===0);w.useEffect(()=>{yt&&A(null)},[yt]);const Ie=w.useMemo(()=>yt?null:lt.find(y=>y.nodeKey===x)??dt,[lt,dt,x,yt]),qe=Ie?.nodeKey??null,an=Ie?dt?"ready":Re.isError?"error":Gt&&Re.isLoading?"loading":"ready":"idle",ve=me({...ii({client:le,path:{name:n},query:{...we,nodeKey:qe??void 0,limit:os}}),enabled:ye&&!!qe}),Me=me({...Rn({client:le,path:{name:n},query:{...we,nodeKey:qe??void 0}}),enabled:ye&&!!qe}),$s=w.useMemo(()=>{const y=ce.filter(V=>V.status==="completed"||V.status==="partial"),ne=f?ce.find(V=>V.runId===f):void 0;return ne&&!y.some(V=>V.runId===ne.runId)?[ne,...y]:y},[ce,f]),Ls=ce[0]?.status??null,wt=K?ue:void 0,Be=oe?oe.status:re?B.data?.status??null:p??T?.runStatus??wt?.status??null,Ts=Be==="running"?"Scan running":Be==="queued"?"Scan queued":Be==="partial"?"Partial scan":Be==="completed"?"Complete":Be==="failed"?"Scan failed":Be==="cancelled"?"Scan cancelled":"No scan",vt=js.data,rn=vt&&"found"in vt?vt:T?.deadLinks&&"found"in T.deadLinks?T.deadLinks:void 0,on=ho(vt?.state??T?.deadLinks?.state??"unavailable",rn?.found,rn?.unverified),Ct=to(T?.requestedRootUrl??null,T?.rootUrl??null),ln=zn(T?.rootUrl??null),Nt=O.data?.rootNodeKey??null,dn=me({...pn({client:le,path:{name:n},query:{...we,nodeKey:Nt??void 0,limit:1}}),enabled:!!(te&&Nt)}),Gs=w.useMemo(()=>lt.find(y=>y.nodeKey===Nt)??dn.data?.pages[0]??null,[lt,Nt,dn.data]),Cs=E&&E.runId!==ae?E:null,Ve=ge.isPending||!!oe||!!Cs||re||Ae,Dt=Ue||L&&ge.isPending,Ds=ue?.status==="queued"||ue?.status==="running",Ps=ko({active:L&&Dt&&!!(r&&o)&&!!(Ds||ee===ae&&re),runId:ae,createdAt:ue?.createdAt}),jt=!!(T?.hasCrawlData&&!Dt&&!p),be=L?jt?"technical":"map":l,cn=be==="technical"?"map":be,Rs=y=>{u(y||null),A(null)},ct=()=>{(Y||$t(Ke["site-audit"]))&&!Q||(u(null),A(null),t&&i?.(),L&&b(!0),ge.mutate({projectName:n,projectId:e,body:{checkDeadLinks:L||j,...L?{maxPages:Ut}:C===null?{}:{maxPages:C},...L||R===null?{}:{maxDepth:R}}}))},Is=y=>{const ne=lt.find(V=>V.path===y||V.path.startsWith(`${y}/`));ne&&A(ne.nodeKey)},un=y=>c(y),Ms=(y,ne)=>{let V=null;y.key==="ArrowRight"||y.key==="ArrowDown"?V=(ne+1)%Xe.length:y.key==="ArrowLeft"||y.key==="ArrowUp"?V=(ne-1+Xe.length)%Xe.length:y.key==="Home"?V=0:y.key==="End"&&(V=Xe.length-1),V!=null&&(y.preventDefault(),un(Xe[V].id),d.current[V]?.focus())};return s.jsxs("div",{className:"space-y-5",children:[L?s.jsx(ai,{current:jt?"fixes":"site"}):null,!L&&s.jsxs("header",{className:"flex flex-col justify-between gap-4 lg:flex-row lg:items-start",children:[s.jsx("div",{children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-heading",children:"Site Health"}),s.jsx(fe,{text:as[be]}),s.jsx(X,{tone:no(Be),children:Ts}),wt&&s.jsx("span",{className:"text-xs text-muted",children:ls(wt.finishedAt??wt.startedAt)})]})}),s.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[s.jsxs("label",{className:"grid gap-1 text-xs text-muted",children:["Scan history",s.jsxs("select",{"aria-label":"View a Site Health scan",value:f??"",onChange:y=>Rs(y.target.value),className:"h-9 min-w-48 rounded-md border border-base bg-bg px-3 text-sm text-primary outline-none focus:border-strong focus:ring-2 focus:ring-mono-600",children:[s.jsx("option",{value:"",children:"Latest scan"}),$s.map(y=>s.jsx("option",{value:y.runId,children:so(y)},y.runId))]})]}),!U&&!se&&s.jsxs("div",{className:"flex items-end gap-2 pt-5",children:[s.jsxs("details",{className:"group relative",children:[s.jsxs("summary",{className:"flex h-9 cursor-pointer list-none items-center gap-2 rounded-md border border-base bg-bg px-3 text-sm font-medium text-heading outline-none hover:bg-bg-elevated focus-visible:ring-2 focus-visible:ring-mono-400",children:[s.jsx(xi,{className:"size-4","aria-hidden":"true"}),"Scan settings"]}),s.jsxs("div",{className:"absolute right-0 z-20 mt-2 w-72 rounded-lg border border-strong bg-bg-elevated p-4 shadow-[0_12px_32px_var(--color-shadow-panel)]",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-heading",children:[s.jsxs("span",{className:"flex items-center gap-1.5 font-medium",children:["Check dead links",s.jsx(fe,{text:"Adds dead-link analysis to this scan. Slower on a large site."})]}),s.jsx("input",{type:"checkbox","aria-label":"Check dead links",checked:j,disabled:Ve,onChange:y=>D(y.target.checked),className:"size-4 rounded border-base accent-mono-200 focus:ring-2 focus:ring-mono-400"})]}),s.jsxs("div",{className:"mt-4",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-heading",children:["Page budget",s.jsx(fe,{text:"How many pages one scan may read before it stops."})]}),s.jsx("select",{"aria-label":"Page budget",value:C===null?"":String(C),disabled:Ve,onChange:y=>F(y.target.value===""?null:Number(y.target.value)),className:"mt-1 h-9 w-full rounded-md border border-base bg-bg px-2 text-sm text-primary outline-none focus:border-strong focus:ring-2 focus:ring-mono-600",children:ro.map(y=>s.jsx("option",{value:y.value===null?"":String(y.value),children:y.label},String(y.value)))})]}),s.jsxs("div",{className:"mt-3",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-heading",children:["Crawl depth",s.jsx(fe,{text:"How far from the home page to follow links. A smaller scan is what fixes a scan that ran out of time."})]}),s.jsx("select",{"aria-label":"Crawl depth",value:R===null?"":String(R),disabled:Ve,onChange:y=>g(y.target.value===""?null:Number(y.target.value)),className:"mt-1 h-9 w-full rounded-md border border-base bg-bg px-2 text-sm text-primary outline-none focus:border-strong focus:ring-2 focus:ring-mono-600",children:hs.map(y=>s.jsx("option",{value:y.value===null?"":String(y.value),children:y.label},String(y.value)))})]})]})]}),s.jsxs(Ft,{onClick:ct,disabled:Ve,children:[Ve?s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}):s.jsx(Ht,{className:"size-4","aria-hidden":"true"}),E?.status==="running"?"Scan running":E?.status==="queued"?"Scan queued":"Run scan"]})]})]})]}),se&&s.jsx(ri,{projectName:n,kind:Ke["site-audit"],loadSchedule:!Y}),T?.hasCrawlData&&be!=="technical"&&s.jsxs("div",{className:"grid grid-cols-2 divide-x divide-y divide-default rounded-lg border border-default bg-surface-subtle sm:grid-cols-4 sm:divide-y-0",children:[s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted",children:["Pages found",s.jsx(fe,{text:Ce("pagesFound",!1)})]}),s.jsx("div",{className:"mt-1 text-xl font-semibold tabular-nums text-heading",children:I(T.counts.pagesDiscovered)})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted",children:["Pages checked",s.jsx(fe,{text:Ce("pagesChecked",!1)})]}),s.jsx("div",{className:"mt-1 text-xl font-semibold tabular-nums text-heading",children:I(T.counts.pagesFetched)})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("div",{className:"text-xs text-muted",title:tt("eligible"),children:"Indexable"}),s.jsx("div",{className:"mt-1 text-xl font-semibold tabular-nums text-heading",children:I(T.counts.pagesEligible)})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted",children:["Internal links",s.jsx(fe,{text:Ce("internalLinks",!1)})]}),s.jsx("div",{className:"mt-1 text-xl font-semibold tabular-nums text-heading",children:I(ks)})]})]}),!L&&s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-default",children:[s.jsx("div",{role:"tablist","aria-label":"Site Health views","aria-orientation":"horizontal",className:"flex min-w-0 gap-5",children:Xe.map((y,ne)=>s.jsx("button",{type:"button",role:"tab",id:`site-health-${y.id}-tab`,"aria-selected":be===y.id,"aria-controls":`site-health-${y.id}-panel`,tabIndex:be===y.id?0:-1,ref:V=>{d.current[ne]=V},onClick:()=>un(y.id),onKeyDown:V=>Ms(V,ne),className:`min-h-11 border-b-2 px-0.5 text-sm font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-mono-400 disabled:cursor-not-allowed disabled:opacity-50 ${be===y.id?"border-strong text-heading":"border-transparent text-secondary hover:border-base hover:text-primary"}`,children:y.label},y.id))}),T?.hasCrawlData&&be!=="technical"&&s.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[s.jsx("span",{className:"text-xs text-muted",children:"Dead-link check"}),s.jsx(X,{tone:on.tone,children:on.label})]})]}),!f&&E&&!oe&&s.jsx("div",{className:"rounded-lg border border-caution bg-caution-soft px-4 py-3 text-sm text-caution",role:"status",children:"A newer scan is running. The latest published result remains available until it finishes."}),Ct&&s.jsxs("div",{className:"rounded-lg border border-base bg-surface-subtle px-4 py-3 text-sm text-secondary",role:"status",children:[s.jsx("span",{className:"font-medium text-heading",children:"Site address changed during this scan."})," ","The scan started at ",s.jsx("span",{className:"font-mono text-primary",children:Ct.requested})," and continued at"," ",s.jsx("span",{className:"font-mono text-primary",children:Ct.effective}),"."," ",L?"Page health uses the new address.":"The map and inventory use the new address."]}),T?.hasCrawlData&&!T.complete&&s.jsxs("div",{className:"rounded-lg border border-caution bg-caution-soft px-4 py-3 text-sm text-caution",role:"status",children:[co(T.termination)," ",!U&&!se?lo(T.termination,L):null]}),!E&&Ls==="failed"&&!f&&s.jsxs("div",{className:"flex gap-3 rounded-lg border border-negative bg-negative-soft px-4 py-3 text-sm text-negative",role:"alert",children:[s.jsx(Bt,{className:"mt-0.5 size-4 shrink-0","aria-hidden":"true"}),s.jsx("span",{children:"The latest scan failed. The previous completed results remain available."})]}),p?s.jsx(Ze,{view:cn,tabbed:!L,children:s.jsx(Lo,{phase:p,progress:B.data,onRunAgain:se?void 0:ct,pageHealthDestination:L})}):Dt?s.jsx(Ze,{view:cn,tabbed:!L,children:s.jsx(Eo,{status:B.data?.phase??(oe?.status==="running"?"running":"queued"),progress:B.data,progressError:B.isError,onRetryProgress:()=>{B.refetch()},pageHealthDestination:L,firstLook:L,boundedPageLimit:L&&m?Ut:void 0,livePageHealthPreview:Te.data,livePageHealthError:Te.isError,livePageHealthRunId:ee,continuation:Ps?s.jsx(So,{onContinueOnboarding:r,onSkipOnboarding:o}):null})}):be==="technical"?s.jsxs("div",{id:"site-health-technical-panel",role:L?void 0:"tabpanel","aria-labelledby":L?void 0:"site-health-technical-tab",className:"min-w-0 space-y-6",children:[L?s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-heading",children:"Page health"}):null,s.jsx(Ir,{projectName:n,projectId:e,runId:K,integrated:!0,compactCopy:L,afterSummary:L&&jt?s.jsxs("section",{"aria-labelledby":"ai-visibility-next-heading",className:"flex flex-col gap-3 border-b border-default py-5 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"ai-visibility-next-heading",className:"text-base font-semibold text-heading",children:"Next: Set up AI Visibility"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"See whether answer engines mention your brand and cite your pages."})]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[s.jsx(M,{type:"button",onClick:r,children:"Set up AI Visibility"}),s.jsx(M,{type:"button",variant:"secondary",onClick:o,children:"Skip for now"})]})]}):void 0,unavailableFooter:L&&jt&&!se?s.jsx("section",{"aria-label":"Page health recovery",className:"mt-4",children:s.jsx(M,{type:"button",disabled:Ve,onClick:()=>{c("map"),ct()},children:"Run site audit again"})}):void 0})]}):H.isLoading?s.jsx(Ze,{view:be,tabbed:!L,children:s.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-2 text-sm text-secondary",role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading site health..."]})}):H.error?s.jsx(Ze,{view:be,tabbed:!L,children:s.jsxs("section",{className:"rounded-lg border border-negative bg-negative-soft px-5 py-6",role:"alert",children:[s.jsx("h2",{className:"font-semibold text-negative",children:"Site Health could not load"}),s.jsx("p",{className:"mt-1 text-sm text-negative",children:"Try loading the crawl again."}),s.jsx(M,{variant:"secondary",size:"sm",className:"mt-4",onClick:()=>{H.refetch()},children:"Try again"})]})}):T?.hasCrawlData?T.detailsAvailable?be==="inventory"?s.jsxs("div",{id:"site-health-inventory-panel",role:"tabpanel","aria-labelledby":"site-health-inventory-tab",className:"space-y-5",children:[q.isLoading?s.jsxs("div",{className:"flex min-h-56 items-center justify-center gap-2 text-sm text-secondary",role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading page inventory..."]}):q.error?s.jsx("p",{className:"rounded-lg border border-negative bg-negative-soft px-4 py-3 text-sm text-negative",role:"alert",children:"The page inventory could not be loaded."}):s.jsx(mo,{pages:bt,total:_s,filterUnavailable:q.data?.pages[0]?.healthStateFilter==="unavailable-legacy-scan",selectedNodeKey:qe,onSelect:A,hasNextPage:!!q.hasNextPage,isFetchingNextPage:q.isFetchingNextPage,onLoadMore:()=>{q.fetchNextPage()},filter:N,onFilterChange:_}),s.jsx(Tn,{page:Ie,isLoading:ve.isLoading&&!!Ie,error:ve.error,inbound:ve.data?.inbound??[],outbound:ve.data?.outbound??[],inboundTruncated:ve.data?.inboundTruncated??!1,outboundTruncated:ve.data?.outboundTruncated??!1,audit:Me.data,auditLoading:Me.isLoading&&!!Ie,auditError:Me.error,onRetryAudit:()=>{Me.refetch()},rootHost:ln,reasonSource:dt,reasonsState:an,onRetryReasons:()=>{Re.refetch()},showTemplateLinks:G||_e})]}):s.jsxs("div",{id:"site-health-map-panel",role:"tabpanel","aria-labelledby":"site-health-map-tab",className:"space-y-5",children:[s.jsxs("section",{"aria-labelledby":"site-map-heading",children:[s.jsxs("div",{className:"mb-3 flex flex-col justify-between gap-2 sm:flex-row sm:items-end",children:[s.jsx("div",{children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("h2",{id:"site-map-heading",className:"text-base font-semibold text-heading",children:"Site map"}),s.jsx(fe,{text:ps})]})}),O.data?.sampled&&s.jsxs("span",{className:"text-xs text-muted",children:["Showing ",I(O.data.nodes.length)," of ",I(O.data.totalNodes)," pages"," · ",I(O.data.edges.length)," of ",I(O.data.totalEdges)," links"]})]}),O.data?.layout.state==="ready"&&Ge.length>0&&s.jsxs("div",{className:"mb-3 flex flex-col gap-1.5 rounded-lg border border-default bg-surface-subtle px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("p",{className:"flex items-center gap-1 text-sm text-secondary","data-testid":"site-map-link-counts",children:[xs({filterUnavailable:_e,showTemplateLinks:G,contentEdgeCount:Ss,templateEdgeCount:nn,totalEdgeCount:Ge.length}),s.jsx(fe,{text:ys(xt,{staleLayout:As&&!_e})})]}),s.jsxs("label",{className:He("flex shrink-0 items-center gap-2 text-sm",_e?"cursor-not-allowed text-muted":"cursor-pointer text-heading"),title:_e?fs(xt):"Menu and footer links are drawn on top. Pages do not move, because the map was laid out from the links in your page text.",children:[s.jsx("input",{type:"checkbox",checked:G&&!_e,disabled:_e,onChange:y=>P(y.target.checked),className:"size-4 rounded border-base accent-mono-200 focus:ring-2 focus:ring-mono-400"}),"Show menu and footer links"]})]}),s.jsxs("div",{id:"site-health-map-explorer",className:"grid gap-4 lg:grid-cols-[minmax(14rem,18rem)_minmax(0,1fr)]",children:[s.jsxs("aside",{className:"rounded-lg border border-default bg-surface-subtle","aria-labelledby":"site-sections-heading",children:[s.jsxs("div",{className:"border-b border-default px-4 py-3",children:[s.jsx("h3",{id:"site-sections-heading",className:"text-sm font-semibold text-heading",children:"Site sections"}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Folders in this scan"})]}),s.jsx("div",{className:"max-h-[468px] overflow-auto",children:K&&s.jsx(vs,{projectName:n,runId:K,parentPath:"/",onSelect:Is,rootPage:Gs,onSelectRootPage:A})})]}),s.jsx("div",{className:"min-w-0",children:O.isLoading?s.jsx(bo,{}):O.error?s.jsx("div",{className:"flex min-h-[420px] items-center justify-center rounded-lg border border-negative bg-negative-soft px-6 text-center lg:min-h-[520px]",role:"alert",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-negative",children:"The interactive map could not be loaded."}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"The page inventory and technical findings remain available."}),s.jsx(M,{variant:"secondary",size:"sm",className:"mt-4",onClick:()=>c("inventory"),children:"Open page inventory"})]})}):s.jsx(yr,{nodes:O.data?.nodes??[],edges:Ge,showTemplateLinks:G||_e,layoutState:O.data?.layout.state??"unavailable",layoutUnavailableReason:O.data?.layout.state==="unavailable"?O.data.layout.reason:null,rootNodeKey:O.data?.rootNodeKey??null,selectedNodeKey:qe,onSelectNode:y=>A(y.nodeKey),onOpenInventory:()=>c("inventory"),ariaLabel:`Interactive site map showing ${I(O.data?.nodes.length??0)} pages and ${I(Es.length)} internal links`})})]})]}),s.jsx(Tn,{page:Ie,isLoading:ve.isLoading&&!!Ie,error:ve.error,inbound:ve.data?.inbound??[],outbound:ve.data?.outbound??[],inboundTruncated:ve.data?.inboundTruncated??!1,outboundTruncated:ve.data?.outboundTruncated??!1,audit:Me.data,auditLoading:Me.isLoading&&!!Ie,auditError:Me.error,onRetryAudit:()=>{Me.refetch()},rootHost:ln,reasonSource:dt,reasonsState:an,onRetryReasons:()=>{Re.refetch()},showTemplateLinks:G||_e})]}):s.jsx(Ze,{view:be,tabbed:!L,children:s.jsxs("section",{className:"rounded-lg border border-caution bg-caution-soft px-5 py-6",children:[s.jsx("h2",{className:"font-semibold text-caution",children:L?"Page health results unavailable":"Page details unavailable"}),s.jsx("p",{className:"mt-1 text-sm text-caution",children:se&&L?"This scan did not publish page-level results.":L?"This scan did not publish page-level results. Run it again to continue setup.":"Summary metrics are preserved for this scan, but its page graph cannot be opened."}),L&&!se?s.jsx(M,{type:"button",size:"sm",className:"mt-4",onClick:ct,children:"Run scan again"}):null]})}):s.jsx(Ze,{view:be,tabbed:!L,children:s.jsxs("section",{className:"rounded-lg border border-default bg-surface-subtle px-5 py-8 text-center",children:[s.jsx("h2",{className:"text-base font-semibold text-heading",children:L?"Page health results unavailable":"Full-site map not available"}),s.jsx("p",{className:"mx-auto mt-2 max-w-xl text-sm text-secondary",children:se?In:L?"This scan did not produce page health results. Run it again to continue setup.":T?.legacyAuditAvailable?"Existing page health results are preserved. Run a new scan to build the page and internal-link map.":U?"A full-site scan has not been run for this project.":"Run a scan to discover pages, site sections, and internal links."}),(T?.legacyAuditAvailable||L)&&s.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[T?.legacyAuditAvailable&&!L&&s.jsx(M,{variant:"secondary",size:"sm",onClick:()=>c("technical"),children:"View page health"}),L&&!se&&s.jsx(M,{type:"button",size:"sm",onClick:ct,children:"Run scan again"})]})]})})]})}const Mo=Object.freeze(Object.defineProperty({__proto__:null,CRAWL_DEPTH_CHOICES:hs,LivePageHealthFindings:Ns,PAGE_INTERNAL_LINKS_HELP:ms,SITE_HEALTH_VIEW_DESCRIPTIONS:as,SITE_MAP_HELP:ps,SITE_MAP_LINK_SPLIT_COPY:bs,SITE_MAP_STALE_LAYOUT_COPY:gs,SiteHealthSection:To,TEMPLATE_DETECTION_COPY:tn,emptyLinkCopy:ws,linkTileCount:Vt,siteHealthMetricHelp:Ce,siteMapLinkCountsLabel:xs,siteMapLinkRuleHelp:ys},Symbol.toStringTag,{value:"Module"}));export{$r as D,z as G,Ar as M,To as S,Lr as a,Sr as b,is as c,Mo as d,Di as e,_r as u};
|
|
4
|
+
${r.nodeKey}`.toLocaleLowerCase().includes(i):!0:!1).slice(0,a)}function ar(n,e,t,i,a=!0){const o=!!(e&&n.hasNode(e))?e:null,l=typeof t=="function"?t:()=>t,c=n.nodes().sort((u,h)=>{const x=n.getNodeAttributes(u),A=n.getNodeAttributes(h);return Number(A.isRoot)-Number(x.isRoot)||A.size-x.size||(x.depth??Number.MAX_SAFE_INTEGER)-(A.depth??Number.MAX_SAFE_INTEGER)||nt(x.path,A.path)||nt(u,h)}),d=new Map(c.map((u,h)=>[u,h])),f=new Set(o?n.neighbors(o).filter(u=>u!==o).sort((u,h)=>(d.get(u)??0)-(d.get(h)??0)).slice(0,Va):[]);return{nodeReducer:(u,h)=>{const x=l(),A=x>gt;if(h.isRoot)return u===o?{...h,size:h.size*1.35,forceLabel:!0,zIndex:3}:{...h,forceLabel:!0};if(o)return u===o?{...h,size:h.size*1.35,forceLabel:!0,zIndex:3}:n.areNeighbors(u,o)?A?f.has(u)?{...h,forceLabel:!1}:{...h,forceLabel:!1,label:""}:h:{...h,color:i.dimmedNode,forceLabel:!1,label:"",zIndex:0};const j=Kt(x);return j===Number.POSITIVE_INFINITY?h:(d.get(u)??Number.MAX_SAFE_INTEGER)<j?{...h,forceLabel:!0}:{...h,forceLabel:!1,label:""}},edgeReducer:(u,h)=>{if(h.isTemplate&&!a)return{...h,hidden:!0};const x=l()>gt,[A,j]=n.extremities(u);return o&&(A===o||j===o)?{...h,color:i.edgeActive,size:Math.max(1.4,h.size),zIndex:2}:x?{...h,hidden:!0}:o?{...h,color:i.edgeDimmed,size:Math.min(.45,h.size),zIndex:0}:h}}}const _n={"layout-failed":{heading:"Map could not be built",detail:"The map could not be created for this scan. Run a new scan to try again."},"no-crawl":{heading:"No map yet",detail:"This scan has no map yet. Run a new scan to create one."},"legacy-snapshot":{heading:"No map yet",detail:"This scan has no map yet. Run a new scan to create one."},"details-unavailable":{heading:"No map yet",detail:"This scan has no map yet. Run a new scan to create one."},"empty-crawl":{heading:"No pages to map",detail:"This scan found no pages to put on a map. Run a new scan to try again."}};function rr(n){return(n&&_n[n])??_n["no-crawl"]}class or extends w.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error("[SiteGraphSigma] the map failed to render",e,t.componentStack)}componentDidUpdate(e){this.state.failed&&e.resetToken!==this.props.resetToken&&this.setState({failed:!1})}render(){return this.state.failed?this.props.fallback:this.props.children}}const lr=220;function dr(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:lr}function ft(n,e,t=`${e}s`){return`${n.toLocaleString()} ${n===1?e:t}`}function cr(n,e,t){const a=window.getComputedStyle(n).getPropertyValue(e).trim();if(a&&!a.includes("var(")&&En(a))return a;const r=document.createElement("span");r.style.position="absolute",r.style.visibility="hidden",r.style.color=`var(${e})`,n.appendChild(r);const o=window.getComputedStyle(r).color.trim();return r.remove(),o&&!o.includes("var(")&&En(o)?o:t}function ur(n){const e=t=>{const i=Ka[t];return cr(n,i.property,i.fallback)};return{eligible:e("eligible"),hidden:e("hidden"),resource:e("resource"),redirect:e("redirect"),failed:e("failed"),unchecked:e("unchecked"),dimmedNode:e("dimmedNode"),edge:e("edge"),edgeDimmed:e("edgeDimmed"),edgeActive:e("edgeActive"),label:e("label"),background:e("background")}}function hr(n){return(e,t,i)=>{t.label&&(e.save(),e.fillStyle=i.labelColor.color??n.label,e.font=`${i.labelWeight} ${i.labelSize}px ${i.labelFont}`,e.fillText(t.label,t.x+t.size+3,t.y+i.labelSize/3),e.restore())}}function fr(n,e,t,i,a,r){const o=Math.min(r,i/2,a/2);n.beginPath(),n.moveTo(e+o,t),n.lineTo(e+i-o,t),n.arcTo(e+i,t,e+i,t+o,o),n.lineTo(e+i,t+a-o),n.arcTo(e+i,t+a,e+i-o,t+a,o),n.lineTo(e+o,t+a),n.arcTo(e,t+a,e,t+a-o,o),n.lineTo(e,t+o),n.arcTo(e,t,e+o,t,o),n.closePath()}function pr(n){return(e,t,i)=>{const a=typeof t.label=="string"?t.label:null,r=i.labelSize+10,o=t.x+t.size+7,l=t.y-r/2;if(e.save(),e.font=`${i.labelWeight} ${i.labelSize}px ${i.labelFont}`,e.fillStyle=n.background,e.strokeStyle=n.edgeActive,e.lineWidth=1.5,e.beginPath(),e.arc(t.x,t.y,t.size+3,0,Math.PI*2),e.fill(),e.stroke(),e.fillStyle=t.color,e.beginPath(),e.arc(t.x,t.y,t.size,0,Math.PI*2),e.fill(),a){const c=Math.ceil(e.measureText(a).width)+16;fr(e,o,l,c,r,5),e.fillStyle=n.background,e.fill(),e.strokeStyle=n.edgeActive,e.lineWidth=1,e.stroke(),e.fillStyle=n.label,e.textBaseline="middle",e.fillText(a,o+8,t.y)}e.restore()}}function mr(){if(typeof document>"u")return!1;try{const n=document.createElement("canvas");return!!(n.getContext("webgl2")||n.getContext("webgl"))}catch{return!1}}function gr({onOpenInventory:n}){return s.jsx("div",{className:"flex h-full min-h-80 items-center justify-center px-6 text-center",children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:"Interactive map unavailable"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"This browser could not start WebGL. The page inventory remains available for the complete crawl."}),n&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",className:"mt-4",onClick:n,children:"Open page inventory"})]})})}function xr({onRetry:n}){return s.jsx("div",{className:"flex h-full min-h-80 items-center justify-center px-6 text-center",role:"alert",children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:"The map could not be drawn"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Something went wrong while drawing this map. The page inventory below is unaffected."}),s.jsx(M,{variant:"secondary",size:"sm",className:"mt-4",onClick:n,children:"Try again"})]})})}function br({reactSigma:n,graph:e,theme:t,selectedNodeKey:i,showTemplateLinks:a,onSelectNodeKey:r,onHoverNode:o,onCameraReady:l}){const{useSigma:c,useRegisterEvents:d,useCamera:f}=n,u=c(),h=d(),{zoomIn:x,zoomOut:A,reset:j,gotoNode:D}=f(),[C,F]=w.useState(null),R=C??i,g=w.useRef(null),m=w.useRef({overview:!0,budget:Number.NaN});return w.useEffect(()=>()=>{g.current!==null&&cancelAnimationFrame(g.current)},[]),w.useEffect(()=>{const b=dr();return l({zoomIn:()=>x({duration:b}),zoomOut:()=>A({duration:b}),reset:()=>j({duration:b}),gotoNode:N=>D(N,{duration:b})}),()=>l(null)},[D,l,j,x,A]),w.useEffect(()=>{h({enterNode:({node:b,event:N})=>{F(b),o({nodeKey:b,left:Number.isFinite(N.x)?N.x+14:20,top:Number.isFinite(N.y)?N.y+14:20})},leaveNode:()=>{F(null),o(null)},clickNode:({node:b})=>r(b),clickStage:()=>o(null),updated:()=>{g.current===null&&(g.current=requestAnimationFrame(()=>{g.current=null;const b=u.getCamera().getState().ratio>gt,N=Kt(u.getCamera().getState().ratio);b===m.current.overview&&N===m.current.budget||(m.current={overview:b,budget:N},u.refresh())}))}})},[o,r,h,u]),w.useEffect(()=>{if(u.getGraph()!==e)return;const b=ar(e,R,()=>u.getCamera().getState().ratio,t,a);u.setSetting("nodeReducer",b.nodeReducer),u.setSetting("edgeReducer",b.edgeReducer);const N=u.getCamera().getState().ratio;m.current={overview:N>gt,budget:Kt(N)},u.refresh()},[R,e,a,u,t]),null}function yr({nodes:n,edges:e,layoutState:t="ready",layoutUnavailableReason:i,rootNodeKey:a=null,showTemplateLinks:r=!0,selectedNodeKey:o,onSelectNode:l,onOpenInventory:c,ariaLabel:d,className:f}){const u=w.useRef(null),h=w.useRef(null),x=w.useRef(null),A=w.useId(),j=w.useId(),D=w.useId(),[C,F]=w.useState(null),[R,g]=w.useState(null),[m,b]=w.useState("checking"),[N,_]=w.useState(!1),[G,P]=w.useState(null),[U,Q]=w.useState(null),[Y,se]=w.useState(""),[L,ge]=w.useState(!1),[ze,ce]=w.useState(0),[E,pe]=w.useState(""),[ie,ae]=w.useState(0),Ee=w.useRef(null),ue=w.useDeferredValue(Y),he=o===void 0?G:o,xe=w.useMemo(()=>new Map(n.map(k=>[k.nodeKey,k])),[n]),J=w.useMemo(()=>zn(a?xe.get(a)?.url:null),[xe,a]),ee=w.useCallback(k=>Gi(k,J),[J]),B=he?xe.get(he)??null:null,re=U?xe.get(U.nodeKey)??null:null,Le=w.useMemo(()=>ir(n,ue),[ue,n]),oe=n.some(k=>Number.isFinite(k.x)&&Number.isFinite(k.y)),Ae=w.useMemo(()=>C?sr(n,e,C,a):null,[e,n,a,C]),rt=w.useMemo(()=>C?{allowInvalidContainer:!0,defaultNodeColor:C.unchecked,defaultEdgeColor:C.edge,defaultEdgeType:"line",enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!0,hideLabelsOnMove:!0,itemSizesReference:"screen",defaultDrawNodeHover:pr(C),defaultDrawNodeLabel:hr(C),labelColor:{color:C.label},labelDensity:.07,labelGridCellSize:140,labelFont:"Geist Variable, Geist, sans-serif",labelRenderedSizeThreshold:8,labelSize:13,labelWeight:"600",maxCameraRatio:12,minCameraRatio:.04,minEdgeThickness:.35,renderEdgeLabels:!1,renderLabels:!0,stagePadding:42,zIndex:!0}:null,[C]);w.useEffect(()=>{const k=u.current;if(!k)return;const W=()=>F(ur(k));if(W(),typeof MutationObserver>"u")return;const q=new MutationObserver(W);return q.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>q.disconnect()},[]),w.useEffect(()=>{if(n.length===0||t==="unavailable"||!oe){b("checking");return}b(mr()?"ready":"unavailable")},[oe,t,n.length]),w.useEffect(()=>{if(m!=="ready"){g(null);return}let k=!0;return zs(()=>import("./react-sigma_core.esm.min-DOhuYLQj.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url).then(W=>{k&&g(W)}).catch(()=>{k&&b("unavailable")}),()=>{k=!1}},[m]),w.useEffect(()=>{ce(0)},[ue]);const We=w.useCallback(k=>{x.current=k,_(!!k)},[]),Fe=w.useCallback(k=>{Q(k)},[]),Te=w.useCallback((k,W)=>{const q=xe.get(k);q&&(o===void 0&&P(k),l?.(q),W&&x.current?.gotoNode(k),pe(`Focused ${ee(q)}`))},[xe,l,ee,o]),Ue=w.useCallback(k=>{Te(k,!1)},[Te]);w.useEffect(()=>{if(!N||!o||!xe.has(o)){o||(Ee.current=null);return}Ee.current!==o&&(x.current?.gotoNode(o),Ee.current=o)},[N,xe,o]);const p=k=>{Te(k.nodeKey,!0),se(ee(k)),ge(!1)},H=()=>{window.setTimeout(()=>{document.activeElement!==h.current&&ge(!1)},0)},T=`Interactive site map showing ${ft(n.length,"page")} and ${ft(e.length,"internal link")}`,K=k=>`${j}-${k.replaceAll(/[^\w-]/g,"-")}`,te=rr(i);if(t==="unavailable")return s.jsx("section",{ref:u,role:"group","aria-label":d??T,className:He("flex min-h-80 items-center justify-center rounded-lg border border-default bg-surface-inset px-6 text-center",f),children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:te.heading}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:te.detail}),c&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",className:"mt-4",onClick:c,children:"Open page inventory"})]})});if(n.length===0)return s.jsx("section",{ref:u,role:"group","aria-label":d??T,className:He("flex min-h-80 items-center justify-center rounded-lg border border-default bg-surface-inset px-6 text-center",f),children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm text-secondary",children:"No page graph is available for this scan."}),c&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",className:"mt-4",onClick:c,children:"Open page inventory"})]})});if(!oe)return s.jsx("section",{ref:u,role:"group","aria-label":d??T,className:He("flex min-h-80 items-center justify-center rounded-lg border border-default bg-surface-inset px-6 text-center",f),children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:te.heading}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:te.detail}),c&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",className:"mt-4",onClick:c,children:"Open page inventory"})]})});const ye=Le.at(ze),we=s.jsx(xr,{onRetry:()=>ae(k=>k+1)}),O=R?.SigmaContainer;return s.jsxs("section",{ref:u,role:"group","aria-label":d??T,"aria-describedby":D,className:He("flex h-[clamp(460px,62vh,680px)] min-h-[460px] flex-col overflow-hidden rounded-lg border border-default bg-surface-inset",f),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-subtle bg-bg-elevated/70 px-3 py-2",children:[s.jsx("label",{htmlFor:A,className:"sr-only",children:"Focus a page in the site map"}),s.jsxs("div",{className:"relative min-w-56 max-w-lg flex-1",children:[s.jsx(Yt,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted","aria-hidden":"true"}),s.jsx("input",{id:A,ref:h,role:"combobox",type:"search",autoComplete:"off","aria-label":"Focus a page in the site map","aria-autocomplete":"list","aria-controls":j,"aria-expanded":L,"aria-activedescendant":L&&ye?K(ye.nodeKey):void 0,value:Y,placeholder:B?`Focused: ${ee(B)}`:"Find a page",className:"h-10 w-full rounded-md border border-base bg-bg py-2 pl-9 pr-3 text-sm text-primary placeholder-mono-600 outline-none focus-visible:ring-2 focus-visible:ring-mono-400",onFocus:()=>ge(!0),onBlur:H,onChange:k=>{se(k.target.value),ge(!0)},onKeyDown:k=>{k.key==="ArrowDown"?(k.preventDefault(),ge(!0),ce(W=>Math.max(0,Math.min(Le.length-1,W+1)))):k.key==="ArrowUp"?(k.preventDefault(),ce(W=>Math.max(0,W-1))):k.key==="Enter"&&L&&ye?(k.preventDefault(),p(ye)):k.key==="Escape"&&ge(!1)}}),L&&s.jsxs("div",{className:"absolute left-0 right-0 top-[calc(100%+0.25rem)] z-30 overflow-hidden rounded-md border border-base bg-bg shadow-lg",children:[s.jsx("div",{id:j,role:"listbox","aria-label":"Matching pages",className:"max-h-72 overflow-auto py-1",children:Le.length>0?Le.map((k,W)=>{const q=et(k);return s.jsxs("button",{id:K(k.nodeKey),type:"button",role:"option","aria-selected":W===ze,tabIndex:-1,className:He("flex min-h-11 w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-none",W===ze?"bg-surface-active text-primary":"text-secondary hover:bg-surface-hover hover:text-primary"),onPointerDown:ot=>ot.preventDefault(),onMouseDown:ot=>ot.preventDefault(),onMouseEnter:()=>ce(W),onClick:()=>p(k),children:[s.jsx("span",{className:"min-w-0 truncate font-mono",children:ee(k)}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[13px] text-muted",children:[s.jsx("span",{className:"font-mono font-semibold",style:{color:`var(${Oe[q].property})`},"aria-hidden":"true",children:qt(q)}),s.jsx("span",{title:tt(q),children:Wt(q)})]})]},k.nodeKey)}):s.jsx("p",{className:"px-3 py-4 text-sm text-secondary",children:"No rendered pages match."})}),Le.length===50&&s.jsx("p",{className:"border-t border-subtle px-3 py-2 text-[13px] text-muted",children:"First 50 matches. Refine the search or use the full page inventory."})]})]}),s.jsxs("span",{className:"text-[13px] tabular-nums text-muted",children:[ft(n.length,"page")," · ",ft(e.length,"link")]})]}),s.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden",children:m==="unavailable"?s.jsx(gr,{onOpenInventory:c}):m==="checking"||!C||!Ae||!rt||!R||!O?s.jsx("div",{className:"flex h-full min-h-80 items-center justify-center px-6 text-center",role:"status",children:s.jsx("p",{className:"text-sm text-secondary",children:"Preparing the interactive site map..."})}):s.jsxs(or,{fallback:we,resetToken:ie,children:[s.jsx("div",{"aria-hidden":"true",className:"absolute inset-0",children:s.jsx(O,{graph:Ae.graph,className:"relative size-full bg-bg [&_.sigma-container]:size-full",style:{width:"100%",height:"100%",background:C.background},settings:rt,children:s.jsx(br,{reactSigma:R,graph:Ae.graph,theme:C,selectedNodeKey:he,showTemplateLinks:r,onSelectNodeKey:Ue,onHoverNode:Fe,onCameraReady:We})})}),s.jsxs("div",{className:"absolute right-3 top-3 z-20 flex flex-col overflow-hidden rounded-md border border-base bg-bg shadow-lg",children:[s.jsx(M,{type:"button",variant:"ghost",size:"icon",className:"rounded-none border-b border-subtle","aria-label":"Zoom in",disabled:!N,onClick:()=>x.current?.zoomIn(),children:s.jsx(hi,{className:"size-4","aria-hidden":"true"})}),s.jsx(M,{type:"button",variant:"ghost",size:"icon",className:"rounded-none border-b border-subtle","aria-label":"Zoom out",disabled:!N,onClick:()=>x.current?.zoomOut(),children:s.jsx(fi,{className:"size-4","aria-hidden":"true"})}),s.jsx(M,{type:"button",variant:"ghost",size:"icon",className:"rounded-none","aria-label":"Fit site map",disabled:!N,onClick:()=>x.current?.reset(),children:s.jsx(pi,{className:"size-4","aria-hidden":"true"})})]}),re&&U&&s.jsxs("div",{role:"tooltip",className:"pointer-events-none absolute z-20 max-w-64 rounded-md border border-base bg-bg/95 px-3 py-2 shadow-lg",style:{left:U.left,top:U.top},children:[s.jsx("p",{className:"truncate font-mono text-[13px] font-medium text-heading",children:ee(re)}),s.jsx("p",{className:"mt-1 text-[13px] font-medium text-heading",children:Wt(et(re))}),s.jsx("p",{className:"mt-0.5 text-[13px] text-secondary",children:tt(et(re))}),re.depth!=null&&s.jsxs("p",{className:"mt-1 text-[13px] text-secondary",children:[ft(re.depth,"click")," from home"]}),re.auditScore!=null&&s.jsxs("p",{className:"mt-1 text-[13px] tabular-nums text-heading",children:["Score ",Math.round(re.auditScore),"/100"]})]})]})}),s.jsxs("div",{"aria-label":"Site map legend",className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-subtle bg-bg-elevated/50 px-3 py-2 text-[13px] text-secondary",children:[Fs.map(k=>s.jsxs("span",{className:"inline-flex items-center gap-1.5",title:tt(k),children:[s.jsx("span",{className:"w-3 text-center font-mono text-[15px] font-semibold leading-none",style:{color:`var(${Oe[k].property})`},"aria-hidden":"true",children:qt(k)}),Za(k)]},k)),s.jsx("span",{className:"ml-auto",children:"Bigger = more linked"}),Ae&&(Ae.omittedNodes>0||Ae.omittedEdges>0)&&s.jsx("span",{className:"text-caution",children:"Some records lacked valid layout data."})]}),s.jsx("p",{id:D,className:"sr-only",children:"The WebGL map supports pointer, wheel, and touch navigation. Use the page search to focus a rendered page. Use the full page inventory for an accessible list of every crawled page and its links."}),s.jsx("p",{role:"status","aria-live":"polite",className:"sr-only",children:E})]})}function wr(n){return n>=70?"positive":n>=40?"caution":"negative"}function vr(n){return n>=70?"pass":n>=40?"partial":"fail"}function Nr(n){return n==="pass"?"positive":n==="partial"?"caution":"negative"}function $n(n){return n==="pass"?"Pass":n==="partial"?"Partial":"Fail"}function ss({audit:n,isLoading:e,error:t,onRetry:i}){return s.jsxs("section",{className:"border-t border-default pt-5","aria-labelledby":"site-health-page-audit-heading",children:[s.jsx("div",{children:s.jsx("h3",{id:"site-health-page-audit-heading",className:"text-base font-semibold text-heading",children:"Findings and fixes for this page"})}),e?s.jsx("p",{className:"mt-4 text-sm text-secondary",role:"status",children:"Loading findings..."}):t?s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3 border-y border-negative bg-negative-soft px-4 py-3",role:"alert",children:[s.jsx("p",{className:"text-sm text-negative",children:"Findings could not be loaded."}),s.jsx(M,{type:"button",variant:"secondary",size:"sm",onClick:i,children:"Try again"})]}):n?n.state==="no-crawl"?s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"No Site Health scan is available."}):n.state==="details-unavailable"?s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"This scan saved its summary, but not the findings for each page."}):n.state==="not-found"?s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"This page is not present in the selected scan."}):n.state==="not-audited"?s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"This page was found, but it was not scored."}):s.jsx(jr,{audit:n}):s.jsx("p",{className:"mt-4 text-sm text-secondary",children:"No findings are available for this page."})]})}function jr({audit:n}){const e=n.factors.filter(t=>t.applicable!==!1&&(t.status!=="pass"||t.findings.some(i=>i.type==="missing"||i.type==="timeout"||i.type==="unreachable")));return s.jsxs("div",{className:"mt-4",children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[s.jsxs("span",{"aria-label":`Score ${Math.round(n.auditScore)} out of 100`,className:"text-2xl font-semibold tabular-nums text-heading",children:[Math.round(n.auditScore),s.jsx("span",{className:"text-sm text-muted",children:"/100"})]}),s.jsx(X,{tone:wr(n.auditScore),children:$n(vr(n.auditScore))})]}),n.evidenceState==="scores-only"&&s.jsx("p",{className:"mt-3 border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"This older scan saved only the scores, not the findings or fixes."}),n.criticalDefects.length>0&&s.jsxs("section",{className:"mt-5","aria-labelledby":"site-health-critical-defects-heading",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h4",{id:"site-health-critical-defects-heading",className:"text-sm font-semibold text-heading",children:"Problems outside the score"}),s.jsx(X,{tone:n.criticalDefects.some(t=>t.severity==="critical")?"negative":"caution",children:n.criticalDefects.length}),s.jsx("span",{className:"text-xs text-muted",children:"Not counted in the score"})]}),s.jsx("ul",{className:"mt-2 divide-y divide-default border-y border-default",children:n.criticalDefects.map(t=>s.jsxs("li",{className:"py-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:"text-sm font-medium text-heading",children:t.detail}),s.jsx(X,{tone:t.severity==="critical"?"negative":"caution",children:t.severity==="critical"?"Critical":"Warning"})]}),s.jsxs("p",{className:"mt-1 text-sm text-secondary",children:[s.jsx("span",{className:"font-medium text-heading",children:"Fix:"})," ",t.recommendation]})]},t.id))})]}),e.length>0?s.jsx("div",{className:"mt-5 divide-y divide-default border-y border-default",children:e.map(t=>s.jsxs("details",{className:"group py-1",children:[s.jsxs("summary",{className:"flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 rounded-sm px-1 py-2 outline-none marker:hidden focus-visible:ring-2 focus-visible:ring-mono-400 [&::-webkit-details-marker]:hidden",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-sm font-medium text-heading",children:[s.jsx(Lt,{className:"size-4 shrink-0 text-muted transition-transform group-open:rotate-90","aria-hidden":"true"}),t.name]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs("span",{className:"text-sm tabular-nums text-heading",children:[Math.round(t.score),"/100"]}),s.jsx(X,{tone:Nr(t.status),children:$n(t.status)})]})]}),s.jsxs("div",{className:"grid gap-4 px-1 pb-4 pt-1 md:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Evidence"}),t.findings.length>0?s.jsx("ul",{className:"mt-2 space-y-1.5 text-sm text-secondary",children:t.findings.map((i,a)=>s.jsx("li",{children:i.message},`${i.code}:${a}`))}):s.jsx("p",{className:"mt-2 text-sm text-secondary",children:n.evidenceState==="scores-only"?"This scan did not save the findings here.":"Nothing to report here."})]}),s.jsxs("div",{children:[s.jsx("h5",{className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Recommended fix"}),t.recommendations.length>0?s.jsx("ol",{className:"mt-2 list-decimal space-y-1.5 pl-5 text-sm text-secondary marker:text-muted",children:t.recommendations.map(i=>s.jsx("li",{children:i},i))}):s.jsx("p",{className:"mt-2 text-sm text-secondary",children:n.evidenceState==="scores-only"?"This scan did not save a fix here.":"No fix suggested here."}),s.jsxs("p",{className:"mt-3 text-xs text-muted",children:["Worth ",t.weight,"% of the page score"]})]})]})]},t.id))}):n.criticalDefects.length===0&&n.evidenceState==="complete"?s.jsx("p",{className:"mt-4 border-y border-positive bg-positive-soft px-4 py-3 text-sm text-positive",children:"Nothing needs attention on this page."}):n.criticalDefects.length===0?s.jsx("p",{className:"mt-4 border-y border-default px-4 py-3 text-sm text-secondary",children:"This scan saved only the score. Run a new scan to see findings."}):null]})}const is=25;function kr(n){return n.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean)}function Sr(n){let e=n;try{e=decodeURIComponent(n.replace(/\+/g," "))}catch{}let t="";const i=n.indexOf("?");return i>=0&&new URLSearchParams(n.slice(i+1)).forEach((r,o)=>{t+=` ${o} ${r}`}),`${n} ${e}${t}`}function Er(n,e=36,t=18){const i=[...n];return i.length<=e+t+1?n:`${i.slice(0,e).join("")}…${i.slice(-t).join("")}`}function Ar({value:n,headLength:e,tailLength:t,className:i,title:a}){const r=Er(n,e,t);return s.jsx("span",{className:i,title:a??n,children:r===n?n:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sr-only",children:n}),s.jsx("span",{"aria-hidden":"true",children:r})]})})}function _r({rows:n,getSearchText:e,pageSize:t=is}){const[i,a]=w.useState(""),[r,o]=w.useState(1),l=w.useMemo(()=>kr(i),[i]),c=w.useMemo(()=>l.length===0||!e?n:n.filter(j=>{const D=e(j).toLocaleLowerCase();return l.every(C=>D.includes(C))}),[e,n,l]),d=Math.max(1,Math.ceil(c.length/t)),f=Math.min(Math.max(1,r),d),u=(f-1)*t,h=w.useMemo(()=>c.slice(u,u+t),[c,t,u]),x=w.useCallback(j=>{a(j),o(1)},[]),A=w.useCallback(j=>{o(Math.max(1,j))},[]);return{query:i,setQuery:x,page:f,setPage:A,rows:h,filteredRows:c,totalRows:c.length,totalPages:d,pageSize:t,rangeStart:c.length===0?0:u+1,rangeEnd:u+h.length,hasQuery:i.trim().length>0}}function $r({value:n,onChange:e,label:t,placeholder:i="Filter rows",className:a}){return s.jsxs("div",{className:`relative ${a??""}`,children:[s.jsx(Yt,{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted"}),s.jsx("input",{type:"search",value:n,onChange:r=>e(r.target.value),"aria-label":t,placeholder:i,autoComplete:"off",spellCheck:!1,className:"h-9 w-full rounded-md border border-default bg-surface/50 pl-9 pr-9 text-sm text-strong placeholder:text-muted outline-none transition focus:border-mono-500 focus:ring-1 focus:ring-mono-500 [&::-webkit-search-cancel-button]:appearance-none"}),n.trim().length>0?s.jsx("button",{type:"button",onClick:()=>e(""),"aria-label":`Clear ${t.toLocaleLowerCase()}`,className:"absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded text-muted transition-colors hover:bg-surface-hover hover:text-strong focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-mono-500",children:s.jsx(mi,{"aria-hidden":"true",className:"size-3.5"})}):null]})}function Lr({page:n,pageSize:e=is,visibleRows:t,totalRows:i,hasNextPage:a,onPageChange:r,itemLabel:o="rows",className:l,disabled:c=!1}){if(t===0)return null;const d=(n-1)*e+1,f=d+t-1,u=i===void 0?void 0:Math.max(1,Math.ceil(i/e)),h=a??(u!==void 0&&n<u),x=n>1||h;return s.jsxs("div",{className:`mt-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-secondary ${l??""}`,children:[s.jsxs("p",{className:"tabular-nums",children:[d.toLocaleString("en-US"),"–",f.toLocaleString("en-US"),i===void 0?`${h?"+":""} ${o}`:` of ${i.toLocaleString("en-US")} ${o}`]}),x?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>r(n-1),disabled:c||n<=1,className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:[s.jsx(gi,{"aria-hidden":"true",className:"size-3.5"}),"Previous"]}),s.jsx("span",{className:"tabular-nums",children:u===void 0?`Page ${n}`:`Page ${n} of ${u}`}),s.jsxs("button",{type:"button",onClick:()=>r(n+1),disabled:c||!h,className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:["Next",s.jsx(Lt,{"aria-hidden":"true",className:"size-3.5"})]})]}):null]})}const Tr=100,Ot=12,Gr=[];function Cr(n){return Sr(n.url)}function pt(n){return n>=70?"positive":n>=40?"caution":"negative"}function Et(n){return n>=70?"text-positive-400":n>=40?"text-caution-400":"text-negative-400"}function Dr(n){return n==="pass"?"positive":n==="partial"?"caution":"negative"}function mt(n){return n>=70?"Pass":n>=40?"Partial":"Fail"}function Pr(n){return vi(On(String(n)))}function Rr(n){return Ni(On(String(n)))}function Ir({projectName:n,projectId:e,runId:t,integrated:i=!1,compactCopy:a=!1,afterSummary:r,unavailableFooter:o}){const{isAdmin:l}=Dn(),c=$t(Ke["site-audit"])&&!l,[d,f]=w.useState(!1),[u,h]=w.useState(null),[x,A]=w.useState(null),j=t===void 0?x:t,[D,C]=w.useState(!1),F=w.useRef(null),R=me(Us({client:le,path:{name:n},...j?{query:{runId:j}}:{}})),g=me({...Bs({client:le,path:{name:n},query:{limit:30}}),enabled:!i}),m=me(Hs({client:le,path:{name:n},query:{limit:Tr,sort:"score-asc",...j?{runId:j}:{}}})),b=me({...Ks({client:le,path:{name:n},query:{kind:Ke["site-audit"],limit:10}}),enabled:!i,refetchOnWindowFocus:"always",refetchInterval:p=>p.state.data?.some(T=>T.status==="queued"||T.status==="running")?3e3:1e4}),N=Pn(),_=w.useSyncExternalStore(Ws,hn,hn),G=Object.values(_.runs).find(p=>p.kind===Ke["site-audit"]&&p.projectId===e),P=b.data??[],U=P.find(p=>p.status==="queued"||p.status==="running"),Q=P.at(-1),Y=N.isPending||!!G||!!U,se=N.isPending?"starting":U?.status??G?.lastAnnouncedStatus,L=w.useCallback(async()=>{const p=await Promise.all([R.refetch(),m.refetch(),...i?[]:[g.refetch()]]),H=p.find(T=>T.error);if(H?.error)throw H.error;return p[0]},[i,m.refetch,R.refetch,g.refetch]);w.useEffect(()=>{i||j||!Q||Q.status!=="completed"&&Q.status!=="partial"||R.data?.runId===Q.id||F.current===Q.id||(F.current=Q.id,L().catch(p=>{Pt({title:"Technical AEO auto-refresh failed",detail:p instanceof Error?p.message:"Could not load the completed audit.",tone:"negative",dedupeKey:`technical-aeo:auto-refresh:${n}`,dedupeMode:"replace"})}))},[j,i,Q?.id,Q?.status,n,L,R.data?.runId]);const ge=async()=>{C(!0);try{const p=await L();Pt({title:"Technical AEO refreshed",detail:Y?"The audit is still running. This view will refresh again when it finishes.":p.data?.hasData?`Latest score is ${p.data.aggregateScore}/100 from ${p.data.pagesAudited} audited page${p.data.pagesAudited===1?"":"s"}.`:"No audit data yet. Run an audit to crawl the sitemap.",tone:p.data?.hasData?"positive":"caution",dedupeKey:`technical-aeo:refresh:${n}`,dedupeMode:"replace"})}catch(p){Pt({title:"Technical AEO refresh failed",detail:p instanceof Error?p.message:"Could not reload technical audit data.",tone:"negative",dedupeKey:`technical-aeo:refresh:${n}`,dedupeMode:"replace"})}finally{C(!1)}},ze=()=>{$t(Ke["site-audit"])&&!l||N.mutate({projectName:n,projectId:e})},ce=se==="running"?"Audit running":se==="queued"?"Audit queued":"Starting audit",E=R.data,pe=m.data?.pages??Gr,ie=a?pe.find(p=>p.status==="success"&&p.overallScore<70)??pe.find(p=>p.status==="success"):void 0,ae=!!(ie&&ie.overallScore<70),Ee=me({...Rn({client:le,path:{name:n},query:{...j?{runId:j}:{},url:ie?.url??""}}),enabled:a&&!!ie}),ue=(E?.pagesErrored??0)>0,he=d&&ue,xe=w.useMemo(()=>he?pe.filter(p=>p.status==="error"):pe,[pe,he]),J=_r({rows:xe,getSearchText:Cr}),ee=E?E.pagesAudited>pe.length:!1;if(w.useEffect(()=>{f(!1),h(null)},[a,j,i]),R.isLoading)return s.jsxs("div",{className:`flex min-h-40 items-center justify-center gap-2 text-sm text-secondary ${i?"":"mt-6"}`,role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading page health..."]});if(R.error)return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:`flex flex-col gap-4 rounded-lg border border-negative bg-negative-soft px-5 py-5 sm:flex-row sm:items-center sm:justify-between ${i?"":"mt-6"}`,role:"alert",children:[s.jsxs("div",{className:"flex min-w-0 gap-3",children:[s.jsx(Bt,{className:"mt-0.5 size-4 shrink-0 text-negative","aria-hidden":"true"}),s.jsxs("div",{children:[i?s.jsx("h3",{className:"font-semibold text-negative",children:"Page health could not load"}):s.jsx("h2",{className:"font-semibold text-negative",children:"Page health could not load"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"The saved audit could not be read. Try loading it again."})]})]}),s.jsxs(M,{type:"button",variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{ge()},disabled:D,children:[s.jsx(Rt,{className:`size-4 ${D?"motion-safe:animate-spin":""}`,"aria-hidden":"true"}),D?"Trying again...":"Try again"]})]}),o]});if(!E||!E.hasData)return i?s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"rounded-lg border border-default bg-surface-subtle px-5 py-7 text-center",children:[s.jsx(mn,{className:"mx-auto size-7 text-muted","aria-hidden":"true"}),s.jsx("h2",{className:"mt-3 text-base font-semibold text-heading",children:"Page health unavailable"}),s.jsx("p",{className:"mx-auto mt-2 max-w-md text-sm text-secondary",children:c?In:"Run a new Site Health scan to calculate page-level technical findings."})]}),o]}):s.jsxs(qs,{className:"surface-card mt-6 p-8 text-center",children:[s.jsx(mn,{className:"mx-auto mb-3 h-8 w-8 text-muted","aria-hidden":"true"}),s.jsx("h2",{className:"text-base font-semibold text-heading",children:"No technical audit yet"}),s.jsx("p",{className:"supporting-copy mx-auto mt-2 max-w-md",children:"A technical AEO audit crawls your sitemap and scores every page for structured data, AI-readable content, crawler access, freshness, and more, then rolls it up into one site score."}),!zt()&&!c&&s.jsx("div",{className:"mt-5 flex items-center justify-center gap-3",children:s.jsxs(Ft,{type:"button",onClick:ze,disabled:Y,children:[Y?s.jsx(je,{className:"mr-1.5 h-4 w-4 motion-safe:animate-spin","aria-hidden":"true"}):s.jsx(Ht,{className:"mr-1.5 h-4 w-4","aria-hidden":"true"}),Y?ce:"Run first audit"]})}),Y?s.jsx("p",{className:"mt-3 text-xs text-muted",role:"status","aria-live":"polite",children:"The dashboard will refresh automatically when the audit finishes."}):null]});const B=E.deltaScore==null?null:`${E.deltaScore>=0?"+":""}${E.deltaScore} vs previous`,re=E.trend==="up"?"positive":E.trend==="down"?"negative":"neutral",Le=g.data?.points??[],oe=Le.map(p=>({runId:p.runId,date:p.auditedAt,score:p.aggregateScore})),Ae=t===void 0&&x!==null,rt=pe.filter(p=>p.status==="success"),We=E.factors.filter(p=>p.pagesPartial+p.pagesFailing>0).length,Fe=E.runStatus==="partial",Te=E.crossCuttingIssues.some(p=>p.topRecommendations.length>0);function Ue(p){const H=[];for(const T of rt){const K=T.factors.find(te=>te.id===p);K&&K.score<70&&H.push({url:T.url,score:K.score})}return H.sort((T,K)=>T.score-K.score)}return s.jsxs("div",{className:i?"":"mt-6",children:[i?s.jsxs("section",{className:"flex flex-col gap-3 border-b border-default pb-5 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-secondary",children:Fe?"Score so far":"Site score"}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[s.jsxs("span",{"aria-label":Fe?`Score so far ${E.aggregateScore} out of 100, from a scan that did not cover the whole site`:`Site score ${E.aggregateScore} out of 100`,className:`inline-flex items-baseline gap-1 font-mono tabular-nums ${Et(E.aggregateScore)}`,children:[s.jsx("span",{className:"text-3xl font-semibold",children:E.aggregateScore}),s.jsx("span",{className:"text-sm text-muted",children:"/100"})]}),s.jsx(X,{tone:pt(E.aggregateScore),children:mt(E.aggregateScore)}),Fe?s.jsx(X,{tone:"caution",children:"Part of the site"}):null,B?s.jsx(X,{tone:re,children:B}):null]})]}),s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm tabular-nums text-secondary",children:[s.jsxs("span",{children:[E.pagesAudited," page",E.pagesAudited===1?"":"s"," checked"]}),s.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"·"}),s.jsxs("span",{children:[We," check",We===1?"":"s"," with pages below pass"]}),E.pagesErrored>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",className:"text-faint",children:"·"}),s.jsxs("span",{className:"text-negative",children:[E.pagesErrored," crawl error",E.pagesErrored===1?"":"s"]})]}):null]})]}):s.jsxs("section",{className:"surface-card flex flex-wrap items-start justify-between gap-6 rounded-lg border border-default bg-surface p-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:Ae?"Technical AEO history":"Technical AEO"}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-baseline gap-3",children:[s.jsx("span",{className:`text-4xl font-semibold tabular-nums ${Et(E.aggregateScore)}`,children:E.aggregateScore}),s.jsx("span",{className:"text-lg text-muted",children:"/ 100"}),s.jsx(X,{tone:pt(E.aggregateScore),children:mt(E.aggregateScore)}),B?s.jsx(X,{tone:re,children:B}):null,Y?s.jsx(X,{tone:"neutral",children:ce}):null]}),s.jsxs("p",{className:"supporting-copy mt-2 tabular-nums",children:[E.pagesDiscovered," URL",E.pagesDiscovered===1?"":"s"," in sitemap · ",E.pagesAudited," audited · ",E.pagesSkipped," skipped · ",E.pagesErrored," errored"]}),s.jsxs("p",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 text-xs text-muted",children:[s.jsx("span",{className:"text-faint",children:"Sitemap:"}),s.jsx("a",{href:E.sitemapUrl??"#",target:"_blank",rel:"noreferrer",className:"max-w-[22rem] truncate text-secondary underline decoration-mono-700 underline-offset-2 hover:text-strong",children:E.sitemapUrl}),s.jsx(fe,{text:"Every audit re-reads this sitemap, so pages you add or remove are picked up on the next run. Discovered/audited counts and the score reflect the sitemap at the time of the latest run. Override it with `canonry technical-aeo run <project> --sitemap-url <url>`."})]}),E.auditedAt?s.jsxs("p",{className:"mt-0.5 text-xs text-faint",children:["Audited ",new Date(E.auditedAt).toLocaleString()]}):null,Y?s.jsx("p",{className:"mt-1 text-xs text-muted",role:"status","aria-live":"polite",children:"Results refresh automatically when this audit finishes."}):null]}),s.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[t===void 0&&Le.length>1?s.jsxs("select",{"aria-label":"View a Technical AEO audit",value:x??"",onChange:p=>A(p.target.value||null),className:"min-h-11 rounded-md border border-base bg-bg px-3 text-sm text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[s.jsx("option",{value:"",children:"Latest audit"}),[...Le].reverse().slice(1).map(p=>s.jsxs("option",{value:p.runId,children:[new Date(p.auditedAt).toLocaleDateString()," · ",p.aggregateScore,"/100"]},p.runId))]}):null,s.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:()=>{ge()},disabled:D,children:[s.jsx(Rt,{className:`mr-1.5 h-4 w-4 ${D?"motion-safe:animate-spin":""}`,"aria-hidden":"true"}),D?"Refreshing…":"Refresh"]}),!zt()&&!c&&s.jsxs(Ft,{type:"button",size:"sm",onClick:ze,disabled:Y,children:[Y?s.jsx(je,{className:"mr-1.5 h-4 w-4 motion-safe:animate-spin","aria-hidden":"true"}):s.jsx(Ht,{className:"mr-1.5 h-4 w-4","aria-hidden":"true"}),Y?ce:"Re-run audit"]})]})]}),r,!i&&oe.length>=2?s.jsxs("section",{className:"page-section-divider",children:[s.jsxs("div",{className:"section-head",children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:"Trend"}),s.jsx("h2",{children:"Site score over time"})]}),s.jsxs("div",{className:"mt-3 h-56",children:[s.jsxs("p",{className:"sr-only",children:["Technical AEO scores range from ",Math.min(...oe.map(p=>p.score))," to ",Math.max(...oe.map(p=>p.score))," across ",oe.length," audits. Use the audit selector to inspect a previous scorecard."]}),s.jsx("div",{className:"h-full","aria-hidden":"true",children:s.jsx(ji,{width:"100%",height:"100%",children:s.jsxs(ki,{data:oe,margin:{top:8,right:8,bottom:0,left:0},children:[s.jsx(Si,{stroke:yi,vertical:!1}),s.jsx(Ei,{dataKey:"date",tick:xn,tickLine:!1,axisLine:{stroke:gn},tickFormatter:Pr,minTickGap:24}),s.jsx(Ai,{domain:[0,100],ticks:[0,25,50,75,100],tick:xn,tickLine:!1,axisLine:!1,width:32}),s.jsx(_i,{...wi,cursor:{stroke:gn,strokeWidth:1},labelFormatter:Rr,formatter:p=>[`${p}/100`,"Site score"]}),s.jsx($i,{type:"monotone",dataKey:"score",name:"score",stroke:bn.positive,strokeWidth:2.5,dot:{r:2.5,fill:bn.positive,strokeWidth:0},isAnimationActive:!1})]})})})]})]}):null,s.jsxs("section",{className:i?"pt-5":"page-section-divider",children:[i?s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold text-heading",children:a?"Checks":"Technical findings"}),s.jsx("p",{className:"mt-1 max-w-2xl text-sm text-secondary",children:a?Te?"Open a check to see affected pages and recommended fixes.":ie?ae?"Open a check to see affected pages. Page-level evidence for the first page to fix appears below.":"Open a check to see affected pages. Page-level evidence for one audited page appears below.":"Open a check to see affected pages and score details.":Te?"Select a check to see affected pages and recommended fixes.":"Select a check to see affected pages and score details."})]}):s.jsxs("div",{className:"section-head",children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:"Scorecard"}),s.jsxs("h2",{className:"inline-flex items-center gap-1.5",children:["Ranking factors",s.jsx(fe,{text:"Each factor is scored 0–100 per page (via the aeo-audit engine), then averaged across all successfully-audited pages. Pass ≥70, partial 40–69, fail <40. Expand a row to see which pages fall short and how to fix it."})]})]}),s.jsx("div",{className:"evidence-table-wrap mt-3",children:s.jsxs("table",{className:`evidence-table ${i?"min-w-[42rem]":""}`,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:i?"Technical check":"Factor"}),i?null:s.jsx("th",{className:"text-right",children:"Weight"}),s.jsx("th",{className:"text-right",children:i?"Score":"Avg"}),s.jsx("th",{children:"Status"}),s.jsx("th",{children:i?"Pages affected":"Pass / Partial / Fail"})]})}),s.jsx("tbody",{children:E.factors.map(p=>{const H=u===p.id,T=E.crossCuttingIssues.find(k=>k.factorId===p.id),K=H?Ue(p.id):[],te=p.pagesPartial+p.pagesFailing,ye=p.pagesPassing+te,we=!!T?.topRecommendations.length,O=we&&te>0;return s.jsxs(w.Fragment,{children:[s.jsxs("tr",{className:H?"bg-surface-subtle":void 0,children:[s.jsx("td",{children:s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 text-left font-medium text-strong outline-none hover:text-primary focus-visible:text-primary focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-mono-400","aria-expanded":H,onClick:()=>h(H?null:p.id),children:[H?s.jsx(Mn,{className:"size-4 shrink-0 text-muted","aria-hidden":"true"}):s.jsx(Lt,{className:"size-4 shrink-0 text-muted","aria-hidden":"true"}),p.name]})}),i?null:s.jsxs("td",{className:"text-right tabular-nums text-muted",children:[p.weight,"%"]}),s.jsxs("td",{className:"text-right font-mono tabular-nums text-strong",children:[p.avgScore,i?s.jsx("span",{className:"text-muted",children:"/100"}):null]}),s.jsx("td",{children:s.jsx(X,{tone:Dr(p.status),children:mt(p.avgScore)})}),i?s.jsxs("td",{className:`tabular-nums ${te>0?"text-strong":"text-muted"}`,children:[te," of ",ye]}):s.jsxs("td",{className:"tabular-nums text-secondary",children:[s.jsx("span",{className:"text-positive-400",children:p.pagesPassing})," / ",s.jsx("span",{className:"text-caution-400",children:p.pagesPartial})," / ",s.jsx("span",{className:"text-negative-400",children:p.pagesFailing})]})]}),H?s.jsx("tr",{className:"bg-surface-subtle",children:s.jsx("td",{colSpan:i?4:5,className:"px-4 pb-5 pt-0",children:s.jsxs("div",{className:`grid gap-5 border-t border-subtle pt-4 ${O?"lg:grid-cols-2":""}`,children:[we&&T?s.jsxs("section",{"aria-labelledby":`technical-finding-${p.id}-fixes`,children:[s.jsx("h4",{id:`technical-finding-${p.id}-fixes`,className:"text-sm font-semibold text-heading",children:"Recommended fixes"}),s.jsx("ol",{className:"mt-2 list-decimal space-y-1.5 pl-5 marker:text-muted",children:T.topRecommendations.map((k,W)=>s.jsx("li",{className:"pl-1 text-sm text-secondary",children:k},W))}),i?s.jsxs("p",{className:"mt-3 text-xs text-muted",children:["Weight: ",p.weight,"% of the site score"]}):null]}):te===0?s.jsx("p",{className:"text-sm text-secondary",children:"Every audited page passes this check."}):null,te>0?s.jsxs("section",{"aria-labelledby":`technical-finding-${p.id}-pages`,children:[s.jsxs("h4",{id:`technical-finding-${p.id}-pages`,className:"text-sm font-semibold text-heading",children:["Affected pages (",te,")"]}),i&&m.isLoading?s.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-secondary",role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading affected pages..."]}):i&&m.error?s.jsxs("div",{className:"mt-3",role:"alert",children:[s.jsx("p",{className:"text-sm font-medium text-negative",children:"Affected pages could not load"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Try the page-level audit read again."}),s.jsxs(M,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:()=>{m.refetch()},disabled:m.isFetching,children:[m.isFetching?s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}):s.jsx(Rt,{className:"size-4","aria-hidden":"true"}),m.isFetching?"Retrying affected pages...":"Retry affected pages"]})]}):K.length>0?s.jsx("ul",{className:"mt-2 space-y-1.5",children:K.slice(0,Ot).map(k=>s.jsxs("li",{className:"flex min-w-0 items-center gap-2 text-sm",children:[s.jsx("span",{className:`w-8 shrink-0 text-right font-mono tabular-nums ${Et(k.score)}`,children:k.score}),s.jsx("a",{href:k.url,target:"_blank",rel:"noreferrer",className:"min-w-0 truncate text-link outline-none hover:text-heading focus-visible:ring-2 focus-visible:ring-mono-400",title:k.url,children:k.url})]},k.url))}):s.jsx("p",{className:"mt-2 text-sm text-secondary",children:"Page details are not available in the loaded audit sample."}),K.length>Ot?s.jsxs("p",{className:"mt-2 text-xs text-muted",children:["+ ",K.length-Ot," more below pass"]}):null,ee&&(!i||!m.isLoading&&!m.error)?s.jsxs("p",{className:"mt-2 text-xs text-muted",children:["Showing the worst ",pe.length," audited pages."]}):null]}):null]})})}):null]},p.id)})})]})})]}),a&&ie?s.jsxs("section",{className:"border-t border-default pt-5","aria-labelledby":"onboarding-page-evidence-heading",children:[s.jsxs("div",{className:"flex flex-col justify-between gap-3 sm:flex-row sm:items-start",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{id:"onboarding-page-evidence-heading",className:"text-base font-semibold text-heading",children:ae?"First page to fix":"Example audited page"}),s.jsx("a",{href:ie.url,target:"_blank",rel:"noreferrer",className:"mt-1 block max-w-2xl truncate font-mono text-sm text-link outline-none hover:text-heading focus-visible:ring-2 focus-visible:ring-mono-400",title:ie.url,children:ie.url})]}),s.jsxs(X,{tone:pt(ie.overallScore),children:[Math.round(ie.overallScore),"/100"]})]}),s.jsx(ss,{audit:Ee.data,isLoading:Ee.isLoading,error:Ee.error,onRetry:()=>{Ee.refetch()}})]}):null,!i&&E.crossCuttingIssues.length>0?s.jsxs("section",{className:"page-section-divider",children:[s.jsxs("div",{className:"section-head",children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:"Opportunities"}),s.jsxs("h2",{className:"inline-flex items-center gap-1.5",children:["Prioritized fixes",s.jsx(fe,{text:"Factors scoring below pass across the most pages, ranked by site-wide impact. Fixing one of these typically lifts many pages at once."})]})]}),s.jsx("div",{className:"mt-3 divide-y divide-mono-800/60 overflow-hidden rounded-lg border border-default",children:E.crossCuttingIssues.map(p=>s.jsxs("div",{className:"p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("span",{className:"text-sm font-medium text-heading",children:p.factorName}),s.jsx(X,{tone:pt(p.avgScore),children:mt(p.avgScore)}),s.jsxs("span",{className:"text-xs tabular-nums text-muted",children:["avg ",p.avgScore," · affects ",p.affectedPages," of ",p.totalPages," pages (",p.affectedPct,"%)"]})]}),p.topRecommendations.length>0?s.jsx("ul",{className:"mt-2 space-y-1",children:p.topRecommendations.map((H,T)=>s.jsxs("li",{className:"flex gap-2 text-sm text-secondary",children:[s.jsx("span",{className:"select-none text-faint",children:"→"}),s.jsx("span",{children:H})]},T))}):null]},p.factorId))})]}):null,i?null:s.jsxs("section",{className:"page-section-divider",children:[s.jsxs("div",{className:"section-head section-head-inline",children:[s.jsxs("div",{children:[s.jsx("p",{className:"eyebrow eyebrow-soft",children:"Pages"}),s.jsx("h2",{children:"Per-page breakdown"})]}),ue?s.jsxs("div",{className:"segmented",role:"group","aria-label":"Filter pages",children:[s.jsxs("button",{type:"button",onClick:()=>{f(!1),J.setPage(1)},"aria-pressed":!he,className:`segmented-option min-h-11 tabular-nums ${he?"":"segmented-option-active"}`,children:["All ",E.pagesAudited]}),s.jsxs("button",{type:"button",onClick:()=>{f(!0),J.setPage(1)},"aria-pressed":he,className:`segmented-option min-h-11 tabular-nums ${he?"segmented-option-active text-negative":""}`,children:["Errors ",E.pagesErrored]})]}):null]}),pe.length>0?s.jsx($r,{value:J.query,onChange:J.setQuery,label:"Filter audited page URLs",placeholder:"Filter page URL or query parameters",className:"mt-3 max-w-md"}):null,J.totalRows===0?s.jsx("p",{className:"supporting-copy mt-3",children:J.hasQuery?"No pages match this filter.":"No pages recorded."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"evidence-table-wrap mt-3",children:s.jsxs("table",{className:"evidence-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-right",children:"Score"}),s.jsx("th",{children:"Status"}),s.jsx("th",{className:"w-full",children:"URL"})]})}),s.jsx("tbody",{children:J.rows.map(p=>s.jsxs("tr",{children:[s.jsx("td",{className:"text-right tabular-nums",children:p.status==="error"?s.jsxs("span",{className:"inline-flex items-center gap-1 text-negative-400",children:[s.jsx(Bt,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"err"]}):s.jsx("span",{className:Et(p.overallScore),children:p.overallScore})}),s.jsx("td",{children:p.status==="error"?s.jsx(X,{tone:"negative",children:"Error"}):s.jsx(X,{tone:pt(p.overallScore),children:mt(p.overallScore)})}),s.jsx("td",{className:"w-full max-w-0",children:s.jsx("a",{href:p.url,target:"_blank",rel:"noreferrer",className:"block truncate text-neutral hover:text-heading",title:p.status==="error"?p.error??p.url:p.url,children:s.jsx(Ar,{value:p.url,headLength:54,tailLength:20,title:p.status==="error"?p.error??p.url:p.url})})})]},p.url))})]})}),s.jsx(Lr,{page:J.page,pageSize:J.pageSize,visibleRows:J.rows.length,totalRows:J.totalRows,onPageChange:J.setPage,itemLabel:J.hasQuery?"matches":"rows"}),ee?s.jsxs("p",{className:"mt-2 text-xs text-faint",children:["Showing the worst ",pe.length," of ",E.pagesAudited," audited pages."]}):null]})]})]})}const Xe=[{id:"map",label:"Map"},{id:"inventory",label:"Pages"},{id:"technical",label:"Page health"}],as={map:"Explore how pages, site sections, and internal links fit together.",inventory:"Review discovered pages and the links that shape their visibility.",technical:"Prioritize audit findings and inspect the pages that need work."},rs=[{id:"all",label:"All",healthState:void 0},{id:"hidden",label:"Hidden pages",healthState:ti.hidden}],Mr={[Ye.metaRobotsNoindex]:"Hidden by meta robots tag",[Ye.xRobotsNoindex]:"Hidden by X-Robots-Tag header",[Ye.robotsDisallow]:"Blocked by robots.txt",[Ye.redirectTerminal]:"Redirects to another page",[Ye.canonicalToOther]:"Points to another page as canonical",[Ye.notHtmlOrUnavailable]:"Not an HTML page, so it was not scored"},Or=new Map(Object.entries(Mr));function zr(n){return Or.get(n)??n}const Fr=20,Ur=200,Br=100,os=100,Hr=50,Kr=ui,Wr=ci,qr=2e4,Vr=3,ke=new Intl.NumberFormat,Yr=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}),Qr={eligible:"positive",hidden:"caution",resource:"neutral",redirect:"neutral",failed:"negative",unchecked:"neutral"};function ls(n){if(!n)return"Date unavailable";const e=new Date(n);return Number.isNaN(e.getTime())?"Date unavailable":Yr.format(e)}function Xr(n){return n.replaceAll("_"," ").replaceAll("-"," ").replace(/\b\w/g,e=>e.toUpperCase())}function ds(n){const e=et(n);return{label:Wt(e),tone:Qr[e]}}function cs(n){if(n==null)return"Not scored";const e=n<=1?n*100:n;return`${Math.round(e)}%`}function Zr(n){return n.auditScore==null?"Not checked":`${Math.round(n.auditScore)}/100`}function I(n){return n==null?"Not available":ke.format(n)}const Jr={clicksFromHome:"How many clicks it takes to reach this page from the home page, following links.",linksIn:"How many other pages link to this page.",linksOut:"How many other pages this page links to.",linkImportance:"How much link value flows to this page, based on how many pages link to it and how important those pages are. Shown relative to the highest page on this site, which is 100%.",technicalScore:"How well this page is set up for AI and search engines to read, from 0 to 100. Open a page to see what it is marked down for.",linkTimes:"How many times this link appears on the page it comes from.",pagesFound:"How many pages this scan discovered, whether or not it could load them.",pagesChecked:"How many of the pages it found this scan actually loaded.",internalLinks:"How many links between pages on this site the scan recorded."},eo=new Set(["clicksFromHome","linkImportance","internalLinks","pagesFound","pagesChecked"]);function Ce(n,e){const t=Jr[n];return eo.has(n)?`${t} This always counts every link, including menu and footer.`:n==="technicalScore"||n==="linkTimes"?t:e?`${t} Right now this counts only links written in your page text. Menu and footer links are hidden.`:`${t} This counts every link, including menu and footer.`}function us(n,e){return`${ke.format(n)} ${e}${n===1?"":"s"}`}function to(n,e){if(!n||!e)return null;try{const t=new URL(n),i=new URL(e),a=r=>r.hostname.toLowerCase().replace(/\.$/,"").replace(/^www\./,"");return a(t)!==a(i)?{requested:t.host,effective:i.host}:null}catch{return null}}function no(n){return n==="completed"?"positive":n==="partial"||n==="queued"||n==="running"?"caution":n==="failed"||n==="cancelled"?"negative":"neutral"}function so(n){const e=ls(n.finishedAt??n.startedAt??n.createdAt),t=n.hasCrawlData?"":" · Score only";return`${e} · ${Xr(n.status)}${t}`}const io={complete:"This scan finished on its own.",unknown:"This scan stopped before it checked every page it found.","max-pages":"This scan stopped at the page limit, so some pages were not checked.","max-edges":"This scan stopped at the link limit, so some links are missing.","max-fetches":"This scan stopped after checking as many pages as it could.","max-duration":"This scan ran out of time, so some pages were not checked.","max-bytes":"This scan stopped at the data limit, so some pages were not checked.","max-page-bytes":"This scan skipped a page that was too large to read.","max-depth":"This scan stopped at the depth limit, so deeper pages were not checked.","max-links-per-page":"This scan stopped reading links on pages that had too many.","max-query-variants":"This scan stopped at the limit for pages that differ only by a query string.","max-sitemap-fanout":"This scan stopped at the sitemap limit, so some sitemaps were not read.","max-sitemap-urls":"This scan stopped at the sitemap page limit, so some pages were not found.","root-host-redirect":"The site moved to another address during this scan."},ao=new Map(Object.entries(io)),ro=[{value:null,label:`Default (${li.toLocaleString()} pages)`},{value:Ut,label:"100 pages (quick look)"},{value:500,label:"500 pages"},{value:2500,label:"2,500 pages"},{value:1e4,label:"10,000 pages"}],hs=[{value:null,label:`Default (${Vs} clicks)`},{value:1,label:"1 click from the home page"},{value:2,label:"2 clicks"},{value:3,label:"3 clicks"},{value:5,label:"5 clicks"},{value:20,label:"20 clicks"},{value:50,label:"50 clicks"},{value:100,label:"100 clicks (maximum)"}],oo={"max-pages":"Raise the page budget in Scan settings.","max-edges":"Raise the page budget in Scan settings.","max-fetches":"Raise the page budget in Scan settings.","max-duration":"Try a smaller scan in Scan settings.","max-depth":"Raise the crawl depth in Scan settings."};function lo(n,e=!1){if(!n)return null;const t=oo[n]??null;return t&&e?`${t.replace(/ in Scan settings\.$/,"")} in Site Health's Scan settings after setup.`:t}function co(n){return n?ao.get(n)??`This scan stopped early: ${n}.`:"This scan stopped before it checked every page it found."}const tn={applied:"This scan told menu and footer links apart by how often the same link repeats across pages. It cannot spot a link written into the page text when its wording matches the menu. Run a new scan to read the page layout instead.","applied-placement":"This scan read where each link sits in the page, so links in the page text are separated from the menu, header, and footer even when they use the same wording.","applied-placement-with-ubiquity":"This scan read where each link sits in the page. Some pages mark out no menu or main area, so those links fall back to how often the link repeats across pages, which can miss a link written into the page text.","applied-placement-partial":`This scan read where each link sits in the page. Some pages mark out no menu or main area, and this scan found fewer than ${fn} pages, so nothing could tell those links apart. They are counted as links in your page text, which is what a link no rule marked as menu, header, or footer means here.`,"unavailable-too-few-pages":`This scan found fewer than ${fn} pages and did not read where each link sits in the page. On a site that small every link is on most pages, so menu and footer links cannot be told apart from the rest.`,"unavailable-legacy-scan":"This scan ran before menu and footer links were separated. Run a new scan to split them out."},uo=new Map(Object.entries(tn));function fs(n){return n===null?"":uo.get(n)??tn["unavailable-legacy-scan"]}const ps="Scroll to zoom. Click a page to inspect it.",ms="Observed links to and from this page in the selected scan.",gs="Page positions on this map were set before menu and footer links were separated. Run a new scan to update them.";function xs(n){if(n.filterUnavailable)return`All ${us(n.totalEdgeCount,"link")} shown.`;const e=`${ke.format(n.contentEdgeCount)} link${n.contentEdgeCount===1?"":"s"} in your page text`,t=ke.format(n.templateEdgeCount);return n.showTemplateLinks?`${e}, ${t} menu and footer.`:`${e}. ${t} menu and footer link${n.templateEdgeCount===1?"":"s"} hidden.`}const bs="Menu, header, and footer links repeat on every page, so they say nothing about which pages relate to each other. Links written in your page text do.";function ys(n,e){const t=[bs,fs(n)];return e.staleLayout&&t.push(gs),t.filter(Boolean).join(" ")}function ho(n,e,t){if(n==="disabled")return{label:"Broken links: not checked",tone:"neutral"};const i=t??0,a=i>0?`, ${ke.format(i)} unchecked`:"";return n==="complete"?e?{label:`Broken links: ${ke.format(e)} found${a}`,tone:"negative"}:i>0?{label:`Broken links: none found, ${ke.format(i)} unchecked`,tone:"caution"}:{label:"Broken links: none found",tone:"positive"}:n==="partial"?{label:`Broken links: ${ke.format(e??0)} found so far${a}`,tone:"caution"}:{label:"Broken links: not checked",tone:"neutral"}}function Vt(n){return n.showTemplateLinks||!n.known?{value:I(n.total),hiddenNote:null,filtered:!1}:{filtered:!0,value:n.truncated?`${I(n.visible)}+`:I(n.visible),hiddenNote:n.hidden===0?null:n.truncated?`At least ${I(n.hidden)} menu and footer hidden`:`${I(n.hidden)} menu and footer hidden`}}function At({label:n,value:e,hiddenNote:t,help:i}){return s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("dt",{className:"flex items-center gap-1 text-xs text-muted",children:[n,s.jsx(fe,{text:i})]}),s.jsx("dd",{className:"mt-1 text-sm font-medium tabular-nums text-heading",children:e}),t&&s.jsx("dd",{className:"mt-0.5 text-xs text-muted",children:t})]})}function fo({page:n,inbound:e,outbound:t}){return s.jsx(s.Fragment,{children:s.jsxs("dl",{className:"grid grid-cols-2 divide-x divide-y divide-default rounded-lg border border-default sm:grid-cols-4 sm:divide-y-0",children:[s.jsx(At,{label:"Clicks from home",value:String(n.depth??"Not reached"),help:Ce("clicksFromHome",!1)}),s.jsx(At,{label:"Links in",value:e.value,hiddenNote:e.hiddenNote,help:Ce("linksIn",e.filtered)}),s.jsx(At,{label:"Links out",value:t.value,hiddenNote:t.hiddenNote,help:Ce("linksOut",t.filtered)}),s.jsx(At,{label:"Link importance",value:cs(n.linkScoreNormalized),help:Ce("linkImportance",!1)})]})})}function ws(n,e,t){if(e===0)return n==="inbound"?"Nothing links to this page.":"This page links to nothing.";const i=n==="inbound"?"No links in the page text point here.":"No links in the page text lead away from here.",a=t?`At least ${I(e)} menu and footer links hidden.`:`${us(e,"menu and footer link")} hidden.`;return`${i} ${a}`}function Je({label:n,metric:e}){return s.jsxs("span",{className:"inline-flex items-center gap-1",children:[n,s.jsx(fe,{text:Ce(e,!1)})]})}function Ln({direction:n,edges:e,truncated:t,rootHost:i,hiddenTemplateCount:a}){const r=n==="inbound"?"Links in":"Links out";return s.jsxs("section",{className:"min-w-0","aria-labelledby":`site-health-${n}-heading`,children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsxs("h4",{id:`site-health-${n}-heading`,className:"text-sm font-medium text-heading",children:[r," (",I(e.length),")"]}),t&&s.jsxs("span",{className:"text-xs text-muted",children:["First ",os]})]}),e.length===0?s.jsx("p",{className:"rounded-lg border border-subtle bg-surface-subtle px-3 py-4 text-sm text-secondary",children:ws(n,a,t)}):s.jsx("div",{className:"evidence-table-wrap max-h-64 overflow-auto",children:s.jsxs("table",{className:"evidence-table site-health-table min-w-[420px]",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{scope:"col",children:"Page"}),s.jsx("th",{scope:"col",children:"Anchor text"}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Times",metric:"linkTimes"})})]})}),s.jsx("tbody",{children:e.map(o=>{const l=n==="inbound"?o.sourceUrl:o.targetUrl;return s.jsxs("tr",{children:[s.jsx("td",{className:"max-w-64 truncate font-mono",title:l,children:Fn(l,i)}),s.jsx("td",{className:"max-w-52 truncate",title:o.anchors.join(", ")||void 0,children:o.anchors.join(", ")||"No anchor text"}),s.jsx("td",{className:"tabular-nums",children:I(o.occurrences)})]},o.edgeKey)})})]})})]})}function po(n){return n&&"indexabilityReasons"in n?n.indexabilityReasons:[]}function Tn({page:n,isLoading:e,error:t,inbound:i,outbound:a,inboundTruncated:r,outboundTruncated:o,audit:l,auditLoading:c,auditError:d,onRetryAudit:f,rootHost:u,reasonSource:h,reasonsState:x,onRetryReasons:A,showTemplateLinks:j}){if(!n)return s.jsxs("section",{className:"border-t border-default pt-5","aria-label":"Selected page details",children:[s.jsx("h3",{className:"text-base font-medium text-heading",children:"Page links"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Select a page to inspect its internal links and crawl signals."})]});const D=ds(n),C=po(h??n),F=j?i:i.filter(G=>!G.isTemplate),R=j?a:a.filter(G=>!G.isTemplate),g=!e&&!t,m=i.length-F.length,b=a.length-R.length,N=Vt({total:n.inboundUniqueEdges,visible:F.length,hidden:m,truncated:r,showTemplateLinks:j,known:g}),_=Vt({total:n.outboundUniqueEdges,visible:R.length,hidden:b,truncated:o,showTemplateLinks:j,known:g});return s.jsxs("section",{className:"border-t border-default pt-5","aria-labelledby":"site-health-page-inspector-title",children:[s.jsxs("div",{className:"flex flex-col justify-between gap-3 sm:flex-row sm:items-start",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h3",{id:"site-health-page-inspector-title",className:"break-words font-mono text-base font-semibold text-heading",children:n.path}),s.jsx(X,{tone:D.tone,children:D.label})]}),s.jsx("p",{className:"mt-1 break-all text-sm text-secondary",children:n.url}),x==="loading"?s.jsx("p",{className:"mt-2 text-sm text-secondary",role:"status",children:"Loading page details..."}):x==="error"?s.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-2 text-sm text-negative",role:"alert",children:["Page details could not be loaded, so any reason this page is hidden is unknown.",s.jsx(M,{type:"button",variant:"secondary",size:"sm",onClick:A,children:"Try again"})]}):C.length>0?s.jsx("ul",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-sm text-secondary","aria-label":"Why this page is hidden",children:C.map(G=>s.jsx("li",{children:zr(G)},G))}):null]}),s.jsx(M,{asChild:!0,variant:"secondary",size:"sm",children:s.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",children:["Open page ",s.jsx(bi,{className:"size-3.5","aria-hidden":"true"})]})})]}),s.jsx("div",{className:"mt-4",children:s.jsx(ss,{audit:l,isLoading:c,error:d,onRetry:f})}),s.jsxs("section",{className:"mt-5 border-t border-default pt-5","aria-labelledby":"site-health-page-links-heading",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("h3",{id:"site-health-page-links-heading",className:"text-base font-semibold text-heading",children:"Internal links"}),s.jsx(fe,{text:ms})]}),s.jsx("div",{className:"mt-4",children:s.jsx(fo,{page:n,inbound:N,outbound:_})}),s.jsx("div",{className:"mt-5",children:e?s.jsxs("div",{className:"flex items-center gap-2 py-6 text-sm text-secondary",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading page links..."]}):t?s.jsx("p",{className:"rounded-lg border border-negative bg-negative-soft px-4 py-3 text-sm text-negative",role:"alert",children:"Page links could not be loaded."}):s.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[s.jsx(Ln,{direction:"inbound",edges:F,truncated:r,rootHost:u,hiddenTemplateCount:m}),s.jsx(Ln,{direction:"outbound",edges:R,truncated:o,rootHost:u,hiddenTemplateCount:b})]})})]})]})}function mo({pages:n,total:e,selectedNodeKey:t,onSelect:i,hasNextPage:a,isFetchingNextPage:r,onLoadMore:o,filter:l,onFilterChange:c,filterUnavailable:d}){const[f,u]=w.useState(""),h=f.trim().toLowerCase(),x=w.useMemo(()=>h?n.filter(j=>`${j.path} ${j.url}`.toLowerCase().includes(h)):n,[h,n]),A=h.length>0&&(a||n.length<e);return s.jsxs("section",{"aria-labelledby":"site-health-inventory-heading",children:[s.jsxs("div",{className:"mb-3 flex flex-col justify-between gap-3 sm:flex-row sm:items-end",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"site-health-inventory-heading",className:"text-base font-semibold text-heading",children:"Pages"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:l==="all"?`Showing ${I(n.length)} of ${I(e)} pages found.`:`Showing ${I(n.length)} of ${I(e)} hidden pages.`})]}),s.jsxs("label",{className:"relative block w-full sm:w-72",children:[s.jsx("span",{className:"sr-only",children:"Search loaded pages"}),s.jsx(Yt,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted","aria-hidden":"true"}),s.jsx("input",{type:"search",value:f,onChange:j=>u(j.target.value),placeholder:"Search loaded pages",className:"h-9 w-full rounded-md border border-base bg-bg pl-9 pr-3 text-sm text-primary outline-none placeholder-mono-600 focus:border-strong focus:ring-2 focus:ring-mono-600"})]})]}),s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",role:"group","aria-label":"Filter pages",children:rs.map(j=>s.jsx("button",{type:"button","aria-pressed":l===j.id,onClick:()=>c(j.id),className:`filter-chip ${l===j.id?"filter-chip-active":""}`,children:j.label},j.id))}),s.jsx("div",{className:"evidence-table-wrap",children:s.jsxs("table",{className:"evidence-table site-health-table min-w-[800px]",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{scope:"col",children:"Page"}),s.jsx("th",{scope:"col",title:tt("eligible"),children:"Status"}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Clicks from home",metric:"clicksFromHome"})}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Links in",metric:"linksIn"})}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Links out",metric:"linksOut"})}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Link importance",metric:"linkImportance"})}),s.jsx("th",{scope:"col",children:s.jsx(Je,{label:"Score",metric:"technicalScore"})})]})}),s.jsx("tbody",{children:x.map(j=>{const D=ds(j);return s.jsxs("tr",{className:t===j.nodeKey?"bg-surface-active":void 0,children:[s.jsx("td",{className:"max-w-80",children:s.jsx("button",{type:"button",onClick:()=>i(j.nodeKey),className:"block max-w-full truncate rounded-sm font-mono text-sm font-medium text-link outline-none focus-visible:ring-2 focus-visible:ring-mono-400",title:j.url,children:j.path})}),s.jsx("td",{title:tt(et(j)),children:s.jsx(X,{tone:D.tone,children:D.label})}),s.jsx("td",{className:"tabular-nums",children:j.depth??"Not reached"}),s.jsx("td",{className:"tabular-nums",children:I(j.inboundUniqueEdges)}),s.jsx("td",{className:"tabular-nums",children:I(j.outboundUniqueEdges)}),s.jsx("td",{className:"tabular-nums",children:cs(j.linkScoreNormalized)}),s.jsx("td",{className:"tabular-nums",children:Zr(j)})]},j.nodeKey)})})]})}),x.length===0&&s.jsx("p",{className:"border-x border-b border-default px-4 py-8 text-center text-sm text-secondary",children:h.length===0?d?"This scan cannot be filtered. Run a new scan to filter its pages.":l==="hidden"?"No hidden pages were found in this scan.":"No pages are available.":A?`No matches in the ${I(n.length)} loaded pages. Load more pages to continue searching.`:"No pages match this search."}),a&&s.jsx("div",{className:"flex justify-center border-x border-b border-default px-4 py-3",children:s.jsxs(M,{variant:"secondary",size:"sm",disabled:r,onClick:o,children:[r&&s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),r?"Loading more pages":"Load more pages"]})})]})}function go({projectName:n,runId:e,section:t,onSelect:i}){const[a,r]=w.useState(!1),l=t.pageCount-(t.hasPage?1:0)>0;return s.jsxs("li",{children:[s.jsxs("div",{className:"flex min-h-11 items-center gap-1 px-2 py-1",children:[l?s.jsx("button",{type:"button","aria-label":`${a?"Collapse":"Expand"} ${t.path}`,"aria-expanded":a,onClick:()=>r(c=>!c),className:"flex size-8 shrink-0 items-center justify-center rounded-sm text-muted outline-none hover:bg-surface-hover hover:text-heading focus-visible:ring-2 focus-visible:ring-mono-400",children:a?s.jsx(Mn,{className:"size-3.5","aria-hidden":"true"}):s.jsx(Lt,{className:"size-3.5","aria-hidden":"true"})}):s.jsx("span",{className:"block size-8 shrink-0","aria-hidden":"true"}),s.jsx("button",{type:"button",onClick:()=>i(t.path),className:"min-w-0 flex-1 break-all rounded-sm py-2 text-left font-mono text-sm text-heading outline-none hover:text-link focus-visible:ring-2 focus-visible:ring-mono-400",children:t.path}),s.jsx("span",{className:"shrink-0 px-2 font-mono text-xs text-muted",children:I(t.pageCount)})]}),a&&s.jsx("div",{className:"ml-6 border-l border-default pl-1",children:s.jsx(vs,{projectName:n,runId:e,parentPath:t.path,onSelect:i})})]})}function xo({page:n,onSelect:e}){return s.jsx("li",{className:"bg-surface-subtle",children:s.jsxs("div",{className:"flex min-h-11 items-center gap-1 px-2 py-1",children:[s.jsx("span",{className:"block size-8 shrink-0","aria-hidden":"true"}),s.jsx("button",{type:"button",onClick:()=>e(n.nodeKey),className:"min-w-0 flex-1 break-all rounded-sm py-2 text-left font-mono text-sm font-semibold text-heading outline-none hover:text-link focus-visible:ring-2 focus-visible:ring-mono-400",children:n.path||"/"}),s.jsx("span",{className:"shrink-0 px-2 font-mono text-xs text-muted",children:I(1)})]})})}function vs({projectName:n,runId:e,parentPath:t,onSelect:i,rootPage:a,onSelectRootPage:r}){const o={client:le,path:{name:n},query:{runId:e,parentPath:t,limit:Br}},l=Cn({...di(o),initialPageParam:o,getNextPageParam:d=>d.nextCursor?{path:o.path,query:{...o.query,cursor:d.nextCursor}}:void 0}),c=l.data?.pages.flatMap(d=>d.children)??[];return l.isLoading?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-sm text-secondary",role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," Loading sections..."]}):l.error?s.jsx("p",{className:"px-3 py-4 text-sm text-negative",role:"alert",children:"Site sections could not be loaded."}):c.length===0&&!a?s.jsx("p",{className:"px-3 py-4 text-sm text-secondary",children:"No nested sections were found."}):s.jsxs(s.Fragment,{children:[s.jsxs("ul",{className:"divide-y divide-default",children:[a&&r&&s.jsx(xo,{page:a,onSelect:r}),c.map(d=>s.jsx(go,{projectName:n,runId:e,section:d,onSelect:i},d.path))]}),l.hasNextPage&&s.jsx("div",{className:"px-3 py-2",children:s.jsx(M,{variant:"ghost",size:"sm",disabled:l.isFetchingNextPage,onClick:()=>{l.fetchNextPage()},children:l.isFetchingNextPage?"Loading more sections":"Load more sections"})})]})}function bo(){return s.jsx("div",{role:"status",className:"flex min-h-[420px] items-center justify-center rounded-lg border border-default bg-surface-inset px-6 text-center lg:min-h-[520px]",children:s.jsxs("div",{className:"max-w-sm",children:[s.jsx(je,{className:"mx-auto size-5 motion-safe:animate-spin text-muted","aria-hidden":"true"}),s.jsx("p",{className:"mt-3 text-sm font-medium text-heading",children:"Preparing the interactive site map"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Page and link data is ready for the graph renderer."})]})})}function Gn(n){return n==="discovering"?"Discovering pages":n==="checking"?"Checking pages":n==="arranging-map"?"Arranging map":n==="queued"?"Waiting to start":"Preparing scan"}function yo(n){return n!=="completed"&&n!=="partial"&&n!=="failed"&&n!=="cancelled"}function wo(n){return n==="queued"||n==="discovering"||n==="checking"||n==="arranging-map"}function vo(n){return n==="completed"||n==="partial"||n==="failed"||n==="cancelled"}function No(n){if(!n||typeof n!="object")return null;const e=n;if(typeof e.code=="string")return e.code;if(e.error&&typeof e.error=="object"){const t=e.error;return typeof t.code=="string"?t.code:null}return null}function jo(n){if(!n)return null;const e=Date.parse(n);return!Number.isFinite(e)||e>Date.now()?null:e+qr}function ko({active:n,runId:e,createdAt:t}){const i=jo(t),[a,r]=w.useState(null);return w.useEffect(()=>{if(!n||!e||i==null){r(null);return}const o=i-Date.now();if(o<=0){r({runId:e,deadline:i});return}r(null);const l=window.setTimeout(()=>r({runId:e,deadline:i}),o);return()=>window.clearTimeout(l)},[n,i,e]),n&&e!=null&&i!=null&&(Date.now()>=i||a?.runId===e&&a.deadline===i)}function So({onContinueOnboarding:n,onSkipOnboarding:e}){return s.jsxs("section",{"aria-labelledby":"site-health-continuation-heading",className:"mt-5 flex flex-col gap-3 border-t border-default pt-5 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h3",{id:"site-health-continuation-heading",className:"text-base font-semibold text-heading",children:"Continue while Site Health finishes"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Canonry will finish this scan locally. Saved results will appear in Site Health."})]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[s.jsx(M,{type:"button",onClick:n,children:"Set up AI Visibility"}),s.jsx(M,{type:"button",variant:"secondary",onClick:e,children:"Skip for now"})]})]})}function Ze({view:n,tabbed:e=!0,children:t}){return s.jsx("div",{id:e?`site-health-${n}-panel`:void 0,role:e?"tabpanel":void 0,"aria-labelledby":e?`site-health-${n}-tab`:void 0,className:"min-w-0",children:t})}function Eo({status:n,progress:e,progressError:t,onRetryProgress:i,pageHealthDestination:a=!1,firstLook:r=!1,boundedPageLimit:o,livePageHealthPreview:l,livePageHealthError:c=!1,livePageHealthRunId:d=null,continuation:f}){const u=e?.attempt??null,h=e?.phase??n,x=h==="arranging-map";return s.jsxs("section",{"aria-label":"Current scan progress",className:"rounded-lg border border-caution bg-caution-soft px-5 py-6",children:[s.jsx("h2",{className:"min-h-6 text-base font-semibold text-heading",children:x&&a?"Preparing page health":x?"Preparing site map":"Scanning site"}),s.jsx("p",{"aria-atomic":"true","aria-label":"Current scan progress","aria-live":"polite",role:"status",className:"mt-1 min-h-[4.5rem] text-sm text-secondary sm:min-h-10",children:a?x?"Finalizing page health. The scan is complete and its findings are being published.":`${Gn(h)}. Page health appears after the scan finishes.`:x?"Arranging map. The scan is complete and its map is being published.":`${Gn(h)}. The map appears after the scan finishes.`}),r?s.jsxs("p",{className:"mt-3 flex items-center gap-1.5 rounded-lg border border-default bg-bg px-4 py-2 text-sm text-primary",children:["A quick scan to find your first fixes.",s.jsx(fe,{text:o?`Reads up to ${o} pages, or stops sooner at the time limit, so results come back fast. You can run a larger scan from Site Health later.`:"Stops at its page budget or the time limit, so results come back fast. You can run a larger scan from Site Health later."})]}):null,s.jsxs("dl",{"aria-label":"Live scan counters",className:"mt-5 grid grid-cols-2 divide-x divide-y divide-default rounded-lg border border-default bg-surface-subtle sm:grid-cols-4 sm:divide-y-0",children:[s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("dt",{className:"text-sm text-secondary",children:"Pages found"}),s.jsx("dd",{className:"mt-1 font-mono text-lg font-semibold tabular-nums text-heading",children:u?I(u.pagesDiscovered):"—"})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("dt",{className:"text-sm text-secondary",children:"Pages checked"}),s.jsx("dd",{className:"mt-1 font-mono text-lg font-semibold tabular-nums text-heading",children:u?I(u.pagesFetched):"—"})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("dt",{className:"text-sm text-secondary",children:"Links found"}),s.jsx("dd",{className:"mt-1 font-mono text-lg font-semibold tabular-nums text-heading",children:u?I(u.edgesDiscovered):"—"})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("dt",{className:"text-sm text-secondary",children:"Pages failed"}),s.jsx("dd",{className:"mt-1 font-mono text-lg font-semibold tabular-nums text-heading",children:u?I(u.pagesErrored):"—"})]})]}),t&&s.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 text-sm text-secondary",children:[s.jsx("span",{children:x?a?"Page health publishing status could not load.":"Map publishing status could not load.":"Live scan counts could not load. The scan is still running."}),i&&s.jsx(M,{type:"button",variant:"secondary",size:"sm",onClick:i,children:"Retry progress"})]}),a?s.jsx(Ns,{runId:d,preview:l,error:c}):null,f]})}function _t(){return Array.from({length:Vr},()=>null)}function Ao(n,e){return n===e||n!=null&&e!=null&&n.nodeKey===e.nodeKey&&n.url===e.url&&n.auditScore===e.auditScore&&n.checksNeedingAttention===e.checksNeedingAttention}function _o(n,e){return n.length===e.length&&n.every((t,i)=>Ao(t,e[i]??null))}function $o(n,e){const t=[...n];for(const i of e){const a=t.findIndex(o=>o?.nodeKey===i.nodeKey);if(a>=0){t[a]=i;continue}const r=t.findIndex(o=>o==null);if(r<0)break;t[r]=i}return t}function Ns({runId:n,preview:e,error:t=!1}){const[i,a]=w.useState(()=>({runId:n,slots:_t()})),r=e?.state==="terminal",o=r||i.runId!==n?_t():i.slots;w.useEffect(()=>{a(d=>{const f=d.runId===n?d.slots:_t(),u=r?_t():$o(f,e?.examples??[]);return d.runId===n&&_o(d.slots,u)?d:{runId:n,slots:u}})},[e?.examples,n,r]);const l=e?.pagesAudited??0,c=o.some(d=>d!=null);return s.jsxs("section",{"aria-labelledby":"live-page-health-findings-heading",className:"mt-5 border-t border-default pt-5",children:[s.jsx("h3",{id:"live-page-health-findings-heading",className:"text-base font-semibold text-heading",children:"Findings so far"}),s.jsxs("div",{className:"relative mt-1 min-h-[5.25rem] text-sm text-secondary sm:min-h-[3.5rem]",children:[s.jsxs("p",{children:["Based on ",ke.format(l)," audited pages. Results may change until the scan finishes."]}),s.jsx("p",{className:He("absolute bottom-0 text-caution",t?"visible":"invisible"),children:"Live findings paused. The scan is still running."})]}),s.jsx("ul",{"aria-label":"Live Page Health findings",className:"mt-3 grid h-[10.5rem] grid-rows-3 divide-y divide-default overflow-hidden rounded-lg border border-default bg-surface-subtle",children:o.map((d,f)=>{const u=d==null&&f===0&&!c,h=d==null&&!u;return s.jsx("li",{"aria-hidden":h||void 0,"data-testid":"live-page-health-slot",className:"grid h-14 min-h-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 px-4 sm:gap-4",children:d?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-strong",title:d.url,children:d.url}),s.jsxs("span",{className:"shrink-0 whitespace-nowrap text-sm tabular-nums text-secondary",children:[s.jsxs("span",{"aria-hidden":"true",className:"sm:hidden",children:[ke.format(d.checksNeedingAttention)," checks"]}),s.jsxs("span",{className:"hidden sm:inline",children:[ke.format(d.checksNeedingAttention)," checks need attention"]}),s.jsxs("span",{className:"sr-only sm:hidden",children:[ke.format(d.checksNeedingAttention)," checks need attention"]})]})]}):u?s.jsx("span",{className:"text-sm text-secondary",children:"Checks that need attention will appear here."}):null},`live-page-health-slot-${f}`)})})]})}function Lo({phase:n,progress:e,onRunAgain:t,pageHealthDestination:i=!1}){const a=n==="cancelled",r=e?.error??e?.attempt?.error;return s.jsxs("section",{"aria-label":"Site scan recovery",role:"alert",className:"rounded-lg border border-negative bg-negative-soft px-5 py-6",children:[s.jsx("h2",{className:"text-base font-semibold text-negative",children:a?"Scan cancelled":"Scan failed"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:i?a?"The scan was cancelled before Canonry could publish page health results.":"The scan did not complete, so page health results are unavailable.":a?"The scan was cancelled before Canonry could publish a site map.":"The scan did not complete, so there is no site map for this run."}),r&&s.jsx("p",{className:"mt-3 text-sm text-negative",children:r}),t&&s.jsx(M,{type:"button",className:"mt-4",onClick:t,children:"Run scan again"})]})}function To({projectName:n,projectId:e,initialRunId:t,onReleaseInitialRun:i,showOnboardingActions:a=!1,onContinueOnboarding:r,onSkipOnboarding:o}){const[l,c]=w.useState("map"),d=w.useRef([]),[f,u]=w.useState(()=>t??null),h=w.useRef(t),[x,A]=w.useState(null),[j,D]=w.useState(!1),[C,F]=w.useState(null),[R,g]=w.useState(null),[m,b]=w.useState(!1),[N,_]=w.useState("all"),[G,P]=w.useState(!1),U=zt(),{isAdmin:Q}=Dn(),Y=Ys(),se=(Y||$t(Ke["site-audit"]))&&!Q,L=a&&!U,ge=Pn();w.useEffect(()=>{const y=h.current;y!==t&&(h.current=t,u(ne=>t??(ne===y?null:ne)),A(null))},[t]);const ce=me({...Qs({client:le,path:{name:n},query:{limit:Fr}}),refetchOnWindowFocus:"always",refetchInterval:y=>y.state.data?.scans.some(ne=>ne.status==="queued"||ne.status==="running")?3e3:15e3}).data?.scans??[],E=ce.find(y=>y.status==="queued"||y.status==="running"),pe=ce.find(y=>y.status==="completed"||y.status==="partial"),ie=L?ge.data?.runId??null:null,ae=f??(L?ie??E?.runId??pe?.runId:pe?.runId??E?.runId)??null,Ee=E?.runId===ae?E:null,ue=ae?ce.find(y=>y.runId===ae):void 0,he=!!(t&&ae===t),xe=!!(ie&&ae===ie),J=xe&&!ue,ee=Ee?.runId??(he||J?ae:null),B=me({...Xs({client:le,path:{name:n,runId:ee??""}}),enabled:!!ee,refetchInterval:y=>yo(y.state.data?.phase)?3e3:!1,refetchIntervalInBackground:!0});w.useEffect(()=>{!he||!B.isError||No(B.error)==="NOT_FOUND"&&(u(null),A(null),i?.())},[B.error,B.isError,he,i]);const re=wo(B.data?.phase),oe=vo(B.data?.phase)?null:Ee,Ae=!!(ee&&B.isPending),We=!!(!!((he||xe)&&!ue)&&B.isError),Fe=!!(L&&ee&&(oe?.runId===ee||re)),Te=me({...Zs({client:le,path:{name:n,runId:ee??""}}),enabled:Fe,refetchInterval:y=>y.state.data?.state==="terminal"?!1:3e3,refetchIntervalInBackground:!0}),Ue=!!(oe||re||Ae||We),p=B.data?.phase==="failed"||B.data?.phase==="cancelled"?B.data.phase:(he||xe)&&(ue?.status==="failed"||ue?.status==="cancelled")?ue.status:null,H=me({...Js({client:le,path:{name:n},...ae?{query:{runId:ae}}:{}}),enabled:!Ue}),T=H.data,K=ae??T?.runId??null,te=!!(K&&T?.hasCrawlData&&T.detailsAvailable),ye=te&&!L,we=K?{runId:K}:{},O=me({...ei({client:le,path:{name:n},query:{...we,maxNodes:Kr,maxEdges:Wr}}),enabled:ye&&!Ue}),k=rs.find(y=>y.id===N)?.healthState,W={client:le,path:{name:n},query:{...we,...k?{healthState:k}:{},limit:Ur,sort:"path"}},q=Cn({...ni(W),enabled:ye,initialPageParam:W,getNextPageParam:y=>y.nextCursor?{path:W.path,query:{...W.query,cursor:y.nextCursor}}:void 0}),ot=ye&&(T?.deadLinks.state==="complete"||T?.deadLinks.state==="partial"),js=me({...si({client:le,path:{name:n},query:{...we,limit:Hr}}),enabled:ot}),lt=O.data?.nodes??[],ks=O.data?.layout.state==="ready"?O.data.totalEdges:null,Ge=O.data?.edges??[],nn=w.useMemo(()=>Ge.filter(y=>y.isTemplate).length,[Ge]),Ss=Ge.length-nn,xt=O.data?.templateDetection??null,_e=xt===null||!oi(xt),Es=w.useMemo(()=>G||_e?Ge:Ge.filter(y=>!y.isTemplate),[Ge,G,_e]),As=O.data?.layout.state==="ready"&&!O.data.layout.templateLinksExcluded,bt=w.useMemo(()=>q.data?.pages.flatMap(y=>y.pages)??[],[q.data]),_s=q.data?.pages[0]?.total??bt.length,sn=w.useMemo(()=>bt.find(y=>y.nodeKey===x)??null,[bt,x]),Gt=!!(te&&x&&!sn),Re=me({...pn({client:le,path:{name:n},query:{...we,...k?{healthState:k}:{},nodeKey:x??void 0,limit:1}}),enabled:Gt}),dt=sn??Re.data?.pages[0]??null,yt=!!(x&&k&&Gt&&Re.isSuccess&&Re.data.healthStateFilter==="applied"&&Re.data.pages.length===0);w.useEffect(()=>{yt&&A(null)},[yt]);const Ie=w.useMemo(()=>yt?null:lt.find(y=>y.nodeKey===x)??dt,[lt,dt,x,yt]),qe=Ie?.nodeKey??null,an=Ie?dt?"ready":Re.isError?"error":Gt&&Re.isLoading?"loading":"ready":"idle",ve=me({...ii({client:le,path:{name:n},query:{...we,nodeKey:qe??void 0,limit:os}}),enabled:ye&&!!qe}),Me=me({...Rn({client:le,path:{name:n},query:{...we,nodeKey:qe??void 0}}),enabled:ye&&!!qe}),$s=w.useMemo(()=>{const y=ce.filter(V=>V.status==="completed"||V.status==="partial"),ne=f?ce.find(V=>V.runId===f):void 0;return ne&&!y.some(V=>V.runId===ne.runId)?[ne,...y]:y},[ce,f]),Ls=ce[0]?.status??null,wt=K?ue:void 0,Be=oe?oe.status:re?B.data?.status??null:p??T?.runStatus??wt?.status??null,Ts=Be==="running"?"Scan running":Be==="queued"?"Scan queued":Be==="partial"?"Partial scan":Be==="completed"?"Complete":Be==="failed"?"Scan failed":Be==="cancelled"?"Scan cancelled":"No scan",vt=js.data,rn=vt&&"found"in vt?vt:T?.deadLinks&&"found"in T.deadLinks?T.deadLinks:void 0,on=ho(vt?.state??T?.deadLinks?.state??"unavailable",rn?.found,rn?.unverified),Ct=to(T?.requestedRootUrl??null,T?.rootUrl??null),ln=zn(T?.rootUrl??null),Nt=O.data?.rootNodeKey??null,dn=me({...pn({client:le,path:{name:n},query:{...we,nodeKey:Nt??void 0,limit:1}}),enabled:!!(te&&Nt)}),Gs=w.useMemo(()=>lt.find(y=>y.nodeKey===Nt)??dn.data?.pages[0]??null,[lt,Nt,dn.data]),Cs=E&&E.runId!==ae?E:null,Ve=ge.isPending||!!oe||!!Cs||re||Ae,Dt=Ue||L&&ge.isPending,Ds=ue?.status==="queued"||ue?.status==="running",Ps=ko({active:L&&Dt&&!!(r&&o)&&!!(Ds||ee===ae&&re),runId:ae,createdAt:ue?.createdAt}),jt=!!(T?.hasCrawlData&&!Dt&&!p),be=L?jt?"technical":"map":l,cn=be==="technical"?"map":be,Rs=y=>{u(y||null),A(null)},ct=()=>{(Y||$t(Ke["site-audit"]))&&!Q||(u(null),A(null),t&&i?.(),L&&b(!0),ge.mutate({projectName:n,projectId:e,body:{checkDeadLinks:L||j,...L?{maxPages:Ut}:C===null?{}:{maxPages:C},...L||R===null?{}:{maxDepth:R}}}))},Is=y=>{const ne=lt.find(V=>V.path===y||V.path.startsWith(`${y}/`));ne&&A(ne.nodeKey)},un=y=>c(y),Ms=(y,ne)=>{let V=null;y.key==="ArrowRight"||y.key==="ArrowDown"?V=(ne+1)%Xe.length:y.key==="ArrowLeft"||y.key==="ArrowUp"?V=(ne-1+Xe.length)%Xe.length:y.key==="Home"?V=0:y.key==="End"&&(V=Xe.length-1),V!=null&&(y.preventDefault(),un(Xe[V].id),d.current[V]?.focus())};return s.jsxs("div",{className:"space-y-5",children:[L?s.jsx(ai,{current:jt?"fixes":"site"}):null,!L&&s.jsxs("header",{className:"flex flex-col justify-between gap-4 lg:flex-row lg:items-start",children:[s.jsx("div",{children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-heading",children:"Site Health"}),s.jsx(fe,{text:as[be]}),s.jsx(X,{tone:no(Be),children:Ts}),wt&&s.jsx("span",{className:"text-xs text-muted",children:ls(wt.finishedAt??wt.startedAt)})]})}),s.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[s.jsxs("label",{className:"grid gap-1 text-xs text-muted",children:["Scan history",s.jsxs("select",{"aria-label":"View a Site Health scan",value:f??"",onChange:y=>Rs(y.target.value),className:"h-9 min-w-48 rounded-md border border-base bg-bg px-3 text-sm text-primary outline-none focus:border-strong focus:ring-2 focus:ring-mono-600",children:[s.jsx("option",{value:"",children:"Latest scan"}),$s.map(y=>s.jsx("option",{value:y.runId,children:so(y)},y.runId))]})]}),!U&&!se&&s.jsxs("div",{className:"flex items-end gap-2 pt-5",children:[s.jsxs("details",{className:"group relative",children:[s.jsxs("summary",{className:"flex h-9 cursor-pointer list-none items-center gap-2 rounded-md border border-base bg-bg px-3 text-sm font-medium text-heading outline-none hover:bg-bg-elevated focus-visible:ring-2 focus-visible:ring-mono-400",children:[s.jsx(xi,{className:"size-4","aria-hidden":"true"}),"Scan settings"]}),s.jsxs("div",{className:"absolute right-0 z-20 mt-2 w-72 rounded-lg border border-strong bg-bg-elevated p-4 shadow-[0_12px_32px_var(--color-shadow-panel)]",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-heading",children:[s.jsxs("span",{className:"flex items-center gap-1.5 font-medium",children:["Check dead links",s.jsx(fe,{text:"Adds dead-link analysis to this scan. Slower on a large site."})]}),s.jsx("input",{type:"checkbox","aria-label":"Check dead links",checked:j,disabled:Ve,onChange:y=>D(y.target.checked),className:"size-4 rounded border-base accent-mono-200 focus:ring-2 focus:ring-mono-400"})]}),s.jsxs("div",{className:"mt-4",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-heading",children:["Page budget",s.jsx(fe,{text:"How many pages one scan may read before it stops."})]}),s.jsx("select",{"aria-label":"Page budget",value:C===null?"":String(C),disabled:Ve,onChange:y=>F(y.target.value===""?null:Number(y.target.value)),className:"mt-1 h-9 w-full rounded-md border border-base bg-bg px-2 text-sm text-primary outline-none focus:border-strong focus:ring-2 focus:ring-mono-600",children:ro.map(y=>s.jsx("option",{value:y.value===null?"":String(y.value),children:y.label},String(y.value)))})]}),s.jsxs("div",{className:"mt-3",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-medium text-heading",children:["Crawl depth",s.jsx(fe,{text:"How far from the home page to follow links. A smaller scan is what fixes a scan that ran out of time."})]}),s.jsx("select",{"aria-label":"Crawl depth",value:R===null?"":String(R),disabled:Ve,onChange:y=>g(y.target.value===""?null:Number(y.target.value)),className:"mt-1 h-9 w-full rounded-md border border-base bg-bg px-2 text-sm text-primary outline-none focus:border-strong focus:ring-2 focus:ring-mono-600",children:hs.map(y=>s.jsx("option",{value:y.value===null?"":String(y.value),children:y.label},String(y.value)))})]})]})]}),s.jsxs(Ft,{onClick:ct,disabled:Ve,children:[Ve?s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}):s.jsx(Ht,{className:"size-4","aria-hidden":"true"}),E?.status==="running"?"Scan running":E?.status==="queued"?"Scan queued":"Run scan"]})]})]})]}),se&&s.jsx(ri,{projectName:n,kind:Ke["site-audit"],loadSchedule:!Y}),T?.hasCrawlData&&be!=="technical"&&s.jsxs("div",{className:"grid grid-cols-2 divide-x divide-y divide-default rounded-lg border border-default bg-surface-subtle sm:grid-cols-4 sm:divide-y-0",children:[s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted",children:["Pages found",s.jsx(fe,{text:Ce("pagesFound",!1)})]}),s.jsx("div",{className:"mt-1 text-xl font-semibold tabular-nums text-heading",children:I(T.counts.pagesDiscovered)})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted",children:["Pages checked",s.jsx(fe,{text:Ce("pagesChecked",!1)})]}),s.jsx("div",{className:"mt-1 text-xl font-semibold tabular-nums text-heading",children:I(T.counts.pagesFetched)})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsx("div",{className:"text-xs text-muted",title:tt("eligible"),children:"Indexable"}),s.jsx("div",{className:"mt-1 text-xl font-semibold tabular-nums text-heading",children:I(T.counts.pagesEligible)})]}),s.jsxs("div",{className:"px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted",children:["Internal links",s.jsx(fe,{text:Ce("internalLinks",!1)})]}),s.jsx("div",{className:"mt-1 text-xl font-semibold tabular-nums text-heading",children:I(ks)})]})]}),!L&&s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-default",children:[s.jsx("div",{role:"tablist","aria-label":"Site Health views","aria-orientation":"horizontal",className:"flex min-w-0 gap-5",children:Xe.map((y,ne)=>s.jsx("button",{type:"button",role:"tab",id:`site-health-${y.id}-tab`,"aria-selected":be===y.id,"aria-controls":`site-health-${y.id}-panel`,tabIndex:be===y.id?0:-1,ref:V=>{d.current[ne]=V},onClick:()=>un(y.id),onKeyDown:V=>Ms(V,ne),className:`min-h-11 border-b-2 px-0.5 text-sm font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-mono-400 disabled:cursor-not-allowed disabled:opacity-50 ${be===y.id?"border-strong text-heading":"border-transparent text-secondary hover:border-base hover:text-primary"}`,children:y.label},y.id))}),T?.hasCrawlData&&be!=="technical"&&s.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[s.jsx("span",{className:"text-xs text-muted",children:"Dead-link check"}),s.jsx(X,{tone:on.tone,children:on.label})]})]}),!f&&E&&!oe&&s.jsx("div",{className:"rounded-lg border border-caution bg-caution-soft px-4 py-3 text-sm text-caution",role:"status",children:"A newer scan is running. The latest published result remains available until it finishes."}),Ct&&s.jsxs("div",{className:"rounded-lg border border-base bg-surface-subtle px-4 py-3 text-sm text-secondary",role:"status",children:[s.jsx("span",{className:"font-medium text-heading",children:"Site address changed during this scan."})," ","The scan started at ",s.jsx("span",{className:"font-mono text-primary",children:Ct.requested})," and continued at"," ",s.jsx("span",{className:"font-mono text-primary",children:Ct.effective}),"."," ",L?"Page health uses the new address.":"The map and inventory use the new address."]}),T?.hasCrawlData&&!T.complete&&s.jsxs("div",{className:"rounded-lg border border-caution bg-caution-soft px-4 py-3 text-sm text-caution",role:"status",children:[co(T.termination)," ",!U&&!se?lo(T.termination,L):null]}),!E&&Ls==="failed"&&!f&&s.jsxs("div",{className:"flex gap-3 rounded-lg border border-negative bg-negative-soft px-4 py-3 text-sm text-negative",role:"alert",children:[s.jsx(Bt,{className:"mt-0.5 size-4 shrink-0","aria-hidden":"true"}),s.jsx("span",{children:"The latest scan failed. The previous completed results remain available."})]}),p?s.jsx(Ze,{view:cn,tabbed:!L,children:s.jsx(Lo,{phase:p,progress:B.data,onRunAgain:se?void 0:ct,pageHealthDestination:L})}):Dt?s.jsx(Ze,{view:cn,tabbed:!L,children:s.jsx(Eo,{status:B.data?.phase??(oe?.status==="running"?"running":"queued"),progress:B.data,progressError:B.isError,onRetryProgress:()=>{B.refetch()},pageHealthDestination:L,firstLook:L,boundedPageLimit:L&&m?Ut:void 0,livePageHealthPreview:Te.data,livePageHealthError:Te.isError,livePageHealthRunId:ee,continuation:Ps?s.jsx(So,{onContinueOnboarding:r,onSkipOnboarding:o}):null})}):be==="technical"?s.jsxs("div",{id:"site-health-technical-panel",role:L?void 0:"tabpanel","aria-labelledby":L?void 0:"site-health-technical-tab",className:"min-w-0 space-y-6",children:[L?s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-heading",children:"Page health"}):null,s.jsx(Ir,{projectName:n,projectId:e,runId:K,integrated:!0,compactCopy:L,afterSummary:L&&jt?s.jsxs("section",{"aria-labelledby":"ai-visibility-next-heading",className:"flex flex-col gap-3 border-b border-default py-5 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"ai-visibility-next-heading",className:"text-base font-semibold text-heading",children:"Next: Set up AI Visibility"}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"See whether answer engines mention your brand and cite your pages."})]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[s.jsx(M,{type:"button",onClick:r,children:"Set up AI Visibility"}),s.jsx(M,{type:"button",variant:"secondary",onClick:o,children:"Skip for now"})]})]}):void 0,unavailableFooter:L&&jt&&!se?s.jsx("section",{"aria-label":"Page health recovery",className:"mt-4",children:s.jsx(M,{type:"button",disabled:Ve,onClick:()=>{c("map"),ct()},children:"Run site audit again"})}):void 0})]}):H.isLoading?s.jsx(Ze,{view:be,tabbed:!L,children:s.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-2 text-sm text-secondary",role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading site health..."]})}):H.error?s.jsx(Ze,{view:be,tabbed:!L,children:s.jsxs("section",{className:"rounded-lg border border-negative bg-negative-soft px-5 py-6",role:"alert",children:[s.jsx("h2",{className:"font-semibold text-negative",children:"Site Health could not load"}),s.jsx("p",{className:"mt-1 text-sm text-negative",children:"Try loading the crawl again."}),s.jsx(M,{variant:"secondary",size:"sm",className:"mt-4",onClick:()=>{H.refetch()},children:"Try again"})]})}):T?.hasCrawlData?T.detailsAvailable?be==="inventory"?s.jsxs("div",{id:"site-health-inventory-panel",role:"tabpanel","aria-labelledby":"site-health-inventory-tab",className:"space-y-5",children:[q.isLoading?s.jsxs("div",{className:"flex min-h-56 items-center justify-center gap-2 text-sm text-secondary",role:"status",children:[s.jsx(je,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading page inventory..."]}):q.error?s.jsx("p",{className:"rounded-lg border border-negative bg-negative-soft px-4 py-3 text-sm text-negative",role:"alert",children:"The page inventory could not be loaded."}):s.jsx(mo,{pages:bt,total:_s,filterUnavailable:q.data?.pages[0]?.healthStateFilter==="unavailable-legacy-scan",selectedNodeKey:qe,onSelect:A,hasNextPage:!!q.hasNextPage,isFetchingNextPage:q.isFetchingNextPage,onLoadMore:()=>{q.fetchNextPage()},filter:N,onFilterChange:_}),s.jsx(Tn,{page:Ie,isLoading:ve.isLoading&&!!Ie,error:ve.error,inbound:ve.data?.inbound??[],outbound:ve.data?.outbound??[],inboundTruncated:ve.data?.inboundTruncated??!1,outboundTruncated:ve.data?.outboundTruncated??!1,audit:Me.data,auditLoading:Me.isLoading&&!!Ie,auditError:Me.error,onRetryAudit:()=>{Me.refetch()},rootHost:ln,reasonSource:dt,reasonsState:an,onRetryReasons:()=>{Re.refetch()},showTemplateLinks:G||_e})]}):s.jsxs("div",{id:"site-health-map-panel",role:"tabpanel","aria-labelledby":"site-health-map-tab",className:"space-y-5",children:[s.jsxs("section",{"aria-labelledby":"site-map-heading",children:[s.jsxs("div",{className:"mb-3 flex flex-col justify-between gap-2 sm:flex-row sm:items-end",children:[s.jsx("div",{children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("h2",{id:"site-map-heading",className:"text-base font-semibold text-heading",children:"Site map"}),s.jsx(fe,{text:ps})]})}),O.data?.sampled&&s.jsxs("span",{className:"text-xs text-muted",children:["Showing ",I(O.data.nodes.length)," of ",I(O.data.totalNodes)," pages"," · ",I(O.data.edges.length)," of ",I(O.data.totalEdges)," links"]})]}),O.data?.layout.state==="ready"&&Ge.length>0&&s.jsxs("div",{className:"mb-3 flex flex-col gap-1.5 rounded-lg border border-default bg-surface-subtle px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("p",{className:"flex items-center gap-1 text-sm text-secondary","data-testid":"site-map-link-counts",children:[xs({filterUnavailable:_e,showTemplateLinks:G,contentEdgeCount:Ss,templateEdgeCount:nn,totalEdgeCount:Ge.length}),s.jsx(fe,{text:ys(xt,{staleLayout:As&&!_e})})]}),s.jsxs("label",{className:He("flex shrink-0 items-center gap-2 text-sm",_e?"cursor-not-allowed text-muted":"cursor-pointer text-heading"),title:_e?fs(xt):"Menu and footer links are drawn on top. Pages do not move, because the map was laid out from the links in your page text.",children:[s.jsx("input",{type:"checkbox",checked:G&&!_e,disabled:_e,onChange:y=>P(y.target.checked),className:"size-4 rounded border-base accent-mono-200 focus:ring-2 focus:ring-mono-400"}),"Show menu and footer links"]})]}),s.jsxs("div",{id:"site-health-map-explorer",className:"grid gap-4 lg:grid-cols-[minmax(14rem,18rem)_minmax(0,1fr)]",children:[s.jsxs("aside",{className:"rounded-lg border border-default bg-surface-subtle","aria-labelledby":"site-sections-heading",children:[s.jsxs("div",{className:"border-b border-default px-4 py-3",children:[s.jsx("h3",{id:"site-sections-heading",className:"text-sm font-semibold text-heading",children:"Site sections"}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Folders in this scan"})]}),s.jsx("div",{className:"max-h-[468px] overflow-auto",children:K&&s.jsx(vs,{projectName:n,runId:K,parentPath:"/",onSelect:Is,rootPage:Gs,onSelectRootPage:A})})]}),s.jsx("div",{className:"min-w-0",children:O.isLoading?s.jsx(bo,{}):O.error?s.jsx("div",{className:"flex min-h-[420px] items-center justify-center rounded-lg border border-negative bg-negative-soft px-6 text-center lg:min-h-[520px]",role:"alert",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-negative",children:"The interactive map could not be loaded."}),s.jsx("p",{className:"mt-1 text-sm text-secondary",children:"The page inventory and technical findings remain available."}),s.jsx(M,{variant:"secondary",size:"sm",className:"mt-4",onClick:()=>c("inventory"),children:"Open page inventory"})]})}):s.jsx(yr,{nodes:O.data?.nodes??[],edges:Ge,showTemplateLinks:G||_e,layoutState:O.data?.layout.state??"unavailable",layoutUnavailableReason:O.data?.layout.state==="unavailable"?O.data.layout.reason:null,rootNodeKey:O.data?.rootNodeKey??null,selectedNodeKey:qe,onSelectNode:y=>A(y.nodeKey),onOpenInventory:()=>c("inventory"),ariaLabel:`Interactive site map showing ${I(O.data?.nodes.length??0)} pages and ${I(Es.length)} internal links`})})]})]}),s.jsx(Tn,{page:Ie,isLoading:ve.isLoading&&!!Ie,error:ve.error,inbound:ve.data?.inbound??[],outbound:ve.data?.outbound??[],inboundTruncated:ve.data?.inboundTruncated??!1,outboundTruncated:ve.data?.outboundTruncated??!1,audit:Me.data,auditLoading:Me.isLoading&&!!Ie,auditError:Me.error,onRetryAudit:()=>{Me.refetch()},rootHost:ln,reasonSource:dt,reasonsState:an,onRetryReasons:()=>{Re.refetch()},showTemplateLinks:G||_e})]}):s.jsx(Ze,{view:be,tabbed:!L,children:s.jsxs("section",{className:"rounded-lg border border-caution bg-caution-soft px-5 py-6",children:[s.jsx("h2",{className:"font-semibold text-caution",children:L?"Page health results unavailable":"Page details unavailable"}),s.jsx("p",{className:"mt-1 text-sm text-caution",children:se&&L?"This scan did not publish page-level results.":L?"This scan did not publish page-level results. Run it again to continue setup.":"Summary metrics are preserved for this scan, but its page graph cannot be opened."}),L&&!se?s.jsx(M,{type:"button",size:"sm",className:"mt-4",onClick:ct,children:"Run scan again"}):null]})}):s.jsx(Ze,{view:be,tabbed:!L,children:s.jsxs("section",{className:"rounded-lg border border-default bg-surface-subtle px-5 py-8 text-center",children:[s.jsx("h2",{className:"text-base font-semibold text-heading",children:L?"Page health results unavailable":"Full-site map not available"}),s.jsx("p",{className:"mx-auto mt-2 max-w-xl text-sm text-secondary",children:se?In:L?"This scan did not produce page health results. Run it again to continue setup.":T?.legacyAuditAvailable?"Existing page health results are preserved. Run a new scan to build the page and internal-link map.":U?"A full-site scan has not been run for this project.":"Run a scan to discover pages, site sections, and internal links."}),(T?.legacyAuditAvailable||L)&&s.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[T?.legacyAuditAvailable&&!L&&s.jsx(M,{variant:"secondary",size:"sm",onClick:()=>c("technical"),children:"View page health"}),L&&!se&&s.jsx(M,{type:"button",size:"sm",onClick:ct,children:"Run scan again"})]})]})})]})}const Mo=Object.freeze(Object.defineProperty({__proto__:null,CRAWL_DEPTH_CHOICES:hs,LivePageHealthFindings:Ns,PAGE_INTERNAL_LINKS_HELP:ms,SITE_HEALTH_VIEW_DESCRIPTIONS:as,SITE_MAP_HELP:ps,SITE_MAP_LINK_SPLIT_COPY:bs,SITE_MAP_STALE_LAYOUT_COPY:gs,SiteHealthSection:To,TEMPLATE_DETECTION_COPY:tn,emptyLinkCopy:ws,linkTileCount:Vt,siteHealthMetricHelp:Ce,siteMapLinkCountsLabel:xs,siteMapLinkRuleHelp:ys},Symbol.toStringTag,{value:"Module"}));export{$r as D,z as G,Ar as M,To as S,Lr as a,Sr as b,is as c,Mo as d,Di as e,_r as u};
|