@ainyc/canonry 2.15.1 → 2.16.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.
@@ -1,25 +1,25 @@
1
1
  ---
2
2
  name: memory-patterns
3
- description: When to remember vs. re-query — project state lives in canonry, only durable user-scoped facts go in Aero memory. Read when unsure whether to call remember or look up.
3
+ description: When to remember vs. re-query — project state lives in canonry, only durable user-scoped facts go in Aero memory. Read when unsure whether to call canonry_memory_set or look up.
4
4
  ---
5
5
 
6
6
  # Memory Patterns
7
7
 
8
8
  Canonry is the source of truth for project state. Do **not** maintain a parallel copy of project facts in Aero memory — it will drift from the DB and mislead the next session.
9
9
 
10
- Aero now ships with a built-in durable notes store — the `remember`, `forget`, and `recall` tools — backed by the `agent_memory` table. The N most-recently-updated notes are injected into the system prompt at every session start, so you usually see relevant memory without calling `recall`.
10
+ Aero ships with a built-in durable notes store — the `canonry_memory_set`, `canonry_memory_forget`, and `canonry_memory_list` tools — backed by the `agent_memory` table. The N most-recently-updated notes are injected into the system prompt at every session start, so you usually see relevant memory without calling `canonry_memory_list`.
11
11
 
12
12
  ## What belongs where
13
13
 
14
14
  | Scope | Examples | Home |
15
15
  |---|---|---|
16
16
  | **Project state** | Baselines, historical regressions, citation rates per keyword/provider, recent insights, sweep history, audit trail | Canonry DB — query via CLI / API / read tools |
17
- | **Operator facts** | Personal preferences, non-observable context ("content lead is Sarah", "migrating off Webflow next quarter"), tone/voice preferences the operator confirmed | Aero memory (`remember`) |
17
+ | **Operator facts** | Personal preferences, non-observable context ("content lead is Sarah", "migrating off Webflow next quarter"), tone/voice preferences the operator confirmed | Aero memory (`canonry_memory_set`) |
18
18
  | **Session scratch** | "I just tried X and it failed", intermediate reasoning, turn-local state | Nowhere — let it die with the session |
19
19
 
20
20
  ## How to read project state from canonry
21
21
 
22
- Prefer Aero's read tools (`get_status`, `get_health`, `get_timeline`, `get_insights`, `list_keywords`, `list_competitors`, `get_run`) over shelling out, but the CLI exists for operators too:
22
+ Prefer Aero's read tools (`canonry_project_overview`, `canonry_health_latest`, `canonry_timeline_get`, `canonry_insights_list`, `canonry_keywords_list`, `canonry_competitors_list`, `canonry_run_get`) over shelling out, but the CLI exists for operators too:
23
23
 
24
24
  ```bash
25
25
  canonry status <project> --format json
@@ -36,13 +36,13 @@ If the data you need isn't reachable with a single read tool or CLI call, that's
36
36
 
37
37
  Derived interpretations (trend summaries, correlations between events) are cheap to recompute from the underlying DB rows. Prefer running the analysis again on fresh data over recalling what you concluded last session — conclusions age, the data doesn't.
38
38
 
39
- ## Using `remember` / `forget` / `recall`
39
+ ## Using `canonry_memory_set` / `canonry_memory_forget` / `canonry_memory_list`
40
40
 
41
- - `remember(key, value)` — upsert a project-scoped note. Capped at 2 KB per value. Same key replaces the prior value, so use stable keys (e.g. `operator-pref.reporting-tone`, not `note-2026-04-17`).
42
- - `forget(key)` — remove a single note. Returns `status: missing` when the key never existed (non-fatal).
43
- - `recall(limit?)` — read notes newest-first. Usually unnecessary — the top 20 are already in the system prompt under `<memory>`. Reach for it when you need older context or the full value of a note that's been summarized.
41
+ - `canonry_memory_set({ key, value })` — upsert a project-scoped note. Capped at 2 KB per value. Same key replaces the prior value, so use stable keys (e.g. `operator-pref.reporting-tone`, not `note-2026-04-17`).
42
+ - `canonry_memory_forget({ key })` — remove a single note. Returns `status: missing` when the key never existed (non-fatal).
43
+ - `canonry_memory_list()` — read notes newest-first. Usually unnecessary — the top 20 are already in the system prompt under `<memory>`. Reach for it when you need older context or the full value of a note that's been summarized.
44
44
 
45
- **Reserved prefix.** Keys starting with `compaction:` are reserved for LLM-summarized transcript slices. `remember` and `forget` both reject them. Compaction notes are pruned automatically — you can `recall` them but never write or delete them by hand.
45
+ **Reserved prefix.** Keys starting with `compaction:` are reserved for LLM-summarized transcript slices. `canonry_memory_set` and `canonry_memory_forget` both reject them. Compaction notes are pruned automatically — you can list them but never write or delete them by hand.
46
46
 
47
47
  **CLI parity.** Operators can manage memory without talking to you:
48
48
 
@@ -112,7 +112,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
112
112
  `);for(;S!==-1;){const j=m.slice(0,S);m=m.slice(S+2);for(const N of j.split(`
113
113
  `)){if(!N.startsWith("data:"))continue;const O=N.slice(5).trim();if(O)try{o(JSON.parse(O))}catch{}}S=m.indexOf(`
114
114
 
115
- `)}}}finally{a?.removeEventListener("abort",y);try{f.releaseLock()}catch{}}}function W4(e){return!e||e.role!=="assistant"?"":e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}const ioe=[{label:"Status",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{label:"Top insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{label:"Last failed run",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{label:"Schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"}],aoe=[{command:"/status",label:"Status",hint:"Latest runs, health, anything unusual",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{command:"/insights",label:"Top insights",hint:"Walk through the most severe active insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{command:"/last-run",label:"Last run",hint:"Summarize the latest sweep",prompt:"Summarize the latest run for this project — provider mix, visibility changes, and anything that moved."},{command:"/last-failed",label:"Last failed run",hint:"Diagnose the most recent failure",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{command:"/run-sweep",label:"Run sweep now",hint:"Trigger a new visibility sweep",prompt:"Run a new answer-visibility sweep for this project now and tell me when it lands."},{command:"/schedule",label:"Schedule",hint:"Review the sweep schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"},{command:"/keywords",label:"Keywords",hint:"List tracked keywords",prompt:"List the tracked keywords for this project and flag any that are obvious duplicates or underperformers."},{command:"/competitors",label:"Competitors",hint:"List tracked competitors",prompt:"List this project's tracked competitors and call out which ones are showing up in answer citations."}],xm=e=>`canonry:aero:provider:${e}`,cT=e=>`canonry:aero:scope:${e}`;function soe({projectName:e}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1),[a,o]=b.useState([]),[u,d]=b.useState(""),[f,p]=b.useState(!1),[m,y]=b.useState([]),[v,w]=b.useState(""),[S,j]=b.useState(null),[N,O]=b.useState(()=>typeof window>"u"?null:window.localStorage.getItem(xm(e))??null),[_,C]=b.useState(()=>typeof window>"u"?"read-only":window.localStorage.getItem(cT(e))==="all"?"all":"read-only"),T=b.useRef(null),E=b.useRef(null),A=b.useRef(null),[P,I]=b.useState(0),q=b.useMemo(()=>{const F=u.trimStart();if(!F.startsWith("/"))return[];if(/\s/.test(F))return[];const D=F.toLowerCase();return aoe.filter(Q=>Q.command.startsWith(D)||Q.label.toLowerCase().includes(D.slice(1)))},[u]);b.useEffect(()=>{I(F=>q.length===0?0:Math.min(F,q.length-1))},[q.length]);const B=rs({queryKey:Ar.agent.providers(e),queryFn:()=>toe(e),enabled:t,staleTime:6e4}),$=b.useMemo(()=>{const F=B.data?.providers??[];if(N){const Q=F.find(se=>se.id===N&&se.configured);if(Q)return Q}const D=B.data?.defaultProvider;return D?F.find(Q=>Q.id===D)??null:null},[N,B.data]);b.useEffect(()=>{if(!B.data||!N)return;B.data.providers.find(D=>D.id===N&&D.configured)||(O(null),window.localStorage.removeItem(xm(e)))},[B.data,N,e]);const V=b.useCallback(F=>{O(F),!(typeof window>"u")&&(F?window.localStorage.setItem(xm(e),F):window.localStorage.removeItem(xm(e)))},[e]),te=b.useCallback(()=>{C(F=>{const D=F==="all"?"read-only":"all";return typeof window<"u"&&window.localStorage.setItem(cT(e),D),D})},[e]);b.useEffect(()=>{if(!t)return;const F=D=>{D.key==="Escape"&&(r?i(!1):n(!1))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[t,r]),b.useEffect(()=>{if(!t)return;let F=!1;j(null);const D=()=>{F||f||lT(e).then(ae=>{F||o(ae.messages)}).catch(ae=>{F||j(ae instanceof Error?ae.message:"Failed to load transcript")})};D();const se=window.setInterval(D,15e3);return()=>{F=!0,window.clearInterval(se)}},[t,e,f]),b.useEffect(()=>()=>{T.current?.abort()},[e]),b.useEffect(()=>{const F=E.current;F&&(F.scrollTop=F.scrollHeight)},[a,v,m]);async function Y(F){const D=F.trim();if(!D||f)return;j(null),d(""),p(!0),w(""),y([]);const Q={role:"user",content:D,timestamp:Date.now()};o(ae=>[...ae,Q]);const se=new AbortController;T.current=se;try{await roe({project:e,prompt:D,provider:N??void 0,scope:_,signal:se.signal,onEvent:H});const ae=await lT(e);o(ae.messages)}catch(ae){ae.name!=="AbortError"&&j(ae instanceof Error?ae.message:"Prompt failed")}finally{p(!1),w(""),T.current=null}}function H(F){switch(F.type){case"message_update":w(W4(F.message));break;case"message_end":F.message.role==="assistant"&&w("");break;case"tool_execution_start":y(D=>[...D,{id:F.toolCallId,name:F.toolName,args:F.args,startedAt:Date.now()}]);break;case"tool_execution_end":y(D=>D.map(Q=>Q.id===F.toolCallId?{...Q,endedAt:Date.now(),isError:F.isError,result:F.result}:Q));break;case"error":j(F.message);break}}async function J(){T.current?.abort();try{await noe(e),o([]),j(null)}catch(F){j(F instanceof Error?F.message:"Reset failed")}}const pe=a.length===0,Se=t&&r?"pointer-events-auto fixed inset-0 z-40 flex items-stretch justify-center bg-zinc-950/70 p-4 sm:p-8 backdrop-blur-sm":"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",R=r?"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-zinc-800/80 bg-zinc-950/95 shadow-2xl":"pointer-events-auto w-full max-w-3xl",U=r?"flex-1 overflow-y-auto px-6 py-5 text-sm text-zinc-200":"max-h-[40vh] min-h-[120px] overflow-y-auto px-4 py-3 text-sm text-zinc-200";return c.jsx("div",{className:Se,onClick:F=>{r&&F.target===F.currentTarget&&i(!1)},children:c.jsx("div",{className:R,children:t?c.jsxs("div",{className:r?"flex h-full flex-col":"flex flex-col overflow-hidden rounded-2xl border border-zinc-800/80 bg-zinc-950/95 shadow-xl backdrop-blur",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-zinc-800/70 px-4 py-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(k2,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-zinc-100",children:"Aero"}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:f?"working…":e})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(ooe,{providers:B.data?.providers??[],active:$,override:N,onPick:V,disabled:f}),c.jsx("button",{type:"button",onClick:J,className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":"Reset conversation",title:"Reset conversation",children:c.jsx(aL,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),c.jsx("button",{type:"button",onClick:()=>i(F=>!F),className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":r?"Collapse":"Expand",title:r?"Collapse":"Expand",children:r?c.jsx(FG,{className:"h-3.5 w-3.5","aria-hidden":"true"}):c.jsx(LG,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),c.jsx("button",{type:"button",onClick:()=>{i(!1),n(!1)},className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":"Close Aero",children:c.jsx(lh,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),c.jsxs("div",{ref:E,className:U,children:[S&&c.jsx("div",{className:"mb-2 rounded-md border border-rose-700/40 bg-rose-950/40 px-3 py-2 text-xs text-rose-200",children:S}),pe&&!f&&c.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[c.jsxs("p",{className:"text-xs text-zinc-500",children:["Ask anything about ",c.jsx("span",{className:"text-zinc-300",children:e}),", or start with:"]}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:ioe.map(F=>c.jsx("button",{type:"button",onClick:()=>Y(F.prompt),className:"rounded-full border border-zinc-800 bg-zinc-900/70 px-3 py-1 text-xs text-zinc-300 transition hover:border-zinc-700 hover:bg-zinc-800/70 hover:text-zinc-100",children:F.label},F.label))})]}),foe(a,e,N,_),m.length>0&&c.jsx("div",{className:"mt-3 space-y-1.5",children:m.map(F=>c.jsx(Q4,{trail:F},F.id))}),f&&v&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),c.jsx(X4,{content:v})]}),f&&!v&&m.every(F=>F.endedAt!==void 0)&&c.jsx(goe,{})]}),c.jsx(loe,{projectName:e,activeProvider:$,scope:_,onToggleScope:te,disabled:f}),c.jsxs("div",{className:"relative",children:[q.length>0&&c.jsx(coe,{matches:q,selectedIndex:P,onHover:I,onPick:F=>{d(""),A.current?.focus(),Y(F.prompt)}}),c.jsxs("form",{className:"flex items-end gap-2 border-t border-zinc-800/70 bg-zinc-950/80 px-3 py-2.5",onSubmit:F=>{if(F.preventDefault(),q.length>0){const D=q[P];d(""),Y(D.prompt);return}Y(u)},children:[c.jsx("textarea",{ref:A,value:u,onChange:F=>d(F.target.value),onKeyDown:F=>{if(q.length>0){if(F.key==="ArrowDown"){F.preventDefault(),I(D=>(D+1)%q.length);return}if(F.key==="ArrowUp"){F.preventDefault(),I(D=>(D-1+q.length)%q.length);return}if(F.key==="Tab"){F.preventDefault();const D=q[P];d(`${D.command} `);return}if(F.key==="Escape"){F.preventDefault(),d("");return}}if(F.key==="Enter"&&!F.shiftKey)if(F.preventDefault(),q.length>0){const D=q[P];d(""),Y(D.prompt)}else Y(u)},placeholder:"Ask Aero, or / for commands…",disabled:f,rows:r?3:1,className:"flex-1 resize-none bg-transparent text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none disabled:opacity-60"}),c.jsx("button",{type:"submit",disabled:f||!u.trim(),className:"inline-flex h-7 w-7 items-center justify-center rounded-md bg-emerald-500 text-zinc-950 transition hover:bg-emerald-400 disabled:opacity-40","aria-label":"Send",children:c.jsx(mG,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})]}):c.jsxs("button",{type:"button",onClick:()=>n(!0),className:"flex w-full items-center justify-between rounded-full border border-zinc-800/80 bg-zinc-950/95 px-4 py-2 text-left text-sm text-zinc-400 shadow-lg backdrop-blur transition hover:border-zinc-700 hover:bg-zinc-900/90 hover:text-zinc-200",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(k2,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),"Ask Aero about ",e,"…"]}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-600",children:"Enter"})]})})})}function ooe({providers:e,active:t,override:n,onPick:r,disabled:i}){const[a,o]=b.useState(!1),u=b.useRef(null);if(b.useEffect(()=>{if(!a)return;const p=y=>{u.current?.contains(y.target)||o(!1)},m=y=>{y.key==="Escape"&&o(!1)};return window.addEventListener("mousedown",p),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",p),window.removeEventListener("keydown",m)}},[a]),e.length===0)return null;const d=t?.label.replace(/\s+\(.+\)$/,"")??"No provider",f=t?.defaultModel;return c.jsxs("div",{ref:u,className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>o(p=>!p),disabled:i,className:"flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-zinc-400 transition hover:bg-zinc-800/60 hover:text-zinc-200 disabled:opacity-50","aria-label":"Switch agent model","aria-haspopup":"listbox","aria-expanded":a,title:t?`${t.label} · ${t.defaultModel}`:"Pick a provider",children:[c.jsx("span",{className:"font-medium text-zinc-200",children:d}),f&&c.jsx("span",{className:"hidden font-mono text-[10px] text-zinc-500 sm:inline",children:f}),c.jsx(vG,{className:"h-3 w-3","aria-hidden":"true"})]}),a&&c.jsxs("div",{role:"listbox",className:"absolute right-0 top-full z-50 mt-1 w-64 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950 shadow-xl",children:[c.jsx("div",{className:"border-b border-zinc-800/60 px-3 py-2 text-[10px] uppercase tracking-wider text-zinc-500",children:"Aero provider"}),c.jsx("ul",{className:"max-h-72 overflow-y-auto py-1",children:e.map(p=>{const m=t?.id===p.id,y=n===p.id;return c.jsx("li",{children:c.jsxs("button",{type:"button",role:"option","aria-selected":m,disabled:!p.configured,onClick:()=>{p.configured&&(r(y?null:p.id),o(!1))},className:"flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition enabled:hover:bg-zinc-900 disabled:cursor-not-allowed disabled:opacity-50",children:[c.jsx("span",{className:"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:m?c.jsx(eL,{className:"h-3 w-3 text-emerald-400","aria-hidden":"true"}):null}),c.jsxs("span",{className:"flex-1",children:[c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"font-medium text-zinc-100",children:p.label}),y&&c.jsx("span",{className:"rounded-full border border-emerald-800/60 bg-emerald-950/60 px-1.5 text-[9px] uppercase tracking-wider text-emerald-300",children:"Pinned"}),!p.configured&&c.jsx("span",{className:"rounded-full border border-zinc-800 px-1.5 text-[9px] uppercase tracking-wider text-zinc-500",children:"Key missing"})]}),c.jsx("span",{className:"mt-0.5 block font-mono text-[10px] text-zinc-500",children:p.defaultModel}),p.keySource==="env"&&c.jsx("span",{className:"mt-0.5 block text-[10px] text-zinc-600",children:"via env var"}),!p.configured&&c.jsxs("span",{className:"mt-0.5 block text-[10px] text-zinc-600",children:["Add key in config.yaml or export"," ",c.jsx("code",{className:"font-mono text-zinc-400",children:uoe(p.id)})]})]})]})},p.id)})}),n&&c.jsx("button",{type:"button",onClick:()=>{r(null),o(!1)},className:"w-full border-t border-zinc-800/60 px-3 py-2 text-left text-[11px] text-zinc-400 transition hover:bg-zinc-900 hover:text-zinc-100",children:"Reset to auto-detected default"})]})]})}function loe({projectName:e,activeProvider:t,scope:n,onToggleScope:r,disabled:i}){const a=t?.label.replace(/\s+\(.+\)$/,"")??null,o=n==="all";return c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-zinc-800/70 bg-zinc-950/80 px-3 pt-2",children:[c.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-800 bg-zinc-900/70 px-2 py-0.5 text-[10px] text-zinc-400",children:[c.jsx("span",{className:"text-zinc-600",children:"project"}),c.jsx("span",{className:"font-medium text-zinc-200",children:e})]}),a&&c.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-800 bg-zinc-900/70 px-2 py-0.5 text-[10px] text-zinc-400",children:[c.jsx("span",{className:"text-zinc-600",children:"model"}),c.jsx("span",{className:"font-medium text-zinc-200",children:a})]}),c.jsxs("button",{type:"button",onClick:r,disabled:i,className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] transition disabled:opacity-50 ${o?"border-amber-800/60 bg-amber-950/40 text-amber-300 hover:border-amber-700 hover:text-amber-200":"border-zinc-800 bg-zinc-900/70 text-zinc-400 hover:border-zinc-700 hover:text-zinc-200"}`,title:o?"Aero can invoke write tools (run sweep, dismiss insight, etc). Click to restrict.":"Aero is restricted to read-only tools. Click to allow writes.",children:[c.jsx("span",{className:o?"text-amber-500":"text-zinc-600",children:"scope"}),c.jsx("span",{className:"font-medium",children:o?"all tools":"read-only"})]})]})}function coe({matches:e,selectedIndex:t,onHover:n,onPick:r}){return c.jsxs("div",{className:"absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950/98 shadow-2xl",children:[c.jsx("div",{className:"border-b border-zinc-800/60 px-3 py-1.5 text-[10px] uppercase tracking-wider text-zinc-500",children:"Commands"}),c.jsx("ul",{role:"listbox",className:"max-h-72 overflow-y-auto py-1",children:e.map((i,a)=>{const o=a===t;return c.jsx("li",{children:c.jsxs("button",{type:"button",role:"option","aria-selected":o,onMouseEnter:()=>n(a),onClick:()=>r(i),className:`flex w-full items-center gap-3 px-3 py-1.5 text-left text-xs transition ${o?"bg-zinc-900 text-zinc-100":"text-zinc-300 hover:bg-zinc-900/60"}`,children:[c.jsx("span",{className:"font-mono text-[11px] text-emerald-400",children:i.command}),c.jsx("span",{className:"font-medium",children:i.label}),c.jsx("span",{className:"ml-auto text-[10px] text-zinc-500",children:i.hint})]})},i.command)})}),c.jsxs("div",{className:"border-t border-zinc-800/60 px-3 py-1.5 text-[10px] text-zinc-600",children:[c.jsx("span",{className:"mr-3",children:"↑↓ to select"}),c.jsx("span",{className:"mr-3",children:"Enter to run"}),c.jsx("span",{children:"Tab to autocomplete"})]})]})}function uoe(e){switch(e){case"claude":return"ANTHROPIC_API_KEY";case"openai":return"OPENAI_API_KEY";case"gemini":return"GOOGLE_API_KEY";case"zai":return"ZAI_API_KEY"}}function doe(e,t){const n=e.timestamp??0;return`${e.role}:${n}:${t}`}function foe(e,t,n,r){const i=[];for(let a=0;a<e.length;a++){const o=e[a],u=doe(o,a);if(o.role==="user"){const d=typeof o.content=="string"?o.content:JSON.stringify(o.content);if(d.startsWith("[system]"))continue;i.push(c.jsx(hoe,{text:d,projectName:t,providerOverride:n,scope:r},u));continue}if(o.role==="assistant"){const d=new Map;let f=a+1;for(;f<e.length&&e[f].role==="toolResult";){const y=e[f];d.set(y.toolCallId,y),f++}const p=moe(o,d,o.timestamp??0),m=W4(o);i.push(c.jsxs(b.Fragment,{children:[p.length>0&&c.jsx("div",{className:"mt-3 space-y-1.5",children:p.map(y=>c.jsx(Q4,{trail:y},y.id))}),m.trim()&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),c.jsx(X4,{content:m})]})]},u)),a=f-1;continue}}return i}function hoe({text:e,projectName:t,providerOverride:n,scope:r}){const[i,a]=b.useState(!1),o=b.useMemo(()=>poe(t,e,n,r),[t,e,n,r]);async function u(){try{await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1500)}catch{}}return c.jsxs("div",{className:"group relative mt-3 rounded-md bg-zinc-900/60 px-3 py-2 text-zinc-200",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:"You"}),c.jsx("button",{type:"button",onClick:u,className:"inline-flex items-center gap-1 rounded border border-zinc-800/70 bg-zinc-950/60 px-1.5 py-0.5 text-[10px] text-zinc-400 opacity-0 transition hover:border-zinc-700 hover:text-zinc-100 group-hover:opacity-100 focus:opacity-100","aria-label":"Copy as CLI command",title:o,children:i?c.jsxs(c.Fragment,{children:[c.jsx(eL,{className:"h-2.5 w-2.5 text-emerald-400","aria-hidden":"true"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(NG,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Copy as CLI"]})})]}),c.jsx("div",{className:"whitespace-pre-wrap",children:e})]})}function poe(e,t,n,r){const i=["canonry","agent","ask",uT(e),uT(t)];return n&&i.push("--provider",n),r==="read-only"&&i.push("--scope","read-only"),i.join(" ")}function uT(e){return`'${e.replace(/'/g,"'\\''")}'`}function moe(e,t,n){const r=[];for(const i of e.content){if(i.type!=="toolCall")continue;const a=i,o=t.get(a.id);r.push({id:a.id,name:a.name,args:a.arguments,startedAt:n,endedAt:o?.timestamp,isError:o?.isError,result:o?.content})}return r}function Q4({trail:e}){const[t,n]=b.useState(!1),r=e.endedAt===void 0,i=!r&&e.isError===!0,a=e.endedAt!=null?e.endedAt-e.startedAt:null,o=a==null||a<0?null:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`,u=i?"border-rose-800/50":r?"border-emerald-800/50":"border-zinc-800/70",d=i?"bg-rose-950/20":r?"bg-emerald-950/20":"bg-zinc-900/40";return c.jsxs("div",{className:`rounded-md border ${u} ${d} font-mono`,children:[c.jsxs("button",{type:"button",onClick:()=>n(f=>!f),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left","aria-expanded":t,children:[c.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?c.jsx(iL,{className:"h-3 w-3 animate-spin text-emerald-400","aria-hidden":"true"}):i?c.jsx(wg,{className:"h-3 w-3 text-rose-400","aria-hidden":"true"}):c.jsx(aV,{className:"h-3 w-3 text-zinc-500","aria-hidden":"true"})}),c.jsx("span",{className:"text-[11px] font-semibold text-zinc-100",children:e.name}),c.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-zinc-500",children:[r?c.jsx("span",{className:"text-emerald-400",children:"running…"}):c.jsxs(c.Fragment,{children:[c.jsx("span",{children:i?"failed":"ok"}),o&&c.jsx("span",{children:o})]}),c.jsx(oh,{className:`h-3 w-3 transition-transform ${t?"rotate-90":""}`,"aria-hidden":"true"})]})]}),t&&c.jsxs("div",{className:"border-t border-zinc-800/60 px-2.5 py-2 text-[11px] text-zinc-400",children:[c.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:"Args"}),c.jsx("pre",{className:"mb-2 overflow-x-auto whitespace-pre-wrap break-all text-[10px] text-zinc-300",children:dT(e.args)}),!r&&e.result!==void 0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:i?"Error":"Result"}),c.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-all text-[10px] text-zinc-300",children:dT(e.result)})]})]})]})}function dT(e){try{const t=typeof e=="string"?e:JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}
115
+ `)}}}finally{a?.removeEventListener("abort",y);try{f.releaseLock()}catch{}}}function W4(e){return!e||e.role!=="assistant"?"":e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}const ioe=[{label:"Status",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{label:"Top insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{label:"Last failed run",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{label:"Schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"}],aoe=[{command:"/status",label:"Status",hint:"Latest runs, health, anything unusual",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{command:"/insights",label:"Top insights",hint:"Walk through the most severe active insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{command:"/last-run",label:"Last run",hint:"Summarize the latest sweep",prompt:"Summarize the latest run for this project — provider mix, visibility changes, and anything that moved."},{command:"/last-failed",label:"Last failed run",hint:"Diagnose the most recent failure",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{command:"/run-sweep",label:"Run sweep now",hint:"Trigger a new visibility sweep",prompt:"Run a new answer-visibility sweep for this project now and tell me when it lands."},{command:"/schedule",label:"Schedule",hint:"Review the sweep schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"},{command:"/keywords",label:"Keywords",hint:"List tracked keywords",prompt:"List the tracked keywords for this project and flag any that are obvious duplicates or underperformers."},{command:"/competitors",label:"Competitors",hint:"List tracked competitors",prompt:"List this project's tracked competitors and call out which ones are showing up in answer citations."},{command:"/clear",label:"Clear conversation",hint:"Wipe transcript and start fresh",action:"clear"}],xm=e=>`canonry:aero:provider:${e}`,cT=e=>`canonry:aero:scope:${e}`;function soe({projectName:e}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1),[a,o]=b.useState([]),[u,d]=b.useState(""),[f,p]=b.useState(!1),[m,y]=b.useState([]),[v,w]=b.useState(""),[S,j]=b.useState(null),[N,O]=b.useState(()=>typeof window>"u"?null:window.localStorage.getItem(xm(e))??null),[_,C]=b.useState(()=>typeof window>"u"?"read-only":window.localStorage.getItem(cT(e))==="all"?"all":"read-only"),T=b.useRef(null),E=b.useRef(null),A=b.useRef(null),[P,I]=b.useState(0),q=b.useMemo(()=>{const F=u.trimStart();if(!F.startsWith("/"))return[];if(/\s/.test(F))return[];const D=F.toLowerCase();return aoe.filter(Q=>Q.command.startsWith(D)||Q.label.toLowerCase().includes(D.slice(1)))},[u]);b.useEffect(()=>{I(F=>q.length===0?0:Math.min(F,q.length-1))},[q.length]);const B=rs({queryKey:Ar.agent.providers(e),queryFn:()=>toe(e),enabled:t,staleTime:6e4}),$=b.useMemo(()=>{const F=B.data?.providers??[];if(N){const Q=F.find(se=>se.id===N&&se.configured);if(Q)return Q}const D=B.data?.defaultProvider;return D?F.find(Q=>Q.id===D)??null:null},[N,B.data]);b.useEffect(()=>{if(!B.data||!N)return;B.data.providers.find(D=>D.id===N&&D.configured)||(O(null),window.localStorage.removeItem(xm(e)))},[B.data,N,e]);const V=b.useCallback(F=>{O(F),!(typeof window>"u")&&(F?window.localStorage.setItem(xm(e),F):window.localStorage.removeItem(xm(e)))},[e]),te=b.useCallback(()=>{C(F=>{const D=F==="all"?"read-only":"all";return typeof window<"u"&&window.localStorage.setItem(cT(e),D),D})},[e]);b.useEffect(()=>{if(!t)return;const F=D=>{D.key==="Escape"&&(r?i(!1):n(!1))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[t,r]),b.useEffect(()=>{if(!t)return;let F=!1;j(null);const D=()=>{F||f||lT(e).then(ae=>{F||o(ae.messages)}).catch(ae=>{F||j(ae instanceof Error?ae.message:"Failed to load transcript")})};D();const se=window.setInterval(D,15e3);return()=>{F=!0,window.clearInterval(se)}},[t,e,f]),b.useEffect(()=>()=>{T.current?.abort()},[e]),b.useEffect(()=>{const F=E.current;F&&(F.scrollTop=F.scrollHeight)},[a,v,m]);async function Y(F){const D=F.trim();if(!D||f)return;j(null),d(""),p(!0),w(""),y([]);const Q={role:"user",content:D,timestamp:Date.now()};o(ae=>[...ae,Q]);const se=new AbortController;T.current=se;try{await roe({project:e,prompt:D,provider:N??void 0,scope:_,signal:se.signal,onEvent:H});const ae=await lT(e);o(ae.messages)}catch(ae){ae.name!=="AbortError"&&j(ae instanceof Error?ae.message:"Prompt failed")}finally{p(!1),w(""),T.current=null}}function H(F){switch(F.type){case"message_update":w(W4(F.message));break;case"message_end":F.message.role==="assistant"&&w("");break;case"tool_execution_start":y(D=>[...D,{id:F.toolCallId,name:F.toolName,args:F.args,startedAt:Date.now()}]);break;case"tool_execution_end":y(D=>D.map(Q=>Q.id===F.toolCallId?{...Q,endedAt:Date.now(),isError:F.isError,result:F.result}:Q));break;case"error":j(F.message);break}}async function J(){T.current?.abort();try{await noe(e),o([]),j(null)}catch(F){j(F instanceof Error?F.message:"Reset failed")}}const pe=a.length===0,Se=t&&r?"pointer-events-auto fixed inset-0 z-40 flex items-stretch justify-center bg-zinc-950/70 p-4 sm:p-8 backdrop-blur-sm":"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",R=r?"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-zinc-800/80 bg-zinc-950/95 shadow-2xl":"pointer-events-auto w-full max-w-3xl",U=r?"flex-1 overflow-y-auto px-6 py-5 text-sm text-zinc-200":"max-h-[40vh] min-h-[120px] overflow-y-auto px-4 py-3 text-sm text-zinc-200";return c.jsx("div",{className:Se,onClick:F=>{r&&F.target===F.currentTarget&&i(!1)},children:c.jsx("div",{className:R,children:t?c.jsxs("div",{className:r?"flex h-full flex-col":"flex flex-col overflow-hidden rounded-2xl border border-zinc-800/80 bg-zinc-950/95 shadow-xl backdrop-blur",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-zinc-800/70 px-4 py-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(k2,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-zinc-100",children:"Aero"}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:f?"working…":e})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(ooe,{providers:B.data?.providers??[],active:$,override:N,onPick:V,disabled:f}),c.jsx("button",{type:"button",onClick:J,className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":"Reset conversation",title:"Reset conversation",children:c.jsx(aL,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),c.jsx("button",{type:"button",onClick:()=>i(F=>!F),className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":r?"Collapse":"Expand",title:r?"Collapse":"Expand",children:r?c.jsx(FG,{className:"h-3.5 w-3.5","aria-hidden":"true"}):c.jsx(LG,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),c.jsx("button",{type:"button",onClick:()=>{i(!1),n(!1)},className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":"Close Aero",children:c.jsx(lh,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),c.jsxs("div",{ref:E,className:U,children:[S&&c.jsx("div",{className:"mb-2 rounded-md border border-rose-700/40 bg-rose-950/40 px-3 py-2 text-xs text-rose-200",children:S}),pe&&!f&&c.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[c.jsxs("p",{className:"text-xs text-zinc-500",children:["Ask anything about ",c.jsx("span",{className:"text-zinc-300",children:e}),", or start with:"]}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:ioe.map(F=>c.jsx("button",{type:"button",onClick:()=>Y(F.prompt),className:"rounded-full border border-zinc-800 bg-zinc-900/70 px-3 py-1 text-xs text-zinc-300 transition hover:border-zinc-700 hover:bg-zinc-800/70 hover:text-zinc-100",children:F.label},F.label))})]}),foe(a,e,N,_),m.length>0&&c.jsx("div",{className:"mt-3 space-y-1.5",children:m.map(F=>c.jsx(Q4,{trail:F},F.id))}),f&&v&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),c.jsx(X4,{content:v})]}),f&&!v&&m.every(F=>F.endedAt!==void 0)&&c.jsx(goe,{})]}),c.jsx(loe,{projectName:e,activeProvider:$,scope:_,onToggleScope:te,disabled:f}),c.jsxs("div",{className:"relative",children:[q.length>0&&c.jsx(coe,{matches:q,selectedIndex:P,onHover:I,onPick:F=>{d(""),A.current?.focus(),F.action==="clear"?J():Y(F.prompt)}}),c.jsxs("form",{className:"flex items-end gap-2 border-t border-zinc-800/70 bg-zinc-950/80 px-3 py-2.5",onSubmit:F=>{if(F.preventDefault(),q.length>0){const D=q[P];d(""),D.action==="clear"?J():Y(D.prompt);return}Y(u)},children:[c.jsx("textarea",{ref:A,value:u,onChange:F=>d(F.target.value),onKeyDown:F=>{if(q.length>0){if(F.key==="ArrowDown"){F.preventDefault(),I(D=>(D+1)%q.length);return}if(F.key==="ArrowUp"){F.preventDefault(),I(D=>(D-1+q.length)%q.length);return}if(F.key==="Tab"){F.preventDefault();const D=q[P];d(`${D.command} `);return}if(F.key==="Escape"){F.preventDefault(),d("");return}}if(F.key==="Enter"&&!F.shiftKey)if(F.preventDefault(),q.length>0){const D=q[P];d(""),D.action==="clear"?J():Y(D.prompt)}else Y(u)},placeholder:"Ask Aero, or / for commands…",disabled:f,rows:r?3:1,className:"flex-1 resize-none bg-transparent text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none disabled:opacity-60"}),c.jsx("button",{type:"submit",disabled:f||!u.trim(),className:"inline-flex h-7 w-7 items-center justify-center rounded-md bg-emerald-500 text-zinc-950 transition hover:bg-emerald-400 disabled:opacity-40","aria-label":"Send",children:c.jsx(mG,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})]}):c.jsxs("button",{type:"button",onClick:()=>n(!0),className:"flex w-full items-center justify-between rounded-full border border-zinc-800/80 bg-zinc-950/95 px-4 py-2 text-left text-sm text-zinc-400 shadow-lg backdrop-blur transition hover:border-zinc-700 hover:bg-zinc-900/90 hover:text-zinc-200",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(k2,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),"Ask Aero about ",e,"…"]}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-600",children:"Enter"})]})})})}function ooe({providers:e,active:t,override:n,onPick:r,disabled:i}){const[a,o]=b.useState(!1),u=b.useRef(null);if(b.useEffect(()=>{if(!a)return;const p=y=>{u.current?.contains(y.target)||o(!1)},m=y=>{y.key==="Escape"&&o(!1)};return window.addEventListener("mousedown",p),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",p),window.removeEventListener("keydown",m)}},[a]),e.length===0)return null;const d=t?.label.replace(/\s+\(.+\)$/,"")??"No provider",f=t?.defaultModel;return c.jsxs("div",{ref:u,className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>o(p=>!p),disabled:i,className:"flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-zinc-400 transition hover:bg-zinc-800/60 hover:text-zinc-200 disabled:opacity-50","aria-label":"Switch agent model","aria-haspopup":"listbox","aria-expanded":a,title:t?`${t.label} · ${t.defaultModel}`:"Pick a provider",children:[c.jsx("span",{className:"font-medium text-zinc-200",children:d}),f&&c.jsx("span",{className:"hidden font-mono text-[10px] text-zinc-500 sm:inline",children:f}),c.jsx(vG,{className:"h-3 w-3","aria-hidden":"true"})]}),a&&c.jsxs("div",{role:"listbox",className:"absolute right-0 top-full z-50 mt-1 w-64 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950 shadow-xl",children:[c.jsx("div",{className:"border-b border-zinc-800/60 px-3 py-2 text-[10px] uppercase tracking-wider text-zinc-500",children:"Aero provider"}),c.jsx("ul",{className:"max-h-72 overflow-y-auto py-1",children:e.map(p=>{const m=t?.id===p.id,y=n===p.id;return c.jsx("li",{children:c.jsxs("button",{type:"button",role:"option","aria-selected":m,disabled:!p.configured,onClick:()=>{p.configured&&(r(y?null:p.id),o(!1))},className:"flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition enabled:hover:bg-zinc-900 disabled:cursor-not-allowed disabled:opacity-50",children:[c.jsx("span",{className:"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:m?c.jsx(eL,{className:"h-3 w-3 text-emerald-400","aria-hidden":"true"}):null}),c.jsxs("span",{className:"flex-1",children:[c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"font-medium text-zinc-100",children:p.label}),y&&c.jsx("span",{className:"rounded-full border border-emerald-800/60 bg-emerald-950/60 px-1.5 text-[9px] uppercase tracking-wider text-emerald-300",children:"Pinned"}),!p.configured&&c.jsx("span",{className:"rounded-full border border-zinc-800 px-1.5 text-[9px] uppercase tracking-wider text-zinc-500",children:"Key missing"})]}),c.jsx("span",{className:"mt-0.5 block font-mono text-[10px] text-zinc-500",children:p.defaultModel}),p.keySource==="env"&&c.jsx("span",{className:"mt-0.5 block text-[10px] text-zinc-600",children:"via env var"}),!p.configured&&c.jsxs("span",{className:"mt-0.5 block text-[10px] text-zinc-600",children:["Add key in config.yaml or export"," ",c.jsx("code",{className:"font-mono text-zinc-400",children:uoe(p.id)})]})]})]})},p.id)})}),n&&c.jsx("button",{type:"button",onClick:()=>{r(null),o(!1)},className:"w-full border-t border-zinc-800/60 px-3 py-2 text-left text-[11px] text-zinc-400 transition hover:bg-zinc-900 hover:text-zinc-100",children:"Reset to auto-detected default"})]})]})}function loe({projectName:e,activeProvider:t,scope:n,onToggleScope:r,disabled:i}){const a=t?.label.replace(/\s+\(.+\)$/,"")??null,o=n==="all";return c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-zinc-800/70 bg-zinc-950/80 px-3 pt-2",children:[c.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-800 bg-zinc-900/70 px-2 py-0.5 text-[10px] text-zinc-400",children:[c.jsx("span",{className:"text-zinc-600",children:"project"}),c.jsx("span",{className:"font-medium text-zinc-200",children:e})]}),a&&c.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-800 bg-zinc-900/70 px-2 py-0.5 text-[10px] text-zinc-400",children:[c.jsx("span",{className:"text-zinc-600",children:"model"}),c.jsx("span",{className:"font-medium text-zinc-200",children:a})]}),c.jsxs("button",{type:"button",onClick:r,disabled:i,className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] transition disabled:opacity-50 ${o?"border-amber-800/60 bg-amber-950/40 text-amber-300 hover:border-amber-700 hover:text-amber-200":"border-zinc-800 bg-zinc-900/70 text-zinc-400 hover:border-zinc-700 hover:text-zinc-200"}`,title:o?"Aero can invoke write tools (run sweep, dismiss insight, etc). Click to restrict.":"Aero is restricted to read-only tools. Click to allow writes.",children:[c.jsx("span",{className:o?"text-amber-500":"text-zinc-600",children:"scope"}),c.jsx("span",{className:"font-medium",children:o?"all tools":"read-only"})]})]})}function coe({matches:e,selectedIndex:t,onHover:n,onPick:r}){return c.jsxs("div",{className:"absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950/98 shadow-2xl",children:[c.jsx("div",{className:"border-b border-zinc-800/60 px-3 py-1.5 text-[10px] uppercase tracking-wider text-zinc-500",children:"Commands"}),c.jsx("ul",{role:"listbox",className:"max-h-72 overflow-y-auto py-1",children:e.map((i,a)=>{const o=a===t;return c.jsx("li",{children:c.jsxs("button",{type:"button",role:"option","aria-selected":o,onMouseEnter:()=>n(a),onClick:()=>r(i),className:`flex w-full items-center gap-3 px-3 py-1.5 text-left text-xs transition ${o?"bg-zinc-900 text-zinc-100":"text-zinc-300 hover:bg-zinc-900/60"}`,children:[c.jsx("span",{className:"font-mono text-[11px] text-emerald-400",children:i.command}),c.jsx("span",{className:"font-medium",children:i.label}),c.jsx("span",{className:"ml-auto text-[10px] text-zinc-500",children:i.hint})]})},i.command)})}),c.jsxs("div",{className:"border-t border-zinc-800/60 px-3 py-1.5 text-[10px] text-zinc-600",children:[c.jsx("span",{className:"mr-3",children:"↑↓ to select"}),c.jsx("span",{className:"mr-3",children:"Enter to run"}),c.jsx("span",{children:"Tab to autocomplete"})]})]})}function uoe(e){switch(e){case"claude":return"ANTHROPIC_API_KEY";case"openai":return"OPENAI_API_KEY";case"gemini":return"GOOGLE_API_KEY";case"zai":return"ZAI_API_KEY"}}function doe(e,t){const n=e.timestamp??0;return`${e.role}:${n}:${t}`}function foe(e,t,n,r){const i=[];for(let a=0;a<e.length;a++){const o=e[a],u=doe(o,a);if(o.role==="user"){const d=typeof o.content=="string"?o.content:JSON.stringify(o.content);if(d.startsWith("[system]"))continue;i.push(c.jsx(hoe,{text:d,projectName:t,providerOverride:n,scope:r},u));continue}if(o.role==="assistant"){const d=new Map;let f=a+1;for(;f<e.length&&e[f].role==="toolResult";){const y=e[f];d.set(y.toolCallId,y),f++}const p=moe(o,d,o.timestamp??0),m=W4(o);i.push(c.jsxs(b.Fragment,{children:[p.length>0&&c.jsx("div",{className:"mt-3 space-y-1.5",children:p.map(y=>c.jsx(Q4,{trail:y},y.id))}),m.trim()&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),c.jsx(X4,{content:m})]})]},u)),a=f-1;continue}}return i}function hoe({text:e,projectName:t,providerOverride:n,scope:r}){const[i,a]=b.useState(!1),o=b.useMemo(()=>poe(t,e,n,r),[t,e,n,r]);async function u(){try{await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1500)}catch{}}return c.jsxs("div",{className:"group relative mt-3 rounded-md bg-zinc-900/60 px-3 py-2 text-zinc-200",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:"You"}),c.jsx("button",{type:"button",onClick:u,className:"inline-flex items-center gap-1 rounded border border-zinc-800/70 bg-zinc-950/60 px-1.5 py-0.5 text-[10px] text-zinc-400 opacity-0 transition hover:border-zinc-700 hover:text-zinc-100 group-hover:opacity-100 focus:opacity-100","aria-label":"Copy as CLI command",title:o,children:i?c.jsxs(c.Fragment,{children:[c.jsx(eL,{className:"h-2.5 w-2.5 text-emerald-400","aria-hidden":"true"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(NG,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Copy as CLI"]})})]}),c.jsx("div",{className:"whitespace-pre-wrap",children:e})]})}function poe(e,t,n,r){const i=["canonry","agent","ask",uT(e),uT(t)];return n&&i.push("--provider",n),r==="read-only"&&i.push("--scope","read-only"),i.join(" ")}function uT(e){return`'${e.replace(/'/g,"'\\''")}'`}function moe(e,t,n){const r=[];for(const i of e.content){if(i.type!=="toolCall")continue;const a=i,o=t.get(a.id);r.push({id:a.id,name:a.name,args:a.arguments,startedAt:n,endedAt:o?.timestamp,isError:o?.isError,result:o?.content})}return r}function Q4({trail:e}){const[t,n]=b.useState(!1),r=e.endedAt===void 0,i=!r&&e.isError===!0,a=e.endedAt!=null?e.endedAt-e.startedAt:null,o=a==null||a<0?null:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`,u=i?"border-rose-800/50":r?"border-emerald-800/50":"border-zinc-800/70",d=i?"bg-rose-950/20":r?"bg-emerald-950/20":"bg-zinc-900/40";return c.jsxs("div",{className:`rounded-md border ${u} ${d} font-mono`,children:[c.jsxs("button",{type:"button",onClick:()=>n(f=>!f),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left","aria-expanded":t,children:[c.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?c.jsx(iL,{className:"h-3 w-3 animate-spin text-emerald-400","aria-hidden":"true"}):i?c.jsx(wg,{className:"h-3 w-3 text-rose-400","aria-hidden":"true"}):c.jsx(aV,{className:"h-3 w-3 text-zinc-500","aria-hidden":"true"})}),c.jsx("span",{className:"text-[11px] font-semibold text-zinc-100",children:e.name}),c.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-zinc-500",children:[r?c.jsx("span",{className:"text-emerald-400",children:"running…"}):c.jsxs(c.Fragment,{children:[c.jsx("span",{children:i?"failed":"ok"}),o&&c.jsx("span",{children:o})]}),c.jsx(oh,{className:`h-3 w-3 transition-transform ${t?"rotate-90":""}`,"aria-hidden":"true"})]})]}),t&&c.jsxs("div",{className:"border-t border-zinc-800/60 px-2.5 py-2 text-[11px] text-zinc-400",children:[c.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:"Args"}),c.jsx("pre",{className:"mb-2 overflow-x-auto whitespace-pre-wrap break-all text-[10px] text-zinc-300",children:dT(e.args)}),!r&&e.result!==void 0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:i?"Error":"Result"}),c.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-all text-[10px] text-zinc-300",children:dT(e.result)})]})]})]})}function dT(e){try{const t=typeof e=="string"?e:JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}
116
116
  … (${t.length-2e3} more chars)`:t}catch{return String(e)}}function X4({content:e}){return c.jsx("div",{className:"aero-markdown text-zinc-100",children:c.jsx(Yse,{components:{h1:t=>c.jsx("h1",{...t,className:"mt-3 mb-2 text-base font-semibold text-zinc-50"}),h2:t=>c.jsx("h2",{...t,className:"mt-3 mb-2 text-sm font-semibold text-zinc-50"}),h3:t=>c.jsx("h3",{...t,className:"mt-3 mb-1.5 text-sm font-semibold text-zinc-100"}),h4:t=>c.jsx("h4",{...t,className:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-zinc-300"}),p:t=>c.jsx("p",{...t,className:"mb-2 leading-relaxed"}),ul:t=>c.jsx("ul",{...t,className:"mb-2 ml-4 list-disc space-y-1"}),ol:t=>c.jsx("ol",{...t,className:"mb-2 ml-4 list-decimal space-y-1"}),li:t=>c.jsx("li",{...t,className:"marker:text-zinc-600"}),strong:t=>c.jsx("strong",{...t,className:"font-semibold text-zinc-50"}),em:t=>c.jsx("em",{...t,className:"text-zinc-200"}),code:({children:t,...n})=>c.jsx("code",{...n,className:"rounded bg-zinc-800/70 px-1 py-0.5 font-mono text-[12px] text-emerald-200",children:t}),pre:t=>c.jsx("pre",{...t,className:"mb-2 overflow-x-auto rounded-md border border-zinc-800 bg-zinc-900/70 p-3 font-mono text-xs text-zinc-200"}),a:t=>c.jsx("a",{...t,className:"text-emerald-400 underline decoration-emerald-700 hover:decoration-emerald-400",target:"_blank",rel:"noopener noreferrer"}),table:t=>c.jsx("div",{className:"mb-2 overflow-x-auto",children:c.jsx("table",{...t,className:"w-full border-collapse text-xs"})}),thead:t=>c.jsx("thead",{...t,className:"border-b border-zinc-800"}),th:t=>c.jsx("th",{...t,className:"px-2 py-1 text-left font-semibold text-zinc-300"}),tr:t=>c.jsx("tr",{...t,className:"border-b border-zinc-900"}),td:t=>c.jsx("td",{...t,className:"px-2 py-1 text-zinc-200"}),blockquote:t=>c.jsx("blockquote",{...t,className:"mb-2 border-l-2 border-zinc-700 pl-3 italic text-zinc-400"}),hr:()=>c.jsx("hr",{className:"my-3 border-zinc-800"})},children:e})})}function goe(){return c.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),c.jsxs("div",{className:"flex items-center gap-1","aria-label":"Aero is thinking",children:[c.jsx("span",{className:"aero-dot h-1.5 w-1.5 rounded-full bg-emerald-400/80"}),c.jsx("span",{className:"aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-emerald-400/60"}),c.jsx("span",{className:"aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-emerald-400/40"})]})]})}function yoe(){const e=$I(),t=/^\/projects\/([^/]+)/.exec(e.pathname),n=t?decodeURIComponent(t[1]):null,r=rs({queryKey:Ar.projects.all,queryFn:Gj,enabled:n!==null,staleTime:6e4});if(!n)return null;const i=r.data??[],a=i.find(o=>o.id===n)??i.find(o=>o.name===n);return a?c.jsx(soe,{projectName:a.name},a.name):null}const fT=[{label:"Architecture",href:"https://github.com/AINYC/canonry/blob/main/docs/architecture.md"},{label:"Testing Guide",href:"https://github.com/AINYC/canonry/blob/main/docs/testing.md"}],hT=e=>({label:e,state:"checking",detail:"Checking service health"}),voe={apiStatus:hT("API"),workerStatus:hT("Worker")};function boe(e){switch(e){case Kt["answer-visibility"]:return"Visibility sweep";case Kt["gsc-sync"]:return"GSC sync";case Kt["inspect-sitemap"]:return"Sitemap inspection";case Kt["ga-sync"]:return"GA sync";case Kt["bing-inspect"]:return"Bing URL inspection";case Kt["bing-inspect-sitemap"]:return"Bing sitemap inspection";case Kt["site-audit"]:return"Site audit";case Kt["backlink-extract"]:return"Backlink extract"}}function xoe(e){return e==="completed"?"positive":e==="partial"?"caution":"negative"}function woe(e){const t=boe(e.kind);return e.status==="completed"?`${t} completed`:e.status==="partial"?`${t} completed with partial results`:e.status==="cancelled"?`${t} cancelled`:`${t} failed`}function Soe(e,t){return e.error?`${t}: ${sk(e.error)}`:e.location?`${t} · ${e.location}`:t}function joe(e,t,n){if(t)return t;const r=n.find(i=>i.id===e);return r?.displayName||r?.name||e}function koe(e,t){return[e.completed>0?`${e.completed} completed`:null,e.partial>0?`${e.partial} partial`:null,e.failed>0?`${e.failed} failed`:null,e.cancelled>0?`${e.cancelled} cancelled`:null,t>0?`${t} skipped at queue time`:null].filter(Boolean).join(", ")}function Noe(e){return e.failed>0||e.cancelled>0?"negative":e.partial>0?"caution":"positive"}function Coe(){const e=b.useSyncExternalStore(nJ,zl,zl),t=Object.keys(e.runs).length>0||Object.keys(e.batches).length>0,n=rs({queryKey:Ar.runs.all,queryFn:UI,enabled:t}),r=rs({queryKey:Ar.projects.all,queryFn:Gj,enabled:t}),i=b.useRef({}),a=b.useCallback(()=>{n.refetch()},[n.refetch]);return b.useEffect(()=>{t&&a()},[t,a]),b.useEffect(()=>{if(!t||typeof window>"u")return;const o=()=>{document.visibilityState==="visible"&&a()};return window.addEventListener("focus",a),document.addEventListener("visibilitychange",o),()=>{window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",o)}},[t,a]),b.useEffect(()=>{const o=n.data??[],u=r.data??[],d=Object.fromEntries(o.map(p=>[p.id,p])),f=Object.fromEntries(o.map(p=>[p.id,p.status]));for(const p of Object.values(e.runs)){const m=d[p.runId];if(!m||!ck(m.status)||(i.current[m.id]??p.lastAnnouncedStatus)===m.status)continue;if(p.sourceAction==="run-all"){Q2(m.id);continue}const v=joe(m.projectId,p.projectLabel,u);ht({title:woe(m),detail:Soe(m,v),tone:xoe(m.status),dedupeKey:`run:${m.id}`,dedupeMode:"replace",cta:{label:"View run",intent:"open-run-drawer",runId:m.id}}),Q2(m.id)}for(const p of Object.values(e.batches)){const m=aJ(p.runIds,d);m.finished&&(ht({title:"Run-all batch finished",detail:koe(m,p.skippedCount),tone:Noe(m),dedupeKey:`batch:${p.batchId}`,dedupeMode:"replace",cta:{label:"View runs",intent:"go-to-runs"}}),iJ(p.batchId))}i.current=f},[r.data,n.data,e]),null}function _oe(){const e=ch(),{dashboard:t,isLoading:n,refetch:r}=Zl(),o=ev(!e,e?.health).data??e?.health??voe,u=$I(),{runId:d,evidenceId:f,closeDrawer:p}=Mu(),[m,y]=b.useState(!1),v=Ene(d),w=v.data??null,S=v.isLoading;b.useEffect(()=>{w&&w.status!=="running"&&w.status!=="queued"&&r()},[w?.status,r]),b.useEffect(()=>{y(!1)},[u.pathname]),b.useEffect(()=>{if(typeof window>"u"||!d&&!f)return;const C=T=>{T.key==="Escape"&&p()};return window.addEventListener("keydown",C),()=>{window.removeEventListener("keydown",C)}},[d,f,p]);const j=t??e?.dashboard??null,N=d&&j?Jte(j,d):void 0,O=f&&j?ene(j,f):void 0,_=(()=>{const C=u.pathname;if(C==="/")return"Portfolio";if(C==="/projects")return"Projects";if(C==="/runs")return"Runs";if(C==="/settings")return"Settings";if(C==="/setup")return"Setup";if(C==="/backlinks")return"Backlinks";if(C.startsWith("/projects/")){const E=C.split("/").filter(Boolean)[1];if(E&&j){const A=j.projects.find(P=>P.project.id===E);if(A)return A.project.name}return"Project"}return"Not found"})();return c.jsxs("div",{className:"app-shell",children:[c.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),c.jsxs("aside",{className:"sidebar","aria-label":"Primary navigation",children:[c.jsx("div",{className:"sidebar-brand",children:c.jsx(oz,{})}),c.jsxs("nav",{className:"sidebar-nav",children:[c.jsxs(qt,{to:"/",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(RG,{className:"sidebar-icon"}),c.jsx("span",{children:"Overview"})]}),c.jsxs(qt,{to:"/projects",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[c.jsx(TG,{className:"sidebar-icon"}),c.jsx("span",{children:"Projects"})]}),c.jsxs(qt,{to:"/runs",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(xg,{className:"sidebar-icon"}),c.jsx("span",{children:"Runs"})]}),c.jsxs(qt,{to:"/backlinks",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(rL,{className:"sidebar-icon"}),c.jsx("span",{children:"Backlinks"})]}),c.jsxs(qt,{to:"/settings",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(WG,{className:"sidebar-icon"}),c.jsx("span",{children:"Settings"})]}),n?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"sidebar-section-title",children:"Projects"}),[1,2,3].map(C=>c.jsxs("div",{className:"sidebar-skeleton-item",children:[c.jsx("span",{className:"skeleton-circle size-2"}),c.jsx("span",{className:"skeleton-text flex-1",style:{width:`${50+C*15}%`}})]},C))]}):j&&j.projects.length>0?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"sidebar-section-title",children:"Projects"}),j.projects.map(C=>{const T=C.visibilitySummary.tone;return c.jsxs(qt,{to:"/projects/$projectId",params:{projectId:C.project.id},className:"sidebar-project",activeProps:{className:"sidebar-project sidebar-project-active"},children:[c.jsx("span",{className:`sidebar-dot sidebar-dot-${T}`}),c.jsx("span",{children:C.project.name})]},C.project.id)})]}):n?null:c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"sidebar-section-title",children:"Resources"}),c.jsxs(qt,{to:"/setup",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(VG,{className:"sidebar-icon"}),c.jsx("span",{children:"Setup"})]})]})]}),c.jsx("div",{className:"sidebar-footer",children:fT.map(C=>c.jsx("a",{className:"sidebar-footer-link",href:C.href,target:"_blank",rel:"noopener noreferrer",children:C.label},C.href))})]}),c.jsxs("div",{className:"main-area",children:[c.jsxs("header",{className:"topbar",children:[c.jsxs("div",{className:"topbar-left",children:[c.jsx("div",{className:"topbar-brand-mobile",children:c.jsx(oz,{compact:!0})}),c.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[c.jsx(qt,{to:"/",children:"Home"}),c.jsx(oh,{className:"breadcrumb-sep size-3"}),c.jsx("span",{className:"breadcrumb-current",children:_})]})]}),c.jsxs("div",{className:"topbar-actions",children:[c.jsxs("div",{className:"health-pill-row",children:[c.jsxs("span",{className:`health-pill health-pill-${o.apiStatus.state}`,title:vo(o.apiStatus),children:["API ",o.apiStatus.state==="ok"?"ok":o.apiStatus.state]}),c.jsxs("span",{className:`health-pill health-pill-${o.workerStatus.state}`,title:vo(o.workerStatus),children:["Worker ",o.workerStatus.state==="ok"?"ok":o.workerStatus.state]})]}),c.jsxs(be,{className:"nav-toggle",variant:"secondary",size:"icon",type:"button","aria-expanded":m,"aria-controls":"mobile-nav",onClick:()=>y(C=>!C),children:[c.jsx(BG,{className:"size-4"}),c.jsx("span",{className:"sr-only",children:"Open navigation"})]})]})]}),c.jsxs("div",{id:"mobile-nav",className:`mobile-nav ${m?"mobile-nav-open":""}`,children:[c.jsxs(be,{className:"mobile-nav-close",variant:"ghost",size:"icon",type:"button",onClick:()=>y(!1),children:[c.jsx(lh,{className:"size-5"}),c.jsx("span",{className:"sr-only",children:"Close navigation"})]}),c.jsx(qt,{to:"/",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Overview"}),c.jsx(qt,{to:"/projects",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Projects"}),c.jsx(qt,{to:"/runs",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Runs"}),c.jsx(qt,{to:"/settings",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Settings"}),j&&j.projects.length>0?c.jsxs("div",{className:"mobile-nav-section",children:[c.jsx("p",{className:"mobile-nav-section-title",children:"Projects"}),j.projects.map(C=>c.jsx(qt,{to:"/projects/$projectId",params:{projectId:C.project.id},className:"mobile-nav-link",children:C.project.name},C.project.id))]}):null]}),c.jsx("main",{id:"content",className:"page-shell",children:n&&!e?c.jsxs("div",{className:"page-skeleton",children:[c.jsxs("div",{className:"page-skeleton-header",children:[c.jsx("div",{className:"skeleton-text h-6 w-40"}),c.jsx("div",{className:"skeleton-text-sm w-72"})]}),c.jsx("div",{className:"page-skeleton-grid",children:[1,2,3].map(C=>c.jsxs("div",{className:"page-skeleton-card",children:[c.jsx("div",{className:"skeleton-text w-24"}),c.jsx("div",{className:"skeleton-text w-full"}),c.jsx("div",{className:"skeleton-text-sm w-3/4"})]},C))}),c.jsx("div",{className:"page-skeleton-grid",style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map(C=>c.jsxs("div",{className:"page-skeleton-card",children:[c.jsx("div",{className:"skeleton-text w-20"}),c.jsx("div",{className:"space-y-2",children:[1,2,3].map(T=>c.jsx("div",{className:"skeleton-text-sm w-full"},T))})]},C))})]}):c.jsx(Kj,{})}),c.jsxs("footer",{className:"footer",children:[c.jsxs("a",{href:"https://github.com/AINYC/canonry",target:"_blank",rel:"noopener noreferrer",className:"footer-brand",children:[c.jsx(EG,{className:"size-3.5"}),c.jsx("span",{children:"Canonry"})]}),c.jsx("div",{className:"footer-links",children:fT.map(C=>c.jsx("a",{href:C.href,target:"_blank",rel:"noopener noreferrer",children:C.label},C.href))})]})]}),N?c.jsxs(Hte,{open:N!==void 0,title:N.summary,subtitle:`${N.projectName} · ${N.kindLabel}`,onClose:p,children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1 text-sm",children:[c.jsx(Yy,{status:N.status}),c.jsx("span",{className:"text-zinc-400",children:N.startedAt}),c.jsx("span",{className:"text-zinc-500",children:N.duration}),c.jsx("span",{className:"text-zinc-600",children:N.triggerLabel})]}),N.status==="failed"&&N.statusDetail&&c.jsx("p",{className:"text-sm text-rose-300/80 mt-2",children:N.statusDetail}),c.jsxs("div",{className:"mt-4",children:[c.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-2",children:"Activity Log"}),S?c.jsx("p",{className:"text-sm text-zinc-500",children:"Loading run details..."}):w&&w.snapshots.length>0?c.jsxs("div",{className:"space-y-2",children:[w.snapshots.map(C=>c.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 p-3",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[c.jsx("p",{className:"text-sm font-medium text-zinc-200 truncate",children:C.keyword??"Unknown key phrase"}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(Df,{provider:C.provider}),c.jsx(j5,{variant:C.citationState==="cited"?"success":"neutral",children:C.citationState})]})]}),C.model&&c.jsx("p",{className:"text-[11px] text-zinc-500 font-mono",children:C.model}),C.citedDomains.length>0&&c.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[c.jsx("span",{className:"text-zinc-400",children:"Sources:"})," ",C.citedDomains.join(", ")]}),C.competitorOverlap.length>0&&c.jsxs("p",{className:"text-xs text-rose-400/80 mt-0.5",children:["Competitor cited: ",C.competitorOverlap.join(", ")]}),C.groundingSources&&C.groundingSources.length>0&&c.jsxs("details",{className:"mt-2",children:[c.jsxs("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:[C.groundingSources.length," grounding source",C.groundingSources.length!==1?"s":""]}),c.jsx("ul",{className:"mt-1 space-y-0.5",children:C.groundingSources.map((T,E)=>c.jsx("li",{className:"text-xs text-zinc-500 truncate",children:c.jsx("a",{href:T.uri,target:"_blank",rel:"noopener noreferrer",className:"hover:text-zinc-300",children:T.title||T.uri})},E))})]}),C.answerText&&c.jsxs("details",{className:"mt-1",children:[c.jsx("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:"Answer preview"}),c.jsx("p",{className:"mt-1 text-xs text-zinc-400 leading-relaxed whitespace-pre-wrap",children:C.answerText})]})]},C.id)),w.status==="running"&&c.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[c.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Querying remaining key phrases..."]})]}):w&&w.status==="running"?c.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[c.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Waiting for first key phrase result..."]}):w&&w.status==="queued"?c.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[c.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-zinc-500 animate-pulse"}),"Run queued, waiting for execution slot..."]}):w&&w.error?c.jsxs("div",{className:"rounded-lg border border-rose-800/40 bg-rose-950/20 p-3",children:[c.jsx("p",{className:"text-sm font-medium text-rose-300 mb-2",children:"Run failed"}),c.jsx("pre",{className:"text-xs text-rose-300/80 whitespace-pre-wrap break-words max-h-48 overflow-y-auto font-mono leading-5",children:qX(w.error)})]}):c.jsx("p",{className:"text-sm text-zinc-500",children:"No snapshot data available."})]})]}):null,O?c.jsx(Gte,{evidence:O.evidence,project:O.project,onClose:p}):null,c.jsx(Coe,{}),c.jsx(Pne,{}),c.jsx(yoe,{})]})}class Aoe extends b.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[ErrorBoundary]",t,n.componentStack)}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?c.jsx("div",{className:"page-container",children:c.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-20 text-center",children:[c.jsx("div",{className:"rounded-full bg-rose-950/40 p-3",children:c.jsx(wg,{className:"size-6 text-rose-400"})}),c.jsx("h2",{className:"text-lg font-semibold text-zinc-100",children:"Something went wrong"}),c.jsx("p",{className:"text-sm text-zinc-400 max-w-md",children:this.state.error.message||"An unexpected error occurred while rendering this page."}),c.jsxs("div",{className:"flex gap-3 mt-2",children:[c.jsxs(be,{variant:"secondary",size:"sm",onClick:this.handleReset,children:[c.jsx(aL,{className:"size-3.5 mr-1.5"}),"Try again"]}),c.jsx(be,{variant:"secondary",size:"sm",onClick:()=>{const t=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??"";window.location.href=t||"/"},children:"Go home"})]})]})}):this.props.children}}const Be=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:zi("rounded-xl border border-zinc-800 bg-zinc-950/75 shadow-[0_0_0_1px_rgba(255,255,255,0.01)] backdrop-blur",e),...t}));Be.displayName="Card";const w1=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:zi("flex flex-col gap-1.5 p-5",e),...t}));w1.displayName="CardHeader";const S1=b.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:zi("font-medium tracking-tight text-zinc-50",e),...t}));S1.displayName="CardTitle";const j1=b.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:zi("text-sm text-zinc-500",e),...t}));j1.displayName="CardDescription";const eg=b.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:zi("p-5 pt-0",e),...t}));eg.displayName="CardContent";function Ooe({points:e,tone:t}){const n=b.useId();if(e.length===0)return null;const r=42,i=132,a=5,o=Math.min(...e),d=Math.max(...e)-o||1,f=i-a*2,p=r-a*2,m=e.map((y,v)=>{const w=a+v/Math.max(e.length-1,1)*f,S=a+(1-(y-o)/d)*p;return`${w},${S}`}).join(" ");return c.jsxs("svg",{className:`sparkline sparkline-${t}`,viewBox:`0 0 ${i} ${r}`,"aria-hidden":"true",children:[c.jsx("defs",{children:c.jsx("clipPath",{id:n,children:c.jsx("rect",{x:a,y:a,width:f,height:p,rx:"8"})})}),c.jsx("line",{className:"sparkline-guide",x1:a,x2:i-a,y1:r-a,y2:r-a}),c.jsx("polyline",{clipPath:`url(#${n})`,points:m,vectorEffect:"non-scaling-stroke"})]})}function Eoe({project:e}){return c.jsxs(qt,{to:"/projects/$projectId",params:{projectId:e.project.id},className:"project-row cursor-pointer",children:[c.jsxs("div",{className:"project-row-primary",children:[c.jsxs("div",{children:[c.jsx("p",{className:"project-name",children:e.project.name}),c.jsx("p",{className:"project-domain",children:e.project.canonicalDomain})]}),c.jsx("p",{className:"project-insight",children:e.insight})]}),c.jsx("div",{className:"project-row-stat",children:c.jsxs("div",{className:"metric-inline-block",children:[c.jsx("p",{className:"metric-inline-label",children:"Answer Visibility"}),c.jsx("p",{className:`metric-inline-value ${e.visibilityTone==="caution"?"text-amber-400":""}`,children:e.visibilityScore}),c.jsx("p",{className:"metric-inline-delta",children:e.visibilityDelta}),e.providerCoverage&&c.jsx("p",{className:"text-[10px] font-medium text-amber-400/80",children:e.providerCoverage})]})}),c.jsx("div",{className:"project-row-stat",children:c.jsxs("div",{className:"metric-inline-block",children:[c.jsx("p",{className:"metric-inline-label",children:"Competitor Pressure"}),c.jsx("p",{className:"metric-inline-value",children:e.competitorPressureLabel}),c.jsxs("p",{className:"metric-inline-delta",children:[e.lastRun.kindLabel," · ",Gy(e.lastRun.status)]})]})}),c.jsx("div",{className:"project-row-chart",children:c.jsx(Ooe,{points:e.trend,tone:n5(e.lastRun.status)})}),c.jsx("span",{className:"project-row-link",children:c.jsx(oh,{className:"h-4 w-4 text-zinc-500"})})]})}function zoe(){const e=ch(),{dashboard:t,isLoading:n}=Zl(),r=t??e?.dashboard;if(!r||n)return c.jsxs("div",{className:"page-skeleton",children:[c.jsxs("div",{className:"page-skeleton-header",children:[c.jsx("div",{className:"skeleton-text h-6 w-32"}),c.jsx("div",{className:"skeleton-text-sm w-64"})]}),c.jsx("div",{className:"space-y-3",children:[1,2,3].map(p=>c.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-4 flex items-center gap-4",children:[c.jsxs("div",{className:"flex-1 space-y-2",children:[c.jsx("div",{className:"skeleton-text w-36"}),c.jsx("div",{className:"skeleton-text-sm w-48"})]}),c.jsx("div",{className:"skeleton-text w-16"}),c.jsx("div",{className:"skeleton-text w-16"}),c.jsx("div",{className:"skeleton h-8 w-20 rounded"})]},p))})]});const i=r.portfolioOverview,u=ev(!e,e?.health).data??e?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},d=YX(i.systemHealth,u,r.settings),{openRun:f}=Mu();return c.jsxs("div",{className:"page-container",children:[c.jsxs("div",{className:"page-header",children:[c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Portfolio"}),c.jsx("p",{className:"page-subtitle",children:"Visibility and execution state across all projects"})]}),c.jsx("div",{className:"page-header-right",children:c.jsx("p",{className:"text-[11px] text-zinc-600",children:i.lastUpdatedAt})})]}),i.projects.length>0?c.jsx("div",{className:"project-list project-list-scrollable",children:i.projects.map(p=>c.jsx(Eoe,{project:p},p.project.id))}):c.jsxs(Be,{className:"surface-card empty-card",children:[c.jsx("h3",{children:i.emptyState?.title??"No projects yet"}),c.jsx("p",{className:"supporting-copy",children:i.emptyState?.detail}),c.jsx(be,{size:"sm",asChild:!0,children:c.jsx(qt,{to:i.emptyState?.ctaHref==="/setup"||!i.emptyState?.ctaHref?"/setup":"/",children:i.emptyState?.ctaLabel??"Launch setup"})})]}),c.jsxs("div",{className:"overview-secondary-grid",children:[i.attentionItems.length>0&&c.jsxs("section",{className:"overview-secondary-section",children:[c.jsx("div",{className:"section-head section-head-inline",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Needs attention"}),c.jsx("h2",{className:"section-title-sm",children:"What changed"})]})}),c.jsx("div",{className:"attention-list attention-list-scrollable",children:i.attentionItems.map(p=>c.jsxs(qt,{to:p.href,className:`attention-item attention-item-${p.tone}`,children:[c.jsxs("div",{children:[c.jsx("p",{className:"attention-title",children:p.title}),c.jsx("p",{className:"attention-detail",children:p.detail})]}),c.jsx("span",{className:"attention-action",children:p.actionLabel})]},p.id))})]}),c.jsxs("section",{className:"overview-secondary-section",children:[c.jsx("div",{className:"section-head section-head-inline",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Recent runs"}),c.jsx("h2",{className:"section-title-sm",children:"Activity"})]})}),c.jsx("div",{className:"compact-stack compact-stack-scrollable",children:i.recentRuns.length>0?i.recentRuns.map(p=>c.jsxs("button",{className:"compact-run",type:"button",onClick:()=>f(p.id),children:[c.jsxs("div",{children:[c.jsx("p",{className:"compact-run-title",children:p.projectName}),c.jsx("p",{className:"compact-run-detail",children:p.summary})]}),c.jsx(Yy,{status:p.status})]},p.id)):c.jsx("p",{className:"supporting-copy",children:"Run history appears here after the first launch."})})]})]}),c.jsxs("section",{className:"page-section",children:[c.jsx("div",{className:"section-head section-head-inline",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"System health"}),c.jsx("h2",{className:"section-title-sm",children:"Infrastructure"})]})}),c.jsx("div",{className:"health-grid",children:d.map(p=>c.jsxs(Be,{className:"surface-card compact-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:p.label}),c.jsx("h3",{children:p.detail})]}),c.jsx(vt,{tone:p.tone,title:p.id==="api"?vo(u.apiStatus):p.id==="worker"?vo(u.workerStatus):void 0,children:p.label})]}),c.jsx("p",{className:"supporting-copy",children:p.meta})]},p.id))})]})]})}const Dk=Symbol.for("yaml.alias"),k1=Symbol.for("yaml.document"),fo=Symbol.for("yaml.map"),J4=Symbol.for("yaml.pair"),ba=Symbol.for("yaml.scalar"),$u=Symbol.for("yaml.seq"),Ci=Symbol.for("yaml.node.type"),Wl=e=>!!e&&typeof e=="object"&&e[Ci]===Dk,av=e=>!!e&&typeof e=="object"&&e[Ci]===k1,fh=e=>!!e&&typeof e=="object"&&e[Ci]===fo,Sn=e=>!!e&&typeof e=="object"&&e[Ci]===J4,Vt=e=>!!e&&typeof e=="object"&&e[Ci]===ba,hh=e=>!!e&&typeof e=="object"&&e[Ci]===$u;function xn(e){if(e&&typeof e=="object")switch(e[Ci]){case fo:case $u:return!0}return!1}function wn(e){if(e&&typeof e=="object")switch(e[Ci]){case Dk:case fo:case ba:case $u:return!0}return!1}const e$=e=>(Vt(e)||xn(e))&&!!e.anchor,al=Symbol("break visit"),Toe=Symbol("skip children"),jf=Symbol("remove node");function Bu(e,t){const n=Poe(t);av(e)?nu(null,e.contents,n,Object.freeze([e]))===jf&&(e.contents=null):nu(null,e,n,Object.freeze([]))}Bu.BREAK=al;Bu.SKIP=Toe;Bu.REMOVE=jf;function nu(e,t,n,r){const i=Roe(e,t,n,r);if(wn(i)||Sn(i))return Doe(e,r,i),nu(e,i,n,r);if(typeof i!="symbol"){if(xn(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){const o=nu(a,t.items[a],n,r);if(typeof o=="number")a=o-1;else{if(o===al)return al;o===jf&&(t.items.splice(a,1),a-=1)}}}else if(Sn(t)){r=Object.freeze(r.concat(t));const a=nu("key",t.key,n,r);if(a===al)return al;a===jf&&(t.key=null);const o=nu("value",t.value,n,r);if(o===al)return al;o===jf&&(t.value=null)}}return i}function Poe(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Roe(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(fh(t))return n.Map?.(e,t,r);if(hh(t))return n.Seq?.(e,t,r);if(Sn(t))return n.Pair?.(e,t,r);if(Vt(t))return n.Scalar?.(e,t,r);if(Wl(t))return n.Alias?.(e,t,r)}function Doe(e,t,n){const r=t[t.length-1];if(xn(r))r.items[e]=n;else if(Sn(r))e==="key"?r.key=n:r.value=n;else if(av(r))r.contents=n;else{const i=Wl(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const Moe={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ioe=e=>e.replace(/[!,[\]{}]/g,t=>Moe[t]);class dr{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},dr.defaultYaml,t),this.tags=Object.assign({},dr.defaultTags,n)}clone(){const t=new dr(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new dr(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:dr.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},dr.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:dr.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},dr.defaultTags),this.atNextDocument=!1);const r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;const[a,o]=r;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[a]=r;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{const o=/^\d+\.\d+$/.test(a);return n(6,`Unsupported YAML version ${a}`,o),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const o=t.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}const[,r,i]=t.match(/^(.*!)([^!]*)$/s);i||n(`The ${t} tag has no suffix`);const a=this.tags[r];if(a)try{return a+decodeURIComponent(i)}catch(o){return n(String(o)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+Ioe(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags);let i;if(t&&r.length>0&&wn(t.contents)){const a={};Bu(t.contents,(o,u)=>{wn(u)&&u.tag&&(a[u.tag]=!0)}),i=Object.keys(a)}else i=[];for(const[a,o]of r)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||i.some(u=>u.startsWith(o)))&&n.push(`%TAG ${a} ${o}`);return n.join(`
117
117
  `)}}dr.defaultYaml={explicit:!1,version:"1.2"};dr.defaultTags={"!!":"tag:yaml.org,2002:"};function t$(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function n$(e){const t=new Set;return Bu(e,{Value(n,r){r.anchor&&t.add(r.anchor)}}),t}function r$(e,t){for(let n=1;;++n){const r=`${e}${n}`;if(!t.has(r))return r}}function Loe(e,t){const n=[],r=new Map;let i=null;return{onAnchor:a=>{n.push(a),i??(i=n$(e));const o=r$(t,i);return i.add(o),o},setAnchors:()=>{for(const a of n){const o=r.get(a);if(typeof o=="object"&&o.anchor&&(Vt(o.node)||xn(o.node)))o.node.anchor=o.anchor;else{const u=new Error("Failed to resolve repeated object (this should not happen)");throw u.source=a,u}}},sourceObjects:r}}function ru(e,t,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let i=0,a=r.length;i<a;++i){const o=r[i],u=ru(e,r,String(i),o);u===void 0?delete r[i]:u!==o&&(r[i]=u)}else if(r instanceof Map)for(const i of Array.from(r.keys())){const a=r.get(i),o=ru(e,r,i,a);o===void 0?r.delete(i):o!==a&&r.set(i,o)}else if(r instanceof Set)for(const i of Array.from(r)){const a=ru(e,r,i,i);a===void 0?r.delete(i):a!==i&&(r.delete(i),r.add(a))}else for(const[i,a]of Object.entries(r)){const o=ru(e,r,i,a);o===void 0?delete r[i]:o!==a&&(r[i]=o)}return e.call(t,n,r)}function ji(e,t,n){if(Array.isArray(e))return e.map((r,i)=>ji(r,String(i),n));if(e&&typeof e.toJSON=="function"){if(!n||!e$(e))return e.toJSON(t,n);const r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=a=>{r.res=a,delete n.onCreate};const i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e=="bigint"&&!n?.keep?Number(e):e}class Mk{constructor(t){Object.defineProperty(this,Ci,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){if(!av(t))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},u=ji(this,"",o);if(typeof i=="function")for(const{count:d,res:f}of o.anchors.values())i(f,d);return typeof a=="function"?ru(a,{"":u},"",u):u}}class Ik extends Mk{constructor(t){super(Dk),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Bu(t,{Node:(a,o)=>{(Wl(o)||e$(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let i;for(const a of r){if(a===this)break;a.anchor===this.source&&(i=a)}return i}toJSON(t,n){if(!n)return{source:this.source};const{anchors:r,doc:i,maxAliasCount:a}=n,o=this.resolve(i,n);if(!o){const d=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(d)}let u=r.get(o);if(u||(ji(o,null,n),u=r.get(o)),u?.res===void 0){const d="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(d)}if(a>=0&&(u.count+=1,u.aliasCount===0&&(u.aliasCount=tg(i,o,r)),u.count*u.aliasCount>a)){const d="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(d)}return u.res}toString(t,n,r){const i=`*${this.source}`;if(t){if(t$(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${i} `}return i}}function tg(e,t,n){if(Wl(t)){const r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(xn(t)){let r=0;for(const i of t.items){const a=tg(e,i,n);a>r&&(r=a)}return r}else if(Sn(t)){const r=tg(e,t.key,n),i=tg(e,t.value,n);return Math.max(r,i)}return 1}const i$=e=>!e||typeof e!="function"&&typeof e!="object";class Qe extends Mk{constructor(t){super(ba),this.value=t}toJSON(t,n){return n?.keep?this.value:ji(this.value,t,n)}toString(){return String(this.value)}}Qe.BLOCK_FOLDED="BLOCK_FOLDED";Qe.BLOCK_LITERAL="BLOCK_LITERAL";Qe.PLAIN="PLAIN";Qe.QUOTE_DOUBLE="QUOTE_DOUBLE";Qe.QUOTE_SINGLE="QUOTE_SINGLE";const $oe="tag:yaml.org,2002:";function Boe(e,t,n){if(t){const r=n.filter(a=>a.tag===t),i=r.find(a=>!a.format)??r[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return n.find(r=>r.identify?.(e)&&!r.format)}function $f(e,t,n){if(av(e)&&(e=e.contents),wn(e))return e;if(Sn(e)){const m=n.schema[fo].createNode?.(n.schema,null,n);return m.items.push(e),m}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:u}=n;let d;if(r&&e&&typeof e=="object"){if(d=u.get(e),d)return d.anchor??(d.anchor=i(e)),new Ik(d.anchor);d={anchor:null,node:null},u.set(e,d)}t?.startsWith("!!")&&(t=$oe+t.slice(2));let f=Boe(e,t,o.tags);if(!f){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){const m=new Qe(e);return d&&(d.node=m),m}f=e instanceof Map?o[fo]:Symbol.iterator in Object(e)?o[$u]:o[fo]}a&&(a(f),delete n.onTagObj);const p=f?.createNode?f.createNode(n.schema,e,n):typeof f?.nodeClass?.from=="function"?f.nodeClass.from(n.schema,e,n):new Qe(e);return t?p.tag=t:f.default||(p.tag=f.tag),d&&(d.node=p),p}function Tg(e,t,n){let r=n;for(let i=t.length-1;i>=0;--i){const a=t[i];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){const o=[];o[a]=r,r=o}else r=new Map([[a,r]])}return $f(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const hf=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class a$ extends Mk{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){const n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(r=>wn(r)||Sn(r)?r.clone(t):r),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(hf(t))this.add(n);else{const[r,...i]=t,a=this.get(r,!0);if(xn(a))a.addIn(i,n);else if(a===void 0&&this.schema)this.set(r,Tg(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(t){const[n,...r]=t;if(r.length===0)return this.delete(n);const i=this.get(n,!0);if(xn(i))return i.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(t,n){const[r,...i]=t,a=this.get(r,!0);return i.length===0?!n&&Vt(a)?a.value:a:xn(a)?a.getIn(i,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!Sn(n))return!1;const r=n.value;return r==null||t&&Vt(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){const[n,...r]=t;if(r.length===0)return this.has(n);const i=this.get(n,!0);return xn(i)?i.hasIn(r):!1}setIn(t,n){const[r,...i]=t;if(i.length===0)this.set(r,n);else{const a=this.get(r,!0);if(xn(a))a.setIn(i,n);else if(a===void 0&&this.schema)this.set(r,Tg(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}}const Uoe=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function es(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const hl=(e,t,n)=>e.endsWith(`
118
118
  `)?es(n,t):n.includes(`
package/assets/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
13
13
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
14
14
  <title>Canonry</title>
15
- <script type="module" crossorigin src="./assets/index-D0BgyJJT.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-B18l8ugs.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="./assets/index-DMx3Oy9W.css">
17
17
  </head>
18
18
  <body>