@canonry/canonry 7.12.0 → 7.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/assets/assets/{AuditHistoryPanel-Bpkuj-iF.js → AuditHistoryPanel-BYxGn9mS.js} +1 -1
  2. package/assets/assets/{BacklinksPage-CbRIZhu5.js → BacklinksPage-BQxB_eFt.js} +1 -1
  3. package/assets/assets/{HistoryPage-Dfq1vK9k.js → HistoryPage-DgGUM2tr.js} +1 -1
  4. package/assets/assets/{MeasurementPropertyPage-DcH0zYNN.js → MeasurementPropertyPage-Cl91vUu5.js} +1 -1
  5. package/assets/assets/{ProjectPage-enF4twWt.js → ProjectPage-B_S900QN.js} +7 -7
  6. package/assets/assets/{RunsPage-aOeJ60pX.js → RunsPage-BtjVuurK.js} +1 -1
  7. package/assets/assets/{SettingsPage-nA0_ImoQ.js → SettingsPage-p0x0ZwGY.js} +1 -1
  8. package/assets/assets/{SiteHealthSection-CUOt7jeo.js → SiteHealthSection-DMHWsfM4.js} +3 -3
  9. package/assets/assets/{TrafficPage-C0fVYizx.js → TrafficPage-Bf0NkbIR.js} +1 -1
  10. package/assets/assets/{TrafficSourceDetailPage-LMhXbFlA.js → TrafficSourceDetailPage-BtwOdTAO.js} +1 -1
  11. package/assets/assets/{extract-error-message-5aHy0fsK.js → extract-error-message-Cyc59Xi7.js} +1 -1
  12. package/assets/assets/index-D4QB1Igv.css +1 -0
  13. package/assets/assets/{index-BJh8cX5E.js → index-DR_kNdE4.js} +2 -2
  14. package/assets/assets/{react-sigma_core.esm.min-ldX35rMq.js → react-sigma_core.esm.min-CFB4bYg_.js} +1 -1
  15. package/assets/assets/{v2-overview-adapter-CaO9vY-l.js → v2-overview-adapter-CLF10Pij.js} +1 -1
  16. package/assets/index.html +2 -2
  17. package/dist/{chunk-DXI2FTSW.js → chunk-GBH7N3VZ.js} +1 -1
  18. package/dist/cli.js +1 -1
  19. package/dist/index.js +1 -1
  20. package/package.json +11 -11
  21. package/assets/assets/index-BNeiohKS.css +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SiteHealthSection-CUOt7jeo.js","./vendor-tanstack-ZXXkndVj.js","./vendor-lucide-N6vOpZmh.js","./ChartPrimitives-CYlrwLJs.js","./vendor-recharts-D-cUuLZo.js","./ProjectPage-enF4twWt.js","./v2-overview-adapter-CaO9vY-l.js","./vendor-markdown-B4giJcws.js","./extract-error-message-5aHy0fsK.js","./AuditHistoryPanel-Bpkuj-iF.js","./vendor-radix-twS1M3FF.js","./vendor-yaml-GWJz5H2G.js","./RunsPage-aOeJ60pX.js","./HistoryPage-Dfq1vK9k.js","./SettingsPage-nA0_ImoQ.js","./BacklinksPage-CbRIZhu5.js","./TrafficPage-C0fVYizx.js","./TrafficSourceDetailPage-LMhXbFlA.js","./MeasurementPropertyPage-DcH0zYNN.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SiteHealthSection-DMHWsfM4.js","./vendor-tanstack-ZXXkndVj.js","./vendor-lucide-N6vOpZmh.js","./ChartPrimitives-CYlrwLJs.js","./vendor-recharts-D-cUuLZo.js","./ProjectPage-B_S900QN.js","./v2-overview-adapter-CLF10Pij.js","./vendor-markdown-B4giJcws.js","./extract-error-message-Cyc59Xi7.js","./AuditHistoryPanel-BYxGn9mS.js","./vendor-radix-twS1M3FF.js","./vendor-yaml-GWJz5H2G.js","./RunsPage-BtjVuurK.js","./HistoryPage-DgGUM2tr.js","./SettingsPage-p0x0ZwGY.js","./BacklinksPage-BQxB_eFt.js","./TrafficPage-Bf0NkbIR.js","./TrafficSourceDetailPage-BtwOdTAO.js","./MeasurementPropertyPage-Cl91vUu5.js"])))=>i.map(i=>d[i]);
2
2
  import{c as C5,d as _5,r as C,j as l,Q as T5,M as E5,q as xe,e as Ic,L as tt,a as R5,t as kr,u as yt,f as D5,h as _o,k as Es,l as oS,m as z5,n as rS,O as Gf,o as ii,p as I5,s as Bt,v as q0,x as Rs,y as O5,z as P5,A as q5}from"./vendor-tanstack-ZXXkndVj.js";import{S as M5,O as M0,P as lS,C as B0,a as cS,T as L0,D as uS,R as dS}from"./vendor-radix-twS1M3FF.js";import{c as mS}from"./vendor-recharts-D-cUuLZo.js";import{A as Ac,X as Ur,S as U0,a as pS,G as hS,C as Oc,L as Cs,R as ud,M as B5,b as L5,P as Hf,H as fS,c as gS,d as U5,e as Pc,f as V0,T as pm,g as qc,W as yS,h as V5,i as $5,j as K5,k as G5,l as H5,m as Q5,n as F5,B as Z5,F as Y5,o as X5,p as J5,q as W5,r as e6,s as bS,t as vS,u as Qf,v as xS,w as t6,x as wS,E as n6}from"./vendor-lucide-N6vOpZmh.js";import{M as a6,r as i6}from"./vendor-markdown-B4giJcws.js";import{p as s6}from"./vendor-yaml-GWJz5H2G.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))r(u);new MutationObserver(u=>{for(const h of u)if(h.type==="childList")for(const f of h.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&r(f)}).observe(document,{childList:!0,subtree:!0});function i(u){const h={};return u.integrity&&(h.integrity=u.integrity),u.referrerPolicy&&(h.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?h.credentials="include":u.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function r(u){if(u.ep)return;u.ep=!0;const h=i(u);fetch(u.href,h)}})();var nf={exports:{}},sc={},af={exports:{}},sf={};var ux;function o6(){return ux||(ux=1,(function(e){function n(B,ee){var be=B.length;B.push(ee);e:for(;0<be;){var je=be-1>>>1,te=B[je];if(0<u(te,ee))B[je]=ee,B[be]=te,be=je;else break e}}function i(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var ee=B[0],be=B.pop();if(be!==ee){B[0]=be;e:for(var je=0,te=B.length,_e=te>>>1;je<_e;){var qe=2*(je+1)-1,ve=B[qe],de=qe+1,ce=B[de];if(0>u(ve,be))de<te&&0>u(ce,ve)?(B[je]=ce,B[de]=be,je=de):(B[je]=ve,B[qe]=be,je=qe);else if(de<te&&0>u(ce,be))B[je]=ce,B[de]=be,je=de;else break e}}return ee}function u(B,ee){var be=B.sortIndex-ee.sortIndex;return be!==0?be:B.id-ee.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var h=performance;e.unstable_now=function(){return h.now()}}else{var f=Date,b=f.now();e.unstable_now=function(){return f.now()-b}}var v=[],x=[],k=1,S=null,N=3,_=!1,z=!1,q=!1,E=!1,P=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function $(B){for(var ee=i(x);ee!==null;){if(ee.callback===null)r(x);else if(ee.startTime<=B)r(x),ee.sortIndex=ee.expirationTime,n(v,ee);else break;ee=i(x)}}function H(B){if(q=!1,$(B),!z)if(i(v)!==null)z=!0,J||(J=!0,$e());else{var ee=i(x);ee!==null&&Ue(H,ee.startTime-B)}}var J=!1,V=-1,F=5,ie=-1;function Ge(){return E?!0:!(e.unstable_now()-ie<F)}function We(){if(E=!1,J){var B=e.unstable_now();ie=B;var ee=!0;try{e:{z=!1,q&&(q=!1,M(V),V=-1),_=!0;var be=N;try{t:{for($(B),S=i(v);S!==null&&!(S.expirationTime>B&&Ge());){var je=S.callback;if(typeof je=="function"){S.callback=null,N=S.priorityLevel;var te=je(S.expirationTime<=B);if(B=e.unstable_now(),typeof te=="function"){S.callback=te,$(B),ee=!0;break t}S===i(v)&&r(v),$(B)}else r(v);S=i(v)}if(S!==null)ee=!0;else{var _e=i(x);_e!==null&&Ue(H,_e.startTime-B),ee=!1}}break e}finally{S=null,N=be,_=!1}ee=void 0}}finally{ee?$e():J=!1}}}var $e;if(typeof L=="function")$e=function(){L(We)};else if(typeof MessageChannel<"u"){var Pe=new MessageChannel,ke=Pe.port2;Pe.port1.onmessage=We,$e=function(){ke.postMessage(null)}}else $e=function(){P(We,0)};function Ue(B,ee){V=P(function(){B(e.unstable_now())},ee)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return N},e.unstable_next=function(B){switch(N){case 1:case 2:case 3:var ee=3;break;default:ee=N}var be=N;N=ee;try{return B()}finally{N=be}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(B,ee){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var be=N;N=B;try{return ee()}finally{N=be}},e.unstable_scheduleCallback=function(B,ee,be){var je=e.unstable_now();switch(typeof be=="object"&&be!==null?(be=be.delay,be=typeof be=="number"&&0<be?je+be:je):be=je,B){case 1:var te=-1;break;case 2:te=250;break;case 5:te=1073741823;break;case 4:te=1e4;break;default:te=5e3}return te=be+te,B={id:k++,callback:ee,priorityLevel:B,startTime:be,expirationTime:te,sortIndex:-1},be>je?(B.sortIndex=be,n(x,B),i(v)===null&&B===i(x)&&(q?(M(V),V=-1):q=!0,Ue(H,be-je))):(B.sortIndex=te,n(v,B),z||_||(z=!0,J||(J=!0,$e()))),B},e.unstable_shouldYield=Ge,e.unstable_wrapCallback=function(B){var ee=N;return function(){var be=N;N=ee;try{return B.apply(this,arguments)}finally{N=be}}}})(sf)),sf}var dx;function r6(){return dx||(dx=1,af.exports=o6()),af.exports}var mx;function l6(){if(mx)return sc;mx=1;var e=r6(),n=C5(),i=_5();function r(t){var a="https://react.dev/errors/"+t;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)a+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+t+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function h(t){var a=t,s=t;if(t.alternate)for(;a.return;)a=a.return;else{t=a;do a=t,(a.flags&4098)!==0&&(s=a.return),t=a.return;while(t)}return a.tag===3?s:null}function f(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function b(t){if(t.tag===31){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function v(t){if(h(t)!==t)throw Error(r(188))}function x(t){var a=t.alternate;if(!a){if(a=h(t),a===null)throw Error(r(188));return a!==t?null:t}for(var s=t,c=a;;){var p=s.return;if(p===null)break;var g=p.alternate;if(g===null){if(c=p.return,c!==null){s=c;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===s)return v(p),t;if(g===c)return v(p),a;g=g.sibling}throw Error(r(188))}if(s.return!==c.return)s=p,c=g;else{for(var w=!1,A=p.child;A;){if(A===s){w=!0,s=p,c=g;break}if(A===c){w=!0,c=p,s=g;break}A=A.sibling}if(!w){for(A=g.child;A;){if(A===s){w=!0,s=g,c=p;break}if(A===c){w=!0,c=g,s=p;break}A=A.sibling}if(!w)throw Error(r(189))}}if(s.alternate!==c)throw Error(r(190))}if(s.tag!==3)throw Error(r(188));return s.stateNode.current===s?t:a}function k(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t;for(t=t.child;t!==null;){if(a=k(t),a!==null)return a;t=t.sibling}return null}var S=Object.assign,N=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),z=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),L=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),Ge=Symbol.for("react.memo_cache_sentinel"),We=Symbol.iterator;function $e(t){return t===null||typeof t!="object"?null:(t=We&&t[We]||t["@@iterator"],typeof t=="function"?t:null)}var Pe=Symbol.for("react.client.reference");function ke(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Pe?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case q:return"Fragment";case P:return"Profiler";case E:return"StrictMode";case H:return"Suspense";case J:return"SuspenseList";case ie:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case z:return"Portal";case L:return t.displayName||"Context";case M:return(t._context.displayName||"Context")+".Consumer";case $:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case V:return a=t.displayName||null,a!==null?a:ke(t.type)||"Memo";case F:a=t._payload,t=t._init;try{return ke(t(a))}catch{}}return null}var Ue=Array.isArray,B=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,be={pending:!1,data:null,method:null,action:null},je=[],te=-1;function _e(t){return{current:t}}function qe(t){0>te||(t.current=je[te],je[te]=null,te--)}function ve(t,a){te++,je[te]=t.current,t.current=a}var de=_e(null),ce=_e(null),Y=_e(null),pe=_e(null);function Oe(t,a){switch(ve(Y,a),ve(ce,t),ve(de,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?zv(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=zv(a),t=Iv(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}qe(de),ve(de,t)}function Ae(){qe(de),qe(ce),qe(Y)}function st(t){t.memoizedState!==null&&ve(pe,t);var a=de.current,s=Iv(a,t.type);a!==s&&(ve(ce,t),ve(de,s))}function Ve(t){ce.current===t&&(qe(de),qe(ce)),pe.current===t&&(qe(pe),tc._currentValue=be)}var Nt,He;function me(t){if(Nt===void 0)try{throw Error()}catch(s){var a=s.stack.trim().match(/\n( *(at )?)/);Nt=a&&a[1]||"",He=-1<s.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+Nt+t+He}var at=!1;function It(t,a){if(!t||at)return"";at=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(a){var oe=function(){throw Error()};if(Object.defineProperty(oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(oe,[])}catch(X){var Z=X}Reflect.construct(t,[],oe)}else{try{oe.call()}catch(X){Z=X}t.call(oe.prototype)}}else{try{throw Error()}catch(X){Z=X}(oe=t())&&typeof oe.catch=="function"&&oe.catch(function(){})}}catch(X){if(X&&Z&&typeof X.stack=="string")return[X.stack,Z.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),w=g[0],A=g[1];if(w&&A){var D=w.split(`
@@ -83,4 +83,4 @@ spec:
83
83
  `);En(Fe),Us(!0)}}catch(Q){il(Q instanceof Error?Q.message:"Failed to generate queries"),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.blocked",step:"queries",action:"generate_queries",reasonCode:wc(Q,"unknown")},"onboarding.blocked:queries:generate")}finally{nl(!1)}}},hl=async()=>{if(!He)return;const Q=fi;if(Q.length!==0){Qa(!0),ll(null);try{await qG(He,Q),Yi(!0),await r(),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"competitors",method:"manual",countBucket:ai(Q.length)},"onboarding.step_completed:competitors"),ee(4)}catch(Fe){ll(Fe instanceof Error?Fe.message:"Failed to save competitors"),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.blocked",step:"competitors",action:"save",reasonCode:"unknown"},"onboarding.blocked:competitors:save")}finally{Qa(!1)}}},fl=async()=>{const Q=Ji.trim();if(Q){Vo(!0),$o(null);try{await SN("gemini",{apiKey:Q}),xn({title:"Gemini configured",detail:"Provider is ready — continuing setup.",tone:"positive",dedupeKey:"setup:gemini:configured",dedupeMode:"drop"}),su(""),await r(),mi(v.providerStatuses.find(Fe=>Fe.name.toLowerCase()==="gemini")?.name??"gemini"),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"system",method:"inline"},"onboarding.step_completed:system")}catch(Fe){$o(Fe instanceof Error?Fe.message:"Failed to save Gemini key"),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.blocked",step:"system",action:"configure_provider",reasonCode:"provider_save_failed"},"onboarding.blocked:system:provider_save_failed")}finally{Vo(!1)}}},gi=async()=>{if(!fo()){if(!He||Ya){zn(Ya??"Complete setup before launching the first sweep.");const Q=ya??(He?ga===0?"no_queries":"run_rejected":"unknown");za||M({flowVersion:ft,onboardingSessionId:E,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:ai(xt),queryCountBucket:ai(ga),reasonCode:Q});return}Gs(!0),zn(null);try{const Q=await ml.mutateAsync({projectName:He,projectLabel:ve||_e||He,sourceAction:"setup-launch"});tp(Q.id),ep(!0),uN(He,Q.id),dl.current=Q.id,za||M({flowVersion:ft,onboardingSessionId:E,event:"run.requested",origin:"dashboard_setup",result:"queued",providerCountBucket:ai(xt),queryCountBucket:ai(ga)}),await r()}catch(Q){zn(Q instanceof Error?Q.message:"Failed to queue the visibility sweep. Retry when the instance is ready."),za||M({flowVersion:ft,onboardingSessionId:E,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:ai(xt),queryCountBucket:ai(ga),reasonCode:wc(Q,"run_rejected")})}finally{Gs(!1)}}},qn=()=>ee(Q=>_?2:Math.max(0,Q-1)),Ho=(Q,Fe,yi)=>{M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:Q,method:"existing",...yi===void 0?{}:{countBucket:ai(yi)}},`onboarding.step_completed:${Q}`),ee(Fe)},gl=()=>{if(M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"queries",method:"skipped",countBucket:"0"},"onboarding.step_completed:queries"),_){Qt();return}ee(3)},yl=()=>{M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"competitors",method:"skipped",countBucket:"0"},"onboarding.step_completed:competitors"),ee(4)},Hs=_?"section":Ca,ba=Je!==!0||Ot===!0?l.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",onClick:()=>{r(),Vs&&Ye.refetch()},children:"Check again"}):null,bl=(Je===!1||fa)&&!!Wn,Qs=_&&(B===2||B===4)?x?l.jsxs("section",{"aria-labelledby":"setup-provider-heading",className:"space-y-3 border-b border-default pb-6 mb-6",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx("h2",{id:"setup-provider-heading",className:"text-lg font-semibold text-heading",children:Je===!1?"Connect a provider":"Answer engine provider"}),l.jsx(vn,{tone:Je===!0?"positive":"neutral",children:Je===!0?"Configured":Je===!1?"Not connected":"Checking"})]}),l.jsx("p",{className:"max-w-prose text-sm text-secondary",children:Je===!0?Tt.length>0?`${Tt.map(Q=>Q.displayName??Q.name).join(", ")} available for this project. Research and sweeps use your provider account.`:"ChatGPT in Chrome is configured for sweeps. Query Research needs an API provider.":Je===!1?"An answer engine is required for visibility sweeps. You can save queries now and connect later.":"Checking available providers. You can choose queries while this finishes."}),Je===!1||fa?Wn?l.jsx("div",{children:l.jsx(PJ,{compact:!0,leadingField:l.jsxs("div",{className:"min-w-0 space-y-1.5",children:[l.jsx("label",{className:"block text-sm font-medium text-secondary",htmlFor:"setup-provider",children:"Provider to connect"}),l.jsx("select",{ref:au,id:"setup-provider",className:"setup-input",value:Wn.name,onChange:Q=>{Q.target.value!==Wn.name&&(Bo.current=document.activeElement===Q.currentTarget,ol(Q.target.value))},children:Uo.map(Q=>l.jsx("option",{value:Q.name,children:Q.displayName??Q.name},Q.name))})]}),secondaryActions:ba,providerName:Wn.name,keyUrl:Wn.keyUrl,modelHint:Wn.modelHint,onSaved:()=>{on(!1),r()}},Wn.name)}):l.jsx("p",{className:"max-w-prose text-sm text-secondary",children:yn.length>0?`This project's provider selection is ${yn.join(", ")}. Configure an allowed provider in Settings, or change the selection in project Settings.`:"Provider configuration is unavailable here. Open Settings to connect an answer engine, then check again."}):null,l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Je===!0&&!fa&&Wn?l.jsx(le,{type:"button",variant:"outline",size:"sm",onClick:()=>on(!0),children:"Configure a provider"}):null,!Wn||Ot===!0?l.jsx(le,{type:"button",variant:"outline",size:"sm",asChild:!0,children:l.jsx(tt,{to:"/settings",target:"_blank",rel:"noopener noreferrer",children:"Open provider settings"})}):null,bl?null:ba]})]}):l.jsxs("section",{"aria-labelledby":"setup-provider-heading",className:"space-y-2 border-b border-default pb-6 mb-6",children:[l.jsx("h2",{id:"setup-provider-heading",className:"text-lg font-semibold text-heading",children:"Answer engine provider"}),l.jsx("p",{className:"max-w-prose text-sm text-secondary",children:"Provider settings are managed by an administrator."}),Ee?l.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Provider readiness could not be checked. Try again."}):l.jsx("p",{className:"max-w-prose text-sm text-secondary",role:"status",children:Je===!0?"An answer engine is available for this project.":Je===!1?"Ask an administrator to connect an answer engine for this project. You can save queries now.":"Checking provider readiness. You can save queries now."}),l.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",disabled:Jn.isFetching,onClick:()=>{Jn.refetch()},children:Ee?"Retry provider check":"Check again"})]}):null,Xa=(()=>{switch(B){case 0:return l.jsxs(Ca,{className:"surface-card step-card",children:[l.jsx("div",{className:"section-head",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 1 of 5"}),l.jsx("h2",{children:"System check"})]})}),l.jsx("p",{className:"supporting-copy",children:"Checking that your Canonry instance is configured and reachable."}),l.jsx("div",{className:"compact-stack",children:N.healthChecks.map(Q=>l.jsxs("div",{className:"health-check-row",children:[l.jsxs("div",{children:[l.jsx("p",{className:"run-row-title",children:Q.label}),l.jsx("p",{className:"supporting-copy",children:Q.detail}),Q.id==="provider"&&Q.state!=="ready"&&l.jsxs("div",{className:"mt-3 rounded-md border border-default bg-bg-elevated/40 p-3 space-y-2",children:[l.jsxs("p",{className:"text-xs text-secondary",children:["Paste a Gemini key to enable visibility checks (free at"," ",l.jsx("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noreferrer",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"aistudio.google.com"}),")."]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"password",value:Ji,onChange:Fe=>su(Fe.target.value),placeholder:"AI... (paste here)",className:"flex-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-sm text-heading placeholder:text-faint focus:border-mono-600 focus:outline-none font-mono",disabled:In}),l.jsx(le,{type:"button",size:"sm",disabled:In||!Ji.trim(),onClick:fn(fl),children:In?"Saving...":"Save"})]}),pl&&l.jsxs("div",{role:"alert",className:"space-y-1 text-xs text-negative",children:[l.jsx("p",{children:pl}),l.jsx("p",{children:"Check that the key is complete, then retry Save."})]}),l.jsxs("p",{className:"text-sm text-secondary",children:["Connect more answer engines later in"," ",l.jsx(tt,{to:"/settings",className:"text-link hover:underline",children:"Settings"}),"."]})]})]}),l.jsx(vn,{tone:Q.state==="ready"?"positive":"caution",title:Q.id==="api"?Lr(S.apiStatus):Q.id==="worker"?Lr(S.workerStatus):Q.detail,children:Q.state==="ready"?"Ready":"Attention"})]},Q.id))}),l.jsxs("div",{className:"setup-nav",children:[N.launchState.blockedReason?l.jsx("p",{role:"status",className:"supporting-copy text-negative",children:N.launchState.blockedReason}):l.jsx("span",{}),l.jsx(le,{type:"button",disabled:!N.launchState.enabled,title:N.launchState.blockedReason,onClick:()=>{M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"system",method:"automatic"},"onboarding.step_completed:system"),ee(Ue)},children:"Continue"})]})]});case 1:return l.jsxs(Ca,{className:"surface-card step-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 2 of 5"}),l.jsx("h2",{children:"Create project"})]}),He?l.jsx(vn,{tone:"positive",children:"Created"}):null]}),He?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-neutral",children:["Project ",l.jsx("span",{className:"text-heading font-medium",children:He})," created successfully."]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:qn,children:"Back"}),l.jsx(le,{type:"button",onClick:()=>Ho("project",2),children:"Continue"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"project-name",children:"Project name"}),l.jsx("input",{id:"project-name",className:"setup-input",type:"text",placeholder:"my-website",value:_e,onChange:Q=>qe(Q.target.value)}),Kn&&Kn!==_e?l.jsxs("p",{className:"supporting-copy",children:["Slug: ",Kn]}):null]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"display-name",children:"Display name (optional)"}),l.jsx("input",{id:"display-name",className:"setup-input",type:"text",placeholder:"My Website",value:ve,onChange:Q=>de(Q.target.value)})]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"domain",children:"Canonical domain"}),l.jsx("input",{id:"domain",className:"setup-input",type:"text",placeholder:"example.com",value:ce,onChange:Q=>Y(Q.target.value)})]}),l.jsxs("div",{className:"setup-field-row",children:[l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"country",children:"Country"}),l.jsx("input",{id:"country",className:"setup-input",type:"text",placeholder:"US",maxLength:2,value:pe,onChange:Q=>Oe(Q.target.value.toUpperCase())})]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"language",children:"Language"}),l.jsx("input",{id:"language",className:"setup-input",type:"text",placeholder:"en",maxLength:5,value:Ae,onChange:Q=>st(Q.target.value.toLowerCase())})]})]}),l.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-default bg-surface p-3 cursor-pointer hover:border-strong",children:[l.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-strong bg-bg",checked:Ve,onChange:Q=>Nt(Q.target.checked)}),l.jsxs("span",{className:"flex-1",children:[l.jsx("span",{className:"block text-sm text-heading",children:"Auto-extract backlinks"}),l.jsxs("span",{className:"block text-xs text-muted mt-0.5",children:["When a new Common Crawl release syncs, automatically extract backlinks for this project."," ",l.jsx(tt,{to:"/backlinks",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"Manage backlinks"})]})]})]}),at?l.jsx("p",{className:"text-negative-400 text-sm",children:at}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:qn,children:"Back"}),l.jsx(le,{type:"button",disabled:!Kn||!ce||Pn,onClick:fn(ap),children:Pn?"Creating...":"Create project"})]})]})]});case 2:return l.jsxs(Hs,{className:_?"visibility-setup-section step-card":"surface-card step-card","aria-labelledby":"setup-queries-heading",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:_?"Step 1 of 2":"Step 3 of 5"}),l.jsx("h2",{id:"setup-queries-heading",children:"Add queries"})]}),te?l.jsx(vn,{tone:"neutral",children:"Loading"}):V.isError?l.jsx(vn,{tone:"negative",children:"Load failed"}):Vt?l.jsxs(vn,{tone:"positive",children:[ea.length," saved"]}):l.jsxs(vn,{tone:"neutral",children:[ea.length," quer",ea.length!==1?"ies":"y"]})]}),l.jsx("p",{className:"supporting-copy",children:"Add the queries your customers use, one per line. You can refine your list later."}),l.jsxs("div",{className:"space-y-2 border-b border-default pb-4",children:[l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[l.jsxs("div",{className:"min-w-0 space-y-1",children:[l.jsx("h3",{className:"text-sm font-semibold text-heading",children:"Research queries with your agent"}),l.jsx("p",{className:"max-w-prose text-sm text-secondary",children:"Ask your agent to compare answers and available sources with Canonry Research, then recommend queries. Research does not change your tracked queries."})]}),l.jsx(le,{type:"button",variant:"outline",size:"sm",className:"min-h-11 shrink-0 self-start",onClick:fn(rl),children:Dn?"Research prompt copied":"Copy research prompt"})]}),l.jsxs("details",{open:Lo||void 0,className:"text-sm text-secondary",children:[l.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-link",children:"View agent prompt"}),l.jsx("textarea",{"aria-label":"Agent query research prompt",readOnly:!0,className:"setup-textarea mt-2 w-full",rows:8,value:Qi})]}),Lo?l.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Could not copy. Select and copy the prompt above."}):null]}),te?l.jsx("div",{className:"rounded-md border border-default bg-bg-elevated/40 p-4 text-sm text-secondary",role:"status",children:"Loading saved queries…"}):V.isError?l.jsxs("div",{className:"compact-stack",children:[l.jsx("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:"Saved queries could not be loaded. Retry before changing the query basket."}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:_?Me:qn,children:"Back"}),l.jsx(le,{type:"button",onClick:()=>{V.refetch()},children:"Retry loading queries"})]})]}):Vt?l.jsxs("div",{className:"compact-stack",children:[l.jsx("ul",{className:"detail-list",children:ea.map(Q=>l.jsx("li",{children:Q},Q))}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:_?Me:qn,children:"Back"}),l.jsx(le,{type:"button",variant:"outline",onClick:()=>ci(!1),children:"Edit queries"}),l.jsx(le,{type:"button",onClick:()=>Ho("queries",_?4:3,ea.length),children:"Continue"})]})]}):l.jsxs("div",{className:"compact-stack",children:[Tt.length>0?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[l.jsx("span",{className:"flex-1 border-t border-base"}),"auto-generate",l.jsx("span",{className:"flex-1 border-t border-base"})]}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"setup-field flex-1",children:[l.jsx("label",{className:"setup-label",htmlFor:"gen-provider",children:"Provider"}),l.jsx("select",{id:"gen-provider",className:"setup-input",value:sn,onChange:Q=>mi(Q.target.value),children:Tt.map(Q=>l.jsxs("option",{value:Q.name,children:[Q.displayName??Q.name,Q.model?` (${Q.model})`:""]},Q.name))})]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"gen-count",children:"Count"}),l.jsx("select",{id:"gen-count",className:"setup-input",value:Mo,onChange:Q=>$s(Number(Q.target.value)),children:[3,5,10,15,20].map(Q=>l.jsx("option",{value:Q,children:Q},Q))})]}),l.jsx(le,{type:"button",variant:"outline",disabled:nu||!sn,onClick:fn(Oa),children:nu?"Analyzing site...":"Generate"})]}),al?l.jsx("p",{className:"text-negative-400 text-sm",children:al}):null]}):null,_?null:l.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[l.jsx("span",{className:"flex-1 border-t border-base"}),"or type manually",l.jsx("span",{className:"flex-1 border-t border-base"})]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"queries",children:"Queries (one per line)"}),l.jsx("textarea",{id:"queries",className:"setup-textarea",rows:6,placeholder:`emergency dentist brooklyn
84
84
  best invisalign downtown brooklyn
85
85
  pediatric dentist brooklyn heights`,value:Ft,onChange:Q=>En(Q.target.value)})]}),Bs?l.jsx("p",{className:"text-negative-400 text-sm",children:Bs}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:_?Me:qn,children:"Back"}),l.jsx(le,{type:"button",variant:"ghost",onClick:gl,children:_?"Finish without AI Visibility":"Skip for now"}),l.jsx(le,{type:"button",disabled:ea.length===0||Rn,onClick:fn(Go),children:Rn?"Saving...":`Save ${ea.length} quer${ea.length!==1?"ies":"y"}`})]})]})]});case 3:return l.jsxs(Ca,{className:"surface-card step-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 4 of 5"}),l.jsx("h2",{children:"Add competitors"})]}),Zi?l.jsx(vn,{tone:"positive",children:"Saved"}):null]}),l.jsx("p",{className:"supporting-copy",children:"Optional. Domains that compete for the same queries, one per line. You can add them later from the project."}),Zi?l.jsxs("div",{className:"compact-stack",children:[l.jsx("ul",{className:"detail-list",children:fi.map(Q=>l.jsx("li",{children:Q},Q))}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:qn,children:"Back"}),l.jsx(le,{type:"button",onClick:()=>Ho("competitors",4,fi.length),children:"Continue"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"competitors",children:"Competitor domains (one per line)"}),l.jsx("textarea",{id:"competitors",className:"setup-textarea",rows:4,placeholder:`competitor1.com
86
- competitor2.com`,value:pi,onChange:Q=>Fi(Q.target.value)})]}),en?l.jsx("p",{className:"text-negative-400 text-sm",children:en}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:qn,children:"Back"}),l.jsx("div",{className:"flex gap-2",children:fi.length===0?l.jsx(le,{type:"button",onClick:yl,children:"Continue without competitors"}):l.jsxs(l.Fragment,{children:[l.jsx(le,{type:"button",variant:"outline",onClick:yl,children:"Skip"}),l.jsx(le,{type:"button",disabled:cl,onClick:fn(hl),children:cl?"Saving...":`Save ${fi.length} competitor${fi.length!==1?"s":""}`})]})})]})]})]});case 4:{const Q=Za.data,Fe=Q?.status??(Xi===We?.id?We.status:void 0),yi=Fe==="completed"||Fe==="partial"||Fe==="failed"||Fe==="cancelled",Wi=Q?.snapshots??[],Pa=Q?.queryCounts,vl=Fe?Jk(Fe,Wi.length):!1,jn=$e&&!Fa,bi=Sn??(Q?.error?TH(Q.error):Fe==="cancelled"?"The sweep was cancelled before it produced a baseline.":(Fe==="completed"||Fe==="partial")&&Wi.length===0?"The sweep finished without producing any snapshots.":We?.statusDetail||"The sweep did not produce a baseline.");let Ja=null;return jn||vl?Ja=l.jsx(vn,{tone:"positive",children:"Complete"}):Sn&&!Fa?Ja=l.jsx(vn,{tone:"negative",children:"Failed"}):yi?Ja=l.jsx(vn,{tone:"negative",children:Fe==="cancelled"?"Cancelled":"Failed"}):Fa&&(Ja=l.jsx(vn,{tone:"caution",children:"Running"})),l.jsxs(Ca,{className:"surface-card step-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:_?"Step 2 of 2":"Step 5 of 5"}),l.jsx("h2",{children:fo()?"AI Visibility":"Launch first run"})]}),Ja]}),jn?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-secondary",children:["Setup is complete. ",l.jsx("span",{className:"text-strong font-medium",children:He})," already has a successful answer-visibility baseline."]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:()=>ct(),children:f?"Finish setup":"Open project dashboard →"})]})]}):!Fa&&fo()?l.jsxs("div",{className:"compact-stack",children:[He?l.jsx(HY,{projectName:He}):l.jsx("p",{className:"text-sm text-secondary",children:T0}),Sn&&l.jsx("p",{role:"alert",className:"text-sm text-negative",children:Sn}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:Me,children:"Open project dashboard →"})]})]}):Fa?yi?vl?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",l.jsx("span",{className:"text-heading font-medium",children:He}),":"]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Mentioned"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Pa?l.jsxs(l.Fragment,{children:[Pa.mentionedQueries,l.jsxs("span",{className:"text-faint text-lg",children:[" / ",Pa.totalQueries]})]}):"Unavailable"}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries naming your brand"})]}),l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Cited"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Pa?l.jsxs(l.Fragment,{children:[Pa.citedQueries,l.jsxs("span",{className:"text-faint text-lg",children:[" / ",Pa.totalQueries]})]}):"Unavailable"}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries citing your site"})]}),l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Results"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Wi.length}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),!b&&He?l.jsx(OJ,{projectName:He}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:()=>ct(),children:f?"Finish setup":"Open project dashboard →"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:bi}),l.jsx("p",{className:"mt-1 text-xs text-secondary",children:fo()?T0:x?"Fix provider or query configuration if needed, then retry without leaving setup.":"Ask an administrator to review the provider and query configuration."})]}),l.jsxs("div",{className:"setup-nav",children:[x&&!fo()?l.jsx(le,{type:"button",variant:"outline",asChild:!0,children:l.jsx(tt,{to:"/settings",children:"Configure providers"})}):l.jsx("span",{}),fo()||!x?l.jsx(le,{type:"button",onClick:Me,children:"Open project dashboard →"}):l.jsx(le,{type:"button",disabled:hi||!!Ya,onClick:fn(gi),children:hi?"Retrying...":"Retry visibility sweep"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsx("p",{className:"text-neutral",children:"Sweep running. This usually takes 30 to 60 seconds."}),l.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:l.jsxs("p",{children:["Status: ",l.jsx("span",{className:"text-neutral",children:Fe??"queued"})]})}),Za.isError&&l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:Za.error instanceof Error?Za.error.message:"Could not refresh the sweep status."}),l.jsx(le,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{Za.refetch()},children:"Retry status check"})]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",variant:"outline",onClick:f?()=>ct():Me,children:f?"Finish setup":"Watch on project page"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"supporting-copy",children:["Your queries are saved. Run a first sweep to get a baseline for"," ",l.jsx("span",{className:"text-heading font-medium",children:He}),", or finish and run it later from the project. A sweep calls the answer engines, so it costs provider usage."]}),(Ya||Sn)&&l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:Sn??Ya}),l.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Resolve the blocker above, then retry the sweep here."})]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:qn,children:"Back"}),l.jsx(le,{type:"button",variant:"ghost",onClick:Qt,children:"Finish without running"}),ya==="no_provider"&&!_?l.jsx(le,{type:"button",asChild:!0,children:l.jsx(tt,{to:"/settings",children:"Configure a provider"})}):l.jsx(le,{type:"button",disabled:hi||!!Ya,title:Ya,onClick:fn(gi),children:hi?"Launching...":Sn?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return l.jsxs("div",{className:_?"page-container visibility-setup":"page-container",children:[f?l.jsx(Co,{current:"visibility"}):null,l.jsxs("div",{className:"page-header",children:[l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{ref:u?h:void 0,tabIndex:u?-1:void 0,className:"page-title",children:u?"Set up AI Visibility":"Setup"}),l.jsx("p",{className:"page-subtitle",children:u?"Connect an answer engine, then choose queries for your first sweep.":"Create a project and run its first visibility check."})]}),f?l.jsx("div",{className:"page-header-right",children:l.jsx(le,{type:"button",variant:"outline",className:"min-h-11",onClick:Qt,children:"Skip AI Visibility"})}):null]}),f?null:l.jsx(UJ,{current:_?B===4?1:0:B,labels:_?BJ:MJ}),l.jsxs("section",{className:"setup-wizard",children:[Qs,Xa]})]})}const Kf="canonry mcp install --client claude-code",KJ="https://github.com/Canonry/canonry/blob/main/docs/mcp.md";function GJ(){const e=C.useRef(p1()).current,n=C.useRef(new Set),i=C.useCallback((r,u)=>{n.current.has(r)||(n.current.add(r),b1({...u,flowVersion:ft,onboardingSessionId:e,surface:"platform",eventId:h1()}))},[e]);return C.useEffect(()=>{i("started",{event:"onboarding.started",step:"finish",resumed:!1})},[i]),C.useCallback(r=>{i(`action:${r}`,{event:"onboarding.step_completed",step:"finish",method:"manual",nextAction:r})},[i])}const Jm=C.createContext(()=>{});function HJ({projectName:e,skippedVisibility:n=!1}){const i=yt({...mF({client:W,path:{name:e}}),retry:!1}),r=i.data?.hasData?i.data:null,u=GJ(),h=tS(e,De["site-audit"]),f=tS(e,De["answer-visibility"]),b={...h?{site:h,fixes:h}:{},...QJ(f,n)};return l.jsx(Jm.Provider,{value:u,children:l.jsxs("div",{className:"page-container max-w-6xl py-8 md:py-10",children:[l.jsx(Co,{current:"done",outcomes:b}),l.jsxs("header",{className:"relative mx-auto mt-12 max-w-2xl text-center md:mt-16",children:[l.jsx(FJ,{}),l.jsx("p",{className:"onb-reveal mt-6 text-sm font-medium text-positive",style:_a(250),children:"Setup complete"}),l.jsx("h1",{className:"onb-reveal mt-2 text-5xl font-semibold tracking-tight text-heading md:text-6xl",style:_a(350),children:"You’re set."}),l.jsxs("p",{className:"onb-reveal mx-auto mt-4 max-w-xl text-lg text-secondary",style:_a(450),children:["Canonry is tracking ",l.jsx("span",{className:"font-medium text-heading",children:e}),". Here’s how to get the most out of it from here."]})]}),l.jsxs("div",{className:"mt-14 grid gap-4 md:grid-cols-6",children:[l.jsx(Cd,{className:"md:col-span-4 md:row-span-2",delayMs:600,labelledBy:"onb-agent-heading",children:l.jsx(XJ,{projectName:e})}),l.jsx(Cd,{className:"md:col-span-2 md:row-span-2",delayMs:700,labelledBy:"onb-data-heading",children:l.jsx(eW,{projectName:e})}),l.jsx(Cd,{className:"md:col-span-3",delayMs:800,labelledBy:"onb-schedule-heading",children:l.jsx(aW,{projectName:e})}),l.jsx(Cd,{className:"md:col-span-3",delayMs:900,labelledBy:"onb-alerts-heading",children:l.jsx(iW,{projectName:e,score:r?.aggregateScore??null})})]}),l.jsxs("div",{className:"onb-reveal mt-12 flex flex-col items-center gap-3 sm:flex-row sm:justify-center",style:_a(1e3),children:[l.jsx(le,{asChild:!0,className:"h-11 rounded-full px-6 text-base md:h-11",children:l.jsxs(tt,{to:"/projects/$projectName",params:{projectName:e},replace:!0,onClick:()=>u("open_project"),children:["Open ",e,l.jsx(Ac,{className:"size-4","aria-hidden":"true"})]})}),l.jsx(le,{asChild:!0,variant:"ghost",className:"h-11 rounded-full px-5 md:h-11",children:l.jsx(tt,{to:"/projects/$projectName/technical-aeo",params:{projectName:e},replace:!0,onClick:()=>u("review_page_health"),children:"Review page health"})})]})]})})}function tS(e,n){const i=yt({...EN({client:W,path:{name:e},query:{kind:n,limit:20}}),retry:!1,refetchInterval:r=>nS(r.state.status==="success"?{isSuccess:!0,data:r.state.data}:{isSuccess:!1})==="pending"?5e3:!1});return nS(i)}function QJ(e,n){return e===void 0?{}:n?{visibility:"skipped"}:{visibility:e}}function nS(e){if(!e.isSuccess||!e.data)return"unknown";const n=e.data.filter(i=>i.trigger!==Ua.probe);if(!n.some(i=>i.status===jt.completed||i.status===jt.partial))return n.some(i=>i.status===jt.queued||i.status===jt.running)?"pending":n.length>0?"incomplete":"skipped"}function _a(e){return{"--onb-delay":`${e}ms`}}function FJ(){return l.jsx("div",{className:"onb-check relative mx-auto size-20","aria-hidden":"true",children:l.jsxs("svg",{viewBox:"0 0 80 80",className:"relative size-20",children:[l.jsx("circle",{className:"onb-check-ring",cx:"40",cy:"40",r:"36",fill:"none",strokeWidth:"3",pathLength:"1"}),l.jsx("path",{className:"onb-check-mark",d:"M25 41 L35 51 L56 30",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",pathLength:"1"})]})})}function Cd({className:e="",delayMs:n,labelledBy:i,children:r}){return l.jsx("section",{"aria-labelledby":i,className:`onb-reveal onb-tile flex flex-col overflow-hidden rounded-2xl border border-default bg-surface p-6 md:p-7 ${e}`,style:_a(n),children:r})}function Wm({id:e,eyebrow:n,title:i,children:r}){return l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted",children:n}),l.jsx("h2",{id:e,className:"mt-1.5 text-2xl font-semibold tracking-tight text-heading",children:i}),l.jsx("p",{className:"mt-2 text-sm text-secondary",children:r})]})}const _d=[{id:"diagnose",label:"Diagnose",prompt:"Why did we lose citations this week?",calls:["canonry_insights_list","canonry_competitor_landscape"],reply:"Two engines started citing a competitor’s comparison page instead of yours. Want me to draft one that answers the same query?"},{id:"fix",label:"Fix",prompt:"Fix the weakest pages on the site.",calls:["canonry_technical_aeo_pages","canonry_site_health_page_audit"],reply:"The lowest-scoring pages are missing structured data and answer-first intros. I’ve written the changes for you to review."},{id:"automate",label:"Automate",prompt:"Re-check everything every Monday and tell me in Slack.",calls:["canonry_schedule_set","canonry_agent_webhook_attach"],reply:"Done. A sweep runs every Monday, and I’ll post what changed to Slack."}],ZJ=9e3;function YJ(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function XJ({projectName:e}){const n=C.useContext(Jm),[i,r]=C.useState(0),[u,h]=C.useState(!1),[f,b]=C.useState(!1);C.useEffect(()=>{if(u||YJ())return;const k=window.setTimeout(()=>r(S=>(S+1)%_d.length),ZJ);return()=>window.clearTimeout(k)},[i,u]);const v=async()=>{try{await navigator.clipboard.writeText(Kf),n("copy_agent_command"),b(!0),window.setTimeout(()=>b(!1),1800)}catch{xn({tone:"negative",title:"Could not copy the command",detail:`Run ${Kf} in your terminal.`})}},x=_d[i]??_d[0];return l.jsxs(l.Fragment,{children:[l.jsxs(Wm,{id:"onb-agent-heading",eyebrow:"Your agent",title:"Let your agent run it.",children:["Your agent can do everything in Canonry: diagnose a drop, fix pages, run sweeps and scans, and write the client report. Use Claude Code, Codex, Cursor, or Aero, the analyst built into"," ",l.jsx("span",{className:"text-heading",children:e})," that reviews every sweep on its own."]}),l.jsxs("div",{className:"mt-6 flex flex-1 flex-col rounded-xl border border-default bg-bg",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onFocus:()=>h(!0),children:[l.jsxs("div",{className:"flex items-center gap-1 border-b border-default px-3 py-2",role:"tablist","aria-label":"Example agent sessions",children:[_d.map((k,S)=>l.jsx("button",{type:"button",role:"tab","aria-selected":S===i,onClick:()=>{r(S),h(!0)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${S===i?"bg-surface-inset text-heading":"text-muted hover:text-secondary"}`,children:k.label},k.id)),l.jsx("span",{className:"ml-auto text-xs text-faint",children:"Example"})]}),l.jsxs("div",{role:"tabpanel","aria-label":`${x.label} example`,className:"flex-1 p-4 font-mono text-[13px] leading-relaxed",children:[l.jsxs("p",{className:"onb-type text-heading",style:_a(150),children:[l.jsx("span",{className:"text-muted",children:"> "}),x.prompt]}),x.calls.map((k,S)=>l.jsxs("p",{className:"onb-line mt-1 text-muted first:mt-3",style:_a(1300+S*450),children:[l.jsx("span",{className:"text-positive",children:"●"})," ",k]},k)),l.jsx("p",{className:"onb-line mt-3 text-secondary",style:_a(1500+x.calls.length*450),children:x.reply}),l.jsx("span",{className:"onb-caret mt-2 inline-block h-4 w-2 bg-current align-middle text-secondary",style:_a(1900+x.calls.length*450),"aria-hidden":"true"})]},x.id)]}),l.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[l.jsx("code",{className:"min-w-0 flex-1 truncate rounded-lg border border-default bg-surface-inset px-3 py-2 font-mono text-[13px] text-heading",children:Kf}),l.jsxs(le,{type:"button",variant:"secondary",size:"sm",className:"h-9 md:h-9",onClick:()=>{v()},children:[f?l.jsx(Pc,{className:"size-4","aria-hidden":"true"}):l.jsx(V0,{className:"size-4","aria-hidden":"true"}),f?"Copied":"Copy"]}),l.jsx("a",{href:KJ,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-link underline-offset-4 hover:underline",children:"Other clients"})]})]})}const JJ=[{icon:U0,label:"Search Console",action:"connect_search_console",to:"/projects/$projectName/search-console"},{icon:bS,label:"Google Analytics",action:"connect_analytics",to:"/projects/$projectName/activity"},{icon:xS,label:"Business Profile",action:"connect_business_profile",to:"/projects/$projectName/local"}],WJ=["GPTBot","ClaudeBot","PerplexityBot"];function eW({projectName:e}){const n=C.useContext(Jm);return l.jsxs(l.Fragment,{children:[l.jsx(Wm,{id:"onb-data-heading",eyebrow:"Server-side traffic",title:"See the AI bots.",children:"AI crawlers and answer-engine fetches never run JavaScript, so Google Analytics never sees them. Canonry reads them straight from your server."}),l.jsx(tW,{}),l.jsxs(tt,{to:"/traffic",onClick:()=>n("connect_server_traffic"),"aria-label":"Connect server-side traffic",className:"group flex items-center gap-3 rounded-xl border border-strong bg-surface-inset px-4 py-3 text-sm font-medium text-heading transition-colors hover:bg-surface-inset-hover",children:[l.jsx(wS,{className:"size-4 text-positive","aria-hidden":"true"}),l.jsxs("span",{className:"flex-1",children:["Connect your server",l.jsx("span",{className:"block text-xs font-normal text-secondary",children:"Cloudflare, Vercel, WordPress, or Cloud Run"})]}),l.jsx(Ac,{className:"size-4 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]}),l.jsx("p",{className:"mt-5 text-xs font-medium uppercase tracking-wide text-muted",children:"Also connect"}),l.jsx("ul",{className:"mt-1 divide-y divide-default",children:JJ.map(({icon:i,label:r,action:u,to:h})=>l.jsx("li",{children:l.jsxs(tt,{to:h,params:{projectName:e},"aria-label":`Connect ${r}`,onClick:()=>n(u),className:"group flex items-center gap-3 py-2.5 text-sm text-heading",children:[l.jsx(i,{className:"size-4 text-muted","aria-hidden":"true"}),l.jsx("span",{className:"flex-1",children:r}),l.jsx(Ac,{className:"size-3.5 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})},r))})]})}function tW(){const e=[22,70,118];return l.jsxs("div",{className:"relative my-6 h-36","aria-hidden":"true",children:[l.jsx("svg",{viewBox:"0 0 200 140",preserveAspectRatio:"none",className:"absolute inset-0 size-full",children:e.map((n,i)=>l.jsx("path",{className:"onb-flow",style:_a(i*400),d:`M20 ${n} C 100 ${n}, 118 70, 170 70`,fill:"none",strokeWidth:"1.5"},n))}),WJ.map((n,i)=>l.jsx("span",{className:"onb-bot absolute left-0 -translate-y-1/2 rounded-md border border-default bg-bg-elevated px-2 py-1 font-mono text-[11px] text-secondary",style:{top:`${(e[i]??70)/140*100}%`,..._a(i*600)},children:n},n)),l.jsx("span",{className:"onb-hub absolute right-0 top-1/2 flex size-11 -translate-y-1/2 items-center justify-center rounded-2xl bg-accent text-on-inverse",children:l.jsx(wS,{className:"size-5"})})]})}const nW=["M","T","W","T","F","S","S"];function aW({projectName:e}){return l.jsxs(l.Fragment,{children:[l.jsx(Wm,{id:"onb-schedule-heading",eyebrow:"Scheduled sweeps",title:"Runs on its own.",children:"Re-measure every week without lifting a finger, so a drop shows up before a customer notices."}),l.jsx("ol",{className:"mt-6 grid grid-cols-7 gap-2","aria-hidden":"true",children:nW.map((n,i)=>l.jsxs("li",{className:"flex flex-col items-center gap-2",children:[l.jsx("span",{className:"onb-day size-3 rounded-full bg-surface-inset",style:_a(i*500)}),l.jsx("span",{className:"text-xs text-muted",children:n})]},i))}),l.jsx(xC,{projectName:e,to:"/projects/$projectName/settings",icon:vS,label:"Set a schedule",action:"set_schedule"})]})}function iW({projectName:e,score:n}){return l.jsxs(l.Fragment,{children:[l.jsx(Wm,{id:"onb-alerts-heading",eyebrow:"Notifications",title:"Hear about changes.",children:"Get a webhook in Slack or anywhere else when a sweep finishes or a score moves."}),l.jsxs("div",{className:"relative mt-6 flex h-14 items-center","aria-hidden":"true",children:[l.jsx("span",{className:"onb-bell flex size-10 items-center justify-center rounded-full border border-default bg-bg-elevated",children:l.jsx(Qf,{className:"size-4 text-secondary"})}),l.jsxs("span",{className:"onb-toast ml-3 flex items-center gap-2 rounded-xl border border-default bg-bg-elevated px-3 py-2 text-sm shadow-[0_8px_24px_var(--color-shadow-panel)]",children:[l.jsx("span",{className:"size-2 rounded-full bg-positive-400"}),l.jsx("span",{className:"text-heading",children:e}),l.jsx("span",{className:"text-secondary",children:n===null?"sweep finished":`page health ${n}`})]})]}),l.jsx(xC,{projectName:e,to:"/projects/$projectName/settings",icon:Qf,label:"Add a notification",action:"add_notification"})]})}function xC({projectName:e,to:n,icon:i,label:r,action:u}){const h=C.useContext(Jm);return l.jsxs(tt,{to:n,params:{projectName:e},onClick:()=>h(u),className:"group mt-6 inline-flex items-center gap-2 self-start text-sm font-medium text-link",children:[l.jsx(i,{className:"size-4","aria-hidden":"true"}),r,l.jsx(Ac,{className:"size-3.5 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})}const sW=C.lazy(async()=>({default:(await Gi(()=>import("./SiteHealthSection-CUOt7jeo.js").then(n=>n.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),oW=`Public pages only, crawled from this computer and stored locally. The first scan reads up to ${yj} pages, then stops.`,rW=1800,lW="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",cW="Help me set up Canonry for my public site.\n\nUse the official Canonry docs:\n- Agent quickstart: https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent\n- CLI reference: https://github.com/Canonry/canonry/blob/main/skills/canonry/references/canonry-cli.md\n- Plugin setup: https://github.com/Canonry/canonry/blob/main/docs/plugins.md\n- MCP setup: https://github.com/Canonry/canonry/blob/main/docs/mcp.md\n\nPick one path and stay on it. Use connected Canonry tools (plugin or MCP) only if you have them and I have not pointed you at a specific install. A connected tool runs in its own process and never sees `CANONRY_CONFIG_DIR`, `CANONRY_PORT`, or anything else you export in a shell, so it always acts on my default install. If I named a config directory, a port, or a sandbox, that is the shell path: use `cnry` and tell me which path you chose. Never mix the two in one run, and never create a duplicate project. The `cnry` and `canonry` commands are interchangeable.\n\n1. Ask for my public domain, country, and language. Do not create or scan anything yet. Country and language are only applied when a project is created, so if you reuse an existing project, report its country and language instead of changing them.\n2. Shell path only: confirm `cnry` is on PATH, then run `cnry --version`. If Canonry is missing, propose `npm install -g @canonry/canonry` and wait for approval. Then run `cnry doctor --format json`, which is the command that says whether config, database, and server are in place. `cnry --version` does not read config and succeeds on a completely unconfigured install, so it cannot answer this. If config is missing, run `cnry bootstrap` yourself: it is not interactive, takes about a second, and is safe to rerun. Do not hand it to me and wait. The interactive command is `cnry init`, which is optional provider and OAuth setup that Page Health does not need. Bootstrap prints an API key, so do not repeat its output back to me, and never ask me to paste passwords, API keys, OAuth credentials, or command output.\n3. Confirm the API is reachable. `cnry doctor --format json` reports it, and any project read exits non-zero with `CONNECTION_ERROR` when it is not. If it is unreachable, propose `cnry start` and wait for approval. Use `cnry start`, which is the background daemon, and not `cnry serve`, which runs in the foreground and will block you until I stop it, even though some error messages suggest it. Stop anything you started with `cnry stop`.\n4. List projects with the connected project tool or `cnry project list --format json`, and reuse one whose domain matches. Confirm the proposed name is not already assigned to a different domain. To find out whether a project has already been scanned, run `cnry technical-aeo score <project> --format json` with no `--run-id`, which reports the latest run. Read the `hasData` field, not the score: this command exits 0 and reports `aggregateScore: 0` for a project that has never been scanned, so reading the score alone would have you tell me my site scored zero. If `hasData` is true and `runStatus` is `completed` or `partial`, read that scan instead of starting a new one. If no project matches, show the exact create operation and wait for approval.\n5. Propose a bounded Site Health scan: `--max-pages 100` for a first look, plus whether dead-link checking is on (it is off unless you pass `--check-dead-links`). Show the connected operation or the exact `cnry technical-aeo run <project> --max-pages 100 --wait --format json` command with the project name filled in, and wait for separate approval before scanning. `--wait` polls for up to 15 minutes and returns only the run id and status. If the status it returns is still `queued` or `running`, the scan has not finished: do not rerun it or report results, poll `cnry technical-aeo progress <project> --run-id <run-id> --format json` until it is terminal. If `--wait` outruns your own tool timeout first, recover the run id with `cnry technical-aeo score <project> --format json` and poll the same way.\n6. When the run is `completed` or `partial`, read `cnry technical-aeo crawl <project> --run-id <run-id> --format json` first. It is the only one of these commands that carries `termination` and `complete`; the score and pages commands do not. Then read `cnry technical-aeo score <project> --run-id <run-id> --format json` and `cnry technical-aeo pages <project> --run-id <run-id> --sort score-asc --limit 10 --format jsonl`. Tell me the termination reason in plain words and whether the scan covered the whole site or stopped at a page, link, depth, or time limit. A `partial` run scored the pages it reached and not my site, so never present it as a full-site result. If it stopped early, the fix depends on the reason, so say which: a page or depth limit needs a larger budget, a time limit needs a smaller scan (a lower `--max-pages` or `--max-depth`). If the run failed or was cancelled, inspect the run error and stop.\n7. Summarize only completed evidence, then propose AI Visibility setup. Ask before you add queries, connect providers, start a provider-backed or quota-consuming run, edit files, or publish.";function uW(e,n){return e==="legacy"?"legacy":e==="platform"?"platform":n.state==="success"?n.projectCount===0?"platform":"legacy":n.state==="error"?"retry":"loading"}const dW="2000-01-01T00:00:00.000Z",mW=5e3;function pW(e,n){const i=new Set,r=new Map;for(const f of n)f.trigger!==Ua.probe&&(r.has(f.projectId)||r.set(f.projectId,f.id),(f.status===jt.completed||f.status===jt.partial)&&i.add(f.projectId));const h=(e.every(f=>f.createdAt)?[...e].sort((f,b)=>(f.createdAt??"").localeCompare(b.createdAt??"")||f.name.localeCompare(b.name)):e).find(f=>!i.has(f.id));return h?{projectName:h.name,runId:r.get(h.id)}:null}const wC=[{value:"US",label:"United States"},{value:"CA",label:"Canada"},{value:"GB",label:"United Kingdom"},{value:"AU",label:"Australia"},{value:"NZ",label:"New Zealand"},{value:"IE",label:"Ireland"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"ES",label:"Spain"},{value:"IT",label:"Italy"},{value:"NL",label:"Netherlands"},{value:"BR",label:"Brazil"},{value:"MX",label:"Mexico"},{value:"IN",label:"India"},{value:"SG",label:"Singapore"},{value:"JP",label:"Japan"}],kC=[{value:"en",label:"English"},{value:"es",label:"Spanish"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"it",label:"Italian"},{value:"pt",label:"Portuguese"},{value:"nl",label:"Dutch"},{value:"ja",label:"Japanese"}];function hW(e,n){try{const i=new Intl.DisplayNames(["en"],{type:"region"}),r=new Intl.DisplayNames(["en"],{type:"language"}),u=e.length===2?i.of(e.toUpperCase()):void 0,h=n?r.of(n.toLowerCase()):void 0;return`${u??(e||"Country")} · ${h??(n||"Language")}`}catch{return`${e||"Country"} · ${n||"Language"}`}}function fW(e,n){const i=e.trim().toUpperCase(),r=n.trim().toLowerCase();return{countryValid:wC.some(u=>u.value===i),languageValid:kC.some(u=>u.value===r)}}function gW(e){const n=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(n)||n.includes(":")}function yW(e){const n=e.trim();if(!n)return null;const i=/^[a-z][a-z\d+.-]*:\/\//i.test(n)?n:`https://${n}`;let r;try{r=new URL(i)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:")return null;const u=r.hostname.toLowerCase().replace(/^www\./,"");if(!u||u==="localhost"||gW(u)||!u.includes("."))return null;const h=u.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return h?{canonicalDomain:u,projectName:h,displayName:u}:null}async function bW(e,n=rW){let i;const r=new Promise(h=>{i=setTimeout(()=>h({state:"timed-out"}),n)}),u=await Promise.race([e.then(h=>({state:"queued",run:h})),r]);return i&&clearTimeout(i),u}function vW(e,n){e.catch(()=>{xn({title:"Site Health scan did not start",detail:"The project is safe. Choose Run scan in Site Health to retry.",tone:"negative",dedupeKey:`site-health-dispatch:${n}`})})}function SC(e){const n=C.useRef(p1()).current,i=C.useRef(new Set),r=C.useCallback((u,h)=>{if(h){if(i.current.has(h))return;i.current.add(h)}b1({...u,surface:e,eventId:h1()})},[e]);return{onboardingSessionId:n,emit:r}}function aS(e,n){return e instanceof Tn&&e.statusCode===409?"A project with this name already exists. Change the project name, or open the existing project.":e instanceof Error&&e.message?e.message:n}function P0(){return l.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Preparing setup"}),l.jsx("p",{className:"page-subtitle",children:"Checking the projects already on this install."})]})}),l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary",role:"status",children:[l.jsx(Cs,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function xW({onRetry:e}){return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Can’t load projects"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not confirm whether this install already has a project."})]})}),l.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:"Setup is paused to protect existing projects."}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function wW({projectName:e,initialRunId:n}){return l.jsx(E1,{title:"Site Health setup",children:l.jsx(kW,{projectName:e,initialRunId:n})})}function kW({projectName:e,initialRunId:n}){const i=Es(),r=yt({...Oo({client:W}),enabled:!!e,retry:!1,refetchOnMount:"always"}),{onboardingSessionId:u,emit:h}=SC("site_health"),[f]=C.useState(()=>LK(n));C.useEffect(()=>{f&&UK()},[f]),C.useEffect(()=>{e&&h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.started",step:"run",resumed:!!n&&!f},"onboarding.started")},[h,f,n,u,e]),C.useEffect(()=>{!e||!n||dN(e)?.runId!==n&&uN(e,n)},[n,e]);const v=yt({...w1({client:W,path:{id:n??""}}),enabled:!!n,refetchInterval:({state:_})=>{const z=_.data?.status;return z==="completed"||z==="partial"||z==="failed"||z==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if(C.useEffect(()=>{if(!e||!n||!v)return;if(v==="completed"||v==="partial"){h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"automatic"},"onboarding.step_completed:run"),nm(n);return}if(v!=="failed"&&v!=="cancelled")return;const _=v==="cancelled"?"run_cancelled":"run_failed";h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:_},`onboarding.blocked:run:${_}`),nm(n)},[h,n,u,e,v]),!e)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project not found"}),l.jsx("p",{className:"page-subtitle",children:"This setup link does not identify a project."})]})}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});if(r.isPending)return l.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[l.jsx(Co,{current:"site"}),l.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[l.jsx(Cs,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health setup…"]})]});if(r.isError)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Can’t resume setup"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project for this Site Health scan."})]})}),l.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[l.jsx("p",{className:"text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const x=r.data.find(_=>_.name===e);if(!x)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project not found"}),l.jsxs("p",{className:"page-subtitle",children:["Canonry could not find ",e,". It will not open a different project."]})]})}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});const k=()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:x.name},replace:!0})},S=()=>{i({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:x.name},replace:!0})},N=()=>{h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"skipped"},"onboarding.step_completed:run"),i({to:"/setup",search:{onboarding:"complete",setupProject:x.name,skipped:"visibility"},replace:!0})};return l.jsxs("div",{className:"page-container max-w-7xl py-8 md:py-10",children:[l.jsx("h1",{className:"sr-only",children:"Set up Canonry"}),l.jsx(C.Suspense,{fallback:l.jsxs("div",{className:"space-y-5",children:[l.jsx(Co,{current:"site"}),l.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-3 text-sm text-secondary",role:"status",children:[l.jsx(Cs,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:l.jsx(sW,{projectName:x.name,projectId:x.id,initialRunId:n,onReleaseInitialRun:k,showOnboardingActions:!0,onContinueOnboarding:S,onSkipOnboarding:N})})]})}function SW(){const e=oS({from:"/setup"}),n=e.onboarding==="site-health"&&!e.setupProject,i=e.onboarding==="site-health"&&e.experience!=="legacy",r=hG(),u=e.experience==="legacy"?"legacy":e.experience==="platform"?"platform":r,[h,f]=C.useState(!1),[b,v]=C.useState(void 0),x=yt({...Oo({client:W}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),k=yt({...Dc({client:W,query:{kind:De["site-audit"],since:dW,limit:mW}}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),S=u==="auto"&&x.isSuccess&&x.isFetchedAfterMount&&x.data.length===0;C.useEffect(()=>{S&&f(!0)},[S]);const N=u!=="auto"?{state:"idle"}:x.isSuccess&&x.isFetchedAfterMount?{state:"success",projectCount:x.data.length}:x.isError?{state:"error"}:{state:"loading"},_=u==="legacy"?"legacy":h||S?"platform":uW(u,N);if(e.onboarding==="complete"&&e.setupProject)return l.jsx(HJ,{projectName:e.setupProject,skippedVisibility:e.skipped==="visibility"});if(n||i)return l.jsx(wW,{projectName:e.setupProject,initialRunId:e.siteHealthRunId});const z=u==="auto"&&_==="legacy"&&!e.setupProject&&x.isSuccess;if(z&&b===void 0)return k.isError?v(null):k.isSuccess&&k.isFetchedAfterMount&&v(pW(x.data,k.data)),l.jsx(P0,{});const q=z?b:null;return q?l.jsx(jW,{projectName:q.projectName,runId:q.runId}):_==="legacy"?l.jsx(VJ,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health",onboardingFinish:e.onboarding==="site-health"||e.onboarding==="first-run"}):_==="loading"?l.jsx(P0,{}):_==="retry"?l.jsx(xW,{onRetry:()=>{x.refetch()}}):l.jsx(AW,{onActivationStarted:()=>f(!0),skipSiteScan:e.siteScan==="skip"})}function jW({projectName:e,runId:n}){const i=Es();return C.useEffect(()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:e,...n?{siteHealthRunId:n}:{}},replace:!0})},[i,e,n]),l.jsx(P0,{})}function AW({onActivationStarted:e,skipSiteScan:n}){return l.jsx(E1,{title:"Site Health setup",children:l.jsx(NW,{onActivationStarted:e,skipSiteScan:n})})}function NW({onActivationStarted:e,skipSiteScan:n}){const i=Es(),r=_o(),u=RJ(),h=yt({...yQ({client:W}),retry:!1}),f=ii(bQ()),[b,v]=C.useState(""),[x,k]=C.useState(""),[S,N]=C.useState(""),[_,z]=C.useState("US"),[q,E]=C.useState("en"),[P,M]=C.useState(!1),[L,$]=C.useState("idle"),[H,J]=C.useState(null),[V,F]=C.useState(null),[ie,Ge]=C.useState(!1),[We,$e]=C.useState(null),[Pe,ke]=C.useState(!1),Ue=h.isError?void 0:h.data,B=typeof Ue?.enabled=="boolean"?Ue.enabled:null,ee=f.isPending?f.variables.body.enabled:B,[be,je]=C.useState(null),te=C.useRef(null),{onboardingSessionId:_e,emit:qe}=SC("platform");C.useEffect(()=>{qe({flowVersion:ft,onboardingSessionId:_e,event:"onboarding.started",step:"project",resumed:!1},"onboarding.started")},[qe,_e]);const ve=yW(b),de=x||ve?.projectName||"",ce=S||ve?.displayName||"",Y=L==="creating"||L==="dispatching",pe=V??We,Oe=hW(_,q),{countryValid:Ae,languageValid:st}=fW(_,q),Ve=Ae&&st;C.useEffect(()=>{pe&&te.current?.focus()},[pe]);const Nt=(Me,ct)=>i({to:"/setup",search:{...ct?{siteHealthRunId:ct}:{},onboarding:"site-health",setupProject:Me.name},replace:!0}),He=async Me=>{$("dispatching"),$e(null);try{const ct=u.mutateAsync({projectName:Me.name,projectId:Me.id,projectLabel:Me.displayName||Me.name,suppressErrorToast:!0,body:{checkDeadLinks:!0,maxPages:yj}}),Qt=await bW(ct);if(Qt.state==="queued"){qe({flowVersion:ft,onboardingSessionId:_e,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"}),BK(Qt.run.runId),await Nt(Me,Qt.run.runId);return}ct.then(()=>{qe({flowVersion:ft,onboardingSessionId:_e,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"})},Ft=>{qe({flowVersion:ft,onboardingSessionId:_e,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:wc(Ft,"run_rejected")})}),vW(ct,Me.id),await Nt(Me)}catch(ct){$("recovery"),$e(aS(ct,"The project was created, but the Site Health scan could not be started."));const Qt=wc(ct,"run_rejected");qe({flowVersion:ft,onboardingSessionId:_e,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Qt}),qe({flowVersion:ft,onboardingSessionId:_e,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:Qt},`onboarding.blocked:run:${Qt}`)}},me=async Me=>{if(Me.preventDefault(),!(!ve||!n&&!P||!Ve||Y)){$("creating"),F(null),Ge(!1),$e(null);try{const ct=await IG({name:de,displayName:ce,canonicalDomain:ve.canonicalDomain,country:_,language:q});if(e(),J(ct),qe({flowVersion:ft,onboardingSessionId:_e,event:"onboarding.step_completed",step:"project",method:"manual"},"onboarding.step_completed:project"),await r.invalidateQueries({queryKey:Br({client:W})}),n){await i({to:"/setup",search:{experience:"legacy",onboarding:"first-run",setupProject:ct.name},replace:!0});return}await He(ct)}catch(ct){$("idle");const Qt=ct instanceof Tn&&ct.statusCode===409;Ge(Qt),F(aS(ct,"Could not create the project. Try again.")),qe({flowVersion:ft,onboardingSessionId:_e,event:"onboarding.blocked",step:"project",action:"save",reasonCode:wc(ct,"project_create_failed")},"onboarding.blocked:project"),Qt&&(e(),r.invalidateQueries({queryKey:Br({client:W})}))}}},at=()=>{H&&!Y&&He(H)},It=()=>{Y||i({to:"/projects"})},Pn=async()=>{try{await navigator.clipboard.writeText(cW),ke(!0)}catch{xn({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}},Ht=async Me=>{je(null);try{const ct=await f.mutateAsync({client:W,body:{enabled:Me}});r.setQueryData(DN({client:W}),ct),ct.enabled!==Me&&je(`The server kept telemetry ${ct.enabled?"on":"off"}. Check its telemetry settings.`)}catch{je("Could not update telemetry. Try again.")}};return H&&L==="recovery"?l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx(Co,{current:"site"}),l.jsx("div",{className:"page-header mt-8",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project created"}),l.jsxs("p",{className:"page-subtitle",children:[H.displayName||H.name," is ready. The Site Health scan needs another try."]})]})}),l.jsxs("div",{ref:te,className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:We}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"You can retry the scan or continue setup and retry from Site Health."}),l.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[l.jsx(le,{type:"button",onClick:at,children:"Retry Site Health scan"}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{Nt(H)},children:"Continue setup"})]})]})]}):l.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[n?null:l.jsx(Co,{current:"site"}),l.jsxs("header",{className:`mb-8 ${n?"":"mt-8"}`,children:[l.jsx("h1",{id:"site-map-setup-title",className:"text-2xl font-semibold tracking-[-0.025em] text-heading",children:n?"Create a project":"Scan your site"}),l.jsx("p",{className:"mt-2 max-w-lg text-sm leading-6 text-secondary",children:n?"Add a public domain, then choose the queries you want to track. No site scan will run.":"Enter your public website to see its pages, structure, internal links, and technical SEO scores."})]}),l.jsxs("form",{"aria-labelledby":"site-map-setup-title",className:"space-y-6",onSubmit:fn(me),noValidate:!0,children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm font-medium text-heading",htmlFor:"launchpad-domain",children:"Website URL"}),l.jsx("input",{id:"launchpad-domain",className:"h-11 w-full rounded-md border border-strong bg-bg-elevated/50 px-3 text-base text-heading outline-none transition placeholder:text-muted focus:border-mono-500 focus:ring-1 focus:ring-mono-500",type:"text",inputMode:"url",autoComplete:"url",autoCapitalize:"none",spellCheck:!1,required:!0,"aria-invalid":!!(b&&!ve),"aria-describedby":b&&!ve?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:b,onChange:Me=>{v(Me.target.value),F(null),Ge(!1)}}),l.jsx("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:n?l.jsxs(l.Fragment,{children:["A public domain is still required."," ",l.jsx(tt,{to:"/setup",search:{experience:"platform"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Map with Site Health instead"})]}):l.jsxs(l.Fragment,{children:["Only public pages are scanned."," ",l.jsx(tt,{to:"/setup",search:{experience:"platform",onboarding:"first-run",siteScan:"skip"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Set up without a site scan"})]})}),b&&!ve?l.jsx("p",{id:"launchpad-domain-error",className:"text-sm text-negative",role:"alert",children:"Enter a public domain, such as example.com."}):null]}),l.jsxs("details",{className:"group border-y border-default",children:[l.jsxs("summary",{className:"flex min-h-11 cursor-pointer list-none items-center justify-between gap-4 py-3 text-sm [&::-webkit-details-marker]:hidden",children:[l.jsx("span",{className:"font-medium text-heading",children:"Project name and locale"}),l.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[Oe,l.jsx(Oc,{className:"size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none","aria-hidden":"true"})]})]}),l.jsxs("div",{className:"space-y-5 border-t border-default py-4",children:[ve?l.jsxs("div",{children:[l.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Project"}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-project-name",children:"Project name"}),l.jsx("input",{id:"launchpad-project-name",className:"setup-input h-10",type:"text",value:de,onChange:Me=>k(Me.target.value)})]}),l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-display-name",children:"Display name"}),l.jsx("input",{id:"launchpad-display-name",className:"setup-input h-10",type:"text",value:ce,onChange:Me=>N(Me.target.value)})]})]})]}):null,l.jsxs("div",{children:[l.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Locale"}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-country",children:"Country"}),l.jsx("select",{id:"launchpad-country",className:"setup-input h-10",value:_,onChange:Me=>z(Me.target.value),children:wC.map(Me=>l.jsx("option",{value:Me.value,children:Me.label},Me.value))})]}),l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-language",children:"Language"}),l.jsx("select",{id:"launchpad-language",className:"setup-input h-10",value:q,onChange:Me=>E(Me.target.value),children:kC.map(Me=>l.jsx("option",{value:Me.value,children:Me.label},Me.value))})]})]})]})]})]}),n?null:l.jsxs("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 py-2",children:[l.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg",type:"checkbox",checked:P,onChange:Me=>M(Me.target.checked),"aria-label":"Allow Canonry to scan this public site."}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),l.jsx(la,{text:oW})]})]}),pe?l.jsxs("div",{ref:te,className:"rounded-md border border-negative bg-negative-soft p-3",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:pe}),ie?l.jsx(le,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:It,children:"View projects"}):null]}):null,l.jsxs("div",{className:"grid gap-2",children:[l.jsx(le,{className:"h-11 w-full",type:"submit",disabled:!ve||!n&&!P||!Ve||Y,children:L==="creating"||L==="dispatching"?l.jsxs(l.Fragment,{children:[l.jsx(Cs,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," ",n?"Creating project…":"Mapping site…"]}):n?"Create project":"Scan site"}),L==="dispatching"?l.jsx("span",{className:"text-center text-sm text-secondary",role:"status",children:"Opening Site Health when the scan is ready."}):null]})]}),l.jsxs("section",{className:"mt-8 border-t border-default pt-6","aria-labelledby":"agent-setup-title",children:[l.jsx("p",{id:"agent-setup-title",className:"text-sm font-medium text-heading",children:"Use your agent instead"}),l.jsx("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"Copy a complete CLI setup request into any agent."}),l.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[l.jsxs(le,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:fn(Pn),children:[Pe?l.jsx(Pc,{className:"size-3.5","aria-hidden":"true"}):l.jsx(V0,{className:"size-3.5","aria-hidden":"true"}),l.jsx("span",{"aria-live":"polite",children:Pe?"Copied setup request":"Copy setup request"})]}),l.jsx(le,{asChild:!0,variant:"ghost",size:"sm",children:l.jsxs("a",{href:lW,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",l.jsx(n6,{className:"size-3.5","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]}),B!==null?l.jsxs("section",{className:"mt-6 border-t border-default pt-5","aria-labelledby":"telemetry-title",children:[l.jsxs("label",{className:`flex min-h-11 items-start gap-3 py-2 ${f.isPending?"cursor-wait":"cursor-pointer"}`,children:[l.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg accent-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mono-500 disabled:cursor-wait",type:"checkbox",checked:ee??!1,disabled:f.isPending,onChange:Me=>{Ht(Me.target.checked)},"aria-describedby":"telemetry-detail"}),l.jsxs("span",{className:"grid gap-0.5",children:[l.jsx("span",{id:"telemetry-title",className:"text-sm leading-5 text-heading",children:"Share anonymous product telemetry"}),l.jsx("span",{id:"telemetry-detail",className:"max-w-[70ch] text-sm leading-5 text-secondary",children:"Helps prioritize improvements. Canonry does not send raw domains, URLs, queries, answer content, or credentials."})]})]}),f.isPending?l.jsx("p",{className:"mt-1 text-sm text-secondary",role:"status",children:"Saving preference…"}):null,be?l.jsx("p",{className:"mt-1 text-sm text-negative",role:"alert",children:be}):null]}):null]})}function CW(){return l.jsx("div",{className:"page-container",children:l.jsx("section",{className:"page-section",children:l.jsxs(Ca,{className:"surface-card empty-card",children:[l.jsx("h1",{children:"Route not found"}),l.jsx("p",{children:"The current path does not map to a dashboard view."}),l.jsx(le,{asChild:!0,children:l.jsx(tt,{to:"/",children:"Return to overview"})})]})})})}const Da=Rs(()=>Gi(()=>import("./ProjectPage-enF4twWt.js"),__vite__mapDeps([5,1,0,2,3,4,6,7,8,9,10,11]),import.meta.url),"ProjectPage"),_W=Rs(()=>Gi(()=>import("./RunsPage-aOeJ60pX.js"),__vite__mapDeps([12,1,10,4,2,7,11]),import.meta.url),"RunsPage"),TW=Rs(()=>Gi(()=>import("./HistoryPage-Dfq1vK9k.js"),__vite__mapDeps([13,1,9,10,4,2,7,11]),import.meta.url),"HistoryPage"),EW=Rs(()=>Gi(()=>import("./SettingsPage-nA0_ImoQ.js"),__vite__mapDeps([14,1,10,4,2,7,11]),import.meta.url),"SettingsPage"),RW=Rs(()=>Gi(()=>import("./BacklinksPage-CbRIZhu5.js"),__vite__mapDeps([15,1,2,10,4,7,11]),import.meta.url),"BacklinksPage"),DW=Rs(()=>Gi(()=>import("./TrafficPage-C0fVYizx.js"),__vite__mapDeps([16,1,8,2,10,4,7,11]),import.meta.url),"TrafficPage"),zW=Rs(()=>Gi(()=>import("./TrafficSourceDetailPage-LMhXbFlA.js"),__vite__mapDeps([17,1,8,3,4,2,10,7,11]),import.meta.url),"TrafficSourceDetailPage"),IW=Rs(()=>Gi(()=>import("./MeasurementPropertyPage-DcH0zYNN.js"),__vite__mapDeps([18,1,3,4,6,7,2,10,11]),import.meta.url),"MeasurementPropertyPage");function OW(){return l.jsx(BX,{children:l.jsx(NH,{children:l.jsx(MX,{})})})}const Un=I5()({component:OW,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries==="true"?!0:void 0,runId:typeof e.runId=="string"?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId=="string"?e.siteHealthRunId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0,runStatus:typeof e.runStatus=="string"?e.runStatus:void 0,runKind:typeof e.runKind=="string"?e.runKind:void 0,runProject:typeof e.runProject=="string"?e.runProject:void 0,runWindow:typeof e.runWindow=="string"?e.runWindow:void 0,runQuery:typeof e.runQuery=="string"?e.runQuery:void 0,onboarding:e.onboarding==="site-health"||e.onboarding==="first-run"||e.onboarding==="complete"?e.onboarding:void 0,experience:e.experience==="legacy"||e.experience==="platform"?e.experience:void 0,siteScan:e.siteScan==="skip"?"skip":void 0,skipped:e.skipped==="visibility"?"visibility":void 0,setupProject:typeof e.setupProject=="string"?e.setupProject:void 0,scope:typeof e.scope=="string"?e.scope:void 0,class:typeof e.class=="string"?e.class:void 0,...Object.fromEntries(["queryWorkspace","researchMode","trackingQueryId","measurementScope","measurementScopeKey","measurementMarketKey","queryClass","measurementProvider","measurementModel","measurementLocation","measurementFrom","measurementTo","measurementRevision","measurementRunId","measurementQueryKey","measurementAnswer"].map(n=>[n,typeof e[n]=="string"?e[n]:void 0]))})}),PW=Bt({getParentRoute:()=>Un,path:"/",component:xJ,beforeLoad:async({context:e})=>{let n=e.queryClient.getQueryData(Br({client:W}));if(n===void 0)try{n=await e.queryClient.ensureQueryData(Oo({client:W}))}catch{return}if(n.length===0)throw q0({to:"/setup"})}}),qW=Bt({getParentRoute:()=>Un,path:"/projects",component:jJ}),MW=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Vn=Bt({getParentRoute:()=>Un,path:"/projects/$projectName",component:()=>l.jsx(Gf,{}),beforeLoad:async({context:e,params:n,location:i})=>{const r=n.projectName;if(!MW.test(r))return;let u=e.queryClient.getQueryData(Br({client:W}));if(!u)try{u=await e.queryClient.ensureQueryData(Oo({client:W}))}catch{return}const h=u.find(f=>f.id===r);if(h)throw q0({to:i.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(h.name)}`),replace:!0})}}),BW=Bt({getParentRoute:()=>Vn,path:"/",component:()=>l.jsx(Da,{tab:"overview"})}),LW=Bt({getParentRoute:()=>Vn,path:"/portfolio",component:()=>l.jsx(Da,{tab:"portfolio"})}),UW=Bt({getParentRoute:()=>Vn,path:"/search-console",component:()=>l.jsx(Da,{tab:"search-console"})}),VW=Bt({getParentRoute:()=>Vn,path:"/conversions",component:()=>l.jsx(Da,{tab:"conversions"})}),$W=Bt({getParentRoute:()=>Vn,path:"/local",component:()=>l.jsx(Da,{tab:"local"})}),KW=Bt({getParentRoute:()=>Vn,path:"/discovery",component:()=>l.jsx(Da,{tab:"discovery"})}),GW=Bt({getParentRoute:()=>Vn,path:"/queries",component:()=>l.jsx(Da,{tab:"queries"})}),HW=Bt({getParentRoute:()=>Vn,path:"/properties/$targetKey",component:()=>l.jsx(IW,{})}),QW=Bt({getParentRoute:()=>Vn,path:"/report",beforeLoad:({params:e})=>{throw q0({to:"/projects/$projectName",params:e,replace:!0})}}),FW=Bt({getParentRoute:()=>Vn,path:"/activity",component:()=>l.jsx(Da,{tab:"activity"})}),ZW=Bt({getParentRoute:()=>Vn,path:"/backlinks",component:()=>l.jsx(Da,{tab:"backlinks"})}),YW=Bt({getParentRoute:()=>Vn,path:"/technical-aeo",component:()=>l.jsx(Da,{tab:"technical-aeo"})}),XW=Bt({getParentRoute:()=>Vn,path:"/history",component:()=>l.jsx(Da,{tab:"history"})}),JW=Bt({getParentRoute:()=>Vn,path:"/settings",component:()=>l.jsx(Da,{tab:"settings"})}),WW=Bt({getParentRoute:()=>Un,path:"/runs",component:_W}),eee=Bt({getParentRoute:()=>Un,path:"/history",component:TW}),tee=Bt({getParentRoute:()=>Un,path:"/settings",component:EW,beforeLoad:({context:e})=>{}}),nee=Bt({getParentRoute:()=>Un,path:"/setup",component:SW}),aee=Bt({getParentRoute:()=>Un,path:"/backlinks",component:RW}),iee=Bt({getParentRoute:()=>Un,path:"/traffic",component:DW}),see=Bt({getParentRoute:()=>Un,path:"/traffic/$projectName/$sourceId",component:zW}),oee=Bt({getParentRoute:()=>Un,path:"*",component:CW}),ree=Un.addChildren([PW,qW,Vn.addChildren([BW,LW,UW,VW,$W,KW,GW,HW,QW,FW,ZW,YW,XW,JW]),WW,eee,tee,nee,aee,iee,see,oee]);function lee(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const iS=lee(),cee=iS==="/"?"":iS.replace(/\/$/,"");function uee(e,n){return O5({routeTree:ree,basepath:cee||"/",context:{queryClient:e},...n?.initialEntries})}let sS=!1;async function dee(e){return(await B_({client:W,body:e,keepalive:!0})).data}function mee(){sS||typeof window>"u"||(sS=!0,!(Lm()||xo())&&(FK({send:dee}),W.interceptors.request.use((e,n)=>{const i=n.fetch??globalThis.fetch,r=typeof n.url=="string"?n.url:void 0;return n.fetch=async(u,h)=>{try{return await i(u,h)}catch(f){throw f instanceof DOMException&&f.name==="AbortError"||sm({method:e.method,route:r,network:!0}),f}},e}),W.interceptors.response.use((e,n,i)=>(sm({method:n.method,route:typeof i.url=="string"?i.url:void 0,path:hee(n.url),status:e.status}),e)),window.addEventListener("error",e=>{im({kind:"unhandled",error:e.error})}),window.addEventListener("unhandledrejection",e=>{im({kind:"unhandled",error:e.reason})}),vee()))}function pee(e){let n=null;const i=()=>{const r=e.state.matches.at(-1);if(!r)return;ZK(r.fullPath);const u=e.state.location;if(!u)return;const h=u.search&&typeof u.search=="object"?u.search:{};n&&n.pathname===u.pathname&&eG(n.search,h),n={pathname:u.pathname,search:h}};return i(),e.subscribe("onResolved",i)}function hee(e){try{return new URL(e,window.location.origin).pathname}catch{return}}const fee={LCP:[2500,4e3],INP:[200,500],CLS:[.1,.25],FCP:[1800,3e3],TTFB:[800,1800]};function gee(e,n){const[i,r]=fee[e];return n<=i?"good":n<=r?"needs-improvement":"poor"}function yee(){let e=0,n=0,i=-1/0,r=-1/0;return{add(u){u.hadRecentInput||(u.startTime-r<1e3&&u.startTime-i<5e3?n+=u.value:(n=u.value,i=u.startTime),r=u.startTime,e=Math.max(e,n))},value:()=>e}}function bee(){let e=0;return{add(n){n.interactionId&&(e=Math.max(e,n.duration))},value:()=>e}}function vee(){if(typeof PerformanceObserver>"u")return;const e=new Set,n=(b,v)=>{e.has(b)||!Number.isFinite(v)||(e.add(b),nG(b,gee(b,v)))},i=(b,v,x={})=>{try{new PerformanceObserver(k=>v(k.getEntries())).observe({type:b,buffered:!0,...x})}catch{}};try{const b=performance.getEntriesByType("navigation")[0];b&&b.responseStart>0&&n("TTFB",b.responseStart)}catch{}i("paint",b=>{const v=b.find(x=>x.name==="first-contentful-paint");v&&n("FCP",v.startTime)});let r=0;i("largest-contentful-paint",b=>{const v=b.at(-1);v&&(r=v.startTime)});const u=yee();i("layout-shift",b=>{for(const v of b)u.add({startTime:v.startTime,value:v.value??0,hadRecentInput:v.hadRecentInput===!0})});const h=bee();i("event",b=>{for(const v of b)h.add(v)},{durationThreshold:40});const f=()=>{r>0&&n("LCP",r),n("CLS",u.value()),h.value()>0&&n("INP",h.value())};document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&f()}),window.addEventListener("pagehide",f)}const xee=6e4;function wee(){const e=C.useRef(RG()).current,[n,i]=C.useState(e?"ready":"checking"),[r,u]=C.useState(null),[h,f]=C.useState(null),[b,v]=C.useState(e),[x,k]=C.useState(!1),[S,N]=C.useState(""),[_,z]=C.useState(""),[q,E]=C.useState(""),[P,M]=C.useState(!1),[L,$]=C.useState("password"),[H,J]=C.useState(null),[V,F]=C.useState(!1),[ie,Ge]=C.useState(!1),We=C.useRef(null),$e=C.useRef(null),Pe=C.useRef(null),ke=()=>{const Y=r?`${r.name}:${r.role}`:e?"api-key:explicit":h?`api-key:${h.id}`:"no-accounts";if(!We.current||Pe.current!==Y){$e.current?.clear();const pe=SH();$e.current=pe,We.current=uee(pe),pee(We.current),Pe.current=Y}return{queryClient:$e.current,router:We.current}},Ue=Y=>Y.authRequired?(k(!0),u(Y.user),f(null),v(!1),i(Y.user?"ready":"account-login"),!0):!1;C.useEffect(()=>{let Y=!1;const pe=async(Oe,Ae=!1)=>{try{const st=await Of();if(Y)return;f(st),v(!1),i("ready")}catch(st){if(Y)return;if(Ae&&st instanceof Tn&&st.statusCode===401)return VG().then(()=>{Y||(J(null),f(null),v(!1),Ge(!0),i("login"))}).catch(Ve=>{Y||(J(Ve instanceof Error?Ve.message:"Could not clear the invalid session"),i(Oe))});J(st instanceof Error?st.message:"Could not verify API key access"),i(Oe)}};return e?(pe("api-key-error"),()=>{Y=!0}):(Promise.allSettled([sk(),ik()]).then(([Oe,Ae])=>{if(Y||Oe.status==="fulfilled"&&Ue(Oe.value))return;if(Ae.status==="rejected"){const Ve=Ae.reason;J(Ve instanceof Error?Ve.message:"Failed to reach the Canonry API"),i("login");return}const st=Ae.value;st.authenticated?(v(!0),pe("api-key-error",!0)):(f(null),v(!1),i(st.setupRequired?"setup":"login"))}),()=>{Y=!0})},[]),C.useEffect(()=>{if(n!=="ready"||e)return;const Y=setInterval(()=>{if(x){sk().then(pe=>{pe.authRequired&&!pe.user&&(Ge(!0),u(null),f(null),i("account-login"))}).catch(()=>{});return}ik().then(pe=>{pe.authenticated||(Ge(!0),f(null),i(pe.setupRequired?"setup":"login"))}).catch(()=>{})},xee);return ak(()=>{Ge(!0),u(null),f(null),v(!1),i(x?"account-login":"login")}),()=>{clearInterval(Y),ak(null)}},[n,x,e]);const B=async Y=>{if(Y.preventDefault(),!_.trim()||_.trim().length<8){J("Password must be at least 8 characters");return}if(_!==q){J("Passwords do not match");return}F(!0),J(null);try{if(!(await BG(_.trim())).authenticated){J("Setup failed");return}z(""),E(""),M(!1),Ge(!1),f(null),v(!0),i("checking");try{const Oe=await Of();f(Oe),v(!1),i("ready")}catch(Oe){J(Oe instanceof Error?Oe.message:"Could not verify API key access"),i("api-key-error")}}catch(pe){J(pe instanceof Tn||pe instanceof Error?pe.message:"Setup failed")}finally{F(!1)}},ee=Y=>{z(Y),J(null)},be=Y=>{E(Y),J(null)},je=async Y=>{if(Y.preventDefault(),!!_.trim()){F(!0),J(null);try{if(!(L==="api-key"?await UG(_.trim()):await LG(_.trim())).authenticated){J(L==="api-key"?"Invalid API key":"Incorrect password");return}const Oe=await Of();f(Oe),v(!1),z(""),M(!1),Ge(!1),i("ready")}catch(pe){J(pe instanceof Tn||pe instanceof Error?pe.message:"Authentication failed")}finally{F(!1)}}},te=Y=>{$(Y),z(""),M(!1),J(null)},_e=async Y=>{if(Y.preventDefault(),!(!S.trim()||!_)){F(!0),J(null);try{const pe=await $G(S.trim(),_);if(!pe.user){J("Incorrect name or password.");return}z(""),Ge(!1),u(pe.user),f(null),v(!1),i("ready")}catch(pe){J(pe instanceof Tn?pe.message:"Incorrect name or password.")}finally{F(!1)}}};if(n==="ready"){const{queryClient:Y,router:pe}=ke();return l.jsx(dH,{account:r,apiKey:h,apiKeyPending:b,children:l.jsx(P5,{client:Y,children:l.jsx(q5,{router:pe})})})}const qe=_.trim(),ve=_.length>0&&qe.length<8,de=q.length>0&&_!==q,ce=qe.length>=8&&_===q;return l.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:l.jsxs("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5",children:[l.jsxs("div",{"data-testid":"auth-brand",className:"flex items-center gap-2.5",children:[l.jsx("img",{className:"size-7",src:"./favicon.svg",alt:"","aria-hidden":"true"}),l.jsx("span",{className:"text-lg font-semibold tracking-tight text-heading",children:"Canonry"})]}),l.jsx(Ca,{className:"surface-card w-full",children:n==="checking"?l.jsx(go,{className:"py-8",children:l.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):n==="api-key-error"?l.jsxs(l.Fragment,{children:[l.jsxs(_r,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Could not verify API key access"})]}),l.jsxs(go,{className:"space-y-4",children:[l.jsx("p",{className:"supporting-copy",children:H??"Canonry could not verify this session’s access, so the dashboard stayed locked."}),l.jsx(le,{type:"button",className:"w-full",onClick:()=>{window.location.reload()},children:"Try again"})]})]}):n==="account-login"?l.jsxs(l.Fragment,{children:[l.jsxs(_r,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"})]}),l.jsxs(go,{children:[ie?l.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"You were signed out — please sign in again."}):null,l.jsxs("form",{className:"space-y-4",onSubmit:fn(_e),children:[l.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-name",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:"Name"}),l.jsx("input",{autoFocus:!0,id:"account-name",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"text",name:"username",autoComplete:"username",value:S,onChange:Y=>{N(Y.target.value),J(null)},"aria-invalid":!!H,"aria-describedby":H?"account-login-error":void 0})]}),l.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-password",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),l.jsx("input",{id:"account-password",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",name:"password",autoComplete:"current-password",value:_,onChange:Y=>ee(Y.target.value),"aria-invalid":!!H,"aria-describedby":H?"account-login-error":void 0})]}),H?l.jsx("p",{id:"account-login-error",role:"alert",className:"text-sm text-negative-400",children:H}):null,l.jsx(le,{type:"submit",disabled:V||!S.trim()||!_,children:V?"Signing in…":"Sign in"})]})]})]}):n==="setup"?l.jsxs(l.Fragment,{children:[l.jsxs(_r,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Create a dashboard password"}),l.jsx(dm,{children:"This password protects the dashboard on this computer."})]}),l.jsx(go,{children:l.jsxs("form",{className:"space-y-4",onSubmit:fn(B),children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-new",children:"Password"}),l.jsx("input",{autoFocus:!0,id:"dashboard-password-new",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"new-password",autoComplete:"new-password",minLength:8,required:!0,value:_,onChange:Y=>ee(Y.target.value),"aria-invalid":ve,"aria-describedby":"dashboard-password-new-help"}),l.jsx("span",{id:"dashboard-password-new-help","aria-live":"polite",className:ve?"block text-sm text-negative-400":"block text-sm text-secondary",children:ve?"Enter at least 8 characters.":"Use at least 8 characters."})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-confirm",children:"Confirm password"}),l.jsx("input",{id:"dashboard-password-confirm",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"confirm-password",autoComplete:"new-password",minLength:8,required:!0,value:q,onChange:Y=>be(Y.target.value),"aria-invalid":de,"aria-describedby":"dashboard-password-confirm-help"}),l.jsx("span",{id:"dashboard-password-confirm-help","aria-live":"polite",className:de?"block text-sm text-negative-400":"block text-sm text-secondary",children:de?"Passwords do not match.":"Enter the same password again."})]}),l.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-password-show",children:[l.jsx("input",{id:"dashboard-password-show",type:"checkbox",checked:P,onChange:Y=>M(Y.target.checked)}),"Show passwords"]}),H?l.jsx("p",{id:"dashboard-password-setup-error",role:"alert",className:"text-sm text-negative-400",children:H}):null,l.jsx(le,{type:"submit",disabled:V||!ce,children:V?"Creating password…":"Create password and continue"})]})})]}):l.jsxs(l.Fragment,{children:[l.jsxs(_r,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"}),l.jsx(dm,{children:L==="api-key"?"Enter an API key from this Canonry install. This opens the dashboard with that key’s access and does not change the password.":"Enter your dashboard password to continue."})]}),l.jsxs(go,{children:[ie?l.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"Your session expired — please sign in again."}):null,l.jsxs("form",{className:"space-y-4",onSubmit:fn(je),children:[l.jsxs("label",{className:"block space-y-1.5",htmlFor:"dashboard-password-current",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:L==="api-key"?"Canonry API key":"Password"}),l.jsx("input",{autoFocus:!0,id:"dashboard-password-current",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:L==="api-key"?"apiKey":"password",autoComplete:L==="api-key"?"off":"current-password",spellCheck:!1,required:!0,value:_,onChange:Y=>ee(Y.target.value),"aria-invalid":!!H,"aria-describedby":H?"dashboard-password-login-error":void 0})]}),l.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-login-password-show",children:[l.jsx("input",{id:"dashboard-login-password-show",type:"checkbox",checked:P,onChange:Y=>M(Y.target.checked)}),L==="api-key"?"Show API key":"Show password"]}),H?l.jsx("p",{id:"dashboard-password-login-error",role:"alert",className:"text-sm text-negative-400",children:H}):null,l.jsx(le,{type:"submit",disabled:V||!_.trim(),children:V?"Signing in…":"Open dashboard"}),l.jsx(le,{type:"button",variant:"ghost",onClick:()=>te(L==="api-key"?"password":"api-key"),children:L==="api-key"?"Use dashboard password instead":"Forgot password? Use API key"})]})]})]})})]})})}const jC=document.getElementById("root");if(!jC)throw new Error("Expected #root element for web app bootstrap.");mee();u6.createRoot(jC).render(l.jsx(C.StrictMode,{children:l.jsx(wee,{})}));export{Lae as $,Bn as A,le as B,bc as C,fn as D,oie as E,cie as F,lie as G,dne as H,la as I,pne as J,mne as K,ha as L,Die as M,_H as N,Fie as O,Zie as P,BZ as Q,$a as R,Yk as S,vn as T,OH as U,mte as V,Pne as W,Lne as X,qte as Y,Ine as Z,qae as _,Rie as a,Bne as a$,Bae as a0,Hte as a1,Gte as a2,nne as a3,xn as a4,$ae as a5,Kae as a6,Xte as a7,Gae as a8,Jte as a9,Tne as aA,Tn as aB,Ene as aC,_te as aD,TH as aE,MF as aF,y0 as aG,Rne as aH,Od as aI,die as aJ,T0 as aK,fo as aL,DH as aM,jt as aN,xH as aO,Jne as aP,BY as aQ,Zte as aR,fte as aS,pte as aT,Oi as aU,$ie as aV,ute as aW,Ate as aX,GP as aY,kte as aZ,cte as a_,Fte as aa,Yte as ab,Uae as ac,Vae as ad,Mae as ae,Qte as af,Hae as ag,Wae as ah,Zae as ai,Xae as aj,Yae as ak,Jae as al,vne as am,k1 as an,De as ao,Fae as ap,PN as aq,$i as ar,Qae as as,z0 as at,Y9 as au,X9 as av,Xee as aw,Yee as ax,kne as ay,_ne as az,IH as b,zee as b$,lte as b0,GH as b1,pQ as b2,iae as b3,cae as b4,sae as b5,bte as b6,xte as b7,FV as b8,wte as b9,bae as bA,Nae as bB,Cae as bC,_ae as bD,yae as bE,Aae as bF,vae as bG,Tae as bH,xae as bI,Eae as bJ,Sae as bK,Dae as bL,Oae as bM,NJ as bN,wae as bO,fe as bP,Fee as bQ,Qee as bR,Hee as bS,Gee as bT,Vee as bU,Uee as bV,Kee as bW,$ee as bX,Lee as bY,Bee as bZ,Dee as b_,nQ as ba,aae as bb,YV as bc,f0 as bd,vte as be,kG as bf,oae as bg,nae as bh,iQ as bi,rae as bj,Dne as bk,lae as bl,gie as bm,yie as bn,Wte as bo,RN as bp,uie as bq,EN as br,hae as bs,gae as bt,jae as bu,Iae as bv,zae as bw,kae as bx,Rae as by,Pae as bz,Zee as c,Zne as c$,Mee as c0,qee as c1,Pee as c2,Iee as c3,Oee as c4,Ree as c5,Eee as c6,Tee as c7,_ee as c8,O6 as c9,Gne as cA,SY as cB,A0 as cC,lm as cD,N0 as cE,cm as cF,um as cG,MY as cH,ZH as cI,yo as cJ,mm as cK,xQ as cL,qJ as cM,Yie as cN,qie as cO,PY as cP,Pie as cQ,EJ as cR,uae as cS,Qne as cT,Oie as cU,Xne as cV,Fne as cW,jI as cX,yP as cY,dae as cZ,Iie as c_,Ste as ca,Ote as cb,Ite as cc,zte as cd,une as ce,wG as cf,gj as cg,Cm as ch,yj as ci,gQ as cj,fae as ck,$ne as cl,hte as cm,mk as cn,Bte as co,Lte as cp,Une as cq,Vne as cr,Ute as cs,Vte as ct,Kte as cu,$te as cv,tu as cw,Oo as cx,yN as cy,Hne as cz,zH as d,o1 as d$,_ie as d0,GY as d1,zG as d2,MH as d3,HY as d4,Ete as d5,Rte as d6,Tte as d7,PG as d8,Mie as d9,mae as dA,pae as dB,NG as dC,Nte as dD,Cte as dE,Mte as dF,ene as dG,tne as dH,E1 as dI,Gm as dJ,N1 as dK,PJ as dL,cne as dM,Lr as dN,hk as dO,xne as dP,Sne as dQ,Ane as dR,Nne as dS,wne as dT,jne as dU,Cne as dV,Df as dW,bne as dX,hie as dY,kJ as dZ,yte as d_,Bie as da,Lie as db,Vie as dc,Dte as dd,KH as de,Pte as df,IZ as dg,eie as dh,QG as di,rne as dj,nie as dk,aie as dl,iie as dm,tie as dn,qne as dp,ane as dq,ine as dr,sne as ds,lne as dt,one as du,A1 as dv,Ns as dw,Dc as dx,Qie as dy,eu as dz,Kie as e,Kne as e0,mie as e1,fie as e2,yne as e3,gte as e4,fne as e5,gne as e6,hne as e7,pie as e8,One as e9,jie as eA,Cie as eB,Sie as eC,Nie as eD,Co as eE,rte as eF,ate as eG,Aie as eH,nte as eI,IO as eJ,ste as eK,ite as eL,GI as ea,Wne as eb,Yne as ec,tae as ed,eae as ee,Ak as ef,ote as eg,pw as eh,tte as ei,Gi as ej,Ra as ek,ete as el,im as em,jte as en,mF as eo,vie as ep,bie as eq,RJ as er,kie as es,VY as et,Jee as eu,Tie as ev,Eie as ew,xie as ex,wie as ey,Wee as ez,Jd as f,Uie as g,Gie as h,Hie as i,C0 as j,Lc as k,LZ as l,zie as m,rV as n,JK as o,zne as p,sie as q,rie as r,Mne as s,RH as t,C1 as u,Ca as v,dte as w,W as x,Lm as y,xo as z};
86
+ competitor2.com`,value:pi,onChange:Q=>Fi(Q.target.value)})]}),en?l.jsx("p",{className:"text-negative-400 text-sm",children:en}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:qn,children:"Back"}),l.jsx("div",{className:"flex gap-2",children:fi.length===0?l.jsx(le,{type:"button",onClick:yl,children:"Continue without competitors"}):l.jsxs(l.Fragment,{children:[l.jsx(le,{type:"button",variant:"outline",onClick:yl,children:"Skip"}),l.jsx(le,{type:"button",disabled:cl,onClick:fn(hl),children:cl?"Saving...":`Save ${fi.length} competitor${fi.length!==1?"s":""}`})]})})]})]})]});case 4:{const Q=Za.data,Fe=Q?.status??(Xi===We?.id?We.status:void 0),yi=Fe==="completed"||Fe==="partial"||Fe==="failed"||Fe==="cancelled",Wi=Q?.snapshots??[],Pa=Q?.queryCounts,vl=Fe?Jk(Fe,Wi.length):!1,jn=$e&&!Fa,bi=Sn??(Q?.error?TH(Q.error):Fe==="cancelled"?"The sweep was cancelled before it produced a baseline.":(Fe==="completed"||Fe==="partial")&&Wi.length===0?"The sweep finished without producing any snapshots.":We?.statusDetail||"The sweep did not produce a baseline.");let Ja=null;return jn||vl?Ja=l.jsx(vn,{tone:"positive",children:"Complete"}):Sn&&!Fa?Ja=l.jsx(vn,{tone:"negative",children:"Failed"}):yi?Ja=l.jsx(vn,{tone:"negative",children:Fe==="cancelled"?"Cancelled":"Failed"}):Fa&&(Ja=l.jsx(vn,{tone:"caution",children:"Running"})),l.jsxs(Ca,{className:"surface-card step-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:_?"Step 2 of 2":"Step 5 of 5"}),l.jsx("h2",{children:fo()?"AI Visibility":"Launch first run"})]}),Ja]}),jn?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-secondary",children:["Setup is complete. ",l.jsx("span",{className:"text-strong font-medium",children:He})," already has a successful answer-visibility baseline."]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:()=>ct(),children:f?"Finish setup":"Open project dashboard →"})]})]}):!Fa&&fo()?l.jsxs("div",{className:"compact-stack",children:[He?l.jsx(HY,{projectName:He}):l.jsx("p",{className:"text-sm text-secondary",children:T0}),Sn&&l.jsx("p",{role:"alert",className:"text-sm text-negative",children:Sn}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:Me,children:"Open project dashboard →"})]})]}):Fa?yi?vl?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",l.jsx("span",{className:"text-heading font-medium",children:He}),":"]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Mentioned"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Pa?l.jsxs(l.Fragment,{children:[Pa.mentionedQueries,l.jsxs("span",{className:"text-faint text-lg",children:[" / ",Pa.totalQueries]})]}):"Unavailable"}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries naming your brand"})]}),l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Cited"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Pa?l.jsxs(l.Fragment,{children:[Pa.citedQueries,l.jsxs("span",{className:"text-faint text-lg",children:[" / ",Pa.totalQueries]})]}):"Unavailable"}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries citing your site"})]}),l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Results"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Wi.length}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),!b&&He?l.jsx(OJ,{projectName:He}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:()=>ct(),children:f?"Finish setup":"Open project dashboard →"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:bi}),l.jsx("p",{className:"mt-1 text-xs text-secondary",children:fo()?T0:x?"Fix provider or query configuration if needed, then retry without leaving setup.":"Ask an administrator to review the provider and query configuration."})]}),l.jsxs("div",{className:"setup-nav",children:[x&&!fo()?l.jsx(le,{type:"button",variant:"outline",asChild:!0,children:l.jsx(tt,{to:"/settings",children:"Configure providers"})}):l.jsx("span",{}),fo()||!x?l.jsx(le,{type:"button",onClick:Me,children:"Open project dashboard →"}):l.jsx(le,{type:"button",disabled:hi||!!Ya,onClick:fn(gi),children:hi?"Retrying...":"Retry visibility sweep"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsx("p",{className:"text-neutral",children:"Sweep running. This usually takes 30 to 60 seconds."}),l.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:l.jsxs("p",{children:["Status: ",l.jsx("span",{className:"text-neutral",children:Fe??"queued"})]})}),Za.isError&&l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:Za.error instanceof Error?Za.error.message:"Could not refresh the sweep status."}),l.jsx(le,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{Za.refetch()},children:"Retry status check"})]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",variant:"outline",onClick:f?()=>ct():Me,children:f?"Finish setup":"Watch on project page"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"supporting-copy",children:["Your queries are saved. Run a first sweep to get a baseline for"," ",l.jsx("span",{className:"text-heading font-medium",children:He}),", or finish and run it later from the project. A sweep calls the answer engines, so it costs provider usage."]}),(Ya||Sn)&&l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:Sn??Ya}),l.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Resolve the blocker above, then retry the sweep here."})]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:qn,children:"Back"}),l.jsx(le,{type:"button",variant:"ghost",onClick:Qt,children:"Finish without running"}),ya==="no_provider"&&!_?l.jsx(le,{type:"button",asChild:!0,children:l.jsx(tt,{to:"/settings",children:"Configure a provider"})}):l.jsx(le,{type:"button",disabled:hi||!!Ya,title:Ya,onClick:fn(gi),children:hi?"Launching...":Sn?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return l.jsxs("div",{className:_?"page-container visibility-setup":"page-container",children:[f?l.jsx(Co,{current:"visibility"}):null,l.jsxs("div",{className:"page-header",children:[l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{ref:u?h:void 0,tabIndex:u?-1:void 0,className:"page-title",children:u?"Set up AI Visibility":"Setup"}),l.jsx("p",{className:"page-subtitle",children:u?"Connect an answer engine, then choose queries for your first sweep.":"Create a project and run its first visibility check."})]}),f?l.jsx("div",{className:"page-header-right",children:l.jsx(le,{type:"button",variant:"outline",className:"min-h-11",onClick:Qt,children:"Skip AI Visibility"})}):null]}),f?null:l.jsx(UJ,{current:_?B===4?1:0:B,labels:_?BJ:MJ}),l.jsxs("section",{className:"setup-wizard",children:[Qs,Xa]})]})}const Kf="canonry mcp install --client claude-code",KJ="https://github.com/Canonry/canonry/blob/main/docs/mcp.md";function GJ(){const e=C.useRef(p1()).current,n=C.useRef(new Set),i=C.useCallback((r,u)=>{n.current.has(r)||(n.current.add(r),b1({...u,flowVersion:ft,onboardingSessionId:e,surface:"platform",eventId:h1()}))},[e]);return C.useEffect(()=>{i("started",{event:"onboarding.started",step:"finish",resumed:!1})},[i]),C.useCallback(r=>{i(`action:${r}`,{event:"onboarding.step_completed",step:"finish",method:"manual",nextAction:r})},[i])}const Jm=C.createContext(()=>{});function HJ({projectName:e,skippedVisibility:n=!1}){const i=yt({...mF({client:W,path:{name:e}}),retry:!1}),r=i.data?.hasData?i.data:null,u=GJ(),h=tS(e,De["site-audit"]),f=tS(e,De["answer-visibility"]),b={...h?{site:h,fixes:h}:{},...QJ(f,n)};return l.jsx(Jm.Provider,{value:u,children:l.jsxs("div",{className:"page-container max-w-6xl py-8 md:py-10",children:[l.jsx(Co,{current:"done",outcomes:b}),l.jsxs("header",{className:"relative mx-auto mt-12 max-w-2xl text-center md:mt-16",children:[l.jsx(FJ,{}),l.jsx("p",{className:"onb-reveal mt-6 text-sm font-medium text-positive",style:_a(250),children:"Setup complete"}),l.jsx("h1",{className:"onb-reveal mt-2 text-5xl font-semibold tracking-tight text-heading md:text-6xl",style:_a(350),children:"You’re set."}),l.jsxs("p",{className:"onb-reveal mx-auto mt-4 max-w-xl text-lg text-secondary",style:_a(450),children:["Canonry is tracking ",l.jsx("span",{className:"font-medium text-heading",children:e}),". Here’s how to get the most out of it from here."]})]}),l.jsxs("div",{className:"mt-14 grid gap-4 md:grid-cols-6",children:[l.jsx(Cd,{className:"md:col-span-4 md:row-span-2",delayMs:600,labelledBy:"onb-agent-heading",children:l.jsx(XJ,{projectName:e})}),l.jsx(Cd,{className:"md:col-span-2 md:row-span-2",delayMs:700,labelledBy:"onb-data-heading",children:l.jsx(eW,{projectName:e})}),l.jsx(Cd,{className:"md:col-span-3",delayMs:800,labelledBy:"onb-schedule-heading",children:l.jsx(aW,{projectName:e})}),l.jsx(Cd,{className:"md:col-span-3",delayMs:900,labelledBy:"onb-alerts-heading",children:l.jsx(iW,{projectName:e,score:r?.aggregateScore??null})})]}),l.jsxs("div",{className:"onb-reveal mt-12 flex flex-col items-center gap-3 sm:flex-row sm:justify-center",style:_a(1e3),children:[l.jsx(le,{asChild:!0,className:"h-11 rounded-full px-6 text-base md:h-11",children:l.jsxs(tt,{to:"/projects/$projectName",params:{projectName:e},replace:!0,onClick:()=>u("open_project"),children:["Open ",e,l.jsx(Ac,{className:"size-4","aria-hidden":"true"})]})}),l.jsx(le,{asChild:!0,variant:"ghost",className:"h-11 rounded-full px-5 md:h-11",children:l.jsx(tt,{to:"/projects/$projectName/technical-aeo",params:{projectName:e},replace:!0,onClick:()=>u("review_page_health"),children:"Review page health"})})]})]})})}function tS(e,n){const i=yt({...EN({client:W,path:{name:e},query:{kind:n,limit:20}}),retry:!1,refetchInterval:r=>nS(r.state.status==="success"?{isSuccess:!0,data:r.state.data}:{isSuccess:!1})==="pending"?5e3:!1});return nS(i)}function QJ(e,n){return e===void 0?{}:n?{visibility:"skipped"}:{visibility:e}}function nS(e){if(!e.isSuccess||!e.data)return"unknown";const n=e.data.filter(i=>i.trigger!==Ua.probe);if(!n.some(i=>i.status===jt.completed||i.status===jt.partial))return n.some(i=>i.status===jt.queued||i.status===jt.running)?"pending":n.length>0?"incomplete":"skipped"}function _a(e){return{"--onb-delay":`${e}ms`}}function FJ(){return l.jsx("div",{className:"onb-check relative mx-auto size-20","aria-hidden":"true",children:l.jsxs("svg",{viewBox:"0 0 80 80",className:"relative size-20",children:[l.jsx("circle",{className:"onb-check-ring",cx:"40",cy:"40",r:"36",fill:"none",strokeWidth:"3",pathLength:"1"}),l.jsx("path",{className:"onb-check-mark",d:"M25 41 L35 51 L56 30",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",pathLength:"1"})]})})}function Cd({className:e="",delayMs:n,labelledBy:i,children:r}){return l.jsx("section",{"aria-labelledby":i,className:`onb-reveal onb-tile flex flex-col overflow-hidden rounded-2xl border border-default bg-surface p-6 md:p-7 ${e}`,style:_a(n),children:r})}function Wm({id:e,eyebrow:n,title:i,children:r}){return l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted",children:n}),l.jsx("h2",{id:e,className:"mt-1.5 text-2xl font-semibold tracking-tight text-heading",children:i}),l.jsx("p",{className:"mt-2 text-sm text-secondary",children:r})]})}const _d=[{id:"diagnose",label:"Diagnose",prompt:"Why did we lose citations this week?",calls:["canonry_insights_list","canonry_competitor_landscape"],reply:"Two engines started citing a competitor’s comparison page instead of yours. Want me to draft one that answers the same query?"},{id:"fix",label:"Fix",prompt:"Fix the weakest pages on the site.",calls:["canonry_technical_aeo_pages","canonry_site_health_page_audit"],reply:"The lowest-scoring pages are missing structured data and answer-first intros. I’ve written the changes for you to review."},{id:"automate",label:"Automate",prompt:"Re-check everything every Monday and tell me in Slack.",calls:["canonry_schedule_set","canonry_agent_webhook_attach"],reply:"Done. A sweep runs every Monday, and I’ll post what changed to Slack."}],ZJ=9e3;function YJ(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function XJ({projectName:e}){const n=C.useContext(Jm),[i,r]=C.useState(0),[u,h]=C.useState(!1),[f,b]=C.useState(!1);C.useEffect(()=>{if(u||YJ())return;const k=window.setTimeout(()=>r(S=>(S+1)%_d.length),ZJ);return()=>window.clearTimeout(k)},[i,u]);const v=async()=>{try{await navigator.clipboard.writeText(Kf),n("copy_agent_command"),b(!0),window.setTimeout(()=>b(!1),1800)}catch{xn({tone:"negative",title:"Could not copy the command",detail:`Run ${Kf} in your terminal.`})}},x=_d[i]??_d[0];return l.jsxs(l.Fragment,{children:[l.jsxs(Wm,{id:"onb-agent-heading",eyebrow:"Your agent",title:"Let your agent run it.",children:["Your agent can do everything in Canonry: diagnose a drop, fix pages, run sweeps and scans, and write the client report. Use Claude Code, Codex, Cursor, or Aero, the analyst built into"," ",l.jsx("span",{className:"text-heading",children:e})," that reviews every sweep on its own."]}),l.jsxs("div",{className:"mt-6 flex flex-1 flex-col rounded-xl border border-default bg-bg",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onFocus:()=>h(!0),children:[l.jsxs("div",{className:"flex items-center gap-1 border-b border-default px-3 py-2",role:"tablist","aria-label":"Example agent sessions",children:[_d.map((k,S)=>l.jsx("button",{type:"button",role:"tab","aria-selected":S===i,onClick:()=>{r(S),h(!0)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${S===i?"bg-surface-inset text-heading":"text-muted hover:text-secondary"}`,children:k.label},k.id)),l.jsx("span",{className:"ml-auto text-xs text-faint",children:"Example"})]}),l.jsxs("div",{role:"tabpanel","aria-label":`${x.label} example`,className:"flex-1 p-4 font-mono text-[13px] leading-relaxed",children:[l.jsxs("p",{className:"onb-type text-heading",style:_a(150),children:[l.jsx("span",{className:"text-muted",children:"> "}),x.prompt]}),x.calls.map((k,S)=>l.jsxs("p",{className:"onb-line mt-1 text-muted first:mt-3",style:_a(1300+S*450),children:[l.jsx("span",{className:"text-positive",children:"●"})," ",k]},k)),l.jsx("p",{className:"onb-line mt-3 text-secondary",style:_a(1500+x.calls.length*450),children:x.reply}),l.jsx("span",{className:"onb-caret mt-2 inline-block h-4 w-2 bg-current align-middle text-secondary",style:_a(1900+x.calls.length*450),"aria-hidden":"true"})]},x.id)]}),l.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[l.jsx("code",{className:"min-w-0 flex-1 truncate rounded-lg border border-default bg-surface-inset px-3 py-2 font-mono text-[13px] text-heading",children:Kf}),l.jsxs(le,{type:"button",variant:"secondary",size:"sm",className:"h-9 md:h-9",onClick:()=>{v()},children:[f?l.jsx(Pc,{className:"size-4","aria-hidden":"true"}):l.jsx(V0,{className:"size-4","aria-hidden":"true"}),f?"Copied":"Copy"]}),l.jsx("a",{href:KJ,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-link underline-offset-4 hover:underline",children:"Other clients"})]})]})}const JJ=[{icon:U0,label:"Search Console",action:"connect_search_console",to:"/projects/$projectName/search-console"},{icon:bS,label:"Google Analytics",action:"connect_analytics",to:"/projects/$projectName/activity"},{icon:xS,label:"Business Profile",action:"connect_business_profile",to:"/projects/$projectName/local"}],WJ=["GPTBot","ClaudeBot","PerplexityBot"];function eW({projectName:e}){const n=C.useContext(Jm);return l.jsxs(l.Fragment,{children:[l.jsx(Wm,{id:"onb-data-heading",eyebrow:"Server-side traffic",title:"See the AI bots.",children:"AI crawlers and answer-engine fetches never run JavaScript, so Google Analytics never sees them. Canonry reads them straight from your server."}),l.jsx(tW,{}),l.jsxs(tt,{to:"/traffic",onClick:()=>n("connect_server_traffic"),"aria-label":"Connect server-side traffic",className:"group flex items-center gap-3 rounded-xl border border-strong bg-surface-inset px-4 py-3 text-sm font-medium text-heading transition-colors hover:bg-surface-inset-hover",children:[l.jsx(wS,{className:"size-4 text-positive","aria-hidden":"true"}),l.jsxs("span",{className:"flex-1",children:["Connect your server",l.jsx("span",{className:"block text-xs font-normal text-secondary",children:"Cloudflare, Vercel, WordPress, or Cloud Run"})]}),l.jsx(Ac,{className:"size-4 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]}),l.jsx("p",{className:"mt-5 text-xs font-medium uppercase tracking-wide text-muted",children:"Also connect"}),l.jsx("ul",{className:"mt-1 divide-y divide-default",children:JJ.map(({icon:i,label:r,action:u,to:h})=>l.jsx("li",{children:l.jsxs(tt,{to:h,params:{projectName:e},"aria-label":`Connect ${r}`,onClick:()=>n(u),className:"group flex items-center gap-3 py-2.5 text-sm text-heading",children:[l.jsx(i,{className:"size-4 text-muted","aria-hidden":"true"}),l.jsx("span",{className:"flex-1",children:r}),l.jsx(Ac,{className:"size-3.5 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})},r))})]})}function tW(){const e=[22,70,118];return l.jsxs("div",{className:"relative my-6 h-36","aria-hidden":"true",children:[l.jsx("svg",{viewBox:"0 0 200 140",preserveAspectRatio:"none",className:"absolute inset-0 size-full",children:e.map((n,i)=>l.jsx("path",{className:"onb-flow",style:_a(i*400),d:`M20 ${n} C 100 ${n}, 118 70, 170 70`,fill:"none",strokeWidth:"1.5"},n))}),WJ.map((n,i)=>l.jsx("span",{className:"onb-bot absolute left-0 -translate-y-1/2 rounded-md border border-default bg-bg-elevated px-2 py-1 font-mono text-[11px] text-secondary",style:{top:`${(e[i]??70)/140*100}%`,..._a(i*600)},children:n},n)),l.jsx("span",{className:"onb-hub absolute right-0 top-1/2 flex size-11 -translate-y-1/2 items-center justify-center rounded-2xl bg-accent text-on-inverse",children:l.jsx(wS,{className:"size-5"})})]})}const nW=["M","T","W","T","F","S","S"];function aW({projectName:e}){return l.jsxs(l.Fragment,{children:[l.jsx(Wm,{id:"onb-schedule-heading",eyebrow:"Scheduled sweeps",title:"Runs on its own.",children:"Re-measure every week without lifting a finger, so a drop shows up before a customer notices."}),l.jsx("ol",{className:"mt-6 grid grid-cols-7 gap-2","aria-hidden":"true",children:nW.map((n,i)=>l.jsxs("li",{className:"flex flex-col items-center gap-2",children:[l.jsx("span",{className:"onb-day size-3 rounded-full bg-surface-inset",style:_a(i*500)}),l.jsx("span",{className:"text-xs text-muted",children:n})]},i))}),l.jsx(xC,{projectName:e,to:"/projects/$projectName/settings",icon:vS,label:"Set a schedule",action:"set_schedule"})]})}function iW({projectName:e,score:n}){return l.jsxs(l.Fragment,{children:[l.jsx(Wm,{id:"onb-alerts-heading",eyebrow:"Notifications",title:"Hear about changes.",children:"Get a webhook in Slack or anywhere else when a sweep finishes or a score moves."}),l.jsxs("div",{className:"relative mt-6 flex h-14 items-center","aria-hidden":"true",children:[l.jsx("span",{className:"onb-bell flex size-10 items-center justify-center rounded-full border border-default bg-bg-elevated",children:l.jsx(Qf,{className:"size-4 text-secondary"})}),l.jsxs("span",{className:"onb-toast ml-3 flex items-center gap-2 rounded-xl border border-default bg-bg-elevated px-3 py-2 text-sm shadow-[0_8px_24px_var(--color-shadow-panel)]",children:[l.jsx("span",{className:"size-2 rounded-full bg-positive-400"}),l.jsx("span",{className:"text-heading",children:e}),l.jsx("span",{className:"text-secondary",children:n===null?"sweep finished":`page health ${n}`})]})]}),l.jsx(xC,{projectName:e,to:"/projects/$projectName/settings",icon:Qf,label:"Add a notification",action:"add_notification"})]})}function xC({projectName:e,to:n,icon:i,label:r,action:u}){const h=C.useContext(Jm);return l.jsxs(tt,{to:n,params:{projectName:e},onClick:()=>h(u),className:"group mt-6 inline-flex items-center gap-2 self-start text-sm font-medium text-link",children:[l.jsx(i,{className:"size-4","aria-hidden":"true"}),r,l.jsx(Ac,{className:"size-3.5 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})}const sW=C.lazy(async()=>({default:(await Gi(()=>import("./SiteHealthSection-DMHWsfM4.js").then(n=>n.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),oW=`Public pages only, crawled from this computer and stored locally. The first scan reads up to ${yj} pages, then stops.`,rW=1800,lW="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",cW="Help me set up Canonry for my public site.\n\nUse the official Canonry docs:\n- Agent quickstart: https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent\n- CLI reference: https://github.com/Canonry/canonry/blob/main/skills/canonry/references/canonry-cli.md\n- Plugin setup: https://github.com/Canonry/canonry/blob/main/docs/plugins.md\n- MCP setup: https://github.com/Canonry/canonry/blob/main/docs/mcp.md\n\nPick one path and stay on it. Use connected Canonry tools (plugin or MCP) only if you have them and I have not pointed you at a specific install. A connected tool runs in its own process and never sees `CANONRY_CONFIG_DIR`, `CANONRY_PORT`, or anything else you export in a shell, so it always acts on my default install. If I named a config directory, a port, or a sandbox, that is the shell path: use `cnry` and tell me which path you chose. Never mix the two in one run, and never create a duplicate project. The `cnry` and `canonry` commands are interchangeable.\n\n1. Ask for my public domain, country, and language. Do not create or scan anything yet. Country and language are only applied when a project is created, so if you reuse an existing project, report its country and language instead of changing them.\n2. Shell path only: confirm `cnry` is on PATH, then run `cnry --version`. If Canonry is missing, propose `npm install -g @canonry/canonry` and wait for approval. Then run `cnry doctor --format json`, which is the command that says whether config, database, and server are in place. `cnry --version` does not read config and succeeds on a completely unconfigured install, so it cannot answer this. If config is missing, run `cnry bootstrap` yourself: it is not interactive, takes about a second, and is safe to rerun. Do not hand it to me and wait. The interactive command is `cnry init`, which is optional provider and OAuth setup that Page Health does not need. Bootstrap prints an API key, so do not repeat its output back to me, and never ask me to paste passwords, API keys, OAuth credentials, or command output.\n3. Confirm the API is reachable. `cnry doctor --format json` reports it, and any project read exits non-zero with `CONNECTION_ERROR` when it is not. If it is unreachable, propose `cnry start` and wait for approval. Use `cnry start`, which is the background daemon, and not `cnry serve`, which runs in the foreground and will block you until I stop it, even though some error messages suggest it. Stop anything you started with `cnry stop`.\n4. List projects with the connected project tool or `cnry project list --format json`, and reuse one whose domain matches. Confirm the proposed name is not already assigned to a different domain. To find out whether a project has already been scanned, run `cnry technical-aeo score <project> --format json` with no `--run-id`, which reports the latest run. Read the `hasData` field, not the score: this command exits 0 and reports `aggregateScore: 0` for a project that has never been scanned, so reading the score alone would have you tell me my site scored zero. If `hasData` is true and `runStatus` is `completed` or `partial`, read that scan instead of starting a new one. If no project matches, show the exact create operation and wait for approval.\n5. Propose a bounded Site Health scan: `--max-pages 100` for a first look, plus whether dead-link checking is on (it is off unless you pass `--check-dead-links`). Show the connected operation or the exact `cnry technical-aeo run <project> --max-pages 100 --wait --format json` command with the project name filled in, and wait for separate approval before scanning. `--wait` polls for up to 15 minutes and returns only the run id and status. If the status it returns is still `queued` or `running`, the scan has not finished: do not rerun it or report results, poll `cnry technical-aeo progress <project> --run-id <run-id> --format json` until it is terminal. If `--wait` outruns your own tool timeout first, recover the run id with `cnry technical-aeo score <project> --format json` and poll the same way.\n6. When the run is `completed` or `partial`, read `cnry technical-aeo crawl <project> --run-id <run-id> --format json` first. It is the only one of these commands that carries `termination` and `complete`; the score and pages commands do not. Then read `cnry technical-aeo score <project> --run-id <run-id> --format json` and `cnry technical-aeo pages <project> --run-id <run-id> --sort score-asc --limit 10 --format jsonl`. Tell me the termination reason in plain words and whether the scan covered the whole site or stopped at a page, link, depth, or time limit. A `partial` run scored the pages it reached and not my site, so never present it as a full-site result. If it stopped early, the fix depends on the reason, so say which: a page or depth limit needs a larger budget, a time limit needs a smaller scan (a lower `--max-pages` or `--max-depth`). If the run failed or was cancelled, inspect the run error and stop.\n7. Summarize only completed evidence, then propose AI Visibility setup. Ask before you add queries, connect providers, start a provider-backed or quota-consuming run, edit files, or publish.";function uW(e,n){return e==="legacy"?"legacy":e==="platform"?"platform":n.state==="success"?n.projectCount===0?"platform":"legacy":n.state==="error"?"retry":"loading"}const dW="2000-01-01T00:00:00.000Z",mW=5e3;function pW(e,n){const i=new Set,r=new Map;for(const f of n)f.trigger!==Ua.probe&&(r.has(f.projectId)||r.set(f.projectId,f.id),(f.status===jt.completed||f.status===jt.partial)&&i.add(f.projectId));const h=(e.every(f=>f.createdAt)?[...e].sort((f,b)=>(f.createdAt??"").localeCompare(b.createdAt??"")||f.name.localeCompare(b.name)):e).find(f=>!i.has(f.id));return h?{projectName:h.name,runId:r.get(h.id)}:null}const wC=[{value:"US",label:"United States"},{value:"CA",label:"Canada"},{value:"GB",label:"United Kingdom"},{value:"AU",label:"Australia"},{value:"NZ",label:"New Zealand"},{value:"IE",label:"Ireland"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"ES",label:"Spain"},{value:"IT",label:"Italy"},{value:"NL",label:"Netherlands"},{value:"BR",label:"Brazil"},{value:"MX",label:"Mexico"},{value:"IN",label:"India"},{value:"SG",label:"Singapore"},{value:"JP",label:"Japan"}],kC=[{value:"en",label:"English"},{value:"es",label:"Spanish"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"it",label:"Italian"},{value:"pt",label:"Portuguese"},{value:"nl",label:"Dutch"},{value:"ja",label:"Japanese"}];function hW(e,n){try{const i=new Intl.DisplayNames(["en"],{type:"region"}),r=new Intl.DisplayNames(["en"],{type:"language"}),u=e.length===2?i.of(e.toUpperCase()):void 0,h=n?r.of(n.toLowerCase()):void 0;return`${u??(e||"Country")} · ${h??(n||"Language")}`}catch{return`${e||"Country"} · ${n||"Language"}`}}function fW(e,n){const i=e.trim().toUpperCase(),r=n.trim().toLowerCase();return{countryValid:wC.some(u=>u.value===i),languageValid:kC.some(u=>u.value===r)}}function gW(e){const n=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(n)||n.includes(":")}function yW(e){const n=e.trim();if(!n)return null;const i=/^[a-z][a-z\d+.-]*:\/\//i.test(n)?n:`https://${n}`;let r;try{r=new URL(i)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:")return null;const u=r.hostname.toLowerCase().replace(/^www\./,"");if(!u||u==="localhost"||gW(u)||!u.includes("."))return null;const h=u.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return h?{canonicalDomain:u,projectName:h,displayName:u}:null}async function bW(e,n=rW){let i;const r=new Promise(h=>{i=setTimeout(()=>h({state:"timed-out"}),n)}),u=await Promise.race([e.then(h=>({state:"queued",run:h})),r]);return i&&clearTimeout(i),u}function vW(e,n){e.catch(()=>{xn({title:"Site Health scan did not start",detail:"The project is safe. Choose Run scan in Site Health to retry.",tone:"negative",dedupeKey:`site-health-dispatch:${n}`})})}function SC(e){const n=C.useRef(p1()).current,i=C.useRef(new Set),r=C.useCallback((u,h)=>{if(h){if(i.current.has(h))return;i.current.add(h)}b1({...u,surface:e,eventId:h1()})},[e]);return{onboardingSessionId:n,emit:r}}function aS(e,n){return e instanceof Tn&&e.statusCode===409?"A project with this name already exists. Change the project name, or open the existing project.":e instanceof Error&&e.message?e.message:n}function P0(){return l.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Preparing setup"}),l.jsx("p",{className:"page-subtitle",children:"Checking the projects already on this install."})]})}),l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary",role:"status",children:[l.jsx(Cs,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function xW({onRetry:e}){return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Can’t load projects"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not confirm whether this install already has a project."})]})}),l.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:"Setup is paused to protect existing projects."}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function wW({projectName:e,initialRunId:n}){return l.jsx(E1,{title:"Site Health setup",children:l.jsx(kW,{projectName:e,initialRunId:n})})}function kW({projectName:e,initialRunId:n}){const i=Es(),r=yt({...Oo({client:W}),enabled:!!e,retry:!1,refetchOnMount:"always"}),{onboardingSessionId:u,emit:h}=SC("site_health"),[f]=C.useState(()=>LK(n));C.useEffect(()=>{f&&UK()},[f]),C.useEffect(()=>{e&&h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.started",step:"run",resumed:!!n&&!f},"onboarding.started")},[h,f,n,u,e]),C.useEffect(()=>{!e||!n||dN(e)?.runId!==n&&uN(e,n)},[n,e]);const v=yt({...w1({client:W,path:{id:n??""}}),enabled:!!n,refetchInterval:({state:_})=>{const z=_.data?.status;return z==="completed"||z==="partial"||z==="failed"||z==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if(C.useEffect(()=>{if(!e||!n||!v)return;if(v==="completed"||v==="partial"){h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"automatic"},"onboarding.step_completed:run"),nm(n);return}if(v!=="failed"&&v!=="cancelled")return;const _=v==="cancelled"?"run_cancelled":"run_failed";h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:_},`onboarding.blocked:run:${_}`),nm(n)},[h,n,u,e,v]),!e)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project not found"}),l.jsx("p",{className:"page-subtitle",children:"This setup link does not identify a project."})]})}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});if(r.isPending)return l.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[l.jsx(Co,{current:"site"}),l.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[l.jsx(Cs,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health setup…"]})]});if(r.isError)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Can’t resume setup"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project for this Site Health scan."})]})}),l.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[l.jsx("p",{className:"text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const x=r.data.find(_=>_.name===e);if(!x)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project not found"}),l.jsxs("p",{className:"page-subtitle",children:["Canonry could not find ",e,". It will not open a different project."]})]})}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});const k=()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:x.name},replace:!0})},S=()=>{i({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:x.name},replace:!0})},N=()=>{h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"skipped"},"onboarding.step_completed:run"),i({to:"/setup",search:{onboarding:"complete",setupProject:x.name,skipped:"visibility"},replace:!0})};return l.jsxs("div",{className:"page-container max-w-7xl py-8 md:py-10",children:[l.jsx("h1",{className:"sr-only",children:"Set up Canonry"}),l.jsx(C.Suspense,{fallback:l.jsxs("div",{className:"space-y-5",children:[l.jsx(Co,{current:"site"}),l.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-3 text-sm text-secondary",role:"status",children:[l.jsx(Cs,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:l.jsx(sW,{projectName:x.name,projectId:x.id,initialRunId:n,onReleaseInitialRun:k,showOnboardingActions:!0,onContinueOnboarding:S,onSkipOnboarding:N})})]})}function SW(){const e=oS({from:"/setup"}),n=e.onboarding==="site-health"&&!e.setupProject,i=e.onboarding==="site-health"&&e.experience!=="legacy",r=hG(),u=e.experience==="legacy"?"legacy":e.experience==="platform"?"platform":r,[h,f]=C.useState(!1),[b,v]=C.useState(void 0),x=yt({...Oo({client:W}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),k=yt({...Dc({client:W,query:{kind:De["site-audit"],since:dW,limit:mW}}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),S=u==="auto"&&x.isSuccess&&x.isFetchedAfterMount&&x.data.length===0;C.useEffect(()=>{S&&f(!0)},[S]);const N=u!=="auto"?{state:"idle"}:x.isSuccess&&x.isFetchedAfterMount?{state:"success",projectCount:x.data.length}:x.isError?{state:"error"}:{state:"loading"},_=u==="legacy"?"legacy":h||S?"platform":uW(u,N);if(e.onboarding==="complete"&&e.setupProject)return l.jsx(HJ,{projectName:e.setupProject,skippedVisibility:e.skipped==="visibility"});if(n||i)return l.jsx(wW,{projectName:e.setupProject,initialRunId:e.siteHealthRunId});const z=u==="auto"&&_==="legacy"&&!e.setupProject&&x.isSuccess;if(z&&b===void 0)return k.isError?v(null):k.isSuccess&&k.isFetchedAfterMount&&v(pW(x.data,k.data)),l.jsx(P0,{});const q=z?b:null;return q?l.jsx(jW,{projectName:q.projectName,runId:q.runId}):_==="legacy"?l.jsx(VJ,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health",onboardingFinish:e.onboarding==="site-health"||e.onboarding==="first-run"}):_==="loading"?l.jsx(P0,{}):_==="retry"?l.jsx(xW,{onRetry:()=>{x.refetch()}}):l.jsx(AW,{onActivationStarted:()=>f(!0),skipSiteScan:e.siteScan==="skip"})}function jW({projectName:e,runId:n}){const i=Es();return C.useEffect(()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:e,...n?{siteHealthRunId:n}:{}},replace:!0})},[i,e,n]),l.jsx(P0,{})}function AW({onActivationStarted:e,skipSiteScan:n}){return l.jsx(E1,{title:"Site Health setup",children:l.jsx(NW,{onActivationStarted:e,skipSiteScan:n})})}function NW({onActivationStarted:e,skipSiteScan:n}){const i=Es(),r=_o(),u=RJ(),h=yt({...yQ({client:W}),retry:!1}),f=ii(bQ()),[b,v]=C.useState(""),[x,k]=C.useState(""),[S,N]=C.useState(""),[_,z]=C.useState("US"),[q,E]=C.useState("en"),[P,M]=C.useState(!1),[L,$]=C.useState("idle"),[H,J]=C.useState(null),[V,F]=C.useState(null),[ie,Ge]=C.useState(!1),[We,$e]=C.useState(null),[Pe,ke]=C.useState(!1),Ue=h.isError?void 0:h.data,B=typeof Ue?.enabled=="boolean"?Ue.enabled:null,ee=f.isPending?f.variables.body.enabled:B,[be,je]=C.useState(null),te=C.useRef(null),{onboardingSessionId:_e,emit:qe}=SC("platform");C.useEffect(()=>{qe({flowVersion:ft,onboardingSessionId:_e,event:"onboarding.started",step:"project",resumed:!1},"onboarding.started")},[qe,_e]);const ve=yW(b),de=x||ve?.projectName||"",ce=S||ve?.displayName||"",Y=L==="creating"||L==="dispatching",pe=V??We,Oe=hW(_,q),{countryValid:Ae,languageValid:st}=fW(_,q),Ve=Ae&&st;C.useEffect(()=>{pe&&te.current?.focus()},[pe]);const Nt=(Me,ct)=>i({to:"/setup",search:{...ct?{siteHealthRunId:ct}:{},onboarding:"site-health",setupProject:Me.name},replace:!0}),He=async Me=>{$("dispatching"),$e(null);try{const ct=u.mutateAsync({projectName:Me.name,projectId:Me.id,projectLabel:Me.displayName||Me.name,suppressErrorToast:!0,body:{checkDeadLinks:!0,maxPages:yj}}),Qt=await bW(ct);if(Qt.state==="queued"){qe({flowVersion:ft,onboardingSessionId:_e,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"}),BK(Qt.run.runId),await Nt(Me,Qt.run.runId);return}ct.then(()=>{qe({flowVersion:ft,onboardingSessionId:_e,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"})},Ft=>{qe({flowVersion:ft,onboardingSessionId:_e,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:wc(Ft,"run_rejected")})}),vW(ct,Me.id),await Nt(Me)}catch(ct){$("recovery"),$e(aS(ct,"The project was created, but the Site Health scan could not be started."));const Qt=wc(ct,"run_rejected");qe({flowVersion:ft,onboardingSessionId:_e,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Qt}),qe({flowVersion:ft,onboardingSessionId:_e,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:Qt},`onboarding.blocked:run:${Qt}`)}},me=async Me=>{if(Me.preventDefault(),!(!ve||!n&&!P||!Ve||Y)){$("creating"),F(null),Ge(!1),$e(null);try{const ct=await IG({name:de,displayName:ce,canonicalDomain:ve.canonicalDomain,country:_,language:q});if(e(),J(ct),qe({flowVersion:ft,onboardingSessionId:_e,event:"onboarding.step_completed",step:"project",method:"manual"},"onboarding.step_completed:project"),await r.invalidateQueries({queryKey:Br({client:W})}),n){await i({to:"/setup",search:{experience:"legacy",onboarding:"first-run",setupProject:ct.name},replace:!0});return}await He(ct)}catch(ct){$("idle");const Qt=ct instanceof Tn&&ct.statusCode===409;Ge(Qt),F(aS(ct,"Could not create the project. Try again.")),qe({flowVersion:ft,onboardingSessionId:_e,event:"onboarding.blocked",step:"project",action:"save",reasonCode:wc(ct,"project_create_failed")},"onboarding.blocked:project"),Qt&&(e(),r.invalidateQueries({queryKey:Br({client:W})}))}}},at=()=>{H&&!Y&&He(H)},It=()=>{Y||i({to:"/projects"})},Pn=async()=>{try{await navigator.clipboard.writeText(cW),ke(!0)}catch{xn({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}},Ht=async Me=>{je(null);try{const ct=await f.mutateAsync({client:W,body:{enabled:Me}});r.setQueryData(DN({client:W}),ct),ct.enabled!==Me&&je(`The server kept telemetry ${ct.enabled?"on":"off"}. Check its telemetry settings.`)}catch{je("Could not update telemetry. Try again.")}};return H&&L==="recovery"?l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx(Co,{current:"site"}),l.jsx("div",{className:"page-header mt-8",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project created"}),l.jsxs("p",{className:"page-subtitle",children:[H.displayName||H.name," is ready. The Site Health scan needs another try."]})]})}),l.jsxs("div",{ref:te,className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:We}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"You can retry the scan or continue setup and retry from Site Health."}),l.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[l.jsx(le,{type:"button",onClick:at,children:"Retry Site Health scan"}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{Nt(H)},children:"Continue setup"})]})]})]}):l.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[n?null:l.jsx(Co,{current:"site"}),l.jsxs("header",{className:`mb-8 ${n?"":"mt-8"}`,children:[l.jsx("h1",{id:"site-map-setup-title",className:"text-2xl font-semibold tracking-[-0.025em] text-heading",children:n?"Create a project":"Scan your site"}),l.jsx("p",{className:"mt-2 max-w-lg text-sm leading-6 text-secondary",children:n?"Add a public domain, then choose the queries you want to track. No site scan will run.":"Enter your public website to see its pages, structure, internal links, and technical SEO scores."})]}),l.jsxs("form",{"aria-labelledby":"site-map-setup-title",className:"space-y-6",onSubmit:fn(me),noValidate:!0,children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm font-medium text-heading",htmlFor:"launchpad-domain",children:"Website URL"}),l.jsx("input",{id:"launchpad-domain",className:"h-11 w-full rounded-md border border-strong bg-bg-elevated/50 px-3 text-base text-heading outline-none transition placeholder:text-muted focus:border-mono-500 focus:ring-1 focus:ring-mono-500",type:"text",inputMode:"url",autoComplete:"url",autoCapitalize:"none",spellCheck:!1,required:!0,"aria-invalid":!!(b&&!ve),"aria-describedby":b&&!ve?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:b,onChange:Me=>{v(Me.target.value),F(null),Ge(!1)}}),l.jsx("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:n?l.jsxs(l.Fragment,{children:["A public domain is still required."," ",l.jsx(tt,{to:"/setup",search:{experience:"platform"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Map with Site Health instead"})]}):l.jsxs(l.Fragment,{children:["Only public pages are scanned."," ",l.jsx(tt,{to:"/setup",search:{experience:"platform",onboarding:"first-run",siteScan:"skip"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Set up without a site scan"})]})}),b&&!ve?l.jsx("p",{id:"launchpad-domain-error",className:"text-sm text-negative",role:"alert",children:"Enter a public domain, such as example.com."}):null]}),l.jsxs("details",{className:"group border-y border-default",children:[l.jsxs("summary",{className:"flex min-h-11 cursor-pointer list-none items-center justify-between gap-4 py-3 text-sm [&::-webkit-details-marker]:hidden",children:[l.jsx("span",{className:"font-medium text-heading",children:"Project name and locale"}),l.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[Oe,l.jsx(Oc,{className:"size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none","aria-hidden":"true"})]})]}),l.jsxs("div",{className:"space-y-5 border-t border-default py-4",children:[ve?l.jsxs("div",{children:[l.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Project"}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-project-name",children:"Project name"}),l.jsx("input",{id:"launchpad-project-name",className:"setup-input h-10",type:"text",value:de,onChange:Me=>k(Me.target.value)})]}),l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-display-name",children:"Display name"}),l.jsx("input",{id:"launchpad-display-name",className:"setup-input h-10",type:"text",value:ce,onChange:Me=>N(Me.target.value)})]})]})]}):null,l.jsxs("div",{children:[l.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Locale"}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-country",children:"Country"}),l.jsx("select",{id:"launchpad-country",className:"setup-input h-10",value:_,onChange:Me=>z(Me.target.value),children:wC.map(Me=>l.jsx("option",{value:Me.value,children:Me.label},Me.value))})]}),l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-language",children:"Language"}),l.jsx("select",{id:"launchpad-language",className:"setup-input h-10",value:q,onChange:Me=>E(Me.target.value),children:kC.map(Me=>l.jsx("option",{value:Me.value,children:Me.label},Me.value))})]})]})]})]})]}),n?null:l.jsxs("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 py-2",children:[l.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg",type:"checkbox",checked:P,onChange:Me=>M(Me.target.checked),"aria-label":"Allow Canonry to scan this public site."}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),l.jsx(la,{text:oW})]})]}),pe?l.jsxs("div",{ref:te,className:"rounded-md border border-negative bg-negative-soft p-3",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:pe}),ie?l.jsx(le,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:It,children:"View projects"}):null]}):null,l.jsxs("div",{className:"grid gap-2",children:[l.jsx(le,{className:"h-11 w-full",type:"submit",disabled:!ve||!n&&!P||!Ve||Y,children:L==="creating"||L==="dispatching"?l.jsxs(l.Fragment,{children:[l.jsx(Cs,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," ",n?"Creating project…":"Mapping site…"]}):n?"Create project":"Scan site"}),L==="dispatching"?l.jsx("span",{className:"text-center text-sm text-secondary",role:"status",children:"Opening Site Health when the scan is ready."}):null]})]}),l.jsxs("section",{className:"mt-8 border-t border-default pt-6","aria-labelledby":"agent-setup-title",children:[l.jsx("p",{id:"agent-setup-title",className:"text-sm font-medium text-heading",children:"Use your agent instead"}),l.jsx("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"Copy a complete CLI setup request into any agent."}),l.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[l.jsxs(le,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:fn(Pn),children:[Pe?l.jsx(Pc,{className:"size-3.5","aria-hidden":"true"}):l.jsx(V0,{className:"size-3.5","aria-hidden":"true"}),l.jsx("span",{"aria-live":"polite",children:Pe?"Copied setup request":"Copy setup request"})]}),l.jsx(le,{asChild:!0,variant:"ghost",size:"sm",children:l.jsxs("a",{href:lW,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",l.jsx(n6,{className:"size-3.5","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]}),B!==null?l.jsxs("section",{className:"mt-6 border-t border-default pt-5","aria-labelledby":"telemetry-title",children:[l.jsxs("label",{className:`flex min-h-11 items-start gap-3 py-2 ${f.isPending?"cursor-wait":"cursor-pointer"}`,children:[l.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg accent-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mono-500 disabled:cursor-wait",type:"checkbox",checked:ee??!1,disabled:f.isPending,onChange:Me=>{Ht(Me.target.checked)},"aria-describedby":"telemetry-detail"}),l.jsxs("span",{className:"grid gap-0.5",children:[l.jsx("span",{id:"telemetry-title",className:"text-sm leading-5 text-heading",children:"Share anonymous product telemetry"}),l.jsx("span",{id:"telemetry-detail",className:"max-w-[70ch] text-sm leading-5 text-secondary",children:"Helps prioritize improvements. Canonry does not send raw domains, URLs, queries, answer content, or credentials."})]})]}),f.isPending?l.jsx("p",{className:"mt-1 text-sm text-secondary",role:"status",children:"Saving preference…"}):null,be?l.jsx("p",{className:"mt-1 text-sm text-negative",role:"alert",children:be}):null]}):null]})}function CW(){return l.jsx("div",{className:"page-container",children:l.jsx("section",{className:"page-section",children:l.jsxs(Ca,{className:"surface-card empty-card",children:[l.jsx("h1",{children:"Route not found"}),l.jsx("p",{children:"The current path does not map to a dashboard view."}),l.jsx(le,{asChild:!0,children:l.jsx(tt,{to:"/",children:"Return to overview"})})]})})})}const Da=Rs(()=>Gi(()=>import("./ProjectPage-B_S900QN.js"),__vite__mapDeps([5,1,0,2,3,4,6,7,8,9,10,11]),import.meta.url),"ProjectPage"),_W=Rs(()=>Gi(()=>import("./RunsPage-BtjVuurK.js"),__vite__mapDeps([12,1,10,4,2,7,11]),import.meta.url),"RunsPage"),TW=Rs(()=>Gi(()=>import("./HistoryPage-DgGUM2tr.js"),__vite__mapDeps([13,1,9,10,4,2,7,11]),import.meta.url),"HistoryPage"),EW=Rs(()=>Gi(()=>import("./SettingsPage-p0x0ZwGY.js"),__vite__mapDeps([14,1,10,4,2,7,11]),import.meta.url),"SettingsPage"),RW=Rs(()=>Gi(()=>import("./BacklinksPage-BQxB_eFt.js"),__vite__mapDeps([15,1,2,10,4,7,11]),import.meta.url),"BacklinksPage"),DW=Rs(()=>Gi(()=>import("./TrafficPage-Bf0NkbIR.js"),__vite__mapDeps([16,1,8,2,10,4,7,11]),import.meta.url),"TrafficPage"),zW=Rs(()=>Gi(()=>import("./TrafficSourceDetailPage-BtwOdTAO.js"),__vite__mapDeps([17,1,8,3,4,2,10,7,11]),import.meta.url),"TrafficSourceDetailPage"),IW=Rs(()=>Gi(()=>import("./MeasurementPropertyPage-Cl91vUu5.js"),__vite__mapDeps([18,1,3,4,6,7,2,10,11]),import.meta.url),"MeasurementPropertyPage");function OW(){return l.jsx(BX,{children:l.jsx(NH,{children:l.jsx(MX,{})})})}const Un=I5()({component:OW,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries==="true"?!0:void 0,runId:typeof e.runId=="string"?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId=="string"?e.siteHealthRunId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0,runStatus:typeof e.runStatus=="string"?e.runStatus:void 0,runKind:typeof e.runKind=="string"?e.runKind:void 0,runProject:typeof e.runProject=="string"?e.runProject:void 0,runWindow:typeof e.runWindow=="string"?e.runWindow:void 0,runQuery:typeof e.runQuery=="string"?e.runQuery:void 0,onboarding:e.onboarding==="site-health"||e.onboarding==="first-run"||e.onboarding==="complete"?e.onboarding:void 0,experience:e.experience==="legacy"||e.experience==="platform"?e.experience:void 0,siteScan:e.siteScan==="skip"?"skip":void 0,skipped:e.skipped==="visibility"?"visibility":void 0,setupProject:typeof e.setupProject=="string"?e.setupProject:void 0,scope:typeof e.scope=="string"?e.scope:void 0,class:typeof e.class=="string"?e.class:void 0,...Object.fromEntries(["queryWorkspace","researchMode","trackingQueryId","measurementScope","measurementScopeKey","measurementMarketKey","queryClass","measurementProvider","measurementModel","measurementLocation","measurementFrom","measurementTo","measurementRevision","measurementRunId","measurementQueryKey","measurementAnswer"].map(n=>[n,typeof e[n]=="string"?e[n]:void 0]))})}),PW=Bt({getParentRoute:()=>Un,path:"/",component:xJ,beforeLoad:async({context:e})=>{let n=e.queryClient.getQueryData(Br({client:W}));if(n===void 0)try{n=await e.queryClient.ensureQueryData(Oo({client:W}))}catch{return}if(n.length===0)throw q0({to:"/setup"})}}),qW=Bt({getParentRoute:()=>Un,path:"/projects",component:jJ}),MW=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Vn=Bt({getParentRoute:()=>Un,path:"/projects/$projectName",component:()=>l.jsx(Gf,{}),beforeLoad:async({context:e,params:n,location:i})=>{const r=n.projectName;if(!MW.test(r))return;let u=e.queryClient.getQueryData(Br({client:W}));if(!u)try{u=await e.queryClient.ensureQueryData(Oo({client:W}))}catch{return}const h=u.find(f=>f.id===r);if(h)throw q0({to:i.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(h.name)}`),replace:!0})}}),BW=Bt({getParentRoute:()=>Vn,path:"/",component:()=>l.jsx(Da,{tab:"overview"})}),LW=Bt({getParentRoute:()=>Vn,path:"/portfolio",component:()=>l.jsx(Da,{tab:"portfolio"})}),UW=Bt({getParentRoute:()=>Vn,path:"/search-console",component:()=>l.jsx(Da,{tab:"search-console"})}),VW=Bt({getParentRoute:()=>Vn,path:"/conversions",component:()=>l.jsx(Da,{tab:"conversions"})}),$W=Bt({getParentRoute:()=>Vn,path:"/local",component:()=>l.jsx(Da,{tab:"local"})}),KW=Bt({getParentRoute:()=>Vn,path:"/discovery",component:()=>l.jsx(Da,{tab:"discovery"})}),GW=Bt({getParentRoute:()=>Vn,path:"/queries",component:()=>l.jsx(Da,{tab:"queries"})}),HW=Bt({getParentRoute:()=>Vn,path:"/properties/$targetKey",component:()=>l.jsx(IW,{})}),QW=Bt({getParentRoute:()=>Vn,path:"/report",beforeLoad:({params:e})=>{throw q0({to:"/projects/$projectName",params:e,replace:!0})}}),FW=Bt({getParentRoute:()=>Vn,path:"/activity",component:()=>l.jsx(Da,{tab:"activity"})}),ZW=Bt({getParentRoute:()=>Vn,path:"/backlinks",component:()=>l.jsx(Da,{tab:"backlinks"})}),YW=Bt({getParentRoute:()=>Vn,path:"/technical-aeo",component:()=>l.jsx(Da,{tab:"technical-aeo"})}),XW=Bt({getParentRoute:()=>Vn,path:"/history",component:()=>l.jsx(Da,{tab:"history"})}),JW=Bt({getParentRoute:()=>Vn,path:"/settings",component:()=>l.jsx(Da,{tab:"settings"})}),WW=Bt({getParentRoute:()=>Un,path:"/runs",component:_W}),eee=Bt({getParentRoute:()=>Un,path:"/history",component:TW}),tee=Bt({getParentRoute:()=>Un,path:"/settings",component:EW,beforeLoad:({context:e})=>{}}),nee=Bt({getParentRoute:()=>Un,path:"/setup",component:SW}),aee=Bt({getParentRoute:()=>Un,path:"/backlinks",component:RW}),iee=Bt({getParentRoute:()=>Un,path:"/traffic",component:DW}),see=Bt({getParentRoute:()=>Un,path:"/traffic/$projectName/$sourceId",component:zW}),oee=Bt({getParentRoute:()=>Un,path:"*",component:CW}),ree=Un.addChildren([PW,qW,Vn.addChildren([BW,LW,UW,VW,$W,KW,GW,HW,QW,FW,ZW,YW,XW,JW]),WW,eee,tee,nee,aee,iee,see,oee]);function lee(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const iS=lee(),cee=iS==="/"?"":iS.replace(/\/$/,"");function uee(e,n){return O5({routeTree:ree,basepath:cee||"/",context:{queryClient:e},...n?.initialEntries})}let sS=!1;async function dee(e){return(await B_({client:W,body:e,keepalive:!0})).data}function mee(){sS||typeof window>"u"||(sS=!0,!(Lm()||xo())&&(FK({send:dee}),W.interceptors.request.use((e,n)=>{const i=n.fetch??globalThis.fetch,r=typeof n.url=="string"?n.url:void 0;return n.fetch=async(u,h)=>{try{return await i(u,h)}catch(f){throw f instanceof DOMException&&f.name==="AbortError"||sm({method:e.method,route:r,network:!0}),f}},e}),W.interceptors.response.use((e,n,i)=>(sm({method:n.method,route:typeof i.url=="string"?i.url:void 0,path:hee(n.url),status:e.status}),e)),window.addEventListener("error",e=>{im({kind:"unhandled",error:e.error})}),window.addEventListener("unhandledrejection",e=>{im({kind:"unhandled",error:e.reason})}),vee()))}function pee(e){let n=null;const i=()=>{const r=e.state.matches.at(-1);if(!r)return;ZK(r.fullPath);const u=e.state.location;if(!u)return;const h=u.search&&typeof u.search=="object"?u.search:{};n&&n.pathname===u.pathname&&eG(n.search,h),n={pathname:u.pathname,search:h}};return i(),e.subscribe("onResolved",i)}function hee(e){try{return new URL(e,window.location.origin).pathname}catch{return}}const fee={LCP:[2500,4e3],INP:[200,500],CLS:[.1,.25],FCP:[1800,3e3],TTFB:[800,1800]};function gee(e,n){const[i,r]=fee[e];return n<=i?"good":n<=r?"needs-improvement":"poor"}function yee(){let e=0,n=0,i=-1/0,r=-1/0;return{add(u){u.hadRecentInput||(u.startTime-r<1e3&&u.startTime-i<5e3?n+=u.value:(n=u.value,i=u.startTime),r=u.startTime,e=Math.max(e,n))},value:()=>e}}function bee(){let e=0;return{add(n){n.interactionId&&(e=Math.max(e,n.duration))},value:()=>e}}function vee(){if(typeof PerformanceObserver>"u")return;const e=new Set,n=(b,v)=>{e.has(b)||!Number.isFinite(v)||(e.add(b),nG(b,gee(b,v)))},i=(b,v,x={})=>{try{new PerformanceObserver(k=>v(k.getEntries())).observe({type:b,buffered:!0,...x})}catch{}};try{const b=performance.getEntriesByType("navigation")[0];b&&b.responseStart>0&&n("TTFB",b.responseStart)}catch{}i("paint",b=>{const v=b.find(x=>x.name==="first-contentful-paint");v&&n("FCP",v.startTime)});let r=0;i("largest-contentful-paint",b=>{const v=b.at(-1);v&&(r=v.startTime)});const u=yee();i("layout-shift",b=>{for(const v of b)u.add({startTime:v.startTime,value:v.value??0,hadRecentInput:v.hadRecentInput===!0})});const h=bee();i("event",b=>{for(const v of b)h.add(v)},{durationThreshold:40});const f=()=>{r>0&&n("LCP",r),n("CLS",u.value()),h.value()>0&&n("INP",h.value())};document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&f()}),window.addEventListener("pagehide",f)}const xee=6e4;function wee(){const e=C.useRef(RG()).current,[n,i]=C.useState(e?"ready":"checking"),[r,u]=C.useState(null),[h,f]=C.useState(null),[b,v]=C.useState(e),[x,k]=C.useState(!1),[S,N]=C.useState(""),[_,z]=C.useState(""),[q,E]=C.useState(""),[P,M]=C.useState(!1),[L,$]=C.useState("password"),[H,J]=C.useState(null),[V,F]=C.useState(!1),[ie,Ge]=C.useState(!1),We=C.useRef(null),$e=C.useRef(null),Pe=C.useRef(null),ke=()=>{const Y=r?`${r.name}:${r.role}`:e?"api-key:explicit":h?`api-key:${h.id}`:"no-accounts";if(!We.current||Pe.current!==Y){$e.current?.clear();const pe=SH();$e.current=pe,We.current=uee(pe),pee(We.current),Pe.current=Y}return{queryClient:$e.current,router:We.current}},Ue=Y=>Y.authRequired?(k(!0),u(Y.user),f(null),v(!1),i(Y.user?"ready":"account-login"),!0):!1;C.useEffect(()=>{let Y=!1;const pe=async(Oe,Ae=!1)=>{try{const st=await Of();if(Y)return;f(st),v(!1),i("ready")}catch(st){if(Y)return;if(Ae&&st instanceof Tn&&st.statusCode===401)return VG().then(()=>{Y||(J(null),f(null),v(!1),Ge(!0),i("login"))}).catch(Ve=>{Y||(J(Ve instanceof Error?Ve.message:"Could not clear the invalid session"),i(Oe))});J(st instanceof Error?st.message:"Could not verify API key access"),i(Oe)}};return e?(pe("api-key-error"),()=>{Y=!0}):(Promise.allSettled([sk(),ik()]).then(([Oe,Ae])=>{if(Y||Oe.status==="fulfilled"&&Ue(Oe.value))return;if(Ae.status==="rejected"){const Ve=Ae.reason;J(Ve instanceof Error?Ve.message:"Failed to reach the Canonry API"),i("login");return}const st=Ae.value;st.authenticated?(v(!0),pe("api-key-error",!0)):(f(null),v(!1),i(st.setupRequired?"setup":"login"))}),()=>{Y=!0})},[]),C.useEffect(()=>{if(n!=="ready"||e)return;const Y=setInterval(()=>{if(x){sk().then(pe=>{pe.authRequired&&!pe.user&&(Ge(!0),u(null),f(null),i("account-login"))}).catch(()=>{});return}ik().then(pe=>{pe.authenticated||(Ge(!0),f(null),i(pe.setupRequired?"setup":"login"))}).catch(()=>{})},xee);return ak(()=>{Ge(!0),u(null),f(null),v(!1),i(x?"account-login":"login")}),()=>{clearInterval(Y),ak(null)}},[n,x,e]);const B=async Y=>{if(Y.preventDefault(),!_.trim()||_.trim().length<8){J("Password must be at least 8 characters");return}if(_!==q){J("Passwords do not match");return}F(!0),J(null);try{if(!(await BG(_.trim())).authenticated){J("Setup failed");return}z(""),E(""),M(!1),Ge(!1),f(null),v(!0),i("checking");try{const Oe=await Of();f(Oe),v(!1),i("ready")}catch(Oe){J(Oe instanceof Error?Oe.message:"Could not verify API key access"),i("api-key-error")}}catch(pe){J(pe instanceof Tn||pe instanceof Error?pe.message:"Setup failed")}finally{F(!1)}},ee=Y=>{z(Y),J(null)},be=Y=>{E(Y),J(null)},je=async Y=>{if(Y.preventDefault(),!!_.trim()){F(!0),J(null);try{if(!(L==="api-key"?await UG(_.trim()):await LG(_.trim())).authenticated){J(L==="api-key"?"Invalid API key":"Incorrect password");return}const Oe=await Of();f(Oe),v(!1),z(""),M(!1),Ge(!1),i("ready")}catch(pe){J(pe instanceof Tn||pe instanceof Error?pe.message:"Authentication failed")}finally{F(!1)}}},te=Y=>{$(Y),z(""),M(!1),J(null)},_e=async Y=>{if(Y.preventDefault(),!(!S.trim()||!_)){F(!0),J(null);try{const pe=await $G(S.trim(),_);if(!pe.user){J("Incorrect name or password.");return}z(""),Ge(!1),u(pe.user),f(null),v(!1),i("ready")}catch(pe){J(pe instanceof Tn?pe.message:"Incorrect name or password.")}finally{F(!1)}}};if(n==="ready"){const{queryClient:Y,router:pe}=ke();return l.jsx(dH,{account:r,apiKey:h,apiKeyPending:b,children:l.jsx(P5,{client:Y,children:l.jsx(q5,{router:pe})})})}const qe=_.trim(),ve=_.length>0&&qe.length<8,de=q.length>0&&_!==q,ce=qe.length>=8&&_===q;return l.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:l.jsxs("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5",children:[l.jsxs("div",{"data-testid":"auth-brand",className:"flex items-center gap-2.5",children:[l.jsx("img",{className:"size-7",src:"./favicon.svg",alt:"","aria-hidden":"true"}),l.jsx("span",{className:"text-lg font-semibold tracking-tight text-heading",children:"Canonry"})]}),l.jsx(Ca,{className:"surface-card w-full",children:n==="checking"?l.jsx(go,{className:"py-8",children:l.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):n==="api-key-error"?l.jsxs(l.Fragment,{children:[l.jsxs(_r,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Could not verify API key access"})]}),l.jsxs(go,{className:"space-y-4",children:[l.jsx("p",{className:"supporting-copy",children:H??"Canonry could not verify this session’s access, so the dashboard stayed locked."}),l.jsx(le,{type:"button",className:"w-full",onClick:()=>{window.location.reload()},children:"Try again"})]})]}):n==="account-login"?l.jsxs(l.Fragment,{children:[l.jsxs(_r,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"})]}),l.jsxs(go,{children:[ie?l.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"You were signed out — please sign in again."}):null,l.jsxs("form",{className:"space-y-4",onSubmit:fn(_e),children:[l.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-name",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:"Name"}),l.jsx("input",{autoFocus:!0,id:"account-name",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"text",name:"username",autoComplete:"username",value:S,onChange:Y=>{N(Y.target.value),J(null)},"aria-invalid":!!H,"aria-describedby":H?"account-login-error":void 0})]}),l.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-password",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),l.jsx("input",{id:"account-password",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",name:"password",autoComplete:"current-password",value:_,onChange:Y=>ee(Y.target.value),"aria-invalid":!!H,"aria-describedby":H?"account-login-error":void 0})]}),H?l.jsx("p",{id:"account-login-error",role:"alert",className:"text-sm text-negative-400",children:H}):null,l.jsx(le,{type:"submit",disabled:V||!S.trim()||!_,children:V?"Signing in…":"Sign in"})]})]})]}):n==="setup"?l.jsxs(l.Fragment,{children:[l.jsxs(_r,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Create a dashboard password"}),l.jsx(dm,{children:"This password protects the dashboard on this computer."})]}),l.jsx(go,{children:l.jsxs("form",{className:"space-y-4",onSubmit:fn(B),children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-new",children:"Password"}),l.jsx("input",{autoFocus:!0,id:"dashboard-password-new",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"new-password",autoComplete:"new-password",minLength:8,required:!0,value:_,onChange:Y=>ee(Y.target.value),"aria-invalid":ve,"aria-describedby":"dashboard-password-new-help"}),l.jsx("span",{id:"dashboard-password-new-help","aria-live":"polite",className:ve?"block text-sm text-negative-400":"block text-sm text-secondary",children:ve?"Enter at least 8 characters.":"Use at least 8 characters."})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-confirm",children:"Confirm password"}),l.jsx("input",{id:"dashboard-password-confirm",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"confirm-password",autoComplete:"new-password",minLength:8,required:!0,value:q,onChange:Y=>be(Y.target.value),"aria-invalid":de,"aria-describedby":"dashboard-password-confirm-help"}),l.jsx("span",{id:"dashboard-password-confirm-help","aria-live":"polite",className:de?"block text-sm text-negative-400":"block text-sm text-secondary",children:de?"Passwords do not match.":"Enter the same password again."})]}),l.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-password-show",children:[l.jsx("input",{id:"dashboard-password-show",type:"checkbox",checked:P,onChange:Y=>M(Y.target.checked)}),"Show passwords"]}),H?l.jsx("p",{id:"dashboard-password-setup-error",role:"alert",className:"text-sm text-negative-400",children:H}):null,l.jsx(le,{type:"submit",disabled:V||!ce,children:V?"Creating password…":"Create password and continue"})]})})]}):l.jsxs(l.Fragment,{children:[l.jsxs(_r,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"}),l.jsx(dm,{children:L==="api-key"?"Enter an API key from this Canonry install. This opens the dashboard with that key’s access and does not change the password.":"Enter your dashboard password to continue."})]}),l.jsxs(go,{children:[ie?l.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"Your session expired — please sign in again."}):null,l.jsxs("form",{className:"space-y-4",onSubmit:fn(je),children:[l.jsxs("label",{className:"block space-y-1.5",htmlFor:"dashboard-password-current",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:L==="api-key"?"Canonry API key":"Password"}),l.jsx("input",{autoFocus:!0,id:"dashboard-password-current",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:L==="api-key"?"apiKey":"password",autoComplete:L==="api-key"?"off":"current-password",spellCheck:!1,required:!0,value:_,onChange:Y=>ee(Y.target.value),"aria-invalid":!!H,"aria-describedby":H?"dashboard-password-login-error":void 0})]}),l.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-login-password-show",children:[l.jsx("input",{id:"dashboard-login-password-show",type:"checkbox",checked:P,onChange:Y=>M(Y.target.checked)}),L==="api-key"?"Show API key":"Show password"]}),H?l.jsx("p",{id:"dashboard-password-login-error",role:"alert",className:"text-sm text-negative-400",children:H}):null,l.jsx(le,{type:"submit",disabled:V||!_.trim(),children:V?"Signing in…":"Open dashboard"}),l.jsx(le,{type:"button",variant:"ghost",onClick:()=>te(L==="api-key"?"password":"api-key"),children:L==="api-key"?"Use dashboard password instead":"Forgot password? Use API key"})]})]})]})})]})})}const jC=document.getElementById("root");if(!jC)throw new Error("Expected #root element for web app bootstrap.");mee();u6.createRoot(jC).render(l.jsx(C.StrictMode,{children:l.jsx(wee,{})}));export{Lae as $,Bn as A,le as B,bc as C,fn as D,oie as E,cie as F,lie as G,dne as H,la as I,pne as J,mne as K,ha as L,Die as M,_H as N,Fie as O,Zie as P,BZ as Q,$a as R,Yk as S,vn as T,OH as U,mte as V,Pne as W,Lne as X,qte as Y,Ine as Z,qae as _,Rie as a,Bne as a$,Bae as a0,Hte as a1,Gte as a2,nne as a3,xn as a4,$ae as a5,Kae as a6,Xte as a7,Gae as a8,Jte as a9,Tne as aA,Tn as aB,Ene as aC,_te as aD,TH as aE,MF as aF,y0 as aG,Rne as aH,Od as aI,die as aJ,T0 as aK,fo as aL,DH as aM,jt as aN,xH as aO,Jne as aP,BY as aQ,Zte as aR,fte as aS,pte as aT,Oi as aU,$ie as aV,ute as aW,Ate as aX,GP as aY,kte as aZ,cte as a_,Fte as aa,Yte as ab,Uae as ac,Vae as ad,Mae as ae,Qte as af,Hae as ag,Wae as ah,Zae as ai,Xae as aj,Yae as ak,Jae as al,vne as am,k1 as an,De as ao,Fae as ap,PN as aq,$i as ar,Qae as as,z0 as at,Y9 as au,X9 as av,Xee as aw,Yee as ax,kne as ay,_ne as az,IH as b,zee as b$,lte as b0,GH as b1,pQ as b2,iae as b3,cae as b4,sae as b5,bte as b6,xte as b7,FV as b8,wte as b9,bae as bA,Nae as bB,Cae as bC,_ae as bD,yae as bE,Aae as bF,vae as bG,Tae as bH,xae as bI,Eae as bJ,Sae as bK,Dae as bL,Oae as bM,NJ as bN,wae as bO,fe as bP,Fee as bQ,Qee as bR,Hee as bS,Gee as bT,Vee as bU,Uee as bV,Kee as bW,$ee as bX,Lee as bY,Bee as bZ,Dee as b_,nQ as ba,aae as bb,YV as bc,f0 as bd,vte as be,kG as bf,oae as bg,nae as bh,iQ as bi,rae as bj,Dne as bk,lae as bl,gie as bm,yie as bn,Wte as bo,RN as bp,uie as bq,EN as br,hae as bs,gae as bt,jae as bu,Iae as bv,zae as bw,kae as bx,Rae as by,Pae as bz,Zee as c,Zne as c$,Mee as c0,qee as c1,Pee as c2,Iee as c3,Oee as c4,Ree as c5,Eee as c6,Tee as c7,_ee as c8,O6 as c9,Gne as cA,SY as cB,A0 as cC,lm as cD,N0 as cE,cm as cF,um as cG,MY as cH,ZH as cI,yo as cJ,mm as cK,xQ as cL,qJ as cM,Yie as cN,qie as cO,PY as cP,Pie as cQ,EJ as cR,uae as cS,Qne as cT,Oie as cU,Xne as cV,Fne as cW,jI as cX,yP as cY,dae as cZ,Iie as c_,Ste as ca,Ote as cb,Ite as cc,zte as cd,une as ce,wG as cf,gj as cg,Cm as ch,yj as ci,gQ as cj,fae as ck,$ne as cl,hte as cm,mk as cn,Bte as co,Lte as cp,Une as cq,Vne as cr,Ute as cs,Vte as ct,Kte as cu,$te as cv,tu as cw,Oo as cx,yN as cy,Hne as cz,zH as d,o1 as d$,_ie as d0,GY as d1,zG as d2,MH as d3,HY as d4,Ete as d5,Rte as d6,Tte as d7,PG as d8,Mie as d9,mae as dA,pae as dB,NG as dC,Nte as dD,Cte as dE,Mte as dF,ene as dG,tne as dH,E1 as dI,Gm as dJ,N1 as dK,PJ as dL,cne as dM,Lr as dN,hk as dO,xne as dP,Sne as dQ,Ane as dR,Nne as dS,wne as dT,jne as dU,Cne as dV,Df as dW,bne as dX,hie as dY,kJ as dZ,yte as d_,Bie as da,Lie as db,Vie as dc,Dte as dd,KH as de,Pte as df,IZ as dg,eie as dh,QG as di,rne as dj,nie as dk,aie as dl,iie as dm,tie as dn,qne as dp,ane as dq,ine as dr,sne as ds,lne as dt,one as du,A1 as dv,Ns as dw,Dc as dx,Qie as dy,eu as dz,Kie as e,Kne as e0,mie as e1,fie as e2,yne as e3,gte as e4,fne as e5,gne as e6,hne as e7,pie as e8,One as e9,jie as eA,Cie as eB,Sie as eC,Nie as eD,Co as eE,rte as eF,ate as eG,Aie as eH,nte as eI,IO as eJ,ste as eK,ite as eL,GI as ea,Wne as eb,Yne as ec,tae as ed,eae as ee,Ak as ef,ote as eg,pw as eh,tte as ei,Gi as ej,Ra as ek,ete as el,im as em,jte as en,mF as eo,vie as ep,bie as eq,RJ as er,kie as es,VY as et,Jee as eu,Tie as ev,Eie as ew,xie as ex,wie as ey,Wee as ez,Jd as f,Uie as g,Gie as h,Hie as i,C0 as j,Lc as k,LZ as l,zie as m,rV as n,JK as o,zne as p,sie as q,rie as r,Mne as s,RH as t,C1 as u,Ca as v,dte as w,W as x,Lm as y,xo as z};
@@ -1,4 +1,4 @@
1
- import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-CUOt7jeo.js";import"./index-BJh8cX5E.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-lucide-N6vOpZmh.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-CYlrwLJs.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-DMHWsfM4.js";import"./index-DR_kNdE4.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-lucide-N6vOpZmh.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-CYlrwLJs.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ee(r,n){return qt(r)||Yt(r,n)||Tt(r,n)||Xt()}var pe={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},Ct=new Int8Array(4),be=new Int32Array(Ct.buffer,0,1),$t=new Float32Array(Ct.buffer,0,1),Kt=/^\s*rgba?\s*\(/,Jt=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Qt(r){var n=0,i=0,e=0,t=1;if(r[0]==="#")r.length===4?(n=parseInt(r.charAt(1)+r.charAt(1),16),i=parseInt(r.charAt(2)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(3),16)):(n=parseInt(r.charAt(1)+r.charAt(2),16),i=parseInt(r.charAt(3)+r.charAt(4),16),e=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(t=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(Kt.test(r)){var a=r.match(Jt);a&&(n=+a[1],i=+a[2],e=+a[3],a[4]&&(t=+a[4]))}return{r:n,g:i,b:e,a:t}}var J={};for(var le in pe)J[le]=oe(pe[le]),J[pe[le]]=J[le];function Rt(r,n,i,e,t){return be[0]=e<<24|i<<16|n<<8|r,be[0]=be[0]&4278190079,$t[0]}function oe(r){if(r=r.toLowerCase(),typeof J[r]<"u")return J[r];var n=Qt(r),i=n.r,e=n.g,t=n.b,a=n.a;a=a*255|0;var o=Rt(i,e,t,a);return J[r]=o,o}var Ee={};function _t(r){if(typeof Ee[r]<"u")return Ee[r];var n=(r&16711680)>>>16,i=(r&65280)>>>8,e=r&255,t=255,a=Rt(n,i,e,t);return Ee[r]=a,a}function We(r,n,i,e){return i+(n<<8)+(r<<16)}function Ve(r,n,i,e,t,a){var o=Math.floor(i/a*t),s=Math.floor(r.drawingBufferHeight/a-e/a*t),l=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,n),r.readPixels(o,s,1,1,r.RGBA,r.UNSIGNED_BYTE,l);var h=ee(l,4),u=h[0],d=h[1],f=h[2],g=h[3];return[u,d,f,g]}function c(r,n,i){return(n=ae(n))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,r}function je(r,n){var i=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),i.push.apply(i,e)}return i}function b(r){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?je(Object(i),!0).forEach(function(e){c(r,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):je(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function ei(r,n){for(;!{}.hasOwnProperty.call(r,n)&&(r=Q(r))!==null;);return r}function Ae(){return Ae=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,n,i){var e=ei(r,n);if(e){var t=Object.getOwnPropertyDescriptor(e,n);return t.get?t.get.call(arguments.length<3?r:i):t.value}},Ae.apply(null,arguments)}function wt(r,n,i,e){var t=Ae(Q(r.prototype),n,i);return typeof t=="function"?function(a){return t.apply(i,a)}:t}function ti(r){return r.normalized?1:r.size}function ye(r){var n=0;return r.forEach(function(i){return n+=ti(i)}),n}function xt(r,n,i){var e=r==="VERTEX"?n.VERTEX_SHADER:n.FRAGMENT_SHADER,t=n.createShader(e);if(t===null)throw new Error("loadShader: error while creating the shader");n.shaderSource(t,i),n.compileShader(t);var a=n.getShaderParameter(t,n.COMPILE_STATUS);if(!a){var o=n.getShaderInfoLog(t);throw n.deleteShader(t),new Error(`loadShader: error while compiling the shader:
3
3
  `.concat(o,`
4
4
  `).concat(i))}return t}function ii(r,n){return xt("VERTEX",r,n)}function ri(r,n){return xt("FRAGMENT",r,n)}function ni(r,n){var i=r.createProgram();if(i===null)throw new Error("loadProgram: error while creating the program.");var e,t;for(e=0,t=n.length;e<t;e++)r.attachShader(i,n[e]);r.linkProgram(i);var a=r.getProgramParameter(i,r.LINK_STATUS);if(!a){var o=r.getProgramInfoLog(i);throw r.deleteProgram(i),new Error("loadProgram: error while linking the program: ".concat(o))}return i}function Ze(r){var n=r.gl,i=r.buffer,e=r.program,t=r.vertexShader,a=r.fragmentShader;n.deleteShader(t),n.deleteShader(a),n.deleteProgram(e),n.deleteBuffer(i)}var qe=`#define PICKING_MODE